diff options
author | hut <hut@lavabit.com> | 2010-04-08 17:40:51 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-04-08 17:40:51 +0200 |
commit | e01ea6523445c49fe440ebceeaeed1293f268b5f (patch) | |
tree | dcf9feee1150ccd0a71a4aeb38d738fd4ff26f6c | |
parent | e02d47edf8ef8ed3dda680e1e78aae779cb4e053 (diff) | |
download | ranger-e01ea6523445c49fe440ebceeaeed1293f268b5f.tar.gz |
added option 'mouse_enabled'
-rw-r--r-- | ranger/defaults/options.py | 3 | ||||
-rw-r--r-- | ranger/gui/ui.py | 33 | ||||
-rw-r--r-- | ranger/shared/settings.py | 1 |
3 files changed, 25 insertions, 12 deletions
diff --git a/ranger/defaults/options.py b/ranger/defaults/options.py index 6b2a0dc9..d96955b7 100644 --- a/ranger/defaults/options.py +++ b/ranger/defaults/options.py @@ -61,6 +61,9 @@ draw_bookmark_borders = True # How many columns are there, and what are their relative widths? column_ratios = (1, 1, 4, 3) +# Enable the mouse support? +mouse_enabled = True + # Display the file size in the main column or status bar? display_size_in_main_column = True display_size_in_status_bar = False diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py index 68285718..cdaf6cde 100644 --- a/ranger/gui/ui.py +++ b/ranger/gui/ui.py @@ -27,9 +27,25 @@ TERMINALS_WITH_TITLE = ("xterm", "xterm-256color", "rxvt", "rxvt-256color", "rxvt-unicode", "aterm", "Eterm", "screen", "screen-256color") +MOUSEMASK = curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION + +def _setup_mouse(signal): + if signal['value']: + curses.mousemask(MOUSEMASK) + curses.mouseinterval(0) + + ## this line solves this problem: + ## If an action, following a mouse click, includes the + ## suspension and re-initializion of the ui (e.g. running a + ## file by clicking on its preview) and the next key is another + ## mouse click, the bstate of this mouse event will be invalid. + ## (atm, invalid bstates are recognized as scroll-down) + curses.ungetmouse(0,0,0,0,0) + else: + curses.mousemask(0) + class UI(DisplayableContainer): is_set_up = False - mousemask = curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION load_mode = False def __init__(self, commandlist=None, env=None, fm=None): self._draw_title = os.environ["TERM"] in TERMINALS_WITH_TITLE @@ -66,16 +82,8 @@ class UI(DisplayableContainer): curses.start_color() curses.use_default_colors() - curses.mousemask(self.mousemask) - curses.mouseinterval(0) - - ## this line solves this problem: - ## If an action, following a mouse click, includes the - ## suspension and re-initializion of the ui (e.g. running a - ## file by clicking on its preview) and the next key is another - ## mouse click, the bstate of this mouse event will be invalid. - ## (atm, invalid bstates are recognized as scroll-down) - curses.ungetmouse(0,0,0,0,0) + self.settings.signal_bind('setopt.mouse_enabled', _setup_mouse) + _setup_mouse(dict(value=self.settings.mouse_enabled)) if not self.is_set_up: self.is_set_up = True @@ -91,7 +99,8 @@ class UI(DisplayableContainer): curses.curs_set(1) except: pass - curses.mousemask(0) + if self.settings.mouse_enabled: + _setup_mouse(dict(value=False)) curses.endwin() def set_load_mode(self, boolean): diff --git a/ranger/shared/settings.py b/ranger/shared/settings.py index a4a58e6e..6933957a 100644 --- a/ranger/shared/settings.py +++ b/ranger/shared/settings.py @@ -39,6 +39,7 @@ ALLOWED_SETTINGS = { 'scroll_offset': int, 'preview_files': bool, 'preview_directories': bool, + 'mouse_enabled': bool, 'flushinput': bool, 'colorscheme': str, 'colorscheme_overlay': (type(None), type(lambda:0)), |