Python curses.ungetch() Examples

The following are 7 code examples of curses.ungetch(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module curses , or try the search function .
Example #1
Source File: screen.py    From asciimatics with Apache License 2.0 5 votes vote down vote up
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) 
Example #2
Source File: test_screen.py    From asciimatics with Apache License 2.0 5 votes vote down vote up
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]) 
Example #3
Source File: screen.py    From deepWordBug with Apache License 2.0 5 votes vote down vote up
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 
Example #4
Source File: screen.py    From aws-elastic-beanstalk-cli with Apache License 2.0 5 votes vote down vote up
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 
Example #5
Source File: curses_util.py    From ci_edit with Apache License 2.0 5 votes vote down vote up
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) 
Example #6
Source File: controller.py    From ci_edit with Apache License 2.0 5 votes vote down vote up
def changeToFindPrior(self):
        curses.ungetch(self.savedCh)
        self.findAndChangeTo('interactiveFind') 
Example #7
Source File: controller.py    From ci_edit with Apache License 2.0 5 votes vote down vote up
def saveEventChangeToHostWindow(self, *args):
        curses.ungetch(self.savedCh)
        host = self.getNamedWindow('inputWindow')
        host.bringToFront()
        self.view.changeFocusTo(host)