Python curses.mousemask() Examples

The following are 19 code examples of curses.mousemask(). 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: termpdf.py    From termpdf.py with MIT License 5 votes vote down vote up
def init_curses(self):
        os.environ.setdefault('ESCDELAY', '25')
        self.stdscr = curses.initscr()
        self.stdscr.clear()
        curses.noecho()
        curses.curs_set(0) 
        curses.mousemask(curses.REPORT_MOUSE_POSITION
            | curses.BUTTON1_PRESSED | curses.BUTTON1_RELEASED
            | curses.BUTTON2_PRESSED | curses.BUTTON2_RELEASED
            | curses.BUTTON3_PRESSED | curses.BUTTON3_RELEASED
            | curses.BUTTON4_PRESSED | curses.BUTTON4_RELEASED
            | curses.BUTTON1_CLICKED | curses.BUTTON3_CLICKED
            | curses.BUTTON1_DOUBLE_CLICKED 
            | curses.BUTTON1_TRIPLE_CLICKED
            | curses.BUTTON2_DOUBLE_CLICKED 
            | curses.BUTTON2_TRIPLE_CLICKED
            | curses.BUTTON3_DOUBLE_CLICKED 
            | curses.BUTTON3_TRIPLE_CLICKED
            | curses.BUTTON4_DOUBLE_CLICKED 
            | curses.BUTTON4_TRIPLE_CLICKED
            | curses.BUTTON_SHIFT | curses.BUTTON_ALT
            | curses.BUTTON_CTRL)
        self.stdscr.keypad(True) # Handle our own escape codes for now

        # The first call to getch seems to clobber the statusbar.
        # So we make a dummy first call.
        self.stdscr.nodelay(True)
        self.stdscr.getch()
        self.stdscr.nodelay(False) 
Example #2
Source File: curses_ui.py    From keras-lambda with MIT License 5 votes vote down vote up
def _screen_set_mousemask(self):
    curses.mousemask(self._mouse_enabled) 
Example #3
Source File: curses_ui.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 5 votes vote down vote up
def _screen_set_mousemask(self):
    curses.mousemask(self._mouse_enabled) 
Example #4
Source File: apNPSApplication.py    From TelegramTUI with MIT License 5 votes vote down vote up
def __remove_argument_call_main(self, screen, enable_mouse=True):
        # screen disgarded.
        if enable_mouse:
            curses.mousemask(curses.ALL_MOUSE_EVENTS)
        del screen
        return self.main() 
Example #5
Source File: top.py    From python-scripts with GNU General Public License v3.0 5 votes vote down vote up
def init_screen():
    curses.start_color() # load colors
    curses.use_default_colors()
    curses.noecho()      # do not echo text
    curses.cbreak()      # do not wait for "enter"
    curses.mousemask(curses.ALL_MOUSE_EVENTS)

    # Hide cursor, if terminal AND curse supports it
    if hasattr(curses, 'curs_set'):
        try:
            curses.curs_set(0)
        except:
            pass 
Example #6
Source File: cgroup_top.py    From python-scripts with GNU General Public License v3.0 5 votes vote down vote up
def init_screen():
    curses.start_color() # load colors
    curses.use_default_colors()
    curses.noecho()      # do not echo text
    curses.cbreak()      # do not wait for "enter"
    curses.mousemask(curses.ALL_MOUSE_EVENTS)

    # Hide cursor, if terminal AND curse supports it
    if hasattr(curses, 'curs_set'):
        try:
            curses.curs_set(0)
        except:
            pass 
Example #7
Source File: ui.py    From suplemon with MIT License 5 votes vote down vote up
def setup_mouse(self):
        # Mouse support
        curses.mouseinterval(10)
        if self.app.config["editor"]["use_mouse"]:
            curses.mousemask(-1)  # All events
        else:
            curses.mousemask(0)  # All events 
Example #8
Source File: apNPSApplication.py    From EDCOP with Apache License 2.0 5 votes vote down vote up
def __remove_argument_call_main(self, screen, enable_mouse=True):
        # screen disgarded.
        if enable_mouse:
            curses.mousemask(curses.ALL_MOUSE_EVENTS)
        del screen
        return self.main() 
Example #9
Source File: overrides.py    From aws-elastic-beanstalk-cli with Apache License 2.0 5 votes vote down vote up
def apply():
    if not sys.platform.startswith('win32'):
        def noop(_):
            pass
        curses.mousemask = noop

    Screen.refresh = ScreenPatch.refresh 
Example #10
Source File: curses_ui.py    From lambda-packs with MIT License 5 votes vote down vote up
def _screen_set_mousemask(self):
    curses.mousemask(self._mouse_enabled) 
Example #11
Source File: screen.py    From pyModeS with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, uncertainty=False):
        super(Screen, self).__init__()
        self.screen = curses.initscr()
        curses.noecho()
        curses.mousemask(1)
        self.screen.keypad(True)
        self.y = 3
        self.x = 1
        self.offset = 0
        self.acs = {}
        self.lock_icao = None

        self.columns = COLUMNS
        if uncertainty:
            self.columns.extend(UNCERTAINTY_COLUMNS) 
