Compare commits

...

333 Commits
v2.9.7 ... v3.2

Author SHA1 Message Date
Benno Schulenberg
8a049e3233 po: update translations and regenerate POT file and PO files 2018-11-11 16:53:55 +01:00
Benno Schulenberg
31fdd2908b bump version numbers and add a news item for the 3.2 release 2018-11-11 16:42:46 +01:00
Benno Schulenberg
2404474dce tweaks: change a bunch of URLs to use 'https' instead of 'http' 2018-11-11 14:46:23 +01:00
David Lawrence Ramsey
5474a9f34b input: properly consume a modified Delete key also in the tiny version
This fixes https://savannah.gnu.org/bugs/?54981.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Bug existed since version 2.9.4, commit 54103d8e.

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

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

Bug existed since version 2.9.4, commit 54103d8e.

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

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

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

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

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

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

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

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

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

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

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

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

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

Also remove two unneeded conditions.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Also, remove some superfluous backslashes, use a non-breaking space
in the texinfo document, and order the regex consistently.
2018-05-21 20:08:19 +02:00
Benno Schulenberg
9d6621afd0 tweaks: remove two superfluous checks, after making one of them so 2018-05-21 09:44:06 +02:00
Benno Schulenberg
cdd637d69f syntaxes: condense and/or correct some extension regexes 2018-05-18 20:40:08 +02:00
Benno Schulenberg
4d232a4aef tweaks: frob some comments, and rename two parameters to make sense 2018-05-18 13:24:07 +02:00
Benno Schulenberg
455899fe27 credits: sort the names roughly according to amount of influence
And spell-fix a name.
2018-05-16 12:05:40 +02:00
Benno Schulenberg
6aef1fa905 docs: thank Kamil for his bug fixes, and update an email address 2018-05-16 09:57:02 +02:00
100 changed files with 31279 additions and 29500 deletions

11
AUTHORS
View File

@@ -5,6 +5,11 @@ nano editor. Please see the ChangeLog for specific changes by author.
Chris Allegretta <chrisa@asty.org>
* Original program author and long-time maintainer.
Benno Schulenberg <bensberg@telfort.nl>
* An array of small bug fixes, the cut-word and block-jump
routines, text selection by holding Shift, macro recording
and replay, plus some key bindings. Current maintainer.
David Lawrence Ramsey <pooka109@gmail.com>
* Former stable series maintainer. Multiple buffer support,
operating dir (-o) option, bug fixes for display routines,
@@ -60,7 +65,5 @@ Sumedh Pendurkar <sumedh.pendurkar@gmail.com>
Rishabh Dave <rishabhddave@gmail.com>
* Searchable help.
Benno Schulenberg <bensberg@justemail.net>
* An array of small bug fixes, the cut-word and block-jump
routines, text selection by holding Shift, and some extra
key bindings. Current maintainer.
Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
* Filtering text through an external command.

379
ChangeLog
View File

