aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBlake DeMarcy <ofunknowndescent@gmail.com>2017-04-25 20:31:40 -0500
committerBlake DeMarcy <ofunknowndescent@gmail.com>2017-04-25 20:31:40 -0500
commita6e3e1675f810033bed35fd5ce27a7e87c636132 (patch)
tree8ecb5d93884f2b72d1e6e754cfddf17663727130
parent0f6846c3609c3b8caa34a296355e06d18261a1e1 (diff)
downloadbbj-a6e3e1675f810033bed35fd5ce27a7e87c636132.tar.gz
really basic mouse support
-rw-r--r--clients/urwid/main.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/clients/urwid/main.py b/clients/urwid/main.py
index 0f0c942..c07db81 100644
--- a/clients/urwid/main.py
+++ b/clients/urwid/main.py
@@ -181,6 +181,7 @@ editors = ["nano", "vim", "emacs", "vim -u NONE", "emacs -Q", "micro", "ed", "jo
default_prefs = {
# using default= is not completely reliable, sadly...
"editor": os.getenv("EDITOR") or "nano",
+ "mouse_integration": False,
"jump_count": 1,
"shift_multiplier": 5,
"integrate_external_editor": True,
@@ -261,7 +262,7 @@ class App(object):
self.loop = urwid.MainLoop(
urwid.Frame(self.body),
palette=colormap,
- handle_mouse=False)
+ handle_mouse=self.prefs["mouse_integration"])
def set_header(self, text, *format_specs):
@@ -981,6 +982,13 @@ class App(object):
bbjrc("update", **self.prefs)
+ def toggle_mouse(self, button, value):
+ self.prefs["mouse_integration"] = value
+ self.loop.handle_mouse = value
+ self.loop.screen.set_mouse_tracking(value)
+ bbjrc("update", **self.prefs)
+
+
def toggle_spacing(self, button, value):
self.prefs["index_spacing"] = value
bbjrc("update", **self.prefs)
@@ -1162,6 +1170,11 @@ class App(object):
state=self.prefs["index_spacing"],
on_state_change=self.toggle_spacing
),
+ urwid.CheckBox(
+ "Handle mouse (disrupts URL clicking)",
+ state=self.prefs["mouse_integration"],
+ on_state_change=self.toggle_mouse
+ ),
urwid.Divider(),
*time_stuff,
urwid.Divider(),
@@ -1768,6 +1781,19 @@ class ActionBox(urwid.ListBox):
app.reply(None, message)
+ def mouse_event(self, size, event, button, x, y, focus):
+ if super(ActionBox, self).mouse_event(size, event, button, x, y, focus):
+ return
+ if button == 4:
+ for x in range(app.prefs["shift_multiplier"]):
+ self._keypress_up(size)
+
+ elif button == 5:
+ for x in range(app.prefs["shift_multiplier"]):
+ self._keypress_down(size)
+
+
+
def frilly_exit():
"""
Exit with some flair. Will fill the screen with rainbows
Un proyecto texto-plano.xyz