Compare commits

...

86 Commits
v5.4 ... v5.5

Author SHA1 Message Date
Benno Schulenberg
4bc6d67052 po: update translations and regenerate POT file and PO files 2021-01-14 11:21:21 +01:00
Benno Schulenberg
7519a458b2 bump version numbers and add a news item for the 5.5 release 2021-01-14 11:08:05 +01:00
Benno Schulenberg
bc36813349 memory: avoid leaking the speller or linter command string, when invoked
This fixes https://savannah.gnu.org/bugs/?59854.
Reported-by: Mike Frysinger <vapier@gentoo.org>

Bug existed probably since version 2.9.6, commit 94347f08.
2021-01-11 19:36:34 +01:00
Benno Schulenberg
9bd7d62c10 tweaks: do not change the pointer, but move the content of the string 2021-01-11 19:22:40 +01:00
Benno Schulenberg
735a608e80 speller: strip leading whitespace from command, to avoid a sneaky crash
This completes the fix for https://savannah.gnu.org/bugs/?59855.
2021-01-11 19:15:35 +01:00
Benno Schulenberg
71402bb7e9 feedback: wipe the status bar by default after 20 keystrokes
The 26 keystrokes inherited from Pico is a weird number, and too long.
2021-01-11 16:18:35 +01:00
Benno Schulenberg
9266fa6657 speller: do an internal spell check when --speller is an empty string
This fixes https://savannah.gnu.org/bugs/?59855.
Indirectly-reported-by: Mike Frysinger <vapier@gentoo.org>

Bug existed since version 2.9.6, commit 94347f08.
2021-01-11 16:05:54 +01:00
Benno Schulenberg
6360e4170a copyright: update the years for the FSF 2021-01-11 14:22:51 +01:00
Benno Schulenberg
dcb072d04b build: fix compilation for --enable-{tiny,help,multibuffer}
The mark is not available in the tiny version,
nor can the cursor get hidden by --markmatch.
2021-01-11 13:24:10 +01:00
Benno Schulenberg
4c6ce3c39d minibar: when the overnext character has zero width too, show its code
Requested-by: Peter Passchier <peter@passchier.net>
2021-01-09 12:44:10 +01:00
Benno Schulenberg
41fd09706d minibar: when the next character has zero width, show its code too
This allows seeing that an accented character is not a single code point
but composed from a base character plus a combining character.
2021-01-09 12:44:10 +01:00
Benno Schulenberg
24e5f956d0 build: fix compilation when configured with --disable-utf8
This fixes https://savannah.gnu.org/bugs/?59842.
Reported-by: Ruben van Wyk <admin@knwip.com>

Bug existed since commit 5129e718 from two days ago.
2021-01-08 12:05:55 +01:00
Benno Schulenberg
f602613a9a tweaks: avoid compilation warnings on 32-bit machine plus newer compiler 2021-01-07 16:17:17 +01:00
Benno Schulenberg
ba124ffa5d gnulib: update to its current upstream state 2021-01-07 15:20:45 +01:00
Benno Schulenberg
d30ddf0add tweaks: correct a translator hint 2021-01-07 15:18:57 +01:00
Benno Schulenberg
e66c7d0f8d tweaks: put the new options in a consistent order in the code 2021-01-07 14:27:49 +01:00
Benno Schulenberg
7b9567719c tweaks: reshuffle an option, to have two related ones grouped together
Options --stateflags and --minibar are slightly related; it looks
better to not have them separated by an unrelated option.
2021-01-07 14:27:49 +01:00
Benno Schulenberg
04d33e7981 tweaks: reword the description of an option
Avoid using the word "state" in the description of --minibar,
as it could cause confusion with the --stateflags option.
2021-01-07 14:27:49 +01:00
Benno Schulenberg
c62d12ca93 tweaks: drop a small optimization for invalid UTF-8 starter bytes 2021-01-07 10:37:35 +01:00
Benno Schulenberg
297633d086 minibar: show Unicode codes when in a UTF-8 locale
The only exception is 0x00.  But that code should really not occur
in a normal text.  And if it does, it is fine that it stands out.
2021-01-07 10:36:14 +01:00
Benno Schulenberg
10b99d8ac0 chars: short-circuit determining the width of characters under U+0300
The combining characters (that are zero-width) start at U+0300.
After that it's pretty much chaos, width-wise.

The mbwidth() function is not called for control characters (whose
representation takes up two columns), as they are handled separately.

The calls of mbwidth() that *can* happen with a control character as
argument are only to determine whether the character is zero-width,
and then it doesn't matter whether the exact width is 1 or 2.
2021-01-06 20:15:14 +01:00
Benno Schulenberg
0693d6974a minibar: represent bytes as 0xNN and valid Unicode code points as U+NNNN
An invalid UTF-8 starter byte should not be represented in the same way
as a valid Unicode character.

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

Bug existed since two weeks ago, since the mini-bar code was merged.
2021-01-06 15:10:11 +01:00
Benno Schulenberg
5129e718d7 chars: speed up the handling of invalid UTF-8 starter bytes
The first byte of a multi-byte UTF-8 sequence must be in the range
0xC2...0xFF.  Any other byte cannot be a starter byte and can thus
immediately be treated as a single byte.
2021-01-06 12:41:49 +01:00
Benno Schulenberg
8c406bc875 tweaks: change an intermediate variable to a better one 2021-01-06 10:05:35 +01:00
Benno Schulenberg
c53da9aa5b tweaks: fold some conditions into bitwise masks, for efficiency 2021-01-05 11:49:03 +01:00
Benno Schulenberg
e7a420eca7 prompt: suppress the ">" character always when exactly at the right edge
When the tail of the answer still fits exactly on the screen, the ">"
continuation character should not be shown -- also when the start of
the answer is "scrolled off" to the left.

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

Bug existed in this form since version 4.0, commit 56181896.
2021-01-04 15:39:29 +01:00
Benno Schulenberg
1236341746 tweaks: reshuffle a condition, to probably avoid an unneeded calculation
Also frob three comments.
2021-01-04 11:37:47 +01:00
Benno Schulenberg
c96c343fac tweaks: avoid computing the cursor column twice, and the "page" too 2021-01-04 11:31:07 +01:00
Benno Schulenberg
02f1fec497 prompt: restore a workaround for a cursor misplacement bug in ncurses
When making small movements in the lower right corner, ncurses can
get confused about where the cursor actually is -- a double-width
character seems to throw its calculations off.

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

Bug existed since version 5.4, commit 39705c60.
2021-01-03 13:52:31 +01:00
Benno Schulenberg
a102e45e90 tweaks: elide a variable, by using a reallocation instead
Also unwrap a line.
2021-01-03 11:35:11 +01:00
Benno Schulenberg
86c9b9b54e files: when truncating a file name, give an indication of this
Show leading dots for the truncated part, or (if there is no room
at all) show just an underscore instead of the file name.

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

Bug existed since version 2.9.3, commit 97cbbb0c.
2021-01-03 11:32:14 +01:00
Benno Schulenberg
e14127b843 rcfile: rename 'nowrap' toggle to 'breaklonglines', to match the option
Now all toggle functions have the same name as their corresponding
long command-line option.  Also, all names now indicate the effect
of the toggle when it is invoked from a default setting.
2021-01-02 17:14:07 +01:00
Benno Schulenberg
67cdd71352 tweaks: push back the deprecation of the 'set nowrap' option
It is probably the most used option in a .nanorc file.
Keep accepting it for three more years.
2021-01-02 16:55:17 +01:00
Benno Schulenberg
6a88fe8807 tweaks: fold two similar and three identical cases together 2021-01-01 20:27:30 +01:00
Benno Schulenberg
90f6f25e31 oops: use the correct condition for checking the last line will change
Only when the replacement string (in 'answer') is non-empty will the
last line be changed and thus possibly a magic lined added.
2021-01-01 20:09:42 +01:00
Benno Schulenberg
0f4bb64eaf undo: remove the added magic line when a replacement caused one
This fixes https://savannah.gnu.org/bugs/?59796.

Bug existed since before version 2.2.4.
2021-01-01 19:48:03 +01:00
Benno Schulenberg
45efe28f05 minibar: drop the side spaces before suppressing the state flags
Also, consistently keep the right-side elements at least two spaces
away from the modification asterisk.
2020-12-30 19:03:27 +01:00
Benno Schulenberg
c8c7986f65 minibar: allow the number-of-lines to overrule also the state flags 2020-12-30 16:14:38 +01:00
Benno Schulenberg
f437117bf2 tweaks: avoid hitting negative values when using size_t 2020-12-30 16:07:29 +01:00
Benno Schulenberg
33e882e6f8 minibar: allow the number-of-lines to overrule location + character code
When space is too tight to show all three elements, show the report on
the number of lines in preference to the current location and character
code.  The latter two will be shown again upon the next keystroke, so
there is little harm in hiding them for a moment.
2020-12-29 20:10:18 +01:00
Benno Schulenberg
bad591d43d tweaks: adjust the indentation after the previous change
Also, reduce the scope of a variable, and rehuffle two lines.
2020-12-29 15:55:14 +01:00
Benno Schulenberg
7b48458380 minibar: suppress some elements when there is no room to show them
This fixes https://savannah.gnu.org/bugs/?59767.

Bug existed since last week, since the mini-bar code was merged.
2020-12-29 15:54:28 +01:00
Benno Schulenberg
1e16a3f411 syntax: nanorc: colorize 'bookstyle' as a valid option
This fixes https://savannah.gnu.org/bugs/?59769.
Reported-by: Tiago Almeida <tjamadeira@gmail.com>

Bug existed since version 5.0, since --bookstyle was introduced.
2020-12-29 09:36:42 +01:00
Benno Schulenberg
6a3ba2ab50 syntax: sh: recognize shebangs with any shell after 'env', not just 'sh'
(Inspired by a complaint seen somewhere on Stackoverflow.)
2020-12-25 17:05:02 +01:00
Benno Schulenberg
1878168ae3 tweaks: condense the description of how to report a bug
The list of bugs is quite short these days, and most of them are
feature requests, so asking the user to check whether a particular
problem has already been reported doesn't make much sense.
2020-12-25 16:45:31 +01:00
Benno Schulenberg
545709a165 weeding: remove some obsolete information from the README
The distinction between a stable series (even minor number) and
a development series (uneven) was abandonned five years ago.
This information is no longer helpful.
2020-12-25 16:34:08 +01:00
Benno Schulenberg
ca398fdfdf docs: explain the purpose of --markmatch / -^ / 'set markmatch'
Also, colorize 'set markmatch' as a valid option in a nanorc file.
2020-12-24 11:49:49 +01:00
Benno Schulenberg
d0bceb1449 options: add --markmatch and -^ for activating the select-match behavior
And add, of course, the 'set markmatch' nanorc option.
2020-12-24 11:49:22 +01:00
Benno Schulenberg
caef3128eb search: suppress the cursor when highlighting a match
Having a block cursor present when highlighting a match...
does not look nice.  So... hide the cursor until the next
keystroke, unless --showcursor or 'set showcursor' is used.
2020-12-24 11:49:22 +01:00
Benno Schulenberg
856a6ecde3 search: set the mark at the end of a found match so it gets highlighted
Not only does the match get highlighted (for better visibility), but
this also allows deleting the match with a single keystroke (^K, or
<Del> or <Bsp> when --zap is used) and then type something else.

This https://savannah.gnu.org/bugs/?59655.
Requested-by: Noam Sondak <noamso@gmail.com>
2020-12-24 11:49:22 +01:00
Benno Schulenberg
e353203010 docs: explain the effect of --minibar / -_ / 'set minibar'
Also, colorize 'set minibar' as valid option in a nanorc file.
2020-12-23 17:15:06 +01:00
Benno Schulenberg
f1fc66060f minibar: add a percentage that shows how far the cursor is into the file
Requested-by: Peter Passchier <peter@passchier.net>
2020-12-23 12:17:06 +01:00
Benno Schulenberg
ba4f4bdc64 minibar: show the line count in the bar (at startup and when saving)
Show the line count too when switching between buffers.
2020-12-23 12:17:06 +01:00
Benno Schulenberg
2b6c08b955 minibar: add an [x/y] "counter" when multiple files are open 2020-12-23 12:17:06 +01:00
Benno Schulenberg
b86f7868d1 feedback: differentiate between remarks, mistakes, and information
Remarks are about unsurprising things but it's good to give feedback
on them; "mistakes" are unexpected things, and get colored like an
error; and information is something that the user requested and thus
needs to stay on the status bar until the next keystroke.
2020-12-23 12:17:06 +01:00
Benno Schulenberg
54995defd2 input: intercept ^Z also when --minibar is active
For some reason, calling halfdelay() undoes the ISIG mask.
So, mask keyboard interrupts again immediately after the call.

Reported-by: Peter Passchier <peter@passchier.net>
2020-12-23 12:17:06 +01:00
Benno Schulenberg
b89bc2cce6 minibar: show the info bar again some 0.8 seconds after a message
Instead of redisplaying the minibar only upon the next keystroke
(when some feedback message is shown on the status bar), time the
waiting for the keystroke out after four fifths of a second, then
redisplay the minibar and continue the wait.
2020-12-23 12:17:06 +01:00
Benno Schulenberg
8f24ffaaef options: add --minibar and -_ for activating basic state-information bar 2020-12-23 12:17:05 +01:00
Benno Schulenberg
d31cc373de display: add code for showing minimal state-information bar at the bottom
When activated, it suppresses the title bar, and suppresses feedback
on the status bar for toggles whose effect is obvious or whose state
is already shown in the minibar.

This addresses https://savannah.gnu.org/bugs/?58152,
and addresses https://savannah.gnu.org/bugs/?58789.
2020-12-23 12:17:05 +01:00
Benno Schulenberg
f52f503c38 tweaks: move the displaying of the state letters into a separate function 2020-12-23 12:17:05 +01:00
Benno Schulenberg
8939163659 tweaks: reshuffle two lines, and rename a variable to a plain word 2020-12-22 19:23:40 +01:00
Benno Schulenberg
265bdd94f1 mouse: do not offset the shortcuts by 'margin' when using --linenumbers
The bottom window (the prompt bar and the shortcuts) does not shift
its position when line numbers are active, so mouse clicks in this
window should be not be compensated for the line-numbers margin.

This fixes https://savannah.gnu.org/bugs/?59749.
Indirectly-reported-by: ObeliX <ObeliX-@gmx.de>

Bug existed since version 2.7.0, since line numbers were introduced.
2020-12-22 19:15:32 +01:00
OIX
d1c412d200 mouse: update title bar (the M flag) when the click is on the cursor
Clicking on the cursor toggles the mark, meaning that the flags in
the title bar should be updated when --stateflags is active.

This fixes https://savannah.gnu.org/bugs/?59747.
Indirectly-reported-by: ObeliX <ObeliX-@gmx.de>

Signed-off-by: OIX <ObeliX-@gmx.de>
2020-12-22 14:21:28 +01:00
Benno Schulenberg
5c4c30e26b display: do not show the state flags in the help viewer or file browser
The state flags are relevant only when editing.

This fixes https://savannah.gnu.org/bugs/?59744.
Indirectly-reported-by: ObeliX <ObeliX-@gmx.de>