Example #12
Source File: curses_display.py    From anyMesh-Python with MIT License 5 votes vote down vote up
def set_mouse_tracking(self, enable=True):
        """
        Enable mouse tracking.

        After calling this function get_input will include mouse
        click events along with keystrokes.
        """
        enable = bool(enable)
        if enable == self._mouse_tracking_enabled:
            return

        if enable:
            curses.mousemask(0
                | curses.BUTTON1_PRESSED | curses.BUTTON1_RELEASED
                | curses.BUTTON2_PRESSED | curses.BUTTON2_RELEASED
                | curses.BUTTON3_PRESSED | curses.BUTTON3_RELEASED
                | curses.BUTTON4_PRESSED | curses.BUTTON4_RELEASED
                | curses.BUTTON1_DOUBLE_CLICKED | curses.BUTTON1_TRIPLE_CLICKED
                | curses.BUTTON2_DOUBLE_CLICKED | curses.BUTTON2_TRIPLE_CLICKED
                | curses.BUTTON3_DOUBLE_CLICKED | curses.BUTTON3_TRIPLE_CLICKED
                | curses.BUTTON4_DOUBLE_CLICKED | curses.BUTTON4_TRIPLE_CLICKED
                | curses.BUTTON_SHIFT | curses.BUTTON_ALT
                | curses.BUTTON_CTRL)
        else:
            raise NotImplementedError()

        self._mouse_tracking_enabled = enable 
Example #13
Source File: mouse_events.py    From Learning-Python-by-building-games with MIT License 5 votes vote down vote up
def main(screen):
    c.curs_set(0)
    c.mousemask(1)

    inp = screen.getch()
    if inp == c.KEY_MOUSE:
        screen.addstr(17, 40, "Mouse is clicked")
        screen.refresh()

    screen.getch()
    time.sleep(10) 
Example #14
Source File: apNPSApplication.py    From HomePWN with GNU General Public License v3.0 5 votes vote down vote up
def __remove_argument_call_main(self, screen, enable_mouse=True):
        # screen disgarded.
        if enable_mouse:
            curses.mousemask(curses.ALL_MOUSE_EVENTS)
        del screen
        return self.main() 
Example #15
Source File: cgroup_top.py    From ctop with MIT License 5 votes vote down vote up
def init_screen():
    curses.start_color() # load colors
    curses.use_default_colors()
    curses.noecho()      # do not echo text
    curses.cbreak()      # do not wait for "enter"
    curses.mousemask(curses.ALL_MOUSE_EVENTS)

    # Hide cursor, if terminal AND curse supports it
    if hasattr(curses, 'curs_set'):
        try:
            curses.curs_set(0)
        except:
            pass 
Example #16
Source File: apNPSApplication.py    From apple_bleee with GNU General Public License v3.0 5 votes vote down vote up
def __remove_argument_call_main(self, screen, enable_mouse=True):
        # screen disgarded.
        if enable_mouse:
            curses.mousemask(curses.ALL_MOUSE_EVENTS)
        del screen
        return self.main() 
Example #17
Source File: overrides.py    From deepWordBug with Apache License 2.0 5 votes vote down vote up
def apply():
    if not sys.platform.startswith('win32'):
        def noop(_):
            pass
        curses.mousemask = noop

    Screen.refresh = ScreenPatch.refresh 
Example #18
Source File: curses_ui.py    From auto-alt-text-lambda-api with MIT License 5 votes vote down vote up
def _screen_set_mousemask(self):
    curses.mousemask(self._mouse_enabled) 
Example #19
Source File: ci_program.py    From ci_edit with Apache License 2.0 4 votes vote down vote up
def setUpCurses(self, cursesScreen):
        self.cursesScreen = cursesScreen
        curses.mousemask(-1)
        curses.mouseinterval(0)
        # Enable mouse tracking in xterm.
        sys.stdout.write('\033[?1002;h')
        #sys.stdout.write('\033[?1005;h')
        curses.meta(1)
        # Access ^c before shell does.
        curses.raw()
        # Enable Bracketed Paste Mode.
        sys.stdout.write('\033[?2004;h')
        # Push the escape codes out to the terminal. (Whether this is needed
        # seems to vary by platform).
        sys.stdout.flush()
        try:
            curses.start_color()
            if not curses.has_colors():
                userMessage("This terminal does not support color.")
                self.quitNow()
            else:
                curses.use_default_colors()
        except curses.error as e:
            app.log.error(e)
        app.log.startup(u"curses.COLORS", curses.COLORS)
        if 0:
            assert curses.COLORS == 256
            assert curses.can_change_color() == 1
            assert curses.has_colors() == 1
            app.log.detail("color_content:")
            for i in range(0, curses.COLORS):
                app.log.detail("color", i, ": ", curses.color_content(i))
            for i in range(16, curses.COLORS):
                curses.init_color(i, 500, 500, i * 787 % 1000)
            app.log.detail("color_content, after:")
            for i in range(0, curses.COLORS):
                app.log.detail("color", i, ": ", curses.color_content(i))
        if 1:
            #rows, cols = self.cursesScreen.getmaxyx()
            cursesWindow = self.cursesScreen
            cursesWindow.leaveok(1)  # Don't update cursor position.
            cursesWindow.scrollok(0)
            cursesWindow.timeout(10)
            cursesWindow.keypad(1)
            app.window.mainCursesWindow = cursesWindow