199
199
Current position of the user terminal cursor.< br >
200
200
self.< strong > echo</ strong > : bool = True< br >
201
201
Whether or not the user input is shown on the terminal. Don't modify it manually< br >
202
- self.< strong > ctrl_c</ strong > : async function< br >
202
+ self.< strong > ctrl_c</ strong > : ( async) function< br >
203
203
Async callback that is called when Ctrl + C is pressed in the terminal< br >
204
204
self.< strong > keystrokes</ strong > : dict< br >
205
205
Mapping of keystroke handlers.< br >
223
223
stdout : io.TextIOWrapper = sys.stdout< br >
224
224
File-like < a href ="builtins.html#object "> object</ a > handling standard output.</ tt > </ dd > </ dl >
225
225
226
- < dl > < dt > < a name ="AsyncRawInput-add_keystroke "> < strong > add_keystroke</ strong > </ a > (self, keystroke: str, awaitable )</ dt > < dd > < tt > Add a new keystroke to the terminal< br >
226
+ < dl > < dt > < a name ="AsyncRawInput-add_keystroke "> < strong > add_keystroke</ strong > </ a > (self, keystroke: str, asyncfunction )</ dt > < dd > < tt > Add a new keystroke to the terminal< br >
227
227
< br >
228
228
Parameters< br >
229
229
----------< br >
230
230
keystroke : str< br >
231
231
Raw keystroke code. For example, tab keystroke will be: "\t", Ctrl + F will be "\x06"< br >
232
- awaitable : async function< br >
232
+ asyncfunction : async function< br >
233
233
Async callback called without arguments</ tt > </ dd > </ dl >
234
234
235
- < dl > < dt > < a name ="AsyncRawInput-end "> < strong > end</ strong > </ a > (self)</ dt > < dd > < tt > Disables raw mode, restoring the old TTY settings for standard input</ tt > </ dd > </ dl >
235
+ < dl > < dt > < a name ="AsyncRawInput-end "> < strong > end</ strong > </ a > (self)</ dt > < dd > < tt > Disables raw mode, restoring the old TTY settings for standard input< br >
236
+ Unhooks the SIGWINCH signal handler.</ tt > </ dd > </ dl >
236
237
237
- < dl > < dt > < a name ="AsyncRawInput-prepare "> < strong > prepare </ strong > </ a > (self)</ dt > < dd > < tt > Enables raw mode, saving the old TTY settings. Disables blocking mode for standard input </ tt > </ dd > </ dl >
238
+ < dl > < dt > < a name ="AsyncRawInput-get_interrupt_handler "> < strong > get_interrupt_handler </ strong > </ a > (self) -> Callable[[Any], Coroutine[Any, Any, Any]] </ dt > </ dl >
238
239
239
- < dl > < dt > async < a name ="AsyncRawInput-prompt_keystroke "> < strong > prompt_keystroke</ strong > </ a > (self, prompt=': ', echo=True)</ dt > < dd > < tt > Start reading a single character from a terminal. Not handling the keystrokes.< br >
240
+ < dl > < dt > < a name ="AsyncRawInput-get_terminal_size "> < strong > get_terminal_size</ strong > </ a > (self) -> Union[os.terminal_size, Tuple[int, int]]</ dt > </ dl >
241
+
242
+ < dl > < dt > < a name ="AsyncRawInput-move_cursor "> < strong > move_cursor</ strong > </ a > (self, at: int, *, flush=True, redraw=False)</ dt > < dd > < tt > Moves the cursor across the current line.< br >
243
+ Parameter at starts from 1, which means that at=1 is the first character of the terminal line</ tt > </ dd > </ dl >
244
+
245
+ < dl > < dt > < a name ="AsyncRawInput-move_input_cursor "> < strong > move_input_cursor</ strong > </ a > (self, at_char: int)</ dt > < dd > < tt > Sets the cursor's input position at specified character. Scrolls the input horizontally when necessary.</ tt > </ dd > </ dl >
246
+
247
+ < dl > < dt > < a name ="AsyncRawInput-on_terminal_resize "> < strong > on_terminal_resize</ strong > </ a > (self)</ dt > </ dl >
248
+
249
+ < dl > < dt > < a name ="AsyncRawInput-prepare "> < strong > prepare</ strong > </ a > (self)</ dt > < dd > < tt > Enables raw mode, saving the old TTY settings. Disables blocking mode for standard input< br >
250
+ Hooks up the SIGWINCH signal handler, which will redraw the prompt line if any.</ tt > </ dd > </ dl >
251
+
252
+ < dl > < dt > async < a name ="AsyncRawInput-prompt_keystroke "> < strong > prompt_keystroke</ strong > </ a > (self, prompt=': ', echo=True) -> str</ dt > < dd > < tt > Start reading a single character from a terminal. Not handling the keystrokes.< br >
240
253
< br >
241
254
Parameters< br >
242
255
----------< br >
243
256
prompt : str< br >
244
257
The text that is displayed before user input< br >
245
258
echo : bool< br >
246
- Whether or not a user input will be displayed.</ tt > </ dd > </ dl >
247
-
248
- < dl > < dt > async < a name ="AsyncRawInput-prompt_line "> < strong > prompt_line</ strong > </ a > (self, prompt='> ', echo=True, history_disabled=False, prompt_formats={}, input_formats={})</ dt > < dd > < tt > Start reading a single-line user input with prompt from < a href ="#AsyncRawInput "> AsyncRawInput</ a > .stdin. Asynchronous version of input(prompt), handling the keystrokes.< br >
259
+ Whether or not a user input will be displayed.< br >
260
+ < br >
261
+ Returns< br >
262
+ -------< br >
263
+ str< br >
264
+ Resulting pressed keystroke</ tt > </ dd > </ dl >
265
+
266
+ < dl > < dt > async < a name ="AsyncRawInput-prompt_line "> < strong > prompt_line</ strong > </ a > (self, prompt='> ', echo=True, history_disabled=False, prompt_formats={}, input_formats={})</ dt > < dd > < tt > Start reading a single-line user input with prompt from < a href ="#AsyncRawInput "> AsyncRawInput</ a > .stdin.< br >
267
+ Asynchronous version of input(prompt), handling the keystrokes.< br >
268
+ In addition to Python's input(prompt) function, the input is not wrapped< br >
269
+ into the new line when overflowed, instead it hides the leftmost characters,< br >
270
+ as well as handling the controlling terminal's resizing.< br >
249
271
To register a keystroke, use < a href ="#AsyncRawInput "> AsyncRawInput</ a > .< a href ="#AsyncRawInput-add_keystroke "> add_keystroke</ a > (code, asyncfunction)< br >
250
272
< br >
251
273
Parameters< br >
263
285
Dictionary of text formatting settings that are passed into format_term< br >
264
286
self.< strong > input_formats</ strong > = < a href ="#-format_term "> format_term</ a > (**input_formats)</ tt > </ dd > </ dl >
265
287
266
- < dl > < dt > < a name ="AsyncRawInput-redraw_lastinp "> < strong > redraw_lastinp</ strong > </ a > (self, at: int)</ dt > < dd > < tt > Redisplay a user prompt at specified position on current cursor line.</ tt > </ dd > </ dl >
288
+ < dl > < dt > < a name ="AsyncRawInput-redraw_lastinp "> < strong > redraw_lastinp</ strong > </ a > (self, at: int, force_redraw_prompt=False)</ dt > < dd > < tt > Redisplay a user input at specified position on current cursor line.< br >
289
+ If force_redraw_prompt is True, redraws the whole line entirely (including the prompt) regardless of scrolling state</ tt > </ dd > </ dl >
267
290
268
291
< dl > < dt > < a name ="AsyncRawInput-remove_keystroke "> < strong > remove_keystroke</ strong > </ a > (self, keystroke: str)</ dt > < dd > < tt > Remove a keystroke from the terminal< br >
269
292
< br >
270
293
Parameters : str< br >
271
294
Raw keystroke code.</ tt > </ dd > </ dl >
272
295
273
- < dl > < dt > < a name ="AsyncRawInput-set_interrupt_handler "> < strong > set_interrupt_handler</ strong > </ a > (self, awaitable )</ dt > < dd > < tt > Sets the callback for Ctrl + C keystroke< br >
296
+ < dl > < dt > < a name ="AsyncRawInput-set_interrupt_handler "> < strong > set_interrupt_handler</ strong > </ a > (self, callback )</ dt > < dd > < tt > Sets the callback for Ctrl + C keystroke< br >
274
297
< br >
275
298
Parameters< br >
276
299
----------< br >
277
- awaitable : coroutine function< br >
278
- async callback, called without arguments</ tt > </ dd > </ dl >
300
+ callback : coroutine or regular function< br >
301
+ ( async) callback, called without arguments</ tt > </ dd > </ dl >
279
302
280
303
< dl > < dt > < a name ="AsyncRawInput-write "> < strong > write</ strong > </ a > (self, msg: str, **formats)</ dt > < dd > < tt > Write a formatted text to a terminal without CRLF.< br >
281
304
Don't use it when a user input is prompted< br >
416
439
< strong > MutableSequence</ strong > = typing.MutableSequence< br >
417
440
< strong > NOTSET</ strong > = 0< br >
418
441
< strong > Optional</ strong > = typing.Optional< br >
442
+ < strong > SIGWINCH</ strong > = <Signals.SIGWINCH: 28>< br >
419
443
< strong > Sequence</ strong > = typing.Sequence< br >
420
444
< strong > Tuple</ strong > = typing.Tuple< br >
421
445
< strong > Union</ strong > = typing.Union< br >
422
446
< strong > WARNING</ strong > = 30< br >
423
- < strong > __warningregistry__</ strong > = {'version': 0}< br >
424
447
< strong > ansi_escape</ strong > = re.compile('(\\x9B|\\x1B\\[)[0-?]*[ -\\/]*[@-~]')< br >
425
448
< strong > do_backspace</ strong > = '< font color ="#c040c0 "> \x08\x1b</ font > [0K'< br >
426
- < strong > loop</ strong > = <_UnixSelectorEventLoop running=False closed=False debug=False></ td > </ tr > </ table >
449
+ < strong > next_word</ strong > = re.compile('\\w+\\W+(\\w+)')< br >
450
+ < strong > prev_word</ strong > = re.compile('(\\w+) *$')</ td > </ tr > </ table >
427
451
</ body > </ html >
0 commit comments