Bug existed since version 5.3, since --stateflags was introduced.
2020-12-21 14:59:18 +01:00
Benno Schulenberg
1b65d39722 docs: insert links to the mailing-list archives into the README
To make those archives easier to find.
2020-12-21 12:29:41 +01:00
Benno Schulenberg
96e4fec31c tweaks: use a boolean instead of an enumeration of two values 2020-12-19 16:40:21 +01:00
Benno Schulenberg
208146f2f2 syntax: go: add author and license line
In the original submission (https://savannah.gnu.org/patch/?8189)
the submitter said: "I hereby put it into the public domain."

Public-domain license: https://directory.fsf.org/wiki/License:CC0

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2020-12-10 15:48:28 +01:00
Benno Schulenberg
89e84e76c3 build: fix compilation when configured with --enable-tiny
The BACK and DEL symbols are used as parameters for do_deletion().
2020-12-09 16:27:34 +01:00
Benno Schulenberg
c44a5e960e syntax: nanorc: colorize 'set promptcolor' as valid 2020-12-07 11:19:48 +01:00
Benno Schulenberg
c1bd54dd47 tweaks: move 'set indicator' to its alphabetical place in the manual
Also, reword some option descriptions, to mention the effect of the
option instead of what the user should give as argument.
2020-12-06 16:34:42 +01:00
Benno Schulenberg
3efb9c3a2e docs: mention the new 'set promptcolor' option 2020-12-06 16:34:42 +01:00
Benno Schulenberg
b87d7f69fc options: accept 'set promptcolor' for setting the color of the prompt bar
When it is not specified, it defaults to the value for 'titlecolor'.
2020-12-06 16:34:42 +01:00
Benno Schulenberg
8ba653f395 docs: mention in NEWS that some workarounds were removed
It would have been good to mention this for the 5.4 release,
but when all is well, no one should be affected by it.
2020-12-06 16:34:18 +01:00
Benno Schulenberg
c6501beba7 tweaks: reshuffle some more lines, to have most #defines together 2020-12-06 12:30:52 +01:00
Benno Schulenberg
dbf522b750 tweaks: reshuffle some lines, to have most #includes near the beginning 2020-12-06 11:49:37 +01:00
Benno Schulenberg
651e97ceef tweaks: reshuffle some lines, to group things better 2020-12-06 11:40:25 +01:00
Benno Schulenberg
d8500f0467 tweaks: remove some #ifdefs that were there only for Slang 2020-12-05 12:34:17 +01:00
Benno Schulenberg
a9bc118178 docs: remove all mentions of Slang 2020-12-05 12:23:06 +01:00
Benno Schulenberg
903942b4f0 build: remove the '--with-slang' configure option 2020-12-05 12:17:48 +01:00
Benno Schulenberg
7ebf5f52b8 tweaks: clean up after the previous change 2020-12-05 12:12:11 +01:00
Benno Schulenberg
4f7593b704 general: remove support for Slang
Slang has too many bugs to be useful.

This addresses https://savannah.gnu.org/bugs/?59210.
2020-12-05 11:57:08 +01:00
Benno Schulenberg
2157738a18 tweaks: correct two comments after the previous changes 2020-12-04 17:03:10 +01:00
Benno Schulenberg
681d11c0cf tweaks: rename a variable, to be similar to its sister 2020-12-04 16:57:17 +01:00
Benno Schulenberg
d96f296b8e input: interpret a keystroke as Meta only when an earlier escape was solo
This allows using <Esc> <Esc> <letter> in a macro as an alternative
for <Ctrl+letter>, but it does require that one does not type <Esc>
by accident when recording a macro as it might modify the subsequent
keystroke when the macro is replayed.

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

Bug existed since version 3.0, commit ecc9211a.
2020-12-04 16:35:28 +01:00
Benno Schulenberg
048ab0ee0b tweaks: reduce the scope of a static variable 2020-12-04 16:30:28 +01:00
Benno Schulenberg
16dff06a4c tweaks: simplify a bit of logic 2020-12-04 16:27:34 +01:00
70 changed files with 21818 additions and 20910 deletions

View File

@@ -1,3 +1,96 @@
Changes between v5.4 and v5.5:
------------------------------
Benno Schulenberg (84):
build: fix compilation for --enable-{tiny,help,multibuffer}
build: fix compilation when configured with --disable-utf8
build: fix compilation when configured with --enable-tiny
build: remove the '--with-slang' configure option
bump version numbers and add a news item for the 5.5 release
chars: short-circuit determining the width of characters under U+0300
chars: speed up the handling of invalid UTF-8 starter bytes
copyright: update the years for the FSF
display: add code for showing minimal state-information bar at the bottom
display: do not show the state flags in the help viewer or file browser
docs: explain the effect of --minibar / -_ / 'set minibar'
docs: explain the purpose of --markmatch / -^ / 'set markmatch'
docs: insert links to the mailing-list archives into the README
docs: mention in NEWS that some workarounds were removed
docs: mention the new 'set promptcolor' option
docs: remove all mentions of Slang
feedback: differentiate between remarks, mistakes, and information
feedback: wipe the status bar by default after 20 keystrokes
files: when truncating a file name, give an indication of this
general: remove support for Slang
gnulib: update to its current upstream state
input: intercept ^Z also when --minibar is active
input: interpret a keystroke as Meta only when an earlier escape was solo
memory: avoid leaking the speller or linter command string, when invoked
minibar: add an [x/y] "counter" when multiple files are open
minibar: add a percentage that shows how far the cursor is into the file
minibar: allow the number-of-lines to overrule also the state flags
minibar: allow the number-of-lines to overrule location + character code
minibar: drop the side spaces before suppressing the state flags
minibar: represent bytes as 0xNN and valid Unicode code points as U+NNNN
minibar: show the info bar again some 0.8 seconds after a message
minibar: show the line count in the bar (at startup and when saving)
minibar: show Unicode codes when in a UTF-8 locale
minibar: suppress some elements when there is no room to show them
minibar: when the next character has zero width, show its code too
minibar: when the overnext character has zero width too, show its code
mouse: do not offset the shortcuts by 'margin' when using --linenumbers
oops: use the correct condition for checking the last line will change
options: accept 'set promptcolor' for setting the color of the prompt bar
options: add --markmatch and -^ for activating the select-match behavior
options: add --minibar and -_ for activating basic state-information bar
prompt: restore a workaround for a cursor misplacement bug in ncurses
prompt: suppress the ">" character always when exactly at the right edge
rcfile: rename 'nowrap' toggle to 'breaklonglines', to match the option
search: set the mark at the end of a found match so it gets highlighted
search: suppress the cursor when highlighting a match
speller: do an internal spell check when --speller is an empty string
speller: strip leading whitespace from command, to avoid a sneaky crash
syntax: go: add author and license line
syntax: nanorc: colorize 'bookstyle' as a valid option
syntax: nanorc: colorize 'set promptcolor' as valid
syntax: sh: recognize shebangs with any shell after 'env', not just 'sh'
tweaks: adjust the indentation after the previous change
tweaks: avoid compilation warnings on 32-bit machine plus newer compiler
tweaks: avoid computing the cursor column twice, and the "page" too
tweaks: avoid hitting negative values when using size_t
tweaks: change an intermediate variable to a better one
tweaks: clean up after the previous change
tweaks: condense the description of how to report a bug
tweaks: correct a translator hint
tweaks: correct two comments after the previous changes
tweaks: do not change the pointer, but move the content of the string
tweaks: drop a small optimization for invalid UTF-8 starter bytes
tweaks: elide a variable, by using a reallocation instead
tweaks: fold some conditions into bitwise masks, for efficiency
tweaks: fold two similar and three identical cases together
tweaks: move 'set indicator' to its alphabetical place in the manual
tweaks: move the displaying of the state letters into a separate function
tweaks: push back the deprecation of the 'set nowrap' option
tweaks: put the new options in a consistent order in the code
tweaks: reduce the scope of a static variable
tweaks: remove some #ifdefs that were there only for Slang
tweaks: rename a variable, to be similar to its sister
tweaks: reshuffle a condition, to probably avoid an unneeded calculation
tweaks: reshuffle an option, to have two related ones grouped together
tweaks: reshuffle some lines, to group things better
tweaks: reshuffle some lines, to have most #includes near the beginning
tweaks: reshuffle some more lines, to have most #defines together
tweaks: reshuffle two lines, and rename a variable to a plain word
tweaks: reword the description of an option
tweaks: simplify a bit of logic
tweaks: use a boolean instead of an enumeration of two values
undo: remove the added magic line when a replacement caused one
weeding: remove some obsolete information from the README
OIX (1):
mouse: update title bar (the M flag) when the click is on the cursor
Changes between v5.3 and v5.4:
------------------------------

View File

@@ -2,6 +2,8 @@ Improvements in GNU nano
========================
Since 5.0:
- Option --minibar reduces the interface to a bottom bar with basic info.
- Option --markmatch marks the search result, for better visibility.
- The cursor skips over combining characters, <Del> deletes them together
with the character they combine with, but <Bsp> deletes them separately.
- For using libmagic the option --magic or -! or 'set magic' is required.

19
NEWS
View File

@@ -1,8 +1,27 @@
2021.01.14 - GNU nano 5.5 "Rebecca"
• Option 'set minibar' makes nano suppress the title bar and instead
show a bar with basic editing information at the bottom: file name
(plus an asterisk when the buffer is modified), the cursor position
(line,column), the character under the cursor (U+xxxx), the flags
that --stateflags normally shows, plus the percentage of the buffer
that is above the cursor.
• With 'set promptcolor' the color combination of the prompt bar can
be changed, to allow contrasting it with the mini bar (which always
has the same color as the title bar).
• Option 'set markmatch' highlights the result of a successful search
by putting the mark at the end of the match, making the match more
visible. It also suppresses the cursor until the next keystroke.
(If you dislike the hiding of the cursor, use 'set showcursor'.)
• The bindable toggle 'nowrap' has been renamed to 'breaklonglines',
to match the corresponding option, like for all other toggles.
• Support for Slang has been removed.
2020.12.02 - GNU nano 5.4 "Terre des hommes"
• Moving the cursor now skips over combining characters (and other
zero-width characters). Deleting a character deletes also any
succeeding zero-width characters, but backspacing deletes just
one character at a time.
• Workarounds for older ncurses and older libvtes were removed.
2020.10.07 - GNU nano 5.3 "Revolution!"
• Option 'set stateflags' makes nano show the state of auto-indenting,

17
README
View File

@@ -62,18 +62,15 @@ Mailing Lists
To subscribe, send email to <name>-request@gnu.org with a subject
of "subscribe", where <name> is the list you want to subscribe to.
The archives of the development and help mailing lists are here:
https://lists.gnu.org/archive/html/nano-devel/
https://lists.gnu.org/archive/html/help-nano/
Bug Reports
To report a bug, please file a description of the problem on nano's
bug tracker (https://savannah.gnu.org/bugs/?group=nano -- hover on
"Bugs", then click "Submit new"). The issue may have already been
reported, so please look first.
Current Status
Since version 2.5.0, GNU nano has abandoned the distinction between
a stable and a development branch: it is now on a "rolling" release
-- fixing bugs and adding new features go hand in hand.
If you find a bug, please file a detailed description of the problem
on nano's bug tracker: https://savannah.gnu.org/bugs/?group=nano.
Copyright Years

View File

@@ -2,7 +2,7 @@
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="387d654cabd7bc1594b1fc8d195cd9b66f820296"
gnulib_hash="30820c2d7c9f04a6a0aa6cdaaea09c9672f502a1"
modules="
futimens

View File

@@ -1,6 +1,6 @@
# Configuration for GNU nano - a small and user-friendly text editor
#
# Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc.
# Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc.
# Copyright (C) 2014, 2017 Mike Frysinger
#
# GNU nano is free software: you can redistribute it and/or modify
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see https://www.gnu.org/licenses/.
AC_INIT([GNU nano], [5.4], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [5.5], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.14])
@@ -90,13 +90,6 @@ 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
@@ -354,194 +347,6 @@ AS_HELP_STRING([--enable-altrcname], [Specify an alternate rcfile name (default:
AC_DEFINE_UNQUOTED(RCFILE_NAME, "$enableval", [Specify an alternate rcfile name (default: .nanorc).]) rcfilename=$enableval
fi])
AC_MSG_CHECKING([whether to use slang])
CURSES_LIB_NAME=""
AC_ARG_WITH(slang,
AS_HELP_STRING([--with-slang[=DIR]], [Use the slang library instead of curses]),
[ case "$with_slang" in
no)
AC_MSG_RESULT(no)
;;
*)
AC_MSG_RESULT(yes)
if test x$with_slang != xyes; then
# Add additional search path.
LDFLAGS="-L$with_slang/lib $LDFLAGS"
CPPFLAGS="-I$with_slang/include $CPPFLAGS"
fi
if test "x$enable_utf8" != xno; then
AC_CHECK_HEADER(slcurses.h,
AC_MSG_CHECKING([for SLutf8_enable in -lslang])
_libs=$LIBS
LIBS="$LIBS -lslang"
AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
SLutf8_enable(1);
return 0;
}],
[AC_MSG_RESULT(yes)
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
CURSES_LIB_WIDE=yes
if test x$with_slang != xyes; then
CURSES_LIB="-L${with_slang}/lib -lslang"
else
CURSES_LIB="-lslang"
fi
CURSES_LIB_NAME=slang],
[AC_MSG_RESULT(no)
# We might need the term library.
for termlib in ncurses curses termcap terminfo termlib; do
AC_CHECK_LIB([${termlib}], tputs, [tcap="-l$termlib"])
test -n "$tcap" && break
done
AC_MSG_CHECKING([for SLutf8_enable in -lslang $tcap])
LIBS="$LIBS $tcap"
AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
SLutf8_enable(1);
return 0;
}],
[AC_MSG_RESULT(yes)
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
CURSES_LIB_WIDE=yes
if test x$with_slang != xyes; then
CURSES_LIB="-L${with_slang}/lib -lslang $tcap"
else
CURSES_LIB="-lslang $tcap"
fi
CURSES_LIB_NAME=slang],
[AC_MSG_RESULT(no)
# We might need the math library.
AC_MSG_CHECKING([for SLutf8_enable in -lslang $tcap -lm])
LIBS="$LIBS -lm"
AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
SLutf8_enable(1);
return 0;
}],
[AC_MSG_RESULT(yes)
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
CURSES_LIB_WIDE=yes
if test x$with_slang != xyes; then
CURSES_LIB="-L${with_slang}/lib -lslang $tcap -lm"
else
CURSES_LIB="-lslang $tcap -lm"
fi
CURSES_LIB_NAME=slang],
[AC_MSG_RESULT(no)],
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
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. 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
# Reset libs if the above slang tests failed.
if test "x$enable_utf8" != xno; then
LIBS=$_libs
fi
AC_CHECK_HEADER(slcurses.h,
AC_MSG_CHECKING([for SLtt_initialize in -lslang])
_libs=$LIBS
LIBS="$LIBS -lslang"
AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
SLtt_initialize(NULL);
return 0;
}],
[AC_MSG_RESULT(yes)
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
if test x$with_slang != xyes; then
CURSES_LIB="-L${with_slang}/lib -lslang"
else
CURSES_LIB="-lslang"
fi
CURSES_LIB_NAME=slang],
[AC_MSG_RESULT(no)
# We might need the term library.
for termlib in ncurses curses termcap terminfo termlib; do
AC_CHECK_LIB([${termlib}], tputs, [tcap="-l$termlib"])
test -n "$tcap" && break
done
AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap])
LIBS="$LIBS $tcap"
AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
SLtt_initialize(NULL);
return 0;
}],
[AC_MSG_RESULT(yes)
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
if test x$with_slang != xyes; then
CURSES_LIB="-L${with_slang}/lib -lslang $tcap"
else
CURSES_LIB="-lslang $tcap"
fi
CURSES_LIB_NAME=slang],
[AC_MSG_RESULT(no)
# We might need the math library.
AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap -lm])
LIBS="$LIBS -lm"
AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
SLtt_initialize(NULL);
return 0;
}],
[AC_MSG_RESULT(yes)
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
if test x$with_slang != xyes; then
CURSES_LIB="-L${with_slang}/lib -lslang $tcap -lm"
else
CURSES_LIB="-lslang $tcap -lm"
fi
CURSES_LIB_NAME=slang],
[AC_MSG_RESULT(no)],
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
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. 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
LIBS=$_libs
fi
if test x$with_slang != xyes; then
LDFLAGS=${_ldflags}
fi
;;
esac], [AC_MSG_RESULT(no)])
dnl Checks for functions.
if test "x$enable_utf8" != xno; then

View File

@@ -89,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>5.4</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<blockquote><p>The current version of nano <i>should</i> be <b>5.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>
<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%">

View File

@@ -1,4 +1,4 @@
.\" Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc.
.\" Copyright (C) 1999-2011, 2013-2021 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:
@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 5.4" "December 2020"
.TH NANO 1 "version 5.5" "January 2021"
.SH NAME
nano \- Nano's ANOther editor, inspired by Pico
@@ -329,6 +329,12 @@ Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
.BR \-z ", " \-\-suspendable
Allow the user to suspend the editor (with \fB^Z\fR by default).
.TP
.BR \-^ ", " \-\-markmatch
After a search, set the mark at the end of the found match
(if there is any) so that it gets highlighted. This makes
the match more visible, but also allows deleting the match
with a single keystroke.
.TP
.BR \-% ", " \-\-stateflags
Use the top-right corner of the screen for showing some state flags:
\fBI\fR when auto-indenting, \fBM\fR when the mark is on, \fBL\fR when
@@ -337,6 +343,20 @@ and \fBS\fR when soft-wrapping.
When the buffer is modified, a star (\fB*\fR) is shown after the
filename in the center of the title bar.
.TP
.BR \-_ ", " \-\-minibar
Suppress the title bar and instead show information about
the current buffer at the bottom of the screen, in the space
for the status bar. In this "minibar" the file name is shown
on the left, followed by an asterisk if the buffer has been modified.
On the right are displayed the current line and column number, the
code of the character under the cursor (in Unicode format: U+xxxx),
the same flags as are shown by \fB\-\-stateflags\fR, and a percentage
that expresses how far the cursor is into the file (linewise).
When a file is loaded or saved, and also when switching between buffers,
the number of lines in the buffer is displayed after the file name.
This number is cleared upon the next keystroke, or replaced with an
[i/n] counter when multiple buffers are open.
.TP
.BR \-! ", " \-\-magic
When neither the file's name nor its first line give a clue,
try using libmagic to determine the applicable syntax.

View File

