nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 051fc6e05a65edaa87e91f2394e7f918e73f1066
parent 88520c93be59ea8696974d12d2bb07a995c3cc9f
Author: Chris Allegretta <chrisa@asty.org>
Date:   Sat,  5 May 2001 23:17:36 +0000

Added file clicking ability in file browser


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@640 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

Diffstat:
MChangeLog | 4++--
MTODO | 2+-
Mfiles.c | 37+++++++++++++++++++++++++++++++++++--
3 files changed, 38 insertions(+), 5 deletions(-)

diff --git 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 @@ -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 @@ -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