當前位置: 首頁>>代碼示例>>Python>>正文


Python curses.ungetch方法代碼示例

本文整理匯總了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) 
開發者ID:peterbrittain,項目名稱:asciimatics,代碼行數:15,代碼來源:screen.py

示例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]) 
開發者ID:peterbrittain,項目名稱:asciimatics,代碼行數:43,代碼來源:test_screen.py

示例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 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:16,代碼來源:screen.py

示例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) 
開發者ID:google,項目名稱:ci_edit,代碼行數:14,代碼來源:curses_util.py

示例5: changeToFindPrior

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import ungetch [as 別名]
def changeToFindPrior(self):
        curses.ungetch(self.savedCh)
        self.findAndChangeTo('interactiveFind') 
開發者ID:google,項目名稱:ci_edit,代碼行數:5,代碼來源:controller.py

示例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) 
開發者ID:google,項目名稱:ci_edit,代碼行數:7,代碼來源:controller.py


注:本文中的curses.ungetch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。