diff --git a/doc/faq.html b/doc/faq.html index bf32fbd4..7928aa48 100644 --- a/doc/faq.html +++ b/doc/faq.html @@ -222,10 +222,10 @@

Try holding down the Shift key and selecting or pasting the text as you normally would.

4.6. When I paste text into a document, each line gets indented further than the last. Why? And how can I stop this?

You have the autoindent feature turned on. Hit Meta-I to turn it off, paste your text, and then hit Meta-I again to turn it back on.

-

Update: Since version 4.8, nano will suppress auto-indentation during a paste, so you no longer need to toggle it off and on manually.

+

Update: Since version 4.8, nano will suppress auto-indentation during a paste (when your terminal understands bracketed pastes), so you no longer need to toggle it off and on manually.

4.7. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?

When pasting from Windows, in some situations linefeeds are sent instead of carriage returns (Enters). And linefeeds are ^Js, which make nano justify (rewrap) the current paragraph. To prevent these linefeeds from causing these unwanted justifications, add this line to your .nanorc on the remote Linux box: unbind ^J main or bind ^J enter main, depending on whether the paste contains CR + LF or only LF.

-

Update: Since version 4.8, nano will ignore linefeed characters in a paste, so you no longer need the above workaround.

+

Update: Since version 4.8, nano will ignore linefeed characters in a paste (when your terminal understands bracketed pastes), so you no longer need the above workaround.

4.8. I've compiled nano with color support, but I don't see any color when I run it!

If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Several example configurations are in the syntax/ subdirectory of the nano source, which are normally installed to /usr/local/share/nano/. To enable all of them, uncomment the line # include "/usr/local/share/nano/*.nanorc" in your nanorc. See also section 3.9.

4.9. How do I make nano my default editor (in Pine, mutt, etc.)?

diff --git a/src/browser.c b/src/browser.c index d569bb43..e5a4047c 100644 --- a/src/browser.c +++ b/src/browser.c @@ -436,7 +436,10 @@ char *browse(char *path) titlebar(path); - while (TRUE) { + if (list_length == 0) { + statusline(ALERT, _("No entries")); + napms(1200); + } else while (TRUE) { functionptrtype function; int kbinput; diff --git a/src/definitions.h b/src/definitions.h index ef5791de..b56034be 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -214,6 +214,9 @@ #define SHIFT_DELETE 0x45D #define SHIFT_TAB 0x45F +#define FOCUS_IN 0x491 +#define FOCUS_OUT 0x499 + /* Special keycodes for when a string bind has been partially implanted * or has an unpaired opening brace, or when a function in a string bind * needs execution or a specified function name is invalid. */ diff --git a/src/global.c b/src/global.c index fa6f31b1..c2ef1778 100644 --- a/src/global.c +++ b/src/global.c @@ -107,6 +107,7 @@ int altpageup, altpagedown; int altinsert, altdelete; int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown; #endif +int mousefocusin, mousefocusout; #ifdef ENABLED_WRAPORJUSTIFY ssize_t fill = -COLUMNS_FROM_EOL; diff --git a/src/nano.c b/src/nano.c index 783f2997..5f09d3a1 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2434,6 +2434,8 @@ int main(int argc, char **argv) shiftaltup = get_keycode("kUP4", SHIFT_ALT_UP); shiftaltdown = get_keycode("kDN4", SHIFT_ALT_DOWN); #endif + mousefocusin = get_keycode("kxIN", FOCUS_IN); + mousefocusout = get_keycode("kxOUT", FOCUS_OUT); #ifdef HAVE_SET_ESCDELAY /* Tell ncurses to pass the Esc key quickly. */ diff --git a/src/prototypes.h b/src/prototypes.h index 66449b49..6d34b98b 100644 --- a/src/prototypes.h +++ b/src/prototypes.h @@ -80,6 +80,7 @@ extern int altinsert, altdelete; extern int shiftaltleft, shiftaltright; extern int shiftaltup, shiftaltdown; #endif +extern int mousefocusin, mousefocusout; #ifdef ENABLED_WRAPORJUSTIFY extern ssize_t fill; diff --git a/src/rcfile.c b/src/rcfile.c index 9e09f5f4..062fba55 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -991,16 +991,22 @@ void parse_includes(char *ptr) } /* Return the index of the color that is closest to the given RGB levels, - * assuming that the terminal uses the 6x6x6 color cube of xterm-256color. */ + * assuming that the terminal uses the 6x6x6 color cube of xterm-256color. + * When red == green == blue, return an index in the xterm gray scale. */ short closest_index_color(short red, short green, short blue) { - /* Translation table, from 16 intended levels to 6 available levels. */ + /* Translation table, from 16 intended color levels to 6 available levels. */ static const short level[] = { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 }; - if (COLORS == 256) - return (36 * level[red] + 6 * level[green] + level[blue] + 16); - else + /* Translation table, from 14 intended gray levels to 24 available levels. */ + static const short gray[] = { 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 15, 18, 21, 23 }; + + if (COLORS != 256) return THE_DEFAULT; + else if (red == green && green == blue && 0 < red && red < 0xF) + return 232 + gray[red - 1]; + else + return (36 * level[red] + 6 * level[green] + level[blue] + 16); } #define COLORCOUNT 34 diff --git a/src/winio.c b/src/winio.c index 8c1c4c34..f6fa2d89 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1294,6 +1294,10 @@ int parse_kbinput(WINDOW *frame) return INDENT_KEY; #endif + /* Spurious codes from VTE -- see https://sv.gnu.org/bugs/?64578. */ + if (keycode == mousefocusin || keycode == mousefocusout) + return ERR; + switch (keycode) { case KEY_SLEFT: shift_held = TRUE;