ncurses does not support the scrollwheel well, but this is a step in that direction.

This commit is contained in:
Hisham Muhammad 2011-05-26 16:32:50 +00:00
parent 9599e5650e
commit 7a9615960f
1 changed files with 31 additions and 24 deletions

55
htop.c
View File

@ -1,6 +1,6 @@
/* /*
htop - htop.c htop - htop.c
(C) 2004-2010 Hisham H. Muhammad (C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file Released under the GNU GPL, see the COPYING file
in the source distribution for its full text. in the source distribution for its full text.
*/ */
@ -37,7 +37,7 @@ in the source distribution for its full text.
#define INCSEARCH_MAX 40 #define INCSEARCH_MAX 40
#define COPYRIGHT "(C) 2004-2010 Hisham Muhammad" #define COPYRIGHT "(C) 2004-2011 Hisham Muhammad"
static void printVersionFlag() { static void printVersionFlag() {
fputs("htop " VERSION " - " COPYRIGHT "\n" fputs("htop " VERSION " - " COPYRIGHT "\n"
@ -496,30 +496,37 @@ int main(int argc, char** argv) {
MEVENT mevent; MEVENT mevent;
int ok = getmouse(&mevent); int ok = getmouse(&mevent);
if (ok == OK) { if (ok == OK) {
if (mevent.y == panel->y) { if (mevent.bstate & BUTTON1_CLICKED) {
int x = panel->scrollH + mevent.x + 1; if (mevent.y == panel->y) {
ProcessField field = ProcessList_keyAt(pl, x); int x = panel->scrollH + mevent.x + 1;
if (field == pl->sortKey) { ProcessField field = ProcessList_keyAt(pl, x);
ProcessList_invertSortOrder(pl); if (field == pl->sortKey) {
pl->treeView = false; ProcessList_invertSortOrder(pl);
} else { pl->treeView = false;
setSortKey(pl, field, panel, settings); } else {
setSortKey(pl, field, panel, settings);
}
refreshTimeout = 0;
continue;
} else if (mevent.y >= panel->y + 1 && mevent.y < LINES - 1) {
Panel_setSelected(panel, mevent.y - panel->y + panel->scrollV - 1);
doRefresh = false;
refreshTimeout = resetRefreshTimeout;
follow = true;
continue;
} if (mevent.y == LINES - 1) {
FunctionBar* bar;
if (incSearchMode) bar = searchBar;
else bar = defaultBar;
ch = FunctionBar_synthesizeEvent(bar, mevent.x);
} }
refreshTimeout = 0; } else if (mevent.bstate & BUTTON4_CLICKED) {
continue; ch = KEY_UP;
} else if (mevent.y >= panel->y + 1 && mevent.y < LINES - 1) { #if NCURSES_MOUSE_VERSION > 1
Panel_setSelected(panel, mevent.y - panel->y + panel->scrollV - 1); } else if (mevent.bstate & BUTTON5_CLICKED) {
doRefresh = false; ch = KEY_DOWN;
refreshTimeout = resetRefreshTimeout; #endif
follow = true;
continue;
} if (mevent.y == LINES - 1) {
FunctionBar* bar;
if (incSearchMode) bar = searchBar;
else bar = defaultBar;
ch = FunctionBar_synthesizeEvent(bar, mevent.x);
} }
} }
} }