From: NeilBrown Date: Thu, 15 Nov 2012 05:09:13 +0000 (+1100) Subject: vpatch: add mouse support for main window. X-Git-Tag: v1.0~72 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=24eb40c48122f869974ee0cecd8d4345e4ce2208;p=wiggle.git vpatch: add mouse support for main window. Clicking on a line will cause that file or folder to be opened. Signed-off-by: NeilBrown --- diff --git a/vpatch.c b/vpatch.c index 3895562..49f42c5 100644 --- a/vpatch.c +++ b/vpatch.c @@ -2439,6 +2439,7 @@ static void main_window(struct plist *pl, int *np, FILE *f, int reverse, int cnt; /* count of files that need saving */ int any; /* count of files that have been save*/ int ans; + MEVENT mevent; freopen("/dev/null","w",stderr); term_init(); @@ -2500,7 +2501,7 @@ static void main_window(struct plist *pl, int *np, FILE *f, int reverse, } else { /* debugging help: report last keystroke */ char bb[30]; - sprintf(bb, "last-key = %d", c); + sprintf(bb, "last-key = 0%o", c); attrset(0); last_mesg_len = strlen(bb); mvaddstr(0, cols - last_mesg_len, bb); @@ -2531,6 +2532,24 @@ static void main_window(struct plist *pl, int *np, FILE *f, int reverse, } break; + case KEY_MOUSE: + if (getmouse(&mevent) != OK) + break; + while (row < mevent.y && + (tpos = get_next(pos, pl, *np, mode, f, reverse)) + >= 0) { + pos = tpos; + row++; + } + while (row > mevent.y && + (tpos = get_prev(pos, pl, *np, mode)) >= 0) { + pos = tpos; + row--; + } + if (row != mevent.y) + /* couldn't find the line */ + break; + /* FALL THROUGH */ case ' ': case 13: if (pl[pos].end == 0) {