本文整理汇总了Python中curses.ungetch方法的典型用法代码示例。如果您正苦于以下问题:Python curses.ungetch方法的具体用法?Python curses.ungetch怎么用?Python curses.ungetch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类curses
的用法示例。
在下文中一共展示了curses.ungetch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _catch_interrupt
# 需要导入模块: import curses [as 别名]
# 或者: from curses import ungetch [as 别名]
def _catch_interrupt(signal_no, frame):
"""
SIGINT handler. We ignore the signal and frame info passed in.
"""
# Stop pep-8 shouting at me for unused params I can't control.
del frame
# The OS already caught the ctrl-c, so inject it now for the next
# input.
if signal_no == signal.SIGINT:
curses.ungetch(3)
elif signal_no == signal.SIGTSTP:
curses.ungetch(26)
示例2: _inject_key
# 需要导入模块: import curses [as 别名]
# 或者: from curses import ungetch [as 别名]
def _inject_key(screen, char):
"""
Inject a specified character into the input buffers.
"""
if sys.platform == "win32":
event = win32console.PyINPUT_RECORDType(win32console.KEY_EVENT)
event.RepeatCount = 1
event.ControlKeyState = 0
event.VirtualScanCode = 0
if char >= 0:
event.Char = chr(char)
event.VirtualKeyCode = ord(chr(char).upper())
else:
# Lookup in mapping dicts
reverse = dict((v, k) for k, v in
screen._EXTRA_KEY_MAP.items())
if char in reverse:
event.VirtualKeyCode = reverse[char]
else:
# Fudge key state required for BACK_TAB if needed.
if char == Screen.KEY_BACK_TAB:
char = Screen.KEY_TAB
event.ControlKeyState = win32con.SHIFT_PRESSED
reverse = dict((v, k) for k, v in
screen._KEY_MAP.items())
event.VirtualKeyCode = reverse[char]
event.KeyDown = 1
screen._stdin.WriteConsoleInput([event])
event.KeyDown = 0
screen._stdin.WriteConsoleInput([event])
else:
if char > 0:
# Curses uses a LIFO stack for key injection, so reverse the
# byte string to be injected. Note that this still works for
# ASCII as it is a single char subset of UTF-8.
for c in reversed(bytes(chr(char).encode("utf-8"))):
curses.ungetch(c)
else:
reverse = dict((v, k) for k, v in
screen._KEY_MAP.items())
curses.ungetch(reverse[char])
示例3: _catch_interrupt
# 需要导入模块: import curses [as 别名]
# 或者: from curses import ungetch [as 别名]
def _catch_interrupt(signal_no, frame):
"""
SIGINT handler. We ignore the signal and frame info passed in.
"""
# Stop pep-8 shouting at me for unused params I can't control.
del frame
# The OS already caught the ctrl-c, so inject it now for the next
# input.
if signal_no == signal.SIGINT:
curses.ungetch(3)
elif signal_no == signal.SIGTSTP:
curses.ungetch(26)
return
示例4: hackCursesFixes
# 需要导入模块: import curses [as 别名]
# 或者: from curses import ungetch [as 别名]
def hackCursesFixes():
if sys.platform == u'darwin':
def windowChangedHandler(signum, frame):
curses.ungetch(curses.KEY_RESIZE)
signal.signal(signal.SIGWINCH, windowChangedHandler)
def wakeGetch(signum, frame):
curses.ungetch(0)
signal.signal(signal.SIGUSR1, wakeGetch)
示例5: changeToFindPrior
# 需要导入模块: import curses [as 别名]
# 或者: from curses import ungetch [as 别名]
def changeToFindPrior(self):
curses.ungetch(self.savedCh)
self.findAndChangeTo('interactiveFind')
示例6: saveEventChangeToHostWindow
# 需要导入模块: import curses [as 别名]
# 或者: from curses import ungetch [as 别名]
def saveEventChangeToHostWindow(self, *args):
curses.ungetch(self.savedCh)
host = self.getNamedWindow('inputWindow')
host.bringToFront()
self.view.changeFocusTo(host)