File tree Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -43,16 +43,16 @@ def create_input(
4343 return Vt100Input (stdin )
4444
4545
46- def create_pipe_input () -> Input :
46+ def create_pipe_input (responds_to_cpr : bool = True ) -> Input :
4747 """
4848 Create an input pipe.
4949 This is mostly useful for unit testing.
5050 """
5151 if is_windows ():
5252 from .win32_pipe import Win32PipeInput
5353
54- return Win32PipeInput ()
54+ return Win32PipeInput (responds_to_cpr = responds_to_cpr )
5555 else :
5656 from .posix_pipe import PosixPipeInput
5757
58- return PosixPipeInput ()
58+ return PosixPipeInput (responds_to_cpr = responds_to_cpr )
Original file line number Diff line number Diff line change @@ -23,7 +23,8 @@ class PosixPipeInput(Vt100Input):
2323
2424 _id = 0
2525
26- def __init__ (self , text : str = "" ) -> None :
26+ def __init__ (self , text : str = "" , responds_to_cpr : bool = True ) -> None :
27+ self ._responds_to_cpr = True
2728 self ._r , self ._w = os .pipe ()
2829
2930 class Stdin :
@@ -44,7 +45,7 @@ def fileno(stdin) -> int:
4445
4546 @property
4647 def responds_to_cpr (self ) -> bool :
47- return False
48+ return self . _responds_to_cpr
4849
4950 def send_bytes (self , data : bytes ) -> None :
5051 os .write (self ._w , data )
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ class Win32PipeInput(_Win32InputBase):
2929
3030 _id = 0
3131
32- def __init__ (self ) -> None :
32+ def __init__ (self , responds_to_cpr : bool = True ) -> None :
3333 super ().__init__ ()
3434 # Event (handle) for registering this input in the event loop.
3535 # This event is set when there is data available to read from the pipe.
@@ -39,6 +39,7 @@ def __init__(self) -> None:
3939 self ._event = create_win32_event ()
4040
4141 self ._closed = False
42+ self ._responds_to_cpr = responds_to_cpr
4243
4344 # Parser for incoming keys.
4445 self ._buffer : List [KeyPress ] = [] # Buffer to collect the Key objects.
@@ -105,7 +106,7 @@ def flush_keys(self) -> List[KeyPress]:
105106
106107 @property
107108 def responds_to_cpr (self ) -> bool :
108- return False
109+ return self . _responds_to_cpr
109110
110111 def send_bytes (self , data : bytes ) -> None :
111112 " Send bytes to the input. "
You can’t perform that action at this time.
0 commit comments