On Tue, May 08, 2012 at 10:50:41PM +0200, Raphaël Droz wrote:
> before pushing to the main abook repository I pushed 9 reworked
> commits here [1]
> If nothing is wrong with them I hope they can make their way in
> the main repository at sf.net.
>
> [1] https://gitorious.org/drzraf/abook/commits/master
The only strange thing is scrolling, because it just moves the selected
line-marker instead of really scrolling the list (like it is known from
vim, ncmpcpp or real gui-applications). You'll find a patch
0001-Scroll-whole-list-on-mouse-wheel-action.patch attached that let's
the actual whole list scroll.
I didn't push it to my repository because the names of the new functions
and maybe even its behaviour is worth discussing. What's your opinion
about these two points?
Thorsten
>From 0c858687c552338c3d069d69aed78edfc748a6bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thorsten=20Wi=C3=9Fmann?= <e...@thorsten-wissmann.de>
Date: Sat, 12 May 2012 16:07:50 +0200
Subject: [PATCH] Scroll whole list on mouse wheel action
This lets the whole list scroll on mouse action (button 5 and 6) instead
of just moving the selection. This also adds the scroll_speed option
that sets the number of lines the list is scrolled by.
---
abookrc.5 | 5 +++++
list.c | 35 +++++++++++++++++++++++++++++++++++
list.h | 2 ++
options.c | 1 +
options.h | 1 +
ui.c | 4 ++--
6 Dateien geändert, 46 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)
diff --git a/abookrc.5 b/abookrc.5
index 8c13366..0a0060f 100644
--- a/abookrc.5
+++ b/abookrc.5
@@ -151,6 +151,11 @@ Defines if the cursor is visible in main display. Default
is false.
Defines if navigation via the mouse is activated. Default is false.
.TP
+\fBscroll_speed\fP=lines
+Defines the number of lines the adress list is scrolled by on a mouse wheel
+action. This option only takes effect if use_mouse is enabled. Default is 2.
+
+.TP
\fBuse_colors\fP=[true|false]
Defines if the output of abook is colorized. Default is false.
diff --git a/list.c b/list.c
index ca4892b..7357467 100644
--- a/list.c
+++ b/list.c
@@ -24,6 +24,7 @@
int curitem = -1;
int first_list_item = -1;
+int scroll_speed = 2;
char *selected = NULL;
extern abook_field_list *fields_list;
@@ -130,6 +131,7 @@ init_list()
{
list = newwin(LIST_LINES, LIST_COLS, LIST_TOP, 0);
scrollok(list, TRUE);
+ scroll_speed = abs(opt_get_int(INT_SCROLL_SPEED));
}
void
@@ -352,6 +354,39 @@ scroll_down()
refresh_list();
}
+void
+scroll_list_up()
+{
+ if(first_list_item <= 0)
+ return;
+
+ first_list_item -= scroll_speed;
+ if(first_list_item < 0) {
+ first_list_item = 0;
+ }
+ if(curitem > LAST_LIST_ITEM) {
+ curitem = LAST_LIST_ITEM;
+ }
+
+ refresh_list();
+}
+
+void
+scroll_list_down()
+{
+ if(first_list_item > db_n_items() - 2)
+ return;
+
+ first_list_item += scroll_speed;
+ if(first_list_item >= db_n_items()) {
+ first_list_item = db_n_items() - 1;
+ }
+ if(curitem < first_list_item) {
+ curitem = first_list_item;
+ }
+
+ refresh_list();
+}
void
page_up()
diff --git a/list.h b/list.h
index 0cc3113..35befc5 100644
--- a/list.h
+++ b/list.h
@@ -34,6 +34,8 @@ void get_list_field(int item, struct index_elem *e, struct
list_field *res);
void list_headerline();
void scroll_up();
void scroll_down();
+void scroll_list_up();
+void scroll_list_down();
void page_up();
void page_down();
void select_none();
diff --git a/options.c b/options.c
index 2c1303c..6f75a06 100644
--- a/options.c
+++ b/options.c
@@ -68,6 +68,7 @@ static struct option abook_vars[] = {
{ "sort_field", OT_STR, STR_SORT_FIELD, UL "nick" },
{ "show_cursor", OT_BOOL, BOOL_SHOW_CURSOR, FALSE },
{ "use_mouse", OT_BOOL, BOOL_USE_MOUSE, FALSE },
+ { "scroll_speed", OT_INT, INT_SCROLL_SPEED, UL 2 },
{ "use_colors", OT_BOOL, BOOL_USE_COLORS, FALSE },
{ "color_header_fg", OT_STR, STR_COLOR_HEADER_FG, UL "blue" },
{ "color_header_fg", OT_STR, STR_COLOR_HEADER_FG, UL "blue" },
diff --git a/options.h b/options.h
index d2cc8c0..78515a9 100644
--- a/options.h
+++ b/options.h
@@ -38,6 +38,7 @@ enum bool_opts {
enum int_opts {
INT_EMAILPOS,
INT_EXTRAPOS,
+ INT_SCROLL_SPEED,
INT_MAXIMUM /* INT_MAX conflicts on some systems */
};
diff --git a/ui.c b/ui.c
index 170583e..e802670 100644
--- a/ui.c
+++ b/ui.c
@@ -556,9 +556,9 @@ get_commands()
refresh_list();
}
} else if(event.bstate & BUTTON4_PRESSED) {
- scroll_up();
+ scroll_list_up();
} else if(event.bstate & BUTTON5_PRESSED) {
- scroll_down();
+ scroll_list_down();
}
}
}
--
1.7.10.1
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Abook-devel mailing list
Abook-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/abook-devel