aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-10-03 08:26:17 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2016-10-03 08:26:17 +0200
commit91b6a799c8242d31b3ef511f67f02b1f348b4645 (patch)
tree6e0ea6421283ed3e504448c69d93d72bd20ba90d
parent49c6a31742e54fa5d6bfa31d6baa8a88ad78d315 (diff)
downloadnncmpp-91b6a799c8242d31b3ef511f67f02b1f348b4645.tar.gz
nncmpp-91b6a799c8242d31b3ef511f67f02b1f348b4645.tar.xz
nncmpp-91b6a799c8242d31b3ef511f67f02b1f348b4645.zip
Handle mouse clicks on the scrollbar
-rw-r--r--nncmpp.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/nncmpp.c b/nncmpp.c
index d58cc26..a6faaa1 100644
--- a/nncmpp.c
+++ b/nncmpp.c
@@ -1324,7 +1324,16 @@ app_process_left_mouse_click (int line, int column)
|| row_index >= (int) tab->item_count - tab->item_top)
return;
- tab->item_selected = row_index + tab->item_top;
+ // TODO: handle the scrollbar a bit better than this
+ int visible_items = app_visible_items ();
+ if ((int) tab->item_count > visible_items && column == COLS - 1)
+ {
+ tab->item_top = (float) row_index / visible_items
+ * (int) tab->item_count - visible_items / 2;
+ app_fix_view_range ();
+ }
+ else
+ tab->item_selected = row_index + tab->item_top;
app_redraw_view ();
}
}