Python curses.flash() Examples

The following are 6 code examples of curses.flash(). 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: terminal.py    From ttrv with MIT License 6 votes vote down vote up
def flash(self):
        """
        Flash the screen to indicate that an action was invalid.
        """
        if self.config['flash']:
            return curses.flash()
        else:
            return None 
Example #2
Source File: terminal.py    From ttrv with MIT License 5 votes vote down vote up
def prompt_y_or_n(self, prompt):
        """
        Wrapper around prompt_input for simple yes/no queries.
        """

        ch = self.prompt_input(prompt, key=True)
        if ch in (ord('Y'), ord('y')):
            return True
        elif ch in (ord('N'), ord('n'), None):
            return False
        else:
            self.flash()
            return False 
Example #3
Source File: terminal.py    From ttrv with MIT License 5 votes vote down vote up
def clear_screen(self):
        """
        In the beginning this always called touchwin(). However, a bug
        was discovered in tmux when TERM was set to `xterm-256color`, where
        only part of the screen got redrawn when scrolling. tmux automatically
        sets TERM to `screen-256color`, but many people choose to override
        this in their tmux.conf or .bashrc file which can cause issues.
        Using clearok() instead seems to fix the problem, with the trade off
        of slightly more expensive screen refreshes.

        Update: It was discovered that using clearok() introduced a
        separate bug for urxvt users in which their screen flashed when
        scrolling. Heuristics were added to make it work with as many
        configurations as possible. It's still not perfect
        (e.g. urxvt + xterm-256color) will screen flash, but it should
        work in all cases if the user sets their TERM correctly.

        Reference:
            https://github.com/tildeclub/ttrv/issues/343
            https://github.com/tildeclub/ttrv/issues/323
        """

        if self._term != 'xterm-256color':
            self.stdscr.touchwin()
        else:
            self.stdscr.clearok(True) 
Example #4
Source File: terminal.py    From rtv with MIT License 5 votes vote down vote up
def flash(self):
        """
        Flash the screen to indicate that an action was invalid.
        """
        if self.config['flash']:
            return curses.flash()
        else:
            return None 
Example #5
Source File: terminal.py    From rtv with MIT License 5 votes vote down vote up
def prompt_y_or_n(self, prompt):
        """
        Wrapper around prompt_input for simple yes/no queries.
        """

        ch = self.prompt_input(prompt, key=True)
        if ch in (ord('Y'), ord('y')):
            return True
        elif ch in (ord('N'), ord('n'), None):
            return False
        else:
            self.flash()
            return False 
Example #6
Source File: terminal.py    From rtv with MIT License 5 votes vote down vote up
def clear_screen(self):
        """
        In the beginning this always called touchwin(). However, a bug
        was discovered in tmux when TERM was set to `xterm-256color`, where
        only part of the screen got redrawn when scrolling. tmux automatically
        sets TERM to `screen-256color`, but many people choose to override
        this in their tmux.conf or .bashrc file which can cause issues.
        Using clearok() instead seems to fix the problem, with the trade off
        of slightly more expensive screen refreshes.

        Update: It was discovered that using clearok() introduced a
        separate bug for urxvt users in which their screen flashed when
        scrolling. Heuristics were added to make it work with as many
        configurations as possible. It's still not perfect
        (e.g. urxvt + xterm-256color) will screen flash, but it should
        work in all cases if the user sets their TERM correctly.

        Reference:
            https://github.com/michael-lazar/rtv/issues/343
            https://github.com/michael-lazar/rtv/issues/323
        """

        if self._term != 'xterm-256color':
            self.stdscr.touchwin()
        else:
            self.stdscr.clearok(True)