From 6dc7f1c7b3cf51744d02e4b8d1969bcde24c0eb3 Mon Sep 17 00:00:00 2001 From: wiz Date: Mon, 16 Oct 2000 01:34:38 +0000 Subject: Clean up input handling. Patches provided by Brett Lymn in private mail. --- sysutils/whowatch/files/patch-sum | 6 +-- sysutils/whowatch/patches/patch-ab | 50 ++++++++++++++++++--- sysutils/whowatch/patches/patch-ac | 90 +++++++++++++++++++++++++++++++------- 3 files changed, 120 insertions(+), 26 deletions(-) (limited to 'sysutils/whowatch') diff --git a/sysutils/whowatch/files/patch-sum b/sysutils/whowatch/files/patch-sum index 97ead475eaf..2a8820f2378 100644 --- a/sysutils/whowatch/files/patch-sum +++ b/sysutils/whowatch/files/patch-sum @@ -1,4 +1,4 @@ -$NetBSD: patch-sum,v 1.2 2000/08/11 23:49:04 itojun Exp $ +$NetBSD: patch-sum,v 1.3 2000/10/16 01:34:38 wiz Exp $ -MD5 (patch-ab) = 2efbede552652f0ef692c5ef3f0efc98 -MD5 (patch-ac) = bdb96f44d469dc9b1b626b9b3870f33c +MD5 (patch-ab) = ab1a89e96c6c2663ac29f5759fc85de6 +MD5 (patch-ac) = 0cd8d85fd350bc9c892744be8b5a5e1a diff --git a/sysutils/whowatch/patches/patch-ab b/sysutils/whowatch/patches/patch-ab index 1feac1b3f85..4320573e4a1 100644 --- a/sysutils/whowatch/patches/patch-ab +++ b/sysutils/whowatch/patches/patch-ab @@ -1,12 +1,48 @@ -$NetBSD: patch-ab,v 1.2 2000/08/11 23:49:06 itojun Exp $ -BSD curses: use strlen(s) on waddnstr(w, s, 0) -ncurses: print nothing on waddnstr(w, s, 0) -the code assumes ncurses behavior. be explicit about the requirement. ---- screen.c- Fri Aug 11 22:05:43 2000 -+++ screen.c Fri Aug 11 22:06:00 2000 -@@ -118,3 +118,4 @@ +$NetBSD: patch-ab,v 1.3 2000/10/16 01:34:39 wiz Exp $ + +--- screen.c.orig Tue Jun 6 20:53:24 2000 ++++ screen.c +@@ -6,6 +6,7 @@ + struct window info_win; + static chtype *curs_buf; + extern int screen_cols; ++int old_cur_vis = 1; /* this is the cursor mode, set to normal as default */ + + char *help_line[] = + { +@@ -38,7 +39,7 @@ + } + + wattrset(users_list.wd, A_BOLD); +- printf("\033[?25l"); /* disable cursor */ ++ old_cur_vis = curs_set(0); /* disable cursor */ + + start_color(); + init_pair(1,COLOR_CYAN,COLOR_BLACK); +@@ -58,6 +59,7 @@ + + cbreak(); + nodelay(stdscr,TRUE); ++ keypad(info_win.wd, TRUE); + scrollok(users_list.wd,TRUE); + noecho(); + } +@@ -67,7 +69,7 @@ + werase(help_win.wd); + wrefresh(help_win.wd); + endwin(); +- printf("\033[?25h"); /* enable cursor */ ++ curs_set(old_cur_vis); /* enable cursor */ + } + + void cursor_on(struct window *w, int line) +@@ -116,7 +118,8 @@ + if (i > w->cols) break; + if (*p < 17){ i--; - waddnstr(w->wd, q, p - q); + if (p - q != 0) + waddnstr(w->wd, q, p - q); wattrset(w->wd, COLOR_PAIR(*p)); + q = p + 1; + } diff --git a/sysutils/whowatch/patches/patch-ac b/sysutils/whowatch/patches/patch-ac index acab72222ce..9494e145727 100644 --- a/sysutils/whowatch/patches/patch-ac +++ b/sysutils/whowatch/patches/patch-ac @@ -1,26 +1,84 @@ -$NetBSD: patch-ac,v 1.1 2000/08/11 23:47:52 itojun Exp $ -UP/DOWN conflicts with some curses.h ---- whowatch.c- Fri Aug 11 22:06:36 2000 -+++ whowatch.c Fri Aug 11 22:07:02 2000 -@@ -22,3 +22,3 @@ +$NetBSD: patch-ac,v 1.2 2000/10/16 01:34:39 wiz Exp $ + +--- whowatch.c.orig Tue Jun 6 12:21:44 2000 ++++ whowatch.c +@@ -20,8 +20,7 @@ + #define ut_user ut_name + #endif -enum key { ENTER=0x100, UP, DOWN, LEFT, RIGHT, DELETE, ESC, CTRL_K, CTRL_I, -+enum key { ENTER=0x100, K_UP, K_DOWN, LEFT, RIGHT, DELETE, ESC, CTRL_K, CTRL_I, - PG_DOWN, PG_UP, HOME, END }; -@@ -346,4 +346,4 @@ - switch(c) { +- PG_DOWN, PG_UP, HOME, END }; ++enum key { ENTER=KEY_MAX + 1, ESC, CTRL_K, CTRL_I}; + + enum State{ USERS_LIST, PROC_TREE, INIT_TREE } state; + +@@ -334,30 +333,12 @@ + int read_key() + { + int c; +- c = getc(stdin); ++ c = wgetch(info_win.wd); + switch (c){ + case 0xD: + case 0xA: return ENTER; + case 0xB: return CTRL_K; + case 0x9: return CTRL_I; +- case 0x1B: +- getc(stdin); +- c = getc(stdin); +- switch(c) { - case 0x41: return UP; - case 0x42: return DOWN; -+ case 0x41: return K_UP; -+ case 0x42: return K_DOWN; - case 0x34: -@@ -476,3 +476,3 @@ +- case 0x34: +- case 0x38: +- case 0x46: return END; +- case 0x36: +- case 0x47: return PG_DOWN; +- case 0x31: +- case 0x37: +- case 0x48: return HOME; +- case 0x35: +- case 0x49: return PG_UP; +- } +- break; + default: + break; + } +@@ -420,6 +401,7 @@ + signal_sent = 0; + } + switch(key){ ++ case KEY_ENTER: + case ENTER: + werase(windows[state]->wd); + switch(state){ +@@ -462,23 +444,23 @@ + send_signal(9, pid); + tree_periodic(); + break; +- case PG_DOWN: ++ case KEY_NPAGE: + page_down(windows[state], rfrsh[state]); + break; +- case PG_UP: ++ case KEY_PPAGE: + page_up(windows[state], rfrsh[state]); + break; +- case HOME: ++ case KEY_HOME: + key_home(windows[state], rfrsh[state]); + break; +- case END: ++ case KEY_END: + key_end(windows[state], rfrsh[state]); break; - case UP: -+ case K_UP: ++ case KEY_UP: cursor_up(windows[state]); -@@ -480,3 +480,3 @@ + wrefresh(windows[state]->wd); break; - case DOWN: -+ case K_DOWN: ++ case KEY_DOWN: cursor_down(windows[state]); + wrefresh(windows[state]->wd); + break; -- cgit v1.2.3