diff --git a/doc/man/nanorc.5 b/doc/man/nanorc.5 index 801f7f5b92c10f96701cab7b17b2ebc8f73fa53b..053c9fe232f513d2d4c998b75963cc6f500e5b5d 100644 --- a/doc/man/nanorc.5 +++ b/doc/man/nanorc.5 @@ -200,6 +200,10 @@ won't work properly with this option enabled. .B set regexp Do extended regular expression searches by default. .TP +.B set showcursor +Put the cursor on the highlighted item in the file browser, to aid +braille users. +.TP .B set smarthome Make the Home key smarter. When Home is pressed anywhere but at the very beginning of non-whitespace characters on a line, the cursor will diff --git a/doc/nanorc.sample.in b/doc/nanorc.sample.in index 6c5689977e41a8d6acc3290fd1f1be527a420973..cc08e79361b8510b90416d8a753c02a51cd0c770 100644 --- a/doc/nanorc.sample.in +++ b/doc/nanorc.sample.in @@ -138,6 +138,10 @@ ## Do extended regular expression searches by default. # set regexp +## Put the cursor on the highlighted item in the file browser; +## useful for people who use a braille display. +# set showcursor + ## Make the Home key smarter. When Home is pressed anywhere but at the ## very beginning of non-whitespace characters on a line, the cursor ## will jump to that beginning (either forwards or backwards). If the diff --git a/doc/syntax/nanorc.nanorc b/doc/syntax/nanorc.nanorc index 3d2e353c7939a39716b3258502f781cf5a813f06..762674ee0ef5bff0db5477683bd3e35718f5d53e 100644 --- a/doc/syntax/nanorc.nanorc +++ b/doc/syntax/nanorc.nanorc @@ -7,7 +7,7 @@ comment "#" icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|comment|magic|linter|i?color|extendsyntax).*$" # Keywords -icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|const(antshow)?|cut|fill|historylog|justifytrim|locking|morespace|mouse|multibuffer|noconvert|nohelp|nonewlines|nowrap|pos(ition)?log|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|suspend|tabsize|tabstospaces|tempfile|unix|view|wordbounds)\>" +icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|const(antshow)?|cut|fill|historylog|justifytrim|locking|morespace|mouse|multibuffer|noconvert|nohelp|nonewlines|nowrap|pos(ition)?log|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize|tabstospaces|tempfile|unix|view|wordbounds)\>" icolor yellow "^[[:space:]]*set[[:space:]]+(functioncolor|keycolor|statuscolor|titlecolor)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>" icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|functioncolor|keycolor|matchbrackets|operatingdir|punct|quotestr|speller|statuscolor|titlecolor|whitespace)[[:space:]]+" icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^|M-)([[:alpha:]]|space|[]]|[0-9^_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]+(all|main|search|replace(2|with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)" diff --git a/doc/texinfo/nano.texi b/doc/texinfo/nano.texi index b870fa3dedb7bef928ea69a902c55e929a7d2dc1..d4f64265186805e8d6bb1d1d626ad9993cdff984 100644 --- a/doc/texinfo/nano.texi +++ b/doc/texinfo/nano.texi @@ -782,6 +782,10 @@ won't work properly with this option enabled. @item set regexp Do extended regular expression searches by default. +@item set showcursor +Put the cursor on the highlighted item in the file browser, to aid +braille users. + @item set smarthome Make the Home key smarter. When Home is pressed anywhere but at the very beginning of non-whitespace characters on a line, the cursor will diff --git a/src/browser.c b/src/browser.c index f4cd3fe3df08b4eebb59534735a0510967062fa2..8ccf1723f49401db3d8dfe6418bd80fcf3a80e3b 100644 --- a/src/browser.c +++ b/src/browser.c @@ -502,6 +502,8 @@ void browser_refresh(void) size_t i; int line = 0, col = 0; /* The current line and column while the list is getting displayed. */ + int the_line = 0, the_column = 0; + /* The line and column of the selected item. */ char *info; /* The additional information that we'll display about a file. */ @@ -536,9 +538,13 @@ void browser_refresh(void) * "(dir)", or the file size, plus three columns for the * ellipsis. */ - /* Start highlighting the currently selected file or directory. */ - if (i == selected) + /* If this is the selected item, start its highlighting, and + * remember its location to be able to place the cursor on it. */ + if (i == selected) { wattron(edit, hilite_attribute); + the_line = line; + the_column = col; + } blank_line(edit, line, col, longest); @@ -610,7 +616,7 @@ void browser_refresh(void) mvwaddstr(edit, line, col - infolen, info); - /* Finish highlighting the currently selected file or directory. */ + /* If this is the selected item, finish its highlighting. */ if (i == selected) wattroff(edit, hilite_attribute); @@ -629,6 +635,12 @@ void browser_refresh(void) wmove(edit, line, col); } + /* If requested, put the cursor on the selected item and switch it on. */ + if (ISSET(SHOW_CURSOR)) { + wmove(edit, the_line, the_column); + curs_set(1); + } + wnoutrefresh(edit); } diff --git a/src/nano.h b/src/nano.h index 4e31f34d44135b9933527f6edd1b9d108b28fc3d..474e8c279eb2efaf6f174bcdb32d4b48996f95cc 100644 --- a/src/nano.h +++ b/src/nano.h @@ -535,7 +535,8 @@ enum LOCKING, NOREAD_MODE, MAKE_IT_UNIX, - JUSTIFY_TRIM + JUSTIFY_TRIM, + SHOW_CURSOR }; /* Flags for the menus in which a given function should be present. */ diff --git a/src/rcfile.c b/src/rcfile.c index 1b1b5d316d703b03a5a6beae86046070693d1652..b078f0316163cdbc2eb84807cba7364de131633d 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -96,6 +96,7 @@ static const rcoption rcopts[] = { {"noconvert", NO_CONVERT}, {"quickblank", QUICK_BLANK}, {"quiet", QUIET}, + {"showcursor", SHOW_CURSOR}, {"smarthome", SMART_HOME}, {"smooth", SMOOTH_SCROLL}, {"softwrap", SOFTWRAP},