Merge branch 'master' of https://git.savannah.gnu.org/git/nano into line-folding

This commit is contained in:
rexy712 2025-04-02 15:23:18 -07:00
commit 9a96973b00
61 changed files with 12959 additions and 12328 deletions

View File

@ -1,3 +1,52 @@
Changes between v8.3 and v8.4:
------------------------------
Benno Schulenberg (40):
bump version numbers and add a news item for the 8.4 release
copyright: update the years for the FSF
docs: add a suggestion to the FAQ on how to configure nano for git
docs: change two interface colors in the sample nanorc
docs: improve the description of the `constantshow` bindable function
docs: in the FAQ, replace an old item with an item about Byte Order Marks
docs: replace a word that is better not used in the plural
docs: use proper emdashes instead of double hyphens: "--" => "\(em"
execute: retain what the user typed before a tool was invoked
feedback: warn when the cursor sits on a Byte Order Mark (BOM)
gnulib: update to its current upstream state
input: adjust file browser and help viewer for changed bracketed pastes
input: implement bracketed pastes in a different manner
input: make bracketed paste more robust against loss of closing sequence
input: remove a special-case workaround
input: remove single-keycode detection from the bracketed-paste routine
input: robustness is good, but dropping a key code is not a good idea
input: wait a bit for "~" when bracketed-paste sequence is incomplete
prompt: accept tabs in an external paste as literal tabs
prompt: beep when an external paste contains a command code
syntax: groff: highlight the zeroeth macro argument too
syntax: man: highlight some escapes, like \& and \(em, specially
syntax: po: colorize also a 'msgctxt' line, and the 'c++-format' flag
syntax: po: colorize also format specifiers like "%.6f"
syntax: po: colorize also format specifiers like "%<PRIu64>"
syntax: po: colorize also Python's "%(name)x" format specifiers
syntax: po: colorize also the %llu and %hhi format specifiers
syntax: po: colorize also the Python-specific conversion specifier "%r"
tweaks: add a translator hint for the three changed file-writing prompts
tweaks: add missing closing quotes, as reported by `mandoc -T lint ...`
tweaks: avoid running tolower() on an out-of-range value
tweaks: change the man-page markup of options that take an argument
tweaks: condense a fragment of code
tweaks: consistently use "\fR" for switching back to normal, roman font
tweaks: prevent some color keywords from getting hyphenated in man page
tweaks: prevent some more keywords from getting hyphenated
tweaks: remove an unwanted newline from a debugging message
tweaks: remove three redundant pairs of parentheses from a nanorc regex
tweaks: remove two commented-out lines and two unused variables
tweaks: swap two fragments of code, to allow unwrapping a line
Brand Huntsman (1):
files: improve the wording of the normal file-writing prompts
Changes between v8.2 and v8.3:
------------------------------

6
NEWS
View File

@ -1,3 +1,9 @@
2025.04.02 - GNU nano 8.4 "Five Miles Out"
• Bracketed pastes over a slow connection are more reliable.
• Tabs in an external paste at a prompt are not dropped.
• Feedback occurs when the cursor sits on a Byte Order Mark.
• The Execute prompt is more forgiving of a typo.
2024.12.21 - GNU nano 8.3 "like mice in the dream of a tabby cat"
• A build failure with gcc-15 is fixed.
• Several translations were updated.

2
README
View File

@ -15,7 +15,7 @@ Appearance
In rough ASCII graphics, this is what nano's screen looks like:
____________________________________________________________________
| GNU nano 8.3 filename Modified |
| GNU nano 8.4 filename Modified |
--------------------------------------------------------------------
| This is the text window, displaying the contents of a 'buffer', |
| the contents of the file you are editing. |

View File

@ -2,7 +2,7 @@
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="4631e9b4d5d3bd5ba42864c7001cf3509a00c7b3"
gnulib_hash="f1daedcb4c6c653dfc2936847dfe55f5a076d94b"
modules="
canonicalize-lgpl

View File

@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see https://www.gnu.org/licenses/.
AC_INIT([GNU nano], [8.3], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [8.4], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.14])

