[ekg2-commit] ekg2: bindings.c (HEAD) mouse.c (HEAD) old.c (HEAD) [peres]
CVS commit
cvs w toxygen.net
Nie, 9 Wrz 2007, 01:01:14 CEST
Module name: ekg2
Changes by: peres 2007-09-09 01:01:11
Modified files:
bindings.c mouse.c old.c
Log message:
Multiline input scrolling by mouse wheel. If current line gets outta sight,
we move cursor to min/max y and max x, and try to hide it.
Index: bindings.c
===================================================================
RCS file: /home/cvs/ekg2/plugins/ncurses/bindings.c,v
diff -d -u -r1.72 -r1.73
--- bindings.c 8 Sep 2007 22:05:54 -0000 1.72
+++ bindings.c 8 Sep 2007 23:01:11 -0000 1.73
@@ -133,6 +133,7 @@
else
ncurses_typing_win = NULL;
+ curs_set(1);
xfree(tmp);
}
}
@@ -456,7 +457,7 @@
line_start = 0;
}
-static BINDING_FUNCTION(binding_previous_only_history)
+BINDING_FUNCTION(binding_previous_only_history)
{
if (history[history_index + 1]) {
if (history_index == 0)
@@ -494,7 +495,7 @@
}
}
-static BINDING_FUNCTION(binding_next_only_history)
+BINDING_FUNCTION(binding_next_only_history)
{
if (history_index > 0) {
if (history_index == 0)
@@ -533,12 +534,11 @@
}
-BINDING_FUNCTION(binding_previous_history)
+static BINDING_FUNCTION(binding_previous_history)
{
if (lines) {
- if (lines_index - lines_start == 0)
- if (lines_start)
- lines_start--;
+ if (lines_index - lines_start == 0 && lines_start)
+ lines_start--;
if (lines_index)
lines_index--;
@@ -551,7 +551,7 @@
binding_previous_only_history(NULL);
}
-BINDING_FUNCTION(binding_next_history)
+static BINDING_FUNCTION(binding_next_history)
{
if (lines) {
if (lines_index - line_start == 4)
Index: mouse.c
===================================================================
RCS file: /home/cvs/ekg2/plugins/ncurses/mouse.c,v
diff -d -u -r1.27 -r1.28
--- mouse.c 8 Sep 2007 22:05:54 -0000 1.27
+++ mouse.c 8 Sep 2007 23:01:11 -0000 1.28
@@ -37,8 +37,8 @@
#include "mouse.h"
/* imported bindings */
-BINDING_FUNCTION(binding_previous_history);
-BINDING_FUNCTION(binding_next_history);
+BINDING_FUNCTION(binding_previous_only_history);
+BINDING_FUNCTION(binding_next_only_history);
int mouse_initialized = 0;
@@ -159,18 +159,26 @@
if (y > stdscr->_maxy - input_size + 1) {
if (input_size == 1) {
if (mouse_flag == EKG_SCROLLED_UP)
- binding_previous_history(NULL);
+ binding_previous_only_history(NULL);
else if (mouse_flag == EKG_SCROLLED_DOWN)
- binding_next_history(NULL);
+ binding_next_only_history(NULL);
else if (mouse_flag == EKG_BUTTON1_CLICKED) {
/* XXX: move cursor */
}
} else {
- if (mouse_flag == EKG_SCROLLED_UP)
- /* XXX: scroll */;
- else if (mouse_flag == EKG_SCROLLED_DOWN)
- /* XXX: scroll */;
- else if (mouse_flag == EKG_BUTTON1_CLICKED) {
+ if (mouse_flag == EKG_SCROLLED_UP) {
+ if (lines_start > 2)
+ lines_start -= 2;
+ else
+ lines_start = 0;
+ } else if (mouse_flag == EKG_SCROLLED_DOWN) {
+ const int lines_count = array_count((char **) ncurses_lines);
+
+ if (lines_start < lines_count - 2)
+ lines_start += 2;
+ else
+ lines_start = lines_count - 1;
+ } else if (mouse_flag == EKG_BUTTON1_CLICKED) {
/* XXX: move cursor */
}
}
Index: old.c
===================================================================
RCS file: /home/cvs/ekg2/plugins/ncurses/old.c,v
diff -d -u -r1.152 -r1.153
--- old.c 6 Sep 2007 23:03:18 -0000 1.152
+++ old.c 8 Sep 2007 23:01:11 -0000 1.153
@@ -2167,7 +2167,15 @@
xfree(aspell_line);
#endif
}
- wmove(input, lines_index - lines_start, line_index - line_start);
+
+ {
+ const int beforewin = (lines_index < lines_start);
+ const int outtawin = (beforewin || lines_index > lines_start + 4);
+
+ wmove(input, (beforewin ? 0 : outtawin ? 4 : lines_index - lines_start),
+ outtawin ? stdscr->_maxx : line_index - line_start);
+ curs_set(!outtawin);
+ }
} else {
int i;
/* const */size_t linelen = xwcslen(ncurses_line);
Więcej informacji o liście dyskusyjnej ekg2-commit