diff --git a/doc/man/nanorc.5 b/doc/man/nanorc.5 index 801f7f5b..053c9fe2 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 6c568997..cc08e793 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 3d2e353c..762674ee 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 b870fa3d..d4f64265 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 f4cd3fe3..8ccf1723 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 4e31f34d..474e8c27 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 1b1b5d31..b078f031 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},