MCPcopy Index your code
hub / github.com/python/cpython / _insert_printable_char

Method _insert_printable_char

Lib/curses/textpad.py:70–93  ·  view source on GitHub ↗
(self, ch)

Source from the content-addressed store, hash-verified

68 return last
69
70 def _insert_printable_char(self, ch):
71 self._update_max_yx()
72 (y, x) = self.win.getyx()
73 backyx = None
74 while y < self.maxy or x < self.maxx:
75 if self.insert_mode:
76 oldch = self.win.inch()
77 # The try-catch ignores the error we trigger from some curses
78 # versions by trying to write into the lowest-rightmost spot
79 # in the window.
80 try:
81 self.win.addch(ch)
82 except curses.error:
83 pass
84 if not self.insert_mode or not curses.ascii.isprint(oldch):
85 break
86 ch = oldch
87 (y, x) = self.win.getyx()
88 # Remember where to put the cursor back since we are in insert_mode
89 if backyx is None:
90 backyx = y, x
91
92 if backyx is not None:
93 self.win.move(*backyx)
94
95 def do_command(self, ch):
96 "Process a single editing command."

Callers 2

test_issue13051Method · 0.95
do_commandMethod · 0.95

Calls 2

_update_max_yxMethod · 0.95
moveMethod · 0.45

Tested by 1

test_issue13051Method · 0.76