View File

@ -45,13 +45,13 @@
<blockquote><p>
<a href="#4.1">4.1. Alt+Up does nothing on a Linux console. How can I make it scroll?</a><br>
<a href="#4.2">4.2. How can I make Ctrl+Shift+Left/Right select words on urxvt?</a><br>
<a href="#4.3">4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</a><br>
<a href="#4.3">4.3. How do I remove an unwanted Byte Order Mark?</a><br>
<a href="#4.4">4.4. With what keystroke can I paste text from the clipboard into nano?</a><br>
<a href="#4.5">4.5. How do I select text for or paste text from the clipboard when nano's mouse support is turned on?</a><br>
<a href="#4.6">4.6. When I paste text into a document, each line gets indented further than the last. Why? And how can I stop this?</a><br>
<a href="#4.7">4.7. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?</a><br>
<a href="#4.8">4.8. I've compiled nano with color support, but I don't see any color when I run it!</a><br>
<a href="#4.9">4.9. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
<a href="#4.9">4.9. How do I make nano my default editor (in Pine, mutt, git, ...)?</a><br>
</p></blockquote>
<h3><a href="#5">5. Internationalization</a></h3>
<blockquote><p>
@ -92,7 +92,7 @@
<h3 id="1.3">1.3. Why the name change from TIP?</h3>
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program &quot;establishes a full duplex terminal connection to a remote host&quot;, and was included with many older Unix systems (and newer ones like Solaris). The conflict was not noticed at first because there is no 'tip' utility included with most GNU/Linux distributions (where nano was developed).</p></blockquote>
<h3 id="1.4">1.4. What is the current version of nano?</h3>
<blockquote><p>The current version of nano <i>should</i> be <b>8.3</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<blockquote><p>The current version of nano <i>should</i> be <b>8.4</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<h3 id="1.5">1.5. I want to read the man page without having to download the program!</h3>
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="https://nano-editor.org/dist/latest/nano.1.html">here</a>.</p></blockquote>
<hr width="100%">
@ -219,8 +219,9 @@
URxvt.keysym.S-Page_Up: \033[5;2~
URxvt.keysym.S-Page_Down: \033[6;2~</pre>
<p>Then run <b>xrdb ~/.Xresources</b> and restart your urxvt terminal. Now <b>Ctrl+Shift+Left</b> and <b>Ctrl+Shift+Right</b> will select words, <b>Alt+Up</b> and <b>Alt+Down</b> will scroll the text without moving the cursor, and several such things more.</p></blockquote>
<h3 id="4.3">4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</h3>
<blockquote><p>You can use the <b>-K</b> or <b>--rawsequences</b> option on the command line, or add the line <b>set rawsequences</b> to your .nanorc. However, nano's mouse support will be disabled if you do any of these things.</p></blockquote>
<h3 id="4.3">4.3. How do I remove an unwanted Byte Order Mark?</h3>
<blockquote><p>To check whether a file contains a Byte Order Mark (BOM), open the file and type <b>Ctrl+Home</b>. If there is a BOM, the status bar will tell you so. Now type <b>Delete</b> to remove the BOM, and <b>^S</b> to save the file.</p>
<p>If you've accidentally deleted a Byte Order Mark from a file that needs it, and you want to restore it, then type: <b>Ctrl+Home Alt+V feff Enter</b>. Verify that the BOM is back with <b>Ctrl+Home</b>, and save the file with <b>^S</b>. (Note that on Unix, files should not contain a BOM.)</p></blockquote>
<h3 id="4.4">4.4. With what keystroke can I paste text from the clipboard into nano?</h3>
<blockquote><p>In most desktop environments <b>Shift+Insert</b> pastes the contents of the clipboard.</p></blockquote>
<h3 id="4.5">4.5. How do I select text for or paste text from the clipboard when nano's mouse support is turned on?</h3>
@ -233,11 +234,9 @@
<p><i>Update:</i> Since version 4.8, nano ignores linefeed characters in a paste (when your terminal understands <a href="https://en.wikipedia.org/wiki/Bracketed-paste">bracketed pastes</a>), so you no longer need the above workaround.</p></blockquote>
<h3 id="4.8">4.8. I've compiled nano with color support, but I don't see any color when I run it!</h3>
<blockquote><p>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 <b>syntax/</b> subdirectory of the nano source, which are normally installed to <b>/usr/local/share/nano/</b>. To enable all of them, uncomment the line <b># include "/usr/local/share/nano/*.nanorc"</b> in your nanorc. See also section <a href="#3.9">3.9</a>.</p></blockquote>
<h3 id="4.9">4.9. How do I make nano my default editor (in Pine, mutt, etc.)?</h3>
<h3 id="4.9">4.9. How do I make nano my default editor (in Pine, mutt, git, ...)?</h3>
<blockquote><p>You need to make nano your $EDITOR. If you want this to be saved, you should put a line like this in your <b>.bashrc</b> if you use bash (or <b>.zshrc</b> if you believe in zsh):</p>
<p class="indented"><b>export EDITOR=/usr/local/bin/nano</b></p>
<p>or, if you use tcsh, put this in your <b>.cshrc</b> file:</p>
<p class="indented"><b>setenv EDITOR /usr/local/bin/nano</b></p>
<p>Change /usr/local/bin/nano to wherever nano is installed on your system. Type &quot;which nano&quot; to find out. This will not take effect until the next time you log in. So log out and back in again.</p>
<p>Then, on top of that, if you use Pine, you must go into setup (type <b>S</b> at the main menu), and then configure (type <b>C</b>). Hit Enter on the lines that say:</p>
<p class="indented"><b>[ ] enable-alternate-editor-cmd</b><br>
@ -245,7 +244,10 @@
<p>Then exit (<b>E</b>) and select Yes (<b>Y</b>).</p>
<p>If you're a mutt user, you should see an effect immediately the next time you log in. No further configuration is needed. However, if you want to let people know you use nano to compose your email messages, you can put a line like this in your <b>.muttrc</b>:</p>
<p class="indented"><b>my_hdr X-Composer: nano-x.y</b></p>
<p>Again, replace x.y with the version of nano you use.</p></blockquote>
<p>Again, replace x.y with the version of nano you use.</p>
<p>To use nano to edit your git commit messages, you can run:</p>
<p class="indented"><b>git config --global core.editor "nano --guide=74 --nohelp +1"</b></p>
<p>Note the <b>+1</b> at the end — it makes nano start always at the top of the edit window. The guidestripe helps you keep the text within a reasonable width.</blockquote>
<hr width="100%">
<h1 id="5">5. Internationalization</h1>

View File

@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 8.3" "December 2024"
.TH NANO 1 "version 8.4" "April 2025"
.SH NAME
nano \- Nano's ANOther text editor, inspired by Pico

View File

@ -13,8 +13,8 @@ The complete manual for the GNU nano text editor.
@smallbook
@set EDITION 0.8
@set VERSION 8.3
@set UPDATED December 2024
@set VERSION 8.4
@set UPDATED April 2025
@dircategory Editors
@direntry
@ -29,7 +29,7 @@ The complete manual for the GNU nano text editor.
@title GNU @command{nano}
@subtitle a small and friendly text editor
@subtitle version 8.3
@subtitle version 8.4
@author Chris Allegretta
@ -79,7 +79,7 @@ For suggesting improvements: @email{nano-devel@@gnu.org}
@node Top
@top
This manual documents GNU @command{nano}, version 8.3.
This manual documents GNU @command{nano}, version 8.4.
@menu
* Introduction::

View File

@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 8.3" "December 2024"
.TH NANORC 5 "version 8.4" "April 2025"
.SH NAME
nanorc \- GNU nano's configuration file

View File

@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH RNANO 1 "version 8.3" "December 2024"
.TH RNANO 1 "version 8.4" "April 2025"
.SH NAME
rnano \- a restricted nano

View File

@ -224,9 +224,9 @@
# set statuscolor bold,white,green
# set errorcolor bold,white,red
# set spotlightcolor black,lightyellow
# set selectedcolor lightwhite,magenta
# set selectedcolor lightwhite,#804
# set stripecolor ,#444
# set scrollercolor cyan
# set scrollercolor slate,#222
# set numbercolor cyan
# set keycolor cyan
# set functioncolor green

625
po/bg.po

File diff suppressed because it is too large Load Diff

645
po/ca.po

File diff suppressed because it is too large Load Diff

676
po/cs.po

File diff suppressed because it is too large Load Diff

623
po/da.po

File diff suppressed because it is too large Load Diff

655
po/de.po

File diff suppressed because it is too large Load Diff

637
po/eo.po

File diff suppressed because it is too large Load Diff

634
po/es.po

File diff suppressed because it is too large Load Diff

625
po/eu.po

File diff suppressed because it is too large Load Diff

655
po/fi.po

File diff suppressed because it is too large Load Diff

633
po/fr.po

File diff suppressed because it is too large Load Diff

625
po/ga.po

File diff suppressed because it is too large Load Diff

623
po/gl.po

File diff suppressed because it is too large Load Diff

711
po/hr.po

File diff suppressed because it is too large Load Diff

637
po/hu.po

File diff suppressed because it is too large Load Diff

633
po/id.po

File diff suppressed because it is too large Load Diff

623
po/is.po

File diff suppressed because it is too large Load Diff

638
po/it.po

File diff suppressed because it is too large Load Diff

647
po/ja.po

File diff suppressed because it is too large Load Diff

623
po/ka.po

File diff suppressed because it is too large Load Diff

629
po/ko.po

File diff suppressed because it is too large Load Diff

656
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

637
po/nb.po

File diff suppressed because it is too large Load Diff

629
po/nl.po

File diff suppressed because it is too large Load Diff

633
po/pl.po

File diff suppressed because it is too large Load Diff

780
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

632
po/ro.po

File diff suppressed because it is too large Load Diff

623
po/ru.po

File diff suppressed because it is too large Load Diff

637
po/sk.po

File diff suppressed because it is too large Load Diff

625
po/sl.po

File diff suppressed because it is too large Load Diff

641
po/sq.po

File diff suppressed because it is too large Load Diff

623
po/sr.po

File diff suppressed because it is too large Load Diff

664
po/sv.po

File diff suppressed because it is too large Load Diff

623
po/tr.po

File diff suppressed because it is too large Load Diff

629
po/uk.po

File diff suppressed because it is too large Load Diff

623
po/vi.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
#!/bin/bash
VERSION="8.3"
VERSION="8.4"
./configure -C --enable-tiny && make && ./configure -C &&

View File

@ -483,14 +483,7 @@ char *browse(char *path)
continue;
}
#endif /* ENABLE_MOUSE */
#ifndef NANO_TINY
while (bracketed_paste)
kbinput = get_kbinput(midwin, BLIND);
if (kbinput == BRACKETED_PASTE_MARKER) {
beep();
continue;
}
#endif
function = interpret(kbinput);
if (function == do_help || function == full_refresh) {
@ -641,6 +634,10 @@ char *browse(char *path)
implant(first_sc_for(MBROWSER, function)->expansion);
#endif
#ifndef NANO_TINY
} else if (kbinput == START_OF_PASTE) {
while (get_kbinput(midwin, BLIND) != END_OF_PASTE)
;
statusline(AHEM, _("Paste is ignored"));
} else if (kbinput == THE_WINDOW_RESIZED) {
; /* Gets handled below. */
#endif

View File

@ -205,8 +205,6 @@
#define SHIFT_ALT_RIGHT 0x432
#define SHIFT_ALT_UP 0x433
#define SHIFT_ALT_DOWN 0x434
//#define SHIFT_LEFT 0x451
//#define SHIFT_RIGHT 0x452
#define SHIFT_UP 0x453
#define SHIFT_DOWN 0x454
#define SHIFT_HOME 0x455
@ -219,6 +217,10 @@
#define FOCUS_IN 0x491
#define FOCUS_OUT 0x499
/* Custom keycodes for signaling the start and end of a bracketed paste. */
#define START_OF_PASTE 0x4B5
#define END_OF_PASTE 0x4BE
/* 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. */
@ -235,9 +237,6 @@
#define THE_WINDOW_RESIZED 0x4F7
#endif
/* A special keycode to signal the beginning and end of a bracketed paste. */
#define BRACKETED_PASTE_MARKER 0x4FB
/* A special keycode for when a key produces an unknown escape sequence. */
#define FOREIGN_SEQUENCE 0x4FC

View File

@ -1198,6 +1198,12 @@ void insert_a_file_or(bool execute)
/* Reset the flag that is set by the Spell Checker and Linter and such. */
ran_a_tool = FALSE;
#ifndef NANO_TINY
/* If something was typed at the Execute prompt without being run, restore it. */
if (execute && *foretext)
given = mallocstrcpy(given, foretext);
#endif
while (TRUE) {
#ifndef NANO_TINY
if (execute) {
@ -2157,8 +2163,8 @@ int write_it_out(bool exiting, bool withprompt)
(method == APPEND) ? _("Append Selection to File") :
_("Write Selection to File");
else if (method != OVERWRITE)
msg = (method == PREPEND) ? _("Prepend to File") :
_("Append to File");
/* TRANSLATORS: Next three prompts are analogous to the above three. */
msg = (method == PREPEND) ? _("Prepend to File") : _("Append to File");
else
#endif
msg = _("Write to File");

View File

@ -43,8 +43,6 @@ bool shift_held;
/* Whether Shift was being held together with a movement key. */
bool mute_modifiers = FALSE;
/* Whether to ignore modifier keys while running a macro or string bind. */
bool bracketed_paste = FALSE;
/* Whether text is being pasted into nano from outside. */
bool we_are_running = FALSE;
/* Becomes TRUE as soon as all options and files have been read. */
@ -52,8 +50,13 @@ bool more_than_one = FALSE;
/* Whether more than one buffer is or has been open. */
bool report_size = TRUE;
/* Whether to show the number of lines when the minibar is used. */
bool ran_a_tool = FALSE;
/* Whether a tool has been run at the Execute-Command prompt. */
#ifndef NANO_TINY
char *foretext = NULL;
/* What was typed at the Execute prompt before invoking a tool. */
#endif
bool inhelp = FALSE;
/* Whether we are in the help viewer. */
@ -100,7 +103,7 @@ int controlleft, controlright, controlup, controldown;
int controlhome, controlend;
#ifndef NANO_TINY
int controldelete, controlshiftdelete;
int shiftleft, shiftright, shiftup, shiftdown;
int shiftup, shiftdown;
int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown;
int shiftcontrolhome, shiftcontrolend;
int altleft, altright, altup, altdown;
@ -475,11 +478,6 @@ const keystruct *get_shortcut(const int keycode)
if (meta_key && keycode < 0x20)
return NULL;
#ifndef NANO_TINY
/* During a paste at a prompt, ignore all command keycodes. */
if (bracketed_paste && keycode != BRACKETED_PASTE_MARKER)
return NULL;
#endif
#ifdef ENABLE_NANORC
if (keycode == PLANTED_A_COMMAND)
return planted_shortcut;
@ -1591,8 +1589,9 @@ void shortcut_init(void)
add_to_sclist((MMOST & ~MMAIN) | MYESNO, "", KEY_CANCEL, do_cancel, 0);
add_to_sclist(MMAIN, "", KEY_CENTER, do_center, 0);
add_to_sclist(MMAIN, "", KEY_SIC, do_insertfile, 0);
/* Catch and ignore bracketed paste marker keys. */
add_to_sclist(MMOST|MBROWSER|MHELP|MYESNO, "", BRACKETED_PASTE_MARKER, do_nothing, 0);
add_to_sclist(MMAIN, "", START_OF_PASTE, suck_up_input_and_paste_it, 0);
add_to_sclist(MMOST, "", START_OF_PASTE, do_nothing, 0);
add_to_sclist(MMOST, "", END_OF_PASTE, do_nothing, 0);
#else
add_to_sclist(MMOST|MBROWSER|MHELP|MYESNO, "", KEY_FRESH, full_refresh, 0);
#endif

View File

@ -476,13 +476,6 @@ void show_help(void)
#ifndef NANO_TINY
spotlighted = FALSE;
while (bracketed_paste)
kbinput = get_kbinput(midwin, BLIND);
if (kbinput == BRACKETED_PASTE_MARKER) {
beep();
continue;
}
#endif
function = interpret(kbinput);
@ -511,6 +504,10 @@ void show_help(void)
get_mouseinput(&dummy_row, &dummy_col, TRUE);
#endif
#ifndef NANO_TINY
} else if (kbinput == START_OF_PASTE) {
while (get_kbinput(midwin, BLIND) != END_OF_PASTE)
;
statusline(AHEM, _("Paste is ignored"));
} else if (kbinput == THE_WINDOW_RESIZED) {
; /* Nothing to do. */
#endif

View File

@ -1446,25 +1446,25 @@ void suck_up_input_and_paste_it(void)
linestruct *was_cutbuffer = cutbuffer;
linestruct *line = make_new_node(NULL);
size_t index = 0;
int input = ERR;
line->data = copy_of("");
cutbuffer = line;
while (bracketed_paste) {
int input = get_kbinput(midwin, BLIND);
while (TRUE) {
input = get_kbinput(midwin, BLIND);
if (input == '\r' || input == '\n') {
if ((0x20 <= input && input <= 0xFF && input != DEL_CODE) || input == '\t') {
line->data = nrealloc(line->data, index + 2);
line->data[index++] = (char)input;
line->data[index] = '\0';
} else if (input == '\r' || input == '\n') {
line->next = make_new_node(line);
line = line->next;
line->data = copy_of("");
index = 0;
} else if ((0x20 <= input && input <= 0xFF && input != DEL_CODE) ||
input == '\t') {
line->data = nrealloc(line->data, index + 2);
line->data[index++] = (char)input;
line->data[index] = '\0';
} else if (input != BRACKETED_PASTE_MARKER)
beep();
} else
break;
}
if (ISSET(VIEW_MODE))
@ -1472,6 +1472,9 @@ void suck_up_input_and_paste_it(void)
else
paste_text();
if (input != END_OF_PASTE)
statusline(ALERT, _("Flawed paste"));
free_lines(cutbuffer);
cutbuffer = was_cutbuffer;
}
@ -1728,9 +1731,6 @@ void process_a_keystroke(void)
} else if (openfile->current != was_current)
also_the_last = FALSE;
if (bracketed_paste)
suck_up_input_and_paste_it();
if (ISSET(STATEFLAGS) && openfile->mark != was_mark)
titlebar(NULL);
#endif
@ -2392,6 +2392,9 @@ int main(int argc, char **argv)
whitelen[1] = 1;
}
}
/* Initialize a special stash for something typed at the Execute prompt. */
foretext = copy_of("");
#endif /* !NANO_TINY */
/* Initialize the search string. */
@ -2483,6 +2486,10 @@ int main(int argc, char **argv)
shiftaltright = get_keycode("kRIT4", SHIFT_ALT_RIGHT);
shiftaltup = get_keycode("kUP4", SHIFT_ALT_UP);
shiftaltdown = get_keycode("kDN4", SHIFT_ALT_DOWN);
/* Tell ncurses to transform bracketed-paste sequences into keycodes. */
define_key("\e[200~", START_OF_PASTE);
define_key("\e[201~", END_OF_PASTE);
#endif
mousefocusin = get_keycode("kxIN", FOCUS_IN);
mousefocusout = get_keycode("kxOUT", FOCUS_OUT);
@ -2684,6 +2691,16 @@ int main(int argc, char **argv)
as_an_at = TRUE;
#if defined(ENABLE_UTF8) && !defined(NANO_TINY)
#define byte(n) (unsigned char)openfile->current->data[n]
/* Tell the user when the cursor sits on a BOM. */
if (openfile->current_x == 0 && byte(0) == 0xEF && byte(1) == 0xBB &&
byte(2) == 0xBF && using_utf8()) {
statusline(NOTICE, _("Byte Order Mark"));
set_blankdelay_to_one();
}
#endif
if ((refresh_needed && LINES > 1) || (LINES == 1 && lastmessage <= HUSH))
edit_refresh();
else

View File

@ -261,7 +261,7 @@ void absorb_character(int input, functionptrtype function)
* Apart from that, only accept input when not in restricted mode, or when
* not at the "Write File" prompt, or when there is no filename yet. */
if (!function) {
if (input < 0x20 || input > 0xFF || meta_key)
if ((input < 0x20 && input != '\t') || meta_key || input > 0xFF)
beep();
else if (!ISSET(RESTRICTED) || currmenu != MWRITEFILE ||
openfile->filename[0] == '\0') {
@ -426,6 +426,9 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
size_t fragment_length = 0;
/* The length of the fragment that the user tries to tab complete. */
#endif
#endif
#ifndef NANO_TINY
bool bracketed_paste = FALSE;
#endif
const keystruct *shortcut;
functionptrtype function;
@ -450,6 +453,8 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
#endif
return NULL;
}
if (input == START_OF_PASTE || input == END_OF_PASTE)
bracketed_paste = (input == START_OF_PASTE);
#endif
#ifdef ENABLE_MOUSE
/* For a click on a shortcut, read in the resulting keycode. */
@ -462,10 +467,23 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
/* Check for a shortcut in the current list. */
shortcut = get_shortcut(input);
function = (shortcut ? shortcut->func : NULL);
#ifndef NANO_TINY
/* Tabs in an external paste are not commands. */
if (input == '\t' && bracketed_paste)
function = NULL;
#endif
/* When it's a normal character, add it to the answer. */
absorb_character(input, function);
#ifndef NANO_TINY
/* Ignore any commands inside an external paste. */
if (bracketed_paste) {
if (function && function != do_nothing)
beep();
continue;
}
#endif
if (function == do_cancel || function == do_enter)
break;
@ -538,6 +556,11 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
else if (function && !handle_editing(function)) {
/* When it's a permissible shortcut, run it and done. */
if (!ISSET(VIEW_MODE) || !changes_something(function)) {
#ifndef NANO_TINY
/* When invoking a tool at the Execute prompt, stash an "answer". */
if (currmenu == MEXECUTE)
foretext = mallocstrcpy(foretext, answer);
#endif
function();
break;
} else
@ -549,6 +572,11 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
#endif
}
#ifndef NANO_TINY
/* When an external command was run, clear a possibly stashed answer. */
if (currmenu == MEXECUTE && function == do_enter)
*foretext = '\0';
#endif
#ifdef ENABLE_HISTORIES
/* If the history pointer was moved, point it at the bottom again. */
if (stored_string != NULL) {
@ -701,10 +729,11 @@ int ask_user(bool withall, const char *question)
continue;
/* Accept first character of an external paste and ignore the rest. */
if (bracketed_paste)
if (kbinput == START_OF_PASTE) {
kbinput = get_kbinput(footwin, BLIND);
while (bracketed_paste)
get_kbinput(footwin, BLIND);
while (get_kbinput(footwin, BLIND) != END_OF_PASTE)
;
}
#endif
#ifdef ENABLE_NLS

View File

@ -32,12 +32,13 @@ extern bool shifted_metas;
extern bool meta_key;
extern bool shift_held;
extern bool mute_modifiers;
extern bool bracketed_paste;
extern bool we_are_running;
extern bool more_than_one;
extern bool report_size;
extern bool ran_a_tool;
extern char *foretext;
extern bool inhelp;
extern char *title;
@ -68,7 +69,6 @@ extern int controlup, controldown;
extern int controlhome, controlend;
#ifndef NANO_TINY
extern int controldelete, controlshiftdelete;
extern int shiftleft, shiftright;
extern int shiftup, shiftdown;
extern int shiftcontrolleft, shiftcontrolright;
extern int shiftcontrolup, shiftcontroldown;
@ -441,6 +441,7 @@ void confirm_margin(void);
#endif
void unbound_key(int code);
bool changes_something(functionptrtype f);
void suck_up_input_and_paste_it(void);
void inject(char *burst, size_t count);
/* Most functions in prompt.c. */

View File

@ -353,7 +353,7 @@ void read_keys_from(WINDOW *frame)
nodelay(frame, FALSE);
#ifdef DEBUG
fprintf(stderr, "\nSequence of hex codes:");
fprintf(stderr, "Sequence of hex codes:");
for (size_t i = 0; i < waiting_codes; i++)
fprintf(stderr, " %3x", key_buffer[i]);
fprintf(stderr, "\n");
@ -777,19 +777,10 @@ int convert_CSI_sequence(const int *seq, size_t length, int *consumed)
/* Esc [ 2 0 0 ~ == start of a bracketed paste,
* Esc [ 2 0 1 ~ == end of a bracketed paste. */
*consumed = 4;
if (seq[2] == '0') {
bracketed_paste = TRUE;
return BRACKETED_PASTE_MARKER;
} else if (seq[2] == '1') {
bracketed_paste = FALSE;
return BRACKETED_PASTE_MARKER;
}
return (seq[2] == '0') ? START_OF_PASTE : END_OF_PASTE;
} else {
/* When invalid, assume it's a truncated end-of-paste sequence,
* in order to avoid a hang -- https://sv.gnu.org/bugs/?64996. */
bracketed_paste = FALSE;
*consumed = length;
return ERR;
return FOREIGN_SEQUENCE;
}
#endif
break;

View File

@ -22,8 +22,8 @@ color brightblue "^(msgid|msgid_plural|msgstr)\>"
color red " fuzzy(,|$)"
color yellow " (no-)?([a-z-]+|c\+\+)-format(,|$)"
# Format specifiers.
color brightmagenta "%([1-9]\$)?[#0 +'I-]?(\*([1-9]\$)?|[1-9](\.[0-9]?)?)?(hh|ll|[hlLjzt])?[diouxXeEfFgGaAcspnmr]|%%"
color rosy "%\([[:alpha:]][[:alnum:]_]*\)([1-9](\.[0-9])?)?[#0 +-]?[diouxXeEfFgGcrs]"
color brightmagenta "%([1-9]\$)?[#0 +'I-]?(\*([1-9]\$)?|[0-9]\.?|[0-9]?\.[0-9])?(hh|ll|[hlLjzt])?([diouxXeEfFgGaAcspnmr]|<PRI[diouxX](32|64)>)|%%"
color rosy "%\([[:alpha:]][[:alnum:]_]*\)([0-9]\.?|[0-9]?\.[0-9])?[#0 +-]?[diouxXeEfFgGcrs]"
# Quotes and escaped characters.
color yellow """
color cyan "\\([abcefnrtv"\]|x[[:xdigit:]]{2}|[0-7]{3})"