Compare commits

..

2130 Commits
v2.9.5 ... v5.2

Author SHA1 Message Date
Benno Schulenberg
070c9c60ec po: update translations and regenerate POT file and PO files 2020-08-24 11:08:23 +02:00
Benno Schulenberg
63ac050733 bump version numbers and add a news item for the 5.2 release 2020-08-24 09:53:07 +02:00
Benno Schulenberg
3ade8b29cc build: stop distributing the README.GIT file
There is no need for normal users to build from git.  Do not give
the impression that that procedure is in any way recommended.
2020-08-24 09:29:05 +02:00
Benno Schulenberg
51a6d5897e gnulib: back away from a commit that causes trouble when using clang
The issue has been reported here:
  https://lists.gnu.org/archive/html/bug-gnulib/2020-08/msg00202.html
2020-08-23 10:52:20 +02:00
Benno Schulenberg
785d28d5d1 gnulib: update to its current upstream state 2020-08-23 09:10:35 +02:00
Benno Schulenberg
4873cc26f2 build: stop mentioning Slang in two ./configure messages
Nobody ought to be using Slang, so don't give people the wrong
impression by mentioning it (and even mentioning it *first*).
2020-08-23 09:05:47 +02:00
Benno Schulenberg
0f8423eb4c tweaks: elide an unneeded variable
Storing the orientation of the marked region beforehand is not needed,
as this orientation is readily available also after the justification.

(By the way, cursor and mark need to be swapped after justifying
a backward-marked region because the rule is that the cursor gets
placed *after* the justified paragraph.  Maybe that should change?)
2020-08-22 19:35:48 +02:00
Benno Schulenberg
b60fec5db3 history: do not interpret a failing stat() as an error
The most likely reason for stat() returning -1 is that the file
does not exist.  And an absent positionlog file is not an error.
(In some cases it is, like immediately after writing the file,
but even then we don't want to complain, because it may have
been some other process that deleted the file straightaway.)

This fixes https://savannah.gnu.org/bugs/?58993.

Bug existed since version 5.0, commit fcb9e58b.
2020-08-22 10:27:02 +02:00
Benno Schulenberg
7ffbf01607 tweaks: improve three comments and an indentation 2020-08-21 16:06:38 +02:00
Benno Schulenberg
f6b4c243d8 tweaks: reshuffle four declarations, and rename two variables 2020-08-21 16:03:59 +02:00
Benno Schulenberg
0287be7660 tweaks: move the keyboard-checking code to the end of the search loop 2020-08-20 10:51:19 +02:00
Benno Schulenberg
e6709d684b tweaks: condense two fragments of code, for compactness 2020-08-20 10:44:06 +02:00
Benno Schulenberg
aa257ef58e display: restore the ability to resize the screen while searching
This ability was lost in commit 92298349 from two hours ago, which
bypasses the keystroke buffer and its integrated screen resizing.

This new implementation is better than it was before, because it
responds almost instantly to a resize instead of with a delay of
up to a second.
2020-08-20 10:31:58 +02:00
Benno Schulenberg
8daa7cbda0 tweaks: remove a variable and two functions that have become redundant 2020-08-20 09:17:48 +02:00
Benno Schulenberg
8a5449cebe input: allow also a Meta keystroke to abort a Search command
(Still, this does not allow a full escape sequence to be used as
the Cancel command, but I think that is an acceptable limitation,
because 1) nobody ought to be using --rawsequences, and 2) very
few people will bind Cancel to something like F3 or Ins.)

This improves the fix for https://savannah.gnu.org/bugs/?58825.
2020-08-20 09:17:03 +02:00
Benno Schulenberg
9229834935 search: poll the input stream directly, not nano's own keystroke buffer
When checking (during a Search command) whether the user has pressed
the Cancel keystroke, look at ncurses' input stream directly instead
of at nano's own keystroke buffer, because the latter may contain the
copied keystrokes of a macro and we don't want to discard those.

(This does not yet allow a Meta keystroke to be used for Cancel, but
the next commit will fix that.)

This fixes https://savannah.gnu.org/bugs/?58825.

Bug existed since version 2.9.0, since the macro was introduced.
2020-08-20 08:25:26 +02:00
Benno Schulenberg
6469e9668b tweaks: condense two declarations 2020-08-19 16:52:28 +02:00
Benno Schulenberg
68d71f649e rcfile: make sure that "bright"/"light" are prefixes, not separate words
This fixes https://savannah.gnu.org/bugs/?58984.

The bug was old -- it existed since at least version 2.0.6.
2020-08-19 16:18:29 +02:00
Benno Schulenberg
71752f47cb docs: reshuffle the section about the file browser to a better place
First mention the three main 'pieces' of the editor: Editing window,
Help viewer, and File browser.  Then mention how to change settings:
with the toggles or with nanorc files.
2020-08-19 08:54:30 +02:00
Benno Schulenberg
51f27d3f0c input: hold on to a shift-selected region when an unbound key is struck
There is no reason to deselect the region, as nothing has changed.

(This also retains the shift-selected region when a non-shortcut key is
typed in view mode, which makes sense, as again nothing was changed.)

This fixes https://savannah.gnu.org/bugs/?58980.

Bug existed since version 4.9, commit 0ed62e84.
2020-08-19 08:36:00 +02:00
Benno Schulenberg
b38265cfb8 search: retain the current answer when something is toggled
This fixes https://savannah.gnu.org/bugs/?58972.

Bug existed since version 5.0, commit bccb0ea0.
2020-08-18 09:17:39 +02:00
Benno Schulenberg
b5fb41e963 docs: mention in the FAQ how to change the escape sequences of urxvt
Replace an obsolete question that doesn't have a good answer: setting
TERM to vt100 is unlikely to make the more complicated keystrokes work,
which are the ones that are most likely not to work.
2020-08-18 09:00:56 +02:00
Benno Schulenberg
a14c894325 docs: add a cross-reference from 'findbracket' to 'set matchbrackets' 2020-08-17 14:20:03 +02:00
Benno Schulenberg
bc6b9bf955 tweaks: rename a variable, to not seem to refer to the scrollbar 2020-08-17 13:36:03 +02:00
Benno Schulenberg
4b6090ded3 replacing: do not try to wipe nonexistent multidata, to avoid crashing
This fixes https://savannah.gnu.org/bugs/?58970.
Reported-by: Matteo Raso <mraso@uoguelph.ca>

Bug existed since version 5.0, commit 569d0056.
2020-08-17 10:05:25 +02:00
Benno Schulenberg
fb98f0ced7 tweaks: adjust a comment, and reshuffle the setting of a boolean 2020-08-15 16:07:30 +02:00
Benno Schulenberg
d09055db43 input: dawdle after an ESC also when --rawsequences is used
When keypad() is set to FALSE, like for verbatim input, ncurses is
not waiting its fifty milliseconds after an ESC to see if another
code will follow it, so nano itself will have to pause a little.

Otherwise 'solitary' could get set to TRUE when in fact the ESC
is followed very closely by another code.

This fixes https://savannah.gnu.org/bugs/?58955.

Bug existed since version 2.6.2, commit f2150d3f.
2020-08-15 14:45:02 +02:00
Benno Schulenberg
50b61bef6f input: discard any multibyte character when <Alt> is being held
Otherwise the <Alt> key would simply be ignored.  It's better to reject
the combination, to compel the user to be precise in what they type.
2020-08-15 14:00:53 +02:00
Benno Schulenberg
3d0bfb0a00 input: do not enter invalid bytes when holding down both Alt keys
This fixes https://savannah.gnu.org/bugs/?58954.

Bug existed since version 5.1, commit 49231191.
2020-08-15 13:18:48 +02:00
Benno Schulenberg
3cb55c8b27 verbatim: reserve enough space for the result also in non-UTF-8 locales
Also when each character is just one byte, parse_verbatim_kbinput()
can produce two bytes; plus the terminating NUL that is three bytes.

This fixes https://savannah.gnu.org/bugs/?58959.

Bug existed since version 4.9, commit 03d296eb.
2020-08-15 11:55:48 +02:00
Benno Schulenberg
306906a8a7 docs: adjust description of ^T in cheatsheet, and mention M-Bsp 2020-08-13 07:21:21 +02:00
Benno Schulenberg
6e2c245ecc po: update translations and regenerate POT file and PO files 2020-08-12 08:35:14 +02:00
Benno Schulenberg
74a0ffcbc5 tweaks: baptize the release 2020-08-12 08:24:06 +02:00
Benno Schulenberg
b1a0f5e65a bump version numbers and add a news item for the 5.1 release 2020-08-12 07:57:31 +02:00
Benno Schulenberg
7e8b1ed420 build: stop distributing the two old Changelogs
For installing and using nano, those two Changelogs are useless,
and for inspecting the history of nano, 'git log' is much better.

Only the most recent Changelog is somewhat useful for some users,
for walking in some detail through the changes that were made in
the last few versions.
2020-08-11 20:12:56 +02:00
Benno Schulenberg
b2ea7d29d0 build: fix compilation for --enable-tiny --enable-nanorc --enable-color 2020-08-11 20:10:40 +02:00
Benno Schulenberg
e597ad4908 build: fix compilation when configured with --enable-tiny 2020-08-11 19:59:24 +02:00
Benno Schulenberg
100747f56b verbatim: discard entire keystroke when it's not valid for Unicode Input
This will not work for the deviant escape sequences for F1 to F5
on the Linux console nor for Alt+arrow on urxvt and such, but...
I can't be bothered to handle those too.

This fixes https://savannah.gnu.org/bugs/?58929.

Bug existed since commit be203832 from earlier today.
2020-08-10 16:18:03 +02:00
Benno Schulenberg
d7b2b55bf5 display: show the cursor position also right after the screen is resized
Bug existed since commit 8e226a9f from half an hour ago.
2020-08-10 12:16:18 +02:00
Benno Schulenberg
9875252fd7 tweaks: remove an unneeded beep, and reshuffle the lines for compactness
The beep is produced later, after get_verbatim_kbinput() returns.
2020-08-10 12:07:16 +02:00
Benno Schulenberg
1551c1c771 verbatim: do not report "Invalid code" when a Unicode character is typed
This fixes https://savannah.gnu.org/bugs/?58928.

Bug existed since version 5.0, commit 5899181a.
2020-08-10 11:48:31 +02:00
Benno Schulenberg
8e226a9f28 verbatim: do not report "Invalid code" when the terminal is resized
During verbatim input at most four integers are produced (the longest
possible unicode sequence), so use the value 999 to indicate a special
condition (a screen resize) that should not enter anything into the
buffer AND should not produce any error message or beep.

This fixes https://savannah.gnu.org/bugs/?58923.

Bug existed since version 5.0, commit 5899181a.
2020-08-10 11:42:09 +02:00
Benno Schulenberg
be20383240 verbatim: report and ignore an invalid keystroke for Unicode input
When Unicode Input has started (by typing 0 or 1 at the Verbatim Input
"prompt"), and something is typed that is not a hexadecimal digit, then
don't try to enter this character into the buffer but simply report it
as invalid and ignore it.  Because most likely the user mistyped and
actually meant to enter a valid hex digit.

This fixes https://savannah.gnu.org/bugs/?58927.

The bug was old -- it existed since at least version 2.0.6.
2020-08-10 09:31:24 +02:00
Benno Schulenberg
cf769bbd2f tweaks: adjust the indentation after the previous change 2020-08-10 07:55:00 +02:00
Benno Schulenberg
4ec96f9f2e tweaks: reshuffle a few lines, to condense the code, and improve comment 2020-08-10 07:53:41 +02:00
Benno Schulenberg
bdc856812f tweaks: read keycodes from the keystroke buffer without copying them
Allocating and freeing memory for reading every single keycode
is a waste of time and effort.

This addresses https://savannah.gnu.org/bugs/?58806.
2020-08-10 07:39:29 +02:00
Benno Schulenberg
96bb8149e9 moving: make <Ctrl+Up> go to the top when above the cursor all is blank
Just like <Ctrl+Down> goes to the end of the buffer when after the
cursor there are only blank lines.

This fixes https://savannah.gnu.org/bugs/?58921.

Bug existed since version 2.6.2, since <Ctrl+Up/Down> were introduced.
2020-08-09 16:57:25 +02:00
Benno Schulenberg
07e69d54b2 tweaks: elide two variables that are no longer needed, and update comment 2020-08-09 15:40:53 +02:00
Benno Schulenberg
aeb15e9549 tweaks: parse the escape-sequence bytes without copying them first 2020-08-09 15:25:22 +02:00
Benno Schulenberg
435d9acb5c tweaks: exclude old and mistaken "Esc O" sequences from the tiny version
The correct sequences begin with "Esc [" instead.  I cannot find in the
histories of VTE and Gnome Terminal when these sequences were corrected.

Also exclude a bug check from the tiny version.
2020-08-09 10:48:03 +02:00
Benno Schulenberg
12fe0a3b29 tweaks: normalize the indentation after the previous change
This finally gets rid of the piece of specially reduced indentation
(<-<- ... ->->) that made it hard to see the structure of the code.
2020-08-09 10:48:03 +02:00
Benno Schulenberg
c14e77ce9e tweaks: split a function into two, one for "Esc O" and one for "Esc [" 2020-08-09 10:48:03 +02:00
Benno Schulenberg
2c8c061e67 tweaks: pass first byte of sequence directly to the decoding function
Don't bother stuffing it back into the keyboard buffer when it will be
taken out again straight afterward.
2020-08-09 10:48:03 +02:00
Benno Schulenberg
5fab1e6754 verbatim: pause a little after an ESC, to not miss a succeeding code
When we get an ESC from the keyboard, it might be the start of an
escape sequence, but the keyboard routines will need a little time
(tens of microseconds, probably) to get these codes to ncurses.
So, when doing verbatim input, pause a moment after an ESC.

This completes the fix for https://savannah.gnu.org/bugs/?58909.
2020-08-08 07:51:47 +02:00
Benno Schulenberg
b0e3767af5 input: understand M-Bsp also when terminfo does not match the terminal
Always interpret ESC followed by BS or DEL as <Alt+Backspace>.

This fixes https://savannah.gnu.org/bugs/?58910.

Bug existed since commit 40b03162 from one week ago,
since M-Bsp was hard-bound to deleting a word backwards.
2020-08-07 19:17:36 +02:00
Benno Schulenberg
4923119174 tweaks: reshuffle some fragments, to make the next change easier 2020-08-07 18:46:55 +02:00
Benno Schulenberg
cdd6882541 verbatim: insert the full code sequence when <Alt+Backspace> is pressed
(This could lead to unwanted behavior when the user wants to enter
a literal escape character (0x1B) while the input is somehow getting
stalled, because then a command keystroke after the M-V <Esc> would
get inserted verbatim too, instead of getting acted upon.  But that
is a small price to pay for getting the correct behavior for both
M-V M-Bsp and M-V M-Enter.)

This fixes https://savannah.gnu.org/bugs/?58909.

Bug existed since version 2.6.3, commit 08c51cfd,
but also occurred erratically beforehand.
2020-08-07 16:21:21 +02:00
Benno Schulenberg
5a6a74fe70 gnulib: update to its current upstream state 2020-08-06 16:03:03 +02:00
Benno Schulenberg
d7c2b98ead feedback: when creating a pipe fails, report also the reason
After commit 59bbc0b8 from five days ago (that made a divergent pipe
failure to be treated in the same way as the other two), this became
possible without having two different pipe-failure messages.
2020-08-06 08:47:52 +02:00
Benno Schulenberg
4c63ef204d tweaks: make a few more direct returns, and reshuffle another bit of code 2020-08-05 11:03:35 +02:00
Benno Schulenberg
4c6b6cad99 tweaks: elide an unneeded variable, by transforming the key code directly 2020-08-05 10:51:02 +02:00
Benno Schulenberg
cc6d1d59a6 tweaks: optimize for byte-range characters, and shorten some comments 2020-08-05 10:12:03 +02:00
Benno Schulenberg
f80ce71d13 tweaks: adjust the indentation after the previous change 2020-08-05 10:09:49 +02:00
Benno Schulenberg
2bbbd85852 tweaks: stop using a 'switch' when there are just three possibilities 2020-08-05 10:08:51 +02:00
Benno Schulenberg
54238a5c46 tweaks: reshuffle the zeroing of a counter, to allow some direct returns 2020-08-05 10:06:43 +02:00
Benno Schulenberg
8b2114a25f rcfile: allow to bind M-[ (even though it is an escape-sequence starter)
The user had better avoid using the keystroke in a macro, but
when typing directly at a responsive machine there is no problem,
M-[ is a perfectly valid and recognizable keystroke.

This fulfills https://savannah.gnu.org/bugs/?58820.
2020-08-04 17:28:16 +02:00
Benno Schulenberg
65da6341ba tweaks: avoid a maybe-uninitialized-variable warning from gcc 2020-08-04 17:08:02 +02:00
Benno Schulenberg
c8a87b4d2a softwrap: initialize the 'extrarows' value for the magic line correctly
The make_new_node() function initializes 'extrarows' to a bad value
on purpose, to catch cases like this one where it doesn't get updated
properly.

This fixes https://savannah.gnu.org/bugs/?58890.
Reported-by: Jerry Kindall <kindall@gmail.com>

Bug existed since version 5.0, since the indicator was introduced.
2020-08-04 09:40:25 +02:00
Benno Schulenberg
551a971e16 tweaks: reshuffle four lines, for esthetics 2020-08-03 11:36:35 +02:00
Benno Schulenberg
c2b6eb01cd feedback: use three dots to indicate processing, like everywhere else
For all occurrences, run:  grep '\.\.\."))' src/*.c
2020-08-03 11:33:28 +02:00
Benno Schulenberg
e9e26934ea speller: give startup feedback (relevant when running on a Linux console)
This fixes https://savannah.gnu.org/bugs/?58856.

Bug existed since version 4.8, commit 8b2f7bd5.
2020-08-03 11:21:19 +02:00
Benno Schulenberg
5b56791aef docs: mention that anchors are visible when line numbers are shown
Suggested-by: Tomáš Mudruňka <mudrunka@spoje.net>
2020-08-03 10:27:57 +02:00
Benno Schulenberg
71c0cde5ce anchor: show an anchor also when the line is horizontally scrolled
This fixes https://savannah.gnu.org/bugs/?58884.

Bug existed since version 5.0, since anchors were introduced.
2020-08-03 10:02:09 +02:00
Benno Schulenberg
18a4658d4f anchor: in a UTF-8 locale, show an anchor as a diamond, for visibility 2020-08-03 09:43:55 +02:00
Benno Schulenberg
6fa81ca5b8 formatter: force the mark off, to not crash by accessing empty cutbuffer
More generally, after invoking the formatter, the entire buffer should
be cut (to be replaced with the reformatted text) and not just the part
before the mark, because then everything after it would be duplicated.

This fixes https://savannah.gnu.org/bugs/?58879.

Bug existed since version 4.9, commit 19517fc5.
2020-08-02 19:29:31 +02:00
Michalis Kokologiannakis
4940b02ae0 build: avoid compilation warnings by using memcpy() instead of strncpy()
When compiling with GCC 10.1.0 and -O2 -Wall, the strncpy() call
in measured_copy() produced two stringop-truncation warnings.

This addresses https://savannah.gnu.org/bugs/?58861.

Signed-off-by: Michalis Kokologiannakis <michalis@mpi-sws.org>
2020-08-02 16:47:05 +02:00
Benno Schulenberg
7942dab014 tweaks: make a misplaced call of statusline() more obvious by crashing
Also, reshuffle the lines, to take advantage of an other #ifndef.
2020-08-02 14:50:50 +02:00
Benno Schulenberg
312bcebf44 files: do not try writing to the status bar while not in curses mode
Between an endwin() and a doupdate() there should be no calls of
statusline() or statusbar() -- these two functions may be called
only when in curses mode.

This fixes https://savannah.gnu.org/bugs/?58868.

Bug existed since version 4.3, commit 57390cff.
2020-08-02 10:29:29 +02:00
Benno Schulenberg
eb57b10273 docs: fix a closing tag in the FAQ [tidy] 2020-08-01 20:58:29 +02:00
Benno Schulenberg
844f95e6df speller: give proper feedback when the user tries to check emptiness
(The wording is general, because it should cover also the formatter.)

This fixes https://savannah.gnu.org/bugs/?58865.

Bug existed since version 4.6, commit d2fb371f.
2020-08-01 20:57:23 +02:00
Benno Schulenberg
67d22f4cce tweaks: simplify two functions, as they now return always NULL 2020-08-01 19:00:07 +02:00
Benno Schulenberg
59bbc0b858 tweaks: print error message directly instead of passing it to the caller
This will allow a simplification in the next commit.
2020-08-01 11:50:55 +02:00
Benno Schulenberg
731fd935ff feedback: add the reason to the error message when forking fails
This makes all the "Could not fork" messages the same again
after the change in commit 3eff34b0 from yesterday.
2020-08-01 11:34:23 +02:00
Benno Schulenberg
0e1f7fe2ef tweaks: normalize the indentation, and regroup two lines 2020-07-31 20:39:28 +02:00
Benno Schulenberg
3eff34b075 speller: re-enter curses mode before trying to report an error
If forking fails, we must first return to curses mode before we can show
an error message on the status bar.  (This additionally requires storing
the error number, because doupdate() apparently sets it to zero.)

This fixes https://savannah.gnu.org/bugs/?58864.

Bug existed since version 4.8, commit 61197563.
2020-07-31 20:28:10 +02:00
Benno Schulenberg
40b03162c3 bindings: make <Alt+Backspace> delete a word backwards, like in Bash
It jars a bit that it is <Ctrl+Delete> that deletes a word rightward
and <Alt+Backspace> that deletes a word leftward.  But it's good to
also have a two-key keystroke bound by default to 'chopwordleft',
and not just the three-key <Ctrl+Shift+Delete>.

This fulfills https://savannah.gnu.org/bugs/?58709.
Requested-by: Axel Scheepers <axel.scheepers76+gnu@gmail.com>
2020-07-31 18:52:51 +02:00
Benno Schulenberg
34f4ceb77e help: list again the keystroke for toggling the help lines (M-X)
This fixes https://savannah.gnu.org/bugs/?58855.

Bug existed since version 5.0, commit d8249917.
2020-07-30 10:23:35 +02:00
Michalis Kokologiannakis
d0ad1e42d9 files: ignore only EPERM when fchmod() or fchown() fails
While ignoring permission errors from fchmod() and fchown() is okay
(since normal users are not always privileged to make such changes),
ignoring also more serious errors (like EIO) is not ideal.

Signed-off-by: Michalis Kokologiannakis <michalis@mpi-sws.org>
2020-07-30 09:48:12 +02:00
Benno Schulenberg
59bdce9503 syntax: default: colorize also "GNU nano 5.x" 2020-07-30 09:25:56 +02:00
Benno Schulenberg
9517766aab syntax: css: differentiate pseudo-classes (now cyan) from comments (blue)
Also, add comments, remove a duplicated ":link", and add ":checked".
2020-07-30 09:25:12 +02:00
Benno Schulenberg
c561b4280f po: update translations and regenerate POT file and PO files 2020-07-29 10:10:15 +02:00
Benno Schulenberg
df9ca85961 bump version numbers and add a news item for the 5.0 release 2020-07-29 09:44:39 +02:00
Benno Schulenberg
7475b4d3bf tweaks: reshuffle a few lines, and remove a few unneeded comments 2020-07-28 19:12:02 +02:00
Benno Schulenberg
f502f6fdb2 syntaxes: remove unneeded backslash escapes before quotes
(They may have been needed in the past to avoid miscoloring of the
nanorc file itself, but they are no longer needed now.)
2020-07-27 13:23:13 +02:00
Benno Schulenberg
fd667b5191 tweaks: add four more translator hints 2020-07-27 10:33:42 +02:00
Benno Schulenberg
aabfefde7e syntax: css: color multiline comments correctly
A forward slash does not need to be escaped, and the backslash itself
should not be escaped: it serves to escape the star, to make it literal.

Also, remove a stray end-of-line anchor ($).
2020-07-26 19:54:02 +02:00
Benno Schulenberg
bccb0ea0bb tweaks: handle two similar things in the same way 2020-07-26 11:51:34 +02:00
Benno Schulenberg
6ca22b80ef tweaks: elide a redundant intermediate function
It hasn't been used elsewhere since commit 7f203100 from two years ago.
2020-07-25 15:08:32 +02:00
Benno Schulenberg
cf52f2ed62 tweaks: rename a variable, and condense a comment 2020-07-25 13:51:34 +02:00
Benno Schulenberg
294051769c tweaks: remove a superfluous check on the length of the key buffer
None of the calls of get_input() ask for more codes than those which
already were or will now have become available in the key buffer.
2020-07-25 13:42:06 +02:00
Benno Schulenberg
7157f5a3ce tabbing: properly terminate the answer when the sole match is a folder
When there is just one match when <Tab> is pressed, and this match
is a directory, then a slash is added to 'shared', overwriting the
terminating NUL character.  So, strcpy() cannot be used for copying
this 'shared' string, but strncpy() is needed, and the result needs
to be NUL terminated afterward.

This fixes https://savannah.gnu.org/bugs/?58826.

Bug existed since commit b0f56398 from eleven days ago.
2020-07-25 13:25:48 +02:00
Benno Schulenberg
5ca4e9f5b3 tweaks: remove three unneeded while loops from two input routines
The whiles are unneeded because the result of get_input() can
never be NULL when in waiting mode -- and only when searching
for something are we NOT in waiting mode.
2020-07-25 12:11:48 +02:00
Benno Schulenberg
3e899b15c2 tweaks: reduce the indentation after the previous change 2020-07-24 17:12:31 +02:00
Benno Schulenberg
a33b04ce90 tweaks: cascade the ifs properly: without increasing the indentation 2020-07-24 17:08:53 +02:00
Benno Schulenberg
36ab5d91de input: interpret an escape sequence only when it starts with "[" or "O"
This fixes https://savannah.gnu.org/bugs/?58818.

Bug existed since version 2.9.0, since macros were introduced.
2020-07-24 16:49:39 +02:00
Benno Schulenberg
8dc1b97465 tweaks: three escapes is the same as either zero escapes or one escape 2020-07-24 13:38:44 +02:00
Benno Schulenberg
350115242d bindings: stop supporting <Esc> <Esc> <numeric slash> without NumLock
<Ctrl+numeric slash> does not invoke Go To Line, so it is fitting
that <Esc> <Esc> <numeric slash> does neither.  If some user does
want the double escape plus slash to work, they can use --raw.

(Also, if someone really uses <Esc> <Esc> <numeric slash>, they
probably also type the desired line number on the numeric keypad,
and for that to work they needed to have NumLock engaged, and in
that case the double escape plus slash will work fine.)

(Getting rid of this numeric-slash support makes the three-escapes
case very similar to the one-escape case, allowing the first to be
folded into the latter in the next commit.)
2020-07-24 13:16:41 +02:00
Benno Schulenberg
7bf413db76 tweaks: rename two parameters, away from an abbreviation 2020-07-23 09:56:38 +02:00
Benno Schulenberg
aafda2358f tweaks: rename two variables, away from abbreviations 2020-07-23 09:44:14 +02:00
Benno Schulenberg
6b9084ad09 tweaks: reshuffle a few lines, to elide an 'if' from the most common path
And for compactness.
2020-07-22 20:32:38 +02:00
Benno Schulenberg
d0501d0ebd tweaks: update a translator hint, and add another 2020-07-22 11:38:29 +02:00
Benno Schulenberg
ba5a191f26 gnulib: update to its current upstream state 2020-07-22 11:25:04 +02:00
Benno Schulenberg
364a1518de tweaks: reshuffle some lines, to better separate the three cases 2020-07-22 11:07:20 +02:00
Benno Schulenberg
93b2877758 tweaks: use three switches instead of cascading ifs, for brevity 2020-07-22 10:56:41 +02:00
Benno Schulenberg
832037e2ec tweaks: condense some cases to a single line, for more clarity
And return directly for codes that will not be changed any more.
2020-07-22 10:43:24 +02:00
Benno Schulenberg
ad2920acd0 tweaks: handle the double escapes directly, instead of going round again
Immediately pull the available extra character from the keyboard buffer,
instead of cycling through the whole circus again.
2020-07-22 10:17:48 +02:00
Benno Schulenberg
e59a0f5e77 build: replace the non-standard backslash escape "\e" with "\x1B"
Older compilers do not understand "\e".  Also, it's not in the standard
(see http://open-std.org/JTC1/SC22/WG14/www/docs/n1570.pdf, §6.4.4.4).

This addresses https://savannah.gnu.org/bugs/?58799.
Reported-by: Henry Bent <henry.r.bent@gmail.com>
2020-07-22 09:17:57 +02:00
Benno Schulenberg
fd10c0eadd tweaks: rake a common statement to the end of the case
With the two situations that need to preserve the escape counter
now returning directly, the resetting of this counter can happen
at the end of each case block.
2020-07-21 14:03:18 +02:00
Benno Schulenberg
7e53fcb581 tweaks: remove two redundant conditions, and make a more direct return
The escape-parsing routine nowadays returns FOREIGN_SEQUENCE instead
of ERR when encountering an unknown sequence.  So, with the two cases
that demand ERR now handled directly, there is no need to check for
ERR any more.
2020-07-21 14:02:55 +02:00
Benno Schulenberg
8249f3560f tweaks: normalize the indentation after the previous change 2020-07-20 19:46:27 +02:00
Benno Schulenberg
dd1b16cd54 tweaks: trim an ASCII case, as the function is called only for UTF-8 2020-07-20 19:37:40 +02:00
Benno Schulenberg
43b39ed04f tweaks: use knowledge of Unicode to skip the general multibyte conversion
The relevant range is so small (128 bytes) that "manual" conversion
is much faster (and a bit shorter, eliding two variables).
2020-07-20 19:31:25 +02:00
Benno Schulenberg
17a8b24fe5 tweaks: skip the conversion to multibyte for plain ASCII codes
Converting an ASCII code to "multibyte" is a no-op: it stays one byte.
2020-07-20 19:16:45 +02:00
Benno Schulenberg
b9db967bc4 tweaks: reshuffle some lines, for esthetics
There is no need to reset the digit counter (because this counter
matters only when the escape counter equals two) -- resetting the
escape counter is enough.
2020-07-20 19:06:16 +02:00
Benno Schulenberg
2a5d129738 tweaks: rename a variable, and normalize the indentation 2020-07-20 18:25:19 +02:00
Benno Schulenberg
6980cfbf70 tweaks: change a 'switch' to 'if', to elide a dummy 'return' 2020-07-20 18:21:43 +02:00
Benno Schulenberg
a0d2e63c8e tweaks: improve four comments 2020-07-20 17:15:06 +02:00
Benno Schulenberg
57c52de99a tweaks: rename a function, and move it to before the one that calls it 2020-07-20 17:04:48 +02:00
Benno Schulenberg
9067f7a0c7 tweaks: elide a variable, by returning the result directly 2020-07-20 16:54:22 +02:00
Benno Schulenberg
e4fa0b54a2 tweaks: remove two superfluous assignments
The digit counter will be reset to zero the next time when <Esc>
is pressed, and the byte holder gets re-initialized when the next
first digit is pressed.  And the escape counter is reset to zero
after returning from a result-giving call of get_byte_kbinput().
2020-07-20 16:28:36 +02:00
Benno Schulenberg
b41405233f tweaks: remove some superfluous conditions
When get_byte_kbinput() is called, it has already been determined that
the keyboard input is a digit from zero to nine (or from zero to two
for the first digit), so there is no need to check this again.
2020-07-20 12:40:26 +02:00
Benno Schulenberg
88561506c9 tweaks: improve two comments, and reshuffle some lines for conciseness 2020-07-20 11:47:10 +02:00
Benno Schulenberg
a08ca026f0 input: reset the counters when a three-digit sequence is not completed
When <Esc><Esc> is followed by digit 0 or 1 or 2 but then NOT two more
digits follow, then both the escape counter and the digit counter should
start afresh when a new ESC code arrives.

This fixes https://savannah.gnu.org/bugs/?58788.

Bug existed since before version 2.0.6.
2020-07-20 11:19:44 +02:00
Benno Schulenberg
180a53cc0c files: warn the root user when all the write bits are missing
Root has carte blanche to both read unreadable files and write
unwritable files -- the file system does not prevent this.  So,
alert root when opening a file that is intended to be read-only.

This fulfills https://savannah.gnu.org/bugs/?58685.
Requested-by: Marius Bakke <mbakke@fastmail.com>
2020-07-20 10:26:45 +02:00
Benno Schulenberg
d18cfb26cd tweaks: adjust the indentation after the previous change 2020-07-19 11:52:57 +02:00
Benno Schulenberg
eb70578c5e tweaks: do not use 'switch' when there are just two possibilities
Also, remove an unneeded 'if', as parse_escape_sequence() is only
ever called when there are at least two bytes after the Esc code.
(If there were not, the 'for' loop after calling convert_sequence()
would use an uninitialized 'consumed' value.)
2020-07-19 11:52:47 +02:00
Benno Schulenberg
63efc59758 tweaks: don't check for escape sequences that start with a lowercase "o"
Such escape sequences don't exist -- those mistaken sequences were
removed in commit 4991b3bb from half a year ago.
2020-07-19 11:50:30 +02:00
Benno Schulenberg
dcd34b246a tweaks: move a function to the file where it is used the most
Also, fully exclude the function from the tiny version.
2020-07-19 10:43:26 +02:00
Benno Schulenberg
b0dcb15f94 tweaks: elide a function that is too sparse
The two calls of the function can be replaced with two lines each.
2020-07-17 18:40:34 +02:00
Benno Schulenberg
7dbfbbb8d6 tweaks: reshuffle a few lines, for conciseness 2020-07-17 17:13:43 +02:00
Benno Schulenberg
4cefd699ca tweaks: shorten an error message, to be appropriate in all situations
Saying "Cannot write backup %s" is misleading when it is the original
file that cannot be reread.
2020-07-17 17:10:46 +02:00
Benno Schulenberg
8eddf7bc26 tweaks: reshuffle a condition, to avoid a repetition of code 2020-07-17 16:53:48 +02:00
Benno Schulenberg
2623f39c7b backup: when rereading the original file fails, ask the user what to do
Rereading is unlikely to fail, but *if* it fails, maybe there is a
serious problem and the user wants to try and fix it before saving
the buffer and thus overwriting the original file.
2020-07-17 16:50:25 +02:00
Benno Schulenberg
da71322000 tweaks: rename two labels, for brevity 2020-07-17 16:24:53 +02:00
Benno Schulenberg
292e505e01 tweaks: rename two variables, to avoid a repetitive prefix
Also, fold a condition into an assignment, for conciseness.
2020-07-17 16:23:22 +02:00
Benno Schulenberg
a322dab482 tweaks: elide a function that is called just once
It also nicely groups the backup stuff together in a single function.
2020-07-16 15:03:06 +02:00
Benno Schulenberg
0ed1695fd4 build: fix miscompilation for --enable-{tiny,color,nanorc}
This should have been part of commit 096e3627 from a month ago.
2020-07-16 12:47:43 +02:00
Benno Schulenberg
60d31d2ea6 tweaks: avoid a warning about an unused variable in the tiny version 2020-07-16 12:41:01 +02:00
Benno Schulenberg
b744eec1a9 tweaks: remove an incorrect mention of umask() from a comment
Since commit f8366cd5, umask() is no longer used.
2020-07-15 10:52:49 +02:00
Benno Schulenberg
a6f64212ae tweaks: rename a function, to not shadow a variable, and elide parameter 2020-07-15 10:52:49 +02:00
Benno Schulenberg
a6cee410ef tweaks: normalize the indentation after the previous change 2020-07-15 10:52:49 +02:00
Benno Schulenberg
f7682730bd files: make a backup only when requested, not an unrequested failsafe one
After thinking about it, I don't like it that nano makes an unrequested
failsafe backup: in the vast, vast majority of cases it is a waste both
of time and of disk wear.  If the user is worried about data loss, they
can use --backup.  The fsync() after writing out the buffer (added in
commit a84cdaaa) already reduces the chances on data loss somewhat.
2020-07-15 10:50:36 +02:00
Benno Schulenberg
5f90e067f1 tweaks: rename a parameter and a variable, to be more meaningful 2020-07-14 17:31:47 +02:00
Benno Schulenberg
b0f563980d tweaks: elide an unneeded call of strlen(), and copy NUL byte with string 2020-07-14 17:22:08 +02:00
Benno Schulenberg
258e7c6e65 oops -- restore an accidentally changed file 2020-07-14 15:22:22 +02:00
Benno Schulenberg
65321f9234 files: do not make a failsafe backup when in restricted mode
When in restricted mode, nano should not write to any other file
than to the ones mentioned on the command line.
2020-07-14 15:19:50 +02:00
Benno Schulenberg
bde8858a3a tweaks: rename a variable, to avoid overrepetition of 'backup'
Also, reshuffle three calls of fclose().
2020-07-14 13:52:34 +02:00
Benno Schulenberg
a2b7fc1c81 tweaks: slightly improve a comment and the ordering of some lines 2020-07-14 13:00:34 +02:00
Benno Schulenberg
69e6ccf641 tweaks: reshuffle a fragment of code, to elide a 'goto' 2020-07-14 13:00:34 +02:00
Michalis Kokologiannakis
14717d7449 tweaks: adjust some indentation after the previous change
Signed-off-by: Michalis Kokologiannakis <michalis@mpi-sws.org>
2020-07-14 12:59:30 +02:00
Michalis Kokologiannakis
ed76a045ae tweaks: move the backup code to a separate function
This change moves the code responsible for backup creation to a new,
separate function, backup_file().  This function returns a boolean
indicating whether saving the buffer should proceed or not.

Signed-off-by: Michalis Kokologiannakis <michalis@mpi-sws.org>
2020-07-14 12:12:26 +02:00
Benno Schulenberg
62ffc221aa tweaks: rename a function, and move it to before the one that calls it 2020-07-11 19:43:37 +02:00
Benno Schulenberg
ec8fd9f365 tweaks: reshuffle some code, to avoid needlessly calling a function 2020-07-11 19:11:00 +02:00
Benno Schulenberg
d3a8488b0e tweaks: use a better symbol than 'ERR' to signify a valid hex digit 2020-07-11 18:58:12 +02:00
Benno Schulenberg
b3d6c27502 tweaks: improve a comment, rename a function, and elide a parameter
Checking the current menu instead of the current subwindow works fine.
2020-07-11 18:36:52 +02:00
Benno Schulenberg
2e4d78a714 tweaks: fold translation of all modified keypad keystrokes together
The escape-sequence codes for the different keypad keys are simply
the relevant ASCII code plus 0x40, so they are easy to translate.

Also, do not accept keypad keys with multiple modifiers (Shift+Alt,
Shift+Ctrl, Alt+Ctrl, Shift+Alt+Ctrl) -- report "Unknown sequence"
for those.
2020-07-11 12:16:18 +02:00
Benno Schulenberg
476c838753 bindings: allow typing digits on the numeric keypad by holding Shift
Until now, on an xterm, Shift plus any keypad key would say
"Unknown sequence", which is not useful.  On other terminal
emulators (urxvt, Pantheon, LXTerminal), Shift plus a keypad
key already produces the relevant digit or symbol, so this
change harmonizes the behavior of the different emulators.

However, on a Linux console, Shift plus a keypad key moves
the cursor and selects the text that is passed over.  And
holding Alt while pressing a keypad key does nothing at all.
2020-07-11 11:49:41 +02:00
Benno Schulenberg
ecb4dac494 bindings: stop <Alt+operator> on the keypad from entering spurious letter
For the operator keys on the numeric keypad (/, *, -, and +),
make both the Alt and the Ctrl modifier a no-op.

This fixes https://savannah.gnu.org/bugs/?58731.

Bug existed since version 2.9.3, commit e734488c.
2020-07-11 11:46:43 +02:00
Benno Schulenberg
95df7dbc8e tweaks: correct some comments, as VT100 and such have smaller keypads
The DEC VTnnn terminals only have period, comma, and minus on the
numeric keypad, not slash nor star nor plus nor Insert nor Delete.
2020-07-11 11:44:23 +02:00
Michalis Kokologiannakis
a84cdaaa50 files: improve the backup procedure to ensure no data is lost
The file-saving procedure that nano followed was not crash-safe
under ext4 (and perhaps other filesystems) when editing existing
files.  Specifically, modifying an existing file could lead to data
loss, since a modified file is not replaced atomically on disk.
Using "-B" did not ensure crash-safety either since the backup might
not have persisted on disk when the writeout of the file started.

In addition, if I/O pressure filled up the remaining disk space
after an existing file is truncated during save, nano would not
be able to finish saving the file, which would remain truncated.

This change addresses these issues by making nano do the following:

1) Make a temporary backup of the file being written so that there
is no time window such that (a) an existing file is truncated, and
(b) the buffer corresponding to said file has not been flushed to
disk.  Such time windows are dangerous because, under certain
circumstances, they can lead to data loss on some filesystems.

The backup is made by copying the original file, and a second
attempt to HOME is made in case that first copy fails.

2) Use fsync() so that, when the save finishes, it is certain
that the file has been successfully written to disk.

This addresses https://savannah.gnu.org/bugs/?58642.

Signed-off-by: Michalis Kokologiannakis <michalis@mpi-sws.org>
2020-07-09 16:28:21 +02:00
Benno Schulenberg
97a993d401 verbatim: turn bracketed-paste mode off while waiting for input
This allows pasting six hexadecimal digits after typing M-V
in order to enter a specific Unicode character.

This fixes https://savannah.gnu.org/bugs/?58730.

Bug existed since version 4.8, since bracketed pastes
were introduced in commit f705a967.
2020-07-08 16:24:53 +02:00
Benno Schulenberg
1542cbf942 bindings: add mistakenly removed M-J (Full Justify) back to the main menu
This fixes https://savannah.gnu.org/bugs/?58729.

Bug existed since commit ee03c4b8 from six weeks ago.
2020-07-08 15:46:50 +02:00
Benno Schulenberg
727abceb0f tweaks: adjust comments and indentation after the previous change 2020-07-06 16:59:35 +02:00
Benno Schulenberg
5899181a31 verbatim: show an error message when an invalid Unicode code is entered
The codes from (for example) U+D800 to U+DFFF are invalid.  If any
such invalid code is entered at the Unicode Input prompt, nano should
not act as if the code was accepted and inserted into the buffer, and
should certainly not mark the buffer as Modified.

This fixes https://savannah.gnu.org/bugs/?58714.

Bug existed since version 4.9, commit b3faf353.
2020-07-06 16:47:23 +02:00
Benno Schulenberg
a2fdf6c486 tweaks: remove an unneeded cursor movement, and rename a variable
There is no need to place the cursor up front, as the drawing of
each name includes the coordinates where the name must be drawn.

Also, trim two comments and reshuffle a free().
2020-07-05 19:29:05 +02:00
Benno Schulenberg
29d493a986 tweaks: move an initialization function to before the one that calls it
Also, frob two comments in that function,
and delete three unneeded blank lines.
2020-07-05 19:01:31 +02:00
Benno Schulenberg
940a17268b speller: take into account that statting a file can fail [coverity] 2020-07-05 17:21:56 +02:00
Benno Schulenberg
ee78f2348b rcfile: rename bindable function 'curpos' to 'location'
It is better that the bindable function is named the same as the
tag in the help lines, and that it is not an ugly abbreviation.
2020-07-05 11:05:45 +02:00
Benno Schulenberg
2261377309 docs: complete the renaming of 'tempfile' to 'saveonexit'
This should have been part of commit d4ee6a2b from two months ago.
2020-07-05 10:53:57 +02:00
Benno Schulenberg
cb1675dac7 tweaks: rename two functions and a variable, and improve two comments 2020-07-04 17:43:16 +02:00
Benno Schulenberg
808d0894f1 tweaks: condense a comment, and reshuffle a few lines 2020-07-04 17:25:32 +02:00
Benno Schulenberg
07c1ac9035 tweaks: delete two functions that are never executed
Those two operations are performed directly in do_browser().
2020-07-04 17:14:52 +02:00
Benno Schulenberg
2b9c0c5724 tweaks: rename a variable, and reduce the scope of two others 2020-07-04 15:12:04 +02:00
Benno Schulenberg
abfde53945 tweaks: drop an unneeded assignment, and reshuffle a few lines
And reset the 'lastmessage' variable to a more fitting value.
2020-07-04 09:36:17 +02:00
Benno Schulenberg
f21508f071 tweaks: improve some comments, and reshuffle an assignment 2020-07-03 19:10:48 +02:00
Benno Schulenberg
2c228796a8 docs: improve some descriptions concerning the file browser 2020-07-03 18:45:09 +02:00
Benno Schulenberg
a84653dc19 feedback: show the cursor position also at startup in an empty buffer
When using --constantshow and --nohelp and opening a new buffer,
the cursor location should be shown on the status bar right away.

Bug existed since commit 2e688640 from a few hours ago.
2020-07-03 13:03:44 +02:00
Benno Schulenberg
1388af2bdc tweaks: elide a wrapper function, by checking a precondition earlier 2020-07-03 12:41:40 +02:00
Benno Schulenberg
2e6886406c tweaks: elide an unneeded global variable
The constant cursor display must be suppressed whenever a message
was printed to the status bar.  That is: whenever 'lastmessage' is
something other than 'VACUUM'.
2020-07-03 12:41:40 +02:00
Benno Schulenberg
80ff5e76d6 help: pair the items in the two bottom lines better in the tiny version
This fixes https://savannah.gnu.org/bugs/?58693.

Bug existed since commit 9b8930cc from ten days ago.
2020-07-03 11:28:41 +02:00
Benno Schulenberg
1a2d0c1770 scrolling: add a function and a key binding to center the cursor line
By default, this function is bound to ^L, to make that keystroke do
something actually useful.  To not lose the Refresh function that this
keystroke had, the centering function additionally does a full redraw
and refresh of the screen.
2020-07-02 11:11:44 +02:00
Benno Schulenberg
eb413a99f2 tweaks: do not use the string "stat()" in any of the comments 2020-06-30 10:56:37 +02:00
Benno Schulenberg
fcb9e58b2d history: take into account that statting a file can fail too 2020-06-30 10:53:28 +02:00
Benno Schulenberg
675a8e4899 history: take into account that closing a file can fail 2020-06-29 13:47:20 +02:00
Benno Schulenberg
3344571227 tweaks: reshuffle some conditions, to straighten the logic 2020-06-29 12:39:46 +02:00
Benno Schulenberg
f9b1306adf tweaks: normalize the indentation after the previous change 2020-06-29 12:35:17 +02:00
Benno Schulenberg
722467cb6b tweaks: add four early returns for read/write errors of history files
Also rewrap a comment and rename a variable.
2020-06-29 12:23:59 +02:00
Benno Schulenberg
b3b3d04552 tweaks: rename a variable, to better fit related ones
Since commit c16e79b6 from nearly three years ago, the string "histfile"
does not occur in other variables any more, so it is fine to use it.
2020-06-29 12:04:15 +02:00
Benno Schulenberg
b9e3e4edb8 history: don't send error messages to the screen; store them in the queue 2020-06-29 11:56:36 +02:00
Benno Schulenberg
2d204bcbfd rcfile: restore terminal settings when exiting upon excessive unbindings
This fixes https://savannah.gnu.org/bugs/?58671.

Bug existed since commit 24cdf78a from two weeks ago.
2020-06-29 11:25:57 +02:00
Benno Schulenberg
3e609ee4c7 rcfile: complain when an essential key binding is missing
This fixes https://savannah.gnu.org/bugs/?58670.

Bug existed since commit 009fb2fa from two days ago.
2020-06-29 11:09:12 +02:00
Benno Schulenberg
13327203e0 build: use a more dependable method for detecting a build from git
The Haiku recipe seems to detect a .git directory somewhere, even though
they are building from a tarball.  So, check instead for the presence of
nano's release script, which ought to be present only in a git checkout,
not in a released tarball.
2020-06-28 15:21:04 +02:00
Benno Schulenberg
da0ac58ecc docs: document the new -O/--bookstyle and 'set bookstyle' options 2020-06-27 11:12:21 +02:00
Benno Schulenberg
712f68c697 options: add -O/--bookstyle to make leading whitespace mean new paragraph
Before version 2.9.8, nano would consider any line that started with
leading whitespace as the beginning of a new paragraph, and would thus
be unable to justify an indented piece of text (unless autoindent was
switched on).  I thought that this was too limiting and changed the
way nano detects and parses paragraphs.  It works fine in texts where
paragraphs occupy multiple lines, but breaks down for paragraphs of
a single line: nano merges those with adjoining lines.

Now, when -O or --bookstyle or 'set bookstyle' is used, nano will again
consider a line that begins with whitespace as the start of a paragraph
-- when 'autoindent' is OFF.

This addresses https://savannah.gnu.org/bugs/?57402.
Indirectly-reported-by: Sébastien Desreux <seb@h-k.fr>
Also-reported-by: Bill Kendrick <nbs@sonic.net>
2020-06-27 11:12:21 +02:00
Benno Schulenberg
331bd7662e tweaks: delete a now-unused function 2020-06-27 10:23:03 +02:00
Benno Schulenberg
009fb2fae6 tweaks: make three hard-bindings of special keys more efficiently
Instead of calling a function that tries to find the relevant operation,
just add three hidden hard-bindings at the end of the shortcuts list.

They are hidden because we don't want them to show up in the help text,
because we don't know what to call them (as a Cancel and Suspend key
don't exist on normal keyboards) or naming the key would be confusing
(Sh-Ins is grabbed by the desktop manager and doesn't reach nano).
2020-06-27 10:20:45 +02:00
Benno Schulenberg
7fa6e95ce1 tweaks: avoid a function call when a simple boolean will do 2020-06-26 19:44:19 +02:00
Benno Schulenberg
8bce70e038 tweaks: rename a variable, to better describe what it holds 2020-06-26 19:27:28 +02:00
Benno Schulenberg
b55153524a tweask: adjust the indentation after the previous change
Also improve a comment.
2020-06-26 19:18:05 +02:00
Benno Schulenberg
a9ce488cc5 tweaks: drop a superfluous check for a non-zero length
The get_history_completion() function is called in just one place,
and gets called only when the length parameter is larger than zero.

Also, improve a few comments.
2020-06-26 19:07:47 +02:00
Benno Schulenberg
8061a981b1 tweaks: correct two spelling mistakes [codespell] 2020-06-26 11:27:07 +02:00
Benno Schulenberg
e64c950896 tweaks: close opened files when something goes wrong [coverity] 2020-06-26 10:24:52 +02:00
Benno Schulenberg
69b12d907e tweaks: avoid unneeded calls of free() by reallocating the full name 2020-06-26 09:57:38 +02:00
Benno Schulenberg
c0c4a1b2b5 tweaks: plug a leak, by always freeing the full filename [valgrind] 2020-06-26 09:47:38 +02:00
Benno Schulenberg
18659f3485 build: fix the Makefile after two header files were renamed
Reported-by: Kamil Dudka <kdudka@redhat.com>
2020-06-25 21:11:26 +02:00
Benno Schulenberg
94f49e208f tabbing: beep at the first listing, and when there are zero possibilities
A successful single completion is silent, but when there are zero
or multiple possibilities, nano beeps.
2020-06-25 10:26:01 +02:00
Benno Schulenberg
3f63982593 tweaks: rewrap a few lines in old news items, for more balanced lines 2020-06-25 10:09:13 +02:00
Benno Schulenberg
7f77cad1b4 tweaks: condense the code a little further, by grouping things better 2020-06-25 10:03:56 +02:00
Benno Schulenberg
e7511abd86 tweaks: avoid checking a variable three times for each pass in the loop 2020-06-25 09:57:41 +02:00
Benno Schulenberg
b1b89f01b7 docs: mention that M-X toggle is special, because available in most menus 2020-06-24 09:30:08 +02:00
Benno Schulenberg
24740815f6 files: make better use of the last row when there are many completions
Put the "(more)" not in the first column of the last row but in the
last column.
2020-06-23 08:28:47 +02:00
Benno Schulenberg
c7356c2d85 files: show possible tab completions near the bottom of the edit window
Especially when it are just a handful of possible completions, it is
much nicer to have them listed close to the prompt bar where the eyes
of the user are.

This fulfills https://savannah.gnu.org/bugs/?58620.
2020-06-23 08:28:47 +02:00
Benno Schulenberg
91ba76e1e0 tweaks: normalize the indentation after the previous change
Also, improve five comments.
2020-06-23 08:28:47 +02:00
Benno Schulenberg
3dcabd6d03 tweaks: make an early return for zero matches, and rename a variable 2020-06-23 08:28:47 +02:00
Benno Schulenberg
0f843b007a tweaks: avoid an unnecessary refresh for zero or just one completion 2020-06-23 08:28:47 +02:00
Benno Schulenberg
ff11ab6b66 files: list possible completions after just one <Tab> instead of two
This gives quicker feedback, and spares the user unnecessary beeps
and typing.  Also, now a beep after a <Tab> means just one thing:
there are NO completions.

This fulfills https://savannah.gnu.org/bugs/?58627.
2020-06-23 08:28:47 +02:00
Benno Schulenberg
096e36279f build: fix compilation for --enable-tiny --enable-color --enable-nanorc 2020-06-22 14:03:48 +02:00
Benno Schulenberg
5eb3b8feb5 tweaks: add a helpful message for when pkg.m4 is missing during a build 2020-06-22 14:03:32 +02:00
Benno Schulenberg
f601eeda57 build: fix compilation when configured with --disable-color 2020-06-22 12:49:04 +02:00
Benno Schulenberg
2430c5b230 build: allow compilation to succeed on curses without italic support
The OpenBSD system that I have access to still uses ncurses-5.7,
and support for A_ITALIC appeared in version 6.0.
2020-06-22 11:19:05 +02:00
Benno Schulenberg
9b8930cc13 tweaks: adjust the conditional help-item pairing for absence of speller
The Spell Checker is no longer among the first twelve items of the
main menu, so the conditional placing of the Go To Line item should
no longer depend on it.
2020-06-22 09:09:05 +02:00
Benno Schulenberg
0f0b620c65 build: fix compilation when configured with --disable-speller
Move two functions that are used by the formatter too
to between the proper #ifdef.

Problem existed since commit 8089f5ad from a month ago.
2020-06-22 08:42:49 +02:00
Benno Schulenberg
a7aab18dfe colors: move purple one step away from magenta, and use a darker mauve 2020-06-21 19:21:07 +02:00
Benno Schulenberg
a9e171de52 tweaks: update three translator hints, add two, and frob three strings 2020-06-21 14:10:37 +02:00
Andreas K. Foerster
ad2490c3fc syntax: ada: new file -- coloring rules for Ada 2012 files
Signed-off-by: Andreas K. Foerster <akf@akfoerster.de>
2020-06-21 09:33:14 +02:00
Benno Schulenberg
380589d95d tweaks: reshuffle and trim a comment, and remove unneeded pair of braces 2020-06-21 09:20:44 +02:00
Benno Schulenberg
bb496bf456 tweaks: rename two variables, to be shorter and without abbreviations 2020-06-21 09:12:59 +02:00
Benno Schulenberg
b086d0bad0 tweaks: elide another parameter, relevant in just three menus
The parameter was referenced in just one place.  So, simply check for
the three relevant menus (and unrestricted mode) and be done with it.

This also has the pleasant effect that the menu name is now the first
parameter of do_prompt(), thus clearly indicating what prompt it is,
instead of having an opaque TRUE or FALSE value at the beginning.
2020-06-20 17:19:23 +02:00
Benno Schulenberg
a13b0bc854 files: disallow tabbing when in restricted mode
Tabbing can list all files in the given directory, but restricted mode
is supposed to prevent the user from any access to the filesystem...

This fixes https://savannah.gnu.org/bugs/?58632.

Bug existed (in this form) since version 1.3.4, commit f7b5d930.
2020-06-20 14:55:28 +02:00
Benno Schulenberg
bbdbf4586f build: make ./configure report which global nanorc file will be used
This addresses https://savannah.gnu.org/bugs/?57061.
Requested-by: Robert Johnson <aloha@blastpuppy.com>
2020-06-20 14:02:34 +02:00
Benno Schulenberg
af5010c96f syntax: default: colorize embedded control codes 2020-06-20 13:54:48 +02:00
Benno Schulenberg
90f6342fd1 tweaks: rename two header files, to be distinct and not an abbreviation 2020-06-20 12:09:31 +02:00
Pedro Victor de Brito Cordeiro
84b187f627 tweaks: make parameter names in prototypes match those in the definitions
Also, remove three prototypes of functions that no longer exist.

Signed-off-by: Pedro Victor de Brito Cordeiro <pedrocga1.opensource@gmail.com>
2020-06-20 11:25:09 +02:00
Benno Schulenberg
499b926b74 tweaks: elide a parameter that is relevant for only one menu (Goto Dir)
Instead of burdening seven other calls of do_prompt() with a useless
parameter, just check for MGOTODIR in the appropriate place.  It also
saves having to pass the parameter down through three more functions.
2020-06-19 10:55:28 +02:00
Benno Schulenberg
61dda8ff62 tweaks: rename a variable, to make more sense 2020-06-19 10:12:49 +02:00
Benno Schulenberg
6ce4e3ede8 feedback: do not list "." and ".." as possible <Tab><Tab> completions
The single dot serves no purpose, as the user is already there.  And
the double dot is reached more easily by typing a second dot first.

And anyway, . and .. are not shown when the user does not type a dot
first, so why show them when the user types a single dot followed by
<Tab><Tab>?  Most likely the user wants to see actual dot files, so
just show those.

This fixes https://savannah.gnu.org/bugs/?58619.
2020-06-19 10:06:33 +02:00
Benno Schulenberg
287718cf8b tweaks: rename two parameters, to be more fitting 2020-06-18 19:12:11 +02:00
Benno Schulenberg
78f54523d9 tweaks: elide a variable and be more direct, and rename another 2020-06-18 19:02:02 +02:00
Benno Schulenberg
9faa95450b tweaks: rename two functions, and rename and reshuffle a parameter
Also, drop an unneeded nulling: the function copy_of() already
NUL-terminates the copied string.
2020-06-18 17:24:18 +02:00
Benno Schulenberg
26d7a7494e tweaks: improve several comments, and rewrap two lines 2020-06-18 17:10:05 +02:00
Benno Schulenberg
d8249917c3 bindings: allow toggling the help lines at several prompts and in browser
Now the help lines can be toggled not only while editing, but also at
the Read (^R), Write (^O), Execute (^T), Search (^W), Replace (M-R),
Goto (^/), and Yesno prompts, and also in the file browser and when
searching for a file name.  The help lines cannot be toggled in the
help viewer, nor when searching in a help text, nor in the linter,
as these three things force the help lines to be on.

Furthermore, the 'nohelp' function can be rebound in all relevant
menus (default binding: M-X).

This fulfills https://savannah.gnu.org/bugs/?58471.
2020-06-18 15:36:10 +02:00
Benno Schulenberg
054cafa138 docs: mention the nine new color names, and "bold" plus "italic" 2020-06-18 15:31:06 +02:00
Benno Schulenberg
bafcc19b7a tweaks: rename a symbol, from a phrase to a noun 2020-06-18 15:31:06 +02:00
Benno Schulenberg
61c94c2f81 rcfile: report the first bad color element, not a later one that is okay
This fixes https://savannah.gnu.org/bugs/?58605.

Bug existed since commit c275c515 from several days ago.
2020-06-18 15:31:06 +02:00
Benno Schulenberg
69a90dd7af tweaks: elide two redundant calls of strchr() 2020-06-18 15:31:06 +02:00
Benno Schulenberg
fae2eeadce rcfile: introduce the modifier 'italic', for slanted text
The modifier has to come before the foreground color name, separated
by a comma, and after 'bold,' (when present).  This has no effect on
terminals that are incapable of cursive text, like the Linux console.

This fulfills https://savannah.gnu.org/bugs/?56525.
2020-06-18 15:31:06 +02:00
Benno Schulenberg
3ff524821c tweaks: move a copyright notice to a better place, and improve it
The username_tab_completion() function taken from busybox-0.46 was
just a stub, it contained basically nothing.  Chris himself wrote
the function in November 2000 (commit be77c611), and rewrote it in
January 2001 (commit 2c2c5f21).

The version of username_tab_completion() in that latter commit looks
somewhat like the version of Vladimir N. Oleynik <dzo@simtreas.ru>
(busybox commit 4e338757).  That commit comes three days after Chris'
commit, but Vladimir's original email is from a week earlier:
http://lists.busybox.net/pipermail/busybox/2001-January/035687.html.
So... it is quite possible that Rocco saw that email and suggested
to Chris to rewrite username_tab_completion() using getpwent().

Anyway, the version that was taken from busybox-0.46 was just four
lines and thus not worthy of copyright.  The two other functions
that were copied were heavily modified in 2000, so it's better to
add that year in the copyright notice.  It is fine to tweak the
notice: it just says that the original authors must be attributed,
not that the exact text must remain unchanged.
2020-06-18 12:50:24 +02:00
Benno Schulenberg
290b250141 tweaks: elide an unneeded variable, as there is nothing beyond '*place' 2020-06-18 12:12:43 +02:00
Benno Schulenberg
b61d97eb9a tweaks: elide a variable, and shortcircuit a return
Instead of first trying to match things, and then discarding these
matches when the cursor is not at the end of the offered fragment
('buf'), simply don't bother to do any matching in that case.
2020-06-18 12:12:33 +02:00
Benno Schulenberg
0bced0a5e9 tweaks: condense and improve some comments 2020-06-18 11:44:25 +02:00
Benno Schulenberg
23c62c5032 tweaks: drop two unneeded assignments
The variable is set to zero at its declaration, and the second function
is called only when the first is either not called or found nothing --
thus '*num_matches' will still be zero.
2020-06-18 11:20:25 +02:00
Benno Schulenberg
2770ec81e2 build: make a deeper clone of gnulib (when building from git)
This increases the chances that the wanted hash will be present in
the checkout when we haven't changed the hash for a few months.

Reported-by: Félix Piédallu <felix@piedallu.me>
2020-06-17 12:25:23 +02:00
Benno Schulenberg
c35c5af5d8 syntax: nanorc: colorize the new named colors too, from "mint" to "mauve" 2020-06-17 11:29:05 +02:00
Benno Schulenberg
f6e7b7fbc5 rcfile: introduce nine new named colors, from "pink" to "latte"
Names give a rough idea of what the color will look like, whereas
numerical indexes would not do this at all.

Nine extra colors seems enough.  If there were more, no one would be
able to say for sure which is which when two similar colors are used
several rows apart.

This partially fulfills https://savannah.gnu.org/bugs/?56445.
2020-06-17 11:18:22 +02:00
Benno Schulenberg
96a5aa9e90 syntax: nanorc: colorize 'bright' anyway, so existing syntaxes look okay
After a year or so, when people have had time to convert their syntaxes
to use 'bold' and/or 'light' instead of 'bright', we can drop this
colorizing, and still later stop recognizing 'bright' altogether.
2020-06-16 17:33:49 +02:00
Benno Schulenberg
e998c35c53 syntax: sql: rename the file to match the name of the syntax 2020-06-16 14:44:57 +02:00
Benno Schulenberg
4d7e7e28fd tweaks: drop obsolete 'nano.spec' from .gitignore file, and reshuffle 2020-06-15 19:11:45 +02:00
Marco Diego Aurélio Mesquita
648eac936e files: make the M-F (New Buffer) toggle non-persistent
Having the M-F toggle non-persistent, makes the behavior of ^R
predictable.  This allows string binds that load a file to work
correctly independently of when M-F was last pressed.

The -F/--multibuffer command-line option and "set multibuffer"
in a nanorc file determine the default behavior of ^R.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2020-06-15 16:05:31 +02:00
Benno Schulenberg
26fb83c61f docs: use 'bold' and 'light' instead of 'bright' in the sample nanorc 2020-06-15 15:30:52 +02:00
Benno Schulenberg
2fd9974e0e syntax: nanorc: stop colorizing 'bright', even though it's still accepted
The name 'bright' does not fit its effect (often bolding the typeface),
so better discourage its use.

Furthermore, colorize 'bold' and 'light' also for interface colors.
2020-06-15 15:15:06 +02:00
Benno Schulenberg
7ff82aa5e2 rcfile: add bindable function 'execute', for access to "Execute Command"
(This should have been added three weeks ago when ^T was rebound.)
2020-06-15 14:27:49 +02:00
Benno Schulenberg
fd28e5f36c build: fix compilation when configured with --enable-tiny 2020-06-15 12:38:16 +02:00
Benno Schulenberg
7f40eeab0a tweaks: call the spotlighting routines only for the relevant line
Otherwise the affected piece of text gets drawn and spotlighted as
many times as there are rows in the edit window.
2020-06-15 09:45:01 +02:00
Benno Schulenberg
d67faa2bb5 tweaks: remove a superfluous global variable
There were no calls of statusbar() or statusline() before curses mode
was entered.  But since the previous commit curses mode is entered
even earlier, so...
2020-06-14 13:09:23 +02:00
Benno Schulenberg
24cdf78a93 startup: enter curses mode before reading the nanorc files
This way the COLORS variable will be set when the nanorc files specify
interface colors, so that "light" will work for them.
2020-06-14 12:57:46 +02:00
Benno Schulenberg
d01dbbb284 rcfile: do not complain when "bright" is used with a background color
A background color *can* be bright (in the sense of lighter, shinier).
It's just that the background cannot be bold.  Only the typeface used
on the foreground can be bold (if the terminal supports it).  So, let
"bright", when used with a background color, simply mean "light".
2020-06-14 12:05:18 +02:00
Benno Schulenberg
c275c5158e rcfile: introduce the modifier "bold", for specifying bolding separately
This makes it possible to avoid the misnamed prefix "bright".  It is
misnamed because (on current terminal emulators, when the brightening
of bold is switched off) it just makes the typeface bold, not the color
brighter.  The prefix "light" will now only make the color brigther,
and the modifier "bold" will just make the typeface bold (on terminal
emulators, when the brightening of bold is switched off).

On a Linux console, which is not capable of bolding the typeface,
"bold" will brighten the color.

This fully fulfills https://savannah.gnu.org/bugs/?58503.
2020-06-14 11:54:18 +02:00
Benno Schulenberg
adf7f33ea8 rcfile: allow specifying a bright background color (with prefix "light")
If the terminal is capable of more than eight colors, specifying
indexes 8 to 15 works fine for getting a light background color.
2020-06-14 11:51:00 +02:00
Benno Schulenberg
4d10f583e4 rcfile: accept prefix "light" to make a color brighter without bolding it
The prefix "bright" will continue to make the color brighter AND/OR
make the typeface bold (depending on how the terminal is configured
and on its capabilities), but the prefix "light" will just make the
color brighter (if the terminal can do that).

The prefix "bright" continues to do the same as what it did before,
to not change the appearance of user-defined syntaxes.  And having
an option to change the meaning of "bright"... would be confusing.

This partially fulfills https://savannah.gnu.org/bugs/?58503.
2020-06-14 11:45:45 +02:00
Benno Schulenberg
926bc6751e startup: check stdout instead of stdin when probing for a Linux console
This way we don't have to probe twice, and the result is accurate also
when nano is reading data from standard input.  Standard output should
always be connected to a terminal, as nano is not meant to operate
without a screen.
2020-06-14 10:52:42 +02:00
Benno Schulenberg
1c8c02f63b tweaks: move a function, to be in the order in which they are called
In addition, rename two variables and adjust the type of one of them.
2020-06-13 17:16:33 +02:00
Benno Schulenberg
43a1756783 tweaks: call init_pair() just once for each pair number 2020-06-13 14:17:45 +02:00
Benno Schulenberg
34528db096 tweaks: remove unneeded variables after the previous change 2020-06-13 14:17:45 +02:00
Benno Schulenberg
c79b52da1d tweaks: do the conversion of -1 to a specific color just once
Do the conversion (when needed) when the syntax is loaded,
not for each buffer switch.
2020-06-13 14:17:45 +02:00
Benno Schulenberg
454dc6e1ec tweaks: elide two ifs for the most likely case, when defaults are allowed 2020-06-13 14:17:45 +02:00
Benno Schulenberg
23460bc6a8 tweaks: rename a variable, for more contrast with the function name 2020-06-13 14:17:45 +02:00
Benno Schulenberg
ba2807c6f7 tweaks: call use_default_colors() just once for each run 2020-06-13 14:17:45 +02:00
Benno Schulenberg
3899a09dea tweaks: rename a variable, improve a comment, and reshuffle a few things 2020-06-11 19:23:37 +02:00
Benno Schulenberg
b535714671 tweaks: reshuffle a statement, to have major initialization in nano.c 2020-06-11 16:48:52 +02:00
Benno Schulenberg
8535b3db4c tweaks: rename a variable, to not refer to a row as a "line" 2020-06-11 16:45:47 +02:00
Benno Schulenberg
77bce9f1c4 tweaks: remove a redundant cursor movement, remove a redundant condition
Each listing of a name is preceeded by a call to wmove(), so there
is no need for an initial wmove().  And after writing "more" on the
bottom row of the edit window, the loop is terminated, so there is
no need to check that this is the first item on the bottom row.
2020-06-11 16:29:38 +02:00
Benno Schulenberg
a2b85e0c12 indicator: recompute the extra rows also when justifying and resizing
And when the margin changes (when line numbers are switched on or off,
or when the buffer grows or shrinks), and when a piece of text from a
different buffer with a different margin is pasted.

This fixes https://savannah.gnu.org/bugs/?58517.

Bug existed since commit 9a9f36fc from yesterday.
2020-06-07 12:16:15 +02:00
Benno Schulenberg
786d2221e1 indicator: recompute the extra rows also for cut/paste/split/join
This fixes https://savannah.gnu.org/bugs/?58511.

Bug existed since commit 9a9f36fc from yesterday.
2020-06-07 11:05:14 +02:00
Benno Schulenberg
9a9f36fca7 indicator: rework how the "scrollbar" is computed when softwrapping
Instead of storing for each line the ordinal number of the first chunk
in that line, simply store the number of extra chunks in the line.

It now takes some more computation to actually draw the scrollbar, but
it saves a lot of computation when just inserting or deleting characters
(when using --softwrap and causing a change in chunk count).

This fixes https://savannah.gnu.org/bugs/?58510.

Bug existed since commit 6bccedb3 from two days ago.
2020-06-06 19:21:23 +02:00
Benno Schulenberg
00d4a06cc7 tweaks: group the exiting routines together, and condense the comments 2020-06-05 19:10:36 +02:00
Benno Schulenberg
2aec478ea6 tweaks: elide an unneeded parameter, and rename the other 2020-06-05 17:23:52 +02:00
Benno Schulenberg
ae7f5ebdeb tweaks: move a function to before the one that calls it 2020-06-05 17:14:38 +02:00
Benno Schulenberg
bea5e85f3e tweaks: make an error message more accurate and reduce it to its essence
There is no need to be explicit about not having saved the buffer --
it is implied in the "Too many".  And anyway, no one is ever going to
see this message -- who will have a hundred thousand .save files?
Trimming this message makes the tiny version smaller.

Also, rewrap a neighbouring line.
2020-06-05 12:19:42 +02:00
Benno Schulenberg
32ee39e44a docs: document the --indicator (-q) and 'set indicator' options 2020-06-04 18:52:28 +02:00
Benno Schulenberg
8e7b869cd9 options: add --indicator and -q for switching on the scroll-bar thing
By default, the position indicator is off.  It can be turned on
by passing -q or --indicator on the command line, or by adding
'set indicator' in your nanorc file.
2020-06-04 18:52:28 +02:00
Marco Diego Aurélio Mesquita
6bccedb319 display: support the position indicator also when --softwrap is used
A new member ('chunk_nr') is added to each 'linestruct', to store
the serial number of the first chunk of that line, so that, when
softwrap is on, the scroll-bar thing can be computed relative to
chunks instead of relative to actual lines.

To guarantee that 'chunk_nr' is correctly synced, the buffer is
renumbered whenever the number of chunks in a line changes, and
also when softwrap is toggled on, and when buffers are switched.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2020-06-04 18:52:28 +02:00
Benno Schulenberg
b33a62af8c new feature: a position-plus-portion indicator on the righthand side
This displays a scrollbar-like thing on the right edge of the screen,
giving a rough indication where in the buffer the text that is being
shown in the viewport is located, and how large/small a portion of
the buffer this text is.

(Support for softwrapping, and an option to turn the indicator on,
will arrive in subsequent commits.)

This fulfills https://savannah.gnu.org/bugs/?57956.

Original-patch-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2020-06-04 18:52:28 +02:00
Benno Schulenberg
d729edaeda bindings: make ^L (Refresh) work at all the prompts too
(Unfortunately, this means that ^L cannot be used for the
Linter in the "Execute Command" menu.)

This fixes https://savannah.gnu.org/bugs/?58469.

Bug existed since around version 2.1.0.
2020-06-04 09:10:48 +02:00
Benno Schulenberg
bc92e28b30 tweaks: elide an unused parameter, and rename the other and a variable
Also, regroup a few lines.
2020-06-03 18:45:14 +02:00
Benno Schulenberg
c5b0e1958a feedback: beep also at a prompt when receiving an unknown escape sequence
Nano would beep (and report "Unknown sequence") only when in the main
edit window, in the help viewer, or in the file browser.  But the same
keystroke at a prompt would be enigmatically silent.

Also, in the file browser, nano would leave the cursor at the end of
the "Unknown sequence" message when --showcursor was used.

This fixes https://savannah.gnu.org/bugs/?58490.

Bug existed (in this form) since around version 2.7.4,
and in a worse form since around version 2.3.5.
2020-06-03 17:15:51 +02:00
Benno Schulenberg
da43cc0959 display: reposition the cursor after an error message also in a help text
A help text is contained in a normal buffer (since quite a while now),
so cursor placement should work like in a regular edit window.

Also, remove an unneeded switching on of the cursor -- it is already on
as nano is waiting for keyboard input.

This fixes https://savannah.gnu.org/bugs/?58489.

Bug existed since version 3.2, commit 10d9742c, since --showcursor
shows the cursor also in the help viewer.
2020-06-03 10:38:08 +02:00
Benno Schulenberg
506f617d5b tweaks: remove an unneeded call of wnoutrefresh()
On NetBSD, nano requires ncurses nowadays.  With ncurses, cursor
placement works fine without the extra call of wnoutrefresh().
2020-06-03 10:14:50 +02:00
Benno Schulenberg
e81e18dd14 tweaks: recalculate the multiline info just once when doing "Replace All" 2020-06-02 19:14:36 +02:00
Benno Schulenberg
569d00564b replacing: recalculate the multiline coloring info when needed
If a replacement changed the matching of a multiline coloring regex,
then wipe the existing multiline data and recalculate it for the whole
buffer.

There is no need to redraw the current line (let alone the whole window)
directly after a replacement, because if there is a next occurrence, the
edit window will be redrawn then in order to spotlight that occurrence;
and if there is no other occurrence, the edit window will be redrawn in
the main loop because there has been at least one replacement.

This fixes https://savannah.gnu.org/bugs/?58481.

Bug existed (in this form) since version 2.7.5.  Before that,
the miscoloring could happen even without scrolling.
2020-06-02 18:52:40 +02:00
Benno Schulenberg
881106c487 tweaks: drop two unneeded wnoutrefresh() calls in the spotlight routines
The call will be made at the end of edit_refresh() or in the main loop.
2020-06-01 20:28:07 +02:00
Benno Schulenberg
2a44cb2ed8 tweaks: rename a function, to leave the old names behind
What the function does has changed, so better change the name too.
2020-06-01 09:43:08 +02:00
Benno Schulenberg
19a124e806 display: avoid an additional redrawing when redrawing the screen
When resizing the screen or toggling the help lines or refreshing
the screen with ^L, what used to be total_refresh() would first call
what used to be total_redraw(), to tell ncurses to redraw whatever
had been on the screen so far, before proceeding to fully redraw the
content of the title bar and the edit window and the bottom bars.
That was duplicate work.

Thus, rename total_redraw() to total_refresh(), so that ^L in the
edit window, help viewer, and file browser will redraw the screen
just once.  This also preserves whatever was on the status bar
(when --quickblank isn't used).

Rename the old total_refresh() to draw_all_subwindows() and call
this routine when resizing the screen or toggling the help lines
or returning from the credits crawl.
2020-06-01 09:40:09 +02:00
Benno Schulenberg
d9106abfda rcfile: rename 'extcmd' to 'execute', to be more readable and fitting
Also, improve its description in the documentation.
2020-05-31 12:04:58 +02:00
Benno Schulenberg
bc0ea5ea71 help: describe what has been added to the "Execute Command" menu 2020-05-30 19:21:44 +02:00
Benno Schulenberg
ee03c4b857 bindings: remove the Full-Justify function from the Search menu
It was out of place there and found a new home in the Execute menu.
2020-05-30 18:58:41 +02:00
Benno Schulenberg
6d7ff17901 help: put the two toggles first in the "Execute Command" menu
This makes that the M-F toggle stays roughly in the same place when
toggling between "Read File" and "Execute Command", and groups the
six special commands together.
2020-05-30 18:57:04 +02:00
Benno Schulenberg
7bad92c50b bindings: add ^Z (Suspend) to the "Execute Command" menu
This makes suspension more discoverable, and allows the user to rebind
^Z in the main menu without losing the ability to suspend nano.

This drops the ^X (Flip Execute) toggle from the menu -- keeping it
would make an ugly uneven number and would reduce the space for each
menu item too much (clipping "Full Justify" and "Cut Till End") --
but it is still present as a blind toggle.
2020-05-30 18:56:58 +02:00
Benno Schulenberg
d3954901a9 bindings: make ^T invoke the "Execute Command" menu, and ^T^T the Speller
Make the "Execute Command" menu accessible also with a single keystroke
(^T), not just with a double one (^R^X).  This is useful, because no one
will suspect that "Execute Command" can be found behind "Read File".

To not disturb muscle memory too much for people who are used to ^T
invoking the Spell Checker, a second ^T will invoke it.
2020-05-30 18:56:55 +02:00
Benno Schulenberg
cd594b85f4 general: make five tools accessible through the "Execute Command" menu
Instead of creating a special Tools menu, add the five functions that
affect the whole buffer to the "Execute Command" menu.  There is room
for these five functions there, and they kind of fit in because three
of them (Speller, Linter, and Formatter) actually invoke an external
command, and Full Justify could have been implemented externally, and
the destructive Cut Till End ought to have required a double keystroke
since the beginning.
2020-05-30 18:56:51 +02:00
Benno Schulenberg
933dd567de tweaks: separate a symbol from its definition by two spaces
It's a little clearer, and new ones were like that already.
2020-05-29 18:45:14 +02:00
Benno Schulenberg
248d392c4d tweaks: rename a symbol, and actually use it where it is needed 2020-05-29 17:19:38 +02:00
Benno Schulenberg
e1f80b9707 tweaks: move a function to a more logical place
Initialization should come first.
2020-05-29 17:12:45 +02:00
Benno Schulenberg
6b4e7d0f78 tweaks: reshuffle a declaration and six calls of free(), to avoid a leak
If the user chose to skip making a backup,
'backupname' would not be freed.
2020-05-29 13:57:38 +02:00
Benno Schulenberg
4b4a8be58b files: before prompting, show also the reason why the backup failed
Also, do not prompt when there is no space left on the device,
because then trying to save the actual file would likely lead
to truncating it, resulting in an empty file.
2020-05-29 11:57:33 +02:00
Benno Schulenberg
512b0fd32d files: take into account that also closing a backup file can fail
Only when fclose() is called, does the data get flushed out to disk,
and maybe only then the system realizes that there is no space left on
the device, as Chris noted in: https://savannah.gnu.org/bugs/?24000.
2020-05-29 11:40:27 +02:00
Benno Schulenberg
586d22109b files: show a warning when writing a backup fails, before prompting
Make the behavior similar to that of the other failure cases.

Also, plug a tiny memory leak.
2020-05-29 11:22:57 +02:00
Benno Schulenberg
47953bd6ac files: also when creating a backup fails, ask the user whether to proceed
When asking this question when deleting fails or writing fails,
it should be asked too when creating fails.  Otherwise the user
is blocked from saving the file -- until she realizes that maybe
toggling off backups would help.
2020-05-29 10:58:11 +02:00
Benno Schulenberg
11d3b01050 files: give a more precise warning when deleting an existing backup fails
This addresses https://savannah.gnu.org/bugs/?58410.
2020-05-29 10:48:01 +02:00
Benno Schulenberg
eddd8963e7 files: ask the user whether to proceed every time a backup fails
If the user answered "No" or "Cancel" the first time, they should
be allowed to answer "Yes" the next time -- possibly after fixing
the necessary permissions in another terminal.

This fixes https://savannah.gnu.org/bugs/?58442.

Bug existed since version 2.3.0, commit 3d411188.
2020-05-29 10:23:54 +02:00
Benno Schulenberg
160f07baba tweaks: simplify an error message, by mentioning just the main point
Also, correct a comment.
2020-05-28 19:30:09 +02:00
Benno Schulenberg
822d764d27 files: ignore errors when calling futimens() on a backup file
Access control lists can permit read and write access to a file
but not permit to manipulate any attributes of the file.  So it
is quite possible for futimens() to fail, just like chown() and
chmod() can fail, but this should be no cause for alarm: as long
as writing the backup file worked, then writing the file itself
will probably work too.
2020-05-28 17:19:45 +02:00
Benno Schulenberg
6d00e75dc2 tweaks: rename a function, to be more correct 2020-05-28 16:59:50 +02:00
Benno Schulenberg
90772ad05b backup: do not understand ^C as "Yes" when asking whether to continue
This fixes https://savannah.gnu.org/bugs/?58443.

Bug existed since version 2.3.0, commit 3d411188.
2020-05-28 14:58:05 +02:00
Benno Schulenberg
756b95748b tweaks: rename a struct element, to be shorter and preciser
And anyway, there are too many occurrences of 'current'.
2020-05-28 14:38:48 +02:00
Benno Schulenberg
8d31ad8a70 files: ignore errors when calling chmod() on a backup file
First, it is very unlikely that chmod() would fail as the user just
created the file herself.  Second, even if chmod() would fail, this
is not a problem, because we have created the file with read+write
permissions for the owner only, so the file cannot accidentally be
left accessible to unintended others.

But most of all, such a failure should not stop nano from trying to
write the backup file.  Only when the actual *writing* fails, should
we bother the user with a prompt.
2020-05-28 14:35:42 +02:00
Ryan Westlund
3480518a5c syntax: go: highlight the chan keyword, and the special +build comment
This fixes https://savannah.gnu.org/bugs/?58424
Reported-by: Ryan Westlund <rlwestlund@gmail.com>

Signed-off-by: Ryan Westlund <rlwestlund@gmail.com>
2020-05-26 16:50:31 +02:00
Benno Schulenberg
b48dfde3b2 files: remove two superfluous calls for shielding temp files from others
If there are still systems where mkstemp() creates world-readable
temporary files, then please holler.  On current BSDs and on GNU,
I've verified that mkstemp() creates files with 0600 permissions.
2020-05-26 13:40:11 +02:00
Benno Schulenberg
f8366cd5c9 tweaks: remove two calls of umask() by specifying permissions directly 2020-05-26 12:36:18 +02:00
Benno Schulenberg
423105e371 tweaks: improve some comments and whitespace, and reshuffle a few lines
Also, silence a compiler warning.
2020-05-25 19:49:17 +02:00
Benno Schulenberg
5a7cdacf46 startup: allow presetting case-sensitive search also in the tiny version
If nanorc-file support is re-enabled (--enable-tiny --enable-nanorc),
then it ought to be possible to set case sensitivity at startup.
2020-05-25 19:08:00 +02:00
Benno Schulenberg
d909291b0c tweaks: rename one of the flag symbols, to be clearer
I kept understanding 'BACKUP_FILE' as a noun instead of as an imperative.
2020-05-25 18:52:09 +02:00
Benno Schulenberg
b30522463a files: do not append but truncate when allowing insecure backups
When deleting an existing backup file failed, we do not want to
append to this file, but want instead to overwrite it (when the
user has put 'set allow_insecure_backup' in their nanorc file).

Also, when using O_EXCL (in the normal, secure case), O_APPEND
is pointless, because the file will be created and thus empty.

This fixes https://savannah.gnu.org/bugs/?58439.

Bug existed since version 2.2.5, commit 461519cc.
2020-05-25 12:22:15 +02:00
Benno Schulenberg
5449d1e6a5 files: ignore errors when calling chown() on a backup file
A normal user can change the group of a file (if the user is a member
of that group), but cannot change the owner of that file.  So, when a
user edits a file that belongs to a different user, the call of fchown()
will fail.  But there is no harm in that.  Also when the user is root,
there is no harm in fchown() failing -- it will simply mean that the
backup file will remain owned by root and will not be writable by the
intended owner (when root has the normal umask of 0022).

This fixes https://savannah.gnu.org/bugs/?58383.

Bug existed since version 2.2.5, commit 86be3af7.
2020-05-24 16:08:05 +02:00
Benno Schulenberg
d7743b05f0 tweaks: correct a comment, and drop a redundant (because nested) #ifdef
Also, drop an unneeded case-insensivity when comparing two strings,
as all commands in a nanorc file have to be in lower case.
2020-05-24 12:30:40 +02:00
Benno Schulenberg
8089f5ad54 build: do not let --disable-speller exclude also the formatter code
In the past, when Speller and Linter and Formatter were all bound
to ^T (later ones taking priority), it was easier to exclude also
the formatter code when --disable-speller was used.  But since the
formatter was reintroduced (in commit 34170611) and bound to its
own keystroke (M-F), this is no longer the case.
2020-05-24 12:08:50 +02:00
Benno Schulenberg
2579b105da tweaks: slightly improve the grouping of shortcuts in some help texts 2020-05-24 11:54:02 +02:00
Benno Schulenberg
09a004cad9 tweaks: order three menu names in the documentation slightly better 2020-05-24 11:24:49 +02:00
Benno Schulenberg
3162e73540 docs: copy the 4.9.3 news item from the release branch 2020-05-24 09:01:53 +02:00
Benno Schulenberg
2c5045bfce feedback: skip wiping the prompt bar when the shortcut printed a message
When, at a prompt, the user chose a function shortcut instead of typing
an answer, and this function printed some message to the status bar,
then we do not want to wipe this message.  Also: the message overwrote
and cleared the prompt bar, so there is no need to wipe the latter.

This fixes https://savannah.gnu.org/bugs/?56273.

Bug existed since version 4.0, since justifying started giving feedback
(or rather since version 4.1, since M-J no longer crashed).
2020-05-22 12:12:36 +02:00
Benno Schulenberg
53c5ace8c3 tweaks: rename a symbol, away from a double abbreviation 2020-05-22 10:04:33 +02:00
Benno Schulenberg
e0d00bc750 tweaks: avoid a compiler warning 2020-05-21 10:47:04 +02:00
Benno Schulenberg
b72f3b10ba prompt: at Yes-No, do not treat a screen resize as an invalid keystroke
Commit 12cf1c99 added a beep() for every invalid keystroke at the
Yes-No prompt, but overlooked that KEY_WINCH is not invalid.

This fixes https://savannah.gnu.org/bugs/?58422.

Bug existed since version 4.8, commit 12cf1c99.
2020-05-21 09:50:13 +02:00
Benno Schulenberg
c9482bcd2b display: do not try to draw content when there is no open buffer yet
Commit b63c90bf avoided creating an empty buffer before asking the
yes-no question when encountering a lock file at startup, but the
SIGWINCH code still expected to have an open buffer whose contents
to show.

This fix also has the pleasant effect that, when resizing the screen
at the lock-file yes-no prompt, the title bar doesn't suddenly appear.

This fixes https://savannah.gnu.org/bugs/?58414.
Reported-by: Liu Hao <lh_mouse@126.com>

Bug existed since version 4.9, commit b63c90bf.
2020-05-21 09:24:02 +02:00
Benno Schulenberg
747ce3b5da tweaks: don't bother statting the lock file before unlinking it
If unlinking would fail because the parent directory is unwritable,
then a check in has_valid_path() would have prevented do_lockfile()
from being called at all.
2020-05-20 16:56:32 +02:00
Benno Schulenberg
10800ee410 locking: prevent a symlink attack by not opening an existing lock file
If in between the unlink() in delete_lockfile() and the fopen() in
write_lockfile() some other process creates a symlink in the place
of the lock file, then the fopen() could unexpectedly overwite a
root-owned file (when the user is root).

This basically reverts the previous commit, b4299f4f, but makes the
code a bit conciser.
2020-05-20 16:22:15 +02:00
Benno Schulenberg
b4299f4f4e tweaks: don't bother using the exclusive flag when creating a lock file
One microsecond earlier, the lock file has been deleted (if it existed),
so, if between our unlink() and our open() some other process managed to
recreate the lock file... well, we want to delete it *again*.  So, just
overwrite and truncate the lock file (if it exists).

When the lock file did NOT exist (a few microseconds earlier, when
checking in do_lockfile(), before calling write_lockfile()), then
the user expects the lock file to be written, so: just write it.

That between the check and the actual writing of the lock file there
is a small window of opportunity for other processes to write this
lock file is unfortunate, but it is not a reason to bother the user
with an error message when it happens.
2020-05-19 17:07:31 +02:00
Benno Schulenberg
c45df589fa locking: ignore the insecure-backup flag when creating a lock file
One microsecond before a lock file is created an existing lock file
has been deleted, and if that deletion failed, writing the lock file
is aborted.  So why should writing the lock file not be aborted when
the lock file cannot be exclusively created one microsecond later?
This makes no sense.  So... always include the O_EXCL flag, also
when the INSECURE_BACKUP flag is set.

(And anyway: lock files are not an essential part of editing, they
are just a small service to the user, AND they have nothing to do
with backups, so a backup flag should not influence them.)
2020-05-19 14:56:37 +02:00
Benno Schulenberg
44fd299921 tweaks: add a symbol, in order to condense three function calls 2020-05-17 19:11:54 +02:00
Benno Schulenberg
40a0463250 tweaks: reshuffle an assignment, for conciseness, and rename a variable 2020-05-17 11:34:22 +02:00
Benno Schulenberg
187843d2da tweaks: exclude a bit of bracketed-paste code from the tiny version
The tiny version does not support bracketed pastes.
2020-05-14 18:47:50 +02:00
Benno Schulenberg
0f2dd8456f usage: unabbreviate option arguments where possible
And make it clearer what kind of argument is expected:
digits, characters, or a program name.
2020-05-14 17:27:15 +02:00
Benno Schulenberg
821fbf713d tweaks: reshuffle a bit of code, to elide an #ifndef 2020-05-14 11:44:21 +02:00
Benno Schulenberg
ebc2364742 tweaks: move a fragment of code to the one branch that needs it
When two lines are joined, 'refresh_needed' is already set to TRUE,
so only when a midline character is deleted the check for a changed
number of chunks is needed.
2020-05-14 11:43:30 +02:00
Benno Schulenberg
15fadd700a tweaks: rename a function, to be more precise, and reshuffle it 2020-05-13 12:43:22 +02:00
Benno Schulenberg
78bfc9223a tweaks: add a condition, so that two ifs can be elided
Now all functions that are relevant only to softwrapping
get called only when softwrapping is on.

This also allows to elide an intermediate function call.
2020-05-13 12:32:57 +02:00
Benno Schulenberg
e8e9b8ad82 tweaks: move an 'if', to not call leftedge_for() when not softwrapping 2020-05-13 12:01:55 +02:00
Benno Schulenberg
964771afc3 tweaks: reshuffle a condition, for symmetry 2020-05-13 11:11:24 +02:00
Benno Schulenberg
fe94999c1c tweaks: don't bother overwriting a CR -- decreasing the length is enough
The string of bytes get properly terminated by encode_data(); there is
no need to do that earlier.
2020-05-13 10:31:39 +02:00
Benno Schulenberg
56bf29409b tweaks: correct a comment, and avoid third repetition of some conditions 2020-05-12 20:53:08 +02:00
Benno Schulenberg
fcbf85887b files: never report a file as being of mixed format
A file is always in either Unix or DOS or Mac format, and should
by default be saved again in that same format.

Any lone CRs or LFs after the first line should not change the
format that was deduced from that very first line.
2020-05-12 18:55:31 +02:00
Benno Schulenberg
ac0f2c9485 files: do not let a stray CR in a DOS file trigger Mac format
Only when a CR is seen before any LF, and the CR is not followed
by a LF, should this CR be interpreted as a line separator.  And
only then the file should be reported as being in Mac format --
as long as --noconvert is not used.

This fixes https://savannah.gnu.org/bugs/?58357.

Bug existed since at least version 2.0.6.
2020-05-12 17:25:04 +02:00
Benno Schulenberg
0a1817e893 tweaks: exclude an unneeded fragment of code from the tiny version 2020-05-12 11:09:23 +02:00
Benno Schulenberg
b18f1265ff tweaks: reshuffle a condition, to make a little more sense 2020-05-11 19:40:17 +02:00
Benno Schulenberg
2dd97a0352 tweaks: rename two variables, and reduce the scope of a third 2020-05-11 16:59:39 +02:00
Benno Schulenberg
ef4b0edd4e tweaks: rename a symbol, to better suit its purpose, and reduce its scope 2020-05-11 16:44:16 +02:00
Benno Schulenberg
b47d111a3d tweaks: don't use a symbol for other purposes 2020-05-11 16:18:03 +02:00
Benno Schulenberg
d80ecf0209 tweaks: trim some oververbose comments -- they overshadow the code
The text was harder to understand than the code itself.
2020-05-11 15:58:08 +02:00
Benno Schulenberg
ff4973458c tweaks: adjust the file format indicator in a quicker way 2020-05-11 15:32:41 +02:00
Benno Schulenberg
f9ff902bbc tweaks: drop two redundant conditions, and improve three comments 2020-05-08 11:06:43 +02:00
Benno Schulenberg
95c966c3fc tweaks: do the saving of histories in a single place
Also, when finish() is called when the user presses Cancel upon
encountering a lock file, there is no need to save any history
files because nothing has changed.
2020-05-08 11:01:37 +02:00
Benno Schulenberg
982e226c3f tweaks: elide three parameters, as they are the same for both calls 2020-05-08 10:40:03 +02:00
Benno Schulenberg
42ca89039a tweaks: improve three comments, drop one, and unwrap a line 2020-05-08 10:21:02 +02:00
Benno Schulenberg
07b48024d1 tweaks: condense a comment, and reshuffle some conditions 2020-05-07 13:34:07 +02:00
Benno Schulenberg
1c4dd79b9b files: trigger the Easter egg only when "zzy" is typed at the prompt
When the user mentions the file "zzy" on the command line,
the magic spell "Xyzzy" does not actually get typed, so the
Easter egg should then not be triggered.
2020-05-07 13:28:41 +02:00
Benno Schulenberg
56fc8f6d30 tweaks: improve a comment, reshuffle a scroll command, elide a variable
Also, drop an unneeded keyboard check: the next check is just a few
microseconds away.
2020-05-06 17:29:20 +02:00
Benno Schulenberg
ad1331527e color: when syntax coloring is toggled back on, calculate multiline data
This will not catch all cases, but at least it will precalculate the
data when syntax coloring was toggled off (M-Y) while in one buffer
and then toggled back on after having switched to a new buffer.
2020-05-01 14:08:55 +02:00
Benno Schulenberg
1bbf07b27e color: avoid allocating emptiness when there are no multiline regexes
When a file is saved under a different name, and as a result the
applicable syntax changes, and the old syntax had multiline regexes
and the new syntax doesn't, then the call of precalc_multicolorinfo()
in write_file() should not result in nano setting up a multicache of
zero bytes for each line in the buffer.

(Problem was found by locally letting nano crash when zero bytes are
allocated, and then happening to rename a file.py to a file.sh.)
2020-05-01 13:59:56 +02:00
Benno Schulenberg
b9deb883fa tweaks: shorten the name of a symbol, to match its bindable function 2020-05-01 13:25:15 +02:00
Benno Schulenberg
9c4ebed3ff tweaks: remove an unneeded element from the openfilestruct 2020-05-01 12:38:02 +02:00
Benno Schulenberg
e64e54d57f tweaks: condense a bit of code, by reusing an existing variable 2020-05-01 12:37:50 +02:00
Benno Schulenberg
d4ee6a2b53 options: rename --tempfile to --saveonexit, to be far clearer
A long option should describe what it does, not vaguely hint at it.

Also, in several places of nano's code we deal with actual temp files,
and then having a flag called TEMP_FILE that doesn't have anything to
do with temp files is somewhat confusing.
2020-04-30 19:12:54 +02:00
Benno Schulenberg
af062af490 docs: mention that doing a full-buffer operation wipes away all anchors 2020-04-30 18:58:17 +02:00
Benno Schulenberg
4bdd6013b0 anchor: do not let piping and spelling transfer an anchor to the top
Just let all anchors disappear when doing an external spell check or
formatting or piping the buffer through an external command, because
leaving just a single anchor on the top line is useless.

This fixes https://savannah.gnu.org/bugs/?58273.

Bug existed since commit 732cf887 from one month ago.  That code
causes an anchor to persist at the point where lines are removed.
2020-04-30 16:51:22 +02:00
Benno Schulenberg
11f099e1da anchor: during full justification preserve anchors as during single ones
When a single paragraph is justified, any anchor on any of its lines
gets moved to its first line.  Let a full justification do the same
for each of the paragraphs.

This fixes https://savannah.gnu.org/bugs/?58272 in a better way.
2020-04-30 16:07:31 +02:00
Benno Schulenberg
703cebaaac anchor: do not let a full justification transfer an anchor to the top
This fixes https://savannah.gnu.org/bugs/?58272.

Bug existed since commit 732cf887 from one month ago.  That code
causes an anchor to persist at the point where lines are removed.
2020-04-29 19:34:48 +02:00
Benno Schulenberg
4710b94cfb tweaks: move a function to before the one that calls it 2020-04-29 12:22:02 +02:00
Benno Schulenberg
5ca2fd887a startup: initialize colors only when the terminal is capable of colors
This avoids trying to show colors on a vt100, for example.
2020-04-29 12:07:31 +02:00
Benno Schulenberg
d1e1438ca0 tweaks: delete some unneeded code, and rename the function accordingly
When set_colorpairs() is called, no files have been loaded yet, so
no syntaxes will have been loaded yet either.  Thus it is pointless
to run through the list of available syntaxes.
2020-04-28 16:49:45 +02:00
Benno Schulenberg
382ec84248 tweaks: rename a function, to match with the boolean that guards it 2020-04-28 16:38:27 +02:00
Benno Schulenberg
bc4240dda5 tweaks: rename a function, to better describe what it does
Its major function is to find an applicable syntax, if there is any.
And if the syntax hasn't been used before, to prime its color pairs.

Also, reshuffle a line to be able to elide an #ifdef.
2020-04-28 16:34:45 +02:00
Benno Schulenberg
b97da1dfe4 files: reinitialize the palette only when the syntax actually changed 2020-04-28 15:30:00 +02:00
Benno Schulenberg
e62a6964f7 syntax: sql: condense some regexes, and reduce their number 2020-04-26 19:32:44 +02:00
Benno Schulenberg
fd70c25d21 menus: remove unneeded words and shortenings from key labels
In "Cut Text" and "Paste Text" the word "Text" is superfluous.  (It
could even be called slightly misleading, because by default ^K will
cut the current line, whether or not it contains text.)

The "Get Help" is of course inherited from Pico, but to me it has
always sounded a bit as if it would go search help on the internet.

Instead of "Spelling" I would have preferred "Spellcheck", but that
gets a bit too cramped on an 80-column terminal.

For ^C I've chosen "Location" because I tend to understand "Position"
as a verb, especially when seen next to "Go To Line" (even when having
two items with the same meaning next to each other doesn't make sense).

"Mark Text" has simply always been wrong.  It doesn't mark anything,
but just *sets* the mark (or unsets it, but that normally happens
automatically, no need to mention that in the label).

The "Cut Till End" and "Full Justify" get shown only on very wide
terminals, and at such widths there is enough room for each label
to write out those two labels in full.
2020-04-21 19:14:28 +02:00
Benno Schulenberg
227467adb9 syntaxes: remove some superfluous outer parentheses from regexes
Also, standardize some comments, condense a few regexes, add some
word-edge anchors, and remove some superfluous backslashes.
2020-04-21 12:49:29 +02:00
Benno Schulenberg
afce41c754 syntaxes: move the rules for Fortran and Povray files down to extra/
Fortran and POV-Ray files are not found on any regular install of a
Unixy system nor in common software packages.  People who want these
syntaxes will have to make a little effort to enable them.
2020-04-21 12:11:44 +02:00
Ryan Westlund
36e22c99a1 syntax: haskell: new file -- coloring rules for Haskell programs
Adapted from the original coloring rules by Alex Taber found at:
  https://github.com/scopatz/nanorc/blob/master/haskell.nanorc

Signed-off-by: Ryan Westlund <rlwestlund@gmail.com>
2020-04-21 11:56:24 +02:00
Benno Schulenberg
dd25d807df syntaxes: remove some stuff that has been commented out for a long time 2020-04-20 19:22:39 +02:00
Benno Schulenberg
fea5d7c612 syntaxes: uniformize the initial comment 2020-04-20 19:21:56 +02:00
Benno Schulenberg
c859fd40b6 syntax: markdown: do not colorize text between two bold words as italic
Also, do not colorize the text between two stricken-through words,
do not colorize text immediately after an indented piece of code,
but do give color to a double trailing space.

Signed-off-by: Ryan Westlund <rlwestlund@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2020-04-20 13:42:00 +02:00
Benno Schulenberg
890e12fc79 docs: note Marco as the original author of the bookmarking code 2020-04-16 11:05:14 +02:00
Benno Schulenberg
ab1a5c7abb tweaks: rename two parameters, away from abbreviations 2020-04-15 17:50:59 +02:00
Benno Schulenberg
079a679431 tweaks: rename two functions, to better indicate what they do 2020-04-15 17:20:03 +02:00
Benno Schulenberg
56d1214187 syntax: move distro-specific files down to a subdirectory, syntax/extra/ 2020-04-14 19:05:41 +02:00
Benno Schulenberg
fb53ad9c3a syntax: markdown: new file -- coloring rules for Markdown files
First-draft-by: Ryan Westlund <rlwestlund@gmail.com>
2020-04-14 16:15:49 +02:00
Benno Schulenberg
5755ecdbfc options: let --afterends affect also the deleting of words (Ctrl+Delete)
It makes more sense that <Ctrl+Delete> deletes the same thing as what
<Shift+Ctrl+Right> would select.

Suggested-by: Liu Hao <lh_mouse@126.com>
2020-04-14 12:14:49 +02:00
Benno Schulenberg
bcaa1ef7f2 docs: explain how anchors work, and document their bindable functions 2020-04-13 12:20:36 +02:00
Benno Schulenberg
9bb9a747e2 feedback: indicate an anchor with a "+" in the line-number margin 2020-04-13 11:48:36 +02:00
Benno Schulenberg
e86180119e tweaks: implement the anchor routines in a different way 2020-04-13 11:35:40 +02:00
Benno Schulenberg
40053593a8 general: rename "bookmark" to "anchor", to sound less permanent 2020-04-13 11:25:29 +02:00
Benno Schulenberg
732cf88786 text: retain a bookmark when two lines are joined or something is cut
Also, do not copy the bookmark into the cutbuffer, so it will not get
pasted elsewhere.
2020-04-13 11:10:23 +02:00
Marco Diego Aurélio Mesquita
9fb0beca1d bindings: hard-bind the bookmark functions to M-Ins and M-PgUp/M-PgDn
Bind the toggling of a bookmark to <Alt+Insert>, and the jumping to the
previous and next bookmark to <Alt+PageUp> and <Alt+PageDown>, so that
these functions are available by default.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2020-04-13 10:51:40 +02:00
Marco Diego Aurélio Mesquita
f091c34bac new feature: bindable functions for toggling and jumping to "bookmarks"
With the 'bookmark' function, the user can place a bookmark on any
line in the buffer.  Multiple lines can be bookmarked in this way.
With 'prevbookmark' and 'nextbookmark', the user can then easily
return to the bookmarked lines.  The search for a bookmark wraps
around, as if start and end of buffer are connected.

[However, in this implementation, when a bookmarked line is deleted,
the bookmark is deleted too.  This is undesirable.  Also, when such
a deleted line is pasted elsewhere, the bookmark reappears with it,
and when pasted multiple times, the bookmark will be there as many
times.  This is thoroughly undesirable.  These behaviors will be
changed in a later commit.]

A bookmark is not yet visible in any way.

This fulfills https://savannah.gnu.org/bugs/?57577.
Requested-by: Ken Tyler <kent@werple.net.au>

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2020-04-13 10:51:40 +02:00
Benno Schulenberg
fd9f6e4619 syntax: mgp: drop the almost-empty MagicPoint file and syntax
It colored any word after a % sign.  But a good syntax would color
only the valid commands, and also the ones after a comma.
2020-04-12 10:40:29 +02:00
Benno Schulenberg
4f9bebddec syntax: email: rename file and syntax, away from the mistaken 'mutt'
Also, colorize lines that are multiply quoted, and email addresses,
and URLs.
2020-04-10 13:01:57 +02:00
Benno Schulenberg
edf2d8d68f docs: mention that the dedicated cursor-moving keys are not rebindable 2020-04-10 12:25:02 +02:00
Benno Schulenberg
654d694e39 tweaks: simplify the counting of characters in a section
The line after the given section is always NULL (or when it is not,
it is intended to be NULL), so always subtract 1 at the end.
2020-04-09 12:58:41 +02:00
Benno Schulenberg
19a6120dc8 tweaks: rename a function, to be more general and clearer 2020-04-09 12:27:07 +02:00
Benno Schulenberg
f4a33b868a tweaks: delete the now-unused partitioning and unpartitioning routines 2020-04-09 12:12:04 +02:00
Benno Schulenberg
cd3db5fcc4 cutting: change the implementation of cutting to not use partitioning
This has the pleasing effect of not changing the linestruct of the
succeeding line when a line is cut.

This addresses https://savannah.gnu.org/bugs/?56226.
2020-04-09 11:45:10 +02:00
Benno Schulenberg
ae5a4ecee2 cutting: overhaul the pasting routine, to not make use of partitioning
This has the pleasing effect of not changing the linestructs of the
current line nor of the line after it (if any).
2020-04-09 11:29:44 +02:00
Benno Schulenberg
fd4a5fc473 files: write out a marked region without partitioning the buffer
Use the same mechanism as when copying a marked region: temporarily
clipping the buffer.
2020-04-09 11:07:05 +02:00
Benno Schulenberg
66e64dd2d2 docs: in the sample nanorc file, refer instead of duplicating
Instead of duplicating information, just refer to 'man nanorc'.

Also reshuffle a paragraph, and add a suggestion to just select
the syntax files that will actually get used.
2020-04-09 10:27:39 +02:00
Benno Schulenberg
a0119b83ca tweaks: add two comments, and improve another 2020-04-08 11:25:02 +02:00
Benno Schulenberg
dba7a8a70a copying: do not forget to update the screen when M-6 is pressed
This fixes https://savannah.gnu.org/bugs/?58140.

Bug existed since commit f52b6cf1 from one week ago.
2020-04-08 11:04:35 +02:00
Benno Schulenberg
5c3a22dbd6 tweaks: rename a function, to be more precise, and reshuffle some things 2020-04-07 19:19:26 +02:00
Benno Schulenberg
b70510f4be docs: copy the 4.9.2 news item from the release branch 2020-04-07 14:35:42 +02:00
Benno Schulenberg
2d4bacf61d docs: stop mentioning that --wordchars overrides --wordbounds
Since the previous commit, it no longer does.  Instead, the two
interfere, and the user probably wants to use just one of them.
2020-04-06 19:07:02 +02:00
Benno Schulenberg
547de4a7bb counting: count words correctly also when --wordchars is used
It should give the same result as 'wc -w' as long as the content
of 'wordchars' does not affect the counting.

This fixes https://savannah.gnu.org/bugs/?58123.

Bug existed since version 2.6.2, since the --wordchars option was
introduced in commit 6f12992c.
2020-04-06 11:17:43 +02:00
Benno Schulenberg
845a5973c9 counting: count words and characters without partitioning the file 2020-04-05 17:29:54 +02:00
Benno Schulenberg
6e5195f650 tweaks: invert a condition, to have two clauses in a more logical order
First the clause for the intro text and the normal lines, and then the
clause for the continuation lines (that are narrower and indented).

Also, avoid blanking the status bar when initializing the subwindows
anyway, and avoid an unneeded resfreshing call -- the bottombars()
function will take care of that.
2020-04-03 17:19:15 +02:00
Benno Schulenberg
f3624b1b87 build: fix compilation when configured with --enable-tiny 2020-04-03 17:12:28 +02:00
Benno Schulenberg
1a2c9044d7 display: blank the status bar for a copy operation, like for cut & paste
This way an earlier "Copied nothing" or other message cannot confuse
the user.
2020-04-03 16:34:27 +02:00
Benno Schulenberg
9a67d7958f undo: choose the proper x positions to place the cursor and rejoin lines
Normally, when undoing an <Enter> that created automatic indentation,
the created whitespace should be skipped when rejoining the two lines.
In other words: take the data starting from tail_x in the second line.
But when the <Enter> occurred at the end of leading whitespace, then
that whitespace has disappeared from the original line and it should
be copied back in from the second line.  That is: from x is zero.

This fixes https://savannah.gnu.org/bugs/?58108.
Reported-by: Liu Hao <lh_mouse@126.com>

Bug existed since version 4.9, commit 1961c052.
2020-04-03 11:21:24 +02:00
Benno Schulenberg
23f73cb8b3 tweaks: exit from the writing loop as soon as the last line is reached
Avoid having to decrement the count in order to offset the increment
at the end of the loop.

Also, declare a variable on a separate line, and rename it.
2020-04-01 16:05:45 +02:00
Benno Schulenberg
9f6962f3f1 tweaks: condense a comment, and express a condition in a different way 2020-04-01 15:54:08 +02:00
Benno Schulenberg
958e3ec201 feedback: show a message also when trying to copy an empty region 2020-03-31 19:44:32 +02:00
Benno Schulenberg
ce9cfdaa45 tweaks: normalize the indentation after the previous change
Also improve a comment.
2020-03-31 19:44:32 +02:00
Benno Schulenberg
56a111afa3 tweaks: fold two blocks into each other, to elide three overlapping cases 2020-03-31 19:42:22 +02:00
Benno Schulenberg
38bbdf8fc3 tweaks: change a helping variable, to make two blocks still more similar 2020-03-31 19:27:07 +02:00
Benno Schulenberg
a0e523cd4b tweaks: add a helping variable, to slightly condense the code
And to prepare for folding two blocks together.
2020-03-31 19:21:38 +02:00
Benno Schulenberg
7660849b8f tweaks: invert a condition, to see the similarity between the two modes
The two modes being: the normal full-line cutting, and --cutfromcursor.
2020-03-31 19:17:17 +02:00
Benno Schulenberg
4b814698bd copying: with --nonewlines, don't add a final newline to the cutbuffer
This fixes https://savannah.gnu.org/bugs/?58086.

Bug existed since commit f52b6cf1 from yesterday.
2020-03-31 19:12:46 +02:00
Benno Schulenberg
96046f1e82 copying: when using M-6, copy the final line in the buffer just once
When using --nonewlines and the cursor has arrived at the end of the
final line, each press of M-6 would add another copy of that line to
the cutbuffer.  That is clearly not the right behavior.

Also, give feedback when a press of M-6 does not actually copy anything.

This fixes https://savannah.gnu.org/bugs/?58088.

The bug was old -- it existed since before version 2.2.0.
2020-03-31 17:59:21 +02:00
Benno Schulenberg
387be713c8 docs: copy the 4.9.1 news item from the release branch 2020-03-31 14:09:08 +02:00
Benno Schulenberg
d9943120ed tweaks: move two functions, to have them in a more logical order
The logical order being: cut, copy, paste.
2020-03-30 19:20:18 +02:00
Benno Schulenberg
a1907d77f8 tweaks: add a helping variable, in order to unwrap three lines
Also, move an administrative thing to after the actual operations.
2020-03-30 19:13:50 +02:00
Benno Schulenberg
f25a3f8a36 tweaks: elide three functions that are called just once
The function that they were called from has shrunk a lot,
so there is now room to write their content out in full.
2020-03-30 19:05:57 +02:00
Benno Schulenberg
9f1c3c8513 memory: plug a leak, by freeing the cutbuffer after a bracketed paste
Also, remove an unneeded assignment -- the 'cutbottom' variable is
needed only when consecutives cuts (^K) or copies (M-6) are made.
2020-03-30 16:55:38 +02:00
Benno Schulenberg
d1521c584d tweaks: elide a now-unused parameter -- it is always FALSE 2020-03-30 16:55:30 +02:00
Benno Schulenberg
f52b6cf19f copying: change the implementation, away from cutting plus copying back
First cutting the text to be copied (before copying it back into the
buffer) had unwanted side effects: it moved the cursor, and changed
the linestructs of the current line and the line where the mark was.

[This takes thirty more lines, but the idea is to later get rid of
the partitioning routines entirely.]
2020-03-30 16:55:17 +02:00
Benno Schulenberg
59040169ed tweaks: get rid of a bunch of annoying casts, and thus condense the code 2020-03-29 20:17:32 +02:00
Benno Schulenberg
8f6559828d files: make filtering of the entire buffer into a new buffer work again
This fixes https://savannah.gnu.org/bugs/?58076.

Bug existed since version 4.9, commit 477a9b33.
2020-03-29 18:04:36 +02:00
Benno Schulenberg
619962ee18 undo: when undoing a line cut, place the cursor back where it was
This fixes https://savannah.gnu.org/bugs/?58074.

Bug existed since version 4.9, commit ac612545.
2020-03-29 14:25:15 +02:00
Benno Schulenberg
7ebe44ac25 tweaks: rename a symbol, to be more accurate, and reshuffle two lines 2020-03-29 14:24:16 +02:00
Benno Schulenberg
0cc2104257 tweaks: elide a parameter, by calling the relevant function beforehand
This means that in most cases mark_is_before_cursor() is called twice:
once before get_region() is called, and once by get_region() itself.
This small duplication of effort is acceptable: the affected functions
are not time critical, and it makes the code shorter.
2020-03-29 13:22:17 +02:00
Benno Schulenberg
9a6158cd94 input: stop recognizing the raw escape sequences for F13 to F16
It is very unlikely that anyone uses those keystrokes: 1) no keyboard
has such keys; 2) the default bindings for these keys were removed a
year and a half ago, and no one complained; 3) for several years nano
did not recognize the modern xterm escape sequences for F13 to F16,
and no one ssh'ing from a new machine to an old machine complained.

The only people who might be affected by this removal are Konsole users:
a Konsole claims to be an xterm, but sends its own peculiar "Esc O 2 X"
sequences for F13 to F16.  Using the data from terminfo, ncurses will
not recognize those sequences, and will pass them untranslated to nano.
When nano now stops recognizing them too...  Well, let's see if there
are any Konsole users that use F13 to F16.
2020-03-29 12:04:37 +02:00
Benno Schulenberg
7d3aad403d options: make -S the short synonym of --softwrap
The form -$ is still accepted, but is deprecated.
2020-03-27 17:02:55 +01:00
Benno Schulenberg
aa70f3d95e options: stop recognizing the obsolete --morespace and --smooth
They have been no-ops for a year.

Also remove their documentation entries.

(The nanorc options still remain -- to be removed next year.)
2020-03-27 16:54:09 +01:00
Benno Schulenberg
ec457dc33a tweaks: rename a variable, for shortness and contrast 2020-03-27 15:29:48 +01:00
Benno Schulenberg
31b978ca3e docs: reduce the TODO file to a reference to the bug tracker on Savannah
All those items that were marked as DONE are not actually TO-DO items.

Also, most of those things are mentioned in the IMPROVEMENTS file too.
So, add the few that were missing there, and condense/rewrap some.
2020-03-26 19:27:46 +01:00
Benno Schulenberg
9a4586557b build: stop distributing a nano.spec file
We do not provide an RPM package.  And distros like Fedora, Mageia,
and Suse have their own spec files -- they don't need ours.  And in
case anyone would like to create their own RPM package from nano,
they can look at the spec files of those distros.
2020-03-26 17:08:36 +01:00
Benno Schulenberg
02c48dc8a4 tweaks: delete another pointless ChangeLog 2020-03-26 13:17:41 +01:00
Benno Schulenberg
384c9aaad3 tweaks: delete a ChangeLog that is no longer updated and is incomplete
It is incomplete at the top, in the middle, and at the bottom.

Also, the Makefile from gettext automatically includes this ChangeLog
in a release tarball when the ChangeLog exists.  This is an unneeded
burden on the tarball, as I don't think any distro installs this file
in nano's doc directory.  And if any does, I don't think they should:
it is not helpful for using nano.

If anyone would like to know more about the history of a PO file,
since we now have git, they can do something like:

        git log -p po/<LANGUAGECODE>.po |
        grep -e Revision-Date -e Last-Translator |
        grep -A1 "^\+.PO" | less
2020-03-26 13:17:21 +01:00
Benno Schulenberg
0c249de9e5 tweaks: for each version, mention the changes to the PO files last
Also, rewrap some lines, and  normalize how function names are listed,
back until version 0.9.9.
2020-03-26 12:18:22 +01:00
Benno Schulenberg
abf4658ab9 tweaks: uniformize some old translator credits
And add two of the earliest that were missing.
2020-03-25 19:37:09 +01:00
Benno Schulenberg
ba25d0df1d tweaks: fix twenty typos, in old Changelogs and in some comments
They were found by a run of 'codespell' at https://fossies.org/.

Reported-by: Jens Schleusener <Jens.Schleusener@fossies.org>
2020-03-25 16:57:43 +01:00
Benno Schulenberg
e7fa43d600 po: update translations and regenerate POT file and PO files 2020-03-24 11:21:03 +01:00
Benno Schulenberg
49a84f9e8a bump version numbers and add a news item for the 4.9 release 2020-03-24 11:11:22 +01:00
Benno Schulenberg
6ee657b7d8 docs: trim some TODO items, and condense several others
Remove the suggested clever bracket matching.
2020-03-23 11:30:34 +01:00
Benno Schulenberg
6866ea0d0e justify: skip over in-line whitespace only, not over leading whitespace
This fixes https://savannah.gnu.org/bugs/?58028.

Bug existed since commit 107abd26 from yesterday.
2020-03-23 11:00:17 +01:00
Benno Schulenberg
34d38fe1c6 undo: treat a cut-until-end-of-buffer like a backward marked region
This fixes https://savannah.gnu.org/bugs/?58024.

Bug existed since commit ac612545 from two weeks go.
2020-03-22 19:16:22 +01:00
Benno Schulenberg
b17309b652 tweaks: when extending the marked region, include also exotic blanks
Just in case someone uses multibyte whitespace characters.
2020-03-22 18:45:46 +01:00
Benno Schulenberg
107abd2654 justify: skip over blanks after the region, to not skew the indentation
This fixes https://savannah.gnu.org/bugs/?58023.

Bug existed since commit 3225c71e from six days ago.
2020-03-22 17:48:39 +01:00
Benno Schulenberg
f528ced22b tweaks: use a symbol instead of a number, and drop two unneeded casts 2020-03-22 14:29:10 +01:00
Benno Schulenberg
71628ad0b8 build: fix compilation for --enable-tiny --enable-justify 2020-03-22 13:41:28 +01:00
Benno Schulenberg
481529e865 input: accommodate silly emulators that have LF instead of CR in a paste
Even though a user would never type ^J to start a new line, accept it
as a synonym of <Enter> (^M) in a bracketed paste, because apparently
bash accepts it as a synonym too.

This works around https://savannah.gnu.org/bugs/?58010.
2020-03-20 14:25:27 +01:00
Benno Schulenberg
bc6645f753 tweaks: move two functions to before the ones that call them 2020-03-19 15:12:40 +01:00
Benno Schulenberg
c1ca578853 tweaks: unwrap four lines, and use explicit codes where possible
The explicit codes are slightly faster, and they show the correspondence.
2020-03-19 14:55:39 +01:00
Benno Schulenberg
4ce2e146ea tweaks: elide three unneeded #defines
Backspace and Tab and Carriage Return have standard backslash escapes.
2020-03-19 14:40:51 +01:00
Benno Schulenberg
39ed865043 docs: improve the descriptions of --softwrap and 'set softwrap' 2020-03-19 13:10:28 +01:00
Benno Schulenberg
0de4700002 gnulib: update to its current upstream state 2020-03-17 09:56:54 +01:00
Benno Schulenberg
ea95ad24be usage: improve the description of --softwrap
Concisely say what the option actually does.
2020-03-17 09:51:03 +01:00
Benno Schulenberg
415e55ff37 tweaks: move a function to before the one that calls it 2020-03-16 10:17:15 +01:00
Benno Schulenberg
c20134c20d tweaks: rename a variable, away from a single letter 2020-03-16 10:15:01 +01:00
Benno Schulenberg
56308b3256 display: keep the help items aligned, by not writing too many characters
Only for the last item at the end of each of the two help lines there
are sometimes a few extra columns available.  Do not use these extra
columns also for the other help items, because apparently, when wmove()
lands in the second column of a double-width character, it does not
wipe out this character (replacing it with a space) but goes to the
next column instead, causing a misalignment of the text.

This fixes https://savannah.gnu.org/bugs/?57994.

Bug existed since version 1.3.12, commit e806ab84.
2020-03-16 09:44:12 +01:00
Benno Schulenberg
3d8cd65b1b tweaks: reshuffle a condition, for compactness 2020-03-15 19:01:07 +01:00
Benno Schulenberg
2b6924ef6e display: do not show a "[" double-width placeholder when softwrapping
The placeholder half-duplicates the character that is actually shown
at the beginning of the next row.  When NOT softwrapping, showing a
"[" before the ">" kind of makes sense: to avoid having a gaping gap
there.  But when softwrapping, all characters of the line will be on
the screen (except when going offscreen at the bottom), so there is
no need to show a placeholder for anything.

I imagine that when reading softwrapped Chinese or Japanese text,
things are easier to understand when no characters are shown that
are not actually in the text.

This avoids https://savannah.gnu.org/bugs/?57993.

Bug existed since version 2.8.6, commit 8490f4ac.
2020-03-15 17:00:05 +01:00
Benno Schulenberg
01d8b0e15d help: increase the minimum help-text width from 32 to 40 columns
Getting long words like "Rechtschreibprüfung" broken somewhere in
the middle doesn't look nice.
2020-03-15 14:04:57 +01:00
Benno Schulenberg
16f17f3f1b help: do not break a line inside the 17-column keystrokes area
When the description of a keystroke starts with a very long word,
or when it does not contain any spaces at all (like for Chinese
and Japanese), do not break in the blanks before the description
but instead break IN the description, at the edge of the screen.

In other words: when wrapping a help text, do not consider blanks in
the first 17 columns to be blanks (unless it is a continuation line).

This fixes https://savannah.gnu.org/bugs/?57987.

Bug existed since version 4.8, commit 1486f32d,
when the wrapping of help texts was improved.
2020-03-15 13:59:04 +01:00
Benno Schulenberg
09042f5499 tweaks: do some text alignments properly: with spaces, not tabs 2020-03-15 11:26:55 +01:00
Benno Schulenberg
3690d60b71 rcfile: rename bindable function 'suspendenable' to 'suspendable'
The name of a toggle function should match the name of the corresponding
option, like for 'mouse' and 'linenumbers' and 'smarthome' and such.
2020-03-15 11:17:46 +01:00
Benno Schulenberg
4dedb1c1b1 moving: do not put the cursor at end-of-line when in a help text
Keeping the invisible cursor at the left edge avoids any line getting
scrolled horizontally.

This fixes https://savannah.gnu.org/bugs/?57991.

Bug existed since version 2.8.2, since the help texts got generated
and displayed in a different way in order to become searchable.
2020-03-13 19:37:02 +01:00
Benno Schulenberg
067ee1a6b1 tweaks: highlight keystrokes in the documentation more consistently 2020-03-13 16:40:34 +01:00
Benno Schulenberg
0c1db4879e docs: update the missed occurrences of --suspendable / 'set suspendable' 2020-03-13 16:34:41 +01:00
Benno Schulenberg
02efc760bf tweaks: rename a symbol, to match the corresponding renamed option 2020-03-13 16:17:10 +01:00
Benno Schulenberg
a91bc04e04 docs: update the form of an option, --suspendable / 'set suspendable' 2020-03-13 15:58:56 +01:00
Benno Schulenberg
9a59cddcd4 options: rename --suspend to --suspendable, to make more sense 2020-03-13 15:54:24 +01:00
Benno Schulenberg
6ab754676a build: update the conditional placement of the "Go To Line" menu item
When either only --disable-justify or --disable-speller is used, the
"Go To Line" item should not be placed after the ^C Position item, to
keep the subsequent items (Undo, Redo, and so on) nicely paired.

(Things changed since the Linter is no longer bound to ^T by default.)
2020-03-13 12:24:44 +01:00
Benno Schulenberg
9917a05f04 tweaks: exclude a function when compiled without spell-checking support 2020-03-13 11:59:08 +01:00
Benno Schulenberg
fcda76f684 build: restore non-UTF8 fallbacks, to allow compiling with --disable-utf8
Commits b2c63c3d and 004af03e from yesterday mistakenly removed those
calls.
2020-03-13 11:43:31 +01:00
Benno Schulenberg
639f37669a docs: remove the note saying that nanorc files must be in Unix format
Since commit 98f038ad from a month ago, nanorc files do not need to be
in Unix format (LF) but may also be in DOS (CR+LF) and Mac (CR) format.
2020-03-12 19:03:02 +01:00
Benno Schulenberg
6d720bf7b2 tweaks: improve two comments, and remove an unneeded one 2020-03-12 17:18:10 +01:00
Benno Schulenberg
f3b030c8e5 tweaks: condense a fragment of code
Leave the skipping of subsequent blanks to the succeeding code.
2020-03-12 16:59:27 +01:00
Benno Schulenberg
6b8b7c9d55 tweaks: elide a supporting variable, to make four loops slightly faster
At the cost of making the return statements slower.  But, all-in-all,
this should be slightly quicker.
2020-03-12 16:47:39 +01:00
Benno Schulenberg
21ed79938e tweaks: normalize the indentation after the previous two changes 2020-03-12 15:54:19 +01:00
Benno Schulenberg
004af03ea5 tweaks: remove non-UTF-8 code from three more functions 2020-03-12 15:54:19 +01:00
Benno Schulenberg
b2c63c3d3c chars: optimize a function for the most common blanks: space and tab
Also, do not bother to provide separate code for the non-UTF-8 case.
Instead, optimize for plain ASCII characters.
2020-03-12 15:54:19 +01:00
Benno Schulenberg
ae139021eb tweaks: rename four more functions, to get rid of an abbreviation
Also, improve their comments.
2020-03-12 15:54:19 +01:00
Benno Schulenberg
f6dedf3598 tweaks: rename another function, to remove the obscuring abbreviation 2020-03-12 15:54:19 +01:00
Benno Schulenberg
8003842e5c tweaks: rename a function, to remove an obscuring abbreviation
The "mb" made the name harder to read.  Also, the function is
not only for multibyte characters but for any character.
2020-03-12 15:53:49 +01:00
Benno Schulenberg
01477d3b81 justify: never break a line in leading whitespace
This fixes https://savannah.gnu.org/bugs/?57984.

The bug was old -- it existed since at least version 2.0.6.
2020-03-12 10:15:57 +01:00
Benno Schulenberg
ebf9279f95 tweaks: rename two more functions, to match the style of others 2020-03-11 19:47:21 +01:00
Benno Schulenberg
304548ef82 tweaks: rename two functions, to match the style of others 2020-03-11 19:45:06 +01:00
Benno Schulenberg
dd6f129c3c tweaks: rename two functions, for shortness 2020-03-11 19:43:03 +01:00
Benno Schulenberg
c2f007afc5 tweaks: trim an unnecessary detail from an error message 2020-03-11 14:23:22 +01:00
Benno Schulenberg
8dc83951ee tweaks: normalize a translator hint, update one, and add another 2020-03-11 14:21:08 +01:00
Benno Schulenberg
b7dc5abca7 tweaks: rename two more variables, to harmonize with two others 2020-03-11 12:53:39 +01:00
Benno Schulenberg
8b784785ec tweaks: rename two variables, for distinctiveness 2020-03-11 12:23:07 +01:00
Benno Schulenberg
750b51c343 copyright: update to the current year for significantly changed files 2020-03-11 11:52:15 +01:00
Benno Schulenberg
e09ed765a1 syntax: nanorc: colorize 'rawsequences', not the obsolete 'rebindkeypad'
Bug existed since version 4.0, commit b596639f.
2020-03-10 16:21:02 +01:00
Benno Schulenberg
70a765e387 feedback: give a clearer message when trying to justify an empty region
Also, increase the level of the message, as trying to justify an empty
selection is a user error.
2020-03-10 15:58:30 +01:00
Benno Schulenberg
c65fa25ce2 docs: mention that ^[ (Esc) is unbindable, and explain why 2020-03-10 15:55:19 +01:00
Benno Schulenberg
cbbfebbc7a bindings: remove the translation of ^H to Backspace on the BSDs
This avoids an unintended rebinding of the <Backspace> key
on terminal emulators.

This fixes https://savannah.gnu.org/bugs/?57981.
Reported-by: Ciprian Tomoiaga <ciprian.tomoiaga@gmail.com>.
2020-03-10 14:28:55 +01:00
Benno Schulenberg
9d499c769b justify: do not take an empty line as template for first-line indentation
This fixes https://savannah.gnu.org/bugs/?57437.
2020-03-10 10:56:05 +01:00
Benno Schulenberg
dad2b5541e tweaks: rename a variable, for aptness 2020-03-10 10:50:27 +01:00
Benno Schulenberg
56960ce05e tweaks: reshuffle some stuff, to have related things together
Also for compactness, and not to use 'lead_len' for two purposes.
2020-03-10 10:45:46 +01:00
Benno Schulenberg
e247be69bf justify: when the cursor is at the left edge, keep it there
Only when the endpoint of the selection is actually IN a leading part,
then it should be advanced to include the whole leading part, so that
the succeeding paragraph will get the proper first-line indentation.
2020-03-10 10:32:21 +01:00
Benno Schulenberg
e209686835 justify: give the first line of a marked region its proper indentation
When justifying a selection from the middle of a paragraph, the first
line of both that selection and of the new paragraph after it should
get the same indentation as the first line of the original paragraph.

This fulfills https://savannah.gnu.org/bugs/?56308.
2020-03-10 10:29:49 +01:00
Benno Schulenberg
047936c338 tweaks: reshuffle an assignment and a free() 2020-03-09 14:28:57 +01:00
Benno Schulenberg
ca0571ea52 tweaks: remove an unneeded indirection
The concatenating function does not change the passed linestruct.
The data yes, but not the linestruct itself.
2020-03-09 14:25:41 +01:00
Benno Schulenberg
655cf9573f tweaks: always determine the second lead, to simplify the rewrap call
Also rename some variables.
2020-03-09 14:11:47 +01:00
Benno Schulenberg
c457f744ef justify: trim the leading blanks of a marked region at the right moment
This fixes https://savannah.gnu.org/bugs/?57977.

Bug existed since commit 5310a355 from three hours ago.
2020-03-09 14:05:18 +01:00
Benno Schulenberg
8f3ea23ece tweaks: rename a variable, to not be a substring of a function name 2020-03-09 12:31:10 +01:00
Benno Schulenberg
3225c71ecd justify: when appropriate, move end point of marked region forward
So that also the line after the newly made paragraph gets the
leading part that belongs to the start of a new paragraph.

This https://savannah.gnu.org/bugs/?57974.

Bug existed since version 4.0, since the justifying
of a marked region was introduced.
2020-03-09 12:15:01 +01:00
Benno Schulenberg
5310a355ef tweaks: reshuffle the trimming of leading whitespace, for compactness 2020-03-09 11:43:50 +01:00
Benno Schulenberg
d7875cdf4f tweaks: when appropriate, move starting point of justified region back
This makes things simpler, so that I can understand them.
2020-03-09 11:33:16 +01:00
Benno Schulenberg
dc05defb8a tweaks: rename four variables, to be a bit more telling 2020-03-09 11:10:07 +01:00
Benno Schulenberg
98c11d0a82 tweaks: reshuffle some code, in preparation for improving it 2020-03-09 11:09:56 +01:00
Benno Schulenberg
14f1652842 tweaks: move a function to its proper place in the order of things 2020-03-09 09:44:43 +01:00
Benno Schulenberg
d4b97a08cd tweaks: elide a variable and an unneeded iteration 2020-03-08 16:55:02 +01:00
Benno Schulenberg
c934c1d71b justify: trim prefixed whitespace when justifying a marked region
This fixes https://savannah.gnu.org/bugs/?56307.

Bug existed since version 4.0, when the justifying
of a marked region was introduced.
2020-03-08 16:18:34 +01:00
Benno Schulenberg
a16315a65f tweaks: remove a redundant statement, a spurious reference to 'cutbottom'
This assignment should have been removed in commit f5ac8c1e from
six years ago, as it became superfluous then.  Later changes made
'cutbottom' become valid only when something had actually been cut.
2020-03-08 15:50:55 +01:00
Benno Schulenberg
d6beca5dcf justify: do not copy too many bytes when trimming leading whitespace
This fixes https://savannah.gnu.org/bugs/?57972.

Bug existed since version 4.0, commit 877a6498.
2020-03-08 15:09:40 +01:00
Benno Schulenberg
9d7e62be1a tweaks: rename two variables, to be different or for more contrast
Also, invert the logic of the second.
2020-03-08 14:12:45 +01:00
Benno Schulenberg
5c008726f0 tweaks: rename two variables, to harmonize with two others 2020-03-08 14:04:29 +01:00
Benno Schulenberg
8c506d86af tweaks: rename two variables, to suit both the marked and unmarked case 2020-03-08 13:57:04 +01:00
Benno Schulenberg
db7a49edc6 tweaks: create an undo item earlier, and discard it when needed
This avoids having to temporariyly store and then later fill in
the original cursor position.
2020-03-08 13:40:38 +01:00
Benno Schulenberg
2428c5cbe6 tweaks: strip a parameter that is equivalent to 'openfile' for both calls 2020-03-08 12:54:47 +01:00
Benno Schulenberg
01bc0148c0 tweaks: strip a parameter that is TRUE for both calls
The parameter has been redundant since version 4.0, commit d54840c1,
when the last call with FALSE was removed.
2020-03-08 12:48:41 +01:00
Benno Schulenberg
a92511ceaf tweaks: move another function to where it is used 2020-03-06 18:52:42 +01:00
Benno Schulenberg
19517fc51e tweaks: elide a parameter, and rename a variable 2020-03-06 17:06:14 +01:00
Benno Schulenberg
71c35d3ca2 tweaks: move a function to where it is used 2020-03-06 17:00:31 +01:00
Benno Schulenberg
38af812a82 tweaks: reshuffle the setting of the starting point of a cut 2020-03-06 16:57:22 +01:00
Benno Schulenberg
622111613f tweaks: elide two variables and their two assignments
Also reshuffle two declarations, and confine the swapping of
the endpoints of a backward-marked region to a smaller scope.
2020-03-06 12:49:06 +01:00
Benno Schulenberg
21ef05058c tweaks: add a COUPLE_END undo item a bit later, instead of updating it 2020-03-06 12:30:24 +01:00
Benno Schulenberg
abcdd6605c tweaks: reshuffle a condition, for compacter code 2020-03-05 19:37:09 +01:00
Benno Schulenberg
f2d89cb3bc justify: restore a region properly when it was marked backwards
This fixes https://savannah.gnu.org/bugs/?57960.

Bug existed since version 4.8, commit e01651cd.
2020-03-05 18:46:37 +01:00
Benno Schulenberg
2d05ce37c6 justify: do not crash when the user attempts to justify an empty region
This fixes https://savannah.gnu.org/bugs/?57959.

Bug existed since version 4.0, since the justifying
of a marked region was introduced.
2020-03-05 16:57:16 +01:00
Benno Schulenberg
2bc5c1987c tweaks: factor out a three-line condition into a separate function
For clarity.
2020-03-05 16:09:56 +01:00
Benno Schulenberg
e39e2ddf52 tweaks: add a supporting variable, in order to condense some statements 2020-03-05 16:07:52 +01:00
Benno Schulenberg
ac61254581 tweaks: invert the logic of a symbol, to make more sense
Giving a name to the uncommon case is more fitting.

It also avoids a negation and allows to elide a condition.
2020-03-05 15:12:08 +01:00
Benno Schulenberg
9e182fde66 tweaks: swap the use of 'head' and 'tail' for CUT and PASTE undo items
Now the 'head' endpoint is closer to the top of the buffer, and the
'tail' endpoint closer to the bottom.  That makes more sense.
2020-03-05 14:52:02 +01:00
Benno Schulenberg
70d59ffe16 tweaks: remove a redundant assignment
Consecutive additions all happen on the same line.  When automatic
hard-wrapping occurs, the ADD item is grouped together with an ENTER
item, and subsequent additions go into a new ADD item.
2020-03-05 13:32:20 +01:00
Benno Schulenberg
fb4bcd8cfd undo: store the cursor row, for redoing filtering & justification better
This fixes https://savannah.gnu.org/bugs/?57958.
2020-03-05 12:34:55 +01:00
Benno Schulenberg
2288abcd49 tweaks: use the variable that suits 'END' better 2020-03-05 12:34:17 +01:00
Benno Schulenberg
42fde1cbc6 tweaks: improve four comments, and condense two fragments of code 2020-03-04 16:45:26 +01:00
Benno Schulenberg
d675a549de rcfile: don't store a coloring rule before it is complete
This really fixes https://savannah.gnu.org/bugs/?57950.
2020-03-04 16:08:34 +01:00
Benno Schulenberg
6bab8d19c6 tweaks: adjust the indentation after the previous change
And regroup things a bit.
2020-03-03 19:46:46 +01:00
Benno Schulenberg
365058c48f rcfile: when a start= is not matched with an end=, abandon the whole rule
This fixes https://savannah.gnu.org/bugs/?57950.

Bug existed since before version 2.2.0.
2020-03-03 19:42:40 +01:00
Benno Schulenberg
5eb7145939 rcfile: do not allow a regex for name, header, or magic to be empty
If the user really wants to match anything, ".*" should be used.

(This also stops nano looking at the rest of the line as soon as an
empty regular expression is encountered.  This may seem like poorer
feedback than before, but... I think that multiple error messages
per line are more confusing than helpful.)

This fixes https://savannah.gnu.org/bugs/?57942.

Bug existed since before version 2.2.0.
2020-03-03 19:21:08 +01:00
Benno Schulenberg
4dab491df2 tweaks: improve three comments, and reshuffle two declarations 2020-03-03 16:42:40 +01:00
Benno Schulenberg
9f92341c84 tweaks: check for a starting quote in one place instead of three 2020-03-03 16:31:28 +01:00
Benno Schulenberg
3357712928 tweaks: remove two superfluous conditions
The 'ptr' variable can never be NULL in those places -- whenever it
becomes NULL, the routine returns immediately.
2020-03-03 12:08:09 +01:00
Benno Schulenberg
0e59c12af4 tweaks: rename a function, and split a variable into two separate ones 2020-03-03 11:27:37 +01:00
Benno Schulenberg
aab0d43f47 tweaks: rename a function, to be more fitting, and improve some comments 2020-03-03 11:16:51 +01:00
Benno Schulenberg
9cc32c920b rcfile: when finding a mistake, skip the rest of the line 2020-03-03 10:55:23 +01:00
Benno Schulenberg
72ad00f9d0 tweaks: change an integer to a short, and reshuffle it for better packing
A short allows for more than 32 thousand values, and the maximum number
of multiline regexes in any of the current syntaxes is... just four.

Reshuffle it to the beginning also because it is used the most often.
2020-03-02 19:50:08 +01:00
Benno Schulenberg
89217f20af tweaks: rename two symbols, to be more precise 2020-03-02 17:16:07 +01:00
Benno Schulenberg
477a9b33b4 files: when piping, always pipe whatever was cut to the external command
Either the marked region was cut (even when zero characters) or
the entire contents of the buffer were cut.  In both cases this
is what needs to be piped to the command.  That is: the contents
of the cutbuffer.

This fixes https://savannah.gnu.org/bugs/?57931.

Bug existed since version 2.9.8, commit f304b9ae,
when piping text to an external command was introduced.
2020-03-02 13:36:56 +01:00
Benno Schulenberg
5c6fe50487 tweaks: rename a variable, to be a bit clearer 2020-03-01 19:45:02 +01:00
Benno Schulenberg
6c34ae5804 files: don't check uninitialized memory when writing new file [valgrind]
This fixes https://savannah.gnu.org/bugs/?57934.

Bug existed since version 4.3, commit e8e30e51.
2020-03-01 19:22:35 +01:00
Benno Schulenberg
4409b275fc tweaks: avoid a complaint about uninitialized memory [valgrind]
This addresses https://savannah.gnu.org/bugs/?57932.
2020-03-01 17:08:50 +01:00
Benno Schulenberg
8848ac5a9b undo: do not try to copy a cutbuffer that is NULL
Allow the creation of an empty CUT undo item (because the result of a
filtering operation may be empty), but then don't crash when undoing
such an empty CUT.

This fixes https://savannah.gnu.org/bugs/?57929.

Bug existed since version 2.9.8, when filtering was introduced.
2020-03-01 12:59:54 +01:00
Benno Schulenberg
c055e629c7 tweaks: copy and store a deleted character in a conciser manner 2020-02-28 19:24:31 +01:00
Benno Schulenberg
e6f26464d7 tweaks: add calls of die() for five theoretical programming mistakes 2020-02-28 19:15:23 +01:00
Benno Schulenberg
a0aeeba075 tweaks: remove two redundant case labels
The add_undo() and update_undo() functions are never called with
JOIN as argument, so there is no need to have a case label for it.
2020-02-28 19:05:09 +01:00
Benno Schulenberg
c640a55b1c tweaks: frob a statement, rewrap two lines, and remove a pair of braces 2020-02-28 18:59:04 +01:00
Benno Schulenberg
7d0b7e47c1 undo: use the correct original fusion point when unjoining two lines
When a <Backspace> did the join, 'head' and 'tail' are not the same.

This fixes https://savannah.gnu.org/bugs/?57916.

Bug existed since commit 7cf08b93 from yesterday.
2020-02-28 17:09:03 +01:00
Benno Schulenberg
132ed5c8f0 tweaks: instead of swapping the end points later, assign them correctly
(This also makes it clear that the naming of 'head' and 'tail'
is the wrong way around for CUT too.)
2020-02-28 15:25:23 +01:00
Benno Schulenberg
bd88b8b5a6 undo: do not mark the buffer as modified when pasting back nothing
This completes the fix for https://savannah.gnu.org/bugs/?57915.
2020-02-28 13:40:35 +01:00
Benno Schulenberg
0568f7a2b6 undo: do not try to paste back an empty cutbuffer
Trying to do so would dereference a NULL pointer in copy_node().

This fixes https://savannah.gnu.org/bugs/?57915.

Bug existed since before version 2.2.0.
2020-02-28 13:40:06 +01:00
Benno Schulenberg
1a28b08694 tweaks: frob two statements, condense another, and add a comment
Also, remove two superfluous closings of file descriptors.  The second
one has most likely already been closed by send_data(), by closing the
tube, and the first one will be closed by exiting from the process.
2020-02-28 12:41:27 +01:00
Benno Schulenberg
3b3a6b12a7 tweaks: remove two superfluous checks
The single check when creating any CUT undo item is enough.
2020-02-28 10:28:23 +01:00
Benno Schulenberg
50213eee81 tweaks: reorder a case item, to have SPLIT_BEGIN always before SPLIT_END
Also, avoid two superfluous assignments of a message, as they get
overwritten immediately by other ones, and later with the same.

Furthermore, remove two pointless placements of the cursor.  Any
necessary placements are handled by the actual adding of data and
the breaking of lines in the ADD and ENTER items.
2020-02-27 16:38:52 +01:00
Benno Schulenberg
7cd2a7da7c tweaks: remove a superfluous assignment, and reshuffle a call 2020-02-27 15:09:36 +01:00
Benno Schulenberg
4f67f364bc tweaks: when undoing an addition or redoing a deletion, do not reallocate
Especially when undoing an addition, reallocating the line data is a
waste of time, because most likely other text will be added instead.

(This also removes a coding error in the redo code for a deletion:
it allocated too many bytes for the new line data: twice the amount
of the deletion too much.)
2020-02-27 14:16:49 +01:00
Benno Schulenberg
7cf08b93ff tweaks: don't bother reallocating the line data when undoing a line join 2020-02-27 13:51:56 +01:00
Benno Schulenberg
474a1f0447 tweaks: rename to the same name two variables that have the same role 2020-02-27 13:46:57 +01:00
Benno Schulenberg
76d7fbd5ee tweaks: rename a variable, away from a single letter 2020-02-27 13:28:01 +01:00
Benno Schulenberg
8d87410c94 tweaks: rearrange a case item, so that PASTE is always after CUT
Also, for a REPLACE, the 'head' point does not need to be updated,
because a replacement does not change the cursor position.
2020-02-27 12:13:24 +01:00
Benno Schulenberg
1961c052c8 tweaks: simplify the undoing and redoing of an <Enter>
I don't know what I was thinking three years ago with this convoluted
'from_x' and 'to_x'.  When undoing an <Enter>, the cursor always needs
to be placed back at the 'head' point.  And the data always needs to be
copied starting from 'tail_x' (skipping any whitespace that autoindent
might have added).

When redoing an <Enter>, there is no need to reallocate and copy the
data of the line, it is enough to just clip it at the original cursor
position.  (This wastes some memory, but... how often does one redo
an <Enter>?  So, conciseness of the code is preferable.)
2020-02-27 12:11:58 +01:00
Benno Schulenberg
843dbd56ef tweaks: rename two more elements of an undo record, for symmetry
(Note that for a PASTE and a COUPLE_END the variables seem to be used
the wrong way around.  Maybe this can be improved.)
2020-02-27 10:08:48 +01:00
Benno Schulenberg
be3c54c670 tweaks: rename two elements of an undo record, to be more telling 2020-02-27 10:08:48 +01:00
Benno Schulenberg
01afcb243c tweaks: rename a variable, to get out of the way of a later rename 2020-02-27 09:35:23 +01:00
Benno Schulenberg
b0eb73f7b3 feedback: make sure that a later message can overwrite a short warning
This fixes https://savannah.gnu.org/bugs/?57901.

Bug existed since version 3.0, commit 25e98776.
2020-02-26 16:41:09 +01:00
Benno Schulenberg
1907174c5f tweaks: drop a check for something that will not occur
The check has been there for a few months, and will be there for
five more years in the next Ubuntu LTS.
2020-02-26 14:01:25 +01:00
Benno Schulenberg
4da604be5a tweaks: relocate a function to before its callers 2020-02-26 13:27:22 +01:00
Benno Schulenberg
43754bd11d cutting: let M-T cut a trailing empty line, but not nothing at all
This fixes https://savannah.gnu.org/bugs/?57900.

Bug existed since version 4.0, commit 67873e96.
2020-02-26 12:38:00 +01:00
Benno Schulenberg
acd9046093 tweaks: rearrange some conditions, for compactness 2020-02-26 12:10:28 +01:00
Benno Schulenberg
2fd6181873 cutting: with --cutfromcursor, allow ^K to cut the penultimate empty line
This fixes https://savannah.gnu.org/bugs/?57897.

Bug existed since version 4.0, commit 67873e96.
2020-02-26 11:55:19 +01:00
Benno Schulenberg
b15c5a7eaf tweaks: abort in three situations that should never occur
Since is_cuttable() was added just over a year ago, ^K will
not add an undo item when it doesn't actually cut anything.
2020-02-26 11:53:27 +01:00
Benno Schulenberg
1b1d60b9d7 tweaks: drop two comments that contain variable names
Grepping for those names shouldn't find comments.  Also, the name
of the relevant boolean is clear enough to not need a comment.
2020-02-25 16:59:27 +01:00
Benno Schulenberg
9c70fdaef9 syntax: spec: drop invalid parentheses after "Summary"
Also, add the missing "RemovePathPostfixes", add extra word boundaries,
and reshuffle and regroup some things.
2020-02-25 11:47:11 +01:00
Benno Schulenberg
fcbe5aedbd tweaks: use spaces when aligning things, not tabs
Also, remove a reference to the French man page that no longer exists.
2020-02-24 19:43:19 +01:00
Benno Schulenberg
6c6a3f6bd3 syntax: spec: colorize the date and author of changelog items differently
Also, remove superfluous parentheses, add missing edge-of-word markers,
correct the "ppciseries" keyword, and fold some regexes (or elements of
them) together.
2020-02-23 20:02:48 +01:00
Benno Schulenberg
e873121372 syntax: spec: add two missing % signs, and colorize also "%triggerprein"
Furthermore, actually colorize the header line of a %changelog entry,
and remove two redundant fragments and simplify their overrides.
2020-02-23 19:38:54 +01:00
Neal Gompa
ad52830fb8 syntax: spec: add some keywords that were added in RPM 4.15 and 4.13
In RPM 4.15, a number of new spec section features were introduced:

* %dnl                       - macro-engine level comments
* %elif, %elifos, %elifarch  - 'else if' stanzas for conditionals
* %sourcelist                - section for listing sources line by line
* %patchlist                 - section for listing patches line by line
* %generate_buildrequires    - script section after %prep for
                               generating build dependencies

(Reference: https://rpm.org/wiki/Releases/4.15.0.html.)

An enhancement added in RPM 4.13:

* Sections for file trigger stanzas

(Reference: https://rpm.org/user_doc/file_triggers.html.)

As these are being increasingly used in Fedora and other distributions,
it's quite helpful to have syntax highlighting be up to date on handling
them.

Signed-off-by: Neal Gompa <ngompa13@gmail.com>
2020-02-23 15:12:04 +01:00
Benno Schulenberg
c802f91f4e tweaks: remove some unneeded braces, not used elsewhere either 2020-02-21 17:07:11 +01:00
Benno Schulenberg
51913542f4 tweaks: rename a variable, and reshuffle a declaration 2020-02-21 17:02:24 +01:00
Benno Schulenberg
be7e000389 tweaks: pull the NUL-terminating of a string into a function
Also, avoid copying one byte too many that afterward gets
overwritten with '\0'.
2020-02-20 17:08:32 +01:00
Benno Schulenberg
1d4411a474 tweaks: elide a function call, by copying a byte directly
Now all remaining calls of measured_copy() have a "+ 1" in their
second argument, and can thus be simplified.  And each of those
calls is followed by terminating the string with a NUL byte, so
thát can be pulled into the function.
2020-02-20 16:38:14 +01:00
Benno Schulenberg
76f1a4af4f tweaks: add a different helping variable 2020-02-19 19:06:04 +01:00
Benno Schulenberg
bb1a0bd86c input: after reallocating a string, do not write to its old address
The old address has become invalid, and probably does not have enough
room for the write, thus causing a crash.

This fixes https://savannah.gnu.org/bugs/?57858.

Bug existed since commit 8625609c from two days ago.
2020-02-19 18:54:01 +01:00
Benno Schulenberg
8b2b9654ab tweaks: condense a comment, reshuffle conditions, and remove unwanted one 2020-02-18 16:26:56 +01:00
Benno Schulenberg
60ae71bf3a softwrap: when typing goes beyond the bottom row, scroll just one row
This fixes https://savannah.gnu.org/bugs/?57851.

Bug existed since version 2.8.0, when scrolling per soft-wrapped chunk
was made possible.
2020-02-18 15:42:20 +01:00
Benno Schulenberg
8625609c2d tweaks: rename a variable, and add a helping one 2020-02-18 15:00:27 +01:00
Benno Schulenberg
3c4a4b04ce tweaks: normalize the indentation after the previous change
Also rewrap two lines, reshuffle three, and improve three comments.
2020-02-18 14:58:06 +01:00
Benno Schulenberg
b3faf353c9 tweaks: inject the entire burst of bytes at once into the edit buffer
Not doing it characterwise saves a reallocation, a memmove(), several
checks, and an update_undo() for each character over one.

This has been tested by temporarily setting 'bracketed_paste = FALSE'
instead of 'bracketed_paste = TRUE' in convert_sequence() in winio.c,
and then pasting stuff into nano.
2020-02-18 14:54:19 +01:00
Benno Schulenberg
f700b422be tweaks: call add_undo() before the character is actually added
And before the buffer size is adjusted, so that the add_undo()
doesn't need to correct the stored former size of the buffer.

This will allow the injection of multiple characters at once,
in the next commit.
2020-02-18 14:40:15 +01:00
Saagar Jha
1b2a2e6737 rcfile: fix an out-of-bounds read on empty lines
Signed-off-by: Saagar Jha <saagar@saagarjha.com>

Bug existed since commit 98f038ad from a week ago.
2020-02-17 12:11:40 +01:00
Benno Schulenberg
12e5c2f07d undo: for an automatic hard-wrap, store the correct previous buffer size
The SPLIT_BEGIN item gets tucked underneath the ADD item on the top of
the undo stack.  Thus: that SPLIT_BEGIN item should copy the 'wassize'
of the ADD item instead of storing the current buffer size.

This fixes https://savannah.gnu.org/bugs/?57832.

Bug existed since the undo functionality was added, and existed
in this form since version 2.3.5, commit be10c2a4.
2020-02-17 11:41:52 +01:00
Benno Schulenberg
5c07a747bb tweaks: adjust some whitespace, reshuffle two ifs, and remove two braces 2020-02-17 11:29:13 +01:00
Benno Schulenberg
a9f7277b1b tweaks: remove a now-unused helper function 2020-02-16 12:33:29 +01:00
Benno Schulenberg
d13b6d6896 tweaks: elide an intermediate copy of an added character
In theory this would allow injecting more than one character at a time
into the edit buffer.  But the creation and updating of an undo item for
the addition or the deletion of a character are a bit strange.  For all
other operations and add_undo() is called before the operation, and an
update_undo() afterward.  But for an ADD, the add_undo() is called after
the operation, and for a DEL/BACK, the update_undo() is called before
the operation.  There is some logic to that, but things would be easier
to understand if all operations were handled the same: an add_undo()
beforehand (when needed), and an update_undo() afterward.
2020-02-16 12:32:10 +01:00
Benno Schulenberg
819066c5d5 tweaks: extend the undo data for deleting and backspacing more directly
To get rid of an intermediate copy of the deleted character.
2020-02-16 11:06:45 +01:00
Benno Schulenberg
a65982bffb tweaks: relocate eleven functions to before they are called 2020-02-14 19:10:21 +01:00
Benno Schulenberg
6b8f446b52 tweaks: rename a constant, and rename and relocate a function 2020-02-14 19:00:16 +01:00
Benno Schulenberg
2b97d6563d tweaks: correct a typo, improve two indentations, and rewrap a line 2020-02-14 16:03:15 +01:00
Benno Schulenberg
a0506a15ee undo: when undoing a paste or an insertion, remove an added magic line
When something is pasted or inserted onto the final, empty line of a
buffer, an automatic new magic line is created after it, when needed.
When this paste or insertion is undone, the added magic line should
also be removed again.

This fixes https://savannah.gnu.org/bugs/?57808.

Bug existed since the undo capabilities were added,
since before version 2.3.0.
2020-02-14 15:27:06 +01:00
Benno Schulenberg
68ca1732b8 prompt: insert a burst of bytes in one go instead of characterwise
There is no need to count characters, so just insert the whole batch
of bytes at once.
2020-02-13 14:42:47 +01:00
Benno Schulenberg
75f4309c1f tweaks: rename four parameters, to be more distinct and telling 2020-02-13 14:22:40 +01:00
Benno Schulenberg
78767b583d tweaks: elide an intermediate copy of a character during injection, twice 2020-02-13 14:22:23 +01:00
Benno Schulenberg
a0703ab62d tweaks: mesh two bits of code together 2020-02-13 13:46:31 +01:00
Benno Schulenberg
9d232cd8af input: keep a multibyte character together during verbatim entry
When the user (unexpectedly) types a multibyte character after M-V,
put its first byte back into the keyboard buffer, so that the next
call of process_a_keystroke() will retrieve the byte sequence as a
whole, and will inject them as one character into the edit buffer.

This fixes https://savannah.gnu.org/bugs/?57804.

Bug existed since version 2.6.3, commit 08c51cfd.
2020-02-13 13:15:46 +01:00
Benno Schulenberg
03d296eb35 input: allocate sufficient bytes for entering a Unicode codepoint
This fixes https://savannah.gnu.org/bugs/?57803.

Bug existed since commit 2b27df67 from yesterday.
2020-02-13 11:57:35 +01:00
Benno Schulenberg
2b27df6733 tweaks: convert integers to bytes in one place instead of two 2020-02-12 17:16:27 +01:00
Benno Schulenberg
f012d54a1d tweaks: make prompt-bar input more similar to edit-buffer input
In preparation for the next commit.
2020-02-12 16:59:48 +01:00
Benno Schulenberg
61dc2cab0b tweaks: rename two variables, and frob four comments 2020-02-12 16:20:20 +01:00
Benno Schulenberg
a2313f499c tweaks: move a function to after the one that it calls 2020-02-12 16:06:57 +01:00
Benno Schulenberg
cbda89766f tweaks: rename a parameter and a variable, and reword two comments
Also reshuffle a declaration.
2020-02-12 16:05:18 +01:00
Benno Schulenberg
070ccf4a5b tweaks: rename two variables, and reshuffle a few things 2020-02-12 14:28:07 +01:00
Benno Schulenberg
8e4b68917c tweaks: rename a function, and condense a few comments 2020-02-12 14:15:35 +01:00
Benno Schulenberg
0d0d011579 tweaks: combine two ifs into one 2020-02-12 12:09:12 +01:00
Benno Schulenberg
71daa1ef6b tweaks: update several comments after the previous changes 2020-02-12 12:05:52 +01:00
Benno Schulenberg
0ed62e84de tweaks: weld two fragments together, twice, by eliding an unneeded 'if'
The get_kbinput() routine will never return ERR, so there is no need
to check for that.
2020-02-12 11:46:15 +01:00
Benno Schulenberg
0a31a9aa38 tweaks: make two conditions more direct, and thus elide two functions
Using straightforward comparisons is clearer and faster and shorter.

Again, note that this does not filter out 0x7F (DEL).  But that is
okay, as that code will never be returned from get_kbinput().
2020-02-12 11:38:33 +01:00
Benno Schulenberg
6747142cd7 tweaks: remove some redundant filtering, and thus elide a parameter
The few calls of the injection routines that had 'filtering' set to
TRUE have already filtered out ASCII control codes earlier on.  And
in the case of injecting a completion, this completion only contains
word-forming characters -- and if the user somehow added a control
code to the word-forming characters, then nano should NOT filter it
out, so in fact that setting of 'filtering' to TRUE was mistaken.

Note that this filtering did not filter out 0x7F (DEL).  But that is
fine: it should not occur in the input stream at that point anyway,
as it gets translated to either KEY_DC or KEY_BACKSPACE earlier in
the keyboard parsing routines.
2020-02-12 11:12:34 +01:00
Benno Schulenberg
6cf442e329 docs: mark bracketed pasting as done in the TODO list 2020-02-11 16:59:15 +01:00
Benno Schulenberg
d26f16a175 tweaks: correct two typos in a changelog, and drop a doubled word 2020-02-10 19:04:42 +01:00
Benno Schulenberg
8d7f8cda8c tweaks: improve two comments 2020-02-10 17:13:12 +01:00
Benno Schulenberg
75a70d98d5 tweaks: reshuffle two declarations plus a fragment of code
Also, don't bother statting the path that the user provided,
as that case will happen right away in the next 'if'.
2020-02-10 17:12:53 +01:00
Benno Schulenberg
b3374ea1fb tweaks: rename two parameters, to not overlap with other names 2020-02-10 16:11:07 +01:00
Benno Schulenberg
0905c6ae7e files: be consistent in which code means "New File"
This fixes https://savannah.gnu.org/bugs/?57782.

Bug existed since commit dd429d9c from yesterday.
2020-02-10 15:57:40 +01:00
Benno Schulenberg
3eeedd7caf tweaks: move a function to before the one that calls it 2020-02-10 09:55:21 +01:00
Benno Schulenberg
410dcee0a1 tweaks: move some definitions closer to where they are used
Also slightly improve a few comments.
2020-02-10 09:53:10 +01:00
Benno Schulenberg
5b4d2350e6 tweaks: condense two fragments of code 2020-02-10 09:40:12 +01:00
Benno Schulenberg
cbeea859c2 shutdown: don't refer to an open file when there aren't any
This fixes https://savannah.gnu.org/bugs/?57780.

Bug existed since commit b63c90bf from yesterday.
2020-02-10 09:28:37 +01:00
Benno Schulenberg
422cd726fa tweaks: normalize the indentation after the previous change 2020-02-09 20:17:05 +01:00
Benno Schulenberg
9f43b4c758 tweaks: update some comments after the previous changes 2020-02-09 20:10:28 +01:00
Benno Schulenberg
dd429d9c00 tweaks: rename a variable, reshuffle an assignment, and change a code 2020-02-09 19:50:33 +01:00
Benno Schulenberg
b63c90bf6b locking: do not open an empty buffer when respecting the first lock file
When opening multiple files, and the first of them has a lock file,
and the user chooses to not open the corresponding file, then nano
should NOT create an empty buffer in its stead.

This fixes https://savannah.gnu.org/bugs/?57777.

Bug existed since lock files were introduced, in version 2.4.0,
specifically since commit 6948d2e7.
2020-02-09 17:35:00 +01:00
Benno Schulenberg
fa26889d03 tweaks: change a function to return the name of the lock file on success
This makes it possible to fix a small bug in the next commit.
2020-02-09 17:01:38 +01:00
Benno Schulenberg
30011b8525 tweaks: elide one variable and three gotos
Returning the relevant value directly is clearer.
2020-02-09 16:35:18 +01:00
Benno Schulenberg
3ac5432e29 tweaks: reshuffle a few declarations and assignments
Also reshuffle two fragments of code.
2020-02-09 14:54:15 +01:00
Benno Schulenberg
1d52548575 tweaks: change another function with two possible results to boolean 2020-02-09 14:30:57 +01:00
Benno Schulenberg
d5ce44820a tweaks: change a function with two possible results to boolean 2020-02-09 14:24:26 +01:00
Benno Schulenberg
cc2b4f712c tweaks: unabbreviate the name of a variable 2020-02-09 12:02:37 +01:00
Benno Schulenberg
98f038ad96 rcfile: allow alternate line endings in nanorc files
When copy-pasting has resulted in a nanorc file with DOS line endings
(CR+LF), then silently ignore the carriage return, to avoid printing
an error message that partly overwrites itself.

This fulfills https://savannah.gnu.org/bugs/?57756.
Requested-by: Matthias Aßhauer <mha1993@live.de>
2020-02-09 11:55:07 +01:00
Benno Schulenberg
f8d2f552bd po: update translations and regenerate POT file and PO files 2020-02-07 11:23:43 +01:00
Benno Schulenberg
f2ae08ab19 bump version numbers and add a news item for the 4.8 release 2020-02-07 10:50:44 +01:00
Benno Schulenberg
325d774393 locking: accept a minimal amount of data, enough for PID plus username
Maybe reading from a remote filesystem happens in small chunks;
don't call foul when the first chunk contains all we need.
2020-02-06 16:13:22 +01:00
Benno Schulenberg
0856f53703 docs: mention that -D/--boldtext gets overridden by some nanorc options
Also, remove an obsolete anchor, and add a missing word.
2020-02-06 16:07:11 +01:00
Benno Schulenberg
7f0bfdfeb2 docs: put the three new behaviors in a bulletted list, to catch the eye
Also, move the relevant section down in the nanorc man page, to increase
the contrast between the two pages.
2020-02-06 16:07:11 +01:00
Benno Schulenberg
51371e0ca5 tweaks: exclude two unneeded fragments of code from the tiny version 2020-02-05 11:41:31 +01:00
Benno Schulenberg
3bd66b78c1 tweaks: don't bother including Haiku escape sequences in the tiny version 2020-02-05 11:31:03 +01:00
Benno Schulenberg
5ea6054a75 tweaks: use a simple subtraction instead of a function call 2020-02-05 11:29:36 +01:00
Benno Schulenberg
04738996fc tweaks: rename two parameters, to be more general and to sound shorter 2020-02-04 17:32:05 +01:00
Benno Schulenberg
07a9477213 tweaks: rename five variables, away from a single letter 2020-02-04 17:20:37 +01:00
Benno Schulenberg
a5b48f9a0d build: fix compilation for --enable-{tiny,help,multibuffer} 2020-02-04 12:58:57 +01:00
Benno Schulenberg
d141e849a3 tweaks: unabbreviate "argument" in the documentation
Also, show that the argument in the extendsyntax format is not optional,
as any command requires at least one argument.  Also mention 'tabgives'
among the commands that are allowed in an included file.
2020-02-04 12:23:58 +01:00
Benno Schulenberg
da68ee19e7 tweaks: reorder two symbols 2020-02-04 11:41:05 +01:00
Benno Schulenberg
8b2f7bd5a2 tweaks: drop a message that will never be seen
Since the previous commit, nano exits from curses mode soon after
this message is printed, so that the user does not have any time
to read it or even see it.
2020-02-03 19:59:58 +01:00
Benno Schulenberg
6119756347 speller: avoid messing up the screen when an unknown locale is used
When invoking the "internal" speller, leave curses mode while the three
programs in the pipe array are executing, to prevent 'hunspell' from
writing a long error message to the end of the status bar, making the
screen scroll, and thus messing it up.  Now the error message gets
printed to the screen that nano was started up from, and will thus be
visible when the user exits from nano.  (At least: it will be so on a
terminal emulator -- on a VT, nothing will be seen.)

This fixes https://savannah.gnu.org/bugs/?57728.

Bug existed since version 4.6, commit 4d77e0ad.
2020-02-03 13:50:33 +01:00
Benno Schulenberg
06c80b6ccd tweaks: rearrange a few global variables, to group things better 2020-02-02 17:05:06 +01:00
Benno Schulenberg
7ce1f6d86d locking: when finding a lock file at startup, quit when user cancels
When at startup the user presses Cancel at the "open anyway?" prompt,
cancel the whole startup: quit.  But when the user answers No, just
skip the file and continue starting up.
2020-02-02 13:00:37 +01:00
Benno Schulenberg
88087f2b2f tweaks: move a function to related ones, and after one that it calls 2020-02-02 12:26:33 +01:00
Benno Schulenberg
16c4f5bbd0 tweaks: move a function to be before the ones that call it 2020-02-02 12:21:28 +01:00
Benno Schulenberg
e877c2406e tweaks: allocate the lock data only when ready to write them 2020-02-02 12:05:45 +01:00
Benno Schulenberg
b6a1583e8e tweaks: take just one shot at reading the lock file, and correct a type
Don't bother looping until the 1024 bytes are read.  Writing the lock
file takes just one shot too, and that is more important to get right.

Also, correct the type for the result of read(), so that -1 doesn't
get turned into a positive number, which would mean that any error
would get ignored.
2020-02-02 11:41:20 +01:00
Benno Schulenberg
48df800db3 tweaks: rewrite the same file name into the lock file as the first time
It would be better if nano wrote the full filename into the lock file,
because that would be clearer when Vim displays its warning, but...
this is faster and will do for now.

(Nano should simply also store the full filename in the openfile struct,
so that get_full_path() needs to be called just once for each file.)

This addresses https://savannah.gnu.org/bugs/?57713.
2020-02-02 11:22:22 +01:00
Benno Schulenberg
ee05daab92 tweaks: do not leak a file descriptor when fdopen() fails 2020-02-02 11:08:59 +01:00
Benno Schulenberg
74f4c37d5f locking: avoid crashing when there is a problem writing the lock file
The call of ferror() as parameter of a %s specifier was a mistake --
it returns a number, not a string.  Avoid the problem by combining
two error checks.

The man page of fwrite() does not say anything about errno, but I guess
that the function calls write() and that the possible error numbers of
that function apply.

In theory it is now possible that fclose() fails and returns an error
that then masks an earlier error of fwrite().  But I can't be bothered:
lock files are not essential, and any errors that might occur are most
likely overlooked anyway because they are not displayed in red.

This fixes https://savannah.gnu.org/bugs/?57724.

Bug existed since lock files were introduced, in version 2.3.2,
commit bf88d27a.
2020-02-02 10:55:19 +01:00
Benno Schulenberg
3f5ba950d6 tweaks: suggest a few more alternative key bindings and unbindings
This demonstrates the presence of the 'savefile' function,
and makes the main help text look better.
2020-01-31 17:16:31 +01:00
Benno Schulenberg
0a52e92d4c docs: for the alternative bindings, rebind ^C only in the main menu
Because ^C is needed for Cancel in most other menus.

This fixes https://bugs.debian.org/950223.
Reported-by: Jonas Smedegaard <dr@jones.dk>

Bug existed since version 4.0, commit 3a170d2c.
2020-01-31 16:54:55 +01:00
Benno Schulenberg
7c57806c6f rcfile: require "bright", "start=", and "end=" to be in lowercase too 2020-01-31 16:11:38 +01:00
Benno Schulenberg
a2f8703df5 tweaks: tumble three conditions, for consistency in comparisons 2020-01-31 16:05:51 +01:00
Benno Schulenberg
073251fdb1 tweaks: condense two comments, and reshuffle an #endif
There is no need to fake success when the whole writing of the lock file
is skipped, because also a zero return value means "continue anyway".
2020-01-31 11:39:11 +01:00
Benno Schulenberg
5a0ee3c2f9 tweaks: harmonize the amount of lock data that we read and write
All the things that we need are located within the first 68 bytes of
the .swp file.  We do write byte 1007 when the file is modified, but
we never reference it.  We always wrote just 1024 bytes to the .swp
file, so it makes no sense to read in any more than that.

(Vim writes 4096 bytes to a .swp at first, before adding undo stuff
four seconds later.  But the 1024 bytes appear to be enough for Vim
to recognize it as a lock file.)
2020-01-31 11:06:11 +01:00
Benno Schulenberg
6bd5dce954 tweaks: ensure that editor name and user name are NUL terminated
When copying those pieces from a lock file, it is not certain that
they end with a NUL character.
2020-01-30 20:00:17 +01:00
Benno Schulenberg
f25059c244 tweaks: frob a couple of indentations and white lines 2020-01-30 19:55:26 +01:00
Benno Schulenberg
856f2c433e feedback: ask a clearer question when a valid lock file is encountered
When asking "continue?", I always thought that answering No would mean
that nano would not continue, that it would stop, that it would abort.
But No only means that it will not open the relevant file but continues
anyway to start up.  Asking "open anyway?" is more easily understood in
that way.
2020-01-30 19:44:25 +01:00
Benno Schulenberg
38c5a4465b tweaks: reshuffle some assignments for a return value 2020-01-30 19:43:19 +01:00
Benno Schulenberg
f494bfcbb9 locking: when a lock file is unreadable, open the file itself anyway
Unreadable or corrupt lock files are not a user error nor user intent,
so they should not keep the user from editing the corresponding file.

Also, combine some error conditions to compact the code.

This addresses https://savannah.gnu.org/bugs/?57700.
2020-01-30 19:10:34 +01:00
Benno Schulenberg
b856fc4664 locking: check two magic bytes, to verify that it is a lock file
Also, when the check fails, then nano should continue and simply
open the file, just like Vim.

This fixes https://savannah.gnu.org/bugs/?57698.
2020-01-30 18:48:35 +01:00
Benno Schulenberg
faa96ead44 tweaks: correct the description of what nano writes into the lock file
Also, limit the stored program's name to ten bytes.  Vim uses four for
its name plus a space, and a maximum of six for its version number.
2020-01-30 17:44:04 +01:00
Benno Schulenberg
26444bf8df tweaks: reformat a comment, and resuffle a line to match byte order 2020-01-30 15:55:42 +01:00
Benno Schulenberg
4eaade2938 gnulib: update to its current upstream state 2020-01-29 19:48:15 +01:00
Benno Schulenberg
662e8b2d20 tweaks: remove some superfluous conditions for rewriting a lock file
A lock file needs to be rewritten (with the modified flag) only when the
relevant lock file already exists.  All other conditions are redundant.
2020-01-29 19:38:07 +01:00
Benno Schulenberg
4502295a34 locking: do not write a lock file when in view mode
When in view mode, the file cannot be edited, so there is no need to
warn anyone (through a lock file) that the file might soon change.

This fixes https://savannah.gnu.org/bugs/?57694.
2020-01-29 19:14:41 +01:00
Benno Schulenberg
25b0bf0ae8 tweaks: correct a couple of comments about escape sequences 2020-01-29 18:48:03 +01:00
Benno Schulenberg
f6b6bc47d6 tweaks: remove a redundant call, as there is nothing to free there
At that point, 'u->cutbuffer' will always be NULL, either from the
original creation of the INSERT undo item, or by having been freed
and set to NULL by do_redo().
2020-01-29 12:33:55 +01:00
Benno Schulenberg
a692b01c04 tweaks: reshuffle two lines, to do the linking first, then the content 2020-01-29 12:33:30 +01:00
Benno Schulenberg
a197ccf12d tweaks: move another function, to group the deleting ones together 2020-01-29 12:16:09 +01:00
Benno Schulenberg
67e5913edf tweaks: move another function to before the one that calls it 2020-01-29 10:54:30 +01:00
Benno Schulenberg
e864107046 tweaks: move a function to right before the one that calls it 2020-01-29 10:53:05 +01:00
Benno Schulenberg
7984ea4eb6 tweaks: remove two superfluous assignments, and rename a variable
The 'prev' and 'next' links get assigned to immediately after the
call of copy_node().  And anyway, it does not make sense to link
a copied node to the predecessor and successor of its original.

Also slightly regroup some lines.
2020-01-29 10:47:09 +01:00
Benno Schulenberg
f38bd5030d tweaks: add a little change that was overlooked in the previous commit
Option --showcursor applies also to the help viewer, which means that
it can do something useful in restricted mode too.
2020-01-28 12:00:05 +01:00
Benno Schulenberg
a2fea9928d build: exclude option '-g' when configured without browser and help 2020-01-28 10:33:56 +01:00
Benno Schulenberg
c64f506933 tweaks: reshuffle some declarations, and expand a few variable names 2020-01-28 10:21:34 +01:00
Benno Schulenberg
445cd2a6c5 usage: improve the description of --restricted and --quickblank
Give a little more information than just a rehash of the long option.
2020-01-28 10:04:01 +01:00
Benno Schulenberg
fb073ec88d display: ensure the guiding stripe can be shown when not softwrapping
This fixes https://savannah.gnu.org/bugs/?57683.

Bug existed since commit 0b54785f from yesterday.
2020-01-28 09:35:45 +01:00
Benno Schulenberg
c09e96f294 suspension: put in an extra terminal-initialization call for Slang
Also, the disabling of the keyboard interrupt (SIGINT) must happen
after that initialization call, otherwise ^C will still do nothing
after returning from suspension (when nano is built against Slang).

This fixes https://savannah.gnu.org/bugs/?57656.

Bug existed since version 2.2.0, commit daaf468c.
2020-01-27 16:46:01 +01:00
Benno Schulenberg
0b54785fe5 softwrap: suppress the guiding stripe on unaffected chunks
When the guiding stripe (when softwrapping) will be shown in
a later chunk, it shouldn't be shown in the current chunk.

This fixes https://savannah.gnu.org/bugs/?57654.

Bug existed since --guidestripe was introduced, in version 4.0.
2020-01-27 15:46:57 +01:00
Benno Schulenberg
8835c0d486 tweaks: reduce the scope of a variable, and reshuffle a declaration 2020-01-27 13:36:28 +01:00
Benno Schulenberg
0442eef95b tweaks: elide a somewhat costly call by remembering some state
When having prepared a line for displaying on the screen, nano already
determind whether the line extends beyond the right edge or not.  There
is no need to calculate again the full width of the current line later.
Just let display_string() make a note whether the piece of text that
it converted to displayable form still has more text coming after it,
and use this note when it's time to show the ">" continuation sign.

Using a static variable is ugly, but passing it along as a parameter
would be even uglier, because for all other calls of display_string()
the parameter would be just a useless burden.
2020-01-27 13:23:56 +01:00
Benno Schulenberg
6ae11071b3 tweaks: add an error message for something that should never occur 2020-01-27 12:06:27 +01:00
Benno Schulenberg
3c177c1bb9 tweaks: elide a variable, and rename its sister 2020-01-26 19:23:37 +01:00
Benno Schulenberg
e0213b1a41 tweaks: drop a pointless suffix from two function names 2020-01-26 16:36:23 +01:00
Benno Schulenberg
e70ff87c86 tweaks: move another function to after the one that it calls
(The diff is stupid.  It should just remove 440 contiguous lines, and
add back 440 contiguous lines further down.  Instead it tries to find
similarities between what is moved and what remains, and makes a mess.
You have to use --patience or --minimal to get the better diff.)
2020-01-26 16:21:21 +01:00
Benno Schulenberg
db10a421dc tweaks: move a function to after the one that it calls 2020-01-26 16:21:21 +01:00
Benno Schulenberg
5725336149 tweaks: slightly condense a function by conflating case 2020-01-26 16:21:21 +01:00
Benno Schulenberg
b8ba27bbc0 tweaks: fuse two nearly identical functions into a single one
The plain keys that are valid in the help viewer are a perfect subset of
those that are valid in the file browser, so just use the same function
to do the interpretation for both.  It is not a problem that it returns
function pointers for some keystrokes that have no meaning in the help
viewer, because both NULL and an unhandled function pointer result in
the "Unbound key" message.
2020-01-26 16:20:37 +01:00
Benno Schulenberg
e3f6638a76 prompt: for a Yes-No-All, accept the first character of an external paste
Allow the user to paste in the character for Yes, No, or All.  If the
paste contains more than one character, ignore all but the first.

This fully fixes https://savannah.gnu.org/bugs/?57623.
Reported-by: Brand Huntsman <alpha@qzx.com>
2020-01-26 12:22:49 +01:00
Benno Schulenberg
f8553f6d3a feedback: restore a message that can occur in help viewer or file browser
It was mistakenly removed in commit ea874112, two days ago.
2020-01-24 19:45:07 +01:00
Benno Schulenberg
a78da18aa4 input: ignore bracketed pastes in help viewer and file browser
This partially fixes https://savannah.gnu.org/bugs/?57623.
Reported-by: Brand Huntsman <alpha@qzx.com>
2020-01-24 19:20:21 +01:00
Benno Schulenberg
d764d7094f tweaks: don't enable bracketed pasting when not handling such pastes
The tiny version is oblivious of bracketed pastes, as it serves no
purpose: in the tiny version there is no auto-indent nor undo nor
tabs-to-spaces conversion.
2020-01-24 17:21:47 +01:00
Benno Schulenberg
2651554721 syntax: nanorc: colorize all-lowercase Meta key binds as valid too
Also, colorize as valid only ASCII letters, not any Unicode letters.
2020-01-23 13:34:37 +01:00
Benno Schulenberg
fa686457c2 input: ignore modifiers on a VT while executing a macro or a string bind
Any modifier keys that are needed to start the execution of a macro
(or of a string bind) should not affect the interpretation of the
keystrokes that are contained within the macro or the string.

This fixes https://savannah.gnu.org/bugs/?57660.

Bug existed since macros were introduced, in version 2.9.0.
2020-01-23 12:39:23 +01:00
Benno Schulenberg
a65f0ec80c tweaks: elide a function that has become too small for its two calls 2020-01-23 12:06:32 +01:00
Benno Schulenberg
e01e1d8ab5 tweaks: remove the now-unused meta flag from 'keystruct' 2020-01-23 12:06:32 +01:00
Benno Schulenberg
58597b6d9b tweaks: judge from the key code itself whether it is a Meta keystroke 2020-01-23 12:06:32 +01:00
Benno Schulenberg
196e913681 tweaks: elide three checks of a shortcut's meta flag
A control code cannot be a Meta keystroke, and a plain printable
character as key code necessarily means it is a Meta keystroke.
So, comparing just the key code is enough.
2020-01-23 12:06:32 +01:00
Benno Schulenberg
620553b795 input: filter out Ctrl+Meta keystrokes, as they can never be shortcuts
Note that DEL_CODE (0x7F) will never occur as input key code, because
it gets translated to KEY_DC in the input routine (or to KEY_BACKSPACE
when --rebinddelete is in effect).
2020-01-23 12:06:32 +01:00
Benno Schulenberg
6df50790cd input: prevent unintentional marking of text for shifted Meta keystrokes
The Shift detection on a Linux console was meant to affect only the
dedicated cursor-movement keys, not <Shift+Meta+character>.

This fixes https://savannah.gnu.org/bugs/?57598.
Indirectly-reported-by: Brand Huntsman <alpha@qzx.com>
2020-01-23 11:22:23 +01:00
Benno Schulenberg
6cd98e32f7 docs: document the new Sh-M-X format for binding <Shift+Meta+letter> 2020-01-23 11:11:34 +01:00
Benno Schulenberg
f9baa4de71 syntax: nanohelp, nanorc: colorize the Sh-M-X format as a valid key name 2020-01-23 11:11:34 +01:00
Benno Schulenberg
1cd5005d06 bindings: allow to bind shifted Meta+letter combinations with Sh-M-X
As long as the user does not define any Sh-M-X bindings in their nanorc,
<Shift> and <CapsLock> will not have any effect on <Alt+letter> combos.
But as soon as any Sh-M-X combination is bound, <Shift+Alt+letter> will
be seen as different from the unshifted keystroke.

This kind of fulfills https://savannah.gnu.org/bugs/?54659.
Requested-by: Peter Passchier <peter@passchier.net>
2020-01-23 11:11:34 +01:00
Benno Schulenberg
f7a3b996fa bindings: force the first letter in a key name to uppercase
So that converting it to a key code remains easy.

This fixes https://savannah.gnu.org/bugs/?57655.

Bug existed since commit 077d307b from yesterday.
2020-01-22 19:05:23 +01:00
Benno Schulenberg
ea874112d8 tweaks: remove a feedback message that is never shown
A plain printable ASCII character (from 0x20 to 0x7E) can never be
a shortcut, so it also can never get reported as being unbound.
2020-01-22 15:41:04 +01:00
Benno Schulenberg
25d397e7b3 feedback: report Ctrl+Alt keystrokes as unbindable
When reporting them as simply unbound, the user might think that M-^X
keystrokes might somehow become bound.
2020-01-22 15:10:41 +01:00
Benno Schulenberg
5111b20bf5 build: exclude bracketed pasting from the tiny version 2020-01-22 12:58:48 +01:00
Benno Schulenberg
f571d6ba36 tweaks: gather four calls that are always done together into a function 2020-01-22 12:49:00 +01:00
Benno Schulenberg
0e21baf611 tweaks: reshuffle three lines, to make the grouping tighther 2020-01-21 15:47:03 +01:00
Benno Schulenberg
1e78881a70 tweaks: avoid analyzing the key string when the target key code is known
For the special keys, pass the key code directly, so that later on
keycode_from_string() does not need to be called.
2020-01-21 15:40:28 +01:00
Benno Schulenberg
077d307b30 tweaks: trim some excessive error checking and key-name frobbing
Also, it is clearer to say that "key name %s is invalid" than it is
to say that some unspecified key name is too short.
2020-01-21 12:14:07 +01:00
Benno Schulenberg
998992ddcb tweaks: condense three comments to one, and do the masking more directly 2020-01-20 19:00:44 +01:00
Benno Schulenberg
0ff9499583 tweaks: reshuffle some lines, to avoid tallying the menus when not needed 2020-01-20 17:44:41 +01:00
Benno Schulenberg
eb1668ce81 tweaks: reshuffle some declarations 2020-01-20 17:44:01 +01:00
Benno Schulenberg
54b97a6f03 bindings: allow to rebind also ^`, although it is synonymous with ^Space
Since ^@ is rebindable too and also a synonym of ^Space, it makes
more sense to allow the user to specify ^` instead, as it is an
unshifted keystroke on US keyboards.

Also, color ^` as valid in a nanorc file, and color ^` and ^@ in
the help viewer.
2020-01-20 17:19:23 +01:00
Benno Schulenberg
5e48c36877 rcfile: do set the meta flag for plain <Meta+ASCII> combinations
The meta flag needs to be suppressed only for the self-defined
<Meta+arrow> key codes.

This fixes https://savannah.gnu.org/bugs/?57643.

Bug existed since commit 5130c35b from a few hours ago.
2020-01-20 16:37:15 +01:00
Benno Schulenberg
9e3fca4021 rcfile: unbind keys by their key code instead of by their key string
Some key strings map to the same key code, so to unbind also a string's
synonyms, go through the list comparing against the key code.  It has
the additional advantage that it is faster: a plain value comparison
instead of a string comparison.

There is no need to compare also the meta flag, because plain printable
ASCII characters (from 0x20 to 0x7E) cannot be shortcuts, so when such
a character matches, it necessarily means it is a meta keystroke.

This fixes https://savannah.gnu.org/bugs/?57397.
2020-01-20 15:44:17 +01:00
Benno Schulenberg
5130c35b85 tweaks: avoid determining the key code from the key string twice
When assign_keyinfo() gets passed zero as key code, it will call
keycode_from_string() to determine the key code from the string.
So, remember the key code when keycode_from_string() gets called
the first time to avoid the second call.
2020-01-20 15:41:34 +01:00
Benno Schulenberg
e01651cde1 pasting: retain the mark's position when it was set at the cursor
When the mark is set at the current cursor position, and then something
is pasted (either with ^U or from outside of nano), then this entire
pasted text should be marked -- just like when it had been typed.  So,
the mark's position should not be adjusted not only when it is located
before the cursor but also when it is at the same place as the cursor.

This fixes https://savannah.gnu.org/bugs/?57631.

Bug existed since version 2.0.7.
2020-01-20 10:34:27 +01:00
Brand Huntsman
12cf1c9980 input: beep when invalid key is pressed at yesno prompt or in linter menu
Just like nano beeps when an unbound key is pressed at other prompts,
or in the help viewer, or in the file browser.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2020-01-19 16:37:14 +01:00
Benno Schulenberg
092711e412 tweaks: remove the now-unneeded code related to bracketed pasting
The suppression of auto-indentation, automatic hard-wrapping, and
tab-to-spaces conversion is now inherent in the way the reading-in
of a bracketed paste is handled by the previous commit: as a single
block of text.
2020-01-19 14:44:28 +01:00
Benno Schulenberg
0e6d693dc8 input: read in an external paste in one go, to allow undoing with one M-U
This makes an external paste (with mouse or <Shift+Insert>) behave
the same as an internal paste (^U), and also inherently suppresses
auto-indentation, automatic hard-wrapping, and tab conversion.

This fulfills https://savannah.gnu.org/bugs/?54950.
2020-01-19 14:44:28 +01:00
Benno Schulenberg
aac3126183 docs: improve the description of which rc-files are read during startup 2020-01-19 13:27:41 +01:00
Benno Schulenberg
63cddceeaa docs: document the new -f/--rcfile option 2020-01-19 12:55:43 +01:00
Benno Schulenberg
486d4956ff tweaks: elide an 'if', by moving the relevant code to a better place 2020-01-17 19:19:22 +01:00
Benno Schulenberg
7567a67cdd tweaks: elide a small function, as it's in fact needed just once 2020-01-17 19:19:04 +01:00
Benno Schulenberg
c4939c76a5 tweaks: rename a function, to make it not contain the name of another
Also, improve the names of its two parameters,
and make the tiny version a wee bit smaller.
2020-01-17 17:28:48 +01:00
Benno Schulenberg
04e557fdaf tweaks: avoid fiddling with the keybuffer when it's not needed
Just change KEY_MOUSE directly into KEY_ENTER for a double click.
2020-01-17 17:06:17 +01:00
Benno Schulenberg
7dcc8f1d7a tweaks: adjust the indentation after the previous change
Also reshuffle some lines, and adjust the comments.
2020-01-17 16:51:21 +01:00
Benno Schulenberg
343f97b3ac new feature: allow specifying a custom nanorc file on the command line
This fulfills https://savannah.gnu.org/bugs/?57547.
Requested-by: Saagar Jha <saagar@saagarjha.com>
2020-01-17 16:51:21 +01:00
Benno Schulenberg
706f3e93f4 tweaks: in comments, reword "titlebar" and "statusbar" to two words each
To differentiate them from the function names.
2020-01-16 19:37:28 +01:00
Benno Schulenberg
f47ef539db display: skip zero-width characters on a Linux console, to avoid a mess
This is a workaround for the VT not being able to handle zero-width
characters properly, displaying them mistakenly as visible characters.

This avoids https://savannah.gnu.org/bugs/?52954.

The problem has existed since forever, but has become noticeable
since the capability for line numbers was added in version 2.7.1.
2020-01-15 18:50:44 +01:00
Benno Schulenberg
2148e857e5 copyright: update the years for significantly changed files 2020-01-15 12:11:56 +01:00
Benno Schulenberg
afa4c6b9fc copyright: update the years for the FSF 2020-01-15 11:42:38 +01:00
Benno Schulenberg
27127853db tweaks: exclude an unneeded fragment of code from the tiny version 2020-01-14 16:28:28 +01:00
Benno Schulenberg
a81ba0215a display: exclude a bit of feedback from the tiny version 2020-01-14 11:22:28 +01:00
Benno Schulenberg
3e0bd533db tweaks: free two strings as soon as they are no longer needed 2020-01-14 11:01:32 +01:00
Benno Schulenberg
e8d20a8e4b display: clear the help lines before a briefly shown warning
This makes the message stand out more.

Also slightly shorten the duration of the pause.
2020-01-14 10:49:12 +01:00
Benno Schulenberg
6896d8df47 tweaks: reduce the scope of two constants and of four variables 2020-01-14 10:35:54 +01:00
Benno Schulenberg
8455251c35 files: revert the previous commit, as the extra warning is annoying
It also erroneously left the succeeding prompt on the screen.

This fixes https://savannah.gnu.org/bugs/?57593.
2020-01-13 21:42:44 +01:00
Benno Schulenberg
5cf351913e files: warn doubly when the user is about to overwrite an existing file 2020-01-13 20:05:56 +01:00
Benno Schulenberg
416386edcd files: alert the user afterward when an overwritten file is being edited
(The ideal behavior would be that nano would warn the user beforehand,
before the file that is being edited by someone else gets overwritten,
but that would require many more changes.  So... just give a helpful
warning -- that's already better than it was.)
2020-01-13 20:00:07 +01:00
Benno Schulenberg
497f126bb2 files: write a lock file also for a new file and when the name changed
(When the new or changed name is that of an existing file AND this
file is being edited by some other editor (or nano itself), then the
behavior is rather strange: nano asks whether to continue, but the
file has already been overwritten and there is nothing the user can
do to cancel or revert things.  A later commit should improve this.)

This fixes https://savannah.gnu.org/bugs/?47975,
and fixes https://savannah.gnu.org/bugs/?53883.
2020-01-13 20:00:07 +01:00
Benno Schulenberg
4687322398 tweaks: rewrap two lines, for consistency with similar lines 2020-01-13 20:00:07 +01:00
Benno Schulenberg
99f0265d34 tweaks: condense a fragment of code 2020-01-12 12:32:20 +01:00
Benno Schulenberg
7b0b9a12ea docs: mention in the FAQ that auto-indentation is suppressed when pasting
And that ^Js will be filtered out too.
2020-01-12 12:09:09 +01:00
Benno Schulenberg
7d483987ce input: do not auto-indent when something is pasted into nano from outside
Also, do not break overlong lines and do not convert tabs to spaces,
nor interpret a <Tab> as an indent command (when the mark is on).
In other words: accept an outside paste as literally as possible.

This fulfills https://savannah.gnu.org/bugs/?40060.
Requested-by: Egmont Koblinger <egmont@gmail.com>

And fulfills https://savannah.gnu.org/bugs/?57527.
Requested-by: Sébastien Desreux <seb@h-k.fr>
Requested-by: Hans Ecke <hecke@gxt.com>

Original-idea-by: Brand Huntsman <alpha@qzx.com>
2020-01-12 11:18:51 +01:00
Brand Huntsman
f705a9674b input: recognize the start and stop sequences of a bracketed paste
Also, tell the terminal to switch on bracketed-paste mode, and toggle
a boolean when the start and stop sequences of such a paste are seen.
This boolean can later be used to suppress auto-indent and such.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2020-01-12 11:18:51 +01:00
Benno Schulenberg
3233e9cfe0 tweaks: correct a comment
The maximum length was increased two weeks ago, in commit 4dcbd40c.
2020-01-12 11:18:29 +01:00
Benno Schulenberg
5a98a51173 bindings: do not show the Full-Justify keystroke when in View mode
The file may not be modified when in View mode, so it makes no sense
to prominently show the M-J keystroke in the Search menu when in that
mode, especially since the keystroke does not really belong there.

This addresses https://savannah.gnu.org/bugs/?57574.
2020-01-10 17:24:29 +01:00
Benno Schulenberg
2eaba21a4c help: increase the minimum help-text width from 24 to 32 columns
Even at 32 columns, the key descriptions are already hopelessly
fragmented.  Any width smaller than that is useless.
2020-01-09 15:10:52 +01:00
Benno Schulenberg
9a227de3e7 tweaks: recompute the wrapping point just once
Instead of for every row after the intro.
2020-01-09 14:47:48 +01:00
Benno Schulenberg
3f57200e10 help: prevent double spaces from protruding across the right edge
This fixes https://savannah.gnu.org/bugs/?57563.
2020-01-09 12:02:49 +01:00
Benno Schulenberg
1486f32d42 help: when a key description wraps, indent its wrapped part
This prevents the wrapped text from cluttering up the two key columns.

This addresses https://savannah.gnu.org/bugs/?57451.
2020-01-09 11:37:49 +01:00
Benno Schulenberg
e3edce4e7b tweaks: elide a helper function, in preparation for an improvement 2020-01-09 11:02:36 +01:00
Benno Schulenberg
0e559c5bbc tweaks: initialize three more booleans straightaway, at declaration
Also improve three comments.
2020-01-09 10:37:56 +01:00
Benno Schulenberg
edfbfbfd0a tweaks: initialize three booleans straightaway, when they are declared
Also improve three comments.
2020-01-08 16:55:45 +01:00
Benno Schulenberg
a4eae770ce tweaks: rename a function, to be a bit more expressive 2020-01-08 16:13:04 +01:00
Benno Schulenberg
72e5c15110 tweaks: move three functions to the file where they are mainly used
The extract() and copy_from_buffer() functions are mainly used for
cutting a line or a region, so move them to src/cut.c.  Also move
the function for which copy_from_buffer() is a wrapper.
2020-01-08 16:04:49 +01:00
Benno Schulenberg
97c8140cea tweaks: rename two functions, to make more sense 2020-01-08 11:09:57 +01:00
Benno Schulenberg
c5b03ca4ae tweaks: rename two variables, to make more sense 2020-01-08 11:00:51 +01:00
Benno Schulenberg
c2f2c659d9 tweaks: rename a parameter and invert its logic, and correct a comment
This changes the main injection routine in the same way that the prompt
injection routine was changed four years ago in commit e540053e.
2020-01-08 10:49:19 +01:00
Benno Schulenberg
9364bd6c81 tweaks: reword two comments, and rewrap another 2020-01-08 10:27:30 +01:00
Benno Schulenberg
baa2be3217 tweaks: improve a comment by indirectly referring to the ncurses docs
See https://invisible-island.net/ncurses/ncurses-intro.html#xterm.
2020-01-07 20:25:31 +01:00
Benno Schulenberg
12742586e5 tweaks: adjust or reword a few items in the FAQ 2020-01-07 16:55:30 +01:00
Benno Schulenberg
194620c5f0 docs: add a FAQ item about a self-compiled nano not reading /etc/nanorc 2020-01-07 14:34:23 +01:00
Benno Schulenberg
67d37adf98 tweaks: renumber some FAQ items in preparation for adding another 2020-01-07 14:24:47 +01:00
Benno Schulenberg
3f0d2fd5ca display: don't let a message write over the second help line
When suspending nano on a Linux console (or FreeBSD console), the
helpful message about using the 'fg' command overwrote the start
of the second help line, kind of hiding the message.  So, output
a double newline before the message to make it stand out.

Also, drop a pointless cursor movement, as endwin() determines
the placement of the cursor all by itself.
2020-01-07 13:38:52 +01:00
Benno Schulenberg
5b07e5fd1f input: discard partial sequences that Slang produces for F17 to F24
This fixes https://savannah.gnu.org/bugs/?57503.
2020-01-03 12:34:15 +01:00
Benno Schulenberg
3cae32390d display: show the cursor during suspension also when built with Slang
This fixes https://savannah.gnu.org/bugs/?57517.

Bug existed since version 2.9.0.
2020-01-03 12:08:27 +01:00
Benno Schulenberg
1be0285832 tweaks: delete some fragments of code that have become irrelevant
Since the previous commit, USE_SLANG can only be defined when NANO_TINY
is also defined.  This means that code that is present only in non-tiny
versions does not need to cater for Slang.
2020-01-03 12:00:06 +01:00
Benno Schulenberg
2867f1bbde build: restrict the use of --with-slang to together with --enable-tiny
Slang contains bugs that get triggered when resizing the terminal,
or rather: when its existing data structures get reinitialized.
Avoid those bugs by forcing the exclusion of the resizing code
when nano is configured with --with-slang.

(The only reason for not entirely eliminating the support for Slang
is to allow Debian to build a tiny nano against Slang for on their
install image.)

This avoids https://savannah.gnu.org/bugs/?57520,
and avoids https://savannah.gnu.org/bugs/?57518,
and dodges https://savannah.gnu.org/bugs/?57513,
and dodges https://savannah.gnu.org/bugs/?57507.
2020-01-03 11:41:22 +01:00
Benno Schulenberg
c4d2bf59fb display: adjust line and column count upon a resize also when using Slang
This partially fixes https://savannah.gnu.org/bugs/?57513.
2020-01-01 14:17:03 +01:00
Benno Schulenberg
5527883c43 input: don't discard the first keystroke after a resize when using Slang
With ncurses, a window resize will cause getch() to return immediately
with some dummy value, which nano can discard.  But with Slang, getch()
will return only when the next keystroke is typed, so the received code
should then not be discarded.

This fixes https://savannah.gnu.org/bugs/?57507.
2020-01-01 13:54:07 +01:00
Benno Schulenberg
ade93ccf25 docs: use more generally available arrows in the cheatsheet
Use bolded HTML entities for the four arrows, instead of the literal
triangular Unicode "arrows" which many fonts don't include.

This addresses https://savannah.gnu.org/bugs/?57505.
2019-12-30 16:41:22 +01:00
Benno Schulenberg
84b305f3f0 build: exclude the escape sequences for F13...F16 from the tiny version
The F13 to F16 function keys are no longer bound by default, and when
there is no nanorc file, there is no way to bind them, so there is no
point in recognizing their escape sequences.
2019-12-30 11:55:41 +01:00
Benno Schulenberg
67b89459d5 tweaks: drop an unneeded call of keypad() -- we never read from topwin
The title bar is used only for showing things, never for typing anything
into.  That is: we never call wgetch() with 'topwin' as an argument.
2019-12-29 14:14:08 +01:00
Benno Schulenberg
6d916c6c4a tweaks: rewrap a comment and a line, and reshuffle a fragment of code 2019-12-29 14:13:27 +01:00
Benno Schulenberg
87542eeaf1 tweaks: move a function to before the one that calls it
And condense its logic.  And improve its comment.
2019-12-27 17:01:15 +01:00
Benno Schulenberg
29f2e3181a tweaks: rename a function and its parameter, to be more fitting
Also, avoid calling a case-changing function when it's not needed.
And elide a default case that can never occur (because the function
always gets called with one of the four letters).
2019-12-27 16:48:07 +01:00
Benno Schulenberg
8255696b45 tweaks: condense five more fragments of repetitious code 2019-12-27 13:49:03 +01:00
Benno Schulenberg
fc00e89499 tweaks: comment fully, so that all handled escape sequences are findable
Also correct a few other comments.
2019-12-27 13:48:36 +01:00
Benno Schulenberg
55946c15e7 tweaks: reshuffle some lines, to group all ignored keystrokes together 2019-12-27 12:16:50 +01:00
Benno Schulenberg
2e539e2c97 tweaks: stop recognizing escape sequences for a key without meaning
Nano does not do anything for the keystroke anyway (KEY_B2, the center
key on the numeric keypad, gets translated to ERR later on), so there
is no point in recognizing some of its escape sequences -- let those
sequences result in "Unknown sequence" instead.
2019-12-27 12:13:40 +01:00
Benno Schulenberg
38c286c019 input: recognize the raw escape sequences for F13 to F16 on xterm too
For symmetry with Gnome Terminal, Konsole, and the Linux console.

This fixes https://savannah.gnu.org/bugs/?57482.
2019-12-26 17:07:51 +01:00
Benno Schulenberg
56d842258c tweaks: condense three fragments of repetitious code 2019-12-26 16:50:19 +01:00
Benno Schulenberg
8ed8ab69d5 tweaks: make a couple of comments more precise 2019-12-26 14:32:44 +01:00
Benno Schulenberg
4dcbd40c49 input: consume and ignore the raw escape sequences for F17 to F24
When --rawsequences is used, consume the full escape sequences for
the F17 to F24 function keys (on xterm-compatible terminals and on
the Linux console), to prevent them entering junk into the buffer.

This fixes https://savannah.gnu.org/bugs/?57483.
2019-12-26 14:02:17 +01:00
Benno Schulenberg
72645b160d input: correct the escape sequence for PageUp/PageDown on Eterm/Urxvt
There is not a single terminal in the terminfo database that has an
"Esc [ n ^" sequence for any keystroke (where n is a digit).
2019-12-26 12:23:08 +01:00
Benno Schulenberg
dda1b167c9 help: don't waste the last column in the help viewer on narrow terminals
When a line in a help text is wider than the terminal, then do not break
that line at COLS - 1, but simply at COLS.  In olden times it made some
sense to have an empty column on the right of the introductory text, to
mirror the one on the left.  But since the width of the introductions
got limited to 74 columns (four years ago, in commit a9aa0ef9), those
texts have (on a default 80-column terminal) at least six empty columns
on their righthand side.  And on narrower terminals, we really don't
want to waste anything and should use all available space.

Also, this whole mechanism of making an exception for end-of-string or
end-of-paragraph and letting only those make use of the final column,
it was a waste of time: it kind-of did the whole break_line() process
again, but then for the entire string (which can be some five hundred
characters long in the introductory texts).  So... get rid of it, make
it simple.  On an 80-column terminal it doesn't make any difference.
2019-12-25 14:39:17 +01:00
Benno Schulenberg
074cf40409 tweaks: remove a superfluous check
When break_line() is called with its last parameter set to TRUE
(meaning that it will break also at a newline) it will return a
value that is bigger than 1.  So it is pointless to ensure that
it is at least 1.
2019-12-25 14:32:04 +01:00
Benno Schulenberg
6c09504040 docs: stop saying that 'set fill' enables hard-wrapping -- it does not
This fixes https://savannah.gnu.org/bugs/?57477.
2019-12-25 14:20:35 +01:00
Benno Schulenberg
4991b3bb1a input: Ctrl+arrow is "Esc O x" on Eterm, as on rxvt -- not "Esc o x"
(Checked on Eterm-0.9.6 running on Xubuntu 18.04.)
2019-12-24 20:01:48 +01:00
Benno Schulenberg
075b7e75bc po: update translations and regenerate POT file and PO files 2019-12-23 11:37:33 +01:00
Benno Schulenberg
c00431134f bump version numbers and add a news item for the 4.7 release 2019-12-23 11:15:53 +01:00
Benno Schulenberg
51065ff24b gnulib: update to its current upstream state 2019-12-22 13:25:32 +01:00
Benno Schulenberg
4314feae11 build: fix compilation for --enable-tiny --enable-wrapping 2019-12-22 12:56:18 +01:00
Benno Schulenberg
410280b089 build: fix compilation when configured with --disable-justify 2019-12-22 11:32:49 +01:00
Benno Schulenberg
178dd9181f tweaks: slightly streamline the search for a possible wrapping point
That is, elide an 'if' for the it-is-a-blank case.
2019-12-19 19:22:02 +01:00
Benno Schulenberg
d30ca576b7 tweaks: optimize the trimming of trailing whitespace
When justifying a paragraph, always first squeeze() is called on
the text (which at that moment consists of a single long line),
which means that (in its wrappable part) this line contains only
single spaces as word separators (and maybe a double space after
a period).  So there is no need to call the general is_blank()
function -- checking for a space is enough.
2019-12-19 12:16:15 +01:00
Benno Schulenberg
ed520c89bc tweaks: improve two comments and the ordering of some operands 2019-12-19 12:15:47 +01:00
Benno Schulenberg
cb44a2bd2c tweaks: reshuffle and rename a few things, to elide duplication 2019-12-19 10:52:06 +01:00
Benno Schulenberg
a0055f3640 wrapping: never break in the quoting part nor in the indentation part
Rationale: nano should not wrap inside the quoting part of a line
because it would change the quoting level, which would misrepresent
things, nor should it wrap inside the indentation part because when
the user tries to indent something beyond the target wrapping width,
she/he does not intend to create a line containing only whitespace,
but effectively wants to push the text beyond the wrapping width.

This copies the behavior of the rewrap_paragraph() routine that is
used during justification, so that automatic hard-wrapping ends up
with the same result as justifying.

Also, always do automatic hard-wrapping when --breaklonglines is in
effect, also when --autoindent is active.

This fixes https://savannah.gnu.org/bugs/?57425.

The bug was old -- it existed since at least version 2.0.6.

This furthermore avoids https://savannah.gnu.org/bugs/?57422.
Reported-by: Sébastien Desreux <seb@h-k.fr>

That bug existed since version 4.4, commit 8fce33af.
2019-12-18 11:22:30 +01:00
Benno Schulenberg
b00c1d6110 justify: treat consecutive indentations that look the same as the same
That is: allow tabs and spaces to be mixed when comparing indentation.
When the mix of tabs and spaces pushes the text of a line to the same
column as on a consecutive line, then those two lines are considered
to have the same indentation and thus belong to the same paragraph.

This reverts the previous commit (594ef222), and improves upon how
nano has behaved since version 2.9.8.

This fixes https://savannah.gnu.org/bugs/?57404 differently.
2019-12-17 16:56:28 +01:00
Benno Schulenberg
594ef2225f justify: distinguish between tabs and spaces when comparing indentation
That is: two consecutive lines are considered to belong to separate
paragraphs when the smallest indentation of those two lines is not
character-by-character identical with the corresponding piece of
indentation of the other line.

In other words: if one line is indented with spaces, and a consecutive
line is indented by the same distance but with tabs, they are taken to
belong to different paragraphs: a justification will not merge them.

This fixes https://savannah.gnu.org/bugs/?57404.

Bug existed since version 2.9.8, commit 432a7d77.
2019-12-17 12:23:55 +01:00
Benno Schulenberg
9631e858f2 display: don't color the space that separates line numbers from text
Go back to how line numbers were colored in versions 2.7.1 to 4.3 --
coloring the space (when a background color is used) was unintented.

This fixes https://savannah.gnu.org/bugs/?57412.

Bug existed since version 4.4, commit 699cacf7.
2019-12-16 19:23:08 +01:00
Benno Schulenberg
26d88ccbb1 syntax: sh: recognize shell rc files also in dedicated directories
This fulfills https://savannah.gnu.org/bugs/?57411.
2019-12-16 19:09:48 +01:00
Benno Schulenberg
413b9cb774 tweaks: rename a function, to get rid of a useless suffix 2019-12-15 19:47:05 +01:00
Benno Schulenberg
d3a8d81afb tweaks: rename a function, to get out of the way for another rename 2019-12-15 19:40:22 +01:00
Benno Schulenberg
e16026eacd linter: beep when trying to go beyond first or last message 2019-12-15 16:15:54 +01:00
Benno Schulenberg
90f18af8bd tweaks: reshuffle two declarations, for compactness 2019-12-15 15:30:48 +01:00
Benno Schulenberg
011e8de480 rcfile: demand that function 'exit' is bound in the file browser
For symmetry with the help viewer.

Even though the user could still exit with the bare Q, E, or X keys,
these are not listed in the help text, so they don't really count.
2019-12-15 15:28:22 +01:00
Benno Schulenberg
4e8afb2877 tweaks: drop M-Space and ^Space from the browser's key list
The 'prevword' and 'nextword' functions do not exist in the browser.

The mistake was made in commit a8c13d79 from five years ago.
2019-12-13 19:29:15 +01:00
Benno Schulenberg
c7ad5c8d86 tweaks: reshuffle an item, to avoid a lone 'else' 2019-12-13 19:06:39 +01:00
Benno Schulenberg
0b1a766964 rcfile: accept also function names and menu names only in lowercase 2019-12-13 19:03:38 +01:00
Benno Schulenberg
a7e11495bd tweaks: move three functions to the file where they are used
Also move the corresponding two arrays.
2019-12-13 18:57:42 +01:00
Benno Schulenberg
b56db25a35 docs: mention that all keywords in a nanorc file should be in lowercase 2019-12-12 19:19:07 +01:00
Benno Schulenberg
e3957ee5ee rcfile: accept only keywords in all lowercase, for speed of comparison
As was noted two months ago: nowhere in the manual does it say that
keywords are case-insensitive, and the manual shows all keywords in
lowercase, and all the examples are in lowercase too.  So... simply
expect keywords to be in all lowercase.
2019-12-12 19:18:56 +01:00
Benno Schulenberg
2a73b4a050 tweaks: reshuffle a fragment of code, for efficiency
First comparing each keystring that starts with "^" against "^Space"
was a waste of time when only one out of fifty such strings actually
is "^Space".
2019-12-12 19:00:52 +01:00
Benno Schulenberg
ef7c78910c tweaks: reshuffle a few lines, for brevity or speed or consistency
Also, don't compare case-insensitively where it is not needed.
2019-12-12 12:34:56 +01:00
Benno Schulenberg
772f1029e5 tweaks: avoid using strlen() where it is not needed 2019-12-12 12:14:38 +01:00
Benno Schulenberg
3251a216cd tweaks: unwrap a few lines, and move some strings to among their peers 2019-12-12 11:41:04 +01:00
Benno Schulenberg
00b0316ab8 syntax: nanohelp: colorize also ^/ as a possible keystroke
(In addition, colorize F20...F24 too.)

This fixes https://savannah.gnu.org/bugs/?57390.

Bug existed since version 4.6, commit 2a97cb9f.
2019-12-10 15:42:28 +01:00
Benno Schulenberg
76d90617cc build: avoid three compiler warnings when using gcc-9.2 or newer
This addresses https://savannah.gnu.org/bugs/?57360.
Reported-by: Brand Huntsman <alpha@qzx.com>
2019-12-08 11:27:06 +01:00
Benno Schulenberg
f516cddce7 build: fix compilation on macOS, where 'st_mtim' is unknown
This fixes https://savannah.gnu.org/bugs/?57367.
Reported-by: Bo Anderson <bo@toxicflames.co.uk>
Tested-by: Bo Anderson <bo@toxicflames.co.uk>
2019-12-06 12:19:32 +01:00
Benno Schulenberg
60b826e5ee tweaks: trim or adjust some whitespace in HTML, and add two keywords 2019-12-05 17:01:55 +01:00
Benno Schulenberg
fc0fcdea10 build: add the uploading of PDF and cheatsheet to the release script 2019-12-05 12:23:45 +01:00
Benno Schulenberg
1dd7b216a0 docs: add or improve the 'description' meta tag in the two HTML pages 2019-12-05 12:06:24 +01:00
Benno Schulenberg
87bf46ffb6 docs: add the 'lang' attribute in the right place to the two HTML pages 2019-12-05 11:52:17 +01:00
Benno Schulenberg
a921bdadbf tweaks: remove a stray space
Reported-by: Brand Huntsman <alpha@qzx.com>
2019-12-05 11:23:47 +01:00
Benno Schulenberg
0271e4a187 input: make <Tab> indent only when mark and cursor are on different lines
It allows entering a TAB character at the cursor position while the
mark is on the same line as the cursor, as some users sometimes do.

This refines the feature that was added in version 2.9.2, and makes
it behave like in the Gedit and Kate editors, for example.

This addresses https://savannah.gnu.org/bugs/?57357.
Reported-by: Sébastien Desreux <seb@h-k.fr>
2019-12-04 17:29:40 +01:00
Benno Schulenberg
076eb6f6af docs: mention that a negative number after "+" counts from the end
A negative line number given on the command line counts from the end
of the relevant file (-1 meaning the first line from the bottom),
and a negative column number from the end of the relevant line.

The feature was added in version 2.8.5 but not mentioned in the manual.

This addresses https://savannah.gnu.org/bugs/?57342.
Suggested-by: Andreas Schamanek <schamane@fam.tuwien.ac.at>
2019-12-02 17:00:35 +01:00
Benno Schulenberg
e484918ef2 tweaks: reshuffle a few lines, for symmetry with the preceding function 2019-12-01 17:04:15 +01:00
Benno Schulenberg
fdf095c32f po: update translations and regenerate POT file and PO files 2019-11-29 11:26:13 +01:00
Benno Schulenberg
81402101d9 tweaks: baptize the release 2019-11-29 11:19:11 +01:00
Benno Schulenberg
154742c5e3 bump version numbers and add a news item for the 4.6 release 2019-11-29 11:08:22 +01:00
Benno Schulenberg
ec569b4bd0 tweaks: rename a variable, to be a bit more fitting 2019-11-27 11:58:40 +01:00
Benno Schulenberg
38743b0016 tweaks: reshuffle an 'if' to avoid a negation, and improve a comment 2019-11-27 11:56:35 +01:00
Benno Schulenberg
68c3aaf2df softwrap: when switching to another buffer, re-align the starting column
When we switch to another buffer, the window may have been resized
since we were last in this buffer, so make sure that 'firstcolumn'
gets a fitting value.

This fixes https://savannah.gnu.org/bugs/?56991.

Bug existed since version 2.8.0, since the softwrap overhaul.
2019-11-27 11:49:09 +01:00
Benno Schulenberg
2a97cb9f41 bindings: allow to rebind ^/, even though it is synonymous with ^_
This fixes https://savannah.gnu.org/bugs/?57302.
Reported-by: Tiago Almeida <tjamadeira@gmail.com>
2019-11-26 19:25:24 +01:00
Benno Schulenberg
af8ffa8c94 tweaks: silence a warning when configured with --enable-tiny 2019-11-25 19:21:03 +01:00
Benno Schulenberg
3ffefbfddc build: fix compilation for --enable-tiny --enable-histories 2019-11-25 19:17:41 +01:00
Benno Schulenberg
8637acb106 docs: correct the description of the 'spell' menu 2019-11-25 17:42:40 +01:00
Benno Schulenberg
51a3f78d69 docs: mention that 'hunspell' is now the first default spelling program 2019-11-25 17:38:50 +01:00
Benno Schulenberg
4d77e0adbb speller: prefer 'hunspell' over 'spell', because it can handle UTF-8
Also, 'hunspell' is sensitive to the 'LANG' environment variable,
so that spell checking will take place for the language that the
user is using, instead of always for English.  (This is a behavior
change, and some people may not like it, expecting the spell check
to occur always for English, but... we'll see.)
2019-11-25 16:57:04 +01:00
Benno Schulenberg
2b8a73348c gnulib: update to its current upstream state 2019-11-24 13:12:41 +01:00
Benno Schulenberg
576502a5c5 speller: when 'spell' is not found, try running 'hunspell -l' instead
This increases the chances that spell checking will work out of the box,
without any extra installing or configuration.

This addresses https://savannah.gnu.org/bugs/?57296.
2019-11-24 12:12:38 +01:00
Benno Schulenberg
ec9a11c761 display: do refresh the edit window when exiting from the help viewer
There are several cases (searching, replacing, spell checking, ...)
where exiting from the help viewer does NOT return the user to the
editing of the buffer.

This fixes https://savannah.gnu.org/bugs/?57295.

Bug existed since version 4.3, commit 5817e83e.
2019-11-23 20:22:31 +01:00
Benno Schulenberg
1c63bf0e38 bindings: the 'all' keyword should include the browser menu always
Also for the "universal" functions (like cursor movement) and the
special 'implant' function, the 'all' keyword should include the
browser menu.

This fully fixes https://savannah.gnu.org/bugs/?57280.

Bug existed since version 3.2, commit cc01bc3e.
2019-11-22 13:21:20 +01:00
Benno Schulenberg
4aa1678f3b bindings: the 'all' keyword should encompass the browser menu too
This fixes https://savannah.gnu.org/bugs/?57280.
Reported-by: Tiago Almeida <tjamadeira@gmail.com>

Bug existed since version 3.2, commit cc01bc3e.
2019-11-22 12:44:28 +01:00
Benno Schulenberg
c60d3bbb97 tweaks: don't do in the parent something that only the child needs 2019-11-17 08:20:32 +01:00
Benno Schulenberg
90d4b51837 tweaks: group the closing of two descriptors, and reword two comments 2019-11-17 08:15:52 +01:00
Benno Schulenberg
302ea79d1c syntaxes: put the 'linter' and 'formatter' commands on a separate line
To show that they are a different class of thing than the file-matching
regexes and the comment thing, which all kind of "describe" the file.
2019-11-04 20:56:41 +02:00
Benno Schulenberg
ebeed9c013 tweaks: fuse two regexes into one 2019-11-04 20:49:17 +02:00
Benno Schulenberg
75dd9bee38 syntax: javascript: colorize the boolean values 'true' and 'false' too
Original-patch-by: Ryan Westlund <rlwestlund@gmail.com>
2019-11-03 19:50:41 +02:00
Benno Schulenberg
9151abcd45 tweaks: avoid setting and resetting a variable when there is no need 2019-10-28 10:28:52 +01:00
Benno Schulenberg
3258bb0ff4 docs: adjust the compilation instructions to two-digit version numbers 2019-10-27 19:21:55 +01:00
Benno Schulenberg
3f3698640b syntax: ruby: colorize also lowercase global/instance variables
And avoid recoloring the reserved words BEGIN and END as constants.

Inspired-by: Rory Thrasher <thrasher@redhat.com>
2019-10-27 16:34:06 +01:00
Benno Schulenberg
432388b23e tweaks: add two translator hints
And unmark two identical strings, to cause the marked ones to sit
next to each other in the POT file.
2019-10-27 16:30:50 +01:00
Benno Schulenberg
bad618e537 tweaks: harmonize a message with another 2019-10-27 16:19:45 +01:00
Benno Schulenberg
7ae305fdc0 tweaks: group the closing of descriptors together, for compactness 2019-10-27 10:40:09 +01:00
Benno Schulenberg
7d4f279c04 tweaks: close the unused reading ends of two more output pipes
It is done for 'spell', so do it also for 'sort' and 'uniq'.
2019-10-27 10:34:12 +01:00
Benno Schulenberg
f230c46e5e tweaks: drop the unneeded closing of descriptors when exiting anyway
Also, when something goes wrong in the later stages of the pipeline,
the error code would try to close descriptors that are already closed,
which is not right.  So, just let exit() handle any file descriptors
that are still open.
2019-10-27 10:25:37 +01:00
Benno Schulenberg
bc5a225678 tweaks: improve some comments, and trim some repetitive ones 2019-10-27 10:10:03 +01:00
Benno Schulenberg
493b334ebb tweaks: mark two strings for translation
The marking was accidentally lost two weeks ago in commit d12191db.
2019-10-26 17:09:00 +02:00
Benno Schulenberg
7d54207627 tweaks: be explicit about which program complained 2019-10-26 12:04:10 +02:00
Benno Schulenberg
458933f09e tweaks: elide an unneeded and leaky function 2019-10-26 12:01:23 +02:00
Benno Schulenberg
2b49a19793 linter: report it as an error when running the linting program fails
When something goes wrong, nano should beep and the status bar should
use the error color (red by default).

This fixes https://savannah.gnu.org/bugs/?57116.
2019-10-26 11:52:53 +02:00
Benno Schulenberg
fc716156a4 tweaks: correct a comment, and retype a variable 2019-10-26 11:18:38 +02:00
Benno Schulenberg
2b9f06194f formatter: don't let output from the program pollute the screen
Run the formatting program outside of curses mode, so that any output
(complaints) that it produces will be on the terminal after exiting
from nano -- at least on a terminal emulator, not on a Linux VT.

This also allows the formatter to be an interactive program.

The disadvantage is that the screen flickers when typing M-F.

This fixes https://savannah.gnu.org/bugs/?57104.
2019-10-25 19:23:24 +02:00
Benno Schulenberg
631defb8b2 tweaks: reword an undo/redo string that was overlooked during the rename 2019-10-25 19:21:17 +02:00
Benno Schulenberg
a6dae403e6 formatter: accept the formatted result also upon a nonzero exit status
For a nonzero exit status of the formatting program, report on the
status bar that the program "complained", but read in the (probably)
reformatted text anyway -- it can be easily undone with M-U.  Only
report failure when the intended program could not be run.

This fixes https://savannah.gnu.org/bugs/?57105.
2019-10-25 17:45:52 +02:00
Benno Schulenberg
b4dbbe3799 syntax: html: add a formatter command, making use of 'tidy' 2019-10-25 17:27:14 +02:00
Benno Schulenberg
4281b6becb commands: rename 'fixer' to 'formatter', to be less misleading
The word "fixer" sounds too much as if the command would be able
to fix mistakes or correct errors.  Especially when seen next to
"linter", it sounds as if one does a syntax check and the other
fixes the found mistakes.  (Although the command might in theory
be used for this, it is not its intended purpose.)
2019-10-25 17:24:28 +02:00
Benno Schulenberg
34b1824822 syntax: default: don't colorize stuff between two pairs of brackets
That is, don't allow another bracket between the opening and the
closing bracket.
2019-10-25 12:23:40 +02:00
Jeroen Roovers
b025f67805 syntax: gentoo: highlight the BDEPEND variable as well
This fixes https://bugs.gentoo.org/698420.
Reported-by: Alessandro Barbieri <lssndrbarbieri@gmail.com>

Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
2019-10-24 17:24:06 +02:00
Benno Schulenberg
40f8ca0d07 syntax: html: colorize only full attributes, and colorize strings later
Attribute names that are a part of another word should not be colored,
nor should attribute names within strings.

This addresses the other half of https://savannah.gnu.org/patch/?9865.
Original-patch-by: Ryan Westlund <rlwestlund@gmail.com>
2019-10-24 17:19:04 +02:00
Benno Schulenberg
aae752912e syntax: javascript: colorize also special values 'null' and 'undefined'
This addresses one half of https://savannah.gnu.org/patch/?9865.
Original-patch-by: Ryan Westlund <rlwestlund@gmail.com>
2019-10-24 17:19:04 +02:00
Benno Schulenberg
3c695664ec tweaks: elide a function call for the plain ASCII case
When dealing with a plain, seven-bit ASCII character, don't bother
calling is_cntrl_mbchar() but determine directly whether it is a
control character.  Also reshuffle things so that we don't compare
charlen == 1 when we already know it is 1.
2019-10-21 18:52:44 +02:00
Benno Schulenberg
8a7634f070 tweaks: rename two parameters plus a variable, to match others
Also improve a comment and normalize an indentation.
2019-10-21 13:02:17 +02:00
Benno Schulenberg
fa88fcc8f2 tweaks: rename a function, and elide a parameter that is always NULL
After the previous change, all remaining calls of parse_mbchar() have
NULL as their third parameter.  So, drop that parameter and remove the
chunk of code that handles it.  Also rename the function, as there are
already too many functions that start with "parse".
2019-10-21 12:35:14 +02:00
Benno Schulenberg
c2d8641f01 chars: add a faster version of the character-parsing function
It elides a parameter that is always NULL, and elides two ifs
that always take the same path.
2019-10-21 12:24:23 +02:00
Benno Schulenberg
3d5e51bcd0 syntax: nanorc: colorize in bright red everything that is invalid
Random words or mistyped keywords should not stay uncolored.
2019-10-20 14:47:15 +02:00
Benno Schulenberg
95ae124891 history: don't wait when there is something wrong with the history files
Do not wait for the user to press a key when there is some problem
with any of the history files.  Just start and indicate the problem
on the status bar.  The precise error message is stored and will be
shown on the terminal when exiting from nano.

This addresses https://savannah.gnu.org/bugs/?56524.
2019-10-20 14:30:04 +02:00
Benno Schulenberg
1a8646393a tweaks: condense a fragment of code by making use of a helper function
(It copies a byte too many, which then gets overwritten in the next
statement, but this is not speed-critical code.)
2019-10-20 09:45:58 +02:00
Benno Schulenberg
054559dc93 tweaks: rename three variables, to be more descriptive 2019-10-20 09:45:58 +02:00
Benno Schulenberg
fdeab9b4c9 tweaks: order two functions more sensibly 2019-10-20 09:45:58 +02:00
Benno Schulenberg
f26c121ca9 tweaks: adjust two comments, to better fit the actual functions 2019-10-20 09:45:58 +02:00
Benno Schulenberg
17c16a4bf5 tweaks: rename a function and elide its first parameter 2019-10-20 09:45:58 +02:00
Benno Schulenberg
46566572d6 utils: don't accept NULL for the string to be copied
This should not occur, so crash when it does happen.
2019-10-20 09:45:58 +02:00
Benno Schulenberg
b4a5fac744 tweaks: use a literal NULL instead of a variable that is NULL
Now all calls of mallocstrncpy() have NULL as the first parameter
(apart from one call in utils.c, but that can be changed), so the
function can be simplified.
2019-10-20 09:45:58 +02:00
Benno Schulenberg
f816da413a tweaks: elide a variable that is the same as another 2019-10-18 17:12:51 +02:00
Benno Schulenberg
3a0ac428ba tweaks: remove a redundant check for an existing emergency file
This case is caught (by O_EXCL) later on, at the appropriate moment:
when the file is created.

Also, this removes a superfluous lstat() for each temporary file.
2019-10-18 17:04:55 +02:00
Benno Schulenberg
97ab28a164 tweaks: exclude two fragments of code from the tiny version
Also improve a comment, and recorrect an indentation.
2019-10-18 14:25:55 +02:00
Benno Schulenberg
ccb739dd7d tweaks: don't wrap calls of statusline() that slightly overshoot 80 cols 2019-10-18 14:04:15 +02:00
Benno Schulenberg
1082f2adec files: don't mention the name of the temp file when reading goes wrong
When writing a temp file goes wrong, its name is not mentioned either.
2019-10-18 13:38:20 +02:00
Benno Schulenberg
042b8394a0 tweaks: use a simpler positive/negative check for after copy_file() 2019-10-18 13:25:38 +02:00
Benno Schulenberg
f2d6e6fa5e tweaks: check the return value of copy_file() also after its other uses 2019-10-18 12:37:39 +02:00
Benno Schulenberg
5390f96900 files: distinguish between read error and write error when prepending
This fixes https://savannah.gnu.org/bugs/?57066.

Bug existed in this form since version 2.4.3 -- in older versions
it segfaulted.
2019-10-18 12:15:14 +02:00
Benno Schulenberg
50ed18be17 tweaks: move a call of umask() closer to where it is relevant 2019-10-17 17:29:11 +02:00
Benno Schulenberg
a6365707c0 tweaks: remove the superfluous closing of a file descriptor
The file itself is closed three lines earlier; this also closes the
corresponding descriptor.
2019-10-17 16:43:07 +02:00
Benno Schulenberg
6fad6a17da tweaks: rename a variable, to be distinct and visible 2019-10-17 12:17:09 +02:00
Benno Schulenberg
eb757e7c5b tweaks: simplify the opening of files when prepending
There is no need for a file descriptor: all reading and writing
is done on streams.
2019-10-17 12:12:07 +02:00
Benno Schulenberg
b554606047 tweaks: add a local variable, for clarity, to not preuse another one 2019-10-17 11:49:21 +02:00
Benno Schulenberg
e915fb1650 tweaks: adjust the indentation after the previous change, and another 2019-10-17 11:45:03 +02:00
Benno Schulenberg
4e40ec057e tweaks: elide an unneeded check when making a backup
When making a backup, we can be certain that the relevant file
is not a temporary file, so 'stream' will necessarily be NULL.
2019-10-17 11:45:03 +02:00
Benno Schulenberg
bd0026be86 tweaks: elide another two calls of umask(), and rename two variables 2019-10-17 11:43:42 +02:00
Benno Schulenberg
a1bef0e953 tweaks: avoid three unneeded calls of umask() in the normal case 2019-10-16 19:17:42 +02:00
Benno Schulenberg
f5693d4151 tweaks: elide a duplicate opening of the existing file when prepending 2019-10-16 17:40:52 +02:00
Benno Schulenberg
e3807f00a2 tweaks: rename two variables, and add a third, for more contrast 2019-10-16 17:16:48 +02:00
Benno Schulenberg
022cc084a7 files: when opening a file for copying, it should NOT be created
Weird bug.  The first occurrence is probably never hit because the
existing file has been tentatively opened fourteen lines earlier,
but that looks superfluous: double work.  And the second occurrence
will not be hit because the temp file is unlikely to have disappeared.
2019-10-16 16:27:23 +02:00
Benno Schulenberg
0f98466e2f tweaks: adjust the indentation after the previous change
Also, don't bother assigning the stream pointer of the existing file
to variable 'f', as it gets overwritten right away by the pointer of
the temp file.
2019-10-16 16:05:40 +02:00
Benno Schulenberg
40c067133a tweaks: remove two superfluous conditions when prepending
When prepending, we cannot be writing to a temp file,
so 'stream' (and thus 'f') will necessarily be NULL.
2019-10-16 15:47:35 +02:00
Benno Schulenberg
36270748dc tweaks: condense or improve some comments 2019-10-16 13:47:30 +02:00
Benno Schulenberg
1894c81412 tweaks: rename two parameters, for contrast and to match others 2019-10-16 13:07:41 +02:00
Benno Schulenberg
e917ef0105 tweaks: die on an impossible condition -- to be removed later 2019-10-16 12:27:27 +02:00
Benno Schulenberg
3347682fd0 tweaks: remove a pointless updating of the title bar
A possible change in filename won't be pushed to the screen until a
doupdate() is done, and that won't happen until nano is waiting for
a keystroke again.  So... just let it be.
2019-10-16 12:22:39 +02:00
Benno Schulenberg
7c5b104859 tweaks: rename three variables, to match others elsewhere 2019-10-16 11:46:22 +02:00
Benno Schulenberg
3b9a24a7ca tweaks: rename a local variable, to not shadow another 2019-10-16 11:11:19 +02:00
Benno Schulenberg
7d3290fb91 tweaks: rename three variables, to be consistent with other linestructs 2019-10-16 11:04:26 +02:00
Benno Schulenberg
df0ae2ace5 tweaks: reshuffle a few declarations, and reduce the scope of one 2019-10-16 10:48:14 +02:00
Benno Schulenberg
bc91af2e3c tweaks: pass an empty string as an answer instead of a NULL pointer
Also, rename a parameter, to be more distinct and to avoid an abbrev.
2019-10-15 13:39:57 +02:00
Benno Schulenberg
48b94d71c7 tweaks: pass an empty string for copying instead of a non-existent one 2019-10-15 11:49:07 +02:00
Benno Schulenberg
f14be47878 tweaks: move two functions to after the one that they make use of 2019-10-15 11:23:09 +02:00
Benno Schulenberg
c51f5f4bff docs: mention that the 'nopauses' option is obsolete 2019-10-15 11:23:05 +02:00
Benno Schulenberg
7f8851caa8 statusbar: show only the first error message, with dots to indicate more
The old default behavior of showing the first three messages with a
long pause after each of them was annoying, and the final "Further
messages were suppressed" hid the relevant information.  So, when
there is more than one error message, just pause very briefly and
then add trailing dots to the first message.

This makes the 'nopauses' option a no-op.

This addresses https://savannah.gnu.org/bugs/?57048.
2019-10-15 11:17:20 +02:00
Benno Schulenberg
bfdc31fbb4 docs: add the M-F and M-N keystrokes to the cheatsheet 2019-10-14 17:14:07 +02:00
Benno Schulenberg
69d2045c9f syntax: nanorc: colorize only lowercase keywords as valid
Nowhere does the manual say that nanorc keywords are case-insensitive,
and none of the examples use uppercase keywords.  So, simply consider
uppercase keywords to be invalid.  This will later allow nano to use
case-sensitive comparisons, which are slightly faster.
2019-10-14 11:45:56 +02:00
Benno Schulenberg
c63f4c1f58 docs: remove the note about the formatter having been removed
The 'fixer' command has taken the place of the 'formatter' command.

(Also, normalize a double blank line before a chapter.)
2019-10-14 10:30:04 +02:00
Benno Schulenberg
b8dc8d4a37 syntax: nanorc: colorize all arguments of 'fixer' and 'linter' as valid 2019-10-14 10:28:45 +02:00
Benno Schulenberg
8749ccb469 syntax: nanorc: colorize the 'fixer' command as valid
Also add a default formatting command to the Go syntax.
2019-10-14 10:28:45 +02:00
Benno Schulenberg
b5c5cde0d4 docs: document the 'fixer' command, a per-syntax content arranger 2019-10-14 10:28:45 +02:00
Benno Schulenberg
d8c03cd4cd tweaks: elide a variable, and add a condition to elide an assignment 2019-10-14 10:28:45 +02:00
Benno Schulenberg
1536a76ced tweaks: normalize the indentation after the previous change 2019-10-14 10:28:45 +02:00
Benno Schulenberg
d2fb371fe2 feedback: say it when spell check or manipulation did not change anything 2019-10-14 10:28:45 +02:00
Benno Schulenberg
34170611d3 restored feature: a per-syntax 'fixer' command that processes the buffer
The command can be used to run some kind of formatter or corrector or
arranging tool on the buffer.  By default the command is bound to M-F.
The formatter/corrector/arranging program must be non-interactive.

This addresses https://savannah.gnu.org/bugs/?55365,
and addresses https://savannah.gnu.org/bugs/?54651.
2019-10-14 10:28:45 +02:00
Benno Schulenberg
23c36ba667 tweaks: remove two pointless re-inclusion guards
The nano.h file is included only by proto.h, and the proto.h file is
included just once by each src/*.c file.  The include guards for these
two header files serve no purpose.

(Include guards are useful when you have bunches of header files
and several of them include others from amongst themselves.)
2019-10-13 19:14:27 +02:00
Benno Schulenberg
31d5cb1118 build: slightly speed up the compilation of the tiny version
Don't include header files when they won't actually be needed.

(Also, remove a superfluous #ifdef.)
2019-10-13 18:55:49 +02:00
Benno Schulenberg
f551c07e7a tweaks: add some "fall-through" comments, and reshuffle some breaks 2019-10-13 17:35:57 +02:00
Benno Schulenberg
2656f543f4 undo: don't try to copy a string that doesn't exist
This fixes https://savannah.gnu.org/bugs/?57051.

Bug existed since commit d256d0cb from earlier today.
2019-10-13 17:31:53 +02:00
Benno Schulenberg
ba79602281 tweaks: condense two comments, and rename two parameters
Also use 'while' instead of 'for'.
2019-10-13 16:45:02 +02:00
Benno Schulenberg
094758be15 tweaks: reshuffle a fragment of code into two alternatives 2019-10-13 16:11:15 +02:00
Benno Schulenberg
06bbc70d4a tweaks: use a string-copy function that checks for out-of-memory 2019-10-13 12:38:46 +02:00
Benno Schulenberg
d256d0cbc0 tweaks: add a helper function without the ubiquitous NULL argument
For conciseness and clarity.
2019-10-13 12:24:27 +02:00
Benno Schulenberg
ab6635c3a6 tweaks: use the given string instead of the found match, for clarity 2019-10-13 11:52:09 +02:00
Benno Schulenberg
416ad4c5fd tweaks: use a better variable name for the argument of an option 2019-10-13 11:46:22 +02:00
Benno Schulenberg
0374708597 undo: put the cursor back on the original row for a full-buffer operation
When an operation that replaces the entire buffer is undone, the
position of the viewport is lost.  Compensate for this by storing
the row of the cursor in the undo item, and, after executing the
undo item, arranging the viewport so that the cursor is back on
the original row -- the row where the operation was invoked.

This fixes https://savannah.gnu.org/bugs/?57039.
2019-10-12 11:20:41 +02:00
Benno Schulenberg
101987f5c6 build: fix compilation when configured with --disable-color 2019-10-12 11:20:19 +02:00
Benno Schulenberg
ad451933c6 tweaks: rename a function and add a parameter, so it becomes more general
Also adjust the comments and rename three variables.
2019-10-10 08:28:08 +02:00
Benno Schulenberg
222e67300e tweaks: reshuffle some declarations, and rename a variable 2019-10-10 08:23:16 +02:00
Benno Schulenberg
d12191db5a tweaks: pass any special undo/redo messages to the add_undo() function
For the three operations (justification, spell checking, and filtering)
that need to undo or redo two suboperations (cutting and then pasting)
in one go, pass the message that describes the operation to add_undo(),
so that the undo item does not need to be modified after the call.

This looks better, but does add some twenty NULL parameters elsewhere.
2019-10-09 19:21:27 +02:00
Benno Schulenberg
785efc2087 tweaks: make a function do a check so its calls don't need to 2019-10-09 18:58:30 +02:00
Benno Schulenberg
557ad827f9 tweaks: condense two comments, and rewrap a line 2019-10-09 14:49:42 +02:00
Benno Schulenberg
600f81cf98 tweaks: rename three variables, and reshuffle some lines 2019-10-09 14:20:29 +02:00
Benno Schulenberg
56d98052d1 tweaks: adjust the indentation after the previous change 2019-10-08 11:51:47 +02:00
Benno Schulenberg
265d3245af rcfile: process extensions to file-matching commands straightaway
When 'extendsyntax' is used with a 'header' or 'magic' command, it
must be processed immediately.  It is pointless to store the command,
because when then it is processed (when the syntax gets used), it is
too late to have any effect.

This fixes https://savannah.gnu.org/bugs/?56997.

With-help-from: Brand Huntsman <alpha@qzx.com>

Bug existed since version 4.3, commit cba9d8d0.
2019-10-08 11:37:02 +02:00
Benno Schulenberg
53d4224be9 cutting: do nothing when trying to chop a word leftward at start of file
Instead of marking the buffer as modified, provide the feedback that
"nothing was cut", like when trying to chop a word rightward at the
end of the buffer.

This fixes https://savannah.gnu.org/bugs/?57015.

Bug existed since version 4.4, commit 4314b8de.
2019-10-07 17:24:18 +02:00
Benno Schulenberg
f813fd0f4d rcfile: allow binding also F17...F24
For historical reasons the rebinding code allows binding F13...F16,
which on most terminals are typable with Shift plus F1...F4.  But,
at least on an Xfce Terminal, Shift plus F1...F12 produce F13...F24.
On a Linux console, Shift plus F1...F8 produce F13...F20.  So: allow
to bind the full shifted F13...F24 range.  It costs no extra code
and makes things more rounded.
2019-10-07 16:23:40 +02:00
Benno Schulenberg
e90b40e651 docs: add a note saying that rebinding ^M or ^I is not advisable
Also say that rebinding ^H is sometimes impossible, or when it's
made possible, that it rebinds the Backspace key too.

This addresses https://savannah.gnu.org/bugs/?56994.
Reported-by: Tiago Almeida <tjamadeira@gmail.com>
2019-10-07 13:28:27 +02:00
Benno Schulenberg
07c1e72216 tweaks: slightly reword some fragments in the manual's rebinding section 2019-10-07 13:01:18 +02:00
Benno Schulenberg
7338b45d36 docs: remove some excessive detail from the sample nanorc file
The sample file should just mention the basics.  The manual contains
all the details.
2019-10-06 14:50:27 +02:00
Benno Schulenberg
c95e5362e6 docs: mention that color rules are applied in the order they are listed
Suggested-by: Tiago Almeida <tjamadeira@gmail.com>
2019-10-06 14:27:29 +02:00
Benno Schulenberg
2698a2ba68 syntax: c: recognize some C++ header files by their Emacs modeline
For extensionless files, recognize C/C++ ones from the mode name
between the -*- marks on the first line.

This addresses https://savannah.gnu.org/patch/?9719.

Inspired-by: Devin Hussey <husseydevin@gmail.com>
2019-10-06 12:01:02 +02:00
Benno Schulenberg
ff0e01a69e bindings: don't hard-bind ^H in the help viewer or the file browser
Hard-binding the ^H control code prevents the user from rebinding
the keystroke.

This fixes https://savannah.gnu.org/bugs/?56995.

Bug existed since version 4.0, commit 72a49dbb.
2019-10-05 12:43:46 +02:00
Benno Schulenberg
72b13adeff po: update translations and regenerate POT file and PO files 2019-10-04 12:11:14 +02:00
Benno Schulenberg
481178428b oops: fix typo in Changelog 2019-10-04 12:00:09 +02:00
Benno Schulenberg
9a2ef3a542 bump version numbers and add a news item for the 4.5 release 2019-10-04 11:31:29 +02:00
Benno Schulenberg
b480e7fc9c tweaks: remove some timing code that has served its purpose 2019-10-03 19:00:50 +02:00
Benno Schulenberg
3e33d1eba6 tweaks: rewrap a line, reshuffle a declaration, and improve some comments 2019-10-03 17:22:55 +02:00
Benno Schulenberg
cdb9b04980 docs: add two examples of the 'tabgives' command to the sample nanorc 2019-10-03 16:41:10 +02:00
Benno Schulenberg
31ff7ead73 tweaks: move a function to before its callers and next to its kind
Also, improve the indentation of two random lines.
2019-10-03 11:24:01 +02:00
Benno Schulenberg
5398d986ef tweaks: speed up determining the width of plain ASCII characters 2019-10-03 11:09:21 +02:00
Benno Schulenberg
b02dccc51f tweaks: elide a function from a non-UTF8 build
In a non-UTF8 build, mbwidth() returns always 1, so it is pointless
to call that function and compare its result to zero then.

Also, don't bother special-casing the function for a non-UTF8 locale.
2019-10-03 10:48:10 +02:00
Benno Schulenberg
3158133edd tweaks: rename three variables, for contrast and more sense 2019-10-03 10:12:30 +02:00
Benno Schulenberg
acf50ae26d tweaks: improve a handful of comments, and reduce the needed padding
Reshuffle a few struct elements so they will require less padding.
2019-10-02 19:33:03 +02:00
Benno Schulenberg
01b840890d tweaks: rename another type, again to better fit the general pattern 2019-10-02 19:32:41 +02:00
Benno Schulenberg
9bd60e7d5d tweaks: frob a few comments 2019-10-02 17:46:20 +02:00
Benno Schulenberg
c5e46101b1 tweaks: reshuffle some lines, to elide an unneeded assignment 2019-10-02 17:39:45 +02:00
Benno Schulenberg
53b77cb4c6 tweaks: rename another type, to also better fit the general pattern 2019-10-02 17:18:51 +02:00
Benno Schulenberg
cc4ce8d83b tweaks: rename a type, to better fit the general pattern 2019-10-02 17:09:22 +02:00
Benno Schulenberg
23c8ef70aa tweaks: reshuffle some lines, to have the same order as elsewhere 2019-10-02 15:20:49 +02:00
Benno Schulenberg
2a4d338d97 tweaks: reshuffle a fragment, to group some toggles together 2019-10-02 15:07:04 +02:00
Benno Schulenberg
9c202198a3 tweaks: simplify a calculation, as done elsewhere 2019-10-01 15:03:40 +02:00
Benno Schulenberg
c8dc67717b tweaks: mark as 'const' a parameter that takes fixed strings [coverity] 2019-10-01 15:02:08 +02:00
Benno Schulenberg
4df2f81295 tweaks: avoid recomputing a maximum value every time round the loop 2019-10-01 13:28:50 +02:00
Benno Schulenberg
78def852d1 mouse: make the clickable width of menu items more consistent
When there are fewer than four menu items, act as if there are four:
make their clickable width half the width of the screen.

Until now, when there were two menu items, their clickable width would
be the full width of the screen, which was overwide.  But when there
was just one menu item, its clickable width would suddenly be as small
as when the menu had the maximum number of items (12 for an 80-column
screen).  This was odd.

Also, slightly simplify another computation.
2019-10-01 12:46:31 +02:00
Benno Schulenberg
a4933873c9 tweaks: avoid leaking memory when finding an invalid string [coverity] 2019-09-30 19:42:27 +02:00
Benno Schulenberg
1861052234 tweaks: avoid a comparison between signed and unsigned [coverity] 2019-09-30 19:30:54 +02:00
Benno Schulenberg
2307b31887 tweaks: use 'void' in prototypes of parameterless functions [coverity] 2019-09-30 19:06:25 +02:00
Benno Schulenberg
108a3b0b41 tweaks: sort two keywords strictly alphabetically 2019-09-29 15:11:15 +02:00
Benno Schulenberg
e0d9b7a8af tweaks: add a translator hint, and correct two others 2019-09-29 15:08:57 +02:00
Benno Schulenberg
b3ace4d8f6 tweaks: don't burden all menus with something meant for the WriteOut menu
The first_sc_for() function is somewhat costly, so avoid calling it
when it is not necessary.

Most menus have either so many entries that unbinding some keys does
not reduce the number of shown entries, or they have so few entries
that each entry already has space enough and will not profit from
having more room available.  But the WriteOut menu is an edge case.
Most translators don't use --tempfile and translate the key tags for
the WriteOut menu making use of all 17 positions that are available
for each of them.  This makes that when --tempfile is used, some of
those tags get truncated.  This is not so bad, because --tempfile is
normally not used.  But when it isn't used (when the discardbuffer
function isn't bound), the WriteOut menu should make full use of the
available width to avoid truncating any translated tags.
2019-09-29 13:27:03 +02:00
Dirkjan Ochtman
e9d6ceab0b syntax: rust: add the words reserved in 2018, and remove unreserved ones
See https://doc.rust-lang.org/reference/keywords.html,
and https://rust-lang.github.io/rfcs/2421-unreservations-2018.html.

Signed-off-by: Dirkjan Ochtman <dirkjan@ochtman.nl>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2019-09-28 13:29:23 +02:00
Benno Schulenberg
5103bfe6b8 bindings: add a dedicated keycode for <Tab> for when a region is marked
In this way the keycode cannot be unbound from the 'indent' function,
so pressing <Tab> on a marked region will always indent the region.

This fixes https://savannah.gnu.org/bugs/?56960.

Bug existed since the "tabbing" of a marked region was introduced,
in version 2.9.2, commit 09958ebd.
2019-09-28 12:39:42 +02:00
Benno Schulenberg
cfd17f5722 tweaks: speed up the counting of the menu entries to be shown
Instead of first counting all available entries and then capping it
at MAIN_VISIBLE, simply stop counting when MAIN_VISIBLE is reached.
2019-09-28 12:03:02 +02:00
Benno Schulenberg
43235c2f16 tweaks: rename a function, to be a bit more fitting 2019-09-27 19:07:25 +02:00
Benno Schulenberg
b14ad451a9 tweaks: rename two variables, away from single letters 2019-09-27 18:53:44 +02:00
Benno Schulenberg
cd00d0975e tweaks: move a fragment of common code into the appropriate function 2019-09-27 18:49:39 +02:00
Benno Schulenberg
40f6dbc34e tweaks: move two functions to after the ones that they call 2019-09-27 18:41:22 +02:00
Benno Schulenberg
a9fb56a8c9 tweaks: move a function to a better file, to be amongst its kind 2019-09-27 17:43:28 +02:00
Benno Schulenberg
07c0d29276 gnulib: update to its current upstream state 2019-09-27 11:17:35 +02:00
Benno Schulenberg
310c971d50 docs: describe the new syntax-specific 'tabgives' command 2019-09-25 19:42:16 +02:00
Benno Schulenberg
3644d51b97 new feature: a 'tabgives' command to define what the Tab key produces
The 'tabgives' command is syntax-specific and should be followed by a
string containing the character(s) that a single press of the <Tab> key
should produce -- most likely a single TAB or a small bunch of spaces,
but any string is allowed.  This overrides the 'tabstospaces' option.

When one wants to make sure <Tab> inserts always four spaces and never
a TAB when editing a Python file, one could add to one's nanorc:

  extendsyntax python tabgives "    "

where there are four spaces between the quotes.  And when one wants
to ensure, when editing a Makefile, that <Tab> always inserts a TAB
and never spaces, independent of what tabstospaces is set to, one
could add to one's nanorc:

  extendsyntax makefile tabgives "	"

where there is a literal TAB character between the quotes.

This fulfills https://savannah.gnu.org/bugs/?53661,
Requested-by: Andrew Pennebaker <andrew.pennebaker@gmail.com>
And addresses https://savannah.gnu.org/bugs/?54760.
Requested-by: Henry van Megen <hvanmegen@gmail.com>
And addresses part of https://savannah.gnu.org/bugs/?54775.
Requested-by: Dirkjan Ochtman <dirkjan@ochtman.nl>
2019-09-25 19:35:07 +02:00
Benno Schulenberg
591d3170aa tweaks: add some translator hints, be more precise on permissible length 2019-09-24 17:15:42 +02:00
Benno Schulenberg
752dde1130 docs: mention that gcc must be at least version 5.0
This is needed to get '-std=c11' by default.

Reported-by: Ansuel Smith <ansuelsmth@gmail.com>
in https://lists.gnu.org/archive/html/nano-devel/2019-09/msg00004.html
2019-09-23 13:50:51 +02:00
Benno Schulenberg
b5eda7f812 tweaks: reshuffle two fragments, to group things better 2019-09-23 13:03:52 +02:00
Benno Schulenberg
4d44b03fc8 tweaks: rename a variable, to be more compact 2019-09-22 17:38:22 +02:00
Benno Schulenberg
2d16c27820 tweaks: add two hints for translators, to try and help avoid mistakes 2019-09-22 17:31:27 +02:00
Benno Schulenberg
ad65b79ac7 usage: mark the -J/--guidestripe option plus argument as translatable
This fixes https://savannah.gnu.org/bugs/?56930.

Bug existed since the vertical guiding bar was introduced,
in version 4.0, commit 66c6eb51.
2019-09-21 19:50:55 +02:00
Benno Schulenberg
fe5bd8cdef usage: properly align --help output also when it has accented characters
As printf() is not UTF8-aware, we have to determine ourselves how many
columns each short and long flag take up and add the required number of
spaces (not tabs, because their size is not fixed) to fill things up.

This fixes https://savannah.gnu.org/bugs/?56928.

Bug existed since version 4.3, commit 2f169107.
2019-09-21 19:31:48 +02:00
Benno Schulenberg
c848ec3d53 tweaks: elide two multiplications with something that is always 1 2019-09-18 15:25:42 +02:00
Benno Schulenberg
ab6390cad0 tweaks: remove two superfluous macros, as sizeof(char) is always 1 2019-09-18 15:20:08 +02:00
Benno Schulenberg
48124fdba4 tweaks: use a more effecient way to skip storing an empty file name
Position history refers only to actual files, so when the filename
is blank...  there is nothing that needs to be remembered.
2019-09-18 14:18:48 +02:00
Benno Schulenberg
ebd9eb346d tweaks: improve a bunch of comments, and reshuffle some declarations 2019-09-17 17:38:42 +02:00
Benno Schulenberg
413116e1b5 tweaks: rename another variable, for a better fit 2019-09-17 16:46:11 +02:00
Benno Schulenberg
69a3d39bc4 tweaks: rename three variables, for more contrast 2019-09-17 16:42:53 +02:00
Benno Schulenberg
f081fa3047 tweaks: rename two variables, to better describe what they contain
The 'tilded' variable is used for two purposes: a user's home directory,
and an intermediate user name.
2019-09-17 14:26:09 +02:00
Benno Schulenberg
4383b01b9b tweaks: adjust indentation after previous change, reshuffle declarations 2019-09-17 14:11:45 +02:00
Benno Schulenberg
b901a20a06 tweaks: use an early return when there is no tilde
Also improve a comment, and use a 'while' instead of a 'for'.
2019-09-17 14:09:40 +02:00
Benno Schulenberg
d6e05d8376 tweaks: simplify the determination of a canonical path
Suggested-by: Brand Huntsman <alpha@qzx.com>
2019-09-17 13:32:15 +02:00
Benno Schulenberg
21e307e820 tweaks: rename a variable, normalize a comment, and reshuffle a free() 2019-09-16 17:25:47 +02:00
Benno Schulenberg
dbcf4f0cbe color: don't concatenate an absolute path with the working directory
When the user specified an absolute path... it is NOT relative to the
current working directory.

This fixes https://savannah.gnu.org/bugs/?56902.
Reported-by: Brand Huntsman <alpha@qzx.com>

Bug existed since version 2.4.2, commit ec8d51be.
2019-09-16 17:12:25 +02:00
Benno Schulenberg
7b88557ef5 tweaks: meld two calls of free() into a single one, to elide an 'else' 2019-09-16 16:55:03 +02:00
Benno Schulenberg
75a6abe6d2 docs: mark the undoing of justifications as done in the TODO list 2019-09-11 17:25:35 +02:00
Benno Schulenberg
ba5b85baf0 tweaks: rename three variables, to better indicate what they hold
They hold not a terminal but flags, settings, state.
2019-09-06 19:40:38 +02:00
Benno Schulenberg
9f95fa9ce5 tweaks: reshuffle a line, to group things better 2019-09-06 19:25:43 +02:00
Brand Huntsman
8853bc448d search: accept a match at start of file when searching from command line
For a forward search from the command line, pass FALSE to 'skipone'
so that an occurrence at the head of the file is not skipped over.

This fixes https://savannah.gnu.org/bugs/?56845.
Reported-by: Derek Wolfe <dwwolfe1@gmail.com>

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-09-02 09:05:50 +02:00
Benno Schulenberg
15148a5e6d search: after search-at-startup, store the column (for vertical movement)
This fixes https://savannah.gnu.org/bugs/?56846.
2019-09-01 16:15:15 +02:00
Benno Schulenberg
7d9ad31cd9 po: update translations and regenerate POT file and PO files 2019-08-25 10:57:32 +02:00
Benno Schulenberg
aecbc6faa9 bump version numbers and add a news item for the 4.4 release 2019-08-25 10:29:14 +02:00
Benno Schulenberg
a06b921f12 docs: document the search-at-startup feature (+/string or +?string) 2019-08-20 19:22:25 +02:00
Benno Schulenberg
bdf1a9d4e7 syntax: perl: avoid upsetting older glibcs with crafty range expression
The regcomp() function from glibc-2.27 (and older) considers the
bracket expression ['-.] to be invalid -- mistakenly.  Avoid using
any range expression in the relevant regex and instead enumerate
all acceptable characters.

This avoids https://savannah.gnu.org/bugs/?56766.
2019-08-19 17:15:29 +02:00
Benno Schulenberg
5c399dfc6e build: exclude the search-at-startup feature from the tiny version 2019-08-18 13:03:11 +02:00
Benno Schulenberg
ed4b6486a1 search: don't wipe the status bar at startup when there was an error 2019-08-18 12:59:23 +02:00
Brand Huntsman
2326bf695e search: accept toggles for case and regex when searching at startup
Allow the user to specify that the search string should be interpreted
case-sensitively and/or as a regular expression by preceding the search
indicator (/ or ?) with c and/or r.  Or to switch these things off by
using C and/or R.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2019-08-18 12:59:04 +02:00
Benno Schulenberg
a9dd73fb16 new feature: allow specifying a search string to "jump to" at startup
The string to "jump to" is specified with +/ for a forward search
(from the top of the file), or with +? for a backward search (from
the bottom of the file).

This fulfills https://savannah.gnu.org/bugs/?54535.
Requested-by: Derek Wolfe <dwwolfe1@gmail.com>

With-help-from: Brand Huntsman <alpha@qzx.com>
2019-08-18 11:16:03 +02:00
Benno Schulenberg
073bd3ad6e rcfile: properly handle an empty syntax before an 'include' statement
So that in the error message the correct filename gets shown
instead of the name of the (first) include file.

Reported-by: Brand Huntsman <alpha@qzx.com>
2019-08-18 10:56:17 +02:00
Benno Schulenberg
4bcc224560 docs: change a few URLs over to https, and rewrap a couple of NEWS items 2019-08-17 17:17:32 +02:00
Benno Schulenberg
f2f367ba9c syntaxes: change some unneeded 'icolor' commands to 'color' commands 2019-08-17 17:01:19 +02:00
Benno Schulenberg
48bff32ee3 gnulib: update to its current upstream state 2019-08-17 15:35:43 +02:00
Brand Huntsman
304f07258b rcfile: for an empty syntax, show the line number of the 'syntax' command
When reporting a syntax without any color commands, show the line number
of the relevant 'syntax' command instead of the line number where the
emptiness is concluded, because the latter can be many lines later.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-08-17 13:47:19 +02:00
Benno Schulenberg
e1c2573c7a tweaks: improve a comment, and drop a superfluous one 2019-08-17 13:28:47 +02:00
Benno Schulenberg
07ec7de8eb tweaks: remove a saving and restoring that has become superfluous
The previous commit saves and restores filename and linenumber for
each single included file (after globbing), so it is now redundant
to do it for each 'include' command.
2019-08-17 13:21:34 +02:00
Brand Huntsman
82f5fed45a rcfile: report the correct command location for an invalid 'include'
For each included file, save and restore file name and line number of
the including file, so that an error message about a faulty 'include'
command can indicate the location of this 'include'.

This fixes https://savannah.gnu.org/bugs/?56488.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-08-17 13:07:20 +02:00
Benno Schulenberg
a2f7e31ba2 new document: a condensed overview of nano's shortcut keystrokes
It's in a two-column format that fits on a single page, and uses the
more widely known Ctrl+X and Alt+X notations (instead of ^X and M-X).

The file is published on https://nano-editor.org/cheatsheet.html.
2019-08-16 19:49:50 +02:00
Benno Schulenberg
55983ee9d1 docs: make the synopsis of --speller and 'set speller' more accurate 2019-08-16 18:50:49 +02:00
Benno Schulenberg
cd274a7830 syntax: perl: don't color the character after a variable name
And generally improve the regex for coloring Perl variable names.

This fixes https://savannah.gnu.org/bugs/?56713.
With-help-from: Brand Huntsman <alpha@qzx.com>

Bug existed since the Perl syntax was introduced,
in version 1.2.2, commit 70047eef.
2019-08-14 09:24:32 +02:00
Benno Schulenberg
f773fa3968 syntax: default: colorize bracketed section headers in some config files 2019-08-14 09:18:51 +02:00
Benno Schulenberg
288355686b syntax: c: allow an underscore in lowercase type names 2019-08-11 20:06:46 +02:00
Benno Schulenberg
f7d5a82a5d search: wipe the status bar before searching again (M-W / M-Q)
So that any message that is on the status bar after the search
will be a response to this search and not some leftover.

This fixes https://savannah.gnu.org/bugs/?56737.
2019-08-10 13:11:41 +02:00
Benno Schulenberg
63e04ac31e tweaks: make a function name unique, to not overlap with others 2019-08-09 19:34:03 +02:00
Benno Schulenberg
0c63b50fdc tweaks: move a general function to a better place 2019-08-09 19:24:30 +02:00
Benno Schulenberg
94c9defde1 docs: slightly reword some of the descriptions around syntax highlighting 2019-08-09 19:16:16 +02:00
Benno Schulenberg
ee91c51e09 syntax: perl: avoid recognizing embedded hash signs as a comment starter
Require that a comment starts at the start of a line or is preceded by
whitespace.  This prevents most hash signs used for other purposes (and
what follows them) getting colored as comments.
2019-08-08 12:08:34 +02:00
Benno Schulenberg
1e3f3a7511 syntaxes: recognize .ctp extension as a PHP file, and .cu as a C/C++ file
This brings color to CakePHP template files, and to CUDA files.

This addresses https://bugs.debian.org/932192.
Requested-by: Jérôme Bardot <bardot.jerome@gmail.com>
2019-08-08 12:02:07 +02:00
Benno Schulenberg
8fce33afe0 text: copy leading quote characters when automatic hard-wrapping occurs
When the user is typing a long text and --breaklonglines is in effect,
then any leading comment or quoting characters are automatically added
to each automatic new line.

This fulfills https://savannah.gnu.org/bugs/?56042.
Requested-by: Sébastien Desreux <seb@h-k.fr>
2019-08-06 09:10:34 +02:00
Benno Schulenberg
4314b8ded3 display: blank the status bar on a successful cut or paste
But don't blank it when using the word-deletion functions.

This addresses https://savannah.gnu.org/bugs/?56564.

Original-patch-by: Bill Hager <prog00@protonmail.com>
2019-08-03 19:32:54 +02:00
Benno Schulenberg
52e39ae5f7 docs: slightly reword the descriptions of most configure options 2019-08-02 17:10:11 +02:00
Benno Schulenberg
5e7ba03ad1 docs: stop mentioning the 'unjustify' function, as it no longer exists
Unjustifying is done by using the general undo function (M-U).
2019-07-29 19:42:52 +02:00
Benno Schulenberg
97fec5603f docs: mention the M-N toggle instead of the obsolete M-# one
Reported-by: Bill Hager <prog00@protonmail.com>
2019-07-29 19:29:55 +02:00
Benno Schulenberg
3b8847f319 syntax: po: colorize numbers only when they form a self-contained word 2019-07-29 19:12:58 +02:00
Benno Schulenberg
a578d2706c copying: do not prevent M-6 from copying emptiness into the cutbuffer
The check mistakenly prevented the user from copying a region that
ended at EOF.  Removing the check also gives the user a way to clear
the cutbuffer (with M-A M-6 or ^6 M-6, for example).

This fixes https://savannah.gnu.org/bugs/?56563.
Reported-by: Liu Hao <lh_mouse@126.com>
2019-07-29 19:00:22 +02:00
Benno Schulenberg
44d38815cc display: clear the remainder of a row only when there actually is some
Make display_string() report back (via a global variable) whether the
just converted string has room to spare within the allotted span, so
that draw_row() can avoid trying to clear the remainder when there is
nothing to clear.

This fixes https://savannah.gnu.org/bugs/?56562.

Bug existed since commit 699cacf7 from three days ago.
2019-06-28 20:45:47 +02:00
Benno Schulenberg
b23a5d5b29 tweaks: rewrap two lines, and reshuffle some logic to make more sense 2019-06-26 19:44:51 +02:00
Benno Schulenberg
b96cc8c212 tweaks: rename a parameter in three functions, to say what it points to 2019-06-26 19:44:51 +02:00
Benno Schulenberg
09ad0eb5f7 tweaks: rename a function, to suit better, and reshuffle its parameters 2019-06-26 19:44:51 +02:00
Benno Schulenberg
62ca113ed3 tweaks: reword and condense two comments, and correct another 2019-06-26 19:07:08 +02:00
Benno Schulenberg
5cfb74650d scrolling: don't overscroll when the edit window has just one row
If the edit window consists of a single row, then the do_down() call
has already brought the desired line or chunk into view -- no attempt
should then be made to scroll the screen further.

This fixes https://savannah.gnu.org/bugs/?56553.

Bug existed since version 2.9.6, commit 0d9080a2.
2019-06-26 12:55:29 +02:00
Benno Schulenberg
8cd6aa0a32 display: when linenumbering, correctly spotlight text that spans two rows
This fixes https://savannah.gnu.org/bugs/?56552.

Bug existed since line numbers were introduced, in version 2.7.1.
2019-06-26 11:24:44 +02:00
Benno Schulenberg
fcbe41942f tweaks: reshuffle an assignment, and trim some excessive blank lines 2019-06-26 10:18:32 +02:00
Benno Schulenberg
39e5b52734 tweaks: call the correct lighting function directly when softwrapping 2019-06-26 10:12:23 +02:00
Benno Schulenberg
70b347183b tweaks: condense some comments, and drop two unneeded initializations 2019-06-26 09:47:07 +02:00
Benno Schulenberg
699cacf7a4 display: don't clear a row beforehand -- just clear the remainder
It is a waste of time to first fully clear a row when right afterward
text will be written to it (for most of the row, on average).  So...
just clear the part of the row after the written text.  Curses has the
perfect function for this: clrtoeol().
2019-06-25 12:09:28 +02:00
Benno Schulenberg
23cb26c58f tweaks: improve a handful of comments 2019-06-25 11:34:04 +02:00
Benno Schulenberg
3422ec3419 browser: draw a bar of spaces only where needed -- for the selected item
The edit window has been fully cleared just before the list-drawing
loop has started, so there is no need to wipe anything.  Only for the
highlighting bar all its characters need to be drawn with the correct
attributes.
2019-06-25 11:25:03 +02:00
Benno Schulenberg
5f1d9af375 tweaks: drop two parameters that are no longer needed 2019-06-25 11:13:35 +02:00
Benno Schulenberg
f3a441043d display: where needed, use slow blanking, but elsewhere do it much faster
Where the row needs to be filled with spaces with the attributes that
were set (title bar, prompt bar, and browser highlight), use printw().
But when the row needs to be actually cleared, use the much faster
clrtoeol().

This reduces the time needed to clear a full row with 95 percent.
2019-06-25 11:12:27 +02:00
Benno Schulenberg
e6c629951f display: use a somewhat faster method to clear a row
On an 80-column terminal, using a single printw() instead of
a loop of addch() reduces the time taken with 13 percent.
2019-06-23 20:49:01 +02:00
Benno Schulenberg
c06d5452f5 tweaks: move a call from two different places to a single place 2019-06-23 19:57:15 +02:00
Benno Schulenberg
1fcb9b99cf tweaks: move a function to before the first one that calls it 2019-06-23 12:29:17 +02:00
Benno Schulenberg
d8c840692e tweaks: reshuffle an 'if' out of a function, and rename the function 2019-06-23 12:15:19 +02:00
Benno Schulenberg
8c7b6bd21a tweaks: when precalculating, allocate all the cache space upfront
Instead of doing it haphazardly while lines are getting categorized.
2019-06-23 11:57:27 +02:00
Benno Schulenberg
21d0755de5 tweaks: try the allocation of a multidata cache just once per line
It does not need to be allocated for each multiline regex separately.
2019-06-23 11:45:03 +02:00
Benno Schulenberg
bbab9e2e62 tweaks: shorten two messages that translators tend to make too long 2019-06-19 19:34:19 +02:00
Benno Schulenberg
9ea1cd947c tweaks: add a translator hint, to clarify four short words 2019-06-19 19:14:47 +02:00
Benno Schulenberg
b8987a1e40 po: update translations and regenerate POT file and PO files 2019-06-18 10:33:21 +02:00
Benno Schulenberg
895d2b8e9c bump version numbers and add a news item for the 4.3 release 2019-06-18 10:04:16 +02:00
Benno Schulenberg
47068c3770 build: fix compilation when configured with --disable-color 2019-06-17 09:59:15 +02:00
Benno Schulenberg
345cf5accc files: don't close a newly-created buffer when it is the only one
This fixes https://savannah.gnu.org/bugs/?56504.
Reported-by: Liu Hao <lh_mouse@126.com>

Bug existed since commit 7e422402 from two weeks ago.
2019-06-16 19:12:52 +02:00
Benno Schulenberg
c7ca60b046 tweaks: don't check the user's nanorc file for accessibility twice
Also, condense some alternatives into a single 'if'.
2019-06-16 17:53:44 +02:00
Benno Schulenberg
01e4f85f29 tweaks: remove a check that is no longer relevant
Since commit 7028adf2 from three days ago, also the color commands of
syntaxes that are defined in a main nanorc will get parsed during a
second pass, so it is perfectly possible to extend such syntaxes
later on in the same (or another) nanorc file.
2019-06-16 11:02:03 +02:00
Benno Schulenberg
6bfbb2bcd9 tweaks: remove two more unneeded assignments
'opensyntax' is relevant only during the first pass through all the
nanorc files (intros_only == TRUE) when it is checked that syntax
commands are grouped properly and not mixed with others.  And
'lastcolor' is relevant only during the second pass of a specific
syntax, because only then the color commands are actually parsed.
2019-06-16 10:41:53 +02:00
Benno Schulenberg
d82c753ba4 rcfile: at terminating points, verify that a defined syntax is not empty
Whenever, in an rcfile, a command is encountered that is not part of a
syntax definition, a currently open syntax should be closed, but only
after checking that the syntax contains at least one color command.

This fixes https://savannah.gnu.org/bugs/?56501.

Bug existed since version 2.3.3.
2019-06-15 19:42:31 +02:00
Benno Schulenberg
0af9ce926b rcfile: close off a syntax when a non-syntax command is encountered
The 'color' commands of a syntax definition should not be allowed to
be interspersed with other, non-syntax commands.

This fixes https://savannah.gnu.org/bugs/?56498.

Bug existed since before version 2.6.0.
2019-06-15 15:07:57 +02:00
Benno Schulenberg
4e14a8a977 tweaks: remove two unneeded assignments, and improve a comment
Also reshuffle a line, for esthetics.
2019-06-15 14:35:53 +02:00
Benno Schulenberg
accd17c249 tweaks: remove four unneeded pre-processor directives
The parse_next_word() function is not being used by the history code
anymore since commit ecd18c16, more than two years ago.
2019-06-15 14:17:13 +02:00
Benno Schulenberg
e8eb30cad6 tweaks: just mark four rcfile errors for translation, like the others
The messages get translated when they get stored in the linked list.
This is to economize on the number of actual calls of gettext().
2019-06-15 14:13:20 +02:00
Benno Schulenberg
36bd68f3ab tweaks: rename a function, to better suit what it does 2019-06-15 14:07:57 +02:00
Benno Schulenberg
03692363a2 tweaks: move a syntax check to a better place, to reduce duplication 2019-06-15 13:04:01 +02:00
Benno Schulenberg
0e94575c6b rcfile: check for missing color commands only when a syntax is still open
This fixes https://savannah.gnu.org/bugs/?56497.

Bug existed since commit 7028adf2 from two days ago.
2019-06-15 12:17:33 +02:00
Benno Schulenberg
27cc3117e2 tweaks: rename two parameters, for more contrast, and elide another
Also rename a function.
2019-06-14 10:56:49 +02:00
Benno Schulenberg
19f71632c8 tweaks: remove an unneeded "closing" of a syntax after extending it
As 'extendsyntax' commands are no longer interpreted immediately when
the rcfiles are read, there is no need to set 'opensyntax' to FALSE
after interpreting such a command -- for a single syntax they are all
interpreted in a row.
2019-06-14 10:56:49 +02:00
Benno Schulenberg
e3f18e7a6c tweaks: rename two variables, and frob some comments
Also reshuffle the newline stripping, as it's pointless for lines
that are skipped.
2019-06-14 10:56:49 +02:00
Benno Schulenberg
b55923f5ec tweaks: reshuffle some lines, to group things more sensibly 2019-06-14 10:56:49 +02:00
Benno Schulenberg
7028adf211 rcfile: fully read each included file, so all its syntaxes are seen
An included file can contain multiple syntaxes.  If reading would stop
as soon as a command different from 'syntax' and 'header' and 'magic'
is found, any later syntaxes would not be seen.  So each nanorc file
needs to be fully scanned -- it's just the interpretation of all the
color commands that we want to delay until the syntax gets actually
used.

This fixes https://savannah.gnu.org/bugs/?56478.

Bug existed since commit cba9d8d0 from a month ago.
2019-06-14 10:49:30 +02:00
Benno Schulenberg
d7df7c694a tweaks: elide a pre-processor #else clause, by using braces instead 2019-06-13 15:47:29 +02:00
Benno Schulenberg
ce69d5be88 tweaks: condense two comments, and normalize the whitespace of a label 2019-06-12 11:10:27 +02:00
Benno Schulenberg
3da4240229 tweaks: rename a variable, to fit a little better 2019-06-12 11:03:03 +02:00
Benno Schulenberg
43caf7bb7b tweaks: avoid an unneeded, extra stat() for temporary files 2019-06-12 10:48:03 +02:00
Benno Schulenberg
e8e30e5197 tweaks: elide an unneeded, duplicate stat() for the FIFO check 2019-06-12 10:34:53 +02:00
Benno Schulenberg
189de5ee78 files: suppress feedback when writing an emergency or temporary file
This fixes https://savannah.gnu.org/bugs/?56474.

Bug existed since commit 47770bd3 from two weeks ago.
2019-06-12 09:51:14 +02:00
Benno Schulenberg
c57d040e99 tweaks: don't bother calling mblen() in a non-UTF-8 build
There is no need, because in non-UTF-8 encodings nano treats
each single byte as one character anyway.
2019-06-11 19:48:03 +02:00
Benno Schulenberg
0adb15c7a1 display: properly show all characters in a non-UTF-8 build
Also, don't use mblen() directly, to not get stuck when it returns -1,
which it will when running a non-UTF-8 build in a UTF-8 locale.

This fixes https://savannah.gnu.org/bugs/?56472.

Bug existed since commit cd094822 from yesterday.
2019-06-11 19:07:34 +02:00
Benno Schulenberg
1e48df388e build: avoid a warning when using --disable-utf8 2019-06-11 14:24:30 +02:00
Benno Schulenberg
d477775871 build: avoid a warning on FreeBSD, OpenBSD, and Alpine 2019-06-11 12:29:32 +02:00
Benno Schulenberg
ed40fd8031 tweaks: reorder some code, to further optimize display_string() for ASCII
The majority of characters in the files that get edited with nano will
be single-byte printable ASCII characters, so their case should come
first in the main loop of display_string().
2019-06-11 12:08:28 +02:00
Benno Schulenberg
5c4b0b38f4 chars: redo the speedup for plain ASCII from three commits ago
It was lost in the elision of length_of_char() two commits ago.
2019-06-11 11:10:53 +02:00
Benno Schulenberg
bd331b0198 tweaks: reshuffle some lines and frob some comments 2019-06-10 20:07:10 +02:00
Benno Schulenberg
cd09482231 tweaks: elide a function that is an amalgam of three others
In addition, the function was used just once, had a weird return value,
and now some more code can be excluded from a non-UTF8 build.

Make use of the fact that any single-byte character always occupies
just one column, and call the costly mbtowc() and wcwidth() only for
characters that actually are multibyte.
2019-06-10 19:43:50 +02:00
Benno Schulenberg
c5955d14ce chars: speed up the determination of length and width for plain ASCII 2019-06-10 17:22:41 +02:00
Benno Schulenberg
7d38379919 tweaks: rename two parameters, away from single letters 2019-06-10 12:36:16 +02:00
Benno Schulenberg
45bf18f8fe tweaks: rename three variables, to get rid of a suffix or an underscore
Also drop an unneeded cast.
2019-06-10 12:34:24 +02:00
Benno Schulenberg
787dca6724 tweaks: elide an unneeded variable 2019-06-10 12:06:12 +02:00
Benno Schulenberg
15e36956b5 tweaks: avoid parsing a character twice
Let mbtowc() do all the work, and thus also elide a variable.
2019-06-10 12:01:10 +02:00
Benno Schulenberg
967f581860 tweaks: adjust some whitespace and rewrap a few lines
And remove two unneeded casts.
2019-06-09 20:03:44 +02:00
Benno Schulenberg
1075de1222 tweaks: rename two functions, to get rid of the "mb" abbreviation
Also, for me "move" is about moving the cursor.  But these functions
are about moving an index in a text, which is more general.
2019-06-09 19:37:56 +02:00
Benno Schulenberg
3457039cee tweaks: rename a variable, to get out of the way of the next commit 2019-06-09 19:31:01 +02:00
Benno Schulenberg
ca77254968 tweaks: use a slightly faster function where appropriate
Also, correct a call of move_mbright() to use the intended format.
2019-06-09 19:22:24 +02:00
Benno Schulenberg
710a600f22 chars: speed up case-insensitive searching by roughly one percent
It is less of a speedup than I was hoping for, though.
2019-06-09 19:13:25 +02:00
Benno Schulenberg
843eef65b8 tweaks: put some timing code back into the search function 2019-06-09 18:48:52 +02:00
Benno Schulenberg
781c7a7a5f chars: create a dedicated function for getting the length of a character
Instead of calling in twenty places parse_mbchar(pointer, NULL, NULL),
use a simpler and faster char_length(pointer).  This saves pushing two
unneeded parameters onto the stack, avoids two needless ifs, and elides
an intermediate variable.

Its main purpose will follow in a later commit: to speed up searching.
2019-06-09 18:38:46 +02:00
Benno Schulenberg
aa205f58ca tweaks: rename a bunch of variables, to become identical to others 2019-06-09 17:07:02 +02:00
Benno Schulenberg
3bf04afa6d tweaks: specifically refer to the manual of GNU grep for more regex info 2019-06-09 12:30:35 +02:00
Benno Schulenberg
71236e145d tweaks: rename two variables, away from a single letter
And adjust the indentation after the previous change.
2019-06-09 11:08:34 +02:00
Benno Schulenberg
7be76af418 tweaks: speed up the counting of characters in mbstrlen()
This function is used in get_totsize(), so speed is important.

There is no reason why the length of the string must limited to a
certain size -- that is just a leftover from the function merge in
commit ba2e6f43 from a year ago.
2019-06-09 11:04:52 +02:00
Benno Schulenberg
fb17929fab tweaks: use FALSE for booleans instead of zero
Also adjust some indentation and reduce the scope of a variable.
2019-06-09 10:41:14 +02:00
Benno Schulenberg
fea1901592 docs: remove "--" from the default value of 'quotestr'
Adjust the documentation to the removal of "--" in the previous commit.
2019-06-08 17:48:44 +02:00
Benno Schulenberg
33fea90bcd justify: remove "--" from the quoting regex, to avoid false paragraphs
The use of a double dash (for an option name or as sentence separator)
is too common to allow it to be seen always as a comment introducer.
Users of Lua and Postgres will have to redefine 'quotestr' themselves
if they want to be able to rewrap block comments with ^J.

The other characters that were added in commit c5a72103 (!, %, and ;)
are less problematic because they tend to be glued to the end of words,
so they are unlikely to appear at the start of a line.

This fixes https://savannah.gnu.org/bugs/?56462,
and fixes https://savannah.gnu.org/bugs/?56461.

Bug existed since version 4.0, commit c5a72103.
2019-06-08 16:47:08 +02:00
Benno Schulenberg
f03c87c300 tweaks: squeeze excess spaces out of a line in situ
There is no need to make a copy of the line, because if there are some
bytes that are moved, they are always moved toward the left -- the line
can only shrink, never expand.
2019-06-08 16:17:59 +02:00
Benno Schulenberg
45b1a38b82 tweaks: factor out a fragment of code that is repeated three times 2019-06-08 14:17:41 +02:00
Benno Schulenberg
c3bf17a801 tweaks: improve a handful of comments 2019-06-08 14:00:24 +02:00
Benno Schulenberg
8582e4a6b9 tweaks: don't bother keeping track of whether a squeezed line has shrunk
When squeezing excess spaces from a line has proved unsuccessful, we
have already copied all of its data, so it hardly makes a difference
whether we free the old or the new data.  Choose to free always the
old data, so that we can simplify things.
2019-06-08 14:00:03 +02:00
Benno Schulenberg
9b34d0a4fb tweaks: rename two variables, to be unique 2019-06-08 10:10:31 +02:00
Benno Schulenberg
26d16ab9d1 tweaks: rename a variable, to better suit its counterpart 2019-06-08 10:05:32 +02:00
Benno Schulenberg
6ca8518428 tweaks: make better use of two variables, and reshuffle two comments 2019-06-08 10:03:15 +02:00
Benno Schulenberg
f2c61c4b9a docs: mention the default value for 'errorcolor' 2019-06-07 11:24:51 +02:00
Benno Schulenberg
c4e04eb682 docs: show double quotes where they are needed
Instead of saying that string parameters should be enclosed in
double quotes, just show the quotes in the relevant commands.

Also, rename the parameters, to better fit the subsequent description.
2019-06-07 11:15:02 +02:00
Benno Schulenberg
0b257fe558 tweaks: sort three translator names better 2019-06-06 15:22:02 +02:00
Benno Schulenberg
941637615b docs: clarify that in nano regexes are extended regular expressions
And add a concise summary of the most important special characters.

This addresses https://savannah.gnu.org/bugs/?56438.
2019-06-06 15:16:56 +02:00
Benno Schulenberg
378aa8bc41 docs: slightly reword the notice about the changed defaults since 4.0 2019-06-05 19:40:15 +02:00
Benno Schulenberg
157098ee75 gnulib: update to its current upstream state 2019-06-05 16:45:27 +02:00
Benno Schulenberg
8d4e171d3c tweaks: improve a couple of comments 2019-06-05 16:23:34 +02:00
Benno Schulenberg
6f1e5912a9 tweaks: stop allocating and freeing a holder struct for every cut/paste
This "holder" information is needed for every cut and paste and other
block operation.  Instead of allocating and freeing it for every such
operation, just have the six elements as static variables.  This saves
a little churn, and saves having to declare a type that is used just
once.  Plus, the access to these variables will be a little quicker.
2019-06-05 16:10:07 +02:00
Benno Schulenberg
28a6d9f300 tweaks: rename four elements of the holder struct, for more contrast 2019-06-05 15:32:50 +02:00
Benno Schulenberg
f92606491c speller: when something goes wrong with 'sort', do not blame 'spell'
That is, check the exit status of 'sort' before the one of 'spell'.
2019-06-05 15:07:33 +02:00
Benno Schulenberg
260588af1e speller: be more concise and to the point when something goes wrong 2019-06-05 14:57:24 +02:00
Benno Schulenberg
cdc9482d8f tweaks: rename three variables, to use full words instead of abbrevs 2019-06-05 14:50:01 +02:00
Benno Schulenberg
7c1b649eb8 tweaks: rename a function and its parameters, to be more fitting
Also, reshuffle their order, and improve or adjust some comments.
And change the type of 'pairnum' to short, what ncurses uses too.
2019-06-05 13:08:14 +02:00
Brand Huntsman
57b3f83cfe rcfile: compile the color regexes just once
When a syntax gets parsed, store the compiled color regexes right away,
instead of compiling them a second time in color_update().

This addresses https://savannah.gnu.org/bugs/?56432.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2019-06-04 19:57:46 +02:00
Benno Schulenberg
edbdcb9b9a docs: add a light warning to the explanation of --nonewlines 2019-06-04 19:54:58 +02:00
Benno Schulenberg
a6978b54f1 docs: say thanks to the Korean translator, and trim a double space 2019-06-04 19:32:52 +02:00
Brand Huntsman
8bc2d18fa9 tweaks: remove an unneeded pre-processor '#else' clause
Commit 1e2e6733 added braces and made the semicolon no longer needed
when libmagic is not used.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-06-04 19:27:34 +02:00
Brand Huntsman
fb10a94f35 startup: prevent a crash when no applicable syntax is found
This fixes https://savannah.gnu.org/bugs/?56434.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-06-04 12:42:24 +02:00
Benno Schulenberg
9b30bb15cc tweaks: adjust the indentation after the previous change
And reshuffle two declarations.
2019-06-03 15:51:07 +02:00
Benno Schulenberg
a1669e1bfd rcfile: disallow extending a syntax that is defined in a main nanorc
The /etc/nanorc file should not define any syntax directly (and
preferably not include any either, to not slow startup down with
syntaxes the user is never going to use), and if the ~/.nanorc file
defines a syntax directly, there is no need to use 'extendsyntax':
the command can be added to the syntax itself -- it would be better
even: it keeps things together.
2019-06-03 15:42:06 +02:00
Benno Schulenberg
3d6eca3f26 tweaks: reshuffle some lines, to put the most likely candidate first 2019-06-03 15:04:00 +02:00
Benno Schulenberg
c025a60ce9 tweaks: rename a function and a variable, for contrast and variety 2019-06-03 15:01:28 +02:00
Benno Schulenberg
5e1f90d8fa tweaks: don't bother to free the content of 'extendsyntax' commands
Extending a syntax will be rather rare, so the amount of memory it
takes up will be minimal.  It's not worth the trouble to free this
memory -- it only takes time.  Plus: we don't bother to free the
memory of a syntax that gets fully redefined either.
2019-06-03 14:37:27 +02:00
Benno Schulenberg
7f3ffe8544 tweaks: remove a bit of redundant code
When an included file has just been fully parsed, 'lastcolor' is still
pointing at the last color regex that was added to the list -- no need
to refind the end of this list.
2019-06-03 14:21:17 +02:00
Benno Schulenberg
ea1016efdb feedback: make an error check work also when curses hasn't started yet
Add a temporary boolean for this, because isendwin() returns TRUE
only when curses mode has actually been started with initscr() and
then exited with endwin().
2019-06-03 13:38:21 +02:00
Benno Schulenberg
f63fee79e3 tweaks: merge two functions, as the first is called just once 2019-06-01 11:14:21 +02:00
Benno Schulenberg
2003413989 tweaks: move a function to the file where it is used 2019-06-01 10:52:38 +02:00
Benno Schulenberg
9369af77ce tweaks: elide a function that is used just once 2019-06-01 10:43:50 +02:00
Benno Schulenberg
35d2bc6b38 build: fix compilation on another system
The <signal.h> header file is needed to define 'sig_atomic_t'.
(Don't know why on my main system it compiled fine without it.)
2019-05-31 20:53:00 +02:00
Benno Schulenberg
b52d166afa tweaks: rename a type, to make more sense
The sphere, the holder, is everything *around* the partition;
it was confusing to call this holder type 'partition'.

Also correct and improve some comments.
2019-05-31 19:44:47 +02:00
Benno Schulenberg
3952dcb629 tweaks: rename a variable, reduce its scope, and use it consistently 2019-05-31 19:25:50 +02:00
Benno Schulenberg
7e9dd385f5 tweaks: elide a parameter and a return value
As 'filepart' is a global variable, there is no need to pass it around.
Just use it directly.
2019-05-31 19:00:20 +02:00
Benno Schulenberg
2e81023553 tweaks: rename two variables, and reshuffle their declarations 2019-05-31 17:45:51 +02:00
Benno Schulenberg
b9f994b2c0 tweaks: elide a variable, drop a comment, and remove unneeded braces
There is no need to save, clear, and restore the mark when counting
words, lines and characters, because partitioning and unpartitioning
the buffer does not use the mark nor affect it.
2019-05-31 17:43:40 +02:00
Benno Schulenberg
e98847200e tweaks: reshuffle some lines, to reduce duplication 2019-05-31 17:42:42 +02:00
Benno Schulenberg
a77b21388a build: remove two #includes that don't seem to be needed 2019-05-31 17:16:07 +02:00
Benno Schulenberg
58ca5fb0f3 build: move an #include to where it is needed 2019-05-31 17:14:28 +02:00
Benno Schulenberg
844214b4a0 tweaks: rename two variables, to not be abbreviations
Also reshuffle two declarations.
2019-05-31 12:54:20 +02:00
Benno Schulenberg
f9dfca7d5a tweaks: rename a variable, to be shorter 2019-05-31 12:46:15 +02:00
Benno Schulenberg
fe40e8867d tweaks: rename a struct element, to be distinct
And to match the style of its sisters.
2019-05-31 12:25:15 +02:00
Benno Schulenberg
923a90cba0 tweaks: rename a type, for more contrast 2019-05-31 12:18:30 +02:00
Benno Schulenberg
5817e83e33 tweaks: be more sparing in redrawing things when exiting from help viewer
That is: don't redraw the title bar twice, don't redraw the bottom bars
twice, nor unnecessarily redraw the whole screen.
2019-05-31 10:28:23 +02:00
Benno Schulenberg
122cabd3ba tweaks: elide another parameter, and rename the function to match 2019-05-31 09:33:28 +02:00
Benno Schulenberg
c5d157dd9d tweaks: close a buffer differently and elide a parameter 2019-05-31 09:15:12 +02:00
Benno Schulenberg
3a65c0d192 feedback: when the last line is empty, don't include it in the count
Now M-D will report 0 lines instead of 1 line for an empty buffer, and
will match the output of 'wc --lines' as long the file is a POSIX file.

This fixes https://savannah.gnu.org/bugs/?56054.

Bug existed since before version 2.1.10.
2019-05-30 19:51:25 +02:00
Benno Schulenberg
e1c011c9a1 tweaks: rename a variable, to match the style of its brothers 2019-05-30 19:34:57 +02:00
Benno Schulenberg
477ff49f66 feedback: don't try to represent keys outside of the seven-bit range
This fixes https://savannah.gnu.org/bugs/?56415.
2019-05-30 19:06:06 +02:00
Benno Schulenberg
85eb9b9a53 tweaks: use a cheaper way to switch between buffers where possible
For this one quick switch back and forth there is no need to report
anything on the status bar nor to update colors and such.  In this
case, those things are just a waste of time.
2019-05-30 17:42:37 +02:00
Benno Schulenberg
484523b3bb tweaks: drop two checks that were made redundant by the previous commit 2019-05-30 17:18:30 +02:00
Benno Schulenberg
5a48edc9ae tweaks: reshuffle some code to the one place that needs it
The extra things that close_buffer() did are only needed and useful
when manually closing a buffer, so move them there.  The other three
calls of close_buffer() only need to get rid of the current buffer
(making the preceding buffer the new current one) and nothing else.
2019-05-30 17:09:49 +02:00
Benno Schulenberg
6dc8570d55 tweaks: reshuffle a few things, partly to make two chunks more alike 2019-05-30 16:00:11 +02:00
Benno Schulenberg
7e422402d5 tweaks: change a function to void, to make things more direct 2019-05-29 20:02:50 +02:00
Benno Schulenberg
5f03c20ea0 tweaks: switch to the preceding buffer in a cheaper way (when in help)
When a help-text buffer is closed while exiting from the help viewer,
the rest of the exit code takes care that the preceding buffer gets
displayed properly.  And when a help-text buffer is closed because a
SIGWINCH occurred, doing anything for the preceding buffer is a waste
of time because a new help-text buffer will be opened and displayed
instantly.
2019-05-29 19:48:42 +02:00
Benno Schulenberg
71574e7a6f tweaks: reshuffle some closing and switching to a better place
And rename the function and elide a parameter besides.
2019-05-29 19:48:42 +02:00
Benno Schulenberg
821445d284 tweaks: drop some checks that were made redundant by the previous commit
And move one to a better place.
2019-05-29 19:48:42 +02:00
Benno Schulenberg
3eab405e7b help: write the text directly into a new buffer, without using a tempfile
This avoids the substantial overhead of first writing and then reading a
temporary file, and in the bargain removes two possible failure points.

This fulfills https://savannah.gnu.org/bugs/?56371.
2019-05-29 19:48:42 +02:00
Benno Schulenberg
423ed031b4 help: don't cycle through the buffers for every resizing step
Closing a buffer automatically switches to the next buffer.  But for
the help-text buffer this is not the desired behavior, so each closing
needs to be followed by a switch to the preceding buffer.

This fixes https://savannah.gnu.org/bugs/?56411.
2019-05-29 12:33:59 +02:00
Benno Schulenberg
57390cff04 tweaks: exclude another bug check from the tiny version 2019-05-29 11:24:25 +02:00
Benno Schulenberg
4e637cd1c7 tweaks: delete a now-unused function 2019-05-28 17:41:28 +02:00
Benno Schulenberg
add1159675 tweaks: don't bother checking the return value of wait()
It is not done for the external spell checker either.
2019-05-28 17:39:19 +02:00
Benno Schulenberg
dbdf38cce5 tweaks: consistently report failures to fork (and the like) as errors 2019-05-28 17:36:32 +02:00
Benno Schulenberg
47770bd321 feedback: treat statusline() being called outside of curses mode as a bug 2019-05-28 17:19:34 +02:00
Benno Schulenberg
d656b0d3b9 feedback: show an appropriate message when reading a file was cut short 2019-05-28 17:06:07 +02:00
Benno Schulenberg
d9deaf9f2f tweaks: reduce the scope of a variable, and let the compiler zero it
Also, rename the variable, to have a unique name.
2019-05-28 14:09:54 +02:00
Benno Schulenberg
b75563b88e tweaks: use a symbol instead of zero to refer to standard input 2019-05-28 12:31:16 +02:00
Benno Schulenberg
33e1bf1435 startup: remove the now-unneeded workaround for a SIGWINCH during input
The previous commit makes that the terminal's state is only resaved
when standard input is actually reconnected to the terminal, and
leaves it unchanged otherwise.  Apparently this is enough to fix
https://savannah.gnu.org/bugs/?56394.
2019-05-28 12:19:49 +02:00
Benno Schulenberg
d946f38a2b files: when needed, reconnect the keyboard and reenter curses mode
When after reading a file we are not in curses mode, it means we have
read data from standard input, either from the keyboard or from a pipe.
In the latter case, we first need to reconnect standard input to the tty.
And in both cases, we then need to reenter curses mode before being able
to display the number of lines that were read (or an error message).

So, move the reconnecting code from scoop_stdin() to its own function,
and call this function from read_file() when needed.

This fixes https://savannah.gnu.org/bugs/?56310.

Bug existed since version 2.1.8 when reading from stdin was introduced.
2019-05-28 11:28:23 +02:00
Benno Schulenberg
b53dffaeed startup: resave the terminal's state only when there were no signals
For some reason a SIGWINCH or SIGINT "corrupts" the current state of
the terminal, and magically validates the state that was saved first.

This fixes https://savannah.gnu.org/bugs/?56394 properly.
2019-05-27 19:35:46 +02:00
Benno Schulenberg
6dcfcd11ce tweaks: rename two functions, to better describe what they do 2019-05-27 17:24:35 +02:00
Benno Schulenberg
f21b094dad tweaks: condense a couple of comments, and reshuffle a line 2019-05-27 17:21:05 +02:00
Benno Schulenberg
a521ac4ae7 tweaks: exclude a bug check from the tiny version 2019-05-27 10:11:22 +02:00
Benno Schulenberg
d972c17050 build: exclude the ability to open a FIFO from the tiny version 2019-05-27 09:55:24 +02:00
Benno Schulenberg
f6e182ca72 tweaks: check in a single place for files that should not be opened 2019-05-27 09:42:41 +02:00
Benno Schulenberg
6a83bb7508 tweaks: delete a leftover 2019-05-27 09:33:36 +02:00
Benno Schulenberg
728498fde5 files: don't say "Error...: Success" when aborting after resizing
For some reason 'errno' is not EINTR but zero when a SIGINT is
produced after a SIGWINCH.
2019-05-26 19:49:23 +02:00
Brand Huntsman
05f34bbfaf files: block SIGWINCH while opening a FIFO for reading or writing
This fixes https://savannah.gnu.org/bugs/?56354.
Reported-by: Brand Huntsman <alpha@qzx.com>

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-05-26 19:40:33 +02:00
Benno Schulenberg
b7e2da7434 files: don't save the state of the terminal a second time
The user will understand that changing the state of the terminal
while inputting data into nano is not the same as changing this
state before nano has started or after nano has exited.

This fixes https://savannah.gnu.org/bugs/?56394.

Bug existed since version 2.4.2.
2019-05-26 19:16:40 +02:00
Benno Schulenberg
8e2d03b92c build: fix compilation when configured with --enable-tiny 2019-05-26 14:48:14 +02:00
Benno Schulenberg
308a094d8d feedback: show a more fitting message when opening a FIFO is interrupted 2019-05-26 14:17:35 +02:00
Benno Schulenberg
5757aa8a0c tweaks: reuse the install and restore functions for a signal handler 2019-05-26 13:57:29 +02:00
Benno Schulenberg
8c5b67379f tweaks: factor out the installing and restoring of the ^C signal handler
So that these two functions can be used elsewhere too.
2019-05-26 13:55:59 +02:00
Benno Schulenberg
b2926eb675 tweaks: include the enabling of SIGINT into the tiny version
Either this enabling is not needed at all when the original terminal
state has been restored, or it will be needed in the tiny version too.

Also condense some comments.
2019-05-26 13:49:38 +02:00
Benno Schulenberg
ea11709564 files: allow to abort the reading of slow files with Ctrl+C
This addresses https://savannah.gnu.org/bugs/?44907.

Original-patch-by: Martin van Zijl <martin.vanzijl@gmail.com>
2019-05-26 13:34:38 +02:00
Benno Schulenberg
8550c6bd93 files: allow to interrupt the opening of a FIFO for writing with Ctrl+C 2019-05-26 11:45:51 +02:00
Benno Schulenberg
65560a583c tweaks: rename a parameter and a variable, to be more distinct 2019-05-24 19:27:04 +02:00
Benno Schulenberg
35a791dee5 tweaks: remove two unneeded checks for NULL
If the rest of nano is correct, then these checks are superfluous and
only slow the loops down.  But if there is some incorrect code, then
let nano crash on dereferencing NULL so we can find and fix the bug.
2019-05-24 19:17:01 +02:00
Benno Schulenberg
98ffb19746 tweaks: stop checking for a NULL result from line_from_number()
No one ever reported seeing the message that was removed in commit
c039aaad one month ago, so most likely the code is correct and nano
never calls line_from_number() with a non-existent line number.
2019-05-24 19:08:29 +02:00
Benno Schulenberg
93edd12099 tweaks: rename a function, to be clearer and to stop using an old abbrev 2019-05-24 18:56:34 +02:00
Benno Schulenberg
9a475bf2d3 speller: don't crash when the spell-checked tempfile cannot be opened
This addresses https://savannah.gnu.org/bugs/?56361.
2019-05-24 17:31:35 +02:00
Benno Schulenberg
b512e253b6 tweaks: drop an unneeded parameter from open_file()
The 'quiet' parameter is only used when opening a help-text tempfile
or a spell-checked tempfile, and these files necessarily exist, so
'quiet' will never be checked for them.  But in the weird case that
the help-text tempfile could not be opened, it is not a problem that
"New File" gets printed to the status bar because nano will crash
shortly afterwards.  And when the spell-checked tempfile could not
be opened, a "Not Found" message is appropriate, but nano will crash
in this case too.
2019-05-24 13:00:00 +02:00
Benno Schulenberg
137c4467ef speller: ensure that a Shift-selected region is retained
For both an integrated and an external spell check, fake the Shift key
being held so that (when the cursor is moved by a changed length of a
word) a Shift-selected region is not unexpectedly cancelled.

This fixes https://savannah.gnu.org/bugs/?56365.
2019-05-24 12:30:07 +02:00
Benno Schulenberg
4cacb626a0 files: allow to interrupt the opening of a FIFO with Ctrl+C
With-help-from: Brand Huntsman <alpha@qzx.com>
2019-05-24 10:51:56 +02:00
Benno Schulenberg
e3e81879b1 tweaks: condense the setup of the two signal handlers for Ctrl+C
Don't bother checking for an error from sigaction(), because the only
things it could error out for is when it is passed an invalid signal
(which SIGINT isn't) or oldaction/newaction would point to memory that
is outside of nano's control (which is obviously not the case).

Also, the setup of signal handlers during startup does not check for
errors, so why do it here?
2019-05-24 10:48:03 +02:00
Benno Schulenberg
acd23551c3 help: don't check for confinement when opening a temporary help-text file
This fixes https://savannah.gnu.org/bugs/?56369.
2019-05-23 12:43:31 +02:00
Benno Schulenberg
2f1691079e usage: make the --help output independent from the terminal's tab size
Use printf's ability to align things (instead of trying to do it
ourselves and failing when the tab size of the terminal is not 8.)

Suggested-by: Vincent Huisman <site.gentoobugzilla@dataghost.com>

This fixes https://savannah.gnu.org/bugs/?56372.
Reported-by: Vincent Huisman <site.gentoobugzilla@dataghost.com>
2019-05-22 19:55:25 +02:00
Benno Schulenberg
12bf3bfce4 feedback: don't clear off possible error messages after a spell check
If functions deeper down would put up some message on the status bar,
it should not be cleared.  The chance that messages from a spell-check
program stay onscreen is minute: the edit window is fully refreshed,
the status bar is fully drawn, and the help lines (if there are any)
are redrawn.  Only the title bar is not refreshed, but the chance that
an error message has spilled onto the top row...  And anyway, the
spell checker should not print any error messages at all.
2019-05-21 19:42:44 +02:00
Benno Schulenberg
d7555d071f tweaks: adjust a comment and drop two others, and reshuffle two lines 2019-05-21 19:42:08 +02:00
Benno Schulenberg
9596f7de9d tweaks: delete a now-unused function 2019-05-21 18:56:35 +02:00
Benno Schulenberg
20635b40f4 tweaks: merge two very similar functions into a single one 2019-05-21 18:56:13 +02:00
Benno Schulenberg
1128a40d42 tweaks: remove an unneeded setting and unsetting of a flag
This twiddling was made superfluous by commit faa0eb99 from a year ago.
2019-05-21 18:55:34 +02:00
Benno Schulenberg
1e2e6733df tweaks: add a pair of braces, to silence a compiler warning
Also, put an 'else' on the same line as the preceding closing brace.
2019-05-21 17:25:45 +02:00
Benno Schulenberg
2669d3623d tweaks: set a boolean directly, instead of using a function call 2019-05-21 12:15:37 +02:00
Benno Schulenberg
22fc16b2d0 tweaks: add a missing forward declaration of make_new_buffer()
Reported-by: Brand Huntsman <alpha@qzx.com>
2019-05-20 11:53:22 +02:00
Benno Schulenberg
372e858ec8 docs: note David as author of undoable indenting and undoable justifying 2019-05-20 10:55:03 +02:00
Benno Schulenberg
da8c74a44f docs: note Brand as the author of the delayed syntax parsing 2019-05-20 10:45:33 +02:00
Brand Huntsman
cba9d8d05e rcfile: fully parse a syntax file only when needed
When parsing an included syntax file, stop reading when a command other
than 'syntax', 'header' or 'magic' is encountered.  The syntax file is
fully parsed the first time that a file needs it.  Each 'extendsyntax'
command is stored for unloaded syntaxes and applied after the syntax
is loaded.

Closing a buffer does not unload the syntax, even if no longer used by
another buffer.

This addresses https://savannah.gnu.org/bugs/?54928.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-05-20 10:25:47 +02:00
Brand Huntsman
0e29c2a24a rcfile: store errors and display them when nano terminates
This is needed to implement the demand loading of syntax files, as any
errors that these files may contain would otherwise overwrite things on
the screen and the messages wouldn't be on the terminal when nano exits.

It also allows nano to start up on a Linux console when there are errors.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-05-20 10:25:47 +02:00
Benno Schulenberg
9e182722cc feedback: print helpful message only when data comes from keyboard
When the data is fed to nano through a pipe, it is pointless to print
this message as it can be seen only after nano has exited.

This addresses https://savannah.gnu.org/bugs/?56348.
2019-05-19 19:49:47 +02:00
Benno Schulenberg
4f1eb5fdd4 tweaks: remove the two remaining handfuls of asserts
They are just clutter -- no one runs a debug build for any length
of time.
2019-05-19 18:58:02 +02:00
Benno Schulenberg
53352d0b26 files: try matching a syntax after scooping data from standard input
The blank filename should not give any match, but maybe the header line
or the magic finds a fitting syntax.

This fixes https://savannah.gnu.org/bugs/?56344.
2019-05-19 17:48:08 +02:00
Benno Schulenberg
1d3a4df3b3 browser: don't show a mistaken message when exiting from help viewer
This fixes https://savannah.gnu.org/bugs/?56346.

Bug existed since version 3.0, commit 8d6b205e.
2019-05-18 19:59:54 +02:00
Benno Schulenberg
afbaf8ae2d files: give feedback while waiting for a FIFO to open up 2019-05-18 19:14:32 +02:00
Benno Schulenberg
1b2018e921 files: check for writability by the access bits, not by trying to append
Trying to append does not work on a fifo, and we'd like to be able to
open a fifo again.  Also, the append test causes a close event for the
given file at the moment of opening it, which makes using 'inotify' for
waiting for this file to be closed useless.

Commit f8f90272 added the append test, but the original request
(https://lists.gnu.org/archive/html/info-nano/2009-05/msg00000.html
by Damien Joldersma) asked only for a warning when the user did not
have enough privileges to write to the file.

So, drop the append test and just check the access bits.

This fixes https://bugs.debian.org/583196
and fixes https://savannah.gnu.org/bugs/?29312.
2019-05-18 19:13:42 +02:00
Benno Schulenberg
26642a39c3 files: allow a given file to be a special file but not a directory
The original requests (https://bugs.debian.org/551717 by Paul Wise,
and https://savannah.gnu.org/bugs/?45383 by Mike Frysinger) asked
only that specifying a directory instead of a file name should not
open a new buffer.  But commit 98ffb642 excluded everything that was
not a normal file.  This avoids a hang when the user accidentally
tries to open a pipe or a socket, but also prevents any user from
doing so on purpose.  And opening a fifo can be useful when wanting
to handle sensitive data that shouldn't be stored on disk.

This prepares the fix for https://bugs.debian.org/583196.
2019-05-18 17:24:13 +02:00
Benno Schulenberg
8723375443 tweaks: remove a superfluous and ineffective assignment
This assignment became superfluous two years ago, by David's revamping
of read_file() in commit 86f7bc18.
2019-05-18 17:21:54 +02:00
Benno Schulenberg
82aea04c79 bindings: at a Yes-No prompt, accept also ^Y for "Yes"
For symmetry with ^N for "No".

Suggested-by: Brand Huntsman <alpha@qzx.com>
2019-05-17 11:39:40 +02:00
Benno Schulenberg
341601e1a2 bindings: at a Yes-No prompt, accept also ^N and ^Q for "No"
When wanting to exit after having modified a buffer by mistake, I don't
want to politely answer a question by typing precisely an unmodified N,
I want to give a command: ^N, meaning *No!*.  Or seen another way: I
don't want to be obliged to let go of the Ctrl key before typing N.

When at startup --tempfile was used, the user can discard a modified
buffer with ^O ^Q.  It would be nice when (without --tempfile) ^X ^Q
would work too.
2019-05-17 11:31:59 +02:00
Benno Schulenberg
368f1a1c9d tweaks: elide a function that is called in just one place
Since commit b5f15cb5 from a year ago, there remains just one call
of initialize_buffer_text().
2019-05-16 16:16:52 +02:00
Benno Schulenberg
527c6c1ca0 tweaks: reshuffle a few lines, to be more straightforward 2019-05-16 16:04:12 +02:00
Benno Schulenberg
a9e8f88e77 tweaks: enforce the miminum amount of scrolling in a simpler way
This improves the fix for https://savannah.gnu.org/bugs/?56317.
2019-05-16 16:00:42 +02:00
Benno Schulenberg
0cbf1f4027 help: don't show Alt+Left and Alt+Right when running on a Linux console
On a VT, <Alt+Left> and <Alt+Right> switch between VTs and nano
does not receive those keystrokes.
2019-05-13 13:01:10 +02:00
Benno Schulenberg
96baa70cc8 tweaks: reshuffle a couple of lines and adjust a few comments
Also, compute the required space for the keystrokes more tightly:
most of those characters are plain ASCII, so that means 17 bytes
for 17 cells, and at most one of those characters is a three-byte
arrow, which means 2 bytes extra.  Adding the two newlines at the
end, the needed room besides the description is 21 bytes.
2019-05-13 12:25:39 +02:00
Benno Schulenberg
b18e2129ce bindings: bind the Alt+arrow keystrokes also in non-UTF-8 locales
Fall back to using the words "Left", "Right", "Up", and "Down",
instead of graphical arrows.

This fixes https://savannah.gnu.org/bugs/?56313.

Bug was left to exist since the Alt+arrow keys were introduced,
in version 2.8.7, commit 1cc030f7.
2019-05-13 11:35:15 +02:00
Benno Schulenberg
e26cbdd6cd help: make the column for the first keystroke a little wider
To make room for the "M-Right" that is coming in the next commit --
seven characters are needed instead of six.
2019-05-13 11:07:21 +02:00
Benno Schulenberg
0ebfd54e17 softwrap: use smooth scrolling when softwrapping is toggled on
If the cursor is near the bottom row when softwrap gets switched on, the
screen should scroll just the amount needed to keep the cursor onscreen.

This fixes https://savannah.gnu.org/bugs/?56317.

Bug existed since softwrapping was introduced in version 2.1.11.
2019-05-13 10:25:12 +02:00
Benno Schulenberg
8f1cd50f1e syntax: python: avoid miscoloring stuff between two empty strings
The quotes of an empty string ('' or "") should be colored just like
those of a non-empty string, because otherwise the text *between* two
empty strings on the same line gets colored.

Add an extra rule to discolor triple quotes again to not make them
look like valid by themselves.

Also, remove six superfluous backslashes.

This addresses https://savannah.gnu.org/patch/?9801.
Reported-by: Ryan Westlund <rlwestlund@gmail.com>
2019-05-11 19:05:45 +02:00
Benno Schulenberg
4fb9f298c9 tweaks: adjust some indentation after the previous change
Also reshuffle some arguments.
2019-05-08 19:35:42 +02:00
Benno Schulenberg
c338d86843 tweaks: rename some single-letter variables to the same significant word
And simply elide one of those variables.
2019-05-08 19:35:03 +02:00
Benno Schulenberg
247dd8f052 tweaks: rename a variable, reshuffle declarations, and drop an assert 2019-05-08 15:34:06 +02:00
Benno Schulenberg
71d0847b19 tweaks: merge two functions, as the one is used only by the other 2019-05-08 15:25:11 +02:00
Benno Schulenberg
c55d144748 tweaks: drop most of the remaining debugging code, and some timing code 2019-05-08 15:23:36 +02:00
Benno Schulenberg
da91a44f9e tweaks: reshuffle two #ifdefs, to avoid an unpaired brace 2019-05-08 13:56:02 +02:00
Benno Schulenberg
02d3a2c0fb tweaks: remove some unneeded braces, and reshuffle for more symmetry 2019-05-06 11:20:31 +02:00
Benno Schulenberg
5764619655 search: stay in the Search menu when trying to Replace in view mode
This fixes https://savannah.gnu.org/bugs/?56274.

Bug existed since version 3.1, commit 6cd53e7f.
2019-05-06 11:08:22 +02:00
Benno Schulenberg
3c959fd038 tweaks: drop a useless tidying-up call, as spelling does not use regexes
The integrated spell checker does not use regular expressions, and
'refresh_needed' is set to TRUE anyway, so the tidy_up_after_search()
call there is effectively a no-op.
2019-05-06 10:57:45 +02:00
Benno Schulenberg
f0bc94fd02 tweaks: move the tyding-up-after-a-search to a single exit point 2019-05-06 10:29:45 +02:00
Benno Schulenberg
8720cfcce9 tweaks: rename two more functions, to be simpler too 2019-05-04 11:21:45 +02:00
Benno Schulenberg
954c4d03ac tweaks: rename two functions, to be simpler 2019-05-04 11:21:45 +02:00
Benno Schulenberg
edf6995be4 zapping: use the 'keep_cutbuffer' logic to keep undo items apart
The 'keep_cutbuffer' variable becomes FALSE whenever there is cursor
movement or there was a marked region.  Use this variable to simplify
the condition for creating a new ZAP undo item.  But then typing the
'zap' shortcut should not cause the variable to be set to FALSE.

This fixes the first part of https://savannah.gnu.org/bugs/?56261.

Bug existed since zapping was introduced, in version 3.2.
2019-05-04 11:18:51 +02:00
Benno Schulenberg
b50d5758ef zapping: disjoin a zap command from earlier ones when the mark is set
This fixes the third part of https://savannah.gnu.org/bugs/?56261.

Bug existed since zapping was introduced, in version 3.2.
2019-05-03 12:58:17 +02:00
Benno Schulenberg
6c4d0d87f0 tweaks: remove a condition that has become superfluous
After the previous change, a copy command will break a chain of cut
commands, so there is no need any more to verify that the line number
hasn't changed.
2019-05-03 12:41:49 +02:00
Benno Schulenberg
a962bceca6 copying: let a copy command break a chain of cut or zap commands
This fixes the second part of https://savannah.gnu.org/bugs/?56261.

Bug existed since zapping was introduced, in version 3.2.
2019-05-03 12:33:42 +02:00
Benno Schulenberg
e0c5c589ad tweaks: remove a superfluous condition, in three places
When 'last_action' has a specific value, then necessarily there must
exist a corresponding current undo item.

(The condition is already absent in do_deletion(), for the BACK and DEL
undo items, and it works fine there.)
2019-05-03 12:18:04 +02:00
Benno Schulenberg
dfe87540c6 syntax: po: colorize also escaped hex and octal codes 2019-05-03 12:12:44 +02:00
Benno Schulenberg
6c4f228f6f tweaks: invert two conditions, in order to elide an extra variable 2019-05-02 14:34:05 +02:00
Benno Schulenberg
fe06ae5f48 tweaks: normalize the indentation after the previous two changes 2019-05-02 14:27:35 +02:00
Benno Schulenberg
07289f437f tweaks: invert a condition, in order to return earlier 2019-05-02 14:12:23 +02:00
Benno Schulenberg
99d155d80f tweaks: reshuffle an assignment, to be able to return earlier 2019-05-02 14:10:23 +02:00
Benno Schulenberg
3346c5395e tweaks: place a function better, and reduce some comments to a single one 2019-05-02 10:17:10 +02:00
Benno Schulenberg
083218aca5 tweaks: rename two parameters, to differentiate them from function names 2019-05-02 10:17:04 +02:00
Benno Schulenberg
fd3b3bc1d6 cutting: clear the cutbuffer when the previous operation was copying
The cut and copy operations (^K and M-6) are different operations and
one should not add to the cutbuffer created by the other.

This fixes https://savannah.gnu.org/bugs/?56251.

Bug existed since version 3.0, commit 71f85937.
2019-05-02 09:27:37 +02:00
Benno Schulenberg
9bc6bc83c0 tweaks: rename two variables, for more contrast 2019-05-01 19:14:06 +02:00
Benno Schulenberg
d4468b2def tweaks: condense a comment and reshuffle a couple of lines 2019-05-01 19:10:56 +02:00
Benno Schulenberg
404a6862cd tweaks: really don't bother renumbering the lines in the cutbuffer
The lines from the cutbuffer will be renumbered when it matters: when
they get pasted.

The only place that used the numbering of (a copy of) the cutbuffer
(the updating of an undo item) already iterates through its lines.
Just add a counter there instead of making use of the line numbers.
2019-05-01 13:09:22 +02:00
Benno Schulenberg
85fc41470b tweaks: stop passing 'cutbuffer' and 'cutbottom' back and forth
All extractions are done into the cutbuffer, so it is pointless to pass
'cutbuffer' and 'cutbottom' in and back out as parameters all the time.
Just use those global variables directly.

Also, rename the function as there is no longer a buffer among its
parameters.
2019-05-01 11:33:37 +02:00
Benno Schulenberg
2b9dd6c574 tweaks: don't bother saving and restoring 'cutbottom' all the time
The 'cutbottom' variable is only ever used when cutting or copying
consecutive lines: for appending the current line to the already
existing lines in the cutbuffer.  As soon as some other operation
is performed, 'cutbottom' becomes irrelevant, it could be set to
anything, it doesn't matter: the pasting of the cutbuffer does not
use the value of 'cutbottom', nor does any other operation.
2019-05-01 11:19:14 +02:00
Benno Schulenberg
9e44a53be7 copying: scroll just one line when M-6 is pressed on the bottom row
This fixes https://savannah.gnu.org/bugs/?56249.

Bug existed since version 2.6.0, commit 318ed6b1.
2019-04-30 19:31:44 +02:00
Benno Schulenberg
0c561f0325 copying: make M-6 do nothing when at end of buffer 2019-04-30 19:03:18 +02:00
Benno Schulenberg
e5831f81bb tweaks: rename two variables, to be less cryptic 2019-04-30 18:41:05 +02:00
Benno Schulenberg
fa21986ecf oops: apparently the line numbers in the cutbuffer do matter
The line numbers don't matter for the cutbuffer itself, but they matter
for the copy of the cutbuffer that is stored in an undo item.

This reverts commit 14140d52 from two hours ago.

This fixes https://savannah.gnu.org/bugs/?56245.
2019-04-30 12:49:57 +02:00
Benno Schulenberg
772137cabe tweaks: rename a variable, to fit a bit better 2019-04-30 12:24:56 +02:00
Benno Schulenberg
4c53e2f56b tweaks: elide two unneeded variables
After extracting a line or region, the current line is always the one
where renumbering should start.  And when ingrafting a buffer, it is
always the first ingrafted line where renumbering should start.  The
'top_save' variable was indirectly getting set to those lines.

Also, renumber immediately after unpartitioning the file buffer, before
doing anything else.
2019-04-30 12:20:41 +02:00
Benno Schulenberg
14140d5249 tweaks: don't bother renumbering the lines in the cutbuffer
The numbering of the lines in the cutbuffer is irrelevant.  These lines
will be renumbered when it matters: when they get pasted.
2019-04-30 10:55:15 +02:00
Benno Schulenberg
17aa9371b5 tweaks: rename a function, to better indicate what it does 2019-04-30 10:27:10 +02:00
Benno Schulenberg
208995e4a7 tweaks: move a bit of timing code to where it will be needed 2019-04-30 10:15:46 +02:00
Benno Schulenberg
b503670750 tweaks: rename a variable, to match another with the same meaning
Also, remove a redundant condition.
2019-04-30 10:15:11 +02:00
Benno Schulenberg
7c08e8ea69 cutting: ignore the mark when a word is deleted
Just like for deleting a word to the left, the mark should be ignored
also when deleting a word to the right.

This fixes https://savannah.gnu.org/bugs/?56241.
2019-04-30 09:53:10 +02:00
Benno Schulenberg
542426f1f1 tweaks: add a warning for something that shouldn't occur 2019-04-30 09:44:47 +02:00
Benno Schulenberg
6319a86178 tweaks: improve some comments, reshuffle a line, and rename a variable 2019-04-29 11:08:21 +02:00
Benno Schulenberg
9888e67b20 tweaks: rename two variables, for more contrast with the partition stuff 2019-04-29 09:45:41 +02:00
Benno Schulenberg
8fe19e344f tweaks: use a more direct call when a single linestruct is deleted 2019-04-28 17:20:08 +02:00
Benno Schulenberg
896cfcef95 tweaks: when OR'ing, put the most likely condition first
Also, slightly reword a comment, adjust some whitespace, and use
a more direct comparison for equality.
2019-04-28 15:53:33 +02:00
Benno Schulenberg
d54180ad8b tweaks: reduce a bit of mark-adjusting code to its essence
It doesn't matter whether the grafted text contains a newline or not.

It only matters whether the mark was before or after the cursor.  When
it was after the cursor, the mark needs to be set to the bottom line of
the grafted text and its x coordinate needs adjustment; and when it was
before the cursor, the mark just needs to be set to the top line of the
grafted text.
2019-04-28 12:18:24 +02:00
Benno Schulenberg
065afe6e0f tweaks: reshuffle a bit of code, to be less intertwined 2019-04-28 11:54:23 +02:00
Benno Schulenberg
37eccd3117 tweaks: rename a function, to be more fitting
Also, adjust some whitespace, for esthetics.
2019-04-28 11:01:51 +02:00
Benno Schulenberg
b9dd572a67 tweaks: set a boolean directly, instead of using a function call 2019-04-28 10:40:37 +02:00
Benno Schulenberg
3fe17e0355 docs: adjust the wording of the README to be factually correct
That is: don't say that nano doesn't change the file contents by default.

Also, correct the style of the preceding paragraph.
2019-04-28 10:35:27 +02:00
Benno Schulenberg
6e3a3964ce tweaks: adjust the indentation after the previous change
Also, condense a couple of comments.
2019-04-27 17:17:06 +02:00
Benno Schulenberg
18eb7e6d21 tweaks: elide an unneeded 'if' and 'break' 2019-04-27 17:10:10 +02:00
Benno Schulenberg
e84a790b5d tweaks: rename a variable, to better indicate it contains two characters
Also rename a function, to differentiate it more from do_find_bracket().
2019-04-27 17:01:34 +02:00
Benno Schulenberg
20d9070aa1 tweaks: move an assignment that is useful only when searching forward 2019-04-27 16:31:57 +02:00
Benno Schulenberg
482b2814b4 tweaks: step away one character from the current bracket, not one byte 2019-04-27 14:41:53 +02:00
Benno Schulenberg
e92c3110a1 po: update translations and regenerate POT file and PO files 2019-04-24 11:08:23 +02:00
Benno Schulenberg
1ca9241eaa bump version numbers and add a news item for the 4.2 release 2019-04-24 10:55:23 +02:00
Benno Schulenberg
0b6889cbd8 tweaks: rename another function, to be distinct and fitting 2019-04-24 10:52:49 +02:00
Benno Schulenberg
00410d83fc tweaks: rename a function, to be distinct and fitting
It was hard to remember that the "pt" stood for "plus tabs", and the
"len" seemed to say it was about number of bytes instead of columns.
2019-04-24 10:52:35 +02:00
Benno Schulenberg
fcad442d80 tweaks: declare a function as const and let its allocated string leak
Avoiding this leak is more trouble than it's worth: invocation_error()
will be called seldomly, and when it is called, the user will probably
quickly exit from nano to fix things.

Also declare the speller functions as const again, so they don't give
the impression that their result can be freed.

Suggested-by: Brand Huntsman <alpha@qzx.com>
2019-04-23 12:07:56 +02:00
Benno Schulenberg
34d22d3f00 wrapping: improve the persistence of the prepending behavior
Now you can have a look elsewhere in the buffer (and even delete
or paste stuff there) and when you return to the original line
and continue typing, any spillover from automatic hard-wrapping
will spill over onto the same line it spilled over to before.

You can even switch to a different buffer and return and continue
typing, and stuff will still spill over to the same line.

In the bargain, this gets rid of a bit of flag-resetting code
that was run for many keystrokes, in most cases needlessly.

This addresses https://savannah.gnu.org/bugs/?56189.
2019-04-23 10:20:12 +02:00
Benno Schulenberg
1326af7eae tweaks: drop an unneeded saving and restoring of a variable
Since commit aa1ae0a1, from three years ago, do_next_word() no longer
changes 'placewewant'.
2019-04-23 10:18:46 +02:00
Benno Schulenberg
11aa191bdc tweaks: rename a variable, to distinguish it from a browser function 2019-04-22 19:58:43 +02:00
Benno Schulenberg
ea844d28fe tweaks: exclude a bit more code from a single-buffer build 2019-04-22 19:38:19 +02:00
Benno Schulenberg
7668bfe6f2 tweaks: remove a redundant, enclosed #ifdef 2019-04-22 19:18:29 +02:00
Benno Schulenberg
493f215513 speller: do not crash by trying to free something that cannot be freed
Most of the returned error messages are fixed strings, not allocated
strings.

This fixes https://savannah.gnu.org/bugs/?56188.
Reported-by: Aliaksei Sakovets <alexeysakovets@gmail.com>

Bug existed since version 4.1, commit f645009a.
2019-04-22 11:32:03 +02:00
Benno Schulenberg
723451a5ce tweaks: adjust a few comments and some indentation 2019-04-21 11:58:08 +02:00
Benno Schulenberg
326e41d799 tweaks: elide an unneeded intermediate variable 2019-04-21 11:41:54 +02:00
Benno Schulenberg
3ce74eb8fe wrapping: compute the width of a succeeding line in the correct manner
Its number of columns needs to be computed, not its number of bytes.
2019-04-21 11:39:06 +02:00
Benno Schulenberg
ec4883b6a9 tweaks: remove an unneeded condition
The 'prepend_wrap' flag gets set to TRUE only when there is a next line,
and it can remain TRUE only when the cursor stays on the current line.
2019-04-21 11:26:00 +02:00
Benno Schulenberg
e8f69e40d1 wrapping: add a missing space only when the remainder will be prepended
When automatic hard-wrapping causes some piece of a line to be pushed
to the next line, then a separating space needs to be added at the tail
of this piece only when this piece actually gets prepended.

This fixes https://savannah.gnu.org/bugs/?56185.

Bug existed since version 2.9.2, commit 29f7654a.
2019-04-21 10:35:11 +02:00
Benno Schulenberg
297fb013cb wrapping: trim any trailing blanks when cursor goes to next line
When typing a space causes both the succeeding word and the cursor to
be pushed to the next line, then this space (and any contiguous ones)
does need to be snipped (when --trimblanks is in effect).

This fixes https://savannah.gnu.org/bugs/?56180.

Bug existed since version 2.9.3, commit 91073be4.
2019-04-21 09:31:18 +02:00
Benno Schulenberg
4e52c75568 options: make --breaklonglines work also when --ignorercfiles is used
This fixes https://savannah.gnu.org/bugs/?56179.

Bug existed since version 4.1, commit 167a8e5c.
2019-04-20 14:04:07 +02:00
Benno Schulenberg
192a303e40 tweaks: condense and improve a handful of comments 2019-04-20 14:00:07 +02:00
Benno Schulenberg
dcec8a4112 tweaks: rename a variable, for a little more meaning 2019-04-19 10:10:14 +02:00
Benno Schulenberg
5316f5078f tweaks: elide an unneeded variable
After a line break, the preceding line is readily available through
the 'prev' element.
2019-04-19 10:06:57 +02:00
Benno Schulenberg
286c877853 tweaks: elide an unneeded parameter, as the function already assumes it
The do_wrap() function always gets 'openfile->current' as parameter,
and, internally, it assumes that it is handling the current line.
2019-04-19 09:47:21 +02:00
Benno Schulenberg
8613285321 build: be more specific and avoid committing accidentally changed files 2019-04-16 10:23:16 +02:00
Benno Schulenberg
8a4639cdd6 docs: put the 'set guidestripe' option into its alphabetical position 2019-04-16 10:05:35 +02:00
Benno Schulenberg
576c20c4e4 po: update translations and regenerate POT file and PO files 2019-04-15 09:57:12 +02:00
Benno Schulenberg
3a0a6b5db8 bump version numbers and add a news item for the 4.1 release 2019-04-15 09:33:07 +02:00
Benno Schulenberg
c039aaad9d tweaks: remove several unneeded bad-state checks and their messages
No one ever reported seeing any of them, and each of these checks
has been there for at least a year.
2019-04-14 19:38:04 +02:00
Benno Schulenberg
145bb6e01a build: don't do fuzzy matching when merging PO files against the POT file
Fuzzy strings don't contribute anything to the translations that the
users get to see.  They are useful only for translators, but translators
fetch or receive their PO files from the TP.  For nano, fuzzy strings
just bloat the distribution tarball.
2019-04-14 10:47:41 +02:00
Benno Schulenberg
9cc70d2069 tweaks: shorten a comment to its essence 2019-04-14 10:10:03 +02:00
Benno Schulenberg
3604ad2950 build: remove obsolete translations from the PO files after merging
These obsolete strings contribute nothing to the translations that the
users get to see.  They are somewhat useful only for translators.  But
as nano is registered at the Translation Project, translators fetch or
receive their PO file from there (or they keep their own archive), so
these obsolete strings are not getting lost.  But for nano, they just
burden the distribution tarball.
2019-04-14 09:55:23 +02:00
Benno Schulenberg
1fe3e2ed69 docs: mention that -b is the opposite of -w also in the latter's item 2019-04-14 08:49:25 +02:00
Benno Schulenberg
baca8bb19e indenting, commenting: ensure a partial line stays displayed properly
Do the same as in the previous commit: re-evaluate the start of the
viewport when lines that are located above this viewport may have
changed.  This is relevant when softwrap is on.
2019-04-13 11:51:14 +02:00
Benno Schulenberg
1c707d4f99 unindent: ensure that a partial line gets displayed properly afterwards
When only the trailing chunk of a line is displayed on the top row of
the screen, and the unindenting of this line leads to a reduction in
the number of chunks, then the starting point of the viewport needs
to be re-evaluated.  For simplicity, do this always when something is
unindented.

This fixes https://savannah.gnu.org/bugs/?56102.
Reported-by: Devin Hussey <husseydevin@gmail.com>

Bug existed since around version 2.9.2.
2019-04-13 11:36:53 +02:00
Benno Schulenberg
c0e3779453 display: report and catch a bad state, to prevent a possible hang 2019-04-12 19:18:21 +02:00
Benno Schulenberg
bf6bcde078 tweaks: initialize a boolean before it is referenced [valgrind]
Found because of a report by Devin Hussey <husseydevin@gmail.com>.
2019-04-12 13:37:54 +02:00
Benno Schulenberg
167a8e5c09 options: make --nowrap override again a contrary nanorc setting
All other options are off by default and can only be switched *on*
(either by a command-line option or a nanorc setting) -- there are
no command-line options to switch them off again.  Except for the
--breaklonglines/--nowrap pair.  So these need special handling.

This fixes https://savannah.gnu.org/bugs/?56119.
Reported-by: Sébastien Desreux <seb@h-k.fr>

Bug existed since version 4.0, commit 4d40bea5.
2019-04-12 10:35:20 +02:00
Benno Schulenberg
90cbdbbe75 docs: mention that M-S now toggles softwrap and M-N line numbers 2019-04-11 17:46:19 +02:00
Benno Schulenberg
d83a8eb359 justify: correctly compute the number of lines to take, to avoid a crash
When the file starts with one or more blank lines, the first paragraph
doesn't start on line 1.

This fixes https://savannah.gnu.org/bugs/?56117.

Bug existed since version 4.0, commit ac8bd2a2.
2019-04-11 16:11:49 +02:00
Benno Schulenberg
98cc39e8e5 tweaks: reshuffle some lines, to elide an 'if' 2019-04-11 15:12:04 +02:00
Benno Schulenberg
b20fadd604 tweaks: free the copy of a linter message in all cases [valgrind] 2019-04-11 14:17:32 +02:00
Benno Schulenberg
cdf0f8e68a tweaks: drop two 'const' qualifiers, to silence the compiler 2019-04-11 12:31:50 +02:00
Benno Schulenberg
f645009a5e tweaks: free the result string from an invocation error [coverity] 2019-04-11 10:05:39 +02:00
Benno Schulenberg
2b2736d41a tweaks: free some memory before a possible error exit [coverity] 2019-04-11 09:55:18 +02:00
Benno Schulenberg
5a6029a938 tweaks: rename some variables, for more contrast and to match others 2019-04-11 09:38:06 +02:00
Benno Schulenberg
8d272db4e6 tweaks: rename two variables, for more contrast 2019-04-11 09:14:30 +02:00
Benno Schulenberg
70885d0f9a tweaks: use a signed type for a result that could be negative [coverity] 2019-04-11 09:11:53 +02:00
Benno Schulenberg
f1e5da6cdd help: don't doubly list toggles that have two keys assigned to them 2019-04-09 19:48:41 +02:00
Benno Schulenberg
d79b9823ae bindings: add easier keystrokes for the linenumber and softwrap toggles
For most people, M-N and M-S are simpler to type than M-# and M-$,
and more mnemonic.
2019-04-09 17:48:26 +02:00
Benno Schulenberg
82f1ce8ebf bindings: remove the jumpy-scrolling toggle entirely
It is still possible to use --jumpyscrolling on the command line or
'set jumpyscrolling' in a nanorc file, but a user will have to restart
nano when they decide they want chunky instead of smooth scrolling,
a decision that should be rather rare.

This frees up the M-S keystroke to be reused for toggling softwrap.
2019-04-09 17:46:21 +02:00
Benno Schulenberg
50ee655f9d gnulib: update to its current upstream state 2019-04-09 14:44:51 +02:00
Benno Schulenberg
5459f56f6d build: add gnulib modules to the list of files with translatable strings
The error messages from gnulib need to be included into nano's POT file
so that those messages get translated when nano is built on a platform
where the modules that contain the messages get used.

This fixes https://savannah.gnu.org/bugs/?56107.

Bug existed since gnulib support was added in version 2.8.0.
The relevant modules were added by commits 3deec435 and 272345cc.
2019-04-09 13:49:36 +02:00
Benno Schulenberg
209531a761 docs: remove all mention of --finalnewline, and undefault --nonewlines 2019-04-07 10:02:22 +02:00
Benno Schulenberg
2552307064 options: remove -f (--finalnewline); go back to auto-adding this newline
For relatively inexperienced users (as most users of nano probably are)
it is far better that nano produces POSIX text files by default, where
each line ends with a newline character.  This means that these files
will "print" properly (not gluing the next prompt at the end of the
last line), tools will see and process each line of them, and, while
editing, adding text at the end is easier.

This addresses https://savannah.gnu.org/bugs/?55997.
Reported-by: Ralph Corderoy <ralph@inputplus.co.uk>
2019-04-07 10:02:05 +02:00
Benno Schulenberg
5601b9a66b tweaks: switch back from checking FINAL_NEWLINE to checking NO_NEWLINES
This effectively reverts commit b6a76223 from a good two months ago.
2019-04-07 08:50:35 +02:00
Benno Schulenberg
81dcb13783 tweaks: remove an unpaired closing parenthesis from the NEWS file 2019-04-06 21:21:38 +02:00
Benno Schulenberg
580fd13424 tweaks: do a check up front instead of every time round the loop
Instead of doing a check every time round the loop when it is useful
only the first time, duplicate a bit a code and do the check and its
related action beforehand.

Also, improve some comments.
2019-04-06 21:07:20 +02:00
Benno Schulenberg
790ce3791a tweaks: reshuffle some lines, condense a comment and drop another
Also, find_bracket_match() is only called when there is a bracket under
the cursor, so stepping forward will never go beyond the end-of-line,
so the central loop does not need to check for that.
2019-04-06 20:37:22 +02:00
Benno Schulenberg
97cd62a8fb tweaks: rename two variables, to make more sense 2019-04-06 20:29:04 +02:00
Benno Schulenberg
2f68bbb5e8 tweaks: reword a comment, and drop an unneeded assert 2019-04-06 20:08:39 +02:00
Benno Schulenberg
55952c0984 tweaks: adjust the indentation after the previous change
Also, improve a comment and shorten another, change a 'for' to a 'while'
(as the end point is not known), and rename a parameter from a single
letter to a word.
2019-04-06 19:45:45 +02:00
Benno Schulenberg
d9cfdd364b tweaks: don't bother special-casing non-UTF8 when seeking a character
This code is seldom used (only when searching for a matching bracket),
so speed is not a priority.
2019-04-06 19:34:09 +02:00
Liu Hao
c9605e7308 syntax: c: change the highlighting of preprocessor directives
Some of these directives are now colored in their entirety, while for
a few others it's still just the keyword itself that is colored.

Signed-off-by: Liu Hao <lh_mouse@126.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2019-04-06 17:51:07 +02:00
Benno Schulenberg
c3f97bc9b7 rcfile: read the syntax files in alphabetical order when globbing
The reading order must be predictable, otherwise things might get
colored differently from system to system.

This fixes https://savannah.gnu.org/bugs/?56012.
2019-04-06 17:50:55 +02:00
Benno Schulenberg
4399b734db bindings: disallow executing an external command when in view mode
Otherwise the user could do something like

  ^R^X  sed -i 's/a/surprise!/g' name-of-current-file  <Enter>

and the file being viewed would be modified anyway.
2019-04-06 17:41:44 +02:00
Benno Schulenberg
b9581bd50a tweaks: rename two variables, to match others
Also, initialize them straightaway.
2019-04-06 11:54:32 +02:00
Benno Schulenberg
408f15954e feedback: replace an assert with a check plus error message at startup 2019-04-06 10:03:52 +02:00
Benno Schulenberg
f585403b36 build: add src/cut.c to the list of files with translatable strings
(Also, adjust the style of one of the messages.)

This fixes https://savannah.gnu.org/bugs/?56083.

Bug existed since version 4.0, commit 50e8f8aa.
2019-04-06 09:40:53 +02:00
Benno Schulenberg
601973ddc2 tweaks: rename another variable, to be more descriptive 2019-04-05 11:01:07 +02:00
Benno Schulenberg
25a5fb8231 tweaks: rename a variable, to get out of the way for another rename 2019-04-05 10:50:15 +02:00
Benno Schulenberg
897e557ce3 tweaks: rename a variable, to be more distinct and more descriptive 2019-04-05 10:45:22 +02:00
Benno Schulenberg
81bee1f5fd tweaks: shorten and improve some comments, and reshuffle a few lines 2019-04-05 10:35:48 +02:00
Benno Schulenberg
691eb1145c tweaks: remove a function that is now unused 2019-04-04 14:53:53 +02:00
Benno Schulenberg
fb04dff6d7 tweaks: don't bother reallocating the data when a line gets hard-wrapped
This will waste some memory, but... if the user keeps editing, she is
likely to revisit the line and the data will get reallocated soon enough.
2019-04-04 14:44:44 +02:00
Benno Schulenberg
c224ea3ce7 tweaks: reshuffle two lines, and reword a comment 2019-04-04 14:23:07 +02:00
Benno Schulenberg
2a2fe7208a tweaks: condense a bit of copying code 2019-04-04 14:11:52 +02:00
Benno Schulenberg
3f9d8011b9 tweaks: don't bother copying the NUL byte -- it is set nine lines down 2019-04-04 13:59:00 +02:00
Benno Schulenberg
4788c5f97d tweaks: don't bother reallocating the squeezed string, just terminate it
The string will be rewrapped right after, within microseconds.
2019-04-04 13:56:41 +02:00
Benno Schulenberg
a5869ba450 tweaks: rename another variable, to be more fitting 2019-04-04 13:52:27 +02:00
Benno Schulenberg
7bc324f276 tweaks: rename two variables, to be more distinct and more fitting 2019-04-04 13:48:34 +02:00
Benno Schulenberg
8d40b568fa tweaks: rename a variable, to be more distinct and more apt 2019-04-04 13:39:11 +02:00
Benno Schulenberg
0c0afb0039 tweaks: simplify a message, and normalize the spelling of another one
The word "buffer" in relation to undo has been confusing to translators.

Also, drop the exclamation mark, as there is nothing important or urgent
about these messages.
2019-04-04 12:55:58 +02:00
Benno Schulenberg
2281ec9a31 tweaks: remove an unneeded check for NULL [coverity] 2019-04-04 12:47:20 +02:00
Benno Schulenberg
cd0917fe10 tweaks: remove an unneeded check for NULL and its associated message
The message (or its equivalent) has been there for years
and no one ever reported seeing it.
2019-04-04 12:40:03 +02:00
Benno Schulenberg
1a1519b6cd tweaks: drop an assignment whose value is never used [scan-build]
This useless assignment has been there for ages, since before 2.0.0.
2019-04-03 19:10:21 +02:00
Benno Schulenberg
947ccbb597 rcfile: don't break a chain of 'else if' [scan-build]
The mistake was made when 'guidestripe' was added, in commit 66c6eb51.
2019-04-03 19:06:04 +02:00
Benno Schulenberg
671db5e1e3 tweaks: rename an overshort type to something that makes some sense 2019-04-03 17:34:05 +02:00
Benno Schulenberg
acfee2538e tweaks: rename a cryptic type to something that makes a little sense 2019-04-03 17:11:24 +02:00
Brand Huntsman
32431cddf8 files: block the resizing signal while reading from an external command
A SIGWINCH somehow causes the input stream to see EOT, with the result
that any remaining output of an external program would be lost.

This fixes https://savannah.gnu.org/bugs/?56038,
and fixes https://savannah.gnu.org/bugs/?56033.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-04-03 15:14:33 +02:00
Benno Schulenberg
8e302738e8 bindings: recognize the ^W^Y and ^W^V legacy keystrokes again
The keystrokes are recognized and acted upon, but they are not visible
in the menu nor in the help text, and they cannot be rebound.  They are
there just to avoid frustrating the muscle memory of long-time users.

This fixes https://savannah.gnu.org/bugs/?56002.
Reported-by: Peter Zwegat <peterzwegat@yopmail.com>
2019-04-03 15:13:47 +02:00
Benno Schulenberg
aa2568858e tweaks: remove a superfluous check for NULL plus the associated message
The message has been there for a year and no one ever reported seeing it.
2019-04-03 15:11:18 +02:00
Benno Schulenberg
5375403b9d syntax: nanorc: colorize also strings preceded by 'start=' or 'end=' 2019-04-02 12:01:56 +02:00
Benno Schulenberg
b0c9809a2e speller: block the resizing signal also during an integrated spell check
Because somehow something goes wrong when SIGWINCHes are handled while
reading from a pipe.

This fixes https://savannah.gnu.org/bugs/?56011.

Bug existed since version 2.4.2, commit 75d64e67.
2019-04-01 20:21:23 +02:00
Benno Schulenberg
19c82e6a43 feedback: spare the user a superfluous scaring when trying to exit
Also, a simple question is easier to answer than an annotated one.
2019-04-01 19:56:10 +02:00
Benno Schulenberg
84d21b0972 tweaks: consistently use .sp instead of .PP to insert a blank line
And use plain .P to start a new paragraph.
2019-04-01 17:31:35 +02:00
Benno Schulenberg
f8e0320722 syntax: nanorc: require whitespace both before and after a quoted string
This ensures that the keyname M-" is not miscolored.
2019-04-01 17:24:19 +02:00
Benno Schulenberg
e5a8c35104 feedback: show a message while executing an external command
Some commands can take a little while to execute; showing just the prompt
during that time could give the impression that nothing is happening.

This addresses https://savannah.gnu.org/bugs/?56041.
2019-03-31 18:04:52 +02:00
Devin Hussey
7ad232d714 files: initialize a variable before referencing it
The lack of initialization caused a nasty bug on some targets (such as
ARMv7) which would make it so that ^S would just say "Cancelled".

While x86 (both 64 and 32 bits) seems to initialize 'response' to zero or
a positive number, ARM does not, and there is usually a negative value in
its place, which triggers the 'if (response < 0)' check and, as a result,
the code says "Cancelled".

This fixes https://savannah.gnu.org/bugs/?56023.
Reported-by: Devin Hussey <husseydevin@gmail.com>

Bug existed since version 4.0, commit 0f9d60a3.

Signed-off-by: Devin Hussey <husseydevin@gmail.com>
2019-03-31 12:57:27 +02:00
Benno Schulenberg
85804ec70d syntax: man: require the dot to be at start of line, not the comment 2019-03-31 12:42:53 +02:00
Benno Schulenberg
e473ba5e6c syntax: man: anchor macros at start of line, as only then they are valid 2019-03-30 20:54:31 +01:00
Benno Schulenberg
9120a62cdd syntax: man: add comments, and color all the safe lowercase macros 2019-03-30 20:47:45 +01:00
Benno Schulenberg
53ecb3225f syntax: default: color in red also versions 4.x of nano 2019-03-30 19:54:58 +01:00
Benno Schulenberg
3f695b8fb7 speller: resizing can happen also when configured with --enable-tiny
When nano was configured with --enable-tiny --enable-speller, the
block_sigwinch() function should be available, to mask SIGWINCHes
during a spell check.
2019-03-30 19:23:15 +01:00
Benno Schulenberg
55699dc171 tweaks: rename some variables, to be less repititious
The repeated 'read_buff_' made everything look the same.
2019-03-30 19:10:44 +01:00
Benno Schulenberg
fa48d523b2 tweaks: stop doing tandem assignments (one passing through the other) 2019-03-30 18:52:45 +01:00
Benno Schulenberg
92cbc7c426 syntax: c: color as a type any lowercase word that ends with "_t" 2019-03-30 17:48:34 +01:00
Benno Schulenberg
6f07f2b444 tweaks: rename a function plus parameter, to stay closer to what it does 2019-03-27 19:46:37 +01:00
Benno Schulenberg
f58869d072 tweaks: put the unblocking of SIGWINCHes in a better place
The blocking is needed only during the wait(), so unblock SIGWINCH
again right after the wait() -- also to have the unblocking before
a possible error exit.
2019-03-27 19:10:24 +01:00
Benno Schulenberg
978c121de1 speller: block the resizing signal again during an external spell check
Somehow a SIGWINCH pushes nano past the wait() in do_alt_speller(),
even though the external spelling program hasn't finished.

This fixes https://savannah.gnu.org/bugs/?56010
by reverting commit 1f39f60b.

Bug existed since version 3.2.
2019-03-27 17:43:43 +01:00
Benno Schulenberg
f6a7983a8a docs: for two of the toggles, mention the new instead of the old option 2019-03-26 17:08:31 +01:00
Benno Schulenberg
a1375474d9 docs: remove the AUTHOR section, per advice from 'man man-pages'
Also because most of nano has meanwhile been written by other people
than Chris.  And because authorship is meta-information, irrelevant
for knowing how to operate nano.
2019-03-25 15:55:34 +01:00
Benno Schulenberg
d0cc75f197 docs: put paths and filenames in italics, per 'man man-pages'
Plus a few other text and formatting tweaks.
2019-03-25 15:31:47 +01:00
Benno Schulenberg
0fccfc0373 docs: re-title the temporary section about the changed defaults
To avoid having both a NOTE and a NOTES section.
2019-03-25 15:22:30 +01:00
Benno Schulenberg
d0a7e6e6a6 docs: give the FILES section in the man page its canonical title
Suggested-by: Michael Siegel <msi@malbolge.net>
2019-03-25 14:59:28 +01:00
Benno Schulenberg
d7a5bacf15 po: update translations and regenerate POT file and PO files 2019-03-24 12:47:41 +01:00
Benno Schulenberg
20facb40c3 build: ensure that also new PO files are committed to git 2019-03-24 12:40:05 +01:00
Benno Schulenberg
a5498feea6 build: stop using the --disable-wrapping-as-root configure option 2019-03-24 12:21:22 +01:00
Benno Schulenberg
3e4edb2a5a bump version numbers and add a news item for the 4.0 release 2019-03-24 12:14:12 +01:00
Benno Schulenberg
92ad431be4 tweaks: escape hyphens that must be hard hyphens in the man pages 2019-03-24 11:32:01 +01:00
Benno Schulenberg
123a102c52 docs: remove the mentioning of --disable-wrapping-as-root from the FAQ
This configure option is gone.
2019-03-24 11:02:33 +01:00
Benno Schulenberg
37477bfbb5 tweaks: slightly reword, for esthetics of the resulting Info document 2019-03-24 10:57:55 +01:00
Benno Schulenberg
bc40dd645a docs: adjust and extend the Pico-compatibility section in the manual 2019-03-24 10:49:47 +01:00
Benno Schulenberg
e02c8aeb20 tweaks: adjust indentation after previous change, and rename a parameter 2019-03-24 09:42:57 +01:00
Benno Schulenberg
003ddc763e tweaks: don't bother special-casing non-UTF8 when checking for a blank
This code is almost never used; conciseness is the only consideration.
2019-03-24 09:36:15 +01:00
Benno Schulenberg
1c3953705c tweaks: avoid parsing the same character twice
Also, make the second loop similar in form to the first.
2019-03-24 09:34:21 +01:00
Benno Schulenberg
b58418b32f tweaks: rename a variable, to be more distinct 2019-03-21 19:21:45 +01:00
Benno Schulenberg
23190aa60f tweaks: make an assignment only when the option is valid, like elsewhere 2019-03-21 19:17:03 +01:00
Benno Schulenberg
01e6d435fe tweaks: rename a function, to be simpler and more accurate 2019-03-21 17:42:34 +01:00
Benno Schulenberg
2b21d53857 tweaks: elide a function that is called just once 2019-03-21 17:36:46 +01:00
Benno Schulenberg
cddfcb1b9d tweaks: rename a struct element, to make sense 2019-03-21 17:23:49 +01:00
Benno Schulenberg
6755b7c0a0 tweaks: rename four functions, to make more sense 2019-03-21 17:18:50 +01:00
Benno Schulenberg
aac4fc46e9 tweaks: rename a type, to make more sense 2019-03-21 17:08:52 +01:00
Benno Schulenberg
04cfe5a258 tweaks: rename a function for aptness, and two variables for shortness 2019-03-19 21:17:06 +01:00
Benno Schulenberg
954cab81b4 tweaks: improve and condense some comments, and remove an unneeded one 2019-03-19 21:13:34 +01:00
Benno Schulenberg
69601315c4 docs: add notes to draw attention to the changed defaults 2019-03-18 20:08:01 +01:00
Benno Schulenberg
43c6bc6619 tweaks: add a consistency check plus a corresponding warning
Since commit 4c6ec637 from about half a year ago, the 'action' parameter
of update_undo() is unused.  Verify that this parameter matches the type
of the item at the top of the undo stack, so that in another half year
the parameter can be safely removed.
2019-03-17 20:51:43 +01:00
Benno Schulenberg
e0fab690cc tweaks: don't pass a pointer when a boolean is expected
For some reason, when configured with --with-slang, some extra compiler
warnings are enabled that are not enabled by --extra-warnings.  :|
2019-03-17 19:13:24 +01:00
Benno Schulenberg
513d2ae905 build: fix compilation when configured with --disable-utf8 2019-03-15 16:41:02 +01:00
Benno Schulenberg
47f3dc75d8 display: use non-breaking space instead of dot for VTE-bug workaround
When UTF-8 is available, it is better to use a character that displays
as a space.

This improves the fix for https://savannah.gnu.org/bugs/?55896.
2019-03-15 14:58:37 +01:00
Benno Schulenberg
5f529a48e6 tweaks: don't bother trying to draw characters beyond the screen's edge 2019-03-15 14:04:23 +01:00
Benno Schulenberg
d9faac618d display: dot the stripe when it's in the last column, to defeat a VTE bug
This addresses https://savannah.gnu.org/bugs/?55896.
2019-03-15 13:49:12 +01:00
David Lawrence Ramsey
93ee0a8a65 display: show the guide stripe for double-width/multi-byte characters
Determine the actual number of bytes the striped character consists of,
instead of assuming it's simply one, and determine the real column that
the character starts in, instead of assuming it's the stripe column.

This fixes https://savannah.gnu.org/bugs/?55917
and fixes https://savannah.gnu.org/bugs/?55922.

Condensed-by: Benno Schulenberg <bensberg@telfort.nl>
2019-03-15 13:29:11 +01:00
Benno Schulenberg
15959346fb tweaks: exclude the guide-stripe code from the tiny version
The option is not available, so including the code is pointless.
2019-03-14 19:34:35 +01:00
Benno Schulenberg
902b4674f9 display: account for horizontal scrolling when drawing the guide stripe
That is, draw the stripe relative to the column at which the current
"chunk" starts.

This fixes https://savannah.gnu.org/bugs/?55920.
2019-03-14 17:01:48 +01:00
David Lawrence Ramsey
37be9b54ca justify: initialize a variable before making use of its value
When the mark is off, initialize not just 'bot_x' but also 'top_x'.

This fixes https://savannah.gnu.org/bugs/?55898.

Bug existed since the justifying of a marked region was introduced,
four days ago, with commit f7f5514e.
2019-03-14 11:48:07 +01:00
Benno Schulenberg
19a833c94e startup: check again for a Linux console after reading all files
When there is a dash among the files on the command line, nano will read
data from standard input, which means that the latter is not connected to
a terminal and thus cannot be recognized as a Linux VT until nano has
finished reading the input and has reconnected the input source to the
terminal.

The first probe for a Linux VT is kept in place for now, so that nano
can stop when there are errors in an rcfile while running on a VT.
(This stopping will not work when data is read from standard input,
of course, but that is a smaller fish.)

This fixes https://savannah.gnu.org/bugs/?55912.
Reported-by: Enrico Mioso <mrkiko.rs@gmail.com>

Bug existed since the recognition of modified cursor keys on a Linux
console was introduced, in version 2.6.3, commit 290d278f.
2019-03-13 19:31:11 +01:00
Benno Schulenberg
169da8aec0 docs: mention three features in their proper place
They were introduced in version 2.5.0.
2019-03-11 11:21:57 +01:00
Benno Schulenberg
20514eca19 feedback: make two error messages better match the option
And keep them identical.
2019-03-11 09:07:08 +01:00
Benno Schulenberg
f54f122637 gnulib: update to its current upstream state 2019-03-11 08:29:50 +01:00
Benno Schulenberg
d5b21d7bd0 copyright: update the years for the FSF in the documentation too 2019-03-11 08:27:19 +01:00
Benno Schulenberg
4240423b9c help: in the tiny version, don't list an option that is the default
And don't recognize it either.
2019-03-10 19:19:31 +01:00
Benno Schulenberg
74752686f4 help: don't list the obsoleted -O and -S options in the --help output
And don't bother to recognize them either.
2019-03-10 19:19:17 +01:00
Benno Schulenberg
4205567bb1 tweaks: add deprecation comments to the four superseded options 2019-03-10 17:05:19 +01:00
Benno Schulenberg
a20340b5a8 copyright: update the years for significantly changed files 2019-03-10 17:03:42 +01:00
David Lawrence Ramsey
932a35c072 tweaks: normalize the indentation, and remove unneeded braces 2019-03-10 09:22:02 +01:00
David Lawrence Ramsey
877a649819 justify: when justifying a marked region, strip whitespace after the lead
This matches Pico's behavior.
2019-03-10 09:22:02 +01:00
David Lawrence Ramsey
5d7b723c16 justify: put a mid-line marked region onto separate lines
This matches Pico's behavior.  However, Pico doesn't add the quoting +
indentation to the line in which the selection ends, but this is wrong,
so nano does add it.  Also, Pico doesn't account for partial quoting +
indentation at the start or end of a selection, but this is wrong, so
nano does.
2019-03-10 09:22:02 +01:00
David Lawrence Ramsey
053244db70 justify: handle the leading part when justifying a marked region
Unlike a regular paragraph, marked text may have different quotes and
more than two types of indentation.  Handle this by replacing deviant
quotes with the quote of the first line, and deviant indentation with
the indentation of the second line.
2019-03-10 09:22:02 +01:00
David Lawrence Ramsey
f7f5514eef new feature: marked text gets justified into a single, new paragraph
This is modelled after Pico's behavior.  However, Pico won't do anything
if you do a full-justify while the mark is on.  But this is unnecessarily
limiting, so, when the mark is on, nano will handle a full-justify and a
plain justify the same.

This currently does not handle the lead (quoting + indentation) in
justified selections, does not put mid-line justified selections onto
separate lines, and does not strip whitespace after the lead in justified
selections, the latter two of which Pico does.  These behaviors are
forthcoming.
2019-03-10 09:22:02 +01:00
David Lawrence Ramsey
afa0097ceb tweaks: rename a variable, to prepare for its new role 2019-03-10 09:22:02 +01:00
David Lawrence Ramsey
6e960012c2 tweaks: split justify_paragraph() into three separate functions
concat_paragraph() concatenates a paragraph into a single line, and
rewrap_paragraph() rewraps that line into multiple lines again.

These two will be needed when the justifying of marked text is added.
2019-03-10 09:22:02 +01:00
David Lawrence Ramsey
311a7138b2 tweaks: adapt find_paragraph()/justify_paragraph() for multiple quotes
Instead of passing 'quote_len' to these functions, calculate it directly
in them.

This will be needed when the justifying of marked text is added.  When
unmarked text is justified, it is a single paragraph and by definition
has a uniform quoting part.  But marked text may be a jumble of lines
that have different quoting parts.
2019-03-10 09:22:02 +01:00
David Lawrence Ramsey
0ac04347d5 tweaks: remove unnecessary variable initializations 2019-03-10 09:22:02 +01:00
Benno Schulenberg
610be482fa docs: suggest a setting for 'stripecolor' in the sample nanorc 2019-03-09 09:54:27 +01:00
Benno Schulenberg
9ad3a17954 syntax: nanorc: stop coloring 'unset fill ...' as if it were valid
The same for 'unset tabsize ...'.

Also, color 'set guidestripe' plus a following number as valid.
2019-03-09 09:27:08 +01:00
Benno Schulenberg
6e04d697a1 docs: describe the new options -J, --guidestripe, and 'set stripecolor' 2019-03-09 09:27:08 +01:00
Benno Schulenberg
916b4d81d0 rcfile: add 'stripecolor' for changing the color of the guiding stripe
The default is now simply reverse video, which works better than a
"loud" colored bar in an interface that for the rest is monochrome.
2019-03-09 09:27:08 +01:00
Benno Schulenberg
66c6eb5166 new feature: option --guidestripe that shows a vertical guiding bar
Option -J (--guidestripe) takes a column number as argument and then
shows a vertical, colored bar over the entire height of the buffer,
to aid the user in regulating the width of the text when the terminal
is wider than this desired width.

This fulfills https://bugs.debian.org/916392.
Requested-by: Arturo Borrero González <arturo@debian.org>
And fulfills https://savannah.gnu.org/bugs/?55315.
Requested-by: Bryan Christ <bryan.christ@gmail.com>
2019-03-09 09:27:08 +01:00
David Lawrence Ramsey
43b42246d3 display: properly handle double-width characters when spotlighting
When the right half of a two-column character gets overwritten by the
">" continuation character, then represent its left half as "[" also
when spotlighting a replacement candidate.  Achieve this by calling
display_string() in the overshooting case with 'isprompt' set to TRUE,
which also makes this function reserve space for the ">" continuation
character so spotlight() doesn't need to do this any more.

This fixes https://savannah.gnu.org/bugs/?55679.

Improved-by: Benno Schulenberg <bensberg@telfort.nl>
2019-03-08 19:56:52 +01:00
David Lawrence Ramsey
40a74e46e6 display: correct the logic for making room for the ">" character
The change in commit edc0d628 was flawed.  The old logic covered
every case but one: having reached the end of 'buf' but 'column'
still having overshot the screen width.  Now cover this latter
case too.

This fixes https://savannah.gnu.org/bugs/?55638 properly,
allowing the next commit to fix another buglet.

Condensed-by: Benno Schulenberg <bensberg@telfort.nl>
2019-03-08 19:52:33 +01:00
Benno Schulenberg
c3cd0f3411 help: reword the description of ^U to avoid the impression of "Undo"
Instead of "Uncut" use the word "Paste", which is the common name for
this function.
2019-03-07 20:36:03 +01:00
Benno Schulenberg
85e895508b display: scroll horizontally one column earlier
In this way, for single-width characters, one can see what character is
ahead of the cursor before actually moving the cursor to that position,
and, for double-width characters, the cursor never sits on a placeholder
but always shows the character that is actually there.

This addresses https://savannah.gnu.org/bugs/?55716.
2019-03-07 20:34:31 +01:00
Benno Schulenberg
37c8232f4d bindings: provide usable shortcuts for prevword/nextword in tiny version
In the tiny version the feature toggles are absent, so most of the
Meta-key combinations do nothing, and when --with-slang was used, the
<Ctrl+Left/Right> keystrokes do not work (as they produce truncated
escape sequences under Slang), and the <Ctrl+Space> and <Alt+Space>
keystrokes are awkward to type and make no sense.  So... use some
of the free Meta combinations to jump a word to the left or right,
since these functions *are* present in the tiny version.
2019-03-03 14:25:51 +01:00
David Lawrence Ramsey
f13dd140eb display: correctly trim an overshooting character from a prompt answer
Tell display_string() explicitly when we're at a prompt, instead of
letting it glean this from the current menu not being MMAIN, which
fails in some circumstances.

This improves the fix for https://savannah.gnu.org/bugs/?55620,
fixes https://savannah.gnu.org/bugs/?55680 in a better way,
and fixes https://savannah.gnu.org/bugs/?55773.
2019-02-28 19:47:55 +01:00
Benno Schulenberg
de47b58dc1 tweaks: move declaration of variable that does not need to be global
More importantly: searching in src/history.c will now not only find
the uses of 'position_history' but also its declaration.
2019-02-27 19:54:43 +01:00
Brand Huntsman
a5ef013e82 history: use an unfreed 'position_history' to avoid a possible crash
The reload_positions_if_needed() routine can free the existing
'position_history' and allocate a new one.  Using the old one,
from before the reload, could lead to a crash.

This fixes https://savannah.gnu.org/bugs/?55792.
Reported-by: Enrico Mioso <mrkiko.rs@gmail.com>

Bug existed since the reloading of the position-history file was
introduced, a year and a half ago, in commit bfc53f30.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-02-27 18:03:08 +01:00
Benno Schulenberg
70da1889ee feedback: complete the removal of some superfluous words
This should have been part of commit 1053a3c4.
2019-02-25 10:04:10 +01:00
Benno Schulenberg
1eb639d55e display: show "[" for half of two-column character also when softwrapping
This should have been part of commit ad505e7f.
2019-02-24 21:45:53 +01:00
Benno Schulenberg
79ca3ceabf copyright: update the years for the FSF 2019-02-24 19:35:56 +01:00
Benno Schulenberg
b5ca8a00af tweaks: rename three functions and two symbols, to match the new wording 2019-02-24 17:32:17 +01:00
Benno Schulenberg
2c7d336711 bindings: rename 'cutwordleft' to 'chopwordleft', and similar for right
These bindable functions should not connote cutting, as they don't put
anything into the cutbuffer.
2019-02-24 17:31:40 +01:00
Benno Schulenberg
15c3e924b8 help: reword the tags for deleting a word left and right
Don't use the word "Cut", as the words are discarded and
not added to the cutbuffer.
2019-02-24 16:49:44 +01:00
Benno Schulenberg
1053a3c440 feedback: remove some superfluous words from Undid/Redid messages
Also, change some words to nouns, to fit the scheme.
2019-02-24 16:27:47 +01:00
Benno Schulenberg
7c30d1fa69 display: account for zero-width characters when reserving space for '>'
That is: keep nibbling off characters until a character is eaten that
takes up at least one column.

This fixes https://savannah.gnu.org/bugs/?55759.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>

Bug existed since version 2.8.0, commit 5283acdc.
2019-02-24 11:28:52 +01:00
Benno Schulenberg
031166c34d help: don't list the unbound <Alt+Up> and <Alt+Down> in the tiny version 2019-02-24 11:27:10 +01:00
Benno Schulenberg
5e769686fb docs: mention that 'cutwordleft' is bound to <Shift+Ctrl+Delete>
The default binding was made in commit e6429e78, half a year ago,
but the documentation was not adjusted.
2019-02-24 11:25:35 +01:00
Benno Schulenberg
df4d181987 help, docs: say "Delete" when things don't go into the cutbuffer
Reported-by: Božidar Putanec <bozidarp@yahoo.com>
2019-02-24 11:00:06 +01:00
Benno Schulenberg
7fcf6e6068 menus: don't show ^S and ^Q in the help lines in the tiny version
On small terminals (80 columns or so), ^S and ^Q would be in
the last position of the help lines.  But some terminals might
intercept ^S and stop all output (until ^Q is pressed), which
could be unexpected and frustrating.  So, rearrange things for
the tiny version so that ^S appears only on very wide terminals.

Also, having two keystrokes for saving the current buffer
(^O and ^S) in the two help lines is wasteful, more so as
in the tiny version there are no ^G help texts.

So, show the more useful M-Q and M-W instead.

This addresses https://bugs.debian.org/915017.
Reported-by: Steve McIntyre <steve@einval.com>
2019-02-21 17:42:51 +01:00
Benno Schulenberg
0f9d60a386 tweaks: split a variable into two, as they have different roles 2019-02-20 19:33:48 +01:00
Benno Schulenberg
11a66d74b8 tweaks: condense and correct a comment 2019-02-20 19:33:32 +01:00
Benno Schulenberg
d3fdd20471 tweaks: rename an overlooked variable from a single letter to a word 2019-02-20 17:39:04 +01:00
Benno Schulenberg
82492ead47 tweaks: rename two variables, to be less confusing 2019-02-20 16:43:03 +01:00
Benno Schulenberg
00713a7c47 docs: deprecate the use of morespace, smooth, nonewlines, and nowrap 2019-02-20 16:34:29 +01:00
Benno Schulenberg
420fe4d1e6 tweaks: switch from checking MORE_SPACE to checking EMPTY_LINE 2019-02-19 19:53:19 +01:00
Benno Schulenberg
322a6f46fa tweaks: switch from checking SMOOTH_SCROLL to checking JUMPY_SCROLLING 2019-02-19 19:52:57 +01:00
Benno Schulenberg
b6a762232e tweaks: switch from referencing NO_NEWLINES to referencing FINAL_NEWLINE 2019-02-19 19:45:55 +01:00
Benno Schulenberg
54055b6174 tweaks: switch from referencing NO_WRAP to referencing BREAK_LONG_LINES 2019-02-19 19:45:55 +01:00
Benno Schulenberg
3270250184 docs: mention that --morespace and --smooth are obsolete and ignored 2019-02-19 19:34:34 +01:00
Benno Schulenberg
cb7c8255f4 options: warn when option -O or -S is given, and ignore them
If these two command-line options would override an rcfile setting of
their counterpart new option, the user might come to expect being able
to do this also in the future.  But these old options will be obsoleted
at some moment, so... better start ignoring them right now.
2019-02-19 19:13:53 +01:00
Benno Schulenberg
60bdac2bbc docs: describe breaklonglines, emptyline, finalnewline, jumpyscrolling 2019-02-19 19:06:26 +01:00
Benno Schulenberg
f6c767a372 docs: describe the four new options (-b, -f, -j, -e) 2019-02-19 17:48:43 +01:00
Benno Schulenberg
6c89815e8b docs: stop saying that --fill switches on automatic hard-wrapping
The two were decoupled in the previous commit.  Just say that --fill
sets the target width for both justifying and automatic hard-wrapping.
2019-02-18 09:41:56 +01:00
Benno Schulenberg
894aff0816 options: let --fill no longer imply automatic hard-wrapping
Now --fill only sets the target width for hard-wrapping and justifying,
but automatic hard-wrapping itself is switched on with --breaklonglines.
2019-02-18 09:34:18 +01:00
Benno Schulenberg
556c0a3865 rcfile: when an old flag is unset, set the corresponding new flag
This fixes https://savannah.gnu.org/bugs/?55583.
2019-02-18 09:34:18 +01:00
Benno Schulenberg
4d40bea58a rcfile: add the options that correspond to -b, -f, -j, and -e 2019-02-18 09:34:18 +01:00
Benno Schulenberg
ee979ae7b3 options: add -e, --emptyline, the counterpart of --morespace 2019-02-18 09:34:18 +01:00
Benno Schulenberg
401e43969c options: add -j, --jumpyscrolling, the counterpart of --smooth 2019-02-18 09:34:18 +01:00
Benno Schulenberg
5dbd9c0043 options: add -f, --finalnewline, the counterpart of --nonewlines 2019-02-18 09:34:18 +01:00
Benno Schulenberg
cd9328fbf5 options: add -b, --breaklonglines, the counterpart of --nowrap 2019-02-18 09:34:18 +01:00
Benno Schulenberg
7811f3fc5a menus: put the ^T toggle in Search in the same position as in Goto-Line
So that when toggling it, the ^T in the help lines stays roughly in the
same place.
2019-02-17 10:24:03 +01:00
Benno Schulenberg
5f07b96d47 menus: move the paragraph-jumping functions from Search to Goto-Line
The start-of-paragraph and end-of-paragraph seeking functions are only
vaguely related to searching, and have nothing to do with replacing --
the functions make more sense in the Goto-Line menu.

Also, the Goto-Line menu is much less crowded, so the functions are
more likely to be noticed there.  Furthermore, this makes harmless a
typo that I sometimes make: typing ^W again when I've already done so.
2019-02-17 09:53:35 +01:00
Benno Schulenberg
bc98dbcab4 menus: remove the ^Y and ^V shortcuts from the Search menus
Jumping to the first or last line of the buffer doesn't have anything
to do with searching, so these functions shouldn't be present in the
search menus.  They make perfect sense in the Goto-Line menu, though.
2019-02-17 09:52:57 +01:00
Benno Schulenberg
252bb60036 display: highlight the ">"/"<" continuation characters in reverse video
To make it obvious that they are not actual characters in the file.

The default highlighting is in reverse video, but this can be changed
to bold by using --bold or 'set boldtext'.

This fulfills https://savannah.gnu.org/bugs/?55571.
2019-02-15 17:15:28 +01:00
Benno Schulenberg
6d34b8a5cd display: change the "$" continuation character to ">" and "<"
The angular brackets look a bit like arrows and thus hint much more
at the idea of continuation than a dollar sign.

With-help-from: David Lawrence Ramsey <pooka109@gmail.com>
2019-02-15 17:12:57 +01:00
Benno Schulenberg
ad505e7fff display: represent half of a double-width character with "[" and "]"
When the screen's edge leaves just one column for a two-column
character, then show its left half as "[" and its right half as "]".

(They used to be shown as ">" and "<", but these characters will be
repurposed in the next commit.)

This addresses https://savannah.gnu.org/bugs/?55657.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2019-02-15 17:12:34 +01:00
Benno Schulenberg
e7557a9293 tweaks: condense a handful of comments 2019-02-12 17:32:56 +01:00
Benno Schulenberg
757d223064 tweaks: don't bother executing two functions that are empty
The get_history_older_void() and get_history_newer_void() functions
are mere names, they don't actually do anything.  So... don't bother
to execute them, so the 'finished' variable doesn't have to be reset
after calling them.

Also, normalize the order of those two empty functions.
2019-02-12 16:06:24 +01:00
Benno Schulenberg
ea4ba3a150 tweaks: add an alias for a string variable, so the code makes more sense 2019-02-12 16:06:24 +01:00
Benno Schulenberg
32d7d3900d tweaks: reshuffle a few lines, and condense some comments 2019-02-12 16:06:24 +01:00
Benno Schulenberg
b57336ad00 tweaks: rename some variables, to match others that have the same task 2019-02-12 16:06:24 +01:00
Benno Schulenberg
ebfe752841 tweaks: rename some variables from a single letter to meaningful word 2019-02-12 16:06:24 +01:00
Benno Schulenberg
14f32577ee display: ensure that spotlighted text is not treated as a prompt answer
When doing replacements or fixing misspelled words, and edit_refresh()
is called to highlight the relevant word, then the current menu can be
anything from MREPLACEWITH, MYESNO, MSPELL, or MMAIN.  Make sure it is
always set to the latter just before calling edit_refresh(), so that
display_string() will use the full length and the word gets properly
highlighted.

This fixes https://savannah.gnu.org/bugs/?55680.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>

Bug was introduced by the previous commit, 56181896.
2019-02-12 15:07:55 +01:00
Benno Schulenberg
5618189643 prompt: trim a double-width character at the screen's edge
It needs to be trimmed and substituted with a single-width placeholder
to prevent the continuation character ">" from getting pushed to the
next row.

Also, use the correct width for the answer so that the continuation
character is only displayed when the answer does not fit any more.

This fixes https://savannah.gnu.org/bugs/?55620.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>

Original-patch-by: David Lawrence Ramsey <pooka109@gmail.com>
2019-02-07 20:04:56 +01:00
Benno Schulenberg
cf634d1aff browser: show the ^G item again in the help lines
Also, prune another statement as MMOST no longer includes MBROWSER.

This fixes https://savannah.gnu.org/bugs/?55655.

Bug existed since version 3.2, commit cc01bc3e.
2019-02-06 16:36:42 +01:00
David Lawrence Ramsey
edc0d6280a display: properly trim double-width characters at the edit window's edge
When a line ends with a two-column character, and this character straddles
the edit window's edge, then, although we've reached the end of 'buf', we
have exceeded the 'beyond' column and this two-column character needs to
be trimmed from the 'converted' string, otherwise it would get printed on
the next row.

This fixes https://savannah.gnu.org/bugs/?55638.

Bug existed since version 2.8.0, commit 5283acdc.
2019-02-06 10:09:55 +01:00
Benno Schulenberg
6470106eef docs: mention nano's major features directly instead of referring
In addition, the referral in the FAQ was to nano's home page,
which does not mention any advantages or features of nano.
2019-01-31 20:30:53 +01:00
Benno Schulenberg
b89540218d tweaks: add two comments, and reduce the scope of another variable 2019-01-27 11:18:55 +01:00
Benno Schulenberg
77c60201d5 tweaks: reduce the scope of a variable, and rename it 2019-01-27 11:10:29 +01:00
Benno Schulenberg
2482cfca56 build: eradicate the --disable-wrapping-as-root configure option
Hard-wrapping is disabled by default for any user, so this special
configure option is no longer needed.
2019-01-25 11:37:51 +01:00
Benno Schulenberg
946755a307 options: disable hard-wrapping and automatic newlines by default
Also, enable smooth scrolling by default, and don't waste the row
directly below the title bar.  The use of the latter also serves
as a small visual reminder that this nano is different.

This addresses https://savannah.gnu.org/bugs/?55067.
2019-01-25 11:37:21 +01:00
Benno Schulenberg
98b1f8f059 options: stop recognizing and ignoring -b, -e, -f, -j, and -q
This signals our break from trying to be as compatible with Pico as
possible.  We were already incompatible with modern Pico in the -n
and -W options, and in several character-set and color options, so
ignoring those five options brought us very little.

Anyway, soon some of those options will be reused and will have the
effect of making nano look and behave more like Pico.
2019-01-25 11:22:56 +01:00
Benno Schulenberg
38e3318e5f tweaks: reword the description of the disadvantages of Pico
Also reword a list of features to exclude the ones that only
make sense when contrasting nano with Pico.
2019-01-25 11:00:51 +01:00
Benno Schulenberg
6aad99bd81 docs: stop implying that nano wants to be fully compatible with Pico 2019-01-25 10:50:14 +01:00
Benno Schulenberg
4b8bd27d08 bindings: change the action of <Alt+Up>/<Alt+Down> to 'scroll linewise'
Using the cursor keys for movement-related functions makes more sense
than using them for jumping to the previous or next occurrence of the
search string.

(For searching another occurrence backward the M-Q binding has become
available, while M-W will search another occurrence always forward.)
2019-01-24 20:24:09 +01:00
Benno Schulenberg
757f558f3b tweaks: renumber some FAQ items, to compensate for the deleted ones
Also, reshuffle one item, to have related items next to each other.
2019-01-23 20:59:30 +01:00
Benno Schulenberg
1f9283ec82 docs: remove from the FAQ some items that are no longer relevant 2019-01-23 20:53:08 +01:00
Benno Schulenberg
2eb1960523 docs: mention that 'quotestr' enables the rewrapping of comment blocks
Inspired-by: David Griffith <dave@661.org>
2019-01-23 20:01:49 +01:00
Benno Schulenberg
4bf650f021 tweaks: condense a comment, and drop two others
And replace a statement with a self-explanatory one.
2019-01-22 20:25:07 +01:00
Benno Schulenberg
63db58cbfd docs: adjust for the enhancement of the default quoting regex 2019-01-22 20:06:14 +01:00
Benno Schulenberg
c5a72103bf justify: extend the quoting regex, to cover more types of comments
Now also comment blocks in Fortran, Lisp, Lua, Postgres, and TeX
can be rewrapped with ^J.

This partially addresses https://savannah.gnu.org/bugs/?55435.
Kind-of-requested-by: David Griffith <dave@661.org>
2019-01-22 17:57:19 +01:00
Benno Schulenberg
da4b7e430f files: retain a Shift-selected region when switching between buffers
The user did not move the cursor nor intend to move the cursor, so
leave things as they are.

This fixes https://savannah.gnu.org/bugs/?55535.
Indirectly-reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2019-01-21 12:24:45 +01:00
David Lawrence Ramsey
e771503ee5 tweaks: adjust indentation after the previous commit 2019-01-15 19:47:11 +01:00
David Lawrence Ramsey
194d18586c input: properly handle <Escape>s followed by a shifted Meta+letter
After a series of escapes, also <Shift+Meta+letter> should be recognized
as a command keystroke, not just <Meta+letter>.

This fixes https://savannah.gnu.org/bugs/?55442.

Bug existed since the ignoring of <Escape>s before a valid command
keystroke was introduced in version 3.0, commit ecc9211a.
2019-01-15 19:41:48 +01:00
Benno Schulenberg
e1a6f58da6 startup: check that a backup directory is valid also when backups are off
When the user switches backups on later (with M-B in the ^O menu),
the specified folder should have been checked for validity.

This fixes https://savannah.gnu.org/bugs/?55423.

Bug existed since the check for a valid backup directory was introduced
in version 2.8.7, commit 751e7f0f.
2019-01-10 20:31:48 +01:00
Benno Schulenberg
0ae80ce362 tweaks: reduce two parameters to a single one by summing them
Also, rename the remaining parameter and rename a variable.
2019-01-06 17:56:46 +01:00
Benno Schulenberg
0c42c51aa4 tweaks: rename two variables, to indicate better what they mean 2019-01-06 15:46:23 +01:00
Benno Schulenberg
f74a120803 tweaks: refer to the magic line as "magic line", not as "magicline" 2019-01-06 15:35:31 +01:00
Benno Schulenberg
911eb0cf2a tweaks: rename and invert a function, to avoid double negatives 2019-01-06 13:12:44 +01:00
Benno Schulenberg
67873e961b cutting: cover the corner cases where cut commands do not cut anything
Give the correct feedback in those cases and do not add an undo item.

This fixes both parts of https://savannah.gnu.org/bugs/?55396.
2019-01-06 13:07:20 +01:00
Benno Schulenberg
50e8f8aab9 cutting: give feedback when otherwise nothing happens
This makes the cutting and pasting keystrokes somewhat discoverable.
2019-01-05 17:39:05 +01:00
Benno Schulenberg
ce6f320947 cutting: when ^K does not actually cut anything, do not add an undo item
Act the same way for M-T and for zapping.

This addresses https://savannah.gnu.org/bugs/?55330.
2019-01-05 17:36:34 +01:00
Benno Schulenberg
4104376e7c tweaks: rename a variable, elide another, and adjust two comments
Also, adjust the type of a parameter to 'size_t', as it is a
character index.
2019-01-02 18:05:58 +01:00
Benno Schulenberg
ffa0a9ef64 tweaks: calculate the length of a completion word in a more direct way 2019-01-02 17:44:15 +01:00
David Lawrence Ramsey
eef6b2b442 tweaks: use proper variable types in the word-completion functions
Use 'size_t' for character indexes, and 'ssize_t' for the threshold.
2019-01-01 17:48:23 +01:00
Benno Schulenberg
16c20ad873 tweaks: move the character/word-deletion functions to a better location
Having all the cutting and deleting functions together in one file
kind of makes sense.
2019-01-01 17:48:02 +01:00
Benno Schulenberg
f9bb5382aa tweaks: reshuffle and frob a couple of comments, and reindent two lines 2019-01-01 17:33:10 +01:00
Benno Schulenberg
329b82d284 undo: set the correct file size for a redo of a character deletion
The reduced file size should be stored not just when joining two lines
but also when simply a character in the middle of a line is deleted.

This fixes https://savannah.gnu.org/bugs/?55352.

Bug existed since version 2.5.0, commit 66e21416.
2019-01-01 12:35:53 +01:00
Benno Schulenberg
b596639f95 options: actually rename --rebindkeypad to --rawsequences (-K) 2018-12-31 18:35:46 +01:00
David Lawrence Ramsey
d0982536a7 undo: after undoing a cut, don't remove the magicline if we're on it
This fixes https://savannah.gnu.org/bugs/?55332.
2018-12-31 14:10:02 +01:00
Benno Schulenberg
798695ff1e utils: retire the fixbounds() function -- it is no longer needed
All tested systems (FreeBSD, NetBSD, OpenBSD, Alpine, and Ubuntu)
support the GNU-style word boundaries (\< and \>), either natively
or through using the regex module from gnulib.

If this change breaks regexes containing \< or \> on your system,
please report a bug: https://savannah.gnu.org/bugs/?group=nano

This addresses https://savannah.gnu.org/bugs/?55207.
2018-12-31 13:49:07 +01:00
Benno Schulenberg
15320d3b96 tweaks: word some comments more concisely 2018-12-30 21:30:26 +01:00
Benno Schulenberg
0e9fb6a0da tweaks: rename two variables, to be more descriptive 2018-12-30 20:18:29 +01:00
Benno Schulenberg
34b8d58871 rcfile: reject an attempt to bind ^[
Also, for <Esc> <Esc> [, report that it is unbindable.

This fixes https://savannah.gnu.org/bugs/?55336.
2018-12-30 19:47:43 +01:00
Benno Schulenberg
fb4ce71cfc tweaks: correct a comment typo, and trim a few other comments 2018-12-30 18:00:28 +01:00
Benno Schulenberg
7a2c851dfc tweaks: reorder some ifs, to reduce the average number of comparisons 2018-12-30 17:50:10 +01:00
Benno Schulenberg
4d55748999 tweaks: reduce a bunch of repetitious comments to their essence
And in the bargain add two missing equivalences.
2018-12-30 17:31:36 +01:00
Benno Schulenberg
e7198f49a4 tweaks: elide an unneeded intermediate variable 2018-12-30 16:48:48 +01:00
Benno Schulenberg
125cc0cd74 tweaks: elide a tiny function by making a variable global
And in the bargain it makes things clearer, because the name
cutbuffer_reset() is misleading.
2018-12-30 13:36:29 +01:00
Benno Schulenberg
afab65e8a8 tweaks: elide a parameter that is always TRUE
The parameter was made redundant by David's overhaul of the
justification code.
2018-12-30 12:48:26 +01:00
David Lawrence Ramsey
7e152f2a48 undo: when undoing a cut, remove also the magicline if it added one
Reuse the WAS_FINAL_LINE flag to signal a cut that added a magicline,
for both a marked cut and cut-to-eof.

This fixes https://savannah.gnu.org/bugs/?55305.
2018-12-30 11:37:46 +01:00
David Lawrence Ramsey
8854ddb728 undo: set and check 'xflags' in a bitwise manner
This allows multiple flags to be set, which will be needed for the
next commit.
2018-12-30 11:36:49 +01:00
Benno Schulenberg
0213f412d1 docs: say that --rebinddelete can correct both <Backspace> and <Delete> 2018-12-28 19:48:54 +01:00
Benno Schulenberg
dc99610c36 docs: reword and reshuffle the description of --rawsequences
It's not just about the numeric keypad, but about the interpretation
of all editing keys (arrows, Home, End, PageUp, PageDown, Insert, and
Delete), of the escape sequences that they produce.
2018-12-28 19:29:38 +01:00
Benno Schulenberg
d3c0fe3923 options: make --rawsequences disable --mouse, to prevent entering junk
When using --raw, ncurses does not catch and convert any mouse event,
and thus the coordinates of a mouse click would get inserted into the
buffer as seemingly random characters.  So, let --rawsequences override
and disable --mouse, to prevent the accidental entering of junk.

This fixes https://savannah.gnu.org/bugs/?55303.
2018-12-28 19:15:20 +01:00
Benno Schulenberg
997826d794 tweaks: rename a symbol, to match its corresponding option 2018-12-28 17:47:03 +01:00
Benno Schulenberg
67c69b2298 options: rename long version of -K from --rebindkeypad to --rawsequences
To better describe what it does, and to have full contrast with the
--rebinddelete option: the latter can now be shortened to --rebind
without getting a conflict, and --rawsequences can be abbreviated
to simply --raw and still make sense.
2018-12-28 17:35:55 +01:00
Benno Schulenberg
72a49dbbb4 browser, help: make <Bsp> page up also when terminfo mismatches terminal 2018-12-28 17:20:24 +01:00
Benno Schulenberg
0946153b47 tweaks: hard-bind ASCII DEL in a slightly more economical way
And in the bargain get rid of a duplicate help-text entry for
either "Del" or "Bsp".
2018-12-28 17:20:18 +01:00
Benno Schulenberg
9b2c2697cb options: make -d (--rebinddelete) work without -K (--rebindkeypad)
When the terminfo selected by TERM does not match the terminal and
the <Delete> key behaves the same as <Backspace> (deleting leftward)
or the <Backspace> key behaves the same as <Delete> (deleting without
moving the cursor), then using just -d or --rebinddelete should make
the deviant key behave correctly again without affecting the other.
2018-12-28 17:19:09 +01:00
Benno Schulenberg
a57c6a6763 tweaks: elide a one-line function that is used just twice 2018-12-27 21:19:47 +01:00
Benno Schulenberg
597d90207e startup: improve two error messages by mentioning the invalid operand
This addresses https://savannah.gnu.org/bugs/?55304.
2018-12-27 21:08:57 +01:00
Benno Schulenberg
b1b2369541 tweaks: rewrap a line and improve a few comments 2018-12-26 15:11:20 +01:00
Benno Schulenberg
8a88cea256 tweaks: elide a variable that is a copy of another 2018-12-26 14:56:29 +01:00
Benno Schulenberg
6f23d9c18c tweaks: rename a variable, because it also serves as "last line" 2018-12-26 14:37:36 +01:00
Benno Schulenberg
dfbffff4b0 tweaks: remove a superfluous incrementing and decrementing of a variable 2018-12-26 14:28:54 +01:00
Benno Schulenberg
ea73d7fd70 tweaks: condense a couple of comments and rewrap a few lines 2018-12-26 14:26:54 +01:00
Benno Schulenberg
55c52c50d0 bindings: hard-bind ASCII code 0x08 (BS) to the backspace function
ASCII code BS should always do a backspace, also on systems where the
"^H" string gets redirected (for rebinding purposes) to KEY_BACKSPACE.

This fixes https://savannah.gnu.org/bugs/?55247.
Reported-by: Norton Warner <nortonwarner@gmail.com>
2018-12-23 18:45:12 +01:00
David Lawrence Ramsey
77bd8c2630 tweaks: swap the names of the variables 'wrap_at' and 'fill'
Now 'fill' contains the original specified value,
and 'wrap_at' the column that 'fill' translates to.
2018-12-18 19:50:59 +01:00
Benno Schulenberg
3121ee4b2e options: stop recognizing and mentioning --quiet and 'set quiet'
Those options have been a no-op and obsolete for over a year.

Just continue to accept and ignore -q, for some "compatibility"
with Pico.
2018-12-18 19:29:40 +01:00
Benno Schulenberg
762cee242a tweaks: reshuffle a bit of code, to have the exit point near the end 2018-12-18 19:27:17 +01:00
Benno Schulenberg
3a170d2c3e rcfile: when rebound, DO unbind a keystroke from its earlier function
When not unbinding it from its earlier function (in the same menu),
it would result in showing the keystroke twice in the help text.

This fixes https://savannah.gnu.org/bugs/?55239.

Bug was introduced a month ago, by commit f81d174f.
2018-12-18 19:25:33 +01:00
Benno Schulenberg
e8751d1d5c bindings: make the normal scrolling keystrokes work also in help viewer
There is no reason why they shouldn't work.
2018-12-17 17:05:56 +01:00
Benno Schulenberg
9dd6407bea docs: correct the descriptions of 'speller' and 'linter' functions
Since the last release, the linter function is bound separately and
no longer masks or overrides the speller function.
2018-12-17 16:05:35 +01:00
Benno Schulenberg
670dd9bbe0 tweaks: condense two regexes in the Tcl syntax, and add a comment
Also, make a range of characters more explicit.
2018-12-17 16:00:54 +01:00
Benno Schulenberg
9cdc64c97a syntax: tcl: colorize comments normally, not with a background hue
This makes for a less "messy" and more readable appearance.

Suggested-by: Michael Siegel <msi@malbolge.net>
2018-12-17 15:35:56 +01:00
Benno Schulenberg
5acfa5bb7b tweaks: slightly indent warnings and errors during the configure phase
To make them stand out in the waterfall of messages.
2018-12-16 14:41:31 +01:00
Benno Schulenberg
38ca2a41f4 tweaks: reduce the scope of two variables, and rename one of them
Also, swap the order of the 'if', and don't bother setting a freed
string pointer to NULL as it will never be used again.
2018-12-11 10:59:12 +01:00
David Lawrence Ramsey
6e3b9ac058 options: exit on a bad quoting regex, instead of crashing later
The paragraph-jumping functions used the regex unverified...

This fixes https://savannah.gnu.org/bugs/?55169.
2018-12-11 10:29:29 +01:00
Benno Schulenberg
41c561c5cf tweaks: schedule a call of edit_refresh() instead calling it directly
The direct call was a leftover of the old unjustify mechanism.

Also, move two statements to the end of the do_justify() routine,
since that is their place in comparable routines.

Suggested-by: David Lawrence Ramsey <pooka109@gmail.com>
2018-12-10 17:38:39 +01:00
Benno Schulenberg
c0abcc6018 docs: harmonize the style of bindable-function descriptions 2018-12-10 11:57:14 +01:00
Benno Schulenberg
55537dc218 display: show it in title bar when starting up in restricted mode 2018-12-03 12:33:00 +01:00
Benno Schulenberg
3a79766da6 rcfile, docs: remove deprecated forms of two options and five bindables
This addresses https://savannah.gnu.org/bugs/?53785.
2018-12-03 10:25:55 +01:00
Benno Schulenberg
0f79a42333 browser: say "Close" instead of "Exit" for the ^X shortcut
When multiple buffers are open, the edit window says "Close" for ^X
instead of "Exit" (when one buffer is open).  In the help viewer ^X
says "Close".  Apparently the idea is that ^X should say "Exit" only
when pressing ^X leads to exiting from nano.  Pressing ^X in the file
browser does not exit from nano, so make it say "Close" instead.

(The help viewer says "Close" since version 2.8.6, commit 934a2192.)
2018-12-03 10:07:42 +01:00
Benno Schulenberg
3b79c7168e help: don't advertise ^S and ^Q when --preserve is used
When using --preserve, ^S and ^Q are "eaten" by the terminal and
do not reach nano: they have no effect in nano, so the help lines
and the help texts should not mention these shortcuts.

Also, to keep the help lines in the help viewer neatly arranged,
^L is not bound there when --preserve is used.
2018-12-03 09:50:00 +01:00
Benno Schulenberg
a9b4430888 docs: update the links in the FAQ to the mailing-list info pages
This fixes https://savannah.gnu.org/bugs/?55129.
Reported-by: Peter Passchier <peter@passchier.net>
2018-12-02 20:05:32 +01:00
Benno Schulenberg
7ca20711a2 build: verify that 'pkg.m4' is available when building from git
This addresses https://savannah.gnu.org/bugs/?44630.
Reported-by: Peter Passchier <peter@passchier.net>
2018-11-29 19:40:54 +01:00
Benno Schulenberg
cad8493e24 tweaks: move the checks for git and gettext to a far earlier point 2018-11-29 19:36:51 +01:00
Benno Schulenberg
6bead051d2 justify: move the check for a bad quoting regex to a better place
So that the cursor will not move when a justification is attempted.
2018-11-26 10:56:20 +01:00
Benno Schulenberg
ac8bd2a227 tweaks: elide a parameter -- do the NULL checks in the caller
Determine more directly: the length of the last paragraph line,
and the exit condition for a full justify.
2018-11-26 10:38:04 +01:00
Benno Schulenberg
0d96df7a91 tweaks: condense and improve a couple of comments 2018-11-26 09:38:02 +01:00
Benno Schulenberg
e2c61d83ef tweaks: change do_para_end() to not step beyond end of paragraph
Not stepping beyond the last line of the paragraph means that the
length of the paragraph is always the difference in line numbers
(between first and last line of the paragraph) plus one.
2018-11-26 09:16:09 +01:00
Benno Schulenberg
9a77c997e2 tweaks: remove two tag definitions that are no longer needed 2018-11-26 09:13:22 +01:00
Benno Schulenberg
2cee79fbbf tweaks: remove a variable that is no longer used
It was made superfluous by David's overhaul of the justify mechanism.
2018-11-26 09:07:22 +01:00
Benno Schulenberg
2c126b201f text: turn the mark off when justifying, to not confuse an undo
When leaving the mark on while justifying and then undoing the
justification, things are likely to get messed up.  My applying
David's patches only partially caused this breakage.

This fixes https://savannah.gnu.org/bugs/?55074.
2018-11-25 20:10:30 +01:00
Benno Schulenberg
2500debbd2 tweaks: don't bother zeroing the x position when doing a full justify
The x position of the cursor is irrelevant when doing justifications.
2018-11-25 15:23:24 +01:00
Benno Schulenberg
500c41b83b tweaks: move the check for beginning-of-paragraph to a better place
Only the first search for a paragraph needs to check whether we're
currently in the middle of a paragraph.  When the 'while' loop for
a full justify is executed, all calls of find_paragraph() start
either on the first line of a paragraph or between two paragraphs.
2018-11-25 15:20:48 +01:00
Benno Schulenberg
2c83047842 tweaks: condense the logic of find_paragraph()
To find a paragraph, what needs to be done is:

  a) When not in a paragraph, move forward until we find one, if any.
  b) When in a paragraph but not at its start, move back to its start.
  c) Move forward to the end of the paragraph, if any.
2018-11-25 13:22:45 +01:00
Benno Schulenberg
5f5682240a tweaks: remove a superfluous check for a special case
The case is handled fine by the rest of the code.  The unnecessary
check wastes some cycles for every call of find_paragraph().
2018-11-25 12:43:29 +01:00
Benno Schulenberg
4a70c1393f tweaks: improve a comment, to better match the changed code 2018-11-25 12:24:57 +01:00
Benno Schulenberg
66cd897dc4 justify: correctly detect when we've reached end of buffer
When, in the 'while' loop for a full justify, 'filebot_inpar' becomes
TRUE, it means that EOF has been reached and find_paragraph() should
not be called again.  To allow 'filebot_inpar' to convey this meaning,
it should not be set to TRUE elsewhere, so another boolean is needed
for setting the correct length of the final line of the cutbuffer.

This fixes https://savannah.gnu.org/bugs/?55086.
2018-11-25 11:57:10 +01:00
Benno Schulenberg
67e6eee26e tweaks: rename two parameters to be more descriptive
Also rename one variable, to be more general, as it does not always
point to a line in a paragraph.
2018-11-22 20:54:22 +01:00
Benno Schulenberg
7ccdb1970a tweaks: elide two unneeded intermediate variables 2018-11-22 20:43:40 +01:00
Benno Schulenberg
539a18e4c7 tweaks: condense and improve a handful of comments, and rewrap two lines 2018-11-22 20:02:29 +01:00
Benno Schulenberg
a7083d632b tweaks: improve a comment, and add an intermediate variable for clarity 2018-11-21 19:49:09 +01:00
David Lawrence Ramsey
44ea37573a docs: remove references to not being able to undo justifications
Any series of justifications (and other edits) is now undoable.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey
d54840c152 text: hook the new justify mechanism up to the undo system
This fixes https://savannah.gnu.org/bugs/?46900.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey
14c085898b text: make do_justify() use the cutbuffer
This is the last preparation for making justifications undoable in
the regular way.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey
fb38995d36 tweaks: adjust some indentation after the previous change 2018-11-20 19:21:35 +01:00
David Lawrence Ramsey
2cdb87ee62 text: remove the old unjustify mechanism, to prepare for the new justify
This leaves two variables unused, but they will be used again two commits
from now, when do_justify() is converted to use the cutbuffer.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey
ba8462a458 text: properly check again for no paragraphs after the current line
The removal of the x-coordinate handling affected this.  Reshuffle things
so that we can check for it after we have moved (the same way we check for
it at the beginning of the function before we move) without having to set
'quote_len' and 'par_len' unnecessarily.

Also, adjust some comments accordingly.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey
4af81823e2 text: make find_paragraph() work on any buffer
Move detecting the final line of the paragraph to find_paragraph(),
since a paragraph of which the final line is the last line of the
buffer will still be that way after being justified.

Also, move all x-coordinate handling to do_justify(), since it only
applies to the current buffer.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey
2c28a22971 text: prepare to make find_paragraph() work on any buffer
Move a few references to the current buffer to do_justify().  Also,
the check for being at the end of the buffer needs to be done after the
first paragraph is found, so that the existing behavior of finding an
initial paragraph regardless of cursor position is preserved.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey
c8e5c85113 moving: make the generic paragraph movement functions work on any buffer
The functions do_para_begin() and do_para_end() can now move through any
buffer, while the functions do_para_begin_void() and do_para_end_void()
operate on the current buffer.  The latter function also returns TRUE
if the last line in the buffer is part of the paragraph.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey
4c0572a799 text: make justify_paragraph() work on any buffer
Remove the handling of 'edittop', 'totsize', and the mark, to make the
function more general, which is needed to make it undoable eventually.

This breaks the function somewhat.  Fixes for this are forthcoming.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey
9aa382e69e text: make justify_format() work on any buffer
The function assumes that it works on the current buffer by handling
'totsize' and the mark.  Remove this handling to make the function
more general, which is needed to make it undoable eventually.

This breaks the function somewhat.  Fixes for this are forthcoming.
2018-11-20 19:21:35 +01:00
Benno Schulenberg
929e1b6809 tweaks: rename a parameter plus a variable, and reshuffle an assignment
Also improve the comment.
2018-11-19 16:54:12 +01:00
Benno Schulenberg
d3f0d32e16 rcfile: don't report an error when the globbing pattern matches nothing
Because a message like "Error expanding EMPTY/*.nanorc: Success"
looks silly.

Indirectly-reported-by: Ντέντος Σταύρος <stdedos@gmail.com>
(https://lists.gnu.org/archive/html/nano-devel/2018-11/msg00044.html)
2018-11-19 12:06:43 +01:00
Benno Schulenberg
3f309bc36a tweaks: rename three variables, and reshuffle two declarations 2018-11-19 11:47:02 +01:00
Benno Schulenberg
2516b64046 tweaks: adjust the indentation after the previous change
Also reshuffle two declarations and improve two comments.
2018-11-14 17:58:34 +01:00
Benno Schulenberg
0ad0dcc926 tweaks: reshuffle some code, to require two fewer ifs 2018-11-14 17:57:20 +01:00
Benno Schulenberg
f81d174f11 rcfile: when a keystroke is rebound, don't bother unbinding it
The new binding will be put at the head of the list and thus will
be the one that is found -- the old binding will never be seen, so
rubbing it out is just a waste of time.
2018-11-14 17:41:32 +01:00
Benno Schulenberg
4fc728b405 build: use wget over https (instead of plain rsync) to fetch PO files
It is the recommended method at the TP.
2018-11-12 19:16:26 +01:00
Benno Schulenberg
8a049e3233 po: update translations and regenerate POT file and PO files 2018-11-11 16:53:55 +01:00
Benno Schulenberg
31fdd2908b bump version numbers and add a news item for the 3.2 release 2018-11-11 16:42:46 +01:00
Benno Schulenberg
2404474dce tweaks: change a bunch of URLs to use 'https' instead of 'http' 2018-11-11 14:46:23 +01:00
David Lawrence Ramsey
5474a9f34b input: properly consume a modified Delete key also in the tiny version
This fixes https://savannah.gnu.org/bugs/?54981.

Bug existed since commit fb8d981b from a month ago.
2018-11-08 18:12:39 +01:00
Benno Schulenberg
4bd423fc92 tweaks: reorder some code to put backward motion before the forward one 2018-11-07 20:48:04 +01:00
Benno Schulenberg
03d10941cc bindings: recognize ASCII DEL as backspace also in viewer and browser
This completes the fix for https://savannah.gnu.org/bugs/?54978.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2018-11-07 20:18:39 +01:00
Benno Schulenberg
cc01bc3edb tweaks: redefine MMOST to exclude MBROWSER, to simplify the bindings 2018-11-07 20:01:03 +01:00
Benno Schulenberg
5f6f8a8083 bindings: stop binding <Bsp> to do_backspace() in the browser menu
Further down, the <Backspace> key is bound to do_page_up() for MHELP
and MBROWSER, so this earlier binding should exclude MBROWSER.

This partially fixes https://savannah.gnu.org/bugs/?54978.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>

Bug existed since version 2.9.2, commit 8581e702.
2018-11-07 19:57:10 +01:00
Benno Schulenberg
e938c24d04 tweaks: renumber a couple of symbols, and reshuffle a bit of code
Also, contract the regex for key strings.
2018-11-07 19:30:04 +01:00
David Lawrence Ramsey
f55a3fabef input: recognize some escape sequences for <Shift+Delete>
Also, hard-bind <Shift+Delete> in the same way as <Backspace>.

This fixes https://savannah.gnu.org/bugs/?54948,
and fixes https://savannah.gnu.org/bugs/?54975.
2018-11-07 19:17:16 +01:00
Benno Schulenberg
7ee07af081 tweaks: reshuffle a couple of conditions, to group things better 2018-11-06 20:56:16 +01:00
Benno Schulenberg
15ec0eb3ee bindings: make <Alt+Up> and <Alt+Down> work also on a Linux console
This fixes https://savannah.gnu.org/bugs/?54964.
2018-11-06 20:55:09 +01:00
Benno Schulenberg
7dad21f4f4 tweaks: don't bother asking ncurses for keycodes for shifted Left/Right
These modified keys have codes by default: KEY_SLEFT and KEY_SRIGHT.
It's just the shifted Up/Down keys that don't have default codes.
2018-11-06 19:18:54 +01:00
Benno Schulenberg
362965b9a3 gnulib: update to its current upstream state 2018-11-05 20:12:39 +01:00
Benno Schulenberg
eaa0f1a122 tweaks: remove an unneeded check for NULL, and rename a parameter
(And if it were NULL, it should crash instead of passing over the bug.)
2018-11-05 13:05:17 +01:00
Benno Schulenberg
9923b073af tweaks: include an extra function call only where it is needed
And fix a typo.
2018-11-05 10:21:17 +01:00
Benno Schulenberg
9d9ae8dc76 tweaks: add two more translator hints 2018-11-05 09:54:06 +01:00
Benno Schulenberg
ca6281e821 tweaks: condense a handful of comments, and drop an assert 2018-11-05 09:38:07 +01:00
Benno Schulenberg
77826c2b06 tweaks: stop setting and requiring the Meta flag for special keycodes
Set the Meta flag only for the regular Meta keystrokes: "M-" plus a
printable ASCII character.  The special keycodes are unique and do
not need any extra flags to differentiate them.
2018-11-04 20:35:15 +01:00
Benno Schulenberg
89760cd6ec tweaks: reshuffle some conditions, putting the least likely one first 2018-11-04 20:34:50 +01:00
David Lawrence Ramsey
f02e2d3b6e input: properly recognize Alt+Delete when using -K/--rebindkeypad
This works for xterm, rxvt, Eterm, Konsole, and xfce4-terminal, which
generate "Esc [ 3 ; 3 ~", but not for urxvt, which generates one of
its double-escape sequences, "Esc Esc [ 3 ~".
2018-11-04 11:47:09 +01:00
Brand Huntsman
252f14796e bindings: hard-bind the zap function to M-Del (Alt+Delete)
So that the function is available in a default setup.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-11-04 11:47:03 +01:00
Brand Huntsman
ae3ec1784d options: add --zap, that makes <Bsp> and <Del> erase a marked region
Using --zap or -Z on the command line, or 'set zap' in a nanorc file,
makes the <Bsp> and <Del> keys erase selected text (a marked region)
as they do in some other editors, and without affecting the cutbuffer.

This fulfills https://savannah.gnu.org/bugs/?54837.
Requested-by: Liu Hao <lh_mouse@126.com>

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-11-04 11:46:57 +01:00
Brand Huntsman
5662a38802 new feature: a bindable 'zap', to erase text without changing cutbuffer
This function allows the user to "make space": annihilating lines or
regions while keeping intact for pasting the stuff in the cutbuffer
that was cut or copied earlier.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-11-04 11:46:19 +01:00
Benno Schulenberg
02eaa4ce6d tweaks: fold a few pairs of regexes into each other 2018-11-03 21:32:07 +01:00
Benno Schulenberg
636e9ac3e8 syntaxes: remove several redundant end-of-line anchors from regexes 2018-11-03 21:12:44 +01:00
Benno Schulenberg
af71d44e4e tweaks: snip trailing whitespace that ended with a non-breaking space 2018-11-03 20:41:42 +01:00
Benno Schulenberg
e9ba058f3d tweaks: elide a function that is used just once and is a oneliner 2018-10-30 19:34:03 +01:00
Benno Schulenberg
9e2a12b62a tweaks: drop a check for the needle (the search string) being empty
No one ever reported seeing this.  And even if the needle were empty,
this is not a problem: it will simply match right away.
2018-10-30 19:18:37 +01:00
Benno Schulenberg
5be94a3bbe debug: report for which modified editing keys ncurses has no keycode 2018-10-30 19:01:39 +01:00
Benno Schulenberg
518a2b4c45 tweaks: remove some old debugging code 2018-10-24 17:41:32 +02:00
Benno Schulenberg
e0d9fee5d6 build: exclude scrolling functions only from tiny version without help
This fixes https://savannah.gnu.org/bugs/?54891.
2018-10-24 17:33:54 +02:00
Benno Schulenberg
065672bf12 tweaks: condense another bit of code 2018-10-24 17:20:30 +02:00
Benno Schulenberg
477f63d8b5 linter: do not pause when there are no messages for unopened files
Return immediately to editing mode when there are no messages for
the original file and the user does not wish to open any of the
included files that do have messages.

Also, reword the message that the linter gives then, and leave it
on the status bar (just like when Cancel is pressed).
2018-10-24 17:14:02 +02:00
Benno Schulenberg
95dd873205 bindings: no longer bind F13 and F14 and F15
The bindings for F1 to F12 are there for compatibility with Pico.
But Pico does not know anything about F13 to F16; for unknown reasons
they were added to nano.  They seem hardly useful: normal keyboards
do not have the F13 to F16 keys, and very few people know that they
can "produce" those keys by holding Shift with F1 to F4.  But typing
Shift plus F1 to F4 are just as "hard" as, for example, M-G and M-W,
so why anyone would want to use the first ones...?  Especially since
many other functions of nano can only be accessed through Meta and
Control combinations.

Furthermore, F13 to F15 haven't been shown in the help texts since
version 2.3.3, so for more than four years no new user will have
learned about those keystrokes.

The rare user who wants these strange bindings can easily make them
herself.
2018-10-23 19:44:22 +02:00
Benno Schulenberg
e901387b72 tweaks: capitalize the word "nano" when at the start of a sentence
As is done in two other messages.
2018-10-23 19:42:07 +02:00
Benno Schulenberg
280ac81b31 display: ensure that the help lines are shown when in linting mode
The help lines will help differentiate this mode from normal editing
mode, and will tell the user how to jump to other messages.

This is a third step to address https://savannah.gnu.org/bugs/?54714.
2018-10-23 19:35:21 +02:00
Benno Schulenberg
b7f53096fb display: use a different color when showing a linting message
This is a second step to address https://savannah.gnu.org/bugs/?54714.
2018-10-23 19:31:40 +02:00
Benno Schulenberg
f7f7767e7d display: let the title bar show when nano is in linting mode
This is a first step to address https://savannah.gnu.org/bugs/?54714.
2018-10-23 19:30:22 +02:00
Benno Schulenberg
91155486c7 docs: document the slightly changed workings of the --view option 2018-10-23 19:29:18 +02:00
Benno Schulenberg
63f2be7a2f options: let view mode activate "multibuffer" to allow viewing more files
When --view is used without --ignorercfiles, the user could view
other files anyway if they had 'set multibuffer' in their nanorc.
So, just make this the default when --view is used, also because
"multibuffer" cannot be toggled once nano is running in view mode.

When the viewing of other files in view mode should not be allowed,
one should now additionally use --restricted.
2018-10-23 19:15:27 +02:00
Brand Huntsman
71de0b9e2f linter: throttle "first"/"last" message on repeated key presses
To avoid stacking up pauses, which would make nano unresponsive
for too long.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-10-22 20:36:00 +02:00
Benno Schulenberg
b8c51329f6 linter: for "first"/"last", reshow actual message after a short pause
This fixes https://savannah.gnu.org/bugs/?54754.
2018-10-21 17:57:28 +02:00
Benno Schulenberg
bab5eeb808 bindings: allow using <Enter> to exit from the linter
Understand the key as: "Enter into editing mode on the current line".
2018-10-21 17:55:17 +02:00
Brand Huntsman
d342cbbff8 display: make all dying messages end in a newline
So that the following shell prompt will not be glued onto the message
but will be on a line by itself.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-10-21 17:27:58 +02:00
Benno Schulenberg
5c5806bbe7 wrapping: make the --fill option override 'set fill' again
This completes the reverting of commit e90b7cf4 as intended by the
previous commit.
2018-10-21 17:24:20 +02:00
David Lawrence Ramsey
16a3dc90c7 wrapping: make relative fill values work again also for screen resizes
The 'wrap_at' variable, removed in commit e90b7cf4, is actually needed
to store the original value of the --fill option when it is negative.
Otherwise, changing the screen width will not update the wrapping point
properly.

This fixes https://savannah.gnu.org/bugs/?54861.
Reported-by: Brand Huntsman <alpha@qzx.com>
2018-10-18 20:35:49 +02:00
Benno Schulenberg
769a0e661f tweaks: reduce some repetitious and superfluous comments to just one
The code itself is clear enough.
2018-10-16 19:22:40 +02:00
David Lawrence Ramsey
6ed0a12d80 tweaks: join two lines, and add a clarifying comment 2018-10-16 19:18:58 +02:00
David Lawrence Ramsey
dda9d4e357 input: don't detect <Ctrl+Shift+Delete> on Linux console in tiny version 2018-10-16 19:15:33 +02:00
Benno Schulenberg
c43177487a help: pull "Older" and "Newer" into view on an 80-column terminal
The ^P and ^N keystrokes for Older and Newer are relevant to searching
and should be visible in the help lines.  FullJustify, paragraph jumps,
and top/tail jumping are there only for compatibility with Pico but
don't make any sense there, so it's no problem if they are pushed out
of view.
2018-10-15 17:33:51 +02:00
Benno Schulenberg
f442f91187 bindings: rename 'prevhistory' to 'older' and 'nexthistory' to 'newer'
Rename not only the bindable functions, but more importantly reword the
tags that are shown for ^P and ^N in the help lines: "Older" / "Newer",
because these are clearer and not awkward abbreviations.
2018-10-15 17:31:40 +02:00
Benno Schulenberg
33d67d5cee docs: give suggestions for alternative key bindings in the sample nanorc 2018-10-15 17:19:40 +02:00
Benno Schulenberg
a4e7d6b80b tweaks: define a symbol to make the code itself a little simpler 2018-10-15 16:55:36 +02:00
David Lawrence Ramsey
06416e3d5c tweaks: don't define controldelete or controlshiftdelete in tiny version
The tiny version never uses them because it doesn't know word deletion.
2018-10-15 16:52:01 +02:00
Benno Schulenberg
e1c8dd0091 build: fix compilation when configured with --disable-multibuffer
Commit 7ea6d6bb from five days ago caused this breakage.
2018-10-12 12:32:21 +02:00
Benno Schulenberg
b167444ee8 tweaks: remove a check that was made redundant by the previous commit
The previous commit also fixes https://savannah.gnu.org/bugs/?54650,
so the change that was made to address that bug can be removed.
2018-10-12 12:23:44 +02:00
Benno Schulenberg
6b08648377 feedback: give proper message for ^R when combining --view & --restricted
When using --view --multibuffer --restricted, it is the latter option
that forbids reading in another file, so that is what the status bar
should say.

This fixes https://savannah.gnu.org/bugs/?54824.

Bug existed since version 2.9.5, commit 8b8c6bb8.
2018-10-12 12:04:39 +02:00
Benno Schulenberg
8c456423e9 display: correct a mistaken label in the help lines of the browser
This was a second pasting mistake made in commit 0c263bda, a good
two months ago.
2018-10-09 21:54:54 +02:00
David Lawrence Ramsey
53865ced9d weeding: remove the 'active' parameter from spotlight()
After the previous change, it is always TRUE and thus pointless.
2018-10-09 20:03:52 +02:00
David Lawrence Ramsey
c2e4f77594 display: do spotlighting as part of drawing the screen
When something is spotlighted, it should survive a refresh of
the screen and an excursion to a help text, so the spotlight
should get painted whenever the edit window is drawn.

This fully fixes https://savannah.gnu.org/bugs/?54721.
2018-10-09 20:03:47 +02:00
Benno Schulenberg
7ea6d6bbda bindings: in tiny version with help, don't show unfunctional M-◀ and M-▶
The code for recognizing those keystrokes is not present in the tiny
version, so there is no point in binding anything to them.
2018-10-07 15:51:21 +02:00
Benno Schulenberg
e4f5848425 tweaks: move all the function keys to the end of the shortcuts list
To have them grouped together, but also so that keystrokes that are
used more commonly are found slightly quicker.
2018-10-07 14:42:42 +02:00
Benno Schulenberg
ddd033adaf docs: remove a no-longer-needed suggestion from the sample nanorc
It would result in having both <Delete> and <Backspace> behaving as
Backspace, which seems senseless -- unless the <Delete> key produces
ASCII DEL and --rebinddelete is needed to make it behave as Delete.
In the latter case it would make more sense if --rebinddelete made
both rebindings: ASCII DEL to Delete and KEY_DC to Backspace, like
it used to be in the distant past, before commit 79a33bb3.
2018-10-07 14:27:54 +02:00
Benno Schulenberg
233a0807ec tweaks: remove a stray file that was accidentally comitted
It was mistakenly added in commit fb8d981b, two days ago.
2018-10-07 11:40:24 +02:00
Benno Schulenberg
f9134af504 docs, usage: mention that --showcursor now covers help texts too 2018-10-07 10:38:11 +02:00
Benno Schulenberg
10d9742c11 display: show the cursor also in a help text (when --showcursor is used)
The cursor can function as a reading aid for people with poor vision.

This fulfills https://savannah.gnu.org/bugs/?54654.
Requested-by: Ben Key <benk1976@yahoo.com>
2018-10-07 10:26:27 +02:00
Benno Schulenberg
2a894213e0 tweaks: group a series of related variables together 2018-10-07 10:24:19 +02:00
Benno Schulenberg
826be439db bindings: make the Shift+arrow keys work by default on more terminals
Ask ncurses for the codes for the Shift+arrow keys, so that also
<Shift+Up> and <Shift+Down> can be recognized, for which ncurses
doesn't have standard codes.

This fixes https://savannah.gnu.org/bugs/?54790.
Reported-by: Javier Valencia <javiervalencia80@gmail.com>
2018-10-07 10:17:10 +02:00
Benno Schulenberg
8bffc8ea53 tweaks: add a comment, and correct an indentation 2018-10-05 20:32:02 +02:00
Benno Schulenberg
fb8d981bfa tweaks: exclude word-deletion keystrokes from the tiny version
Because word deletion is not available there.
2018-10-05 19:24:38 +02:00
Benno Schulenberg
915064870f tweaks: swap and reword two bullet points in the rnano manpage 2018-10-03 19:56:03 +02:00
David Lawrence Ramsey
401c49e611 docs: update rnano manpage, as -R/--restricted now reads nanorc
This fixes https://savannah.gnu.org/bugs/?54770.
2018-10-03 19:50:40 +02:00
Benno Schulenberg
eb9111a575 docs: update the description of -R/--restricted, as it now reads nanorc 2018-10-02 19:30:51 +02:00
Benno Schulenberg
9c2b67231e tweaks: rename a flag, to match the name of the option 2018-10-02 19:18:55 +02:00
Benno Schulenberg
b81995af8a options: --ignorercfiles is now available in restricted mode
Also, allow syntax highlighting to be toggled in restricted mode,
and adjust a comment.
2018-10-02 19:18:55 +02:00
Benno Schulenberg
339e0c131a tweaks: rename a bunch of variables, to make it clearer what they contain 2018-10-02 19:18:55 +02:00
Benno Schulenberg
2ee2407e63 tweaks: reshuffle some lines, to put things in order of option name 2018-10-02 19:18:55 +02:00
Benno Schulenberg
5ca444e5df startup: allow reading nanorc in restricted mode, to permit customization
Move the unsetting of some options further down, to prevent the user's
nanorc enabling things that are not permitted in restricted mode.

Also, in restricted mode, suppress error messages about functions not
being present in the requested menus, so that a nanorc that is valid in
normal mode does not cause unnecessary messages when using --restricted.

This fulfills https://savannah.gnu.org/bugs/?54732.
Requested-by: Mark Webb-Johnson <mark@webb-johnson.net>
2018-10-02 19:18:55 +02:00
Benno Schulenberg
d245b07c25 tweaks: remove a now-unused parameter from four functions 2018-10-01 19:56:32 +02:00
Benno Schulenberg
d66a68166d tweaks: move some calls of edit_redraw() to where they are needed
Only when actually moving the cursor does the screen need to be redrawn,
not when the wrapped functions are called in other places.
2018-10-01 19:55:06 +02:00
David Lawrence Ramsey
13a4f3130d tweaks: normalize the indentation of the shuffled code
And remove some superfluous braces.
2018-09-30 20:47:08 +02:00
David Lawrence Ramsey
b32deee382 tweaks: move the justifying of a single paragraph into its own function
The new function, justify_paragraph(), takes a quote length and a
paragraph length (which it should get from find_paragraph()), and
runs the paragraph at (current, current_x) through justify_format().
2018-09-30 20:47:08 +02:00
David Lawrence Ramsey
076bc31ce5 tweaks: simplify by using a 'do/while' loop instead of 'while (TRUE)'
The do/while loop will run once when doing a justify, and enough times
for the entire file when doing a full-justify.
2018-09-30 20:47:08 +02:00
David Lawrence Ramsey
22c8ef6c39 tweaks: reshuffle some code to avoid several checks for having justified
Move some fragments out of the justifying loop, and adjust/clarify comments
to account for the changes.  This will allow some of the code to be cleaned
up and simplified in the next commits.
2018-09-30 20:47:08 +02:00
Benno Schulenberg
c8852aa5e2 help: add a relevant explanatory text for the linter
This fixes https://savannah.gnu.org/bugs/?54713.
2018-09-30 20:46:05 +02:00
David Lawrence Ramsey
5f1b618a5a syntax: nanohelp: properly color the keystroke "Sh-^Del"
This fixes https://savannah.gnu.org/bugs/?54758.
2018-09-30 20:40:20 +02:00
Benno Schulenberg
52ba76b2a2 help: show <PgUp> and <PgDn> instead of F7 and F8 for pagewise scrolling
The dedicated editing keys make sense, whereas the function keys are
bound only for compatibility with Pico.
2018-09-30 14:19:12 +02:00
Benno Schulenberg
5bb2b5c08a help: move the linter to the end, to restore pairing in the help lines
Items that are (vaguely) related should be one above the other.
2018-09-30 14:12:42 +02:00
Benno Schulenberg
062b6691bb tweaks: drop the checking of two flags that can no longer be toggled
Also, remove a superfluous condition, and swap two others.
2018-09-30 13:11:43 +02:00
Benno Schulenberg
f4c958e810 bindings: allow using ^X to exit from the linter
One can use ^X to exit from the file browser and from the help viewer,
so...  For symmetry.
2018-09-29 09:59:30 +02:00
Benno Schulenberg
4b32c62674 tweaks: reshuffle some lines to get standard order (first up, then down) 2018-09-29 09:46:05 +02:00
Benno Schulenberg
b4b9e9b012 linter: allow using <Ctrl+Up> and <Ctrl+Down> to jump to other message
These are more "natural" keystrokes for jumping than <PgUp> and <PgDn>.
2018-09-29 09:42:25 +02:00
Benno Schulenberg
0b63de335e tweaks: elide a wrapper function that is no longer useful 2018-09-28 20:09:12 +02:00
Benno Schulenberg
628eef28b3 bindings: make the linter separately accessible, through M-B by default
This allows running the speller (default binding: ^T) also on files for
which a linter has been defined.  This makes it possible to spell check
comment blocks in source files, for example.

This fulfills https://savannah.gnu.org/bugs/?54711.
Requested-by: Mike Frysinger <vapier@gentoo.org>
2018-09-28 20:08:59 +02:00
Benno Schulenberg
600295a3af bindings: when implanting a string, make sure to use positive values
This fixes https://savannah.gnu.org/bugs/?54712.
2018-09-28 19:51:53 +02:00
David Lawrence Ramsey
bed997171c speller: restore the mark coordinates slightly later
To avoid a confusing mishighlighting of just part of a marked region.

This partially addresses https://savannah.gnu.org/bugs/?54721.
2018-09-26 19:45:38 +02:00
Benno Schulenberg
8d0b7a490d undo: move another piece of checking to the two places that need it
And in the bargain get rid of a function that is used just once.
2018-09-26 19:25:21 +02:00
Benno Schulenberg
efa323ec88 tweaks: improve two comments, and reshuffle a line for consistency
(Line number first, x position second.)
2018-09-25 20:26:26 +02:00
Benno Schulenberg
4c6ec6377f undo: move some special checking code to the one place that needs it
Only for BACK and DEL was the first call to update_undo() -- all other
types of action would call add_undo() first, so for them the action in
update_undo() would never be different, but the line number might have
changed (like for ENTER and INSERT), so for them exceptions needed to
be made, which was wasteful.

This addresses https://savannah.gnu.org/bugs/?54728.
2018-09-25 18:09:28 +02:00
Benno Schulenberg
c545438a5f bindings: drop M-| as a keystroke for 'cutwordleft' -- set it free again
The binding was made only to have *something* bound by default to the
'cutwordleft' function.  But now that <Ctrl+Shift+Delete> is available
*and* visible in the help text, the M-| binding is superfluous.
2018-09-23 20:21:57 +02:00
Benno Schulenberg
e998814bbc help: show the keystroke <Ctrl+Shift+Delete> as "Sh-^Del"
And in the bargain always return a fixed code instead of searching for
a keystroke that is bound to 'cutwordleft' (which might fail).
2018-09-23 19:57:04 +02:00
Benno Schulenberg
fe6cb6e516 bindings: recognize <Ctrl+Shift+Delete> also on a Linux console
This fixes https://savannah.gnu.org/bugs/?54716.
2018-09-23 19:43:27 +02:00
Benno Schulenberg
be69a7c299 tweaks: rename a variable, to be a bit more fitting 2018-09-23 14:51:40 +02:00
Benno Schulenberg
33b576c289 speller: remove a pointless message -- it is never seen
When using the internal spell checker, the message gets overwritten
immediately by "Creating misspelled word list...", and when using
the external spell checker, nano immediately exits from curses mode
and thus the message disappears (when in a terminal emulator) or it
soon gets wiped by the spell checker (when on a Linux console), thus
creating a little flash on the bottom row, which we can do without.
2018-09-23 14:41:25 +02:00
Benno Schulenberg
1f39f60b2f tweaks: there is no reason to block SIGWINCHes while waiting for speller
In the past, SIGWINCHes were responded to immediately (which was madness),
but since commit 75d64e67 all a SIGWINCH does is set a flag so that, when
the time comes to update the screen, nano knows the dimensions may have
changed.  The mentioned commit removed most blockings and unblockings of
SIGWINCH, but not this one.
2018-09-23 14:07:36 +02:00
Benno Schulenberg
818ee3e68c help: restore the blank line between manipulation and position stuff
This separation line was lost when the 'formatter' command was removed
in commit 975b4912.
2018-09-23 12:57:56 +02:00
Benjamin Mintz
790f98560b syntax: python: do not highlight 'print' and 'exec' in Python 3
Assume that 'print' and 'exec' are statements when they are followed
by whitespace, and are functions otherwise.  This does not highlight
"print'x'" nor "print{x}", but these statements are poor style.

Signed-off-by: Benjamin Mintz <bmintz@protonmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-09-20 20:45:01 +02:00
Benno Schulenberg
d718ed4fc3 build: verify that --enable-tiny compiles before allowing a release 2018-09-20 20:09:54 +02:00
Benno Schulenberg
368ec04870 build: fix compilation again when configured with --enable-tiny
Reported-by: Jordi Mallach <jordi@mallach.net>
2018-09-19 20:36:39 +02:00
Benno Schulenberg
ce94cb1dc6 po: update translations and regenerate POT file and PO files 2018-09-18 19:39:06 +02:00
Benno Schulenberg
031f255ffd bump version numbers and add a news item for the 3.1 release 2018-09-18 19:27:31 +02:00
Benno Schulenberg
e8a5665d2c bindings: make ^H rebindable also on NetBSD, FreeBSD and macOS
So that the user can do 'bind ^H cutwordleft all' in their nanorc
to make ^H (and sometimes also <Ctrl+Backspace>) delete the word
to the left of the cursor while <Backspace> continues to delete
just one character.
2018-09-18 19:14:05 +02:00
Benno Schulenberg
65e4784eec bindings: bind ASCII DEL during startup instead of repeatedly at runtime 2018-09-18 19:14:05 +02:00
Benno Schulenberg
e2051a61e0 syntax: sh: let the header regex match also busybox shell scripts
And recognize calls via 'env' too.

This addresses https://savannah.gnu.org/bugs/?54674.
Reported-by: Aaron Sears <geodelic@gmail.com>
2018-09-18 19:06:11 +02:00
Benno Schulenberg
a8fa0a82c4 tweaks: rename a variable to be special and distinct 2018-09-17 20:35:13 +02:00
Benno Schulenberg
d19169c263 tweaks: condense a bit of code 2018-09-17 20:32:48 +02:00
Benno Schulenberg
4e7b92ed4c tweaks: sharpen an optimization, to allow DEL to be a shortcut 2018-09-16 19:21:27 +02:00
Benno Schulenberg
eaeafe29ca suspension: don't try to show the cursor position when going to sleep
As the statusbar() function will write the position directly to the
terminal when not in curses mode, the final part of this position
message will seem to be after the prompt when exiting from nano.

The cursor position will get written correctly to the status bar
anyway, because returning from suspension enters a fake key into
the keyboard buffer, and this key elicits an update of the display.

This fixes https://savannah.gnu.org/bugs/?54639.
Reported-by: Lauri Kasanen <cand@gmx.com>

Bug existed since version 2.4.2, commit 75d64e67.
2018-09-13 19:55:20 +02:00
Benno Schulenberg
fe3a72ce3e main: allow toggling all editor features when in view mode
Most of these toggles just change the appearance of things, and
all of them are harmless -- none of them modify the contents of
the buffer.

This fixes https://savannah.gnu.org/bugs/?54650.
Reported-by: Liu Hao <lh_mouse@126.com>

Bug existed since version 2.9.4, commit 54103d8e.

(The offending commit meant in the previous commit was 60f1090d.
My mistake.)
2018-09-12 19:54:32 +02:00
Liu Hao
6cd53e7f44 search: disallow switching to the Replace prompt when in view mode
Switching to Replace allows modifiying the buffer, which should
not be possible in view mode.

This fixes https://savannah.gnu.org/bugs/?54649.

Bug existed since version 2.9.4, commit 54103d8e.

Signed-off-by: Liu Hao <lh_mouse@126.com>
2018-09-12 19:22:08 +02:00
Benno Schulenberg
b84d7bf7a5 input: keep the cursor in edit window after message, also on NetBSD
This fixes https://savannah.gnu.org/bugs/?54632.
2018-09-12 15:22:53 +02:00
Benno Schulenberg
6840205e84 tweaks: remove a superfluous comment and a redundant assignment 2018-09-12 15:07:44 +02:00
Benno Schulenberg
3c5e5d4b6f input: recognize the sequences for Ctrl+Shift+Delete on xterm and urxvt
This fixes https://savannah.gnu.org/bugs/?54648.
2018-09-12 15:04:59 +02:00
Benno Schulenberg
09ab2e3d0e bindings: when Ctrl+Shift+Delete has no keycode, don't use KEY_BSP
When curses gives no code for Ctrl+Shift+Delete, do not fall back
to KEY_BACKSPACE, because then ^H and/or <Backspace> get bound to
'cutwordleft'.

This fixes https://savannah.gnu.org/bugs/?54642.

Bug was introduced with version 3.0, commit e6429e78.
2018-09-12 14:34:50 +02:00
Benno Schulenberg
5b1229599e po: update translations and regenerate POT file and PO files 2018-09-09 11:50:47 +02:00
Benno Schulenberg
8efdd08a86 bump version numbers and add a news item for the 3.0 release 2018-09-09 11:29:00 +02:00
Benno Schulenberg
27d2db2d1f tweaks: improve a couple of comments in the sample nanorc 2018-09-09 10:14:04 +02:00
Benno Schulenberg
571676eb85 docs: improve a comment about rebinding <Backspace>
And move it up, to give the now-final comment a bit more prominence.
2018-09-09 08:33:23 +02:00
Benno Schulenberg
9e71de12cd tweaks: improve a translator hint and some other comments 2018-09-09 08:17:22 +02:00
Benno Schulenberg
c7affe17c0 build: fix compilation again when configured with --enable-tiny 2018-09-08 12:24:12 +02:00
Benno Schulenberg
e21ce0db1f cutting: when deleting whole words, don't join lines unexpectedly
That is, wait with deleting words until they start under cursor,
so the user can see which word is goin to be eaten, and join lines
only when the cursor already sits at the edge of a line.
2018-09-07 19:35:01 +02:00
Benno Schulenberg
e6429e782a bindings: hard-bind <Ctrl+Shift+Delete> to 'cutwordleft'
On FreeBSD and NetBSD (when reached through ssh from a Linux machine)
this has the absurd effect of making <Ctrl+Backspace> do a 'cutwordleft'
by default, out of the box, without needing any rebindings.  Weird, but
wonderful, because the ideal behavior.

Also ensure that <Shift+Delete> always does a Backspace.

This makes that we have the following set of "congruent" keys:

  <Tab> moves text to the right,
  <Shift+Tab> moves text to the left,
  <Delete> "eats" a character to the right,
  <Shift+Delete> "eats" a character to the left,
  <Ctrl+Delete> "eats" a word to the right,
  <Shift+Ctrl+Delete> "eats" a word to the left.
2018-09-07 19:31:38 +02:00
Brand Huntsman
3270aac7db input: give feedback for all unbound keys also in the help viewer
Silently doing nothing robs the user of a bit of information.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-09-01 10:05:23 +02:00
Mark-Weston
13615d0953 build: fix compilation when CC=tcc
Signed-off-by: Mark-Weston <markweston@cock.li>
2018-08-31 20:06:08 +02:00
Benno Schulenberg
921f8ae4c9 syntax: default: colorize also two-digit and capitalized nano versions 2018-08-30 19:46:34 +02:00
Benno Schulenberg
24487d48ff tweaks: adjust one more translator hint, for removed toggles 2018-08-29 20:25:57 +02:00
Benno Schulenberg
388cd0b514 tweaks: remove two needless words, and split up a changed text further 2018-08-29 20:21:20 +02:00
Benno Schulenberg
33c4bb22d5 tweaks: adjust some translator hints for past changes, and add two more 2018-08-29 20:20:43 +02:00
Brand Huntsman
6e80772311 tweaks: correct four spaces of indentation to a tab, in two places
Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-08-29 18:01:21 +02:00
Benno Schulenberg
5f00b02f7c tweaks: fix a pasting error from a month ago 2018-08-28 21:39:01 +02:00
Benno Schulenberg
c6bdc46bb0 gnulib: update to its current upstream state 2018-08-28 20:21:17 +02:00
Mark-Weston
bf5949395d syntax: lua: do not color strings inside comments, and add a linter
Also, don't partially color "..." as an operator, because it isn't,
and color also the unary operator "#".

Signed-off-by: Mark-Weston <markweston@cock.li>
2018-08-28 20:16:16 +02:00
Benno Schulenberg
a18b48f0f7 help: for ^R^X, mention that the buffer can be piped to the command 2018-08-28 20:09:31 +02:00
Brand Huntsman
25e9877607 statusbar: elevate three messages to an ALERT, to make them more visible
Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-08-28 20:02:59 +02:00
Benno Schulenberg
c524fbe6d0 tweaks: remove some ineffectual parts from header-line regexes
Adding "[abc]*" does not restrict the recognized header line in any way.

Also, improve the header-line regex for shell scripts, because it should
not match "barunscript" (for example).
2018-08-28 19:53:36 +02:00
David Lawrence Ramsey
93c8e316a8 justify: verify being in a paragraph before trying to find its beginning
If find_paragraph() detects that we're not in a paragraph, it moves
forward a paragraph and then backward to that paragraph's beginning.
Make it check whether we're in a paragraph before moving backward
(since there might not *be* any more paragraphs), to prevent going
forth-and-back and never reaching the end of the buffer.

This fixes https://savannah.gnu.org/bugs/?54573.
2018-08-27 20:27:02 +02:00
Benno Schulenberg
80bea3eb9b docs: slightly reword the description of four bindable functions 2018-08-26 09:41:27 +02:00
Brand Huntsman
b5ede4ff65 tweaks: remove the 'bright' field from the colortype struct
Put the corresponding value into the 'attributes' field sooner.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-08-25 10:54:20 +02:00
Benno Schulenberg
63b15275bd bindings: remove the More-Space toggle entirely
It is so unlikely that a user will want to bind it that it
just clutters the help text (and the documentation).
2018-08-25 10:10:27 +02:00
Benno Schulenberg
772c324f25 bindings: remove backup and new-buffer toggles (M-B, M-F) from main menu
These are available in the menus where they are relevant: the Write-Out
and the Insert menu, respectively.  Having them duplicated in the main
menu is inconsistent and eats precious keystrokes.  (Sorry, Chris.)
2018-08-25 10:07:28 +02:00
Benno Schulenberg
f1e5872e6a tweaks: reshuffle the order of the bindings, for help-line esthetics 2018-08-25 10:06:13 +02:00
Benno Schulenberg
bc42ae42a9 docs: the 'noconvert' bindable function was renamed to 'flipconvert'
Also, move it to sit with the other toggles of the Insert menu, and
remove its mention from among the main-menu toggles.
2018-08-25 10:05:21 +02:00
Benno Schulenberg
6d62682ddb bindings: move the noconvert toggle from the main to the insert menu
Also add feedback, so that it will be clear whether a file will be
inserted unconverted or not.

This addresses https://savannah.gnu.org/bugs/?54536.
2018-08-25 10:04:03 +02:00
Benno Schulenberg
8d6b205e4c tweaks: remove a superfluous condition and a redundant refresh
When 'inhelp' is true, there are at least two buffers open: an
edit buffer and the help-text buffer.

And bottombars() already does a full refresh of the bottom window.
2018-08-22 18:10:55 +02:00
David Lawrence Ramsey
03f9761c35 undo: store the correct cursor position after a paired cut+insert
And restore the cursor to this position when redoing the cut+insert.

Also remove two unneeded conditions.

This fully fixes https://savannah.gnu.org/bugs/?54466.
2018-08-21 19:21:14 +02:00
Benno Schulenberg
ec339d3b08 filtering: wait for the data-sending process to terminate too
When piping the buffer (or the marked region) to an external command,
we should wait not only for the external command to terminate but also
for the data-sending process, so that it will release its resources.

This fixes https://savannah.gnu.org/bugs/?54499.

With-help-from: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2018-08-20 19:46:38 +02:00
Benno Schulenberg
3218d8358a tweaks: remove a redundant "struct" word, and replace it in comments 2018-08-20 19:33:31 +02:00
Benno Schulenberg
a3a10dfafe tweaks: don't bother having debug code that deallocates all memory
Who runs debug builds for any length of time?
2018-08-18 11:00:03 +02:00
Benno Schulenberg
850e538ff7 syntax: python: avoid coloring the three special values inside strings
Reported-by: Benjamin Mintz <bmintz@protonmail.com>
Suggested-by: Brand Huntsman <alpha@qzx.com>
2018-08-16 19:56:01 +02:00
Benno Schulenberg
18419b5e3f syntax: awk: recognize any {g,m,n,}awk script also by its shebang line
This fulfills https://savannah.gnu.org/bugs/?54516.

Suggested-by: Javier Valencia <javiervalencia80@gmail.com>
2018-08-15 20:20:22 +02:00
David Lawrence Ramsey
07447f3278 undo: restore the cursor position when a cut and paste are paired
When undoing/redoing an alternate spell check (of the entire file
or of a backwards marked region), put the cursor back where it was
when the spell check was invoked/finished.

This fixes https://savannah.gnu.org/bugs/?54466.
2018-08-15 19:58:46 +02:00
David Lawrence Ramsey
fd65f74428 undo: always initialize the 'newsize' element in the undo struct
So that do_redo() cannot set the file size to a "random" value.

This fixes https://savannah.gnu.org/bugs/?54478.
2018-08-11 10:07:20 +02:00
Benno Schulenberg
e40e6bbf10 tweaks: rename a function to better match its counterpart
Also rename its parameter, to describe what it ought to be.
2018-08-11 09:55:22 +02:00
Benno Schulenberg
2147e161bf rcfile: when a vital function is not mapped, mention in which menu
Add the reverse of the name-to-menu function to accomplish this.

This fixes https://savannah.gnu.org/bugs/?54449.
2018-08-11 09:46:03 +02:00
Benno Schulenberg
dc079bdf31 tweaks: implement the name-to-menu function in another manner
Use arrays, to make it easy to also implement the reverse function.
2018-08-11 09:45:02 +02:00
Benno Schulenberg
8560a0a225 docs: mention that "normal" can be used to give things the default color 2018-08-10 19:42:31 +02:00
Benno Schulenberg
52d851a1aa startup: don't overwrite rcfile error messages on a Linux console
On a Linux VT, refuse to start when there are errors in a nanorc file,
so that the messages no longer get overwritten -- which prevented the
user from seeing and reading them.

This fixes https://savannah.gnu.org/bugs/?54442.
2018-08-10 19:41:54 +02:00
Benno Schulenberg
2d434f63e2 syntaxes: remove all traces of the 'formatter' command 2018-08-09 21:12:10 +02:00
Benno Schulenberg
5c179aae7d docs: mention that the 'formatter' command has been superseded 2018-08-09 20:29:30 +02:00
Benno Schulenberg
975b491235 dropping a feature: remove the ability to use the 'formatter' command
Since the last version, the user can filter an entire buffer through
an external command.  This external command can also be a formatting
program, so there is no longer any need for this specific and special
formatter command.
2018-08-09 20:29:30 +02:00
Benno Schulenberg
94b4f07281 tweaks: adjust indentation after the previous change
Also improve a couple of comments.
2018-08-08 19:53:05 +02:00
Benno Schulenberg
61b4eeda66 speller: do not replace the text when the temporary file did not change 2018-08-08 19:44:40 +02:00
Benno Schulenberg
667fcea65e undo: differentiate between general filtering and spell checking
With-help-from: David Lawrence Ramsey <pooka109@gmail.com>
2018-08-07 20:42:39 +02:00
David Lawrence Ramsey
c39c9c241b undo: actually enable undoing/redoing an alternative spellcheck
Make sure the inserts of the spell-checked text are undoable, and no
longer discard the undo stack after running the alternate spell checker.
2018-08-07 20:41:05 +02:00
David Lawrence Ramsey
115f089d5f speller: hook up a marked-text alternative spellcheck to the undo system 2018-08-07 20:39:50 +02:00
David Lawrence Ramsey
7f6460b804 speller: hook up a full alternative spellcheck to the undo system 2018-08-07 20:39:13 +02:00
David Lawrence Ramsey
bc6787826a speller: make replace_marked_buffer() use the cutting functions directly 2018-08-07 20:38:50 +02:00
David Lawrence Ramsey
b5f15cb574 speller: make replace_buffer() use the cutting functions directly 2018-08-07 20:38:21 +02:00
Benno Schulenberg
4c66a6259c tweaks: slightly improve error message when vital function is unmapped
This fails to fix https://savannah.gnu.org/bugs/?54449, because
it would take far too much code for an exceptional case.
2018-08-06 19:35:47 +02:00
Benno Schulenberg
db1893ef2d syntax: nanorc: recognize 'yesno' as a valid menu to bind/unbind keys in 2018-08-06 18:05:10 +02:00
Benno Schulenberg
ad79a4fcfb rcfile: ensure that in the yesno menu Cancel is bound to some keystroke
(In the Search and Replace menus Cancel is not essential.  And in the
Goto Line menu Cancel is not needed at all: a simple <Enter> after an
empty answer works fine.)

This fixes the second part of https://savannah.gnu.org/bugs/?54447.
2018-08-05 20:11:48 +02:00
Benno Schulenberg
418bd3be34 rcfile: allow to rebind the Cancel function in the yesno menu
This fixes the first part of https://savannah.gnu.org/bugs/?54447.
2018-08-05 20:01:47 +02:00
Benno Schulenberg
4170454837 tweaks: exclude a global flagging variable when it is not needed 2018-08-05 13:00:44 +02:00
Benno Schulenberg
e90b7cf4aa tweaks: elide an unneeded/duplicate variable 2018-08-04 11:34:44 +02:00
Benno Schulenberg
bb90de0eb4 tweaks: rename a constant, to match what it actually means
Wrapping is concerned with columns, not with number of characters.
2018-08-04 11:21:42 +02:00
Benno Schulenberg
157c7b1bc4 rcfile: explicitly check for disallowed keywords in included files
This fixes https://savannah.gnu.org/bugs/?54441.
2018-08-04 07:29:36 +02:00
Benno Schulenberg
ac102a7516 tweaks: show "Space" and "Bsp" in the help text of the browser
These keys make more mnemonic sense for scrolling than F7 and F8.

Also adjust the nanohelp syntax to cover the lone word "Space".
2018-07-31 20:36:32 +02:00
Benno Schulenberg
d249233ea7 bindings: unassign the M-? keystroke, to free it up for future use
There are at least three other ways to achieve the thing that it did:
^End, M-/, and ^W^V.  No need to have a fourth way by default.

For symmetry, also unassign the corresponding binding for M-|.
2018-07-31 20:36:27 +02:00
Benno Schulenberg
33fb54c75f bindings: reassign the M-| keystroke to 'cutwordleft' by default
The 'cutwordright' function has gotten ^Delete as its default binding,
so the 'cutwordleft' function needs a default binding too -- also to
keep the items on the two help lines nicely paired.  M-| was chosen
because it is close to the Backspace key on many keyboard layouts.
2018-07-31 20:36:07 +02:00
Benno Schulenberg
c231b774d7 tweaks: reshuffle some lines, in order to elide one 2018-07-30 21:03:08 +02:00
Benno Schulenberg
0c263bda7d tweaks: elide a bunch of unneeded constant strings 2018-07-30 20:45:15 +02:00
Benno Schulenberg
60ee4408be signals: don't call a print routine in a signal handler
Print routines are not asynchronous-safe.

But... the only reason the call of kill() could return an error code
is when the relevant process has already terminated -- which is not
a problem, because that was the goal of calling kill().

This fixes https://savannah.gnu.org/bugs/?54409.
Reported-by: Daniel Kozovsky <dkozovsk@redhat.com>
2018-07-30 20:22:24 +02:00
Benno Schulenberg
72a590d60a tweaks: rename a variable and a function, for more clarity 2018-07-30 20:07:25 +02:00
Benno Schulenberg
9a47a9c4c0 rcfile, docs: no longer recognize nor mention 'set backwards'
The option has been a no-op since 2.9.0.  And now that the
^W/^Q/M-W/M-Q set is available, 'set backwards' is entirely
outdated.
2018-07-29 21:00:12 +02:00
David Lawrence Ramsey
9c8e40b442 bindings: make "n" work again in file browser and help viewer
Also, "N" shouldn't be a synonym of "n" in tiny mode.
2018-07-29 20:49:56 +02:00
Benno Schulenberg
54a4123d4c bindings: remove the 'searchagain' function entirely
The user is obliged to make use of 'findprevious' and 'findnext' instead.

Also, adjust the description of 'wherewas' to its wider availability.
2018-07-29 11:43:13 +02:00
David Lawrence Ramsey
7a31507167 bindings: make ^Q start a backward search also in the file browser
This makes the four search keystrokes (^W/^Q/M-W/M-Q) available in
all three areas of nano: editor, help viewer, and file browser.
2018-07-29 11:43:13 +02:00
Benno Schulenberg
7f2031006a bindings: make ^Q and M-Q available also in the help viewer
As the help viewer is almost a normal buffer, commands that make sense
-- like searching backwards, and searching the previous occurrence --
should work in the help viewer too.

In addition, show all Search commands prominently in the help lines of
the help viewer, so that users are likely to notice them and will maybe
infer that they work in the editor itself too.

This fixes https://savannah.gnu.org/bugs/?54368.

With-help-from: David Lawrence Ramsey <pooka109@gmail.com>
2018-07-29 11:43:13 +02:00
Benno Schulenberg
7e18b91ead help: move "Search Again" away from "Find Next" and "Find Previous"
Put "Where Was" in its place, to make the symmetry of ^W/M-W/^Q/M-Q
somewhat clearer.  Also, conditionally reshuffle "Save File", to try
and keep menu items nicely paired.
2018-07-29 11:43:13 +02:00
Benno Schulenberg
f82eefa303 tweaks: exclude the file-prepending code from the tiny version
The prepending and appending toggles are not available in tiny nano,
so there is no need to have the code either.
2018-07-24 19:31:03 +02:00
Benno Schulenberg
8e1ce7034d search: include 'findprevious' and 'findnext' in the tiny version
Thus fix a compilation failure when configured with --enable-tiny.

Now M-Q will be functional also in a tiny nano.
2018-07-24 19:19:27 +02:00
Benno Schulenberg
c4d09cc24b text: add auto-whitespace to the file size after creating the undo item
The undo item for ENTER should record the file size *before* the amount
of auto-indentation whitespace is added to it.

This fixes https://savannah.gnu.org/bugs/?54344.
Reported-by: Liu Hao <lh_mouse@126.com>
2018-07-23 17:57:47 +02:00
Benno Schulenberg
d04c8f88f1 docs: say that 'cutwordright' is now bound to <Ctrl+Delete> by default
Also, suggest to rebind ^H to 'cutwordleft' so that <Ctrl+Backspace>
will delete the word to the left of the cursor (on some terminals).
2018-07-22 19:27:50 +02:00
Marco Diego Aurélio Mesquita
a67f6c6031 input: erase the next word when Ctrl is held while pressing Delete
Bind the until-now unbound function 'cutwordright' to <Ctrl+Delete>.
The complementary function, 'cutwordleft', is not bound by default
because on many terminals the keystroke <Ctrl+Backspace> generates
^H -- the canonical ASCII backspace character.  We cannot change the
existing action of ^H without upsetting some users.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-07-22 19:27:50 +02:00
Benno Schulenberg
8d8f5788ce rcfile: do not accept rebinding F0 nor function keys above F16
To match the documentation and to match what the nanorc.nanorc
colors as valid.

In theory it would be possible to allow rebinding also F17...F63,
but nano does not recognize escape sequences for these high-order
function keys.  As no one ever complained about unknown sequences
when pressing function keys, I am guessing that no one has these
high-order keys, or at least that no one uses them.

This fixes https://savannah.gnu.org/bugs/?54332.
2018-07-20 19:12:36 +02:00
Devin Hussey
4a268678a5 syntax: sh: recognize more file extensions and header lines
Signed-off-by: Devin Hussey <husseydevin@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-07-20 19:12:20 +02:00
Benno Schulenberg
7c9a4793dd tweaks: properly escape "\" in a man page and "@" in a texi document
Also make the involved sentences more precise.
2018-07-19 20:17:27 +02:00
Benno Schulenberg
05592a84ec completion: when the cursor is not after a word fragment, say so
Instead of being entirely silent when ^] is hit after whitespace
or punctuation, report what is lacking -- similar to M-] saying
"Not a bracket" when the cursor is not sitting on a bracket.
This makes the ^] keystroke more discoverable.
2018-07-19 19:29:24 +02:00
Benno Schulenberg
c46696d40c tweaks: delete some old debugging code that no longer seems useful 2018-07-18 19:53:44 +02:00
Benno Schulenberg
bfe65af6f3 bindings: bind M-Q to 'findprevious' by default, and M-W to 'findnext'
This makes things symmetrical: ^W starts a forward search, ^Q starts
a backward search, M-W searches the next occurrence forward, and M-Q
searches the next occurrence backward.

The Tabs-To-Spaces toggle is moved to M-O, and thus the More-Space
toggle is no longer bound by default.
2018-07-18 19:18:45 +02:00
Benno Schulenberg
46f5d51fb5 input: fully consume modified PgUp and PgDn keys also in the tiny version
They should not enter a digit plus a squiggle into the buffer.
2018-07-17 18:28:55 +02:00
Benno Schulenberg
b99ec28a60 tweaks: recognize escape sequences of modified Ins/Del more precisely
The third character after the escape must be a semicolon.
2018-07-16 18:45:41 +02:00
Benno Schulenberg
b2acffe5be input: stop <Alt+Insert> from entering "3~" into the buffer 2018-07-16 18:45:21 +02:00
Benno Schulenberg
2fef7f647d input: stop a modified Delete key from entering stuff into the buffer
When using option -K on an xterm-like terminal, pressing <Shift+Del>,
<Alt+Del>, or <Ctrl+Del> would enter "2~", "3~", or "5~", respectively,
into the buffer.  Now it will just report an "Unknown sequence".
2018-07-15 09:22:55 +02:00
Benno Schulenberg
6d3b16b761 tweaks: close a temp file only when descriptor is valid [coverity scan] 2018-07-14 21:33:46 +02:00
Benno Schulenberg
89c0e7493f tweaks: don't call va_start() without calling va_end() [coverity scan] 2018-07-14 21:15:23 +02:00
Benno Schulenberg
14b9a42f5b tweaks: move a call to where it will be executed [coverity scan] 2018-07-14 21:02:32 +02:00
Benno Schulenberg
3227ba46d9 mouse: put the row/column arguments in the proper order [coverity scan]
(This one call was overlooked in commit f5c87a7f that changed the order.)

This makes clicking on the Yes/No/All/Cancel menu items work again.
2018-07-14 20:49:30 +02:00
Benno Schulenberg
d994af0334 tweaks: avoid dereferencing a pointer when it is NULL [coverity scan] 2018-07-14 20:02:03 +02:00
Benno Schulenberg
75c7c35cfd tweaks: use a shorter message, because when the screen is small... 2018-07-14 19:42:38 +02:00
Benno Schulenberg
eb84205426 bindings: rename two bindable functions: copytext to copy, uncut to paste
To match the common names used for these functions, for consistency,
and because 'uncut' sounds too much like "undo the cut".
2018-07-13 19:46:56 +02:00
Benno Schulenberg
c2593c1c5a docs: reshuffle a bindable function to a slightly better position 2018-07-13 19:46:56 +02:00
Benno Schulenberg
d92142c66a easter: show the crawl only when there is room enough for the lines
The crawl needs at least five rows to be perceived as a crawl, and
the widest line is 31 characters (ignoring translations, which might
be even longer).  Formerly, when only two or three rows were available,
nothing was shown at all, which was puzzling.  So, better do the credits
only when there is room enough for them, and print a message otherwise.
2018-07-13 19:45:15 +02:00
Benno Schulenberg
f598a4f12d files: add the file format on the status bar when switching buffers
Suggested-by: Brand Huntsman <alpha@qzx.com>
2018-07-13 11:15:48 +02:00
Benno Schulenberg
063a8b0870 startup: show the correct number of lines when opening multiple files
When switching to a different buffer, don't just show its name but
also the number of lines it contains.  This is useful extra info.

Then use this same message when at startup multiple files are opened
and (after reading them all) we switch back to the first buffer.

(This loses, when multiple files are opened, the information about
format conversion that nano still shows when a single file is opened,
but... this bug has shown that people don't really look at this line
anyway, so... let it be.  The info can still be seen when writing out
the file with ^O.)

This addresses https://savannah.gnu.org/bugs/?54047.
2018-07-13 09:37:04 +02:00
Benno Schulenberg
ecc9211afc input: ignore any <Escape>s before a valid command keystroke
Just like an <Esc> before a Ctrl+letter keystroke is ignored, an <Esc>
before an Alt+letter keystroke should be ignored too -- it should not
be interpreted as if the user had typed <Esc> <Esc> letter.

This fixes https://savannah.gnu.org/bugs/?54301.
2018-07-13 09:27:38 +02:00
Benno Schulenberg
ab0897072a input: consume the whole escape sequence for modified PgUp and PgDn keys
Even when we don't act on most of these combinations, at least eat up
the whole sequence so the unknown keystroke doesn't enter things like
"3~" into the buffer.

This fixes https://savannah.gnu.org/bugs/?54291.
2018-07-13 09:25:01 +02:00
Devin Hussey
b2ff574678 files: speed up reading by using getc_unlocked() instead of getc()
Unlike glibc, which in getc() locks the file only when it is needed,
FreeBSD and Bionic libc will always lock the file, causing a massive
slowdown, as the system has to create and destroy a mutex each time
getc() is called.

Avoid that massive overhead by locking the file before starting to read
and unlocking it after reading is complete, and using getc_unlocked() to
read each byte.  This makes reading on FreeBSD/macOS and Android anywhere
from 2 to 6 times faster, and on glibc roughly seventy percent faster.

This partially addresses https://savannah.gnu.org/bugs/?50406.

Signed-off-by: Devin Hussey <husseydevin@gmail.com>
2018-07-12 12:44:35 +02:00
Benno Schulenberg
3bac3c4c78 rcfile: reject things like "M-Del" and "^{" as invalid key names
This fixes https://savannah.gnu.org/bugs/?54274.
2018-07-11 14:42:10 +02:00
Benno Schulenberg
acadf71b13 syntax: nanorc: show ^@ as validly rebindable, but not any ^digit 2018-07-11 14:14:40 +02:00
David Lawrence Ramsey
4c02329205 docs: mention that "Ins" and "Del" are valid rebindable keys
Also, consistently refer to Latin letters and ASCII characters
where needed, and document more accepted characters.

This addresses https://savannah.gnu.org/bugs/?54071.
2018-07-11 14:10:35 +02:00
Benno Schulenberg
a31896011a tweaks: elide a one-line function -- no, a half-line function 2018-07-11 11:11:30 +02:00
Benno Schulenberg
769504c495 tweaks: rename a function, to better state what it does 2018-07-11 11:03:14 +02:00
Benno Schulenberg
18f13c3a75 tweaks: rename a variable, to better match its task
The 'statusbar_x' variable does not refer to a position in the status
bar, but to a position in the answer that is currently being typed at
the prompt.  So... let's call it 'typing_x', for lots of contrast.
2018-07-11 10:55:59 +02:00
Benno Schulenberg
aea54276b6 tweaks: rename a function and place its call better 2018-07-11 10:48:27 +02:00
Benno Schulenberg
0c455155ad prompt: concentrate manipulations of 'statusbar_x' into a single file 2018-07-11 10:45:58 +02:00
Benno Schulenberg
e6c6a72ee8 tweaks: remove some braces that are now superfluous
Also move a function to a better place: after the function that it calls.
2018-07-11 09:56:39 +02:00
Benno Schulenberg
4a853cf451 prompt: remove redundant redrawings of the prompt bar
The prompt bar is redrawn in acquire_an_answer() for every keystroke,
so there is no need to do this explicitly for some commands.
2018-07-11 09:49:00 +02:00
Benno Schulenberg
078265456c docs: mention that also Ctrl increases the stride when selecting text
The Alt key together with Shift is a special workaround for when
Shift+PgUp and Shift+PgDn don't work on the user's terminal.  But
probably it is more common to use the Ctrl key together with Shift
to select larger pieces of text.  So mention this possibility.
2018-07-10 15:58:41 +02:00
Benno Schulenberg
3ac821ee0c build: fix compilation when configured with --enable-tiny 2018-07-10 15:31:04 +02:00
Benno Schulenberg
ce0ecf67a6 tweaks: elide another function that is used just once 2018-07-10 13:57:05 +02:00
Benno Schulenberg
b6f7ff5c6f tweaks: normalize the indentation after the previous change
And remove two superfluous pairs of braces.
2018-07-10 13:55:51 +02:00
Benno Schulenberg
035b91cb15 chars: make the UTF-8 case ever so slightly faster by eliding an 'if'
And in the bargain get rid of some duplicate code.

This makes a binary without UTF-8 support slightly slower, but that's
not important -- it is more than fast enough anyway.  Important is that
the most used and longest code path, the UTF-8 case, becomes faster.

Note that 'is_cntrl_mbchar()' will fall back to 'is_cntrl_char()' for
a non-UTF-8 build, so the deleted piece of code really was equivalent
with the remaining piece for that case.
2018-07-10 12:22:11 +02:00
Benno Schulenberg
f456794045 tweaks: adjust two comments, to be more accurate and general 2018-07-08 17:40:19 +02:00
David Lawrence Ramsey
20971e8392 undo: position the cursor properly when undoing/redoing magicline cuts
Take our cue from undoing/redoing line joins: when they take place on
the magicline without --nonewlines, they produce undo/redo items that
don't do anything to the text, but still position the cursor properly.
Reshuffle a bit of code so that we can do the same for magicline cuts.

This fixes https://savannah.gnu.org/bugs/?54032.
2018-07-08 17:29:28 +02:00
Benno Schulenberg
fa454abb1c build: verify that 'msgfmt' is available when building from git
Fail during the configure phase when it is not,
instead of failing cryptically during 'make'.

This addresses https://savannah.gnu.org/bugs/?54265.
Reported-by: Peter Passchier <peter@passchier.net>
2018-07-08 14:13:25 +02:00
Benno Schulenberg
f2adefb158 tweaks: drop some old debugging code 2018-07-08 10:45:43 +02:00
Benno Schulenberg
7ae8f3bca4 tweaks: elide a function that is used just once 2018-07-08 10:40:22 +02:00
Benno Schulenberg
9a7ba5db79 chars: speed up the parsing of a character for the plain ASCII case
Again, if the most significant bit of a UTF-8 byte is zero, it means
the character is a single byte and we can skip the call of mblen(),
*and* if the character is one byte it also occupies just one column,
because all ASCII characters are single-column characters -- apart
from control codes.

This partially addresses https://savannah.gnu.org/bugs/?51491.
2018-06-04 14:07:43 +02:00
Benno Schulenberg
cc2b19c8fd chars: speed up the counting of string length for the plain ASCII case
For UTF-8, if the most significant bit of a byte is zero, it means the
character is just a single byte and we can skip the call of mblen().

For files consisting of pure ASCII bytes (between 0x00 and 0x7F), this
change reduces the counting time of mbstrlen() by ninety six percent.

This partially addresses https://savannah.gnu.org/bugs/?50406.
2018-06-03 20:07:04 +02:00
Benno Schulenberg
430d3bad7a debug: add some code to time the performance of get_totsize()
Don't activate this by passing --enable-debug.  Just remove the
relevant #ifdefs when you want to test the performance of changes
in the counting code.
2018-06-03 20:06:28 +02:00
Benno Schulenberg
4e667bd048 tweaks: reduce the counting of characters to just the needed function
Evade the indirect use of the general-purpose function parse_mbchar().
This reduces the counting time by roughly ten percent.
2018-06-03 17:58:05 +02:00
Benno Schulenberg
ba2e6f43c2 tweaks: elide a subfunction that is used just once
(Forgot to say: the previous two commits addressed
https://savannah.gnu.org/bugs/?54044.)
2018-06-03 17:47:02 +02:00
Benno Schulenberg
6c555828c9 tweaks: remove redundant braces and conditions after the previous change 2018-06-03 14:13:33 +02:00
Benno Schulenberg
0ff068380c tweaks: remove the superfluous calls that reset the mbtowc() state
When mbtowc() is never called with anything less than MAXCHARLEN as
the length parameter, it will apparently not get confused and will
not need to be reset.
2018-06-03 14:06:59 +02:00
Benno Schulenberg
fb372ed0a8 tweaks: remove two superfluous assignments
The variable 'last_action' is set at the end of these functions,
serving to prevent a fresh action from being merged with an older
action further down on the stack.  Setting 'last_action' before
exiting from undo()/redo() makes no sense.

Also adjust a sideways related old Changelog item.
2018-06-02 19:32:54 +02:00
Benno Schulenberg
ed433f6af0 tweaks: drop a condition that has been made redundant two commits ago 2018-06-02 18:17:31 +02:00
Benno Schulenberg
44814055b5 tweaks: correct a comment, rewrap a line, and drop some debugging stuff
An add can be contiguous even when the cursor has moved around in the
meantime but has returned to the same spot before more characters are
typed.
2018-06-02 18:04:36 +02:00
Benno Schulenberg
71f859377d cut: concentrate the logic for clearing the cutbuffer mostly in one place
It should not be the task of the undo code to take care that the
cutbuffer will be cleared at the right moments.
2018-06-02 17:57:19 +02:00
Benno Schulenberg
33d81fa1e6 build: add the release script to the repository 2018-06-02 11:18:04 +02:00
Benno Schulenberg
78dc7b8f0a po: update translations and regenerate POT file and PO files 2018-06-02 10:26:36 +02:00
Benno Schulenberg
1057ca7a16 bump version numbers and add a news item for the 2.9.8 release 2018-06-02 09:51:16 +02:00
Benno Schulenberg
5550d15418 tweaks: improve a couple of comments, and reshuffle a group of lines 2018-06-01 16:56:56 +02:00
Benno Schulenberg
54cab02030 docs: improve the description of --nonewlines, and properly sort it 2018-06-01 15:54:08 +02:00
Benno Schulenberg
2633114b8e docs: add a missing double quote in the default brackets string
It was accidentally lost three years ago, in commit 7e1bc82d.

Also improve the description of this option in the other documents.
2018-06-01 15:53:57 +02:00
Benno Schulenberg
2e1e157967 copyright: update the years for significantly changed files 2018-06-01 10:18:32 +02:00
Benno Schulenberg
6df30a634e docs: register Marco as the author of the filtering feature
The macro stuff, however, is basically my code: I told him exactly
how to do it, and I changed most of the patch before applying it.

Also, put myself in second place, as I've just about overtaken David
in the duration of maintainership.
2018-06-01 10:00:08 +02:00
Benno Schulenberg
856322b01e main: interpret only a double slash (//) as quoting, not a single one
Otherwise the first line of a multiline /*...*/-comment would be
seen as quoted and thus *not* as the first line of a paragraph.

In the code, use "/{2}" to prevent the remainder of the line
getting colored as a comment.
2018-06-01 09:21:03 +02:00
Benno Schulenberg
ad5d0f7530 wrapping: use "smart" autoindenting only when hard-wrapping is enabled
The paragraph-aware indenting is needed only when automatic long-line
wrapping is on (that is, when not using 'nowrap': when writing prose).
When writing code, the user most likely uses --nowrap, which will make
nano indent a new line always to the same amount as the preceding line
-- when --autoindent is in effect, of course.
2018-06-01 08:45:25 +02:00
Benno Schulenberg
0f2b0ffbd3 tweaks: reshuffle a condition, and adjust a comment and some indentation 2018-05-31 16:27:13 +02:00
Benno Schulenberg
f2f901c895 files: give feedback during writeout also when prepending or appending
The only time that feedback about the number of lines written is *not*
wanted is when writing a temporary file.

This fixes https://savannah.gnu.org/bugs/?54025.
2018-05-31 16:08:16 +02:00
Benno Schulenberg
a4e353799b docs: make quotes around regexes bold, as they are part of the command 2018-05-31 12:07:12 +02:00
Benno Schulenberg
64f28515fd docs: remove quotes around the name of a syntax -- they are not needed 2018-05-31 11:25:21 +02:00
Benno Schulenberg
b84dea9898 docs: improve description of 'speller' and related bindable functions 2018-05-30 20:38:27 +02:00
Benno Schulenberg
8492de53f7 syntax: makefile: color all keywords that GNU make recognizes
Plus one that automake recognizes: if.  Color them only at the start
of a line.  Also color all possible assignment sequences (surrounded
by spaces to not color the ones in shell fragments), and add some
comments.
2018-05-30 11:29:08 +02:00
Benno Schulenberg
a1dc1376be docs: describe what constitutes a paragraph
Also fix a typo.
2018-05-30 10:32:26 +02:00
Benno Schulenberg
6fe132194c docs: improve the description of the --autoindent option 2018-05-30 10:29:31 +02:00
Benno Schulenberg
0ea434b006 tweaks: reduce the abundance of the word 'toggle' in the Info manual 2018-05-30 10:01:45 +02:00
Benno Schulenberg
d430934f09 gnulib: update to its current upstream state 2018-05-29 11:08:55 +02:00
Benno Schulenberg
dc3261b685 tweaks: avoid a warning with --enable-{tiny,help,multibuffer}
This also places the Pipe toggle among the other, similar togglles,
which makes more sense.
2018-05-29 09:07:39 +02:00
David Lawrence Ramsey
dc4146f077 tweaks: avoid an unused variable warning with --enable-tiny
This fixes https://savannah.gnu.org/bugs/?53998.
2018-05-29 09:00:08 +02:00
Benno Schulenberg
59eb01b403 build: fix compilation with --enable-{tiny,help,multibuffer} 2018-05-28 11:31:30 +02:00
Benno Schulenberg
738487f13d tweaks: make better use of an existing variable 2018-05-28 10:39:47 +02:00
Benno Schulenberg
c8a9a96578 build: fix compilation when configured with --disable-justify 2018-05-28 09:57:24 +02:00
Benno Schulenberg
cd8e932c65 main: add "/" to the quoting regex, to allow justifying //-comments
And adjust the documentation accordingly.
2018-05-27 20:29:52 +02:00
David Lawrence Ramsey
fce54a724d tweaks: fix some grammar plus a typo in the comments 2018-05-27 20:19:46 +02:00
Benno Schulenberg
4ae1b99c92 docs: mark the filtering of text through an external command as done 2018-05-27 19:33:04 +02:00
Benno Schulenberg
ebdb647450 tweaks: adjust a translator hint 2018-05-27 17:53:36 +02:00
Benno Schulenberg
0c2aac5ff8 tweaks: reshuffle a couple of assignments 2018-05-27 17:45:51 +02:00
Benno Schulenberg
7952d68830 tweaks: frob a couple of comments 2018-05-27 17:27:07 +02:00
Benno Schulenberg
5cb4485fa5 tweaks: remove a superfluous assignment -- the lead length never changes 2018-05-27 17:16:04 +02:00
Benno Schulenberg
d7c1ab8e80 tweaks: rename two variables, to better fit their tasks 2018-05-27 17:11:18 +02:00
Benno Schulenberg
1881db099d tweaks: make better use of an intermediate variable 2018-05-27 16:41:55 +02:00
Benno Schulenberg
36c83d92dd tweaks: stop decreasing both the iterator and the limit of a loop 2018-05-27 16:34:20 +02:00
Benno Schulenberg
9021725d53 justification: limit the amount of recursion to prevent a stack overflow 2018-05-27 16:09:53 +02:00
Benno Schulenberg
d00ab406bc wrapping: when autoindenting, use indentation of next line as example
When doing autoindentation, and the next line is not the start of
a new paragraph, then use the indentation of that line for the new
line, as it is more likely to have the desired indentation -- the
current line might be the start of the paragraph and thus could
have a deviant indentation.
2018-05-27 16:09:53 +02:00
Benno Schulenberg
d63d79b067 tweaks: elide another function that is called just once 2018-05-27 16:09:53 +02:00
Benno Schulenberg
446c7d5fff tweaks: elide a function that is called just once 2018-05-27 16:09:53 +02:00
Benno Schulenberg
52efac535b tweaks: rename a variable, to give it some meaning 2018-05-27 16:09:53 +02:00
Benno Schulenberg
45c36f93e5 tweaks: simplify the determining of the prefix for justified lines 2018-05-27 16:09:53 +02:00
Benno Schulenberg
432a7d7729 justification: find the beginning of a paragraph in a better way
Any line whose indentation differs from that of a pair of adjacent lines
is the beginning of a paragraph, also when its indentation is smaller.

This fulfills https://savannah.gnu.org/bugs/?53932,
and fixes point 2) of https://savannah.gnu.org/bugs/?53933.
2018-05-27 16:09:53 +02:00
Benno Schulenberg
d7fe5a7db3 justification: recognize indented paragraphs also without --autoindent
Pico does not require any option to do this, so nano should neither.

This fixes point 1) of https://savannah.gnu.org/bugs/?53933.
2018-05-27 16:09:53 +02:00
David Lawrence Ramsey
a6c0212158 bindings: add the "flippipe" bindable function
So the toggle for piping to an external command can be rebound.

This fixes https://savannah.gnu.org/bugs/?53987.
2018-05-27 10:36:33 +02:00
Benno Schulenberg
a832f33291 justification: when leading whitespace exceeds fill width, wrap anyway
Pico wraps at the last blank character before or on the target column;
if there is no such blank, then it will wrap at the first blank *after*
the target column -- when it can wrap, it will wrap.  Nano should do
the same (and judging from the comments, it intended to do the same),
instead of turning the paragraph into a single unwrapped line.

This fixes https://savannah.gnu.org/bugs/?53986.
2018-05-27 10:24:02 +02:00
Benno Schulenberg
b9f533a69e tweaks: rename a function, for more aptness and extra contrast 2018-05-25 20:09:24 +02:00
Benno Schulenberg
ac31669ec3 linter: don't try to access absent stat info, as that gives a crash
This fixes https://savannah.gnu.org/bugs/?53981.
2018-05-25 19:25:11 +02:00
Benno Schulenberg
86c08560ad linter: make sure that the margin is updated before displaying a buffer
This fixes https://savannah.gnu.org/bugs/?53977.
Reported-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2018-05-25 17:58:25 +02:00
Benno Schulenberg
119a6f0de3 rcfile: don't crash when a bind to a string lacks the closing quote
This fixes https://savannah.gnu.org/bugs/?53972.
Reported-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2018-05-25 13:15:52 +02:00
Benno Schulenberg
3757683e3f build: fix compilation when configured with --disable-multibuffer 2018-05-24 21:09:14 +02:00
Benno Schulenberg
c07586d9f3 tweaks: condense some repetitious comments, and check before assigning
Check that the option argument is okay (contains no blank characters),
before assigning it to the relevant variable.
2018-05-24 20:49:29 +02:00
Benno Schulenberg
3e9ef3032f tweaks: use a more meaningful variable name, and avoid a distant 'else'
Also, indent a continuation line better.
2018-05-24 19:40:52 +02:00
Benno Schulenberg
6fb1509817 tweaks: condense two statements into one, and elide a 'break' 2018-05-24 18:17:58 +02:00
Benno Schulenberg
07ddf25cc0 tweaks: exclude an unneeded 'if' from the single-buffer version 2018-05-24 18:14:35 +02:00
Marco Diego Aurélio Mesquita
73d397c64b linter: check all open buffers, instead of just the next one
First step to the next buffer, and then iterate until we either
find a match or are back at the buffer where we started.

This fixes https://savannah.gnu.org/bugs/?53970.

Signed-off-by: Marco Diego Aurélio Mesquita <address@hidden>
2018-05-24 18:10:52 +02:00
Benno Schulenberg
e0c7ff2a7e linter: make sure the shortcuts bar will redrawn when exiting early
The two help lines will be redrawn in main() only when the current
menu is not MMAIN.  So, set it to MLINTER as soon as the help lines
are cleared, just before preparing to invoke the linter.

This fixes https://savannah.gnu.org/bugs/?53967.
Reported-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2018-05-24 11:37:14 +02:00
Benno Schulenberg
84f8df2df8 tweaks: avoid an unused-variable warning with --enable-tiny 2018-05-23 12:00:43 +02:00
Benno Schulenberg
408d9b8708 build: fix compilation failure when configured with --enable-tiny 2018-05-23 11:57:55 +02:00
Brand Huntsman
b5427ebb98 tweaks: avoid two unused variable warnings when NLS is disabled
Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-05-23 11:54:45 +02:00
Cristian Caloghera
22663f8a2e syntax: makefile: recognize also an all-lowercase makefile name
Recognize not just "Makefile" but also "makefile" and "GNUmakefile".
And recognize these only when they are the full filenames, not when
they are the tail part of a longer name.

Signed-off-by: Cristian Caloghera <cristi.caloghera@gmail.com>
2018-05-22 20:41:43 +02:00
Benno Schulenberg
5d02ee64b6 filtering: pair the cut and the insert, so they can be undone together
When executing a command in the current buffer and piping this buffer
(or marked region) to that command, then the cutting of the existing
text and the insertion of the new text should be undone and redone
together, as to the user they appear as a single operation.

With-help-from: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2018-05-22 19:36:21 +02:00
Benno Schulenberg
5ffd8d96ae tweaks: rename a variable, for contrast, and improve two comments 2018-05-22 19:36:21 +02:00
Marco Diego Aurélio Mesquita
f304b9aee1 new feature: allow piping (selected) text to an external command
When executing a command, it is now possible to pipe the entire buffer
(or the marked region, if anything is marked) to the external command.
The output from the command replaces the buffer (or the marked region),
or goes to a new buffer.

This fulfills https://savannah.gnu.org/bugs/?28993,
and fulfills https://savannah.gnu.org/bugs/?53041.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-05-22 19:36:21 +02:00
Benno Schulenberg
299e710845 docs, usage: make it clear that the argument of --quotestr is a regex
In the past, the argument could be either a regex or a literal string,
so the wording was kind of vague.  But nowadays we can count on having
regex support (through gnulib), so be more precise in the description.
2018-05-22 18:45:58 +02:00
Benno Schulenberg
d9ba6c10d2 tweaks: give some continuation lines a more obvious indentation
Also, put a translator hint in a better place: not in the middle
of a function call.
2018-05-22 18:07:50 +02:00
Benno Schulenberg
03c184d7f2 tweaks: condense a comment, and elide an unneeded 'if' 2018-05-22 18:01:15 +02:00
Benno Schulenberg
4ec19847a3 startup: provide a hint for people unfamiliar with the ^char convention
But give this hint only when nano was started without any file arguments.
2018-05-22 11:53:17 +02:00
Benno Schulenberg
3628863f90 docs: remove mention of the quotestr for when regex support is lacking
Since version 2.8.0, nano will use (wnen needed) the regex routines
from gnulib, so mentioning the quotestr for when regex support is
lacking, has been obsolete and pointless for more than a year.

Also, remove some superfluous backslashes, use a non-breaking space
in the texinfo document, and order the regex consistently.
2018-05-21 20:08:19 +02:00
Benno Schulenberg
9d6621afd0 tweaks: remove two superfluous checks, after making one of them so 2018-05-21 09:44:06 +02:00
Benno Schulenberg
cdd637d69f syntaxes: condense and/or correct some extension regexes 2018-05-18 20:40:08 +02:00
Benno Schulenberg
4d232a4aef tweaks: frob some comments, and rename two parameters to make sense 2018-05-18 13:24:07 +02:00
Benno Schulenberg
455899fe27 credits: sort the names roughly according to amount of influence
And spell-fix a name.
2018-05-16 12:05:40 +02:00
Benno Schulenberg
6aef1fa905 docs: thank Kamil for his bug fixes, and update an email address 2018-05-16 09:57:02 +02:00
Benno Schulenberg
06c3e1acde po: update translations and regenerate POT file and PO files 2018-05-15 09:14:23 +02:00
Benno Schulenberg
09d8ee82b7 bump version numbers and add a news item for the 2.9.7 release 2018-05-15 08:48:00 +02:00
Benno Schulenberg
dac3b25d16 docs: note a small difference with Pico in the default hard-wrapping 2018-05-14 12:10:38 +02:00
Benno Schulenberg
ca538e6f08 scrolling: only do a scroll when the edit window has more than one row
If the edit window consists of a single row, then the do_up() call has
already brought the desired line into view -- which means that trying
to scroll then (when already on the first line of the file) would fail.

This fixes https://savannah.gnu.org/bugs/?53891.
2018-05-13 19:31:57 +02:00
Benno Schulenberg
4b26308b6a tweaks: put Yes/No/All in a consistent order (for the translators)
So that it matches the order of the preceding Yy/Nn/Aa.
2018-05-13 09:57:49 +02:00
Benno Schulenberg
f5eeb92f40 tweaks: sort an option better, and reschedule a removal 2018-05-13 09:47:40 +02:00
Benno Schulenberg
ae1ba5e259 tweaks: put check for -h and -l options in their alphabetical positions
And put the Pico-compatibility flags last, as normally they are never
given.
2018-05-12 19:56:37 +02:00
Benno Schulenberg
cecf453b14 tweaks: use symbolic names instead of puzzling TRUE and FALSE 2018-05-10 18:19:12 +02:00
Benno Schulenberg
c3a02f8094 tweaks: rename two variables, to be more descriptive 2018-05-10 18:11:35 +02:00
Benno Schulenberg
87283711ee tweaks: improve a couple of comments 2018-05-10 18:10:23 +02:00
Benno Schulenberg
123f77ff1a docs: say thanks to three recent translators, and re-sort two others 2018-05-10 15:17:04 +02:00
Benno Schulenberg
10c49edd3b prompt: when asking for Yes/No/All, recognize also UTF-8 letters
Letters in other scripts than English often consist of multiple bytes.
When in a UTF-8 locale, correctly gather these bytes from the input and
put them together as the single letter that they are, before comparing
this letter against the translated "Yy", "Nn" and "Aa" strings.
2018-05-10 12:29:08 +02:00
Benno Schulenberg
2d5c917b1a signals: exclude the crash handler from the tiny version
The tiny version contains much less code, so is less likely
to crash.  And the users most likely use it for very simple
and short editing jobs, making the chance of a crash still
smaller.  So the handler would just be bloat.
2018-05-10 12:21:53 +02:00
Benno Schulenberg
95002da66c tweaks: normalize indentation and whitespace after previous changes 2018-05-10 11:33:24 +02:00
Mark-Weston
858663444e new feature: an option to make the 'nextword' function stop at word ends
When 'afterends' is set and Ctrl+Right or Shift+Ctrl+Right is pressed,
nano will stop at the ends of words instead of their beginnings.

Signed-off-by: Mark-Weston <markweston@cock.li>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-05-10 11:32:01 +02:00
Benno Schulenberg
4046dfca63 docs: break down some old improvements further per version 2018-05-09 11:55:16 +02:00
Benno Schulenberg
c0b15c2982 signals: don't trap segfault/abort when envvar NANO_NOCATCH is defined
When the user wants to get a backtrace, the crash handler shouldn't
kick in.
2018-05-09 11:53:34 +02:00
Devin Hussey
e889c28a95 signals: upon a crash, save changed buffers and reset terminal state
Upon a segmentation fault or an abort signal, instead of crashing,
losing all changes, and leaving the terminal in curses mode, nano
now calls die(), to save any changed buffers and to restore the
terminal to a usable state.

For the remote chance that nano segfaults in die(), the handler for
SIGSEGV and for SIGABRT is reset to its default value as soon as the
signal fires, to prevent a crash-handler loop.

Since a core dump is usually more helpful for debugging, the crash
handler is not included in a debug build.

This addresses https://savannah.gnu.org/patch/?9623.

Signed-off-by: Devin Hussey <husseydevin@gmail.com>
2018-05-06 16:36:25 +02:00
Benno Schulenberg
0da554e6d7 startup: suggest using ^D to finish reading from standard input
Also, add a period after the "Read nn lines" message, and
don't let the next shell prompt overwrite this message.

This addresses https://savannah.gnu.org/bugs/?53779.
2018-05-01 11:15:19 +02:00
Benno Schulenberg
f1530c7ba0 docs: add notes about deprecated options and function names
Also remove two notes that are obsolete by now.
2018-04-30 15:28:47 +02:00
Benno Schulenberg
0e46c0f4a5 main: clear a spurious error number, to avoid irrelevant messages later
This addresses https://savannah.gnu.org/bugs/?53777.
2018-04-29 12:08:42 +02:00
Benno Schulenberg
6a064503e5 docs: slightly improve the description of the file browser in the manual 2018-04-28 12:34:39 +02:00
Benno Schulenberg
4d92dffb3a bindings: rename constupdate to constantshow, cuttoend to cutfromcursor
This makes the names of these bindable functions equal to the names of
their corresponding options -- like for all the other toggles that have
a corresponding option.
2018-04-28 12:01:23 +02:00
Benno Schulenberg
4c1c425bbb bindings: add the 'linenumbers' bindable function
This makes the line-numbers toggle rebindable, like all the others.
2018-04-28 11:44:53 +02:00
Benno Schulenberg
21a54a3cf6 syntax: po: highlight also other escaped characters, not just \n 2018-04-27 11:17:12 +02:00
Benno Schulenberg
a0147c5a72 bump version numbers and add a news item for the 2.9.6 release 2018-04-27 10:56:10 +02:00
Benno Schulenberg
553940760e tweaks: set the correct flags just once for each spell-fixing session 2018-04-25 17:27:15 +02:00
Benno Schulenberg
faa0eb991e speller: don't add an extra newline when saving the text to a tempfile
Set the NO_NEWLINES flag to achieve this.  And move the saving and
restoring of the global flags to the main speller routine, so the
flags aren't saved and restored for each internal spell fix.

This fixes https://savannah.gnu.org/bugs/?53742.

Acked-by: David Lawrence Ramsey <pooka109@gmail.com>
2018-04-25 17:26:14 +02:00
Benno Schulenberg
f54cd02652 tweaks: adjust the translator hint about Yes/No/All
There is no longer any need to burden the translators with also
providing the English letters.
2018-04-25 17:14:33 +02:00
Benno Schulenberg
6dd308d0fb prompt: recognize Yes/No/All in English when the locale gives no match 2018-04-25 17:03:13 +02:00
Benno Schulenberg
4872f42cd2 tweaks: rename a function, to be more distinct from its caller 2018-04-25 12:21:40 +02:00
Benno Schulenberg
62007c84c6 tweaks: invert two conditions and reshuffle, to reduce duplication 2018-04-24 13:27:57 +02:00
Benno Schulenberg
d0f37205af search: always go forward by default, also when coming from Goto-Line
This fixes https://savannah.gnu.org/bugs/?53735.
2018-04-24 13:13:38 +02:00
Benno Schulenberg
f05874ea23 gnulib: update to its current upstream state 2018-04-24 10:02:04 +02:00
Benno Schulenberg
0d9080a22c scrolling: don't redraw entire edit window when cursor goes offscreen
When the cursor is on the top or bottom line of the edit window, and
an <Up> or <Down> pushes the cursor offscreen, then use edit_scroll()
to bring it back into view, instead of using edit_redraw(), because
the latter would redraw *every row* on the screen, which is a waste
of time.

This addresses https://savannah.gnu.org/bugs/?53562.
Reported-by: Devin Hussey <husseydevin@gmail.com>
2018-04-24 09:59:39 +02:00
Benno Schulenberg
1ae90e205a command-execution: do not crash when opening the pipe would fail
This fixes https://savannah.gnu.org/bugs/?53723.
2018-04-23 18:04:25 +02:00
Benno Schulenberg
d53086d38d completion: correctly do a signed comparison, to avoid a segfault
Bug existed since commit 30fc197b (a month ago) which changed the
type of 'i' from int to size_t, causing the comparison to do the
wrong thing when 'threshold' is negative.

This fixes https://savannah.gnu.org/bugs/?53722.
Reported-by: Devin Hussey <husseydevin@gmail.com>
2018-04-23 17:09:54 +02:00
Benno Schulenberg
0b6bb37c56 tweaks: improve some comments, and exit with nonzero status upon error 2018-04-23 14:04:08 +02:00
Benno Schulenberg
c43a6fdcc1 tweaks: rename a variable, to match another and to be more visible 2018-04-23 13:04:31 +02:00
Benno Schulenberg
0c613cb1ac tweaks: rename a variable, to be more clear and to match another 2018-04-23 12:57:58 +02:00
Benno Schulenberg
1e5064ef84 tweaks: fix a typo, remove a blank line, and improve some comments 2018-04-23 12:19:25 +02:00
Benno Schulenberg
5b40bad629 files: prevent a hang when a call to sigaction() would fail
Don't try to re-enter curses mode when the terminal is not in
the correct state yet.

This fixes https://savannah.gnu.org/bugs/?53720.
2018-04-23 11:58:18 +02:00
Benno Schulenberg
45f8fc77e0 tweaks: rename a variable, to be a bit more fitting 2018-04-22 12:05:19 +02:00
Benno Schulenberg
94347f0811 memory: use a reallocation to reduce the amount of leakage 2018-04-22 12:00:26 +02:00
Benno Schulenberg
1a4a3de68b formatting, linting: redetermine the argument list for every run
The formatter or linter might have changed in the meantime -- when
the filename was changed to have a different extension, for example.

This fixes https://savannah.gnu.org/bugs/?53716.
2018-04-22 11:44:07 +02:00
Benno Schulenberg
bf8bd02558 build: do not prefix an alternative rcfilename with a dot
When the user configures nano with --enable-altrcname=name,
the specified name should not be prefixed with a dot.

This fixes https://savannah.gnu.org/bugs/?53694.
Reported-by: Cody A. Taylor <codemister99@yahoo.com>
2018-04-21 10:03:30 +02:00
Benno Schulenberg
544d426d86 tweaks: group some more of the empty functions together 2018-04-17 10:34:57 +02:00
Benno Schulenberg
30a984661b syntax: po: highlight also other escaped characters, not just \n
Especially color \a and \t, to make it easier to distinguish them
from contiguous text.
2018-04-17 09:56:19 +02:00
Benno Schulenberg
7ab8a4d835 tweaks: improve the ordering of a couple of functions 2018-04-13 21:09:44 +02:00
Benno Schulenberg
0353a24400 tweaks: rearrange a few if statements more symmetrically 2018-04-13 20:43:08 +02:00
Benno Schulenberg
d4304ca88c search: use a better value to mean "nothing was typed"
When the keyboard buffer is empty, return a value that is not equivalent
to <Ctrl+Space>, so that typing a bunch of these while searching is going
on will not result in some of them getting executed afterward.
2018-04-13 20:13:05 +02:00
Benno Schulenberg
02d8da3bdd tweaks: rename a function, to be more fitting and descriptive
It is not an abort but simply a bit of cleaning up.
2018-04-13 10:32:29 +02:00
Benno Schulenberg
7a09b655c1 tweaks: rename a variable, for clarity 2018-04-13 10:22:39 +02:00
Benno Schulenberg
c8b26baee8 tweaks: elide a function that is called just once
Also adjust and correct a comment.
2018-04-13 10:17:08 +02:00
Liu Hao
bb394990cd replacing: always clear the backwards flag for ^\, just like for ^W
This makes it easier to predict in which direction the replacements
will go when hitting ^\ or M-R.

Signed-off-by: Liu Hao <lh_mouse@126.com>
2018-04-12 20:32:15 +02:00
Benno Schulenberg
7c5d099c6f tweaks: frob a couple of comments 2018-04-01 21:07:18 +02:00
Benno Schulenberg
152cc24d1f tweaks: reshuffle two declarations 2018-04-01 20:08:57 +02:00
Benno Schulenberg
8965103a4d tweaks: remove the group handling for undoing/redoing (un)indents
Indenting/unindenting always happens in a single contiguous block.
Lines that cannot or should not be indented or unindented do not
need to remembered separately as it follows from their content.
2018-04-01 11:41:26 +02:00
Benno Schulenberg
d0d293b8af tweaks: correct or improve a couple of comments 2018-04-01 11:24:44 +02:00
Benno Schulenberg
839743fd24 tweaks: move a function to its proper location 2018-04-01 10:54:14 +02:00
Benno Schulenberg
0b30835dd0 tweaks: use meaningful names instead of puzzling values
Suggested-by: Brand Huntsman <alpha@qzx.com>
2018-04-01 09:49:58 +02:00
Benno Schulenberg
a865c25eea build: fix compilation when configured with --disable-help
This fixes https://savannah.gnu.org/bugs/?53532.
2018-03-31 16:52:22 +02:00
Benno Schulenberg
cf1129a8b4 syntax: sh: colorize options only when they are preceded by whitespace
To prevent any filenames containing hyphens getting partially colored.

Reported-by: Brand Huntsman <alpha@qzx.com>
2018-03-30 10:46:56 +02:00
Benno Schulenberg
0cd833e64b tweaks: move a function to its proper location
Put it after the function that it calls, and before the functions
it is called from.
2018-03-30 10:34:40 +02:00
Benno Schulenberg
cbf226476d rcfile: skip color commands where some color name is invalid
That is, do not fall back to the default background color when the
name for the background color is invalid, but reject the entire
color command, just like for an invalid foreground color.
2018-03-30 10:30:55 +02:00
133 changed files with 72716 additions and 63815 deletions

11
.gitignore vendored
View File

@@ -13,6 +13,9 @@ core
.gdb_history
.gdbinit
/src/nano
/src/revision.h
/ABOUT-NLS
/INSTALL
/aclocal.m4
@@ -35,7 +38,7 @@ core
/mkinstalldirs
/stamp-h1
# gettext m4 files.
# Gettext m4 files:
/m4/codeset.m4
/m4/extern-inline.m4
/m4/fcntl-o.m4
@@ -69,13 +72,9 @@ core
/m4/wint_t.m4
/m4/xsize.m4
# gnulib entries
# Gnulib stuff:
/gnulib/
/lib/
/m4/.gitignore
/m4/gnulib-cache.m4
/snippet/
/nano.spec
/src/nano
/src/revision.h

19
AUTHORS
View File

@@ -5,11 +5,18 @@ nano editor. Please see the ChangeLog for specific changes by author.
Chris Allegretta <chrisa@asty.org>
* Original program author and long-time maintainer.
Benno Schulenberg <bensberg@telfort.nl>
* An array of small bug fixes, the cut-word and block-jump
routines, text selection by holding Shift, macro recording
and replay, plus some key bindings. Current maintainer.
David Lawrence Ramsey <pooka109@gmail.com>
* Former stable series maintainer. Multiple buffer support,
operating dir (-o) option, bug fixes for display routines,
wrapping code, spelling fixes, constantshow mode, parts of
UTF-8 support, softwrap overhaul, and various other fixes.
UTF-8 support, softwrap overhaul, undoable (un)indentations,
undoable justifications, justifiable regions, and numerous
other fixes.
Jordi Mallach <jordi@gnu.org>
* Debian package maintainer, fellow bug squasher.
@@ -60,7 +67,9 @@ Sumedh Pendurkar <sumedh.pendurkar@gmail.com>
Rishabh Dave <rishabhddave@gmail.com>
* Searchable help.
Benno Schulenberg <bensberg@justemail.net>
* An array of small bug fixes, the cut-word and block-jump
routines, text selection by holding Shift, and some extra
key bindings. Current maintainer.
Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
* Filtering text through an external command.
* Placing anchors (bookmarks) and jumping to them.
Brand Huntsman <alpha@qzx.com>
* The delayed parsing of syntax files.

2301
ChangeLog

File diff suppressed because it is too large Load Diff

View File

@@ -3007,7 +3007,7 @@ GNU nano 1.3.5 - 2004.11.22
- Don't change the file format when we insert another file into
the current one. (DLR)
do_insertfile()
- Simplify by reusing variables whereever possible, and add a
- Simplify by reusing variables wherever possible, and add a
parameter execute to indicate whether or not to be in "Execute
Command" mode. (DLR)
- Rework so that goto is no longer needed, using do_writeout()
@@ -5035,7 +5035,7 @@ GNU nano 1.1.99pre2 - 2003.02.03
- Fix the mouse code to work with lines longer than COLS and
with the proper positioning, including special characters.
(David Benbennick)
do_preserve_msg():
do_preserve_msg()
- Unsplit error message into a single fprintf call. (Jordi)
main()
- Call load_file with arg 0 for insert, as we aren't really
@@ -5143,7 +5143,7 @@ GNU nano 1.1.99pre1 - 2003.01.17
- Added --enable-all option to compile in all the extra stuff
we'd normally need extra flags for.
- color.c:
update_color():
update_color()
- Remove an unneeded edit_refresh() call after do_colorinit().
(David Benbennick)
- cut.c:
@@ -5778,7 +5778,7 @@ GNU nano 1.1.10 - 2002.07.25
Also, pass current_x_find to strstrwrapper() so we know whether
we're at the beginning of a string or not (see changes to
strstrwrapper() below), and reset it between lines. (DLR)
do_gotoline():
do_gotoline()
- Make sure placewewant is zero after we go to a line. (David
Benbennick)
do_gotopos()
@@ -6036,7 +6036,7 @@ GNU nano 1.1.8 - 2002.03.30
- Catalan and Spanish translation updates. (Jordi)
- Typo. (DLR)
- po/fr.po:
- French translation updates (Jean-Philippe Guérard).
- French translation updates. (Jean-Philippe Guérard)
- po/gl.po:
- Galician translation updates. (Jacobo Tarrio)
- po/uk.po, po/ru.po:
@@ -6156,10 +6156,9 @@ GNU nano 1.1.7 - 2002.03.05
- po/it.po:
- Italian translation updates. (Marco Colombo)
- po/cs.po:
- Partial Czech translation updates. (Vaclav Haisman)
- Partial Czech translation updates. (Václav Haisman)
- po/hu.po:
- Hungarian translation updates, or to be precise, rewrite.
(Gergely Nagy)
- Hungarian translation updates, or to be precise, rewrite. (Gergely Nagy)
- po/uk.po, po/ru.po:
- Russian and Ukrainian translation updates. (Sergey A. Ribalchenko)
- po/da.po:
@@ -6268,7 +6267,7 @@ nano-1.1.6 - 2002.01.25
- po/nn.po:
- Norwegian nynorsk translation updates. (Kjetil Torgrim Homme)
- po/nb.po:
- New Norwegian bokmål translation. (Stig E Sandoe <stig@ii.uib.no>)
- New Norwegian bokmål translation, by Stig E Sandoe <stig@ii.uib.no>.
- po/da.po:
- Danish translation update. (Keld Simonsen)
@@ -6380,8 +6379,10 @@ nano-1.1.4 - 2001.12.11
do_wrap()
- Many fixes. (David Lawrence Ramsey)
do_spell()
- Dont prompt for replace if we don't change the word in
- Don't prompt for replace if we don't change the word in
question. (Rocco Corsi)
- m4/gettext.m4:
- diff against mutt 1.2.5's gettext.m4.
- po/de.po:
- German translation updates. (Karl Eichwalder)
- po/ru.po:
@@ -6394,8 +6395,6 @@ nano-1.1.4 - 2001.12.11
- Spanish translation updates. (Jordi)
- po/fr.po:
- French translation updates. (Michel Robitaille)
- m4/gettext.m4:
- diff against mutt 1.2.5's gettext.m4.
nano-1.1.3 - 2001.10.26
- General
@@ -6770,7 +6769,7 @@ nano-1.1.0 - 2001.07.15
- po/es.po, po/ca.po:
- Updated. (Jordi)
- po/gl.po:
- Galician translation by Jacobo Tarrío.
- New Galician translation, by Jacobo Tarrío <jtarrio@trasno.net>.
- po/uk.po, po/ru.po:
- New Ukrainian and Russian translations by Sergey A. Ribalchenko
<fisher@obu.ck.ua>, thanks!
@@ -6779,9 +6778,9 @@ nano-1.1.0 - 2001.07.15
- po/it.po
- Updated Italian translation by Marco Colombo.
- po/no.po:
- New Norwegian translation by Eivind Kjørstad <ekj@vestdata.no>.
- New Norwegian translation, by Eivind Kjørstad <ekj@vestdata.no>.
- po/sv.po:
- New Swedish translation by Christian Rose <menthos@menthos.com>.
- New Swedish translation, by Christian Rose <menthos@menthos.com>.
nano 1.0.1 - 2001.04.06
- General:
@@ -6825,15 +6824,15 @@ nano-1.0.0 - 2001.03.22
the "new" C++ reserved word, even though there is likely no way
nano will EVER be compilable with a C++ compiler. (suggested by
Rocco Corsi).
- ca.po, es.po:
- Final tweaks for Nano 1.0.
- cs.po:
- Czech translation from Vaclav Haisman.
- nano.info:
- Added dir entry. (Albert Chin)
- winio.c:
statusq()
- Added NANO_BACK_KEY and NANO_FORWARD_KEY cases for left and right.
- ca.po, es.po:
- Final tweaks for Nano 1.0.
- cs.po:
- New Czech translation, by Václav Haisman <V.Haisman@sh.cvut.cz>.
1.0-test prerelease - 2001.03.17
- nano.c:
@@ -6847,7 +6846,7 @@ nano-1.0.0 - 2001.03.22
edit update. Fixes bug #57.
- search.c:
print_replaced()
- s/occurence/occurrence typos. (Jordi)
- Fix typos in "occurrence". (Jordi)
search_init()
- If using Pico mode and regex and same answer is entered, use
last_search string instead of answer. Fixes bug #56.
@@ -6888,13 +6887,13 @@ nano-0.9.99pre3 - 2001.02.19
- fi.po:
- Translation updates by Pauli Virtanen.
- hu.po:
- Hungarian translation by Horvath Szabolcs.
- New Hungarian translation, by Horvath Szabolcs <horvaths@penguinpowered.com>.
- id.po:
- Translation updates by Tedi Heriyanto.
- es.po:
- Translation updates and grammatical/typo fixes. (Jordi)
- ca.po:
- Catalan translation by Jordi Mallach :)
- Catalan translation by Jordi Mallach. :)
- Miquel Vidal <miquel@sindominio.net> went over it and corrected
many typos and completed bits that remained untranslated by error.
@@ -6998,7 +6997,6 @@ General
repeated string defs and globals.
do_justify()
- Small fix for totsize calculation. (Rob)
- fi.po:
- Update by Pauli Virtanen.
@@ -7395,7 +7393,7 @@ nano 0.9.18 - 2000.09.18
- es.po:
- Translated new strings and minor updates. (Jordi)
- de.po
- Revised translations by <floki@bigfoot.com>.
- Revised translations by Florian König.
nano-0.9.17 - 2000.09.04
- General
@@ -7426,7 +7424,7 @@ nano-0.9.17 - 2000.09.04
do_toggle()
- Added checks for no help and no wrap mode, and print opposite
enable/disable message.
do_suspend(), do_cont():
do_suspend(), do_cont()
- New functions, handle suspend signal in a Pico-like manner and
work with Meta-Z.
- winio.c:
@@ -7447,7 +7445,7 @@ nano-0.9.17 - 2000.09.04
search_abort()
- Now calls edit_refresh_clearok when MARK_ISSET to handle screen
ugliness bug (reported by Ken Tyler).
findnextstr():
findnextstr()
- Added reset for placewewant. (Ben Roberts)
- Fixed check for string that only occurs on the same line failing
(bug discovered by Ken Tyler).
@@ -7532,10 +7530,10 @@ nano-0.9.14 - 2000.07.27
- Changed check for filename to filename[0]. Added some code,
overall fixes bug #30 =-)
- nano.c:
do_justify() & do_wrap():
do_justify(), do_wrap()
- totsize-related fixes. (Rob)
- de.po
- Revised translations by floki@bigfoot.com
- Revised translations by Florian König.
nano-0.9.13 - 2000.07.23
- Implemented Pico's -k mode. New flag CUT_TO_END, option (-k, --cut),
@@ -7548,32 +7546,32 @@ nano-0.9.13 - 2000.07.23
- Don't edit_refresh() if the bottom of the file is in the edit
buffer. (Adam)
- nano.c:
main():
main()
- TABSIZE now set before first call to edit_refresh. (Bill Soudan)
- Different ^C kill code (patch by Christian Weisgerber).
die():
die()
- More intelligent emergency-save filename selection. (Rob)
do_spell():
do_spell()
- Changed exit semantics a bit so that aspell wouldn't get
all screwy (bug discovered by Joshua Jensen).
- files.c:
read_file():
read_file()
- Added init of buf variable, hopefully this will stop the
"bleeding" of text seen with mutt and using i18n.
write_file():
write_file()
- Added code to check to see if using -l and the file is not
in fact a link. This should fix the behavior where a file
that does not have write permission but could be removed and
rewritten is saved without error. Please test this feature
and give feedback.
- search.c:
search_init():
search_init()
- Added " (to replace)" statement to end of search string if
we are doing a replace. Manually converted all the translations
from '%s' to '%s%s' to ensure they still work with the new code.
Also put in the translation for " (replace)" in the .po's. Hope
I didn't step on your toes doing this Jordi. (Chris)
do_search(), do_replace():
do_search(), do_replace()
- Removed call to search_abort()/replace_abort() before call to
the opposite function.
- Fixed bug #28.
@@ -7612,52 +7610,47 @@ nano-0.9.12 - 2000.07.07
- Corrected FIXME in do_enter with explanation. (Rob)
- Fixed FIXME in do_justify, resulted in creation of
fix_editbot [also fixed in do_enter] (winio.c). (Rob)
help_init():
help_init()
- Moved newline out of if statement. (Rocco Corsi)
do_char():
do_char()
- Magic Line related code in do_char. (Rob)
do_backspace(), do_delete():
do_backspace(), do_delete()
- Added magic line code here too.
- de.po:
- Revised translations by floki@bigfoot.com.
- fi.po:
- Finnish translation by pauli.virtanen@saunalahti.fi.
- utils.c:
- Added new_magicline()
- winio.c:
- Added stdlib.h to includes, found by OpenBSD gcc.
- lots of new commenting around display functions
do_yesno(), nanogetstr():
do_yesno(), nanogetstr()
- Removed now unnecessary raw/cbreak combos.
- Removed gettext calls from "Y(es)", "N(o)", "A(ll)" and "^C", till
we decide if those keybindings should be translated. (Jordi)
clear_bottomwin():
clear_bottomwin()
- Removed wrefresh(edit) call.
edit_update_top():
edit_update_top()
- Fixed a bug that caused nano to not update when
current->next == NULL (e.g. paging down to the very bottom of
ABOUT NLS wouldn't work).
fix_editbot:
fix_editbot()
- Added (should rebuild editbot from a valid edittop). (Rob)
edit_add:
edit_add()
- removal of redundant call to mvwaddnstr.
- de.po:
- Revised translations by Florian König.
- fi.po:
- New Finnish translation, by Pauli Virtanen <pauli.virtanen@saunalahti.fi>.
nano-0.9.11 - 2000.06.20
- New flag "-T" or "--tabsize" to specify how to display tab widths.
Affects main() in nano.c, strlenpt(), xpt() and actual_x() (et al) in
winio.c, and nano.h. Many hardcoded "8"s have been changed to the
TABSIZE int. Added changes to nano.1 and nano.1.html.
- id.po:
- Indonesian translation by Tedi Heriyanto.
- es.po:
- Updated translation. (Jordi Mallach)
- winio.c
- Rewrite of display functions to correct the display problems
we had been seeing. Affects: add_marked_sameline, edit_add,
and many others. (Rob Siemborski)
- totsize fixes. (Rob Siemborski)
total_refresh():
total_refresh()
- Cut display_main_list call, as this function is only supposed to
refresh what's already on the screen, not go through the process
of adding the text again.
@@ -7669,12 +7662,12 @@ nano-0.9.11 - 2000.06.20
Changed all calls to editwinrows - 1 in nano.c and move.c.
- Removed all functions that were split into other files.
Affects LOTS of funcs.
do_enter():
do_enter()
- Added reset of placewewant to end.
do_insertfile():
do_insertfile()
- Fix display problem when using Ctrl-R to load a file
into the buffer. (Rob Siemborski)
handle_sigwinch():
handle_sigwinch()
- Added titlebar(), edit_refresh() and display_main_list() calls
because a resize wasn't picking up on possible different width
correctly.
@@ -7689,17 +7682,21 @@ nano-0.9.11 - 2000.06.20
- search.c:
- Contains all our searching and related functions, (do_search(),
findnextstr(), do_replace(), do_gotoline()).
- id.po:
- New Indonesian translation, by Tedi Heriyanto <tedi_h@gmx.net>.
- es.po:
- Updated translation. (Jordi Mallach)
nano-0.9.10 - 2000.06.04
- es.po:
- Translation updates. (Jordi)
- AUTHORS, nano.1.html, TODO, README:
- Documentation and email address updates. (Jordi)
- nano.c:
main():
main()
- Moved Adam's termio code down to after getopt() and before initscr()
to stop people losing their SIGINT character when using args that
exit nano before it runs (--version, --help, etc).
- es.po:
- Translation updates. (Jordi)
nano-0.9.9 - 2000.05.31
- Makefile.am:
@@ -7708,8 +7705,6 @@ nano-0.9.9 - 2000.05.31
- Spelling fixes. (Jordi Mallach)
- Removed CFLAGS changes for gcc, reduces portability according to
some, and it certainly doesn't seem to decrease exe size.
- es.po:
- Spanish translation updates. (Jordi Mallach)
- POTFILES.in:
- Added global.c file, was screwing up translations (i.e. they
weren't getting done).
@@ -7747,6 +7742,8 @@ nano-0.9.9 - 2000.05.31
- winio.c:
total_refresh():
- Completely rewrote function, not quite so brain-damaged now.
- es.po:
- Spanish translation updates. (Jordi Mallach)
nano-0.9.8 - 2000.05.18
- nano.c:
@@ -7768,7 +7765,7 @@ nano-0.9.8 - 2000.05.18
should now only be called once, at the bottom of the main()
loop.
- global.c:
shortcut_init():
shortcut_init():
- Removed suspend sc_init call and suspend message because suspend
is no longer needed in the shortcut list to work properly.
@@ -7787,7 +7784,6 @@ nano-0.9.7 - 2000.05.14
display update (bug discovered by Ken Tyler).
nano-0.9.6 - 2000.05.08
- New Italian translation (it.po), by Daniele Medri.
- nano.c:
page_up(), page_down():
- Added reset of placewewant to 0, as it should be.
@@ -7806,6 +7802,12 @@ nano-0.9.6 - 2000.05.08
- Removed yucky code that didn't work, this function now just
computes edittop and editbot and calls edit_refresh() to do the
rest, which removes a lot of duplicate code...
- it.po:
- New Italian translation, by Daniele Medri <madrid@linux.it>.
- fr.po:
- New French translation, by Pierre Tane <tanep@bigfoot.com>.
- de.po:
- New German translation, by Florian König <floki@bigfoot.com>.
nano-0.9.5 - 2000.05.01
- Removed bytes from file struct because it was computationally wasteful.
@@ -7831,25 +7833,23 @@ nano-0.9.5 - 2000.05.01
- Removed inefficient call to edit_refresh() after every keystroke.
It is now up each function to leave the screen in a good state.
- winio.c:
do_cursorpos()
do_cursorpos():
- Rewritten to not use bytes from filestruct by an incremental sum.
update_line(), reset_cursor():
- Optimized calls to xplustabs() through a single variable.
- update_line() now takes a new arg, an index into the string
for where to update the line from. Needed for new update
code.
for where to update the line from. Needed for new update code.
- configure.in:
- Better checks for slang, allows argument to --with-slang.
(Albert Chin-A-Young)
- Removed -Iintl from CFLAGS in gcc check.
- Makefile.am:
- Addition of -Iintl for gettext (Albert Chin-A-Young)
- Addition of -Iintl for gettext. (Albert Chin-A-Young)
nano-0.9.4 - 2000.04.25
- Fixed calls to no_help and changed them to the more consistent
ISSET(NO_HELP). Fixed return val of no_help to be what it should (2,
not 1. Code to temporarily disable NO_HELP when in the
help system. (Adam Rogoyski)
- Fixed calls to no_help and changed them to the more consistent ISSET(NO_HELP).
Fixed return val of no_help to be what it should (2, not 1). Code to
temporarily disable NO_HELP when in the help system. (Adam Rogoyski)
- cut.c:
do_marked_cut(), do_cut(), do_uncut():
- Commented out unnecessary bits when NANO_SMALL is being used.
@@ -7985,23 +7985,26 @@ nano-0.8.8 - 2000.03.12
support i18n.
- nano.c:
includes: Added sys/param.h and limits.h. (Adam Rogoyski).
statics: Changed some things that were not necessarily static
(Adam Rogoyski).
nrealloc(): New function, similar to nmalloc(). Changed calls from
statics: Changed some things that were not necessarily static.
(Adam Rogoyski)
nrealloc():
New function, similar to nmalloc(). Changed calls from
realloc() to nrealloc. (Adam Rogoyski)
empty_line(), no_spaces(), justify_format(), do_justify():
New functions for justify function. (Adam Rogoyski)
- winio.c:
blank_edit(): Added wrefresh call to edit so that screen updates (like
on ^L) actually work.
xplustabs(), xpt(), strlenpt(): Fixed off-by-one buglets. (Adam Rogoyski)
blank_edit():
Added wrefresh call to edit so that screen updates (like on ^L)
actually work.
xplustabs(), xpt(), strlenpt():
Fixed off-by-one buglets. (Adam Rogoyski)
nano-0.8.7 - 2000.03.01
- main.c:
do_wrap(): Better fix for segfaults, and fix for lines being wrapped
to a single character on one line when no good place to
break the line exists, and for wrapping lines longer than
COLS.
do_wrap():
Better fix for segfaults, and fix for lines being wrapped
to a single character on one line when no good place to break
the line exists, and for wrapping lines longer than COLS.
- nano.1.html:
Html version of man page, now included in dist. For
the benefit of nano packages in Linux distributions.
@@ -8024,7 +8027,8 @@ nano-0.8.6 - 2000.02.24
nano-0.8.5 - 2000.02.18
- nano.c:
main(): Finally fixed tilde being input on page up/down keys in
main():
Finally fixed tilde being input on page up/down keys in
certain terminal types. Fix was input 26->91->5[34] check
for 126, if so make the kbinput PAGE UP/DOWN, else unget
the keystroke and continue. Added #include <ioctl.h> for
@@ -8038,7 +8042,7 @@ nano-0.8.5 - 2000.02.18
edit_refresh() is now unmanageably complex, and must be
revamped.
check_statblank():
Added check for constupdate, makes things less choppy
Added check for constupdate, makes things less choppy.
(Adam Rogoyski)
nano-0.8.4 - 2000.02.11
@@ -8049,7 +8053,8 @@ nano-0.8.4 - 2000.02.11
Removed redundant NANO_CONTROL_H from backspace shortcut,
added char 127 which should have been there.
- nano.c:
main(): Fix for loops looping until MAIN_LEN, added -1 to stop
main():
Fix for loops looping until MAIN_LEN, added -1 to stop
segfaults. (Adam Rogoyski)
- Makefile.am: Added all source filenames. (Adam Rogoyski)
- nano.1: Fixed mail addressed and added mailing list address.
@@ -8057,13 +8062,15 @@ nano-0.8.4 - 2000.02.11
nano-0.8.3 - 2000.02.08
- New Pico mode (-p, --pico), toggles (more) compatibility with the
Pico messages displayed in the shortcut list. Note that there are still
small differences in this mode.
- nano.h: New shortcut struct format, for the benefit of i18n and
Pico messages displayed in the shortcut list. Note that there are
still small differences in this mode.
- nano.h:
New shortcut struct format, for the benefit of i18n and
our help menu. Removed shortcut message macros, they are
now all in shortcut_init in global.c.
- nano.c:
do_wrap(): Removed resetting of current_x when we are in fact
do_wrap():
Removed resetting of current_x when we are in fact
wrapping to the next line, fixes a bug in -i mode.
do_enter():
Rewrote the autoindent mode code to be a lot less pretty,
@@ -8116,7 +8123,8 @@ nano-0.8.1 - 2000.01.28
global variable fill, affects check_wrap(), do_wrap(), main(), usage(),
global.c and proto.h.
- nano.c:
write_file(): Added (incredibly) necessary check for EPERM when
write_file():
Added (incredibly) necessary check for EPERM when
link() fails. This allows us to actually save
files via rename() on filesystems that don't
support hard links (AIEEEEEE).
@@ -8136,7 +8144,7 @@ nano-0.8.0 - 2000.01.25
- View flag (-v, --view) implemented. Global variable view_mode, affects
main loop of nano.c and new_file(). (Chris)
- nano.c:
split checks for TERMIOS_H and TERMIO_H up so we
Split checks for TERMIOS_H and TERMIO_H up so we
can (theoretically) include them both, which is good.
handle_sigwinch():
Added check for ncurses.h. (Andy Kahn)
@@ -8254,7 +8262,6 @@ nano 0.7.6 - 2000.01.15
than one huge buffer, and replaced the strcat at the end
with an index variable. Added call to read_bytes().
do_next_word(): New function, binding is Ctrl-Space (0). (Chris)
- winio.c:
bottombars(): Fixed non-expanding shortcut keys at bottom of screen.
(formula is extra space needed = COLS / 6 - 13).
@@ -8278,7 +8285,7 @@ nano 0.7.6 - 2000.01.15
having a newline at the end doesn't get read, bugfix in do_replace
with replace all, more/better comments. (Robert Siemborski)
0.7.2 Our first patch accepted into the source! configure fixes
and optimizations (Erik Anderson). Added missing stdarg.h to winio.c.
and optimizations (Erik Andersen). Added missing stdarg.h to winio.c.
Bug fix in update_line for editing long lines. Fixed arguments
being put into the filename when none is specified. Preliminary
+line command argument function.

View File

@@ -330,7 +330,7 @@ GNU nano 2.5.2 - 2016.02.12
2016-02-09 Benno Schulenberg <bensberg@justemail.net>
* src/files.c (stat_with_alloc, open_buffer, write_file): Check the
result of a stat() to avoid referencing unitialized data. Original
result of a stat() to avoid referencing uninitialized data. Original
patch was by Kamil Dudka.
* doc/man/{nano.1,rnano.1,nanorc.5}: Adjust version for release.
@@ -661,7 +661,7 @@ GNU nano 2.5.0 - 2015.12.05
This addresses Debian bug #805288.
2015-12-01 Benno Schulenberg <bensberg@justemail.net>
* src/files.c (do_insertfile): Mark the buffer as mofified only when
* src/files.c (do_insertfile): Mark the buffer as modified only when
actually something was inserted. This fixes Savannah bug #45409.
* src/files.c (do_insertfile): Rename two variables for clarity.
* src/text.c (redo_cut): Delete two redundant assignments.
@@ -1305,7 +1305,7 @@ GNU nano 2.4.2 - 2015.07.05
* src/text.c (do_alt_speller, do_linter, do_formatter): Distinguish
a failure to launch the linter from receiving zero parsable lines;
add a new function to glue together the invocation-error string.
* src/global.c (shortcut_init): In the Help Viewer and File Browswer,
* src/global.c (shortcut_init): In the Help Viewer and File Browser,
bind the unbound Home and End keys to goto_top and goto_bottom, to
mimic the behaviour of these keys in file viewers and web browsers.
Also show ^Y and ^V in the WhereisFile menu instead of M-\ and M-/,
@@ -2005,7 +2005,7 @@ GNU nano 2.3.4 - 2014.06.02
2014-06-02 Chris Allegretta <chrisa@asty.org>
* doc/syntax/default.nanorc: Can't do trailing spaces in the
default syntax or it will hilight the spaces as you type them
default syntax or it will highlight the spaces as you type them
into a new file, which for non-programming is infuriating.
2014-05-29 Mark Majeres <mark@engine12.com>
@@ -3448,14 +3448,14 @@ GNU nano 2.1.8 - 2009.02.07
2009-01-25 Chris Allegretta <chrisa@asty.org>
* files.c (open_file), nanorc.c (parse_include): Don't get_full_path on included
rc files, due to it potentially impacting the ability to read files in nano's
cwd(). Fixes Savnanah bug #25297 reported by Mike Frysinger.
cwd(). Fixes Savannah bug #25297 reported by Mike Frysinger.
2009-01-24 Chris Allegretta <chrisa@asty.org>
* First pass at some caching of caching color info. Right now it's only for
* First pass at some caching of color info. Right now it's only for
multi-line regexes but this may not be enough to increase performance.
* Add interruptability to search functions. New functions enable_nodelay and
disable_nodelay and changes to the routines to handle checking for pending
searches. Fixes Savnnah bug #24946: Need interrrupt for search.
searches. Fixes Savannah bug #24946: Need interrupt for search.
2009-01-19 Chris Allegretta <chrisa@asty.org>
* Change function definitions to shorts instead of (void *)s. New mapping function
@@ -3494,7 +3494,7 @@ GNU nano 2.1.6 - 2008.10.03
* ocaml.nanorc: Sample OCaml syntax highlighting file.
2008-09-30 Dave Geering <dgeering@toshiba-tap.com>
* objc.nanorc: Sample Objective-C syntax hightlighting file.
* objc.nanorc: Sample Objective-C syntax highlighting file.
2008-09-30 Chris Allegretta <chrisa@asty.org>
* configure.ac: Change extra, multibuffer, color and rcfile configure options
@@ -3555,10 +3555,10 @@ GNU nano 2.1.4 - 2008.08.09
* text.c (add_undo): Fix check for multi-line cut check skips adding other new legit events.
2008-07-23 Chris Allegretta <chrisa@asty.org>
* text.c: Reset openfile-> to OTHER after an undo or redo so we don't
mistakenly think this is an update when it's really an add. Also
fix an extra ; after an if statement which makes nano try to free
a struct which may be NULL.
* text.c: Reset openfile->last_action to OTHER after an undo or redo
so we don't mistakenly think this is an update when it's really an
add. Also fix a mistaken ; after an if statement which made nano
try to free a struct which might be NULL.
GNU nano 2.1.3 - 2008.08.04
@@ -3648,7 +3648,7 @@ GNU nano 2.1.1 - 2008.04.01
* gentoo.nanorc: Gentoo syntax highlighting config.
2008-03-17 Benno Schulenberg <bensberg@justemail.net>
* global.c: Fix incorrect first line jump messsage, fix
* global.c: Fix incorrect first line jump message, fix
more comments to assist translators.
* winio.c: Fix shortcut labels not being translated.

View File

@@ -1,9 +1,42 @@
Improvements in GNU nano
========================
Since 5.0:
- M-Bsp deletes a word leftward.
- With --indicator a "scrollbar" is shown, indicating position+portion.
- M-Ins places an anchor, M-PgUp/M-PgDn jump to the nearest anchor.
- Toggling help lines (M-X) and Refresh (^L) work nearly everywhere.
- Colors can be modified with the attributes "bold," and/or "italic,".
- Nine new color names: from pink and purple to orange and latte.
Since 4.0:
- Pasting from outside into nano suppresses auto-indentation.
- Such an external paste can be undone with a single M-U.
- Shift+Meta+letter key combos can be bound with 'bind Sh-M-letter ...'.
- A custom nanorc file may be specified with -f / --rcfile.
- What the <Tab> key produces can be specified per syntax with 'tabgives'.
- The ability to perform a search at startup with +/string or +?string.
- Comment characters are copied when automatic hard-wrapping occurs.
- The ability to both read from and write to a FIFO.
- Automatic hard-wrapping is no longer the default.
- Addition of --guidestripe to draw a helpful vertical bar.
- Meta-Up and Meta-Down scroll the screen linewise.
- Continuation is shown with a highlighted ">" instead of a plain "$".
- A marked region gets justified into a single, separate paragraph.
- Any number of justifications can be undone.
Since 3.0:
- Addition of --zap to make <Del> and <Bsp> obliterate marked text.
- <Ctrl+Delete> wipes next word and <Shift+Ctrl+Delete> preceding word.
- An external spell check can be undone.
Since 2.9.0:
- The ability to filter text through an external command.
- Better detection of paragraphs, allowing a less indented beginning.
- Option 'set afterends' for making Ctrl+Right stop at word ends.
- A crash handler that saves changed buffers in case of a crash.
- Addition of the color name "normal", meaning the default color.
- A key can be bound to a string -- any mix of text and commands.
- A key can be bound to a string -- any mix of text and control codes.
- Error messages are shown by default in bright white on red.
- <Tab> and <Shift+Tab> can be used to indent/unindent a marked region.
- Can snip trailing whitespace while typing, with 'set trimblanks'.
@@ -14,7 +47,6 @@ Since 2.9.0:
for the history files (of search strings and cursor positions).
Since 2.8.0:
- Meta-Up/Meta-Down will search the previous/next occurrence.
- ^U pastes the first line of the cutbuffer at a prompt.
- Softwrapping can be done at whitespace (with --soft --atblanks).
- The ^G help texts have become searchable (with ^W and M-W).
@@ -34,28 +66,29 @@ Since 2.6.0:
- The option 'wordchars' for specifying extra word characters.
- Hi-bit control characters are shown in a more readable manner.
- The ability to use negative numbers at the Go To Line prompt.
Noteworthy changes since 2.2
----------------------------
- The ability to comment/uncomment lines with a single keystroke (M-3).
- The ability to refresh the file list in the browser (^L).
- The ability to abort re-searches (^C after an M-W).
- Better feedback at startup when opening large or multiple files.
Since 2.5.0:
- The option 'justifytrim' for snipping whitespace from justified lines.
- The ability to discard a buffer (^O ^Q) when --tempfile is used.
- Replacing things in a marked region now takes place in situ, in context,
instead of changing the view to only the marked text.
- On some terminals Ctrl+Left / Ctrl+Right now work for PrevWord/NextWord.
- On most terminals Ctrl+Left / Ctrl+Right now work for PrevWord/NextWord.
- When in the middle of a word, PrevWord now jumps to the start of this
word (like Pico does) instead of to the start of the preceding word.
- Invalid byte sequences are properly displayed and not mistakenly found.
- Resizing the window does not exit from help viewer nor file browser.
- Improved arrangement of the shortcuts in the two help lines.
- Several small bug fixes in the syntax highlighting.
- System syntaxes can be improved upon with the 'extendsyntax' command.
- The ability to delete whole words with 'cutwordleft' and 'cutwordright'.
- The ability to save a file without prompting for its name ('savefile').
- The ability to search backward without having to toggle the direction.
Since 2.4.0:
- Replacing things in a marked region now takes place in situ, in context,
instead of changing the view to only the marked text.
- Invalid byte sequences are properly displayed and not mistakenly found.
- Resizing the window does not exit from help viewer nor file browser.
Since 2.3.0:
- System syntaxes can be improved upon with the 'extendsyntax' command.
- Whitespace display (M-P) does not require configuration to be useful.
- Undo/redo is enabled by default (M-U/M-E) and works nearly everywhere
-- just not yet for justifying and indenting/unindenting.
@@ -67,25 +100,19 @@ Noteworthy changes since 2.2
- The option 'positionlog' for saving/restoring the cursor position.
- The ability to read and write vim-style lock files.
Visible changes since 2.0
-------------------------
* Editor Features
- The ability to rebind (reassign) keys using the nanorc.
Since 2.0.0:
- The ability to rebind keys, via a nanorc file.
- The ability to read standard input like a pager ("nano -").
- Color syntax highlighting can be set by the first line of a file.
- The ability to silence nanorc error messages (-q).
- Undo/redo operations (-u).
- Undo/redo operations (M-U/M-E, enabled with -u).
- Soft wrapping of text (-$).
* File Handling
- Better handling of backup files: if nano can't write a backup file,
it won't try to write the original file afterward.
- Emergency savefiles retain ownerships and permissions when possible.
- Performance improvements in color syntax highlighting.
Visible changes since 1.2
-------------------------
* Editor Features
Since 1.2.0:
- Support for UTF-8.
- Moving to a specified line and column of a file, instead of just a
line (+LINE,COLUMN).
@@ -94,7 +121,7 @@ Visible changes since 1.2
- Insertion of spaces instead of a tab when Tab is pressed (-E).
- The long option for -K is now --rebindkeypad.
- Regular expression searching can now be toggled when nano is built
with --enable-tiny, so -R now means something else (see below).
with --enable-tiny, so -R now means something else (see next item).
- Restricted mode that provides more security than -o (-R).
- Blanking of the statusbar after 1 keystroke instead of 25 (-U).
- Word searches can optionally skip over punctuation (-W).
@@ -102,70 +129,58 @@ Visible changes since 1.2
- Many more options are supported in the nanorc.
- Improvements to color syntax highlighting support: case insensitive
matching, the ability to include color syntaxes in separate files,
the ability to specify background colors without foreground colors,
etc.
the ability to specify background colors without foreground colors...
- Insertion of single-byte characters via Esc Esc <000-255>.
- Insertion of all characters via "Verbatim Input" mode.
- Insertion of any character via Meta-V, "Verbatim Input".
- Workaround for the "NumLock glitch".
- Meta-W now repeats the last search. Wrapping is now toggled via
Meta-L.
- Meta-W now repeats the last search. Wrapping is toggled via Meta-L.
- Replacing and spell checking only selected text.
- Indenting lines with one keystroke.
- Copying text into the cutbuffer without cutting it.
- Scrolling the text up and down single lines without moving the
cursor.
- Scrolling the text up and down single lines without moving the cursor.
- PageUp and PageDown work more smoothly when using -S.
- Scrolling the help text up and down single lines.
- Cutting all text from the current position to the end of the file
with one keystroke.
- Justifying the entire file with one keystroke.
with one keystroke (Meta-T).
- Justifying the entire file with one keystroke (Meta-J).
- Justifying without removing spaces from the ends of lines.
- Unjustifying after justifying and immediately resizing.
- Going to the first or last line of the current paragraph.
- Going to the first or last line of the file without having to go to
the "Search" prompt.
- Searching for filenames in the file browser.
- Displaying spaces and tabs differently to make it easier to tell
them apart.
- Many more functions available at the statusbar prompt: moving to the
next or previous word, searching for matching brackets, "Verbatim
Input" mode, etc.
- The glibc 2.2.3 crashes involving extended regular expressions are
no longer worked around, as they can break anything using extended
regular expressions, and glibc 2.2.3 is old. You should upgrade to
at least glibc 2.2.4.
* File Handling
- Spaces and tabs are shown differently to make it easier to tell them apart.
- Many more functions are available at the prompt: moving to the next or
previous word, searching for matching brackets, "Verbatim Input"...
- "To Line" (^W^T) and "Read from Command" (^R^X) return to their parent
menu when their keystroke is entered again (^W^T^T and ^R^X^X).
- Automatic adding of newlines to the ends of files without them can
now be disabled (-L).
- Converting from and to DOS/Mac file format is now toggled only at
the "Write File" prompt, via Meta-D and Meta-M, and the default file
format to save in is now set depending on what format the file was
originally in. -D now makes nano use bold text instead of reverse
video text, and Meta-D at the edit window now does a
word/line/character count. -O now makes the unused second line of
the screen part of the edit window, and Meta-O at the edit window
now toggles this behavior.
- Converting from and to DOS/Mac file format is now toggled only at the
"Write File" prompt, via Meta-D and Meta-M, and the default file format
to save in is now set depending on what format the file was originally
in. -D now makes nano use bold text instead of reverse video text,
and Meta-D at the edit window now does a word/line/character count.
-O now makes the unused second line of the screen part of the edit
window, and Meta-O now toggles this behavior while editing.
- Converting files that contain a mix of DOS and Mac format lines.
- Automatic switching on of -N with binary files has been removed, as
it causes problems with UTF-8 support.
Visible changes since 1.0
-------------------------
* Editor Features
- Complete Pico compatibility (--pico has been removed, and -p means
something else, see below).
- nanorc support (see nanorc.sample included in sources).
Since 1.0
- Complete Pico compatibility (option --pico has been removed,
and -p now means something else, see below).
- Support for nanorc files.
- Smooth scrolling (-S).
- Support for searching for matching braces, brackets, etc.
- Jumping to the matching brace, bracket, etc.
- Help for all editor features.
- Color syntax highlighting support.
- Quote string support, useful for mail agents, etc. (-Q).
- Insertion of output of external commands.
- Optional enabling of XON and XOFF control characters (-p).
- Tons of bugfixes/enhancements for already existing features.
* File Handling
- Option -o (--operatingdir) implements a chroot of sorts.
- Mouse support (-m) also allows clicking on shortcuts.
- Option -r allows a negative argument.
- Overwriting and appending or prepending to files.
- Writing marked text to separate files.
- Multiple file buffers (-F).
@@ -174,4 +189,12 @@ Visible changes since 1.0
- Creation of backup files (-B).
- Search/replace history (-H).
See the nano manual for detailed information on each feature.
Available in 1.0:
- Spell checking (^T).
- Justification (^J) and unjustification (^U).
- Internationalization (more translations are welcome).
- Help texts (^G).
- Resizing in X.
- On PageUp/Down, the cursor is put on the first screen line (like Pico).
- Tab completion at the prompt (for filenames and ~user).
- Cut-to-end-of-line option (-k).

View File

@@ -6,7 +6,12 @@ if USE_COLOR
SUBDIRS += syntax
endif
EXTRA_DIST = ChangeLog.1999-2006 ChangeLog.2007-2015 \
IMPROVEMENTS README.GIT nano.spec
EXTRA_DIST = IMPROVEMENTS
ACLOCAL_AMFLAGS = -I m4
showinfo:
@ echo
@ echo " The global nanorc file is: @sysconfdir@/nanorc"
@ echo " Syntaxes get installed in: @PKGDATADIR@/"
@ echo

389
NEWS
View File

@@ -1,3 +1,260 @@
2020.08.24 - GNU nano 5.2 "Ranrapalca"
• Making certain replacements after a large paste does not crash.
• Hitting a toggle at the Search prompt does not clear the answer.
• Using --positionlog does not complain at the first start.
• A macro containing a Search command will not sometimes fail.
2020.08.12 - GNU nano 5.1 "Cantabria"
• M-Bsp (Alt+Backspace) deletes a word backwards, like in Bash.
• M-[ has become bindable. (Be careful, though: as it is the
starting combination of many escape sequences, avoid gluing
it together with other keystrokes, like in a macro.)
• With --indicator and --softwrap, the first keystroke in an
empty buffer does not crash.
• Invoking the formatter while text is marked does not crash.
• In UTF-8 locales, an anchor is shown as a diamond.
2020.07.29 - GNU nano 5.0 "Among the fields of barley"
• With --indicator (or -q or 'set indicator') nano will show a kind
of scrollbar on the righthand side of the screen to indicate where
in the buffer the viewport is located and how much it covers.
• With <Alt+Insert> any line can be "tagged" with an anchor, and
<Alt+PageUp> and <Alt+PageDown> will jump to the nearest anchor.
When using line numbers, an anchor is shown as "+" in the margin.
• The Execute Command prompt is now directly accessible from the
main menu (with ^T, replacing the Spell Checker). The Linter,
Formatter, Spell Checker, Full Justification, Suspension, and
Cut-Till-End functions are available in this menu too.
• On terminals that support at least 256 colors, nine new color
names are available: pink, purple, mauve, lagoon, mint, lime,
peach, orange, and latte. These do not have lighter versions.
• For the color names red, green, blue, yellow, cyan, magenta,
white, and black, the prefix 'light' gives a brighter color.
Prefix 'bright' is deprecated, as it means both bold AND light.
• All color names can be preceded with "bold," and/or "italic,"
(in that order) to get a bold and/or italic typeface.
• With --bookstyle (or -O or 'set bookstyle') nano considers any
line that begins with whitespace as the start of a paragraph.
• Refreshing the screen with ^L now works in every menu.
• In the main menu, ^L also centers the line with the cursor.
• Toggling the help lines with M-X now works in all menus except
in the help viewer and the linter.
• At a filename prompt, the first <Tab> lists the possibilities,
and these are listed near the bottom instead of near the top.
• Bindable function 'curpos' has been renamed to 'location'.
• Long option --tempfile has been renamed to --saveonexit.
• Short option -S is now a synonym of --softwrap.
• The New Buffer toggle (M-F) has become non-persistent. Options
--multibuffer and 'set multibuffer' still make it default to on.
• Backup files will retain their group ownership (when possible).
• Data is synced to disk before "... lines written" is shown.
• The raw escape sequences for F13 to F16 are no longer recognized.
• Distro-specific syntaxes, and syntaxes of less common languages,
have been moved down to subdirectory syntax/extra/. The affected
distros and others may wish to move wanted syntaxes one level up.
• Syntaxes for Markdown, Haskell, and Ada were added.
2020.05.23 - GNU nano 4.9.3 "Almendras"
• One more bug introduced in version 4.9 is fixed: a crash when
the terminal screen is resized while at a lock-file prompt.
2020.04.07 - GNU nano 4.9.2 "Mali Lošinj"
• Another bug introduced in version 4.9 is fixed: a likely crash
after undoing an <Enter> at the end of leading whitespace.
2020.03.31 - GNU nano 4.9.1 "Sapperdeflap"
• Two bugs introduced in version 4.9 are fixed: the cursor
getting misplaced when undoing line cuts, and filtering
of the whole buffer to a new buffer not working.
2020.03.24 - GNU nano 4.9 "die fetten Jahre sind vorbei"
• When justifying a selection, the new paragraph and the
succeeding one get the appropriate first-line indent.
• Trying to justify an empty selection does not crash.
• Redoing the insertion of an empty file does not crash.
• On the BSDs and macOS, ^H has become rebindable again
(in most terminal emulators, not on the console).
• DOS line endings in nanorc files are accepted.
• Option --suspend / 'set suspend' has been renamed to
the more logical --suspendable / 'set suspendable'.
2020.02.07 - GNU nano 4.8 "Jaška"
• When something is pasted into nano, auto-indentation is suppressed,
and the paste can be undone as a whole with a single M-U.
• When a lock file is encountered during startup, pressing ^C/Cancel
quits nano. (Pressing 'No' just skips the file and continues.)
• Shift+Meta+letter key combos can be bound with 'bind Sh-M-letter'.
Making any such binding dismisses the default behavior of ignoring
Shift for all Meta+letter keystrokes.
• The configuration option --with-slang (to be avoided when possible)
can now be used only together with --enable-tiny.
• A custom nanorc file can be specified on the command line, with
-f filename or --rcfile=filename.
2019.12.23 - GNU nano 4.7 "Havikskruid"
• A <Tab> will indent a marked region only when mark and cursor are
on different lines.
• Two indentations (any mix of tabs and spaces) are considered the
same when they look the same (that is: indent to the same level).
• When using --breaklonglines or ^J, a line will never be broken in
its leading whitespace or quoting.
• The keywords in nanorc files must be in lowercase.
2019.11.29 - GNU nano 4.6 "And don't you eat that yellow snow"
• The 'formatter' command has returned, bound by default to M-F.
It allows running a syntax-specific command on the contents of
the buffer.
• ^T will try to run 'hunspell' before 'spell', because it checks
spellling for the locale's language and understands UTF-8.
• Multiple errors or warnings on startup will no longer slow nano
down but will be indicated on the status bar with trailing dots.
2019.10.04 - GNU nano 4.5 "Košice"
• The new 'tabgives' command allows you to specify per syntax what
the <Tab> key should produce: some spaces, a hard TAB, ...
• The output of --help is properly aligned again for all languages.
• <Tab> will indent a marked region also when M-} has been rebound.
2019.08.25 - GNU nano 4.4 "Hagelslag"
• At startup, the cursor can be put on the first or last occurrence
of a string by preceding the filename with +/string or +?string.
• When automatic hard-wrapping occurs (--breaklonglines), any leading
quoting characters will be automatically copied to the new line.
• M-6 works again also when the cursor is at end of buffer.
2019.06.18 - GNU nano 4.3 "Musa Kart"
• The ability to read from and write to a FIFO has been regained.
• Startup time is reduced by fully parsing a syntax only when needed.
• Asking for help (^G) when using --operatingdir does not crash.
• The reading of a huge or slow file can be stopped with ^C.
• Cut, zap, and copy operations are undone separately when intermixed.
• M-D reports the correct number of lines (zero for an empty buffer).
2019.04.24 - GNU nano 4.2 "Tax the rich, pay the teachers"
• The integrated spell checker does not crash when 'spell' is missing.
• Option --breaklonglines works also when --ignorercfiles is used.
• Automatic hard-wrapping is more persistent in pushing words to the
same overflow line.
2019.04.15 - GNU nano 4.1 "Qué corchos será eso?"
• By default, a newline character is again automatically added at the
end of a buffer, to produce valid POSIX text files by default, but
also to get back the easy adding of text at the bottom.
• The now unneeded option --finalnewline (-f) has been removed.
• Syntax files are read in alphabetical order when globbing, so that
the precedence of syntaxes becomes predictable.
• In the C syntax, preprocessor directives are highlighted differently.
• M-S now toggles soft wrapping, and M-N toggles line numbers.
• The jumpy-scrolling toggle has been removed.
• The legacy keystrokes ^W^Y and ^W^V are recognized again.
• Executing an external command is disallowed when in view mode.
• Problems with resizing during external or speller commands were fixed.
2019.03.24 - GNU nano 4.0 "Thy Rope of Sands"
• An overlong line is no longer automatically hard-wrapped.
• Smooth scrolling (one line at a time) has become the default.
• A newline character is no longer automatically added at end of buffer.
• The line below the title bar is by default part of the editing space.
• Option --breaklonglines (-b) turns automatic hard-wrapping back on.
• Option --jumpyscrolling (-j) gives the chunky, half-screen scrolling.
• Option --finalnewline (-f) brings back the automatic newline at EOF.
• Option --emptyline (-e) leaves the line below the title bar unused.
• <Alt+Up> and <Alt+Down> now do a linewise scroll instead of a findnext.
• Any number of justifications can be undone (like all other operations).
• When marked text is justified, it becomes a single, separate paragraph.
• Option --guidestripe=<number> draws a vertical bar at the given column.
• Option --fill=<number> no longer turns on automatic hard-wrapping.
• When a line continues offscreen, it now ends with a highlighted ">".
• The halves of a split two-column character are shown as "[" and "]".
• A line now scrolls horizontally one column earlier.
• The bindable functions 'cutwordleft' and 'cutwordright' were renamed
to 'chopwordleft' and 'chopwordright' as they don't use the cutbuffer.
• The paragraph-jumping functions were moved from Search to Go-to-Line.
• Option --rebinddelete is able to compensate for more misbindings.
• Options --morespace and --smooth are obsolete and thus ignored.
• The --disable-wrapping-as-root configure option was removed.
2018.11.11 - GNU nano 3.2 "Het kromme hout" changes the default binding
for the linter to M-B so that the spell checker (^T) can
always be used, and changes (when linting) the text in the
title bar and the color of the status bar to make linting
mode more obvious. It also adds a bindable 'zap' function
for deleting a line or marked region without changing the
cutbuffer, adds --zap to bind the <Del> and <Backspace>
keys to the zap function when something is marked, and
hard-binds <Alt+Del> to 'zap'. Furthermore, it shows the
cursor also in the help viewer (when --showcursor is used),
renames the bindable functions 'prevhistory' to 'older' and
'nexthistory' to 'newer' (update your nanorcs when needed),
reads the nanorc files also in restricted mode to allow
customization by the user (if this should not be allowed,
use --ignorercfiles in addition to --restricted), allows
in view mode to open also other files (if this should not
be allowed, use --restricted in addition to --view), makes
resizes respect a relative --fill again, no longer binds
F13...F15 by default, properly re-highlights a misspelled
word after invoking help in the internal spell checker,
and does not skip Unicode characters in string binds.
2018.09.18 - GNU nano 3.1 "Je faisais des bonds comme ça!" fixes a
misbinding of ^H on some terminals and some systems,
does not leave stray stuff after the prompt upon exit
when having suspended nano while using --constantshow,
and does not allow to toggle to Replace in view mode.
2018.09.09 - GNU nano 3.0 "Water Flowing Underground" speeds up the
reading of a file by seventy percent, roughly doubles the
speed of handling ASCII text, changes the way words at line
boundaries are deleted, makes <Ctrl+Delete> wipe the next
word and <Ctrl+Shift+Delete> the preceding word, binds M-Q
to 'findprevious' by default (the Tabs-to-Spaces toggle is
placed on M-O, and the More-Space toggle is fully removed),
makes an external spell check undoable, shows the correct
number of lines on the status bar when opening multiple
files, removes the 'formatter' command, removes the
'searchagain' bindable function (M-W is now bound to
'findnext' by default), moves the No-Convert toggle to the
Insert menu, removes the Backup and New-Buffer toggles from
the main menu (they remain in the Write-Out and Insert
menus, respectively), is more precise in what it accepts as
a rebindable key name, ignores any presses of <Esc> before
a valid command keystroke, recognizes some more escape
sequences for modified editing-pad keys, does not hide
rcfile error messages on a Linux console, renames the
bindable functions 'copytext' to 'copy' and 'uncut' to
'paste', and avoids a possible hang during a Full-Justify.
2018.06.02 - GNU nano 2.9.8 "Espresso" brings the ability to filter the
buffer (or the marked region) through an external command
(^R^X and prefix the command with the pipe symbol, "|"), is
better at detecting and maintaining paragraphs, is able to
justify //-style comments, fixes a crash when the binding
of a key to a string lacks a closing quote, gives feedback
about the number of lines written also when prepending or
appending, and fixes a couple of bugs with the linter.
2018.05.15 - GNU nano 2.9.7 "Hvide Sande" adds the option '--afterends'
for making Ctrl+Right (the nextword function) stop at word
ends instead of beginnings, accepts multibyte letters for
the Yes/No/All answers, does emergency saves of changed
buffers in the unlikely event that nano crashes, adds the
until-now missing bindable function 'linenumbers', and
renames the toggles 'constupdate' to 'constantshow' and
'cuttoend' to 'cutfromcursor', for consistency with the
corresponding options -- adjust your nanorc files soon.
2018.04.27 - GNU nano 2.9.6 "Gomance" fixes a crash in word completion,
makes --enable-altrcname work again, improves the fluidity
of scrolling when using the touchpad, tweaks the syntaxes
for shell scripts and PO files, makes a replacing session
go always forward by default, no longer inserts a newline
after an external spell check of a selected region, always
accepts the English Y and N (and A) at a yes-no prompt in
any locale, and solves a few hypothetical bugs.
2018.03.29 - GNU nano 2.9.5 "Kiša pada" changes the way the Scroll-Up
and Scroll-Down commands work (M-- and M-+): instead of
keeping the cursor in the same screen position they now
@@ -483,7 +740,7 @@
like this what could POSSIBLY go WRONG? Hahaha.
Enjoy and if you find new bugs, as always please
use Savannah's bug tracker.
http://savannah.gnu.org/bugs/?func=additem&group=nano
https://savannah.gnu.org/bugs/?func=additem&group=nano
2010.01.17 - GNU nano 2.2.2 is released for you, you, you. This
release includes fixes for: crashes when writing
@@ -566,9 +823,9 @@
without the usual truncation and a '$' symbol at the end
of the line. It can be enabled via Meta-$ inside the
editor, via the -$ or --softwrap command-line flags,
or "set softwrap" in your .nanorc). As always, please
report any bugs to the nano Savannah project page
(http://savannah.gnu.org/bugs/?func=additem&group=nano)
or via "set softwrap" in your .nanorc. As always,
please report any bugs to the nano Savannah project page
(https://savannah.gnu.org/bugs/?func=additem&group=nano)
Remember: data loss happens, back up your files.
2009.07.28 - GNU nano 2.1.10 "Ellie" is released. This version includes
@@ -596,45 +853,41 @@
birthday lenny!
2009.02.07 - GNU nano 2.1.8 "unsafe at any speed" is released. This
release include some long overdue performance
improvements in syntax color highlighting, the ability
to abort running searches (useful mainly when
editing very large files) and the ability to use nano
like a pager for viewing standard input (i.e. "nano -").
Additionally, there are gentoo syntax highlighting
updates and fixes for issues with reading files
in a directory with strange parent directory permissions.
The key bindings code was also substantially changed
in order to be more ISO-C compatible. Be sure to use
the Savannah page not only for bug reports but for any
release includes some long overdue performance improvements
in syntax color highlighting, the ability to abort running
searches (useful mainly when editing very large files) and
the ability to use nano like a pager for viewing standard
input (i.e. "nano -"). Additionally, there are gentoo
syntax highlighting updates and fixes for issues with
reading files in a directory with strange parent directory
permissions. The key-bindings code was also substantially
changed in order to be more ISO-C compatible. Be sure to
use the Savannah page not only for bug reports but for any
features you would like to see before the next stable
series is released. Have fun with it!
2008.11.10 - GNU nano 2.1.7 "Effingham" is ready to make good on those
campaign promises of lower bug rates and 50% more pie.
This release includes a new check for external
modifications when saving a file, some code and
documentation cleanups, and more bug fixes for
the new undo code (but we continue to welcome
your bug reports via the Savannah bug page at
http://savannah.gnu.org/bugs/?func=additem&group=nano).
This release includes a new check for external modifications
when saving a file, some code and documentation cleanups,
and more bug fixes for the new undo code (but we continue
to welcome your bug reports via the Savannah bug page at
https://savannah.gnu.org/bugs/?func=additem&group=nano).
Come get some.
2008.10.03 - GNU nano 2.1.6 was for new features before it was against
them. This release includes more undo capability,
several new syntax highlighting configurations including
Objective C, OCaml, and Fortran, and a new capability
to activate highlighting based on the 1st line of the
file being edited. Also, the new default configure
options now include color syntax highlighting, .nanorc
support, multibuffer and extras. These items can still
be disabled and are not enabled with --enable-tiny. Bug
fixes include better signal handling under Cygwin, and
that's about it. Again please remember to
submit bug reports via Savannah at
http://savannah.gnu.org/bugs/?func=additem&group=nano
as undo functions certainly need more testing.
Bon appetit.
them. This release includes more undo capability, several
new syntax highlighting configurations including Objective
C, OCaml, and Fortran, and a new capability to activate
highlighting based on the 1st line of the file being
edited. Also, the new default configure options now
include color syntax highlighting, .nanorc support,
multibuffer and extras. These items can still be disabled
and are not enabled with --enable-tiny. Bug fixes include
better signal handling under Cygwin, and that's about it.
Again please remember to submit bug reports via Savannah at
https://savannah.gnu.org/bugs/?func=additem&group=nano as
undo functions certainly need more testing. Bon appetit.
2008.08.30 - GNU nano 2.1.5 is ready to lead on day one. This release
contains a better fix for incorrectly reported successful
@@ -657,15 +910,15 @@
are likely to run out of space; see Savannah bug #24000.
Have fun with it!
2008.08.04 - GNU nano 2.1.3 "least stable version ever" is released. This
release includes new (and experimental) undo and redo
functionality for most text operations. The default
key bindings are Meta-U for undo and Meta-E for redo, but
these can be remapped using the new 2.1 keybinding code.
Also included are some fixes for configuring using wide
curses, crashing when invoking the help menu with
certain locales, and not saving the search history when
compiled with configure options.
2008.08.04 - GNU nano 2.1.3 "least stable version ever" is released.
This release includes new (and experimental) undo and redo
functionality for most text operations. The default key
bindings are Meta-U for undo and Meta-E for redo, but these
can be remapped using the new 2.1 keybinding code. Also
included are some fixes for configuring using wide curses,
crashing when invoking the help menu with certain locales,
and not saving the search history when compiled with
configure options.
2008.04.24 - GNU nano 2.1.2 "New York City" is released. This release
contains fixes for binding bad keys, some
@@ -1379,9 +1632,9 @@
some compatibility issues with older ncurses libraries
have also been fixed. All in all, a lot to see.
2001.01.31 - Nano 0.9.99pre2 is released. Not surprisingly, all that is
new is bugfixes, bugfixes, bugfixes. There were a few
cleanups in unneeded global variables and duplicate
2001.01.31 - Nano 0.9.99pre2 is released. Not surprisingly, all that
is new is bugfixes, bugfixes, bugfixes. There were a
few cleanups in unneeded global variables and duplicate
functions, but most is just fixing. Specifically, there
is now a preliminary (read: needs testing) fix for
resizing the editor in any mode other than normal edit
@@ -1425,9 +1678,9 @@
main reason for this release is the less-than-optimal
fix for the security issue in nano with following
symbolic links. Hopefully this will fix the problem
permanently. The --nofollow option also works again for
those who are real security nuts. There are also some
display and search fixes, and the --disable-spell
permanently. The --nofollow option also works again
for those who are real security nuts. There are also
some display and search fixes, and the --disable-spell
function was renamed to --disable-speller to be in line
with nano and Pico's "speller" term.
@@ -1551,12 +1804,11 @@
(id).
2000.06.06 - Nano 0.9.10 is primarily a bugfix for the loss of SIGINT
when using "run and terminate" flags (for example,
--help). There are also some minor documentation
updates. This version of nano is the most stable in
quite some time, and is likely to be the most stable for
awhile. Users are encouraged to upgrade to this
version.
when using "run and terminate" flags (for example, --help).
There are also some minor documentation updates. This
version of nano is the most stable in quite some time,
and is likely to be the most stable for awhile. Users
are encouraged to upgrade to this version.
2000.05.31 - Nano 0.9.9 introduces much better working i18n support,
more portability, and a ton of bugfixes. While nano is
@@ -1571,10 +1823,10 @@
are also the obligatory display fixes and speedups.
Have fun with it.
2000.05.14 - Nano 0.9.7 (the Mother's Day release) continues in the long
line of display fixes, and also fixes the broken symlink
behavior (i.e. symlinks weren't being followed by
default). Hopefully all major bugs can be worked out
2000.05.14 - Nano 0.9.7 (the Mother's Day release) continues in the
long line of display fixes, and also fixes the broken
symlink behavior (i.e. symlinks weren't being followed
by default). Hopefully all major bugs can be worked out
soon and we can have a 1.0 release before the end of the
year, but who knows.
@@ -1585,15 +1837,14 @@
most stable versions of nano to date, but this one may
not be too bad =-)
2000.05.01 - Nano 0.9.5 attempts to speed up the display of text
to be at least somewhat reasonable. Much code profiling
has been done to reduce the ridiculous number of
redundant display updates. This will probably expose a
lot of bugs that can then be fixed, so this release is
probably not for the faint of heart. For anyone
curious, I would call nano 0.9.2 the most stable version
recently, so use that if you're not particularly
concerned with being on the bleeding edge.
2000.05.01 - Nano 0.9.5 attempts to speed up the display of text to be
at least somewhat reasonable. Much code profiling has been
done to reduce the ridiculous number of redundant display
updates. This will probably expose a lot of bugs that can
then be fixed, so this release is probably not for the faint
of heart. For anyone curious, I would call nano 0.9.2 the
most stable version recently, so use that if you're not
particularly concerned with being on the bleeding edge.
2000.04.25 - Nano 0.9.4 fixes some problems in 0.9.3 with the last
line code and related segfaults. It now also has much

29
README
View File

@@ -1,5 +1,5 @@
GNU nano -- an enhanced clone of the Pico text editor
GNU nano -- a simple editor, inspired by Pico
Overview
@@ -7,25 +7,28 @@ Overview
wonderfully easy-to-use and friendly Pico text editor.
First and foremost was its license: the Pine suite does not use
the GPL or a GPL-friendly license, and has unclear restrictions on
redistribution. Because of this, Pine and Pico are not included
with many GNU/Linux distributions. Also, other features (like
go-to-line-number or search-and-replace) were unavailable until
recently or require a command-line flag. Yuck.
the GPL, and (before using the Apache License) it had unclear
restrictions on redistribution. Because of this, Pine and Pico
were not included in many GNU/Linux distributions. Furthermore,
some features (like go-to-line-number or search-and-replace) were
unavailable for a long time or require a command-line flag. Yuck.
nano aims to solve these problems by emulating the functionality of
Pico as closely as possible while addressing the problems above and
providing other extra functionality.
Nano aimed to solve these problems by: 1) being truly free software
by using the GPL, 2) emulating the functionality of Pico as closely
as is reasonable, and 3) including extra functionality by default.
Nowadays, nano wants to be a generally useful editor with sensible
defaults (linewise scrolling, no automatic line breaking).
The nano editor is an official GNU package. For more information on
GNU and the Free Software Foundation, please see http://www.gnu.org/.
GNU and the Free Software Foundation, please see https://www.gnu.org/.
How to compile and install nano
Download the nano source code, then:
Download the latest nano source tarball, then:
tar xvzf nano-x.y.z.tar.gz
cd nano-x.y.z
tar -xvf nano-x.y.tar.gz
cd nano-x.y
./configure
make
make install

View File

@@ -14,13 +14,13 @@ packages:
- autoconf (version >= 2.69)
- automake (version >= 1.14)
- autopoint (version >= 0.18.3)
- gcc (version >= 5.0)
- gettext (version >= 0.18.3)
- git (version >= 2.7.4)
- groff (version >= 1.12)
- make (any version)
- pkg-config (version >= 0.22)
- texinfo (version >= 4.0)
- gcc (any version)
- make (any version)
If you want UTF-8 support, you will also need libncursesw5-dev installed
(version >= 5.7), or libslang2-dev (version >= 2.0) if you use --with-slang.

17
THANKS
View File

@@ -4,13 +4,14 @@ If we missed you here, let us know!
Translations:
============
Sharuzzaman Ahmat Raslan <sharuzzaman@excite.com> Malay
Pedro Albuquerque <palbuquerque73@gmail.com> Portuguese
Josef Andersson <josef.andersson@fripost.org> Swedish
Laurentiu Buzdugan <buzdugan@voyager.net> Romanian
Mario Blättermann <mario.blaettermann@gmail.com> German
Ricardo Cárdenes Medina <ricardo@conisys.com> Spanish
Antonio Ceballos <aceballos@gmail.com> Spanish
Wei-Lun CHAO <chaoweilun@pcmail.com.tw> Chinese (traditional)
Seong-ho Cho <darkcircle.0426@gmail.com> Korean
Yuri Chornoivan <yurchor@ukr.net> Ukrainian
Marco Colombo <magicdice@inwind.it> Italian
Mihai Cristescu <mihai.cristescu@archlinux.info> Romanian
@@ -22,38 +23,40 @@ Rafael Fontenelle <rffontenelle@gmail.com> Brazilian Portuguese
Pavel Fric <pavelfric@seznam.cz> Czech
Jorge González <aloriel@gmail.com> Spanish
Jean-Philippe Guérard <jean-philippe.guerard@laposte.net> French
Geir Helland <pjallabais@users.sourceforge.net> Norwegian Bokmål
Tedi Heriyanto <tedi_h@gmx.net> Indonesian
Václav Haisman <V.Haisman@sh.cvut.cz> Czech
Takeshi Hamasaki <hmatrjp@users.sourceforge.jp> Japanese
Geir Helland <pjallabais@users.sourceforge.net> Norwegian Bokmål
Tedi Heriyanto <tedi_h@gmx.net> Indonesian
Kjetil Torgrim Homme <kjetilho@linpro.no> Norwegian Nynorsk
Szabolcs Horvath <horvaths@janus.gimsz.sulinet.hu> Hungarian
Jorma Karvonen <karvonen.jorma@gmail.com> Finnish
Mehmet Kececi <mkececi@mehmetkececi.com> Turkish
Mehmet Kececi <mkececi@mehmetkececi.com> Turkish
Gabor Kelemen <kelemeng@gnome.hu> Hungarian
Kalle Kivimaa <kalle.kivimaa@iki.fi> Finnish
Eivind Kjørstad <ekj@vestdata.no> Norwegian Nynorsk
Florian König <floki@bigfoot.com> German
Klemen Košir <klemen913@gmail.com> Slovenian
Wojciech Kotwica <wkotwica@post.pl> Polish
Ask Hjorth Larsen <asklarsen@gmail.com> Danish
Clement Laforet <clem_laf@wanadoo.fr> French
Ask Hjorth Larsen <asklarsen@gmail.com> Danish
LI Daobing <lidaobing@gmail.com> Chinese (simplified)
Jordi Mallach <jordi@gnu.org> Catalan
João Victor Duarte Martins <jvdm@sdf.lonestar.org> Brazilian Portuguese
Pavel Maryanov <acid@jack.kiev.ua> Russian
Daniele Medri <madrid@linux.it> Italian
Gergely Nagy <algernon@debian.org> Hungarian
Claudio Neves <cneves@nextis.com> Brazilian Portuguese
Kalle Olavi Niemitalo <kon@iki.fi> Finnish
Мирослав Николић <miroslavnikolic@rocketmail.com> Serbian
Claudio Neves <cneves@nextis.com> Brazilian Portuguese
Lauri Nurmi <lanurmi@iki.fi> Finnish
Daniel Nylander <po@danielnylander.se> Swedish
Mikel Olasagasti <hey_neken@mundurat.net> Basque
Yi-Jyun Pan <pan93412@gmail.com> Chinese (traditional)
Michael Piefel <piefel@informatik.hu-berlin.de> German
Sergey Poznyakoff <gray@gnu.org> Polish
Božidar Putanec <bozidarp@yahoo.com> Croatian
Trần Ngọc Quân <vnwildman@gmail.com> Vietnamese
Sharuzzaman Ahmat Raslan <sharuzzaman@excite.com> Malay
Sergey A. Ribalchenko <fisher@obu.ck.ua> Ukrainian and Russian
Michel Robitaille <robitail@IRO.UMontreal.CA> French
Christian Rose <menthos@menthos.com> Swedish
@@ -76,6 +79,7 @@ Miquel Vidal <miquel@sindominio.net> Catalan
Phan Vinh Thinh <teppi82@gmail.com> Vietnamese
Pauli Virtanen <pauli.virtanen@saunalahti.fi> Finnish
Aron Xu <happyaron.xu@gmail.com> Chinese (simplified)
Boyuan Yang <073plan@gmail.com> Chinese (simplified)
Peio Ziarsolo <peio@sindominio.net> Basque
Anton Zinoviev <zinoviev@debian.org> Bulgarian
@@ -84,6 +88,7 @@ Other stuff:
===========
Ben Armstrong <synrg@sanctuary.nslug.ns.ca> Negative -r value idea, code
Thomas Dickey <dickey@herndon4.his.com> Curses help and advice
Kamil Dudka <kdudka@redhat.com> Several small bug fixes
Sven Guckes <guckes@math.fu-berlin.de> Advice and advocacy
Thijs Kinkhorst <thijs@kinkhorst.com> rnano.1 manpage
Jim Knoble <jmknoble@pobox.com> Pico compat for browser

82
TODO
View File

@@ -1,83 +1,5 @@
A list of desired features
--------------------------
Somewhat urgent:
- Make undo/redo work also for justifying.
- Detect when text is being pasted, so that we can handle it faster.
See https://savannah.gnu.org/bugs/?40060.
- Allow color syntaxes to apply to more than just color, so that we can
e.g. specify a different alternate spell checker depending on which
file type we have open.
- Allow piping marked text to an external command and replacing it with
the command's output -- that is: generalize the spell-check flow.
See also https://savannah.gnu.org/bugs/?28993.
For a list of open bugs and requested features see:
Vague musings:
- Add support for right-to-left text (RTL), through FriBidi?
- Allow setting marks (saved positions, not to be confused with the
mark set via Ctrl-^) at various lines and/or columns in the buffer,
and allow movement between them with a single keystroke?
- Make matching bracket searches sophisticated enough to skip over
brackets inside comments?
https://savannah.gnu.org/bugs/?group=nano
For version 2.9:
- Make undo/redo work also for indenting. [DONE]
- Allow to record and replay a macro: a stored series of keystrokes. [DONE]
For version 2.8:
- Allow text searches in the help viewer. [DONE]
For version 2.4:
- Handle window resizes better. After we've resized, we should stay
wherever we were before we resized, as Pico does. [DONE]
- Allow even better file-type detection than we have currently, e.g.
through libmagic. [DONE]
- Compatibility with vim status files to let other editors know we're
in a file. [DONE]
For version 2.2:
- Rebindable keys? [DONE]
- Undo/Redo keys (M-U and M-E)? [DONE]
- Fix problems with color syntaxes highlighting lines too aggressively. [DONE]
- Allow nano to work like a pager (reading from stdin). [DONE]
- Select a color syntax based on more than just the filename extension. [DONE]
- Allow soft wrapping as well as hard wrapping? [DONE]
For version 2.0:
- UTF-8 support. [DONE]
- Support for paragraph searches. [DONE]
- Support for justifying the entire file at once. [DONE]
- Support for filename searches in the file browser. [DONE]
- Keystroke to implement "Add next sequence as raw" like vi's ^V. [DONE]
- Spell check selected text only. [DONE]
- Make "To Line" (^W^T) and "Read from Command" (^R^X) reenter their
parent menu when their keystroke is entered a second time (^W^T^T and
(^R^X^X) (requires figuring out when to keep cursor position and when
not to). [DONE]
- Fix resetstatuspos global which we shouldn't have. [DONE]
For version 1.2:
- Single-line scroll up/down? [DONE]
- Color syntax highlighting? (There seems to be a demand for it.) [DONE]
- Support for a .nanorc file. [DONE]
- Backup making (filename~)? [DONE]
- Search/replace string history. [DONE]
- Implement Pico's -j and -g flags, as they are pretty easy to do. [DONE]
- Make mouse support work with clicking on the shortcuts (-m). [DONE]
- Implement -o (--operatingdir, a chroot of sorts). [DONE]
- Allow -r to take a negative argument, meaning right margin instead of
left (allows resizing that way), formerly -W arg. [DONE]
For version 1.0:
- Implement Spelling. [DONE]
- Implement Help. [DONE]
- Internationalization [In progress, translators welcome!]
- Allow nano to be resized in X. [DONE]
- On PageUp/Down, put the cursor on the first line (like Pico), not the
center line. [DONE]
- Implement justify function. [DONE]
- Cut to end of line. [DONE]
- Built-in speller command. [DONE]
- Better statusbar interaction (scrolling, tab completion). [DONE]
- Unjustify command (^U after ^J). [DONE]
- Username completion (~user). [DONE]

View File

@@ -2,7 +2,7 @@
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="59e59d99bc1ca635d178778b9b4ee544330775c4"
gnulib_hash="6a78706ae230ad24bc06d33d9eddca25806ffb2a"
modules="
futimens
@@ -30,7 +30,7 @@ modules="
# Make sure the local gnulib git repo is up-to-date.
if [ ! -d "gnulib" ]; then
git clone --depth=123 ${gnulib_url}
git clone --depth=1111 ${gnulib_url}
fi
cd gnulib >/dev/null || exit 1
curr_hash=$(git log -1 --format=%H)

View File

@@ -1,6 +1,6 @@
# Configuration for GNU nano - a small and user-friendly text editor
#
# Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc.
# Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc.
# Copyright (C) 2014, 2017 Mike Frysinger
#
# GNU nano is free software: you can redistribute it and/or modify
@@ -14,9 +14,9 @@
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
# along with this program. If not, see https://www.gnu.org/licenses/.
AC_INIT([GNU nano], [2.9.5], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [5.2], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.14])
@@ -56,12 +56,46 @@ dnl Data location.
pkgdatadir=${datadir}/${PACKAGE}
AC_DEFINE_DIR([PKGDATADIR], [pkgdatadir], [Where data are placed to.])
dnl Whether this is a git repository.
AC_MSG_CHECKING([whether building from git])
if test -f roll-a-release.sh ; then
AC_MSG_RESULT([yes])
from_git=yes
else
AC_MSG_RESULT([no])
from_git=no
fi
AM_CONDITIONAL(BUILDING_FROM_GIT, test x$from_git = xyes)
dnl Checks for pkg-config and gettext when building from git.
if test x$from_git = xyes; then
if test ! -f $(aclocal --print-ac-dir)/pkg.m4; then
AC_MSG_ERROR([
*** The pkg.m4 macros are missing. ***
*** The pkg-config package needs to be installed when building from git. ***
*** After fixing this problem, rerun ./autogen.sh. ***])
fi
if test "$ac_cv_path_MSGFMT" = ":"; then
AC_MSG_ERROR([
*** The msgfmt program is missing. ***
*** The gettext package needs to be installed when building from git. ***])
fi
fi
dnl Checks for header files.
AC_CHECK_HEADERS(libintl.h limits.h pwd.h termios.h sys/param.h)
dnl Checks for options.
if test "x$with_slang" = xyes; then
if test "x$enable_tiny" != xyes; then
AC_MSG_ERROR([--with-slang is supported only together with --enable-tiny])
fi
fi
AC_ARG_ENABLE(browser,
AS_HELP_STRING([--disable-browser], [Disable the built-in file browser]))
if test "x$enable_tiny" = xyes; then
@@ -271,12 +305,6 @@ if test "x$enable_wrapping" != xno; then
AC_DEFINE(ENABLE_WRAPPING, 1, [Define this to have hard text wrapping.])
fi
AC_ARG_ENABLE(wrapping-as-root,
AS_HELP_STRING([--disable-wrapping-as-root], [Disable wrapping of text as root by default]))
if test "x$enable_wrapping_as_root" = xno; then
AC_DEFINE(DISABLE_ROOTWRAPPING, 1, [Define this to disable text wrapping as root by default.])
fi
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug], [Enable debugging (disabled by default)]))
if test "x$enable_debug" = xyes; then
@@ -398,10 +426,10 @@ int main(void)
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
AC_MSG_WARN([*** Can not use slang when cross-compiling])),
AC_MSG_ERROR([
*** The header file slcurses.h was not found. If you wish to use
*** slang support this header file is required. Please either
*** install a version of slang that includes the slcurses.h file or
*** do not call the configure script with --with-slang.]))
*** The header file slcurses.h was not found. This header file
*** is required if you wish to use Slang support. Please either
*** install a version of Slang that includes the slcurses.h file
*** or do not call the configure script with --with-slang.]))
fi
if eval "test x$CURSES_LIB_NAME = x"; then
@@ -479,10 +507,10 @@ int main(void)
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
AC_MSG_WARN([*** Can not use slang when cross-compiling])),
AC_MSG_ERROR([
*** The header file slcurses.h was not found. If you wish to use
*** slang support this header file is required. Please either
*** install a version of slang that includes the slcurses.h file or
*** do not call the configure script with --with-slang.]))
*** The header file slcurses.h was not found. This header file
*** is required if you wish to use Slang support. Please either
*** install a version of Slang that includes the slcurses.h file
*** or do not call the configure script with --with-slang.]))
fi
if test "${_libs+set}" = "set"; then
@@ -495,7 +523,6 @@ int main(void)
;;
esac], [AC_MSG_RESULT(no)])
dnl Checks for functions.
if test "x$enable_utf8" != xno; then
@@ -566,11 +593,11 @@ fi
if eval "test x$CURSES_LIB_NAME = x"; then
AC_MSG_ERROR([
*** No curses lib was found. Please install the curses header files
*** from libncursesw5-dev (Debian), ncurses-devel (Fedora), or similar.
*** (Or install ncurses from https://ftp.gnu.org/gnu/ncurses/.)])
*** No curses lib was found. Please install the curses header files
*** from libncursesw5-dev (Debian), ncurses-devel (Fedora), or similar.
*** (Or install ncurses from https://ftp.gnu.org/gnu/ncurses/.)])
else
AC_MSG_RESULT([Using $CURSES_LIB_NAME as the curses library])
AC_MSG_RESULT([ The curses library to be used is: $CURSES_LIB_NAME])
fi
AC_CHECK_LIB([$CURSES_LIB_NAME], [use_default_colors],
@@ -601,18 +628,16 @@ if test "x$enable_utf8" != xno && \
else
if test "x$enable_utf8" = xyes; then
AC_MSG_ERROR([
*** UTF-8 support was requested, but insufficient UTF-8 support was
*** detected in your curses and/or C libraries. Please verify that your
*** slang was built with UTF-8 support or your curses was built with
*** wide character support, and that your C library was built with wide
*** character support.])
*** UTF-8 support was requested, but insufficient support was
*** detected in your curses and/or C libraries. Please verify
*** that both your curses library and your C library were built
*** with wide-character support.])
elif test "x$enable_utf8" != xno; then
AC_MSG_WARN([
*** Insufficient UTF-8 support was detected in your curses and/or C
*** libraries. If you want UTF-8 support, please verify that your slang
*** was built with UTF-8 support or your curses was built with wide
*** character support, and that your C library was built with wide
*** character support.])
*** Insufficient UTF-8 support was detected in your curses
*** and/or C libraries. If you want UTF-8 support, please
*** verify that both your curses library and your C library
*** were built with wide-character support.])
fi
fi
@@ -638,55 +663,6 @@ fi
AC_DEFINE_UNQUOTED(NANO_REG_EXTENDED, $nano_reg_extended,
[Flag(s) to use to get the full range of extended regular expressions])
# Check for word-boundary support (/< and />).
AC_MSG_CHECKING([for GNU-style word boundary regex support])
AC_ARG_WITH(wordbounds,
AS_HELP_STRING([--with-wordbounds], [Use GNU-style word boundary delimiters]),
[with_wordbounds=$withval], [with_wordbounds=auto])
if test "$with_wordbounds" != "no"; then
dnl If we're using the bundled gnulib regex module, we know it's supported.
if test "$ac_use_included_regex" = "yes"; then
with_wordbounds="yes"
fi
dnl We explicitly don't check if the user forced the option, because
dnl this is needed for cross compilers and we can't test the target.
if test "$with_wordbounds" != "yes"; then
AC_TRY_RUN([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <regex.h>
int main(void)
{
regex_t r;
size_t nmatch;
regmatch_t pmatch;
if (regcomp(&r, "\\\\>", $nano_reg_extended|REG_NOSUB))
return 1;
if (regexec(&r, "word boundary", nmatch, &pmatch, 0))
return 1;
return 0;
}],
with_wordbounds="yes",
with_wordbounds="no",
with_wordbounds="cross")
fi
fi
case $with_wordbounds in
yes)
AC_MSG_RESULT(yes)
AC_DEFINE(GNU_WORDBOUNDS, 1, [Define this if the system supports GNU-style word boundaries in regexes.])
;;
no)
AC_MSG_RESULT(no)
;;
cross)
AC_MSG_WARN([*** Can't check for GNU-style word boundary support when cross-compiling])
;;
esac
if test x$color_support = xyes; then
# if test x$CURSES_LIB_NAME = xcurses; then
AC_MSG_CHECKING([whether _XOPEN_SOURCE_EXTENDED is needed])
@@ -742,8 +718,9 @@ AC_MSG_CHECKING([for HTML support in groff])
groff -t -mandoc -Thtml </dev/null >/dev/null
if test $? -ne 0 ; then
AC_MSG_RESULT([no])
AC_MSG_WARN([*** Will not generate HTML version of man pages ***
*** Consider installing a newer version of groff with HTML support ***])
AC_MSG_WARN([
*** Will not generate HTML version of man pages. ***
*** Consider installing a newer version of groff with HTML support. ***])
groff_html_support=no
else
AC_MSG_RESULT([yes])
@@ -751,17 +728,6 @@ else
fi
AM_CONDITIONAL(GROFF_HTML, test x$groff_html_support = xyes)
# Check whether this is a git repository.
AC_MSG_CHECKING([whether building from git])
if test -d .git ; then
AC_MSG_RESULT([yes])
from_git=yes
else
AC_MSG_RESULT([no])
from_git=no
fi
AM_CONDITIONAL(BUILDING_FROM_GIT, test x$from_git = xyes)
AC_CONFIG_FILES([
Makefile
doc/Makefile
@@ -771,7 +737,8 @@ m4/Makefile
po/Makefile.in
src/Makefile
syntax/Makefile
nano.spec
])
AC_OUTPUT
make showinfo

134
doc/cheatsheet.html Normal file
View File

@@ -0,0 +1,134 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title>Cheatsheet for nano</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="A concise overview of the command shortcuts of the GNU nano editor, grouped by category.">
<meta name="keywords" content="cheatsheet, nano, editor, shortcuts, keystrokes, functions, operations, commands">
<meta name="author" content="Benno Schulenberg">
</head>
<body>
<br>
<h1 align="center">Overview of nano's shortcuts &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</h1>
<h3 align="center">The editor's keystrokes and their functions &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</h3>
<br>
<table align="center"><tbody>
<tr><td>
<b>File handling</b>
<table><tbody>
<tr><td>Ctrl+S &nbsp;&nbsp;</td><td>Save current file</td></tr>
<tr><td>Ctrl+O</td><td>Offer to write file ("Save as")</td></tr>
<tr><td>Ctrl+R</td><td>Insert a file into current one</td></tr>
<tr><td>Ctrl+X</td><td>Close buffer, exit from nano</td></tr>
</tbody></table>
<br>
<b>Editing</b>
<table><tbody>
<tr><td>Ctrl+K &nbsp;&nbsp;</td><td>Cut current line into cutbuffer</td></tr>
<tr><td>Alt+6</td><td>Copy current line into cutbuffer</td></tr>
<tr><td>Ctrl+U</td><td>Paste contents of cutbuffer</td></tr>
<tr><td>Alt+T</td><td>Cut until end of buffer</td></tr>
<tr><td>Ctrl+]</td><td>Complete current word</td></tr>
<tr><td>Alt+3</td><td>Comment/uncomment line/region</td></tr>
<tr><td>Alt+U</td><td>Undo last action</td></tr>
<tr><td>Alt+E</td><td>Redo last undone action</td></tr>
</tbody></table>
<br>
<b>Search and replace</b>
<table><tbody>
<tr><td>Ctrl+Q &nbsp;&nbsp;</td><td>Start backward search</td></tr>
<tr><td>Ctrl+W</td><td>Start forward search</td></tr>
<tr><td>Alt+Q</td><td>Find next occurrence backward</td></tr>
<tr><td>Alt+W</td><td>Find next occurrence forward</td></tr>
<tr><td>Alt+R</td><td>Start a replacing session</td></tr>
</tbody></table>
<br>
<b>Deletion</b>
<table><tbody>
<tr><td>Ctrl+H</td><td>Delete character before cursor &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>
<tr><td>Ctrl+D</td><td>Delete character under cursor</td></tr>
<tr><td>Alt+Bsp</td><td>Delete word to the left</td></tr>
<tr><td>Ctrl+Del &nbsp;&nbsp;</td><td>Delete word to the right</td></tr>
<tr><td>Alt+Del</td><td>Delete current line</td></tr>
</tbody></table>
<br>
<b>Operations</b>
<table><tbody>
<tr><td>Ctrl+T &nbsp;&nbsp;</td><td>Execute some command</td></tr>
<tr><td>Ctrl+J</td><td>Justify paragraph or region</td></tr>
<tr><td>Alt+J</td><td>Justify entire buffer</td></tr>
<tr><td>Alt+B</td><td>Run a syntax check</td></tr>
<tr><td>Alt+F</td><td>Run a formatter/fixer/arranger</td></tr>
<tr><td>Alt+:</td><td>Start/stop recording of macro</td></tr>
<tr><td>Alt+;</td><td>Replay macro</td></tr>
</tbody></table>
<br>
</td><td>
<b>Moving around</b>
<table><tbody>
<tr><td>Ctrl+B &nbsp;&nbsp;</td><td>One character backward</td></tr>
<tr><td>Ctrl+F</td><td>One character forward</td></tr>
<tr><td>Ctrl+<b>&leftarrow;</b></td><td>One word backward</td></tr>
<tr><td>Ctrl+<b>&rightarrow;</b></td><td>One word forward</td></tr>
<tr><td>Ctrl+A</td><td>To start of line</td></tr>
<tr><td>Ctrl+E</td><td>To end of line</td></tr>
<tr><td>Ctrl+P</td><td>One line up</td></tr>
<tr><td>Ctrl+N</td><td>One line down</td></tr>
<tr><td>Ctrl+<b>&uparrow;</b></td><td>To previous block</td></tr>
<tr><td>Ctrl+<b>&downarrow;</b></td><td>To next block</td></tr>
<tr><td>Ctrl+Y</td><td>One page up</td></tr>
<tr><td>Ctrl+V</td><td>One page down</td></tr>
<tr><td>Alt+\</td><td>To top of buffer</td></tr>
<tr><td>Alt+/</td><td>To end of buffer</td></tr>
</tbody></table>
<br>
<b>Special movement</b>
<table><tbody>
<tr><td>Alt+G &nbsp;&nbsp;&nbsp;</td><td>Go to specified line</td></tr>
<tr><td>Alt+]</td><td>Go to complementary bracket</td></tr>
<tr><td>Alt+<b>&uparrow;</b></td><td>Scroll viewport up</td></tr>
<tr><td>Alt+<b>&downarrow;</b></td><td>Scroll viewport down</td></tr>
<tr><td>Alt+&lt;</td><td>Switch to preceding buffer</td></tr>
<tr><td>Alt+&gt;</td><td>Switch to succeeding buffer</td></tr>
</tbody></table>
<br>
<b>Information</b>
<table><tbody>
<tr><td>Ctrl+C &nbsp;&nbsp;</td><td>Report cursor position</td></tr>
<tr><td>Alt+D</td><td>Report word/line/char count</td></tr>
<tr><td>Ctrl+G</td><td>Display help text</td></tr>
</tbody></table>
<br>
<b>Various</b>
<table><tbody>
<tr><td>Alt+A</td><td>Turn the mark on/off</td></tr>
<tr><td>Tab</td><td>Indent marked region</td></tr>
<tr><td>Shift+Tab &nbsp;&nbsp;</td><td>Unindent marked region</td></tr>
<tr><td>Alt+N</td><td>Turn line numbers on/off</td></tr>
<tr><td>Alt+P</td><td>Turn visible whitespace on/off</td></tr>
<tr><td>Alt+V</td><td>Enter next keystroke verbatim</td></tr>
<tr><td>Ctrl+L</td><td>Refresh the screen</td></tr>
<tr><td>Ctrl+Z</td><td>Suspend nano</td></tr>
</tbody></table>
<br>
</td></tr>
</tbody></table>
</body>
</html>

View File

@@ -1,9 +1,12 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title>The GNU nano editor FAQ</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="The genesis story of the nano editor, plus the solution to some common problems.">
</head>
<body text="#330000" bgcolor="#ffffff" link="#0000ef" vlink="#51188e" alink="#ff0000">
<h1>The GNU nano editor FAQ</h1>
@@ -28,29 +31,24 @@
<a href="#3.1">3.1. How do I install the RPM or DEB package?</a><br>
<a href="#3.2">3.2. Compiling from source: WHAT THE HECK DO I DO NOW?</a><br>
<a href="#3.3">3.3. Why does everything go into /usr/local?</a><br>
<a href="#3.5">3.5. nano should automatically run strip on the binary when installing it!</a><br>
<a href="#3.6">3.6. How can I make the executable smaller? This is too bloated!</a><br>
<a href="#3.7">3.7. Tell me more about this multibuffer stuff!</a><br>
<a href="#3.8">3.8. Tell me more about this verbatim input stuff!</a><br>
<a href="#3.9a">3.9a. How do I make a .nanorc file that nano will read when I start it?</a><br>
<a href="#3.9b">3.9b. How about in Win32?</a>
<a href="#3.4">3.4. nano should automatically run strip on the binary when installing it!</a><br>
<a href="#3.5">3.5. How can I make the executable smaller? This is too bloated!</a><br>
<a href="#3.6">3.6. Tell me more about this multibuffer stuff!</a><br>
<a href="#3.7">3.7. Tell me more about this verbatim input stuff!</a><br>
<a href="#3.8">3.8. How do I make a .nanorc file that nano will read when I start it?</a><br>
<a href="#3.9">3.9. Why does my self-compiled nano not read /etc/nanorc?</a><br>
</p></blockquote>
<h3><a href="#4">4. Running</a></h3>
<blockquote><p>
<a href="#4.1">4.1. How do I open a file with a name beginning with '+' from the command line?</a><br>
<a href="#4.2">4.2. Ack! My Backspace/Delete/Enter/Meta/double bucky key doesn't seem to work! What can I do?</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.4">4.4. Ack! When I hold down a Meta key combination for a while, the character of the held key gets inserted now and then. What gives?</a><br>
<a href="#4.5">4.5. How do I type the F13-F16 keys listed in the help viewer? My keyboard only has F1-F12!</a><br>
<a href="#4.6">4.6. nano crashes when I type &lt;insert keystrokes here&gt;!</a><br>
<a href="#4.7">4.7. nano crashes when I resize my window. How can I fix that?</a><br>
<a href="#4.8a">4.8a. With what keystroke can I paste text from the clipboard into nano?</a><br>
<a href="#4.8b">4.8b. 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.8c">4.8c. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?<a><br>
<a href="#4.9">4.9. I've compiled nano with color support, but I don't see any color when I run it!</a><br>
<a href="#4.10">4.10. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
<a href="#4.11">4.11. How do I select text for or paste text from the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?</a><br>
<a href="#4.12">4.12. On startup I get a message that says "Detected a legacy nano history file". Now older nano versions can't find my search history!</a>
<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>
</p></blockquote>
<h3><a href="#5">5. Internationalization</a></h3>
<blockquote><p>
@@ -77,13 +75,13 @@
<h1><a name="1"></a>1. General</h1>
<h3><a name="1.1"></a>1.1. What is GNU nano?</h3>
<blockquote><p>GNU nano is designed to be a free replacement for the Pico text editor, part of the Pine email suite from <a href="http://www.washington.edu/pine/">The University of Washington</a>. It aims to &quot;emulate Pico as closely as possible and then include extra functionality&quot;.</p></blockquote>
<blockquote><p>GNU nano was designed to be a free replacement for the Pico text editor, part of the Pine email suite from <a href="http://www.washington.edu/pine/">The University of Washington</a>. It aimed to &quot;emulate Pico as closely as is reasonable and then include extra functionality&quot;.</p></blockquote>
<h3><a name="1.2"></a>1.2. What is the history behind nano?</h3>
<blockquote><p>Funny you should ask!</p>
<p><b>In the beginning...</b></p>
<p>For years Pine was THE program used to read email on a Unix system. The Pico text editor is the portion of the program one would use to compose his or her mail messages. Many beginners to Unix flocked to Pico and Pine because of their well organized, easy to use interfaces. With the proliferation of GNU/Linux in the mid to late 90's, many University students became intimately familiar with the strengths (and weaknesses) of Pine and Pico.</p>
<p><b>Then came Debian...</b></p>
<p>The <a href="http://www.debian.org/">Debian GNU/Linux</a> distribution, known for its strict standards in distributing truly &quot;free&quot; software (i.e. software with no restrictions on redistribution), would not include a binary package for Pine or Pico. Many people had a serious dilemma: they loved these programs, but the versions available at the time were not truly free software in the <a href="http://www.gnu.org/philosophy/free-sw.html">GNU</a> sense of the word.</p>
<p>The <a href="https://www.debian.org/">Debian GNU/Linux</a> distribution, known for its strict standards in distributing truly &quot;free&quot; software (i.e. software with no restrictions on redistribution), would not include a binary package for Pine or Pico. Many people had a serious dilemma: they loved these programs, but the versions available at the time were not truly free software in the <a href="https://www.gnu.org/philosophy/free-sw.html">GNU</a> sense of the word.</p>
<p><b>The event...</b></p>
<p>It was in late 1999 when Chris Allegretta (our hero) was yet again complaining to himself about the less-than-perfect license Pico was distributed under, the 1000 makefiles that came with it and how just a few small improvements could make it the Best Editor in the World (TM). Having been a convert from Slackware to Debian, he missed having a simple binary package that included Pine and Pico, and had grown tired of downloading them himself.</p>
<p>Finally something snapped inside and Chris coded and hacked like a madman for many hours straight one weekend to make a (barely usable) Pico clone, at the time called TIP (Tip Isn't Pico). The program could not be invoked without a filename, could not save files, had no help text display, spell checker, and so forth. But over time it improved, and with the help of a few great coders it matured to the (hopefully) stable state it is in today.</p>
@@ -91,7 +89,7 @@
<h3><a name="1.3"></a>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><a name="1.4"></a>1.4. What is the current version of nano?</h3>
<blockquote><p>The current version of nano <i>should</i> be <b>2.9.5</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>5.2</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><a name="1.5"></a>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%">
@@ -100,8 +98,8 @@
<h3><a name="2.1"></a>2.1. Web sites that carry nano.</h3>
<blockquote><p>The nano source tarballs can be downloaded from the following web sites:</p>
<ul>
<li><a href="https://nano-editor.org/dist/">https://nano-editor.org/dist/</a></li>
<li><a href="https://ftp.gnu.org/gnu/nano/">https://ftp.gnu.org/gnu/nano/</a></li>
<li><a href="https://nano-editor.org/dist/latest/">https://nano-editor.org/dist/latest/</a></li>
<li><a href="https://ftpmirror.gnu.org/gnu/nano/">https://ftpmirror.gnu.org/gnu/nano/</a></li>
</ul>
</blockquote>
<h3><a name="2.2"></a>2.2. RPM packages (RedHat, OpenSuse, and derivatives).</h3>
@@ -114,11 +112,11 @@
<h3><a name="2.3"></a>2.3. Deb packages (Debian and derivatives):</h3>
<blockquote><p>Debian users can check out the current nano packages for:</p>
<ul>
<li><a href="http://packages.debian.org/stable/editors/nano">stable</a></li>
<li><a href="http://packages.debian.org/testing/editors/nano">testing</a></li>
<li><a href="http://packages.debian.org/unstable/editors/nano">unstable</a></li>
<li><a href="https://packages.debian.org/stable/editors/nano">stable</a></li>
<li><a href="https://packages.debian.org/testing/editors/nano">testing</a></li>
<li><a href="https://packages.debian.org/unstable/editors/nano">unstable</a></li>
</ul>
<p>You can also have a look at the <a href="ftp://ftp.debian.org/debian/pool/main/n/nano/">Package Pool</a> to see all the available binary and source packages.</p>
<p>You can also have a look at the <a href="http://ftp.debian.org/debian/pool/main/n/nano/">Package Pool</a> to see all the available binary and source packages.</p>
</blockquote>
<h3><a name="2.4"></a>2.4. By GIT (for the brave).</h3>
<blockquote><p>For the 'bleeding edge' current version of nano, you can use GIT to download the current source code. <b>Note:</b> believe it or not, by downloading code that has not yet stabilized into an official release, there could quite possibly be bugs, in fact the code may not even compile! Anyway, see <a href="http://git.savannah.gnu.org/cgit/nano.git/tree/README.GIT">the nano GIT document</a> for info on anonymous GIT access to the nano source.</p></blockquote>
@@ -126,23 +124,23 @@
<h1><a name="3"></a>3. Installation and Configuration</h1>
<h3><a name="3.1"></a>3.1. How do I install the RPM or DEB package?</h3>
<blockquote><p>It's simple really! As root, type <b>rpm -Uvh nano-x.y.z-1.i386.rpm</b> if you have a RedHat-ish system or <b>dpkg -i nano_x.y.z-1.deb</b> if you have a Debian-ish system, where <b>x.y.z</b> is the release of nano. There are other programs to install packages, and if you wish to use those, knock yourself out.</p></blockquote>
<blockquote><p>It's simple really! As root, type <b>rpm -Uvh nano-x.y-1*.rpm</b> if you have a RedHat-ish system or <b>dpkg -i nano_x.y-1*.deb</b> if you have a Debian-ish system, where <b>x.y</b> is the version number of nano. There are other programs to install packages, and if you wish to use those, knock yourself out.</p></blockquote>
<h3><a name="3.2"></a>3.2. Compiling from source: WHAT THE HECK DO I DO NOW?</h3>
<blockquote><p>Okay, take a deep breath, this really isn't hard. Unpack the nano source with a command like:</p>
<p><b>tar -xvf nano-x.y.z.tar.gz</b></p>
<p><b>tar -xvf nano-x.y.tar.gz</b></p>
<p>Then you need to run <b>configure</b> with any options you might want (if any).</p>
<p>The average case is this:</p>
<p><b>cd nano-x.y.z/</b><br>
<p><b>cd nano-x.y/</b><br>
<b>./configure</b><br>
<b>make</b><br>
<b>make install</b> (as root, of course)</p></blockquote>
<h3><a name="3.3"></a>3.3. Why does everything go into /usr/local?</h3>
<blockquote><p>Well, that's what the <b>configure</b> script defaults to. If you wish to change this, simply do this:</p>
<p><b>./configure --prefix=/usr</b></p>
<p>to put nano into /usr/bin when you run <b>make install</b>.</p></blockquote>
<h3><a name="3.5"></a>3.5. nano should automatically run strip on the binary when installing it!</h3>
<blockquote><p>Actually, it does, but you have to use <b>make install-strip</b>. The default make install does not, and will not, run strip automatically.</p></blockquote>
<h3><a name="3.6"></a>3.6. How can I make the executable smaller? This is too bloated!</h3>
<p>This will put nano into /usr/bin when you run <b>make install</b>.</p></blockquote>
<h3><a name="3.4"></a>3.4. nano should automatically run strip on the binary when installing it!</h3>
<blockquote><p>It does when you use <b>make install-strip</b>. The default <b>make install</b> does not, and will not, run strip automatically.</p></blockquote>
<h3><a name="3.5"></a>3.5. How can I make the executable smaller? This is too bloated!</h3>
<blockquote><p>Actually, there are several parts of the editor that can be disabled. You can pass arguments to the <b>configure</b> script that disable certain features. Here's a brief list:</p>
<pre>
<b>--disable-browser</b> Disable the built-in file browser
@@ -162,54 +160,64 @@
<b>--disable-tabcomp</b> Disable the tab-completion functions
<b>--disable-wordcomp</b> Disable the word-completion function
<b>--disable-wrapping</b> Disable all hard-wrapping of text</pre>
<p>There's also the <b>--enable-tiny</b> option which disables everything above, as well as some larger chunks of the program (like the marker code that you use with Control-^ to select text). Also, if you know you aren't going to be using other languages, you can use <b>--disable-nls</b> to disable internationalization and save a few K to a few dozen K depending on whether you have locale support on your system. And finally, there's always good old <b>strip</b> to strip all debugging code and code that exists in libraries on your system.</p>
<p>With <b>--disable-wrapping-as-root</b> you can disable any hard-wrapping by default when the user is root, useful to prevent accidentally changing long lines in system configuration files.</p>
<p>There's also the <b>--enable-tiny</b> option which disables everything above, as well as some larger chunks of the program (like the undo/redo code and the code for selecting text). Also, if you know you don't need other languages, you can use <b>--disable-nls</b> to disable internationalization and save a few kilobytes. And finally, there's always good old <b>strip</b> to remove all unneeded symbols.</p>
</blockquote>
<h3><a name="3.7"></a>3.7. Tell me more about this multibuffer stuff!</h3>
<h3><a name="3.6"></a>3.6. Tell me more about this multibuffer stuff!</h3>
<blockquote><p>To use multiple file buffers, you must not have configured nano with <b>--disable-multibuffer</b> nor with <b>--enable-tiny</b> (use <b>nano -V</b> to check the compilation options). Then when you want to insert a file into its own buffer instead of into the current file, just hit <b>Meta-F</b> after typing <b>^R</b>. If you always want files to be loaded into their own buffers, use the <b>-F</b> or <b>--multibuffer</b> flag when you invoke nano, or add <b>set multibuffer</b> to your .nanorc file.</p>
<p>You can move between the buffers you have open with the <b>Meta-&lt;</b> and <b>Meta-&gt;</b> keys, or more easily without holding Shift: <b>Meta-,</b> and <b>Meta-.</b> (clear as mud, right? =-). When you have more than one buffer open, the ^X shortcut will say &quot;Close&quot;, instead of &quot;Exit&quot;.</p></blockquote>
<h3><a name="3.8"></a>3.8. Tell me more about this verbatim input stuff!</h3>
<h3><a name="3.7"></a>3.7. Tell me more about this verbatim input stuff!</h3>
<blockquote><p>When you want to insert a literal character into the file you're editing, such as a control character that nano usually treats as a command, first press <b>Meta-V</b> (if you're not at a prompt, you'll get the message &quot;Verbatim Input&quot; on the status bar), then press the key(s) that generate the character you want.</p>
<p>Alternatively, if Unicode support is enabled (see section <a href="#5.3">5.3</a>), you can press <b>Meta-V</b> and then type a six-digit hexadecimal code (from 000000 to 10FFFF, case-insensitive), and the character with the corresponding value will be inserted. The status bar will change to &quot;Unicode Input: ......&quot; when you do this.</p></blockquote>
<h3><a name="3.9a"></a>3.9a. How do I make a .nanorc file that will be read when I start nano?</h3>
<blockquote><p>It's not hard at all! But, your nano must <b>not</b> have been compiled with <b>--disable-nanorc</b>. Then simply copy the <b>sample.nanorc</b> that came with the nano source or your nano package (most likely in /usr/doc/nano) to .nanorc in your home directory. If you didn't get one, the syntax of the file is simple. Flags are turned on and off by using the words <b>set</b> and <b>unset</b> plus the long option name for the feature. For example, &quot;set nowrap&quot; or &quot;set smarthome&quot;.</p></blockquote>
<h3><a name="3.9b"></a>3.9b. How about in Win32?</h3>
<blockquote><p>If you're using the official nano .zip file and have extracted all the files, you should take the file nano.rc and place it somewhere on your Win32 system (for example, if you have write permission to do so, at the top of C:\). Then you must create an Environment variable called HOME which points to the directory where you put nano.rc. In Windows XP, you can get to Environment variables by right-clicking "My Computer" either on the desktop or in the Start Menu, and selecting Properties. This should bring up the System Properties panel. Then click the Advanced Tab, and there should be a button called Environment Variables. Click that to bring up the Environment Variables section. Now, under User Variables you should be able to click the New button, and make a new Variables Name called HOME, with the Variable Value of whatever path you copied nano.rc into (just the directory name; don't add nano.rc onto the end).</p>
<p>We're still working on documentation for enabling syntax highlighting on Win32; please bear with us.</p>
<p>Note that the nano.rc file must remain Unix-formatted in order for nano to understand it. In other words, you should probably use only nano to edit its config file. Other programs like Wordpad and Notepad will convert the file to DOS format when saving, and the latter does not even properly read Unix-formatted files to begin with.</p></blockquote>
<h3><a name="3.8"></a>3.8. How do I make a .nanorc file that will be read when I start nano?</h3>
<blockquote><p>It's not hard at all! Simply copy the <b>sample.nanorc</b> from the doc/ directory in the nano source package (or from /usr/doc/nano on your system) to <b>.nanorc</b> in your home directory, and then edit it. If you didn't get a sample nanorc, the syntax of the file is simple: features are turned on and off by using the words <b>set</b> and <b>unset</b> followed by the long option name of the feature (see <b>man nanorc</b> for the full list of options). For example, &quot;set quickblank&quot; or &quot;set smarthome&quot;. Of course, for this to work, your nano must <b>not</b> have been compiled with <b>--disable-nanorc</b>.</p></blockquote>
<h3><a name="3.9"></a>3.9. Why does my self-compiled nano not read /etc/nanorc?</h3>
<blockquote><p>By default (see <a href="#3.3">3.3</a>), nano gets installed into /usr/local. This also means that, at startup, nano will read <b>/usr/local/etc/nanorc</b> instead of <b>/etc/nanorc</b>. You can make a symlink from the former to the latter if you want your self-compiled nano to read the same nanorc as the system-installed nano. Or you can configure your nano to overwrite the system nano (again, see <a href="#3.3">3.3</a>).</p></blockquote>
<hr width="100%">
<h1><a name="4"></a>4. Running</h1>
<h3><a name="4.1"></a>4.1. How do I open a file with a name beginning with '+' from the command line?</h3>
<blockquote><p>If a command-line option that begins with '+' is followed by another option, the former is always treated as a starting line and column number, and the latter is always treated as a filename. If a command-line option that begins with '+' isn't followed by another option, it's always treated as a filename. Examples:</p>
<p>To open '+filename.txt' starting on line 1: <b>nano +filename.txt</b><br>
<blockquote><p>If a command-line argument that begins with '+' is followed by another argument, the former is always treated as a starting line (plus column number), and the latter always as a filename. If a command-line argument that begins with '+' isn't followed by another argument, it's treated as a filename. Examples:</p>
<p>To open '+filename.txt': <b>nano +filename.txt</b><br>
To open '+filename.txt' starting on line 10: <b>nano +10 +filename.txt</b><br>
To open '+filename.txt' starting on line 1, column 20: <b>nano +,20 +filename.txt</b><br>
To open '+filename.txt' starting on line 10, column 20: <b>nano +10,20 +filename.txt</b><br>
To open '+filename.txt' starting on line 1 and 'filename.txt' starting on line 40 (if nano has been compiled with multibuffer support): <b>nano +1 +filename.txt +40 filename.txt</b></p></blockquote>
<h3><a name="4.2"></a>4.2. Ack! My Backspace/Delete/Enter/Meta/double bucky key doesn't seem to work! What can I do?</h3>
<blockquote><p>Try setting your $TERM variable to 'vt100'. nano doesn't yet support every term entry under the sun.</p>
<p>Bourne shell users (bash and sh): <b>export TERM=vt100</b><br>
C Shell users (tcsh and csh): <b>setenv TERM vt100</b></p></blockquote>
To open '+filename.txt' starting on line 1 and 'filename.txt' starting on line 40: <b>nano +1 +filename.txt +40 filename.txt</b></p></blockquote>
<h3><a name="4.2"></a>4.2. How can I make Ctrl+Shift+Left/Right select words on urxvt?</h3>
<blockquote><p>The urxvt terminal emulator produces non-standard escape sequences for the modified cursor keys. These deviant sequences are not listed in the terminfo database, which means that ncurses does not recognize them. The easiest way around this is to tell urxvt to produce xterm-compatible escape sequences for the relevant keystrokes. To achieve this, add the following lines to your ~/.Xresources file:</p>
<pre>
URxvt.iso14755_52: False
URxvt.keysym.C-S-Up: \033[1;6A
URxvt.keysym.C-S-Down: \033[1;6B
URxvt.keysym.C-S-Right: \033[1;6C
URxvt.keysym.C-S-Left: \033[1;6D
URxvt.keysym.M-Up: \033[1;3A
URxvt.keysym.M-Down: \033[1;3B
URxvt.keysym.M-Right: \033[1;3C
URxvt.keysym.M-Left: \033[1;3D
URxvt.keysym.M-Insert: \033[2;3~
URxvt.keysym.M-Delete: \033[3;3~
URxvt.keysym.M-Page_Up: \033[5;3~
URxvt.keysym.M-Page_Down: \033[6;3~</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><a name="4.3"></a>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>--rebindkeypad</b> option on the command line, or add the line <b>set rebindkeypad</b> to your .nanorc. However, nano's mouse support won't work properly if you do any of these things.</p></blockquote>
<h3><a name="4.4"></a>4.4. Ack! When I hold down a Meta key combination for a while, the character of the held key gets inserted now and then. What gives?</h3>
<blockquote><p>This was a bug in how nano handled consecutive escape sequences. It should be fixed since version 2.6.0.</p></blockquote>
<h3><a name="4.5"></a>4.5. How do I type the F13-F16 keys listed in the help viewer? My keyboard only has F1-F12!</h3>
<blockquote><p>It depends on the terminal type you're using. On some terminals, such as the FreeBSD console, xterm, konsole, and gnome-terminal, Shift-F1 to Shift-F4 will generate F13 to F16. On other terminals, such as the Linux console, rxvt, and Eterm, Shift-F3 to Shift-F6 will generate F13 to F16.</p></blockquote>
<h3><a name="4.6"></a>4.6. nano crashes when I type &lt;insert keystrokes here&gt;!</h3>
<blockquote><p>If you aren't trying some bizarre keystroke combination with some bizarre $TERM entry, chances are you have found a bug. You are welcome to submit it to the <a href="mailto:nano-devel@gnu.org">nano-devel</a> list or in the <a href="https://savannah.gnu.org/bugs/?group=nano">bug tracker</a> on Savannah.</p></blockquote>
<h3><a name="4.7"></a>4.7. nano crashes when I resize my window. How can I fix that?</h3>
<blockquote><p>Older versions of nano had this problem. Please upgrade to version 2.7.0 or newer.</p></blockquote>
<h3><a name="4.8a"></a>4.8a. With what keystroke can I paste text from the clipboard into nano?</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><a name="4.4"></a>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> will paste the contents of the clipboard.</p></blockquote>
<h3><a name="4.8b"></a>4.8b. When I paste text into a document, each line gets indented further than the last. Why? And how can I stop this?</h3>
<blockquote><p>You have the <i>autoindent</i> feature turned on. Hit <b>Meta-I</b> to turn it off, paste your text, and then hit <b>Meta-I</b> again to turn it back on.</p></blockquote>
<h3><a name="4.8c"></a>4.8c. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?</h3>
<blockquote><p>When pasting from Windows, in some situations linefeeds are sent instead of carriage returns (Enters). And linefeeds are <b>^J</b>s, 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: <b>unbind ^J main</b> or <b>bind ^J enter main</b>, depending on whether the paste contains CR + LF or only LF.</p></blockquote>
<h3><a name="4.9"></a>4.9. 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.9a">3.9a</a>.</p></blockquote>
<h3><a name="4.10"></a>4.10. How do I make nano my default editor (in Pine, mutt, etc.)?</h3>
<h3><a name="4.5"></a>4.5. How do I select text for or paste text from the clipboard when nano's mouse support is turned on?</h3>
<blockquote><p>Try holding down the Shift key and selecting or pasting the text as you normally would.</p></blockquote>
<h3><a name="4.6"></a>4.6. When I paste text into a document, each line gets indented further than the last. Why? And how can I stop this?</h3>
<blockquote><p>You have the <i>autoindent</i> feature turned on. Hit <b>Meta-I</b> to turn it off, paste your text, and then hit <b>Meta-I</b> again to turn it back on.</p>
<p><i>Update:</i> Since version 4.8, nano will suppress auto-indentation during a paste, so you no longer need to toggle it off and on manually.</p></blockquote>
<h3><a name="4.7"></a>4.7. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?</h3>
<blockquote><p>When pasting from Windows, in some situations linefeeds are sent instead of carriage returns (Enters). And linefeeds are <b>^J</b>s, 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: <b>unbind ^J main</b> or <b>bind ^J enter main</b>, depending on whether the paste contains CR + LF or only LF.</p>
<p><i>Update:</i> Since version 4.8, nano will ignore linefeed characters in a paste, so you no longer need the above workaround.</p></blockquote>
<h3><a name="4.8"></a>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><a name="4.9"></a>4.9. How do I make nano my default editor (in Pine, mutt, etc.)?</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><b>export EDITOR=/usr/local/bin/nano</b></p>
<p>or, if you use tcsh, put this in your <b>.cshrc</b> file:</p>
@@ -220,21 +228,15 @@
<b>[ ] enable-alternate-editor-implicitly</b></p>
<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><b>my_hdr X-Composer: nano x.y.z</b></p>
<p>Again, replace x.y.z with the version of nano you use.</p></blockquote>
<h3><a name="4.11"></a>4.11. How do I select text for or paste text from the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?</h3>
<blockquote><p>Try holding down the Shift key and selecting or pasting the text as you normally would.</p></blockquote>
<h3><a name="4.12"></a>4.12. On startup I get a message that says "Detected a legacy nano history file". Now older nano versions can't find my search history!</h3>
<blockquote><p>In nano 2.3.0, cursor-position history was introduced, and both history files now reside in a .nano subdirectory in your home directory. A newer nano will move an existing search-history file to this new location so it can continue to be used. This means that if you then try and use an earlier version of nano, it will be unable to see your current search history. To fix this, run the following command:</p>
<p><b>ln -sf ~/.nano/search_history ~/.nano_history</b></p>
<p>The "migration service" (moving the search-history file to its new location) has been deleted from nano in late 2017, since version 2.9.0. The search-history and position-history files will now be looked for first in ~/.nano/ and, when not found there, then in ~/.local/share/nano/.</p></blockquote>
<p><b>my_hdr X-Composer: nano-x.y</b></p>
<p>Again, replace x.y with the version of nano you use.</p></blockquote>
<hr width="100%">
<h1><a name="5"></a>5. Internationalization</h1>
<h3><a name="5.1"></a>5.1. There's no translation for my language!</h3>
<blockquote><p>In June 2001, GNU nano entered the <a href="http://translationproject.org/html/welcome.html">Translation Project</a> and since then, translations should be managed from there.</p>
<p>If there isn't a translation for your language, you could ask <a href="http://translationproject.org/team/">your language team</a> to translate nano, or better still, join that team and do it yourself. Joining a team is easy. You just need to ask the team leader to add you, and then send a <a href="http://translationproject.org/disclaim.txt">translation disclaimer to the FSF</a> (this is necessary as nano is an official GNU package, but it does <b>not</b> mean that you transfer the rights of your work to the FSF, it's just so the FSF can legally manage them).</p>
<p>In any case, translating nano is easy. Just grab the latest <b>nano.pot</b> file listed on <a href="http://translationproject.org/domain/nano.html">nano's page</a> at the TP, and translate each <b>msgid</b> line into your native language on the <b>msgstr</b> line. When you're done, you should send it to the TP's central PO-file repository.</p></blockquote>
<blockquote><p>In June 2001, GNU nano entered the <a href="https://translationproject.org/html/welcome.html">Translation Project</a> and since then, translations should be managed from there.</p>
<p>If there isn't a translation for your language, you could ask <a href="https://translationproject.org/team/">your language team</a> to translate nano, or better still, join that team and do it yourself. Joining a team is easy. You just need to ask the team leader to add you, and then send a <a href="https://translationproject.org/disclaim.txt">translation disclaimer to the FSF</a> (this is necessary as nano is an official GNU package, but it does <b>not</b> mean that you transfer the rights of your work to the FSF, it's just so the FSF can legally manage them).</p>
<p>In any case, translating nano is easy. Just grab the latest <b>nano.pot</b> file listed on <a href="https://translationproject.org/domain/nano.html">nano's page</a> at the TP, and translate each <b>msgid</b> line into your native language on the <b>msgstr</b> line. When you're done, you should send it to the TP's central PO-file repository.</p></blockquote>
<h3><a name="5.2"></a>5.2. I don't like the translation for &lt;x&gt; in my language. How can I fix it?</h3>
<blockquote><p>The best way is to send an e-mail with your suggested corrections to the team's mailing list. The address is mentioned in the <code>Language-Team:</code> field in the relevant PO file. The team leader or the assigned translator can then make the changes reach the nano-devel list.</p></blockquote>
<h3><a name="5.3"></a>5.3. What is the status of Unicode support?</h3>
@@ -243,12 +245,11 @@
<h1><a name="6"></a>6. Advocacy and Licensing</h1>
<h3><a name="6.1"></a>6.1. Why should I use nano instead of Pico?</h3>
<blockquote><p>There are many reasons to use nano instead of Pico. A more complete list can be found at the <a href="https://nano-editor.org/">nano homepage</a>.</p></blockquote>
<blockquote><p>If you want features like undo/redo, syntax highlighting, line numbers, soft-wrapping, opening multiple files at once, an interface localized to your language, or search and replace with support for regular expressions, then you want nano.</p></blockquote>
<h3><a name="6.2"></a>6.2. Why should I use Pico instead of nano?</h3>
<blockquote><p>Again, check out the <a href="https://nano-editor.org/">nano homepage</a> for a good summary of reasons. It really is a matter of personal preference as to which editor you should use. If you're the type of person who likes using the original version of a program, then Pico is the editor for you. If you don't mind sacrificing mailer integration with Pine, and are looking for a few more features, as well as a 'better' license in terms of adding your own changes, nano is the way to go.</p>
<p>Note that the last of these no longer applies to the new version of Pine, <a href="http://www.washington.edu/alpine/">Alpine</a>, which is under the Apache License, version 2.0.</p></blockquote>
<blockquote><p>If you use your editor only to write emails or other texts and have no need for the above-mentioned features, then Pico will do fine for you.</p></blockquote>
<h3><a name="6.3"></a>6.3. What is so bad about the older Pine license?</h3>
<blockquote><p>The U of W license for older versions of Pine and Pico is not considered truly Free Software according to both the Free Software Foundation and the <a href="http://www.debian.org/social_contract#guidelines">Debian Free Software Guidelines</a>. The main problem regards the limitations on distributing derived works: according to UW, you can distribute their software, and you can modify it, but you can not do both, i.e. distribute modified binaries.</p></blockquote>
<blockquote><p>The U of W license for older versions of Pine and Pico is not considered truly Free Software according to both the Free Software Foundation and the <a href="https://www.debian.org/social_contract#guidelines">Debian Free Software Guidelines</a>. The main problem regards the limitations on distributing derived works: according to UW, you can distribute their software, and you can modify it, but you can not do both, i.e. distribute modified binaries.</p></blockquote>
<h3><a name="6.4"></a>6.4. Okay, well, what mail program should I use then?</h3>
<blockquote><p>If you are looking to use a Free Software program similar to Pine, and Emacs is not your thing, you should definitely take a look at <a href="http://www.mutt.org/">mutt</a>. It is a full-screen, console based mail program that actually has a lot more flexibility than Pine, but has a keymap included in the distribution that allows you to use the same keystrokes as Pine would to send and receive mail. It's also under the GNU General Public License, version 2.0.</p>
<p>Of course, due to the license change you can now use the <a href="http://www.washington.edu/alpine/">Alpine distribution</a> of PINE as it is now considered Free Software, but you would be sacrificing many of nano's features to do so.</p></blockquote>
@@ -256,10 +257,10 @@
<h1><a name="7"></a>7. Miscellaneous</h1>
<h3><a name="7.1"></a>7.1. Where can I ask questions or send suggestions?</h3>
<blockquote><p>There are three mailing lists for nano hosted at <a href="http://savannah.gnu.org/">Savannah</a>: info-nano, help-nano and nano-devel. info-nano is a very low traffic list where new versions of nano are announced (surprise!). help-nano is for getting help with the editor without needing to hear all of the development issues surrounding it. nano-devel is a normally low, sometimes high traffic list for discussing the present and future development of nano. Here are links to where you can sign up for a given list:</p>
<p>info-nano - <a href="http://mail.gnu.org/mailman/listinfo/info-nano/">http://mail.gnu.org/mailman/listinfo/info-nano/</a><br>
help-nano - <a href="http://mail.gnu.org/mailman/listinfo/help-nano/">http://mail.gnu.org/mailman/listinfo/help-nano/</a><br>
nano-devel - <a href="http://mail.gnu.org/mailman/listinfo/nano-devel/">http://mail.gnu.org/mailman/listinfo/nano-devel/</a></p></blockquote>
<blockquote><p>There are three mailing lists for nano hosted at <a href="https://savannah.gnu.org/">Savannah</a>: info-nano, help-nano and nano-devel. info-nano is a very low traffic list where new versions of nano are announced (surprise!). help-nano is for getting help with the editor without needing to hear all of the development issues surrounding it. nano-devel is a normally low, sometimes high traffic list for discussing the present and future development of nano. Here are links to where you can sign up for a given list:</p>
<p>info-nano - <a href="https://lists.gnu.org/mailman/listinfo/info-nano/">https://lists.gnu.org/mailman/listinfo/info-nano/</a><br>
help-nano - <a href="https://lists.gnu.org/mailman/listinfo/help-nano/">https://lists.gnu.org/mailman/listinfo/help-nano/</a><br>
nano-devel - <a href="https://lists.gnu.org/mailman/listinfo/nano-devel/">https://lists.gnu.org/mailman/listinfo/nano-devel/</a></p></blockquote>
<h3><a name="7.2"></a>7.3. How do I submit a bug report or patch?</h3>
<blockquote>
<p>The best way to submit bugs is through the <a href="https://savannah.gnu.org/bugs/?group=nano">Savannah bug tracker</a>, as you can check whether the bug you are reporting has already been submitted, and it makes it easier for the maintainers to keep track of them.

View File

@@ -1,4 +1,4 @@
.\" Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc.
.\" Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc.
.\"
.\" This document is dual-licensed. You may distribute and/or modify it
.\" under the terms of either of the following licenses:
@@ -7,34 +7,63 @@
.\" Foundation, version 3 or (at your option) any later version. You
.\" should have received a copy of the GNU General Public License
.\" along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\" <https://www.gnu.org/licenses/>.
.\"
.\" * The GNU Free Documentation License, as published by the Free
.\" Software Foundation, version 1.2 or (at your option) any later
.\" version, with no Invariant Sections, no Front-Cover Texts, and no
.\" Back-Cover Texts. You should have received a copy of the GNU Free
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 2.9.5" "March 2018"
.TH NANO 1 "version 5.2" "August 2020"
.SH NAME
nano \- Nano's ANOther editor, an enhanced free Pico clone
nano \- Nano's ANOther editor, inspired by Pico
.SH SYNOPSIS
.B nano
.RI [ options "] [[+" line [, column "]]\ " file "]..."
.RI [ options "] [[\fB+" line [\fB, column "]] " file ]...
.sp
.BR nano " [" \fIoptions "] [[" + [ crCR ]( / | ? ) \fIstring "] " \fIfile ]...
.SH NOTICE
Since version 4.0, \fBnano\fR by default:
.sp
.RS 4
\(bu does not automatically hard-wrap lines that become overlong,
.br
\(bu includes the line below the title bar in the editing area,
.br
\(bu does linewise (smooth) scrolling.
.RE
.sp
If you want the old, Pico behavior back, you can use \fB\-\-breaklonglines\fR,
\fB\-\-emptyline\fR, and \fB\-\-jumpyscrolling\fR (or \fB\-bej\fR for short).
.SH DESCRIPTION
\fBnano\fP is a small and friendly editor. It copies the look and feel
of Pico, but is free software, and implements several features that Pico
lacks, such as: opening multiple files, scrolling per line, undo/redo,
syntax coloring, line numbering, and soft-wrapping overlong lines.
.sp
When giving a filename on the command line, the cursor can be put on a
specific line by adding the line number with a plus sign (\fB+\fR) before
the filename, and even in a specific column by adding it with a comma.
(Negative numbers count from the end of the file or line.)
The cursor can be put on the first or last occurrence of a specific string
by specifying that string after \fB+/\fR or \fB+?\fR before the filename.
The string can be made case sensitive and/or caused to be interpreted as a
regular expression by inserting \fBc\fR and/or \fBr\fR after the \fB+\fR sign.
These search modes can be explicitly disabled by using the uppercase variant
of those letters: \fBC\fR and/or \fBR\fR. When the string contains spaces,
it needs to be enclosed in quotes. To give an example: to open a file at
the first occurrence of the word "Foo", one would do:
.sp
.RS 4
.BI "nano +c/Foo " file
.RE
.sp
As a special case: if instead of a filename a dash (\fB\-\fR) is given,
\fBnano\fR will read data from standard input.
@@ -47,17 +76,18 @@ Consecutive \fB^K\fRs will put all deleted lines together in the cutbuffer.
Any cursor movement or executing any other command will cause the next
\fB^K\fR to overwrite the cutbuffer. A \fB^U\fR will paste the current
contents of the cutbuffer at the current cursor position.
.PP
.sp
When a more precise piece of text needs to be cut or copied, one can mark
its start with \fB^6\fR, move the cursor to its end (the marked text will be
highlighted), and then use \fB^K\fR to cut it, or \fBM\-6\fR to copy it to the
cutbuffer. One can also save the marked text to a file with \fB^O\fR, or
spell check it with \fB^T\fR.
.PP
.sp
On some terminals, text can be selected also by holding down Shift while
using the arrow keys. Holding down the Alt key too will increase the stride.
using the arrow keys. Holding down the Ctrl or Alt key too will increase
the stride.
Any cursor movement without Shift being held will cancel such a selection.
.PP
.sp
The two lines at the bottom of the screen show some important commands;
the built-in help (\fB^G\fR) lists all the available ones.
The default key bindings can be changed via a \fInanorc\fR file -- see
@@ -82,7 +112,10 @@ numbered one every time a file is saved -- when backups are enabled (\fB\-B\fR).
The uniquely numbered files are stored in the specified \fIdirectory\fR.
.TP
.BR \-D ", " \-\-boldtext
Use bold text instead of reverse video text.
For the interface, use bold instead of reverse video. This will be overridden
by setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, \fBkeycolor\fP,
\fBfunctioncolor\fP, \fBnumbercolor\fP, and/or \fBselectedcolor\fP in your
nanorc file. See \fBnanorc\fR(5).
.TP
.BR \-E ", " \-\-tabstospaces
Convert typed tabs to spaces.
@@ -100,13 +133,20 @@ executed commands, so they can be easily reused in later sessions.
.BR \-I ", " \-\-ignorercfiles
Don't look at the system's \fInanorc\fR nor at the user's \fInanorc\fR.
.TP
.BR \-K ", " \-\-rebindkeypad
Interpret the numeric keypad keys so that they all work properly. You
should only need to use this option if they don't, as mouse support
won't work properly with this option enabled.
.BR \-J\ \fInumber ", " \-\-guidestripe= \fInumber
Draw a vertical stripe at the given column, to help judge the width of the
text. (The color of the stripe can be changed with \fBset stripecolor\fR
in your \fInanorc\fR file.)
.TP
.BR \-K ", " \-\-rawsequences
Interpret escape sequences directly (instead of asking \fBncurses\fR to
translate them). If you need this option to get your keyboard to work
properly, please report a bug. Using this option disables \fBnano\fR's
mouse support.
.TP
.BR \-L ", " \-\-nonewlines
Don't add newlines to the ends of files.
Don't automatically add a newline when a text does not end with one.
(This can cause you to save non-POSIX text files.)
.TP
.BR \-M ", " \-\-trimblanks
Snip trailing whitespace from the wrapped line when automatic
@@ -115,31 +155,35 @@ hard-wrapping occurs or when text is justified.
.BR \-N ", " \-\-noconvert
Disable automatic conversion of files from DOS/Mac format.
.TP
.BR \-O ", " \-\-morespace
Use the blank line below the title bar as extra editing space.
.BR \-O ", " \-\-bookstyle
When justifying, treat any line that starts with whitespace as the
beginning of a paragraph (unless auto-indenting is on).
.TP
.BR \-P ", " \-\-positionlog
For the 200 most recent files, log the last position of the cursor,
and place it at that position again upon reopening such a file.
.TP
.BR "\-Q ""\fIcharacters\fB""" ", " "\-\-quotestr=""" \fIcharacters """
Set the quoting string for justifying. The default is
\fB"^([\ \\t]*[#:>\\|}])+"\fP if extended regular expression support is
available, or \fB">\ "\fP otherwise. Note that \fB\\t\fP stands for a
Tab.
.BR "\-Q ""\fIregex\fB""" ", " "\-\-quotestr=""" \fIregex """
Set the regular expression for matching the quoting part of a line.
The default value is \fB"^([\ \\t]*([!#%:;>|}]|//))+"\fP.
(Note that \fB\\t\fP stands for an actual Tab.)
This makes it possible to rejustify blocks of quoted text when composing
email, and to rewrap blocks of line comments when writing source code.
.TP
.BR \-R ", " \-\-restricted
Restricted mode: don't read or write to any file not specified on the
command line; don't read any \fInanorc\fP files nor history files;
don't allow suspending nor spell checking;
command line. This means: don't read or write history files;
don't allow suspending; don't allow spell checking;
don't allow a file to be appended to, prepended to, or saved under a
different name if it already has one; and don't use backup files.
This restricted mode is also accessible by invoking \fBnano\fP
different name if it already has one; and don't make backup files.
Restricted mode can also be activated by invoking \fBnano\fP
with any name beginning with 'r' (e.g. "rnano").
.TP
.BR \-S ", " \-\-smooth
Use smooth scrolling: text will scroll line-by-line, instead of the
usual chunk-by-chunk behavior.
.BR \-S ", " \-\-softwrap
Display over multiple screen rows lines that exceed the screen's width.
(You can make this soft-wrapping occur at whitespace instead of rudely at
the screen's edge, by using also \fB\-\-atblanks\fR.)
(The old short option, \fB\-$\fR, is deprecated.)
.TP
.BR \-T\ \fInumber ", " \-\-tabsize= \fInumber
Set the size (width) of a tab to \fInumber\fP columns. The value of
@@ -159,36 +203,57 @@ characters as part of a word.
.TP
.BR "\-X ""\fIcharacters\fB""" ", " "\-\-wordchars=""" \fIcharacters """
Specify which other characters (besides the normal alphanumeric ones)
should be considered as part of a word. This overrides option
\fB\-W\fR (\fB\-\-wordbounds\fR).
should be considered as part of a word. When using this option, you
probably want to omit \fB\-W\fR (\fB\-\-wordbounds\fR).
.TP
.BR \-Y\ \fIname ", " \-\-syntax= \fIname
Specify the name of the syntax highlighting to use from among the ones
defined in the \fInanorc\fP files.
.TP
.BR \-Z ", " \-\-zap
Let an unmodified Backspace or Delete erase the marked region
(instead of a single character, and without affecting the cutbuffer).
.TP
.BR \-a ", " \-\-atblanks
When doing soft line wrapping, wrap lines at whitespace
instead of always at the edge of the screen.
.TP
.BR \-b ", " \-\-breaklonglines
Automatically hard-wrap the current line when it becomes overlong.
(This option is the opposite of \fB\-w\fR (\fB\-\-nowrap\fR) --
the last one given takes effect.)
.TP
.BR \-c ", " \-\-constantshow
Constantly show the cursor position on the status bar.
Note that this overrides option \fB\-U\fR (\fB\-\-quickblank\fR).
.TP
.BR \-d ", " \-\-rebinddelete
Interpret the Delete key differently so that both Backspace and Delete
work properly. You should only need to use this option if Backspace
acts like Delete on your system.
Interpret the Delete and Backspace keys differently so that both Backspace
and Delete work properly. You should only use this option when on your
system either Backspace acts like Delete or Delete acts like Backspace.
.TP
.BR \-e ", " \-\-emptyline
Do not use the line below the title bar, leaving it entirely blank.
.TP
.BR \-f\ \fIfile ", " \-\-rcfile= \fIfile
Read only this \fIfile\fR for setting nano's options, instead of reading
both the system-wide and the user's nanorc files.
.TP
.BR \-g ", " \-\-showcursor
Make the cursor visible in the file browser, putting it on the
highlighted item. Useful for braille users.
Make the cursor visible in the file browser (putting it on the
highlighted item) and in the help viewer. Useful for braille users
and people with poor vision.
.TP
.BR \-h ", " \-\-help
Show a summary of the available command-line options and exit.
.TP
.BR \-i ", " \-\-autoindent
Indent new lines to the previous line's indentation. Useful when
editing source code.
Automatically indent a newly created line to the same number of tabs
and/or spaces as the previous line (or as the next line if the previous
line is the beginning of a paragraph).
.TP
.BR \-j ", " \-\-jumpyscrolling
Scroll the buffer contents per half-screen instead of per line.
.TP
.BR \-k ", " \-\-cutfromcursor
Make the 'Cut Text' command (normally \fB^K\fR) cut from the current cursor
@@ -196,6 +261,7 @@ position to the end of the line, instead of cutting the entire line.
.TP
.BR \-l ", " \-\-linenumbers
Display line numbers to the left of the text area.
(Any line with an anchor additionally gets a mark in the margin.)
.TP
.BR \-m ", " \-\-mouse
Enable mouse support, if available for your system. When enabled, mouse
@@ -216,24 +282,28 @@ Set the operating directory. This makes \fBnano\fP set up something
similar to a chroot.
.TP
.BR \-p ", " \-\-preserve
Preserve the XON and XOFF sequences (^Q and ^S) so they will be caught
by the terminal.
Preserve the XON and XOFF sequences (\fB^Q\fR and \fB^S\fR) so they
will be caught by the terminal.
.TP
.BR \-q ", " \-\-quiet
Obsolete option. Recognized but ignored.
.BR \-q ", " \-\-indicator
Display a "scrollbar" on the righthand side of the edit window.
It shows the position of the viewport in the buffer
and how much of the buffer is covered by the viewport.
.TP
.BR \-r\ \fInumber ", " \-\-fill= \fInumber
Hard-wrap lines at column \fInumber\fP. If this value is 0 or less, wrapping
will occur at the width of the screen less \fInumber\fP columns, allowing
the wrap point to vary along with the width of the screen if the screen
is resized. The default value is \-8. This option conflicts with
\fB\-w\fR (\fB\-\-nowrap\fR) -- the last one given takes effect.
Set the target width for justifying and automatic hard-wrapping at this
\fInumber\fR of columns. If the value is 0 or less, wrapping will occur
at the width of the screen minus \fInumber\fR columns, allowing the wrap
point to vary along with the width of the screen if the screen is resized.
The default value is \-8.
.TP
.BR \-s\ \fIprogram ", " \-\-speller= \fIprogram
Use this alternative spell checker command.
.B "\-s ""\fIprogram\fR [\fIargument \fR...]\fB""\fR, \fB\-\-speller=""\fIprogram\fR [\fIargument \fR...]\fB"""
Use this command to perform spell checking and correcting, instead of
using the built-in corrector that calls \fBhunspell\fR or GNU \fBspell\fR.
.TP
.BR \-t ", " \-\-tempfile
.BR \-t ", " \-\-saveonexit
Save a changed buffer without prompting (when exiting with \fB^X\fR).
(The old form of the long option, \fB\-\-tempfile\fR, is deprecated.)
.TP
.BR \-u ", " \-\-unix
Save a file by default in Unix format. This overrides nano's
@@ -242,41 +312,43 @@ default behavior of saving a file in the format that it had.
.TP
.BR \-v ", " \-\-view
Just view the file and disallow editing: read-only mode.
This mode allows the user to open also other files for viewing,
unless \fB\-\-restricted\fR is given too.
.TP
.BR \-w ", " \-\-nowrap
Disable the hard-wrapping of long lines. This option conflicts with
\fB\-r\fR (\fB\-\-fill\fR) -- the last one given takes effect.
Do not automatically hard-wrap the current line when it becomes overlong.
This is the default. (This option is the opposite of \fB\-b\fR
(\fB\-\-breaklonglines\fR) -- the last one given takes effect.)
.TP
.BR \-x ", " \-\-nohelp
Don't show the two help lines at the bottom of the screen.
.TP
.BR \-z ", " \-\-suspend
Enable the suspend ability.
.BR \-y ", " \-\-afterends
Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
.TP
.BR \-$ ", " \-\-softwrap
Enable 'soft wrapping'. This will make \fBnano\fP attempt to display the
entire contents of any line, even if it is longer than the screen width, by
continuing it over multiple screen lines. Since
\&'$' normally refers to a variable in the Unix shell, you should specify
this option last when using other options (e.g.\& 'nano \-wS$') or pass it
separately (e.g.\& 'nano \-wS \-$').
.TP
.BR \-b ", " \-e ", " \-f ", " \-j
Ignored, for compatibility with Pico.
.BR \-z ", " \-\-suspendable
Allow the user to suspend the editor (with \fB^Z\fR by default).
.SH TOGGLES
Several of the above options can be switched on and off also while
\fBnano\fR is running. For example, \fBM\-L\fR toggles the
hard-wrapping of long lines, \fBM\-$\fR toggles soft-wrapping,
\fBM\-#\fR toggles line numbers, \fBM\-M\fR toggles the mouse,
hard-wrapping of long lines, \fBM\-S\fR toggles soft-wrapping,
\fBM\-N\fR toggles line numbers, \fBM\-M\fR toggles the mouse,
\fBM\-I\fR auto-indentation, and \fBM\-X\fR the help lines.
See at the end of the \fB^G\fR help text for a complete list.
.sp
The \fBM\-X\fR toggle is special: it works in all menus except
the help viewer and the linter. All other toggles work in
the main menu only.
.SH INITIALIZATION FILE
.SH FILES
When \fB\-\-rcfile\fR is given, \fBnano\fR will read just the specified file
for setting its options and syntaxes and key bindings. Without that option,
\fBnano\fR will read two configuration files: first the system's
\fInanorc\fR (if it exists), and then the user's \fInanorc\fR (if it
exists), either \fB~/.nanorc\fR or \fI$XDG_CONFIG_HOME\fB/nano/nanorc\fR
or \fB~/.config/nano/nanorc\fR, whichever is encountered first. See
exists), either \fI~/.nanorc\fR or \fI$XDG_CONFIG_HOME/nano/nanorc\fR
or \fI~/.config/nano/nanorc\fR, whichever is encountered first. See
.BR nanorc (5)
for more information on the possible contents of those files.
@@ -296,29 +368,22 @@ it unique. In multibuffer mode, \fBnano\fP will write all the open
buffers to their respective emergency files.
.SH BUGS
Justifications (\fB^J\fR)
are not yet covered by the general undo system. So after a justification
that is not immediately undone, earlier edits
cannot be undone any more. The workaround is, of course, to exit without
saving.
.sp
The recording and playback of keyboard macros works correctly only on a
terminal emulator, not on a Linux console (VT), because the latter does
not by default distinguish modified from unmodified arrow keys.
.sp
Please report any other bugs that you encounter via:
.br
\fIhttps://savannah.gnu.org/bugs/?group=nano\fR.
.IR https://savannah.gnu.org/bugs/?group=nano .
.sp
When nano crashes, it will save any modified buffers to emergency .save files.
If you are able to reproduce the crash and you want to get a backtrace, define
the environment variable \fBNANO_NOCATCH\fR.
.SH HOMEPAGE
\fIhttps://nano-editor.org/\fR
.I https://nano\-editor.org/
.SH SEE ALSO
.BR nanorc (5)
.PP
.sp
\fI/usr/share/doc/nano/\fP (or equivalent on your system)
.SH AUTHOR
Chris Allegretta and others (see the files \fIAUTHORS\fR and
\fITHANKS\fP for details). This manual page was originally written by
Jordi Mallach for the Debian system (but may be used by others).

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
.\" Copyright (C) 2003-2011, 2013-2017 Free Software Foundation, Inc.
.\" Copyright (C) 2003-2011, 2013-2020 Free Software Foundation, Inc.
.\"
.\" This document is dual-licensed. You may distribute and/or modify it
.\" under the terms of either of the following licenses:
@@ -7,28 +7,44 @@
.\" Foundation, version 3 or (at your option) any later version. You
.\" should have received a copy of the GNU General Public License
.\" along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\" <https://www.gnu.org/licenses/>.
.\"
.\" * The GNU Free Documentation License, as published by the Free
.\" Software Foundation, version 1.2 or (at your option) any later
.\" version, with no Invariant Sections, no Front-Cover Texts, and no
.\" Back-Cover Texts. You should have received a copy of the GNU Free
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 2.9.5" "March 2018"
.TH NANORC 5 "version 5.2" "August 2020"
.SH NAME
nanorc \- GNU nano's configuration file
.SH DESCRIPTION
The \fInanorc\fP file contains the default settings for \fBnano\fP, a
small and friendly editor. The file should be in Unix format, not in
DOS or Mac format. During startup, \fBnano\fP will first read the
system-wide settings, from \fB/etc/nanorc\fP (the exact path might be
The \fInanorc\fP files contain the default settings for \fBnano\fP,
a small and friendly editor. During startup, if \fB\-\-rcfile\fR
is not given, \fBnano\fR will read two files: first the
system-wide settings, from \fI/etc/nanorc\fP (the exact path might be
different on your system), and then the user-specific settings, either
from \fB~/.nanorc\fR or from \fI$XDG_CONFIG_HOME\fB/nano/nanorc\fR
or from \fB~/.config/nano/nanorc\fR, whichever is encountered first.
from \fI~/.nanorc\fR or from \fI$XDG_CONFIG_HOME/nano/nanorc\fR
or from \fI~/.config/nano/nanorc\fR, whichever is encountered first.
If \fB\-\-rcfile\fR is given, \fBnano\fR will read just the specified
settings file.
.SH NOTICE
Since version 4.0, \fBnano\fR by default:
.sp
.RS 4
\(bu does not automatically hard-wrap lines that become overlong,
.br
\(bu includes the line below the title bar in the editing area,
.br
\(bu does linewise (smooth) scrolling.
.RE
.sp
To get the old, Pico behavior back, you can use \fBset breaklonglines\fR,
\fBset emptyline\fR, and \fBset jumpyscrolling\fR.
.SH OPTIONS
The configuration file accepts a series of \fBset\fP and \fBunset\fP
@@ -36,23 +52,24 @@ commands, which can be used to configure nano on startup without using
command-line options. Additionally, there are some commands to define
syntax highlighting and to rebind keys -- see the two separate sections
on those. \fBnano\fP reads one command per line.
.PP
All commands and keywords should be written in lowercase.
.sp
Options in \fInanorc\fP files take precedence over nano's defaults, and
command-line options override \fInanorc\fP settings. Also, options that
do not take an argument are unset by default. So using the \fBunset\fR
command is only needed when wanting to override a setting of the system's
\fInanorc\fR file in your own \fInanorc\fR. Options that take an
argument cannot be unset.
.PP
Below, the \fIstring\fR parameters need to be enclosed in double quotes.
Quotes inside these string parameters don't have to be escaped with
backslashes. The last double quote in the string will be treated as its
end. For example, for the \fBbrackets\fP option, "\fB"')>]}\fP" will
match \fB"\fP, \fB'\fP, \fB)\fP, \fB>\fP, \fB]\fP, and \fB}\fP.
.PP
.sp
Quotes inside the \fIcharacters\fR parameters below should not be escaped.
The last double quote on the line will be seen as the closing quote.
.sp
The supported commands and arguments are:
.TP 3
.B set afterends
Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
.TP
.B set allow_insecure_backup
When backing up files, allow the backup to succeed even if its permissions
can't be (re)set due to special OS considerations. You should
@@ -63,7 +80,9 @@ When soft line wrapping is enabled, make it wrap lines at blank characters
(tabs and spaces) instead of always at the edge of the screen.
.TP
.B set autoindent
Use auto-indentation.
Automatically indent a newly created line to the same number of tabs
and/or spaces as the previous line (or as the next line if the previous
line is the beginning of a paragraph).
.TP
.B set backup
When saving a file, create a backup file by adding a tilde (\fB~\fP) to
@@ -75,22 +94,25 @@ numbered one every time a file is saved -- when backups are enabled
with \fBset backup\fR or \fB\-\-backup\fR or \fB\-B\fR.
The uniquely numbered files are stored in the specified \fIdirectory\fR.
.TP
.B set backwards
Obsolete option. Recognized but ignored. \fB^Q\fR is available to
start a backward search.
.TP
.B set boldtext
Use bold instead of reverse video for the title bar, status bar, key combos,
function tags, line numbers, and selected text. This can be overridden by
setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, \fBkeycolor\fP,
\fBfunctioncolor\fP, \fBnumbercolor\fP, and \fBselectedcolor\fP.
.TP
.B set brackets "\fIstring\fP"
.B set bookstyle
When justifying, treat any line that starts with whitespace as the
beginning of a paragraph (unless auto-indenting is on).
.TP
.BI "set brackets """ characters """
Set the characters treated as closing brackets when justifying
paragraphs. This may not include blank characters. Only closing
punctuation (see \fBpunct\fP), optionally followed by the specified
punctuation (see \fBset punct\fP), optionally followed by the specified
closing brackets, can end sentences. The default value is "\fB"')>]}\fP".
.TP
.B set breaklonglines
Automatically hard-wrap the current line when it becomes overlong.
.TP
.B set casesensitive
Do case-sensitive searches by default.
.TP
@@ -100,46 +122,64 @@ This overrides the option \fBquickblank\fR.
.TP
.B set cutfromcursor
Use cut-from-cursor-to-end-of-line by default, instead of cutting the whole line.
(The old form of this option, '\fBset cut\fR', is deprecated.)
.TP
.B set errorcolor \fIfgcolor\fR,\fIbgcolor\fR
.B set emptyline
Do not use the line below the title bar, leaving it entirely blank.
.TP
.B set errorcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the status bar when an error message is displayed.
The default value is \fBbrightwhite,red\fR.
See \fBset titlecolor\fR for valid color names.
.TP
.B set fill \fInumber\fR
Hard-wrap lines at column number \fInumber\fR. If \fInumber\fR is 0 or less,
the maximum line length will be the screen width less \fInumber\fP columns.
The default value is \fB\-8\fR. This option conflicts with
\fBnowrap\fR -- the last one given takes effect.
Set the target width for justifying and automatic hard-wrapping at this
\fInumber\fR of columns. If the value is 0 or less, wrapping will occur
at the width of the screen minus \fInumber\fR columns, allowing the wrap
point to vary along with the width of the screen if the screen is resized.
The default value is \fB\-8\fR.
.TP
.B set functioncolor \fIfgcolor\fR,\fIbgcolor\fR
.B set functioncolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for the function descriptions
in the two help lines at the bottom of the screen.
See \fBset titlecolor\fR for more details.
.TP
.B set guidestripe \fInumber
Draw a vertical stripe at the given column, to help judge the width of the
text. (The color of the stripe can be changed with \fBset stripecolor\fR.)
.TP
.B set historylog
Save the last hundred search strings and replacement strings and
executed commands, so they can be easily reused in later sessions.
.TP
.B set keycolor \fIfgcolor\fR,\fIbgcolor\fR
.B set indicator
Display a "scrollbar" on the righthand side of the edit window.
It shows the position of the viewport in the buffer
and how much of the buffer is covered by the viewport.
.TP
.B set jumpyscrolling
Scroll the buffer contents per half-screen instead of per line.
.TP
.B set keycolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for the shortcut key combos
in the two help lines at the bottom of the screen.
See \fBset titlecolor\fR for more details.
.TP
.B set linenumbers
Display line numbers to the left of the text area.
(Any line with an anchor additionally gets a mark in the margin.)
.TP
.B set locking
Enable vim-style lock-files for when editing files.
.TP
.B set matchbrackets "\fIstring\fP"
Set the opening and closing brackets that can be found by bracket
.BI "set matchbrackets """ characters """
Specify the opening and closing brackets that can be found by bracket
searches. This may not include blank characters. The opening set must
come before the closing set, and the two sets must be in the same order.
The default value is "\fB(<[{)>]}\fP".
.TP
.B set morespace
Use the blank line below the title bar as extra editing space.
Deprecated option since it has become the default setting.
When needed, use \fBunset emptyline\fR instead.
.TP
.B set mouse
Enable mouse support, if available for your system. When enabled, mouse
@@ -149,7 +189,7 @@ System, and on the console when gpm is running. Text can still be
selected through dragging by holding down the Shift key.
.TP
.B set multibuffer
When reading in a file with ^R, insert it into a new buffer by default.
When reading in a file with \fB^R\fR, insert it into a new buffer by default.
.TP
.B set noconvert
Don't convert files from DOS/Mac format.
@@ -158,17 +198,17 @@ Don't convert files from DOS/Mac format.
Don't display the two help lines at the bottom of the screen.
.TP
.B set nonewlines
Don't automatically add a newline to the ends of files.
Don't automatically add a newline when a text does not end with one.
(This can cause you to save non-POSIX text files.)
.TP
.B set nopauses
Don't pause between warnings at startup. This means that only
the last one will be visible (when there are multiple ones).
Obsolete option. Ignored.
.TP
.B set nowrap
Don't hard-wrap text at all. This option conflicts with
\fBfill\fR -- the last one given takes effect.
Deprecated option since it has become the default setting.
When needed, use \fBunset breaklonglines\fR instead.
.TP
.B set numbercolor \fIfgcolor\fR,\fIbgcolor\fR
.B set numbercolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for line numbers.
See \fBset titlecolor\fR for more details.
.TP
@@ -183,9 +223,9 @@ Save the cursor position of files between editing sessions.
The cursor position is remembered for the 200 most-recently edited files.
.TP
.B set preserve
Preserve the XON and XOFF keys (^Q and ^S).
Preserve the XON and XOFF keys (\fB^Q\fR and \fB^S\fR).
.TP
.B set punct "\fIstring\fP"
.BI "set punct """ characters """
Set the characters treated as closing punctuation when justifying
paragraphs. This may not include blank characters. Only the
specfified closing punctuation, optionally followed by closing brackets
@@ -195,31 +235,33 @@ specfified closing punctuation, optionally followed by closing brackets
Do quick status-bar blanking: status-bar messages will disappear after 1
keystroke instead of 25. The option \fBconstantshow\fR overrides this.
.TP
.B set quiet
Obsolete option. Recognized but ignored.
.BI "set quotestr """ regex """
Set the regular expression for matching the quoting part of a line.
The default value is "\fB^([\ \\t]*([!#%:;>|}]|//))+\fP".
(Note that \fB\\t\fR stands for an actual Tab character.)
This makes it possible to rejustify blocks of quoted text when composing
email, and to rewrap blocks of line comments when writing source code.
.TP
.B set quotestr "\fIstring\fP"
The email-quote string, used to justify email-quoted paragraphs. This
is an extended regular expression if your system supports them,
otherwise a literal string. The default value is
"\fB^([\ \\t]*[#:>\\|}])+\fP" if you have extended regular expression
support, and "\fB>\ \fP" otherwise. Note that '\\t' stands for a literal
Tab character.
.B set rawsequences
Interpret escape sequences directly (instead of asking \fBncurses\fR to
translate them). If you need this option to get your keyboard to work
properly, please report a bug. Using this option disables \fBnano\fR's
mouse support.
.TP
.B set rebinddelete
Interpret the Delete key differently so that both Backspace and Delete
work properly. You should only need to use this option if Backspace
acts like Delete on your system.
.TP
.B set rebindkeypad
Interpret the numeric keypad keys so that they all work properly. You
should only need to use this option if they don't, as mouse support
won't work properly with this option enabled.
Interpret the Delete and Backspace keys differently so that both Backspace
and Delete work properly. You should only use this option when on your
system either Backspace acts like Delete or Delete acts like Backspace.
.TP
.B set regexp
Do extended regular expression searches by default.
Do regular-expression searches by default.
Regular expressions in \fBnano\fR are of the extended type (ERE).
.TP
.B set selectedcolor \fIfgcolor\fR,\fIbgcolor\fR
.B set saveonexit
Save a changed buffer automatically on exit (\fB^X\fR); don't prompt.
(The old form of this option, \fBset tempfile\fR, is deprecated.)
.TP
.B set selectedcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for selected text.
See \fBset titlecolor\fR for more details.
.TP
@@ -235,21 +277,28 @@ already at that position, it will jump to the true beginning of the
line.
.TP
.B set smooth
Use smooth scrolling by default.
Deprecated option since it has become the default setting.
When needed, use \fBunset jumpyscrolling\fR instead.
.TP
.B set softwrap
Enable soft line wrapping for easier viewing of very long lines.
Display lines that exceed the screen's width over multiple screen lines.
(You can make this soft-wrapping occur at whitespace instead of rudely at
the screen's edge, by using also \fBset atblanks\fR.)
.TP
.B set speller "\fIspellprog\fP"
Use spelling checker \fIspellprog\fP instead of the built-in one, which
calls \fIspell\fP.
.B set speller """\fIprogram\fR [\fIargument \fR...]\fB"""
Use the given \fIprogram\fR to do spell checking and correcting, instead of
using the built-in corrector that calls \fBhunspell\fR or GNU \fBspell\fR.
.TP
.B set statuscolor \fIfgcolor\fR,\fIbgcolor\fR
.B set statuscolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for the status bar.
See \fBset titlecolor\fR for more details.
.TP
.B set suspend
Allow \fBnano\fP to be suspended.
.B set stripecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for the vertical guiding stripe.
See \fBset titlecolor\fR for more details.
.TP
.B set suspendable
Allow \fBnano\fP to be suspended (with \fB^Z\fR by default).
.TP
.B set tabsize \fInumber\fR
Use a tab size of \fInumber\fR columns. The value of \fInumber\fP must be
@@ -258,17 +307,22 @@ greater than 0. The default value is \fB8\fR.
.B set tabstospaces
Convert typed tabs to spaces.
.TP
.B set tempfile
Save automatically on exit, don't prompt.
.TP
.B set titlecolor \fIfgcolor\fR,\fIbgcolor\fR
.B set titlecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for the title bar.
Valid names for the foreground and background colors are:
.BR white ", " black ", " blue ", " green ", " red ", "
.BR cyan ", " yellow ", " magenta ", and " normal
.BR red ", " green ", " blue ", " magenta ", " yellow ", " cyan ", "
.BR white ", and " black .
Each of these eight names may be prefixed with the word \fBlight\fR
to get a brighter version of that color.
On terminal emulators that can do at least 256 colors,
other valid (but unprefixable) color names are:
.BR pink ", " purple ", " mauve ", " lagoon ", " mint ", "
.BR lime ", " peach ", " orange ", " latte ", and " normal
-- where \fBnormal\fR means the default foreground or background color.
The name of the foreground color may be prefixed with \fBbright\fR.
And either "\fIfgcolor\fR" or ",\fIbgcolor\fR" may be left out.
Either "\fIfgcolor\fR" or "\fB,\fIbgcolor\fR" may be left out,
and the pair may be preceded by \fBbold\fR and/or \fBitalic\fR
(separated by commas) to get a bold and/or slanting typeface,
if your terminal can do those.
.TP
.B set trimblanks
Remove trailing whitespace from wrapped lines when automatic
@@ -280,9 +334,11 @@ default behavior of saving a file in the format that it had.
(This option has no effect when you also use \fBset noconvert\fR.)
.TP
.B set view
Disallow file modification.
Disallow file modification: read-only mode.
This mode allows the user to open also other files for viewing,
unless \fB\-\-restricted\fR is given on the command line.
.TP
.B set whitespace "\fIstring\fP"
.BI "set whitespace """ characters """
Set the two characters used to indicate the presence of tabs and
spaces. They must be single-column characters. The default pair
for a UTF-8 locale is "\fB\[Fc]\[md]\fR", and for other locales "\fB>.\fR".
@@ -291,10 +347,14 @@ for a UTF-8 locale is "\fB\[Fc]\[md]\fR", and for other locales "\fB>.\fR".
Detect word boundaries differently by treating punctuation
characters as parts of words.
.TP
.B set wordchars \fIstring\fP
.BI "set wordchars """ characters """
Specify which other characters (besides the normal alphanumeric ones)
should be considered as parts of words. This overrides the option
\fBwordbounds\fR.
should be considered as parts of words. When using this option, you
probably want to unset \fBwordbounds\fR.
.TP
.B set zap
Let an unmodified Backspace or Delete erase the marked region
(instead of a single character, and without affecting the cutbuffer).
.SH SYNTAX HIGHLIGHTING
Coloring the different syntactic elements of a file
@@ -304,10 +364,24 @@ powerful enough to fully parse a file. Nevertheless, regular
expressions can do a lot and are easy to make, so they are a
good fit for a small editor like \fBnano\fR.
.sp
All regular expressions in \fBnano\fR are POSIX extended regular expressions.
This means that \fB.\fR, \fB?\fR, \fB*\fR, \fB+\fR, \fB^\fR, \fB$\fR, and
several other characters are special.
The period \fB.\fR matches any single character,
\fB?\fR means the preceding item is optional,
\fB*\fR means the preceding item may be matched zero or more times,
\fB+\fR means the preceding item must be matched one or more times,
\fB^\fR matches the beginning of a line, and \fB$\fR the end,
\fB\\<\fR matches the start of a word, and \fB\\>\fR the end,
and \fB\\s\fR matches a blank.
It also means that lookahead and lookbehind are not possible.
A complete explanation can be found in the manual page of GNU grep:
\fBman grep\fR.
.sp
For each kind of file a separate syntax can be defined
via the following commands:
.TP
.BR syntax " ""\fIname\fR"" [""\fIfileregex\fR"" ...]"
.BI syntax " name \fR[" """" fileregex """ " \fR...]
Start the definition of a syntax with this \fIname\fR.
All subsequent \fBcolor\fR and other such commands
will be added to this syntax, until a new \fBsyntax\fR
@@ -316,20 +390,20 @@ command is encountered.
When \fBnano\fR is run, this syntax will be automatically
activated if the current filename matches the extended regular
expression \fIfileregex\fR. Or the syntax can be explicitly
activated by using the \fB-Y\fR or \fB\-\-syntax\fR
activated by using the \fB\-Y\fR or \fB\-\-syntax\fR
command-line option followed by the \fIname\fR.
The syntax "\fBdefault\fP" is special: it takes no \fIfileregex\fR,
The syntax \fBdefault\fP is special: it takes no \fIfileregex\fR,
and applies to files that don't match any syntax's regexes.
The syntax "\fBnone\fP" is reserved; specifying it on the command line
The syntax \fBnone\fP is reserved; specifying it on the command line
is the same as not having a syntax at all.
.TP
.BR header " ""\fIregex\fR"" " ...
.BI "header """ regex """ \fR...
If from all defined syntaxes no \fIfileregex\fR matched, then compare
this \fIregex\fR (or regexes) against the first line of the current file,
to determine whether this syntax should be used for it.
.TP
.BR magic " ""\fIregex\fR"" " ...
.BI "magic """ regex """ \fR...
If no \fIfileregex\fR matched and no \fBheader\fR regex matched
either, then compare this \fIregex\fR (or regexes) against the
result of querying the \fBmagic\fP database about the current
@@ -337,17 +411,17 @@ file, to determine whether this syntax should be used for it.
(This functionality only works when \fBlibmagic\fP is installed on the
system and will be silently ignored otherwise.)
.TP
.BI linter " program " \fR[ "arg " \fR...]
Use the given \fIprogram\fR to run a syntax check on the current file.
(This overrides the speller function.)
.BI formatter " program " \fR[ "argument " \fR...]
Run the given \fIprogram\fR on the full contents of the current buffer.
(The current buffer is written out to a temporary file, the program is
run on it, and then the temporary file is read back in, replacing the
contents of the buffer.)
.TP
.BI formatter " program " \fR[ "arg " \fR...]
Use the given \fIprogram\fR to automatically reformat text --
useful in a programming language like Go.
(This overrides the speller and linter functions.)
.BI linter " program " \fR[ "argument " \fR...]
Use the given \fIprogram\fR to run a syntax check on the current buffer.
.TP
.BR comment " ""\fIstring\fR"""
Use the given string for commenting and uncommenting lines.
.BI "comment """ string """
Use the given \fIstring\fR for commenting and uncommenting lines.
If the string contains a vertical bar or pipe character (\fB|\fR),
this designates bracket-style comments; for example, "\fB/*|*/\fR" for
CSS files. The characters before the pipe are prepended to the line and the
@@ -357,41 +431,56 @@ for Python files. If empty double quotes are specified, the comment/uncomment
function is disabled; for example, "" for JSON.
The default value is "\fB#\fP".
.TP
.B color \fIfgcolor\fR,\fIbgcolor\fR """\fIregex\fR""" ...
Display all pieces of text that match
the extended regular expression \fIregex\fP with foreground color
\fIfgcolor\fP and background color \fIbgcolor\fP, at least one of which
must be specified. Valid colors for foreground and background
are: white, black, red, blue, green, yellow, magenta, and cyan. You may
use the prefix "bright" to get a stronger color highlight for the
foreground. If your terminal supports transparency, not specifying a
\fIbgcolor\fP tells \fBnano\fP to attempt to use a transparent
background.
.BI "tabgives """ string """
Make the <Tab> key produce the given \fIstring\fR. Useful for languages like
Python that want to see only spaces for indentation.
This overrides the setting of the \fBtabstospaces\fR option.
.TP
.B icolor \fIfgcolor\fR,\fIbgcolor\fR """\fIregex\fR""" ...
.BI "color \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " """ regex """ " \fR...
Paint all pieces of text that match the extended regular expression
\fIregex\fP with the given foreground and background colors, at least
one of which must be specified. Valid color names are:
.BR red ", " green ", " blue ", " magenta ", " yellow ", " cyan ", "
.BR white ", and " black .
Each of these eight names may be prefixed with the word \fBlight\fR
to get a brighter version of that color.
On terminal emulators that can do at least 256 colors,
other valid (but unprefixable) color names are:
.BR pink ", " purple ", " mauve ", " lagoon ", " mint ", "
.BR lime ", " peach ", " orange ", " latte ", and " normal
-- where \fBnormal\fR means the default foreground or background color.
The color pair may be preceded by \fBbold\fR and/or \fBitalic\fR
(separated by commas) to get a bold and/or slanting typeface,
if your terminal can do those.
.sp
All coloring commands are applied in the order in which they are specified,
which means that later commands can recolor stuff that was colored earlier.
.TP
.BI "icolor \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " """ regex """ " \fR...
Same as above, except that the matching is case insensitive.
.TP
.BR color " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIfromrx\fR"" " end= """\fItorx\fR""
Display all pieces of text whose start matches extended regular expression
\fIfromrx\fP and whose end matches extended regular expression \fItorx\fP with
foreground color \fIfgcolor\fP and background color \fIbgcolor\fP,
.BI "color \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " start=""" fromrx """ end=""" torx """
Paint all pieces of text whose start matches extended regular expression
\fIfromrx\fP and whose end matches extended regular expression \fItorx\fP
with the given foreground and background colors,
at least one of which must be specified. This means that, after an
initial instance of \fIfromrx\fP, all text until the first instance of
\fItorx\fP will be colored. This allows syntax highlighting to span
multiple lines.
.TP
.BR icolor " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIfromrx\fR"" " end= """\fItorx\fR""
.BI "icolor \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " start=""" fromrx """ end=""" torx """
Same as above, except that the matching is case insensitive.
.TP
.BR include " ""\fIsyntaxfile\fR"""
.BI "include """ syntaxfile """
Read in self-contained color syntaxes from \fIsyntaxfile\fP. Note that
\fIsyntaxfile\fP may contain only the above commands, from \fBsyntax\fP
to \fBicolor\fP.
.TP
.BI extendsyntax " name command " \fR[ "arg " \fR...]
.BI extendsyntax " name command argument " \fR...
Extend the syntax previously defined as \fIname\fR with another
\fIcommand\fR. This allows adding a new \fBcolor\fP, \fBicolor\fP,
\fBheader\fP, \fBmagic\fP, \fBcomment\fP, \fBlinter\fP, or \fBformatter\fP
\fBheader\fR, \fBmagic\fR, \fBformatter\fR, \fBlinter\fR, \fBcomment\fR,
or \fBtabgives\fR
command to an already defined syntax -- useful when you want to
slightly improve a syntax defined in one of the system-installed
files (which normally are not writable).
@@ -401,40 +490,58 @@ Key bindings can be changed via the following three commands:
.RS 3
.TP
.BI bind " key function menu"
Rebinds the key \fIkey\fP to a new function named \fIfunction\fP in the
context of menu \fImenu\fP (or in all menus where the function exists
by using \fBall\fP).
Rebinds the given \fIkey\fP to the given \fIfunction\fP in the given \fImenu\fP
(or in all menus where the function exists when \fBall\fP is used).
.TP
.BI bind " key " """" string """" " menu"
Makes the given \fIkey\fR produce the given \fIstring\fR in the given
\fImenu\fR (or in all menus where the key exists when \fBall\fR is used).
The \fIstring\fR can consist of text or commands or a mix of them.
(To enter a command into the \fIstring\fR, precede its keystroke
with \fBM-V\fR.)
with \fBM\-V\fR.)
.TP
.BI unbind " key menu"
Unbinds the key \fIkey\fP from the menu named \fImenu\fP (or from all
menus where it exists by using \fBall\fP).
Unbinds the given \fIkey\fP from the given \fImenu\fP (or from all
menus where the key exists when \fBall\fP is used).
.RE
.TP
The format of \fIkey\fP should be one of:
.RS 3
.TP 3
.B ^
followed by an alpha character or the word "Space".
Example: ^C
.TP 7
.BI ^ X
where \fIX\fR is a Latin letter, or one of several ASCII characters
(@, ], \\, ^, _), or the word "Space".
Example: ^C.
.TP
.B M-
followed by a printable character or the word "Space".
Example: M-C
.BI M\- X
where \fIX\fR is any ASCII character except [, or the word "Space".
Example: M\-8.
.TP
.B F
followed by a numeric value from 1 to 16.
Example: F10
.BI Sh\-M\- X
where \fIX\fR is a Latin letter.
Example: Sh\-M\-U.
By default, each Meta+letter keystroke does the same as the corresponding
Shift+Meta+letter. But when any Shift+Meta bind is made, that will
no longer be the case, for all letters.
.TP
.BI F N
where \fIN\fR is a numeric value from 1 to 24.
Example: F10.
(Often, \fBF13\fR to \fBF24\fR can be typed as \fBF1\fR to \fBF12\fR with Shift.)
.TP
.BR Ins " or " Del .
.RE
Rebinding \fB^M\fR (Enter) or \fB^I\fR (Tab) is probably not a good idea.
Rebinding \fB^[\fR (Esc) is not possible, because its keycode
is the starter byte of Meta keystrokes and escape sequences.
Rebinding any of the dedicated cursor-moving keys (the arrows, Home, End,
PageUp and PageDown) is not possible.
On some terminals it's not possible to rebind \fB^H\fR (unless \fB\-\-raw\fR
is used) because its keycode is identical to that of the Backspace key.
.TP
Valid \fIfunction\fP names to be bound are:
.RS 3
@@ -446,7 +553,7 @@ Invokes the help viewer.
Cancels the current command.
.TP
.B exit
Exits from the program (or from the help viewer or the file browser).
Exits from the program (or from the help viewer or file browser).
.TP
.B writeout
Writes the current buffer to disk, asking for a name.
@@ -463,16 +570,14 @@ Starts a forward search for text in the current buffer -- or for filenames
matching a string in the current list in the file browser.
.TP
.B wherewas
Starts a backward search for text in the current buffer.
.TP
.B searchagain
Repeats the last search command without prompting.
Starts a backward search for text in the current buffer -- or for filenames
matching a string in the current list in the file browser.
.TP
.B findprevious
As \fBsearchagain\fR, but always in the backward direction.
Searches the next occurrence in the backward direction.
.TP
.B findnext
As \fBsearchagain\fR, but always in the forward direction.
Searches the next occurrence in the forward direction.
.TP
.B replace
Interactively replaces text within the current buffer.
@@ -480,40 +585,61 @@ Interactively replaces text within the current buffer.
.B cut
Cuts and stores the current line (or the marked region).
.TP
.B copytext
.B copy
Copies the current line (or the marked region) without deleting it.
.TP
.B uncut
Copies the currently stored text into the current buffer at the
.B paste
Pastes the currently stored text into the current buffer at the
current cursor position.
.TP
.B mark
Sets the mark at the current position, to start selecting text.
.B zap
Throws away the current line (or the marked region).
(This function is bound by default to <Meta+Delete>.)
.TP
.B cutwordleft
Cuts from the cursor position to the beginning of the preceding word.
.B chopwordleft
Deletes from the cursor position to the beginning of the preceding word.
(This function is bound by default to <Shift+Ctrl+Delete>. If your terminal
produces \fB^H\fR for <Ctrl+Backspace>, you can make <Ctrl+Backspace> delete
the word to the left of the cursor by rebinding \fB^H\fR to this function.)
.TP
.B cutwordright
Cuts from the cursor position to the beginning of the next word.
.B chopwordright
Deletes from the cursor position to the beginning of the next word.
(This function is bound by default to <Ctrl+Delete>.)
.TP
.B cutrestoffile
Cuts all text from the cursor position till the end of the buffer.
.TP
.B curpos
Shows the current cursor position: the line, column, and character positions.
.B mark
Sets the mark at the current position, to start selecting text.
Or, when it is set, unsets the mark.
.TP
.B location
Reports the current position of the cursor in the buffer:
the line, column, and character positions.
(The old name of this function, 'curpos', is deprecated.)
.TP
.B wordcount
Counts the number of words, lines and characters in the current buffer.
.TP
.B execute
Prompts for a program to execute. The program's output will be inserted
into the current buffer (or into a new buffer when \fBM-F\fR is toggled).
.TP
.B speller
Invokes a spell-checking program (or a linting program, if the current
syntax highlighting defines one).
Invokes a spell-checking program, either the default \fBhunspell\fR or GNU
\fBspell\fR, or the one defined by \fB\-\-speller\fR or \fBset speller\fR.
.TP
.B formatter
Invokes a full-buffer-processing program (if the active syntax defines one).
.TP
.B linter
A synonym of \fBspeller\fR (for when the speller has not been configured).
Invokes a syntax-checking program (if the active syntax defines one).
.TP
.B justify
Justifies the current paragraph.
Justifies the current paragraph. A paragraph is a group of contiguous lines
that, apart from possibly the first line, all have the same indentation. The
beginning of a paragraph is detected by either this lone line with a differing
indentation or by a preceding blank line.
.TP
.B fulljustify
Justifies the entire current buffer.
@@ -552,6 +678,9 @@ while keeping the cursor in the same text position, if possible.
Scrolls the viewport down one row (meaning that the text slides up)
while keeping the cursor in the same text position, if possible.
.TP
.B center
Scrolls the line with the cursor to the middle of the screen.
.TP
.B prevword
Moves the cursor to the beginning of the previous word.
.TP
@@ -594,8 +723,18 @@ Goes to a specific line (and column if specified). Negative numbers count
from the end of the file (and end of the line).
.TP
.B findbracket
Moves the cursor to the bracket (brace, parenthesis, etc.) that matches
(pairs) with the one under the cursor.
Moves the cursor to the bracket (or brace or parenthesis, etc.) that matches
(pairs) with the one under the cursor. See \fBset matchbrackets\fR.
.TP
.B anchor
Places an anchor at the current line, or removes it when already present.
(An anchor is visible when line numbers are activated.)
.TP
.B prevanchor
Goes to the first anchor before the current line.
.TP
.B nextanchor
Goes to the first anchor after the current line.
.TP
.B prevbuf
Switches to editing/viewing the previous buffer when multiple buffers are open.
@@ -636,37 +775,45 @@ Refreshes the screen.
.TP
.B suspend
Suspends the editor (if the suspending function is enabled, see the
"suspendenable" entry below).
\fBsuspendable\fR toggle item below).
.TP
.B casesens
Toggles case sensitivity in searching (search/replace menus only).
Toggles whether searching/replacing ignores or respects the case of
the given characters.
.TP
.B regexp
Toggles whether searching/replacing is based on literal strings or regular expressions.
Toggles whether searching/replacing uses literal strings or regular expressions.
.TP
.B backwards
Toggles whether searching/replacing goes forward or backward.
.TP
.B prevhistory
Shows the previous history entry in the prompt menus (e.g. search).
.B older
Retrieves the previous (earlier) entry at a prompt.
.TP
.B nexthistory
Shows the next history entry in the prompt menus (e.g. search).
.B newer
Retrieves the next (later) entry at a prompt.
.TP
.B flipreplace
Toggles between searching for something and replacing something.
.TP
.B flipgoto
Toggles between searching for text and targeting a line number.
(The form 'gototext' is deprecated.)
.TP
.B flipexecute
Toggles between inserting a file and executing a command.
.TP
.B flippipe
When executing a command, toggles whether the current buffer (or marked
region) is piped to the command.
.TP
.B flipnewbuffer
Toggles between inserting into the current buffer and into a new
empty buffer.
.TP
.B flipconvert
When reading in a file, toggles between converting and not converting
it from DOS/Mac format. Converting is the default.
.TP
.B dosformat
When writing a file, switches to writing a DOS format (CR/LF).
.TP
@@ -684,37 +831,37 @@ When writing a file, creates a backup of the current file.
.TP
.B discardbuffer
When about to write a file, discard the current buffer without saving.
(This function is bound by default only when option \fB\-\-tempfile\fR
(This function is bound by default only when option \fB\-\-saveonexit\fR
is in effect.)
.TP
.B browser
Starts the file browser, allowing to select a file from a list.
Starts the file browser (in the Read File and Write Out menus),
allowing to select a file from a list.
.TP
.B gotodir
Goes to a directory to be specified, allowing to browse anywhere
in the filesystem.
.TP
.B firstfile
Goes to the first file when using the file browser (reading or writing files).
Goes to the first file in the list when using the file browser.
.TP
.B lastfile
Goes to the last file when using the file browser (reading or writing files).
Goes to the last file in the list when using the file browser.
.TP
.B nohelp
Toggles the presence of the two-line list of key bindings at the bottom of the screen.
(This toggle is special: it is available in all menus except the help viewer
and the linter. All further toggles are available in the main menu only.)
.TP
.B constupdate
.B constantshow
Toggles the constant display of the current line, column, and character positions.
.TP
.B morespace
Toggles the presence of the blank line that 'separates' the title bar from the file text.
.TP
.B smoothscroll
Toggles smooth scrolling (when moving around with the arrow keys).
.TP
.B softwrap
Toggles the displaying of overlong lines on multiple screen lines.
.TP
.B linenumbers
Toggles the display of line numbers in front of the text.
.TP
.B whitespacedisplay
Toggles the showing of whitespace.
.TP
@@ -725,9 +872,11 @@ Toggles syntax highlighting.
Toggles the smartness of the Home key.
.TP
.B autoindent
Toggles whether new lines will contain the same amount of whitespace as the preceding line.
Toggles whether a newly created line will contain the same amount of leading
whitespace as the preceding line -- or as the next line if the preceding line
is the beginning of a paragraph.
.TP
.B cuttoend
.B cutfromcursor
Toggles whether cutting text will cut the whole line or just from the current cursor
position to the end of the line.
.TP
@@ -737,21 +886,13 @@ Toggles whether long lines will be hard-wrapped to the next line.
.B tabstospaces
Toggles whether typed tabs will be converted to spaces.
.TP
.B backupfile
Toggles whether a backup will be made of the file being edited.
.TP
.B multibuffer
Toggles whether a file is inserted into the current buffer
or read into a new buffer.
.TP
.B mouse
Toggles mouse support.
.TP
.B noconvert
Toggles automatic conversion of files from DOS/Mac format.
.TP
.B suspendenable
Toggles whether the suspend sequence (normally ^Z) will suspend the editor window.
.B suspendable
Toggles whether the suspend keystroke (\fB^Z\fR by default)
will actually suspend the editor.
(The old name of this function, 'suspendenable', is deprecated.)
.RE
.TP
@@ -761,6 +902,9 @@ Valid \fImenu\fP sections are:
.B main
The main editor window where text is entered and edited.
.TP
.B help
The help-viewer menu.
.TP
.B search
The search menu (AKA whereis).
.TP
@@ -770,6 +914,9 @@ The 'search to replace' menu.
.B replacewith
The 'replace with' menu, which comes up after 'search to replace'.
.TP
.B yesno
The 'yesno' menu, where the Yes/No/All/Cancel question is asked.
.TP
.B gotoline
The 'goto line (and column)' menu.
.TP
@@ -779,20 +926,9 @@ The 'write file' menu.
.B insert
The 'insert file' menu.
.TP
.B extcmd
The menu for inserting output from an external command, reached from the insert menu.
.TP
.B help
The help-viewer menu.
.TP
.B spell
The interactive spell checker Yes/no menu.
.TP
.B linter
The linter menu.
.TP
.B browser
The file browser for inserting or writing a file.
The 'file browser' menu, for selecting a file to be opened or
inserted or written to.
.TP
.B whereisfile
The 'search for a file' menu in the file browser.
@@ -800,6 +936,18 @@ The 'search for a file' menu in the file browser.
.B gotodir
The 'go to directory' menu in the file browser.
.TP
.B execute
The menu for inserting the output from an external command,
or for filtering the buffer (or the marked region) through
an external command, or for executing one of several tools.
(The old form of this menu name, 'extcmd', is deprecated.)
.TP
.B spell
The menu of the integrated spell checker where the user can edit a misspelled word.
.TP
.B linter
The linter menu, which allows jumping through the linting messages.
.TP
.B all
A special name that encompasses all menus.
For \fBbind\fR it means all menus where the specified \fIfunction\fR exists;
@@ -808,16 +956,11 @@ for \fBunbind\fR it means all menus where the specified \fIkey\fR exists.
.SH FILES
.TP
.B /etc/nanorc
.I /etc/nanorc
System-wide configuration file.
.TP
.BR ~/.nanorc " or " \fI$XDG_CONFIG_HOME\fB/nano/nanorc " or " ~/.config/nano/nanorc
.IR ~/.nanorc " or " $XDG_CONFIG_HOME/nano/nanorc " or " ~/.config/nano/nanorc
Per-user configuration file.
.SH SEE ALSO
.BR nano (1)
.SH AUTHOR
Chris Allegretta and others (see the files \fIAUTHORS\fP and
\fITHANKS\fP for details). This manual page was originally written by
Jordi Mallach for the Debian system (but may be used by others).

View File

@@ -1,4 +1,4 @@
.\" Copyright (C) 2002, 2005, 2006, 2007, 2014 Free Software Foundation, Inc.
.\" Copyright (C) 2002-2007, 2014-2020 Free Software Foundation, Inc.
.\"
.\" This document is dual-licensed. You may distribute and/or modify it
.\" under the terms of either of the following licenses:
@@ -7,16 +7,16 @@
.\" Foundation, version 3 or (at your option) any later version. You
.\" should have received a copy of the GNU General Public License
.\" along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\" <https://www.gnu.org/licenses/>.
.\"
.\" * The GNU Free Documentation License, as published by the Free
.\" Software Foundation, version 1.2 or (at your option) any later
.\" version, with no Invariant Sections, no Front-Cover Texts, and no
.\" Back-Cover Texts. You should have received a copy of the GNU Free
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\" <https://www.gnu.org/licenses/>.
.\"
.TH RNANO 1 "version 2.9.5" "March 2018"
.TH RNANO 1 "version 5.2" "August 2020"
.SH NAME
rnano \- a restricted nano
@@ -29,16 +29,14 @@ rnano \- a restricted nano
\fBrnano\fR runs the \fBnano\fR editor in restricted mode. This allows
editing only the specified file or files, and doesn't allow the user
access to the filesystem nor to a command shell.
.PP
.sp
In restricted mode, \fBnano\fR will:
.IP \[bu] 2
not read any nanorc files;
.IP \[bu]
not allow suspending;
.IP \[bu]
not read nor write any file not specified on the command line;
not allow saving the current buffer under a different name;
.IP \[bu]
not allow saving a file under a different name;
not allow inserting another file or opening a new buffer;
.IP \[bu]
not allow appending or prepending to any file;
.IP \[bu]
@@ -47,20 +45,16 @@ not make backup files nor do spell checking.
.SH OPTIONS
.TP
.BR \-h ", " \-\-help
Show a summary of command-line options and exit.
.PP
See the \fBnano\fP(1) manpage for all available options.
Show the available command-line options and exit.
.P
For all existing options, see the \fBnano\fR(1) man page.
.SH BUGS
Please report bugs via \fIhttps://savannah.gnu.org/bugs/?group=nano\fR.
Please report bugs via
.IR https://savannah.gnu.org/bugs/?group=nano .
.SH HOMEPAGE
https://nano-editor.org/
.I https://nano-editor.org/
.SH SEE ALSO
.BR nano (1)
.SH AUTHOR
Chris Allegretta and others (see the files \fIAUTHORS\fR and \fITHANKS\fR
for details). This manual page was originally written by Thijs Kinkhorst
for the Debian system (but may be used by others).

View File

@@ -1,25 +1,24 @@
## Sample initialization file for GNU nano.
##
## Please note that you must have configured nano with --enable-nanorc
## for this file to be read! Also note that this file should not be in
## DOS or Mac format, and that characters specially interpreted by the
## shell should not be escaped here.
## For the options that take parameters, the default value is shown.
## Other options are unset by default. To make sure that an option
## is disabled, you can use "unset <option>".
##
## To make sure an option is disabled, use "unset <option>".
##
## For the options that take parameters, the default value is given.
## Other options are unset by default.
##
## Quotes inside string parameters don't have to be escaped with
## backslashes. The last double quote in the string will be treated as
## its end. For example, for the "brackets" option, ""')>]}" will match
## ", ', ), >, ], and }.
## Characters that are special in a shell should not be escaped here.
## Inside string parameters, quotes should not be escaped -- the last
## double quote on the line will be seen as the closing quote.
## Make 'nextword' (Ctrl+Right) and 'chopwordright' (Ctrl+Delete)
## stop at word ends instead of at beginnings.
# set afterends
## When soft line wrapping is enabled, make it wrap lines at blanks
## (tabs and spaces) instead of always at the edge of the screen.
# set atblanks
## Use auto-indentation.
## Automatically indent a newly created line to the same number of
## tabs and/or spaces as the preceding line -- or as the next line
## if the preceding line is the beginning of a paragraph.
# set autoindent
## Back up files to the current filename plus a tilde.
@@ -31,33 +30,45 @@
## Use bold text instead of reverse video text.
# set boldtext
## The characters treated as closing brackets when justifying
## paragraphs. They cannot contain blank characters. Only closing
## punctuation, optionally followed by closing brackets, can end
## sentences.
## Treat any line with leading whitespace as the beginning of a paragraph.
# set bookstyle
## The characters treated as closing brackets when justifying paragraphs.
## This may not include any blank characters. Only closing punctuation,
## optionally followed by these closing brackets, can end sentences.
# set brackets ""')>]}"
## Automatically hard-wrap the current line when it becomes overlong.
# set breaklonglines
## Do case-sensitive searches by default.
# set casesensitive
## Constantly display the cursor position in the status bar. Note that
## this overrides "quickblank".
# set constantshow
## (The old form, 'const', is deprecated.)
## Use cut-from-cursor-to-end-of-line by default.
# set cutfromcursor
## (The old form, 'cut', is deprecated.)
## Set the line length for wrapping text and justifying paragraphs.
## If the value is 0 or less, the wrapping point will be the screen
## width less this number.
## Do not use the line below the title bar, leaving it entirely blank.
# set emptyline
## Set the target width for automatic hard-wrapping and for justifying
## paragraphs. If the specified value is 0 or less, the wrapping point
## will be the terminal's width minus this number.
# set fill -8
## Remember the used search/replace strings for the next session.
# set historylog
## Display line numbers to the left of the text.
## Display a "scrollbar" on the righthand side of the edit window.
# set indicator
## Scroll the buffer contents per half-screen instead of per line.
# set jumpyscrolling
## Display line numbers to the left (and any anchors in the margin).
# set linenumbers
## Enable vim-style lock-files. This is just to let a vim user know you
@@ -70,9 +81,6 @@
## come before the latter set, and both must be in the same order.
# set matchbrackets "(<[{)>]}"
## Use the blank line below the title bar as extra editing space.
# set morespace
## Enable mouse support, if available for your system. When enabled,
## mouse clicks can be used to place the cursor, set the mark (with a
## double click), and execute shortcuts. The mouse will work in the X
@@ -89,16 +97,9 @@
## Don't display the helpful shortcut lists at the bottom of the screen.
# set nohelp
## Don't pause between warnings at startup. Which means that only the
## last one will be readable (when there are multiple ones).
# set nopauses
## Don't add newlines to the ends of files.
## Don't automatically add a newline when a file does not end with one.
# set nonewlines
## Don't wrap text at all.
# set nowrap
## Set operating directory. nano will not read or write files outside
## this directory and its subdirectories. Also, the current directory
## is changed to here, so any files are inserted from this dir. A blank
@@ -107,7 +108,6 @@
## Remember the cursor position in each file for the next editing session.
# set positionlog
## (The old form, 'poslog', is deprecated.)
## Preserve the XON and XOFF keys (^Q and ^S).
# set preserve
@@ -122,25 +122,27 @@
## 1 keystroke instead of 26. Note that "constantshow" overrides this.
# set quickblank
## The email-quote string, used to justify email-quoted paragraphs.
## This is an extended regular expression if your system supports them,
## otherwise a literal string.
## If you have extended regular expression support, the default is:
# set quotestr "^([ ]*[#:>\|}])+"
## Otherwise:
# set quotestr "> "
## The regular expression that matches quoting characters in email
## or line-comment introducers in source code. The default is:
# set quotestr "^([ ]*([!#%:;>|}]|//))+"
## Try to work around a mismatching terminfo terminal description.
# set rawsequences
## Fix Backspace/Delete confusion problem.
# set rebinddelete
## Fix numeric keypad key confusion problem.
# set rebindkeypad
## Do extended regular expression searches by default.
## Do regular-expression searches by default.
## Regular expressions are of the extended type (ERE).
# set regexp
## Put the cursor on the highlighted item in the file browser;
## useful for people who use a braille display.
## Save a changed buffer automatically on exit; don't prompt.
# set saveonexit
## (The old form of this option, 'set tempfile', is deprecated.)
## Put the cursor on the highlighted item in the file browser, and show
## the cursor in the help viewer; useful for people who use a braille
## display and people with poor vision.
# set showcursor
## Make the Home key smarter. When Home is pressed anywhere but at the
@@ -150,18 +152,16 @@
## beginning of the line.
# set smarthome
## Use smooth scrolling as the default.
# set smooth
## Enable soft line wrapping (AKA full-line display).
## Spread overlong lines over multiple screen lines.
# set softwrap
## Use this spelling checker instead of the internal one. This option
## does not have a default value.
# set speller "aspell -x -c"
## Allow nano to be suspended.
# set suspend
## Allow nano to be suspended (with ^Z by default).
# set suspendable
## (The old form of this option, 'set suspend', is deprecated.)
## Use this tab size instead of the default; it must be greater than 0.
# set tabsize 8
@@ -169,9 +169,6 @@
## Convert typed tabs to spaces.
# set tabstospaces
## Save automatically on exit; don't prompt.
# set tempfile
## Snip whitespace at the end of lines when justifying or hard-wrapping.
# set trimblanks
@@ -195,78 +192,96 @@
## set, it overrides option 'set wordbounds'.
# set wordchars "<_>."
## Let an unmodified Backspace or Delete erase the marked region (instead
## of a single character, and without affecting the cutbuffer).
# set zap
## Paint the interface elements of nano. These are examples;
## by default there are no colors, except for errorcolor.
# set titlecolor brightwhite,blue
# set statuscolor brightwhite,green
# set errorcolor brightwhite,red
# set selectedcolor brightwhite,magenta
# set titlecolor bold,lightwhite,blue
# set statuscolor bold,lightwhite,green
# set errorcolor bold,lightwhite,red
# set selectedcolor lightwhite,magenta
# set stripecolor ,yellow
# set numbercolor cyan
# set keycolor cyan
# set functioncolor green
## In root's .nanorc you might want to use:
# set titlecolor brightwhite,magenta
# set statuscolor brightwhite,magenta
# set errorcolor brightwhite,red
# set selectedcolor brightwhite,cyan
# set titlecolor bold,lightwhite,magenta
# set statuscolor bold,lightwhite,magenta
# set errorcolor bold,lightwhite,red
# set selectedcolor lightwhite,cyan
# set stripecolor ,yellow
# set numbercolor magenta
# set keycolor brightmagenta
# set keycolor lightmagenta
# set functioncolor magenta
## Setup of syntax coloring.
##
## Format:
##
## syntax "short description" ["filename regex" ...]
##
## The "none" syntax is reserved; specifying it on the command line is
## the same as not having a syntax at all. The "default" syntax is
## special: it takes no filename regexes, and applies to files that
## don't match any other syntax's filename regexes.
##
## color foreground,background "regex" ["regex"...]
## or
## icolor foreground,background "regex" ["regex"...]
##
## "color" will do case-sensitive matches, while "icolor" will do
## case-insensitive matches.
##
## Valid colors: white, black, red, blue, green, yellow, magenta, cyan.
## For foreground colors, you may use the prefix "bright" to get a
## stronger highlight.
##
## To use multi-line regexes, use the start="regex" end="regex"
## [start="regex" end="regex"...] format.
##
## If your system supports transparency, not specifying a background
## color will use a transparent color. If you don't want this, be sure
## to set the background color to black or white.
##
## All regexes should be extended regular expressions.
##
## If you wish, you may put your syntax definitions in separate files.
## You can make use of such files as follows:
##
## include "/path/to/syntax_file.nanorc"
##
## Unless otherwise noted, the name of the syntax file (without the
## ".nanorc" extension) should be the same as the "short description"
## name inside that file. These names are kept fairly short to make
## them easier to remember and faster to type using nano's -Y option.
##
## === Syntax coloring ===
## For all details, see 'man nanorc', section SYNTAX HIGHLIGHTING.
## To include all existing syntax definitions, you can do:
# include "@PKGDATADIR@/*.nanorc"
## Or you can select just the ones you need. For example:
# include "@PKGDATADIR@/html.nanorc"
# include "@PKGDATADIR@/python.nanorc"
# include "@PKGDATADIR@/sh.nanorc"
## Key bindings.
## See nanorc(5) (section REBINDING KEYS) for more details on this.
##
## The following two functions are not bound to any key by default.
## You may wish to choose other keys than the ones suggested here.
# bind M-B cutwordleft main
# bind M-N cutwordright main
## In @PKGDATADIR@/extra/ you can find some syntaxes that are
## specific for certain distros or for less common languages.
## Set this if your Backspace key sends Del most of the time.
# bind Del backspace all
## If <Tab> should always produce four spaces when editing a Python file,
## independent of the settings of 'tabsize' and 'tabstospaces':
# extendsyntax python tabgives " "
## If <Tab> should always produce an actual TAB when editing a Makefile:
# extendsyntax makefile tabgives " "
## === Key bindings ===
## For all details, see 'man nanorc', section REBINDING KEYS.
## The <Ctrl+Delete> keystroke deletes the word to the right of the cursor.
## On some terminals the <Ctrl+Backspace> keystroke produces ^H, which is
## the ASCII character for backspace, so it is bound by default to the
## backspace function. The <Backspace> key itself produces a different
## keycode, which is hard-bound to the backspace function. So, if you
## normally use <Backspace> for backspacing and not ^H, you can make
## <Ctrl+Backspace> delete the word to the left of the cursor with:
# bind ^H chopwordleft main
## If you would like nano to have keybindings that are more "usual",
## such as ^O for Open, ^F for Find, ^H for Help, and ^Q for Quit,
## then uncomment these:
#bind ^Q exit all
#bind ^S savefile main
#bind ^W writeout main
#bind ^O insert main
#bind ^H help all
#bind ^H exit help
#bind ^F whereis all
#bind ^G findnext all
#bind ^B wherewas all
#bind ^D findprevious all
#bind ^R replace main
#bind M-X flipnewbuffer all
#bind ^X cut all
#bind ^C copy main
#bind ^V paste all
#bind ^P location main
#bind ^A mark main
#unbind ^K main
#unbind ^U all
#unbind ^N main
#unbind ^Y all
#unbind M-J main
#unbind M-T main
#bind ^T gotoline main
#bind ^T gotodir browser
#bind ^Y speller main
#bind M-U undo main
#bind M-R redo main
#bind ^U undo main
#bind ^E redo main
#set multibuffer

View File

@@ -1,29 +0,0 @@
2002-08-21 gettextize <bug-gnu-gettext@gnu.org>
* gettext.m4: Upgrade to gettext-0.11.5.
* ulonglong.m4: New file, from gettext-0.11.5.
* iconv.m4: Upgrade to gettext-0.11.5.
* intdiv0.m4: New file, from gettext-0.11.5.
* inttypes.m4: New file, from gettext-0.11.5.
* inttypes_h.m4: New file, from gettext-0.11.5.
* inttypes-pri.m4: New file, from gettext-0.11.5.
* lcmessage.m4: Upgrade to gettext-0.11.5.
* lib-link.m4: Upgrade to gettext-0.11.5.
* stdint_h.m4: New file, from gettext-0.11.5.
* uintmax_t.m4: New file, from gettext-0.11.5.
* Makefile.am (EXTRA_DIST): Add the new files.
2002-06-03 gettextize <bug-gnu-gettext@gnu.org>
* codeset.m4: Upgrade to gettext-0.11.2.
* gettext.m4: Upgrade to gettext-0.11.2.
* glibc21.m4: Upgrade to gettext-0.11.2.
* iconv.m4: Upgrade to gettext-0.11.2.
* isc-posix.m4: New file, from gettext-0.11.2.
* lcmessage.m4: Upgrade to gettext-0.11.2.
* lib-ld.m4: New file, from gettext-0.11.2.
* lib-link.m4: New file, from gettext-0.11.2.
* lib-prefix.m4: New file, from gettext-0.11.2.
* progtest.m4: Upgrade to gettext-0.11.2.
* Makefile.am (EXTRA_DIST): Add the new files.

View File

@@ -1,53 +0,0 @@
%define name @PACKAGE@
%define version @VERSION@
%define release 1
Name : %{name}
Version : %{version}
Release : %{release}
Summary : a user-friendly editor, a Pico clone with enhancements
License : GPLv3+
Group : Applications/Editors
URL : https://nano-editor.org/
Source : https://nano-editor.org/dist/latest/%{name}-%{version}.tar.gz
BuildRoot : %{_tmppath}/%{name}-%{version}-root
BuildRequires : autoconf, automake, gettext-devel, ncurses-devel, texinfo
Requires(post) : info
Requires(preun) : info
%description
GNU nano is a small and friendly text editor. It aims to emulate the
Pico text editor while also offering several enhancements.
%prep
%setup -q
%build
%configure
make
%install
make DESTDIR="%{buildroot}" install
#ln -s nano %{buildroot}/%{_bindir}/pico
rm -f %{buildroot}/%{_infodir}/dir
%post
/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir || :
%preun
if [ $1 = 0 ] ; then
/sbin/install-info --delete %{_infodir}/%{name}.info %{_infodir}/dir || :
fi
%files
%defattr(-,root,root)
%doc AUTHORS COPYING ChangeLog INSTALL NEWS README THANKS TODO doc/faq.html doc/sample.nanorc
%{_bindir}/*
%{_docdir}/nano/*
%{_mandir}/man*/*
%{_mandir}/fr/man*/*
%{_infodir}/nano.info*
%{_datadir}/locale/*/LC_MESSAGES/nano.mo
%{_datadir}/nano/*

View File

@@ -1,998 +0,0 @@
2014-05-28 Benno Schulenberg <bensberg@justemail.net>
* de.po, eo.po, nl.po: Updates for German, Dutch, and Esperanto.
2014-05-27 Benno Schulenberg <bensberg@justemail.net>
* de.po, nl.po, ru.po: Updates for Russian, Dutch, and German.
2014-05-25 Benno Schulenberg <bensberg@justemail.net>
* it.po, uk.po: Updates from the TP for Ukrainian and Italian.
2014-05-22 Benno Schulenberg <bensberg@justemail.net>
* de.po, uk.po: Updates from the TP for German and Ukrainian.
2014-05-16 Benno Schulenberg <bensberg@justemail.net>
* eo.po, fi.po, fr.po, nl.po, vi.po: Updates from the TP for
Vietnamese, Finnish, Dutch, French, and Esperanto.
2014-05-13 Benno Schulenberg <bensberg@justemail.net>
* nano.pot, *.po: Regenerated the POT file and refreshed the PO's.
2014-03-22 Benno Schulenberg <bensberg@justemail.net>
* nano.pot: Regenerated the POT file.
* cs.po, es.po, it.po, nb.po, sr.po, zh_TW: Updates from the TP
for Czech, Spanish, Italian, Norwegian, Serbian, and Chinese.
* LINGUAS: Removed rw (Kinyarwanda) -- it was just fragments.
2007-12-09 Jordi Mallach <jordi@gnu.org>
* LINGUAS: Add zh_CN.
* es.po, fr.po, it.po, nb.po, nl.po, pt_BR.po: New pull from the TP,
to fetch the now corrected latest pt_BR file.
2007-12-08 Jordi Mallach <jordi@gnu.org>
* zh_CN.po: New Simplified Chinese translation by
LI Daobing <lidaobing@gmail.com>.
* fr.po, ga.po, ms.po, nl.po, nn.po, vi.po: Translation updates taken
from the Translation Project.
* Refreshed the rest of the files from the latest TP archive.
2007-09-18 Jordi Mallach <jordi@gnu.org>
* po/ru.po: Updated Russian translation by Sergey A. Ribalchenko.
2007-08-11 David Lawrence Ramsey <pooka109@gmail.com>
* po/update.pl: Relicense to the GNU GPL version 3 or later.
2007-07-31 David Lawrence Ramsey <pooka109@gmail.com>
* po/update.pl: Update copyright notice to account for
modifications.
2007-01-29 David Lawrence Ramsey <pooka109@cox.net>
* ru.po: Updated Russian translation by Dimitriy Ryazantcev.
* ru.po: Fix incorrect "Project-Id-Version" entry and misplaced
space.
2007-01-13 David Lawrence Ramsey <pooka109@cox.net>
* es.po: Fix misplaced space.
* eu.po: Fix typos and misplaced space.
* fr.po: Fix misplaced space.
* gl.po: Fix typos and misplaced space.
* nb.po: Fix typos and more misplaced space.
2007-01-06 David Lawrence Ramsey <pooka109@cox.net>
* nb.po: Fix misplaced space.
2006-12-06 David Lawrence Ramsey <pooka109@cox.net>
* hu.po: Removed unneeded duplicate plural forms again.
* ms.po: Fix incorrect "Project-Id-Version" entry.
2006-12-06 Jordi Mallach <jordi@gnu.org>
* hu.po: Updated Hungarian translation by Gabor Kelemen.
* ms.po: Updated Malay translation by
Sharuzzaman Ahmat Raslan.
2006-11-20 David Lawrence Ramsey <pooka109@cox.net>
* tr.po: Removed unneeded blank plural forms, as gettext 0.15
generates errors upon encountering them.
2006-10-25 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by Jean-Philippe Guérard.
* nb.po: Updated Norwegian bokmål translation by
Geir Helland.
2006-10-16 Jordi Mallach <jordi@gnu.org>
* gl.po: Updated Galician translation by
Francisco Javier Tsao Santín.
2006-10-16 Jordi Mallach <jordi@gnu.org>
* eu.po: Updated Basque translation by Mikel Olasagasti.
2006-10-10 Jordi Mallach <jordi@gnu.org>
* gl.po: Updated Galician translation by
Francisco Javier Tsao Santín.
2006-10-02 Jordi Mallach <jordi@gnu.org>
* pt_BR.po: Refetch the current nano 1.9.99pre0 pt_BR file from
the TP, as the latest file offered is apparently for 1.3.11pre1.
2006-10-02 David Lawrence Ramsey <pooka109@cox.net>
* pt_BR.po: Restore previous version of pt_BR, as it was for
nano 1.9.99pre0, and the current version is for 1.3.11pre1.
2006-09-27 Jordi Mallach <jordi@gnu.org>
* pt_BR.po: Updated Brazilian Portuguese translation by
Joao Victor Duarte Martins.
2006-09-10 David Lawrence Ramsey <pooka109@cox.net>
* hu.po: Removed unneeded duplicate plural forms again.
2006-09-10 Jordi Mallach <jordi@gnu.org>
* hu.po: Updated Hungarian translation by Gabor Kelemen.
2006-09-02 Jordi Mallach <jordi@gnu.org>
* pt_BR.po: Updated Brazilian Portuguese translation by
Joao Victor Duarte Martins.
2006-09-01 Benno Schulenberg <bensberg@justemail.net>
* ChangeLog: Fix incorrect years in two entries.
2006-08-31 David Lawrence Ramsey <pooka109@cox.net>
* bg.po: Fix misplaced space.
2006-08-31 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* de.po: Updated German translation by Michael Piefel.
* es.po: Updated Spanish translation by
Ricardo Javier Cardenes Medina.
2006-08-28 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by Jean-Philippe Guérard.
2006-08-25 Jordi Mallach <jordi@gnu.org>
* bg.po: Updated Bulgarian translation by Anton Zinoviev.
* ca.po: Updated Catalan translation.
* ga.po: Updated Irish translation by Kevin Patrick Scannell.
* it.po: Updated Italian translation by Marco Colombo.
* nl.po: Updated Dutch translation by Benno Schulenberg.
* sv.po: Updated Swedish translation by Daniel Nylander.
2006-08-15 David Lawrence Ramsey <pooka109@cox.net>
* hu.po: Removed unneeded duplicate plural forms, as gettext
0.15 generates errors upon encountering them.
* id.po: Removed unneeded duplicate plural forms, as gettext
0.15 generates errors upon encountering them.
2006-06-20 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* fr.po: Updated French translation by Jean-Philippe Guérard.
* hu.po: Updated Hungarian translation by Gabor Kelemen.
* nl.po: Updated Dutch translation by Benno Schulenberg.
2006-06-20 David Lawrence Ramsey <pooka109@cox.net>
* fr.po: Fix incorrect "Project-Id-Version" entry.
* hu.po: Fix incorrect "Project-Id-Version" entry.
* it.po: Fix incorrect "Project-Id-Version" entry.
2006-06-19 Jordi Mallach <jordi@gnu.org>
* bg.po: Updated Bulgarian translation by Anton Zinoviev.
* ga.po: Updated Irish translation by Kevin Patrick Scannell.
2006-06-17 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* de.po: Updated German translation by Michael Piefel.
* fr.po: Updated French translation by Jean-Philippe Guérard.
* hu.po: Updated Hungarian translation by Gabor Kelemen.
* it.po: Updated Italian translation by Marco Colombo.
* nl.po: Updated Dutch translation by Benno Schulenberg.
2006-06-12 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by Jean-Philippe Guérard.
* hu.po: Updated Hungarian translation by Gabor Kelemen.
2006-06-09 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* ga.po: Updated Irish translation by Kevin Patrick Scannell.
* it.po: Updated Italian translation by Marco Colombo.
* nl.po: Updated Dutch translation by Benno Schulenberg.
2006-05-17 Jordi Mallach <jordi@gnu.org>
* LINGUAS: Added "ga".
* ga.po: New Irish translation by
Kevin Patrick Scannell <scannell@SLU.EDU>.
2006-05-10 Jordi Mallach <jordi@gnu.org>
* nl.po: Updated Dutch translation by Benno Schulenberg.
2006-03-15 Jordi Mallach <jordi@gnu.org>
* sv.po: Updated Swedish translation by Daniel Nylander.
2006-03-06 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Vietnamese translation by
Phan Vinh Thinh.
2005-12-21 Jordi Mallach <jordi@gnu.org>
* bg.po: Updated Bulgarian translation by Anton Zinoviev.
* ca.po: Updated Catalan translation.
* fr.po: Updated French translation by Jean-Philippe Guérard.
* ms.po: Updated Malay translation by Sharuzzaman Ahmat Raslan.
* zh_TW: Updated Traditional Chinese translation by
Wei-Lun Chao.
2005-12-13 Jordi Mallach <jordi@gnu.org>
* it.po: Updated Italian translation by Marco Colombo.
* de.po: Updated German translation by Michael Piefel.
* nl.po: Updated Dutch translation by Benno Schulenberg.
2005-11-08 David Lawrence Ramsey <pooka109@cox.net>
* POTFILES.in: Add prompt.c.
2005-11-05 David Lawrence Ramsey <pooka109@cox.net>
* POTFILES.in: Add browser.c.
2005-11-01 David Lawrence Ramsey <pooka109@cox.net>
* POTFILES.in: Add help.c.
2005-10-23 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* eu.po: Updated Basque translation by Mikel Olasagasti.
* fr.po: Updated French translation by Jean-Philippe Guérard.
* it.po: Updated Italian translation by Marco Colombo.
* ms.po: Updated Malay translation by Sharuzzaman Ahmat Raslan.
* nl.po: Updated Dutch translation by Benno Schulenberg.
* zh_TW: Updated Traditional Chinese translation by
Wei-Lun Chao.
2005-08-22 Jordi Mallach <jordi@gnu.org>
* bg.po: New Bulgarian translation by
Yavor Doganov <yavor@doganov.org>.
* LINGUAS: Added "bg".
2005-08-16 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
2005-08-16 Jordi Mallach <jordi@gnu.org>
* nl.po: Updated Dutch translation by
Benno Schulenberg and Reinout van Schouwen.
2005-07-24 David Lawrence Ramsey <pooka109@cox.net>
* POTFILES.in: Add text.c.
2005-07-19 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by
Sharuzzaman Ahmat Raslan.
2005-07-18 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by
Jean-Philippe Guérard.
2005-07-07 Jordi Mallach <jordi@gnu.org>
* it.po: Updated Italian translation by Marco Colombo.
* ca.po: Updated Catalan translation.
2005-06-28 David Lawrence Ramsey <pooka109@cox.net>
* POTFILES.in: Remove source files that contain no translatable
strings.
2005-06-19 David Lawrence Ramsey <pooka109@cox.net>
* pt_BR.po: Typo fix.
2005-06-15 Jordi Mallach <jordi@gnu.org>
* de.po: Typo fix by Jens Seidel.
2005-05-23 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by
Jean-Philippe Guérard.
2005-04-27 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by
Sharuzzaman Ahmat Raslan.
2005-04-22 Jordi Mallach <jordi@gnu.org>
* nb.po: Updated Norwegian bokmål translation by
Geir Helland.
2005-04-20 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by
Sharuzzaman Ahmat Raslan.
* ro.po: Updated Romanian translation by Laurentiu Buzdugan.
* zh_TW.po: Updated Traditional Chinese translation by
CHAO Wei-Lun.
2005-04-18 Jordi Mallach <jordi@gnu.org>
* vi.po: Updated Vietnamese translation by Phan Vinh Thinh.
2005-04-18 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* it.po: Updated Italian translation by Marco Colombo.
* ro.po: Updated Romanian translation by Laurentiu Buzdugan.
2005-04-14 Jordi Mallach <jordi@gnu.org>
* es.po: Updated Spanish translation by
Ricardo Javier Cárdenes Medina.
2005-04-13 Jordi Mallach <jordi@gnu.org>
* vi.po: New Vietnamese translation by Phan Vinh Thinh.
* LINGUAS: Added "vi".
2005-04-09 Jordi Mallach <jordi@gnu.org>
* zh_TW.po: Added Plural-Forms header and fix format specification
typos.
2005-04-08 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* it.po: Updated Italian translation by Marco Colombo.
* zh_TW.po: Updated Traditional Chinese translation by
CHAO Wei-Lun.
2005-04-06 Jordi Mallach <jordi@gnu.org>
* rw.po: New Kinyarwanda translation by Steve Murphy.
* LINGUAS: Added "rw".
2005-04-05 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by
Jean-Philippe Guérard.
* ro.po: Updated Romanian translation by
Laurentiu Buzdugan.
2005-03-11 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by
Sharuzzaman Ahmat Raslan.
2005-01-17 Jordi Mallach <jordi@gnu.org>
* pt_BR.po: Updated Brazilian Portuguese translation by
Joao Victor Duarte Martins.
2004-12-15 Jordi Mallach <jordi@gnu.org>
* it.po: Updated Italian translation by Marco Colombo.
2004-12-15 Jordi Mallach <jordi@gnu.org>
* sv.po: Updated Swedish translation by Christian Rose.
2004-12-13 Jordi Mallach <jordi@gnu.org>
* sv.po: Updated Swedish translation by Christian Rose.
2004-12-07 Jordi Mallach <jordi@gnu.org>
* it.po: Updated Italian translation by
Marco Colombo.
* ro.po: Updated Romanian translation by
Laurentiu Buzdugan.
2004-12-01 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* nb: Updated Norwegian bokmål translation by
Geir Helland.
* fr.po: Updated French translation by
Jean-Philippe Guérard.
2004-11-18 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by
Jean-Philippe Guérard.
2004-11-18 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by
Sharuzzaman Ahmat Raslan.
2004-10-07 Jordi Mallach <jordi@gnu.org>
* eu.po: Updated Basque translation by
Mikel Olasagasti.
2004-08-31 Jordi Mallach <jordi@gnu.org>
* es.po: Updated Spanish translation by
Ricardo Javier Cárdenes Medina.
2004-08-31 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated Catalan translation by
Jean-Philippe Guérard.
2004-08-27 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* de.po: Updated German translation by Michael Piefel.
2004-06-01 Jordi Mallach <jordi@gnu.org>
* zh_TW.po: Added Traditional Chinese translation by
CHAO Wei-Lun <chaoweilun@pcmail.com.tw>.
* LINGUAS: Added "zh_TW".
2004-02-24 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by Sharuzzaman Ahmat Raslan.
2003-11-25 Jordi Mallach <jordi@gnu.org>
* ro.po: Updated Romanian translation by Laurentiu Buzdugan.
2003-11-06 Jordi Mallach <jordi@gnu.org>
* sr.po: Added Serbian translation by Danilo Segan <dsegan@gmx.net>.
* LINGUAS: Added "sr" (Serbian), and alphabetize.
* ChangeLog: Recoded as UTF-8.
2003-10-30 Jordi Mallach <jordi@gnu.org>
* fi.po: Patch from Martin-Eric Racine <q-funk@pp.fishpool.fi>
to accept "Yy" and "Nn" as well as the Finnish letters in Yes/No
prompts.
2003-10-18 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
2003-09-12 Jordi Mallach <jordi@gnu.org>
* POTFILES.in: Updated path to sources.
2003-09-01 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by Jean-Philippe Guérard.
2003-08-17 Jordi Mallach <jordi@gnu.org>
* tr.po: Updated Turkish translation by A. Murat EREN.
2003-08-05 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
2003-06-11 Jordi Mallach <jordi@gnu.org>
* nb.po: Updated Norwegian bokmål translation by Geir Helland.
2003-06-10 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by Jean-Philippe Guérard.
2003-06-02 Jordi Mallach <jordi@gnu.org>
* de.po: Updated German translation by Michael Piefel.
2003-05-06 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by Sharuzzaman Ahmat Raslan.
2003-04-24 Jordi Mallach <jordi@gnu.org>
* ro.po: New Romanian translation by Laurentiu Buzdugan.
* id.po: Updated Indonesian translation by Tedi Heriyanto.
* LINGUAS: Added "ro" (Romanian).
2003-04-12 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by Sharuzzaman Ahmat Raslan.
2003-04-04 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by Jean-Philippe Guérard.
2003-03-17 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by Sharuzzaman Ahmat Raslan.
2003-03-10 Jordi Mallach <jordi@gnu.org>
* da.po: Updated Danish translation by Keld Simonsen.
2003-03-06 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by Sharuzzaman Ahmat Raslan.
* id.po: Updated Indonesian translation by Tedi Heriyanto.
2003-02-23 Jordi Mallach <jordi@gnu.org>
* nl.po: Updated Dutch translation by Guus Sliepen.
2003-02-19 Jordi Mallach <jordi@gnu.org>
* fi.po: Updated Finnish translation by Kalle Olavi Niemitalo.
* es.po: Updated Spanish translation by Ricardo Javier Cárdenes
Medina.
2003-02-17 Jordi Mallach <jordi@gnu.org>
* de.po: Updated German translation by Michael Piefel.
* ru.po: Updated Russian translation by Sergey A. Ribalchenko.
* uk.po: Updated Ukrainian translation by Sergey A. Ribalchenko.
2003-02-16 Jordi Mallach <jordi@gnu.org>
* gl.po: Updated Galician translation by Jacobo Tarrío.
* fr.po: Updated French translation by Jean-Philippe Guérard.
2003-02-15 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by Jean-Philippe Guérard.
* nl.po: Updated Dutch translation by Guus Sliepen.
* sv.po: Updated Swedish translation by Christian Rose.
* ca.po: Updated Catalan translation.
2003-02-13 Jordi Mallach <jordi@gnu.org>
* ru.po: Updated Russian translation from Sergey A. Ribalchenko.
2003-02-10 Jordi Mallach <jordi@gnu.org>
* Makevars (XGETTEXT_OPTIONS): Added --keyword=P_:1,2.
* update.pl: likewise.
* fi.po: Added Plural-Forms: header.
2003-02-10 Jordi Mallach <jordi@gnu.org>
* fi.po: Updated Finnish translation by Kalle Kivimaa and
Kalle Olavi Niemitalo.
2003-02-08 Chris Allegretta <chrisa@asty.org>
* it.po: Fix broken format string in translation.
2003-02-08 Jordi Mallach <jordi@gnu.org>
* it.po: Updated Italian translation by Marco Colombo.
* gl.po: Updated Galician translation by Jacobo Tarrío.
* es.po: Updated Spanish translation by Ricardo Javier Cárdenes
Medina.
2003-02-06 Jordi Mallach <jordi@gnu.org>
* pl.po: Updated Polish translation by Wojciech Kotwica.
* sv.po: Updated Swedish translation by Christian Rose.
2003-02-04 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* fr.po: Updated French translation by Jean-Philippe Guérard.
* uk.po: Updated Ukrainian translation by Sergey A. Ribalchenko.
* de.po: Updated German translation by Michael Piefel.
2003-01-27 Jordi Mallach <jordi@gnu.org>
* es.po: Updated translation by Ricardo Javier Cárdenes Medina.
2002-01-26 Jordi Mallach <jordi@gnu.org>
* pl.po: Updated translation by Wojciech Kotwica.
2002-01-25 Jordi Mallach <jordi@gnu.org>
* gl.po: Updated translation by Jacobo Tarrío.
2002-01-22 Jordi Mallach <jordi@gnu.org>
* de.po: Updated translation by Michael Piefel.
2003-01-21 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated translation by Jean-Philippe Guérard.
* ms.po: Updated translation by Sharuzzaman Ahmat Raslan.
* uk.po: Updated translation by Sergey A. Ribalchenko.
2003-01-18 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated translation by Jean-Philippe Guérard.
* sv.po: Updated translation by Christian Rose.
* nl.po: Updated translation by Guus Sliepen.
* ca.po: Updated translation.
2003-01-15 Jordi Mallach <jordi@gnu.org>
* Makefile.in.in: Removed, generated by autopoint.
* Rules-quot: Likewise.
* boldquot.sed: Likewise.
* en@boldquot.header: Likewise.
* en@quot.header: Likewise.
* insert-header.sin: Likewise.
* quot.sed: Likewise.
* remove-potcdate.sin: Likewise.
2003-01-15 Jordi Mallach <jordi@gnu.org>
* LINGUAS: New file, exported values from configure.ac's ALL_LINGUAS.
* it.po: Updated translation by Marco Colombo.
* eu.po: New Basque translation by Peio Ziarsolo.
2002-12-14 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
* tr.po: New Turkish translation by Doruk Fisek.
2002-11-10 Jordi Mallach <jordi@sindominio.net>
* uk.po: Updated translation by Sergey A. Ribalchenko.
* da.po: Updated translation by Keld Simonsen.
2002-11-05 Jordi Mallach <jordi@sindominio.net>
* ms.po: Updated translation by Sharuzzaman Ahmat Raslan.
2002-11-03 Jordi Mallach <jordi@sindominio.net>
* sv.po: Updated translation by Christian Rose.
* pl.po: Updated translation by Wojciech Kotwica.
2002-10-29 Jordi Mallach <jordi@sindominio.net>
* id.po: Updated translation by Tedi Heriyanto.
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-10-27 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-10-26 Jordi Mallach <jordi@sindominio.net>
* es.po: Updated translation by Ricardo Javier Cárdenes Medina.
2002-10-26 Jordi Mallach <jordi@sindominio.net>
* gl.po: Updated translation by Jacobo Tarrío.
* sv.po: Updated translation by Christian Rose.
* de.po: Updated translation by Michael Piefel.
* fr.po: Updated translation by Jean-Philippe Guérard.
* ca.po: Updated translation.
2002-10-17 Jordi Mallach <jordi@sindominio.net>
* de.po: Updated translation by Michel Piefel.
2002-10-14 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-10-13 Jordi Mallach <jordi@sindominio.net>
* es.po: Updated translation by Ricardo Javier Cárdenes Medina.
2002-10-08 Jordi Mallach <jordi@sindominio.net>
* id.po: Updated translation by Tedi Heriyanto.
* ms.po: Updated translation by Sharuzzaman Ahmat Raslan.
2002-10-07 Jordi Mallach <jordi@sindominio.net>
* de.po: Updated translation by Michel Piefel.
2002-10-07 Jordi Mallach <jordi@sindominio.net>
* ca.po: Updated translation.
2002-10-07 Jordi Mallach <jordi@sindominio.net>
* sv.po: Updated translation by Christian Rose.
* gl.po: Updated translation by Jacobo Tarrío.
* pl.po: Updated translation by Wojciech Kotwica.
2002-09-08 Jordi Mallach <jordi@sindominio.net>
* ms.po: Updated translation by Sharuzzaman Ahmat Raslan.
2002-09-08 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
* da.po: Updated translation by Keld Simonsen.
2002-08-19 Jordi Mallach <jordi@sindominio.net>
* de.po: Updated translation by Michael Piefel.
* ms.po: Updated translation by Sharuzzaman Ahmat Raslan.
2002-07-31 Jordi Mallach <jordi@sindominio.net>
* gl.po: Updated translation by Jacobo Tarrío.
2002-07-31 Jordi Mallach <jordi@sindominio.net>
* es.po: Updated translation by Ricardo Javier Cárdenes Medina.
2002-07-31 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-07-30 Jordi Mallach <jordi@sindominio.net>
* pl.po: Updated translation by Wojciech Kotwica.
* sv.po: Upadted translation by Christian Rose.
2002-07-29 Jordi Mallach <jordi@sindominio.net>
* ca.po: Updated translation.
2002-07-29 Jordi Mallach <jordi@sindominio.net>
* sv.po: Updated translation by Christian Rose.
2002-07-27 Jordi Mallach <jordi@sindominio.net>
* pt_BR.po: New Brazilian Portuguese translation by
Claudio Neves.
2002-07-25 Jordi Mallach <jordi@sindominio.net>
* id.po: Updated translation by Tedi Heriyanto.
2002-07-09 Jordi Mallach <jordi@sindominio.net>
* de.po: Updated translation by Michael Piefel.
2002-07-07 Jordi Mallach <jordi@sindominio.net>
* da.po: Updated translation by Keld Simonsen.
2002-07-03 Jordi Mallach <jordi@sindominio.net>
* ms.po: New Bahasa Melayu translation by
Sharuzzaman Ahmat Raslan.
2002-06-03 gettextize <bug-gnu-gettext@gnu.org>
* Makefile.in.in: Upgrade to gettext-0.11.2.
* Rules-quot: New file, from gettext-0.11.2.
* boldquot.sed: New file, from gettext-0.11.2.
* en@boldquot.header: New file, from gettext-0.11.2.
* en@quot.header: New file, from gettext-0.11.2.
* insert-header.sin: New file, from gettext-0.11.2.
* quot.sed: New file, from gettext-0.11.2.
* remove-potcdate.sin: New file, from gettext-0.11.2.
2002-05-13 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
* de.po: Updated translation by Michael Piefel.
2002-05-13 Jordi Mallach <jordi@sindominio.net>
* it.po: Updated translation by Marco Colombo.
* gl.po: Updated translation by Jacobo Tarrío.
* ca.po: Updated translation.
* es.po: Updated translation.
2002-05-13 Jordi Mallach <jordi@sindominio.net>
* sv.po: Updated translation by Christian Rose.
2002-05-05 Jordi Mallach <jordi@sindominio.net>
* sv.po: Updated translation by Christian Rose.
2002-04-25 Jordi Mallach <jordi@sindominio.net>
* id.po: Updated translation by Tedi Heriyanto.
2002-04-19 Jordi Mallach <jordi@sindominio.net>
* ru.po: Updated translation by Sergey A. Ribalchenko.
* uk.po: Updated translation by Sergey A. Ribalchenko.
2002-04-13 Jordi Mallach <jordi@sindominio.net>
* it.po: Updated translation by Marco Colombo.
2002-04-13 Jordi Mallach <jordi@sindominio.net>
* nl.po: Updated translation by Guus Sliepen.
2002-04-10 Jordi Mallach <jordi@sindominio.net>
* sv.po: Updated translation by Christian Rose.
2002-04-05 Jordi Mallach <jordi@sindominio.net>
* gl.po: Updated translation by Jacobo Tarrio.
* de.po: Updated translation by Michael Piefel.
* fr.po: Updated translation by Jean-Philippe Guérard.
* ca.po: Updated.
* es.po: Updated.
2002-03-29 Jordi Mallach <jordi@sindominio.net>
* da.po: Updated translation by Keld Simonsen.
2002-03-27 Jordi Mallach <jordi@sindominio.net>
* it.po: Updated translation by Marco Colombo.
2002-03-25 Jordi Mallach <jordi@sindominio.net>
* id.po: Updated translation by Tedi Heriyanto.
2002-03-17 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-03-15 Jordi Mallach <jordi@sindominio.net>
* pl.po: Updated translation by Wojciech Kotwica.
2002-03-14 Jordi Mallach <jordi@sindominio.net>
* uk.po, ru.po: Updated translations by Sergey A.
Ribalchenko.
2002-03-12 Jordi Mallach <jordi@sindominio.net>
* ca.po: Updated to current CVS.
* es.po: Updated to current CVS.
* gl.po: Updated translation to current CVS by Jacobo Tarrio.
2002-03-12 Jordi Mallach <jordi@sindominio.net>
* gl.po: Updated translation by Jacobo Tarrio.
2002-03-11 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-03-09 Jordi Mallach <jordi@sindominio.net>
* id.po: Updated translation by Tedi Heriyanto.
* ca.po: Updated.
* es.po: Updated.
2002-03-07 Jordi Mallach <jordi@sindominio.net>
* sv.po: Updated translation by Christian Rose.
* de.po: Updated translation by Michael Piefel.
2002-03-05 Jordi Mallach <jordi@sindominio.net>
* pl.po: Updated translation by Wojciech Kotwica.
2002-02-20 Jordi Mallach <jordi@sindominio.net>
* nl.po: Updated translation by Guus Sliepen.
2002-02-15 Jordi Mallach <jordi@sindominio.net>
* nb.po: Updated translation by Stig E Sandoe.
2002-02-15 Jordi Mallach <jordi@sindominio.net>
* nb.po: Updated translation by Stig E Sandoe.
2002-02-14 Jordi Mallach <jordi@sindominio.net>
* da.po: Updated translation by Keld Simonsen.
2002-02-10 Jordi Mallach <jordi@sindominio.net>
* hu.po: Updated translation by Gergely Nagy.
2002-02-07 Jordi Mallach <jordi@sindominio.net>
* uk.po, ru.po: Updated translations by Sergey A.
Ribalchenko.
2002-02-06 Jordi Mallach <jordi@sindominio.net>
* hu.po: Updated translation by Gergely Nagy.
2002-02-06 Jordi Mallach <jordi@sindominio.net>
* cs.po: Incomplete update by Václav Haisman.
2002-01-27 Jordi Mallach <jordi@sindominio.net>
* it.po: Updated translation by Marco Colombo.
2002-01-26 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
* nn.po: Updated translation by Kjetil Torgrim Homme.
* de.po: Updated translation by Michael Piefel.
2002-01-25 Jordi Mallach <jordi@sindominio.net>
* sv.po: Updated translation by Christian Rose.
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-01-25 Jordi Mallach <jordi@sindominio.net>
* ca.po: Updated.
* es.po: Updated.
2002-01-23 Jordi Mallach <jordi@sindominio.net>
* ca.po: Updated.
* es.po: Updated.
2002-01-19 gettextize <bug-gnu-utils@gnu.org>
* Makefile.in.in: Upgrade to gettext-0.10.40.
* cat-id-tbl.c: Remove file.
* stamp-cat-id: Remove file.
2002-01-19 Jordi Mallach <jordi@sindominio.net>
* ca.po: Updated.
* es.po: Updated.
2002-01-19 Jordi Mallach <jordi@sindominio.net>
* da.po: Updated translation by Keld Simonsen.
2002-01-17 Jordi Mallach <jordi@sindominio.net>
* no.po: Removed, replaced by nn.po.
* nn.po: Updated translation by Kjetil Torgrim Homme.
* nb.po: New Norwegian bokmål translation by Stig E Sandoe.
2002-01-12 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-01-10 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-01-08 Jordi Mallach <jordi@sindominio.net>
* ru.po, uk.po: Updated translations by Sergey A.
Ribalchenko.
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-01-07 Jordi Mallach <jordi@sindominio.net>
* de.po: Updated translation by Michael Piefel.
2002-01-07 Jordi Mallach <jordi@sindominio.net>
* sv.po: Updated translation by Christian Rose.
2002-01-07 Jordi Mallach <jordi@sindominio.net>
* ca.po: Updated.
* es.po: Updated.

View File

@@ -1,2 +1,2 @@
# List of available languages.
bg ca cs da de eo es eu fi fr ga gl hr hu id it ja ms nb nl nn pl pt pt_BR ro ru sl sr sv tr uk vi zh_CN zh_TW
bg ca cs da de eo es eu fi fr ga gl hr hu id it ja ko ms nb nl nn pl pt pt_BR ro ru sl sr sv tr uk vi zh_CN zh_TW

View File

@@ -11,15 +11,12 @@ top_builddir = ..
XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --keyword=P_:1,2
# This is the copyright holder that gets inserted into the header of the
# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
# package. (Note that the msgstr strings, extracted from the package's
# sources, belong to the copyright holder of the package.) Translators are
# expected to transfer the copyright for their translations to this person
# or entity, or to disclaim their copyright. The empty string stands for
# the public domain; in this case the translators are expected to disclaim
# their copyright.
# $(DOMAIN).pot file. Translators are expected to disclaim their copyright.
COPYRIGHT_HOLDER = Free Software Foundation, Inc.
# This is the list of locale categories, beyond LC_MESSAGES, for which the
# message catalogs shall be used. It is usually empty.
EXTRA_LOCALE_CATEGORIES =
# Don't do fuzzy matching when merging the PO files against the POT file.
MSGMERGE_OPTIONS = --no-fuzzy-matching

View File

@@ -2,6 +2,7 @@
src/browser.c
src/color.c
src/cut.c
src/files.c
src/global.c
src/help.c
@@ -13,3 +14,6 @@ src/search.c
src/text.c
src/utils.c
src/winio.c
lib/getopt.c
lib/regcomp.c

3100
po/bg.po

File diff suppressed because it is too large Load Diff

3228
po/ca.po

File diff suppressed because it is too large Load Diff

2977
po/cs.po

File diff suppressed because it is too large Load Diff

3566
po/da.po

File diff suppressed because it is too large Load Diff

2600
po/de.po

File diff suppressed because it is too large Load Diff

2664
po/eo.po

File diff suppressed because it is too large Load Diff

2645
po/es.po

File diff suppressed because it is too large Load Diff

3577
po/eu.po

File diff suppressed because it is too large Load Diff

2764
po/fi.po

File diff suppressed because it is too large Load Diff

4143
po/fr.po

File diff suppressed because it is too large Load Diff

2795
po/ga.po

File diff suppressed because it is too large Load Diff

2630
po/gl.po

File diff suppressed because it is too large Load Diff

3163
po/hr.po

File diff suppressed because it is too large Load Diff

2570
po/hu.po

File diff suppressed because it is too large Load Diff

3673
po/id.po

File diff suppressed because it is too large Load Diff

2573
po/it.po

File diff suppressed because it is too large Load Diff

2693
po/ja.po

File diff suppressed because it is too large Load Diff

2997
po/ko.po Normal file

File diff suppressed because it is too large Load Diff

3015
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2867
po/nb.po

File diff suppressed because it is too large Load Diff

2800
po/nl.po

File diff suppressed because it is too large Load Diff

3733
po/nn.po

File diff suppressed because it is too large Load Diff

2777
po/pl.po

File diff suppressed because it is too large Load Diff

2705
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2618
po/ro.po

File diff suppressed because it is too large Load Diff

2872
po/ru.po

File diff suppressed because it is too large Load Diff

3046
po/sl.po

File diff suppressed because it is too large Load Diff

2759
po/sr.po

File diff suppressed because it is too large Load Diff

3157
po/sv.po

File diff suppressed because it is too large Load Diff

3087
po/tr.po

File diff suppressed because it is too large Load Diff

2787
po/uk.po

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,13 @@
#!/bin/sh
# Let this be executed in the po/ subdir.
cd "$(dirname "$0")" || exit
cd "$(dirname "$0")" || exit 1
echo "Updating translations via TP"
rsync -Lrtvz translationproject.org::tp/latest/nano/ .
# First remove existing PO files, as wget will not overwrite them.
rm *.po
wget --recursive --level=1 --accept=po --no-directories --no-verbose \
https://translationproject.org/latest/nano/ || exit 2
# Are there now PO files that are not in git yet?
NEWSTUFF=$(git status --porcelain *.po | grep "^??")
@@ -18,8 +21,11 @@ fi
echo "Regenerating POT file and remerging and recompiling PO files..."
make update-po
# Ensure that the PO files are newer than the POT.
touch *.po
echo "Removing the dead weight of obsolete and fuzzy translations..."
for pofile in *.po; do
msgattrib --no-obsolete --no-fuzzy $pofile >trimmed.po || exit 4
mv trimmed.po $pofile || exit 4
done
# If needed, fix a problem in the Makefile template.
grep -q '^datarootdir' Makefile.in.in || \

2739
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

33
roll-a-release.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
VERSION="5.2"
./configure -C --enable-tiny && make && ./configure -C &&
echo "Running autogen..." && ./autogen.sh &&
rm -v -f m4/*.m4~ *.asc *.sig *.gz *.xz &&
echo "Rebuilding..." && make &&
po/update_linguas.sh &&
make distcheck && make dist-xz &&
git add po/*.po po/nano.pot &&
git commit -m "$(git log -1 --grep 'po: up' | grep o: | sed 's/^ //')" &&
gpg -a -b nano-$VERSION.tar.gz &&
gpg -a -b nano-$VERSION.tar.xz &&
gpg --verify nano-$VERSION.tar.gz.asc &&
gpg --verify nano-$VERSION.tar.xz.asc &&
git tag -u A0ACE884 -a v$VERSION -m "the nano $VERSION release" &&
make pdf && rm -rf doc/nano.t2p &&
scp doc/nano.pdf bens@wh0rd.org:nano.pdf &&
scp doc/cheatsheet.html bens@wh0rd.org:cheatsheet.html &&
for file in nano-$VERSION.tar.*z*; do scp $file bens@wh0rd.org:$file; done &&
gnupload --to ftp.gnu.org:nano nano-$VERSION.tar.*z &&
echo "Tarballs have been rolled and uploaded."

View File

@@ -21,7 +21,10 @@ revision.h: FORCE
FORCE:
bin_PROGRAMS = nano
nano_SOURCES = browser.c \
nano_SOURCES = \
definitions.h \
prototypes.h \
browser.c \
chars.c \
color.c \
cut.c \
@@ -31,9 +34,7 @@ nano_SOURCES = browser.c \
history.c \
move.c \
nano.c \
nano.h \
prompt.c \
proto.h \
rcfile.c \
search.c \
text.c \

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* browser.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2015-2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -19,15 +19,15 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#ifdef ENABLE_BROWSER
#include <errno.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#ifdef ENABLE_BROWSER
static char **filelist = NULL;
/* The list of files to display in the file browser. */
static size_t filelist_len = 0;
@@ -39,24 +39,22 @@ static size_t longest = 0;
static size_t selected = 0;
/* The currently selected filename in the list; zero-based. */
/* Our main file browser function. path is the tilde-expanded path we
* start browsing from. */
char *do_browser(char *path)
/* Allow the user to browse through the directories in the filesystem,
* starting at the given path. */
char *browse(char *path)
{
char *retval = NULL;
int kbinput;
char *present_name = NULL;
/* The name of the currently selected file, or of the directory we
* were in before backing up to "..". */
size_t old_selected;
/* The number of the selected file before the current selected file. */
functionptrtype func;
/* The function of the key the user typed in. */
DIR *dir;
/* The directory whose contents we are showing. */
char *chosen = NULL;
/* The name of the file that the user picked, or NULL if none. */
read_directory_contents:
/* We come here when we refresh or select a new directory. */
/* We come here when the user refreshes or selects a new directory. */
path = free_and_assign(path, get_full_path(path));
@@ -67,18 +65,16 @@ char *do_browser(char *path)
statusline(ALERT, _("Cannot open directory: %s"), strerror(errno));
/* If we don't have a file list yet, there is nothing to show. */
if (filelist == NULL) {
napms(1200);
lastmessage = HUSH;
free(path);
lastmessage = VACUUM;
free(present_name);
free(path);
napms(1200);
return NULL;
}
path = mallocstrcpy(path, present_path);
present_name = mallocstrcpy(present_name, filelist[selected]);
}
assert(path != NULL && path[strlen(path) - 1] == '/');
if (dir != NULL) {
/* Get the file list, and set longest and width in the process. */
read_the_list(path, dir);
@@ -103,7 +99,10 @@ char *do_browser(char *path)
titlebar(path);
while (TRUE) {
lastmessage = HUSH;
functionptrtype func;
int kbinput;
lastmessage = VACUUM;
bottombars(MBROWSER);
@@ -140,24 +139,30 @@ char *do_browser(char *path)
/* If we selected the same filename as last time, fake a
* press of the Enter key so that the file is read in. */
if (old_selected == selected)
unget_kbinput(KEY_ENTER, FALSE);
kbinput = KEY_ENTER;
}
continue;
if (kbinput == KEY_MOUSE)
continue;
}
#endif /* ENABLE_MOUSE */
#ifndef NANO_TINY
if (bracketed_paste || kbinput == BRACKETED_PASTE_MARKER) {
beep();
continue;
}
#endif
func = interpret(&kbinput);
func = parse_browser_input(&kbinput);
if (func == total_refresh) {
total_redraw();
if (func == full_refresh) {
full_refresh();
#ifndef NANO_TINY
/* Simulate a window resize to force a directory reread. */
kbinput = KEY_WINCH;
#endif
} else if (func == do_help_void) {
} else if (func == do_help) {
#ifdef ENABLE_HELP
do_help_void();
do_help();
#ifndef NANO_TINY
/* The window dimensions might have changed, so act as if. */
kbinput = KEY_WINCH;
@@ -165,25 +170,29 @@ char *do_browser(char *path)
#else
say_there_is_no_help();
#endif
} else if (func == do_search_forward) {
do_filesearch();
} else if (func == do_research) {
do_fileresearch(TRUE);
#ifndef NANO_TINY
} else if (func == do_findprevious) {
do_fileresearch(FALSE);
} else if (func == do_findnext) {
do_fileresearch(TRUE);
} else if (func == do_toggle_void) {
TOGGLE(NO_HELP);
window_init();
kbinput = KEY_WINCH;
#endif
} else if (func == do_search_forward) {
do_filesearch(FORWARD);
} else if (func == do_search_backward) {
do_filesearch(BACKWARD);
} else if (func == do_findprevious) {
do_fileresearch(BACKWARD);
} else if (func == do_findnext) {
do_fileresearch(FORWARD);
} else if (func == do_left) {
if (selected > 0)
selected--;
} else if (func == do_right) {
if (selected < filelist_len - 1)
selected++;
} else if (func == do_prev_word_void) {
} else if (func == to_prev_word) {
selected -= (selected % width);
} else if (func == do_next_word_void) {
} else if (func == to_next_word) {
selected += width - 1 - (selected % width);
if (selected >= filelist_len)
selected = filelist_len - 1;
@@ -193,10 +202,10 @@ char *do_browser(char *path)
} else if (func == do_down) {
if (selected + width <= filelist_len - 1)
selected += width;
} else if (func == do_prev_block) {
} else if (func == to_prev_block) {
selected = ((selected / (editwinrows * width)) *
editwinrows * width) + selected % width;
} else if (func == do_next_block) {
} else if (func == to_next_block) {
selected = ((selected / (editwinrows * width)) *
editwinrows * width) + selected % width +
editwinrows * width - width;
@@ -223,13 +232,11 @@ char *do_browser(char *path)
selected = 0;
} else if (func == to_last_file) {
selected = filelist_len - 1;
} else if (func == goto_dir_void) {
} else if (func == goto_dir) {
/* Ask for the directory to go to. */
int i = do_prompt(TRUE, FALSE, MGOTODIR, NULL, NULL,
/* TRANSLATORS: This is a prompt. */
browser_refresh, _("Go To Directory"));
if (i < 0) {
if (do_prompt(MGOTODIR, "", NULL,
/* TRANSLATORS: This is a prompt. */
browser_refresh, _("Go To Directory")) < 0) {
statusbar(_("Cancelled"));
continue;
}
@@ -291,7 +298,7 @@ char *do_browser(char *path)
/* If it isn't a directory, a file was selected -- we're done. */
if (!S_ISDIR(st.st_mode)) {
retval = mallocstrcpy(NULL, filelist[selected]);
chosen = copy_of(filelist[selected]);
break;
}
@@ -307,13 +314,12 @@ char *do_browser(char *path)
} else if (func == (functionptrtype)implant) {
implant(first_sc_for(MBROWSER, func)->expansion);
#endif
} else if (func == do_exit) {
/* Exit from the file browser. */
break;
#ifndef NANO_TINY
} else if (kbinput == KEY_WINCH) {
;
; /* Nothing to do. */
#endif
} else if (func == do_exit) {
break;
} else
unbound_key(kbinput);
@@ -321,7 +327,7 @@ char *do_browser(char *path)
/* If the window resized, refresh the file list. */
if (kbinput == KEY_WINCH) {
/* Remember the selected file, to be able to reselect it. */
present_name = mallocstrcpy(NULL, filelist[selected]);
present_name = copy_of(filelist[selected]);
/* Reread the contents of the current directory. */
goto read_directory_contents;
}
@@ -337,38 +343,29 @@ char *do_browser(char *path)
filelist = NULL;
filelist_len = 0;
return retval;
return chosen;
}
/* The file browser front end. We check to see if inpath has a
* directory in it. If it does, we start do_browser() from there.
* Otherwise, we start do_browser() from the current directory. */
char *do_browse_from(const char *inpath)
/* Prepare to start browsing. If the given path has a directory part,
* start browsing in that directory, otherwise in the current directory. */
char *browse_in(const char *inpath)
{
struct stat st;
char *path;
/* This holds the tilde-expanded version of inpath. */
char *path = real_dir_from_tilde(inpath);
struct stat fileinfo;
path = real_dir_from_tilde(inpath);
/* Perhaps path is a directory. If so, we'll pass it to
* do_browser(). Or perhaps path is a directory / a file. If so,
* we'll try stripping off the last path element and passing it to
* do_browser(). Or perhaps path doesn't have a directory portion
* at all. If so, we'll just pass the current directory to
* do_browser(). */
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
/* If path is not a directory, try to strip a filename from it; if then
* still not a directory, use the current working directory instead. */
if (stat(path, &fileinfo) == -1 || !S_ISDIR(fileinfo.st_mode)) {
path = free_and_assign(path, strip_last_component(path));
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
if (stat(path, &fileinfo) == -1 || !S_ISDIR(fileinfo.st_mode)) {
char *currentdir = charalloc(PATH_MAX + 1);
free(path);
path = getcwd(currentdir, PATH_MAX + 1);
path = free_and_assign(path, getcwd(currentdir, PATH_MAX + 1));
if (path == NULL) {
free(currentdir);
statusline(MILD, _("The working directory has disappeared"));
free(currentdir);
beep();
napms(1200);
return NULL;
@@ -383,7 +380,7 @@ char *do_browse_from(const char *inpath)
path = mallocstrcpy(path, operating_dir);
#endif
return do_browser(path);
return browse(path);
}
/* Set filelist to the list of files contained in the directory path,
@@ -396,13 +393,11 @@ void read_the_list(const char *path, DIR *dir)
const struct dirent *nextdir;
size_t i = 0, path_len = strlen(path);
assert(path != NULL && path[strlen(path) - 1] == '/' && dir != NULL);
longest = 0;
/* Find the length of the longest filename in the current folder. */
while ((nextdir = readdir(dir)) != NULL) {
size_t name_len = strlenpt(nextdir->d_name);
size_t name_len = breadth(nextdir->d_name);
if (name_len > longest)
longest = name_len;
@@ -447,8 +442,6 @@ void read_the_list(const char *path, DIR *dir)
* filelist, so record it. */
filelist_len = i;
assert(filelist != NULL);
/* Sort the list of names. */
qsort(filelist, filelist_len, sizeof(char *), diralphasort);
@@ -458,51 +451,9 @@ void read_the_list(const char *path, DIR *dir)
width = (COLS + 2) / (longest + 2);
}
/* Return the function that is bound to the given key, accepting certain
* plain characters too, for compatibility with Pico. */
functionptrtype parse_browser_input(int *kbinput)
{
if (!meta_key) {
switch (*kbinput) {
case ' ':
return do_page_down;
case '-':
return do_page_up;
case '?':
return do_help_void;
case 'E':
case 'e':
case 'Q':
case 'q':
case 'X':
case 'x':
return do_exit;
case 'G':
case 'g':
return goto_dir_void;
case 'S':
case 's':
return do_enter;
case 'W':
case 'w':
case '/':
return do_search_forward;
case 'N':
#ifndef NANO_TINY
return do_findprevious;
#endif
case 'n':
return do_research;
}
}
return func_from_key(kbinput);
}
/* Set width to the number of files that we can display per screen row,
* if necessary, and display the list of files. */
/* Display at most a screenful of filenames from the gleaned filelist. */
void browser_refresh(void)
{
size_t i;
int row = 0, col = 0;
/* The current row and column while the list is getting displayed. */
int the_row = 0, the_column = 0;
@@ -513,15 +464,11 @@ void browser_refresh(void)
titlebar(present_path);
blank_edit();
wmove(edit, 0, 0);
i = selected - selected % (editwinrows * width);
for (; i < filelist_len && row < editwinrows; i++) {
struct stat st;
const char *thename = tail(filelist[i]);
for (size_t index = selected - selected % (editwinrows * width);
index < filelist_len && row < editwinrows; index++) {
const char *thename = tail(filelist[index]);
/* The filename we display, minus the path. */
size_t namelen = strlenpt(thename);
size_t namelen = breadth(thename);
/* The length of the filename in columns. */
size_t infolen;
/* The length of the file information in columns. */
@@ -532,58 +479,56 @@ void browser_refresh(void)
/* Whether to put an ellipsis before the filename? We don't
* waste space on dots when there are fewer than 15 columns. */
char *disp = display_string(thename, dots ?
namelen + infomaxlen + 4 - longest : 0, longest, FALSE);
namelen + infomaxlen + 4 - longest : 0, longest, FALSE, FALSE);
/* The filename (or a fragment of it) in displayable format.
* When a fragment, account for dots plus one space padding. */
struct stat state;
/* If this is the selected item, start its highlighting, and
/* If this is the selected item, draw its highlighted bar upfront, and
* remember its location to be able to place the cursor on it. */
if (i == selected) {
if (index == selected) {
wattron(edit, interface_color_pair[SELECTED_TEXT]);
mvwprintw(edit, row, col, "%*s", longest, " ");
the_row = row;
the_column = col;
}
blank_row(edit, row, col, longest);
/* If the name is too long, we display something like "...ename". */
if (dots)
mvwaddstr(edit, row, col, "...");
mvwaddstr(edit, row, dots ? col + 3 : col, disp);
free(disp);
col += longest;
/* Show information about the file: "--" for symlinks (except when
* they point to a directory) and for files that have disappeared,
* "(dir)" for directories, and the file size for normal files. */
if (lstat(filelist[i], &st) == -1 || S_ISLNK(st.st_mode)) {
if (stat(filelist[i], &st) == -1 || !S_ISDIR(st.st_mode))
info = mallocstrcpy(NULL, "--");
if (lstat(filelist[index], &state) == -1 || S_ISLNK(state.st_mode)) {
if (stat(filelist[index], &state) == -1 || !S_ISDIR(state.st_mode))
info = copy_of("--");
else
/* TRANSLATORS: Try to keep this at most 7 characters. */
info = mallocstrcpy(NULL, _("(dir)"));
} else if (S_ISDIR(st.st_mode)) {
info = copy_of(_("(dir)"));
} else if (S_ISDIR(state.st_mode)) {
if (strcmp(thename, "..") == 0) {
/* TRANSLATORS: Try to keep this at most 12 characters. */
info = mallocstrcpy(NULL, _("(parent dir)"));
info = copy_of(_("(parent dir)"));
infomaxlen = 12;
} else
info = mallocstrcpy(NULL, _("(dir)"));
info = copy_of(_("(dir)"));
} else {
off_t result = st.st_size;
off_t result = state.st_size;
char modifier;
info = charalloc(infomaxlen + 1);
/* Massage the file size into a human-readable form. */
if (st.st_size < (1 << 10))
if (state.st_size < (1 << 10))
modifier = ' '; /* bytes */
else if (st.st_size < (1 << 20)) {
else if (state.st_size < (1 << 20)) {
result >>= 10;
modifier = 'K'; /* kilobytes */
} else if (st.st_size < (1 << 30)) {
} else if (state.st_size < (1 << 30)) {
result >>= 20;
modifier = 'M'; /* megabytes */
} else {
@@ -601,7 +546,7 @@ void browser_refresh(void)
}
/* Make sure info takes up no more than infomaxlen columns. */
infolen = strlenpt(info);
infolen = breadth(info);
if (infolen > infomaxlen) {
info[actual_x(info, infomaxlen)] = '\0';
infolen = infomaxlen;
@@ -610,16 +555,16 @@ void browser_refresh(void)
mvwaddstr(edit, row, col - infolen, info);
/* If this is the selected item, finish its highlighting. */
if (i == selected)
if (index == selected)
wattroff(edit, interface_color_pair[SELECTED_TEXT]);
free(disp);
free(info);
/* Add some space between the columns. */
col += 2;
/* If the next entry isn't going to fit on the current row,
* move to the next row. */
/* If the next entry will not fit on this row, move to next row. */
if (col > COLS - longest) {
row++;
col = 0;
@@ -659,42 +604,43 @@ void browser_select_dirname(const char *needle)
}
}
/* Set up the system variables for a filename search. Return -1 or -2 if
* the search should be canceled (due to Cancel or a blank search string),
* return 0 when we have a string, and return a positive value when some
* function was run. */
int filesearch_init(void)
/* Prepare the prompt and ask the user what to search for. If forwards is
* TRUE, search forward in the list; otherwise, search backward. Return -2
* for a blank answer, -1 for Cancel, 0 when we have a string, and a
* positive value when some function was run. */
int filesearch_init(bool forwards)
{
int input;
char *buf;
char *thedefault;
int response;
/* If something was searched for before, show it between square brackets. */
if (*last_search != '\0') {
char *disp = display_string(last_search, 0, COLS / 3, FALSE);
char *disp = display_string(last_search, 0, COLS / 3, FALSE, FALSE);
buf = charalloc(strlen(disp) + 7);
thedefault = charalloc(strlen(disp) + 7);
/* We use (COLS / 3) here because we need to see more on the line. */
sprintf(buf, " [%s%s]", disp,
(strlenpt(last_search) > COLS / 3) ? "..." : "");
sprintf(thedefault, " [%s%s]", disp,
(breadth(last_search) > COLS / 3) ? "..." : "");
free(disp);
} else
buf = mallocstrcpy(NULL, "");
thedefault = copy_of("");
/* This is now one simple call. It just does a lot. */
input = do_prompt(FALSE, FALSE, MWHEREISFILE, NULL, &search_history,
browser_refresh, "%s%s", _("Search"), buf);
/* Release buf now that we don't need it anymore. */
free(buf);
/* Now ask what to search for. */
response = do_prompt(MWHEREISFILE, "", &search_history,
browser_refresh, "%s%s%s", _("Search"),
/* TRANSLATORS: A modifier of the Search prompt. */
!forwards ? _(" [Backwards]") : "", thedefault);
free(thedefault);
/* If only Enter was pressed but we have a previous string, it's okay. */
if (input == -2 && *last_search != '\0')
if (response == -2 && *last_search != '\0')
return 0;
/* Otherwise negative inputs are a bailout. */
if (input < 0)
/* Otherwise negative responses are a bailout. */
if (response < 0)
statusbar(_("Cancelled"));
return input;
return response;
}
/* Look for the given needle in the list of files. If forwards is TRUE,
@@ -756,11 +702,12 @@ void findfile(const char *needle, bool forwards)
selected = looking_at;
}
/* Search for a filename. */
void do_filesearch(void)
/* Search for a filename. If forwards is TRUE, search forward in the list;
* otherwise, search backward.*/
void do_filesearch(bool forwards)
{
/* If the user cancelled or jumped to first or last file, don't search. */
if (filesearch_init() != 0)
if (filesearch_init(forwards) != 0)
return;
/* If answer is now "", copy last_search into answer. */
@@ -775,7 +722,7 @@ void do_filesearch(void)
update_history(&search_history, answer);
#endif
findfile(answer, TRUE);
findfile(answer, forwards);
}
/* Search again without prompting for the last given search string,
@@ -788,23 +735,11 @@ void do_fileresearch(bool forwards)
findfile(last_search, forwards);
}
/* Select the first file in the list. */
void to_first_file(void)
{
selected = 0;
}
/* Select the last file in the list. */
void to_last_file(void)
{
selected = filelist_len - 1;
}
/* Strip one element from the end of path, and return the stripped path.
* The returned string is dynamically allocated, and should be freed. */
char *strip_last_component(const char *path)
{
char *copy = mallocstrcpy(NULL, path);
char *copy = copy_of(path);
char *last_slash = strrchr(copy, '/');
if (last_slash != NULL)

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* chars.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2016-2017 Benno Schulenberg *
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2016-2019 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -19,7 +19,7 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#include <ctype.h>
#include <string.h>
@@ -44,149 +44,104 @@ bool using_utf8(void)
}
#endif /* ENABLE_UTF8 */
/* Concatenate two allocated strings, and free the second. */
char *addstrings(char* str1, size_t len1, char* str2, size_t len2)
{
str1 = charealloc(str1, len1 + len2 + 1);
str1[len1] = '\0';
strncat(&str1[len1], str2, len2);
free(str2);
return str1;
}
/* Return TRUE if the value of c is in byte range, and FALSE otherwise. */
bool is_byte(int c)
{
return ((unsigned int)c == (unsigned char)c);
}
void mbtowc_reset(void)
{
IGNORE_CALL_RESULT(mbtowc(NULL, NULL, 0));
}
/* This function is equivalent to isalpha() for multibyte characters. */
bool is_alpha_mbchar(const char *c)
#ifdef ENABLE_SPELLER
/* Return TRUE when the given character is some kind of letter. */
bool is_alpha_char(const char *c)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
return 0;
}
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return FALSE;
return iswalpha(wc);
} else
return iswalpha(wc);
#else
return isalpha((unsigned char)*c);
#endif
return isalpha((unsigned char)*c);
}
#endif /* ENABLE_SPELLER */
/* This function is equivalent to isalnum() for multibyte characters. */
bool is_alnum_mbchar(const char *c)
/* Return TRUE when the given character is some kind of letter or a digit. */
bool is_alnum_char(const char *c)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
return 0;
}
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return FALSE;
return iswalnum(wc);
} else
return iswalnum(wc);
#else
return isalnum((unsigned char)*c);
#endif
return isalnum((unsigned char)*c);
}
/* This function is equivalent to isblank() for multibyte characters. */
bool is_blank_mbchar(const char *c)
/* Return TRUE when the given character is space or tab or other whitespace. */
bool is_blank_char(const char *c)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
return 0;
}
if ((signed char)*c >= 0)
return (*c == ' ' || *c == '\t');
return iswblank(wc);
} else
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return FALSE;
return iswblank(wc);
#else
return isblank((unsigned char)*c);
#endif
return isblank((unsigned char)*c);
}
/* This function is equivalent to iscntrl(), except in that it only
* handles non-high-bit control characters. */
bool is_ascii_cntrl_char(int c)
{
return (0 <= c && c < 32);
}
/* This function is equivalent to iscntrl(), except in that it also
* handles high-bit control characters. */
bool is_cntrl_char(int c)
{
return ((c & 0x60) == 0 || c == 127);
}
/* This function is equivalent to iscntrl() for multibyte characters,
* except in that it also handles multibyte control characters with
* their high bits set. */
bool is_cntrl_mbchar(const char *c)
/* Return TRUE when the given character is a control character. */
bool is_cntrl_char(const char *c)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
return ((c[0] & 0xE0) == 0 || c[0] == 127 ||
return ((c[0] & 0xE0) == 0 || c[0] == DEL_CODE ||
((signed char)c[0] == -62 && (signed char)c[1] < -96));
} else
#endif
return is_cntrl_char((unsigned char)*c);
return ((*c & 0x60) == 0 || *c == DEL_CODE);
}
/* This function is equivalent to ispunct() for multibyte characters. */
bool is_punct_mbchar(const char *c)
/* Return TRUE when the given character is a punctuation character. */
bool is_punct_char(const char *c)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
return 0;
}
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return FALSE;
return iswpunct(wc);
} else
return iswpunct(wc);
#else
return ispunct((unsigned char)*c);
#endif
return ispunct((unsigned char)*c);
}
/* Return TRUE when the given multibyte character c is a word-forming
* character (that is: alphanumeric, or specified in wordchars, or
* punctuation when allow_punct is TRUE), and FALSE otherwise. */
bool is_word_mbchar(const char *c, bool allow_punct)
/* Return TRUE when the given character is word-forming (it is alphanumeric or
* specified in 'wordchars', or it is punctuation when allow_punct is TRUE). */
bool is_word_char(const char *c, bool allow_punct)
{
if (*c == '\0')
return FALSE;
if (is_alnum_mbchar(c))
if (is_alnum_char(c))
return TRUE;
if (allow_punct && is_punct_char(c))
return TRUE;
if (word_chars != NULL && *word_chars != '\0') {
char symbol[MAXCHARLEN + 1];
int symlen = parse_mbchar(c, symbol, NULL);
int symlen = collect_char(c, symbol);
symbol[symlen] = '\0';
return (strstr(word_chars, symbol) != NULL);
}
return (allow_punct && is_punct_mbchar(c));
} else
return FALSE;
}
/* Return the visible representation of control character c. */
@@ -220,163 +175,152 @@ char control_mbrep(const char *c, bool isdata)
return control_rep(*c);
}
/* Assess how many bytes the given (multibyte) character occupies. Return -1
* if the byte sequence is invalid, and return the number of bytes minus 8
* when it encodes an invalid codepoint. Also, in the second parameter,
* return the number of columns that the character occupies. */
int length_of_char(const char *c, int *width)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
int charlen = mbtowc(&wc, c, MAXCHARLEN);
/* If the sequence is invalid... */
if (charlen < 0) {
mbtowc_reset();
return -1;
}
/* If the codepoint is invalid... */
if (!is_valid_unicode(wc))
return charlen - 8;
else {
*width = wcwidth(wc);
/* If the codepoint is unassigned, assume a width of one. */
if (*width < 0)
*width = 1;
return charlen;
}
} else
#endif
return 1;
}
/* This function is equivalent to wcwidth() for multibyte characters. */
/* Return the width in columns of the given (multibyte) character. */
int mbwidth(const char *c)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
/* Ask for the width only when the character isn't plain ASCII. */
if ((signed char)*c <= 0) {
wchar_t wc;
int width;
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return 1;
}
width = wcwidth(wc);
if (width == -1)
if (width < 0)
return 1;
return width;
} else
return 1;
}
/* Convert the given Unicode value to a multibyte character, if possible.
* If the conversion succeeds, return the (dynamically allocated) multibyte
* character and its length. Otherwise, return a length of zero. */
char *make_mbchar(long code, int *length)
{
char *mb_char = charalloc(MAXCHARLEN);
*length = wctomb(mb_char, (wchar_t)code);
/* Reject invalid Unicode characters. */
if (*length < 0 || !is_valid_unicode((wchar_t)code)) {
IGNORE_CALL_RESULT(wctomb(NULL, 0));
*length = 0;
}
return mb_char;
}
#endif /* ENABLE_UTF8 */
/* Return the length (in bytes) of the character located at *pointer. */
int char_length(const char *pointer)
{
#ifdef ENABLE_UTF8
/* If possibly a multibyte character, get its length; otherwise, it's 1. */
if ((signed char)*pointer < 0) {
int length = mblen(pointer, MAXCHARLEN);
return (length < 0 ? 1 : length);
} else
#endif
return 1;
}
/* Convert the Unicode value in chr to a multibyte character, if possible.
* If the conversion succeeds, return the (dynamically allocated) multibyte
* character and its length. Otherwise, return an undefined (dynamically
* allocated) multibyte character and a length of zero. */
char *make_mbchar(long chr, int *chr_mb_len)
/* Return the number of (multibyte) characters in the given string. */
size_t mbstrlen(const char *pointer)
{
char *chr_mb;
size_t count = 0;
while (*pointer != '\0') {
#ifdef ENABLE_UTF8
if (use_utf8) {
chr_mb = charalloc(MAXCHARLEN);
*chr_mb_len = wctomb(chr_mb, (wchar_t)chr);
if ((signed char)*pointer < 0) {
int length = mblen(pointer, MAXCHARLEN);
/* Reject invalid Unicode characters. */
if (*chr_mb_len < 0 || !is_valid_unicode((wchar_t)chr)) {
IGNORE_CALL_RESULT(wctomb(NULL, 0));
*chr_mb_len = 0;
}
} else
pointer += (length < 0 ? 1 : length);
} else
#endif
{
*chr_mb_len = 1;
chr_mb = mallocstrncpy(NULL, (char *)&chr, 1);
pointer++;
count++;
}
return chr_mb;
return count;
}
/* Parse a multibyte character from buf. Return the number of bytes
* used. If chr isn't NULL, store the multibyte character in it. If
* col isn't NULL, add the character's width (in columns) to it. */
int parse_mbchar(const char *buf, char *chr, size_t *col)
/* Return the length (in bytes) of the character at the start of the
* given string, and return a copy of this character in *thechar. */
int collect_char(const char *string, char *thechar)
{
int charlen;
#ifdef ENABLE_UTF8
if (use_utf8) {
/* Get the number of bytes in the multibyte character. */
int length = mblen(buf, MAXCHARLEN);
/* If this is a UTF-8 starter byte, get the number of bytes of the character. */
if ((signed char)*string < 0) {
charlen = mblen(string, MAXCHARLEN);
/* When the multibyte sequence is invalid, only take the first byte. */
if (length <= 0) {
IGNORE_CALL_RESULT(mblen(NULL, 0));
length = 1;
}
/* When requested, store the multibyte character in chr. */
if (chr != NULL) {
int i;
for (i = 0; i < length; i++)
chr[i] = buf[i];
}
/* When requested, add the width of the character to col. */
if (col != NULL) {
/* If we have a tab, compute its width in columns based on the
* current value of col. */
if (*buf == '\t')
*col += tabsize - *col % tabsize;
/* If we have a control character, it's two columns wide: one
* column for the "^", and one for the visible character. */
else if (is_cntrl_mbchar(buf)) {
*col += 2;
/* If we have a normal character, get its width normally. */
} else
*col += mbwidth(buf);
}
return length;
if (charlen <= 0)
charlen = 1;
} else
#endif
{
/* When requested, store the byte character in chr. */
if (chr != NULL)
*chr = *buf;
charlen = 1;
/* When requested, add the width of the character to col. */
if (col != NULL) {
/* If we have a tab, compute its width in columns using the
* current value of col. */
if (*buf == '\t')
*col += tabsize - *col % tabsize;
/* If we have a control character, it's two columns wide: one
* column for the "^", and one for the visible character. */
else if (is_cntrl_char((unsigned char)*buf))
*col += 2;
/* If we have a normal character, it's one column wide. */
for (int i = 0; i < charlen; i++)
thechar[i] = string[i];
return charlen;
}
/* Return the length (in bytes) of the character at the start of
* the given string, and add this character's width to *column. */
int advance_over(const char *string, size_t *column)
{
#ifdef ENABLE_UTF8
if ((signed char)*string < 0) {
int charlen = mblen(string, MAXCHARLEN);
if (charlen > 0) {
if (is_cntrl_char(string))
*column += 2;
else
(*col)++;
*column += mbwidth(string);
} else {
charlen = 1;
*column += 1;
}
return 1;
return charlen;
}
#endif
if ((unsigned char)*string < 0x20) {
if (*string == '\t')
*column += tabsize - *column % tabsize;
else
*column += 2;
} else if (*string == 0x7F)
*column += 2;
#ifndef ENABLE_UTF8
else if (0x7F < (unsigned char)*string && (unsigned char)*string < 0xA0)
*column += 2;
#endif
else
*column += 1;
return 1;
}
/* Return the index in buf of the beginning of the multibyte character
* before the one at pos. */
size_t move_mbleft(const char *buf, size_t pos)
size_t step_left(const char *buf, size_t pos)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
size_t before, char_len = 0;
size_t before, charlen = 0;
if (pos < 4)
before = 0;
@@ -399,21 +343,21 @@ size_t move_mbleft(const char *buf, size_t pos)
/* Move forward again until we reach the original character,
* so we know the length of its preceding character. */
while (before < pos) {
char_len = parse_mbchar(buf + before, NULL, NULL);
before += char_len;
charlen = char_length(buf + before);
before += charlen;
}
return before - char_len;
return before - charlen;
} else
#endif
return (pos == 0 ? 0 : pos - 1);
return (pos == 0 ? 0 : pos - 1);
}
/* Return the index in buf of the beginning of the multibyte character
* after the one at pos. */
size_t move_mbright(const char *buf, size_t pos)
size_t step_right(const char *buf, size_t pos)
{
return pos + parse_mbchar(buf + pos, NULL, NULL);
return pos + char_length(buf + pos);
}
/* This function is equivalent to strcasecmp() for multibyte strings. */
@@ -430,17 +374,8 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
wchar_t wc1, wc2;
while (*s1 != '\0' && *s2 != '\0' && n > 0) {
bool bad1 = FALSE, bad2 = FALSE;
if (mbtowc(&wc1, s1, MAXCHARLEN) < 0) {
mbtowc_reset();
bad1 = TRUE;
}
if (mbtowc(&wc2, s2, MAXCHARLEN) < 0) {
mbtowc_reset();
bad2 = TRUE;
}
bool bad1 = (mbtowc(&wc1, s1, MAXCHARLEN) < 0);
bool bad2 = (mbtowc(&wc2, s2, MAXCHARLEN) < 0);
if (bad1 || bad2) {
if (*s1 != *s2)
@@ -455,8 +390,8 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
return difference;
}
s1 += move_mbright(s1, 0);
s2 += move_mbright(s2, 0);
s1 += char_length(s1);
s2 += char_length(s2);
n--;
}
@@ -477,13 +412,13 @@ char *mbstrcasestr(const char *haystack, const char *needle)
if (mbstrncasecmp(haystack, needle, needle_len) == 0)
return (char *)haystack;
haystack += move_mbright(haystack, 0);
haystack += char_length(haystack);
}
return NULL;
} else
#endif
return (char *) strcasestr(haystack, needle);
return (char *)strcasestr(haystack, needle);
}
/* This function is equivalent to strstr(), except in that it scans the
@@ -549,178 +484,116 @@ char *mbrevstrcasestr(const char *haystack, const char *needle,
if (pointer == haystack)
return NULL;
pointer = haystack + move_mbleft(haystack, pointer - haystack);
pointer = haystack + step_left(haystack, pointer - haystack);
}
} else
#endif
return revstrcasestr(haystack, needle, pointer);
}
/* This function is equivalent to strlen() for multibyte strings. */
size_t mbstrlen(const char *s)
{
return mbstrnlen(s, (size_t)-1);
}
/* This function is equivalent to strnlen() for multibyte strings. */
size_t mbstrnlen(const char *s, size_t maxlen)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
size_t n = 0;
for (; *s != '\0' && maxlen > 0; s += move_mbright(s, 0),
maxlen--, n++)
;
return n;
} else
#endif
return strnlen(s, maxlen);
}
#if !defined(NANO_TINY) || defined(ENABLE_JUSTIFY)
/* This function is equivalent to strchr() for multibyte strings. */
char *mbstrchr(const char *s, const char *c)
char *mbstrchr(const char *string, const char *chr)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
bool bad_s_mb = FALSE, bad_c_mb = FALSE;
char symbol[MAXCHARLEN];
const char *q = s;
bool bad_s = FALSE, bad_c = FALSE;
wchar_t ws, wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
wc = (unsigned char)*c;
bad_c_mb = TRUE;
if (mbtowc(&wc, chr, MAXCHARLEN) < 0) {
wc = (unsigned char)*chr;
bad_c = TRUE;
}
while (*s != '\0') {
int sym_len = parse_mbchar(s, symbol, NULL);
while (*string != '\0') {
int symlen = mbtowc(&ws, string, MAXCHARLEN);
if (mbtowc(&ws, symbol, sym_len) < 0) {
mbtowc_reset();
ws = (unsigned char)*s;
bad_s_mb = TRUE;
if (symlen < 0) {
ws = (unsigned char)*string;
bad_s = TRUE;
}
if (bad_s_mb == bad_c_mb && ws == wc)
if (ws == wc && bad_s == bad_c)
break;
s += sym_len;
q += sym_len;
string += symlen;
}
if (*s == '\0')
q = NULL;
if (*string == '\0')
return NULL;
return (char *)q;
return (char *)string;
} else
#endif
return (char *) strchr(s, *c);
return strchr(string, *chr);
}
#endif /* !NANO_TINY || ENABLE_JUSTIFY */
#ifndef NANO_TINY
/* This function is equivalent to strpbrk() for multibyte strings. */
char *mbstrpbrk(const char *s, const char *accept)
/* Locate, in the given string, the first occurrence of any of
* the characters in accept, searching forward. */
char *mbstrpbrk(const char *string, const char *accept)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
for (; *s != '\0'; s += move_mbright(s, 0)) {
if (mbstrchr(accept, s) != NULL)
return (char *)s;
}
while (*string != '\0') {
if (mbstrchr(accept, string) != NULL)
return (char *)string;
return NULL;
} else
#endif
return (char *) strpbrk(s, accept);
}
/* Locate, in the string that starts at head, the first occurrence of any of
* the characters in the string accept, starting from pointer and searching
* backwards. */
char *revstrpbrk(const char *head, const char *accept, const char *pointer)
{
if (*pointer == '\0') {
if (pointer == head)
return NULL;
pointer--;
}
while (pointer >= head) {
if (strchr(accept, *pointer) != NULL)
return (char *)pointer;
pointer--;
string += char_length(string);
}
return NULL;
}
/* The same as the preceding function but then for multibyte strings. */
/* Locate, in the string that starts at head, the first occurrence of any of
* the characters in accept, starting from pointer and searching backwards. */
char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
if (*pointer == '\0') {
if (pointer == head)
return NULL;
pointer = head + move_mbleft(head, pointer - head);
}
if (*pointer == '\0') {
if (pointer == head)
return NULL;
pointer = head + step_left(head, pointer - head);
}
while (TRUE) {
if (mbstrchr(accept, pointer) != NULL)
return (char *)pointer;
while (TRUE) {
if (mbstrchr(accept, pointer) != NULL)
return (char *)pointer;
/* If we've reached the head of the string, we found nothing. */
if (pointer == head)
return NULL;
/* If we've reached the head of the string, we found nothing. */
if (pointer == head)
return NULL;
pointer = head + move_mbleft(head, pointer - head);
}
} else
#endif
return revstrpbrk(head, accept, pointer);
pointer = head + step_left(head, pointer - head);
}
}
#endif /* !NANO_TINY */
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || defined(ENABLE_JUSTIFY))
/* Return TRUE if the string s contains one or more blank characters,
/* Return TRUE if the given string contains at least one blank character,
* and FALSE otherwise. */
bool has_blank_chars(const char *s)
bool has_blank_char(const char *string)
{
for (; *s != '\0'; s++) {
if (isblank((unsigned char)*s))
char symbol[MAXCHARLEN];
while (*string != '\0') {
string += collect_char(string, symbol);
if (is_blank_char(symbol))
return TRUE;
}
return FALSE;
}
/* Return TRUE if the multibyte string s contains one or more blank
* multibyte characters, and FALSE otherwise. */
bool has_blank_mbchars(const char *s)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
char symbol[MAXCHARLEN];
for (; *s != '\0'; s += move_mbright(s, 0)) {
parse_mbchar(s, symbol, NULL);
if (is_blank_mbchar(symbol))
return TRUE;
}
return FALSE;
} else
#endif
return has_blank_chars(s);
}
#endif /* ENABLE_NANORC && (!NANO_TINY || ENABLE_JUSTIFY) */
/* Return TRUE when the given string is empty or consists of only blanks. */
bool white_string(const char *string)
{
while (*string != '\0' && (is_blank_char(string) || *string == '\r'))
string += char_length(string);
return !*string;
}
#ifdef ENABLE_UTF8
/* Return TRUE if wc is valid Unicode, and FALSE otherwise. */
bool is_valid_unicode(wchar_t wc)
@@ -731,17 +604,3 @@ bool is_valid_unicode(wchar_t wc)
(0xFFFF < wc && wc <= 0x10FFFF && (wc & 0xFFFF) <= 0xFFFD));
}
#endif
#ifdef ENABLE_NANORC
/* Check if the string s is a valid multibyte string. Return TRUE if it
* is, and FALSE otherwise. */
bool is_valid_mbstring(const char *s)
{
#ifdef ENABLE_UTF8
if (use_utf8)
return (mbstowcs(NULL, s, 0) != (size_t)-1);
else
#endif
return TRUE;
}
#endif /* ENABLE_NANORC */

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* color.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -19,16 +19,15 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#ifdef ENABLE_COLOR
#include <errno.h>
#ifdef HAVE_MAGIC_H
#include <magic.h>
#endif
#include <string.h>
#include <unistd.h>
#ifdef ENABLE_COLOR
/* For early versions of ncurses-6.0, use an additional A_PROTECT attribute
* for all colors, in order to work around an ncurses miscoloring bug. */
@@ -39,100 +38,85 @@
#define A_BANDAID A_NORMAL
#endif
/* Initialize the colors for nano's interface, and assign pair numbers
* for the colors in each syntax. */
void set_colorpairs(void)
static bool defaults_allowed = FALSE;
/* Whether ncurses accepts -1 to mean "default color". */
/* Initialize the color pairs for nano's interface. */
void set_interface_colorpairs(void)
{
const syntaxtype *sint;
bool using_defaults = FALSE;
size_t i;
/* Tell ncurses to enable colors. */
start_color();
#ifdef HAVE_USE_DEFAULT_COLORS
/* Allow using the default colors, if available. */
using_defaults = (use_default_colors() != ERR);
/* Ask ncurses to allow -1 to mean "default color". */
defaults_allowed = (use_default_colors() == OK);
#endif
/* Initialize the color pairs for nano's interface elements. */
for (i = 0; i < NUMBER_OF_ELEMENTS; i++) {
colortype *combo = color_combo[i];
for (size_t index = 0; index < NUMBER_OF_ELEMENTS; index++) {
colortype *combo = color_combo[index];
if (combo != NULL) {
if (combo->fg == -1 && !using_defaults)
combo->fg = COLOR_WHITE;
if (combo->bg == -1 && !using_defaults)
combo->bg = COLOR_BLACK;
init_pair(i + 1, combo->fg, combo->bg);
interface_color_pair[i] = COLOR_PAIR(i + 1) | A_BANDAID |
(combo->bright ? A_BOLD : A_NORMAL);
if (!defaults_allowed) {
if (combo->fg == THE_DEFAULT)
combo->fg = COLOR_WHITE;
if (combo->bg == THE_DEFAULT)
combo->bg = COLOR_BLACK;
}
init_pair(index + 1, combo->fg, combo->bg);
interface_color_pair[index] = COLOR_PAIR(index + 1) | A_BANDAID |
combo->attributes;
} else {
if (i == FUNCTION_TAG)
interface_color_pair[i] = A_NORMAL;
else if (i == ERROR_MESSAGE) {
init_pair(i + 1, COLOR_WHITE, COLOR_RED);
interface_color_pair[i] = COLOR_PAIR(i + 1) | A_BOLD | A_BANDAID;
if (index == FUNCTION_TAG)
interface_color_pair[index] = A_NORMAL;
else if (index == GUIDE_STRIPE)
interface_color_pair[index] = A_REVERSE;
else if (index == ERROR_MESSAGE) {
init_pair(index + 1, COLOR_WHITE, COLOR_RED);
interface_color_pair[index] = COLOR_PAIR(index + 1) |
A_BOLD | A_BANDAID;
} else
interface_color_pair[i] = hilite_attribute;
interface_color_pair[index] = hilite_attribute;
}
free(color_combo[i]);
}
/* For each syntax, go through its list of colors and assign each
* its pair number, giving identical color pairs the same number. */
for (sint = syntaxes; sint != NULL; sint = sint->next) {
colortype *ink;
int new_number = NUMBER_OF_ELEMENTS + 1;
for (ink = sint->color; ink != NULL; ink = ink->next) {
const colortype *beforenow = sint->color;
while (beforenow != ink && (beforenow->fg != ink->fg ||
beforenow->bg != ink->bg))
beforenow = beforenow->next;
if (beforenow != ink)
ink->pairnum = beforenow->pairnum;
else
ink->pairnum = new_number++;
ink->attributes = COLOR_PAIR(ink->pairnum) | A_BANDAID |
(ink->bright ? A_BOLD : A_NORMAL);
}
free(color_combo[index]);
}
}
/* Initialize the color information. */
void color_init(void)
/* Assign a pair number to each of the foreground/background color combinations
* in the given syntax, giving identical combinations the same number. */
void set_syntax_colorpairs(syntaxtype *sntx)
{
const colortype *ink;
bool using_defaults = FALSE;
short foreground, background;
short number = NUMBER_OF_ELEMENTS;
colortype *older;
/* If the terminal is not capable of colors, forget it. */
if (!has_colors())
return;
for (colortype *ink = sntx->color; ink != NULL; ink = ink->next) {
if (!defaults_allowed) {
if (ink->fg == THE_DEFAULT)
ink->fg = COLOR_WHITE;
if (ink->bg == THE_DEFAULT)
ink->bg = COLOR_BLACK;
}
#ifdef HAVE_USE_DEFAULT_COLORS
/* Allow using the default colors, if available. */
using_defaults = (use_default_colors() != ERR);
#endif
older = sntx->color;
/* For each coloring expression, initialize the color pair. */
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
foreground = ink->fg;
background = ink->bg;
while (older != ink && (older->fg != ink->fg || older->bg != ink->bg))
older = older->next;
if (foreground == -1 && !using_defaults)
foreground = COLOR_WHITE;
ink->pairnum = (older != ink) ? older->pairnum : ++number;
if (background == -1 && !using_defaults)
background = COLOR_BLACK;
init_pair(ink->pairnum, foreground, background);
ink->attributes |= COLOR_PAIR(ink->pairnum) | A_BANDAID;
}
}
/* Initialize the color pairs for the current syntax. */
void prepare_palette(void)
{
short number = NUMBER_OF_ELEMENTS;
/* For each unique pair number, tell ncurses the combination of colors. */
for (colortype *ink = openfile->syntax->color; ink != NULL; ink = ink->next)
if (ink->pairnum > number) {
init_pair(ink->pairnum, ink->fg, ink->bg);
number = ink->pairnum;
}
have_palette = TRUE;
}
@@ -145,7 +129,7 @@ bool found_in_list(regexlisttype *head, const char *shibboleth)
regex_t rgx;
for (item = head; item != NULL; item = item->next) {
regcomp(&rgx, fixbounds(item->full_regex), NANO_REG_EXTENDED);
regcomp(&rgx, item->full_regex, NANO_REG_EXTENDED);
if (regexec(&rgx, shibboleth, 0, NULL, 0) == 0) {
regfree(&rgx);
@@ -158,11 +142,11 @@ bool found_in_list(regexlisttype *head, const char *shibboleth)
return FALSE;
}
/* Update the color information based on the current filename and content. */
void color_update(void)
/* Find a syntax that applies to the current buffer, based upon filename
* or buffer content, and load and prime this syntax when needed. */
void find_and_prime_applicable_syntax(void)
{
syntaxtype *sint = NULL;
colortype *ink;
syntaxtype *sntx = NULL;
/* If the rcfiles were not read, or contained no syntaxes, get out. */
if (syntaxes == NULL)
@@ -174,56 +158,39 @@ void color_update(void)
if (strcmp(syntaxstr, "none") == 0)
return;
for (sint = syntaxes; sint != NULL; sint = sint->next) {
if (strcmp(sint->name, syntaxstr) == 0)
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
if (strcmp(sntx->name, syntaxstr) == 0)
break;
}
if (sint == NULL && !inhelp)
if (sntx == NULL && !inhelp)
statusline(ALERT, _("Unknown syntax name: %s"), syntaxstr);
}
/* If no syntax-override string was specified, or it didn't match,
* try finding a syntax based on the filename (extension). */
if (sint == NULL && !inhelp) {
char *reserved = charalloc(PATH_MAX + 1);
char *currentdir = getcwd(reserved, PATH_MAX + 1);
char *joinednames = charalloc(PATH_MAX + 1);
char *fullname = NULL;
if (currentdir == NULL)
free(reserved);
else {
/* Concatenate the current working directory with the
* specified filename, and canonicalize the result. */
sprintf(joinednames, "%s/%s", currentdir, openfile->filename);
fullname = get_full_path(joinednames);
free(currentdir);
}
if (sntx == NULL && !inhelp) {
char *fullname = get_full_path(openfile->filename);
if (fullname == NULL)
fullname = mallocstrcpy(fullname, openfile->filename);
for (sint = syntaxes; sint != NULL; sint = sint->next) {
if (found_in_list(sint->extensions, fullname))
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
if (found_in_list(sntx->extensions, fullname))
break;
}
free(joinednames);
free(fullname);
}
/* If the filename didn't match anything, try the first line. */
if (sint == NULL && !inhelp) {
for (sint = syntaxes; sint != NULL; sint = sint->next) {
if (found_in_list(sint->headers, openfile->fileage->data))
if (sntx == NULL && !inhelp) {
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
if (found_in_list(sntx->headers, openfile->filetop->data))
break;
}
}
#ifdef HAVE_LIBMAGIC
/* If we still don't have an answer, try using magic. */
if (sint == NULL && !inhelp) {
if (sntx == NULL && !inhelp) {
struct stat fileinfo;
magic_t cookie = NULL;
const char *magicstring = NULL;
@@ -247,10 +214,9 @@ void color_update(void)
/* Now try and find a syntax that matches the magic string. */
if (magicstring != NULL) {
for (sint = syntaxes; sint != NULL; sint = sint->next) {
if (found_in_list(sint->magics, magicstring))
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
if (found_in_list(sntx->magics, magicstring))
break;
}
}
if (stat(openfile->filename, &fileinfo) == 0)
@@ -259,34 +225,33 @@ void color_update(void)
#endif /* HAVE_LIBMAGIC */
/* If nothing at all matched, see if there is a default syntax. */
if (sint == NULL && !inhelp) {
for (sint = syntaxes; sint != NULL; sint = sint->next) {
if (strcmp(sint->name, "default") == 0)
if (sntx == NULL && !inhelp) {
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
if (strcmp(sntx->name, "default") == 0)
break;
}
}
openfile->syntax = sint;
openfile->colorstrings = (sint == NULL ? NULL : sint->color);
/* If a syntax was found, compile its specified regexes (which have
* already been checked for validity when they were read in). */
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
if (ink->start == NULL) {
ink->start = (regex_t *)nmalloc(sizeof(regex_t));
regcomp(ink->start, fixbounds(ink->start_regex), ink->rex_flags);
}
if (ink->end_regex != NULL && ink->end == NULL) {
ink->end = (regex_t *)nmalloc(sizeof(regex_t));
regcomp(ink->end, fixbounds(ink->end_regex), ink->rex_flags);
}
/* When the syntax isn't loaded yet, parse it and initialize its colors. */
if (sntx != NULL && sntx->filename != NULL) {
parse_one_include(sntx->filename, sntx);
set_syntax_colorpairs(sntx);
}
openfile->syntax = sntx;
}
/* Allocate and initialize (for the given line) the cache for multiline info. */
void set_up_multicache(linestruct *line)
{
line->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short));
for (short index = 0; index < openfile->syntax->nmultis; index++)
line->multidata[index] = -1;
}
/* Determine whether the matches of multiline regexes are still the same,
* and if not, schedule a screen refresh, so things will be repainted. */
void check_the_multis(filestruct *line)
void check_the_multis(linestruct *line)
{
const colortype *ink;
bool astart, anend;
@@ -297,13 +262,14 @@ void check_the_multis(filestruct *line)
if (openfile->syntax == NULL || openfile->syntax->nmultis == 0)
return;
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
if (line->multidata == NULL)
set_up_multicache(line);
for (ink = openfile->syntax->color; ink != NULL; ink = ink->next) {
/* If it's not a multiline regex, skip. */
if (ink->end == NULL)
continue;
alloc_multidata_if_needed(line);
astart = (regexec(ink->start, line->data, 1, &startmatch, 0) == 0);
afterstart = line->data + (astart ? startmatch.rm_eo : 0);
anend = (regexec(ink->end, afterstart, 1, &endmatch, 0) == 0);
@@ -330,43 +296,30 @@ void check_the_multis(filestruct *line)
}
}
/* Allocate (for one line) the cache space for multiline color regexes. */
void alloc_multidata_if_needed(filestruct *fileptr)
{
int i;
if (fileptr->multidata == NULL) {
fileptr->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short));
for (i = 0; i < openfile->syntax->nmultis; i++)
fileptr->multidata[i] = -1;
}
}
/* Precalculate the multi-line start and end regex info so we can
* speed up rendering (with any hope at all...). */
void precalc_multicolorinfo(void)
{
const colortype *ink;
regmatch_t startmatch, endmatch;
filestruct *line, *tailline;
linestruct *line, *tailline;
if (openfile->colorstrings == NULL || ISSET(NO_COLOR_SYNTAX))
if (openfile->syntax == NULL || openfile->syntax->nmultis == 0 ||
openfile->filetop->multidata || ISSET(NO_SYNTAX))
return;
#ifdef DEBUG
fprintf(stderr, "Precalculating the multiline color info...\n");
#endif
/* For each line, allocate cache space for the multiline-regex info. */
for (line = openfile->filetop; line != NULL; line = line->next)
set_up_multicache(line);
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
for (ink = openfile->syntax->color; ink != NULL; ink = ink->next) {
/* If this is not a multi-line regex, skip it. */
if (ink->end == NULL)
continue;
for (line = openfile->fileage; line != NULL; line = line->next) {
for (line = openfile->filetop; line != NULL; line = line->next) {
int index = 0;
alloc_multidata_if_needed(line);
/* Assume nothing applies until proven otherwise below. */
line->multidata[ink->id] = CNONE;
@@ -379,14 +332,14 @@ void precalc_multicolorinfo(void)
/* When the line contains a start match, look for an end, and if
* found, mark all the lines that are affected. */
while (regexec(ink->start, line->data + index, 1,
&startmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
&startmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
/* Begin looking for an end match after the start match. */
index += startmatch.rm_eo;
/* If there is an end match on this line, mark the line, but
* continue looking for other starts after it. */
if (regexec(ink->end, line->data + index, 1,
&endmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
&endmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
line->multidata[ink->id] = CSTARTENDHERE;
index += endmatch.rm_eo;
/* If both start and end are mere anchors, step ahead. */
@@ -395,7 +348,7 @@ void precalc_multicolorinfo(void)
/* When at end-of-line, we're done. */
if (line->data[index] == '\0')
break;
index = move_mbright(line->data, index);
index = step_right(line->data, index);
}
continue;
}
@@ -418,12 +371,9 @@ void precalc_multicolorinfo(void)
* the lines in between and the end properly. */
line->multidata[ink->id] = CENDAFTER;
for (line = line->next; line != tailline; line = line->next) {
alloc_multidata_if_needed(line);
for (line = line->next; line != tailline; line = line->next)
line->multidata[ink->id] = CWHOLELINE;
}
alloc_multidata_if_needed(tailline);
tailline->multidata[ink->id] = CBEGINBEFORE;
/* Begin looking for a new start after the end match. */

829
src/cut.c
View File

@@ -1,9 +1,9 @@
/**************************************************************************
* cut.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2014 Mark Majeres *
* Copyright (C) 2016 Benno Schulenberg *
* Copyright (C) 2016, 2018, 2019 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -20,246 +20,694 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#include <string.h>
static bool keep_cutbuffer = FALSE;
/* Should we keep the contents of the cutbuffer? */
/* Indicate that we should no longer keep the contents of the cutbuffer. */
void cutbuffer_reset(void)
/* Delete the character under the cursor. */
void do_deletion(undo_type action)
{
keep_cutbuffer = FALSE;
openfile->placewewant = xplustabs();
/* When in the middle of a line, delete the current character. */
if (openfile->current->data[openfile->current_x] != '\0') {
int charlen = char_length(openfile->current->data + openfile->current_x);
size_t line_len = strlen(openfile->current->data + openfile->current_x);
#ifndef NANO_TINY
size_t old_amount = openfile->current->extrarows;
/* If the type of action changed or the cursor moved to a different
* line, create a new undo item, otherwise update the existing item. */
if (action != openfile->last_action ||
openfile->current->lineno != openfile->current_undo->head_lineno)
add_undo(action, NULL);
else
update_undo(action);
#endif
/* Move the remainder of the line "in", over the current character. */
memmove(&openfile->current->data[openfile->current_x],
&openfile->current->data[openfile->current_x + charlen],
line_len - charlen + 1);
#ifndef NANO_TINY
/* When softwrapping, recompute the number of chunks in the line,
* and schedule a refresh if the number changed. */
if (ISSET(SOFTWRAP)) {
openfile->current->extrarows = extra_chunks_in(openfile->current);
if (openfile->current->extrarows != old_amount)
refresh_needed = TRUE;
}
/* Adjust the mark if it is after the cursor on the current line. */
if (openfile->mark == openfile->current &&
openfile->mark_x > openfile->current_x)
openfile->mark_x -= charlen;
#endif
/* Otherwise, when not at end of buffer, join this line with the next. */
} else if (openfile->current != openfile->filebot) {
linestruct *joining = openfile->current->next;
/* If there is a magic line, and we're before it: don't eat it. */
if (joining == openfile->filebot && openfile->current_x != 0 &&
!ISSET(NO_NEWLINES)) {
#ifndef NANO_TINY
if (action == BACK)
add_undo(BACK, NULL);
#endif
return;
}
#ifndef NANO_TINY
add_undo(action, NULL);
/* Adjust the mark if it is on the line that will be "eaten". */
if (openfile->mark == joining) {
openfile->mark = openfile->current;
openfile->mark_x += openfile->current_x;
}
openfile->current->has_anchor |= joining->has_anchor;
#endif
/* Add the content of the next line to that of the current one. */
openfile->current->data = charealloc(openfile->current->data,
strlen(openfile->current->data) + strlen(joining->data) + 1);
strcat(openfile->current->data, joining->data);
unlink_node(joining);
#ifndef NANO_TINY
if (ISSET(SOFTWRAP))
openfile->current->extrarows = extra_chunks_in(openfile->current);
#endif
/* Two lines were joined, so do a renumbering and refresh the screen. */
renumber_from(openfile->current);
refresh_needed = TRUE;
} else
/* We're at the end-of-file: nothing to do. */
return;
/* Adjust the file size, and remember it for a possible redo. */
openfile->totsize--;
#ifndef NANO_TINY
openfile->current_undo->newsize = openfile->totsize;
#endif
set_modified();
}
/* Return the status of cutbuffer preservation. */
inline bool keeping_cutbuffer(void)
/* Delete the character under the cursor. */
void do_delete(void)
{
return keep_cutbuffer;
}
/* If we aren't on the last line of the file, move all the text of the
* current line, plus the newline at the end, into the cutbuffer. If we
* are, move all of the text of the current line into the cutbuffer. In
* both cases, set the current place we want to the beginning of the
* current line. */
void cut_line(void)
{
if (openfile->current != openfile->filebot)
extract_buffer(&cutbuffer, &cutbottom, openfile->current, 0,
openfile->current->next, 0);
#ifndef NANO_TINY
if (openfile->mark && ISSET(LET_THEM_ZAP))
zap_text();
else
extract_buffer(&cutbuffer, &cutbottom, openfile->current, 0,
openfile->current, strlen(openfile->current->data));
openfile->placewewant = 0;
#endif
do_deletion(DEL);
}
/* Backspace over one character. That is, move the cursor left one
* character, and then delete the character under the cursor. */
void do_backspace(void)
{
#ifndef NANO_TINY
if (openfile->mark && ISSET(LET_THEM_ZAP))
zap_text();
else
#endif
if (openfile->current_x > 0 || openfile->current != openfile->filetop) {
do_left();
do_deletion(BACK);
}
}
/* Return FALSE when a cut command would not actually cut anything: when
* on an empty line at EOF, or when the mark covers zero characters, or
* (when test_cliff is TRUE) when the magic line would be cut. */
bool is_cuttable(bool test_cliff)
{
size_t from = (test_cliff) ? openfile->current_x : 0;
if ((openfile->current->next == NULL && openfile->current->data[from] == '\0'
#ifndef NANO_TINY
&& openfile->mark == NULL) ||
(openfile->mark == openfile->current &&
openfile->mark_x == openfile->current_x) ||
(from > 0 && !ISSET(NO_NEWLINES) &&
openfile->current->data[from] == '\0' &&
openfile->current->next == openfile->filebot
#endif
)) {
#ifndef NANO_TINY
statusbar(_("Nothing was cut"));
openfile->mark = NULL;
#endif
return FALSE;
} else
return TRUE;
}
#ifndef NANO_TINY
/* Move all currently marked text into the cutbuffer, and set the
* current place we want to where the text used to start. */
void cut_marked(bool *right_side_up)
/* Delete text from the cursor until the first start of a word to
* the left, or to the right when forward is TRUE. */
void chop_word(bool forward)
{
filestruct *top, *bot;
/* Remember the current cursor position. */
linestruct *is_current = openfile->current;
size_t is_current_x = openfile->current_x;
/* Remember where the cutbuffer is, then make it seem blank. */
linestruct *is_cutbuffer = cutbuffer;
cutbuffer = NULL;
/* Move the cursor to a word start, to the left or to the right.
* If that word is on another line and the cursor was not already
* on the edge of the original line, then put the cursor on that
* edge instead, so that lines will not be joined unexpectedly. */
if (!forward) {
do_prev_word(ISSET(WORD_BOUNDS));
if (openfile->current != is_current) {
if (is_current_x > 0) {
openfile->current = is_current;
openfile->current_x = 0;
} else
openfile->current_x = strlen(openfile->current->data);
}
} else {
do_next_word(ISSET(AFTER_ENDS), ISSET(WORD_BOUNDS));
if (openfile->current != is_current &&
is_current->data[is_current_x] != '\0') {
openfile->current = is_current;
openfile->current_x = strlen(is_current->data);
}
}
/* Set the mark at the start of that word. */
openfile->mark = openfile->current;
openfile->mark_x = openfile->current_x;
/* Put the cursor back where it was, so an undo will put it there too. */
openfile->current = is_current;
openfile->current_x = is_current_x;
/* Now kill the marked region and a word is gone. */
add_undo(CUT, NULL);
do_snip(TRUE, FALSE, FALSE);
update_undo(CUT);
/* Discard the cut word and restore the cutbuffer. */
free_lines(cutbuffer);
cutbuffer = is_cutbuffer;
}
/* Delete a word leftward. */
void chop_previous_word(void)
{
if (openfile->current->prev == NULL && openfile->current_x == 0)
statusbar(_("Nothing was cut"));
else
chop_word(BACKWARD);
}
/* Delete a word rightward. */
void chop_next_word(void)
{
openfile->mark = NULL;
if (is_cuttable(TRUE))
chop_word(FORWARD);
}
#endif /* !NANO_TINY */
/* Excise the text between the given two points and add it to the cutbuffer. */
void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_x)
{
linestruct *taken, *last;
bool edittop_inside = (openfile->edittop->lineno >= top->lineno &&
openfile->edittop->lineno <= bot->lineno);
#ifndef NANO_TINY
bool same_line = (openfile->mark == top);
bool post_marked = (openfile->mark && (openfile->mark->lineno > top->lineno ||
(same_line && openfile->mark_x > top_x)));
bool was_anchored = top->has_anchor;
if (top == bot && top_x == bot_x)
return;
if (top != bot)
for (linestruct *line = top->next; line != bot->next; line = line->next)
was_anchored |= line->has_anchor;
#endif
if (top == bot) {
taken = make_new_node(NULL);
taken->data = measured_copy(top->data + top_x, bot_x - top_x);
memmove(top->data + top_x, top->data + bot_x,
strlen(top->data + bot_x) + 1);
last = taken;
} else if (top_x == 0 && bot_x == 0) {
taken = top;
last = make_new_node(NULL);
last->data = copy_of("");
last->prev = bot->prev;
bot->prev->next = last;
last->next = NULL;
bot->prev = top->prev;
if (top->prev)
top->prev->next = bot;
else
openfile->filetop = bot;
openfile->current = bot;
} else {
taken = make_new_node(NULL);
taken->data = copy_of(top->data + top_x);
taken->next = top->next;
top->next->prev = taken;
top->next = bot->next;
if (bot->next)
bot->next->prev = top;
top->data = charealloc(top->data, top_x + strlen(bot->data + bot_x) + 1);
strcpy(top->data + top_x, bot->data + bot_x);
last = bot;
last->data[bot_x] = '\0';
last->next = NULL;
openfile->current = top;
}
/* Subtract the size of the excised text from the buffer size. */
openfile->totsize -= number_of_characters_in(taken, last);
/* If the cutbuffer is currently empty, just move all the text directly
* into it; otherwise, append the text to what is already there. */
if (cutbuffer == NULL) {
cutbuffer = taken;
cutbottom = last;
} else {
cutbottom->data = charealloc(cutbottom->data,
strlen(cutbottom->data) + strlen(taken->data) + 1);
strcat(cutbottom->data, taken->data);
cutbottom->next = taken->next;
delete_node(taken);
if (cutbottom->next != NULL) {
cutbottom->next->prev = cutbottom;
cutbottom = last;
}
}
openfile->current_x = top_x;
#ifndef NANO_TINY
openfile->current->has_anchor = was_anchored;
if (ISSET(SOFTWRAP))
openfile->current->extrarows = extra_chunks_in(openfile->current);
if (post_marked || same_line)
openfile->mark = openfile->current;
if (post_marked)
openfile->mark_x = openfile->current_x;
#endif
if (openfile->filebot == bot)
openfile->filebot = openfile->current;
renumber_from(openfile->current);
/* When the beginning of the viewport was inside the excision, adjust. */
if (edittop_inside) {
adjust_viewport(STATIONARY);
refresh_needed = TRUE;
}
/* If the text doesn't end with a newline, and it should, add one. */
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
new_magicline();
}
/* Meld the buffer that starts at topline into the current file buffer
* at the current cursor position. */
void ingraft_buffer(linestruct *topline)
{
linestruct *line = openfile->current;
size_t length = strlen(line->data);
size_t extralen = strlen(topline->data);
size_t xpos = openfile->current_x;
char *tailtext = copy_of(line->data + xpos);
#ifndef NANO_TINY
bool mark_follows = (openfile->mark == line && !mark_is_before_cursor());
#endif
linestruct *botline = topline;
while (botline->next != NULL)
botline = botline->next;
/* Add the size of the text to be grafted to the buffer size. */
openfile->totsize += number_of_characters_in(topline, botline);
if (topline != botline)
length = xpos;
if (extralen > 0) {
/* Insert the text of topline at the current cursor position. */
line->data = charealloc(line->data, length + extralen + 1);
memmove(line->data + xpos + extralen, line->data + xpos, length - xpos + 1);
strncpy(line->data + xpos, topline->data, extralen);
}
if (topline != botline) {
#ifndef NANO_TINY
/* First compute the softwrapped chunks for each line in the graft. */
compute_the_extra_rows_per_line_from(topline);
#endif
/* When inserting at end-of-buffer, update the relevant pointer. */
if (line->next == NULL)
openfile->filebot = botline;
line->data[xpos + extralen] = '\0';
/* Hook the grafted lines in after the current one. */
botline->next = openfile->current->next;
if (botline->next)
botline->next->prev = botline;
openfile->current->next = topline->next;
topline->next->prev = openfile->current;
/* Add the text after the cursor position at the end of botline. */
length = strlen(botline->data);
extralen = strlen(tailtext);
botline->data = charealloc(botline->data, length + extralen + 1);
strcpy(botline->data + length, tailtext);
/* Put the cursor at the end of the grafted text. */
openfile->current = botline;
openfile->current_x = length;
} else
openfile->current_x += extralen;
#ifndef NANO_TINY
/* When needed, update the mark's pointer and position. */
if (mark_follows && topline != botline) {
openfile->mark = botline;
openfile->mark_x += length - xpos;
} else if (mark_follows)
openfile->mark_x += extralen;
if (ISSET(SOFTWRAP)) {
line->extrarows = extra_chunks_in(line);
openfile->current->extrarows = extra_chunks_in(openfile->current);
}
#endif
delete_node(topline);
free(tailtext);
renumber_from(line);
/* If the text doesn't end with a newline, and it should, add one. */
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
new_magicline();
}
/* Meld a copy of the given buffer into the current file buffer. */
void copy_from_buffer(linestruct *somebuffer)
{
linestruct *the_copy = copy_buffer(somebuffer);
ingraft_buffer(the_copy);
}
#ifndef NANO_TINY
/* Move all marked text from the current buffer into the cutbuffer. */
void cut_marked_region(void)
{
linestruct *top, *bot;
size_t top_x, bot_x;
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, right_side_up);
get_region(&top, &top_x, &bot, &bot_x);
extract_segment(top, top_x, bot, bot_x);
extract_buffer(&cutbuffer, &cutbottom, top, top_x, bot, bot_x);
openfile->placewewant = xplustabs();
}
/* If we aren't at the end of the current line, move all the text from
* the current cursor position to the end of the current line, not
* counting the newline at the end, into the cutbuffer. If we are, and
* we're not on the last line of the file, move the newline at the end
* into the cutbuffer, and set the current place we want to where the
* newline used to be. */
void cut_to_eol(void)
{
size_t data_len = strlen(openfile->current->data);
if (openfile->current_x < data_len)
/* If we're not at the end of the line, move all the text from
* the current position up to it, not counting the newline at
* the end, into the cutbuffer. */
extract_buffer(&cutbuffer, &cutbottom, openfile->current,
openfile->current_x, openfile->current, data_len);
else if (openfile->current != openfile->filebot) {
/* If we're at the end of the line, and it isn't the last line
* of the file, move all the text from the current position up
* to the beginning of the next line, i.e. the newline at the
* end, into the cutbuffer. */
extract_buffer(&cutbuffer, &cutbottom, openfile->current,
openfile->current_x, openfile->current->next, 0);
openfile->placewewant = xplustabs();
}
}
/* Move all the text from the current cursor position to the end of the
* file into the cutbuffer. */
void cut_to_eof(void)
{
extract_buffer(&cutbuffer, &cutbottom,
openfile->current, openfile->current_x,
openfile->filebot, strlen(openfile->filebot->data));
}
#endif /* !NANO_TINY */
/* Move text from the current buffer into the cutbuffer. If
* copy_text is TRUE, copy the text back into the buffer afterward.
* If cut_till_eof is TRUE, move all text from the current cursor
* position to the end of the file into the cutbuffer. */
void do_cut_text(bool copy_text, bool cut_till_eof)
{
#ifndef NANO_TINY
filestruct *cb_save = NULL;
/* The current end of the cutbuffer, before we add text to it. */
size_t cb_save_len = 0;
/* The length of the string at the current end of the cutbuffer,
* before we add text to it. */
bool old_no_newlines = ISSET(NO_NEWLINES);
bool right_side_up = TRUE;
/* There *is* no region, *or* it is marked forward. */
#endif
size_t was_totsize = openfile->totsize;
/* If a chain of cuts was broken, empty the cutbuffer. */
if (!keep_cutbuffer) {
free_filestruct(cutbuffer);
/* Move text from the current buffer into the cutbuffer.
* If until_eof is TRUE, move all text from the current cursor
* position to the end of the file into the cutbuffer. If append
* is TRUE (when zapping), always append the cut to the cutbuffer. */
void do_snip(bool marked, bool until_eof, bool append)
{
linestruct *line = openfile->current;
#ifndef NANO_TINY
keep_cutbuffer &= (openfile->last_action != COPY);
#endif
/* If cuts were not continuous, or when cutting a region, clear the slate. */
if ((marked || until_eof || !keep_cutbuffer) && !append) {
free_lines(cutbuffer);
cutbuffer = NULL;
/* Indicate that future cuts should add to the cutbuffer. */
keep_cutbuffer = TRUE;
}
#ifndef NANO_TINY
if (copy_text) {
/* If the cutbuffer isn't empty, remember where it currently ends. */
if (cutbuffer != NULL) {
cb_save = cutbottom;
cb_save_len = strlen(cutbottom->data);
}
/* Don't add a magicline when moving text to the cutbuffer. */
SET(NO_NEWLINES);
}
if (cut_till_eof) {
/* Move all text up to the end of the file into the cutbuffer. */
cut_to_eof();
} else if (openfile->mark) {
/* Move the marked text to the cutbuffer, and turn the mark off. */
cut_marked(&right_side_up);
/* Now move the relevant piece of text into the cutbuffer. */
if (until_eof)
extract_segment(openfile->current, openfile->current_x,
openfile->filebot, strlen(openfile->filebot->data));
else if (openfile->mark) {
cut_marked_region();
openfile->mark = NULL;
} else if (ISSET(CUT_FROM_CURSOR))
/* Move all text up to the end of the line into the cutbuffer. */
cut_to_eol();
else
#endif
/* Move the entire line into the cutbuffer. */
cut_line();
#ifndef NANO_TINY
if (copy_text) {
/* Copy the text that is in the cutbuffer (starting at its saved end,
* if there is one) back into the current buffer. This effectively
* uncuts the text we just cut. */
if (cutbuffer != NULL) {
if (cb_save != NULL) {
cb_save->data += cb_save_len;
copy_from_buffer(cb_save);
cb_save->data -= cb_save_len;
} else
copy_from_buffer(cutbuffer);
/* If the copied region was marked forward, put the new desired
* x position at its end; otherwise, leave it at its beginning. */
if (right_side_up)
openfile->placewewant = xplustabs();
} else if (ISSET(CUT_FROM_CURSOR)) {
/* When not at the end of a line, move the rest of this line into
* the cutbuffer. Otherwise, when not at the end of the buffer,
* move just the "line separator" into the cutbuffer. */
if (openfile->current_x < strlen(openfile->current->data))
extract_segment(line, openfile->current_x, line, strlen(line->data));
else if (openfile->current != openfile->filebot) {
extract_segment(line, openfile->current_x, line->next, 0);
openfile->placewewant = xplustabs();
}
/* Restore the magicline behavior now that we're done fiddling. */
if (!old_no_newlines)
UNSET(NO_NEWLINES);
} else
#endif /* !NANO_TINY */
/* Only set the modification flag if actually something was cut. */
if (openfile->totsize != was_totsize)
set_modified();
refresh_needed = TRUE;
#ifdef DEBUG
dump_filestruct(cutbuffer);
#endif
{
/* When not at end-of-buffer, move one full line into the cutbuffer;
* otherwise, move all text until end-of-line into the cutbuffer. */
if (openfile->current != openfile->filebot)
extract_segment(line, 0, line->next, 0);
else
extract_segment(line, 0, line, strlen(line->data));
openfile->placewewant = 0;
}
/* After a line operation, future ones should add to the cutbuffer. */
keep_cutbuffer = !marked && !until_eof;
set_modified();
refresh_needed = TRUE;
}
/* Move text from the current buffer into the cutbuffer. */
void do_cut_text_void(void)
void cut_text(void)
{
#ifndef NANO_TINY
add_undo(CUT);
#endif
do_cut_text(FALSE, FALSE);
#ifndef NANO_TINY
update_undo(CUT);
#endif
}
if (!is_cuttable(ISSET(CUT_FROM_CURSOR) && openfile->mark == NULL))
return;
#ifndef NANO_TINY
/* Move text from the current buffer into the cutbuffer, and copy it
* back into the buffer afterward. If the mark is set or the cursor
* was moved, blow away previous contents of the cutbuffer. */
void do_copy_text(void)
{
static struct filestruct *next_contiguous_line = NULL;
bool mark_is_set = (openfile->mark != NULL);
/* Remember the current viewport and cursor position. */
ssize_t is_edittop_lineno = openfile->edittop->lineno;
size_t is_firstcolumn = openfile->firstcolumn;
ssize_t is_current_lineno = openfile->current->lineno;
size_t is_current_x = openfile->current_x;
if (mark_is_set || openfile->current != next_contiguous_line)
cutbuffer_reset();
do_cut_text(TRUE, FALSE);
/* If the mark was set, blow away the cutbuffer on the next copy. */
next_contiguous_line = (mark_is_set ? NULL : openfile->current);
/* If the mark was set, restore the viewport and cursor position. */
if (mark_is_set) {
openfile->edittop = fsfromline(is_edittop_lineno);
openfile->firstcolumn = is_firstcolumn;
openfile->current = fsfromline(is_current_lineno);
openfile->current_x = is_current_x;
/* Only add a new undo item when the current item is not a CUT or when
* the current cut is not contiguous with the previous cutting. */
if (openfile->last_action != CUT || !keep_cutbuffer) {
keep_cutbuffer = FALSE;
add_undo(CUT, NULL);
}
do_snip(openfile->mark != NULL, FALSE, FALSE);
update_undo(CUT);
#else
if (is_cuttable(FALSE))
do_snip(FALSE, FALSE, FALSE);
#endif
wipe_statusbar();
}
#ifndef NANO_TINY
/* Cut from the current cursor position to the end of the file. */
void do_cut_till_eof(void)
void cut_till_eof(void)
{
add_undo(CUT_TO_EOF);
do_cut_text(FALSE, TRUE);
ran_a_tool = TRUE;
if (openfile->current->data[openfile->current_x] == '\0' &&
(openfile->current->next == NULL ||
(!ISSET(NO_NEWLINES) && openfile->current_x > 0 &&
openfile->current->next == openfile->filebot))) {
statusbar(_("Nothing was cut"));
return;
}
add_undo(CUT_TO_EOF, NULL);
do_snip(FALSE, TRUE, FALSE);
update_undo(CUT_TO_EOF);
wipe_statusbar();
}
/* Erase text (current line or marked region), sending it into oblivion. */
void zap_text(void)
{
/* Remember the current cutbuffer so it can be restored after the zap. */
linestruct *was_cutbuffer = cutbuffer;
if (!is_cuttable(ISSET(CUT_FROM_CURSOR) && openfile->mark == NULL))
return;
/* Add a new undo item only when the current item is not a ZAP or when
* the current zap is not contiguous with the previous zapping. */
if (openfile->last_action != ZAP || !keep_cutbuffer)
add_undo(ZAP, NULL);
/* Use the cutbuffer from the ZAP undo item, so the cut can be undone. */
cutbuffer = openfile->current_undo->cutbuffer;
do_snip(openfile->mark != NULL, FALSE, TRUE);
update_undo(ZAP);
wipe_statusbar();
cutbuffer = was_cutbuffer;
}
/* Make a copy of the marked region, putting it in the cutbuffer. */
void copy_marked_region(void)
{
linestruct *topline, *botline, *afterline;
char *was_datastart, saved_byte;
size_t top_x, bot_x;
get_region(&topline, &top_x, &botline, &bot_x);
openfile->last_action = OTHER;
keep_cutbuffer = FALSE;
openfile->mark = NULL;
refresh_needed = TRUE;
if (topline == botline && top_x == bot_x) {
statusbar(_("Copied nothing"));
return;
}
/* Make the area that was marked look like a separate buffer. */
afterline = botline->next;
botline->next = NULL;
saved_byte = botline->data[bot_x];
botline->data[bot_x] = '\0';
was_datastart = topline->data;
topline->data += top_x;
cutbuffer = copy_buffer(topline);
/* Restore the proper state of the buffer. */
topline->data = was_datastart;
botline->data[bot_x] = saved_byte;
botline->next = afterline;
}
/* Copy text from the current buffer into the cutbuffer. The text is either
* the marked region, the whole line, the text from cursor to end-of-line,
* just the line break, or nothing, depending on mode and cursor position. */
void copy_text(void)
{
bool at_eol = (openfile->current->data[openfile->current_x] == '\0');
bool sans_newline = (ISSET(NO_NEWLINES) && openfile->current->next == NULL);
size_t from_x = (ISSET(CUT_FROM_CURSOR)) ? openfile->current_x : 0;
linestruct *was_current = openfile->current;
linestruct *addition;
if (openfile->mark || openfile->last_action != COPY || !keep_cutbuffer) {
free_lines(cutbuffer);
cutbuffer = NULL;
}
wipe_statusbar();
if (openfile->mark) {
copy_marked_region();
return;
}
/* When at the very end of the buffer, there is nothing to do. */
if (openfile->current->next == NULL && at_eol && (ISSET(CUT_FROM_CURSOR) ||
openfile->current_x == 0 || cutbuffer)) {
statusbar(_("Copied nothing"));
return;
}
addition = make_new_node(NULL);
addition->data = copy_of(openfile->current->data + from_x);
if (ISSET(CUT_FROM_CURSOR))
sans_newline = !at_eol;
/* Create the cutbuffer OR add to it, depending on the mode, the position
* of the cursor, and whether or not the cutbuffer is currently empty. */
if (cutbuffer == NULL && sans_newline) {
cutbuffer = addition;
cutbottom = addition;
} else if (cutbuffer == NULL) {
cutbuffer = addition;
cutbottom = make_new_node(cutbuffer);
cutbottom->data = copy_of("");
cutbuffer->next = cutbottom;
} else if (sans_newline) {
addition->prev = cutbottom->prev;
addition->prev->next = addition;
delete_node(cutbottom);
cutbottom = addition;
} else if (ISSET(CUT_FROM_CURSOR)) {
addition->prev = cutbottom;
cutbottom->next = addition;
cutbottom = addition;
} else {
addition->prev = cutbottom->prev;
addition->prev->next = addition;
addition->next = cutbottom;
cutbottom->prev = addition;
}
/* When needed and possible, move the cursor to the next line. */
if ((!ISSET(CUT_FROM_CURSOR) || at_eol) && openfile->current->next) {
openfile->current = openfile->current->next;
openfile->current_x = 0;
} else
openfile->current_x = strlen(openfile->current->data);
edit_redraw(was_current, FLOWING);
openfile->last_action = COPY;
keep_cutbuffer = TRUE;
}
#endif /* !NANO_TINY */
/* Copy text from the cutbuffer into the current buffer. */
void do_uncut_text(void)
void paste_text(void)
{
ssize_t was_lineno = openfile->current->lineno;
/* The line number where we started the paste. */
size_t was_leftedge = 0;
/* The leftedge where we started the paste. */
/* If the cutbuffer is empty, there is nothing to do. */
if (cutbuffer == NULL)
if (cutbuffer == NULL) {
statusbar(_("Cutbuffer is empty"));
return;
}
#ifndef NANO_TINY
add_undo(PASTE);
add_undo(PASTE, NULL);
if (ISSET(SOFTWRAP))
was_leftedge = leftedge_for(xplustabs(), openfile->current);
@@ -281,5 +729,6 @@ void do_uncut_text(void)
openfile->placewewant = xplustabs();
set_modified();
wipe_statusbar();
refresh_needed = TRUE;
}

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* nano.h -- This file is part of GNU nano. *
* definitions.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -19,25 +19,22 @@
* *
**************************************************************************/
#ifndef NANO_H
#define NANO_H 1
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef NEED_XOPEN_SOURCE_EXTENDED
#ifndef _XOPEN_SOURCE_EXTENDED
#define _XOPEN_SOURCE_EXTENDED 1
#define _XOPEN_SOURCE_EXTENDED 1
#endif
#endif
#ifdef __TANDEM
/* Tandem NonStop Kernel support. */
#include <floss.h>
#define NANO_ROOT_UID 65535
#define ROOT_UID 65535
#else
#define NANO_ROOT_UID 0
#define ROOT_UID 0
#endif
#ifdef HAVE_LIMITS_H
@@ -49,32 +46,30 @@
#endif
/* Suppress warnings for __attribute__((warn_unused_result)). */
#define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0)
#define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0)
/* Macros for flags, indexing each bit in a small array. */
#define FLAGS(flag) flags[((flag) / (sizeof(unsigned) * 8))]
#define FLAGMASK(flag) ((unsigned)1 << ((flag) % (sizeof(unsigned) * 8)))
#define SET(flag) FLAGS(flag) |= FLAGMASK(flag)
#define UNSET(flag) FLAGS(flag) &= ~FLAGMASK(flag)
#define ISSET(flag) ((FLAGS(flag) & FLAGMASK(flag)) != 0)
#define TOGGLE(flag) FLAGS(flag) ^= FLAGMASK(flag)
#define FLAGS(flag) flags[((flag) / (sizeof(unsigned) * 8))]
#define FLAGMASK(flag) ((unsigned)1 << ((flag) % (sizeof(unsigned) * 8)))
#define SET(flag) FLAGS(flag) |= FLAGMASK(flag)
#define UNSET(flag) FLAGS(flag) &= ~FLAGMASK(flag)
#define ISSET(flag) ((FLAGS(flag) & FLAGMASK(flag)) != 0)
#define TOGGLE(flag) FLAGS(flag) ^= FLAGMASK(flag)
/* Macros for character allocation and more. */
#define charalloc(howmuch) (char *)nmalloc((howmuch) * sizeof(char))
#define charealloc(ptr, howmuch) (char *)nrealloc(ptr, (howmuch) * sizeof(char))
#define charmove(dest, src, n) memmove(dest, src, (n) * sizeof(char))
#define charset(dest, src, n) memset(dest, src, (n) * sizeof(char))
/* Macros for allocation of character strings. */
#define charalloc(howmuch) (char *)nmalloc(howmuch)
#define charealloc(ptr, howmuch) (char *)nrealloc(ptr, howmuch)
/* In UTF-8 a character is at most six bytes long. */
#ifdef ENABLE_UTF8
#define MAXCHARLEN 6
#define MAXCHARLEN 6
#else
#define MAXCHARLEN 1
#define MAXCHARLEN 1
#endif
/* Set a default value for PATH_MAX if there isn't one. */
#ifndef PATH_MAX
#define PATH_MAX 4096
#define PATH_MAX 4096
#endif
#ifdef USE_SLANG
@@ -82,8 +77,8 @@
#include <slcurses.h>
/* Slang curses emulation brain damage, part 3: Slang doesn't define the
* curses equivalents of the Insert or Delete keys. */
#define KEY_DC SL_KEY_DELETE
#define KEY_IC SL_KEY_IC
#define KEY_DC SL_KEY_DELETE
#define KEY_IC SL_KEY_IC
/* Ncurses support. */
#elif defined(HAVE_NCURSESW_NCURSES_H)
#include <ncursesw/ncurses.h>
@@ -95,7 +90,7 @@
#endif /* CURSES_H */
#if defined(NCURSES_VERSION_MAJOR) && (NCURSES_VERSION_MAJOR < 6)
#define USING_OLD_NCURSES yes
#define USING_OLD_NCURSES yes
#endif
#ifdef ENABLE_NLS
@@ -103,24 +98,21 @@
#ifdef HAVE_LIBINTL_H
#include <libintl.h>
#endif
#define _(string) gettext(string)
#define P_(singular, plural, number) ngettext(singular, plural, number)
#define _(string) gettext(string)
#define P_(singular, plural, number) ngettext(singular, plural, number)
#else
#define _(string) (string)
#define P_(singular, plural, number) (number == 1 ? singular : plural)
#define _(string) (string)
#define P_(singular, plural, number) (number == 1 ? singular : plural)
#endif
#define gettext_noop(string) (string)
#define N_(string) gettext_noop(string)
#define gettext_noop(string) (string)
#define N_(string) gettext_noop(string)
/* Mark a string that will be sent to gettext() later. */
#include <stddef.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <regex.h>
#include <signal.h>
#include <assert.h>
#include <stdlib.h>
#include <sys/stat.h>
/* If we aren't using an ncurses with mouse support, exclude any
* mouse routines, as they are useless then. */
@@ -129,26 +121,33 @@
#endif
#if defined(ENABLE_WRAPPING) || defined(ENABLE_JUSTIFY)
#define ENABLED_WRAPORJUSTIFY 1
#define ENABLED_WRAPORJUSTIFY 1
#endif
#define BACKWARD FALSE
#define FORWARD TRUE
#define BACKWARD FALSE
#define FORWARD TRUE
#define BLIND FALSE
#define VISIBLE TRUE
#define BLIND FALSE
#define VISIBLE TRUE
#define JUSTFIND 0
#define REPLACING 1
#define INREGION 2
#define JUSTFIND 0
#define REPLACING 1
#define INREGION 2
#ifdef ENABLE_COLOR
#define THE_DEFAULT -1
#define BAD_COLOR -2
#endif
#define STANDARD_INPUT 0
/* Enumeration types. */
typedef enum {
NIX_FILE, DOS_FILE, MAC_FILE
} file_format;
} format_type;
typedef enum {
HUSH, MILD, ALERT
VACUUM, HUSH, NOTICE, MILD, ALERT
} message_type;
typedef enum {
@@ -173,37 +172,29 @@ typedef enum {
#ifdef ENABLE_COMMENT
COMMENT, UNCOMMENT, PREFLIGHT,
#endif
CUT, CUT_TO_EOF, PASTE, INSERT, OTHER
ZAP, CUT, CUT_TO_EOF, COPY, PASTE, INSERT,
COUPLE_BEGIN, COUPLE_END, OTHER
} undo_type;
/* Structure types. */
#ifdef ENABLE_COLOR
typedef struct colortype {
short id;
/* An ordinal number (if this color combo is for a multiline regex). */
short fg;
/* This syntax's foreground color. */
/* This combo's foreground color. */
short bg;
/* This syntax's background color. */
bool bright;
/* Is this color A_BOLD? */
int pairnum;
/* The color pair number used for this foreground color and
* background color. */
/* This combo's background color. */
short pairnum;
/* The pair number for this foreground/background color combination. */
int attributes;
/* Pair number and brightness composed into ready-to-use attributes. */
int rex_flags;
/* The regex compilation flags (with or without REG_ICASE). */
char *start_regex;
/* The start (or all) of the regex string. */
regex_t *start;
/* The compiled start (or all) of the regex string. */
char *end_regex;
/* The end (if any) of the regex string. */
/* The compiled regular expression for 'start=', or the only one. */
regex_t *end;
/* The compiled end (if any) of the regex string. */
/* The compiled regular expression for 'end=', if any. */
struct colortype *next;
/* Next set of colors. */
int id;
/* Basic id for assigning to lines later. */
/* Next color combination. */
} colortype;
typedef struct regexlisttype {
@@ -213,9 +204,26 @@ typedef struct regexlisttype {
/* The next regex. */
} regexlisttype;
typedef struct augmentstruct {
char *filename;
/* The file where the syntax is extended. */
ssize_t lineno;
/* The number of the line of the extendsyntax command. */
char *data;
/* The text of the line. */
struct augmentstruct *next;
/* Next node. */
} augmentstruct;
typedef struct syntaxtype {
char *name;
/* The name of this syntax. */
char *filename;
/* File where the syntax is defined, or NULL if not an included file. */
size_t lineno;
/* The line number where the 'syntax' command was found. */
struct augmentstruct *augmentations;
/* List of extendsyntax commands to apply when loaded. */
regexlisttype *extensions;
/* The list of extensions that this syntax applies to. */
regexlisttype *headers;
@@ -225,14 +233,16 @@ typedef struct syntaxtype {
char *linter;
/* The command with which to lint this type of file. */
char *formatter;
/* The formatting command (for programming languages mainly). */
/* The command with which to format/modify/arrange this type of file. */
char *tab;
/* What the Tab key should produce; NULL for default behavior. */
#ifdef ENABLE_COMMENT
char *comment;
/* The line comment prefix (and postfix) for this type of file. */
#endif
colortype *color;
/* The colors and their regexes used in this syntax. */
int nmultis;
short nmultis;
/* How many multiline regex strings this syntax has. */
struct syntaxtype *next;
/* Next syntax. */
@@ -269,79 +279,67 @@ typedef struct lintstruct {
#endif /* ENABLE_COLOR */
/* More structure types. */
typedef struct filestruct {
typedef struct linestruct {
char *data;
/* The text of this line. */
ssize_t lineno;
/* The number of this line. */
struct filestruct *next;
#ifndef NANO_TINY
ssize_t extrarows;
/* The extra rows that this line occupies when softwrapping. */
#endif
struct linestruct *next;
/* Next node. */
struct filestruct *prev;
struct linestruct *prev;
/* Previous node. */
#ifdef ENABLE_COLOR
short *multidata;
/* Array of which multi-line regexes apply to this line. */
#endif
} filestruct;
typedef struct partition {
filestruct *fileage;
/* The top line of this portion of the file. */
filestruct *top_prev;
/* The line before the top line of this portion of the file. */
char *top_data;
/* The text before the beginning of the top line of this portion
* of the file. */
filestruct *filebot;
/* The bottom line of this portion of the file. */
filestruct *bot_next;
/* The line after the bottom line of this portion of the
* file. */
char *bot_data;
/* The text after the end of the bottom line of this portion of
* the file. */
} partition;
#ifndef NANO_TINY
bool has_anchor;
/* Whether the user has placed an anchor at this line. */
#endif
} linestruct;
#ifndef NANO_TINY
typedef struct undo_group {
typedef struct groupstruct {
ssize_t top_line;
/* First line of group. */
ssize_t bottom_line;
/* Last line of group. */
char **indentations;
/* String data used to restore the affected lines; one per line. */
struct undo_group *next;
} undo_group;
struct groupstruct *next;
/* The next group, if any. */
} groupstruct;
typedef struct undo {
ssize_t lineno;
typedef struct undostruct {
undo_type type;
/* What type of undo this was. */
size_t begin;
/* Where did this action begin or end. */
/* The operation type that this undo item is for. */
int xflags;
/* Some flag data to mark certain corner cases. */
ssize_t head_lineno;
/* The line number where the operation began or ended. */
size_t head_x;
/* The x position where the operation began or ended. */
char *strdata;
/* String type data we will use for copying the affected line back. */
/* String data to help restore the affected line. */
size_t wassize;
/* The file size before the action. */
size_t newsize;
/* The file size after the action. */
int xflags;
/* Some flag data we need. */
undo_group *grouping;
groupstruct *grouping;
/* Undo info specific to groups of lines. */
/* Cut-specific stuff we need. */
filestruct *cutbuffer;
/* Copy of the cutbuffer. */
filestruct *cutbottom;
/* Copy of cutbottom. */
ssize_t mark_begin_lineno;
linestruct *cutbuffer;
/* A copy of the cutbuffer. */
ssize_t tail_lineno;
/* Mostly the line number of the current line; sometimes something else. */
size_t mark_begin_x;
size_t tail_x;
/* The x position corresponding to the above line number. */
struct undo *next;
struct undostruct *next;
/* A pointer to the undo item of the preceding action. */
} undo;
} undostruct;
#endif /* !NANO_TINY */
#ifdef ENABLE_HISTORIES
@@ -351,21 +349,22 @@ typedef struct poshiststruct {
ssize_t lineno;
/* Line number we left off on. */
ssize_t xno;
/* x position in the file we left off on. */
/* The x position in the file we left off on. */
struct poshiststruct *next;
/* The next item of position history. */
} poshiststruct;
#endif
typedef struct openfilestruct {
char *filename;
/* The file's name. */
filestruct *fileage;
linestruct *filetop;
/* The file's first line. */
filestruct *filebot;
linestruct *filebot;
/* The file's last line. */
filestruct *edittop;
linestruct *edittop;
/* The current top of the edit window for this file. */
filestruct *current;
linestruct *current;
/* The current line for this file. */
size_t totsize;
/* The file's total number of characters. */
@@ -378,35 +377,37 @@ typedef struct openfilestruct {
/* The file's x position we would like. */
ssize_t current_y;
/* The file's y-coordinate position. */
bool modified;
/* Whether the file has been modified. */
struct stat *current_stat;
/* The file's current stat information. */
struct stat *statinfo;
/* The file's stat information from when it was opened or last saved. */
#ifdef ENABLE_WRAPPING
linestruct *spillage_line;
/* The line for prepending stuff to during automatic hard-wrapping. */
#endif
#ifndef NANO_TINY
filestruct *mark;
linestruct *mark;
/* The line in the file where the mark is set; NULL if not set. */
size_t mark_x;
/* The mark's x position in the above line. */
mark_type kind_of_mark;
/* Whether it is a soft (with Shift) or a hard mark. */
file_format fmt;
/* The file's format -- Unix or DOS or Mac or mixed. */
undo *undotop;
format_type fmt;
/* The file's format -- Unix or DOS or Mac. */
char *lock_filename;
/* The path of the lockfile, if we created one. */
undostruct *undotop;
/* The top of the undo list. */
undo *current_undo;
undostruct *current_undo;
/* The current (i.e. next) level of undo. */
undo *last_saved;
undostruct *last_saved;
/* The undo item at which the file was last saved. */
undo_type last_action;
/* The type of the last action the user performed. */
char *lock_filename;
/* The path of the lockfile, if we created one. */
#endif
bool modified;
/* Whether the file has been modified. */
#ifdef ENABLE_COLOR
syntaxtype *syntax;
/* The syntax struct for this file, if any. */
colortype *colorstrings;
/* The file's associated colors. */
/* The syntax that applies to this file, if any. */
#endif
#ifdef ENABLE_MULTIBUFFER
struct openfilestruct *next;
@@ -425,17 +426,15 @@ typedef struct rcoption {
} rcoption;
#endif
typedef struct sc {
typedef struct keystruct {
const char *keystr;
/* The string that describes a keystroke, like "^C" or "M-R". */
bool meta;
/* Whether this is a Meta keystroke. */
/* The string that describes the keystroke, like "^C" or "M-R". */
int keycode;
/* The integer that, together with meta, identifies the keystroke. */
int menus;
/* Which menus this applies to. */
/* The menus in which this keystroke is bound. */
void (*func)(void);
/* The function we're going to run. */
/* The function to which this keystroke is bound. */
#ifndef NANO_TINY
int toggle;
/* If a toggle, what we're toggling. */
@@ -447,11 +446,11 @@ typedef struct sc {
char *expansion;
/* The string of keycodes to which this shortcut is expanded. */
#endif
struct sc *next;
struct keystruct *next;
/* Next in the list. */
} sc;
} keystruct;
typedef struct subnfunc {
typedef struct funcstruct {
void (*func)(void);
/* The actual function to call. */
int menus;
@@ -469,9 +468,9 @@ typedef struct subnfunc {
/* Is this function allowed when in view mode? */
long toggle;
/* If this is a toggle, which toggle to affect. */
struct subnfunc *next;
struct funcstruct *next;
/* Next item in the list. */
} subnfunc;
} funcstruct;
#ifdef ENABLE_WORDCOMPLETION
typedef struct completion_word {
@@ -485,6 +484,7 @@ enum
{
TITLE_BAR = 0,
LINE_NUMBER,
GUIDE_STRIPE,
SELECTED_TEXT,
STATUS_BAR,
ERROR_MESSAGE,
@@ -500,23 +500,23 @@ enum
CASE_SENSITIVE,
CONSTANT_SHOW,
NO_HELP,
SUSPEND,
SUSPENDABLE,
NO_WRAP,
AUTOINDENT,
VIEW_MODE,
USE_MOUSE,
USE_REGEXP,
TEMP_FILE,
SAVE_ON_EXIT,
CUT_FROM_CURSOR,
BACKWARDS_SEARCH,
MULTIBUFFER,
SMOOTH_SCROLL,
REBIND_DELETE,
REBIND_KEYPAD,
RAW_SEQUENCES,
NO_CONVERT,
BACKUP_FILE,
MAKE_BACKUP,
INSECURE_BACKUP,
NO_COLOR_SYNTAX,
NO_SYNTAX,
PRESERVE,
HISTORYLOG,
RESTRICTED,
@@ -528,9 +528,8 @@ enum
WORD_BOUNDS,
NO_NEWLINES,
BOLD_TEXT,
QUIET,
SOFTWRAP,
POS_HISTORY,
POSITIONLOG,
LOCKING,
NOREAD_MODE,
MAKE_IT_UNIX,
@@ -538,7 +537,14 @@ enum
SHOW_CURSOR,
LINE_NUMBERS,
NO_PAUSES,
AT_BLANKS
AT_BLANKS,
AFTER_ENDS,
LET_THEM_ZAP,
BREAK_LONG_LINES,
JUMPY_SCROLLING,
EMPTY_LINE,
INDICATOR,
BOOKSTYLE
};
/* Flags for the menus in which a given function should be present. */
@@ -549,7 +555,7 @@ enum
#define MGOTOLINE (1<<4)
#define MWRITEFILE (1<<5)
#define MINSERTFILE (1<<6)
#define MEXTCMD (1<<7)
#define MEXECUTE (1<<7)
#define MHELP (1<<8)
#define MSPELL (1<<9)
#define MBROWSER (1<<10)
@@ -558,90 +564,99 @@ enum
#define MYESNO (1<<13)
#define MLINTER (1<<14)
#define MFINDINHELP (1<<15)
/* This is an abbreviation for all menus except Help and YesNo. */
/* This is an abbreviation for all menus except Help and Browser and YesNo. */
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\
MEXTCMD|MBROWSER|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER)
MEXECUTE|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER)
#ifndef NANO_TINY
#define MSOME MMOST
#define MSOME MMOST|MBROWSER
#else
#define MSOME MMAIN|MBROWSER
#endif
/* Basic control codes. */
#define TAB_CODE 0x09
#define ESC_CODE 0x1B
#define DEL_CODE 0x7F
/* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */
#define CONTROL_LEFT 0x401
#define CONTROL_RIGHT 0x402
#define CONTROL_UP 0x403
#define CONTROL_DOWN 0x404
#define CONTROL_HOME 0x405
#define CONTROL_END 0x406
#define SHIFT_CONTROL_LEFT 0x411
#define SHIFT_CONTROL_RIGHT 0x412
#define SHIFT_CONTROL_UP 0x413
#define SHIFT_CONTROL_DOWN 0x414
#define SHIFT_CONTROL_HOME 0x415
#define SHIFT_CONTROL_END 0x416
#define ALT_LEFT 0x421
#define ALT_RIGHT 0x422
#define ALT_UP 0x423
#define ALT_DOWN 0x424
#define SHIFT_ALT_LEFT 0x431
#define SHIFT_ALT_RIGHT 0x432
#define SHIFT_ALT_UP 0x433
#define SHIFT_ALT_DOWN 0x434
#define SHIFT_HOME 0x455
#define SHIFT_END 0x456
#define SHIFT_PAGEUP 0x457
#define SHIFT_PAGEDOWN 0x458
#define SHIFT_TAB 0x45F
#define CONTROL_LEFT 0x401
#define CONTROL_RIGHT 0x402
#define CONTROL_UP 0x403
#define CONTROL_DOWN 0x404
#define CONTROL_HOME 0x405
#define CONTROL_END 0x406
#define CONTROL_DELETE 0x40D
#define SHIFT_CONTROL_LEFT 0x411
#define SHIFT_CONTROL_RIGHT 0x412
#define SHIFT_CONTROL_UP 0x413
#define SHIFT_CONTROL_DOWN 0x414
#define SHIFT_CONTROL_HOME 0x415
#define SHIFT_CONTROL_END 0x416
#define CONTROL_SHIFT_DELETE 0x41D
#define ALT_LEFT 0x421
#define ALT_RIGHT 0x422
#define ALT_UP 0x423
#define ALT_DOWN 0x424
#define ALT_PAGEUP 0x427
#define ALT_PAGEDOWN 0x428
#define ALT_INSERT 0x42C
#define ALT_DELETE 0x42D
#define SHIFT_ALT_LEFT 0x431
#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
#define SHIFT_END 0x456
#define SHIFT_PAGEUP 0x457
#define SHIFT_PAGEDOWN 0x458
#define SHIFT_DELETE 0x45D
#define SHIFT_TAB 0x45F
/* A special keycode for when <Tab> is pressed while the mark is on. */
#define INDENT_KEY 0x4F1
/* 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
#ifdef USE_SLANG
#ifdef ENABLE_UTF8
#define KEY_BAD 0xFF /* Clipped error code. */
#define KEY_BAD 0xFF /* Clipped error code. */
#endif
#define KEY_FLUSH 0x91 /* User-definable control code. */
#define KEY_FLUSH 0x91 /* User-definable control code. */
#else
#define KEY_FLUSH KEY_F0 /* Nonexistent function key. */
#define KEY_FLUSH KEY_F0 /* Nonexistent function key. */
#endif
#ifndef NANO_TINY
/* An imaginary key for when we get a SIGWINCH (window resize). */
#define KEY_WINCH -2
#define KEY_WINCH -2
/* Some extra flags for the undo function. */
#define WAS_FINAL_BACKSPACE (1<<1)
#define WAS_BACKSPACE_AT_EOF (1<<1)
#define WAS_WHOLE_LINE (1<<2)
#define WAS_FINAL_LINE (1<<3)
/* The flags for the mark need to be the highest. */
#define INCLUDED_LAST_LINE (1<<3)
#define MARK_WAS_SET (1<<4)
#define WAS_MARKED_FORWARD (1<<5)
#define CURSOR_WAS_AT_HEAD (1<<5)
#endif /* !NANO_TINY */
/* The maximum number of entries displayed in the main shortcut list. */
#define MAIN_VISIBLE (((COLS + 40) / 20) * 2)
/* The default number of characters from the end of the line where
* wrapping occurs. */
#define CHARS_FROM_EOL 8
/* The default number of columns from end of line where wrapping occurs. */
#define COLUMNS_FROM_EOL 8
/* The default width of a tab in spaces. */
#define WIDTH_OF_TAB 8
#define WIDTH_OF_TAB 8
/* The default comment character when a syntax does not specify any. */
#define GENERAL_COMMENT_CHARACTER "#"
#define GENERAL_COMMENT_CHARACTER "#"
/* The maximum number of search/replace history strings saved, not
* counting the blank lines at their ends. */
#define MAX_SEARCH_HISTORY 100
/* The maximum number of bytes buffered at one time. */
#define MAX_BUF_SIZE 128
#define MAX_SEARCH_HISTORY 100
/* The largest size_t number that doesn't have the high bit set. */
#define HIGHEST_POSITIVE ((~(size_t)0) >> 1)
#endif /* !NANO_H */
#define HIGHEST_POSITIVE ((~(size_t)0) >> 1)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,9 @@
/**************************************************************************
* help.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2000-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2000-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2017 Rishabh Dave *
* Copyright (C) 2014-2017 Benno Schulenberg *
* Copyright (C) 2014-2019 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -20,277 +20,24 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#ifdef ENABLE_HELP
#include <errno.h>
#include <string.h>
#ifdef ENABLE_HELP
static char *help_text = NULL;
/* The text displayed in the help window. */
static const char *start_of_body = NULL;
/* The point in the help text just after the title. */
static char *end_of_intro = NULL;
/* The point in the help text where the shortcut descriptions begin. */
static size_t location;
/* The offset (in bytes) of the topleft of the shown help text. */
char *tempfilename = NULL;
/* Name of the temporary file used for wrapping the help text. */
/* Hard-wrap the help text, write it to the existing temporary file, and
* read that file into a new buffer. */
void wrap_the_help_text(bool redisplaying)
{
size_t sum = 0;
const char *ptr = start_of_body;
FILE *tempfile = fopen(tempfilename, "w+b");
/* If re-opening the temporary file failed, give up. */
if (tempfile == NULL) {
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
return;
}
/* Write the body of the help_text into the temporary file. */
while (*ptr != '\0') {
int length = help_line_len(ptr);
fwrite(ptr, sizeof(char), length, tempfile);
ptr += length;
/* Hard-wrap the lines in the help text. */
if (*ptr != '\n')
fwrite("\n", sizeof(char), 1, tempfile);
else while (*ptr == '\n')
fwrite(ptr++, sizeof(char), 1, tempfile);
}
fclose(tempfile);
if (redisplaying)
close_buffer();
open_buffer(tempfilename, TRUE);
remove_magicline();
prepare_for_display();
/* Move to the position in the file where we were before. */
while (TRUE) {
sum += strlen(openfile->current->data);
if (sum > location)
break;
openfile->current = openfile->current->next;
}
openfile->edittop = openfile->current;
}
/* Our main help-viewer function. */
void do_help(void)
{
int kbinput = ERR;
functionptrtype func;
/* The function of the key the user typed in. */
int oldmenu = currmenu;
/* The menu we were called from. */
#ifdef ENABLE_LINENUMBERS
int was_margin = margin;
#endif
ssize_t was_tabsize = tabsize;
#ifdef ENABLE_COLOR
char *was_syntax = syntaxstr;
#endif
char *saved_answer = (answer != NULL) ? strdup(answer) : NULL;
/* The current answer when the user invokes help at the prompt. */
unsigned stash[sizeof(flags) / sizeof(flags[0])];
/* A storage place for the current flag settings. */
filestruct *line;
int length;
FILE *fp;
blank_statusbar();
/* Get a temporary file for the help text. If it fails, give up. */
tempfilename = safe_tempfile(&fp);
if (tempfilename == NULL) {
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
free(saved_answer);
return;
}
fclose(fp);
/* Save the settings of all flags. */
memcpy(stash, flags, sizeof(flags));
/* Ensure that the help screen's shortcut list can be displayed. */
if (ISSET(NO_HELP) && LINES > 4) {
UNSET(NO_HELP);
window_init();
}
/* When searching, do it forward, case insensitive, and without regexes. */
UNSET(BACKWARDS_SEARCH);
UNSET(CASE_SENSITIVE);
UNSET(USE_REGEXP);
UNSET(WHITESPACE_DISPLAY);
UNSET(NOREAD_MODE);
#ifdef ENABLE_LINENUMBERS
UNSET(LINE_NUMBERS);
editwincols = COLS;
margin = 0;
#endif
tabsize = 8;
#ifdef ENABLE_COLOR
syntaxstr = "nanohelp";
#endif
curs_set(0);
/* Compose the help text from all the pieces. */
help_init();
inhelp = TRUE;
location = 0;
didfind = 0;
bottombars(MHELP);
wnoutrefresh(bottomwin);
/* Extract the title from the head of the help text. */
length = break_line(help_text, MAX_BUF_SIZE, TRUE);
title = charalloc(length * sizeof(char) + 1);
strncpy(title, help_text, length);
title[length] = '\0';
titlebar(title);
/* Skip over the title to point at the start of the body text. */
start_of_body = help_text + length;
while (*start_of_body == '\n')
start_of_body++;
wrap_the_help_text(FALSE);
edit_refresh();
while (TRUE) {
lastmessage = HUSH;
focusing = TRUE;
/* Show the cursor when we searched and found something. */
kbinput = get_kbinput(edit, didfind == 1);
didfind = 0;
func = parse_help_input(&kbinput);
if (func == total_refresh) {
total_redraw();
} else if (func == do_up) {
do_scroll_up();
} else if (func == do_down) {
if (openfile->edittop->lineno + editwinrows - 1 <
openfile->filebot->lineno)
do_scroll_down();
} else if (func == do_page_up) {
do_page_up();
} else if (func == do_page_down) {
do_page_down();
} else if (func == to_first_line) {
to_first_line();
} else if (func == to_last_line) {
to_last_line();
} else if (func == do_search_forward) {
do_search();
bottombars(MHELP);
} else if (func == do_research) {
do_research();
#ifndef NANO_TINY
} else if (func == do_findprevious) {
do_findprevious();
} else if (func == do_findnext) {
do_findnext();
#ifdef ENABLE_NANORC
} else if (func == (functionptrtype)implant) {
implant(first_sc_for(MHELP, func)->expansion);
#endif
} else if (kbinput == KEY_WINCH) {
; /* Nothing to do. */
#endif
#ifdef ENABLE_MOUSE
} else if (kbinput == KEY_MOUSE) {
int dummy_row, dummy_col;
get_mouseinput(&dummy_row, &dummy_col, TRUE);
#endif
} else if (func == do_exit) {
/* Exit from the help viewer. */
close_buffer();
curs_set(0);
break;
} else
unbound_key(kbinput);
currmenu = MHELP;
edit_refresh();
location = 0;
line = openfile->fileage;
/* Count how far (in bytes) edittop is into the file. */
while (line != openfile->edittop) {
location += strlen(line->data);
line = line->next;
}
}
/* Restore the settings of all flags. */
memcpy(flags, stash, sizeof(flags));
#ifdef ENABLE_LINENUMBERS
margin = was_margin;
editwincols = COLS - margin;
#endif
tabsize = was_tabsize;
#ifdef ENABLE_COLOR
syntaxstr = was_syntax;
#endif
/* Switch back to the buffer we were invoked from. */
switch_to_prev_buffer();
if (ISSET(NO_HELP)) {
currmenu = oldmenu;
window_init();
} else
bottombars(oldmenu);
free(title);
title = NULL;
inhelp = FALSE;
#ifdef ENABLE_BROWSER
if (oldmenu == MBROWSER || oldmenu == MWHEREISFILE || oldmenu == MGOTODIR)
browser_refresh();
else
#endif
total_refresh();
free(answer);
answer = saved_answer;
remove(tempfilename);
free(tempfilename);
free(help_text);
}
/* Allocate space for the help text for the current menu, and concatenate
* the different pieces of text into it. */
/* Allocate space for the help text for the current menu,
* and concatenate the different pieces of text into it. */
void help_init(void)
{
size_t allocsize = 0;
@@ -298,9 +45,9 @@ void help_init(void)
const char *htx[3];
/* Untranslated help introduction. We break it up into three chunks
* in case the full string is too long for the compiler to handle. */
const funcstruct *f;
const keystruct *s;
char *ptr;
const subnfunc *f;
const sc *s;
/* First, set up the initial help text for the current function. */
if (currmenu == MWHEREIS || currmenu == MREPLACE || currmenu == MREPLACEWITH) {
@@ -410,15 +157,26 @@ void help_init(void)
}
#endif /* ENABLE_SPELLER */
#ifndef NANO_TINY
else if (currmenu == MEXTCMD) {
else if (currmenu == MEXECUTE) {
htx[0] = N_("Execute Command Help Text\n\n "
"This mode allows you to insert the output of a "
"command run by the shell into the current buffer (or "
"a new buffer in multiple file buffer mode). If you "
"need another blank buffer, do not enter any "
"command.\n\n The following function keys are "
"into a new buffer). If the command is preceded by '|' "
"(the pipe symbol), the current contents of the buffer "
"(or marked region) will be piped to the command. ");
htx[1] = N_("If you just need another blank buffer, do not enter any "
"command.\n\n You can also pick one of four tools, or cut a "
"large piece of the buffer, or put the editor to sleep.\n\n");
htx[2] = N_(" The following function keys are "
"available in Execute Command mode:\n\n");
htx[1] = NULL;
} else if (currmenu == MLINTER) {
htx[0] = N_("=== Linter ===\n\n "
"In this mode, the status bar shows an error message or "
"warning, and the cursor is put at the corresponding "
"position in the file. With PageUp and PageDown you "
"can switch to earlier and later messages.\n\n");
htx[1] = N_(" The following function keys are "
"available in Linter mode:\n\n");
htx[2] = NULL;
}
#endif /* !NANO_TINY */
@@ -461,23 +219,23 @@ void help_init(void)
if (htx[2] != NULL)
allocsize += strlen(htx[2]);
/* Calculate the length of the shortcut help text. Each entry has
* one or two keys, which fill 16 columns, plus translated text,
* plus one or two \n's. */
/* Calculate the length of the descriptions of the shortcuts.
* Each entry has one or two keystrokes, which fill 17 cells,
* plus translated text, plus one or two \n's. */
for (f = allfuncs; f != NULL; f = f->next)
if (f->menus & currmenu)
allocsize += (16 * MAXCHARLEN) + strlen(_(f->help)) + 2;
allocsize += strlen(_(f->help)) + 21;
#ifndef NANO_TINY
/* If we're on the main list, we also count the toggle help text.
* Each entry has "M-%c\t\t", five chars which fill 16 columns,
* plus a space, plus translated text, plus one or two '\n's. */
* Each entry has "M-%c\t\t ", six chars which fill 17 cells, plus
* two translated texts, plus a space, plus one or two '\n's. */
if (currmenu == MMAIN) {
size_t endis_len = strlen(_("enable/disable"));
size_t onoff_len = strlen(_("enable/disable"));
for (s = sclist; s != NULL; s = s->next)
if (s->func == do_toggle_void)
allocsize += strlen(_(flagtostr(s->toggle))) + endis_len + 8;
allocsize += strlen(_(flagtostr(s->toggle))) + onoff_len + 9;
}
#endif
@@ -491,48 +249,39 @@ void help_init(void)
if (htx[2] != NULL)
strcat(help_text, htx[2]);
ptr = help_text + strlen(help_text);
/* Remember this end-of-introduction, start-of-shortcuts. */
end_of_intro = ptr;
end_of_intro = help_text + strlen(help_text);
ptr = end_of_intro;
/* Now add our shortcut info. */
/* Now add the shortcuts and their descriptions. */
for (f = allfuncs; f != NULL; f = f->next) {
int scsfound = 0;
int tally = 0;
if ((f->menus & currmenu) == 0)
continue;
/* Let's simply show the first two shortcuts from the list. */
/* Show the first two shortcuts (if any) for each function. */
for (s = sclist; s != NULL; s = s->next) {
if ((s->menus & currmenu) == 0)
continue;
if (s->func == f->func) {
scsfound++;
/* Make the first column narrower (6) than the second (10),
* but allow it to spill into the second, for "M-Space". */
if (scsfound == 1) {
sprintf(ptr, "%s ", s->keystr);
if ((s->menus & currmenu) && s->func == f->func && s->keystr[0]) {
/* Make the first column 7 cells wide and the second 10. */
if (++tally == 1) {
sprintf(ptr, "%s ", s->keystr);
/* Unicode arrows take three bytes instead of one. */
if (strstr(s->keystr, "\xE2") != NULL)
ptr += 8;
else
ptr += 6;
ptr += (strstr(s->keystr, "\xE2") != NULL ? 9 : 7);
} else {
ptr += sprintf(ptr, "(%s)\t", s->keystr);
sprintf(ptr, "(%s) ", s->keystr);
ptr += (strstr(s->keystr, "\xE2") != NULL ? 12 : 10);
break;
}
}
}
if (scsfound == 0)
ptr += sprintf(ptr, "\t\t");
else if (scsfound == 1)
if (tally == 0)
ptr += sprintf(ptr, "\t\t ");
else if (tally == 1)
ptr += 10;
/* The shortcut's help text. */
/* The shortcut's description. */
ptr += sprintf(ptr, "%s\n", _(f->help));
if (f->blank_after)
@@ -553,88 +302,271 @@ void help_init(void)
counter++;
for (s = sclist; s != NULL; s = s->next)
if (s->toggle && s->ordinal == counter) {
ptr += sprintf(ptr, "%s\t\t%s %s\n", (s->menus == MMAIN ? s->keystr : ""),
ptr += sprintf(ptr, "%s\t\t %s %s\n", (s->menus & MMAIN ? s->keystr : ""),
_(flagtostr(s->toggle)), _("enable/disable"));
if (s->toggle == NO_COLOR_SYNTAX || s->toggle == TABS_TO_SPACES)
if (s->toggle == NO_SYNTAX || s->toggle == TABS_TO_SPACES)
ptr += sprintf(ptr, "\n");
break;
}
}
}
#endif /* !NANO_TINY */
if (strlen(help_text) > allocsize)
statusline(ALERT, "Help text spilled over -- please report a bug");
}
/* Return the function that is bound to the given key, accepting certain
* plain characters too, for consistency with the file browser. */
functionptrtype parse_help_input(int *kbinput)
/* Hard-wrap the concatenated help text, and write it into a new buffer. */
void wrap_help_text_into_buffer(void)
{
if (!meta_key) {
switch (*kbinput) {
case ' ':
return do_page_down;
case '-':
return do_page_up;
case 'W':
case 'w':
case '/':
return do_search_forward;
case 'N':
#ifndef NANO_TINY
return do_findprevious;
size_t sum = 0;
/* Avoid overtight and overwide paragraphs in the introductory text. */
size_t wrapping_point = ((COLS < 40) ? 40 : (COLS > 74) ? 74 : COLS) - thebar;
const char *ptr = start_of_body;
make_new_buffer();
/* Copy the help text into the just-created new buffer. */
while (*ptr != '\0') {
int length, shim;
char *oneline;
if (ptr == end_of_intro)
wrapping_point = ((COLS < 40) ? 40 : COLS) - thebar;
if (ptr < end_of_intro || *(ptr - 1) == '\n') {
length = break_line(ptr, wrapping_point, TRUE);
oneline = nmalloc(length + 1);
shim = (*(ptr + length - 1) == ' ') ? 0 : 1;
snprintf(oneline, length + shim, "%s", ptr);
} else {
length = break_line(ptr, ((COLS < 40) ? 22 : COLS - 18) - thebar, TRUE);
oneline = nmalloc(length + 5);
snprintf(oneline, length + 5, "\t\t %s", ptr);
}
free(openfile->current->data);
openfile->current->data = oneline;
ptr += length;
if (*ptr != '\n')
ptr--;
/* Create a new line, and then one more for each extra \n. */
do {
openfile->current->next = make_new_node(openfile->current);
openfile->current = openfile->current->next;
openfile->current->data = copy_of("");
} while (*(++ptr) == '\n');
}
openfile->filebot = openfile->current;
openfile->current = openfile->filetop;
remove_magicline();
#ifdef ENABLE_COLOR
find_and_prime_applicable_syntax();
#endif
case 'n':
return do_research;
case 'E':
case 'e':
case 'Q':
case 'q':
case 'X':
case 'x':
return do_exit;
prepare_for_display();
/* Move to the position in the file where we were before. */
while (TRUE) {
sum += strlen(openfile->current->data);
if (sum > location)
break;
openfile->current = openfile->current->next;
}
openfile->edittop = openfile->current;
}
/* Assemble a help text, display it, and allow scrolling through it. */
void show_help(void)
{
int kbinput = ERR;
functionptrtype func;
/* The function of the key the user typed in. */
int oldmenu = currmenu;
/* The menu we were called from. */
#ifdef ENABLE_LINENUMBERS
int was_margin = margin;
#endif
ssize_t was_tabsize = tabsize;
#ifdef ENABLE_COLOR
char *was_syntax = syntaxstr;
#endif
char *saved_answer = (answer != NULL) ? copy_of(answer) : NULL;
/* The current answer when the user invokes help at the prompt. */
unsigned stash[sizeof(flags) / sizeof(flags[0])];
/* A storage place for the current flag settings. */
linestruct *line;
int length;
/* Save the settings of all flags. */
memcpy(stash, flags, sizeof(flags));
/* Ensure that the help screen's shortcut list can be displayed. */
if (ISSET(NO_HELP) && LINES > 4) {
UNSET(NO_HELP);
window_init();
} else
blank_statusbar();
/* When searching, do it forward, case insensitive, and without regexes. */
UNSET(BACKWARDS_SEARCH);
UNSET(CASE_SENSITIVE);
UNSET(USE_REGEXP);
UNSET(WHITESPACE_DISPLAY);
UNSET(NOREAD_MODE);
#ifdef ENABLE_LINENUMBERS
UNSET(LINE_NUMBERS);
editwincols = COLS - thebar;
margin = 0;
#endif
tabsize = 8;
#ifdef ENABLE_COLOR
syntaxstr = "nanohelp";
#endif
curs_set(0);
/* Compose the help text from all the relevant pieces. */
help_init();
inhelp = TRUE;
location = 0;
didfind = 0;
bottombars(MHELP);
/* Extract the title from the head of the help text. */
length = break_line(help_text, HIGHEST_POSITIVE, TRUE);
title = measured_copy(help_text, length);
titlebar(title);
/* Skip over the title to point at the start of the body text. */
start_of_body = help_text + length;
while (*start_of_body == '\n')
start_of_body++;
wrap_help_text_into_buffer();
edit_refresh();
while (TRUE) {
lastmessage = VACUUM;
focusing = TRUE;
/* Show the cursor when we searched and found something. */
kbinput = get_kbinput(edit, didfind == 1 || ISSET(SHOW_CURSOR));
didfind = 0;
#ifndef NANO_TINY
if (bracketed_paste || kbinput == BRACKETED_PASTE_MARKER) {
beep();
continue;
}
#endif
func = interpret(&kbinput);
if (func == full_refresh) {
full_refresh();
} else if (ISSET(SHOW_CURSOR) && (func == do_left || func == do_right ||
func == do_up || func == do_down)) {
func();
} else if (func == do_up || func == do_scroll_up) {
do_scroll_up();
} else if (func == do_down || func == do_scroll_down) {
if (openfile->edittop->lineno + editwinrows - 1 <
openfile->filebot->lineno)
do_scroll_down();
} else if (func == do_page_up || func == do_page_down ||
func == to_first_line || func == to_last_line ||
func == do_findprevious || func == do_findnext) {
func();
} else if (func == do_search_forward || func == do_search_backward) {
func();
bottombars(MHELP);
#ifdef ENABLE_NANORC
} else if (func == (functionptrtype)implant) {
implant(first_sc_for(MHELP, func)->expansion);
#endif
#ifdef ENABLE_MOUSE
} else if (kbinput == KEY_MOUSE) {
int dummy_row, dummy_col;
get_mouseinput(&dummy_row, &dummy_col, TRUE);
#endif
#ifndef NANO_TINY
} else if (kbinput == KEY_WINCH) {
; /* Nothing to do. */
#endif
} else if (func == do_exit) {
break;
} else
unbound_key(kbinput);
currmenu = MHELP;
edit_refresh();
location = 0;
line = openfile->filetop;
/* Count how far (in bytes) edittop is into the file. */
while (line != openfile->edittop) {
location += strlen(line->data);
line = line->next;
}
}
return func_from_key(kbinput);
}
/* Calculate the displayable length of the help-text line starting at ptr. */
size_t help_line_len(const char *ptr)
{
size_t wrapping_point = (COLS > 24) ? COLS - 1 : 24;
/* The target width for wrapping long lines. */
ssize_t wrap_location;
/* Actual position where the line can be wrapped. */
size_t length = 0;
/* Full length of the line, until the first newline. */
/* Discard the help-text buffer. */
close_buffer();
/* Avoid overwide paragraphs in the introductory text. */
if (ptr < end_of_intro && COLS > 74)
wrapping_point = 74;
/* Restore the settings of all flags. */
memcpy(flags, stash, sizeof(flags));
wrap_location = break_line(ptr, wrapping_point, TRUE);
#ifdef ENABLE_LINENUMBERS
margin = was_margin;
editwincols = COLS - margin - thebar;
#endif
tabsize = was_tabsize;
#ifdef ENABLE_COLOR
syntaxstr = was_syntax;
have_palette = FALSE;
#endif
/* Get the length of the entire line up to a null or a newline. */
while (*(ptr + length) != '\0' && *(ptr + length) != '\n')
length = move_mbright(ptr, length);
free(title);
title = NULL;
free(answer);
answer = saved_answer;
free(help_text);
inhelp = FALSE;
/* If the entire line will just fit the screen, don't wrap it. */
if (strnlenpt(ptr, length) <= wrapping_point + 1)
return length;
else if (wrap_location > 0)
return wrap_location;
curs_set(0);
if (ISSET(NO_HELP)) {
currmenu = oldmenu;
window_init();
} else {
blank_statusbar();
bottombars(oldmenu);
}
#ifdef ENABLE_BROWSER
if (oldmenu == MBROWSER || oldmenu == MWHEREISFILE || oldmenu == MGOTODIR)
browser_refresh();
else
return 1;
#endif
{
titlebar(NULL);
edit_refresh();
}
}
#endif /* ENABLE_HELP */
/* Start the help viewer. */
void do_help_void(void)
/* Start the help viewer, or indicate that there is no help. */
void do_help(void)
{
#ifdef ENABLE_HELP
do_help();
show_help();
#else
if (currmenu == MMAIN)
say_there_is_no_help();

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* history.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2003-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2016-2017 Benno Schulenberg *
* Copyright (C) 2003-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2016, 2017, 2019 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -19,50 +19,52 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#ifdef ENABLE_HISTORIES
#include <errno.h>
#include <string.h>
#ifdef ENABLE_HISTORIES
#ifndef SEARCH_HISTORY
#define SEARCH_HISTORY "search_history"
#define SEARCH_HISTORY "search_history"
#endif
#ifndef POSITION_HISTORY
#define POSITION_HISTORY "filepos_history"
#define POSITION_HISTORY "filepos_history"
#endif
static bool history_changed = FALSE;
/* Whether any of the history lists has changed. */
static struct stat stat_of_positions_file;
/* The last-obtained stat information of the positions file. */
static char *poshistname = NULL;
/* The name of the positions-history file. */
static time_t latest_timestamp = 942927132;
/* The last time the positions-history file was written. */
static poshiststruct *position_history = NULL;
/* The list of filenames with their last cursor positions. */
/* Initialize the lists of historical search and replace strings
* and the list of historical executed commands. */
void history_init(void)
{
search_history = make_new_node(NULL);
search_history->data = mallocstrcpy(NULL, "");
search_history->data = copy_of("");
searchtop = search_history;
searchbot = search_history;
replace_history = make_new_node(NULL);
replace_history->data = mallocstrcpy(NULL, "");
replace_history->data = copy_of("");
replacetop = replace_history;
replacebot = replace_history;
execute_history = make_new_node(NULL);
execute_history->data = mallocstrcpy(NULL, "");
execute_history->data = copy_of("");
executetop = execute_history;
executebot = execute_history;
}
/* Set the current position in the given history list to the bottom. */
void history_reset(const filestruct *list)
void history_reset(const linestruct *list)
{
if (list == search_history)
search_history = searchbot;
@@ -75,14 +77,14 @@ void history_reset(const filestruct *list)
/* Return from the history list that starts at start and ends at end
* the first node that contains the first len characters of the given
* text, or NULL if there is no such node. */
filestruct *find_history(const filestruct *start, const filestruct *end,
linestruct *find_history(const linestruct *start, const linestruct *end,
const char *text, size_t len)
{
const filestruct *item;
const linestruct *item;
for (item = start; item != end->prev && item != NULL; item = item->prev) {
if (strncmp(item->data, text, len) == 0)
return (filestruct *)item;
return (linestruct *)item;
}
return NULL;
@@ -90,9 +92,9 @@ filestruct *find_history(const filestruct *start, const filestruct *end,
/* Update a history list (the one in which item is the current position)
* with a fresh string text. That is: add text, or move it to the end. */
void update_history(filestruct **item, const char *text)
void update_history(linestruct **item, const char *text)
{
filestruct **htop = NULL, **hbot = NULL, *thesame;
linestruct **htop = NULL, **hbot = NULL, *thesame;
if (*item == search_history) {
htop = &searchtop;
@@ -110,31 +112,31 @@ void update_history(filestruct **item, const char *text)
/* If an identical string was found, delete that item. */
if (thesame != NULL) {
filestruct *after = thesame->next;
linestruct *after = thesame->next;
/* If the string is at the head of the list, move the head. */
if (thesame == *htop)
*htop = after;
unlink_node(thesame);
renumber(after);
renumber_from(after);
}
/* If the history is full, delete the oldest item (the one at the
* head of the list), to make room for a new item at the end. */
if ((*hbot)->lineno == MAX_SEARCH_HISTORY + 1) {
filestruct *oldest = *htop;
linestruct *oldest = *htop;
*htop = (*htop)->next;
unlink_node(oldest);
renumber(*htop);
renumber_from(*htop);
}
/* Store the fresh string in the last item, then create a new item. */
(*hbot)->data = mallocstrcpy((*hbot)->data, text);
splice_node(*hbot, make_new_node(*hbot));
*hbot = (*hbot)->next;
(*hbot)->data = mallocstrcpy(NULL, "");
(*hbot)->data = copy_of("");
/* Indicate that the history needs to be saved on exit. */
history_changed = TRUE;
@@ -145,7 +147,7 @@ void update_history(filestruct **item, const char *text)
/* Move h to the string in the history list just before it, and return
* that string. If there isn't one, don't move h and return NULL. */
char *get_history_older(filestruct **h)
char *get_history_older(linestruct **h)
{
if ((*h)->prev == NULL)
return NULL;
@@ -157,7 +159,7 @@ char *get_history_older(filestruct **h)
/* Move h to the string in the history list just after it, and return
* that string. If there isn't one, don't move h and return NULL. */
char *get_history_newer(filestruct **h)
char *get_history_newer(linestruct **h)
{
if ((*h)->next == NULL)
return NULL;
@@ -167,80 +169,61 @@ char *get_history_newer(filestruct **h)
return (*h)->data;
}
/* More placeholders. */
void get_history_newer_void(void)
{
;
}
/* Two empty placeholder functions. */
void get_history_older_void(void)
{
;
}
void get_history_newer_void(void)
{
}
#ifdef ENABLE_TABCOMP
/* Move h to the next string that's a tab completion of the string s,
* looking at only the first len characters of s, and return that
* string. If there isn't one, or if len is 0, don't move h and return
* s. */
char *get_history_completion(filestruct **h, char *s, size_t len)
/* Go backward through one of three history lists, starting at its item h,
* searching for a string that is a tab completion of the given string s,
* looking at only the first len characters of s. When found, make h point
* at it and return that string; otherwise, don't move h and return s. */
char *get_history_completion(linestruct **h, char *s, size_t len)
{
if (len > 0) {
filestruct *htop = NULL, *hbot = NULL, *p;
linestruct *htop = NULL, *hbot = NULL, *p;
if (*h == search_history) {
htop = searchtop;
hbot = searchbot;
} else if (*h == replace_history) {
htop = replacetop;
hbot = replacebot;
} else if (*h == execute_history) {
htop = executetop;
hbot = executebot;
}
/* Search the history list from the current position to the top
* for a match of len characters. Skip over an exact match. */
p = find_history((*h)->prev, htop, s, len);
while (p != NULL && strcmp(p->data, s) == 0)
p = find_history(p->prev, htop, s, len);
if (p != NULL) {
*h = p;
return mallocstrcpy(s, (*h)->data);
}
/* Search the history list from the bottom to the current position
* for a match of len characters. Skip over an exact match. */
p = find_history(hbot, *h, s, len);
while (p != NULL && strcmp(p->data, s) == 0)
p = find_history(p->prev, *h, s, len);
if (p != NULL) {
*h = p;
return mallocstrcpy(s, (*h)->data);
}
if (*h == search_history) {
htop = searchtop;
hbot = searchbot;
} else if (*h == replace_history) {
htop = replacetop;
hbot = replacebot;
} else if (*h == execute_history) {
htop = executetop;
hbot = executebot;
}
/* If we're here, we didn't find a match, we didn't find an inexact
* match, or len is 0. Return s. */
/* First search from the current position to the top of the list
* for a match of len characters. Skip over an exact match. */
p = find_history((*h)->prev, htop, s, len);
while (p != NULL && strcmp(p->data, s) == 0)
p = find_history(p->prev, htop, s, len);
if (p != NULL) {
*h = p;
return mallocstrcpy(s, (*h)->data);
}
/* Now search from the bottom of the list to the original position. */
p = find_history(hbot, *h, s, len);
while (p != NULL && strcmp(p->data, s) == 0)
p = find_history(p->prev, *h, s, len);
if (p != NULL) {
*h = p;
return mallocstrcpy(s, (*h)->data);
}
/* When no useful match was found, simply return the given string. */
return (char *)s;
}
#endif /* ENSABLE_TABCOMP */
void history_error(const char *msg, ...)
{
va_list ap;
va_start(ap, msg);
vfprintf(stderr, _(msg), ap);
va_end(ap);
fprintf(stderr, _("\nPress Enter to continue\n"));
while (getchar() != '\n')
;
}
#endif /* ENABLE_TABCOMP */
/* Check whether we have or could make a directory for history files. */
bool have_statedir(void)
@@ -280,14 +263,14 @@ bool have_statedir(void)
free(statepath);
}
if (mkdir(statedir, S_IRWXU) == -1) {
history_error(N_("Unable to create directory %s: %s\n"
jot_error(N_("Unable to create directory %s: %s\n"
"It is required for saving/loading "
"search history or cursor positions.\n"),
statedir, strerror(errno));
return FALSE;
}
} else if (!S_ISDIR(dirstat.st_mode)) {
history_error(N_("Path %s is not a directory and needs to be.\n"
jot_error(N_("Path %s is not a directory and needs to be.\n"
"Nano will be unable to load or save "
"search history or cursor positions.\n"),
statedir);
@@ -298,237 +281,248 @@ bool have_statedir(void)
return TRUE;
}
/* Load the histories for Search and Replace and Execute Command. */
/* Load the histories for Search, Replace With, and Execute Command. */
void load_history(void)
{
char *histname = concatenate(statedir, SEARCH_HISTORY);
FILE *hisfile = fopen(histname, "rb");
FILE *histfile = fopen(histname, "rb");
if (hisfile == NULL) {
if (errno != ENOENT) {
/* When reading failed, don't save history when we quit. */
UNSET(HISTORYLOG);
history_error(N_("Error reading %s: %s"), histname,
strerror(errno));
}
} else {
/* Load the three history lists -- first search, then replace,
* then execute -- from oldest entry to newest. Between two
* lists there is an empty line. */
filestruct **history = &search_history;
char *line = NULL;
size_t buf_len = 0;
ssize_t read;
while ((read = getline(&line, &buf_len, hisfile)) > 0) {
line[--read] = '\0';
if (read > 0) {
/* Encode any embedded NUL as 0x0A. */
unsunder(line, read);
update_history(history, line);
} else if (history == &search_history)
history = &replace_history;
else
history = &execute_history;
}
fclose(hisfile);
free(line);
/* If reading an existing file failed, don't save history when we quit. */
if (histfile == NULL && errno != ENOENT) {
jot_error(N_("Error reading %s: %s"), histname, strerror(errno));
UNSET(HISTORYLOG);
}
/* After reading them in, set the status of the lists to "unchanged". */
history_changed = FALSE;
if (histfile == NULL) {
free(histname);
return;
}
linestruct **history = &search_history;
char *line = NULL;
size_t buf_len = 0;
ssize_t read;
/* Load the three history lists (first search, then replace, then execute)
* from oldest entry to newest. Between two lists there is an empty line. */
while ((read = getline(&line, &buf_len, histfile)) > 0) {
line[--read] = '\0';
if (read > 0) {
recode_NUL_to_LF(line, read);
update_history(history, line);
} else if (history == &search_history)
history = &replace_history;
else
history = &execute_history;
}
if (fclose(histfile) == EOF)
jot_error(N_("Error reading %s: %s"), histname, strerror(errno));
free(histname);
free(line);
/* Reading in the lists has marked them as changed; undo this side effect. */
history_changed = FALSE;
}
/* Write the lines of a history list, starting at head, from oldest to newest,
* to the given file. Return TRUE if writing succeeded, and FALSE otherwise. */
bool write_list(const filestruct *head, FILE *hisfile)
bool write_list(const linestruct *head, FILE *histfile)
{
const filestruct *item;
const linestruct *item;
for (item = head; item != NULL; item = item->next) {
size_t length = strlen(item->data);
/* Decode 0x0A bytes as embedded NULs. */
sunder(item->data);
recode_LF_to_NUL(item->data);
if (fwrite(item->data, sizeof(char), length, hisfile) < length)
if (fwrite(item->data, sizeof(char), length, histfile) < length)
return FALSE;
if (putc('\n', hisfile) == EOF)
if (putc('\n', histfile) == EOF)
return FALSE;
}
return TRUE;
}
/* Save the histories for Search and Replace and Execute Command. */
/* Save the histories for Search, Replace With, and Execute Command. */
void save_history(void)
{
char *histname;
FILE *hisfile;
FILE *histfile;
/* If the histories are unchanged, don't bother saving them. */
if (!history_changed)
return;
histname = concatenate(statedir, SEARCH_HISTORY);
hisfile = fopen(histname, "wb");
histfile = fopen(histname, "wb");
if (hisfile == NULL)
fprintf(stderr, _("Error writing %s: %s\n"), histname,
strerror(errno));
else {
/* Don't allow others to read or write the history file. */
chmod(histname, S_IRUSR | S_IWUSR);
if (!write_list(searchtop, hisfile) ||
!write_list(replacetop, hisfile) ||
!write_list(executetop, hisfile))
fprintf(stderr, _("Error writing %s: %s\n"), histname,
strerror(errno));
fclose(hisfile);
if (histfile == NULL) {
jot_error(N_("Error writing %s: %s\n"), histname, strerror(errno));
free(histname);
return;
}
/* Don't allow others to read or write the history file. */
chmod(histname, S_IRUSR | S_IWUSR);
if (!write_list(searchtop, histfile) || !write_list(replacetop, histfile) ||
!write_list(executetop, histfile))
jot_error(N_("Error writing %s: %s\n"), histname, strerror(errno));
if (fclose(histfile) == EOF)
jot_error(N_("Error writing %s: %s\n"), histname, strerror(errno));
free(histname);
}
/* Load the recorded cursor positions for files that were edited. */
void load_poshistory(void)
{
FILE *hisfile = fopen(poshistname, "rb");
FILE *histfile = fopen(poshistname, "rb");
if (hisfile == NULL) {
if (errno != ENOENT) {
/* When reading failed, don't save history when we quit. */
UNSET(POS_HISTORY);
history_error(N_("Error reading %s: %s"), poshistname, strerror(errno));
}
} else {
char *line = NULL, *lineptr, *xptr;
size_t buf_len = 0;
ssize_t read, count = 0;
poshiststruct *record_ptr = NULL, *newrecord;
/* Read and parse each line, and store the extracted data. */
while ((read = getline(&line, &buf_len, hisfile)) > 5) {
/* Decode nulls as embedded newlines. */
unsunder(line, read);
/* Find where the x index and line number are in the line. */
xptr = revstrstr(line, " ", line + read - 3);
if (xptr == NULL)
continue;
lineptr = revstrstr(line, " ", xptr - 2);
if (lineptr == NULL)
continue;
/* Now separate the three elements of the line. */
*(xptr++) = '\0';
*(lineptr++) = '\0';
/* Create a new position record. */
newrecord = (poshiststruct *)nmalloc(sizeof(poshiststruct));
newrecord->filename = mallocstrcpy(NULL, line);
newrecord->lineno = atoi(lineptr);
newrecord->xno = atoi(xptr);
newrecord->next = NULL;
/* Add the record to the list. */
if (position_history == NULL)
position_history = newrecord;
else
record_ptr->next = newrecord;
record_ptr = newrecord;
/* Impose a limit, so the file will not grow indefinitely. */
if (++count > 200) {
poshiststruct *drop_record = position_history;
position_history = position_history->next;
free(drop_record->filename);
free(drop_record);
}
}
fclose(hisfile);
free(line);
stat(poshistname, &stat_of_positions_file);
/* If reading an existing file failed, don't save history when we quit. */
if (histfile == NULL && errno != ENOENT) {
jot_error(N_("Error reading %s: %s"), poshistname, strerror(errno));
UNSET(POSITIONLOG);
}
if (histfile == NULL)
return;
char *line = NULL, *lineptr, *xptr;
size_t buf_len = 0;
ssize_t read, count = 0;
struct stat fileinfo;
poshiststruct *record_ptr = NULL, *newrecord;
/* Read and parse each line, and store the extracted data. */
while ((read = getline(&line, &buf_len, histfile)) > 5) {
/* Decode NULs as embedded newlines. */
recode_NUL_to_LF(line, read);
/* Find where the x index and line number are in the line. */
xptr = revstrstr(line, " ", line + read - 3);
if (xptr == NULL)
continue;
lineptr = revstrstr(line, " ", xptr - 2);
if (lineptr == NULL)
continue;
/* Now separate the three elements of the line. */
*(xptr++) = '\0';
*(lineptr++) = '\0';
/* Create a new position record. */
newrecord = (poshiststruct *)nmalloc(sizeof(poshiststruct));
newrecord->filename = copy_of(line);
newrecord->lineno = atoi(lineptr);
newrecord->xno = atoi(xptr);
newrecord->next = NULL;
/* Add the record to the list. */
if (position_history == NULL)
position_history = newrecord;
else
record_ptr->next = newrecord;
record_ptr = newrecord;
/* Impose a limit, so the file will not grow indefinitely. */
if (++count > 200) {
poshiststruct *drop_record = position_history;
position_history = position_history->next;
free(drop_record->filename);
free(drop_record);
}
}
if (fclose(histfile) == EOF)
jot_error(N_("Error reading %s: %s"), poshistname, strerror(errno));
free(line);
if (stat(poshistname, &fileinfo) == 0)
latest_timestamp = fileinfo.st_mtime;
}
/* Save the recorded cursor positions for files that were edited. */
void save_poshistory(void)
{
poshiststruct *posptr;
FILE *hisfile = fopen(poshistname, "wb");
struct stat fileinfo;
FILE *histfile = fopen(poshistname, "wb");
if (hisfile == NULL)
fprintf(stderr, _("Error writing %s: %s\n"), poshistname, strerror(errno));
else {
/* Don't allow others to read or write the history file. */
chmod(poshistname, S_IRUSR | S_IWUSR);
for (posptr = position_history; posptr != NULL; posptr = posptr->next) {
char *path_and_place;
size_t length;
/* Assume 20 decimal positions each for line and column number,
* plus two spaces, plus the line feed, plus the null byte. */
path_and_place = charalloc(strlen(posptr->filename) + 44);
sprintf(path_and_place, "%s %zd %zd\n",
posptr->filename, posptr->lineno, posptr->xno);
length = strlen(path_and_place);
/* Encode newlines in filenames as nulls. */
sunder(path_and_place);
/* Restore the terminating newline. */
path_and_place[length - 1] = '\n';
if (fwrite(path_and_place, sizeof(char), length, hisfile) < length)
fprintf(stderr, _("Error writing %s: %s\n"),
poshistname, strerror(errno));
free(path_and_place);
}
fclose(hisfile);
stat(poshistname, &stat_of_positions_file);
if (histfile == NULL) {
jot_error(N_("Error writing %s: %s\n"), poshistname, strerror(errno));
return;
}
/* Don't allow others to read or write the history file. */
chmod(poshistname, S_IRUSR | S_IWUSR);
for (posptr = position_history; posptr != NULL; posptr = posptr->next) {
char *path_and_place;
size_t length;
/* Assume 20 decimal positions each for line and column number,
* plus two spaces, plus the line feed, plus the null byte. */
path_and_place = charalloc(strlen(posptr->filename) + 44);
sprintf(path_and_place, "%s %zd %zd\n",
posptr->filename, posptr->lineno, posptr->xno);
length = strlen(path_and_place);
/* Encode newlines in filenames as NULs. */
recode_LF_to_NUL(path_and_place);
/* Restore the terminating newline. */
path_and_place[length - 1] = '\n';
if (fwrite(path_and_place, sizeof(char), length, histfile) < length)
jot_error(N_("Error writing %s: %s\n"), poshistname, strerror(errno));
free(path_and_place);
}
if (fclose(histfile) == EOF)
jot_error(N_("Error writing %s: %s\n"), poshistname, strerror(errno));
if (stat(poshistname, &fileinfo) == 0)
latest_timestamp = fileinfo.st_mtime;
}
/* Reload the position history file if it has been modified since last load. */
void reload_positions_if_needed(void)
{
struct stat newstat;
struct stat fileinfo;
stat(poshistname, &newstat);
if (stat(poshistname, &fileinfo) == 0 && fileinfo.st_mtime != latest_timestamp) {
poshiststruct *item, *nextone;
if (newstat.st_mtime != stat_of_positions_file.st_mtime) {
poshiststruct *ptr, *nextone;
for (ptr = position_history; ptr != NULL; ptr = nextone) {
nextone = ptr->next;
free(ptr->filename);
free(ptr);
for (item = position_history; item != NULL; item = nextone) {
nextone = item->next;
free(item->filename);
free(item);
}
position_history = NULL;
load_poshistory();
}
}
/* Update the recorded last file positions, given a filename, a line
* and a column. If no entry is found, add a new one at the end. */
void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
/* Update the recorded last file positions with the current position in the
* current buffer. If no existing entry is found, add a new one at the end. */
void update_poshistory(void)
{
poshiststruct *posptr, *theone, *posprev = NULL;
char *fullpath = get_full_path(filename);
char *fullpath = get_full_path(openfile->filename);
if (fullpath == NULL || fullpath[strlen(fullpath) - 1] == '/' || inhelp) {
if (fullpath == NULL || openfile->filename[0] == '\0') {
free(fullpath);
return;
}
@@ -543,7 +537,7 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
}
/* Don't record files that have the default cursor position. */
if (lineno == 1 && xpos == 1) {
if (openfile->current->lineno == 1 && openfile->current_x == 0) {
if (posptr != NULL) {
if (posprev == NULL)
position_history = posptr->next;
@@ -563,7 +557,7 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
* not at the end, move the matching one to the end. */
if (theone == NULL) {
theone = (poshiststruct *)nmalloc(sizeof(poshiststruct));
theone->filename = mallocstrcpy(NULL, fullpath);
theone->filename = copy_of(fullpath);
if (position_history == NULL)
position_history = theone;
else
@@ -579,8 +573,8 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
}
/* Store the last cursor position. */
theone->lineno = lineno;
theone->xno = xpos;
theone->lineno = openfile->current->lineno;
theone->xno = xplustabs() + 1;
theone->next = NULL;
free(fullpath);
@@ -593,7 +587,7 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
* set line and column to the retrieved values. */
bool has_old_position(const char *file, ssize_t *line, ssize_t *column)
{
poshiststruct *posptr = position_history;
poshiststruct *posptr;
char *fullpath = get_full_path(file);
if (fullpath == NULL)
@@ -601,6 +595,7 @@ bool has_old_position(const char *file, ssize_t *line, ssize_t *column)
reload_positions_if_needed();
posptr = position_history;
while (posptr != NULL && strcmp(posptr->filename, fullpath) != 0)
posptr = posptr->next;

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* move.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017 Benno Schulenberg *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2014-2018 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -19,14 +19,14 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#include <string.h>
/* Move to the first line of the file. */
void to_first_line(void)
{
openfile->current = openfile->fileage;
openfile->current = openfile->filetop;
openfile->current_x = 0;
openfile->placewewant = 0;
@@ -37,7 +37,7 @@ void to_first_line(void)
void to_last_line(void)
{
openfile->current = openfile->filebot;
openfile->current_x = strlen(openfile->filebot->data);
openfile->current_x = (inhelp) ? 0 : strlen(openfile->filebot->data);
openfile->placewewant = xplustabs();
/* Set the last line of the screen as the target for the cursor. */
@@ -68,14 +68,14 @@ void get_edge_and_target(size_t *leftedge, size_t *target_column)
* chunk that starts at the given leftedge. If the target column has landed
* on a tab, prevent the cursor from falling back a row when moving forward,
* or from skipping a row when moving backward, by incrementing the index. */
size_t proper_x(filestruct *line, size_t *leftedge, bool forward,
size_t proper_x(linestruct *line, size_t *leftedge, bool forward,
size_t column, bool *shifted)
{
size_t index = actual_x(line->data, column);
#ifndef NANO_TINY
if (ISSET(SOFTWRAP) && line->data[index] == '\t' &&
((forward && strnlenpt(line->data, index) < *leftedge) ||
((forward && wideness(line->data, index) < *leftedge) ||
(!forward && column / tabsize == (*leftedge - 1) / tabsize &&
column / tabsize < (*leftedge + editwincols - 1) / tabsize))) {
index++;
@@ -85,7 +85,7 @@ size_t proper_x(filestruct *line, size_t *leftedge, bool forward,
}
if (ISSET(SOFTWRAP))
*leftedge = leftedge_for(strnlenpt(line->data, index), line);
*leftedge = leftedge_for(wideness(line->data, index), line);
#endif
return index;
@@ -109,7 +109,7 @@ void set_proper_index_and_pww(size_t *leftedge, size_t target, bool forward)
openfile->placewewant = *leftedge + target;
}
/* Move up nearly one screenful. */
/* Move up almost one screenful. */
void do_page_up(void)
{
int mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
@@ -117,7 +117,7 @@ void do_page_up(void)
/* If we're not in smooth scrolling mode, put the cursor at the
* beginning of the top line of the edit window, as Pico does. */
if (!ISSET(SMOOTH_SCROLL)) {
if (ISSET(JUMPY_SCROLLING)) {
openfile->current = openfile->edittop;
leftedge = openfile->firstcolumn;
openfile->current_y = 0;
@@ -139,7 +139,7 @@ void do_page_up(void)
refresh_needed = TRUE;
}
/* Move down nearly one screenful. */
/* Move down almost one screenful. */
void do_page_down(void)
{
int mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
@@ -147,7 +147,7 @@ void do_page_down(void)
/* If we're not in smooth scrolling mode, put the cursor at the
* beginning of the top line of the edit window, as Pico does. */
if (!ISSET(SMOOTH_SCROLL)) {
if (ISSET(JUMPY_SCROLLING)) {
openfile->current = openfile->edittop;
leftedge = openfile->firstcolumn;
openfile->current_y = 0;
@@ -170,71 +170,61 @@ void do_page_down(void)
}
#ifdef ENABLE_JUSTIFY
/* Move to the beginning of the last beginning-of-paragraph line before the
* current line. If update_screen is TRUE, update the screen afterwards. */
void do_para_begin(bool update_screen)
/* Move to the first beginning of a paragraph before the current line. */
void do_para_begin(linestruct **line)
{
filestruct *was_current = openfile->current;
if ((*line)->prev != NULL)
*line = (*line)->prev;
if (openfile->current != openfile->fileage)
openfile->current = openfile->current->prev;
while (!begpar(openfile->current))
openfile->current = openfile->current->prev;
openfile->current_x = 0;
if (update_screen)
edit_redraw(was_current, CENTERING);
while (!begpar(*line, 0))
*line = (*line)->prev;
}
/* Move down to the beginning of the last line of the current paragraph.
* Then move down one line farther if there is such a line, or to the
* end of the current line if not. If update_screen is TRUE, update the
* screen afterwards. A line is the last line of a paragraph if it is
* in a paragraph, and the next line either is the beginning line of a
* paragraph or isn't in a paragraph. */
void do_para_end(bool update_screen)
/* Move down to the last line of the first found paragraph. */
void do_para_end(linestruct **line)
{
filestruct *was_current = openfile->current;
while ((*line)->next != NULL && !inpar(*line))
*line = (*line)->next;
while (openfile->current != openfile->filebot &&
!inpar(openfile->current))
openfile->current = openfile->current->next;
while ((*line)->next != NULL && inpar((*line)->next) &&
!begpar((*line)->next, 0))
*line = (*line)->next;
}
while (openfile->current != openfile->filebot &&
inpar(openfile->current->next) &&
!begpar(openfile->current->next)) {
openfile->current = openfile->current->next;
}
/* Move up to first start of a paragraph before the current line. */
void to_para_begin(void)
{
linestruct *was_current = openfile->current;
if (openfile->current != openfile->filebot) {
do_para_begin(&openfile->current);
openfile->current_x = 0;
edit_redraw(was_current, CENTERING);
}
/* Move down to just after the first found end of a paragraph. */
void to_para_end(void)
{
linestruct *was_current = openfile->current;
do_para_end(&openfile->current);
/* Step beyond the last line of the paragraph, if possible;
* otherwise, move to the end of the line. */
if (openfile->current->next != NULL) {
openfile->current = openfile->current->next;
openfile->current_x = 0;
} else
openfile->current_x = strlen(openfile->current->data);
if (update_screen)
edit_redraw(was_current, CENTERING);
}
/* Move up to first start of a paragraph before the current line. */
void do_para_begin_void(void)
{
do_para_begin(TRUE);
}
/* Move down to just after the first end of a paragraph. */
void do_para_end_void(void)
{
do_para_end(TRUE);
edit_redraw(was_current, CENTERING);
}
#endif /* ENABLE_JUSTIFY */
/* Move to the preceding block of text. */
void do_prev_block(void)
void to_prev_block(void)
{
filestruct *was_current = openfile->current;
linestruct *was_current = openfile->current;
bool is_text = FALSE, seen_text = FALSE;
/* Skip backward until first blank line after some nonblank line(s). */
@@ -244,8 +234,8 @@ void do_prev_block(void)
seen_text = seen_text || is_text;
}
/* Step forward one line again if this one is blank. */
if (openfile->current->next != NULL &&
/* Step forward one line again if we passed text but this line is blank. */
if (seen_text && openfile->current->next != NULL &&
white_string(openfile->current->data))
openfile->current = openfile->current->next;
@@ -254,9 +244,9 @@ void do_prev_block(void)
}
/* Move to the next block of text. */
void do_next_block(void)
void to_next_block(void)
{
filestruct *was_current = openfile->current;
linestruct *was_current = openfile->current;
bool is_white = white_string(openfile->current->data);
bool seen_white = is_white;
@@ -272,10 +262,9 @@ void do_next_block(void)
}
/* Move to the previous word. If allow_punct is TRUE, treat punctuation
* as part of a word. When requested, update the screen afterwards. */
void do_prev_word(bool allow_punct, bool update_screen)
* as part of a word. */
void do_prev_word(bool allow_punct)
{
filestruct *was_current = openfile->current;
bool seen_a_word = FALSE, step_forward = FALSE;
/* Move backward until we pass over the start of a word. */
@@ -289,10 +278,10 @@ void do_prev_word(bool allow_punct, bool update_screen)
}
/* Step back one character. */
openfile->current_x = move_mbleft(openfile->current->data,
openfile->current_x = step_left(openfile->current->data,
openfile->current_x);
if (is_word_mbchar(openfile->current->data + openfile->current_x,
if (is_word_char(openfile->current->data + openfile->current_x,
allow_punct)) {
seen_a_word = TRUE;
/* If at the head of a line now, this surely is a word start. */
@@ -307,22 +296,21 @@ void do_prev_word(bool allow_punct, bool update_screen)
if (step_forward)
/* Move one character forward again to sit on the start of the word. */
openfile->current_x = move_mbright(openfile->current->data,
openfile->current_x = step_right(openfile->current->data,
openfile->current_x);
if (update_screen)
edit_redraw(was_current, FLOWING);
}
/* Move to the next word. If allow_punct is TRUE, treat punctuation
* as part of a word. When requested, update the screen afterwards.
* Return TRUE if we started on a word, and FALSE otherwise. */
bool do_next_word(bool allow_punct, bool update_screen)
/* Move to the next word. If after_ends is TRUE, stop at the ends of words
* instead of their beginnings. If allow_punct is TRUE, treat punctuation as
* part of a word. Return TRUE if we started on a word, and FALSE otherwise. */
bool do_next_word(bool after_ends, bool allow_punct)
{
filestruct *was_current = openfile->current;
bool started_on_word = is_word_mbchar(openfile->current->data +
bool started_on_word = is_word_char(openfile->current->data +
openfile->current_x, allow_punct);
bool seen_space = !started_on_word;
#ifndef NANO_TINY
bool seen_word = started_on_word;
#endif
/* Move forward until we reach the start of a word. */
while (TRUE) {
@@ -336,38 +324,56 @@ bool do_next_word(bool allow_punct, bool update_screen)
seen_space = TRUE;
} else {
/* Step forward one character. */
openfile->current_x = move_mbright(openfile->current->data,
openfile->current_x = step_right(openfile->current->data,
openfile->current_x);
}
/* If this is not a word character, then it's a separator; else
* if we've already seen a separator, then it's a word start. */
if (!is_word_mbchar(openfile->current->data + openfile->current_x,
#ifndef NANO_TINY
if (after_ends) {
/* If this is a word character, continue; else it's a separator,
* and if we've already seen a word, then it's a word end. */
if (is_word_char(openfile->current->data + openfile->current_x,
allow_punct))
seen_space = TRUE;
else if (seen_space)
break;
seen_word = TRUE;
else if (seen_word)
break;
} else
#endif
{
/* If this is not a word character, then it's a separator; else
* if we've already seen a separator, then it's a word start. */
if (!is_word_char(openfile->current->data + openfile->current_x,
allow_punct))
seen_space = TRUE;
else if (seen_space)
break;
}
}
if (update_screen)
edit_redraw(was_current, FLOWING);
/* Return whether we started on a word. */
return started_on_word;
}
/* Move to the previous word in the file, treating punctuation as part of a
* word if the WORD_BOUNDS flag is set, and update the screen afterwards. */
void do_prev_word_void(void)
void to_prev_word(void)
{
do_prev_word(ISSET(WORD_BOUNDS), TRUE);
linestruct *was_current = openfile->current;
do_prev_word(ISSET(WORD_BOUNDS));
edit_redraw(was_current, FLOWING);
}
/* Move to the next word in the file, treating punctuation as part of a word
* if the WORD_BOUNDS flag is set, and update the screen afterwards. */
void do_next_word_void(void)
/* Move to the next word in the file. If the AFTER_ENDS flag is set, stop
* at word ends instead of beginnings. If the WORD_BOUNDS flag is set, treat
* punctuation as part of a word. Update the screen afterwards. */
void to_next_word(void)
{
do_next_word(ISSET(WORD_BOUNDS), TRUE);
linestruct *was_current = openfile->current;
do_next_word(ISSET(AFTER_ENDS), ISSET(WORD_BOUNDS));
edit_redraw(was_current, FLOWING);
}
/* Move to the beginning of the current line (or softwrapped chunk).
@@ -375,7 +381,7 @@ void do_next_word_void(void)
* of the full line when already at the start of a chunk. */
void do_home(void)
{
filestruct *was_current = openfile->current;
linestruct *was_current = openfile->current;
size_t was_column = xplustabs();
bool moved_off_chunk = TRUE;
#ifndef NANO_TINY
@@ -431,11 +437,11 @@ void do_home(void)
}
/* Move to the end of the current line (or softwrapped chunk).
* When softwrapping and alredy at the end of a chunk, go to the
* When softwrapping and already at the end of a chunk, go to the
* end of the full line. */
void do_end(void)
{
filestruct *was_current = openfile->current;
linestruct *was_current = openfile->current;
size_t was_column = xplustabs();
size_t line_len = strlen(openfile->current->data);
bool moved_off_chunk = TRUE;
@@ -484,7 +490,7 @@ void do_end(void)
/* Move the cursor to the preceding line or chunk. */
void do_up(void)
{
filestruct *was_current = openfile->current;
linestruct *was_current = openfile->current;
size_t leftedge, target_column;
get_edge_and_target(&leftedge, &target_column);
@@ -495,7 +501,10 @@ void do_up(void)
set_proper_index_and_pww(&leftedge, target_column, FALSE);
edit_redraw(was_current, FLOWING);
if (openfile->current_y == 0 && !ISSET(JUMPY_SCROLLING))
edit_scroll(BACKWARD);
else
edit_redraw(was_current, FLOWING);
/* <Up> should not change placewewant, so restore it. */
openfile->placewewant = leftedge + target_column;
@@ -504,7 +513,7 @@ void do_up(void)
/* Move the cursor to next line or chunk. */
void do_down(void)
{
filestruct *was_current = openfile->current;
linestruct *was_current = openfile->current;
size_t leftedge, target_column;
get_edge_and_target(&leftedge, &target_column);
@@ -515,14 +524,17 @@ void do_down(void)
set_proper_index_and_pww(&leftedge, target_column, TRUE);
edit_redraw(was_current, FLOWING);
if (openfile->current_y == editwinrows - 1 && !ISSET(JUMPY_SCROLLING))
edit_scroll(FORWARD);
else
edit_redraw(was_current, FLOWING);
/* <Down> should not change placewewant, so restore it. */
openfile->placewewant = leftedge + target_column;
}
#ifdef ENABLE_HELP
/* Scroll up one line or chunk without scrolling the cursor. */
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
/* Scroll up one line or chunk without moving the cursor textwise. */
void do_scroll_up(void)
{
/* When the top of the file is onscreen, we can't scroll. */
@@ -532,34 +544,43 @@ void do_scroll_up(void)
if (openfile->current_y == editwinrows - 1)
do_up();
edit_scroll(BACKWARD);
if (editwinrows > 1)
edit_scroll(BACKWARD);
}
/* Scroll down one line or chunk without scrolling the cursor. */
/* Scroll down one line or chunk without moving the cursor textwise. */
void do_scroll_down(void)
{
if (openfile->current_y == 0)
do_down();
if (openfile->edittop->next != NULL
if (editwinrows > 1 && (openfile->edittop->next != NULL
#ifndef NANO_TINY
|| chunk_for(openfile->firstcolumn, openfile->edittop) <
number_of_chunks_in(openfile->edittop)
|| (ISSET(SOFTWRAP) && (extra_chunks_in(openfile->edittop) >
chunk_for(openfile->firstcolumn, openfile->edittop)))
#endif
)
))
edit_scroll(FORWARD);
}
#endif
/* Scroll the line with the cursor to the center of the screen. */
void do_center(void)
{
adjust_viewport(CENTERING);
draw_all_subwindows();
full_refresh();
}
#endif /* !NANO_TINY || ENABLE_HELP */
/* Move left one character. */
void do_left(void)
{
filestruct *was_current = openfile->current;
linestruct *was_current = openfile->current;
if (openfile->current_x > 0)
openfile->current_x = move_mbleft(openfile->current->data,
openfile->current_x = step_left(openfile->current->data,
openfile->current_x);
else if (openfile->current != openfile->fileage) {
else if (openfile->current != openfile->filetop) {
openfile->current = openfile->current->prev;
openfile->current_x = strlen(openfile->current->data);
}
@@ -570,10 +591,10 @@ void do_left(void)
/* Move right one character. */
void do_right(void)
{
filestruct *was_current = openfile->current;
linestruct *was_current = openfile->current;
if (openfile->current->data[openfile->current_x] != '\0')
openfile->current_x = move_mbright(openfile->current->data,
openfile->current_x = step_right(openfile->current->data,
openfile->current_x);
else if (openfile->current != openfile->filebot) {
openfile->current = openfile->current->next;

2406
src/nano.c

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* proto.h -- This file is part of GNU nano. *
* prototypes.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -18,10 +18,7 @@
* *
**************************************************************************/
#ifndef PROTO_H
#define PROTO_H 1
#include "nano.h"
#include "definitions.h"
/* All external variables. See global.c for their descriptions. */
@@ -29,108 +26,108 @@
extern volatile sig_atomic_t the_window_resized;
#endif
#ifdef __linux__
extern bool on_a_vt;
#endif
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 ran_a_tool;
extern bool inhelp;
extern char *title;
extern bool focusing;
extern bool as_an_at;
extern int margin;
extern int editwincols;
extern bool suppress_cursorpos;
extern bool control_C_was_pressed;
extern message_type lastmessage;
extern filestruct *pletion_line;
extern bool inhelp;
extern char *title;
extern bool more_than_one;
extern linestruct *pletion_line;
extern bool also_the_last;
extern int didfind;
extern int controlleft;
extern int controlright;
extern int controlup;
extern int controldown;
extern int controlhome;
extern int controlend;
#ifndef NANO_TINY
extern int shiftcontrolleft;
extern int shiftcontrolright;
extern int shiftcontrolup;
extern int shiftcontroldown;
extern int shiftcontrolhome;
extern int shiftcontrolend;
extern int altleft;
extern int altright;
extern int altup;
extern int altdown;
extern int shiftaltleft;
extern int shiftaltright;
extern int shiftaltup;
extern int shiftaltdown;
#endif
#ifdef ENABLED_WRAPORJUSTIFY
extern ssize_t fill;
extern ssize_t wrap_at;
#endif
extern char *answer;
extern char *last_search;
extern int didfind;
extern char *present_path;
extern unsigned flags[4];
extern int controlleft, controlright;
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;
extern int shiftcontrolhome, shiftcontrolend;
extern int altleft, altright;
extern int altup, altdown;
extern int altpageup, altpagedown;
extern int altinsert, altdelete;
extern int shiftaltleft, shiftaltright;
extern int shiftaltup, shiftaltdown;
#endif
#ifdef ENABLED_WRAPORJUSTIFY
extern ssize_t fill;
extern size_t wrap_at;
#endif
extern WINDOW *topwin;
extern WINDOW *edit;
extern WINDOW *bottomwin;
extern int editwinrows;
extern int editwincols;
extern int margin;
extern int thebar;
#ifndef NANO_TINY
extern int *bardata;
extern ssize_t stripe_column;
#endif
extern linestruct *cutbuffer;
extern linestruct *cutbottom;
extern bool keep_cutbuffer;
extern filestruct *cutbuffer;
extern filestruct *cutbottom;
extern partition *filepart;
extern openfilestruct *openfile;
extern openfilestruct *firstfile;
#ifdef ENABLE_MULTIBUFFER
extern openfilestruct *startfile;
#endif
#ifndef NANO_TINY
extern char *matchbrackets;
extern char *whitespace;
extern int whitespace_len[2];
extern int whitelen[2];
#endif
extern const char *exit_tag;
extern const char *close_tag;
extern const char *uncut_tag;
#ifdef ENABLE_JUSTIFY
extern const char *unjust_tag;
extern char *punct;
extern char *brackets;
extern char *quotestr;
extern regex_t quotereg;
extern int quoterc;
extern char *quoteerr;
#endif
extern char *word_chars;
extern char *answer;
extern ssize_t tabsize;
#ifndef NANO_TINY
extern char *backup_dir;
extern const char *locking_prefix;
extern const char *locking_suffix;
#endif
#ifdef ENABLE_OPERATINGDIR
extern char *operating_dir;
@@ -149,22 +146,20 @@ extern bool have_palette;
extern bool refresh_needed;
extern int currmenu;
extern sc *sclist;
extern subnfunc *allfuncs;
extern subnfunc *exitfunc;
extern subnfunc *uncutfunc;
extern keystruct *sclist;
extern funcstruct *allfuncs;
extern funcstruct *exitfunc;
extern filestruct *search_history;
extern filestruct *replace_history;
extern filestruct *execute_history;
extern linestruct *search_history;
extern linestruct *replace_history;
extern linestruct *execute_history;
#ifdef ENABLE_HISTORIES
extern filestruct *searchtop;
extern filestruct *searchbot;
extern filestruct *replacetop;
extern filestruct *replacebot;
extern filestruct *executetop;
extern filestruct *executebot;
extern poshiststruct *position_history;
extern linestruct *searchtop;
extern linestruct *searchbot;
extern linestruct *replacetop;
extern linestruct *replacebot;
extern linestruct *executetop;
extern linestruct *executebot;
#endif
extern regex_t search_regexp;
@@ -178,21 +173,27 @@ extern int interface_color_pair[NUMBER_OF_ELEMENTS];
extern char *homedir;
extern char *statedir;
extern char *rcfile_with_errors;
#if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES)
extern char *startup_problem;
#endif
#ifdef ENABLE_NANORC
extern char *custom_nanorc;
#endif
extern bool spotlighted;
extern size_t light_from_col;
extern size_t light_to_col;
typedef void (*functionptrtype)(void);
/* Most functions in browser.c. */
#ifdef ENABLE_BROWSER
char *do_browse_from(const char *inpath);
char *browse_in(const char *inpath);
void read_the_list(const char *path, DIR *dir);
functionptrtype parse_browser_input(int *kbinput);
void browser_refresh(void);
void browser_select_dirname(const char *needle);
void do_filesearch(void);
void do_filesearch(bool forwards);
void do_fileresearch(bool forwards);
void to_first_file(void);
void to_last_file(void);
char *strip_last_component(const char *path);
#endif
@@ -201,168 +202,157 @@ char *strip_last_component(const char *path);
void utf8_init(void);
bool using_utf8(void);
#endif
char *addstrings(char* str1, size_t len1, char* str2, size_t len2);
bool is_byte(int c);
bool is_alpha_mbchar(const char *c);
bool is_blank_mbchar(const char *c);
bool is_ascii_cntrl_char(int c);
bool is_cntrl_mbchar(const char *c);
bool is_word_mbchar(const char *c, bool allow_punct);
bool is_alpha_char(const char *c);
bool is_blank_char(const char *c);
bool is_cntrl_char(const char *c);
bool is_word_char(const char *c, bool allow_punct);
char control_mbrep(const char *c, bool isdata);
int length_of_char(const char *c, int *width);
#ifdef ENABLE_UTF8
int mbwidth(const char *c);
char *make_mbchar(long chr, int *chr_mb_len);
int parse_mbchar(const char *buf, char *chr, size_t *col);
size_t move_mbleft(const char *buf, size_t pos);
size_t move_mbright(const char *buf, size_t pos);
char *make_mbchar(long code, int *length);
#endif
int char_length(const char *pointer);
size_t mbstrlen(const char *pointer);
int collect_char(const char *string, char *thechar);
int advance_over(const char *string, size_t *column);
size_t step_left(const char *buf, size_t pos);
size_t step_right(const char *buf, size_t pos);
int mbstrcasecmp(const char *s1, const char *s2);
int mbstrncasecmp(const char *s1, const char *s2, size_t n);
char *mbstrcasestr(const char *haystack, const char *needle);
char *revstrstr(const char *haystack, const char *needle, const char *index);
char *mbrevstrcasestr(const char *haystack, const char *needle, const char *index);
size_t mbstrlen(const char *s);
size_t mbstrnlen(const char *s, size_t maxlen);
char *revstrstr(const char *haystack, const char *needle, const char *pointer);
char *mbrevstrcasestr(const char *haystack, const char *needle, const char *pointer);
#if !defined(NANO_TINY) || defined(ENABLE_JUSTIFY)
char *mbstrchr(const char *s, const char *c);
char *mbstrchr(const char *string, const char *chr);
#endif
#ifndef NANO_TINY
char *mbstrpbrk(const char *s, const char *accept);
char *revstrpbrk(const char *head, const char *accept, const char *index);
char *mbrevstrpbrk(const char *head, const char *accept, const char *index);
char *mbstrpbrk(const char *string, const char *accept);
char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer);
#endif
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || defined(ENABLE_JUSTIFY))
bool has_blank_mbchars(const char *s);
bool has_blank_char(const char *string);
#endif
bool white_string(const char *string);
#ifdef ENABLE_UTF8
bool is_valid_unicode(wchar_t wc);
#endif
#ifdef ENABLE_NANORC
bool is_valid_mbstring(const char *s);
#endif
/* Most functions in color.c. */
#ifdef ENABLE_COLOR
void set_colorpairs(void);
void color_init(void);
void color_update(void);
void check_the_multis(filestruct *line);
void alloc_multidata_if_needed(filestruct *fileptr);
void set_interface_colorpairs(void);
void prepare_palette(void);
void find_and_prime_applicable_syntax(void);
void set_up_multicache(linestruct *line);
void check_the_multis(linestruct *line);
void precalc_multicolorinfo(void);
#endif
/* Most functions in cut.c. */
void cutbuffer_reset(void);
bool keeping_cutbuffer(void);
void do_delete(void);
void do_backspace(void);
#ifndef NANO_TINY
void cut_marked(bool *right_side_up);
void chop_previous_word(void);
void chop_next_word(void);
#endif
void do_cut_text(bool copy_text, bool cut_till_eof);
void do_cut_text_void(void);
void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_x);
void ingraft_buffer(linestruct *topline);
void copy_from_buffer(linestruct *somebuffer);
#ifndef NANO_TINY
void do_copy_text(void);
void do_cut_till_eof(void);
void cut_marked_region(void);
#endif
void do_uncut_text(void);
void do_snip(bool marked, bool until_eof, bool append);
void cut_text(void);
#ifndef NANO_TINY
void cut_till_eof(void);
void zap_text(void);
void copy_marked_region(void);
void copy_text(void);
#endif
void paste_text(void);
/* Most functions in files.c. */
void initialize_buffer_text(void);
void set_modified(void);
bool open_buffer(const char *filename, bool new_buffer);
#ifdef ENABLE_SPELLER
void replace_buffer(const char *filename);
void make_new_buffer(void);
#ifndef NANO_TINY
void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
filestruct *bot, size_t bot_x);
#endif
bool delete_lockfile(const char *lockfilename);
#endif
bool open_buffer(const char *filename, bool new_one);
void set_modified(void);
void prepare_for_display(void);
#ifdef ENABLE_MULTIBUFFER
void mention_name_and_linecount(void);
void switch_to_prev_buffer(void);
void switch_to_next_buffer(void);
bool close_buffer(void);
void close_buffer(void);
#endif
void read_file(FILE *f, int fd, const char *filename, bool undoable);
int open_file(const char *filename, bool newfie, bool quiet, FILE **f);
int open_file(const char *filename, bool new_one, FILE **f);
char *get_next_filename(const char *name, const char *suffix);
void do_insertfile_void(void);
#ifndef NANO_TINY
void do_execute(void);
#endif
char *get_full_path(const char *origpath);
char *safe_tempfile(FILE **f);
char *safe_tempfile(FILE **stream);
#ifdef ENABLE_OPERATINGDIR
void init_operating_dir(void);
bool outside_of_confinement(const char *currpath, bool allow_tabcomp);
#endif
#ifndef NANO_TINY
void init_backup_dir(void);
int delete_lockfile(const char *lockfilename);
int write_lockfile(const char *lockfilename, const char *origfilename, bool modified);
#endif
int copy_file(FILE *inn, FILE *out, bool close_out);
bool write_file(const char *name, FILE *f_open, bool tmp,
bool write_file(const char *name, FILE *thefile, bool tmp,
kind_of_writing_type method, bool fullbuffer);
#ifndef NANO_TINY
bool write_marked_file(const char *name, FILE *f_open, bool tmp,
bool write_marked_file(const char *name, FILE *stream, bool tmp,
kind_of_writing_type method);
#endif
int do_writeout(bool exiting, bool withprompt);
void do_writeout_void(void);
void do_savefile(void);
char *real_dir_from_tilde(const char *buf);
char *real_dir_from_tilde(const char *path);
#if defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
int diralphasort(const void *va, const void *vb);
#endif
#ifdef ENABLE_TABCOMP
char *input_tab(char *buf, bool allow_files, size_t *place,
bool *lastwastab, void (*refresh_func)(void), bool *listed);
char *input_tab(char *buf, size_t *place, void (*refresh_func)(void), bool *listed);
#endif
/* Some functions in global.c. */
size_t length_of_list(int menu);
const sc *first_sc_for(int menu, void (*func)(void));
int the_code_for(void (*func)(void), int defaultval);
functionptrtype func_from_key(int *kbinput);
const keystruct *first_sc_for(int menu, void (*func)(void));
size_t shown_entries_for(int menu);
const keystruct *get_shortcut(int *keycode);
functionptrtype func_from_key(int *keycode);
#if defined(ENABLE_BROWSER) || defined(ENABLE_HELP)
functionptrtype interpret(int *keycode);
#endif
int keycode_from_string(const char *keystring);
void assign_keyinfo(sc *s, const char *keystring, const int keycode);
void print_sclist(void);
void shortcut_init(void);
#ifdef ENABLE_COLOR
void set_lint_or_format_shortcuts(void);
void set_spell_shortcuts(void);
#endif
const subnfunc *sctofunc(const sc *s);
const char *flagtostr(int flag);
sc *strtosc(const char *input);
int strtomenu(const char *input);
#ifdef DEBUG
void thanks_for_all_the_fish(void);
#endif
/* All functions in help.c. */
/* Some functions in help.c. */
#ifdef ENABLE_HELP
void wrap_the_help_text(bool redisplaying);
void do_help(void);
void help_init(void);
functionptrtype parse_help_input(int *kbinput);
size_t help_line_len(const char *ptr);
void wrap_help_text_into_buffer(void);
#endif
void do_help_void(void);
void do_help(void);
/* Most functions in history.c. */
#ifdef ENABLE_HISTORIES
void history_init(void);
void history_reset(const filestruct *h);
void update_history(filestruct **h, const char *s);
char *get_history_older(filestruct **h);
char *get_history_newer(filestruct **h);
void history_reset(const linestruct *list);
void update_history(linestruct **item, const char *text);
char *get_history_older(linestruct **h);
char *get_history_newer(linestruct **h);
void get_history_older_void(void);
void get_history_newer_void(void);
#ifdef ENABLE_TABCOMP
char *get_history_completion(filestruct **h, char *s, size_t len);
char *get_history_completion(linestruct **h, char *s, size_t len);
#endif
bool have_statedir(void);
void load_history(void);
void save_history(void);
void load_poshistory(void);
void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos);
void update_poshistory(void);
bool has_old_position(const char *file, ssize_t *line, ssize_t *column);
#endif
@@ -372,183 +362,160 @@ void to_last_line(void);
void do_page_up(void);
void do_page_down(void);
#ifdef ENABLE_JUSTIFY
void do_para_begin(bool update_screen);
void do_para_end(bool update_screen);
void do_para_begin_void(void);
void do_para_end_void(void);
void do_para_begin(linestruct **line);
void do_para_end(linestruct **line);
void to_para_begin(void);
void to_para_end(void);
#endif
void do_prev_block(void);
void do_next_block(void);
void do_prev_word(bool allow_punct, bool update_screen);
bool do_next_word(bool allow_punct, bool update_screen);
void do_prev_word_void(void);
void do_next_word_void(void);
void to_prev_block(void);
void to_next_block(void);
void do_prev_word(bool allow_punct);
bool do_next_word(bool after_ends, bool allow_punct);
void to_prev_word(void);
void to_next_word(void);
void do_home(void);
void do_end(void);
void do_up(void);
void do_down(void);
#ifdef ENABLE_HELP
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
void do_scroll_up(void);
void do_scroll_down(void);
void do_center(void);
#endif
void do_left(void);
void do_right(void);
/* Most functions in nano.c. */
filestruct *make_new_node(filestruct *prevnode);
void splice_node(filestruct *afterthis, filestruct *newnode);
void unlink_node(filestruct *fileptr);
void delete_node(filestruct *fileptr);
filestruct *copy_filestruct(const filestruct *src);
void free_filestruct(filestruct *src);
void renumber(filestruct *line);
partition *partition_filestruct(filestruct *top, size_t top_x,
filestruct *bot, size_t bot_x);
void unpartition_filestruct(partition **p);
void extract_buffer(filestruct **file_top, filestruct **file_bot,
filestruct *top, size_t top_x, filestruct *bot, size_t bot_x);
void ingraft_buffer(filestruct *somebuffer);
void copy_from_buffer(filestruct *somebuffer);
openfilestruct *make_new_opennode(void);
#ifdef ENABLE_MULTIBUFFER
void unlink_opennode(openfilestruct *fileptr);
void delete_opennode(openfilestruct *fileptr);
#endif
linestruct *make_new_node(linestruct *prevnode);
void splice_node(linestruct *afterthis, linestruct *newnode);
void unlink_node(linestruct *line);
void delete_node(linestruct *line);
linestruct *copy_buffer(const linestruct *src);
void free_lines(linestruct *src);
void renumber_from(linestruct *line);
void print_view_warning(void);
void show_restricted_warning(void);
bool in_restricted_mode(void);
#ifndef ENABLE_HELP
void say_there_is_no_help(void);
#endif
void finish(void);
void die(const char *msg, ...);
void emergency_save(const char *die_filename, struct stat *die_stat);
void window_init(void);
void do_exit(void);
void close_and_go(void);
void do_exit(void);
void die(const char *msg, ...);
void window_init(void);
void install_handler_for_Ctrl_C(void);
void restore_handler_for_Ctrl_C(void);
void reconnect_and_store_state(void);
RETSIGTYPE handle_hupterm(int signal);
#ifndef DEBUG
RETSIGTYPE handle_crash(int signal);
#endif
RETSIGTYPE do_suspend(int signal);
RETSIGTYPE do_continue(int signal);
#if !defined(NANO_TINY) || defined(ENABLE_SPELLER) || defined(ENABLE_COLOR)
void block_sigwinch(bool blockit);
#endif
#ifndef NANO_TINY
RETSIGTYPE handle_sigwinch(int signal);
void compute_the_extra_rows_per_line_from(linestruct *fromline);
void regenerate_screen(void);
void allow_sigwinch(bool allow);
void do_toggle(int flag);
void do_toggle_void(void);
void enable_signals(void);
#endif
void disable_kb_interrupt(void);
void enable_kb_interrupt(void);
void disable_flow_control(void);
void enable_flow_control(void);
void terminal_init(void);
#ifdef ENABLE_LINENUMBERS
void confirm_margin(void);
#endif
void unbound_key(int code);
bool okay_for_view(const sc *shortcut);
int do_input(bool allow_funcs);
void do_output(char *output, size_t output_len, bool allow_cntrls);
bool okay_for_view(const keystruct *shortcut);
void inject(char *burst, size_t count);
/* Most functions in prompt.c. */
void do_statusbar_output(int *the_input, size_t input_len, bool filtering);
void do_statusbar_home(void);
void do_statusbar_end(void);
void do_statusbar_left(void);
void do_statusbar_right(void);
void do_statusbar_backspace(void);
void do_statusbar_delete(void);
void do_statusbar_cut_text(void);
void do_statusbar_uncut_text(void);
#ifndef NANO_TINY
void do_statusbar_prev_word(void);
void do_statusbar_next_word(void);
#endif
void do_statusbar_verbatim_input(void);
size_t statusbar_xplustabs(void);
size_t get_statusbar_page_start(size_t start_col, size_t column);
void reinit_statusbar_x(void);
void update_the_statusbar(void);
int do_prompt(bool allow_tabs, bool allow_files,
int menu, const char *curranswer, filestruct **history_list,
size_t get_statusbar_page_start(size_t base, size_t column);
void put_cursor_at_end_of_answer(void);
void add_or_remove_pipe_symbol_from_answer(void);
int do_prompt(int menu, const char *provided, linestruct **history_list,
void (*refresh_func)(void), const char *msg, ...);
int do_yesno_prompt(bool all, const char *msg);
/* Most functions in rcfile.c. */
#if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES)
void display_rcfile_errors(void);
void jot_error(const char *msg, ...);
#endif
#ifdef ENABLE_NANORC
#ifdef ENABLE_COLOR
bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright);
void parse_one_include(char *file, syntaxtype *syntax);
void grab_and_store(const char *kind, char *ptr, regexlisttype **storage);
bool parse_syntax_commands(char *keyword, char *ptr);
#endif
void parse_rcfile(FILE *rcstream, bool syntax_only);
void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only);
void do_rcfiles(void);
#endif /* ENABLE_NANORC */
/* Most functions in search.c. */
void not_found_msg(const char *str);
void search_replace_abort(void);
bool regexp_init(const char *regexp);
void tidy_up_after_search(void);
int findnextstr(const char *needle, bool whole_word_only, int modus,
size_t *match_len, bool skipone, const filestruct *begin, size_t begin_x);
void do_search(void);
size_t *match_len, bool skipone, const linestruct *begin, size_t begin_x);
void do_search_forward(void);
void do_search_backward(void);
#ifndef NANO_TINY
void do_findprevious(void);
void do_findnext(void);
#endif
void do_research(void);
void not_found_msg(const char *str);
void go_looking(void);
ssize_t do_replace_loop(const char *needle, bool whole_word_only,
const filestruct *real_current, size_t *real_current_x);
const linestruct *real_current, size_t *real_current_x);
void do_replace(void);
void ask_for_replacement(void);
void ask_for_and_do_replacements(void);
void goto_line_posx(ssize_t line, size_t pos_x);
void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
void do_gotolinecolumn(ssize_t line, ssize_t column, bool retain_answer,
bool interactive);
void do_gotolinecolumn_void(void);
#ifndef NANO_TINY
void do_find_bracket(void);
void put_or_lift_anchor(void);
void to_prev_anchor(void);
void to_next_anchor(void);
#endif
/* Most functions in text.c. */
#ifndef NANO_TINY
void do_mark(void);
#endif
void do_delete(void);
void do_backspace(void);
#ifndef NANO_TINY
void do_cut_prev_word(void);
void do_cut_next_word(void);
#endif
void do_tab(void);
#ifndef NANO_TINY
void do_indent(void);
void do_unindent(void);
#endif
bool white_string(const char *s);
#ifdef ENABLE_COMMENT
void do_comment(void);
bool comment_line(undo_type action, filestruct *f, const char *comment_seq);
#endif
void do_undo(void);
void do_redo(void);
void do_enter(void);
#ifndef NANO_TINY
RETSIGTYPE cancel_command(int signal);
bool execute_command(const char *command);
void discard_until(const undo *thisitem, openfilestruct *thefile, bool keep);
void add_undo(undo_type action);
void discard_until(const undostruct *thisitem);
void add_undo(undo_type action, const char *message);
void update_multiline_undo(ssize_t lineno, char *indentation);
void update_undo(undo_type action);
#endif /* !NANO_TINY */
#ifdef ENABLE_WRAPPING
void wrap_reset(void);
bool do_wrap(filestruct *line);
bool do_wrap(void);
#endif
#if defined(ENABLE_HELP) || defined(ENABLED_WRAPORJUSTIFY)
ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl);
ssize_t break_line(const char *textstart, ssize_t goal, bool snap_at_nl);
#endif
#if !defined(NANO_TINY) || defined(ENABLE_JUSTIFY)
#if !defined(NANO_TINY) || defined(ENABLED_WRAPORJUSTIFY)
size_t indent_length(const char *line);
#endif
#ifdef ENABLE_JUSTIFY
void justify_format(filestruct *paragraph, size_t skip);
bool begpar(const filestruct *const foo);
bool inpar(const filestruct *const foo);
size_t quote_length(const char *line);
bool begpar(const linestruct *const line, int depth);
bool inpar(const linestruct *const line);
void do_justify(bool full_justify);
void do_justify_void(void);
void do_full_justify(void);
@@ -573,146 +540,130 @@ char *concatenate(const char *path, const char *name);
#ifdef ENABLE_LINENUMBERS
int digits(ssize_t n);
#endif
bool parse_num(const char *str, ssize_t *val);
bool parse_num(const char *str, ssize_t *result);
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column);
void snuggly_fit(char **str);
void null_at(char **data, size_t index);
void unsunder(char *str, size_t true_len);
void sunder(char *str);
void recode_NUL_to_LF(char *string, size_t length);
void recode_LF_to_NUL(char *string);
#if !defined(ENABLE_TINY) || defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
void free_chararray(char **array, size_t len);
#endif
const char *fixbounds(const char *r);
#ifdef ENABLE_SPELLER
bool is_separate_word(size_t position, size_t length, const char *buf);
#endif
const char *strstrwrapper(const char *haystack, const char *needle,
const char *start);
void nperror(const char *s);
void *nmalloc(size_t howmuch);
void *nrealloc(void *ptr, size_t howmuch);
char *mallocstrncpy(char *dest, const char *src, size_t n);
char *measured_copy(const char *string, size_t count);
char *mallocstrcpy(char *dest, const char *src);
char *copy_of(const char *string);
char *free_and_assign(char *dest, char *src);
size_t get_page_start(size_t column);
size_t xplustabs(void);
size_t actual_x(const char *text, size_t column);
size_t strnlenpt(const char *text, size_t maxlen);
size_t strlenpt(const char *text);
size_t wideness(const char *text, size_t maxlen);
size_t breadth(const char *text);
void new_magicline(void);
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
void remove_magicline(void);
#endif
#ifndef NANO_TINY
void mark_order(const filestruct **top, size_t *top_x,
const filestruct **bot, size_t *bot_x, bool *right_side_up);
void get_range(const filestruct **top, const filestruct **bot);
bool mark_is_before_cursor(void);
void get_region(linestruct **top, size_t *top_x, linestruct **bot, size_t *bot_x);
void get_range(linestruct **top, linestruct **bot);
#endif
size_t get_totsize(const filestruct *begin, const filestruct *end);
size_t number_of_characters_in(const linestruct *begin, const linestruct *end);
#ifndef NANO_TINY
filestruct *fsfromline(ssize_t lineno);
#endif
#ifdef DEBUG
void dump_filestruct(const filestruct *inptr);
linestruct *line_from_number(ssize_t number);
#endif
/* Most functions in winio.c. */
void record_macro(void);
void run_macro(void);
size_t get_key_buffer_len(void);
void put_back(int keycode);
void unget_kbinput(int kbinput, bool metakey);
#ifdef ENABLE_NANORC
void implant(const char *string);
#endif
int get_kbinput(WINDOW *win, bool showcursor);
int parse_kbinput(WINDOW *win);
int arrow_from_abcd(int kbinput);
int parse_escape_sequence(WINDOW *win, int kbinput);
int get_byte_kbinput(int kbinput);
int get_control_kbinput(int kbinput);
int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len);
int *parse_verbatim_kbinput(WINDOW *win, size_t *count);
int get_kbinput(WINDOW *win, bool showcursor);
char *get_verbatim_kbinput(WINDOW *win, size_t *count);
#ifdef ENABLE_MOUSE
int get_mouseinput(int *mouse_row, int *mouse_col, bool allow_shortcuts);
int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts);
#endif
const sc *get_shortcut(int *kbinput);
void blank_row(WINDOW *win, int y, int x, int n);
void blank_edit(void);
void blank_statusbar(void);
void wipe_statusbar(void);
void blank_bottombars(void);
void check_statusblank(void);
char *display_string(const char *buf, size_t column, size_t span, bool isdata);
char *display_string(const char *buf, size_t column, size_t span,
bool isdata, bool isprompt);
void titlebar(const char *path);
void statusbar(const char *msg);
void warn_and_shortly_pause(const char *msg);
void statusline(message_type importance, const char *msg, ...);
void statusbar(const char *msg);
void warn_and_briefly_pause(const char *msg);
void bottombars(int menu);
void post_one_key(const char *keystroke, const char *tag, int width);
void place_the_cursor(void);
void edit_draw(filestruct *fileptr, const char *converted,
int line, size_t from_col);
int update_line(filestruct *fileptr, size_t index);
int update_line(linestruct *line, size_t index);
#ifndef NANO_TINY
int update_softwrapped_line(filestruct *fileptr);
int update_softwrapped_line(linestruct *line);
#endif
bool line_needs_update(const size_t old_column, const size_t new_column);
int go_back_chunks(int nrows, filestruct **line, size_t *leftedge);
int go_forward_chunks(int nrows, filestruct **line, size_t *leftedge);
int go_back_chunks(int nrows, linestruct **line, size_t *leftedge);
int go_forward_chunks(int nrows, linestruct **line, size_t *leftedge);
bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge);
void edit_scroll(bool direction);
#ifndef NANO_TINY
size_t get_softwrap_breakpoint(const char *text, size_t leftedge,
bool *end_of_line);
size_t get_chunk_and_edge(size_t column, filestruct *line, size_t *leftedge);
size_t chunk_for(size_t column, filestruct *line);
size_t leftedge_for(size_t column, filestruct *line);
size_t number_of_chunks_in(filestruct *line);
size_t get_chunk_and_edge(size_t column, linestruct *line, size_t *leftedge);
size_t chunk_for(size_t column, linestruct *line);
size_t leftedge_for(size_t column, linestruct *line);
size_t extra_chunks_in(linestruct *line);
void ensure_firstcolumn_is_aligned(void);
#endif
size_t actual_last_column(size_t leftedge, size_t column);
void edit_redraw(filestruct *old_current, update_type manner);
void edit_redraw(linestruct *old_current, update_type manner);
void edit_refresh(void);
void adjust_viewport(update_type location);
void total_redraw(void);
void total_refresh(void);
void display_main_list(void);
void do_cursorpos(bool force);
void do_cursorpos_void(void);
void spotlight(bool active, size_t from_col, size_t to_col);
void adjust_viewport(update_type manner);
void full_refresh(void);
void draw_all_subwindows(void);
void report_cursor_position(void);
void spotlight(size_t from_col, size_t to_col);
#ifndef NANO_TINY
void spotlight_softwrapped(bool active, size_t from_col, size_t to_col);
void spotlight_softwrapped(size_t from_col, size_t to_col);
#endif
void do_suspend_void(void);
void disable_waiting(void);
void enable_waiting(void);
#ifdef ENABLE_EXTRA
void do_credits(void);
#endif
/* These are just name definitions. */
void do_cancel(void);
void case_sens_void(void);
void regexp_void(void);
void backwards_void(void);
void flip_replace(void);
void flip_goto(void);
#ifdef ENABLE_BROWSER
void to_files_void(void);
void goto_dir_void(void);
void to_files(void);
void to_first_file(void);
void to_last_file(void);
void goto_dir(void);
#endif
#ifndef NANO_TINY
void do_nothing(void);
void do_toggle_void(void);
void dos_format_void(void);
void mac_format_void(void);
void append_void(void);
void prepend_void(void);
void backup_file_void(void);
void flip_execute(void);
void flip_pipe(void);
void flip_convert(void);
#endif
#ifdef ENABLE_MULTIBUFFER
void flip_newbuffer(void);
#endif
void discard_buffer(void);
#endif /* !PROTO_H */
void do_cancel(void);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

3888
src/text.c

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* utils.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2016-2017 Benno Schulenberg *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2016, 2017, 2019 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -19,7 +19,7 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#include <errno.h>
#ifdef HAVE_PWD_H
@@ -38,7 +38,7 @@ void get_homedir(void)
#ifdef HAVE_PWD_H
/* When HOME isn't set, or when we're root, get the home directory
* from the password file instead. */
if (homenv == NULL || geteuid() == 0) {
if (homenv == NULL || geteuid() == ROOT_UID) {
const struct passwd *userage = getpwuid(geteuid());
if (userage != NULL)
@@ -49,7 +49,7 @@ void get_homedir(void)
/* Only set homedir if some home directory could be determined,
* otherwise keep homedir NULL. */
if (homenv != NULL && *homenv != '\0')
homedir = mallocstrcpy(NULL, homenv);
homedir = copy_of(homenv);
}
}
@@ -149,7 +149,7 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
if (comma == str)
return retval;
firstpart = mallocstrcpy(NULL, str);
firstpart = copy_of(str);
firstpart[comma - str] = '\0';
retval = parse_num(firstpart, line) && retval;
@@ -159,37 +159,24 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
return retval;
}
/* Reduce the memory allocation of a string to what is needed. */
void snuggly_fit(char **str)
/* In the given string, recode each embedded NUL as a newline. */
void recode_NUL_to_LF(char *string, size_t length)
{
if (*str != NULL)
*str = charealloc(*str, strlen(*str) + 1);
}
/* Null a string at a certain index and align it. */
void null_at(char **data, size_t index)
{
*data = charealloc(*data, index + 1);
(*data)[index] = '\0';
}
/* For non-null-terminated lines. A line, by definition, shouldn't
* normally have newlines in it, so encode its nulls as newlines. */
void unsunder(char *str, size_t true_len)
{
for (; true_len > 0; true_len--, str++) {
if (*str == '\0')
*str = '\n';
while (length > 0) {
if (*string == '\0')
*string = '\n';
length--;
string++;
}
}
/* For non-null-terminated lines. A line, by definition, shouldn't
* normally have newlines in it, so decode its newlines as nulls. */
void sunder(char *str)
/* In the given string, recode each embedded newline as a NUL. */
void recode_LF_to_NUL(char *string)
{
for (; *str != '\0'; str++) {
if (*str == '\n')
*str = '\0';
while (*string != '\0') {
if (*string == '\n')
*string = '\0';
string++;
}
}
@@ -207,37 +194,6 @@ void free_chararray(char **array, size_t len)
}
#endif
/* Fix the regex if we're on platforms which require an adjustment
* from GNU-style to BSD-style word boundaries. */
const char *fixbounds(const char *r)
{
#ifndef GNU_WORDBOUNDS
int i, j = 0;
char *r2 = charalloc(strlen(r) * 5);
char *r3;
for (i = 0; i < strlen(r); i++) {
if (r[i] != '\0' && r[i] == '\\' && (r[i + 1] == '>' || r[i + 1] == '<')) {
strcpy(&r2[j], "[[:");
r2[j + 3] = r[i + 1];
strcpy(&r2[j + 4], ":]]");
i++;
j += 6;
} else
r2[j] = r[i];
j++;
}
r2[j] = '\0';
r3 = mallocstrcpy(NULL, r2);
free(r2);
return (const char *) r3;
#endif /* !GNU_WORDBOUNDS */
return r;
}
#ifdef ENABLE_SPELLER
/* Is the word starting at the given position in buf and of the given length
* a separate word? That is: is it not part of a longer word?*/
@@ -247,14 +203,14 @@ bool is_separate_word(size_t position, size_t length, const char *buf)
size_t word_end = position + length;
/* Get the characters before and after the word, if any. */
parse_mbchar(buf + move_mbleft(buf, position), before, NULL);
parse_mbchar(buf + word_end, after, NULL);
collect_char(buf + step_left(buf, position), before);
collect_char(buf + word_end, after);
/* If the word starts at the beginning of the line OR the character before
* the word isn't a letter, and if the word ends at the end of the line OR
* the character after the word isn't a letter, we have a whole word. */
return ((position == 0 || !is_alpha_mbchar(before)) &&
(buf[word_end] == '\0' || !is_alpha_mbchar(after)));
return ((position == 0 || !is_alpha_char(before)) &&
(buf[word_end] == '\0' || !is_alpha_char(after)));
}
#endif /* ENABLE_SPELLER */
@@ -266,13 +222,6 @@ bool is_separate_word(size_t position, size_t length, const char *buf)
const char *strstrwrapper(const char *haystack, const char *needle,
const char *start)
{
if (*needle == '\0') {
#ifndef NANO_TINY
statusline(ALERT, "Searching for nothing -- please report a bug");
#endif
return (char *)start;
}
if (ISSET(USE_REGEXP)) {
if (ISSET(BACKWARDS_SEARCH)) {
size_t last_find, ceiling, far_end;
@@ -298,7 +247,7 @@ const char *strstrwrapper(const char *haystack, const char *needle,
/* If this is the last possible match, don't try to advance. */
if (last_find == ceiling)
break;
next_rung = move_mbright(haystack, last_find);
next_rung = step_right(haystack, last_find);
regmatches[0].rm_so = next_rung;
regmatches[0].rm_eo = far_end;
if (regexec(&search_regexp, haystack, 1, regmatches,
@@ -325,26 +274,18 @@ const char *strstrwrapper(const char *haystack, const char *needle,
else
return haystack + regmatches[0].rm_so;
}
if (ISSET(CASE_SENSITIVE)) {
if (ISSET(BACKWARDS_SEARCH))
return revstrstr(haystack, needle, start);
else
return strstr(start, needle);
} else if (ISSET(BACKWARDS_SEARCH))
}
if (ISSET(BACKWARDS_SEARCH))
return mbrevstrcasestr(haystack, needle, start);
return mbstrcasestr(start, needle);
}
/* This is a wrapper for the perror() function. The wrapper temporarily
* leaves curses mode, calls perror() (which writes to stderr), and then
* reenters curses mode, updating the screen in the process. Note that
* nperror() causes the window to flicker once. */
void nperror(const char *s)
{
endwin();
perror(s);
doupdate();
else
return mbstrcasestr(start, needle);
}
/* This is a wrapper for the malloc() function that properly handles
@@ -354,7 +295,7 @@ void *nmalloc(size_t howmuch)
void *r = malloc(howmuch);
if (r == NULL && howmuch != 0)
die(_("nano is out of memory!"));
die(_("Nano is out of memory!\n"));
return r;
}
@@ -366,33 +307,39 @@ void *nrealloc(void *ptr, size_t howmuch)
void *r = realloc(ptr, howmuch);
if (r == NULL && howmuch != 0)
die(_("nano is out of memory!"));
die(_("Nano is out of memory!\n"));
return r;
}
/* Allocate and copy the first n characters of the given src string, after
* freeing the destination. Usage: "dest = mallocstrncpy(dest, src, n);". */
char *mallocstrncpy(char *dest, const char *src, size_t n)
/* Return an appropriately reallocated dest string holding a copy of src.
* Usage: "dest = mallocstrcpy(dest, src);". */
char *mallocstrcpy(char *dest, const char *src)
{
if (src == NULL)
src = "";
size_t count = strlen(src) + 1;
#ifndef NANO_TINY
if (src == dest)
fprintf(stderr, "\r*** Copying a string to itself -- please report a bug ***");
#endif
dest = charealloc(dest, n);
strncpy(dest, src, n);
dest = charealloc(dest, count);
strncpy(dest, src, count);
return dest;
}
/* Free the dest string and return a malloc'ed copy of src. Should be used as:
* "dest = mallocstrcpy(dest, src);". */
char *mallocstrcpy(char *dest, const char *src)
/* Return an allocated copy of the first count characters
* of the given string, and NUL-terminate the copy. */
char *measured_copy(const char *string, size_t count)
{
return mallocstrncpy(dest, src, (src == NULL) ? 1 : strlen(src) + 1);
char *thecopy = charalloc(count + 1);
memcpy(thecopy, string, count);
thecopy[count] = '\0';
return thecopy;
}
/* Return an allocated copy of the given string. */
char *copy_of(const char *string)
{
return measured_copy(string, strlen(string));
}
/* Free the string at dest and return the string at src. */
@@ -409,10 +356,10 @@ char *free_and_assign(char *dest, char *src)
* get_page_start(column) < COLS). */
size_t get_page_start(size_t column)
{
if (column < editwincols - 1 || ISSET(SOFTWRAP) || column == 0)
if (column + 2 < editwincols || ISSET(SOFTWRAP) || column == 0)
return 0;
else if (editwincols > 8)
return column - 7 - (column - 7) % (editwincols - 8);
return column - 6 - (column - 6) % (editwincols - 8);
else
return column - (editwincols - 2);
}
@@ -421,7 +368,7 @@ size_t get_page_start(size_t column)
* column position of the cursor. */
size_t xplustabs(void)
{
return strnlenpt(openfile->current->data, openfile->current_x);
return wideness(openfile->current->data, openfile->current_x);
}
/* Return the index in text of the character that (when displayed) will
@@ -434,7 +381,7 @@ size_t actual_x(const char *text, size_t column)
/* The current accumulated span, in columns. */
while (*text != '\0') {
int charlen = parse_mbchar(text, NULL, &width);
int charlen = advance_over(text, &width);
if (width > column)
break;
@@ -447,16 +394,15 @@ size_t actual_x(const char *text, size_t column)
/* A strnlen() with tabs and multicolumn characters factored in:
* how many columns wide are the first maxlen bytes of text? */
size_t strnlenpt(const char *text, size_t maxlen)
size_t wideness(const char *text, size_t maxlen)
{
size_t width = 0;
/* The screen display width to text[maxlen]. */
if (maxlen == 0)
return 0;
while (*text != '\0') {
size_t charlen = parse_mbchar(text, NULL, &width);
size_t charlen = advance_over(text, &width);
if (maxlen <= charlen)
break;
@@ -469,34 +415,37 @@ size_t strnlenpt(const char *text, size_t maxlen)
}
/* Return the number of columns that the given text occupies. */
size_t strlenpt(const char *text)
size_t breadth(const char *text)
{
size_t span = 0;
while (*text != '\0')
text += parse_mbchar(text, NULL, &span);
text += advance_over(text, &span);
return span;
}
/* Append a new magicline to the end of the buffer. */
/* Append a new magic line to the end of the buffer. */
void new_magicline(void)
{
openfile->filebot->next = make_new_node(openfile->filebot);
openfile->filebot->next->data = mallocstrcpy(NULL, "");
openfile->filebot->next->data = copy_of("");
openfile->filebot = openfile->filebot->next;
#ifndef NANO_TINY
openfile->filebot->extrarows = 0;
#endif
openfile->totsize++;
}
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
/* Remove the magicline from the end of the buffer, if there is one and
/* Remove the magic line from the end of the buffer, if there is one and
* it isn't the only line in the file. */
void remove_magicline(void)
{
if (openfile->filebot->data[0] == '\0' &&
openfile->filebot != openfile->fileage) {
openfile->filebot != openfile->filetop) {
openfile->filebot = openfile->filebot->prev;
free_filestruct(openfile->filebot->next);
delete_node(openfile->filebot->next);
openfile->filebot->next = NULL;
openfile->totsize--;
}
@@ -504,35 +453,35 @@ void remove_magicline(void)
#endif
#ifndef NANO_TINY
/* Set (top, top_x) and (bot, bot_x) to the start and end "coordinates" of
* the marked region. If right_side_up isn't NULL, set it to TRUE when the
* mark is at the top of the marked region, and to FALSE otherwise. */
void mark_order(const filestruct **top, size_t *top_x,
const filestruct **bot, size_t *bot_x, bool *right_side_up)
/* Return TRUE when the mark is before or at the cursor, and FALSE otherwise. */
bool mark_is_before_cursor(void)
{
if ((openfile->current->lineno == openfile->mark->lineno &&
openfile->current_x > openfile->mark_x) ||
openfile->current->lineno > openfile->mark->lineno) {
return (openfile->mark->lineno < openfile->current->lineno ||
(openfile->mark == openfile->current &&
openfile->mark_x <= openfile->current_x));
}
/* Return in (top, top_x) and (bot, bot_x) the start and end "coordinates"
* of the marked region. */
void get_region(linestruct **top, size_t *top_x, linestruct **bot, size_t *bot_x)
{
if (mark_is_before_cursor()) {
*top = openfile->mark;
*top_x = openfile->mark_x;
*bot = openfile->current;
*bot_x = openfile->current_x;
if (right_side_up != NULL)
*right_side_up = TRUE;
} else {
*bot = openfile->mark;
*bot_x = openfile->mark_x;
*top = openfile->current;
*top_x = openfile->current_x;
if (right_side_up != NULL)
*right_side_up = FALSE;
}
}
/* Get the set of lines to work on -- either just the current line, or the
* first to last lines of the marked region. When the cursor (or mark) is
* at the start of the last line of the region, exclude that line. */
void get_range(const filestruct **top, const filestruct **bot)
void get_range(linestruct **top, linestruct **bot)
{
if (!openfile->mark) {
*top = openfile->current;
@@ -540,7 +489,7 @@ void get_range(const filestruct **top, const filestruct **bot)
} else {
size_t top_x, bot_x;
mark_order(top, &top_x, bot, &bot_x, NULL);
get_region(top, &top_x, bot, &bot_x);
if (bot_x == 0 && *bot != *top && !also_the_last)
*bot = (*bot)->prev;
@@ -549,59 +498,32 @@ void get_range(const filestruct **top, const filestruct **bot)
}
}
/* Given a line number, return a pointer to the corresponding struct. */
filestruct *fsfromline(ssize_t lineno)
/* Return a pointer to the line that has the given line number. */
linestruct *line_from_number(ssize_t number)
{
filestruct *f = openfile->current;
linestruct *line = openfile->current;
if (lineno <= openfile->current->lineno)
while (f->lineno != lineno && f->prev != NULL)
f = f->prev;
if (line->lineno > number)
while (line->lineno != number)
line = line->prev;
else
while (f->lineno != lineno && f->next != NULL)
f = f->next;
while (line->lineno != number)
line = line->next;
if (f->lineno != lineno) {
statusline(ALERT, "Gone undo line -- please report a bug");
return NULL;
}
return f;
return line;
}
#endif /* !NANO_TINY */
/* Count the number of characters from begin to end, and return it. */
size_t get_totsize(const filestruct *begin, const filestruct *end)
size_t number_of_characters_in(const linestruct *begin, const linestruct *end)
{
const filestruct *line;
size_t totsize = 0;
const linestruct *line;
size_t count = 0;
/* Sum the number of characters (plus a newline) in each line. */
for (line = begin; line != end->next; line = line->next)
totsize += mbstrlen(line->data) + 1;
count += mbstrlen(line->data) + 1;
/* The last line of a file doesn't have a newline -- otherwise it
* wouldn't be the last line -- so subtract 1 when at EOF. */
if (line == NULL)
totsize--;
return totsize;
/* Do not count the final newline. */
return (count - 1);
}
#ifdef DEBUG
/* Dump the given buffer to stderr. */
void dump_filestruct(const filestruct *inptr)
{
if (inptr == openfile->fileage)
fprintf(stderr, "Dumping file buffer to stderr...\n");
else if (inptr == cutbuffer)
fprintf(stderr, "Dumping cutbuffer to stderr...\n");
else
fprintf(stderr, "Dumping a buffer to stderr...\n");
while (inptr != NULL) {
fprintf(stderr, "(%zd) %s\n", inptr->lineno, inptr->data);
inptr = inptr->next;
}
}
#endif /* DEBUG */

File diff suppressed because it is too large Load Diff

View File

@@ -5,11 +5,9 @@ pkgdata_DATA = asm.nanorc \
cmake.nanorc \
c.nanorc \
css.nanorc \
debian.nanorc \
default.nanorc \
elisp.nanorc \
fortran.nanorc \
gentoo.nanorc \
email.nanorc \
go.nanorc \
groff.nanorc \
guile.nanorc \
@@ -20,8 +18,7 @@ pkgdata_DATA = asm.nanorc \
lua.nanorc \
makefile.nanorc \
man.nanorc \
mgp.nanorc \
mutt.nanorc \
markdown.nanorc \
nanohelp.nanorc \
nanorc.nanorc \
nftables.nanorc \
@@ -31,16 +28,23 @@ pkgdata_DATA = asm.nanorc \
perl.nanorc \
php.nanorc \
po.nanorc \
postgresql.nanorc \
pov.nanorc \
python.nanorc \
ruby.nanorc \
rust.nanorc \
sh.nanorc \
spec.nanorc \
sql.nanorc \
tcl.nanorc \
tex.nanorc \
texinfo.nanorc \
xml.nanorc
EXTRA_DIST = $(pkgdata_DATA)
nobase_pkgdata_DATA = \
extra/ada.nanorc \
extra/debian.nanorc \
extra/fortran.nanorc \
extra/gentoo.nanorc \
extra/haskell.nanorc \
extra/povray.nanorc \
extra/spec.nanorc
EXTRA_DIST = $(pkgdata_DATA) $(nobase_pkgdata_DATA)

View File

@@ -1,4 +1,4 @@
## Here is an example for assembler.
## Syntax highlighting for assembler.
syntax asm "\.(S|s|asm)$"
magic "assembler source"
@@ -8,14 +8,11 @@ color red "\<[A-Z_]{2,}\>"
color brightgreen "\.(data|subsection|text)"
color green "\.(align|file|globl|global|hidden|section|size|type|weak)"
color brightyellow "\.(ascii|asciz|byte|double|float|hword|int|long|short|single|struct|word)"
icolor brightred "^[[:space:]]*[.0-9A-Z_]*:"
color brightred "^[[:space:]]*[.0-9A-Za-z_]*:"
color brightcyan "^[[:space:]]*#[[:space:]]*(define|undef|include|ifn?def|endif|elif|else|if|warning|error)"
# Strings.
color brightyellow "<[^= ]*>" ""(\\.|[^"])*""
# Multiline strings. This regex is VERY resource intensive,
# and sometimes colours things that shouldn't be coloured.
###color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
# Comments.
color brightblue "//.*"

View File

@@ -1,11 +1,11 @@
## Here is an example for Autoconf.
## Syntax highlighting for Autoconf.
syntax autoconf "\.(ac|m4)$"
comment "#"
# Keywords:
color yellow "\<(if|test|then|elif|else|fi|for|in|do|done)\>"
color yellow "(=|!=|&&|\|\|)"
color yellow "=|!=|&&|\|\|"
# Macros:
color cyan "\<[[:upper:]_[:digit:]]+\>"
@@ -14,13 +14,13 @@ color cyan "\<[[:upper:]_[:digit:]]+\>"
color red "\<[-_.0-9]+\>"
# Strings:
color red "\"[^"]*\"" "\'[^']*\'"
color red ""[^"]*"" "'[^']*'"
# Backticks:
color green "`[^`]*`"
# Error lines:
color brightred "^\*\*\*.*"
color brightred "^[[:space:]]*\*\*\*.*"
# Brackets:
color magenta "\[|\]|\(|\)"

View File

@@ -1,11 +1,12 @@
## Here is an example for awk.
## Syntax highlighting for AWK scripts.
syntax awk "\.awk$"
header "^#!.*awk"
magic "awk script"
comment "#"
# Records.
icolor brightred "\$[0-9A-Z_!@#$*?-]+"
color brightred "\$[0-9A-Za-z_!@#$*?-]+"
# Awk-set variables.
color red "\<(ARGC|ARGIND|ARGV|BINMODE|CONVFMT|ENVIRON|ERRNO|FIELDWIDTHS)\>"
color red "\<(FILENAME|FNR|FS|IGNORECASE|LINT|NF|NR|OFMT|OFS|ORS)\>"
@@ -13,13 +14,12 @@ color red "\<(PROCINFO|RS|RT|RSTART|RLENGTH|SUBSEP|TEXTDOMAIN)\>"
# Function declarations and special patterns.
color brightgreen "\<(function|extension|BEGIN|END)\>"
# Operators.
color green "(\{|\}|\(|\)|\;|\]|\[|\\|<|>|!|=|&|\+|-|\*|%|/|\?:|\^|\|)"
color green "\{|\}|\(|\)|\;|\[|\]|\\|<|>|!|=|&|\+|-|\*|%|/|\?:|\^|\|"
# Flow control.
color brightyellow "\<(for|if|while|do|else|in|delete|exit)\>"
color brightyellow "\<(break|continue|return)\>"
# I/O statements.
color brightgreen "\<(close|getline|next|nextfile|print|printf)\>"
color brightgreen "\<(system|fflush)\>"
color brightgreen "\<(close|fflush|getline|next|nextfile|print|printf|system)\>"
# Standard functions.
color magenta "\<(atan2|cos|exp|int|log|rand|sin|sqrt|srand)\>"
color magenta "\<(asort|asorti|gensub|gsub|index|length|match)\>"

View File

@@ -1,6 +1,7 @@
## Here is an example for C/C++.
## Syntax highlighting for C and C++ files.
syntax c "\.(c(c|pp|xx|\+\+)?|C)$" "\.(h(h|pp|xx)?|H)$" "\.ii?$"
syntax c "\.([ch](pp|xx)?|C|cc|c\+\+|cu|H|hh|ii?)$"
header "-\*-.*\<C(\+\+)?((;|\s).*)?-\*-"
magic "^(C|C\+\+) (source|program)"
comment "//"
@@ -10,12 +11,11 @@ color brightred "\<[A-Z_][0-9A-Z_]+\>"
color brightmagenta "^[[:space:]]*[A-Z_a-z]+:[[:space:]]*$"
color green "\<(float|double|bool|char|int|short|long|sizeof|enum|void|auto|static|const|struct|union|typedef|extern|(un)?signed|inline)\>"
color green "\<((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\>"
color green "\<([[:lower:]][[:lower:]_]*|(u_?)?int(8|16|32|64))_t\>"
color green "\<(class|namespace|template|public|protected|private|typename|this|friend|virtual|override|using|mutable|volatile|register|explicit)\>"
color brightyellow "\<(for|if|while|do|else|case|default|switch)\>"
color brightyellow "\<(try|throw|catch|operator|new|delete)\>"
color magenta "\<(goto|continue|break|return)\>"
color brightcyan "^[[:space:]]*#[[:space:]]*(define|include(_next)?|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)"
color brightmagenta "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
# GCC builtins.
@@ -23,10 +23,11 @@ color cyan "__attribute__[[:space:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidd
# Strings. In general you will want your strings and comments to come last,
# because highlighting rules are applied in the order they are read in.
color brightyellow ""([^"]|\\")*"" "<[^[:blank:]=]*>"
# Multiline strings. This regex is VERY resource intensive,
# and sometimes colours things that shouldn't be coloured.
###color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
color brightyellow ""([^"]|\\")*"" "#[[:space:]]*include[[:space:]]+<[^[:blank:]=]*>"
# Preprocessor directives.
color brightcyan start="^[[:space:]]*#[[:space:]]*(if(n?def)?|elif|warning|error|pragma)\>" end="(\`|[^\\])$"
color brightcyan "^[[:space:]]*#[[:space:]]*(define|else|endif|include(_next)?|undef)\>"
# Comments.
color brightblue "//.*"

View File

@@ -1,9 +1,9 @@
## Colouring for Changelogs.
## Syntax highlighting for Changelogs.
syntax changelog "Change[Ll]og.*"
syntax changelog "Change[Ll]og[^/]*$"
# Author lines.
color green "^(19|20).*$"
color green "^(19|20).*"
# Dates.
color red "^(19|20)[0-9-]{8}"
# Email addresses.
@@ -12,7 +12,7 @@ color yellow "<[^>]*@[^>]*>"
# Command-line options.
color cyan "[[:space:]]-[a-zA-Z\$]" "--[8a-z-]+"
# Bug and patch numbers.
color cyan "(BZ|bug|patch) #[0-9]+" "PR [[:alnum:]]+/[0-9]+"
color cyan "(BZ|bug|patch)[ ]#[0-9]+" "PR [[:alnum:]]+/[0-9]+"
# Probable constants, for variety.
color brightred "\<[A-Z_][0-9A-Z_]+\>"
# Key sequences.

View File

@@ -3,7 +3,7 @@
syntax cmake "(CMakeLists\.txt|\.cmake)$"
comment "#"
icolor green "^[[:space:]]*[A-Z0-9_]+"
color green "^[[:space:]]*[0-9A-Za-z_]+"
icolor brightyellow "^[[:space:]]*(include|include_directories|include_external_msproject)\>"
icolor brightgreen "^[[:space:]]*((else|end)?if|else|(end)?while|(end)?foreach|break)\>"
@@ -12,9 +12,8 @@ color brightgreen "[[:space:]](OR|AND|IS_NEWER_THAN|MATCHES|(STR|VERSION_)?(LESS
icolor brightred "^[[:space:]]*((end)?(function|macro)|return)"
icolor cyan start="\$(\{|ENV\{)" end="\}"
icolor cyan start="\$(ENV)?\{" end="\}"
color magenta "\<(APPLE|UNIX|WIN32|CYGWIN|BORLAND|MINGW|MSVC(_IDE|60|71|80|90)?)\>"
icolor brightblue "^([[:space:]]*)?#.*"
icolor brightblue "[[:space:]]#.*"
color brightblue "(^|[[:space:]])#.*"
color ,green "[[:space:]]+$"

View File

@@ -1,11 +1,20 @@
## Here is an example for CSS files.
## Syntax highlighting for CSS files.
syntax css "\.css$"
comment "/*|*/"
# First make everything red:
color brightred "."
# Then everything between braces yellow:
color brightyellow start="\{" end="\}"
color brightwhite start=":" end="([;^\{]|$)"
color brightblue ":active|:focus|:hover|:link|:visited|:link|:after|:before|$"
color brightblue start="\/\*" end="\\*/"
# Then everything after a colon white:
color brightwhite start=":" end="([;^{]|$)"
# Pseudo-classes:
color brightcyan ":(active|checked|focus|hover|link|visited|after|before)\>"
# Comments:
color brightblue start="/\*" end="\*/"
# Syntactic characters:
color green ";|:|\{|\}"

View File

@@ -1,4 +1,4 @@
## An example of a default syntax. The default syntax is used for
## This is an example of a default syntax. The default syntax is used for
## files that do not match any other syntax.
syntax default
@@ -11,7 +11,13 @@ color cyan "^[[:space:]]*#.*"
color ,red " + +"
# Nano's name, including version.
color brightred "(GNU )?nano [1-9]\.[0-9]\.[^[:space:][:punct:]]+"
color brightred "(GNU )?[Nn]ano [1-5]\.[0-9][-.[:alnum:]]*\>"
# Email addresses.
color magenta "<[[:alnum:].%_+-]+@[[:alnum:].-]+\.[[:alpha:]]{2,}>"
# Bracketed captions in certain config files.
color brightgreen "^\[[^][]+\]$"
# Control codes.
color latte "[[:cntrl:]]"

View File

@@ -1,4 +1,4 @@
## Here is an example for Emacs Lisp.
## Syntax highlighting for Emacs Lisp.
syntax elisp "\.el$"
magic "Lisp/Scheme program"
@@ -27,7 +27,7 @@ color brightred "\<(t|nil)\>"
# Keywords
color blue ":(\w|[?-])+"
# Strings
color yellow start="^[[:blank:]]+\"" end="[^\]\""
color yellow start="^[[:blank:]]+"" end="[^\]""
color yellow ""(\\.|[^"])*""
# Comments
color cyan "(^|[[:space:]]);.*$"
color cyan "(^|[[:space:]]);.*"

17
syntax/email.nanorc Normal file
View File

@@ -0,0 +1,17 @@
## Syntax highlighting for emails.
syntax email "\.eml$"
# Quoted lines.
color green "^>.*"
color cyan "^> ?>.*"
color yellow "^> ?> ?>.*"
# Email addresses.
color brightmagenta "<[^@]+@[^@]+>"
# URLs.
color brightblue "(https?|ftp)://\S+\.\S+[^\s.)]"
# Signatures, even quoted ones.
color yellow start="^>* ?-- $" end="^>* ?$"

39
syntax/extra/ada.nanorc Normal file
View File

@@ -0,0 +1,39 @@
## Syntax highlighting for Ada.
## Original author: Andreas K. Foerster
## License: GPL version 3 or newer
## Language reference: http://www.ada-auth.org/standards/12rm/html/RM-TTL.html
syntax ada "\.ad[abcs]$"
comment "--"
# This linter command leaves an ALI file in the working directory.
linter gcc -c -gnatc
# Reserved Words (RM 2.9)
icolor yellow "\<(abort|abs|abstract|accept|access|aliased|all|and|array|at)\>"
icolor yellow "\<(begin|body|case|constant|declare|delay|delta|do)\>"
icolor yellow "\<(else|elsif|end|entry|exception|exit|for|function|generic|goto)\>"
icolor yellow "\<(if|in|interface|is|limited|loop|mod|new|not|null|of|or|others|out|overriding)\>"
icolor yellow "\<(package|pragma|private|procedure|protected|raise|range|record|rem|renames)\>"
icolor yellow "\<(requeue|return|reverse|select|separate|some|subtype|synchronized)\>"
icolor yellow "\<(tagged|task|terminate|then|type|until|use|when|while|with|xor)\>"
# Separators / Operators
color magenta "'|&|\*|\+|\-|\.|\,|\/|:|;|\(|\)|<|>|\||="
# Attributes
color cyan "'[[:alnum:]]+"
# Numbers (RM 2.4)
color green "\<[0-9][0-9A-Fa-f_#.+-]*"
# Characters / Strings
color red "'.'" ""[^"]*""
# Comments
color brightblue "--.*"
# Trailing whitespace
color ,blue "[[:space:]]+$"

View File

@@ -1,6 +1,6 @@
## Here is an example for apt's sources.list.
## Syntax highlighting for apt's sources.list.
syntax sources.list "sources\.list(~|\.old|\.save)?$" "sources\.list\.d/.*\.list(~|\.old|\.save)?$"
syntax sources.list "sources\.list(\.d/.*\.list)?(~|\.old|\.save)?$"
comment "#"
# Coloring the deb lines, working from tail to head. First the

View File

@@ -1,6 +1,6 @@
## Here is an example for Fortran 90/95.
## Syntax highlighting for Fortran 90/95.
syntax fortran "\.(f|f90|f95)$"
syntax fortran "\.(f|for|f90|f95)$"
comment "!"
color red "\<[0-9]+\>"
@@ -34,7 +34,7 @@ icolor yellow "\<(.or.|repeat|select case|then|where|while)\>"
icolor magenta "\<(continue|cycle|exit|go?to|result|return)\>"
# Strings.
icolor yellow "<[^= ]*>" ""(\\.|[^"])*""
color yellow "<[^= ]*>" ""(\\.|[^"])*""
# Comments.
icolor blue "!.*"
color blue "!.*"

View File

@@ -1,5 +1,5 @@
## Here is an example for Gentoo ebuilds/eclasses,
## and (further down) one for Portage control files.
## Syntax highlighting for Gentoo ebuilds/eclasses,
## and (further down) for Portage control files.
syntax ebuild "\.e(build|class|blit)$"
comment "#"
@@ -17,7 +17,7 @@ color green "-(eq|ne|gt|lt|ge|le)\>"
## Variables... official portage ones in red, all others in bright red:
color brightred "\$[-0-9@*#?$!]" "\$[[:alpha:]_][[:alnum:]_]*"
color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:digit:]]|@)+\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
color red "\<(EAPI|ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|[HPR]?DEPEND|PROVIDE|PROPERTIES|REQUIRED_USE|RESTRICT|USERLAND)\>"
color red "\<(EAPI|ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|[BHPR]?DEPEND|PROVIDE|PROPERTIES|REQUIRED_USE|RESTRICT|USERLAND)\>"
color red "\<(S|E?D|T|PV|PF|P|PN|PR|PVR|A|CATEGORY|DISTDIR|FILESDIR|EPREFIX|E?ROOT|WORKDIR)\>"
color red "\<(AS|C(PP|XX)?|LD)FLAGS\>" "\<C(HOST|TARGET|BUILD)\>" "\<(MERGE_TYPE|REPLACING_VERSIONS|REPLACED_BY_VERSION)\>"
color red "\<EBUILD_PHASE(_FUNC)?\>"
@@ -39,7 +39,7 @@ color brightblue "\<tc-(arch(-kernel)?|export|has-(tls|openmp))\>"
## Common commands used in ebuilds:
color blue "\<(awk|cat|cd|chmod|chown|cp|echo|env|find|e?grep|ln|make|mkdir|mv|popd|printf|pushd|rm|rmdir|sed|set|tar|touch|unset|xargs)\>"
## Comments (doesn't work that well):
color yellow "(^|[[:space:]])#.*$"
color yellow "(^|[[:space:]])#.*"
## Strings (doesn't work that well):
color brightyellow ""(\\.|[^\"])*"" "'(\\.|[^'])*'"
## Trailing space is bad!
@@ -52,7 +52,7 @@ syntax /etc/portage "\.(accept_keywords|env|keywords|mask|unmask|use)(/.+)?$"
comment "#"
## Base text:
color green "^.+$"
color green ".+"
## Likely version and slot numbers:
color magenta "-[[:digit:].]+(_(alpha|beta|pre|rc|p)[[:digit:]]*)*(-r[[:digit:]]+)?([:[:space:]]|$)"
color magenta ":[^[:space:]]+([[:space:]]|$)"
@@ -67,7 +67,7 @@ color cyan "^[[:space:]]*[^/]*/"
## Masking regulators:
color brightmagenta "^[[:space:]]*(=|~|<|<=|>|>=)"
## Comments:
color yellow "#.*$"
color yellow "#.*"
## Trailing space is bad!
color ,green "[[:space:]]+$"
## Mixed whitespace is also bad.

View File

@@ -0,0 +1,40 @@
## Syntax highlighting for Haskell files.
## Original author: Alex Taber
## License: GPL version 3
syntax "haskell" "\.hs$"
comment "--"
# Keywords
color red "\<(as|case|of|class|data|default|deriving|do|forall|foreign|hiding|if|then|else|import|infix(l|r)?|instance|let|in|mdo|module|newtype|qualified|type|where)\>"
# Various symbols
color cyan "\||@|!|:|_|~|=|\\|;|\(\)|,|\[|\]|\{|\}"
# Operators
color magenta "==|/=|&&|\|\||<|>|<=|>="
# More symbols
color cyan "->|<-|=>"
color magenta "\.|\$"
# Data constructors
color magenta "\<(True|False|Nothing|Just|Left|Right|LT|EQ|GT)\>"
# Data classes
color magenta "\<(Bounded|Data|Enum|Eq|Floating|Fractional|Functor|Integral|Monad|MonadPlus|Num|Ord|Read|Real|RealFloat|RealFrac|Show|Typeable)\>"
# Special keyword
color brightred "undefined"
# Strings
color yellow ""([^\"]|\\.)*""
# Characters
color brightyellow "'([^\']|\\.)'"
# Comments
color green "--.*"
color green start="\{-" end="-\}"
# Trailing whitespace
color ,green "[[:space:]]+$"

Some files were not shown because too many files have changed in this diff Show More