From: Chris Allegretta Date: Sat, 5 May 2001 23:17:36 +0000 (+0000) Subject: Added file clicking ability in file browser X-Git-Tag: v1.1.0~61 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=051fc6e05a65edaa87e91f2394e7f918e73f1066;p=nano.git Added file clicking ability in file browser git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@640 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index e23ea10c..a52feaeb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,8 @@ Cvs code - - General - New global variables currshortcut and currslen to support using - the mouse with the shortcuts. FIXME - Does not support clicking - on filenames in the browser, yet. + the mouse with the shortcuts. Also supports clicking on files + in browser. - Changed mouse disabling code from depending on --enable-tiny to its own flag, --disable-mouse. The --tiny option defines this automatically, but now just mouse support can be disabled diff --git a/TODO b/TODO index 62cc7fdc..55828c87 100644 --- a/TODO +++ b/TODO @@ -28,7 +28,7 @@ For Next Version: - Implement Pico's -j and -g flags, as they are pretty easy to do. - Make mouse support work with clicking on the shortcuts (-m). Must make global variable pointing to current shortcut list to determine what - keystroke to ungetch(). + keystroke to ungetch(). [DONE]. - Implement -o (chroot of sorts) $Id$ diff --git a/files.c b/files.c index 51cb2051..28fd5bbd 100644 --- a/files.c +++ b/files.c @@ -1139,6 +1139,11 @@ char *do_browser(char *inpath) int col = 0, selected = 0, editline = 0, width = 0, filecols = 0; int lineno = 0, kb; char **filelist = (char **) NULL; +#ifndef DISABLE_MOUSE +#ifdef NCURSES_MOUSE_VERSION + MEVENT mevent; +#endif +#endif currshortcut = browser_list; currslen = BROWSER_LIST_LEN; @@ -1186,10 +1191,38 @@ char *do_browser(char *inpath) switch (kbinput) { -#ifndef NANO_SMALL +#ifndef DISABLE_MOUSE #ifdef NCURSES_MOUSE_VERSION case KEY_MOUSE: - do_mouse(); + if (getmouse(&mevent) == ERR) + return retval; + + /* If they clicked in the edit window, they probably clicked + on a file */ + if (wenclose(edit, mevent.y, mevent.x)) { + int selectedbackup = selected; + + mevent.y -= 2; + + /* If we're on line 0, don't toy with finding out what + page we're on */ + if (lineno / editwinrows == 0) + selected = mevent.y * width + mevent.x / longest; + else + selected = (lineno / editwinrows) * editwinrows * width + + mevent.y * width + mevent.x / longest; + + /* If we're off the screen, reset to the last item. + If we clicked where we did last time, select this name! */ + if (selected >= numents - 1) + selected = numents - 1; + else if (selectedbackup == selected) { + ungetch('s'); /* Unget the 'select' key */ + break; + } + } else /* Must be clicking a shortcut */ + do_mouse(); + break; #endif #endif