summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2015-08-19 18:55:24 -0300
committerHisham Muhammad <hisham@gobolinux.org>2015-08-19 18:55:24 -0300
commitb003636958377ecad3ee5df4ca2de8717c4530b9 (patch)
tree187106d1eae07e5f1dfd8dfb3a63d288863f3e8a
parent3e93f9b85243e1edf1d3b73658fdf3f8a5b13032 (diff)
Support for NCurses 6.0 and mouse wheel
-rw-r--r--CRT.c12
-rw-r--r--CRT.h5
-rw-r--r--Panel.c15
-rw-r--r--ScreenManager.c41
-rw-r--r--configure.ac8
5 files changed, 61 insertions, 20 deletions
diff --git a/CRT.c b/CRT.c
index b44a86b6..1b44b694 100644
--- a/CRT.c
+++ b/CRT.c
@@ -29,6 +29,9 @@ in the source distribution for its full text.
#define Cyan COLOR_CYAN
#define White COLOR_WHITE
+#define KEY_WHEELUP KEY_F(20)
+#define KEY_WHEELDOWN KEY_F(21)
+
//#link curses
/*{
@@ -515,6 +518,8 @@ int CRT_cursorX = 0;
int CRT_scrollHAmount = 5;
+int CRT_scrollWheelVAmount = 10;
+
char* CRT_termType;
// TODO move color scheme to Settings, perhaps?
@@ -550,6 +555,7 @@ void CRT_init(int delay, int colorScheme) {
nonl();
intrflush(stdscr, false);
keypad(stdscr, true);
+ mouseinterval(0);
curs_set(0);
if (has_colors()) {
start_color();
@@ -598,7 +604,11 @@ void CRT_init(int delay, int colorScheme) {
CRT_treeStr = CRT_utf8 ? CRT_treeStrUtf8 : CRT_treeStrAscii;
- mousemask(BUTTON1_CLICKED, NULL);
+#if NCURSES_MOUSE_VERSION > 1
+ mousemask(BUTTON1_RELEASED | BUTTON4_PRESSED | BUTTON5_PRESSED, NULL);
+#else
+ mousemask(BUTTON1_RELEASED, NULL);
+#endif
}
void CRT_done() {
diff --git a/CRT.h b/CRT.h
index 3e8babe7..69497d76 100644
--- a/CRT.h
+++ b/CRT.h
@@ -20,6 +20,9 @@ in the source distribution for its full text.
#define Cyan COLOR_CYAN
#define White COLOR_WHITE
+#define KEY_WHEELUP KEY_F(20)
+#define KEY_WHEELDOWN KEY_F(21)
+
//#link curses
#include <stdbool.h>
@@ -130,6 +133,8 @@ extern int CRT_cursorX;
extern int CRT_scrollHAmount;
+extern int CRT_scrollWheelVAmount;
+
char* CRT_termType;
// TODO move color scheme to Settings, perhaps?
diff --git a/Panel.c b/Panel.c
index 08d04022..f421a0d5 100644
--- a/Panel.c
+++ b/Panel.c
@@ -412,6 +412,21 @@ bool Panel_onKey(Panel* this, int key) {
this->scrollV += (this->h - 1);
this->needsRedraw = true;
break;
+ case KEY_WHEELUP:
+ this->selected -= CRT_scrollWheelVAmount;
+ this->scrollV -= CRT_scrollWheelVAmount;
+ this->needsRedraw = true;
+ break;
+ case KEY_WHEELDOWN:
+ {
+ this->selected += CRT_scrollWheelVAmount;
+ this->scrollV += CRT_scrollWheelVAmount;
+ if (this->scrollV > Vector_size(this->items) - this->h) {
+ this->scrollV = Vector_size(this->items) - this->h;
+ }
+ this->needsRedraw = true;
+ break;
+ }
case KEY_HOME:
this->selected = 0;
break;
diff --git a/ScreenManager.c b/ScreenManager.c
index c9253c3f..657065c6 100644
--- a/ScreenManager.c
+++ b/ScreenManager.c
@@ -9,6 +9,7 @@ in the source distribution for its full text.
#include "ProcessList.h"
#include "Object.h"
+#include "CRT.h"
#include <assert.h>
#include <time.h>
@@ -196,26 +197,34 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
MEVENT mevent;
int ok = getmouse(&mevent);
if (ok == OK) {
- if (mevent.y == LINES - 1) {
- ch = FunctionBar_synthesizeEvent(panelFocus->currentBar, mevent.x);
- } else {
- for (int i = 0; i < this->panelCount; i++) {
- Panel* panel = (Panel*) Vector_get(this->panels, i);
- if (mevent.x >= panel->x && mevent.x <= panel->x+panel->w) {
- if (mevent.y == panel->y) {
- ch = EVENT_HEADER_CLICK(mevent.x - panel->x);
- break;
- } else if (mevent.y > panel->y && mevent.y <= panel->y+panel->h) {
- if (panel == panelFocus || this->allowFocusChange) {
- focus = i;
- panelFocus = setCurrentPanel(panel);
- Panel_setSelected(panel, mevent.y - panel->y + panel->scrollV - 1);
+ if (mevent.bstate & BUTTON1_RELEASED) {
+ if (mevent.y == LINES - 1) {
+ ch = FunctionBar_synthesizeEvent(panelFocus->currentBar, mevent.x);
+ } else {
+ for (int i = 0; i < this->panelCount; i++) {
+ Panel* panel = (Panel*) Vector_get(this->panels, i);
+ if (mevent.x >= panel->x && mevent.x <= panel->x+panel->w) {
+ if (mevent.y == panel->y) {
+ ch = EVENT_HEADER_CLICK(mevent.x - panel->x);
+ break;
+ } else if (mevent.y > panel->y && mevent.y <= panel->y+panel->h) {
+ if (panel == panelFocus || this->allowFocusChange) {
+ focus = i;
+ panelFocus = setCurrentPanel(panel);
+ Panel_setSelected(panel, mevent.y - panel->y + panel->scrollV - 1);
+ }
+ ch = KEY_MOUSE;
+ break;
}
- ch = KEY_MOUSE;
- break;
}
}
}
+ #if NCURSES_MOUSE_VERSION > 1
+ } else if (mevent.bstate & BUTTON4_PRESSED) {
+ ch = KEY_WHEELUP;
+ } else if (mevent.bstate & BUTTON5_PRESSED) {
+ ch = KEY_WHEELDOWN;
+ #endif
}
}
}
diff --git a/configure.ac b/configure.ac
index 3852d3ba..f9e58eea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -143,9 +143,11 @@ fi
AC_ARG_ENABLE(unicode, [AC_HELP_STRING([--enable-unicode], [enable Unicode support])], ,enable_unicode="yes")
if test "x$enable_unicode" = xyes; then
- AC_CHECK_LIB([ncursesw], [refresh], [], [
- missing_libraries="$missing_libraries libncursesw"
- AC_MSG_ERROR([You may want to use --disable-unicode or install libncursesw.])
+ AC_CHECK_LIB([ncursesw6], [refresh], [], [
+ AC_CHECK_LIB([ncursesw], [refresh], [], [
+ missing_libraries="$missing_libraries libncursesw"
+ AC_MSG_ERROR([You may want to use --disable-unicode or install libncursesw.])
+ ])
])
AC_CHECK_HEADERS([ncursesw/curses.h],[:],
[AC_CHECK_HEADERS([ncurses/ncurses.h],[:],

© 2014-2024 Faster IT GmbH | imprint | privacy policy