@@ -8,8 +8,8 @@
@smallbook
@set EDITION 0.5
@set VERSION 5.4
@set UPDATED December 2020
@set VERSION 5.5
@set UPDATED January 2021
@dircategory Editors
@direntry
@@ -23,7 +23,7 @@
@titlepage
@title GNU @command{nano}
@subtitle a small and friendly text editor
@subtitle version 5.4
@subtitle version 5.5
@author Chris Allegretta
@page
@@ -33,7 +33,7 @@ This manual documents the GNU @command{nano} editor.
This manual is part of the GNU @command{nano} distribution.@*
@sp 4
Copyright @copyright{} 1999-2009, 2014-2020 Free Software Foundation, Inc.
Copyright @copyright{} 1999-2009, 2014-2021 Free Software Foundation, Inc.
@sp 1
This document is dual-licensed. You may distribute and/or modify it
@@ -63,7 +63,7 @@ e-mail: @email{chrisa@@asty.org}@*
@node Top
@top
This manual documents the GNU @command{nano} editor, version 5.4.
This manual documents the GNU @command{nano} editor, version 5.5.
@menu
* Introduction::
@@ -468,6 +468,13 @@ Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
Enable the ability to suspend @command{nano} using the system's suspend
keystroke (usually @kbd{^Z}).
@item -^
@itemx --markmatch
After a search, set the mark at the end of the found match
(if there is any) so that it gets highlighted. This makes
the match more visible, but also allows deleting the match
with a single keystroke.
@item -%
@itemx --stateflags
Use the top-right corner of the screen for showing some state flags:
@@ -477,6 +484,21 @@ and @code{S} when soft-wrapping.
When the buffer is modified, a star (@code{*}) is shown after the
filename in the center of the title bar.
@item -_
@itemx --minibar
Suppress the title bar and instead show information about
the current buffer at the bottom of the screen, in the space
for the status bar. In this "minibar" the file name is shown
on the left, followed by an asterisk if the buffer has been modified.
On the right are displayed the current line and column number, the
code of the character under the cursor (in Unicode format: U+xxxx),
the same flags as are shown by @code{--stateflags}, and a percentage
that expresses how far the cursor is into the file (linewise).
When a file is loaded or saved, and also when switching between buffers,
the number of lines in the buffer is displayed after the file name.
This number is cleared upon the next keystroke, or replaced with an
[i/n] counter when multiple buffers are open.
@item -!
@itemx --magic
When neither the file's name nor its first line give a clue,
@@ -878,6 +900,11 @@ text. (The color of the stripe can be changed with @code{set stripecolor}.)
Save the last hundred search strings and replacement strings and
executed commands, so they can be easily reused in later sessions.
@item 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.
@item set jumpyscrolling
Scroll the buffer contents per half-screen instead of per line.
@@ -899,6 +926,12 @@ try using libmagic to determine the applicable syntax.
(Calling libmagic can be relatively time consuming.
It is therefore not done by default.)
@item set markmatch
After a search, set the mark at the end of the found match
(if there is any) so that it gets highlighted. This makes
the match more visible, but also allows deleting the match
with a single keystroke.
@anchor{@code{set matchbrackets}}
@item set matchbrackets "@var{characters}"
Specify the opening and closing brackets that can be found by bracket
@@ -906,6 +939,20 @@ 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 "@t{(<[@{)>]@}}".
@item set minibar
Suppress the title bar and instead show information about
the current buffer at the bottom of the screen, in the space
for the status bar. In this "minibar" the file name is shown
on the left, followed by an asterisk if the buffer has been modified.
On the right are displayed the current line and column number, the
code of the character under the cursor (in Unicode format: U+xxxx),
the same flags as are shown by @code{set stateflags}, and a percentage
that expresses how far the cursor is into the file (linewise).
When a file is loaded or saved, and also when switching between buffers,
the number of lines in the buffer is displayed after the file name.
This number is cleared upon the next keystroke, or replaced with an
[i/n] counter when multiple buffers are open.
@item set morespace
Deprecated option since it has become the default setting.
When needed, use @code{unset emptyline} instead.
@@ -951,10 +998,10 @@ The cursor position is remembered for the 200 most-recently edited files.
@item set preserve
Preserve the XON and XOFF keys (@kbd{^Q} and @kbd{^S}).
@item 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.
@item set promptcolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
Use this color combination for the prompt bar.
(When this option is not specified, the colors of the title bar are used.)
@xref{@code{set functioncolor}} for valid color names.
@item set punct "@var{characters}"
Set the characters treated as closing punctuation when justifying
@@ -1631,8 +1678,9 @@ is the beginning of a paragraph.
Toggles whether cutting text will cut the whole line or just from the current cursor
position to the end of the line.
@item nowrap
@item breaklonglines
Toggles whether long lines will be hard-wrapped to the next line.
(The old name of this function, 'nowrap', is deprecated.)
@item tabstospaces
Toggles whether typed tabs will be converted to spaces.
@@ -1915,8 +1963,8 @@ Exclude Native Language support. This will disable the use of any
available GNU @command{nano} translations.
@item --enable-utf8
Include support for reading and writing Unicode files. This will require
either a wide version of curses, or a UTF-8-enabled version of Slang.
Include support for reading and writing Unicode files.
This requires a wide version of the curses library.
@item --disable-utf8
Exclude support for reading and writing Unicode files. Normally the
@@ -1927,10 +1975,6 @@ You can use this or the previous option to override that detection.
Use the file with the given @var{name} (in the user's home directory)
as nano's settings file, instead of the default @code{.nanorc}.
@item --with-slang
Compile @command{nano} against Slang instead of against ncurses or other
curses libraries.
@end table
@html

View File

@@ -1,4 +1,4 @@
.\" Copyright (C) 2003-2011, 2013-2020 Free Software Foundation, Inc.
.\" Copyright (C) 2003-2011, 2013-2021 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:
@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 5.4" "December 2020"
.TH NANORC 5 "version 5.5" "January 2021"
.SH NAME
nanorc \- GNU nano's configuration file
@@ -138,7 +138,7 @@ 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 \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for the function descriptions
Use this color combination for the concise function descriptions
in the two help lines at the bottom of the screen.
See \fBset titlecolor\fR for more details.
.TP
@@ -159,7 +159,7 @@ and how much of the buffer is covered by the viewport.
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
Use this color combination for the shortcut key combos
in the two help lines at the bottom of the screen.
See \fBset titlecolor\fR for more details.
.TP
@@ -176,12 +176,32 @@ try using libmagic to determine the applicable syntax.
(Calling libmagic can be relatively time consuming.
It is therefore not done by default.)
.TP
.B set markmatch
After a search, set the mark at the end of the found match
(if there is any) so that it gets highlighted. This makes
the match more visible, but also allows deleting the match
with a single keystroke.
.TP
.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 minibar
Suppress the title bar and instead show information about
the current buffer at the bottom of the screen, in the space
for the status bar. In this "minibar" the file name is shown
on the left, followed by an asterisk if the buffer has been modified.
On the right are displayed the current line and column number, the
code of the character under the cursor (in Unicode format: U+xxxx),
the same flags as are shown by \fBset stateflags\fR, and a percentage
that expresses how far the cursor is into the file (linewise).
When a file is loaded or saved, and also when switching between buffers,
the number of lines in the buffer is displayed after the file name.
This number is cleared upon the next keystroke, or replaced with an
[i/n] counter when multiple buffers are open.
.TP
.B set morespace
Deprecated option since it has become the default setting.
When needed, use \fBunset emptyline\fR instead.
@@ -214,7 +234,7 @@ Deprecated option since it has become the default setting.
When needed, use \fBunset breaklonglines\fR instead.
.TP
.B set numbercolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for line numbers.
Use this color combination for line numbers.
See \fBset titlecolor\fR for more details.
.TP
.B set operatingdir "\fIdirectory\fP"
@@ -230,6 +250,11 @@ The cursor position is remembered for the 200 most-recently edited files.
.B set preserve
Preserve the XON and XOFF keys (\fB^Q\fR and \fB^S\fR).
.TP
.B set promptcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the prompt bar.
(When this option is not specified, the colors of the title bar are used.)
See \fBset titlecolor\fR for more details.
.TP
.BI "set punct """ characters """
Set the characters treated as closing punctuation when justifying
paragraphs. This may not include blank characters. Only the
@@ -267,13 +292,13 @@ 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 scrollercolor \fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for the indicator alias "scrollbar".
Use this color combination for the indicator alias "scrollbar".
(On terminal emulators that link to a libvte older than version 0.55,
using a background color here does not work correctly.)
See \fBset titlecolor\fR for more details.
.TP
.B set selectedcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for selected text.
Use this color combination for selected text.
See \fBset titlecolor\fR for more details.
.TP
.B set showcursor
@@ -309,11 +334,11 @@ When the buffer is modified, a star (\fB*\fR) is shown after the
filename in the center of the title bar.
.TP
.B set statuscolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for the status bar.
Use this color combination for the status bar.
See \fBset titlecolor\fR for more details.
.TP
.B set stripecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for the vertical guiding stripe.
Use this color combination for the vertical guiding stripe.
See \fBset titlecolor\fR for more details.
.TP
.B set suspendable
@@ -327,7 +352,7 @@ greater than 0. The default value is \fB8\fR.
Convert typed tabs to spaces.
.TP
.B set titlecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for the title bar.
Use this color combination for the title bar.
Valid names for the foreground and background colors are:
.BR red ", " green ", " blue ", " magenta ", " yellow ", " cyan ", "
.BR white ", and " black .
@@ -893,8 +918,9 @@ is the beginning of a paragraph.
Toggles whether cutting text will cut the whole line or just from the current cursor
position to the end of the line.
.TP
.B nowrap
.B breaklonglines
Toggles whether long lines will be hard-wrapped to the next line.
(The old name of this function, 'nowrap', is deprecated.)
.TP
.B tabstospaces
Toggles whether typed tabs will be converted to spaces.

View File

@@ -1,4 +1,4 @@
.\" Copyright (C) 2002-2007, 2014-2020 Free Software Foundation, Inc.
.\" Copyright (C) 2002-2007, 2014-2021 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:
@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH RNANO 1 "version 5.4" "December 2020"
.TH RNANO 1 "version 5.5" "January 2021"
.SH NAME
rnano \- a restricted nano

View File

@@ -79,11 +79,17 @@
## Fall back to slow libmagic to try and determine an applicable syntax.
# set magic
# After a search, set the mark at the end of the found match (if any).
# set markmatch
## The opening and closing brackets that can be found by bracket
## searches. They cannot contain blank characters. The former set must
## come before the latter set, and both must be in the same order.
# set matchbrackets "(<[{)>]}"
## Suppress title bar and show file name and editor state at the bottom.
# set minibar
## 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
@@ -203,6 +209,7 @@
## Paint the interface elements of nano. These are examples;
## by default there are no colors, except for errorcolor.
# set titlecolor bold,lightwhite,blue
# set promptcolor lightwhite,lightblack
# set statuscolor bold,lightwhite,green
# set errorcolor bold,lightwhite,red
# set selectedcolor lightwhite,magenta
@@ -214,6 +221,7 @@
## In root's .nanorc you might want to use:
# set titlecolor bold,lightwhite,magenta
# set promptcolor black,yellow
# set statuscolor bold,lightwhite,magenta
# set errorcolor bold,lightwhite,red
# set selectedcolor lightwhite,cyan

1085
po/bg.po

File diff suppressed because it is too large Load Diff

1111
po/ca.po

File diff suppressed because it is too large Load Diff

1086
po/cs.po

File diff suppressed because it is too large Load Diff

1085
po/da.po

File diff suppressed because it is too large Load Diff

1093
po/de.po

File diff suppressed because it is too large Load Diff

1095
po/eo.po

File diff suppressed because it is too large Load Diff

1093
po/es.po

File diff suppressed because it is too large Load Diff

1085
po/eu.po

File diff suppressed because it is too large Load Diff

1085
po/fi.po

File diff suppressed because it is too large Load Diff

1098
po/fr.po

File diff suppressed because it is too large Load Diff

1088
po/ga.po

File diff suppressed because it is too large Load Diff

1085
po/gl.po

File diff suppressed because it is too large Load Diff

1119
po/hr.po

File diff suppressed because it is too large Load Diff

1085
po/hu.po

File diff suppressed because it is too large Load Diff

1084
po/id.po

File diff suppressed because it is too large Load Diff

1085
po/it.po

File diff suppressed because it is too large Load Diff

1084
po/ja.po

File diff suppressed because it is too large Load Diff

1110
po/ko.po

File diff suppressed because it is too large Load Diff

1112
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1091
po/nb.po

File diff suppressed because it is too large Load Diff

1095
po/nl.po

File diff suppressed because it is too large Load Diff

1085
po/nn.po

File diff suppressed because it is too large Load Diff

1375
po/pl.po

File diff suppressed because it is too large Load Diff

1129
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1086
po/ro.po

File diff suppressed because it is too large Load Diff

2164
po/ru.po

File diff suppressed because it is too large Load Diff

1087
po/sl.po

File diff suppressed because it is too large Load Diff

1119
po/sr.po

File diff suppressed because it is too large Load Diff

1266
po/sv.po

File diff suppressed because it is too large Load Diff

1089
po/tr.po

File diff suppressed because it is too large Load Diff

1092
po/uk.po

File diff suppressed because it is too large Load Diff

1084
po/vi.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* browser.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2015-2016, 2020 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* chars.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2016-2020 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -179,8 +179,8 @@ char control_mbrep(const char *c, bool isdata)
/* Return the width in columns of the given (multibyte) character. */
int mbwidth(const char *c)
{
/* Ask for the width only when the character isn't plain ASCII. */
if ((signed char)*c <= 0) {
/* Only characters beyond U+02FF can be other than one column wide. */
if ((unsigned char)*c > 0xCB) {
wchar_t wc;
int width;
@@ -227,7 +227,7 @@ 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) {
if ((unsigned char)*pointer > 0xC1) {
int length = mblen(pointer, MAXCHARLEN);
return (length < 0 ? 1 : length);
@@ -243,7 +243,7 @@ size_t mbstrlen(const char *pointer)
while (*pointer != '\0') {
#ifdef ENABLE_UTF8
if ((signed char)*pointer < 0) {
if ((unsigned char)*pointer > 0xC1) {
int length = mblen(pointer, MAXCHARLEN);
pointer += (length < 0 ? 1 : length);
@@ -265,7 +265,7 @@ int collect_char(const char *string, char *thechar)
#ifdef ENABLE_UTF8
/* If this is a UTF-8 starter byte, get the number of bytes of the character. */
if ((signed char)*string < 0) {
if ((unsigned char)*string > 0xC1) {
charlen = mblen(string, MAXCHARLEN);
/* When the multibyte sequence is invalid, only take the first byte. */

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* color.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017, 2020 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -58,6 +58,8 @@ void set_interface_colorpairs(void)
interface_color_pair[index] = A_NORMAL;
else if (index == GUIDE_STRIPE)
interface_color_pair[index] = A_REVERSE;
else if (index == PROMPT_BAR)
interface_color_pair[index] = interface_color_pair[TITLE_BAR];
else if (index == ERROR_MESSAGE) {
init_pair(index + 1, COLOR_WHITE, COLOR_RED);
interface_color_pair[index] = COLOR_PAIR(index + 1) | A_BOLD;

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* cut.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014 Mark Majeres *
* Copyright (C) 2016, 2018-2020 Benno Schulenberg *
* *
@@ -712,7 +712,7 @@ void paste_text(void)
/* The leftedge where we started the paste. */
if (cutbuffer == NULL) {
statusbar(_("Cutbuffer is empty"));
statusline(AHEM, _("Cutbuffer is empty"));
return;
}

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* definitions.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -41,10 +41,55 @@
#include <limits.h>
#endif
/* Set a default value for PATH_MAX if there isn't one. */
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#include <dirent.h>
#include <regex.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/stat.h>
/* Prefer wide ncurses over normal ncurses over curses. */
#if defined(HAVE_NCURSESW_NCURSES_H)
#include <ncursesw/ncurses.h>
#elif defined(HAVE_NCURSES_H)
#include <ncurses.h>
#else
#include <curses.h>
#endif
/* Native language support. */
#ifdef ENABLE_NLS
#ifdef HAVE_LIBINTL_H
#include <libintl.h>
#endif
#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)
#endif
/* For marking a string on which gettext() will be called later. */
#define gettext_noop(string) (string)
#define N_(string) gettext_noop(string)
/* If we aren't using an ncurses with mouse support, then
* exclude the mouse routines, as they are useless then. */
#ifndef NCURSES_MOUSE_VERSION
#undef ENABLE_MOUSE
#endif
#if defined(ENABLE_WRAPPING) || defined(ENABLE_JUSTIFY)
#define ENABLED_WRAPORJUSTIFY 1
#endif
/* Suppress warnings for __attribute__((warn_unused_result)). */
#define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0)
@@ -56,66 +101,6 @@
#define ISSET(flag) ((FLAGS(flag) & FLAGMASK(flag)) != 0)
#define TOGGLE(flag) FLAGS(flag) ^= FLAGMASK(flag)
/* In UTF-8 a character is at most six bytes long. */
#ifdef ENABLE_UTF8
#define MAXCHARLEN 6
#else
#define MAXCHARLEN 1
#endif
/* Set a default value for PATH_MAX if there isn't one. */
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
#ifdef USE_SLANG
/* Slang support. */
#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
/* Ncurses support. */
#elif defined(HAVE_NCURSESW_NCURSES_H)
#include <ncursesw/ncurses.h>
#elif defined(HAVE_NCURSES_H)
#include <ncurses.h>
#else
/* Curses support. */
#include <curses.h>
#endif /* CURSES_H */
#ifdef ENABLE_NLS
/* Native language support. */
#ifdef HAVE_LIBINTL_H
#include <libintl.h>
#endif
#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)
#endif
#define gettext_noop(string) (string)
#define N_(string) gettext_noop(string)
/* Mark a string that will be sent to gettext() later. */
#include <dirent.h>
#include <regex.h>
#include <signal.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. */
#ifndef NCURSES_MOUSE_VERSION
#undef ENABLE_MOUSE
#endif
#if defined(ENABLE_WRAPPING) || defined(ENABLE_JUSTIFY)
#define ENABLED_WRAPORJUSTIFY 1
#endif
#define BACKWARD FALSE
#define FORWARD TRUE
@@ -126,9 +111,137 @@
#define REPLACING 1
#define INREGION 2
/* In UTF-8 a character is at most six bytes long. */
#ifdef ENABLE_UTF8
#define MAXCHARLEN 6
#else
#define MAXCHARLEN 1
#endif
/* The default width of a tab in spaces. */
#define WIDTH_OF_TAB 8
/* The default number of columns from end of line where wrapping occurs. */
#define COLUMNS_FROM_EOL 8
/* The default comment character when a syntax does not specify any. */
#define GENERAL_COMMENT_CHARACTER "#"
/* The maximum number of search/replace history strings saved. */
#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)
#ifdef ENABLE_COLOR
#define THE_DEFAULT -1
#define BAD_COLOR -2
/* Flags for indicating how a multiline regex pair apply to a line. */
#define CNONE (1<<1)
/* The start/end regexes don't cover this line at all. */
#define CBEGINBEFORE (1<<2)
/* The start regex matches on an earlier line, the end regex on this one. */
#define CENDAFTER (1<<3)
/* The start regex matches on this line, the end regex on a later one. */
#define CWHOLELINE (1<<4)
/* The start regex matches on an earlier line, the end regex on a later one. */
#define CSTARTENDHERE (1<<5)
/* Both the start and end regexes match within this line. */
#define CWOULDBE (1<<6)
/* An unpaired start match is on or before this line. */
#endif
/* Basic control codes. */
#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 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
/* A special keycode for plugging into the input stream after a suspension. */
#define KEY_FLUSH KEY_F0
#ifndef NANO_TINY
/* A special keycode for when we get a SIGWINCH (a window resize). */
#define KEY_WINCH -2
/* Some extra flags for the undo function. */
#define WAS_BACKSPACE_AT_EOF (1<<1)
#define WAS_WHOLE_LINE (1<<2)
#define INCLUDED_LAST_LINE (1<<3)
#define MARK_WAS_SET (1<<4)
#define CURSOR_WAS_AT_HEAD (1<<5)
#endif /* !NANO_TINY */
/* Identifiers for the different menus. */
#define MMAIN (1<<0)
#define MWHEREIS (1<<1)
#define MREPLACE (1<<2)
#define MREPLACEWITH (1<<3)
#define MGOTOLINE (1<<4)
#define MWRITEFILE (1<<5)
#define MINSERTFILE (1<<6)
#define MEXECUTE (1<<7)
#define MHELP (1<<8)
#define MSPELL (1<<9)
#define MBROWSER (1<<10)
#define MWHEREISFILE (1<<11)
#define MGOTODIR (1<<12)
#define MYESNO (1<<13)
#define MLINTER (1<<14)
#define MFINDINHELP (1<<15)
/* This is an abbreviation for all menus except Help and Browser and YesNo. */
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\
MEXECUTE|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER)
#ifndef NANO_TINY
#define MSOME MMOST|MBROWSER
#else
#define MSOME MMAIN|MBROWSER
#endif
/* Enumeration types. */
@@ -137,17 +250,13 @@ typedef enum {
} format_type;
typedef enum {
VACUUM, HUSH, NOTICE, MILD, ALERT
VACUUM, HUSH, REMARK, INFO, NOTICE, AHEM, MILD, ALERT
} message_type;
typedef enum {
OVERWRITE, APPEND, PREPEND
} kind_of_writing_type;
typedef enum {
SOFTMARK, HARDMARK
} mark_type;
typedef enum {
CENTERING, FLOWING, STATIONARY
} update_type;
@@ -166,6 +275,78 @@ typedef enum {
COUPLE_BEGIN, COUPLE_END, OTHER
} undo_type;
/* The elements of the interface that can be colored differently. */
enum {
TITLE_BAR = 0,
LINE_NUMBER,
GUIDE_STRIPE,
SCROLL_BAR,
SELECTED_TEXT,
PROMPT_BAR,
STATUS_BAR,
ERROR_MESSAGE,
KEY_COMBO,
FUNCTION_TAG,
NUMBER_OF_ELEMENTS
};
/* Enumeration used in the flags array. See the definition of FLAGMASK. */
enum {
DONTUSE = 0,
CASE_SENSITIVE,
CONSTANT_SHOW,
NO_HELP,
SUSPENDABLE,
NO_WRAP,
AUTOINDENT,
VIEW_MODE,
USE_MOUSE,
USE_REGEXP,
SAVE_ON_EXIT,
CUT_FROM_CURSOR,
BACKWARDS_SEARCH,
MULTIBUFFER,
SMOOTH_SCROLL,
REBIND_DELETE,
RAW_SEQUENCES,
NO_CONVERT,
MAKE_BACKUP,
INSECURE_BACKUP,
NO_SYNTAX,
PRESERVE,
HISTORYLOG,
RESTRICTED,
SMART_HOME,
WHITESPACE_DISPLAY,
MORE_SPACE,
TABS_TO_SPACES,
QUICK_BLANK,
WORD_BOUNDS,
NO_NEWLINES,
BOLD_TEXT,
SOFTWRAP,
POSITIONLOG,
LOCKING,
NOREAD_MODE,
MAKE_IT_UNIX,
TRIM_BLANKS,
SHOW_CURSOR,
LINE_NUMBERS,
NO_PAUSES,
AT_BLANKS,
AFTER_ENDS,
LET_THEM_ZAP,
BREAK_LONG_LINES,
JUMPY_SCROLLING,
EMPTY_LINE,
INDICATOR,
BOOKSTYLE,
STATEFLAGS,
USE_MAGIC,
MINIBAR,
MARK_MATCH
};
/* Structure types. */
#ifdef ENABLE_COLOR
typedef struct colortype {
@@ -212,7 +393,7 @@ typedef struct syntaxtype {
/* 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;
augmentstruct *augmentations;
/* List of extendsyntax commands to apply when loaded. */
regexlisttype *extensions;
/* The list of extensions that this syntax applies to. */
@@ -252,20 +433,6 @@ typedef struct lintstruct {
struct lintstruct *prev;
/* Previous error. */
} lintstruct;
/* Flags that indicate how a multiline regex applies to a line. */
#define CNONE (1<<1)
/* Yay, regex doesn't apply to this line at all! */
#define CBEGINBEFORE (1<<2)
/* Regex starts on an earlier line, ends on this one. */
#define CENDAFTER (1<<3)
/* Regex starts on this line and ends on a later one. */
#define CWHOLELINE (1<<4)
/* Whole line engulfed by the regex, start < me, end > me. */
#define CSTARTENDHERE (1<<5)
/* Regex starts and ends within this line. */
#define CWOULDBE (1<<6)
/* An unpaired start match on or before this line. */
#endif /* ENABLE_COLOR */
/* More structure types. */
@@ -378,8 +545,8 @@ typedef struct openfilestruct {
/* 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. */
bool softmark;
/* Whether a marked region was made by holding Shift. */
format_type fmt;
/* The file's format -- Unix or DOS or Mac. */
char *lock_filename;
@@ -466,185 +633,3 @@ typedef struct completion_word {
struct completion_word *next;
} completion_word;
#endif
/* The elements of the interface that can be colored differently. */
enum
{
TITLE_BAR = 0,
LINE_NUMBER,
GUIDE_STRIPE,
SCROLL_BAR,
SELECTED_TEXT,
STATUS_BAR,
ERROR_MESSAGE,
KEY_COMBO,
FUNCTION_TAG,
NUMBER_OF_ELEMENTS
};
/* Enumeration used in the flags array. See the definition of FLAGMASK. */
enum
{
DONTUSE,
CASE_SENSITIVE,
CONSTANT_SHOW,
NO_HELP,
SUSPENDABLE,
NO_WRAP,
AUTOINDENT,
VIEW_MODE,
USE_MOUSE,
USE_REGEXP,
SAVE_ON_EXIT,
CUT_FROM_CURSOR,
BACKWARDS_SEARCH,
MULTIBUFFER,
SMOOTH_SCROLL,
REBIND_DELETE,
RAW_SEQUENCES,
NO_CONVERT,
MAKE_BACKUP,
INSECURE_BACKUP,
NO_SYNTAX,
PRESERVE,
HISTORYLOG,
RESTRICTED,
SMART_HOME,
WHITESPACE_DISPLAY,
MORE_SPACE,
TABS_TO_SPACES,
QUICK_BLANK,
WORD_BOUNDS,
NO_NEWLINES,
BOLD_TEXT,
SOFTWRAP,
POSITIONLOG,
LOCKING,
NOREAD_MODE,
MAKE_IT_UNIX,
TRIM_BLANKS,
SHOW_CURSOR,
LINE_NUMBERS,
NO_PAUSES,
AT_BLANKS,
AFTER_ENDS,
LET_THEM_ZAP,
BREAK_LONG_LINES,
JUMPY_SCROLLING,
EMPTY_LINE,
INDICATOR,
BOOKSTYLE,
STATEFLAGS,
USE_MAGIC
};
/* Flags for the menus in which a given function should be present. */
#define MMAIN (1<<0)
#define MWHEREIS (1<<1)
#define MREPLACE (1<<2)
#define MREPLACEWITH (1<<3)
#define MGOTOLINE (1<<4)
#define MWRITEFILE (1<<5)
#define MINSERTFILE (1<<6)
#define MEXECUTE (1<<7)
#define MHELP (1<<8)
#define MSPELL (1<<9)
#define MBROWSER (1<<10)
#define MWHEREISFILE (1<<11)
#define MGOTODIR (1<<12)
#define MYESNO (1<<13)
#define MLINTER (1<<14)
#define MFINDINHELP (1<<15)
/* This is an abbreviation for all menus except Help and Browser and YesNo. */
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\
MEXECUTE|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER)
#ifndef NANO_TINY
#define MSOME MMOST|MBROWSER
#else
#define MSOME MMAIN|MBROWSER
#endif
/* Basic control codes. */
#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 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
#define KEY_FLUSH 0xFF /* Clipped error code. */
#else
#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
/* Some extra flags for the undo function. */
#define WAS_BACKSPACE_AT_EOF (1<<1)
#define WAS_WHOLE_LINE (1<<2)
#define INCLUDED_LAST_LINE (1<<3)
#define MARK_WAS_SET (1<<4)
#define CURSOR_WAS_AT_HEAD (1<<5)
#endif /* !NANO_TINY */
/* 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
/* The default comment character when a syntax does not specify any. */
#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 largest size_t number that doesn't have the high bit set. */
#define HIGHEST_POSITIVE ((~(size_t)0) >> 1)

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* files.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2015-2020 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -81,6 +81,7 @@ void make_new_buffer(void)
#endif
#ifndef NANO_TINY
openfile->mark = NULL;
openfile->softmark = FALSE;
openfile->fmt = NIX_FILE;
@@ -97,6 +98,26 @@ void make_new_buffer(void)
#endif
}
/* Return the given file name in a way that fits within the given space. */
char *crop_to_fit(const char *name, int room)
{
char *clipped;
if (breadth(name) <= room)
return display_string(name, 0, room, FALSE, FALSE);
if (room < 4)
return copy_of("_");
clipped = display_string(name, breadth(name) - room + 3, room, FALSE, FALSE);
clipped = nrealloc(clipped, strlen(clipped) + 4);
memmove(clipped + 3, clipped, strlen(clipped) + 1);
clipped[0] = '.'; clipped[1] = '.'; clipped[2] = '.';
return clipped;
}
#ifndef NANO_TINY
/* Delete the lockfile. Return TRUE on success, and FALSE otherwise. */
bool delete_lockfile(const char *lockfilename)
@@ -225,7 +246,7 @@ char *do_lockfile(const char *filename, bool ask_the_user)
else if (stat(lockfilename, &fileinfo) != -1) {
char *lockbuf, *question, *pidstring, *postedname, *promptstr;
static char lockprog[11], lockuser[17];
int lockfd, lockpid, room, choice;
int lockfd, lockpid, choice;
ssize_t readamt;
if ((lockfd = open(lockfilename, O_RDONLY)) < 0) {
@@ -266,19 +287,8 @@ char *do_lockfile(const char *filename, bool ask_the_user)
/* TRANSLATORS: The second %s is the name of the user, the third that of the editor. */
question = _("File %s is being edited by %s (with %s, PID %s); open anyway?");
room = COLS - breadth(question) + 7 - breadth(lockuser) -
breadth(lockprog) - breadth(pidstring);
if (room < 4)
postedname = copy_of("_");
else if (room < breadth(filename)) {
char *fragment = display_string(filename,
breadth(filename) - room + 3, room, FALSE, FALSE);
postedname = nmalloc(strlen(fragment) + 4);
strcpy(postedname, "...");
strcat(postedname, fragment);
free(fragment);
} else
postedname = display_string(filename, 0, room, FALSE, FALSE);
postedname = crop_to_fit(filename, COLS - breadth(question) - breadth(lockuser) -
breadth(lockprog) - breadth(pidstring) + 7);
/* Allow extra space for username (14), program name (8), PID (8),
* and terminating \0 (1), minus the %s (2) for the file name. */
@@ -500,7 +510,13 @@ void mention_name_and_linecount(void)
{
size_t count = openfile->filebot->lineno -
(openfile->filebot->data[0] == '\0' ? 1 : 0);
#ifndef NANO_TINY
if (ISSET(MINIBAR)) {
report_size = TRUE;
return;
}
if (openfile->fmt != NIX_FILE)
/* TRANSLATORS: First %s is file name, second %s is file format. */
statusline(HUSH, P_("%s -- %zu line (%s)", "%s -- %zu lines (%s)", count),
@@ -519,7 +535,7 @@ void redecorate_after_switch(void)
{
/* If only one file buffer is open, there is nothing to update. */
if (openfile == openfile->next) {
statusbar(_("No more open file buffers"));
statusline(AHEM, _("No more open file buffers"));
return;
}
@@ -831,7 +847,7 @@ int open_file(const char *filename, bool new_one, FILE **f)
free(full_filename);
if (new_one) {
statusbar(_("New File"));
statusline(REMARK, _("New File"));
return 0;
} else {
statusline(ALERT, _("File \"%s\" not found"), filename);
@@ -1981,8 +1997,13 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
titlebar(NULL);
}
#ifndef NANO_TINY
if (ISSET(MINIBAR) && fullbuffer && !tmp)
report_size = TRUE;
else
#endif
if (!tmp)
statusline(HUSH, P_("Wrote %zu line", "Wrote %zu lines",
statusline(REMARK, P_("Wrote %zu line", "Wrote %zu lines",
lineswritten), lineswritten);
retval = TRUE;
@@ -2164,7 +2185,7 @@ int do_writeout(bool exiting, bool withprompt)
did_credits = TRUE;
} else
/* TRANSLATORS: Concisely say the screen is too small. */
statusbar(_("Too tiny"));
statusline(AHEM, _("Too tiny"));
free(given);
return 0;
@@ -2216,10 +2237,8 @@ int do_writeout(bool exiting, bool withprompt)
if (name_exists) {
char *question = _("File \"%s\" exists; OVERWRITE? ");
char *name = display_string(answer, 0,
COLS - breadth(question) + 1, FALSE, FALSE);
char *message = nmalloc(strlen(question) +
strlen(name) + 1);
char *name = crop_to_fit(answer, COLS - breadth(question) + 1);
char *message = nmalloc(strlen(question) + strlen(name) + 1);
sprintf(message, question, name);

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* global.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014-2020 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -49,7 +49,8 @@ bool we_are_running = FALSE;
/* Becomes TRUE as soon as all options and files have been read. */
bool more_than_one = FALSE;
/* Whether more than one buffer is or has been open. */
bool report_size = TRUE;
/* Whether to show the number of lines when the minibar is used. */
bool ran_a_tool = FALSE;
/* Whether a tool has been run at the Execute-Command prompt. */
@@ -79,6 +80,8 @@ linestruct *pletion_line = NULL;
bool also_the_last = FALSE;
/* Whether indenting/commenting should include the last line of
* the marked region. */
bool hide_cursor = FALSE;
/* Whether to suppress the cursor when highlighting a search match. */
char *answer = NULL;
/* The answer string used by the status-bar prompt. */
@@ -946,7 +949,7 @@ void shortcut_init(void)
N_("Next Block"), WITHORSANS(nextblock_gist), TOGETHER, VIEW);
#ifdef ENABLE_JUSTIFY
add_to_funcs(to_para_begin, MMAIN|MGOTOLINE,
/* TRANSLATORS: Try to keep these two strings at most 15 characters. */
/* TRANSLATORS: Try to keep these two strings at most 16 characters. */
N_("Begin of Paragr."), WITHORSANS(parabegin_gist), TOGETHER, VIEW);
add_to_funcs(to_para_end, MMAIN|MGOTOLINE,
N_("End of Paragraph"), WITHORSANS(paraend_gist), BLANKAFTER, VIEW);

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* help.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2000-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2000-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2017 Rishabh Dave *
* Copyright (C) 2014-2019 Benno Schulenberg *
* *
@@ -50,7 +50,7 @@ void help_init(void)
char *ptr;
/* First, set up the initial help text for the current function. */
if (currmenu == MWHEREIS || currmenu == MREPLACE || currmenu == MREPLACEWITH) {
if (currmenu & (MWHEREIS|MREPLACE|MREPLACEWITH)) {
htx[0] = N_("Search Command Help Text\n\n "
"Enter the words or characters you would like to "
"search for, and then press Enter. If there is a "
@@ -457,9 +457,13 @@ void show_help(void)
/* Show the cursor when we searched and found something. */
kbinput = get_kbinput(edit, didfind == 1 || ISSET(SHOW_CURSOR));
didfind = 0;
#ifndef NANO_TINY
openfile->mark = NULL;
hide_cursor = FALSE;
if (bracketed_paste || kbinput == BRACKETED_PASTE_MARKER) {
beep();
continue;
@@ -548,7 +552,7 @@ void show_help(void)
}
#ifdef ENABLE_BROWSER
if (oldmenu == MBROWSER || oldmenu == MWHEREISFILE || oldmenu == MGOTODIR)
if (oldmenu & (MBROWSER|MWHEREISFILE|MGOTODIR))
browser_refresh();
else
#endif
@@ -566,7 +570,7 @@ void do_help(void)
#ifdef ENABLE_HELP
show_help();
#else
if (currmenu == MMAIN || currmenu == MBROWSER)
if (currmenu & (MMAIN|MBROWSER))
statusbar(_("^W = Ctrl+W M-W = Alt+W"));
else
beep();

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* history.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2003-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2003-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2016, 2017, 2019 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* move.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014-2018 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* nano.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014-2020 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -62,10 +62,6 @@ static struct termios original_state;
static struct sigaction oldaction, newaction;
/* Containers for the original and the temporary handler for SIGINT. */
#ifdef USE_SLANG
static bool selfinduced = FALSE;
/* Whether a suspension was caused from inside nano or from outside. */
#endif
/* Create a new linestruct node. Note that we do not set prevnode->next. */
linestruct *make_new_node(linestruct *prevnode)
@@ -201,14 +197,14 @@ void renumber_from(linestruct *line)
/* Display a warning about a key disabled in view mode. */
void print_view_warning(void)
{
statusbar(_("Key is invalid in view mode"));
statusline(AHEM, _("Key is invalid in view mode"));
}
/* When in restricted mode, show a warning and return TRUE. */
bool in_restricted_mode(void)
{
if (ISSET(RESTRICTED)) {
statusbar(_("This function is disabled in restricted mode"));
statusline(AHEM, _("This function is disabled in restricted mode"));
beep();
return TRUE;
} else
@@ -399,22 +395,28 @@ void window_init(void)
delwin(bottomwin);
}
topwin = NULL;
/* If the terminal is very flat, don't set up a title bar. */
if (LINES < 3) {
topwin = NULL;
editwinrows = 1;
/* Set up two subwindows. If the terminal is just one line,
* edit window and status-bar window will cover each other. */
edit = newwin(1, COLS, 0, 0);
bottomwin = newwin(1, COLS, LINES - 1, 0);
} else {
int toprows = (!ISSET(EMPTY_LINE) ? 1 : (LINES < 6) ? 1 : 2);
int bottomrows = (ISSET(NO_HELP) ? 1 : (LINES < 5) ? 1 : 3);
int toprows = ((ISSET(EMPTY_LINE) && LINES > 5) ? 2 : 1);
int bottomrows = ((ISSET(NO_HELP) || LINES < 5) ? 1 : 3);
#ifndef NANO_TINY
if (ISSET(MINIBAR))
toprows = 0;
#endif
editwinrows = LINES - toprows - bottomrows;
/* Set up the normal three subwindows. */
topwin = newwin(toprows, COLS, 0, 0);
if (toprows > 0)
topwin = newwin(toprows, COLS, 0, 0);
edit = newwin(editwinrows, COLS, toprows, 0);
bottomwin = newwin(bottomrows, COLS, toprows + editwinrows, 0);
}
@@ -422,13 +424,11 @@ void window_init(void)
/* In case the terminal shrunk, make sure the status line is clear. */
wipe_statusbar();
#ifndef USE_SLANG
/* When not disabled, turn escape-sequence translation on. */
if (!ISSET(RAW_SEQUENCES)) {
keypad(edit, TRUE);
keypad(bottomwin, TRUE);
}
#endif
#ifdef ENABLED_WRAPORJUSTIFY
/* Set up the wrapping point, accounting for screen width when negative. */
@@ -526,10 +526,8 @@ void usage(void)
print_opt(_("-J <number>"), _("--guidestripe=<number>"),
N_("Show a guiding bar at this column"));
#endif
#ifndef USE_SLANG
print_opt("-K", "--rawsequences",
N_("Fix numeric keypad key confusion problem"));
#endif
#ifndef NANO_TINY
print_opt("-L", "--nonewlines",
N_("Don't add an automatic newline"));
@@ -642,7 +640,9 @@ void usage(void)
if (!ISSET(RESTRICTED))
print_opt("-z", "--suspendable", N_("Enable suspension"));
#ifndef NANO_TINY
print_opt("-^", "--markmatch", N_("Select the match of a search"));
print_opt("-%", "--stateflags", N_("Show some states on the title bar"));
print_opt("-_", "--minibar", N_("Show a feedback bar at the bottom"));
#endif
#ifdef HAVE_LIBMAGIC
print_opt("-!", "--magic", N_("Also try magic to determine syntax"));
@@ -659,8 +659,8 @@ void version(void)
printf(_(" GNU nano, version %s\n"), VERSION);
#endif
#ifndef NANO_TINY
printf(" (C) 1999-2011, 2013-2020 Free Software Foundation, Inc.\n");
printf(_(" (C) 2014-%s the contributors to nano\n"), "2020");
printf(" (C) 1999-2011, 2013-2021 Free Software Foundation, Inc.\n");
printf(_(" (C) 2014-%s the contributors to nano\n"), "2021");
#endif
printf(_(" Compiled options:"));
@@ -775,9 +775,6 @@ void version(void)
printf(" --enable-utf8");
#else
printf(" --disable-utf8");
#endif
#ifdef USE_SLANG
printf(" --with-slang");
#endif
printf("\n");
}
@@ -956,18 +953,11 @@ void do_suspend(int signal)
/* Put nano to sleep (if suspension is enabled). */
void do_suspend_void(void)
{
if (ISSET(SUSPENDABLE)) {
#ifdef USE_SLANG
selfinduced = TRUE;
do_suspend(0);
selfinduced = FALSE;
#else
do_suspend(0);
#endif
} else {
statusbar(_("Suspension is not enabled"));
if (!ISSET(SUSPENDABLE)) {
statusline(AHEM, _("Suspension is not enabled"));
beep();
}
} else
do_suspend(0);
ran_a_tool = TRUE;
}
@@ -987,13 +977,9 @@ void do_continue(int signal)
/* Put the terminal in the desired state again. */
terminal_init();
#endif
#ifdef USE_SLANG
if (!selfinduced)
full_refresh();
#else
/* Insert a fake keystroke, to neutralize a key-eating issue. */
ungetch(KEY_FLUSH);
#endif
}
#if !defined(NANO_TINY) || defined(ENABLE_SPELLER) || defined(ENABLE_COLOR)
@@ -1126,7 +1112,9 @@ void do_toggle(int flag)
if (flag == NO_HELP || flag == NO_SYNTAX)
enabled = !enabled;
statusline(HUSH, "%s %s", _(flagtostr(flag)),
if (!ISSET(MINIBAR) || flag == SMART_HOME || flag == CUT_FROM_CURSOR ||
flag == TABS_TO_SPACES || flag == USE_MOUSE || flag == SUSPENDABLE)
statusline(REMARK, "%s %s", _(flagtostr(flag)),
enabled ? _("enabled") : _("disabled"));
}
#endif /* !NANO_TINY */
@@ -1202,36 +1190,15 @@ void enable_flow_control(void)
* control characters. */
void terminal_init(void)
{
#ifdef USE_SLANG
/* Slang curses emulation brain damage, part 2: Slang doesn't
* implement raw(), nonl(), or noecho() properly, so there's no way
* to properly reinitialize the terminal using them. We have to
* disable the special control keys and interpretation of the flow
* control characters using termios, save the terminal state after
* the first call, and restore it on subsequent calls. */
static struct termios desired_state;
static bool have_new_state = FALSE;
raw();
nonl();
noecho();
if (!have_new_state) {
#endif
raw();
nonl();
noecho();
disable_extended_io();
#ifdef USE_SLANG
tcgetattr(0, &desired_state);
have_new_state = TRUE;
} else
tcsetattr(0, TCSANOW, &desired_state);
disable_extended_io();
SLang_init_tty(-1, 0, 0);
#endif
if (ISSET(PRESERVE))
enable_flow_control();
#ifdef USE_SLANG
else
disable_flow_control();
#endif
disable_kb_interrupt();
#ifndef NANO_TINY
@@ -1289,28 +1256,28 @@ void unbound_key(int code)
if (code == FOREIGN_SEQUENCE)
/* TRANSLATORS: This refers to a sequence of escape codes
* (from the keyboard) that nano does not recognize. */
statusline(ALERT, _("Unknown sequence"));
statusline(AHEM, _("Unknown sequence"));
else if (code > 0x7F)
statusline(ALERT, _("Unbound key"));
statusline(AHEM, _("Unbound key"));
else if (meta_key) {
#ifndef NANO_TINY
if (code < 0x20)
statusline(ALERT, _("Unbindable key: M-^%c"), code + 0x40);
statusline(AHEM, _("Unbindable key: M-^%c"), code + 0x40);
else
#endif
#ifdef ENABLE_NANORC
if (shifted_metas && 'A' <= code && code <= 'Z')
statusline(ALERT, _("Unbound key: Sh-M-%c"), code);
statusline(AHEM, _("Unbound key: Sh-M-%c"), code);
else
#endif
statusline(ALERT, _("Unbound key: M-%c"), toupper(code));
statusline(AHEM, _("Unbound key: M-%c"), toupper(code));
} else if (code == ESC_CODE)
statusline(ALERT, _("Unbindable key: ^["));
statusline(AHEM, _("Unbindable key: ^["));
else if (code < 0x20)
statusline(ALERT, _("Unbound key: ^%c"), code + 0x40);
statusline(AHEM, _("Unbound key: ^%c"), code + 0x40);
#if defined(ENABLE_BROWSER) || defined (ENABLE_HELP)
else
statusline(ALERT, _("Unbound key: %c"), code);
statusline(AHEM, _("Unbound key: %c"), code);
#endif
set_blankdelay_to_one();
}
@@ -1354,9 +1321,11 @@ int do_mouse(void)
#ifndef NANO_TINY
/* Clicking where the cursor is toggles the mark, as does clicking
* beyond the line length with the cursor at the end of the line. */
if (sameline && openfile->current_x == current_x_save)
if (sameline && openfile->current_x == current_x_save) {
do_mark();
else
if (ISSET(STATEFLAGS))
titlebar(NULL);
} else
#endif
/* The cursor moved; clean the cutbuffer on the next cut. */
keep_cutbuffer = FALSE;
@@ -1545,6 +1514,9 @@ void process_a_keystroke(void)
/* Read in a keystroke, and show the cursor while waiting. */
input = get_kbinput(edit, VISIBLE);
lastmessage = VACUUM;
hide_cursor = FALSE;
#ifndef NANO_TINY
if (input == KEY_WINCH)
return;
@@ -1571,7 +1543,7 @@ void process_a_keystroke(void)
print_view_warning();
else {
#ifndef NANO_TINY
if (openfile->mark && openfile->kind_of_mark == SOFTMARK) {
if (openfile->mark && openfile->softmark) {
openfile->mark = NULL;
refresh_needed = TRUE;
}
@@ -1645,7 +1617,7 @@ void process_a_keystroke(void)
if (shift_held && !openfile->mark) {
openfile->mark = openfile->current;
openfile->mark_x = openfile->current_x;
openfile->kind_of_mark = SOFTMARK;
openfile->softmark = TRUE;
}
#endif
@@ -1657,7 +1629,7 @@ void process_a_keystroke(void)
* discard a soft mark. And when the marked region covers a
* different set of lines, reset the "last line too" flag. */
if (openfile->mark) {
if (!shift_held && openfile->kind_of_mark == SOFTMARK &&
if (!shift_held && openfile->softmark &&
(openfile->current != was_current ||
openfile->current_x != was_x ||
wanted_to_move(shortcut->func))) {
@@ -1711,9 +1683,7 @@ int main(int argc, char **argv)
#ifdef ENABLE_NANORC
{"ignorercfiles", 0, NULL, 'I'},
#endif
#ifndef USE_SLANG
{"rawsequences", 0, NULL, 'K'},
#endif
#ifdef ENABLED_WRAPORJUSTIFY
{"trimblanks", 0, NULL, 'M'},
#endif
@@ -1788,7 +1758,9 @@ int main(int argc, char **argv)
{"indicator", 0, NULL, 'q'},
{"unix", 0, NULL, 'u'},
{"afterends", 0, NULL, 'y'},
{"markmatch", 0, NULL, '^'},
{"stateflags", 0, NULL, '%'},
{"minibar", 0, NULL, '_'},
#endif
#ifdef HAVE_LIBMAGIC
{"magic", 0, NULL, '!'},
@@ -1812,15 +1784,10 @@ int main(int argc, char **argv)
fcntl(STDIN_FILENO, F_SETFL, stdin_flags & ~O_NONBLOCK);
#ifdef ENABLE_UTF8
/* If setting the locale is successful and it uses UTF-8, we need
* to use the multibyte functions for text processing. */
if (setlocale(LC_ALL, "") != NULL &&
strcmp(nl_langinfo(CODESET), "UTF-8") == 0) {
#ifdef USE_SLANG
SLutf8_enable(1);
#endif
/* If setting the locale is successful and it uses UTF-8, we will
* need to use the multibyte functions for text processing. */
if (setlocale(LC_ALL, "") && strcmp(nl_langinfo(CODESET), "UTF-8") == 0)
utf8_init();
}
#else
setlocale(LC_ALL, "");
#endif
@@ -1848,7 +1815,7 @@ int main(int argc, char **argv)
SET(RESTRICTED);
while ((optchr = getopt_long(argc, argv, "ABC:DEFGHIJ:KLMNOPQ:RST:UVWX:Y:Z"
"abcdef:ghijklmno:pqr:s:tuvwxyz$%!", long_options, NULL)) != -1) {
"abcdef:ghijklmno:pqr:s:tuvwxyz$^%_!", long_options, NULL)) != -1) {
switch (optchr) {
#ifndef NANO_TINY
case 'A':
@@ -1898,11 +1865,9 @@ int main(int argc, char **argv)
}
break;
#endif
#ifndef USE_SLANG
case 'K':
SET(RAW_SEQUENCES);
break;
#endif
#ifndef NANO_TINY
case 'L':
SET(NO_NEWLINES);
@@ -2087,9 +2052,15 @@ int main(int argc, char **argv)
SET(SUSPENDABLE);
break;
#ifndef NANO_TINY
case '^':
SET(MARK_MATCH);
break;
case '%':
SET(STATEFLAGS);
break;
case '_':
SET(MINIBAR);
break;
#endif
#ifdef HAVE_LIBMAGIC
case '!':
@@ -2195,6 +2166,9 @@ int main(int argc, char **argv)
free(alt_speller);
alt_speller = alt_speller_cmdline;
}
/* Strip leading whitespace from the speller command, if any. */
while (alt_speller && *alt_speller && isblank(*alt_speller))
memmove(alt_speller, alt_speller + 1, strlen(alt_speller));
#endif
/* If an rcfile undid the default settings, copy it to the new flags. */
@@ -2233,15 +2207,9 @@ int main(int argc, char **argv)
#endif
}
#ifdef USE_SLANG
/* When using Slang, do not let Slang translate escape sequences to
* key codes, because it does it wrong for the longer sequences. */
SET(RAW_SEQUENCES);
#else
/* When getting untranslated escape sequences, the mouse cannot be used. */
if (ISSET(RAW_SEQUENCES))
UNSET(USE_MOUSE);
#endif
#ifdef ENABLE_HISTORIES
/* Initialize the pointers for the Search/Replace/Execute histories. */
@@ -2353,6 +2321,7 @@ int main(int argc, char **argv)
interface_color_pair[GUIDE_STRIPE] = A_REVERSE;
interface_color_pair[SCROLL_BAR] = A_NORMAL;
interface_color_pair[SELECTED_TEXT] = hilite_attribute;
interface_color_pair[PROMPT_BAR] = hilite_attribute;
interface_color_pair[STATUS_BAR] = hilite_attribute;
interface_color_pair[ERROR_MESSAGE] = hilite_attribute;
interface_color_pair[KEY_COMBO] = hilite_attribute;
@@ -2549,12 +2518,16 @@ int main(int argc, char **argv)
if (currmenu != MMAIN)
bottombars(MMAIN);
#ifndef NANO_TINY
if (ISSET(MINIBAR) && lastmessage < REMARK)
minibar();
else
#endif
/* Update the displayed current cursor position only when there
* is no message and no keys are waiting in the input buffer. */
if (ISSET(CONSTANT_SHOW) && lastmessage == VACUUM && get_key_buffer_len() == 0)
report_cursor_position();
lastmessage = VACUUM;
as_an_at = TRUE;
/* Refresh just the cursor position or the entire edit window. */

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* prompt.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2016, 2018, 2020 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -380,18 +380,19 @@ void put_cursor_at_end_of_answer(void)
typing_x = HIGHEST_POSITIVE;
}
/* Redraw the promptbar and place the cursor at the right spot. */
/* Redraw the prompt bar and place the cursor at the right spot. */
void draw_the_promptbar(void)
{
size_t base = breadth(prompt) + 2;
size_t the_page, end_page, column;
size_t column = base + wideness(answer, typing_x);
size_t the_page, end_page;
char *expanded;
the_page = get_statusbar_page_start(base, base + wideness(answer, typing_x));
the_page = get_statusbar_page_start(base, column);
end_page = get_statusbar_page_start(base, base + breadth(answer) - 1);
/* Color the promptbar over its full width. */
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
/* Color the prompt bar over its full width. */
wattron(bottomwin, interface_color_pair[PROMPT_BAR]);
mvwprintw(bottomwin, 0, 0, "%*s", COLS, " ");
mvwaddstr(bottomwin, 0, 0, prompt);
@@ -402,14 +403,19 @@ void draw_the_promptbar(void)
waddstr(bottomwin, expanded);
free(expanded);
if (base + breadth(answer) != COLS && the_page < end_page)
if (the_page < end_page && base + breadth(answer) - the_page > COLS)
mvwaddch(bottomwin, 0, COLS - 1, '>');
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
wattroff(bottomwin, interface_color_pair[PROMPT_BAR]);
/* Work around a cursor-misplacement bug -- https://sv.gnu.org/bugs/?59808. */
if (ISSET(NO_HELP)) {
wmove(bottomwin, 0, 0);
wrefresh(bottomwin);
}
/* Place the cursor at the right spot. */
column = base + wideness(answer, typing_x);
wmove(bottomwin, 0, column - get_statusbar_page_start(base, column));
wmove(bottomwin, 0, column - the_page);
wnoutrefresh(bottomwin);
}
@@ -490,8 +496,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
} else
#endif
/* Allow tab completion of filenames, but not in restricted mode. */
if ((currmenu == MINSERTFILE || currmenu == MWRITEFILE ||
currmenu == MGOTODIR) && !ISSET(RESTRICTED))
if ((currmenu & (MINSERTFILE|MWRITEFILE|MGOTODIR)) && !ISSET(RESTRICTED))
answer = input_tab(answer, &typing_x, refresh_func, listed);
} else
#endif /* ENABLE_TABCOMP */
@@ -684,11 +689,11 @@ int do_yesno_prompt(bool all, const char *msg)
post_one_key(cancelshortcut->keystr, _("Cancel"), width);
}
/* Color the promptbar over its full width and display the question. */
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
/* Color the prompt bar over its full width and display the question. */
wattron(bottomwin, interface_color_pair[PROMPT_BAR]);
mvwprintw(bottomwin, 0, 0, "%*s", COLS, " ");
mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
wattroff(bottomwin, interface_color_pair[PROMPT_BAR]);
wnoutrefresh(bottomwin);
currmenu = MYESNO;

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* prototypes.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2021 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 *
@@ -36,7 +36,7 @@ extern bool bracketed_paste;
extern bool we_are_running;
extern bool more_than_one;
extern bool report_size;
extern bool ran_a_tool;
extern bool inhelp;
@@ -53,6 +53,7 @@ extern message_type lastmessage;
extern linestruct *pletion_line;
extern bool also_the_last;
extern bool hide_cursor;
extern char *answer;
@@ -594,6 +595,7 @@ void set_blankdelay_to_one(void);
char *display_string(const char *buf, size_t column, size_t span,
bool isdata, bool isprompt);
void titlebar(const char *path);
void minibar(void);
void statusline(message_type importance, const char *msg, ...);
void statusbar(const char *msg);
void warn_and_briefly_pause(const char *msg);

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* rcfile.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014 Mike Frysinger *
* Copyright (C) 2019 Brand Huntsman *
* Copyright (C) 2014-2020 Benno Schulenberg *
@@ -71,7 +71,7 @@ static const rcoption rcopts[] = {
{"nonewlines", NO_NEWLINES},
{"nopauses", NO_PAUSES}, /* Obsolete; remove in 2021. */
#ifdef ENABLE_WRAPPING
{"nowrap", NO_WRAP}, /* Deprecated; remove in 2021. */
{"nowrap", NO_WRAP}, /* Deprecated; remove in 2024. */
#endif
#ifdef ENABLE_OPERATINGDIR
{"operatingdir", 0},
@@ -109,7 +109,9 @@ static const rcoption rcopts[] = {
{"indicator", INDICATOR},
{"jumpyscrolling", JUMPY_SCROLLING},
{"locking", LOCKING},
{"markmatch", MARK_MATCH},
{"matchbrackets", 0},
{"minibar", MINIBAR},
{"noconvert", NO_CONVERT},
{"showcursor", SHOW_CURSOR},
{"smarthome", SMART_HOME},
@@ -131,6 +133,7 @@ static const rcoption rcopts[] = {
{"stripecolor", 0},
{"scrollercolor", 0},
{"selectedcolor", 0},
{"promptcolor", 0},
{"statuscolor", 0},
{"errorcolor", 0},
{"keycolor", 0},
@@ -473,7 +476,8 @@ keystruct *strtosc(const char *input)
else if (!strcmp(input, "cutfromcursor"))
s->toggle = CUT_FROM_CURSOR;
#ifdef ENABLE_WRAPPING
else if (!strcmp(input, "nowrap"))
else if (!strcmp(input, "breaklonglines") ||
!strcmp(input, "nowrap")) /* Deprecated; remove in 2024. */
s->toggle = BREAK_LONG_LINES;
#endif
else if (!strcmp(input, "tabstospaces"))
@@ -1554,6 +1558,8 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
color_combo[SCROLL_BAR] = parse_interface_color(argument);
else if (strcmp(option, "selectedcolor") == 0)
color_combo[SELECTED_TEXT] = parse_interface_color(argument);
else if (strcmp(option, "promptcolor") == 0)
color_combo[PROMPT_BAR] = parse_interface_color(argument);
else if (strcmp(option, "statuscolor") == 0)
color_combo[STATUS_BAR] = parse_interface_color(argument);
else if (strcmp(option, "errorcolor") == 0)

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* search.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2015-2020 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -42,7 +42,7 @@ bool regexp_init(const char *regexp)
char *str = nmalloc(len);
regerror(value, &search_regexp, str, len);
statusline(ALERT, _("Bad regex \"%s\": %s"), regexp, str);
statusline(AHEM, _("Bad regex \"%s\": %s"), regexp, str);
free(str);
return FALSE;
@@ -251,7 +251,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
line = (ISSET(BACKWARDS_SEARCH)) ? openfile->filebot : openfile->filetop;
if (modus == JUSTFIND) {
statusbar(_("Search Wrapped"));
statusline(REMARK, _("Search Wrapped"));
/* Delay the "Searching..." message for at least two seconds. */
feedback = -2;
}
@@ -322,6 +322,17 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
if (match_len != NULL)
*match_len = found_len;
#ifndef NANO_TINY
if (modus == JUSTFIND && ISSET(MARK_MATCH) && (!openfile->mark || openfile->softmark)) {
openfile->mark = line;
openfile->mark_x = found_x + found_len;
openfile->softmark = TRUE;
if (!ISSET(SHOW_CURSOR))
hide_cursor = TRUE;
shift_held = TRUE;
}
#endif
/* Wipe the "Searching..." message and unsuppress cursor-position display. */
if (feedback > 0) {
wipe_statusbar();
@@ -356,7 +367,7 @@ void do_research(void)
#endif
if (*last_search == '\0') {
statusbar(_("No current search pattern"));
statusline(AHEM, _("No current search pattern"));
return;
}
@@ -394,7 +405,7 @@ void not_found_msg(const char *str)
char *disp = display_string(str, 0, (COLS / 2) + 1, FALSE, FALSE);
size_t numchars = actual_x(disp, wideness(disp, COLS / 2));
statusline(HUSH, _("\"%.*s%s\" not found"), numchars, disp,
statusline(AHEM, _("\"%.*s%s\" not found"), numchars, disp,
(disp[numchars] == '\0') ? "" : "...");
free(disp);
}
@@ -421,14 +432,14 @@ void go_looking(void)
* where we started searching, then this is the only occurrence. */
if (didfind == 1 && openfile->current == was_current &&
openfile->current_x == was_current_x)
statusbar(_("This is the only occurrence"));
statusline(REMARK, _("This is the only occurrence"));
else if (didfind == 1 && LINES == 1)
refresh_needed = TRUE;
else if (didfind == 0)
not_found_msg(last_search);
#ifdef TIMEIT
statusline(HUSH, "Took: %.2f", (double)(clock() - start) / CLOCKS_PER_SEC);
statusline(INFO, "Took: %.2f", (double)(clock() - start) / CLOCKS_PER_SEC);
#endif
edit_redraw(was_current, CENTERING);
@@ -750,7 +761,7 @@ void ask_for_and_do_replacements(void)
refresh_needed = TRUE;
if (numreplaced >= 0)
statusline(HUSH, P_("Replaced %zd occurrence",
statusline(REMARK, P_("Replaced %zd occurrence",
"Replaced %zd occurrences", numreplaced), numreplaced);
}
@@ -798,7 +809,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool retain_answer,
/* Try to extract one or two numbers from the user's response. */
if (!parse_line_column(answer, &line, &column)) {
statusline(ALERT, _("Invalid line or column number"));
statusline(AHEM, _("Invalid line or column number"));
return;
}
} else {
@@ -946,7 +957,7 @@ void do_find_bracket(void)
ch = mbstrchr(matchbrackets, openfile->current->data + openfile->current_x);
if (ch == NULL) {
statusbar(_("Not a bracket"));
statusline(AHEM, _("Not a bracket"));
return;
}
@@ -989,7 +1000,7 @@ void do_find_bracket(void)
}
}
statusbar(_("No matching bracket"));
statusline(AHEM, _("No matching bracket"));
/* Restore the cursor position. */
openfile->current = was_current;
@@ -1004,9 +1015,9 @@ void put_or_lift_anchor(void)
update_line(openfile->current, openfile->current_x);
if (openfile->current->has_anchor)
statusbar(_("Placed anchor"));
statusline(REMARK, _("Placed anchor"));
else
statusbar(_("Removed anchor"));
statusline(REMARK, _("Removed anchor"));
}
/* Make the given line the current line, or report the anchoredness. */
@@ -1020,9 +1031,9 @@ void go_to_and_confirm(linestruct *line)
edit_redraw(was_current, CENTERING);
statusbar(_("Jumped to anchor"));
} else if (openfile->current->has_anchor)
statusbar(_("This is the only anchor"));
statusline(REMARK, _("This is the only anchor"));
else
statusbar(_("There are no anchors"));
statusline(AHEM, _("There are no anchors"));
}
/* Jump to the first anchor before the current line; wrap around at the top. */

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* text.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014-2015 Mark Majeres *
* Copyright (C) 2016 Mike Scalora *
* Copyright (C) 2016 Sumedh Pendurkar *
@@ -50,8 +50,8 @@ void do_mark(void)
if (!openfile->mark) {
openfile->mark = openfile->current;
openfile->mark_x = openfile->current_x;
openfile->softmark = FALSE;
statusbar(_("Mark Set"));
openfile->kind_of_mark = HARDMARK;
} else {
openfile->mark = NULL;
statusbar(_("Mark Unset"));
@@ -387,7 +387,7 @@ void do_comment(void)
comment_seq = openfile->syntax->comment;
if (*comment_seq == '\0') {
statusbar(_("Commenting is not supported for this file type"));
statusline(AHEM, _("Commenting is not supported for this file type"));
return;
}
#endif
@@ -397,7 +397,7 @@ void do_comment(void)
/* If only the magic line is selected, don't do anything. */
if (top == bot && bot == openfile->filebot && !ISSET(NO_NEWLINES)) {
statusbar(_("Cannot comment past end of file"));
statusline(AHEM, _("Cannot comment past end of file"));
return;
}
@@ -519,7 +519,7 @@ void do_undo(void)
size_t original_x, regain_from_x;
if (u == NULL) {
statusbar(_("Nothing to undo"));
statusline(AHEM, _("Nothing to undo"));
return;
}
@@ -583,6 +583,8 @@ void do_undo(void)
break;
case REPLACE:
undidmsg = _("replacement");
if ((u->xflags & INCLUDED_LAST_LINE) && !ISSET(NO_NEWLINES))
remove_magicline();
data = u->strdata;
u->strdata = line->data;
line->data = data;
@@ -696,7 +698,7 @@ void do_redo(void)
undostruct *u = openfile->undotop;
if (u == NULL || u == openfile->current_undo) {
statusbar(_("Nothing to redo"));
statusline(AHEM, _("Nothing to redo"));
return;
}
@@ -755,6 +757,8 @@ void do_redo(void)
break;
case REPLACE:
redidmsg = _("replacement");
if ((u->xflags & INCLUDED_LAST_LINE) && !ISSET(NO_NEWLINES))
new_magicline();
data = u->strdata;
u->strdata = line->data;
line->data = data;
@@ -1039,6 +1043,8 @@ void add_undo(undo_type action, const char *message)
break;
case REPLACE:
u->strdata = copy_of(thisline->data);
if (thisline == openfile->filebot && answer[0] != '\0')
u->xflags |= INCLUDED_LAST_LINE;
break;
#ifdef ENABLE_WRAPPING
case SPLIT_BEGIN:
@@ -1071,9 +1077,7 @@ void add_undo(undo_type action, const char *message)
break;
case PASTE:
u->cutbuffer = copy_buffer(cutbuffer);
if (thisline == openfile->filebot)
u->xflags |= INCLUDED_LAST_LINE;
break;
/* Fall-through. */
case INSERT:
if (thisline == openfile->filebot)
u->xflags |= INCLUDED_LAST_LINE;
@@ -1213,17 +1217,11 @@ void update_undo(undo_type action)
u->tail_x = strlen(bottomline->data);
}
break;
case PASTE:
u->tail_lineno = openfile->current->lineno;
u->tail_x = openfile->current_x;
break;
case INSERT:
u->tail_lineno = openfile->current->lineno;
u->tail_x = openfile->current_x;
break;
case COUPLE_BEGIN:
break;
case COUPLE_END:
case PASTE:
case INSERT:
u->tail_lineno = openfile->current->lineno;
u->tail_x = openfile->current_x;
break;
@@ -1786,7 +1784,7 @@ void do_justify(bool full_justify)
/* When the marked region is empty, do nothing. */
if (startline == endline && start_x == end_x) {
statusline(ALERT, _("Selection is empty"));
statusline(AHEM, _("Selection is empty"));
discard_until(openfile->undotop->next);
return;
}
@@ -1998,7 +1996,7 @@ void do_justify(bool full_justify)
/* Show what we justified on the status bar. */
#ifndef NANO_TINY
if (openfile->mark)
statusbar(_("Justified selection"));
statusline(REMARK, _("Justified selection"));
else
#endif
if (full_justify)
@@ -2106,10 +2104,10 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
if (fileinfo.st_size == 0) {
#ifndef NANO_TINY
if (spelling && openfile->mark)
statusline(ALERT, _("Selection is empty"));
statusline(AHEM, _("Selection is empty"));
else
#endif
statusbar(_("Buffer is empty"));
statusline(AHEM, _("Buffer is empty"));
return;
}
@@ -2144,18 +2142,22 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
if (thepid < 0) {
statusline(ALERT, _("Could not fork: %s"), strerror(errornumber));
free(arguments[0]);
return;
} else if (!WIFEXITED(program_status) || WEXITSTATUS(program_status) > 2) {
statusline(ALERT, _("Error invoking '%s'"), arguments[0]);
free(arguments[0]);
return;
} else if (WEXITSTATUS(program_status) != 0)
statusline(ALERT, _("Program '%s' complained"), arguments[0]);
free(arguments[0]);
/* When the temporary file wasn't touched, say so and leave. */
if (timestamp_sec > 0 && stat(tempfile_name, &fileinfo) == 0 &&
(long)fileinfo.st_mtim.tv_sec == timestamp_sec &&
(long)fileinfo.st_mtim.tv_nsec == timestamp_nsec) {
statusbar(_("Nothing changed"));
statusline(REMARK, _("Nothing changed"));
return;
}
@@ -2203,9 +2205,9 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
adjust_viewport(STATIONARY);
if (spelling)
statusbar(_("Finished checking spelling"));
statusline(REMARK, _("Finished checking spelling"));
else
statusbar(_("Buffer has been processed"));
statusline(REMARK, _("Buffer has been processed"));
}
#endif /* ENABLE_SPELLER || ENABLE_COLOR */
@@ -2490,7 +2492,7 @@ void do_int_speller(const char *tempfile_name)
else if (WIFEXITED(spell_status) == 0 || WEXITSTATUS(spell_status))
statusline(ALERT, _("Error invoking \"spell\""));
else
statusbar(_("Finished checking spelling"));
statusline(REMARK, _("Finished checking spelling"));
}
/* Spell check the current file. If an alternate spell checker is
@@ -2535,7 +2537,7 @@ void do_spell(void)
blank_bottombars();
if (alt_speller)
if (alt_speller && *alt_speller)
treat(temp_name, alt_speller, TRUE);
else
do_int_speller(temp_name);
@@ -2563,7 +2565,6 @@ void do_linter(void)
int lint_status, lint_fd[2];
pid_t pid_lint;
bool helpless = ISSET(NO_HELP);
static char **lintargs = NULL;
lintstruct *lints = NULL, *tmplint = NULL, *curlint = NULL;
time_t last_wait = 0;
@@ -2573,7 +2574,7 @@ void do_linter(void)
return;
if (!openfile->syntax || !openfile->syntax->linter) {
statusbar(_("No linter is defined for this type of file"));
statusline(AHEM, _("No linter is defined for this type of file"));
return;
}
@@ -2602,10 +2603,10 @@ void do_linter(void)
currmenu = MLINTER;
statusbar(_("Invoking linter..."));
construct_argument_list(&lintargs, openfile->syntax->linter, openfile->filename);
/* Fork a process to run the linter in. */
if ((pid_lint = fork()) == 0) {
char **lintargs = NULL;
/* Redirect standard output and standard error into the pipe. */
if (dup2(lint_fd[1], STDOUT_FILENO) < 0)
exit(7);
@@ -2615,6 +2616,8 @@ void do_linter(void)
close(lint_fd[0]);
close(lint_fd[1]);
construct_argument_list(&lintargs, openfile->syntax->linter, openfile->filename);
/* Start the linter program; we are using $PATH. */
execvp(lintargs[0], lintargs);
@@ -2733,7 +2736,7 @@ void do_linter(void)
}
if (!parsesuccess) {
statusline(HUSH, _("Got 0 parsable lines from command: %s"),
statusline(REMARK, _("Got 0 parsable lines from command: %s"),
openfile->syntax->linter);
return;
}
@@ -2810,7 +2813,7 @@ void do_linter(void)
free(dontwantfile);
if (restlint == NULL) {
statusbar(_("No messages for this file"));
statusline(REMARK, _("No messages for this file"));
break;
} else {
curlint = restlint;
@@ -2894,6 +2897,7 @@ void do_linter(void)
refresh_needed = TRUE;
}
lastmessage = VACUUM;
currmenu = MMOST;
titlebar(NULL);
}
@@ -2911,7 +2915,7 @@ void do_formatter(void)
return;
if (!openfile->syntax || !openfile->syntax->formatter) {
statusbar(_("No formatter is defined for this type of file"));
statusline(AHEM, _("No formatter is defined for this type of file"));
return;
}
@@ -2988,7 +2992,7 @@ void do_wordlinechar_count(void)
openfile->current_x = was_x;
/* Report on the status bar the number of lines, words, and characters. */
statusline(HUSH, _("%s%zd %s, %zu %s, %zu %s"),
statusline(INFO, _("%s%zd %s, %zu %s, %zu %s"),
openfile->mark ? _("In Selection: ") : "",
lines, P_("line", "lines", lines),
words, P_("word", "words", words),
@@ -3003,7 +3007,7 @@ void do_verbatim_input(void)
char *bytes;
/* TRANSLATORS: Shown when the next keystroke will be inserted verbatim. */
statusbar(_("Verbatim Input"));
statusline(INFO, _("Verbatim Input"));
place_the_cursor();
/* Read in the first one or two bytes of the next keystroke. */
@@ -3012,7 +3016,7 @@ void do_verbatim_input(void)
/* When something valid was obtained, unsuppress cursor-position display,
* insert the bytes into the edit buffer, and blank the status bar. */
if (count > 0) {
if (ISSET(CONSTANT_SHOW))
if (ISSET(CONSTANT_SHOW) || ISSET(MINIBAR))
lastmessage = VACUUM;
if (count < 999)
@@ -3021,7 +3025,7 @@ void do_verbatim_input(void)
wipe_statusbar();
} else
/* TRANSLATORS: An invalid verbatim Unicode code was typed. */
statusline(ALERT, _("Invalid code"));
statusline(AHEM, _("Invalid code"));
free(bytes);
}
@@ -3097,7 +3101,7 @@ void complete_a_word(void)
/* If there is no word fragment before the cursor, do nothing. */
if (start_of_shard == openfile->current_x) {
/* TRANSLATORS: Shown when no text is directly left of the cursor. */
statusbar(_("No word fragment"));
statusline(AHEM, _("No word fragment"));
pletion_line = NULL;
return;
}
@@ -3189,11 +3193,11 @@ void complete_a_word(void)
/* The search has reached the end of the file. */
if (list_of_completions != NULL) {
statusline(ALERT, _("No further matches"));
statusline(AHEM, _("No further matches"));
refresh_needed = TRUE;
} else
/* TRANSLATORS: Shown when there are zero possible completions. */
statusline(ALERT, _("No matches"));
statusline(AHEM, _("No matches"));
free(shard);
}

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* utils.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2016, 2017, 2019 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* winio.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014-2020 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -46,8 +46,6 @@ static int *key_buffer = NULL;
/* A buffer for the keystrokes that haven't been handled yet. */
static size_t key_buffer_len = 0;
/* The length of the keystroke buffer. */
static bool solitary = FALSE;
/* Whether an Esc arrived by itself -- not as leader of a sequence. */
static int digit_count = 0;
/* How many digits of a three-digit character code we've eaten. */
static bool reveal_cursor = FALSE;
@@ -93,10 +91,10 @@ void record_macro(void)
if (recording) {
macro_length = 0;
statusbar(_("Recording a macro..."));
statusline(REMARK, _("Recording a macro..."));
} else {
snip_last_keystroke();
statusbar(_("Stopped recording"));
statusline(REMARK, _("Stopped recording"));
}
if (ISSET(STATEFLAGS))
@@ -108,13 +106,13 @@ void record_macro(void)
void run_macro(void)
{
if (recording) {
statusbar(_("Cannot run macro while recording"));
statusline(AHEM, _("Cannot run macro while recording"));
snip_last_keystroke();
return;
}
if (macro_length == 0) {
statusbar(_("Macro is empty"));
statusline(REMARK, _("Macro is empty"));
return;
}
@@ -176,16 +174,24 @@ void read_keys_from(WINDOW *win)
{
int input = ERR;
size_t errcount = 0;
#ifndef NANO_TINY
bool timed = FALSE;
#endif
/* Before reading the first keycode, display any pending screen updates. */
doupdate();
if (reveal_cursor) {
if (reveal_cursor && !hide_cursor)
curs_set(1);
#ifdef USE_SLANG
doupdate();
#endif
#ifndef NANO_TINY
if (currmenu == MMAIN && ISSET(MINIBAR) && lastmessage > HUSH &&
lastmessage != INFO && lastmessage < ALERT) {
timed = TRUE;
halfdelay(8);
disable_kb_interrupt();
}
#endif
/* Read in the first keycode, waiting for it to arrive. */
while (input == ERR) {
@@ -196,6 +202,19 @@ void read_keys_from(WINDOW *win)
regenerate_screen();
input = KEY_WINCH;
}
if (timed) {
timed = FALSE;
raw();
if (input == ERR) {
minibar();
as_an_at = TRUE;
place_the_cursor();
doupdate();
continue;
}
}
#endif
/* When we've failed to get a keycode over a hundred times in a row,
* assume our input source is gone and die gracefully. We could
@@ -572,11 +591,6 @@ int convert_CSI_sequence(const int *seq, size_t length, int *consumed)
} else if (length > 4 && seq[2] == ';' && seq[4] == '~')
/* Esc [ 1 n ; 2 ~ == F17...F20 on some terminals. */
*consumed = 5;
#ifdef USE_SLANG
else if (length == 3 && seq[2] == ';')
/* Discard broken sequences that Slang produces. */
*consumed = 3;
#endif
break;
case '2':
if (length > 2 && seq[2] == '~') {
@@ -607,11 +621,6 @@ int convert_CSI_sequence(const int *seq, size_t length, int *consumed)
else if (length > 4 && seq[2] == ';' && seq[4] == '~')
/* Esc [ 2 n ; 2 ~ == F21...F24 on some terminals. */
*consumed = 5;
#ifdef USE_SLANG
else if (length == 3 && seq[2] == ';')
/* Discard broken sequences that Slang produces. */
*consumed = 3;
#endif
#ifndef NANO_TINY
else if (length > 3 && seq[1] == '0' && seq[3] == '~') {
/* Esc [ 2 0 0 ~ == start of a bracketed paste,
@@ -891,6 +900,8 @@ int convert_to_control(int kbinput)
* the function keys (F1-F12), and the numeric keypad with NumLock off. */
int parse_kbinput(WINDOW *win)
{
static bool first_escape_was_alone = FALSE;
static bool last_escape_was_alone = FALSE;
static int escapes = 0;
int keycode;
@@ -903,15 +914,16 @@ int parse_kbinput(WINDOW *win)
if (keycode == ERR)
return ERR;
/* Remember whether an Esc arrived by itself, and increment
* its counter, rolling around on three escapes. */
/* For an Esc, remember whether the last two arrived by themselves.
* Then increment the counter, rolling around on three escapes. */
if (keycode == ESC_CODE) {
solitary = (key_buffer_len == 0);
first_escape_was_alone = last_escape_was_alone;
last_escape_was_alone = (key_buffer_len == 0);
if (digit_count > 0) {
digit_count = 0;
escapes = 1;
} else if (++escapes > 2)
escapes = (solitary ? 0 : 1);
escapes = (last_escape_was_alone ? 0 : 1);
return ERR;
}
@@ -937,7 +949,7 @@ int parse_kbinput(WINDOW *win)
return FOREIGN_SEQUENCE;
}
#endif
else if (!solitary && keycode < 0x20)
else if (keycode < 0x20 && !last_escape_was_alone)
meta_key = TRUE;
} else if (key_buffer_len == 0 || *key_buffer == ESC_CODE ||
(keycode != 'O' && keycode != '[')) {
@@ -997,9 +1009,9 @@ int parse_kbinput(WINDOW *win)
else
return byte;
} else if (digit_count == 0) {
/* If the second escape did not arrive alone, it is a Meta
* keystroke; otherwise, it is an "Esc Esc control". */
if (!solitary) {
/* If the first escape arrived alone but not the second, then it
* is a Meta keystroke; otherwise, it is an "Esc Esc control". */
if (first_escape_was_alone && !last_escape_was_alone) {
if (!shifted_metas)
keycode = tolower(keycode);
meta_key = TRUE;
@@ -1145,18 +1157,14 @@ int parse_kbinput(WINDOW *win)
#endif
switch (keycode) {
#ifdef KEY_SLEFT /* Slang doesn't support KEY_SLEFT. */
case KEY_SLEFT:
shift_held = TRUE;
return KEY_LEFT;
#endif
#ifdef KEY_SRIGHT /* Slang doesn't support KEY_SRIGHT. */
case KEY_SRIGHT:
shift_held = TRUE;
return KEY_RIGHT;
#endif
#ifdef KEY_SR
#ifdef KEY_SUP /* ncurses and Slang don't support KEY_SUP. */
#ifdef KEY_SUP /* Ncurses doesn't know Shift+Up. */
case KEY_SUP:
#endif
case KEY_SR: /* Scroll backward, on Xfce4-terminal. */
@@ -1164,21 +1172,21 @@ int parse_kbinput(WINDOW *win)
return KEY_UP;
#endif
#ifdef KEY_SF
#ifdef KEY_SDOWN /* ncurses and Slang don't support KEY_SDOWN. */
#ifdef KEY_SDOWN /* Ncurses doesn't know Shift+Down. */
case KEY_SDOWN:
#endif
case KEY_SF: /* Scroll forward, on Xfce4-terminal. */
shift_held = TRUE;
return KEY_DOWN;
#endif
#ifdef KEY_SHOME /* HP-UX 10-11 and Slang don't support KEY_SHOME. */
#ifdef KEY_SHOME /* HP-UX 10-11 doesn't know Shift+Home. */
case KEY_SHOME:
#endif
case SHIFT_HOME:
shift_held = TRUE;
case KEY_A1: /* Home (7) on keypad with NumLock off. */
return KEY_HOME;
#ifdef KEY_SEND /* HP-UX 10-11 and Slang don't support KEY_SEND. */
#ifdef KEY_SEND /* HP-UX 10-11 doesn't know Shift+End. */
case KEY_SEND:
#endif
case SHIFT_END:
@@ -1213,28 +1221,17 @@ int parse_kbinput(WINDOW *win)
return (ISSET(REBIND_DELETE) ? KEY_DC : KEY_BACKSPACE);
case KEY_DC:
return (ISSET(REBIND_DELETE) ? KEY_BACKSPACE : KEY_DC);
#ifdef KEY_SDC /* Slang doesn't support KEY_SDC. */
case KEY_SDC:
return SHIFT_DELETE;
#endif
#if defined(KEY_CANCEL) && defined(KEY_SCANCEL) /* Slang doesn't support these. */
case KEY_SCANCEL:
return KEY_CANCEL;
#endif
#if defined(KEY_SUSPEND) && defined(KEY_SSUSPEND) /* Slang doesn't support these. */
case KEY_SSUSPEND:
return KEY_SUSPEND;
#endif
#ifdef KEY_BTAB /* Slang doesn't support KEY_BTAB. */
case KEY_BTAB:
return SHIFT_TAB;
#endif
#ifdef KEY_SBEG /* Slang doesn't support KEY_SBEG. */
case KEY_SBEG:
#endif
#ifdef KEY_BEG /* Slang doesn't support KEY_BEG. */
case KEY_BEG:
#endif
case KEY_B2: /* Center (5) on keypad with NumLock off. */
#ifdef PDCURSES
case KEY_SHIFT_L:
@@ -1244,7 +1241,7 @@ int parse_kbinput(WINDOW *win)
case KEY_ALT_L:
case KEY_ALT_R:
#endif
#ifdef KEY_RESIZE /* Slang and SunOS 5.7-5.9 don't support KEY_RESIZE. */
#ifdef KEY_RESIZE /* SunOS 5.7-5.9 doesn't know KEY_RESIZE. */
case KEY_RESIZE:
#endif
case KEY_FLUSH:
@@ -1340,7 +1337,7 @@ long assemble_unicode(int symbol)
/* TRANSLATORS: This is shown while a six-digit hexadecimal
* Unicode character code (%s) is being typed in. */
statusline(HUSH, _("Unicode Input: %s"), partial);
statusline(INFO, _("Unicode Input: %s"), partial);
}
/* If we have an end result, reset the Unicode digit counter. */
@@ -1446,10 +1443,9 @@ char *get_verbatim_kbinput(WINDOW *win, size_t *count)
* don't get extended keypad values. */
if (ISSET(PRESERVE))
disable_flow_control();
#ifndef USE_SLANG
if (!ISSET(RAW_SEQUENCES))
keypad(win, FALSE);
#endif
#ifndef NANO_TINY
/* Turn bracketed-paste mode off. */
printf("\x1B[?2004l");
@@ -1483,14 +1479,13 @@ char *get_verbatim_kbinput(WINDOW *win, size_t *count)
* keypad back on if necessary now that we're done. */
if (ISSET(PRESERVE))
enable_flow_control();
#ifndef USE_SLANG
/* Use the global window pointers, because a resize may have freed
* the data that the win parameter points to. */
if (!ISSET(RAW_SEQUENCES)) {
keypad(edit, TRUE);
keypad(bottomwin, TRUE);
}
#endif
if (*count < 999) {
for (size_t i = 0; i < *count; i++)
@@ -1517,21 +1512,22 @@ char *get_verbatim_kbinput(WINDOW *win, size_t *count)
* been handled by putting back keystrokes, or 2 if it's been ignored. */
int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
{
MEVENT mevent;
bool in_bottomwin;
bool in_editwin, in_bottomwin;
MEVENT event;
/* First, get the actual mouse event. */
if (getmouse(&mevent) == ERR)
if (getmouse(&event) == ERR)
return -1;
/* Save the screen coordinates where the mouse event took place. */
*mouse_x = mevent.x - margin;
*mouse_y = mevent.y;
in_editwin = wenclose(edit, event.y, event.x);
in_bottomwin = wenclose(bottomwin, event.y, event.x);
in_bottomwin = wenclose(bottomwin, *mouse_y, *mouse_x);
/* Save the screen coordinates where the mouse event took place. */
*mouse_x = event.x - (in_editwin ? margin : 0);
*mouse_y = event.y;
/* Handle releases/clicks of the first mouse button. */
if (mevent.bstate & (BUTTON1_RELEASED | BUTTON1_CLICKED)) {
if (event.bstate & (BUTTON1_RELEASED | BUTTON1_CLICKED)) {
/* If we're allowing shortcuts, and the current shortcut list is
* being displayed on the last two lines of the screen, and the
* first mouse button was released on/clicked inside it, we need
@@ -1551,8 +1547,8 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
/* Clicks on the status bar are handled elsewhere, so
* restore the untranslated mouse-event coordinates. */
if (*mouse_y == 0) {
*mouse_x = mevent.x - margin;
*mouse_y = mevent.y;
*mouse_x = event.x;
*mouse_y = event.y;
return 0;
}
@@ -1603,7 +1599,7 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
/* Handle presses of the fourth mouse button (upward rolls of the
* mouse wheel) and presses of the fifth mouse button (downward
* rolls of the mouse wheel) . */
else if (mevent.bstate & (BUTTON4_PRESSED | BUTTON5_PRESSED)) {
else if (event.bstate & (BUTTON4_PRESSED | BUTTON5_PRESSED)) {
bool in_edit = wenclose(edit, *mouse_y, *mouse_x);
if (in_bottomwin)
@@ -1611,7 +1607,7 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
wmouse_trafo(bottomwin, mouse_y, mouse_x, FALSE);
if (in_edit || (in_bottomwin && *mouse_y == 0)) {
int keycode = (mevent.bstate & BUTTON4_PRESSED) ? KEY_UP : KEY_DOWN;
int keycode = (event.bstate & BUTTON4_PRESSED) ? KEY_UP : KEY_DOWN;
/* One roll of the mouse wheel should move three lines. */
for (int count = 3; count > 0; count--)
@@ -1897,6 +1893,19 @@ int buffer_number(openfilestruct *buffer)
}
#endif
#ifndef NANO_TINY
/* Show the state of auto-indenting, the mark, hard-wrapping, macro recording,
* and soft-wrapping by showing corresponding letters in the given window. */
void show_states_at(WINDOW *window)
{
waddstr(window, ISSET(AUTOINDENT) ? "I" : " ");
waddstr(window, openfile->mark ? "M" : " ");
waddstr(window, ISSET(BREAK_LONG_LINES) ? "L" : " ");
waddstr(window, recording ? "R" : " ");
waddstr(window, ISSET(SOFTWRAP) ? "S" : " ");
}
#endif
/* If path is NULL, we're in normal editing mode, so display the current
* version of nano, the current filename, and whether the current file
* has been modified on the title bar. If path isn't NULL, we're either
@@ -2034,16 +2043,12 @@ void titlebar(const char *path)
#ifndef NANO_TINY
/* When requested, show on the title bar the state of three options and
* the state of the mark and whether a macro is being recorded. */
if (ISSET(STATEFLAGS) && !ISSET(VIEW_MODE)) {
if (*state && ISSET(STATEFLAGS) && !ISSET(VIEW_MODE)) {
if (openfile->modified && COLS > 1)
waddstr(topwin, " *");
if (statelen < COLS) {
wmove(topwin, 0, COLS + 2 - statelen);
waddstr(topwin, ISSET(AUTOINDENT) ? "I" : " ");
waddstr(topwin, openfile->mark ? "M" : " ");
waddstr(topwin, ISSET(BREAK_LONG_LINES) ? "L" : " ");
waddstr(topwin, recording ? "R" : " ");
waddstr(topwin, ISSET(SOFTWRAP) ? "S" : " ");
show_states_at(topwin);
}
} else
#endif
@@ -2060,6 +2065,142 @@ void titlebar(const char *path)
wrefresh(topwin);
}
#ifndef NANO_TINY
/* Draw a bar at the bottom with some minimal state information. */
void minibar(void)
{
char *thename = NULL, *number_of_lines = NULL, *ranking = NULL;
char *location = nmalloc(44);
char *hexadecimal = nmalloc(9);
char *successor = NULL;
size_t namewidth, placewidth;
size_t tallywidth = 0;
size_t padding = 2;
#ifdef ENABLE_UTF8
wchar_t widecode;
#endif
/* Draw a colored bar over the full width of the screen. */
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
mvwprintw(bottomwin, 0, 0, "%*s", COLS, " ");
/* Display the name of the current file, plus a star when modified. */
if (openfile->filename[0] != '\0') {
as_an_at = FALSE;
thename = display_string(openfile->filename, 0, HIGHEST_POSITIVE, FALSE, FALSE);
} else
thename = copy_of(_("(nameless)"));
sprintf(location, "%zi,%zi", openfile->current->lineno, xplustabs() + 1);
placewidth = strlen(location);
namewidth = breadth(thename);
/* If the file name is relatively long, drop the side spaces. */
if (namewidth + 19 > COLS)
padding = 0;
if (COLS > 4) {
/* If the full file name doesn't fit, dottify it. */
if (namewidth > COLS - 2) {
thename = display_string(thename, namewidth - COLS + 5, COLS - 5, FALSE, FALSE);
mvwaddstr(bottomwin, 0, 0, "...");
waddstr(bottomwin, thename);
} else
mvwaddstr(bottomwin, 0, padding, thename);
waddstr(bottomwin, openfile->modified ? " *" : " ");
}
if (report_size && COLS > 35) {
size_t count = openfile->filebot->lineno - (openfile->filebot->data[0] == '\0');
number_of_lines = nmalloc(44);
sprintf(number_of_lines, P_(" (%zu line)", " (%zu lines)", count), count);
tallywidth = breadth(number_of_lines);
if (namewidth + tallywidth + 11 < COLS)
waddstr(bottomwin, number_of_lines);
else
tallywidth = 0;
report_size = FALSE;
}
#ifdef ENABLE_MULTIBUFFER
else if (openfile->next != openfile && COLS > 35) {
ranking = nmalloc(24);
sprintf(ranking, " [%i/%i]", buffer_number(openfile), buffer_number(startfile->prev));
if (namewidth + placewidth + breadth(ranking) + 32 < COLS)
waddstr(bottomwin, ranking);
}
#endif
/* Display the line/column position of the cursor. */
if (namewidth + tallywidth + placewidth + 32 < COLS)
mvwaddstr(bottomwin, 0, COLS - 27 - placewidth, location);
/* Display the hexadecimal code of the character under the cursor. */
if (namewidth + tallywidth + 28 < COLS) {
char *this_position = openfile->current->data + openfile->current_x;
if (*this_position == '\0')
sprintf(hexadecimal, openfile->current->next ?
#ifdef ENABLE_UTF8
using_utf8() ? "U+000A" :
#endif
" 0x0A" : " ----");
else if (*this_position == '\n')
sprintf(hexadecimal, " 0x00");
#ifdef ENABLE_UTF8
else if ((unsigned char)*this_position < 0x80 && using_utf8())
sprintf(hexadecimal, "U+%04X", (unsigned char)*this_position);
else if (using_utf8() && mbtowc(&widecode, this_position, MAXCHARLEN) >= 0)
sprintf(hexadecimal, "U+%04X", (int)widecode);
#endif
else
sprintf(hexadecimal, " 0x%02X", (unsigned char)*this_position);
mvwaddstr(bottomwin, 0, COLS - 23, hexadecimal);
#ifdef ENABLE_UTF8
successor = this_position + char_length(this_position);
if (*this_position && *successor && is_zerowidth(successor) &&
mbtowc(&widecode, successor, MAXCHARLEN) >= 0) {
sprintf(hexadecimal, "|%04X", (int)widecode);
waddstr(bottomwin, hexadecimal);
successor += char_length(successor);
if (is_zerowidth(successor) && mbtowc(&widecode, successor, MAXCHARLEN) >= 0) {
sprintf(hexadecimal, "|%04X", (int)widecode);
waddstr(bottomwin, hexadecimal);
}
} else
successor = NULL;
#endif
}
/* Display the state of three flags, and the state of macro and mark. */
if (!successor && namewidth + tallywidth + 14 + 2 * padding < COLS) {
wmove(bottomwin, 0, COLS - 11 - padding);
show_states_at(bottomwin);
}
/* Display how many percent the current line is into the file. */
if (namewidth + 6 < COLS) {
sprintf(location, "%3zi%%", 100 * openfile->current->lineno / openfile->filebot->lineno);
mvwaddstr(bottomwin, 0, COLS - 4 - padding, location);
}
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
wrefresh(bottomwin);
free(number_of_lines);
free(hexadecimal);
free(location);
free(thename);
free(ranking);
}
#endif /* NANO_TINY */
/* Display the given message on the status bar, but only if its importance
* is higher than that of a message that is already there. */
void statusline(message_type importance, const char *msg, ...)
@@ -2079,8 +2220,7 @@ void statusline(message_type importance, const char *msg, ...)
#endif
/* Ignore a message with an importance that is lower than the last one. */
if ((lastmessage == ALERT && importance != ALERT) ||
(lastmessage == MILD && importance == HUSH))
if (importance < lastmessage && lastmessage > NOTICE)
return;
/* If there are multiple alert messages, add trailing dots to the first. */
@@ -2098,8 +2238,9 @@ void statusline(message_type importance, const char *msg, ...)
return;
}
if (importance == ALERT) {
beep();
if (importance > NOTICE) {
if (importance == ALERT)
beep();
colorpair = interface_color_pair[ERROR_MESSAGE];
} else if (importance == NOTICE)
colorpair = interface_color_pair[SELECTED_TEXT];
@@ -2145,17 +2286,8 @@ void statusline(message_type importance, const char *msg, ...)
SET(WHITESPACE_DISPLAY);
#endif
/* If doing quick blanking, blank the status bar after just one keystroke.
* Otherwise, blank it after twenty-six keystrokes, as Pico does. */
if (ISSET(QUICK_BLANK))
statusblank = 1;
else
statusblank = 26;
#ifdef USE_SLANG
/* Work around a shy cursor -- https://sv.gnu.org/bugs/?59091. */
bottombars(MGOTODIR);
#endif
/* When requested, wipe the status bar after just one keystroke. */
statusblank = (ISSET(QUICK_BLANK) ? 1 : 20);
}
/* Display a normal message on the status bar, quietly. */
@@ -3283,21 +3415,14 @@ void adjust_viewport(update_type manner)
/* Tell curses to unconditionally redraw whatever was on the screen. */
void full_refresh(void)
{
#ifdef USE_SLANG
/* Slang curses emulation brain damage, part 4: Slang doesn't define
* curscr. */
SLsmg_touch_screen();
SLsmg_refresh();
#else
wrefresh(curscr);
#endif
}
/* Draw all elements of the screen. That is: the title bar plus the content
* of the edit window (when not in the file browser), and the bottom bars. */
void draw_all_subwindows(void)
{
if (currmenu != MBROWSER && currmenu != MWHEREISFILE && currmenu != MGOTODIR)
if (currmenu & ~(MBROWSER|MWHEREISFILE|MGOTODIR))
titlebar(title);
#ifdef ENABLE_HELP
if (inhelp) {
@@ -3305,7 +3430,7 @@ void draw_all_subwindows(void)
wrap_help_text_into_buffer();
} else
#endif
if (currmenu != MBROWSER && currmenu != MWHEREISFILE && currmenu != MGOTODIR)
if (currmenu & ~(MBROWSER|MWHEREISFILE|MGOTODIR))
edit_refresh();
bottombars(currmenu);
}
@@ -3332,15 +3457,10 @@ void report_cursor_position(void)
colpct = 100 * column / fullwidth;
charpct = (openfile->totsize == 0) ? 0 : 100 * sum / openfile->totsize;
statusline(HUSH,
statusline(INFO,
_("line %zd/%zd (%d%%), col %zu/%zu (%d%%), char %zu/%zu (%d%%)"),
openfile->current->lineno, openfile->filebot->lineno, linepct,
column, fullwidth, colpct, sum, openfile->totsize, charpct);
#ifdef USE_SLANG
/* Restore the help lines after the above call overwrote them. */
bottombars(MMAIN);
#endif
}
/* Highlight the text between the given two columns on the current line. */
@@ -3480,7 +3600,7 @@ void do_credits(void)
"",
"",
"",
"(C) 2020",
"(C) 2021",
"Free Software Foundation, Inc.",
"",
"",

View File

@@ -1,5 +1,8 @@
## Syntax highlighting for Go.
## Original author: Robert Clausecker
## License: CC0 (public domain)
syntax go "\.go$"
comment "//"

View File

@@ -7,9 +7,9 @@ comment "#"
color brightred ".*"
# Keywords
color brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|boldtext|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|historylog|indicator|jumpyscrolling|linenumbers|locking|magic|mouse|multibuffer|noconvert|nohelp|nonewlines|positionlog|preserve|quickblank|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|softwrap|stateflags|suspendable|tabstospaces|trimblanks|unix|wordbounds|zap)\>"
color yellow "^[[:space:]]*set[[:space:]]+((error|function|key|number|scroller|selected|status|stripe|title)color)[[:space:]]+(bold,)?(italic,)?(bright|light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte)?(,(light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte))?\>"
color brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|scrollercolor|selectedcolor|speller|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:space:]]+"
color brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|boldtext|bookstyle|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|historylog|indicator|jumpyscrolling|linenumbers|locking|magic|markmatch|minibar|mouse|multibuffer|noconvert|nohelp|nonewlines|positionlog|preserve|quickblank|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|softwrap|stateflags|suspendable|tabstospaces|trimblanks|unix|wordbounds|zap)\>"
color yellow "^[[:space:]]*set[[:space:]]+((error|function|key|number|prompt|scroller|selected|status|stripe|title)color)[[:space:]]+(bold,)?(italic,)?(bright|light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte)?(,(light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte))?\>"
color brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|promptcolor|punct|quotestr|scrollercolor|selectedcolor|speller|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:space:]]+"
color brightgreen "^[[:space:]]*set[[:space:]]+(fill[[:space:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:space:]]+[1-9][0-9]*)\>"
color brightgreen "^[[:space:]]*bind[[:space:]]+((\^([A-Za-z]|[]/@\^_`]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:space:]]+([a-z]+|".*")[[:space:]]+(main|help|search|replace(with)?|yesno|gotoline|writeout|insert|browser|whereisfile|gotodir|execute|spell|linter|all)([[:space:]]+#|[[:space:]]*$)"
color brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([A-Za-z]|[]/@\^_`]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:space:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"

View File

@@ -1,7 +1,7 @@
## Syntax highlighting for Bourne shell scripts.
syntax sh "(\.sh|(\.|/)(a|ba|c|da|k|mk|pdk|tc|z)sh(rc|_profile)?|/(etc/|\.)profile)$"
header "^#!.*/(((a|ba|c|da|k|mk|pdk|tc|z)?sh)|(busybox|env) +sh|openrc-run|runscript)"
header "^#!.*/((env\s+)?((a|ba|c|da|k|mk|pdk|tc|z)?sh)|busybox\s+sh|openrc-run|runscript)\>"
header "-\*-.*shell-script.*-\*-"
magic "(POSIX|Bourne-Again) shell script.*text"
comment "#"