MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / do_command

Method do_command

tools/python-3.11.9-amd64/Lib/curses/textpad.py:95–158  ·  view source on GitHub ↗

Process a single editing command.

(self, ch)

Source from the content-addressed store, hash-verified

93 self.win.move(*backyx)
94
95 def do_command(self, ch):
96 "Process a single editing command."
97 self._update_max_yx()
98 (y, x) = self.win.getyx()
99 self.lastcmd = ch
100 if curses.ascii.isprint(ch):
101 if y < self.maxy or x < self.maxx:
102 self._insert_printable_char(ch)
103 elif ch == curses.ascii.SOH: # ^a
104 self.win.move(y, 0)
105 elif ch in (curses.ascii.STX,curses.KEY_LEFT, curses.ascii.BS,curses.KEY_BACKSPACE):
106 if x > 0:
107 self.win.move(y, x-1)
108 elif y == 0:
109 pass
110 elif self.stripspaces:
111 self.win.move(y-1, self._end_of_line(y-1))
112 else:
113 self.win.move(y-1, self.maxx)
114 if ch in (curses.ascii.BS, curses.KEY_BACKSPACE):
115 self.win.delch()
116 elif ch == curses.ascii.EOT: # ^d
117 self.win.delch()
118 elif ch == curses.ascii.ENQ: # ^e
119 if self.stripspaces:
120 self.win.move(y, self._end_of_line(y))
121 else:
122 self.win.move(y, self.maxx)
123 elif ch in (curses.ascii.ACK, curses.KEY_RIGHT): # ^f
124 if x < self.maxx:
125 self.win.move(y, x+1)
126 elif y == self.maxy:
127 pass
128 else:
129 self.win.move(y+1, 0)
130 elif ch == curses.ascii.BEL: # ^g
131 return 0
132 elif ch == curses.ascii.NL: # ^j
133 if self.maxy == 0:
134 return 0
135 elif y < self.maxy:
136 self.win.move(y+1, 0)
137 elif ch == curses.ascii.VT: # ^k
138 if x == 0 and self._end_of_line(y) == 0:
139 self.win.deleteln()
140 else:
141 # first undo the effect of self._end_of_line
142 self.win.move(y, x)
143 self.win.clrtoeol()
144 elif ch == curses.ascii.FF: # ^l
145 self.win.refresh()
146 elif ch in (curses.ascii.SO, curses.KEY_DOWN): # ^n
147 if y < self.maxy:
148 self.win.move(y+1, x)
149 if x > self._end_of_line(y+1):
150 self.win.move(y+1, self._end_of_line(y+1))
151 elif ch == curses.ascii.SI: # ^o
152 self.win.insertln()

Callers 1

editMethod · 0.95

Calls 5

_update_max_yxMethod · 0.95
_end_of_lineMethod · 0.95
moveMethod · 0.45
refreshMethod · 0.45

Tested by

no test coverage detected