aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-02-07 20:36:45 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2015-02-07 20:36:45 +0100
commit627248bd1faca718e47941011e8099fb1b8d2223 (patch)
tree3b97eeac75da1bd44b4134416cd8da0a5333d3c5 /src
parent4730cc47e18b2077fc457cecd8a988e399031188 (diff)
downloadtdv-627248bd1faca718e47941011e8099fb1b8d2223.tar.gz
tdv-627248bd1faca718e47941011e8099fb1b8d2223.tar.xz
tdv-627248bd1faca718e47941011e8099fb1b8d2223.zip
React to mouse wheel scrolling
Diffstat (limited to 'src')
-rw-r--r--src/sdtui.c76
1 files changed, 44 insertions, 32 deletions
diff --git a/src/sdtui.c b/src/sdtui.c
index 694ad12..f55b2a4 100644
--- a/src/sdtui.c
+++ b/src/sdtui.c
@@ -716,38 +716,6 @@ app_process_resize (Application *self)
return TRUE;
}
-/** Process mouse input. */
-static gboolean
-app_process_mouse (Application *self, termo_key_t *event)
-{
- int line, column, button;
- termo_mouse_event_t type;
- termo_interpret_mouse (self->tk, event, &type, &button, &line, &column);
-
- if (type != TERMO_MOUSE_PRESS || button != 1)
- return TRUE;
-
- SAVE_CURSOR
- if (line == 0)
- {
- gsize label_len = g_utf8_strlen (self->search_label, -1);
- gint pos = column - label_len;
- if (pos >= 0)
- {
- self->input_pos = MIN ((guint) pos, self->input->len);
- move (0, label_len + self->input_pos);
- refresh ();
- }
- }
- else if (line <= (int) (app_count_view_items (self) - self->top_offset))
- {
- self->selected = line - 1;
- app_redraw_view (self);
- RESTORE_CURSOR
- }
- return TRUE;
-}
-
// --- User input handling -----------------------------------------------------
/** All the actions that can be performed by the user. */
@@ -1087,6 +1055,50 @@ app_process_key (Application *self, termo_key_t *event)
return TRUE;
}
+static void
+app_process_left_mouse_click (Application *self, int line, int column)
+{
+ SAVE_CURSOR
+ if (line == 0)
+ {
+ gsize label_len = g_utf8_strlen (self->search_label, -1);
+ gint pos = column - label_len;
+ if (pos >= 0)
+ {
+ self->input_pos = MIN ((guint) pos, self->input->len);
+ move (0, label_len + self->input_pos);
+ refresh ();
+ }
+ }
+ else if (line <= (int) (app_count_view_items (self) - self->top_offset))
+ {
+ self->selected = line - 1;
+ app_redraw_view (self);
+ RESTORE_CURSOR
+ }
+}
+
+/** Process mouse input. */
+static gboolean
+app_process_mouse (Application *self, termo_key_t *event)
+{
+ int line, column, button;
+ termo_mouse_event_t type;
+ termo_interpret_mouse (self->tk, event, &type, &button, &line, &column);
+
+ if (type != TERMO_MOUSE_PRESS)
+ return TRUE;
+
+ if (button == 1)
+ app_process_left_mouse_click (self, line, column);
+ else if (button == 4)
+ app_process_user_action (self, USER_ACTION_GOTO_DEFINITION_PREVIOUS);
+ else if (button == 5)
+ app_process_user_action (self, USER_ACTION_GOTO_DEFINITION_NEXT);
+
+ return TRUE;
+}
+
/** Process input events from the terminal. */
static gboolean
app_process_termo_event (Application *self, termo_key_t *event)