@@ -1,3 +1,382 @@
Changes between v3.1 and v3.2:
------------------------------
Benjamin Mintz (1):
syntax: python: do not highlight 'print' and 'exec' in Python 3
Benno Schulenberg (87):
bindings: allow using <Enter> to exit from the linter
bindings: allow using ^X to exit from the linter
bindings: drop M-| as a keystroke for 'cutwordleft' -- set it free again
bindings: in tiny version with help, don't show unfunctional M-◀ and M-▶
bindings: make <Alt+Up> and <Alt+Down> work also on a Linux console
bindings: make the linter separately accessible, through M-B by default
bindings: make the Shift+arrow keys work by default on more terminals
bindings: no longer bind F13 and F14 and F15
bindings: recognize ASCII DEL as backspace also in viewer and browser
bindings: recognize <Ctrl+Shift+Delete> also on a Linux console
bindings: rename 'prevhistory' to 'older' and 'nexthistory' to 'newer'
bindings: stop binding <Bsp> to do_backspace() in the browser menu
bindings: when implanting a string, make sure to use positive values
build: exclude scrolling functions only from tiny version without help
build: fix compilation again when configured with --enable-tiny
build: fix compilation when configured with --disable-multibuffer
build: verify that --enable-tiny compiles before allowing a release
bump version numbers and add a news item for the 3.1 release
debug: report for which modified editing keys ncurses has no keycode
display: correct a mistaken label in the help lines of the browser
display: ensure that the help lines are shown when in linting mode
display: let the title bar show when nano is in linting mode
display: show the cursor also in a help text (when --showcursor is used)
display: use a different color when showing a linting message
docs: document the slightly changed workings of the --view option
docs: give suggestions for alternative key bindings in the sample nanorc
docs: remove a no-longer-needed suggestion from the sample nanorc
docs: update the description of -R/--restricted, as it now reads nanorc
docs, usage: mention that --showcursor now covers help texts too
feedback: give proper message for ^R when combining --view & --restricted
gnulib: update to its current upstream state
help: add a relevant explanatory text for the linter
help: move the linter to the end, to restore pairing in the help lines
help: pull "Older" and "Newer" into view on an 80-column terminal
help: restore the blank line between manipulation and position stuff
help: show <PgUp> and <PgDn> instead of F7 and F8 for pagewise scrolling
help: show the keystroke <Ctrl+Shift+Delete> as "Sh-^Del"
linter: allow using <Ctrl+Up> and <Ctrl+Down> to jump to other message
linter: do not pause when there are no messages for unopened files
linter: for "first"/"last", reshow actual message after a short pause
options: --ignorercfiles is now available in restricted mode
options: let view mode activate "multibuffer" to allow viewing more files
speller: remove a pointless message -- it is never seen
startup: allow reading nanorc in restricted mode, to permit customization
syntaxes: remove several redundant end-of-line anchors from regexes
tweaks: add a comment, and correct an indentation
tweaks: add two more translator hints
tweaks: capitalize the word "nano" when at the start of a sentence
tweaks: change a bunch of URLs to use 'https' instead of 'http'
tweaks: condense a handful of comments, and drop an assert
tweaks: condense another bit of code
tweaks: define a symbol to make the code itself a little simpler
tweaks: don't bother asking ncurses for keycodes for shifted Left/Right
tweaks: drop a check for the needle (the search string) being empty
tweaks: drop the checking of two flags that can no longer be toggled
tweaks: elide a function that is used just once and is a oneliner
tweaks: elide a wrapper function that is no longer useful
tweaks: exclude word-deletion keystrokes from the tiny version
tweaks: fold a few pairs of regexes into each other
tweaks: group a series of related variables together
tweaks: improve two comments, and reshuffle a line for consistency
tweaks: include an extra function call only where it is needed
tweaks: move all the function keys to the end of the shortcuts list
tweaks: move some calls of edit_redraw() to where they are needed
tweaks: redefine MMOST to exclude MBROWSER, to simplify the bindings
tweaks: reduce some repetitious and superfluous comments to just one
tweaks: remove a check that was made redundant by the previous commit
tweaks: remove a now-unused parameter from four functions
tweaks: remove an unneeded check for NULL, and rename a parameter
tweaks: remove a stray file that was accidentally comitted
tweaks: remove some old debugging code
tweaks: rename a bunch of variables, to make it clearer what they contain
tweaks: rename a flag, to match the name of the option
tweaks: rename a variable, to be a bit more fitting
tweaks: renumber a couple of symbols, and reshuffle a bit of code
tweaks: reorder some code to put backward motion before the forward one
tweaks: reshuffle a couple of conditions, to group things better
tweaks: reshuffle some conditions, putting the least likely one first
tweaks: reshuffle some lines to get standard order (first up, then down)
tweaks: reshuffle some lines, to put things in order of option name
tweaks: snip trailing whitespace that ended with a non-breaking space
tweaks: stop setting and requiring the Meta flag for special keycodes
tweaks: swap and reword two bullet points in the rnano manpage
tweaks: there is no reason to block SIGWINCHes while waiting for speller
undo: move another piece of checking to the two places that need it
undo: move some special checking code to the one place that needs it
wrapping: make the --fill option override 'set fill' again
Brand Huntsman (5):
bindings: hard-bind the zap function to M-Del (Alt+Delete)
display: make all dying messages end in a newline
linter: throttle "first"/"last" message on repeated key presses
new feature: a bindable 'zap', to erase text without changing cutbuffer
options: add --zap, that makes <Bsp> and <Del> erase a marked region
David Lawrence Ramsey (16):
display: do spotlighting as part of drawing the screen
docs: update rnano manpage, as -R/--restricted now reads nanorc
input: don't detect <Ctrl+Shift+Delete> on Linux console in tiny version
input: properly consume a modified Delete key also in the tiny version
input: properly recognize Alt+Delete when using -K/--rebindkeypad
input: recognize some escape sequences for <Shift+Delete>
speller: restore the mark coordinates slightly later
syntax: nanohelp: properly color the keystroke "Sh-^Del"
tweaks: don't define controldelete or controlshiftdelete in tiny version
tweaks: join two lines, and add a clarifying comment
tweaks: move the justifying of a single paragraph into its own function
tweaks: normalize the indentation of the shuffled code
tweaks: reshuffle some code to avoid several checks for having justified
tweaks: simplify by using a 'do/while' loop instead of 'while (TRUE)'
weeding: remove the 'active' parameter from spotlight()
wrapping: make relative fill values work again also for screen resizes
Changes between v3.0 and v3.1:
------------------------------
Benno Schulenberg (13):
bindings: bind ASCII DEL during startup instead of repeatedly at runtime
bindings: make ^H rebindable also on NetBSD, FreeBSD and macOS
bindings: when Ctrl+Shift+Delete has no keycode, don't use KEY_BSP
bump version numbers and add a news item for the 3.1 release
input: keep the cursor in edit window after message, also on NetBSD
input: recognize the sequences for Ctrl+Shift+Delete on xterm and urxvt
main: allow toggling all editor features when in view mode
suspension: don't try to show the cursor position when going to sleep
syntax: sh: let the header regex match also busybox shell scripts
tweaks: condense a bit of code
tweaks: remove a superfluous comment and a redundant assignment
tweaks: rename a variable to be special and distinct
tweaks: sharpen an optimization, to allow DEL to be a shortcut
Liu Hao (1):
search: disallow switching to the Replace prompt when in view mode
Changes between v2.9.8 and v3.0:
--------------------------------
Benno Schulenberg (113):
bindings: bind M-Q to 'findprevious' by default, and M-W to 'findnext'
bindings: hard-bind <Ctrl+Shift+Delete> to 'cutwordleft'
bindings: make ^Q and M-Q available also in the help viewer
bindings: move the noconvert toggle from the main to the insert menu
bindings: reassign the M-| keystroke to 'cutwordleft' by default
bindings: remove backup and new-buffer toggles (M-B, M-F) from main menu
bindings: remove the More-Space toggle entirely
bindings: remove the 'searchagain' function entirely
bindings: rename two bindable functions: copytext to copy, uncut to paste
bindings: unassign the M-? keystroke, to free it up for future use
build: add the release script to the repository
build: fix compilation again when configured with --enable-tiny
build: fix compilation when configured with --enable-tiny
build: verify that 'msgfmt' is available when building from git
bump version numbers and add a news item for the 3.0 release
chars: make the UTF-8 case ever so slightly faster by eliding an 'if'
chars: speed up the counting of string length for the plain ASCII case
chars: speed up the parsing of a character for the plain ASCII case
completion: when the cursor is not after a word fragment, say so
cut: concentrate the logic for clearing the cutbuffer mostly in one place
cutting: when deleting whole words, don't join lines unexpectedly
debug: add some code to time the performance of get_totsize()
docs: improve a comment about rebinding <Backspace>
docs: mention that also Ctrl increases the stride when selecting text
docs: mention that "normal" can be used to give things the default color
docs: mention that the 'formatter' command has been superseded
docs: reshuffle a bindable function to a slightly better position
docs: say that 'cutwordright' is now bound to <Ctrl+Delete> by default
docs: slightly reword the description of four bindable functions
docs: the 'noconvert' bindable function was renamed to 'flipconvert'
dropping a feature: remove the ability to use the 'formatter' command
easter: show the crawl only when there is room enough for the lines
files: add the file format on the status bar when switching buffers
filtering: wait for the data-sending process to terminate too
gnulib: update to its current upstream state
help: for ^R^X, mention that the buffer can be piped to the command
help: move "Search Again" away from "Find Next" and "Find Previous"
input: consume the whole escape sequence for modified PgUp and PgDn keys
input: fully consume modified PgUp and PgDn keys also in the tiny version
input: ignore any <Escape>s before a valid command keystroke
input: stop <Alt+Insert> from entering "3~" into the buffer
input: stop a modified Delete key from entering stuff into the buffer
mouse: put the row/column arguments in the proper order [coverity scan]
prompt: concentrate manipulations of 'statusbar_x' into a single file
prompt: remove redundant redrawings of the prompt bar
rcfile: allow to rebind the Cancel function in the yesno menu
rcfile, docs: no longer recognize nor mention 'set backwards'
rcfile: do not accept rebinding F0 nor function keys above F16
rcfile: ensure that in the yesno menu Cancel is bound to some keystroke
rcfile: explicitly check for disallowed keywords in included files
rcfile: reject things like "M-Del" and "^{" as invalid key names
rcfile: when a vital function is not mapped, mention in which menu
search: include 'findprevious' and 'findnext' in the tiny version
signals: don't call a print routine in a signal handler
speller: do not replace the text when the temporary file did not change
startup: don't overwrite rcfile error messages on a Linux console
startup: show the correct number of lines when opening multiple files
syntax: awk: recognize any {g,m,n,}awk script also by its shebang line
syntax: default: colorize also two-digit and capitalized nano versions
syntaxes: remove all traces of the 'formatter' command
syntax: nanorc: recognize 'yesno' as a valid menu to bind/unbind keys in
syntax: nanorc: show ^@ as validly rebindable, but not any ^digit
syntax: python: avoid coloring the three special values inside strings
text: add auto-whitespace to the file size after creating the undo item
tweaks: adjust indentation after the previous change
tweaks: adjust one more translator hint, for removed toggles
tweaks: adjust some translator hints for past changes, and add two more
tweaks: adjust two comments, to be more accurate and general
tweaks: avoid dereferencing a pointer when it is NULL [coverity scan]
tweaks: close a temp file only when descriptor is valid [coverity scan]
tweaks: correct a comment, rewrap a line, and drop some debugging stuff
tweaks: delete some old debugging code that no longer seems useful
tweaks: don't bother having debug code that deallocates all memory
tweaks: don't call va_start() without calling va_end() [coverity scan]
tweaks: drop a condition that has been made redundant two commits ago
tweaks: drop some old debugging code
tweaks: elide a bunch of unneeded constant strings
tweaks: elide a function that is used just once
tweaks: elide another function that is used just once
tweaks: elide an unneeded/duplicate variable
tweaks: elide a one-line function -- no, a half-line function
tweaks: elide a subfunction that is used just once
tweaks: exclude a global flagging variable when it is not needed
tweaks: exclude the file-prepending code from the tiny version
tweaks: fix a pasting error from a month ago
tweaks: implement the name-to-menu function in another manner
tweaks: improve a couple of comments in the sample nanorc
tweaks: improve a translator hint and some other comments
tweaks: move a call to where it will be executed [coverity scan]
tweaks: normalize the indentation after the previous change
tweaks: properly escape "\" in a man page and "@" in a texi document
tweaks: recognize escape sequences of modified Ins/Del more precisely
tweaks: reduce the counting of characters to just the needed function
tweaks: remove a redundant "struct" word, and replace it in comments
tweaks: remove a superfluous condition and a redundant refresh
tweaks: remove redundant braces and conditions after the previous change
tweaks: remove some braces that are now superfluous
tweaks: remove some ineffectual parts from header-line regexes
tweaks: remove the superfluous calls that reset the mbtowc() state
tweaks: remove two needless words, and split up a changed text further
tweaks: remove two superfluous assignments
tweaks: rename a constant, to match what it actually means
tweaks: rename a function and place its call better
tweaks: rename a function to better match its counterpart
tweaks: rename a function, to better state what it does
tweaks: rename a variable and a function, for more clarity
tweaks: rename a variable, to better match its task
tweaks: reshuffle some lines, in order to elide one
tweaks: reshuffle the order of the bindings, for help-line esthetics
tweaks: show "Space" and "Bsp" in the help text of the browser
tweaks: slightly improve error message when vital function is unmapped
tweaks: use a shorter message, because when the screen is small...
undo: differentiate between general filtering and spell checking
Brand Huntsman (4):
input: give feedback for all unbound keys also in the help viewer
statusbar: elevate three messages to an ALERT, to make them more visible
tweaks: correct four spaces of indentation to a tab, in two places
tweaks: remove the 'bright' field from the colortype struct
David Lawrence Ramsey (13):
bindings: make "n" work again in file browser and help viewer
bindings: make ^Q start a backward search also in the file browser
docs: mention that "Ins" and "Del" are valid rebindable keys
justify: verify being in a paragraph before trying to find its beginning
speller: hook up a full alternative spellcheck to the undo system
speller: hook up a marked-text alternative spellcheck to the undo system
speller: make replace_buffer() use the cutting functions directly
speller: make replace_marked_buffer() use the cutting functions directly
undo: actually enable undoing/redoing an alternative spellcheck
undo: always initialize the 'newsize' element in the undo struct
undo: position the cursor properly when undoing/redoing magicline cuts
undo: restore the cursor position when a cut and paste are paired
undo: store the correct cursor position after a paired cut+insert
Devin Hussey (2):
files: speed up reading by using getc_unlocked() instead of getc()
syntax: sh: recognize more file extensions and header lines
Marco Diego Aurélio Mesquita (1):
input: erase the next word when Ctrl is held while pressing Delete
Mark-Weston (2):
build: fix compilation when CC=tcc
syntax: lua: do not color strings inside comments, and add a linter
Changes between v2.9.7 and v2.9.8:
----------------------------------
Benno Schulenberg (64):
build: fix compilation failure when configured with --enable-tiny
build: fix compilation when configured with --disable-justify
build: fix compilation when configured with --disable-multibuffer
build: fix compilation with --enable-{tiny,help,multibuffer}
bump version numbers and add a news item for the 2.9.8 release
copyright: update the years for significantly changed files
credits: sort the names roughly according to amount of influence
docs: add a missing double quote in the default brackets string
docs: describe what constitutes a paragraph
docs: improve description of 'speller' and related bindable functions
docs: improve the description of --nonewlines, and properly sort it
docs: improve the description of the --autoindent option
docs: make quotes around regexes bold, as they are part of the command
docs: mark the filtering of text through an external command as done
docs: register Marco as the author of the filtering feature
docs: remove mention of the quotestr for when regex support is lacking
docs: remove quotes around the name of a syntax -- they are not needed
docs: thank Kamil for his bug fixes, and update an email address
docs, usage: make it clear that the argument of --quotestr is a regex
files: give feedback during writeout also when prepending or appending
filtering: pair the cut and the insert, so they can be undone together
gnulib: update to its current upstream state
justification: find the beginning of a paragraph in a better way
justification: limit the amount of recursion to prevent a stack overflow
justification: recognize indented paragraphs also without --autoindent
justification: when leading whitespace exceeds fill width, wrap anyway
linter: don't try to access absent stat info, as that gives a crash
linter: make sure that the margin is updated before displaying a buffer
linter: make sure the shortcuts bar will redrawn when exiting early
main: add "/" to the quoting regex, to allow justifying //-comments
main: interpret only a double slash (//) as quoting, not a single one
rcfile: don't crash when a bind to a string lacks the closing quote
startup: provide a hint for people unfamiliar with the ^char convention
syntaxes: condense and/or correct some extension regexes
syntax: makefile: color all keywords that GNU make recognizes
tweaks: adjust a translator hint
tweaks: avoid an unused-variable warning with --enable-tiny
tweaks: avoid a warning with --enable-{tiny,help,multibuffer}
tweaks: condense a comment, and elide an unneeded 'if'
tweaks: condense some repetitious comments, and check before assigning
tweaks: condense two statements into one, and elide a 'break'
tweaks: elide a function that is called just once
tweaks: elide another function that is called just once
tweaks: exclude an unneeded 'if' from the single-buffer version
tweaks: frob a couple of comments
tweaks: frob some comments, and rename two parameters to make sense
tweaks: give some continuation lines a more obvious indentation
tweaks: improve a couple of comments, and reshuffle a group of lines
tweaks: make better use of an existing variable
tweaks: make better use of an intermediate variable
tweaks: reduce the abundance of the word 'toggle' in the Info manual
tweaks: remove a superfluous assignment -- the lead length never changes
tweaks: remove two superfluous checks, after making one of them so
tweaks: rename a function, for more aptness and extra contrast
tweaks: rename a variable, for contrast, and improve two comments
tweaks: rename a variable, to give it some meaning
tweaks: rename two variables, to better fit their tasks
tweaks: reshuffle a condition, and adjust a comment and some indentation
tweaks: reshuffle a couple of assignments
tweaks: simplify the determining of the prefix for justified lines
tweaks: stop decreasing both the iterator and the limit of a loop
tweaks: use a more meaningful variable name, and avoid a distant 'else'
wrapping: use "smart" autoindenting only when hard-wrapping is enabled
wrapping: when autoindenting, use indentation of next line as example
Brand Huntsman (1):
tweaks: avoid two unused variable warnings when NLS is disabled
Cristian Caloghera (1):
syntax: makefile: recognize also an all-lowercase makefile name
David Lawrence Ramsey (3):
bindings: add the "flippipe" bindable function
tweaks: avoid an unused variable warning with --enable-tiny
tweaks: fix some grammar plus a typo in the comments
Marco Diego Aurélio Mesquita (2):
linter: check all open buffers, instead of just the next one
new feature: allow piping (selected) text to an external command
Changes between v2.9.6 and v2.9.7:
----------------------------------

View File

@@ -8278,7 +8278,7 @@ nano 0.7.6 - 2000.01.15
having a newline at the end doesn't get read, bugfix in do_replace
with replace all, more/better comments. (Robert Siemborski)
0.7.2 Our first patch accepted into the source! configure fixes
and optimizations (Erik Anderson). Added missing stdarg.h to winio.c.
and optimizations (Erik Andersen). Added missing stdarg.h to winio.c.
Bug fix in update_line for editing long lines. Fixed arguments
being put into the filename when none is specified. Preliminary
+line command argument function.

View File

@@ -3555,10 +3555,10 @@ GNU nano 2.1.4 - 2008.08.09
* text.c (add_undo): Fix check for multi-line cut check skips adding other new legit events.
2008-07-23 Chris Allegretta <chrisa@asty.org>
* text.c: Reset openfile-> to OTHER after an undo or redo so we don't
mistakenly think this is an update when it's really an add. Also
fix an extra ; after an if statement which makes nano try to free
a struct which may be NULL.
* text.c: Reset openfile->last_action to OTHER after an undo or redo
so we don't mistakenly think this is an update when it's really an
add. Also fix a mistaken ; after an if statement which made nano
try to free a struct which might be NULL.
GNU nano 2.1.3 - 2008.08.04

View File

@@ -1,7 +1,14 @@
Improvements in GNU nano
========================
Since 3.0:
- Addition of --zap to make <Del> and <Bsp> obliterate marked text.
- <Ctrl+Delete> wipes next word and <Shift+Ctrl+Delete> preceding word.
- An external spell check can be undone.
Since 2.9.0:
- The ability to filter text through an external command.
- Better detection of paragraphs, allowing a less indented beginning.
- Option 'set afterends' for making Ctrl+Right stop at word ends.
- A crash handler that saves changed buffers in case of a crash.
- Addition of the color name "normal", meaning the default color.

60
NEWS
View File

@@ -1,3 +1,63 @@
2018.11.11 - GNU nano 3.2 "Het kromme hout" changes the default binding
for the linter to M-B so that the spell checker (^T) can
always be used, and changes (when linting) the text in the
title bar and the color of the status bar to make linting
mode more obvious. It also adds a bindable 'zap' function
for deleting a line or marked region without changing the
cutbuffer, adds --zap to bind the <Del> and <Backspace>
keys to the zap function when something is marked, and
hard-binds <Alt+Del> to 'zap'. Furthermore, it shows the
cursor also in the help viewer (when --showcursor is used),
renames the bindable functions 'prevhistory' to 'older' and
'nexthistory' to 'newer' (update your nanorcs when needed),
reads the nanorc files also in restricted mode to allow
customization by the user (if this should not be allowed,
use --ignorercfiles in addition to --restricted), allows
in view mode to open also other files (if this should not
be allowed, use --restricted in addition to --view), makes
resizes respect a relative --fill again, no longer binds
F13...F15 by default, properly re-highlights a misspelled
word after invoking help in the internal spell checker,
and does not skip Unicode characters in string binds.
2018.09.18 - GNU nano 3.1 "Je faisais des bonds comme ça!" fixes a
misbinding of ^H on some terminals and some systems,
does not leave stray stuff after the prompt upon exit
when having suspended nano while using --constantshow,
and does not allow to toggle to Replace in view mode.
2018.09.09 - GNU nano 3.0 "Water Flowing Underground" speeds up the
reading of a file by seventy percent, roughly doubles the
speed of handling ASCII text, changes the way words at line
boundaries are deleted, makes <Ctrl+Delete> wipe the next
word and <Ctrl+Shift+Delete> the preceding word, binds M-Q
to 'findprevious' by default (the Tabs-to-Spaces toggle is
placed on M-O, and the More-Space toggle is fully removed),
makes an external spell check undoable, shows the correct
number of lines on the status bar when opening multiple
files, removes the 'formatter' command, removes the
'searchagain' bindable function (M-W is now bound to
'findnext' by default), moves the No-Convert toggle to the
Insert menu, removes the Backup and New-Buffer toggles from
the main menu (they remain in the Write-Out and Insert
menus, respectively), is more precise in what it accepts as
a rebindable key name, ignores any presses of <Esc> before
a valid command keystroke, recognizes some more escape
sequences for modified editing-pad keys, does not hide
rcfile error messages on a Linux console, renames the
bindable functions 'copytext' to 'copy' and 'uncut' to
'paste', and avoids a possible hang during a Full-Justify.
2018.06.02 - GNU nano 2.9.8 "Espresso" brings the ability to filter the
buffer (or the marked region) through an external command
(^R^X and prefix the command with the pipe symbol, "|"), is
better at detecting and maintaining paragraphs, is able to
justify //-style comments, fixes a crash when the binding
of a key to a string lacks a closing quote, gives feedback
about the number of lines written also when prepending or
appending, and fixes a couple of bugs with the linter.
2018.05.15 - GNU nano 2.9.7 "Hvide Sande" adds the option '--afterends'
for making Ctrl+Right (the nextword function) stop at word
ends instead of beginnings, accepts multibyte letters for

2
README
View File

@@ -18,7 +18,7 @@ Overview
providing other extra functionality.
The nano editor is an official GNU package. For more information on
GNU and the Free Software Foundation, please see http://www.gnu.org/.
GNU and the Free Software Foundation, please see https://www.gnu.org/.
How to compile and install nano

1
THANKS
View File

@@ -87,6 +87,7 @@ Other stuff:
===========
Ben Armstrong <synrg@sanctuary.nslug.ns.ca> Negative -r value idea, code
Thomas Dickey <dickey@herndon4.his.com> Curses help and advice
Kamil Dudka <kdudka@redhat.com> Several small bug fixes
Sven Guckes <guckes@math.fu-berlin.de> Advice and advocacy
Thijs Kinkhorst <thijs@kinkhorst.com> rnano.1 manpage
Jim Knoble <jmknoble@pobox.com> Pico compat for browser

7
TODO
View File

@@ -8,9 +8,6 @@ Somewhat urgent:
- Allow color syntaxes to apply to more than just color, so that we can
e.g. specify a different alternate spell checker depending on which
file type we have open.
- Allow piping marked text to an external command and replacing it with
the command's output -- that is: generalize the spell-check flow.
See also https://savannah.gnu.org/bugs/?28993.
Vague musings:
- Add support for right-to-left text (RTL), through FriBidi?
@@ -21,8 +18,10 @@ Vague musings:
brackets inside comments?
For version 2.9:
- Make undo/redo work also for indenting. [DONE]
- Allow piping (marked) text to an external command and replacing it with
the command's output. That is: implement filtering. [DONE]
- Allow to record and replay a macro: a stored series of keystrokes. [DONE]
- Make undo/redo work also for indenting. [DONE]
For version 2.8:
- Allow text searches in the help viewer. [DONE]

View File

@@ -2,7 +2,7 @@
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="214bf852d8dab02bf62900e61facef2c9f48f2f4"
gnulib_hash="6ccfbb4ce5d4fa79f7afb48f3648f2e0401523c3"
modules="
futimens

View File

@@ -14,9 +14,9 @@
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
# along with this program. If not, see https://www.gnu.org/licenses/.
AC_INIT([GNU nano], [2.9.7], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [3.2], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.14])
@@ -762,6 +762,14 @@ else
fi
AM_CONDITIONAL(BUILDING_FROM_GIT, test x$from_git = xyes)
if test x$from_git = xyes; then
if test "$ac_cv_path_MSGFMT" = ":"; then
AC_MSG_ERROR([
*** The msgfmt program is missing. ***
*** The gettext package needs to be installed when building from git. ***])
fi
fi
AC_CONFIG_FILES([
Makefile
doc/Makefile

View File

@@ -83,7 +83,7 @@
<p><b>In the beginning...</b></p>
<p>For years Pine was THE program used to read email on a Unix system. The Pico text editor is the portion of the program one would use to compose his or her mail messages. Many beginners to Unix flocked to Pico and Pine because of their well organized, easy to use interfaces. With the proliferation of GNU/Linux in the mid to late 90's, many University students became intimately familiar with the strengths (and weaknesses) of Pine and Pico.</p>
<p><b>Then came Debian...</b></p>
<p>The <a href="http://www.debian.org/">Debian GNU/Linux</a> distribution, known for its strict standards in distributing truly &quot;free&quot; software (i.e. software with no restrictions on redistribution), would not include a binary package for Pine or Pico. Many people had a serious dilemma: they loved these programs, but the versions available at the time were not truly free software in the <a href="http://www.gnu.org/philosophy/free-sw.html">GNU</a> sense of the word.</p>
<p>The <a href="https://www.debian.org/">Debian GNU/Linux</a> distribution, known for its strict standards in distributing truly &quot;free&quot; software (i.e. software with no restrictions on redistribution), would not include a binary package for Pine or Pico. Many people had a serious dilemma: they loved these programs, but the versions available at the time were not truly free software in the <a href="https://www.gnu.org/philosophy/free-sw.html">GNU</a> sense of the word.</p>
<p><b>The event...</b></p>
<p>It was in late 1999 when Chris Allegretta (our hero) was yet again complaining to himself about the less-than-perfect license Pico was distributed under, the 1000 makefiles that came with it and how just a few small improvements could make it the Best Editor in the World (TM). Having been a convert from Slackware to Debian, he missed having a simple binary package that included Pine and Pico, and had grown tired of downloading them himself.</p>
<p>Finally something snapped inside and Chris coded and hacked like a madman for many hours straight one weekend to make a (barely usable) Pico clone, at the time called TIP (Tip Isn't Pico). The program could not be invoked without a filename, could not save files, had no help text display, spell checker, and so forth. But over time it improved, and with the help of a few great coders it matured to the (hopefully) stable state it is in today.</p>
@@ -91,7 +91,7 @@
<h3><a name="1.3"></a>1.3. Why the name change from TIP?</h3>
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program &quot;establishes a full duplex terminal connection to a remote host&quot;, and was included with many older Unix systems (and newer ones like Solaris). The conflict was not noticed at first because there is no 'tip' utility included with most GNU/Linux distributions (where nano was developed).</p></blockquote>
<h3><a name="1.4"></a>1.4. What is the current version of nano?</h3>
<blockquote><p>The current version of nano <i>should</i> be <b>2.9.7</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>3.2</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<h3><a name="1.5"></a>1.5. I want to read the man page without having to download the program!</h3>
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="https://nano-editor.org/dist/latest/nano.1.html">here</a>.</p></blockquote>
<hr width="100%">
@@ -114,9 +114,9 @@
<h3><a name="2.3"></a>2.3. Deb packages (Debian and derivatives):</h3>
<blockquote><p>Debian users can check out the current nano packages for:</p>
<ul>
<li><a href="http://packages.debian.org/stable/editors/nano">stable</a></li>
<li><a href="http://packages.debian.org/testing/editors/nano">testing</a></li>
<li><a href="http://packages.debian.org/unstable/editors/nano">unstable</a></li>
<li><a href="https://packages.debian.org/stable/editors/nano">stable</a></li>
<li><a href="https://packages.debian.org/testing/editors/nano">testing</a></li>
<li><a href="https://packages.debian.org/unstable/editors/nano">unstable</a></li>
</ul>
<p>You can also have a look at the <a href="ftp://ftp.debian.org/debian/pool/main/n/nano/">Package Pool</a> to see all the available binary and source packages.</p>
</blockquote>
@@ -232,9 +232,9 @@
<h1><a name="5"></a>5. Internationalization</h1>
<h3><a name="5.1"></a>5.1. There's no translation for my language!</h3>
<blockquote><p>In June 2001, GNU nano entered the <a href="http://translationproject.org/html/welcome.html">Translation Project</a> and since then, translations should be managed from there.</p>
<p>If there isn't a translation for your language, you could ask <a href="http://translationproject.org/team/">your language team</a> to translate nano, or better still, join that team and do it yourself. Joining a team is easy. You just need to ask the team leader to add you, and then send a <a href="http://translationproject.org/disclaim.txt">translation disclaimer to the FSF</a> (this is necessary as nano is an official GNU package, but it does <b>not</b> mean that you transfer the rights of your work to the FSF, it's just so the FSF can legally manage them).</p>
<p>In any case, translating nano is easy. Just grab the latest <b>nano.pot</b> file listed on <a href="http://translationproject.org/domain/nano.html">nano's page</a> at the TP, and translate each <b>msgid</b> line into your native language on the <b>msgstr</b> line. When you're done, you should send it to the TP's central PO-file repository.</p></blockquote>
<blockquote><p>In June 2001, GNU nano entered the <a href="https://translationproject.org/html/welcome.html">Translation Project</a> and since then, translations should be managed from there.</p>
<p>If there isn't a translation for your language, you could ask <a href="https://translationproject.org/team/">your language team</a> to translate nano, or better still, join that team and do it yourself. Joining a team is easy. You just need to ask the team leader to add you, and then send a <a href="https://translationproject.org/disclaim.txt">translation disclaimer to the FSF</a> (this is necessary as nano is an official GNU package, but it does <b>not</b> mean that you transfer the rights of your work to the FSF, it's just so the FSF can legally manage them).</p>
<p>In any case, translating nano is easy. Just grab the latest <b>nano.pot</b> file listed on <a href="https://translationproject.org/domain/nano.html">nano's page</a> at the TP, and translate each <b>msgid</b> line into your native language on the <b>msgstr</b> line. When you're done, you should send it to the TP's central PO-file repository.</p></blockquote>
<h3><a name="5.2"></a>5.2. I don't like the translation for &lt;x&gt; in my language. How can I fix it?</h3>
<blockquote><p>The best way is to send an e-mail with your suggested corrections to the team's mailing list. The address is mentioned in the <code>Language-Team:</code> field in the relevant PO file. The team leader or the assigned translator can then make the changes reach the nano-devel list.</p></blockquote>
<h3><a name="5.3"></a>5.3. What is the status of Unicode support?</h3>
@@ -248,7 +248,7 @@
<blockquote><p>Again, check out the <a href="https://nano-editor.org/">nano homepage</a> for a good summary of reasons. It really is a matter of personal preference as to which editor you should use. If you're the type of person who likes using the original version of a program, then Pico is the editor for you. If you don't mind sacrificing mailer integration with Pine, and are looking for a few more features, as well as a 'better' license in terms of adding your own changes, nano is the way to go.</p>
<p>Note that the last of these no longer applies to the new version of Pine, <a href="http://www.washington.edu/alpine/">Alpine</a>, which is under the Apache License, version 2.0.</p></blockquote>
<h3><a name="6.3"></a>6.3. What is so bad about the older Pine license?</h3>
<blockquote><p>The U of W license for older versions of Pine and Pico is not considered truly Free Software according to both the Free Software Foundation and the <a href="http://www.debian.org/social_contract#guidelines">Debian Free Software Guidelines</a>. The main problem regards the limitations on distributing derived works: according to UW, you can distribute their software, and you can modify it, but you can not do both, i.e. distribute modified binaries.</p></blockquote>
<blockquote><p>The U of W license for older versions of Pine and Pico is not considered truly Free Software according to both the Free Software Foundation and the <a href="https://www.debian.org/social_contract#guidelines">Debian Free Software Guidelines</a>. The main problem regards the limitations on distributing derived works: according to UW, you can distribute their software, and you can modify it, but you can not do both, i.e. distribute modified binaries.</p></blockquote>
<h3><a name="6.4"></a>6.4. Okay, well, what mail program should I use then?</h3>
<blockquote><p>If you are looking to use a Free Software program similar to Pine, and Emacs is not your thing, you should definitely take a look at <a href="http://www.mutt.org/">mutt</a>. It is a full-screen, console based mail program that actually has a lot more flexibility than Pine, but has a keymap included in the distribution that allows you to use the same keystrokes as Pine would to send and receive mail. It's also under the GNU General Public License, version 2.0.</p>
<p>Of course, due to the license change you can now use the <a href="http://www.washington.edu/alpine/">Alpine distribution</a> of PINE as it is now considered Free Software, but you would be sacrificing many of nano's features to do so.</p></blockquote>
@@ -256,10 +256,10 @@
<h1><a name="7"></a>7. Miscellaneous</h1>
<h3><a name="7.1"></a>7.1. Where can I ask questions or send suggestions?</h3>
<blockquote><p>There are three mailing lists for nano hosted at <a href="http://savannah.gnu.org/">Savannah</a>: info-nano, help-nano and nano-devel. info-nano is a very low traffic list where new versions of nano are announced (surprise!). help-nano is for getting help with the editor without needing to hear all of the development issues surrounding it. nano-devel is a normally low, sometimes high traffic list for discussing the present and future development of nano. Here are links to where you can sign up for a given list:</p>
<p>info-nano - <a href="http://mail.gnu.org/mailman/listinfo/info-nano/">http://mail.gnu.org/mailman/listinfo/info-nano/</a><br>
help-nano - <a href="http://mail.gnu.org/mailman/listinfo/help-nano/">http://mail.gnu.org/mailman/listinfo/help-nano/</a><br>
nano-devel - <a href="http://mail.gnu.org/mailman/listinfo/nano-devel/">http://mail.gnu.org/mailman/listinfo/nano-devel/</a></p></blockquote>
<blockquote><p>There are three mailing lists for nano hosted at <a href="https://savannah.gnu.org/">Savannah</a>: info-nano, help-nano and nano-devel. info-nano is a very low traffic list where new versions of nano are announced (surprise!). help-nano is for getting help with the editor without needing to hear all of the development issues surrounding it. nano-devel is a normally low, sometimes high traffic list for discussing the present and future development of nano. Here are links to where you can sign up for a given list:</p>
<p>info-nano - <a href="https://mail.gnu.org/mailman/listinfo/info-nano/">https://mail.gnu.org/mailman/listinfo/info-nano/</a><br>
help-nano - <a href="https://mail.gnu.org/mailman/listinfo/help-nano/">https://mail.gnu.org/mailman/listinfo/help-nano/</a><br>
nano-devel - <a href="https://mail.gnu.org/mailman/listinfo/nano-devel/">https://mail.gnu.org/mailman/listinfo/nano-devel/</a></p></blockquote>
<h3><a name="7.2"></a>7.3. How do I submit a bug report or patch?</h3>
<blockquote>
<p>The best way to submit bugs is through the <a href="https://savannah.gnu.org/bugs/?group=nano">Savannah bug tracker</a>, as you can check whether the bug you are reporting has already been submitted, and it makes it easier for the maintainers to keep track of them.

View File

@@ -7,16 +7,16 @@
.\" Foundation, version 3 or (at your option) any later version. You
.\" should have received a copy of the GNU General Public License
.\" along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\" <https://www.gnu.org/licenses/>.
.\"
.\" * The GNU Free Documentation License, as published by the Free
.\" Software Foundation, version 1.2 or (at your option) any later
.\" version, with no Invariant Sections, no Front-Cover Texts, and no
.\" Back-Cover Texts. You should have received a copy of the GNU Free
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 2.9.7" "May 2018"
.TH NANO 1 "version 3.2" "November 2018"
.SH NAME
nano \- Nano's ANOther editor, an enhanced free Pico clone
@@ -55,7 +55,8 @@ cutbuffer. One can also save the marked text to a file with \fB^O\fR, or
spell check it with \fB^T\fR.
.PP
On some terminals, text can be selected also by holding down Shift while
using the arrow keys. Holding down the Alt key too will increase the stride.
using the arrow keys. Holding down the Ctrl or Alt key too will increase
the stride.
Any cursor movement without Shift being held will cancel such a selection.
.PP
The two lines at the bottom of the screen show some important commands;
@@ -106,7 +107,7 @@ should only need to use this option if they don't, as mouse support
won't work properly with this option enabled.
.TP
.BR \-L ", " \-\-nonewlines
Don't add newlines to the ends of files.
Don't automatically add a newline when a file does not end with one.
.TP
.BR \-M ", " \-\-trimblanks
Snip trailing whitespace from the wrapped line when automatic
@@ -122,19 +123,19 @@ Use the blank line below the title bar as extra editing space.
For the 200 most recent files, log the last position of the cursor,
and place it at that position again upon reopening such a file.
.TP
.BR "\-Q ""\fIcharacters\fB""" ", " "\-\-quotestr=""" \fIcharacters """
Set the quoting string for justifying. The default is
\fB"^([\ \\t]*[#:>\\|}])+"\fP if extended regular expression support is
available, or \fB">\ "\fP otherwise. Note that \fB\\t\fP stands for a
Tab.
.BR "\-Q ""\fIregex\fB""" ", " "\-\-quotestr=""" \fIregex """
Set the regular expression for matching the quoting part of a line.
This is used when justifying.
The default value is \fB"^([\ \\t]*([#:>|}]|//))+"\fP.
Note that \fB\\t\fP stands for an actual Tab.
.TP
.BR \-R ", " \-\-restricted
Restricted mode: don't read or write to any file not specified on the
command line; don't read any \fInanorc\fP files nor history files;
don't allow suspending nor spell checking;
command line. This means: don't read or write history files;
don't allow suspending; don't allow spell checking;
don't allow a file to be appended to, prepended to, or saved under a
different name if it already has one; and don't use backup files.
This restricted mode is also accessible by invoking \fBnano\fP
different name if it already has one; and don't make backup files.
Restricted mode can also be activated by invoking \fBnano\fP
with any name beginning with 'r' (e.g. "rnano").
.TP
.BR \-S ", " \-\-smooth
@@ -166,6 +167,10 @@ should be considered as part of a word. This overrides option
Specify the name of the syntax highlighting to use from among the ones
defined in the \fInanorc\fP files.
.TP
.BR \-Z ", " \-\-zap
Let an unmodified Backspace or Delete erase the marked region
(instead of a single character, and without affecting the cutbuffer).
.TP
.BR \-a ", " \-\-atblanks
When doing soft line wrapping, wrap lines at whitespace
instead of always at the edge of the screen.
@@ -180,15 +185,17 @@ work properly. You should only need to use this option if Backspace
acts like Delete on your system.
.TP
.BR \-g ", " \-\-showcursor
Make the cursor visible in the file browser, putting it on the
highlighted item. Useful for braille users.
Make the cursor visible in the file browser (putting it on the
highlighted item) and in the help viewer. Useful for braille users
and people with poor vision.
.TP
.BR \-h ", " \-\-help
Show a summary of the available command-line options and exit.
.TP
.BR \-i ", " \-\-autoindent
Indent new lines to the previous line's indentation. Useful when
editing source code.
Automatically indent a newly created line to the same number of tabs
and/or spaces as the previous line (or as the next line if the previous
line is the beginning of a paragraph).
.TP
.BR \-k ", " \-\-cutfromcursor
Make the 'Cut Text' command (normally \fB^K\fR) cut from the current cursor
@@ -242,6 +249,8 @@ default behavior of saving a file in the format that it had.
.TP
.BR \-v ", " \-\-view
Just view the file and disallow editing: read-only mode.
This mode allows the user to open also other files for viewing,
unless \fB--restricted\fR is given too.
.TP
.BR \-w ", " \-\-nowrap
Disable the hard-wrapping of long lines. This option conflicts with

View File

@@ -8,8 +8,8 @@
@smallbook
@set EDITION 0.5
@set VERSION 2.9.7
@set UPDATED May 2018
@set VERSION 3.2
@set UPDATED November 2018
@dircategory Editors
@direntry
@@ -23,7 +23,7 @@
@titlepage
@title GNU @command{nano}
@subtitle a small and friendly text editor
@subtitle version 2.9.7
@subtitle version 3.2
@author Chris Allegretta
@page
@@ -43,14 +43,14 @@ under the terms of either of the following licenses:
* The GNU General Public License, as published by the Free Software
Foundation, version 3 or (at your option) any later version. You
should have received a copy of the GNU General Public License along
with this program. If not, see @url{http://www.gnu.org/licenses/}.
with this program. If not, see @url{https://www.gnu.org/licenses/}.
@sp 1
* The GNU Free Documentation License, as published by the Free Software
Foundation, version 1.2 or (at your option) any later version, with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
You should have received a copy of the GNU Free Documentation License
along with this program. If not, see @url{http://www.gnu.org/licenses/}.
along with this program. If not, see @url{https://www.gnu.org/licenses/}.
@sp 1
You may contact the author by
@@ -63,7 +63,7 @@ e-mail: @email{chrisa@@asty.org}@*
@node Top
@top
This manual documents the GNU @command{nano} editor, version 2.9.7.
This manual documents the GNU @command{nano} editor, version 3.2.
@menu
* Introduction::
@@ -198,7 +198,7 @@ won't work properly with this option enabled.
@item -L
@itemx --nonewlines
Don't add newlines to the ends of files.
Don't automatically add a newline when a file does not end with one.
@item -M
@itemx --trimblanks
@@ -218,21 +218,20 @@ Use the blank line below the title bar as extra editing space.
For the 200 most recent files, log the last position of the cursor,
and place it at that position again upon reopening such a file.
@item -Q "@var{characters}"
@itemx --quotestr="@var{characters}"
Set the quoting string for justifying. The default value is
@t{"^([ \t]*[|>:@}#])+"} if extended regular expression support
is available, and @t{"> "} otherwise.
@item -Q "@var{regex}"
@itemx --quotestr="@var{regex}"
Set the regular expression for matching the quoting part of a line, used
when justifying. The default value is @t{"^([@w{ }\t]*([#:>|@}]|//))+"}.
Note that @code{\t} stands for a literal Tab character.
@item -R
@itemx --restricted
Restricted mode: don't read or write to any file not specified on the
command line; don't read any nanorc files nor history files; don't allow
suspending nor spell checking; don't
command line. This means: don't read or write history files; don't allow
suspending; don't allow spell checking; don't
allow a file to be appended to, prepended to, or saved under a different
name if it already has one; and don't use backup files.
This restricted mode is also accessible by invoking @command{nano} with
name if it already has one; and don't make backup files.
Restricted mode can also be activated by invoking @command{nano} with
any name beginning with @code{r} (e.g.@: @command{rnano}).
@item -S
@@ -271,6 +270,11 @@ should be considered as parts of words. This overrides option
Specify the syntax to be used for highlighting.
@xref{Syntax Highlighting} for more info.
@item -Z
@itemx --zap
Let an unmodified @key{Backspace} or @key{Delete} erase the marked region
(instead of a single character, and without affecting the cutbuffer).
@item -a
@itemx --atblanks
When doing soft line wrapping, wrap lines at whitespace
@@ -290,8 +294,9 @@ acts like Delete on your system.
@item -g
@itemx --showcursor
Make the cursor visible in the file browser, putting it on the
highlighted item. Useful for braille users.
Make the cursor visible in the file browser (putting it on the
highlighted item) and in the help viewer. Useful for braille users
and people with poor vision.
@item -h
@itemx --help
@@ -299,8 +304,9 @@ Show a summary of command-line options and exit.
@item -i
@itemx --autoindent
Automatically indent new lines to the same number of spaces and tabs as
the previous line.
Automatically indent a newly created line to the same number of tabs
and/or spaces as the previous line (or as the next line if the previous
line is the beginning of a paragraph).
@item -k
@itemx --cutfromcursor
@@ -355,7 +361,7 @@ The default value is @t{-8}. This option conflicts with @option{-w}
@itemx --speller=@var{program}
Use the given program to do spell checking and correcting. By default,
@command{nano} uses the command specified in the @env{SPELL} environment
variable for this. If @env{SPELL} is not set, and @option{--speller} is
variable. If @env{SPELL} is not set, and @option{--speller} is
not specified either, then @command{nano} uses its own interactive spell
corrector, which requires the GNU @command{spell} program to be installed.
@@ -373,9 +379,11 @@ default behavior of saving a file in the format that it had.
@item -v
@itemx --view
Don't allow the contents of the file to be altered. Note that this
option should NOT be used in place of correct file permissions to
implement a read-only file.
Don't allow the contents of the file to be altered: read-only mode.
This mode allows the user to open also other files for viewing,
unless @option{--restricted} is given too.
(Note that this option should NOT be used in place of correct
file permissions to implement a read-only file.)
@item -w
@itemx --nowrap
@@ -506,8 +514,9 @@ This selection can now be cut or copied in its entirety with a single
@kbd{^K} or @kbd{M-6}. Or the selection can be used to limit the scope of
a search-and-replace (@kbd{^\}) or spell-checking session (@kbd{^T}).
On some terminals, it is also possible to select text by holding down
@kbd{Shift} together with the cursor keys. Such a selection is cancelled
On some terminals, text can be selected also by holding down @kbd{Shift}
while using the cursor keys. Holding down the @kbd{Ctrl} or @kbd{Alt}
key too will increase the stride. Such a selection is cancelled
upon any cursor movement where @kbd{Shift} isn't held.
Cutting or copying selected text will toggle the mark off automatically.
@@ -595,59 +604,47 @@ The following global toggles are available:
@table @code
@item Backup Files toggle
@kbd{Meta-B} toggles the @option{-B} (@option{--backup}) command-line option.
@item Constant Cursor Position Display toggle
@item Constant Cursor Position Display
@kbd{Meta-C} toggles the @option{-c} (@option{--constantshow}) command-line option.
@item Multiple File Buffers toggle
@kbd{Meta-F} toggles the @option{-F} (@option{--multibuffer}) command-line option.
@item Smart Home Key toggle
@item Smart Home Key
@kbd{Meta-H} toggles the @option{-A} (@option{--smarthome}) command-line option.
@item Auto Indent toggle
@item Auto Indent
@kbd{Meta-I} toggles the @option{-i} (@option{--autoindent}) command-line option.
@item Cut From Cursor To End-of-Line toggle
@item Cut From Cursor To End-of-Line
@kbd{Meta-K} toggles the @option{-k} (@option{--cutfromcursor}) command-line option.
@item Long-Line Wrapping toggle
@item Long-Line Wrapping
@kbd{Meta-L} toggles the @option{-w} (@option{--nowrap}) command-line option.
@item Mouse Support toggle
@item Mouse Support
@kbd{Meta-M} toggles the @option{-m} (@option{--mouse}) command-line option.
@item No Conversion From DOS/Mac Format toggle
@kbd{Meta-N} toggles the @option{-N} (@option{--noconvert}) command-line option.
@item Tabs To Spaces
@kbd{Meta-O} toggles the @option{-E} (@option{--tabstospaces}) command-line option.
@item More Space For Editing toggle
@kbd{Meta-O} toggles the @option{-O} (@option{--morespace}) command-line option.
@item Whitespace Display
@kbd{Meta-P} toggles the displaying of whitespace (@pxref{Whitespace}).
@item Whitespace Display toggle
@kbd{Meta-P} toggles the whitespace-display mode (@pxref{Whitespace}).
@item Tabs To Spaces toggle
@kbd{Meta-Q} toggles the @option{-E} (@option{--tabstospaces}) command-line option.
@item Smooth Scrolling toggle
@item Smooth Scrolling
@kbd{Meta-S} toggles the @option{-S} (@option{--smooth}) command-line option.
@item Expert/No Help toggle
@item Expert/No Help
@kbd{Meta-X} toggles the @option{-x} (@option{--nohelp}) command-line option.
@item Color Syntax Highlighting toggle
@item Color Syntax Highlighting
@kbd{Meta-Y} toggles color syntax highlighting (if your nanorc defines syntaxes
--- @pxref{Syntax Highlighting}).
@item Suspension toggle
@item Suspension
@kbd{Meta-Z} toggles the @option{-z} (@option{--suspend}) command-line option.
@item Line Numbers toggle
@item Line Numbers
@kbd{Meta-#} toggles the @option{-l} (@option{--linenumbers}) command-line option.
@item Soft Wrapping toggle
@item Soft Wrapping
@kbd{Meta-$} toggles the @option{-$} (@option{--softwrap}) command-line option.
@end table
@@ -706,7 +703,9 @@ When soft line wrapping is enabled, make it wrap lines at blank characters
(tabs and spaces) instead of always at the edge of the screen.
@item set autoindent
Use auto-indentation.
Automatically indent a newly created line to the same number of tabs
and/or spaces as the previous line (or as the next line if the previous
line is the beginning of a paragraph).
@item set backup
When saving a file, back up the previous version of it, using the current
@@ -718,10 +717,6 @@ numbered one every time a file is saved --- when backups are enabled
with @code{set backup} or @option{--backup} or @option{-B}.
The uniquely numbered files are stored in the specified directory.
@item set backwards
Obsolete option. Recognized but ignored. @code{^Q} is available to
start a backward search.
@item set boldtext
Use bold instead of reverse video for the title bar, status bar, key combos,
function tags, line numbers, and selected text. This can be overridden by
@@ -733,7 +728,7 @@ Set the characters treated as closing brackets when justifying
paragraphs. This may not include blank characters. Only closing
punctuation (see @code{set punct}), optionally followed by the specified
closing brackets, can end sentences. The default value is
@t{"')>]@}"}.
@t{""')>]@}"}.
@item set casesensitive
Do case-sensitive searches by default.
@@ -804,13 +799,13 @@ Don't convert files from DOS/Mac format.
@item set nohelp
Don't display the help lists at the bottom of the screen.
@item set nonewlines
When a file does not end with a newline, don't automatically add one.
@item set nopauses
Don't pause between warnings at startup. This means that only
the last one will be visible (when there are multiple ones).
@item set nonewlines
Don't add newlines to the ends of files.
@item set nowrap
Don't hard-wrap text at all. This option conflicts with
@option{fill}; the last one given takes effect.
@@ -846,12 +841,10 @@ keystroke instead of 25. Note that @option{constantshow} overrides this.
@item set quiet
Obsolete option. Recognized but ignored.
@item set quotestr "@var{string}"
@item set quotestr "@var{regex}"
The email-quote string, used to justify email-quoted paragraphs. This
is an extended regular expression if your system supports them,
otherwise a literal string. The default value is
@t{"^([ \\t]*[#:>\\|@}])+"} if you have extended regular expression
support, and @t{"> "} otherwise.
is an extended regular expression. The default value is
@t{"^([@w{ }\t]*([#:>|@}]|//))+"}.
Note that @code{\t} stands for a literal Tab character.
@item set rebinddelete
@@ -872,8 +865,9 @@ Use this color combination for selected text.
@xref{@code{set functioncolor}} for valid color names.
@item set showcursor
Put the cursor on the highlighted item in the file browser, to aid
braille users.
Put the cursor on the highlighted item in the file browser, and show
the cursor in the help viewer, to aid braille users and people with
poor vision.
@item set smarthome
Make the Home key smarter. When Home is pressed anywhere but at the
@@ -924,7 +918,9 @@ default behavior of saving a file in the format that it had.
(This option has no effect when you also use @code{set noconvert}.)
@item set view
Disallow file modification.
Disallow file modification: read-only mode.
This mode allows the user to open also other files for viewing,
unless @option{--restricted} is given on the command line.
@anchor{Whitespace}
@item set whitespace "@var{string}"
@@ -941,6 +937,10 @@ Specify which other characters (besides the normal alphanumeric ones)
should be considered as parts of words. This overrides the option
@code{wordbounds}.
@item set zap
Let an unmodified @key{Backspace} or @key{Delete} erase the marked region
(instead of a single character, and without affecting the cutbuffer).
@end table
@node Syntax Highlighting
@@ -958,7 +958,7 @@ via the following commands in a nanorc file:
@table @code
@item syntax "@var{name}" ["@var{fileregex}" @dots{}]
@item syntax @var{name} ["@var{fileregex}" @dots{}]
Start the definition of a syntax with this @var{name}.
All subsequent @code{color} and other such commands
will be added to this syntax, until a new @code{syntax}
@@ -989,14 +989,9 @@ file, to determine whether this syntax should be used for it.
on the system and will be silently ignored otherwise.)
@item linter @var{program} [@var{arg} @dots{}]
Use the given @var{program} to do a syntax check on the current file.
Use the given @var{program} to do a syntax check on the current buffer.
(This overrides the speller function.)
@item formatter @var{program} [@var{arg} @dots{}]
Use the given @var{program} to automatically reformat text ---
useful for a programming language like Go.
(This overrides the speller and linter functions.)
@item comment "@var{string}"
Use the given string for commenting and uncommenting lines.
If the string contains a vertical bar or pipe character (@t{|}),
@@ -1012,8 +1007,11 @@ The default value is @t{"#"}.
Display all pieces of text that match the
extended regular expression "regex" with foreground color "fgcolor" and
background color "bgcolor", at least one of which must be specified.
Valid colors for foreground and background are: white, black, red,
blue, green, yellow, magenta, and cyan. You may use the prefix "bright"
Valid names for foreground and background color are:
@code{white}, @code{black}, @code{blue}, @code{green},
@code{red}, @code{cyan}, @code{yellow}, @code{magenta}, and @code{normal}
--- where @code{normal} means the default foreground or background color.
You may use the prefix @code{bright}
to get a stronger color highlight for the foreground. If your
terminal supports transparency, not specifying a "bgcolor" tells @command{nano}
to attempt to use a transparent background.
@@ -1040,13 +1038,28 @@ to @code{icolor}.
@item extendsyntax @var{name} @var{command} [@var{arg} @dots{}]
Extend the syntax previously defined as "@var{name}" with another @var{command}.
This allows you to add a new @code{color}, @code{icolor}, @code{header},
@code{magic}, @code{comment}, @code{linter}, or @code{formatter} command
to an already
@code{magic}, @code{comment}, or @code{linter} command to an already
defined syntax --- useful when you want to slightly improve a syntax defined
in one of the system-installed files (which normally are not writable).
@end table
Note: the @code{formatter} command has been removed. It was superseded by
a more general mechanism: the filtering of buffer or marked text through
an external command. Such filtering is done by typing @code{^R^X} and then
preceding your formatter command with the pipe symbol (@code{|}). It has
the added advantage that the operation can be undone.
If you use such a formatting command regularly, you could assign the relevant
series of keystrokes to a single key in your nanorc:
@example
bind M-F "^R^X|yourformatcommand^M" main
@end example
(Note that the @key{^R}, @key{^X}, and @key{^M} are each a single, literal
control character. You can enter them by preceding each with @key{M-V}.)
@node Rebinding Keys
@section Rebinding Keys
@@ -1077,16 +1090,20 @@ The format of @code{key} should be one of:
@itemize @w{}
@item
@code{^}@ followed by an ASCII character or the word "Space".
@code{^}@ followed by a Latin letter, by one of several ASCII characters
(@@, ], \, ^, or _), or by the word "Space".
Example: @code{^C}.
@item
@code{M-}@ followed by a ASCII character or the word "Space".
@code{M-}@ followed by any ASCII character except [, or by the word "Space".
Example: @code{M-C}.
@item
@code{F}@ followed by a numeric value from 1 to 16.
Example: @code{F10}.
@item
the word "Ins" or the word "Del".
@end itemize
@sp 1
@@ -1118,16 +1135,14 @@ Starts a forward search for text in the current buffer --- or for filenames
matching a string in the current list in the file browser.
@item wherewas
Starts a backward search for text in the current buffer.
@item searchagain
Repeats the last search command without prompting.
Starts a backward search for text in the current buffer --- or for filenames
matching a string in the current list in the file browser.
@item findprevious
As @code{searchagain}, but always in the backward direction.
Searches the next occurrence in the backward direction.
@item findnext
As @code{searchagain}, but always in the forward direction.
Searches the next occurrence in the forward direction.
@item replace
Interactively replaces text within the current buffer.
@@ -1135,25 +1150,36 @@ Interactively replaces text within the current buffer.
@item cut
Cuts and stores the current line (or the marked region).
@item copytext
@item copy
Copies the current line (or the marked region) without deleting it.
(The old form 'copytext' is deprecated.)
@item uncut
Copies the currently stored text into the current buffer at the
@item paste
Pastes the currently stored text into the current buffer at the
current cursor position.
(The old form 'uncut' is deprecated.)
@item mark
Sets the mark at the current position, to start selecting text.
@item zap
Throw away the current line (or the marked region).
(This function is bound by default to <Meta+Delete>.)
@item cutwordleft
Cuts from the cursor position to the beginning of the preceding word.
(This function is not bound by default. If your terminal produces
@code{^H} for <Ctrl+Backspace>, you can make <Ctrl+Backspace> delete
the word to the left of the cursor by rebinding ^H to this function.)
@item cutwordright
Cuts from the cursor position to the beginning of the next word.
(This function is bound by default to <Ctrl+Delete>.)
@item cutrestoffile
Cuts all text from the cursor position till the end of the buffer.
@item mark
Sets the mark at the current position, to start selecting text.
Or, when it is set, unsets the mark.
@item curpos
Shows the current cursor position: the line, column, and character positions.
@@ -1161,11 +1187,14 @@ Shows the current cursor position: the line, column, and character positions.
Counts the number of words, lines and characters in the current buffer.
@item speller
Invokes a spell-checking program (or a linting program, if the current
syntax highlighting defines one).
Invokes a spell-checking program (or linting program,
if the active syntax defines such a thing).
@item justify
Justifies the current paragraph.
Justifies the current paragraph. A paragraph is a group of contiguous lines
that, apart from possibly the first line, all have the same indentation. The
beginning of a paragraph is detected by either this lone line with a differing
indentation or by a preceding blank line.
@item fulljustify
Justifies the entire current buffer.
@@ -1291,19 +1320,20 @@ Suspends the editor (if the suspending function is enabled, see the
"suspendenable" entry below).
@item casesens
Toggles case sensitivity in searching (search/replace menus only).
Toggles whether searching/replacing ignores or respects the case of
the given characters.
@item regexp
Toggles whether searching/replacing is based on literal strings or regular expressions.
Toggles whether searching/replacing uses literal strings or regular expressions.
@item backwards
Toggles whether searching/replacing goes forward or backward.
@item prevhistory
Shows the previous history entry in the prompt menus (e.g.@: search).
@item older
Retrieves the previous (earlier) entry at a prompt.
@item nexthistory
Shows the next history entry in the prompt menus (e.g.@: search).
@item newer
Retrieves the next (later) entry at a prompt.
@item flipreplace
Toggles between searching for something and replacing something.
@@ -1315,10 +1345,18 @@ Toggles between searching for text and targeting a line number.
@item flipexecute
Toggles between inserting a file and executing a command.
@item flippipe
When executing a command, toggles whether the current buffer (or marked
region) is piped to the command.
@item flipnewbuffer
Toggles between inserting into the current buffer and into a new
empty buffer.
@item flipconvert
When reading in a file, toggles between converting and not converting
it from DOS/Mac format. Converting is the default.
@item dosformat
When writing a file, switches to writing a DOS format (CR/LF).
@@ -1359,9 +1397,6 @@ Toggles the presence of the two-line list of key bindings at the bottom of the s
Toggles the constant display of the current line, column, and character positions.
(The form @code{constupdate} is deprecated.)
@item morespace
Toggles the presence of the blank line that 'separates' the title bar from the file text.
@item smoothscroll
Toggles smooth scrolling (when moving around with the arrow keys).
@@ -1381,7 +1416,9 @@ Toggles syntax highlighting.
Toggles the smartness of the Home key.
@item autoindent
Toggles whether new lines will contain the same amount of whitespace as the preceding line.
Toggles whether a newly created line will contain the same amount of leading
whitespace as the preceding line --- or as the next line if the preceding line
is the beginning of a paragraph.
@item cutfromcursor
Toggles whether cutting text will cut the whole line or just from the current cursor
@@ -1394,19 +1431,9 @@ Toggles whether long lines will be hard-wrapped to the next line.
@item tabstospaces
Toggles whether typed tabs will be converted to spaces.
@item backupfile
Toggles whether a backup will be made of the file to be edited.
@item multibuffer
Toggles whether a file is inserted into the current buffer
or read into a new buffer.
@item mouse
Toggles mouse support.
@item noconvert
Toggles automatic conversion of files from DOS/Mac format.
@item suspendenable
Toggles whether the suspend shortcut (normally @kbd{^Z}) will suspend the editor.
@@ -1429,6 +1456,9 @@ The 'search to replace' menu.
@item replacewith
The 'replace with' menu, which comes up after 'search to replace'.
@item yesno
The 'yesno' menu, where the Yes/No/All/Cancel question is asked.
@item gotoline
The 'goto line (and column)' menu.
@@ -1477,7 +1507,7 @@ find the desired file.
Basic movement in the file browser is accomplished with the arrow and
other cursor-movement keys. More targeted movement is accomplished by
searching, via @kbd{^W} or @kbd{w'}, or by changing directory, via
searching, via @kbd{^W} or @kbd{w}, or by changing directory, via
@kbd{^_} or @kbd{g}. The behavior of the @kbd{Enter} key (or @kbd{s})
varies by what is currently selected.
If the currently selected object is a directory, the file browser will

View File

@@ -7,16 +7,16 @@
.\" Foundation, version 3 or (at your option) any later version. You
.\" should have received a copy of the GNU General Public License
.\" along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\" <https://www.gnu.org/licenses/>.
.\"
.\" * The GNU Free Documentation License, as published by the Free
.\" Software Foundation, version 1.2 or (at your option) any later
.\" version, with no Invariant Sections, no Front-Cover Texts, and no
.\" Back-Cover Texts. You should have received a copy of the GNU Free
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 2.9.7" "May 2018"
.TH NANORC 5 "version 3.2" "November 2018"
.SH NAME
nanorc \- GNU nano's configuration file
@@ -66,7 +66,9 @@ When soft line wrapping is enabled, make it wrap lines at blank characters
(tabs and spaces) instead of always at the edge of the screen.
.TP
.B set autoindent
Use auto-indentation.
Automatically indent a newly created line to the same number of tabs
and/or spaces as the previous line (or as the next line if the previous
line is the beginning of a paragraph).
.TP
.B set backup
When saving a file, create a backup file by adding a tilde (\fB~\fP) to
@@ -78,10 +80,6 @@ numbered one every time a file is saved -- when backups are enabled
with \fBset backup\fR or \fB\-\-backup\fR or \fB\-B\fR.
The uniquely numbered files are stored in the specified \fIdirectory\fR.
.TP
.B set backwards
Obsolete option. Recognized but ignored. \fB^Q\fR is available to
start a backward search.
.TP
.B set boldtext
Use bold instead of reverse video for the title bar, status bar, key combos,
function tags, line numbers, and selected text. This can be overridden by
@@ -91,7 +89,7 @@ setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, \fBkeycolor\fP,
.B set brackets "\fIstring\fP"
Set the characters treated as closing brackets when justifying
paragraphs. This may not include blank characters. Only closing
punctuation (see \fBpunct\fP), optionally followed by the specified
punctuation (see \fBset punct\fP), optionally followed by the specified
closing brackets, can end sentences. The default value is "\fB"')>]}\fP".
.TP
.B set casesensitive
@@ -161,7 +159,7 @@ Don't convert files from DOS/Mac format.
Don't display the two help lines at the bottom of the screen.
.TP
.B set nonewlines
Don't automatically add a newline to the ends of files.
When a file does not end with a newline, don't automatically add one.
.TP
.B set nopauses
Don't pause between warnings at startup. This means that only
@@ -201,12 +199,10 @@ keystroke instead of 25. The option \fBconstantshow\fR overrides this.
.B set quiet
Obsolete option. Recognized but ignored.
.TP
.B set quotestr "\fIstring\fP"
.B set quotestr "\fIregex\fP"
The email-quote string, used to justify email-quoted paragraphs. This
is an extended regular expression if your system supports them,
otherwise a literal string. The default value is
"\fB^([\ \\t]*[#:>\\|}])+\fP" if you have extended regular expression
support, and "\fB>\ \fP" otherwise. Note that '\\t' stands for a literal
is an extended regular expression. The default value is
"\fB^([\ \\t]*([#:>|}]|//))+\fP". Note that \fB\\t\fR stands for an actual
Tab character.
.TP
.B set rebinddelete
@@ -243,9 +239,9 @@ Use smooth scrolling by default.
.B set softwrap
Enable soft line wrapping for easier viewing of very long lines.
.TP
.B set speller "\fIspellprog\fP"
Use spelling checker \fIspellprog\fP instead of the built-in one, which
calls \fIspell\fP.
.B set speller "\fIprogram\fP"
Use the given \fIprogram\fR to do spell checking and correcting,
instead of the built-in corrector that calls \fBspell\fR.
.TP
.B set statuscolor \fIfgcolor\fR,\fIbgcolor\fR
Specify the color combination to use for the status bar.
@@ -284,7 +280,9 @@ default behavior of saving a file in the format that it had.
(This option has no effect when you also use \fBset noconvert\fR.)
.TP
.B set view
Disallow file modification.
Disallow file modification: read-only mode.
This mode allows the user to open also other files for viewing,
unless \fB--restricted\fR is given on the command line.
.TP
.B set whitespace "\fIstring\fP"
Set the two characters used to indicate the presence of tabs and
@@ -299,6 +297,10 @@ characters as parts of words.
Specify which other characters (besides the normal alphanumeric ones)
should be considered as parts of words. This overrides the option
\fBwordbounds\fR.
.TP
.B set zap
Let an unmodified Backspace or Delete erase the marked region
(instead of a single character, and without affecting the cutbuffer).
.SH SYNTAX HIGHLIGHTING
Coloring the different syntactic elements of a file
@@ -311,7 +313,7 @@ good fit for a small editor like \fBnano\fR.
For each kind of file a separate syntax can be defined
via the following commands:
.TP
.BR syntax " ""\fIname\fR"" [""\fIfileregex\fR"" ...]"
.BI syntax " name \fR[" """" fileregex """ " \fR...]
Start the definition of a syntax with this \fIname\fR.
All subsequent \fBcolor\fR and other such commands
will be added to this syntax, until a new \fBsyntax\fR
@@ -323,17 +325,17 @@ expression \fIfileregex\fR. Or the syntax can be explicitly
activated by using the \fB-Y\fR or \fB\-\-syntax\fR
command-line option followed by the \fIname\fR.
The syntax "\fBdefault\fP" is special: it takes no \fIfileregex\fR,
The syntax \fBdefault\fP is special: it takes no \fIfileregex\fR,
and applies to files that don't match any syntax's regexes.
The syntax "\fBnone\fP" is reserved; specifying it on the command line
The syntax \fBnone\fP is reserved; specifying it on the command line
is the same as not having a syntax at all.
.TP
.BR header " ""\fIregex\fR"" " ...
.BI "header """ regex """ \fR...
If from all defined syntaxes no \fIfileregex\fR matched, then compare
this \fIregex\fR (or regexes) against the first line of the current file,
to determine whether this syntax should be used for it.
.TP
.BR magic " ""\fIregex\fR"" " ...
.BI "magic """ regex """ \fR...
If no \fIfileregex\fR matched and no \fBheader\fR regex matched
either, then compare this \fIregex\fR (or regexes) against the
result of querying the \fBmagic\fP database about the current
@@ -342,16 +344,11 @@ file, to determine whether this syntax should be used for it.
system and will be silently ignored otherwise.)
.TP
.BI linter " program " \fR[ "arg " \fR...]
Use the given \fIprogram\fR to run a syntax check on the current file.
Use the given \fIprogram\fR to run a syntax check on the current buffer.
(This overrides the speller function.)
.TP
.BI formatter " program " \fR[ "arg " \fR...]
Use the given \fIprogram\fR to automatically reformat text --
useful in a programming language like Go.
(This overrides the speller and linter functions.)
.TP
.BR comment " ""\fIstring\fR"""
Use the given string for commenting and uncommenting lines.
.BI "comment """ string """
Use the given \fIstring\fR for commenting and uncommenting lines.
If the string contains a vertical bar or pipe character (\fB|\fR),
this designates bracket-style comments; for example, "\fB/*|*/\fR" for
CSS files. The characters before the pipe are prepended to the line and the
@@ -361,21 +358,23 @@ for Python files. If empty double quotes are specified, the comment/uncomment
function is disabled; for example, "" for JSON.
The default value is "\fB#\fP".
.TP
.B color \fIfgcolor\fR,\fIbgcolor\fR """\fIregex\fR""" ...
.BI "color " fgcolor , bgcolor " """ regex """ " \fR...
Display all pieces of text that match
the extended regular expression \fIregex\fP with foreground color
\fIfgcolor\fP and background color \fIbgcolor\fP, at least one of which
must be specified. Valid colors for foreground and background
are: white, black, red, blue, green, yellow, magenta, and cyan. You may
use the prefix "bright" to get a stronger color highlight for the
must be specified. Valid names for foreground and background colors are:
.BR white ", " black ", " blue ", " green ", " red ", "
.BR cyan ", " yellow ", " magenta ", and " normal
-- where \fBnormal\fR means the default foreground or background color.
You may use the prefix \fBbright\fR to get a stronger color highlight for the
foreground. If your terminal supports transparency, not specifying a
\fIbgcolor\fP tells \fBnano\fP to attempt to use a transparent
background.
.TP
.B icolor \fIfgcolor\fR,\fIbgcolor\fR """\fIregex\fR""" ...
.BI "icolor " fgcolor , bgcolor " """ regex """ " \fR...
Same as above, except that the matching is case insensitive.
.TP
.BR color " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIfromrx\fR"" " end= """\fItorx\fR""
.BI "color " fgcolor , bgcolor " start=""" fromrx """ end=""" torx """
Display all pieces of text whose start matches extended regular expression
\fIfromrx\fP and whose end matches extended regular expression \fItorx\fP with
foreground color \fIfgcolor\fP and background color \fIbgcolor\fP,
@@ -384,10 +383,10 @@ initial instance of \fIfromrx\fP, all text until the first instance of
\fItorx\fP will be colored. This allows syntax highlighting to span
multiple lines.
.TP
.BR icolor " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIfromrx\fR"" " end= """\fItorx\fR""
.BI "icolor " fgcolor , bgcolor " start=""" fromrx """ end=""" torx """
Same as above, except that the matching is case insensitive.
.TP
.BR include " ""\fIsyntaxfile\fR"""
.BI "include """ syntaxfile """
Read in self-contained color syntaxes from \fIsyntaxfile\fP. Note that
\fIsyntaxfile\fP may contain only the above commands, from \fBsyntax\fP
to \fBicolor\fP.
@@ -395,11 +394,28 @@ to \fBicolor\fP.
.BI extendsyntax " name command " \fR[ "arg " \fR...]
Extend the syntax previously defined as \fIname\fR with another
\fIcommand\fR. This allows adding a new \fBcolor\fP, \fBicolor\fP,
\fBheader\fP, \fBmagic\fP, \fBcomment\fP, \fBlinter\fP, or \fBformatter\fP
\fBheader\fP, \fBmagic\fP, \fBcomment\fP, or \fBlinter\fP
command to an already defined syntax -- useful when you want to
slightly improve a syntax defined in one of the system-installed
files (which normally are not writable).
.P
Note: the \fBformatter\fR command has been removed. It was superseded by
a more general mechanism: the filtering of buffer or marked text through
an external command. Such filtering is done by typing \fB^R^X\fR and then
preceding your formatter command with the pipe symbol (\fB|\fR). It has
the added advantage that the operation can be undone.
.PP
If you use such a formatting command regularly, you could assign the relevant
series of keystrokes to a single key in your nanorc:
.PP
.RS
.B "bind M\-F \(dq^R^X|yourformatcommand^M\(dq main"
.RE
.PP
(Note that the \fB^R\fR, \fB^X\fR, and \fB^M\fR are each a single, literal
control character. You can enter them by preceding each with \fBM-V\fR.)
.SH REBINDING KEYS
Key bindings can be changed via the following three commands:
.RS 3
@@ -427,16 +443,19 @@ The format of \fIkey\fP should be one of:
.RS 3
.TP 3
.B ^
followed by an alpha character or the word "Space".
Example: ^C
followed by a Latin letter, by one of several ASCII characters
(@, ], \\, ^, or _), or by the word "Space".
Example: ^C.
.TP
.B M-
followed by a printable character or the word "Space".
Example: M-C
followed by any ASCII character except [, or by the word "Space".
Example: M-C.
.TP
.B F
followed by a numeric value from 1 to 16.
Example: F10
Example: F10.
.TP
the word "Ins" or the word "Del".
.RE
.TP
@@ -467,16 +486,14 @@ Starts a forward search for text in the current buffer -- or for filenames
matching a string in the current list in the file browser.
.TP
.B wherewas
Starts a backward search for text in the current buffer.
.TP
.B searchagain
Repeats the last search command without prompting.
Starts a backward search for text in the current buffer -- or for filenames
matching a string in the current list in the file browser.
.TP
.B findprevious
As \fBsearchagain\fR, but always in the backward direction.
Searches the next occurrence in the backward direction.
.TP
.B findnext
As \fBsearchagain\fR, but always in the forward direction.
Searches the next occurrence in the forward direction.
.TP
.B replace
Interactively replaces text within the current buffer.
@@ -484,25 +501,36 @@ Interactively replaces text within the current buffer.
.B cut
Cuts and stores the current line (or the marked region).
.TP
.B copytext
.B copy
Copies the current line (or the marked region) without deleting it.
(The old form 'copytext' is deprecated.)
.TP
.B uncut
Copies the currently stored text into the current buffer at the
.B paste
Pastes the currently stored text into the current buffer at the
current cursor position.
(The old form 'uncut' is deprecated.)
.TP
.B mark
Sets the mark at the current position, to start selecting text.
.B zap
Throw away the current line (or the marked region).
(This function is bound by default to <Meta+Delete>.)
.TP
.B cutwordleft
Cuts from the cursor position to the beginning of the preceding word.
(This function is not bound by default. If your terminal produces
\fB^H\fR for <Ctrl+Backspace>, you can make <Ctrl+Backspace> delete
the word to the left of the cursor by rebinding ^H to this function.)
.TP
.B cutwordright
Cuts from the cursor position to the beginning of the next word.
(This function is bound by default to <Ctrl+Delete>.)
.TP
.B cutrestoffile
Cuts all text from the cursor position till the end of the buffer.
.TP
.B mark
Sets the mark at the current position, to start selecting text.
Or, when it is set, unsets the mark.
.TP
.B curpos
Shows the current cursor position: the line, column, and character positions.
.TP
@@ -510,14 +538,17 @@ Shows the current cursor position: the line, column, and character positions.
Counts the number of words, lines and characters in the current buffer.
.TP
.B speller
Invokes a spell-checking program (or a linting program, if the current
syntax highlighting defines one).
Invokes a spell-checking program (or linting program,
if the active syntax defines such a thing).
.TP
.B linter
A synonym of \fBspeller\fR (for when the speller has not been configured).
.TP
.B justify
Justifies the current paragraph.
Justifies the current paragraph. A paragraph is a group of contiguous lines
that, apart from possibly the first line, all have the same indentation. The
beginning of a paragraph is detected by either this lone line with a differing
indentation or by a preceding blank line.
.TP
.B fulljustify
Justifies the entire current buffer.
@@ -643,19 +674,20 @@ Suspends the editor (if the suspending function is enabled, see the
"suspendenable" entry below).
.TP
.B casesens
Toggles case sensitivity in searching (search/replace menus only).
Toggles whether searching/replacing ignores or respects the case of
the given characters.
.TP
.B regexp
Toggles whether searching/replacing is based on literal strings or regular expressions.
Toggles whether searching/replacing uses literal strings or regular expressions.
.TP
.B backwards
Toggles whether searching/replacing goes forward or backward.
.TP
.B prevhistory
Shows the previous history entry in the prompt menus (e.g. search).
.B older
Retrieves the previous (earlier) entry at a prompt.
.TP
.B nexthistory
Shows the next history entry in the prompt menus (e.g. search).
.B newer
Retrieves the next (later) entry at a prompt.
.TP
.B flipreplace
Toggles between searching for something and replacing something.
@@ -667,10 +699,18 @@ Toggles between searching for text and targeting a line number.
.B flipexecute
Toggles between inserting a file and executing a command.
.TP
.B flippipe
When executing a command, toggles whether the current buffer (or marked
region) is piped to the command.
.TP
.B flipnewbuffer
Toggles between inserting into the current buffer and into a new
empty buffer.
.TP
.B flipconvert
When reading in a file, toggles between converting and not converting
it from DOS/Mac format. Converting is the default.
.TP
.B dosformat
When writing a file, switches to writing a DOS format (CR/LF).
.TP
@@ -711,9 +751,6 @@ Toggles the presence of the two-line list of key bindings at the bottom of the s
Toggles the constant display of the current line, column, and character positions.
(The form 'constupdate' is deprecated.)
.TP
.B morespace
Toggles the presence of the blank line that 'separates' the title bar from the file text.
.TP
.B smoothscroll
Toggles smooth scrolling (when moving around with the arrow keys).
.TP
@@ -733,7 +770,9 @@ Toggles syntax highlighting.
Toggles the smartness of the Home key.
.TP
.B autoindent
Toggles whether new lines will contain the same amount of whitespace as the preceding line.
Toggles whether a newly created line will contain the same amount of leading
whitespace as the preceding line -- or as the next line if the preceding line
is the beginning of a paragraph.
.TP
.B cutfromcursor
Toggles whether cutting text will cut the whole line or just from the current cursor
@@ -746,19 +785,9 @@ Toggles whether long lines will be hard-wrapped to the next line.
.B tabstospaces
Toggles whether typed tabs will be converted to spaces.
.TP
.B backupfile
Toggles whether a backup will be made of the file being edited.
.TP
.B multibuffer
Toggles whether a file is inserted into the current buffer
or read into a new buffer.
.TP
.B mouse
Toggles mouse support.
.TP
.B noconvert
Toggles automatic conversion of files from DOS/Mac format.
.TP
.B suspendenable
Toggles whether the suspend sequence (normally ^Z) will suspend the editor window.
.RE
@@ -779,6 +808,9 @@ The 'search to replace' menu.
.B replacewith
The 'replace with' menu, which comes up after 'search to replace'.
.TP
.B yesno
The 'yesno' menu, where the Yes/No/All/Cancel question is asked.
.TP
.B gotoline
The 'goto line (and column)' menu.
.TP

View File

@@ -7,16 +7,16 @@
.\" Foundation, version 3 or (at your option) any later version. You
.\" should have received a copy of the GNU General Public License
.\" along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\" <https://www.gnu.org/licenses/>.
.\"
.\" * The GNU Free Documentation License, as published by the Free
.\" Software Foundation, version 1.2 or (at your option) any later
.\" version, with no Invariant Sections, no Front-Cover Texts, and no
.\" Back-Cover Texts. You should have received a copy of the GNU Free
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\" <https://www.gnu.org/licenses/>.
.\"
.TH RNANO 1 "version 2.9.7" "May 2018"
.TH RNANO 1 "version 3.2" "November 2018"
.SH NAME
rnano \- a restricted nano
@@ -32,13 +32,11 @@ access to the filesystem nor to a command shell.
.PP
In restricted mode, \fBnano\fR will:
.IP \[bu] 2
not read any nanorc files;
.IP \[bu]
not allow suspending;
.IP \[bu]
not read nor write any file not specified on the command line;
not allow saving the current buffer under a different name;
.IP \[bu]
not allow saving a file under a different name;
not allow inserting another file or opening a new buffer;
.IP \[bu]
not allow appending or prepending to any file;
.IP \[bu]

View File

@@ -1,9 +1,7 @@
## Sample initialization file for GNU nano.
##
## Please note that you must have configured nano with --enable-nanorc
## for this file to be read! Also note that this file should not be in
## DOS or Mac format, and that characters specially interpreted by the
## shell should not be escaped here.
## This file should not be in DOS or Mac format, and characters
## specially interpreted by the shell should not be escaped here.
##
## To make sure an option is disabled, use "unset <option>".
##
@@ -23,7 +21,9 @@
## (tabs and spaces) instead of always at the edge of the screen.
# set atblanks
## Use auto-indentation.
## Automatically indent a newly created line to the same number of
## tabs and/or spaces as the preceding line -- or as the next line
## if the preceding line is the beginning of a paragraph.
# set autoindent
## Back up files to the current filename plus a tilde.
@@ -35,10 +35,9 @@
## Use bold text instead of reverse video text.
# set boldtext
## The characters treated as closing brackets when justifying
## paragraphs. They cannot contain blank characters. Only closing
## punctuation, optionally followed by closing brackets, can end
## sentences.
## The characters treated as closing brackets when justifying paragraphs.
## This may not include any blank characters. Only closing punctuation,
## optionally followed by these closing brackets, can end sentences.
# set brackets ""')>]}"
## Do case-sensitive searches by default.
@@ -52,9 +51,9 @@
# set cutfromcursor
## (The old form, 'cut', is deprecated.)
## Set the line length for wrapping text and justifying paragraphs.
## If the value is 0 or less, the wrapping point will be the screen
## width less this number.
## Enable hard-wrapping and set the target width, both for automatic
## line wrapping and for justifying paragraphs. If the value is 0 or
## less, the wrapping point will be the screen width minus this number.
# set fill -8
## Remember the used search/replace strings for the next session.
@@ -92,14 +91,14 @@
## Don't display the helpful shortcut lists at the bottom of the screen.
# set nohelp
## Don't automatically add a newline when a file does not end with one.
# set nonewlines
## Don't pause between warnings at startup. Which means that only the
## last one will be readable (when there are multiple ones).
# set nopauses
## Don't add newlines to the ends of files.
# set nonewlines
## Don't wrap text at all.
## Do not automatically hard-wrap text.
# set nowrap
## Set operating directory. nano will not read or write files outside
@@ -125,12 +124,8 @@
# set quickblank
## The email-quote string, used to justify email-quoted paragraphs.
## This is an extended regular expression if your system supports them,
## otherwise a literal string.
## If you have extended regular expression support, the default is:
# set quotestr "^([ ]*[#:>\|}])+"
## Otherwise:
# set quotestr "> "
## This is an extended regular expression. The default is:
# set quotestr "^([ ]*([#:>|}]|//))+"
## Fix Backspace/Delete confusion problem.
# set rebinddelete
@@ -141,8 +136,9 @@
## Do extended regular expression searches by default.
# set regexp
## Put the cursor on the highlighted item in the file browser;
## useful for people who use a braille display.
## Put the cursor on the highlighted item in the file browser, and show
## the cursor in the help viewer; useful for people who use a braille
## display and people with poor vision.
# set showcursor
## Make the Home key smarter. When Home is pressed anywhere but at the
@@ -152,7 +148,7 @@
## beginning of the line.
# set smarthome
## Use smooth scrolling as the default.
## Use line-by-line scrolling instead of chunk-by-chunk.
# set smooth
## Enable soft line wrapping (AKA full-line display).
@@ -198,6 +194,9 @@
## set, it overrides option 'set wordbounds'.
# set wordchars "<_>."
## Let an unmodified Backspace or Delete erase the marked region (instead
## of a single character, and without affecting the cutbuffer).
# set zap
## Paint the interface elements of nano. These are examples;
## by default there are no colors, except for errorcolor.
@@ -236,9 +235,9 @@
## "color" will do case-sensitive matches, while "icolor" will do
## case-insensitive matches.
##
## Valid colors: white, black, red, blue, green, yellow, magenta, cyan.
## For foreground colors, you may use the prefix "bright" to get a
## stronger highlight.
## Valid color names ares: white, black, normal, red, blue, green,
## yellow, magenta, cyan. For foreground colors, you may use the
## prefix "bright" to get a stronger highlight.
##
## To use multi-line regexes, use the start="regex" end="regex"
## [start="regex" end="regex"...] format.
@@ -258,18 +257,51 @@
## ".nanorc" extension) should be the same as the "short description"
## name inside that file. These names are kept fairly short to make
## them easier to remember and faster to type using nano's -Y option.
##
## To include all existing syntax definitions, you can do:
# include "@PKGDATADIR@/*.nanorc"
## Key bindings.
## See nanorc(5) (section REBINDING KEYS) for more details on this.
##
## The following two functions are not bound to any key by default.
## You may wish to choose other keys than the ones suggested here.
# bind M-B cutwordleft main
# bind M-N cutwordright main
## Set this if your Backspace key sends Del most of the time.
# bind Del backspace all
## The <Ctrl+Delete> keystroke deletes the word to the right of the cursor.
## On some terminals the <Ctrl+Backspace> keystroke produces ^H, which is
## the ASCII character for backspace, so it is bound by default to the
## backspace function. The <Backspace> key itself produces a different
## keycode, which is hard-bound to the backspace function. So, if you
## normally use <Backspace> for backspacing and not ^H, you can make
## <Ctrl+Backspace> delete the word to the left of the cursor with:
# bind ^H cutwordleft main
## If you would like nano to have keybindings that are more "usual",
## such as ^O for Open, ^F for Find, ^H for Help, and ^Q for Quit,
## then uncomment these:
#bind ^Q exit all
#bind ^H help all
#bind ^H exit help
#bind ^F whereis all
#bind ^G findnext all
#bind ^B wherewas all
#bind ^D findprevious all
#bind ^R replace main
#bind ^W writeout main
#bind ^O insert main
#unbind ^V all
#unbind ^Y all
#bind M-X flipnewbuffer all
#bind ^X cut all
#bind ^C copy all
#bind ^V paste all
#bind ^P curpos main
#bind ^T gotoline main
#bind ^T gotodir browser
#bind ^Y speller main
#unbind ^K all
#unbind ^U all
#bind M-R redo main
#bind ^U undo main
#bind ^E redo main
#unbind M-J main
#unbind M-T main
#set multibuffer

1495
po/bg.po

File diff suppressed because it is too large Load Diff

1692
po/ca.po

File diff suppressed because it is too large Load Diff

1556
po/cs.po

File diff suppressed because it is too large Load Diff

1555
po/da.po

File diff suppressed because it is too large Load Diff

1498
po/de.po

File diff suppressed because it is too large Load Diff

1600
po/eo.po

File diff suppressed because it is too large Load Diff

1408
po/es.po

File diff suppressed because it is too large Load Diff

1671
po/eu.po

File diff suppressed because it is too large Load Diff

1506
po/fi.po

File diff suppressed because it is too large Load Diff

3038
po/fr.po

File diff suppressed because it is too large Load Diff

1535
po/ga.po

File diff suppressed because it is too large Load Diff

1509
po/gl.po

File diff suppressed because it is too large Load Diff

1476
po/hr.po

File diff suppressed because it is too large Load Diff

1524
po/hu.po

File diff suppressed because it is too large Load Diff

1584
po/id.po

File diff suppressed because it is too large Load Diff

1296
po/it.po

File diff suppressed because it is too large Load Diff

1556
po/ja.po

File diff suppressed because it is too large Load Diff

1794
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1575
po/nb.po

File diff suppressed because it is too large Load Diff

1591
po/nl.po

File diff suppressed because it is too large Load Diff

1523
po/nn.po

File diff suppressed because it is too large Load Diff

1490
po/pl.po

File diff suppressed because it is too large Load Diff

1532
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1545
po/ro.po

File diff suppressed because it is too large Load Diff

1494
po/ru.po

File diff suppressed because it is too large Load Diff

1502
po/sl.po

File diff suppressed because it is too large Load Diff

1577
po/sr.po

File diff suppressed because it is too large Load Diff

1617
po/sv.po

File diff suppressed because it is too large Load Diff

1639
po/tr.po

File diff suppressed because it is too large Load Diff

1593
po/uk.po

File diff suppressed because it is too large Load Diff

1530
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

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

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

View File

@@ -166,15 +166,13 @@ char *do_browser(char *path)
say_there_is_no_help();
#endif
} else if (func == do_search_forward) {
do_filesearch();
} else if (func == do_research) {
do_fileresearch(FORWARD);
#ifndef NANO_TINY
do_filesearch(FORWARD);
} else if (func == do_search_backward) {
do_filesearch(BACKWARD);
} else if (func == do_findprevious) {
do_fileresearch(BACKWARD);
} else if (func == do_findnext) {
do_fileresearch(FORWARD);
#endif
} else if (func == do_left) {
if (selected > 0)
selected--;
@@ -464,10 +462,11 @@ functionptrtype parse_browser_input(int *kbinput)
{
if (!meta_key) {
switch (*kbinput) {
case ' ':
return do_page_down;
case DEL_CODE:
case '-':
return do_page_up;
case ' ':
return do_page_down;
case '?':
return do_help_void;
case 'E':
@@ -488,11 +487,9 @@ functionptrtype parse_browser_input(int *kbinput)
case '/':
return do_search_forward;
case 'N':
#ifndef NANO_TINY
return do_findprevious;
#endif
case 'n':
return do_research;
return do_findnext;
}
}
return func_from_key(kbinput);
@@ -659,10 +656,11 @@ void browser_select_dirname(const char *needle)
}
}
/* Prepare the prompt and ask the user what to search for. Return -2
/* Prepare the prompt and ask the user what to search for. If forwards is
* TRUE, search forward in the list; otherwise, search backward. Return -2
* for a blank answer, -1 for Cancel, 0 when we have a string, and a
* positive value when some function was run. */
int filesearch_init(void)
int filesearch_init(bool forwards)
{
char *thedefault;
int response;
@@ -681,7 +679,8 @@ int filesearch_init(void)
/* Now ask what to search for. */
response = do_prompt(FALSE, FALSE, MWHEREISFILE, NULL, &search_history,
browser_refresh, "%s%s", _("Search"), thedefault);
browser_refresh, "%s%s%s", _("Search"),
!forwards ? _(" [Backwards]") : "", thedefault);
free(thedefault);
/* If only Enter was pressed but we have a previous string, it's okay. */
@@ -754,11 +753,12 @@ void findfile(const char *needle, bool forwards)
selected = looking_at;
}
/* Search for a filename. */
void do_filesearch(void)
/* Search for a filename. If forwards is TRUE, search forward in the list;
* otherwise, search backward.*/
void do_filesearch(bool forwards)
{
/* If the user cancelled or jumped to first or last file, don't search. */
if (filesearch_init() != 0)
if (filesearch_init(forwards) != 0)
return;
/* If answer is now "", copy last_search into answer. */
@@ -773,7 +773,7 @@ void do_filesearch(void)
update_history(&search_history, answer);
#endif
findfile(answer, TRUE);
findfile(answer, forwards);
}
/* Search again without prompting for the last given search string,

View File

@@ -62,11 +62,6 @@ bool is_byte(int c)
return ((unsigned int)c == (unsigned char)c);
}
void mbtowc_reset(void)
{
IGNORE_CALL_RESULT(mbtowc(NULL, NULL, 0));
}
/* This function is equivalent to isalpha() for multibyte characters. */
bool is_alpha_mbchar(const char *c)
{
@@ -74,10 +69,8 @@ bool is_alpha_mbchar(const char *c)
if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return 0;
}
return iswalpha(wc);
} else
@@ -92,10 +85,8 @@ bool is_alnum_mbchar(const char *c)
if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return 0;
}
return iswalnum(wc);
} else
@@ -110,10 +101,8 @@ bool is_blank_mbchar(const char *c)
if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return 0;
}
return iswblank(wc);
} else
@@ -128,13 +117,6 @@ bool is_ascii_cntrl_char(int c)
return (0 <= c && c < 32);
}
/* This function is equivalent to iscntrl(), except in that it also
* handles high-bit control characters. */
bool is_cntrl_char(int c)
{
return ((c & 0x60) == 0 || c == 127);
}
/* This function is equivalent to iscntrl() for multibyte characters,
* except in that it also handles multibyte control characters with
* their high bits set. */
@@ -146,7 +128,7 @@ bool is_cntrl_mbchar(const char *c)
((signed char)c[0] == -62 && (signed char)c[1] < -96));
} else
#endif
return is_cntrl_char((unsigned char)*c);
return (((unsigned char)*c & 0x60) == 0 || (unsigned char)*c == 127);
}
/* This function is equivalent to ispunct() for multibyte characters. */
@@ -156,10 +138,8 @@ bool is_punct_mbchar(const char *c)
if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return 0;
}
return iswpunct(wc);
} else
@@ -232,10 +212,8 @@ int length_of_char(const char *c, int *width)
int charlen = mbtowc(&wc, c, MAXCHARLEN);
/* If the sequence is invalid... */
if (charlen < 0) {
mbtowc_reset();
if (charlen < 0)
return -1;
}
/* If the codepoint is invalid... */
if (!is_valid_unicode(wc))
@@ -260,10 +238,8 @@ int mbwidth(const char *c)
wchar_t wc;
int width;
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return 1;
}
width = wcwidth(wc);
@@ -309,65 +285,45 @@ char *make_mbchar(long chr, int *chr_mb_len)
* col isn't NULL, add the character's width (in columns) to it. */
int parse_mbchar(const char *buf, char *chr, size_t *col)
{
int length;
#ifdef ENABLE_UTF8
if (use_utf8) {
/* Get the number of bytes in the multibyte character. */
int length = mblen(buf, MAXCHARLEN);
/* If this is a UTF-8 starter byte, get the number of bytes of the character. */
if ((signed char)*buf < 0) {
length = mblen(buf, MAXCHARLEN);
/* When the multibyte sequence is invalid, only take the first byte. */
if (length <= 0) {
IGNORE_CALL_RESULT(mblen(NULL, 0));
if (length <= 0)
length = 1;
}
/* When requested, store the multibyte character in chr. */
if (chr != NULL) {
int i;
for (i = 0; i < length; i++)
chr[i] = buf[i];
}
/* When requested, add the width of the character to col. */
if (col != NULL) {
/* If we have a tab, compute its width in columns based on the
* current value of col. */
if (*buf == '\t')
*col += tabsize - *col % tabsize;
/* If we have a control character, it's two columns wide: one
* column for the "^", and one for the visible character. */
else if (is_cntrl_mbchar(buf)) {
*col += 2;
/* If we have a normal character, get its width normally. */
} else
*col += mbwidth(buf);
}
return length;
} else
#endif
{
/* When requested, store the byte character in chr. */
if (chr != NULL)
*chr = *buf;
length = 1;
/* When requested, add the width of the character to col. */
if (col != NULL) {
/* If we have a tab, compute its width in columns using the
* current value of col. */
if (*buf == '\t')
*col += tabsize - *col % tabsize;
/* If we have a control character, it's two columns wide: one
* column for the "^", and one for the visible character. */
else if (is_cntrl_char((unsigned char)*buf))
*col += 2;
/* If we have a normal character, it's one column wide. */
else
(*col)++;
}
/* When requested, store the multibyte character in chr. */
if (chr != NULL)
for (int i = 0; i < length; i++)
chr[i] = buf[i];
return 1;
/* When requested, add the width of the character to col. */
if (col != NULL) {
/* If we have a tab, compute its width in columns based on the
* current value of col. */
if (*buf == '\t')
*col += tabsize - *col % tabsize;
/* If we have a control character, it's two columns wide: one
* column for the "^", and one for the visible character. */
else if (is_cntrl_mbchar(buf))
*col += 2;
/* If we have a normal character, get its width normally. */
else if (length == 1)
*col += 1;
#ifdef ENABLE_UTF8
else
*col += mbwidth(buf);
#endif
}
return length;
}
/* Return the index in buf of the beginning of the multibyte character
@@ -430,17 +386,8 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
wchar_t wc1, wc2;
while (*s1 != '\0' && *s2 != '\0' && n > 0) {
bool bad1 = FALSE, bad2 = FALSE;
if (mbtowc(&wc1, s1, MAXCHARLEN) < 0) {
mbtowc_reset();
bad1 = TRUE;
}
if (mbtowc(&wc2, s2, MAXCHARLEN) < 0) {
mbtowc_reset();
bad2 = TRUE;
}
bool bad1 = (mbtowc(&wc1, s1, MAXCHARLEN) < 0);
bool bad2 = (mbtowc(&wc2, s2, MAXCHARLEN) < 0);
if (bad1 || bad2) {
if (*s1 != *s2)
@@ -556,22 +503,26 @@ char *mbrevstrcasestr(const char *haystack, const char *needle,
return revstrcasestr(haystack, needle, pointer);
}
/* This function is equivalent to strlen() for multibyte strings. */
/* Count the number of (multibyte) characters in the given string. */
size_t mbstrlen(const char *s)
{
return mbstrnlen(s, (size_t)-1);
}
size_t maxlen = (size_t)-1;
/* This function is equivalent to strnlen() for multibyte strings. */
size_t mbstrnlen(const char *s, size_t maxlen)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
size_t n = 0;
for (; *s != '\0' && maxlen > 0; s += move_mbright(s, 0),
maxlen--, n++)
;
while (*s != '\0' && maxlen > 0) {
if ((signed char)*s < 0) {
int length = mblen(s, MAXCHARLEN);
s += (length < 0 ? 1 : length);
} else
s++;
maxlen--;
n++;
}
return n;
} else
@@ -591,7 +542,6 @@ char *mbstrchr(const char *s, const char *c)
wchar_t ws, wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
wc = (unsigned char)*c;
bad_c_mb = TRUE;
}
@@ -600,7 +550,6 @@ char *mbstrchr(const char *s, const char *c)
int sym_len = parse_mbchar(s, symbol, NULL);
if (mbtowc(&ws, symbol, sym_len) < 0) {
mbtowc_reset();
ws = (unsigned char)*s;
bad_s_mb = TRUE;
}
@@ -731,17 +680,3 @@ bool is_valid_unicode(wchar_t wc)
(0xFFFF < wc && wc <= 0x10FFFF && (wc & 0xFFFF) <= 0xFFFD));
}
#endif
#ifdef ENABLE_NANORC
/* Check if the string s is a valid multibyte string. Return TRUE if it
* is, and FALSE otherwise. */
bool is_valid_mbstring(const char *s)
{
#ifdef ENABLE_UTF8
if (use_utf8)
return (mbstowcs(NULL, s, 0) != (size_t)-1);
else
#endif
return TRUE;
}
#endif /* ENABLE_NANORC */

View File

@@ -66,7 +66,7 @@ void set_colorpairs(void)
combo->bg = COLOR_BLACK;
init_pair(i + 1, combo->fg, combo->bg);
interface_color_pair[i] = COLOR_PAIR(i + 1) | A_BANDAID |
(combo->bright ? A_BOLD : A_NORMAL);
combo->attributes;
} else {
if (i == FUNCTION_TAG)
interface_color_pair[i] = A_NORMAL;
@@ -98,8 +98,7 @@ void set_colorpairs(void)
else
ink->pairnum = new_number++;
ink->attributes = COLOR_PAIR(ink->pairnum) | A_BANDAID |
(ink->bright ? A_BOLD : A_NORMAL);
ink->attributes |= COLOR_PAIR(ink->pairnum) | A_BANDAID;
}
}
}

View File

@@ -33,12 +33,6 @@ void cutbuffer_reset(void)
keep_cutbuffer = FALSE;
}
/* Return the status of cutbuffer preservation. */
inline bool keeping_cutbuffer(void)
{
return keep_cutbuffer;
}
/* If we aren't on the last line of the file, move all the text of the
* current line, plus the newline at the end, into the cutbuffer. If we
* are, move all of the text of the current line into the cutbuffer. In
@@ -110,8 +104,9 @@ void cut_to_eof(void)
/* Move text from the current buffer into the cutbuffer. If
* copy_text is TRUE, copy the text back into the buffer afterward.
* If cut_till_eof is TRUE, move all text from the current cursor
* position to the end of the file into the cutbuffer. */
void do_cut_text(bool copy_text, bool cut_till_eof)
* position to the end of the file into the cutbuffer. If append
* is TRUE (when zapping), always append the cut to the cutbuffer. */
void do_cut_text(bool copy_text, bool marked, bool cut_till_eof, bool append)
{
#ifndef NANO_TINY
filestruct *cb_save = NULL;
@@ -125,12 +120,12 @@ void do_cut_text(bool copy_text, bool cut_till_eof)
#endif
size_t was_totsize = openfile->totsize;
/* If a chain of cuts was broken, empty the cutbuffer. */
if (!keep_cutbuffer) {
/* If cuts were not continuous, or when cutting a region, clear the slate. */
if (!append && (!keep_cutbuffer || marked || cut_till_eof)) {
free_filestruct(cutbuffer);
cutbuffer = NULL;
/* Indicate that future cuts should add to the cutbuffer. */
keep_cutbuffer = TRUE;
/* After a line cut, future line cuts should add to the cutbuffer. */
keep_cutbuffer = !marked && !cut_till_eof;
}
#ifndef NANO_TINY
@@ -187,21 +182,22 @@ void do_cut_text(bool copy_text, bool cut_till_eof)
set_modified();
refresh_needed = TRUE;
#ifdef DEBUG
dump_filestruct(cutbuffer);
#endif
}
/* Move text from the current buffer into the cutbuffer. */
void do_cut_text_void(void)
{
#ifndef NANO_TINY
add_undo(CUT);
#endif
do_cut_text(FALSE, FALSE);
#ifndef NANO_TINY
/* Only add a new undo item when the current item is not a CUT or when
* the current cut is not contiguous with the previous cutting. */
if (openfile->last_action != CUT || openfile->current_undo == NULL ||
openfile->current_undo->mark_begin_lineno != openfile->current->lineno ||
!keep_cutbuffer)
add_undo(CUT);
do_cut_text(FALSE, openfile->mark, FALSE, FALSE);
update_undo(CUT);
#else
do_cut_text(FALSE, FALSE, FALSE, FALSE);
#endif
}
@@ -211,7 +207,7 @@ void do_cut_text_void(void)
* was moved, blow away previous contents of the cutbuffer. */
void do_copy_text(void)
{
static struct filestruct *next_contiguous_line = NULL;
static filestruct *next_contiguous_line = NULL;
bool mark_is_set = (openfile->mark != NULL);
/* Remember the current viewport and cursor position. */
@@ -223,7 +219,7 @@ void do_copy_text(void)
if (mark_is_set || openfile->current != next_contiguous_line)
cutbuffer_reset();
do_cut_text(TRUE, FALSE);
do_cut_text(TRUE, mark_is_set, FALSE, FALSE);
/* If the mark was set, blow away the cutbuffer on the next copy. */
next_contiguous_line = (mark_is_set ? NULL : openfile->current);
@@ -241,9 +237,35 @@ void do_copy_text(void)
void do_cut_till_eof(void)
{
add_undo(CUT_TO_EOF);
do_cut_text(FALSE, TRUE);
do_cut_text(FALSE, FALSE, TRUE, FALSE);
update_undo(CUT_TO_EOF);
}
/* Erase text (current line or marked region), sending it into oblivion. */
void zap_text(void)
{
/* Remember the current cutbuffer so it can be restored after the zap. */
filestruct *was_cutbuffer = cutbuffer;
filestruct *was_cutbottom = cutbottom;
/* Add a new undo item only when the current item is not a ZAP or when
* the current zap is not contiguous with the previous zapping. */
if (openfile->last_action != ZAP || openfile->current_undo == NULL ||
openfile->current_undo->mark_begin_lineno != openfile->current->lineno ||
openfile->current_undo->xflags & (MARK_WAS_SET|WAS_MARKED_FORWARD))
add_undo(ZAP);
/* Use the cutbuffer from the ZAP undo item, so the cut can be undone. */
cutbuffer = openfile->current_undo->cutbuffer;
cutbottom = openfile->current_undo->cutbottom;
do_cut_text(FALSE, openfile->mark, FALSE, TRUE);
update_undo(ZAP);
cutbuffer = was_cutbuffer;
cutbottom = was_cutbottom;
}
#endif /* !NANO_TINY */
/* Copy text from the cutbuffer into the current buffer. */

View File

@@ -2,7 +2,7 @@
* files.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2015-2017 Benno Schulenberg *
* Copyright (C) 2015-2018 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -62,7 +62,7 @@ bool has_valid_path(const char *filename)
/* Add an item to the circular list of openfile structs. */
void make_new_buffer(void)
{
openfilestruct *newnode = make_new_opennode();
openfilestruct *newnode = nmalloc(sizeof(openfilestruct));
if (openfile == NULL) {
/* Make the first open file the only element in the list. */
@@ -512,6 +512,7 @@ void replace_buffer(const char *filename)
{
FILE *f;
int descriptor;
filestruct *was_cutbuffer = cutbuffer;
/* Open the file quietly. */
descriptor = open_file(filename, FALSE, TRUE, &f);
@@ -520,29 +521,44 @@ void replace_buffer(const char *filename)
if (descriptor < 0)
return;
/* Reinitialize the text of the current buffer. */
free_filestruct(openfile->fileage);
initialize_buffer_text();
#ifndef NANO_TINY
add_undo(COUPLE_BEGIN);
openfile->undotop->strdata = mallocstrcpy(NULL, _("spelling correction"));
#endif
/* Throw away the text of the file. */
cutbuffer = NULL;
openfile->current = openfile->fileage;
openfile->current_x = 0;
#ifndef NANO_TINY
add_undo(CUT_TO_EOF);
#endif
do_cut_text(FALSE, FALSE, TRUE, FALSE);
#ifndef NANO_TINY
update_undo(CUT_TO_EOF);
#endif
free_filestruct(cutbuffer);
cutbuffer = was_cutbuffer;
/* Insert the processed file into its place. */
read_file(f, descriptor, filename, FALSE);
read_file(f, descriptor, filename, TRUE);
/* Put current at a place that is certain to exist. */
openfile->current = openfile->fileage;
#ifndef NANO_TINY
add_undo(COUPLE_END);
openfile->undotop->strdata = mallocstrcpy(NULL, _("spelling correction"));
#endif
}
#ifndef NANO_TINY
/* Open the specified file, and if that succeeds, blow away the text of
* the current buffer at the given coordinates and read the file
* the current buffer covered by the mark and read the file
* contents into its place. */
void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
filestruct *bot, size_t bot_x)
void replace_marked_buffer(const char *filename)
{
FILE *f;
int descriptor;
bool old_no_newlines = ISSET(NO_NEWLINES);
filestruct *trash_top = NULL;
filestruct *trash_bot = NULL;
filestruct *was_cutbuffer = cutbuffer;
descriptor = open_file(filename, FALSE, TRUE, &f);
@@ -552,15 +568,26 @@ void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
/* Don't add a magicline when replacing text in the buffer. */
SET(NO_NEWLINES);
/* Throw away the text under the mark, and insert the processed file
* where the marked text was. */
extract_buffer(&trash_top, &trash_bot, top, top_x, bot, bot_x);
free_filestruct(trash_top);
read_file(f, descriptor, filename, FALSE);
add_undo(COUPLE_BEGIN);
openfile->undotop->strdata = mallocstrcpy(NULL, _("spelling correction"));
/* Throw away the text under the mark. */
cutbuffer = NULL;
add_undo(CUT);
do_cut_text(FALSE, TRUE, FALSE, FALSE);
update_undo(CUT);
free_filestruct(cutbuffer);
cutbuffer = was_cutbuffer;
/* Insert the processed file where the marked text was. */
read_file(f, descriptor, filename, TRUE);
/* Restore the magicline behavior now that we're done fiddling. */
if (!old_no_newlines)
UNSET(NO_NEWLINES);
add_undo(COUPLE_END);
openfile->undotop->strdata = mallocstrcpy(NULL, _("spelling correction"));
}
#endif /* !NANO_TINY */
#endif /* ENABLE_SPELLER */
@@ -585,12 +612,31 @@ void prepare_for_display(void)
}
#ifdef ENABLE_MULTIBUFFER
/* Show name of current buffer and its number of lines on the status bar. */
void mention_name_and_linecount(void)
{
size_t count = openfile->filebot->lineno -
(openfile->filebot->data[0] == '\0' ? 1 : 0);
#ifndef NANO_TINY
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),
openfile->filename[0] == '\0' ?
_("New Buffer") : tail(openfile->filename), count,
openfile->fmt == DOS_FILE ? _("DOS") : _("Mac"));
else
#endif
statusline(HUSH, P_("%s -- %zu line", "%s -- %zu lines", count),
openfile->filename[0] == '\0' ?
_("New Buffer") : tail(openfile->filename), count);
}
/* Switch to a neighbouring file buffer; to the next if to_next is TRUE;
* otherwise, to the previous one. */
void switch_to_adjacent_buffer(bool to_next)
{
/* If only one file buffer is open, say so and get out. */
if (openfile == openfile->next && !inhelp) {
if (openfile == openfile->next) {
statusbar(_("No more open file buffers"));
return;
}
@@ -615,14 +661,8 @@ void switch_to_adjacent_buffer(bool to_next)
/* Ensure that the main loop will redraw the help lines. */
currmenu = MMOST;
/* Indicate the switch on the statusbar. */
statusline(HUSH, _("Switched to %s"),
((openfile->filename[0] == '\0') ?
_("New Buffer") : openfile->filename));
#ifdef DEBUG
dump_filestruct(openfile->current);
#endif
/* Indicate on the status bar where we switched to. */
mention_name_and_linecount();
}
/* Switch to the previous entry in the list of open files. */
@@ -647,7 +687,7 @@ bool close_buffer(void)
return FALSE;
#ifdef ENABLE_HISTORIES
if (ISSET(POS_HISTORY))
if (ISSET(POSITIONLOG))
update_poshistory(openfile->filename,
openfile->current->lineno, xplustabs() + 1);
#endif
@@ -760,8 +800,12 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
topline = make_new_node(NULL);
bottomline = topline;
/* Lock the file before starting to read it, to avoid the overhead
* of locking it for each single byte that we read from it. */
flockfile(f);
/* Read the entire file into the new buffer. */
while ((input_int = getc(f)) != EOF) {
while ((input_int = getc_unlocked(f)) != EOF) {
input = (char)input_int;
/* If it's a *nix file ("\n") or a DOS file ("\r\n"), and file
@@ -828,6 +872,9 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
#endif
}
/* We are done with the file, unlock it. */
funlockfile(f);
/* Perhaps this could use some better handling. */
if (ferror(f))
nperror(filename);
@@ -1036,7 +1083,7 @@ void do_insertfile(void)
if (execute) {
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER))
/* TRANSLATORS: The next four messages are prompts. */
/* TRANSLATORS: The next six messages are prompts. */
msg = _("Command to execute in new buffer");
else
#endif
@@ -1046,10 +1093,20 @@ void do_insertfile(void)
{
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER))
msg = _("File to insert into new buffer [from %s]");
#ifndef NANO_TINY
if ISSET(NO_CONVERT)
msg = _("File to read unconverted into new buffer [from %s]");
else
#endif
msg = _("File to read into new buffer [from %s]");
else
#endif
msg = _("File to insert [from %s]");
#ifndef NANO_TINY
if ISSET(NO_CONVERT)
msg = _("File to insert unconverted [from %s]");
else
#endif
msg = _("File to insert [from %s]");
}
present_path = mallocstrcpy(present_path, "./");
@@ -1092,6 +1149,10 @@ void do_insertfile(void)
}
#endif
#ifndef NANO_TINY
if (func == flip_convert) {
TOGGLE(NO_CONVERT);
continue;
}
if (func == flip_execute) {
execute = !execute;
continue;
@@ -1109,6 +1170,13 @@ void do_insertfile(void)
answer = chosen;
i = 0;
}
#endif
#ifndef NANO_TINY
if (func == flip_pipe) {
add_or_remove_pipe_symbol_from_answer();
given = mallocstrcpy(given, answer);
continue;
}
#endif
/* If we don't have a file yet, go back to the prompt. */
if (i != 0 && (!ISSET(MULTIBUFFER) || i != -2))
@@ -1153,7 +1221,7 @@ void do_insertfile(void)
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER)) {
#ifdef ENABLE_HISTORIES
if (ISSET(POS_HISTORY)) {
if (ISSET(POSITIONLOG)) {
ssize_t priorline, priorcol;
#ifndef NANO_TINY
if (!execute)
@@ -1190,10 +1258,6 @@ void do_insertfile_void(void)
{
if (ISSET(RESTRICTED))
show_restricted_warning();
#ifdef ENABLE_MULTIBUFFER
else if (ISSET(VIEW_MODE) && !ISSET(MULTIBUFFER))
statusbar(_("Key invalid in non-multibuffer mode"));
#endif
else
do_insertfile();
}
@@ -1755,6 +1819,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
umask(original_umask);
}
#ifndef NANO_TINY
/* If we're prepending, copy the file to a temp file. */
if (method == PREPEND) {
int fd_source;
@@ -1801,6 +1866,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
goto cleanup_and_exit;
}
}
#endif /* !NANO_TINY */
if (f_open == NULL) {
/* Now open the file in place. Use O_EXCL if tmp is TRUE. This
@@ -1834,13 +1900,12 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
while (fileptr != NULL) {
size_t data_len = strlen(fileptr->data), size;
/* Convert newlines to nulls, just before we write to disk. */
/* Decode LFs as the NULs that they are, before writing to disk. */
sunder(fileptr->data);
size = fwrite(fileptr->data, sizeof(char), data_len, f);
/* Convert nulls to newlines. data_len is the string's real
* length. */
/* Re-encode any embedded NULs as LFs. */
unsunder(fileptr->data, data_len);
if (size < data_len) {
@@ -1882,6 +1947,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
lineswritten++;
}
#ifndef NANO_TINY
/* If we're prepending, open the temp file, and append it to f. */
if (method == PREPEND) {
int fd_source;
@@ -1909,22 +1975,24 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
}
unlink(tempname);
} else if (fclose(f) != 0) {
} else
#endif
if (fclose(f) != 0) {
statusline(ALERT, _("Error writing %s: %s"), realname,
strerror(errno));
goto cleanup_and_exit;
}
if (method == OVERWRITE && !tmp) {
/* If we must set the filename, and it changed, adjust things. */
if (fullbuffer && strcmp(openfile->filename, realname) != 0) {
/* When having written an entire buffer, update some administrivia. */
if (fullbuffer && method == OVERWRITE && !tmp) {
/* If the filename was changed, check if this means a new syntax. */
if (strcmp(openfile->filename, realname) != 0) {
#ifdef ENABLE_COLOR
const char *oldname, *newname;
oldname = openfile->syntax ? openfile->syntax->name : "";
#endif
openfile->filename = mallocstrcpy(openfile->filename, realname);
#ifdef ENABLE_COLOR
/* See if the applicable syntax has changed. */
color_update();
@@ -1941,29 +2009,27 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
line->multidata = NULL;
line = line->next;
}
precalc_multicolorinfo();
refresh_needed = TRUE;
}
#endif
}
if (fullbuffer) {
#ifndef NANO_TINY
/* Get or update the stat info to reflect the current state. */
stat_with_alloc(realname, &openfile->current_stat);
/* Get or update the stat info to reflect the current state. */
stat_with_alloc(realname, &openfile->current_stat);
/* Record at which point in the undo stack the file was saved. */
openfile->last_saved = openfile->current_undo;
openfile->last_action = OTHER;
/* Record at which point in the undo stack the file was saved. */
openfile->last_saved = openfile->current_undo;
openfile->last_action = OTHER;
#endif
openfile->modified = FALSE;
titlebar(NULL);
}
statusline(HUSH, P_("Wrote %zu line", "Wrote %zu lines",
lineswritten), lineswritten);
openfile->modified = FALSE;
titlebar(NULL);
}
if (!tmp)
statusline(HUSH, P_("Wrote %zu line", "Wrote %zu lines",
lineswritten), lineswritten);
retval = TRUE;
cleanup_and_exit:
@@ -2140,8 +2206,12 @@ int do_writeout(bool exiting, bool withprompt)
* egg. Display the credits. */
if (!did_credits && exiting && !ISSET(TEMP_FILE) &&
strcasecmp(answer, "zzy") == 0) {
do_credits();
did_credits = TRUE;
if (LINES > 5 && COLS > 31) {
do_credits();
did_credits = TRUE;
} else
/* TRANSLATORS: Concisely say the screen is too small. */
statusbar(_("Too tiny"));
break;
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -161,7 +161,6 @@ void do_help(void)
didfind = 0;
bottombars(MHELP);
wnoutrefresh(bottomwin);
/* Extract the title from the head of the help text. */
length = break_line(help_text, MAX_BUF_SIZE, TRUE);
@@ -184,41 +183,34 @@ void do_help(void)
focusing = TRUE;
/* Show the cursor when we searched and found something. */
kbinput = get_kbinput(edit, didfind == 1);
kbinput = get_kbinput(edit, didfind == 1 || ISSET(SHOW_CURSOR));
didfind = 0;
func = parse_help_input(&kbinput);
if (func == total_refresh) {
total_redraw();
} else if (ISSET(SHOW_CURSOR) && (func == do_left || func == do_right ||
func == do_up || func == do_down)) {
func();
} else if (func == do_up) {
do_scroll_up();
} else if (func == do_down) {
if (openfile->edittop->lineno + editwinrows - 1 <
openfile->filebot->lineno)
do_scroll_down();
} else if (func == do_page_up) {
do_page_up();
} else if (func == do_page_down) {
do_page_down();
} else if (func == to_first_line) {
to_first_line();
} else if (func == to_last_line) {
to_last_line();
} else if (func == do_search_forward) {
do_search();
} else if (func == do_page_up || func == do_page_down ||
func == to_first_line || func == to_last_line ||
func == do_findprevious || func == do_findnext) {
func();
} else if (func == do_search_forward || func == do_search_backward) {
func();
bottombars(MHELP);
} else if (func == do_research) {
do_research();
#ifndef NANO_TINY
} else if (func == do_findprevious) {
do_findprevious();
} else if (func == do_findnext) {
do_findnext();
#ifdef ENABLE_NANORC
} else if (func == (functionptrtype)implant) {
implant(first_sc_for(MHELP, func)->expansion);
#endif
#ifndef NANO_TINY
} else if (kbinput == KEY_WINCH) {
; /* Nothing to do. */
#endif
@@ -414,11 +406,21 @@ void help_init(void)
htx[0] = N_("Execute Command Help Text\n\n "
"This mode allows you to insert the output of a "
"command run by the shell into the current buffer (or "
"a new buffer in multiple file buffer mode). If you "
"need another blank buffer, do not enter any "
"command.\n\n The following function keys are "
"into a new buffer). If the command is preceded by '|' "
"(the pipe symbol), the current contents of the buffer "
"(or marked region) will be piped to the command. ");
htx[1] = N_("If you just need another blank buffer, do not enter any "
"command.\n\n");
htx[2] = N_(" The following function keys are "
"available in Execute Command mode:\n\n");
htx[1] = NULL;
} else if (currmenu == MLINTER) {
htx[0] = N_("=== Linter ===\n\n "
"In this mode, the status bar shows an error message or "
"warning, and the cursor is put at the corresponding "
"position in the file. With PageUp and PageDown you "
"can switch to earlier and later messages.\n\n");
htx[1] = N_(" The following function keys are "
"available in Linter mode:\n\n");
htx[2] = NULL;
}
#endif /* !NANO_TINY */
@@ -498,28 +500,20 @@ void help_init(void)
/* Now add our shortcut info. */
for (f = allfuncs; f != NULL; f = f->next) {
int scsfound = 0;
int tally = 0;
if ((f->menus & currmenu) == 0)
continue;
/* Let's simply show the first two shortcuts from the list. */
for (s = sclist; s != NULL; s = s->next) {
if ((s->menus & currmenu) == 0)
continue;
if (s->func == f->func) {
scsfound++;
if ((s->menus & currmenu) && s->func == f->func) {
/* Make the first column narrower (6) than the second (10),
* but allow it to spill into the second, for "M-Space". */
if (scsfound == 1) {
if (++tally == 1) {
sprintf(ptr, "%s ", s->keystr);
/* Unicode arrows take three bytes instead of one. */
if (strstr(s->keystr, "\xE2") != NULL)
ptr += 8;
else
ptr += 6;
ptr += (strstr(s->keystr, "\xE2") != NULL ? 8 : 6);
} else {
ptr += sprintf(ptr, "(%s)\t", s->keystr);
break;
@@ -527,9 +521,9 @@ void help_init(void)
}
}
if (scsfound == 0)
if (tally == 0)
ptr += sprintf(ptr, "\t\t");
else if (scsfound == 1)
else if (tally == 1)
ptr += 10;
/* The shortcut's help text. */
@@ -573,20 +567,19 @@ functionptrtype parse_help_input(int *kbinput)
{
if (!meta_key) {
switch (*kbinput) {
case ' ':
return do_page_down;
case DEL_CODE:
case '-':
return do_page_up;
case ' ':
return do_page_down;
case 'W':
case 'w':
case '/':
return do_search_forward;
case 'N':
#ifndef NANO_TINY
return do_findprevious;
#endif
case 'n':
return do_research;
return do_findnext;
case 'E':
case 'e':
case 'Q':

View File

@@ -403,7 +403,7 @@ void load_poshistory(void)
if (hisfile == NULL) {
if (errno != ENOENT) {
/* When reading failed, don't save history when we quit. */
UNSET(POS_HISTORY);
UNSET(POSITIONLOG);
history_error(N_("Error reading %s: %s"), poshistname, strerror(errno));
}
} else {

View File

@@ -2,7 +2,7 @@
* move.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017 Benno Schulenberg *
* Copyright (C) 2014-2018 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -170,41 +170,33 @@ void do_page_down(void)
}
#ifdef ENABLE_JUSTIFY
/* Move to the beginning of the last beginning-of-paragraph line before the
* current line. If update_screen is TRUE, update the screen afterwards. */
void do_para_begin(bool update_screen)
/* Move to the beginning of the first-found beginning-of-paragraph line
* before the current line. */
void do_para_begin(void)
{
filestruct *was_current = openfile->current;
if (openfile->current != openfile->fileage)
openfile->current = openfile->current->prev;
while (!begpar(openfile->current))
while (!begpar(openfile->current, 0))
openfile->current = openfile->current->prev;
openfile->current_x = 0;
if (update_screen)
edit_redraw(was_current, CENTERING);
}
/* Move down to the beginning of the last line of the current paragraph.
* Then move down one line farther if there is such a line, or to the
* end of the current line if not. If update_screen is TRUE, update the
* screen afterwards. A line is the last line of a paragraph if it is
* in a paragraph, and the next line either is the beginning line of a
* paragraph or isn't in a paragraph. */
void do_para_end(bool update_screen)
* end of the current line if not. A line is the last line of a paragraph
* if it is in a paragraph, and the next line either is the beginning line
* of a paragraph or isn't in a paragraph. */
void do_para_end(void)
{
filestruct *was_current = openfile->current;
while (openfile->current != openfile->filebot &&
!inpar(openfile->current))
openfile->current = openfile->current->next;
while (openfile->current != openfile->filebot &&
inpar(openfile->current->next) &&
!begpar(openfile->current->next)) {
!begpar(openfile->current->next, 0)) {
openfile->current = openfile->current->next;
}
@@ -213,21 +205,26 @@ void do_para_end(bool update_screen)
openfile->current_x = 0;
} else
openfile->current_x = strlen(openfile->current->data);
if (update_screen)
edit_redraw(was_current, CENTERING);
}
/* Move up to first start of a paragraph before the current line. */
void do_para_begin_void(void)
{
do_para_begin(TRUE);
filestruct *was_current = openfile->current;
do_para_begin();
edit_redraw(was_current, CENTERING);
}
/* Move down to just after the first end of a paragraph. */
void do_para_end_void(void)
{
do_para_end(TRUE);
filestruct *was_current = openfile->current;
do_para_end();
edit_redraw(was_current, CENTERING);
}
#endif /* ENABLE_JUSTIFY */
@@ -272,10 +269,9 @@ void do_next_block(void)
}
/* Move to the previous word. If allow_punct is TRUE, treat punctuation
* as part of a word. When requested, update the screen afterwards. */
void do_prev_word(bool allow_punct, bool update_screen)
* as part of a word. */
void do_prev_word(bool allow_punct)
{
filestruct *was_current = openfile->current;
bool seen_a_word = FALSE, step_forward = FALSE;
/* Move backward until we pass over the start of a word. */
@@ -309,22 +305,19 @@ void do_prev_word(bool allow_punct, bool update_screen)
/* Move one character forward again to sit on the start of the word. */
openfile->current_x = move_mbright(openfile->current->data,
openfile->current_x);
if (update_screen)
edit_redraw(was_current, FLOWING);
}
/* Move to the next word. If after_ends is TRUE, stop at the ends of words
* instead of their beginnings. If allow_punct is TRUE, treat punctuation
* as part of a word. When requested, update the screen afterwards.
* Return TRUE if we started on a word, and FALSE otherwise. */
bool do_next_word(bool after_ends, bool allow_punct, bool update_screen)
* instead of their beginnings. If allow_punct is TRUE, treat punctuation as
* part of a word. Return TRUE if we started on a word, and FALSE otherwise. */
bool do_next_word(bool after_ends, bool allow_punct)
{
filestruct *was_current = openfile->current;
bool started_on_word = is_word_mbchar(openfile->current->data +
openfile->current_x, allow_punct);
bool seen_space = !started_on_word;
#ifndef NANO_TINY
bool seen_word = started_on_word;
#endif
/* Move forward until we reach the start of a word. */
while (TRUE) {
@@ -364,10 +357,6 @@ bool do_next_word(bool after_ends, bool allow_punct, bool update_screen)
}
}
if (update_screen)
edit_redraw(was_current, FLOWING);
/* Return whether we started on a word. */
return started_on_word;
}
@@ -375,7 +364,11 @@ bool do_next_word(bool after_ends, bool allow_punct, bool update_screen)
* word if the WORD_BOUNDS flag is set, and update the screen afterwards. */
void do_prev_word_void(void)
{
do_prev_word(ISSET(WORD_BOUNDS), TRUE);
filestruct *was_current = openfile->current;
do_prev_word(ISSET(WORD_BOUNDS));
edit_redraw(was_current, FLOWING);
}
/* Move to the next word in the file. If the AFTER_ENDS flag is set, stop
@@ -383,7 +376,11 @@ void do_prev_word_void(void)
* punctuation as part of a word. Update the screen afterwards. */
void do_next_word_void(void)
{
do_next_word(ISSET(AFTER_ENDS), ISSET(WORD_BOUNDS), TRUE);
filestruct *was_current = openfile->current;
do_next_word(ISSET(AFTER_ENDS), ISSET(WORD_BOUNDS));
edit_redraw(was_current, FLOWING);
}
/* Move to the beginning of the current line (or softwrapped chunk).
@@ -543,7 +540,7 @@ void do_down(void)
openfile->placewewant = leftedge + target_column;
}
#ifdef ENABLE_HELP
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
/* Scroll up one line or chunk without scrolling the cursor. */
void do_scroll_up(void)
{

View File

@@ -2,7 +2,7 @@
* nano.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017 Benno Schulenberg *
* Copyright (C) 2014-2018 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -465,11 +465,18 @@ void ingraft_buffer(filestruct *somebuffer)
}
#endif
#ifdef DEBUG
#include <time.h>
clock_t start = clock();
#endif
/* Add the number of characters in the copied text to the file size. */
openfile->totsize += get_totsize(openfile->fileage, openfile->filebot);
#ifdef DEBUG
statusline(ALERT, "Took: %.2f", (double)(clock() - start) / CLOCKS_PER_SEC);
#endif
/* If we pasted onto the first line of the edit window, the corresponding
* struct has been freed, so... point at the start of the copied text. */
* record has been freed, so... point at the start of the copied text. */
if (edittop_inside)
openfile->edittop = openfile->fileage;
@@ -495,12 +502,6 @@ void copy_from_buffer(filestruct *somebuffer)
ingraft_buffer(the_copy);
}
/* Create a new openfile node. */
openfilestruct *make_new_opennode(void)
{
return (openfilestruct *)nmalloc(sizeof(openfilestruct));
}
#ifdef ENABLE_MULTIBUFFER
/* Unlink a node from the rest of the circular list, and delete it. */
void unlink_opennode(openfilestruct *fileptr)
@@ -559,6 +560,13 @@ void finish(void)
blank_bottombars();
wrefresh(bottomwin);
#ifndef NANO_TINY
/* Deallocate the two or three subwindows. */
if (topwin != NULL)
delwin(topwin);
delwin(edit);
delwin(bottomwin);
#endif
/* Switch on the cursor and exit from curses mode. */
curs_set(1);
endwin();
@@ -570,15 +578,11 @@ void finish(void)
/* If the user wants history persistence, write the relevant files. */
if (ISSET(HISTORYLOG))
save_history();
if (ISSET(POS_HISTORY)) {
if (ISSET(POSITIONLOG)) {
update_poshistory(openfile->filename, openfile->current->lineno, xplustabs() + 1);
}
#endif
#ifdef DEBUG
thanks_for_all_the_fish();
#endif
/* Get out. */
exit(0);
}
@@ -742,9 +746,7 @@ void mouse_init(void)
}
#endif /* ENABLE_MOUSE */
/* Print one usage string to the screen. This cuts down on duplicate
* strings to translate, and leaves out the parts that shouldn't be
* translatable (i.e. the flag names). */
/* Print the usage line for the given option to the screen. */
void print_opt(const char *shortflag, const char *longflag, const char *desc)
{
printf(" %s\t", shortflag);
@@ -757,9 +759,7 @@ void print_opt(const char *shortflag, const char *longflag, const char *desc)
else if (strlenpt(longflag) < 16)
printf("\t");
if (desc != NULL)
printf("%s", _(desc));
printf("\n");
printf("%s\n", _(desc));
}
/* Explain how to properly use nano and its command-line options. */
@@ -773,14 +773,13 @@ void usage(void)
printf(_("When a filename is '-', nano reads data from standard input.\n\n"));
printf(_("Option\t\tGNU long option\t\tMeaning\n"));
#ifndef NANO_TINY
print_opt("-A", "--smarthome",
/* TRANSLATORS: The next forty or so strings are option descriptions
* for the --help output. Try to keep them at most 40 characters. */
N_("Enable smart home key"));
/* TRANSLATORS: The next forty or so strings are option descriptions
* for the --help output. Try to keep them at most 40 characters. */
print_opt("-A", "--smarthome", N_("Enable smart home key"));
if (!ISSET(RESTRICTED)) {
print_opt("-B", "--backup", N_("Save backups of existing files"));
print_opt(_("-C <dir>"), _("--backupdir=<dir>"),
N_("Directory for saving unique backup files"));
N_("Directory for saving unique backup files"));
}
#endif
print_opt("-D", "--boldtext", N_("Use bold instead of reverse video text"));
@@ -790,7 +789,7 @@ void usage(void)
#ifdef ENABLE_MULTIBUFFER
if (!ISSET(RESTRICTED))
print_opt("-F", "--multibuffer",
N_("Read a file into a new buffer by default"));
N_("Read a file into a new buffer by default"));
#endif
#ifndef NANO_TINY
print_opt("-G", "--locking", N_("Use (vim-style) lock files"));
@@ -798,32 +797,32 @@ void usage(void)
#ifdef ENABLE_HISTORIES
if (!ISSET(RESTRICTED))
print_opt("-H", "--historylog",
N_("Log & read search/replace string history"));
N_("Log & read search/replace string history"));
#endif
#ifdef ENABLE_NANORC
if (!ISSET(RESTRICTED))
print_opt("-I", "--ignorercfiles", N_("Don't look at nanorc files"));
print_opt("-I", "--ignorercfiles", N_("Don't look at nanorc files"));
#endif
print_opt("-K", "--rebindkeypad",
N_("Fix numeric keypad key confusion problem"));
N_("Fix numeric keypad key confusion problem"));
print_opt("-L", "--nonewlines",
N_("Don't add newlines to the ends of files"));
N_("Don't add newlines to the ends of files"));
#ifdef ENABLED_WRAPORJUSTIFY
print_opt("-M", "--trimblanks",
N_("Trim tail spaces when hard-wrapping"));
N_("Trim tail spaces when hard-wrapping"));
#endif
#ifndef NANO_TINY
print_opt("-N", "--noconvert",
N_("Don't convert files from DOS/Mac format"));
N_("Don't convert files from DOS/Mac format"));
#endif
print_opt("-O", "--morespace", N_("Use one more line for editing"));
#ifdef ENABLE_HISTORIES
if (!ISSET(RESTRICTED))
print_opt("-P", "--positionlog",
N_("Log & read location of cursor position"));
N_("Log & read location of cursor position"));
#endif
#ifdef ENABLE_JUSTIFY
print_opt(_("-Q <str>"), _("--quotestr=<str>"), N_("Quoting string"));
print_opt(_("-Q <regex>"), _("--quotestr=<regex>"),
N_("Regular expression to match quoting"));
#endif
if (!ISSET(RESTRICTED))
print_opt("-R", "--restricted", N_("Restricted mode"));
@@ -831,29 +830,30 @@ void usage(void)
print_opt("-S", "--smooth", N_("Scroll by line instead of half-screen"));
#endif
print_opt(_("-T <#cols>"), _("--tabsize=<#cols>"),
N_("Set width of a tab to #cols columns"));
N_("Set width of a tab to #cols columns"));
print_opt("-U", "--quickblank", N_("Do quick statusbar blanking"));
print_opt("-V", "--version", N_("Print version information and exit"));
#ifndef NANO_TINY
print_opt("-W", "--wordbounds",
N_("Detect word boundaries more accurately"));
N_("Detect word boundaries more accurately"));
print_opt(_("-X <str>"), _("--wordchars=<str>"),
N_("Which other characters are word parts"));
N_("Which other characters are word parts"));
#endif
#ifdef ENABLE_COLOR
if (!ISSET(RESTRICTED))
print_opt(_("-Y <name>"), _("--syntax=<name>"),
N_("Syntax definition to use for coloring"));
N_("Syntax definition to use for coloring"));
#endif
#ifndef NANO_TINY
print_opt("-Z", "--zap", N_("Let Bsp and Del erase a marked region"));
print_opt("-a", "--atblanks", N_("When soft-wrapping, do it at whitespace"));
#endif
print_opt("-c", "--constantshow", N_("Constantly show cursor position"));
print_opt("-d", "--rebinddelete",
N_("Fix Backspace/Delete confusion problem"));
N_("Fix Backspace/Delete confusion problem"));
#ifdef ENABLE_BROWSER
if (!ISSET(RESTRICTED))
print_opt("-g", "--showcursor", N_("Show cursor in file browser"));
print_opt("-g", "--showcursor", N_("Show cursor in file browser & help text"));
#endif
print_opt("-h", "--help", N_("Show this help text and exit"));
#ifndef NANO_TINY
@@ -869,17 +869,17 @@ void usage(void)
print_opt("-n", "--noread", N_("Do not read the file (only write it)"));
#ifdef ENABLE_OPERATINGDIR
print_opt(_("-o <dir>"), _("--operatingdir=<dir>"),
N_("Set operating directory"));
N_("Set operating directory"));
#endif
print_opt("-p", "--preserve", N_("Preserve XON (^Q) and XOFF (^S) keys"));
#ifdef ENABLED_WRAPORJUSTIFY
print_opt(_("-r <#cols>"), _("--fill=<#cols>"),
N_("Set hard-wrapping point at column #cols"));
N_("Set hard-wrapping point at column #cols"));
#endif
#ifdef ENABLE_SPELLER
if (!ISSET(RESTRICTED))
print_opt(_("-s <prog>"), _("--speller=<prog>"),
N_("Enable alternate speller"));
N_("Enable alternate speller"));
#endif
print_opt("-t", "--tempfile", N_("Auto save on exit, don't prompt"));
#ifndef NANO_TINY
@@ -1065,10 +1065,6 @@ void do_exit(void)
"(Answering \"No\" will DISCARD changes.) "));
}
#ifdef DEBUG
dump_filestruct(openfile->fileage);
#endif
/* If the user chose not to save, or if the user chose to save and
* the save succeeded, we're ready to exit. */
if (i == 0 || (i == 1 && do_writeout(TRUE, TRUE) > 0))
@@ -1262,6 +1258,9 @@ RETSIGTYPE do_suspend(int signal)
/* Restore the old terminal settings. */
tcsetattr(0, TCSANOW, &oldterm);
/* The suspend keystroke must not elicit cursor-position display. */
suppress_cursorpos=TRUE;
#ifdef SIGSTOP
/* Do what mutt does: send ourselves a SIGSTOP. */
kill(0, SIGSTOP);
@@ -1360,24 +1359,12 @@ void regenerate_screen(void)
total_refresh();
}
/* If allow is FALSE, block any SIGWINCH signal. If allow is TRUE,
* unblock SIGWINCH so any pending ones can be dealt with. */
void allow_sigwinch(bool allow)
{
sigset_t winch;
sigemptyset(&winch);
sigaddset(&winch, SIGWINCH);
sigprocmask(allow ? SIG_UNBLOCK : SIG_BLOCK, &winch, NULL);
}
/* Handle the global toggle specified in flag. */
void do_toggle(int flag)
{
bool enabled;
if (ISSET(RESTRICTED) && (flag == SUSPEND || flag == MULTIBUFFER ||
flag == BACKUP_FILE || flag == NO_COLOR_SYNTAX)) {
if (flag == SUSPEND && ISSET(RESTRICTED)) {
show_restricted_warning();
return;
}
@@ -1390,7 +1377,6 @@ void do_toggle(int flag)
mouse_init();
break;
#endif
case MORE_SPACE:
case NO_HELP:
window_init();
focusing = FALSE;
@@ -1540,11 +1526,38 @@ int get_keycode(const char *keyname, const int standard)
if (keyvalue != 0 && keyvalue != (char *)-1 && key_defined(keyvalue))
return key_defined(keyvalue);
else
#endif
return standard;
#ifdef DEBUG
if (!ISSET(REBIND_KEYPAD))
fprintf(stderr, "Using fallback keycode for %s\n", keyname);
#endif
return standard;
}
#ifdef ENABLE_LINENUMBERS
/* Ensure that the margin can accomodate the buffer's highest line number. */
void confirm_margin(void)
{
int needed_margin = digits(openfile->filebot->lineno) + 1;
/* When not requested or space is too tight, suppress line numbers. */
if (!ISSET(LINE_NUMBERS) || needed_margin > COLS - 4)
needed_margin = 0;
if (needed_margin != margin) {
margin = needed_margin;
editwincols = COLS - margin;
#ifndef NANO_TINY
/* Ensure that firstcolumn is the starting column of its chunk. */
ensure_firstcolumn_is_aligned();
#endif
/* The margin has changed -- schedule a full refresh. */
refresh_needed = TRUE;
}
}
#endif /* ENABLE_LINENUMBERS */
/* Say that an unbound key was struck, and if possible which one. */
void unbound_key(int code)
{
@@ -1557,7 +1570,7 @@ void unbound_key(int code)
statusline(ALERT, _("Unbound key: M-%c"), toupper(code));
} else if (code < 0x20)
statusline(ALERT, _("Unbound key: ^%c"), code + 0x40);
else if (currmenu != MHELP)
else
statusline(ALERT, _("Unbound key: %c"), code);
}
@@ -1630,12 +1643,12 @@ bool wanted_to_move(void (*func)(void))
func == to_first_line || func == to_last_line;
}
/* Return TRUE when the given shortcut is valid in view mode. */
/* Return TRUE when the given shortcut is admissible in view mode. */
bool okay_for_view(const sc *shortcut)
{
const subnfunc *func = sctofunc(shortcut);
return (func != NULL && func->viewok);
return (func == NULL || func->viewok);
}
/* Read in a keystroke. Act on the keystroke if it is a shortcut or a toggle;
@@ -1739,7 +1752,6 @@ int do_input(bool allow_funcs)
if (shortcut->func == do_cut_text_void
#ifndef NANO_TINY
|| shortcut->func == do_copy_text
|| shortcut->func == do_cut_till_eof
#endif
)
retain_cuts = TRUE;
@@ -1866,7 +1878,12 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
set_modified();
#ifndef NANO_TINY
add_undo(ADD);
/* Only add a new undo item when the current item is not an ADD or when
* the current typing is not contiguous with the previous typing. */
if (openfile->last_action != ADD || openfile->current_undo == NULL ||
openfile->current_undo->mark_begin_lineno != openfile->current->lineno ||
openfile->current_undo->mark_begin_x != openfile->current_x)
add_undo(ADD);
/* Note that current_x has not yet been incremented. */
if (openfile->current == openfile->mark &&
@@ -2004,6 +2021,7 @@ int main(int argc, char **argv)
{"smooth", 0, NULL, 'S'},
{"wordbounds", 0, NULL, 'W'},
{"wordchars", 1, NULL, 'X'},
{"zap", 0, NULL, 'Z'},
{"atblanks", 0, NULL, 'a'},
{"autoindent", 0, NULL, 'i'},
{"cutfromcursor", 0, NULL, 'k'},
@@ -2067,7 +2085,7 @@ int main(int argc, char **argv)
while ((optchr =
getopt_long(argc, argv,
"ABC:DEFGHIKLMNOPQ:RST:UVWX:Y:abcdefghijklmno:pqr:s:tuvwxyz$",
"ABC:DEFGHIKLMNOPQ:RST:UVWX:Y:Zabcdefghijklmno:pqr:s:tuvwxyz$",
long_options, NULL)) != -1) {
switch (optchr) {
#ifndef NANO_TINY
@@ -2130,7 +2148,7 @@ int main(int argc, char **argv)
break;
#ifdef ENABLE_HISTORIES
case 'P':
SET(POS_HISTORY);
SET(POSITIONLOG);
break;
#endif
#ifdef ENABLE_JUSTIFY
@@ -2173,6 +2191,9 @@ int main(int argc, char **argv)
break;
#endif
#ifndef NANO_TINY
case 'Z':
SET(LET_THEM_ZAP);
break;
case 'a':
SET(AT_BLANKS);
break;
@@ -2288,55 +2309,42 @@ int main(int argc, char **argv)
}
}
/* If we're using restricted mode, disable suspending, backups,
* rcfiles, and history files, since they all would allow reading
* from or writing to files not specified on the command line. */
if (ISSET(RESTRICTED)) {
UNSET(SUSPEND);
UNSET(BACKUP_FILE);
#ifdef ENABLE_NANORC
no_rcfiles = TRUE;
UNSET(HISTORYLOG);
UNSET(POS_HISTORY);
#endif
}
/* Set up the function and shortcut lists. This needs to be done
* before reading the rcfile, to be able to rebind/unbind keys. */
shortcut_init();
#ifdef ENABLE_NANORC
if (!no_rcfiles) {
/* Back up the command-line options, then read the rcfile(s). */
#ifdef ENABLE_OPERATINGDIR
char *operating_dir_cpy = operating_dir;
#endif
/* Back up the command-line options, then clear the strings. */
#ifdef ENABLED_WRAPORJUSTIFY
ssize_t wrap_at_cpy = wrap_at;
ssize_t wrap_at_cmdline = wrap_at;
#endif
#ifndef NANO_TINY
char *backup_dir_cpy = backup_dir;
char *word_chars_cpy = word_chars;
char *backup_dir_cmdline = backup_dir;
char *word_chars_cmdline = word_chars;
#endif
#ifdef ENABLE_OPERATINGDIR
char *operating_dir_cmdline = operating_dir;
#endif
#ifdef ENABLE_JUSTIFY
char *quotestr_cpy = quotestr;
char *quotestr_cmdline = quotestr;
#endif
#ifdef ENABLE_SPELLER
char *alt_speller_cpy = alt_speller;
char *alt_speller_cmdline = alt_speller;
#endif
ssize_t tabsize_cpy = tabsize;
unsigned flags_cpy[sizeof(flags) / sizeof(flags[0])];
ssize_t tabsize_cmdline = tabsize;
unsigned flags_cmdline[sizeof(flags) / sizeof(flags[0])];
size_t i;
memcpy(flags_cpy, flags, sizeof(flags_cpy));
memcpy(flags_cmdline, flags, sizeof(flags_cmdline));
#ifdef ENABLE_OPERATINGDIR
operating_dir = NULL;
#endif
#ifndef NANO_TINY
backup_dir = NULL;
word_chars = NULL;
#endif
#ifdef ENABLE_OPERATINGDIR
operating_dir = NULL;
#endif
#ifdef ENABLE_JUSTIFY
quotestr = NULL;
#endif
@@ -2344,6 +2352,7 @@ int main(int argc, char **argv)
alt_speller = NULL;
#endif
/* Now process the system's and the user's nanorc file, if any. */
do_rcfiles();
#ifdef DEBUG
@@ -2352,44 +2361,44 @@ int main(int argc, char **argv)
#endif
/* If the backed-up command-line options have a value, restore them. */
#ifdef ENABLE_OPERATINGDIR
if (operating_dir_cpy != NULL) {
free(operating_dir);
operating_dir = operating_dir_cpy;
}
#endif
#ifdef ENABLED_WRAPORJUSTIFY
if (fill_used)
wrap_at = wrap_at_cpy;
wrap_at = wrap_at_cmdline;
#endif
#ifndef NANO_TINY
if (backup_dir_cpy != NULL) {
if (backup_dir_cmdline != NULL) {
free(backup_dir);
backup_dir = backup_dir_cpy;
backup_dir = backup_dir_cmdline;
}
if (word_chars_cpy != NULL) {
if (word_chars_cmdline != NULL) {
free(word_chars);
word_chars = word_chars_cpy;
word_chars = word_chars_cmdline;
}
#endif
#ifdef ENABLE_OPERATINGDIR
if (operating_dir_cmdline != NULL || ISSET(RESTRICTED)) {
free(operating_dir);
operating_dir = operating_dir_cmdline;
}
#endif
#ifdef ENABLE_JUSTIFY
if (quotestr_cpy != NULL) {
if (quotestr_cmdline != NULL) {
free(quotestr);
quotestr = quotestr_cpy;
quotestr = quotestr_cmdline;
}
#endif
#ifdef ENABLE_SPELLER
if (alt_speller_cpy != NULL) {
if (alt_speller_cmdline != NULL) {
free(alt_speller);
alt_speller = alt_speller_cpy;
alt_speller = alt_speller_cmdline;
}
#endif
if (tabsize_cpy != -1)
tabsize = tabsize_cpy;
if (tabsize_cmdline != -1)
tabsize = tabsize_cmdline;
/* Simply OR the boolean flags from rcfile and command line. */
for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++)
flags[i] |= flags_cpy[i];
flags[i] |= flags_cmdline[i];
}
#ifdef DISABLE_ROOTWRAPPING
/* If we don't have any rcfiles, --disable-wrapping-as-root is used,
@@ -2410,32 +2419,41 @@ int main(int argc, char **argv)
if (ISSET(BOLD_TEXT))
hilite_attribute = A_BOLD;
/* When in restricted mode, disable backups, suspending, and history files,
* since they allow writing to files not specified on the command line. */
if (ISSET(RESTRICTED)) {
UNSET(BACKUP_FILE);
UNSET(SUSPEND);
#ifdef ENABLE_NANORC
UNSET(HISTORYLOG);
UNSET(POSITIONLOG);
#endif
}
#ifdef ENABLE_HISTORIES
/* Initialize the pointers for the Search/Replace/Execute histories. */
history_init();
/* If we need history files, verify that we have a directory for them,
* and when not, cancel the options. */
if ((ISSET(HISTORYLOG) || ISSET(POS_HISTORY)) && !have_statedir()) {
if ((ISSET(HISTORYLOG) || ISSET(POSITIONLOG)) && !have_statedir()) {
UNSET(HISTORYLOG);
UNSET(POS_HISTORY);
UNSET(POSITIONLOG);
}
/* If the user wants history persistence, read the relevant files. */
if (ISSET(HISTORYLOG))
load_history();
if (ISSET(POS_HISTORY))
if (ISSET(POSITIONLOG))
load_poshistory();
#endif /* ENABLE_HISTORIES */
#ifndef NANO_TINY
/* If backups are enabled and a backup directory was specified and
* we're not in restricted mode, make sure the path exists and is
* a directory, so that backup files can be saved there. */
if (ISSET(BACKUP_FILE) && backup_dir != NULL && !ISSET(RESTRICTED))
/* If backups are enabled and a backup directory was specified, make sure
* the path exists and is a folder, so backup files can be saved there. */
if (ISSET(BACKUP_FILE) && backup_dir != NULL)
init_backup_dir();
#endif
#ifdef ENABLE_OPERATINGDIR
/* Set up the operating directory. This entails chdir()ing there,
* so that file reads and writes will be based there. */
@@ -2444,21 +2462,18 @@ int main(int argc, char **argv)
#endif
#ifdef ENABLE_JUSTIFY
/* If punct wasn't specified, set its default value. */
/* Set the default value for things that weren't specified. */
if (punct == NULL)
punct = mallocstrcpy(NULL, "!.?");
/* If brackets wasn't specified, set its default value. */
if (brackets == NULL)
brackets = mallocstrcpy(NULL, "\"')>]}");
/* If quotestr wasn't specified, set its default value. */
if (quotestr == NULL)
quotestr = mallocstrcpy(NULL, "^([ \t]*[#:>|}])+");
quoterc = regcomp(&quotereg, quotestr, NANO_REG_EXTENDED);
quotestr = mallocstrcpy(NULL, "^([ \t]*([#:>|}]|/{2}))+");
/* Compile the quoting regex, and free it when it's good; otherwise,
* retrieve and store the error message, to be shown when justifying. */
quoterc = regcomp(&quotereg, quotestr, NANO_REG_EXTENDED);
if (quoterc == 0) {
/* We no longer need quotestr, just quotereg. */
free(quotestr);
quotestr = NULL;
} else {
@@ -2475,8 +2490,9 @@ int main(int argc, char **argv)
* does (unless we're using restricted mode, in which case spell
* checking is disabled, since it would allow reading from or
* writing to files not specified on the command line). */
if (!ISSET(RESTRICTED) && alt_speller == NULL) {
if (alt_speller == NULL && !ISSET(RESTRICTED)) {
const char *spellenv = getenv("SPELL");
if (spellenv != NULL)
alt_speller = mallocstrcpy(NULL, spellenv);
}
@@ -2551,29 +2567,35 @@ int main(int argc, char **argv)
mouse_init();
#endif
/* Ask ncurses for the key codes for Control+Left/Right/Up/Down. */
/* Ask ncurses for the key codes for most modified editing keys. */
controlleft = get_keycode("kLFT5", CONTROL_LEFT);
controlright = get_keycode("kRIT5", CONTROL_RIGHT);
controlup = get_keycode("kUP5", CONTROL_UP);
controldown = get_keycode("kDN5", CONTROL_DOWN);
/* Ask for the codes for Control+Home/End. */
controlhome = get_keycode("kHOM5", CONTROL_HOME);
controlend = get_keycode("kEND5", CONTROL_END);
#ifndef NANO_TINY
/* Ask for the codes for Shift+Control+Left/Right/Up/Down. */
controldelete = get_keycode("kDC5", CONTROL_DELETE);
controlshiftdelete = get_keycode("kDC6", CONTROL_SHIFT_DELETE);
shiftup = get_keycode("kUP", SHIFT_UP);
shiftdown = get_keycode("kDN", SHIFT_DOWN);
shiftcontrolleft = get_keycode("kLFT6", SHIFT_CONTROL_LEFT);
shiftcontrolright = get_keycode("kRIT6", SHIFT_CONTROL_RIGHT);
shiftcontrolup = get_keycode("kUP6", SHIFT_CONTROL_UP);
shiftcontroldown = get_keycode("kDN6", SHIFT_CONTROL_DOWN);
/* Ask for the codes for Shift+Control+Home/End. */
shiftcontrolhome = get_keycode("kHOM6", SHIFT_CONTROL_HOME);
shiftcontrolend = get_keycode("kEND6", SHIFT_CONTROL_END);
/* Ask for the codes for Alt+Left/Right/Up/Down. */
altleft = get_keycode("kLFT3", ALT_LEFT);
altright = get_keycode("kRIT3", ALT_RIGHT);
altup = get_keycode("kUP3", ALT_UP);
altdown = get_keycode("kDN3", ALT_DOWN);
/* Ask for the codes for Shift+Alt+Left/Right/Up/Down. */
altdelete = get_keycode("kDC3", ALT_DELETE);
shiftaltleft = get_keycode("kLFT4", SHIFT_ALT_LEFT);
shiftaltright = get_keycode("kRIT4", SHIFT_ALT_RIGHT);
shiftaltup = get_keycode("kUP4", SHIFT_ALT_UP);
@@ -2612,7 +2634,7 @@ int main(int argc, char **argv)
if (givenline != 0 || givencol != 0)
do_gotolinecolumn(givenline, givencol, FALSE, FALSE);
#ifdef ENABLE_HISTORIES
else if (ISSET(POS_HISTORY) && openfile->filename[0] != '\0') {
else if (ISSET(POSITIONLOG) && openfile->filename[0] != '\0') {
ssize_t savedline, savedcol;
/* If edited before, restore the last cursor position. */
if (has_old_position(argv[optind - 1], &savedline, &savedcol))
@@ -2629,8 +2651,13 @@ int main(int argc, char **argv)
UNSET(VIEW_MODE);
}
#ifdef ENABLE_MULTIBUFFER
else
else {
openfile = openfile->next;
if (more_than_one)
mention_name_and_linecount();
if (ISSET(VIEW_MODE))
SET(MULTIBUFFER);
}
#endif
#ifdef DEBUG
@@ -2639,31 +2666,23 @@ int main(int argc, char **argv)
prepare_for_display();
#ifdef ENABLE_NANORC
if (rcfile_with_errors != NULL)
statusline(ALERT, _("Mistakes in '%s'"), rcfile_with_errors);
#endif
#ifdef ENABLE_HELP
if (*openfile->filename == '\0' && openfile->totsize == 0 &&
openfile->next == openfile && !ISSET(NO_HELP))
statusbar(_("Welcome to nano. For basic help, type Ctrl+G."));
#endif
while (TRUE) {
#ifdef ENABLE_LINENUMBERS
int needed_margin = digits(openfile->filebot->lineno) + 1;
/* Suppress line numbers when there is not enough room for them. */
if (!ISSET(LINE_NUMBERS) || needed_margin > COLS - 4)
needed_margin = 0;
if (needed_margin != margin) {
margin = needed_margin;
editwincols = COLS - margin;
#ifndef NANO_TINY
/* Ensure that firstcolumn is the starting column of its chunk. */
ensure_firstcolumn_is_aligned();
#endif
/* The margin has changed -- schedule a full refresh. */
refresh_needed = TRUE;
}
confirm_margin();
#endif
if (currmenu != MMAIN)
display_main_list();
bottombars(MMAIN);
lastmessage = HUSH;
as_an_at = TRUE;
@@ -2683,8 +2702,8 @@ int main(int argc, char **argv)
errno = 0;
focusing = TRUE;
/* Forget any earlier statusbar x position. */
reinit_statusbar_x();
/* Forget any earlier cursor position at the prompt. */
put_cursor_at_end_of_answer();
/* Read in and interpret keystrokes. */
do_input(TRUE);

View File

@@ -153,7 +153,7 @@ typedef enum {
} file_format;
typedef enum {
HUSH, MILD, ALERT
HUSH, NOTICE, MILD, ALERT
} message_type;
typedef enum {
@@ -178,7 +178,7 @@ typedef enum {
#ifdef ENABLE_COMMENT
COMMENT, UNCOMMENT, PREFLIGHT,
#endif
CUT, CUT_TO_EOF, PASTE, INSERT, OTHER
ZAP, CUT, CUT_TO_EOF, PASTE, INSERT, COUPLE_BEGIN, COUPLE_END, OTHER
} undo_type;
/* Structure types. */
@@ -188,8 +188,6 @@ typedef struct colortype {
/* This syntax's foreground color. */
short bg;
/* This syntax's background color. */
bool bright;
/* Is this color A_BOLD? */
int pairnum;
/* The color pair number used for this foreground color and
* background color. */
@@ -229,8 +227,6 @@ typedef struct syntaxtype {
/* The list of libmagic results that this syntax applies to. */
char *linter;
/* The command with which to lint this type of file. */
char *formatter;
/* The formatting command (for programming languages mainly). */
#ifdef ENABLE_COMMENT
char *comment;
/* The line comment prefix (and postfix) for this type of file. */
@@ -535,7 +531,7 @@ enum
BOLD_TEXT,
QUIET,
SOFTWRAP,
POS_HISTORY,
POSITIONLOG,
LOCKING,
NOREAD_MODE,
MAKE_IT_UNIX,
@@ -544,7 +540,8 @@ enum
LINE_NUMBERS,
NO_PAUSES,
AT_BLANKS,
AFTER_ENDS
AFTER_ENDS,
LET_THEM_ZAP
};
/* Flags for the menus in which a given function should be present. */
@@ -564,11 +561,11 @@ enum
#define MYESNO (1<<13)
#define MLINTER (1<<14)
#define MFINDINHELP (1<<15)
/* This is an abbreviation for all menus except Help and YesNo. */
/* This is an abbreviation for all menus except Help and Browser and YesNo. */
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\
MEXTCMD|MBROWSER|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER)
MEXTCMD|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER)
#ifndef NANO_TINY
#define MSOME MMOST
#define MSOME MMOST|MBROWSER
#else
#define MSOME MMAIN|MBROWSER
#endif
@@ -585,24 +582,32 @@ enum
#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_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
#ifdef USE_SLANG
@@ -622,7 +627,6 @@ enum
#define WAS_FINAL_BACKSPACE (1<<1)
#define WAS_WHOLE_LINE (1<<2)
#define WAS_FINAL_LINE (1<<3)
/* The flags for the mark need to be the highest. */
#define MARK_WAS_SET (1<<4)
#define WAS_MARKED_FORWARD (1<<5)
#endif /* !NANO_TINY */
@@ -630,9 +634,8 @@ enum
/* The maximum number of entries displayed in the main shortcut list. */
#define MAIN_VISIBLE (((COLS + 40) / 20) * 2)
/* The default number of characters from the end of the line where
* wrapping occurs. */
#define CHARS_FROM_EOL 8
/* The default number of columns from end of line where wrapping occurs. */
#define COLUMNS_FROM_EOL 8
/* The default width of a tab in spaces. */
#define WIDTH_OF_TAB 8

View File

@@ -2,7 +2,7 @@
* prompt.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2016 Benno Schulenberg *
* Copyright (C) 2016, 2018 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -25,7 +25,7 @@
static char *prompt = NULL;
/* The prompt string used for statusbar questions. */
static size_t statusbar_x = HIGHEST_POSITIVE;
static size_t typing_x = HIGHEST_POSITIVE;
/* The cursor position in answer. */
#ifdef ENABLE_MOUSE
@@ -40,12 +40,10 @@ int do_statusbar_mouse(void)
size_t start_col = strlenpt(prompt) + 2;
/* Move to where the click occurred. */
if (click_row == 0 && click_col >= start_col) {
statusbar_x = actual_x(answer,
if (click_row == 0 && click_col >= start_col)
typing_x = actual_x(answer,
get_statusbar_page_start(start_col, start_col +
statusbar_xplustabs()) + click_col - start_col);
update_the_statusbar();
}
strnlenpt(answer, typing_x)) + click_col - start_col);
}
return retval;
@@ -210,113 +208,99 @@ void do_statusbar_output(int *the_input, size_t input_len,
/* Insert the typed character into the existing answer string. */
answer = charealloc(answer, strlen(answer) + char_len + 1);
charmove(answer + statusbar_x + char_len, answer + statusbar_x,
strlen(answer) - statusbar_x + 1);
strncpy(answer + statusbar_x, onechar, char_len);
charmove(answer + typing_x + char_len, answer + typing_x,
strlen(answer) - typing_x + 1);
strncpy(answer + typing_x, onechar, char_len);
statusbar_x += char_len;
typing_x += char_len;
}
free(output);
update_the_statusbar();
}
/* Move to the beginning of the answer. */
void do_statusbar_home(void)
{
statusbar_x = 0;
update_the_statusbar();
typing_x = 0;
}
/* Move to the end of the answer. */
void do_statusbar_end(void)
{
statusbar_x = strlen(answer);
update_the_statusbar();
typing_x = strlen(answer);
}
/* Move left one character. */
void do_statusbar_left(void)
{
if (statusbar_x > 0) {
statusbar_x = move_mbleft(answer, statusbar_x);
update_the_statusbar();
}
if (typing_x > 0)
typing_x = move_mbleft(answer, typing_x);
}
/* Move right one character. */
void do_statusbar_right(void)
{
if (answer[statusbar_x] != '\0') {
statusbar_x = move_mbright(answer, statusbar_x);
update_the_statusbar();
if (answer[typing_x] != '\0')
typing_x = move_mbright(answer, typing_x);
}
/* Delete one character. */
void do_statusbar_delete(void)
{
if (answer[typing_x] != '\0') {
int char_len = parse_mbchar(answer + typing_x, NULL, NULL);
charmove(answer + typing_x, answer + typing_x + char_len,
strlen(answer) - typing_x - char_len + 1);
}
}
/* Backspace over one character. */
void do_statusbar_backspace(void)
{
if (statusbar_x > 0) {
statusbar_x = move_mbleft(answer, statusbar_x);
if (typing_x > 0) {
typing_x = move_mbleft(answer, typing_x);
do_statusbar_delete();
}
}
/* Delete one character. */
void do_statusbar_delete(void)
{
if (answer[statusbar_x] != '\0') {
int char_len = parse_mbchar(answer + statusbar_x, NULL, NULL);
charmove(answer + statusbar_x, answer + statusbar_x + char_len,
strlen(answer) - statusbar_x - char_len + 1);
update_the_statusbar();
}
}
/* Zap some or all text from the answer. */
void do_statusbar_cut_text(void)
{
if (!ISSET(CUT_FROM_CURSOR))
statusbar_x = 0;
typing_x = 0;
answer[statusbar_x] = '\0';
update_the_statusbar();
answer[typing_x] = '\0';
}
#ifndef NANO_TINY
/* Move to the next word in the answer. */
void do_statusbar_next_word(void)
{
bool seen_space = !is_word_mbchar(answer + statusbar_x, FALSE);
bool seen_space = !is_word_mbchar(answer + typing_x, FALSE);
bool seen_word = !seen_space;
/* Move forward until we reach either the end or the start of a word,
* depending on whether the AFTER_ENDS flag is set or not. */
while (answer[statusbar_x] != '\0') {
statusbar_x = move_mbright(answer, statusbar_x);
while (answer[typing_x] != '\0') {
typing_x = move_mbright(answer, typing_x);
if (ISSET(AFTER_ENDS)) {
/* If this is a word character, continue; else it's a separator,
* and if we've already seen a word, then it's a word end. */
if (is_word_mbchar(answer + statusbar_x, FALSE))
if (is_word_mbchar(answer + typing_x, FALSE))
seen_word = TRUE;
else if (seen_word)
break;
} else {
/* If this is not a word character, then it's a separator; else
* if we've already seen a separator, then it's a word start. */
if (!is_word_mbchar(answer + statusbar_x, FALSE))
if (!is_word_mbchar(answer + typing_x, FALSE))
seen_space = TRUE;
else if (seen_space)
break;
}
}
update_the_statusbar();
}
/* Move to the previous word in the answer. */
@@ -325,10 +309,10 @@ void do_statusbar_prev_word(void)
bool seen_a_word = FALSE, step_forward = FALSE;
/* Move backward until we pass over the start of a word. */
while (statusbar_x != 0) {
statusbar_x = move_mbleft(answer, statusbar_x);
while (typing_x != 0) {
typing_x = move_mbleft(answer, typing_x);
if (is_word_mbchar(answer + statusbar_x, FALSE))
if (is_word_mbchar(answer + typing_x, FALSE))
seen_a_word = TRUE;
else if (seen_a_word) {
/* This is space now: we've overshot the start of the word. */
@@ -339,9 +323,7 @@ void do_statusbar_prev_word(void)
if (step_forward)
/* Move one character forward again to sit on the start of the word. */
statusbar_x = move_mbright(answer, statusbar_x);
update_the_statusbar();
typing_x = move_mbright(answer, typing_x);
}
#endif /* !NANO_TINY */
@@ -358,12 +340,6 @@ void do_statusbar_verbatim_input(void)
free(kbinput);
}
/* Return the zero-based column position of the cursor in the answer. */
size_t statusbar_xplustabs(void)
{
return strnlenpt(answer, statusbar_x);
}
/* Paste the first line of the cutbuffer into the current answer. */
void do_statusbar_uncut_text(void)
{
@@ -372,13 +348,13 @@ void do_statusbar_uncut_text(void)
/* Concatenate: the current answer before the cursor, the first line
* of the cutbuffer, plus the rest of the current answer. */
strncpy(fusion, answer, statusbar_x);
strncpy(fusion + statusbar_x, cutbuffer->data, pastelen);
strcpy(fusion + statusbar_x + pastelen, answer + statusbar_x);
strncpy(fusion, answer, typing_x);
strncpy(fusion + typing_x, cutbuffer->data, pastelen);
strcpy(fusion + typing_x + pastelen, answer + typing_x);
free(answer);
answer = fusion;
statusbar_x += pastelen;
typing_x += pastelen;
}
/* Return the column number of the first character of the answer that is
@@ -396,19 +372,19 @@ size_t get_statusbar_page_start(size_t base, size_t column)
}
/* Reinitialize the cursor position in the answer. */
void reinit_statusbar_x(void)
void put_cursor_at_end_of_answer(void)
{
statusbar_x = HIGHEST_POSITIVE;
typing_x = HIGHEST_POSITIVE;
}
/* Redraw the promptbar and place the cursor at the right spot. */
void update_the_statusbar(void)
void draw_the_promptbar(void)
{
size_t base = strlenpt(prompt) + 2;
size_t the_page, end_page, column;
char *expanded;
the_page = get_statusbar_page_start(base, base + strnlenpt(answer, statusbar_x));
the_page = get_statusbar_page_start(base, base + strnlenpt(answer, typing_x));
end_page = get_statusbar_page_start(base, base + strlenpt(answer) - 1);
/* Color the promptbar over its full width. */
@@ -431,12 +407,29 @@ void update_the_statusbar(void)
wmove(bottomwin, 0, 0);
wrefresh(bottomwin);
/* Place the cursor at statusbar_x in the answer. */
column = base + statusbar_xplustabs();
/* Place the cursor at the right spot. */
column = base + strnlenpt(answer, typing_x);
wmove(bottomwin, 0, column - get_statusbar_page_start(base, column));
wnoutrefresh(bottomwin);
}
#ifndef NANO_TINY
/* Remove or add the pipe character at the answer's head. */
void add_or_remove_pipe_symbol_from_answer(void)
{
if (answer[0] == '|') {
charmove(answer, answer + 1, strlen(answer) + 1);
if (typing_x > 0)
typing_x--;
} else {
answer = charealloc(answer, strlen(answer) + 2);
charmove(answer + 1, answer, strlen(answer) + 1);
answer[0] = '|';
typing_x++;
}
}
#endif
/* Get a string of input at the statusbar prompt. */
functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
bool allow_files, bool *listed, filestruct **history_list,
@@ -453,8 +446,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
char *history = NULL;
/* The current history string. */
char *magichistory = NULL;
/* The temporary string typed at the bottom of the history, if
* any. */
/* The (partial) answer that was typed at the prompt, if any. */
#ifdef ENABLE_TABCOMP
int last_kbinput = ERR;
/* The key we pressed before the current key. */
@@ -464,12 +456,12 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
#endif
#endif /* ENABLE_HISTORIES */
if (statusbar_x > strlen(answer))
statusbar_x = strlen(answer);
update_the_statusbar();
if (typing_x > strlen(answer))
typing_x = strlen(answer);
while (TRUE) {
draw_the_promptbar();
kbinput = do_statusbar_input(&finished);
#ifndef NANO_TINY
@@ -502,12 +494,12 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
if (complete_len > 0) {
answer = get_history_completion(history_list,
answer, complete_len);
statusbar_x = strlen(answer);
typing_x = strlen(answer);
}
} else
#endif
if (allow_tabs)
answer = input_tab(answer, allow_files, &statusbar_x,
answer = input_tab(answer, allow_files, &typing_x,
&tabbed, refresh_func, listed);
} else
#endif /* ENABLE_TABCOMP */
@@ -523,7 +515,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
* answer. If there is no older search, don't do anything. */
if ((history = get_history_older(history_list)) != NULL) {
answer = mallocstrcpy(answer, history);
statusbar_x = strlen(answer);
typing_x = strlen(answer);
}
/* This key has a shortcut-list entry when it's used to
@@ -538,16 +530,15 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
* answer. If there is no newer search, don't do anything. */
if ((history = get_history_newer(history_list)) != NULL) {
answer = mallocstrcpy(answer, history);
statusbar_x = strlen(answer);
typing_x = strlen(answer);
}
/* If, after scrolling down, we're at the bottom of the
* history list, answer is blank, and magichistory is set,
* save magichistory in answer. */
/* If we've reached the bottom of the history list, and answer
* is blank, and magichistory is set, restore the old answer. */
if ((*history_list)->next == NULL &&
*answer == '\0' && magichistory != NULL) {
answer = mallocstrcpy(answer, magichistory);
statusbar_x = strlen(answer);
typing_x = strlen(answer);
}
/* This key has a shortcut-list entry when it's used to
@@ -572,8 +563,6 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
if (finished)
break;
update_the_statusbar();
#if defined(ENABLE_HISTORIES) && defined(ENABLE_TABCOMP)
last_kbinput = kbinput;
#endif
@@ -612,7 +601,7 @@ int do_prompt(bool allow_tabs, bool allow_files,
functionptrtype func = NULL;
bool listed = FALSE;
/* Save a possible current statusbar x position and prompt. */
size_t was_statusbar_x = statusbar_x;
size_t was_typing_x = typing_x;
char *saved_prompt = prompt;
bottombars(menu);
@@ -643,7 +632,7 @@ int do_prompt(bool allow_tabs, bool allow_files,
/* If we're done with this prompt, restore the x position to what
* it was at a possible previous prompt. */
if (func == do_cancel || func == do_enter)
statusbar_x = was_statusbar_x;
typing_x = was_typing_x;
/* If we left the prompt via Cancel or Enter, set the return value
* properly. */
@@ -678,12 +667,17 @@ int do_yesno_prompt(bool all, const char *msg)
const char *allstr = _("Aa");
while (response == -2) {
#ifdef ENABLE_NLS
char letter[MAXCHARLEN + 1];
int kbinput, index = 0;
int index = 0;
#endif
int kbinput;
if (!ISSET(NO_HELP)) {
char shortstr[MAXCHARLEN + 2];
/* Temporary string for (translated) " Y", " N" and " A". */
const sc *cancelshortcut = first_sc_for(MYESNO, do_cancel);
/* The keystroke that is bound to the Cancel function. */
if (COLS < 32)
width = COLS / 2;
@@ -707,7 +701,7 @@ int do_yesno_prompt(bool all, const char *msg)
}
wmove(bottomwin, 2, width);
post_one_key("^C", _("Cancel"), width);
post_one_key(cancelshortcut->keystr, _("Cancel"), width);
}
/* Color the statusbar over its full width and display the question. */
@@ -757,7 +751,7 @@ int do_yesno_prompt(bool all, const char *msg)
else if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y;
/* We can click on the Yes/No/All shortcuts to select an answer. */
if (get_mouseinput(&mouse_x, &mouse_y, FALSE) == 0 &&
if (get_mouseinput(&mouse_y, &mouse_x, FALSE) == 0 &&
wmouse_trafo(bottomwin, &mouse_y, &mouse_x, FALSE) &&
mouse_x < (width * 2) && mouse_y > 0) {
int x = mouse_x / width;

View File

@@ -55,32 +55,25 @@ extern bool also_the_last;
extern int didfind;
extern int controlleft;
extern int controlright;
extern int controlup;
extern int controldown;
extern int controlhome;
extern int controlend;
extern int controlleft, controlright;
extern int controlup, controldown;
extern int controlhome, controlend;
#ifndef NANO_TINY
extern int shiftcontrolleft;
extern int shiftcontrolright;
extern int shiftcontrolup;
extern int shiftcontroldown;
extern int shiftcontrolhome;
extern int shiftcontrolend;
extern int altleft;
extern int altright;
extern int altup;
extern int altdown;
extern int shiftaltleft;
extern int shiftaltright;
extern int shiftaltup;
extern int shiftaltdown;
extern int controldelete, controlshiftdelete;
extern int shiftleft, shiftright;
extern int shiftup, shiftdown;
extern int shiftcontrolleft, shiftcontrolright;
extern int shiftcontrolup, shiftcontroldown;
extern int shiftcontrolhome, shiftcontrolend;
extern int altleft, altright;
extern int altup, altdown;
extern int altdelete;
extern int shiftaltleft, shiftaltright;
extern int shiftaltup, shiftaltdown;
#endif
#ifdef ENABLED_WRAPORJUSTIFY
extern ssize_t fill;
extern ssize_t wrap_at;
extern ssize_t wrap_at, fill;
#endif
extern char *last_search;
@@ -178,7 +171,13 @@ extern int interface_color_pair[NUMBER_OF_ELEMENTS];
extern char *homedir;
extern char *statedir;
#ifdef ENABLE_NANORC
extern char *rcfile_with_errors;
#endif
extern bool spotlighted;
extern size_t light_from_col;
extern size_t light_to_col;
typedef void (*functionptrtype)(void);
@@ -189,7 +188,7 @@ void read_the_list(const char *path, DIR *dir);
functionptrtype parse_browser_input(int *kbinput);
void browser_refresh(void);
void browser_select_dirname(const char *needle);
void do_filesearch(void);
void do_filesearch(bool forwards);
void do_fileresearch(bool forwards);
void to_first_file(void);
void to_last_file(void);
@@ -221,7 +220,6 @@ char *mbstrcasestr(const char *haystack, const char *needle);
char *revstrstr(const char *haystack, const char *needle, const char *index);
char *mbrevstrcasestr(const char *haystack, const char *needle, const char *index);
size_t mbstrlen(const char *s);
size_t mbstrnlen(const char *s, size_t maxlen);
#if !defined(NANO_TINY) || defined(ENABLE_JUSTIFY)
char *mbstrchr(const char *s, const char *c);
#endif
@@ -236,9 +234,6 @@ bool has_blank_mbchars(const char *s);
#ifdef ENABLE_UTF8
bool is_valid_unicode(wchar_t wc);
#endif
#ifdef ENABLE_NANORC
bool is_valid_mbstring(const char *s);
#endif
/* Most functions in color.c. */
#ifdef ENABLE_COLOR
@@ -252,15 +247,15 @@ void precalc_multicolorinfo(void);
/* Most functions in cut.c. */
void cutbuffer_reset(void);
bool keeping_cutbuffer(void);
#ifndef NANO_TINY
void cut_marked(bool *right_side_up);
#endif
void do_cut_text(bool copy_text, bool cut_till_eof);
void do_cut_text(bool copy_text, bool marked, bool cut_till_eof, bool append);
void do_cut_text_void(void);
#ifndef NANO_TINY
void do_copy_text(void);
void do_cut_till_eof(void);
void zap_text(void);
#endif
void do_uncut_text(void);
@@ -271,12 +266,12 @@ bool open_buffer(const char *filename, bool new_buffer);
#ifdef ENABLE_SPELLER
void replace_buffer(const char *filename);
#ifndef NANO_TINY
void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
filestruct *bot, size_t bot_x);
void replace_marked_buffer(const char *filename);
#endif
#endif
void prepare_for_display(void);
#ifdef ENABLE_MULTIBUFFER
void mention_name_and_linecount(void);
void switch_to_prev_buffer(void);
void switch_to_next_buffer(void);
bool close_buffer(void);
@@ -324,16 +319,12 @@ int keycode_from_string(const char *keystring);
void assign_keyinfo(sc *s, const char *keystring, const int keycode);
void print_sclist(void);
void shortcut_init(void);
#ifdef ENABLE_COLOR
void set_lint_or_format_shortcuts(void);
void set_spell_shortcuts(void);
#endif
const subnfunc *sctofunc(const sc *s);
const char *flagtostr(int flag);
#ifdef ENABLE_NANORC
sc *strtosc(const char *input);
int strtomenu(const char *input);
#ifdef DEBUG
void thanks_for_all_the_fish(void);
int name_to_menu(const char *name);
char *menu_to_name(int menu);
#endif
/* All functions in help.c. */
@@ -372,22 +363,22 @@ void to_last_line(void);
void do_page_up(void);
void do_page_down(void);
#ifdef ENABLE_JUSTIFY
void do_para_begin(bool update_screen);
void do_para_end(bool update_screen);
void do_para_begin(void);
void do_para_end(void);
void do_para_begin_void(void);
void do_para_end_void(void);
#endif
void do_prev_block(void);
void do_next_block(void);
void do_prev_word(bool allow_punct, bool update_screen);
bool do_next_word(bool after_ends, bool allow_punct, bool update_screen);
void do_prev_word(bool allow_punct);
bool do_next_word(bool after_ends, bool allow_punct);
void do_prev_word_void(void);
void do_next_word_void(void);
void do_home(void);
void do_end(void);
void do_up(void);
void do_down(void);
#ifdef ENABLE_HELP
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
void do_scroll_up(void);
void do_scroll_down(void);
#endif
@@ -409,7 +400,6 @@ void extract_buffer(filestruct **file_top, filestruct **file_bot,
filestruct *top, size_t top_x, filestruct *bot, size_t bot_x);
void ingraft_buffer(filestruct *somebuffer);
void copy_from_buffer(filestruct *somebuffer);
openfilestruct *make_new_opennode(void);
#ifdef ENABLE_MULTIBUFFER
void unlink_opennode(openfilestruct *fileptr);
void delete_opennode(openfilestruct *fileptr);
@@ -434,13 +424,15 @@ RETSIGTYPE do_continue(int signal);
#ifndef NANO_TINY
RETSIGTYPE handle_sigwinch(int signal);
void regenerate_screen(void);
void allow_sigwinch(bool allow);
void do_toggle(int flag);
void enable_signals(void);
#endif
void disable_flow_control(void);
void enable_flow_control(void);
void terminal_init(void);
#ifdef ENABLE_LINENUMBERS
void confirm_margin(void);
#endif
void unbound_key(int code);
bool okay_for_view(const sc *shortcut);
int do_input(bool allow_funcs);
@@ -461,10 +453,9 @@ void do_statusbar_prev_word(void);
void do_statusbar_next_word(void);
#endif
void do_statusbar_verbatim_input(void);
size_t statusbar_xplustabs(void);
size_t get_statusbar_page_start(size_t start_col, size_t column);
void reinit_statusbar_x(void);
void update_the_statusbar(void);
void put_cursor_at_end_of_answer(void);
void add_or_remove_pipe_symbol_from_answer(void);
int do_prompt(bool allow_tabs, bool allow_files,
int menu, const char *curranswer, filestruct **history_list,
void (*refresh_func)(void), const char *msg, ...);
@@ -486,11 +477,8 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
void do_search(void);
void do_search_forward(void);
void do_search_backward(void);
void do_research(void);
#ifndef NANO_TINY
void do_findprevious(void);
void do_findnext(void);
#endif
void not_found_msg(const char *str);
void go_looking(void);
ssize_t do_replace_loop(const char *needle, bool whole_word_only,
@@ -547,7 +535,7 @@ size_t indent_length(const char *line);
#endif
#ifdef ENABLE_JUSTIFY
void justify_format(filestruct *paragraph, size_t skip);
bool begpar(const filestruct *const foo);
bool begpar(const filestruct *const foo, int depth);
bool inpar(const filestruct *const foo);
void do_justify(bool full_justify);
void do_justify_void(void);
@@ -558,7 +546,6 @@ void do_spell(void);
#endif
#ifdef ENABLE_COLOR
void do_linter(void);
void do_formatter(void);
#endif
#ifndef NANO_TINY
void do_wordlinechar_count(void);
@@ -612,9 +599,6 @@ size_t get_totsize(const filestruct *begin, const filestruct *end);
#ifndef NANO_TINY
filestruct *fsfromline(ssize_t lineno);
#endif
#ifdef DEBUG
void dump_filestruct(const filestruct *inptr);
#endif
/* Most functions in winio.c. */
void record_macro(void);
@@ -677,12 +661,11 @@ void edit_refresh(void);
void adjust_viewport(update_type location);
void total_redraw(void);
void total_refresh(void);
void display_main_list(void);
void do_cursorpos(bool force);
void do_cursorpos_void(void);
void spotlight(bool active, size_t from_col, size_t to_col);
void spotlight(size_t from_col, size_t to_col);
#ifndef NANO_TINY
void spotlight_softwrapped(bool active, size_t from_col, size_t to_col);
void spotlight_softwrapped(size_t from_col, size_t to_col);
#endif
void do_suspend_void(void);
void disable_waiting(void);
@@ -709,6 +692,8 @@ void append_void(void);
void prepend_void(void);
void backup_file_void(void);
void flip_execute(void);
void flip_pipe(void);
void flip_convert(void);
#endif
#ifdef ENABLE_MULTIBUFFER
void flip_newbuffer(void);

View File

@@ -3,7 +3,7 @@
* *
* Copyright (C) 2001-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2014 Mike Frysinger *
* Copyright (C) 2014-2017 Benno Schulenberg *
* Copyright (C) 2014-2018 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -69,7 +69,7 @@ static const rcoption rcopts[] = {
{"operatingdir", 0},
#endif
#ifdef ENABLE_HISTORIES
{"positionlog", POS_HISTORY},
{"positionlog", POSITIONLOG},
#endif
{"preserve", PRESERVE},
#ifdef ENABLE_JUSTIFY
@@ -94,7 +94,6 @@ static const rcoption rcopts[] = {
{"autoindent", AUTOINDENT},
{"backup", BACKUP_FILE},
{"backupdir", 0},
{"backwards", BACKWARDS_SEARCH},
{"casesensitive", CASE_SENSITIVE},
{"cut", CUT_FROM_CURSOR}, /* deprecated form, remove end of 2018 */
{"cutfromcursor", CUT_FROM_CURSOR},
@@ -113,6 +112,7 @@ static const rcoption rcopts[] = {
{"whitespace", 0},
{"wordbounds", WORD_BOUNDS},
{"wordchars", 0},
{"zap", LET_THEM_ZAP},
#endif
#ifdef ENABLE_COLOR
{"titlecolor", 0},
@@ -301,7 +301,6 @@ void parse_syntax(char *ptr)
live_syntax->headers = NULL;
live_syntax->magics = NULL;
live_syntax->linter = NULL;
live_syntax->formatter = NULL;
#ifdef ENABLE_COMMENT
live_syntax->comment = mallocstrcpy(NULL, GENERAL_COMMENT_CHARACTER);
#endif
@@ -315,10 +314,6 @@ void parse_syntax(char *ptr)
opensyntax = TRUE;
#ifdef DEBUG
fprintf(stderr, "Starting a new syntax type: \"%s\"\n", nameptr);
#endif
/* The default syntax should have no associated extensions. */
if (strcmp(live_syntax->name, "default") == 0 && *ptr != '\0') {
rcfile_error(N_("The \"default\" syntax does not accept extensions"));
@@ -351,10 +346,6 @@ void parse_binding(char *ptr, bool dobind)
sc *s, *newsc = NULL;
int menu;
#ifdef DEBUG
fprintf(stderr, "Starting the rebinding code...\n");
#endif
if (*ptr == '\0') {
rcfile_error(N_("Missing key name"));
return;
@@ -400,7 +391,8 @@ void parse_binding(char *ptr, bool dobind)
if (funcptr[0] == '\0') {
rcfile_error(N_("Must specify a function to bind the key to"));
goto free_things;
}
} else if (ptr == NULL)
goto free_things;
}
menuptr = ptr;
@@ -423,7 +415,7 @@ void parse_binding(char *ptr, bool dobind)
newsc->toggle = 0;
#endif
} else
newsc = strtosc(funcptr);
newsc = strtosc(funcptr);
if (newsc == NULL) {
rcfile_error(N_("Cannot map name \"%s\" to a function"), funcptr);
@@ -431,7 +423,7 @@ void parse_binding(char *ptr, bool dobind)
}
}
menu = strtomenu(menuptr);
menu = name_to_menu(menuptr);
if (menu < 1) {
rcfile_error(N_("Cannot map name \"%s\" to a menu"), menuptr);
goto free_things;
@@ -460,7 +452,9 @@ void parse_binding(char *ptr, bool dobind)
menu = menu & (is_universal(newsc->func) ? MMOST : mask);
if (!menu) {
rcfile_error(N_("Function '%s' does not exist in menu '%s'"), funcptr, menuptr);
if (!ISSET(RESTRICTED))
rcfile_error(N_("Function '%s' does not exist in menu '%s'"),
funcptr, menuptr);
goto free_things;
}
@@ -510,7 +504,7 @@ bool is_good_file(char *file)
if (access(file, R_OK) != 0)
return FALSE;
/* If the thing exists, it may not be a directory nor a device. */
/* If the thing exists, it may be neither a directory nor a device. */
if (stat(file, &rcinfo) != -1 && (S_ISDIR(rcinfo.st_mode) ||
S_ISCHR(rcinfo.st_mode) || S_ISBLK(rcinfo.st_mode))) {
rcfile_error(S_ISDIR(rcinfo.st_mode) ? _("\"%s\" is a directory") :
@@ -543,10 +537,6 @@ static void parse_one_include(char *file)
nanorc = file;
lineno = 0;
#ifdef DEBUG
fprintf(stderr, "Parsing file \"%s\"\n", file);
#endif
parse_rcfile(rcstream, TRUE);
}
@@ -615,13 +605,16 @@ short color_to_short(const char *colorname, bool *bright)
/* Parse the color name (or pair of color names) in the given string.
* Return FALSE when any color name is invalid; otherwise return TRUE. */
bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright)
bool parse_color_names(char *combostr, short *fg, short *bg, int *attributes)
{
char *comma = strchr(combostr, ',');
bool bright;
*attributes = A_NORMAL;
if (comma != NULL) {
*bg = color_to_short(comma + 1, bright);
if (*bright) {
*bg = color_to_short(comma + 1, &bright);
if (bright) {
rcfile_error(N_("A background color cannot be bright"));
return FALSE;
}
@@ -632,9 +625,12 @@ bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright)
*bg = USE_THE_DEFAULT;
if (comma != combostr) {
*fg = color_to_short(combostr, bright);
*fg = color_to_short(combostr, &bright);
if (*fg == BAD_COLOR)
return FALSE;
if (bright)
*attributes = A_BOLD;
} else
*fg = USE_THE_DEFAULT;
@@ -647,7 +643,7 @@ bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright)
void parse_colors(char *ptr, int rex_flags)
{
short fg, bg;
bool bright;
int attributes;
char *item;
if (!opensyntax) {
@@ -663,7 +659,7 @@ void parse_colors(char *ptr, int rex_flags)
item = ptr;
ptr = parse_next_word(ptr);
if (!parse_color_names(item, &fg, &bg, &bright))
if (!parse_color_names(item, &fg, &bg, &attributes))
return;
if (*ptr == '\0') {
@@ -710,7 +706,7 @@ void parse_colors(char *ptr, int rex_flags)
newcolor->fg = fg;
newcolor->bg = bg;
newcolor->bright = bright;
newcolor->attributes = attributes;
newcolor->rex_flags = rex_flags;
newcolor->start_regex = mallocstrcpy(NULL, item);
@@ -773,7 +769,7 @@ colortype *parse_interface_color(char *combostr)
{
colortype *trio = nmalloc(sizeof(colortype));
if (parse_color_names(combostr, &trio->fg, &trio->bg, &trio->bright)) {
if (parse_color_names(combostr, &trio->fg, &trio->bg, &trio->attributes)) {
free(combostr);
return trio;
} else {
@@ -846,7 +842,7 @@ void grab_and_store(const char *kind, char *ptr, regexlisttype **storage)
}
}
/* Gather and store the string after a comment/linter/formatter command. */
/* Gather and store the string after a comment/linter command. */
void pick_up_name(const char *kind, char *ptr, char **storage)
{
if (!opensyntax) {
@@ -885,17 +881,18 @@ static void check_vitals_mapped(void)
{
subnfunc *f;
int v;
#define VITALS 5
void (*vitals[VITALS])(void) = { do_exit, do_exit, do_cancel, do_cancel, do_cancel };
int inmenus[VITALS] = { MMAIN, MHELP, MWHEREIS, MREPLACE, MGOTOLINE };
#define VITALS 3
void (*vitals[VITALS])(void) = { do_exit, do_exit, do_cancel };
int inmenus[VITALS] = { MMAIN, MHELP, MYESNO };
for (v = 0; v < VITALS; v++) {
for (f = allfuncs; f != NULL; f = f->next) {
if (f->func == vitals[v] && f->menus & inmenus[v]) {
const sc *s = first_sc_for(inmenus[v], f->func);
if (!s) {
fprintf(stderr, _("Fatal error: no keys mapped for function "
"\"%s\". Exiting.\n"), f->desc);
fprintf(stderr, _("No key is bound to function '%s' in "
"menu '%s'. Exiting.\n"), f->desc,
menu_to_name(inmenus[v]));
fprintf(stderr, _("If needed, use nano with the -I option "
"to adjust your nanorc settings.\n"));
exit(1);
@@ -929,8 +926,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
while (isblank((unsigned char)*ptr))
ptr++;
/* If we have a blank line or a comment, skip to the next
* line. */
/* If the line is empty or a comment, skip to next line. */
if (*ptr == '\0' || *ptr == '#')
continue;
@@ -940,7 +936,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
#ifdef ENABLE_COLOR
/* Handle extending first... */
if (strcasecmp(keyword, "extendsyntax") == 0) {
if (strcasecmp(keyword, "extendsyntax") == 0 && !syntax_only) {
syntaxtype *sint;
char *syntaxname = ptr;
@@ -997,13 +993,12 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
parse_colors(ptr, NANO_REG_EXTENDED | REG_ICASE);
else if (strcasecmp(keyword, "linter") == 0)
pick_up_name("linter", ptr, &live_syntax->linter);
else if (strcasecmp(keyword, "formatter") == 0)
#ifdef ENABLE_SPELLER
pick_up_name("formatter", ptr, &live_syntax->formatter);
#else
;
#endif
else if (syntax_only)
else if (syntax_only && (strcasecmp(keyword, "set") == 0 ||
strcasecmp(keyword, "unset") == 0 ||
strcasecmp(keyword, "bind") == 0 ||
strcasecmp(keyword, "unbind") == 0 ||
strcasecmp(keyword, "include") == 0 ||
strcasecmp(keyword, "extendsyntax") == 0))
rcfile_error(N_("Command \"%s\" not allowed in included file"),
keyword);
else if (strcasecmp(keyword, "include") == 0)
@@ -1049,10 +1044,6 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
continue;
}
#ifdef DEBUG
fprintf(stderr, " Option name = \"%s\"\n", rcopts[i].name);
fprintf(stderr, " Flag = %ld\n", rcopts[i].flag);
#endif
/* First handle unsetting. */
if (set == -1) {
if (rcopts[i].flag != 0)
@@ -1081,15 +1072,14 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
ptr = parse_argument(ptr);
option = mallocstrcpy(NULL, option);
#ifdef DEBUG
fprintf(stderr, " Option argument = \"%s\"\n", option);
#endif
/* Make sure the option argument is a valid multibyte string. */
if (!is_valid_mbstring(option)) {
#ifdef ENABLE_UTF8
/* When in a UTF-8 locale, ignore arguments with invalid sequences. */
if (using_utf8() && mbstowcs(NULL, option, 0) == (size_t)-1) {
rcfile_error(N_("Argument is not a valid multibyte string"));
continue;
}
#endif
#ifdef ENABLE_COLOR
if (strcasecmp(rcopts[i].name, "titlecolor") == 0)
color_combo[TITLE_BAR] = parse_interface_color(option);
@@ -1117,7 +1107,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
if (!parse_num(option, &wrap_at)) {
rcfile_error(N_("Requested fill size \"%s\" is invalid"),
option);
wrap_at = -CHARS_FROM_EOL;
wrap_at = -COLUMNS_FROM_EOL;
} else
UNSET(NO_WRAP);
free(option);
@@ -1146,19 +1136,17 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
#endif
#ifdef ENABLE_JUSTIFY
if (strcasecmp(rcopts[i].name, "punct") == 0) {
punct = option;
if (has_blank_mbchars(punct)) {
if (has_blank_mbchars(option)) {
rcfile_error(N_("Non-blank characters required"));
free(punct);
punct = NULL;
}
free(option);
} else
punct = option;
} else if (strcasecmp(rcopts[i].name, "brackets") == 0) {
brackets = option;
if (has_blank_mbchars(brackets)) {
if (has_blank_mbchars(option)) {
rcfile_error(N_("Non-blank characters required"));
free(brackets);
brackets = NULL;
}
free(option);
} else
brackets = option;
} else if (strcasecmp(rcopts[i].name, "quotestr") == 0)
quotestr = option;
else
@@ -1210,9 +1198,6 @@ void parse_one_nanorc(void)
if (!is_good_file(nanorc))
return;
#ifdef DEBUG
fprintf(stderr, "Going to parse file \"%s\"\n", nanorc);
#endif
rcstream = fopen(nanorc, "rb");
/* If opening the file succeeded, parse it. Otherwise, only
@@ -1239,9 +1224,8 @@ void do_rcfiles(void)
{
const char *xdgconfdir;
/* First process the system-wide nanorc, if there is one. */
nanorc = mallocstrcpy(nanorc, SYSCONFDIR "/nanorc");
/* Process the system-wide nanorc. */
parse_one_nanorc();
/* When configured with --disable-wrapping-as-root, turn wrapping off
@@ -1254,8 +1238,8 @@ void do_rcfiles(void)
get_homedir();
xdgconfdir = getenv("XDG_CONFIG_HOME");
/* Now try the to find a nanorc file in the user's home directory
* or in the XDG configuration directories. */
/* Now try the to find a nanorc file in the user's home directory or in
* the XDG configuration directories, and process the first one found. */
if (have_nanorc(homedir, "/" HOME_RC_NAME))
parse_one_nanorc();
else if (have_nanorc(xdgconfdir, "/nano/" RCFILE_NAME))
@@ -1267,6 +1251,16 @@ void do_rcfiles(void)
check_vitals_mapped();
#ifdef __linux__
/* On a Linux console, don't start nano when there are rcfile errors,
* because otherwise these error messages get wiped. */
if (on_a_vt && rcfile_with_errors) {
fprintf(stderr, _("If needed, use nano with the -I option "
"to adjust your nanorc settings.\n"));
exit(1);
}
#endif
free(nanorc);
}

View File

@@ -2,7 +2,7 @@
* search.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2015-2017 Benno Schulenberg *
* Copyright (C) 2015-2018 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -101,12 +101,11 @@ void search_init(bool replacing, bool keep_the_answer)
answer, &search_history,
/* TRANSLATORS: This is the main search prompt. */
edit_refresh, "%s%s%s%s%s%s", _("Search"),
/* TRANSLATORS: The next three modify the search prompt. */
/* TRANSLATORS: The next four modify the search prompt. */
ISSET(CASE_SENSITIVE) ? _(" [Case Sensitive]") : "",
ISSET(USE_REGEXP) ? _(" [Regexp]") : "",
ISSET(BACKWARDS_SEARCH) ? _(" [Backwards]") : "", replacing ?
#ifndef NANO_TINY
/* TRANSLATORS: The next two modify the search prompt. */
openfile->mark ? _(" (to replace) in selection") :
#endif
_(" (to replace)") : "", thedefault);
@@ -156,6 +155,12 @@ void search_init(bool replacing, bool keep_the_answer)
} else if (func == regexp_void) {
TOGGLE(USE_REGEXP);
} else if (func == flip_replace) {
if (ISSET(VIEW_MODE)) {
print_view_warning();
tidy_up_after_search();
free(thedefault);
return;
}
replacing = !replacing;
} else {
if (func == flip_goto)
@@ -366,7 +371,6 @@ void do_research(void)
tidy_up_after_search();
}
#ifndef NANO_TINY
/* Search in the backward direction for the next occurrence. */
void do_findprevious(void)
{
@@ -380,7 +384,6 @@ void do_findnext(void)
UNSET(BACKWARDS_SEARCH);
do_research();
}
#endif /* !NANO_TINY */
/* Report on the status bar that the given string was not found. */
void not_found_msg(const char *str)
@@ -572,19 +575,18 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
numreplaced = 0;
if (!replaceall) {
size_t from_col = xplustabs();
size_t to_col = strnlenpt(openfile->current->data,
spotlighted = TRUE;
light_from_col = xplustabs();
light_to_col = strnlenpt(openfile->current->data,
openfile->current_x + match_len);
/* Refresh the edit window, scrolling it if necessary. */
edit_refresh();
spotlight(TRUE, from_col, to_col);
/* TRANSLATORS: This is a prompt. */
i = do_yesno_prompt(TRUE, _("Replace this instance?"));
spotlight(FALSE, from_col, to_col);
spotlighted = FALSE;
if (i == -1) /* The replacing was cancelled. */
break;

1265
src/text.c

File diff suppressed because it is too large Load Diff

View File

@@ -160,10 +160,9 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
}
/* Reduce the memory allocation of a string to what is needed. */
void snuggly_fit(char **str)
void snuggly_fit(char **string)
{
if (*str != NULL)
*str = charealloc(*str, strlen(*str) + 1);
*string = charealloc(*string, strlen(*string) + 1);
}
/* Null a string at a certain index and align it. */
@@ -266,13 +265,6 @@ bool is_separate_word(size_t position, size_t length, const char *buf)
const char *strstrwrapper(const char *haystack, const char *needle,
const char *start)
{
if (*needle == '\0') {
#ifndef NANO_TINY
statusline(ALERT, "Searching for nothing -- please report a bug");
#endif
return (char *)start;
}
if (ISSET(USE_REGEXP)) {
if (ISSET(BACKWARDS_SEARCH)) {
size_t last_find, ceiling, far_end;
@@ -357,7 +349,7 @@ void *nmalloc(size_t howmuch)
void *r = malloc(howmuch);
if (r == NULL && howmuch != 0)
die(_("nano is out of memory!"));
die(_("Nano is out of memory!\n"));
return r;
}
@@ -369,7 +361,7 @@ void *nrealloc(void *ptr, size_t howmuch)
void *r = realloc(ptr, howmuch);
if (r == NULL && howmuch != 0)
die(_("nano is out of memory!"));
die(_("Nano is out of memory!\n"));
return r;
}
@@ -590,21 +582,3 @@ size_t get_totsize(const filestruct *begin, const filestruct *end)
return totsize;
}
#ifdef DEBUG
/* Dump the given buffer to stderr. */
void dump_filestruct(const filestruct *inptr)
{
if (inptr == openfile->fileage)
fprintf(stderr, "Dumping file buffer to stderr...\n");
else if (inptr == cutbuffer)
fprintf(stderr, "Dumping cutbuffer to stderr...\n");
else
fprintf(stderr, "Dumping a buffer to stderr...\n");
while (inptr != NULL) {
fprintf(stderr, "(%zd) %s\n", inptr->lineno, inptr->data);
inptr = inptr->next;
}
}
#endif /* DEBUG */

View File

@@ -204,7 +204,7 @@ void read_keys_from(WINDOW *win)
* check if errno is set to EIO ("Input/output error") and die in
* that case, but it's not always set properly. Argh. */
if (input == ERR && ++errcount == MAX_BUF_SIZE)
die(_("Too many errors from stdin"));
die(_("Too many errors from stdin\n"));
}
curs_set(0);
@@ -291,7 +291,7 @@ void unget_kbinput(int kbinput, bool metakey)
void implant(const char *string)
{
for (int i = strlen(string); i > 0; i--)
put_back(string[i - 1]);
put_back((unsigned char)string[i - 1]);
}
#endif
@@ -371,11 +371,6 @@ int parse_kbinput(WINDOW *win)
keycode = *kbinput;
free(kbinput);
#ifdef DEBUG
fprintf(stderr, "before parsing: keycode = %d, escapes = %d, digit_count = %d\n",
keycode, escapes, digit_count);
#endif
if (keycode == ERR)
return ERR;
@@ -385,7 +380,7 @@ int parse_kbinput(WINDOW *win)
if (escapes > 3)
escapes = 1;
/* Take note when an Esc arrived by itself. */
solitary = (escapes == 1 && key_buffer_len == 0);
solitary = (key_buffer_len == 0);
return ERR;
}
@@ -476,12 +471,13 @@ int parse_kbinput(WINDOW *win)
}
} else {
if (digit_count == 0)
/* Two escapes followed by a non-decimal
* digit (or a decimal digit that would
* create a byte sequence greater than 2XX)
* and there aren't any other codes waiting:
* control character sequence mode. */
retval = get_control_kbinput(keycode);
/* Two escapes followed by a non-digit: meta key
* or control character sequence mode. */
if (!solitary) {
meta_key = TRUE;
retval = keycode;
} else
retval = get_control_kbinput(keycode);
else {
/* An invalid digit in the middle of a byte
* sequence: reset the byte sequence counter
@@ -505,11 +501,13 @@ int parse_kbinput(WINDOW *win)
}
break;
case 3:
if (key_buffer_len == 0)
if (key_buffer_len == 0) {
if (!solitary)
meta_key = TRUE;
/* Three escapes followed by a non-escape, and no
* other codes are waiting: normal input mode. */
retval = keycode;
else
} else
/* Three escapes followed by a non-escape, and more
* codes are waiting: combined control character and
* escape sequence mode. First interpret the escape
@@ -536,7 +534,17 @@ int parse_kbinput(WINDOW *win)
else if (retval == controlend)
return CONTROL_END;
#ifndef NANO_TINY
else if (retval == shiftcontrolleft) {
else if (retval == controldelete)
return CONTROL_DELETE;
else if (retval == controlshiftdelete)
return CONTROL_SHIFT_DELETE;
else if (retval == shiftup) {
shift_held = TRUE;
return KEY_UP;
} else if (retval == shiftdown) {
shift_held = TRUE;
return KEY_DOWN;
} else if (retval == shiftcontrolleft) {
shift_held = TRUE;
return CONTROL_LEFT;
} else if (retval == shiftcontrolright) {
@@ -562,6 +570,8 @@ int parse_kbinput(WINDOW *win)
return ALT_UP;
else if (retval == altdown)
return ALT_DOWN;
else if (retval == altdelete)
return ALT_DELETE;
else if (retval == shiftaltleft) {
shift_held = TRUE;
return KEY_HOME;
@@ -582,15 +592,31 @@ int parse_kbinput(WINDOW *win)
* Shift/Ctrl/Alt are being held together with them. */
unsigned char modifiers = 6;
/* Modifiers are: Alt (8), Ctrl (4), Shift (1). */
if (on_a_vt && ioctl(0, TIOCLINUX, &modifiers) >= 0) {
#ifndef NANO_TINY
/* Is Delete pressed together with Shift or Shift+Ctrl? */
if (retval == KEY_DC) {
if (modifiers == 0x01)
return SHIFT_DELETE;
if (modifiers == 0x05)
return CONTROL_SHIFT_DELETE;
}
/* Is Shift being held? */
if (modifiers & 0x01) {
/* A shifted <Tab> is a back tab. */
if (retval == TAB_CODE)
return SHIFT_TAB;
shift_held = TRUE;
}
/* Is Alt being held? */
if (modifiers == 0x08) {
if (retval == KEY_DC)
return ALT_DELETE;
if (retval == KEY_UP)
return ALT_UP;
if (retval == KEY_DOWN)
return ALT_DOWN;
}
#endif
/* Is Ctrl being held? */
if (modifiers & 0x04) {
@@ -606,6 +632,8 @@ int parse_kbinput(WINDOW *win)
return CONTROL_HOME;
else if (retval == KEY_END)
return CONTROL_END;
else if (retval == KEY_DC)
return CONTROL_DELETE;
}
#ifndef NANO_TINY
/* Are both Shift and Alt being held? */
@@ -698,12 +726,8 @@ int parse_kbinput(WINDOW *win)
return KEY_NPAGE;
#ifdef KEY_SDC /* Slang doesn't support KEY_SDC. */
case KEY_SDC:
return SHIFT_DELETE;
#endif
case DEL_CODE:
if (ISSET(REBIND_DELETE))
return the_code_for(do_delete, KEY_DC);
else
return KEY_BACKSPACE;
#ifdef KEY_SIC /* Slang doesn't support KEY_SIC. */
case KEY_SIC:
return the_code_for(do_insertfile_void, KEY_IC);
@@ -984,7 +1008,7 @@ int convert_sequence(const int *seq, size_t length, int *consumed)
}
break;
#ifndef NANO_TINY
case '9': /* To accomodate iTerm2 in "xterm mode". */
case '9': /* To accommodate iTerm2 in "xterm mode". */
case '3':
switch (seq[4]) {
case 'A': /* Esc [ 1 ; 3 A == Alt-Up on xterm. */
@@ -1077,11 +1101,42 @@ int convert_sequence(const int *seq, size_t length, int *consumed)
/* Esc [ 2 ~ == Insert on VT220/VT320/
* Linux console/xterm/Terminal. */
return KEY_IC;
else if (length > 4 && seq[2] == ';' && seq[4] == '~')
/* Esc [ 2 ; x ~ == modified Insert on xterm. */
*consumed = 5;
break;
case '3': /* Esc [ 3 ~ == Delete on VT220/VT320/
* Linux console/xterm/Terminal. */
if (length > 2 && seq[2] == '~')
return KEY_DC;
if (length > 4 && seq[2] == ';' && seq[4] == '~') {
*consumed = 5;
#ifndef NANO_TINY
if (seq[3] == '2')
/* Esc [ 3 ; 2 ~ == Shift-Delete on xterm/Terminal. */
return SHIFT_DELETE;
if (seq[3] == '3')
/* Esc [ 3 ; 3 ~ == Alt-Delete on xterm/rxvt/Eterm/Terminal. */
return ALT_DELETE;
if (seq[3] == '5')
/* Esc [ 3 ; 5 ~ == Ctrl-Delete on xterm. */
return CONTROL_DELETE;
if (seq[3] == '6')
/* Esc [ 3 ; 6 ~ == Ctrl-Shift-Delete on xterm. */
return controlshiftdelete;
#endif
}
#ifndef NANO_TINY
if (length > 2 && seq[2] == '$')
/* Esc [ 3 $ == Shift-Delete on urxvt. */
return SHIFT_DELETE;
if (length > 2 && seq[2] == '^')
/* Esc [ 3 ^ == Ctrl-Delete on urxvt. */
return CONTROL_DELETE;
if (length > 2 && seq[2] == '@')
/* Esc [ 3 @ == Ctrl-Shift-Delete on urxvt. */
return controlshiftdelete;
#endif
break;
case '4': /* Esc [ 4 ~ == End on VT220/VT320/
* Linux console/xterm. */
@@ -1093,26 +1148,26 @@ int convert_sequence(const int *seq, size_t length, int *consumed)
* Esc [ 5 ^ == PageUp on Eterm. */
if (length > 2 && (seq[2] == '~' || seq[2] == '^'))
return KEY_PPAGE;
#ifndef NANO_TINY
else if (length > 4 && seq[2] == ';' &&
seq[3] == '2' && seq[4] == '~') {
else if (length > 4 && seq[2] == ';' && seq[4] == '~') {
*consumed = 5;
return shiftaltup;
}
#ifndef NANO_TINY
if (seq[3] == '2')
return shiftaltup;
#endif
}
break;
case '6': /* Esc [ 6 ~ == PageDown on VT220/VT320/
* Linux console/xterm/Terminal;
* Esc [ 6 ^ == PageDown on Eterm. */
if (length > 2 && (seq[2] == '~' || seq[2] == '^'))
return KEY_NPAGE;
#ifndef NANO_TINY
else if (length > 4 && seq[2] == ';' &&
seq[3] == '2' && seq[4] == '~') {
else if (length > 4 && seq[2] == ';' && seq[4] == '~') {
*consumed = 5;
return shiftaltdown;
}
#ifndef NANO_TINY
if (seq[3] == '2')
return shiftaltdown;
#endif
}
break;
case '7': /* Esc [ 7 ~ == Home on Eterm/rxvt;
* Esc [ 7 $ == Shift-Home on Eterm/rxvt;
@@ -1285,12 +1340,15 @@ int parse_escape_sequence(WINDOW *win, int kbinput)
/* If we got an unrecognized escape sequence, notify the user. */
if (retval == ERR && win == edit) {
/* TRANSLATORS: This refers to a sequence of escape codes
* (from the keyboard) that nano does not recogize. */
* (from the keyboard) that nano does not recognize. */
statusline(ALERT, _("Unknown sequence"));
suppress_cursorpos = FALSE;
lastmessage = HUSH;
if (currmenu == MMAIN) {
place_the_cursor();
#ifdef __NetBSD__
wnoutrefresh(edit); /* Needed for correct placement on NetBSD. */
#endif
curs_set(1);
}
}
@@ -1460,10 +1518,6 @@ int get_control_kbinput(int kbinput)
else
retval = kbinput;
#ifdef DEBUG
fprintf(stderr, "get_control_kbinput(): kbinput = %d, retval = %d\n", kbinput, retval);
#endif
return retval;
}
@@ -1730,29 +1784,17 @@ const sc *get_shortcut(int *kbinput)
{
sc *s;
#ifdef DEBUG
fprintf(stderr, "after parsing: kbinput = %d, meta_key = %s -- ",
*kbinput, meta_key ? "TRUE" : "FALSE");
#endif
/* Plain characters cannot be shortcuts, so just skip those. */
if (!meta_key && (*kbinput & 0x7F) >= 0x20 && *kbinput <= 0xFF)
if (!meta_key && ((*kbinput >= 0x20 && *kbinput < 0x7F) ||
(*kbinput >= 0xA0 && *kbinput <= 0xFF)))
return NULL;
for (s = sclist; s != NULL; s = s->next) {
if ((s->menus & currmenu) && *kbinput == s->keycode &&
meta_key == s->meta) {
#ifdef DEBUG
fprintf (stderr, "matched seq '%s' (menu is %x from %x)\n",
s->keystr, currmenu, s->menus);
#endif
meta_key == s->meta)
return s;
}
}
#ifdef DEBUG
fprintf (stderr, "matched nothing\n");
#endif
return NULL;
}
@@ -2026,6 +2068,13 @@ void titlebar(const char *path)
* then sacrifice the prefix, and only then start dottifying. */
/* Figure out the path, prefix and state strings. */
#ifdef ENABLE_COLOR
if (currmenu == MLINTER) {
/* TRANSLATORS: The next four are "labels" in the title bar. */
prefix = _("Linting --");
path = openfile->filename;
} else
#endif
#ifdef ENABLE_BROWSER
if (!inhelp && path != NULL)
prefix = _("DIR:");
@@ -2132,8 +2181,7 @@ void statusbar(const char *msg)
* message can be noticed and read. */
void warn_and_shortly_pause(const char *msg)
{
statusbar(msg);
beep();
statusline(ALERT, msg);
napms(1800);
}
@@ -2154,6 +2202,11 @@ void statusline(message_type importance, const char *msg, ...)
UNSET(WHITESPACE_DISPLAY);
#endif
/* Ignore a message with an importance that is lower than the last one. */
if ((lastmessage == ALERT && importance != ALERT) ||
(lastmessage == MILD && importance == HUSH))
return;
va_start(ap, msg);
/* Curses mode is turned off. If we use wmove() now, it will muck
@@ -2165,11 +2218,6 @@ void statusline(message_type importance, const char *msg, ...)
return;
}
/* If there already was an alert message, ignore lesser ones. */
if ((lastmessage == ALERT && importance != ALERT) ||
(lastmessage == MILD && importance == HUSH))
return;
/* If the ALERT status has been reset, reset the counter. */
if (lastmessage == HUSH)
alerts = 0;
@@ -2185,7 +2233,9 @@ void statusline(message_type importance, const char *msg, ...)
else if (alerts < 4)
beep();
colorpair = interface_color_pair[ERROR_MESSAGE];
} else
} else if (importance == NOTICE)
colorpair = interface_color_pair[SELECTED_TEXT];
else
colorpair = interface_color_pair[STATUS_BAR];
lastmessage = importance;
@@ -2739,6 +2789,9 @@ int update_line(filestruct *fileptr, size_t index)
if (strlenpt(fileptr->data) > from_col + editwincols)
mvwaddch(edit, row, COLS - 1, '$');
if (spotlighted && !inhelp)
spotlight(light_from_col, light_to_col);
return 1;
}
@@ -2805,6 +2858,9 @@ int update_softwrapped_line(filestruct *fileptr)
from_col = to_col;
}
if (spotlighted && !inhelp)
spotlight(light_from_col, light_to_col);
return (row - starting_row);
}
#endif
@@ -3307,21 +3363,6 @@ void total_refresh(void)
bottombars(currmenu);
}
/* Display the main shortcut list on the last two rows of the bottom
* portion of the window. */
void display_main_list(void)
{
#if defined(ENABLE_COLOR) && defined(ENABLE_SPELLER)
if (openfile->syntax &&
(openfile->syntax->formatter || openfile->syntax->linter))
set_lint_or_format_shortcuts();
else
set_spell_shortcuts();
#endif
bottombars(MMAIN);
}
/* Show info about the current cursor position on the statusbar.
* Do this unconditionally when force is TRUE; otherwise, only if
* suppress_cursorpos is FALSE. In any case, reset the latter. */
@@ -3382,9 +3423,8 @@ void enable_waiting(void)
nodelay(edit, FALSE);
}
/* Highlight the text between from_col and to_col when active is TRUE.
* Remove the highlight when active is FALSE. */
void spotlight(bool active, size_t from_col, size_t to_col)
/* Highlight the text between from_col and to_col. */
void spotlight(size_t from_col, size_t to_col)
{
char *word;
size_t word_span, room;
@@ -3393,7 +3433,7 @@ void spotlight(bool active, size_t from_col, size_t to_col)
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
spotlight_softwrapped(active, from_col, to_col);
spotlight_softwrapped(from_col, to_col);
return;
}
#endif
@@ -3415,16 +3455,14 @@ void spotlight(bool active, size_t from_col, size_t to_col)
if (word_span > room)
room--;
if (active)
wattron(edit, interface_color_pair[SELECTED_TEXT]);
wattron(edit, interface_color_pair[SELECTED_TEXT]);
waddnstr(edit, word, actual_x(word, room));
if (word_span > room)
waddch(edit, '$');
if (active)
wattroff(edit, interface_color_pair[SELECTED_TEXT]);
wattroff(edit, interface_color_pair[SELECTED_TEXT]);
free(word);
@@ -3432,10 +3470,9 @@ void spotlight(bool active, size_t from_col, size_t to_col)
}
#ifndef NANO_TINY
/* Highlight the text between from_col and to_col when active is TRUE; remove
* the highlight when active is FALSE. This will not highlight softwrapped
/* Highlight the text between the given columns. This will not highlight soft
* line breaks, since they're not actually part of the spotlighted text. */
void spotlight_softwrapped(bool active, size_t from_col, size_t to_col)
void spotlight_softwrapped(size_t from_col, size_t to_col)
{
ssize_t row = openfile->current_y;
size_t leftedge = leftedge_for(from_col, openfile->current);
@@ -3462,13 +3499,11 @@ void spotlight_softwrapped(bool active, size_t from_col, size_t to_col)
word = display_string(openfile->current->data, from_col,
break_col - from_col, FALSE);
if (active)
wattron(edit, interface_color_pair[SELECTED_TEXT]);
wattron(edit, interface_color_pair[SELECTED_TEXT]);
waddnstr(edit, word, actual_x(word, break_col));
if (active)
wattroff(edit, interface_color_pair[SELECTED_TEXT]);
wattroff(edit, interface_color_pair[SELECTED_TEXT]);
free(word);
@@ -3503,15 +3538,15 @@ void do_credits(void)
"",
NULL, /* "Brought to you by:" */
"Chris Allegretta",
"Benno Schulenberg",
"David Lawrence Ramsey",
"Jordi Mallach",
"David Benbennick",
"Rocco Corsi",
"Mike Frysinger",
"Adam Rogoyski",
"Rob Siemborski",
"Rocco Corsi",
"David Lawrence Ramsey",
"David Benbennick",
"Mark Majeres",
"Mike Frysinger",
"Benno Schulenberg",
"Ken Tyler",
"Sven Guckes",
"Bill Soudan",

View File

@@ -1,6 +1,7 @@
## Here is an example for awk.
syntax awk "\.awk$"
header "^#!.*awk"
magic "awk script"
comment "#"
@@ -18,8 +19,7 @@ color green "(\{|\}|\(|\)|\;|\]|\[|\\|<|>|!|=|&|\+|-|\*|%|/|\?:|\^|\|)"
color brightyellow "\<(for|if|while|do|else|in|delete|exit)\>"
color brightyellow "\<(break|continue|return)\>"
# I/O statements.
color brightgreen "\<(close|getline|next|nextfile|print|printf)\>"
color brightgreen "\<(system|fflush)\>"
color brightgreen "\<(close|fflush|getline|next|nextfile|print|printf|system)\>"
# Standard functions.
color magenta "\<(atan2|cos|exp|int|log|rand|sin|sqrt|srand)\>"
color magenta "\<(asort|asorti|gensub|gsub|index|length|match)\>"

View File

@@ -1,6 +1,6 @@
## Here is an example for C/C++.
syntax c "\.(c(c|pp|xx|\+\+)?|C)$" "\.(h(h|pp|xx)?|H)$" "\.ii?$"
syntax c "\.([ch](pp|xx)?|C|cc|c\+\+|H|hh|ii?)$"
magic "^(C|C\+\+) (source|program)"
comment "//"

View File

@@ -1,9 +1,9 @@
## Colouring for Changelogs.
syntax changelog "Change[Ll]og.*"
syntax changelog "Change[Ll]og[^/]*$"
# Author lines.
color green "^(19|20).*$"
color green "^(19|20).*"
# Dates.
color red "^(19|20)[0-9-]{8}"
# Email addresses.

View File

@@ -15,6 +15,5 @@ icolor brightred "^[[:space:]]*((end)?(function|macro)|return)"
icolor cyan start="\$(\{|ENV\{)" end="\}"
color magenta "\<(APPLE|UNIX|WIN32|CYGWIN|BORLAND|MINGW|MSVC(_IDE|60|71|80|90)?)\>"
icolor brightblue "^([[:space:]]*)?#.*"
icolor brightblue "[[:space:]]#.*"
color brightblue "(^|[[:space:]])#.*"
color ,green "[[:space:]]+$"

View File

@@ -1,6 +1,6 @@
## Here is an example for apt's sources.list.
syntax sources.list "sources\.list(~|\.old|\.save)?$" "sources\.list\.d/.*\.list(~|\.old|\.save)?$"
syntax sources.list "sources\.list(\.d/.*\.list)?(~|\.old|\.save)?$"
comment "#"
# Coloring the deb lines, working from tail to head. First the

View File

@@ -11,7 +11,7 @@ color cyan "^[[:space:]]*#.*"
color ,red " + +"
# Nano's name, including version.
color brightred "(GNU )?nano [1-9]\.[0-9]\.[^[:space:][:punct:]]+"
color brightred "(GNU )?[Nn]ano [1-3]\.[0-9][-.[:alnum:]]*\>"
# Email addresses.
color magenta "<[[:alnum:].%_+-]+@[[:alnum:].-]+\.[[:alpha:]]{2,}>"

View File

@@ -30,4 +30,4 @@ color blue ":(\w|[?-])+"
color yellow start="^[[:blank:]]+\"" end="[^\]\""
color yellow ""(\\.|[^"])*""
# Comments
color cyan "(^|[[:space:]]);.*$"
color cyan "(^|[[:space:]]);.*"

View File

@@ -39,7 +39,7 @@ color brightblue "\<tc-(arch(-kernel)?|export|has-(tls|openmp))\>"
## Common commands used in ebuilds:
color blue "\<(awk|cat|cd|chmod|chown|cp|echo|env|find|e?grep|ln|make|mkdir|mv|popd|printf|pushd|rm|rmdir|sed|set|tar|touch|unset|xargs)\>"
## Comments (doesn't work that well):
color yellow "(^|[[:space:]])#.*$"
color yellow "(^|[[:space:]])#.*"
## Strings (doesn't work that well):
color brightyellow ""(\\.|[^\"])*"" "'(\\.|[^'])*'"
## Trailing space is bad!
@@ -52,7 +52,7 @@ syntax /etc/portage "\.(accept_keywords|env|keywords|mask|unmask|use)(/.+)?$"
comment "#"
## Base text:
color green "^.+$"
color green ".+"
## Likely version and slot numbers:
color magenta "-[[:digit:].]+(_(alpha|beta|pre|rc|p)[[:digit:]]*)*(-r[[:digit:]]+)?([:[:space:]]|$)"
color magenta ":[^[:space:]]+([[:space:]]|$)"
@@ -67,7 +67,7 @@ color cyan "^[[:space:]]*[^/]*/"
## Masking regulators:
color brightmagenta "^[[:space:]]*(=|~|<|<=|>|>=)"
## Comments:
color yellow "#.*$"
color yellow "#.*"
## Trailing space is bad!
color ,green "[[:space:]]+$"
## Mixed whitespace is also bad.

View File

@@ -3,9 +3,6 @@
syntax go "\.go$"
comment "//"
# Set up a formatter since spelling is probably useless...
formatter gofmt -w
# Types.
color green "\<(bool|u?int(8|16|32|64)?|float(32|64)|complex(64|128)|byte|rune|uintptr|string|error)\>"
color green "\<((<-[[:space:]]*)chan|chan[[:space:]]*<-|const|func|interface|map|struct|type|var)\>"

View File

@@ -1,6 +1,6 @@
## Here is an example for groff.
syntax groff "\.m[ems]$" "\.rof" "\.tmac$" "^tmac."
syntax groff "(/tmac\.[^/]+$|\.(m[ems]|rof|tmac)$)"
comment ".\""
# The argument of .ds or .nr
@@ -15,7 +15,7 @@ color cyan start="(\\|\\\\)n\[" end="]"
# Requests
color brightgreen "^\.[[:space:]]*[^[:space:]]*"
# Comments
color yellow "^\.\\".*$"
color yellow "^\.\\".*"
# Strings
color green "(\\|\\\\)\*(.|\(..)"
color green start="(\\|\\\\)\*\[" end="]"

View File

@@ -21,4 +21,4 @@ color blue "#?:(\w|[?-])+"
color yellow start="^[[:blank:]]+\"" end="[^\]\""
color yellow ""(\\.|[^"])*""
# Comments
color cyan "(^|[[:space:]]);.*$"
color cyan "(^|[[:space:]]);.*"

View File

@@ -28,7 +28,7 @@ color brightred "\{" "\}"
color brightred "," ":"
# Comments.
color cyan "(^|[[:space:]]+)(//|#).*$"
color cyan "(^|[[:space:]]+)(//|#).*"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -5,12 +5,15 @@
syntax lua "\.lua$"
magic "Lua script"
linter "luacheck --no-color"
comment "--"
color brightwhite "\[\[.*\]\]"
# Operators
color brightyellow ":|\*|/|%|\+|-|\^|>|>=|<|<=|~=|=|\.\.|\<(not|and|or)\>"
color brightyellow ":|\*|/|%|\+|-|\^|>|>=|<|<=|~=|=|\.\.|#|\<(not|and|or)\>"
# Don't partially color ... as an operator
color normal "\.\.\."
# Statements
color brightblue "\<(do|end|while|repeat|until|if|elseif|then|else|for|in|function|local|return|break)\>"
@@ -49,9 +52,9 @@ color brightmagenta "\(|\)|\[|\]|\{|\}"
# Shebang
color brightcyan "^#!.*"
# Strings
color red ""(\\.|[^"\])*"|'(\\.|[^'\])*'"
# Simple comments and multiline comments
color green "--.*"
color green start="--\[\[" end="\]\]"
# Strings
color red ""(\\.|[^"\])*"|'(\\.|[^'\])*'"

View File

@@ -1,14 +1,24 @@
## Here is an example for Makefiles.
syntax makefile "Makefile[^/]*$" "\.(make|mk)$"
syntax makefile "(/((GNU)?m|M)akefile[^/]*$|\.(make|mk)$)"
magic "makefile script"
comment "#"
color red "[:=]"
color magenta "\<(if|ifeq|else|endif)\>"
# Assignments.
color red " (:?:|\+|\?)?= "
# Keywords.
color magenta "^(if|ifn?def|ifn?eq|else|endif|(-|s)?include)\>"
color magenta "^((override +)?(un)?define|endef|(un)?export|private|vpath)\>"
# Variable expansions.
color blue "\$+[{(][a-zA-Z0-9_-]+[})]"
# Targets.
color brightblue "^[^ ]+:"
# Comments.
color green "(^|[[:space:]]+)#.*"
## Trailing whitespace.
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -4,15 +4,15 @@ syntax man "\.[1-9]x?$"
magic "troff or preprocessor input"
comment ".\""
color green "\.(SH|SS|TH) .*$"
color green "\.(SH|SS|TH) .*"
color brightgreen "\.(SH|SS|TH) " "\.([HIT]P)"
color brightred "\.(B[IR]?|I[BR]?|R[BI]|S[BM]) .*$"
color brightred "\.(B[IR]?|I[BR]?|R[BI]|S[BM]) .*"
color brightblue "\.(B[IR]?|I[BR]?|R[BI]|S[BM]) " "\.([LP]?P)$"
color magenta "\\f[BIPR]"
color yellow "\.(br|DT|RS|RE|PD)"
# Comments.
color cyan "\.?\\\".*$"
color cyan "\.?\\\".*"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -4,7 +4,6 @@ syntax mgp "\.mgp$"
header "^%include.*"
comment "#"
icolor green "^%[a-z].*$"
color cyan "(^|[[:space:]])#.*$"
color cyan "(^|[[:space:]])%%.*$"
icolor green "^%[a-z].*"
color cyan "(^|[[:space:]])(#|%%).*"
color ,green "[[:space:]]+$"

View File

@@ -4,8 +4,8 @@
syntax nanohelp
# Key combos:
color cyan "\^[]4-8A-Z^\_◀▶▲▼]" "[◀▶▲▼]" "(\^|M-)Space" "\<M-." "\<F1?[0-9]"
color cyan "\<(Tab|Sh-Tab|Enter|Ins|Del|Bsp|Up|Down|Left|Right|Home|End|PgUp|PgDn)\>"
color cyan "\^[]4-8A-Z^\_◀▶▲▼]" "[◀▶▲▼]" "\<M-." "\<F1?[0-9]"
color cyan "\<((Sh-)?Tab|Enter|Ins|(Sh-\^?)?Del|Space|Bsp|Up|Down|Left|Right|Home|End|PgUp|PgDn)\>"
# Quoted indicators:
color brightred "'(\^|M-)'"

View File

@@ -4,17 +4,17 @@ syntax nanorc "\.?nanorc$"
comment "#"
# Possible errors and parameters
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|formatter|i?color|extendsyntax).*$"
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|i?color|extendsyntax).*"
# Keywords
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cutfromcursor|fill[[:space:]]+-?[[:digit:]]+|historylog|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize[[:space:]]+[1-9][0-9]*|tabstospaces|tempfile|trimblanks|unix|view|wordbounds)\>"
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cutfromcursor|fill[[:space:]]+-?[[:digit:]]+|historylog|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize[[:space:]]+[1-9][0-9]*|tabstospaces|tempfile|trimblanks|unix|view|wordbounds|zap)\>"
icolor yellow "^[[:space:]]*set[[:space:]]+((error|function|key|number|selected|status|title)color)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>"
icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|selectedcolor|speller|statuscolor|titlecolor|whitespace|wordchars)[[:space:]]+"
icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^([[:alpha:]]|[]0-9\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+([[:alpha:]]+|".*")[[:space:]]+(all|main|search|replace(with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([[:alpha:]]|[]0-9\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+(all|main|search|replace(with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
icolor brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|comment|linter|formatter)[[:space:]]+.*$"
icolor brightgreen "^[[:space:]]*(syntax|linter|formatter)[[:space:]]+[^[:blank:]]+"
icolor green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|formatter|extendsyntax)\>"
icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^([[:alpha:]]|[]@\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+([[:alpha:]]+|".*")[[:space:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([[:alpha:]]|[]@\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
icolor brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|comment|linter)[[:space:]]+.*"
icolor brightgreen "^[[:space:]]*(syntax|linter)[[:space:]]+[^[:blank:]]+"
icolor green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|extendsyntax)\>"
# Strings
color brightmagenta "".+"([[:space:]]|$)"
@@ -24,8 +24,8 @@ icolor yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|gr
icolor magenta "^[[:space:]]*i?color\>" "\<(start|end)="
# Comments
color brightblue "(^|[[:space:]]+)#.*$"
color cyan "^[[:space:]]*##.*$"
color brightblue "(^|[[:space:]]+)#.*"
color cyan "^[[:space:]]*##.*"
# Trailing whitespace
color ,green "[[:space:]]+$"

View File

@@ -17,7 +17,7 @@ color red "\<(drop|reject)\>"
color brightblue "\<(accept|continue|(d|s)nat|goto|jump|masquerade|return)\>"
# Comments
color cyan "(^|[[:space:]])#.*$"
color cyan "(^|[[:space:]])#.*"
# Trailing whitespace
color ,green "[[:space:]]+$"

View File

@@ -38,5 +38,5 @@ color brightblue "^[[:space:]]*#[[:space:]]*(define|include|import|(un|ifn?)def|
color yellow "//.*"
color yellow start="/\*" end="\*/"
# Trailing whitespace.  
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -1,7 +1,7 @@
## Here is an example for Perl.
syntax perl "\.p[lm]$"
header "^#!.*perl[-0-9._]*"
header "^#!.*perl"
magic "Perl script"
comment "#"

View File

@@ -26,4 +26,4 @@ color cyan "\\[abcefnrtv"\]"
# Reminders.
color brightwhite,yellow "(FIXME|TODO|XXX)"
# Obsolete strings.
color red "#~.*$"
color red "#~.*"

View File

@@ -59,9 +59,8 @@ color green "'([^']|(\\'))*'" "%[qw]\{[^}]*\}" "%[qw]\([^)]*\)" "%[qw]<[^>]*>"
color green "%[qw]\[[^]]*\]" "%[qw]\$[^$]*\$" "%[qw]\^[^^]*\^" "%[qw]![^!]*!"
# Comments.
color red "#[^{].*$" "#$"
color red "--[^{].*$" "#$"
color red "##[^{].*$" "##$"
color red "##?[^{].*" "##?$"
color red "--[^{].*" "--$"
color brightblue "//.*"
color brightblue start="/\*" end="\*/"

View File

@@ -1,7 +1,7 @@
## Here is an example for Python.
syntax python "\.py$"
header "^#!.*python[-0-9._]*"
header "^#!.*python"
magic "Python script"
linter pyflakes
comment "#"
@@ -10,22 +10,27 @@ comment "#"
icolor brightblue "def [0-9A-Z_]+"
# Keywords.
color brightcyan "\<(and|as|assert|async|await|break|class|continue)\>"
color brightcyan "\<(def|del|elif|else|except|exec|finally|for|from)\>"
color brightcyan "\<(def|del|elif|else|except|finally|for|from)\>"
color brightcyan "\<(global|if|import|in|is|lambda|nonlocal|not|or)\>"
color brightcyan "\<(pass|print|raise|return|try|while|with|yield)\>"
color brightcyan "\<(pass|raise|return|try|while|with|yield)\>"
# These two are keywords in Python 2, but functions in Python 3,
# so only color them when they are followed by whitespace, assuming
# that print(x) is a function invocation and print (x) is a statement.
color brightcyan "\<(exec|print)([[:blank:]]|$)"
# Special values.
color brightmagenta "\<(False|None|True)\>"
# Single-quoted strings.
color brightgreen "'([^'\]|\\.)+'"
color brightgreen ""([^"\]|\\.)+""
# Comments.
color brightred "(^|[[:blank:]])#.*$"
color brightred "(^|[[:blank:]])#.*"
# Triple-quoted strings.
color brightgreen start="'''([^'),]|$)" end="(^|[^(\])'''"
color brightgreen start="\"\"\"([^"),]|$)" end="(^|[^(\])\"\"\""
# Special values.
color brightmagenta "\<(False|None|True)\>"
# Reminders.
color brightwhite,yellow "(FIXME|TODO|XXX)"

View File

@@ -1,7 +1,7 @@
## Here is an example for Ruby.
syntax ruby "\.rb$"
header "^#!.*ruby[-0-9._]*"
header "^#!.*ruby"
magic "Ruby script"
linter ruby -w -c
comment "#"
@@ -28,8 +28,8 @@ color brightgreen "#\{[^}]*\}"
# Strings, single-quoted.
color green "'([^']|(\\'))*'" "%[qw]\{[^}]*\}" "%[qw]\([^)]*\)" "%[qw]<[^>]*>" "%[qw]\[[^]]*\]" "%[qw]\$[^$]*\$" "%[qw]\^[^^]*\^" "%[qw]![^!]*!"
# Comments.
color cyan "#[^{].*$" "#$"
color brightcyan "##[^{].*$" "##$"
color cyan "#[^{].*" "#$"
color brightcyan "##[^{].*" "##$"
# "Here" docs.
color green start="<<-?'?EOT'?" end="^EOT"
# Some common markers.

View File

@@ -4,7 +4,7 @@
## NOTE: Rules are applied in order: later rules re-colorize matching text.
syntax rust "\.rs"
syntax rust "\.(rlib|rs)$"
comment "//"
# Function definitions

View File

@@ -1,7 +1,7 @@
## Here is an example for Bourne shell scripts.
syntax sh "\.sh$"
header "^#!.*((ba|da|k|pdk)?sh[-0-9_]*|openrc-run|runscript)"
syntax sh "(\.sh|\.(a|ba|c|da|k|mk|pdk|tc|z)(sh|shrc|sh_profile)|/(etc/|\.)profile)$"
header "^#!.*/(((a|ba|c|da|k|mk|pdk|tc|z)?sh)|(busybox|env) +sh|openrc-run|runscript)"
magic "(POSIX|Bourne-Again) shell script.*text"
linter dash -n
comment "#"
@@ -28,7 +28,7 @@ color brightred "\$[-0-9@*#?$!]" "\$[[:alpha:]_][[:alnum:]_]*"
color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:space:]]*[[:alnum:]_]+[[:space:]]*|@)\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
# Comments.
color cyan "(^|[[:space:]])#.*$"
color cyan "(^|[[:space:]])#.*"
# Strings.
color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"

View File

@@ -1,6 +1,6 @@
## Syntax highlighting for RPM spec files.
syntax spec "\.(spec$|spec\.*)"
syntax spec "\.spec(\.[^/]+)?$"
comment "#"
# Main tags.
@@ -31,7 +31,7 @@ color red "^%(post|posttrans|postun|trigger|triggerin|triggerpostun|triggerun|ve
color brightred "%(if|else|endif|define|global|undefine)"
# Comments.
color cyan "#.*$"
color cyan "#.*"
# Special case: "# norootforbuild" is handled as main tag.
color brightblue "^# norootforbuild"
# %changelog date entries.

View File

@@ -12,10 +12,10 @@ color brightmagenta "@[a-zA-Z]+\{[^}]*\}"
color yellow "@[a-zA-Z]+\{?" "\}"
# Menu items.
color brightred "^\*[[:space:]]+.*::.*$"
color brightred "^\*[[:space:]]+.*::.*"
# Comments.
color green "@c[[:space:]]+.*$"
color green "@c[[:space:]]+.*"
# Trailing whitespace.
color ,green "[[:space:]]+$"