Compare commits

...

125 Commits
v3.0 ... 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
85 changed files with 21221 additions and 19343 deletions

143
ChangeLog
View File

@@ -1,3 +1,146 @@
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:
--------------------------------

View File

@@ -2,6 +2,7 @@ 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.

28
NEWS
View File

@@ -1,3 +1,31 @@
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

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

View File

@@ -2,7 +2,7 @@
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="14df8ea0658c8902d1ea60bf57ce696cb51814f5"
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], [3.0], [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])

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>3.0</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 3.0" "September 2018"
.TH NANO 1 "version 3.2" "November 2018"
.SH NAME
nano \- Nano's ANOther editor, an enhanced free Pico clone
@@ -131,11 +131,11 @@ 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
@@ -167,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.
@@ -181,8 +185,9 @@ 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.
@@ -244,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 3.0
@set UPDATED September 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 3.0
@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 3.0.
This manual documents the GNU @command{nano} editor, version 3.2.
@menu
* Introduction::
@@ -227,11 +227,11 @@ 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
@@ -270,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
@@ -289,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
@@ -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
@@ -857,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
@@ -909,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}"
@@ -926,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
@@ -1144,6 +1159,10 @@ Pastes the currently stored text into the current buffer at the
current cursor position.
(The old form 'uncut' is deprecated.)
@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
@@ -1310,11 +1329,11 @@ Toggles whether searching/replacing uses literal strings or regular expressions.
@item backwards
Toggles whether searching/replacing goes forward or backward.
@item prevhistory
Retrieves the previous (older) entry at a prompt.
@item older
Retrieves the previous (earlier) entry at a prompt.
@item nexthistory
Retrieves the next (newer) entry at a prompt.
@item newer
Retrieves the next (later) entry at a prompt.
@item flipreplace
Toggles between searching for something and replacing something.

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 3.0" "September 2018"
.TH NANORC 5 "version 3.2" "November 2018"
.SH NAME
nanorc \- GNU nano's configuration file
@@ -280,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
@@ -295,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
@@ -504,6 +510,10 @@ Pastes the currently stored text into the current buffer at the
current cursor position.
(The old form 'uncut' is deprecated.)
.TP
.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
@@ -673,11 +683,11 @@ Toggles whether searching/replacing uses literal strings or regular expressions.
.B backwards
Toggles whether searching/replacing goes forward or backward.
.TP
.B prevhistory
Retrieves the previous (older) entry at a prompt.
.B older
Retrieves the previous (earlier) entry at a prompt.
.TP
.B nexthistory
Retrieves the next (newer) entry at a prompt.
.B newer
Retrieves the next (later) entry at a prompt.
.TP
.B flipreplace
Toggles between searching for something and replacing something.

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 3.0" "September 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

@@ -136,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
@@ -193,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.
@@ -261,10 +265,6 @@
## Key bindings.
## See nanorc(5) (section REBINDING KEYS) for more details on this.
## If your Backspace key behaves as Delete (when ssh'ing in from another
## machine, for example), set this to make it behave as Backspace again:
# 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
@@ -273,3 +273,35 @@
## 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

1144
po/bg.po

File diff suppressed because it is too large Load Diff

1076
po/ca.po

File diff suppressed because it is too large Load Diff

1070
po/cs.po

File diff suppressed because it is too large Load Diff

1155
po/da.po

File diff suppressed because it is too large Load Diff

1093
po/de.po

File diff suppressed because it is too large Load Diff

1081
po/eo.po

File diff suppressed because it is too large Load Diff

1078
po/es.po

File diff suppressed because it is too large Load Diff

1144
po/eu.po

File diff suppressed because it is too large Load Diff

1217
po/fi.po

File diff suppressed because it is too large Load Diff

1080
po/fr.po

File diff suppressed because it is too large Load Diff

1068
po/ga.po

File diff suppressed because it is too large Load Diff

1069
po/gl.po

File diff suppressed because it is too large Load Diff

1109
po/hr.po

File diff suppressed because it is too large Load Diff

1067
po/hu.po

File diff suppressed because it is too large Load Diff

1143
po/id.po

File diff suppressed because it is too large Load Diff

1065
po/it.po

File diff suppressed because it is too large Load Diff

1067
po/ja.po

File diff suppressed because it is too large Load Diff

1068
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1130
po/nb.po

File diff suppressed because it is too large Load Diff

1077
po/nl.po

File diff suppressed because it is too large Load Diff

1203
po/nn.po

File diff suppressed because it is too large Load Diff

1205
po/pl.po

File diff suppressed because it is too large Load Diff

1077
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1079
po/ro.po

File diff suppressed because it is too large Load Diff

1062
po/ru.po

File diff suppressed because it is too large Load Diff

1064
po/sl.po

File diff suppressed because it is too large Load Diff

1067
po/sr.po

File diff suppressed because it is too large Load Diff

1067
po/sv.po

File diff suppressed because it is too large Load Diff

1077
po/tr.po

File diff suppressed because it is too large Load Diff

1078
po/uk.po

File diff suppressed because it is too large Load Diff

1077
po/vi.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,10 @@
#!/bin/bash
VERSION="3.0"
VERSION="3.2"
./configure -C --enable-tiny && make &&
./configure -C --disable-wrapping-as-root &&
echo "Pulling..." && git pull &&
echo "Running autogen..." && ./autogen.sh &&
rm -v -f m4/*.m4~ *.asc *.sig *.gz *.xz &&

View File

@@ -462,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':

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 marked, 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;
@@ -126,7 +121,7 @@ void do_cut_text(bool copy_text, bool marked, bool cut_till_eof)
size_t was_totsize = openfile->totsize;
/* If cuts were not continuous, or when cutting a region, clear the slate. */
if (!keep_cutbuffer || marked || cut_till_eof) {
if (!append && (!keep_cutbuffer || marked || cut_till_eof)) {
free_filestruct(cutbuffer);
cutbuffer = NULL;
/* After a line cut, future line cuts should add to the cutbuffer. */
@@ -193,11 +188,16 @@ void do_cut_text(bool copy_text, bool marked, bool cut_till_eof)
void do_cut_text_void(void)
{
#ifndef NANO_TINY
add_undo(CUT);
do_cut_text(FALSE, openfile->mark, FALSE);
/* 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);
do_cut_text(FALSE, FALSE, FALSE, FALSE);
#endif
}
@@ -219,7 +219,7 @@ void do_copy_text(void)
if (mark_is_set || openfile->current != next_contiguous_line)
cutbuffer_reset();
do_cut_text(TRUE, mark_is_set, 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);
@@ -237,9 +237,35 @@ void do_copy_text(void)
void do_cut_till_eof(void)
{
add_undo(CUT_TO_EOF);
do_cut_text(FALSE, 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

@@ -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. */
@@ -533,7 +533,7 @@ void replace_buffer(const char *filename)
#ifndef NANO_TINY
add_undo(CUT_TO_EOF);
#endif
do_cut_text(FALSE, FALSE, TRUE);
do_cut_text(FALSE, FALSE, TRUE, FALSE);
#ifndef NANO_TINY
update_undo(CUT_TO_EOF);
#endif
@@ -574,7 +574,7 @@ void replace_marked_buffer(const char *filename)
/* Throw away the text under the mark. */
cutbuffer = NULL;
add_undo(CUT);
do_cut_text(FALSE, TRUE, FALSE);
do_cut_text(FALSE, TRUE, FALSE, FALSE);
update_undo(CUT);
free_filestruct(cutbuffer);
cutbuffer = was_cutbuffer;
@@ -687,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
@@ -1221,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)
@@ -1258,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();
}
@@ -1904,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) {

View File

@@ -68,18 +68,23 @@ bool also_the_last = FALSE;
int didfind = 0;
/* Whether the last search found something. */
int controlleft, controlright, controlup, controldown, controlhome, controlend;
int controldelete, controlshiftdelete;
int controlleft, controlright, controlup, controldown;
int controlhome, controlend;
#ifndef NANO_TINY
int controldelete, controlshiftdelete;
int shiftleft, shiftright, shiftup, shiftdown;
int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown;
int shiftcontrolhome, shiftcontrolend;
int altleft, altright, altup, altdown;
int altdelete;
int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown;
#endif
#ifdef ENABLED_WRAPORJUSTIFY
ssize_t fill = -COLUMNS_FROM_EOL;
/* The column where we will wrap lines. */
ssize_t wrap_at = -COLUMNS_FROM_EOL;
/* The relative column where we will wrap lines. */
ssize_t fill = 0;
/* The actual column where we will wrap lines, based on wrap_at. */
#endif
char *last_search = NULL;
@@ -120,8 +125,7 @@ openfilestruct *firstfile = NULL;
#ifndef NANO_TINY
char *matchbrackets = NULL;
/* The opening and closing brackets that can be found by bracket
* searches. */
/* The opening and closing brackets that bracket searches can find. */
char *whitespace = NULL;
/* The characters used when visibly showing tabs and spaces. */
int whitespace_len[2];
@@ -257,6 +261,13 @@ char *rcfile_with_errors = NULL;
/* The first nanorc file, if any, that produced warnings. */
#endif
bool spotlighted = FALSE;
/* Whether any text is spotlighted. */
size_t light_from_col = 0;
/* Where the spotlighted text starts. */
size_t light_to_col = 0;
/* Where the spotlighted text ends. */
/* Return the number of entries in the shortcut list for a given menu. */
size_t length_of_list(int menu)
{
@@ -275,6 +286,11 @@ size_t length_of_list(int menu)
#define NOVIEW FALSE
#define BLANKAFTER TRUE /* A blank line after this one. */
#define TOGETHER FALSE
#ifdef ENABLE_MULTIBUFFER
#define CAN_OPEN_OTHER_BUFFER TRUE
#else
#define CAN_OPEN_OTHER_BUFFER FALSE
#endif
/* Empty functions, for the most part corresponding to toggles. */
void case_sens_void(void)
@@ -445,9 +461,7 @@ functionptrtype func_from_key(int *kbinput)
void assign_keyinfo(sc *s, const char *keystring, const int keycode)
{
s->keystr = keystring;
s->meta = (keystring[0] == 'M' && keystring[2] != '\xE2');
assert(strlen(keystring) > 1 && (!s->meta || strlen(keystring) > 2));
s->meta = (keystring[0] == 'M' && keycode == 0);
if (keycode)
s->keycode = keycode;
@@ -462,6 +476,10 @@ int keycode_from_string(const char *keystring)
if (keystring[0] == '^') {
if (strcasecmp(keystring, "^Space") == 0)
return 0;
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
if (strcasecmp(keystring, "^H") == 0)
return KEY_BACKSPACE;
#endif
if (keystring[1] <= '_' && strlen(keystring) == 2)
return keystring[1] - 64;
else
@@ -556,6 +574,7 @@ void shortcut_init(void)
const char *mark_gist = N_("Mark text starting from the cursor position");
const char *copy_gist =
N_("Copy current line (or marked region) and store it in cutbuffer");
const char *zap_gist = N_("Throw away the current line (or marked region)");
const char *indent_gist = N_("Indent the current line (or marked lines)");
const char *unindent_gist = N_("Unindent the current line (or marked lines)");
const char *undo_gist = N_("Undo the last operation");
@@ -582,7 +601,7 @@ void shortcut_init(void)
#ifndef NANO_TINY
const char *bracket_gist = N_("Go to the matching bracket");
#endif
#ifdef ENABLE_HELP
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
const char *scrollup_gist =
N_("Scroll up one line without moving the cursor textually");
const char *scrolldown_gist =
@@ -639,9 +658,9 @@ void shortcut_init(void)
const char *regexp_gist =
N_("Toggle the use of regular expressions");
#ifdef ENABLE_HISTORIES
const char *prevhistory_gist =
const char *older_gist =
N_("Recall the previous search/replace string");
const char *nexthistory_gist =
const char *newer_gist =
N_("Recall the next search/replace string");
#endif
#ifndef NANO_TINY
@@ -715,11 +734,7 @@ void shortcut_init(void)
N_("Read File"), WITHORSANS(readfile_gist), BLANKAFTER,
/* We allow inserting files in view mode if multibuffer mode
* is switched on, so that we can view multiple files. */
#ifdef ENABLE_MULTIBUFFER
VIEW);
#else
NOVIEW);
#endif
CAN_OPEN_OTHER_BUFFER);
} else {
#ifdef ENABLE_JUSTIFY
add_to_funcs(do_justify_void, MMAIN,
@@ -761,14 +776,9 @@ void shortcut_init(void)
add_to_funcs(do_justify_void, MMAIN,
N_("Justify"), WITHORSANS(justify_gist), TOGETHER, NOVIEW);
#endif
#ifdef ENABLE_SPELLER
add_to_funcs(do_spell, MMAIN,
N_("To Spell"), WITHORSANS(spell_gist), TOGETHER, NOVIEW);
#endif
#ifdef ENABLE_COLOR
add_to_funcs(do_linter, MMAIN,
N_("To Linter"), WITHORSANS(lint_gist), TOGETHER, NOVIEW);
N_("To Spell"), WITHORSANS(spell_gist), BLANKAFTER, NOVIEW);
#endif
}
@@ -808,6 +818,12 @@ void shortcut_init(void)
add_to_funcs(flip_replace, MREPLACE,
N_("No Replace"), WITHORSANS(whereis_gist), BLANKAFTER, VIEW);
#ifdef ENABLE_HISTORIES
add_to_funcs(get_history_older_void, MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE,
N_("Older"), WITHORSANS(older_gist), TOGETHER, VIEW);
add_to_funcs(get_history_newer_void, MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE,
N_("Newer"), WITHORSANS(newer_gist), BLANKAFTER, VIEW);
#endif
#ifdef ENABLE_JUSTIFY
add_to_funcs(do_full_justify, MWHEREIS,
N_("FullJstify"), WITHORSANS(fulljustify_gist), TOGETHER, NOVIEW);
@@ -835,6 +851,7 @@ void shortcut_init(void)
/* TRANSLATORS: This starts a backward search. */
N_("Where Was"), WITHORSANS(wherewas_gist), TOGETHER, VIEW);
add_to_funcs(do_findprevious, MMAIN|MHELP|MBROWSER,
/* TRANSLATORS: This refers to searching the preceding occurrence. */
N_("Previous"), WITHORSANS(findprev_gist), TOGETHER, VIEW);
add_to_funcs(do_findnext, MMAIN|MHELP|MBROWSER,
N_("Next"), WITHORSANS(findnext_gist), BLANKAFTER, VIEW);
@@ -865,7 +882,7 @@ void shortcut_init(void)
N_("Prev Line"), WITHORSANS(prevline_gist), TOGETHER, VIEW);
add_to_funcs(do_down, MMAIN|MHELP|MBROWSER,
N_("Next Line"), WITHORSANS(nextline_gist), TOGETHER, VIEW);
#ifdef ENABLE_HELP
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
add_to_funcs(do_scroll_up, MMAIN,
N_("Scroll Up"), WITHORSANS(scrollup_gist), TOGETHER, VIEW);
add_to_funcs(do_scroll_down, MMAIN,
@@ -911,10 +928,10 @@ void shortcut_init(void)
add_to_funcs(do_enter, MMAIN,
N_("Enter"), WITHORSANS(enter_gist), BLANKAFTER, NOVIEW);
add_to_funcs(do_delete, MMAIN,
N_("Delete"), WITHORSANS(delete_gist), TOGETHER, NOVIEW);
add_to_funcs(do_backspace, MMAIN,
N_("Backspace"), WITHORSANS(backspace_gist),
N_("Backspace"), WITHORSANS(backspace_gist), TOGETHER, NOVIEW);
add_to_funcs(do_delete, MMAIN,
N_("Delete"), WITHORSANS(delete_gist),
#ifndef NANO_TINY
TOGETHER,
#else
@@ -971,15 +988,17 @@ void shortcut_init(void)
add_to_funcs(run_macro, MMAIN,
N_("Run Macro"), WITHORSANS(runmacro_gist), BLANKAFTER, VIEW);
add_to_funcs(zap_text, MMAIN,
N_("Zap Text"), WITHORSANS(zap_gist), BLANKAFTER, NOVIEW);
#ifdef ENABLE_COLOR
if (!ISSET(RESTRICTED))
add_to_funcs(do_linter, MMAIN,
N_("To Linter"), WITHORSANS(lint_gist), BLANKAFTER, NOVIEW);
#endif
add_to_funcs(do_savefile, MMAIN,
N_("Save"), WITHORSANS(savefile_gist), BLANKAFTER, NOVIEW);
#endif
#ifdef ENABLE_HISTORIES
add_to_funcs(get_history_older_void, MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE,
N_("PrevHstory"), WITHORSANS(prevhistory_gist), TOGETHER, VIEW);
add_to_funcs(get_history_newer_void, MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE,
N_("NextHstory"), WITHORSANS(nexthistory_gist), BLANKAFTER, VIEW);
#endif
#ifndef ENABLE_JUSTIFY
add_to_funcs(flip_goto, MWHEREIS,
@@ -1040,7 +1059,7 @@ void shortcut_init(void)
add_to_funcs(do_page_up, MBROWSER,
N_("Prev Page"), WITHORSANS(prevpage_gist), TOGETHER, VIEW);
add_to_funcs(do_page_down, MBROWSER,
N_("Prev Page"), WITHORSANS(nextpage_gist), TOGETHER, VIEW);
N_("Next Page"), WITHORSANS(nextpage_gist), TOGETHER, VIEW);
add_to_funcs(to_first_file, MBROWSER|MWHEREISFILE,
N_("First File"), WITHORSANS(firstfile_gist), TOGETHER, VIEW);
@@ -1070,59 +1089,50 @@ void shortcut_init(void)
#endif
/* Link key combos to functions in certain menus. */
add_to_sclist(MMOST, "^M", 0, do_enter, 0);
add_to_sclist(MMOST, "Enter", KEY_ENTER, do_enter, 0);
add_to_sclist(MMOST|MBROWSER, "^M", 0, do_enter, 0);
add_to_sclist(MMOST|MBROWSER, "Enter", KEY_ENTER, do_enter, 0);
add_to_sclist(MMOST, "^H", 0, do_backspace, 0);
add_to_sclist(MMOST, "Bsp", KEY_BACKSPACE, do_backspace, 0);
add_to_sclist(MMOST, "Sh-Del", SHIFT_DELETE, do_backspace, 0);
add_to_sclist(MMOST, "^D", 0, do_delete, 0);
add_to_sclist(MMOST, "Del", 0, do_delete, 0);
/* Make ASCII DEL do a delete when requested, otherwise a backspace. */
if (ISSET(REBIND_DELETE))
add_to_sclist(MMOST, "Del", DEL_CODE, do_delete, 0);
else
add_to_sclist(MMOST & ~MBROWSER, "Bsp", DEL_CODE, do_backspace, 0);
add_to_sclist(MMOST, "^I", 0, do_tab, 0);
add_to_sclist(MMOST, "Tab", TAB_CODE, do_tab, 0);
add_to_sclist(MMOST & ~MFINDINHELP, "^G", 0, do_help_void, 0);
add_to_sclist(MMOST & ~MFINDINHELP, "F1", 0, do_help_void, 0);
add_to_sclist((MMOST|MBROWSER) & ~MFINDINHELP, "^G", 0, do_help_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^X", 0, do_exit, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", 0, do_exit, 0);
add_to_sclist(MMAIN, "^S", 0, do_savefile, 0);
add_to_sclist(MMAIN, "^O", 0, do_writeout_void, 0);
add_to_sclist(MMAIN, "F3", 0, do_writeout_void, 0);
add_to_sclist(MMAIN, "^R", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN, "F5", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN, "Ins", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^Q", 0, do_search_backward, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^W", 0, do_search_forward, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "F6", 0, do_search_forward, 0);
add_to_sclist(MMAIN, "^\\", 0, do_replace, 0);
add_to_sclist(MMAIN, "M-R", 0, do_replace, 0);
add_to_sclist(MMAIN, "F14", 0, do_replace, 0);
add_to_sclist(MMOST, "^K", 0, do_cut_text_void, 0);
add_to_sclist(MMOST, "F9", 0, do_cut_text_void, 0);
add_to_sclist(MMOST, "^U", 0, do_uncut_text, 0);
add_to_sclist(MMOST, "F10", 0, do_uncut_text, 0);
#ifdef ENABLE_JUSTIFY
add_to_sclist(MMAIN, "^J", 0, do_justify_void, 0);
add_to_sclist(MMAIN, "F4", 0, do_justify_void, 0);
#endif
#ifdef ENABLE_SPELLER
add_to_sclist(MMAIN, "^T", 0, do_spell, 0);
add_to_sclist(MMAIN, "F12", 0, do_spell, 0);
#else
#ifdef ENABLE_COLOR
add_to_sclist(MMAIN, "^T", 0, do_linter, 0);
add_to_sclist(MMAIN, "F12", 0, do_linter, 0);
#endif
#ifdef ENABLE_COLOR
add_to_sclist(MMAIN, "M-B", 0, do_linter, 0);
#endif
add_to_sclist(MMAIN, "^C", 0, do_cursorpos_void, 0);
add_to_sclist(MMAIN, "F11", 0, do_cursorpos_void, 0);
add_to_sclist(MMAIN, "^_", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MMAIN, "M-G", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MMAIN, "F13", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^Y", 0, do_page_up, 0);
add_to_sclist(MHELP|MBROWSER, "Bsp", KEY_BACKSPACE, do_page_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F7", 0, do_page_up, 0);
add_to_sclist(MHELP|MBROWSER, "Sh-Del", SHIFT_DELETE, do_page_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgUp", KEY_PPAGE, do_page_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^V", 0, do_page_down, 0);
add_to_sclist(MHELP|MBROWSER, "Space", 0x20, do_page_down, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F8", 0, do_page_down, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgDn", KEY_NPAGE, do_page_down, 0);
add_to_sclist(MMAIN|MHELP, "M-\\", 0, to_first_line, 0);
add_to_sclist(MMAIN|MHELP, "^Home", CONTROL_HOME, to_first_line, 0);
@@ -1135,7 +1145,6 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "M-A", 0, do_mark, 0);
add_to_sclist(MMAIN, "^6", 0, do_mark, 0);
add_to_sclist(MMAIN, "^^", 0, do_mark, 0);
add_to_sclist(MMAIN, "F15", 0, do_mark, 0);
add_to_sclist(MMAIN, "M-6", 0, do_copy_text, 0);
add_to_sclist(MMAIN, "M-^", 0, do_copy_text, 0);
add_to_sclist(MMAIN, "M-}", 0, do_indent, 0);
@@ -1146,8 +1155,9 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "M-;", 0, run_macro, 0);
add_to_sclist(MMAIN, "M-U", 0, do_undo, 0);
add_to_sclist(MMAIN, "M-E", 0, do_redo, 0);
add_to_sclist(MMAIN, "M-|", 0, do_cut_prev_word, 0);
add_to_sclist(MMAIN, "Sh-^Del", CONTROL_SHIFT_DELETE, do_cut_prev_word, 0);
add_to_sclist(MMAIN, "^Del", CONTROL_DELETE, do_cut_next_word, 0);
add_to_sclist(MMAIN, "M-Del", ALT_DELETE, zap_text, 0);
#endif
#ifdef ENABLE_WORDCOMPLETION
add_to_sclist(MMAIN, "^]", 0, complete_a_word, 0);
@@ -1155,51 +1165,51 @@ void shortcut_init(void)
#ifdef ENABLE_COMMENT
add_to_sclist(MMAIN, "M-3", 0, do_comment, 0);
#endif
add_to_sclist(MMOST, "^B", 0, do_left, 0);
add_to_sclist(MMOST, "^F", 0, do_right, 0);
add_to_sclist(MMOST|MBROWSER, "^B", 0, do_left, 0);
add_to_sclist(MMOST|MBROWSER, "^F", 0, do_right, 0);
#ifdef ENABLE_UTF8
if (using_utf8()) {
add_to_sclist(MMOST, "\xE2\x97\x80", KEY_LEFT, do_left, 0);
add_to_sclist(MMOST, "\xE2\x96\xb6", KEY_RIGHT, do_right, 0);
add_to_sclist(MMOST|MHELP|MBROWSER, "\xE2\x97\x80", KEY_LEFT, do_left, 0);
add_to_sclist(MMOST|MHELP|MBROWSER, "\xE2\x96\xb6", KEY_RIGHT, do_right, 0);
add_to_sclist(MSOME, "^\xE2\x97\x80", CONTROL_LEFT, do_prev_word_void, 0);
add_to_sclist(MSOME, "^\xE2\x96\xb6", CONTROL_RIGHT, do_next_word_void, 0);
#ifndef NANO_TINY
#ifdef ENABLE_MULTIBUFFER
add_to_sclist(MMAIN, "M-\xE2\x97\x80", ALT_LEFT, switch_to_prev_buffer, 0);
add_to_sclist(MMAIN, "M-\xE2\x96\xb6", ALT_RIGHT, switch_to_next_buffer, 0);
#endif
#ifndef NANO_TINY
add_to_sclist(MMAIN|MHELP|MBROWSER, "M-\xE2\x96\xb2", ALT_UP, do_findprevious, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "M-\xE2\x96\xbc", ALT_DOWN, do_findnext, 0);
#endif
} else
#endif
{
add_to_sclist(MMOST, "Left", KEY_LEFT, do_left, 0);
add_to_sclist(MMOST, "Right", KEY_RIGHT, do_right, 0);
add_to_sclist(MMOST|MHELP|MBROWSER, "Left", KEY_LEFT, do_left, 0);
add_to_sclist(MMOST|MHELP|MBROWSER, "Right", KEY_RIGHT, do_right, 0);
add_to_sclist(MSOME, "^Left", CONTROL_LEFT, do_prev_word_void, 0);
add_to_sclist(MSOME, "^Right", CONTROL_RIGHT, do_next_word_void, 0);
}
add_to_sclist(MMOST, "M-Space", 0, do_prev_word_void, 0);
add_to_sclist(MMOST, "^Space", 0, do_next_word_void, 0);
add_to_sclist((MMOST & ~MBROWSER), "^A", 0, do_home, 0);
add_to_sclist((MMOST & ~MBROWSER), "Home", KEY_HOME, do_home, 0);
add_to_sclist((MMOST & ~MBROWSER), "^E", 0, do_end, 0);
add_to_sclist((MMOST & ~MBROWSER), "End", KEY_END, do_end, 0);
add_to_sclist(MMOST|MBROWSER, "M-Space", 0, do_prev_word_void, 0);
add_to_sclist(MMOST|MBROWSER, "^Space", 0, do_next_word_void, 0);
add_to_sclist(MMOST, "^A", 0, do_home, 0);
add_to_sclist(MMOST, "Home", KEY_HOME, do_home, 0);
add_to_sclist(MMOST, "^E", 0, do_end, 0);
add_to_sclist(MMOST, "End", KEY_END, do_end, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^P", 0, do_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^N", 0, do_down, 0);
#ifdef ENABLE_UTF8
if (using_utf8()) {
add_to_sclist(MMAIN|MHELP|MBROWSER, "\xE2\x96\xb2", KEY_UP, do_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "\xE2\x96\xbc", KEY_DOWN, do_down, 0);
add_to_sclist(MMAIN|MBROWSER, "^\xE2\x96\xb2", CONTROL_UP, do_prev_block, 0);
add_to_sclist(MMAIN|MBROWSER, "^\xE2\x96\xbc", CONTROL_DOWN, do_next_block, 0);
add_to_sclist(MMAIN|MBROWSER|MLINTER, "^\xE2\x96\xb2", CONTROL_UP, do_prev_block, 0);
add_to_sclist(MMAIN|MBROWSER|MLINTER, "^\xE2\x96\xbc", CONTROL_DOWN, do_next_block, 0);
} else
#endif
{
add_to_sclist(MMAIN|MHELP|MBROWSER, "Up", KEY_UP, do_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "Down", KEY_DOWN, do_down, 0);
add_to_sclist(MMAIN|MBROWSER, "^Up", CONTROL_UP, do_prev_block, 0);
add_to_sclist(MMAIN|MBROWSER, "^Down", CONTROL_DOWN, do_next_block, 0);
add_to_sclist(MMAIN|MBROWSER|MLINTER, "^Up", CONTROL_UP, do_prev_block, 0);
add_to_sclist(MMAIN|MBROWSER|MLINTER, "^Down", CONTROL_DOWN, do_next_block, 0);
}
add_to_sclist(MMAIN, "M-7", 0, do_prev_block, 0);
add_to_sclist(MMAIN, "M-8", 0, do_next_block, 0);
@@ -1209,7 +1219,7 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "M-)", 0, do_para_end_void, 0);
add_to_sclist(MMAIN, "M-0", 0, do_para_end_void, 0);
#endif
#ifdef ENABLE_HELP
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
add_to_sclist(MMAIN, "M--", 0, do_scroll_up, 0);
add_to_sclist(MMAIN, "M-_", 0, do_scroll_up, 0);
add_to_sclist(MMAIN, "M-+", 0, do_scroll_down, 0);
@@ -1262,7 +1272,7 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "M-Z", 0, do_toggle_void, SUSPEND);
#endif /* !NANO_TINY */
add_to_sclist(((MMOST & ~MMAIN & ~MBROWSER) | MYESNO), "^C", 0, do_cancel, 0);
add_to_sclist(((MMOST & ~MMAIN) | MYESNO), "^C", 0, do_cancel, 0);
add_to_sclist(MWHEREIS|MREPLACE, "M-C", 0, case_sens_void, 0);
add_to_sclist(MWHEREIS|MREPLACE, "M-R", 0, regexp_void, 0);
@@ -1300,7 +1310,6 @@ void shortcut_init(void)
add_to_sclist(MBROWSER, "^End", CONTROL_END, to_last_file, 0);
add_to_sclist(MBROWSER, "^_", 0, goto_dir_void, 0);
add_to_sclist(MBROWSER, "M-G", 0, goto_dir_void, 0);
add_to_sclist(MBROWSER, "F13", 0, goto_dir_void, 0);
#endif
if (ISSET(TEMP_FILE))
add_to_sclist(MWRITEFILE, "^Q", 0, discard_buffer, 0);
@@ -1343,32 +1352,31 @@ void shortcut_init(void)
add_to_sclist(MHELP, "Home", KEY_HOME, to_first_line, 0);
add_to_sclist(MHELP, "End", KEY_END, to_last_line, 0);
#endif
#ifdef ENABLE_COLOR
add_to_sclist(MLINTER, "^X", 0, do_cancel, 0);
#endif
add_to_sclist(MMOST & ~MFINDINHELP, "F1", 0, do_help_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", 0, do_exit, 0);
add_to_sclist(MMAIN, "F3", 0, do_writeout_void, 0);
#ifdef ENABLE_JUSTIFY
add_to_sclist(MMAIN, "F4", 0, do_justify_void, 0);
#endif
add_to_sclist(MMAIN, "F5", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "F6", 0, do_search_forward, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F7", 0, do_page_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F8", 0, do_page_down, 0);
add_to_sclist(MMOST, "F9", 0, do_cut_text_void, 0);
add_to_sclist(MMOST, "F10", 0, do_uncut_text, 0);
add_to_sclist(MMAIN, "F11", 0, do_cursorpos_void, 0);
#ifdef ENABLE_SPELLER
add_to_sclist(MMAIN, "F12", 0, do_spell, 0);
#endif
#ifdef DEBUG
print_sclist();
#endif
}
#if defined(ENABLE_COLOR) && defined(ENABLE_SPELLER)
/* Assign one function's shortcuts to another function. */
void replace_scs_for(void (*oldfunc)(void), void (*newfunc)(void))
{
for (sc *s = sclist; s != NULL; s = s->next)
if (s->func == oldfunc)
s->func = newfunc;
}
void set_linter_shortcut(void)
{
replace_scs_for(do_spell, do_linter);
}
void set_speller_shortcut(void)
{
replace_scs_for(do_linter, do_spell);
}
#endif /* ENABLE_COLOR && ENABLE_SPELLER */
const subnfunc *sctofunc(const sc *s)
{
subnfunc *f = allfuncs;
@@ -1469,6 +1477,8 @@ sc *strtosc(const char *input)
else if (!strcasecmp(input, "copy") ||
!strcasecmp(input, "copytext")) /* Deprecated. Remove end of 2018. */
s->func = do_copy_text;
else if (!strcasecmp(input, "zap"))
s->func = zap_text;
else if (!strcasecmp(input, "mark"))
s->func = do_mark;
#endif
@@ -1537,7 +1547,7 @@ sc *strtosc(const char *input)
else if (!strcasecmp(input, "down") ||
!strcasecmp(input, "nextline"))
s->func = do_down;
#ifdef ENABLE_HELP
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
else if (!strcasecmp(input, "scrollup"))
s->func = do_scroll_up;
else if (!strcasecmp(input, "scrolldown"))
@@ -1597,9 +1607,9 @@ sc *strtosc(const char *input)
!strcasecmp(input, "gototext")) /* Deprecated. Remove end of 2018. */
s->func = flip_goto;
#ifdef ENABLE_HISTORIES
else if (!strcasecmp(input, "prevhistory"))
else if (!strcasecmp(input, "older"))
s->func = get_history_older_void;
else if (!strcasecmp(input, "nexthistory"))
else if (!strcasecmp(input, "newer"))
s->func = get_history_newer_void;
#endif
#ifndef NANO_TINY

View File

@@ -183,37 +183,29 @@ 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_forward();
} 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_search_backward) {
do_search_backward();
bottombars(MHELP);
} 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);
@@ -421,6 +413,15 @@ void help_init(void)
"command.\n\n");
htx[2] = N_(" The following function keys are "
"available in Execute Command mode:\n\n");
} 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 */
else {
@@ -499,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;
@@ -528,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. */
@@ -574,10 +567,11 @@ 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 '/':

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

@@ -170,12 +170,10 @@ 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;
@@ -183,21 +181,15 @@ void do_para_begin(bool update_screen)
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;
@@ -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,18 +305,13 @@ 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;
@@ -366,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;
}
@@ -377,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
@@ -385,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).
@@ -545,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

@@ -502,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)
@@ -584,7 +578,7 @@ 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
@@ -721,6 +715,7 @@ void window_init(void)
#ifdef ENABLED_WRAPORJUSTIFY
/* Set up the wrapping point, accounting for screen width when negative. */
fill = wrap_at;
if (fill <= 0)
fill += COLS;
if (fill < 0)
@@ -805,8 +800,7 @@ void usage(void)
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"));
@@ -851,6 +845,7 @@ void usage(void)
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"));
@@ -858,7 +853,7 @@ void usage(void)
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
@@ -1263,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);
@@ -1361,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;
}
@@ -1540,9 +1526,12 @@ 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
@@ -1654,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;
@@ -1889,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 &&
@@ -2027,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'},
@@ -2090,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
@@ -2153,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
@@ -2196,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;
@@ -2247,7 +2245,7 @@ int main(int argc, char **argv)
#endif
#ifdef ENABLED_WRAPORJUSTIFY
case 'r':
if (!parse_num(optarg, &fill)) {
if (!parse_num(optarg, &wrap_at)) {
fprintf(stderr, _("Requested fill size \"%s\" is invalid"), optarg);
fprintf(stderr, "\n");
exit(1);
@@ -2311,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 fill_cpy = fill;
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
@@ -2367,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
@@ -2375,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)
fill = fill_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,
@@ -2433,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. */
@@ -2495,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);
}
@@ -2571,31 +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);
controldelete = get_keycode("kDC5", CONTROL_DELETE);
controlshiftdelete = get_keycode("kDC6", KEY_BACKSPACE);
#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);
@@ -2634,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))
@@ -2655,6 +2655,8 @@ int main(int argc, char **argv)
openfile = openfile->next;
if (more_than_one)
mention_name_and_linecount();
if (ISSET(VIEW_MODE))
SET(MULTIBUFFER);
}
#endif
@@ -2680,7 +2682,7 @@ int main(int argc, char **argv)
confirm_margin();
#endif
if (currmenu != MMAIN)
display_main_list();
bottombars(MMAIN);
lastmessage = HUSH;
as_an_at = 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, COUPLE_BEGIN, COUPLE_END, OTHER
ZAP, CUT, CUT_TO_EOF, PASTE, INSERT, COUPLE_BEGIN, COUPLE_END, OTHER
} undo_type;
/* Structure types. */
@@ -531,7 +531,7 @@ enum
BOLD_TEXT,
QUIET,
SOFTWRAP,
POS_HISTORY,
POSITIONLOG,
LOCKING,
NOREAD_MODE,
MAKE_IT_UNIX,
@@ -540,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. */
@@ -560,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
@@ -581,25 +582,32 @@ enum
#define CONTROL_DOWN 0x404
#define CONTROL_HOME 0x405
#define CONTROL_END 0x406
#define CONTROL_DELETE 0x407
#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

View File

@@ -446,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. */
@@ -534,9 +533,8 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
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);

View File

@@ -55,33 +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 controldelete;
extern int controlshiftdelete;
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, fill;
#endif
extern char *last_search;
@@ -183,6 +175,10 @@ extern char *statedir;
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);
/* Most functions in browser.c. */
@@ -251,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 marked, 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);
@@ -323,10 +319,6 @@ 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_linter_shortcut(void);
void set_speller_shortcut(void);
#endif
const subnfunc *sctofunc(const sc *s);
const char *flagtostr(int flag);
#ifdef ENABLE_NANORC
@@ -371,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
@@ -408,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);
@@ -433,7 +424,6 @@ 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
@@ -671,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);

View File

@@ -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
@@ -112,6 +112,7 @@ static const rcoption rcopts[] = {
{"whitespace", 0},
{"wordbounds", WORD_BOUNDS},
{"wordchars", 0},
{"zap", LET_THEM_ZAP},
#endif
#ifdef ENABLE_COLOR
{"titlecolor", 0},
@@ -451,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;
}
@@ -923,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;
@@ -1102,10 +1104,10 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
#endif
#ifdef ENABLED_WRAPORJUSTIFY
if (strcasecmp(rcopts[i].name, "fill") == 0) {
if (!parse_num(option, &fill)) {
if (!parse_num(option, &wrap_at)) {
rcfile_error(N_("Requested fill size \"%s\" is invalid"),
option);
fill = -COLUMNS_FROM_EOL;
wrap_at = -COLUMNS_FROM_EOL;
} else
UNSET(NO_WRAP);
free(option);

View File

@@ -155,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)
@@ -569,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;

View File

@@ -99,7 +99,13 @@ void do_deletion(undo_type action)
openfile->current_x);
#ifndef NANO_TINY
update_undo(action);
/* If the type of action changed or the cursor moved to a different
* line, create a new undo item, otherwise update the existing item. */
if (action != openfile->last_action ||
openfile->current->lineno != openfile->current_undo->lineno)
add_undo(action);
else
update_undo(action);
if (ISSET(SOFTWRAP))
old_amount = number_of_chunks_in(openfile->current);
@@ -177,6 +183,11 @@ void do_deletion(undo_type action)
/* Delete the character under the cursor. */
void do_delete(void)
{
#ifndef NANO_TINY
if (openfile->mark && ISSET(LET_THEM_ZAP))
zap_text();
else
#endif
do_deletion(DEL);
}
@@ -184,6 +195,11 @@ void do_delete(void)
* character, and then delete the character under the cursor. */
void do_backspace(void)
{
#ifndef NANO_TINY
if (openfile->mark && ISSET(LET_THEM_ZAP))
zap_text();
else
#endif
if (openfile->current != openfile->fileage || openfile->current_x > 0) {
do_left();
do_deletion(BACK);
@@ -210,7 +226,7 @@ void do_cutword(bool backward)
* on the edge of the original line, then put the cursor on that
* edge instead, so that lines will not be joined unexpectedly. */
if (backward) {
do_prev_word(ISSET(WORD_BOUNDS), FALSE);
do_prev_word(ISSET(WORD_BOUNDS));
if (openfile->current != is_current) {
if (is_current_x > 0) {
openfile->current = is_current;
@@ -219,7 +235,7 @@ void do_cutword(bool backward)
openfile->current_x = strlen(openfile->current->data);
}
} else {
do_next_word(FALSE, ISSET(WORD_BOUNDS), FALSE);
do_next_word(FALSE, ISSET(WORD_BOUNDS));
if (openfile->current != is_current &&
is_current->data[is_current_x] != '\0') {
openfile->current = is_current;
@@ -681,7 +697,7 @@ void redo_cut(undo *u)
openfile->mark = fsfromline(u->mark_begin_lineno);
openfile->mark_x = (u->xflags == WAS_WHOLE_LINE) ? 0 : u->mark_begin_x;
do_cut_text(FALSE, TRUE, FALSE);
do_cut_text(FALSE, TRUE, FALSE, u->type == ZAP);
free_filestruct(cutbuffer);
cutbuffer = oldcutbuffer;
@@ -786,6 +802,10 @@ void do_undo(void)
undidmsg = _("text add");
break;
#endif
case ZAP:
undidmsg = _("erasure");
undo_cut(u);
break;
case CUT_TO_EOF:
case CUT:
undidmsg = _("text cut");
@@ -962,6 +982,10 @@ void do_redo(void)
redidmsg = _("text add");
break;
#endif
case ZAP:
redidmsg = _("erasure");
redo_cut(u);
break;
case CUT_TO_EOF:
case CUT:
redidmsg = _("text cut");
@@ -1195,7 +1219,7 @@ bool execute_command(const char *command)
if (ISSET(MULTIBUFFER)) {
switch_to_prev_buffer();
if (openfile->mark)
do_cut_text(TRUE, TRUE, FALSE);
do_cut_text(TRUE, TRUE, FALSE, FALSE);
} else
#endif
{
@@ -1206,7 +1230,7 @@ bool execute_command(const char *command)
openfile->current_x = 0;
}
add_undo(CUT);
do_cut_text(FALSE, openfile->mark, openfile->mark == NULL);
do_cut_text(FALSE, openfile->mark, openfile->mark == NULL, FALSE);
update_undo(CUT);
}
@@ -1313,13 +1337,6 @@ void add_undo(undo_type action)
undo *u = openfile->current_undo;
/* The thing we did previously. */
/* When doing contiguous adds or cuts, don't add a new undo item. */
if (u != NULL && action == openfile->last_action && action == u->type &&
openfile->current->lineno == u->mark_begin_lineno &&
((action == ADD && u->mark_begin_x == openfile->current_x) ||
(action == CUT && keeping_cutbuffer())))
return;
/* Blow away newer undo items if we add somewhere in the middle. */
discard_until(u, openfile, TRUE);
@@ -1404,6 +1421,7 @@ void add_undo(undo_type action)
#endif
case CUT_TO_EOF:
break;
case ZAP:
case CUT:
if (openfile->mark) {
u->mark_begin_lineno = openfile->mark->lineno;
@@ -1474,23 +1492,14 @@ void update_multiline_undo(ssize_t lineno, char *indentation)
u->newsize = openfile->totsize;
}
/* Update an undo record, after checking that a new one is not needed. */
/* Update an undo item with (among other things) the file size and
* cursor position after the given action. */
void update_undo(undo_type action)
{
undo *u = openfile->undotop;
char *char_buf;
int char_len;
/* If the action is different or the position changed, don't update the
* current record but add a new one instead. */
if (action != openfile->last_action ||
(action != ENTER && action != CUT && action != INSERT &&
action != COUPLE_END &&
openfile->current->lineno != openfile->current_undo->lineno)) {
add_undo(action);
return;
}
u->newsize = openfile->totsize;
switch (u->type) {
@@ -1531,20 +1540,25 @@ void update_undo(undo_type action)
break;
case REPLACE:
case PASTE:
u->begin = openfile->current_x;
u->lineno = openfile->current->lineno;
u->begin = openfile->current_x;
break;
#ifdef ENABLE_WRAPPING
case SPLIT_BEGIN:
case SPLIT_END:
break;
#endif
case ZAP:
case CUT_TO_EOF:
case CUT:
if (!cutbuffer)
break;
free_filestruct(u->cutbuffer);
u->cutbuffer = copy_filestruct(cutbuffer);
if (u->type == ZAP)
u->cutbuffer = cutbuffer;
else {
free_filestruct(u->cutbuffer);
u->cutbuffer = copy_filestruct(cutbuffer);
}
if (u->xflags == MARK_WAS_SET) {
/* If the "marking" operation was from right-->left or
* bottom-->top, then swap the mark points. */
@@ -2145,7 +2159,7 @@ bool find_paragraph(size_t *const quote, size_t *const par)
/* If the current line isn't in a paragraph, move forward to the
* last line of the next paragraph, if any. */
if (!inpar(openfile->current)) {
do_para_end(FALSE);
do_para_end();
/* If we end up past the beginning of the line, it means that
* we're at the end of the last line of the file, and the line
@@ -2167,14 +2181,14 @@ bool find_paragraph(size_t *const quote, size_t *const par)
/* If the current line is in a paragraph and isn't its first line, move
* back to the first line of the paragraph. */
if (inpar(openfile->current) && !begpar(openfile->current, 0))
do_para_begin(FALSE);
do_para_begin();
/* Now current is the first line of the paragraph. Set quote_len to
* the quotation length of that line, and set par_len to the number
* of lines in this paragraph. */
quote_len = quote_length(openfile->current->data);
current_save = openfile->current;
do_para_end(FALSE);
do_para_end();
par_len = openfile->current->lineno - current_save->lineno;
/* If we end up past the beginning of the line, it means that we're at
@@ -2191,10 +2205,157 @@ bool find_paragraph(size_t *const quote, size_t *const par)
return TRUE;
}
/* Run every line of the current paragraph through justify_format(). Assume
* that current is at the beginning of the paragraph, quote_len is the length
* of the paragraph's quote string, and par_len is the number of lines in the
* paragraph. */
void justify_paragraph(size_t quote_len, size_t par_len)
{
filestruct *firstline;
/* The first line of the current paragraph. */
filestruct *sampleline;
/* The line from which the indentation is copied -- either
* the first and only or the second line of the paragraph. */
size_t lead_len;
/* Length of the quote part plus the indentation part. */
ssize_t break_pos;
/* Where we will break lines. */
char *lead_string;
/* The quote+indent stuff that is copied from the sample line. */
/* Remember the first line of the current paragraph. */
firstline = openfile->current;
/* The sample line is either the only line or the second line. */
sampleline = (par_len == 1 ? firstline : firstline->next);
/* Copy the leading part (quoting + indentation) of the sample line. */
lead_len = quote_len + indent_length(sampleline->data + quote_len);
lead_string = mallocstrncpy(NULL, sampleline->data, lead_len + 1);
lead_string[lead_len] = '\0';
/* Now tack all the lines of the paragraph together, skipping
* the quoting and indentation on all lines after the first. */
while (par_len > 1) {
filestruct *next_line = openfile->current->next;
size_t line_len = strlen(openfile->current->data);
size_t next_line_len = strlen(next_line->data);
lead_len = quote_len + indent_length(next_line->data + quote_len);
/* We're just about to tack the next line onto this one. If
* this line isn't empty, make sure it ends in a space. */
if (line_len > 0 && openfile->current->data[line_len - 1] != ' ') {
openfile->current->data =
charealloc(openfile->current->data, line_len + 2);
openfile->current->data[line_len++] = ' ';
openfile->current->data[line_len] = '\0';
openfile->totsize++;
}
openfile->current->data = charealloc(openfile->current->data,
line_len + next_line_len - lead_len + 1);
strcat(openfile->current->data, next_line->data + lead_len);
#ifndef NANO_TINY
/* If needed, adjust the coordinates of the mark. */
if (openfile->mark == next_line) {
openfile->mark = openfile->current;
openfile->mark_x += line_len - lead_len;
}
#endif
/* Don't destroy edittop! */
if (next_line == openfile->edittop)
openfile->edittop = openfile->current;
unlink_node(next_line);
openfile->totsize -= lead_len + 1;
par_len--;
}
/* Call justify_format() on the paragraph, which will remove excess
* spaces from it and change all blank characters to spaces. */
justify_format(openfile->current, quote_len +
indent_length(openfile->current->data + quote_len));
while (par_len > 0 && strlenpt(openfile->current->data) > fill) {
size_t line_len = strlen(openfile->current->data);
/* If this line is too long, try to wrap it to the next line
* to make it short enough. */
break_pos = break_line(openfile->current->data + lead_len,
fill - strnlenpt(openfile->current->data, lead_len), FALSE);
/* If we can't break the line, or don't need to, we're done. */
if (break_pos == -1 || break_pos + lead_len == line_len)
break;
/* Adjust the breaking position for the leading part and
* move it beyond the found whitespace character. */
break_pos += lead_len + 1;
/* Insert a new line after the current one and allocate it. */
splice_node(openfile->current, make_new_node(openfile->current));
openfile->current->next->data = charalloc(lead_len + 1 +
line_len - break_pos);
/* Copy the leading part and the text after the breaking point
* into the next line. */
strncpy(openfile->current->next->data, lead_string, lead_len);
strcpy(openfile->current->next->data + lead_len,
openfile->current->data + break_pos);
openfile->totsize += lead_len + 1;
par_len++;
#ifndef NANO_TINY
/* If needed, compensate the mark coordinates for the change
* in the current line. */
if (openfile->mark == openfile->current &&
openfile->mark_x > break_pos) {
openfile->mark = openfile->current->next;
openfile->mark_x -= break_pos - lead_len;
}
#endif
/* When requested, snip all trailing blanks. */
if (ISSET(TRIM_BLANKS)) {
while (break_pos > 0 &&
is_blank_mbchar(&openfile->current->data[break_pos - 1])) {
break_pos--;
openfile->totsize--;
}
}
/* Break the current line. */
null_at(&openfile->current->data, break_pos);
/* Go to the next line. */
openfile->current = openfile->current->next;
par_len--;
}
free(lead_string);
/* Go to the next line, if possible. If there is no next line,
* move to the end of the current line. */
if (openfile->current != openfile->filebot)
openfile->current = openfile->current->next;
else
openfile->current_x = strlen(openfile->current->data);
/* Renumber the now-justified paragraph, since both refreshing the
* edit window and finding a paragraph need correct line numbers. */
renumber(firstline);
}
/* Justify the current paragraph, and justify the entire file when
* full_justify is TRUE. */
void do_justify(bool full_justify)
{
size_t quote_len;
/* Length of the quote part of the current paragraph. */
size_t par_len;
/* Number of lines in the current paragraph. */
filestruct *first_par_line = NULL;
/* Will be the first line of the justified paragraph(s), if any.
* For restoring after unjustify. */
@@ -2228,200 +2389,47 @@ void do_justify(bool full_justify)
if (full_justify)
openfile->current = openfile->fileage;
while (TRUE) {
filestruct *firstline;
/* The first line of the current paragraph. */
filestruct *sampleline;
/* The line from which the indentation is copied -- either
* the first and only or the second line of the paragraph. */
size_t quote_len;
/* Length of the quote part of the current paragraph. */
size_t lead_len;
/* Length of the quote part plus the indentation part. */
size_t par_len;
/* Number of lines in the current paragraph. */
ssize_t break_pos;
/* Where we will break lines. */
char *lead_string;
/* The quote+indent stuff that is copied from the sample line. */
/* Find the first line of the paragraph(s) to be justified.
* If the search failed, it means that there are no paragraph(s) to
* justify, so refresh the screen and get out. */
if (!find_paragraph(&quote_len, &par_len)) {
refresh_needed = TRUE;
return;
}
/* Find the first line of the paragraph to be justified. That
* is the start of this paragraph if we're in one, or the start
* of the next otherwise. Save the quote length and paragraph
* length (number of lines). Don't refresh the screen yet,
* since we'll do that after we justify.
*
* If the search failed, we do one of two things. If we're
* justifying the whole file, and we've found at least one
* paragraph, it means that we should justify all the way to the
* last line of the file, so set the last line of the text to be
* justified to the last line of the file and break out of the
* loop. Otherwise, it means that there are no paragraph(s) to
* justify, so refresh the screen and get out. */
if (!find_paragraph(&quote_len, &par_len)) {
if (full_justify && first_par_line != NULL) {
last_par_line = openfile->filebot;
break;
} else {
refresh_needed = TRUE;
return;
}
}
/* Move the original paragraph(s)
* to the justify buffer, splice a copy of the original
* paragraph(s) into the file in the same place, and set
* first_par_line to the first line of the copy. */
backup_lines(openfile->current, full_justify ?
openfile->filebot->lineno - openfile->current->lineno +
((openfile->filebot->data[0] != '\0') ? 1 : 0) : par_len);
first_par_line = openfile->current;
/* Search for a paragraph(s) and justify them. If we're justifying the
* whole file, loop until we've found every paragraph. */
do {
/* par_len will be one greater than the number of lines between
* current and filebot if filebot is the last line in the
* paragraph. Set filebot_inpar to TRUE if this is the case. */
filebot_inpar = (openfile->current->lineno + par_len ==
openfile->filebot->lineno + 1);
/* If we haven't already done it, move the original paragraph(s)
* to the justify buffer, splice a copy of the original
* paragraph(s) into the file in the same place, and set
* first_par_line to the first line of the copy. */
if (first_par_line == NULL) {
backup_lines(openfile->current, full_justify ?
openfile->filebot->lineno - openfile->current->lineno +
((openfile->filebot->data[0] != '\0') ? 1 : 0) : par_len);
first_par_line = openfile->current;
}
/* Justify the current paragraph. */
justify_paragraph(quote_len, par_len);
/* Remember the first line of the current paragraph. */
firstline = openfile->current;
/* If we're justifying the entire file,
* find the next line of the paragraph(s) to be justified.
* If the search failed, it means that there are no paragraph(s) to
* justify, so break out of the loop. */
} while (full_justify && find_paragraph(&quote_len, &par_len));
/* The sample line is either the only line or the second line. */
sampleline = (par_len == 1 ? firstline : firstline->next);
/* Copy the leading part (quoting + indentation) of the sample line. */
lead_len = quote_len + indent_length(sampleline->data + quote_len);
lead_string = mallocstrncpy(NULL, sampleline->data, lead_len + 1);
lead_string[lead_len] = '\0';
/* Now tack all the lines of the paragraph together, skipping
* the quoting and indentation on all lines after the first. */
while (par_len > 1) {
filestruct *next_line = openfile->current->next;
size_t line_len = strlen(openfile->current->data);
size_t next_line_len = strlen(next_line->data);
lead_len = quote_len + indent_length(next_line->data + quote_len);
/* We're just about to tack the next line onto this one. If
* this line isn't empty, make sure it ends in a space. */
if (line_len > 0 && openfile->current->data[line_len - 1] != ' ') {
openfile->current->data =
charealloc(openfile->current->data, line_len + 2);
openfile->current->data[line_len++] = ' ';
openfile->current->data[line_len] = '\0';
openfile->totsize++;
}
openfile->current->data = charealloc(openfile->current->data,
line_len + next_line_len - lead_len + 1);
strcat(openfile->current->data, next_line->data + lead_len);
#ifndef NANO_TINY
/* If needed, adjust the coordinates of the mark. */
if (openfile->mark == next_line) {
openfile->mark = openfile->current;
openfile->mark_x += line_len - lead_len;
}
#endif
/* Don't destroy edittop! */
if (next_line == openfile->edittop)
openfile->edittop = openfile->current;
unlink_node(next_line);
openfile->totsize -= lead_len + 1;
par_len--;
}
/* Call justify_format() on the paragraph, which will remove excess
* spaces from it and change all blank characters to spaces. */
justify_format(openfile->current, quote_len +
indent_length(openfile->current->data + quote_len));
while (par_len > 0 && strlenpt(openfile->current->data) > fill) {
size_t line_len = strlen(openfile->current->data);
/* If this line is too long, try to wrap it to the next line
* to make it short enough. */
break_pos = break_line(openfile->current->data + lead_len,
fill - strnlenpt(openfile->current->data, lead_len), FALSE);
/* If we can't break the line, or don't need to, we're done. */
if (break_pos == -1 || break_pos + lead_len == line_len)
break;
/* Adjust the breaking position for the leading part and
* move it beyond the found whitespace character. */
break_pos += lead_len + 1;
/* Insert a new line after the current one and allocate it. */
splice_node(openfile->current, make_new_node(openfile->current));
openfile->current->next->data = charalloc(lead_len + 1 +
line_len - break_pos);
/* Copy the leading part and the text after the breaking point
* into the next line. */
strncpy(openfile->current->next->data, lead_string, lead_len);
strcpy(openfile->current->next->data + lead_len,
openfile->current->data + break_pos);
openfile->totsize += lead_len + 1;
par_len++;
#ifndef NANO_TINY
/* If needed, compensate the mark coordinates for the change
* in the current line. */
if (openfile->mark == openfile->current &&
openfile->mark_x > break_pos) {
openfile->mark = openfile->current->next;
openfile->mark_x -= break_pos - lead_len;
}
#endif
/* When requested, snip all trailing blanks. */
if (ISSET(TRIM_BLANKS)) {
while (break_pos > 0 &&
is_blank_mbchar(&openfile->current->data[break_pos - 1])) {
break_pos--;
openfile->totsize--;
}
}
/* Break the current line. */
null_at(&openfile->current->data, break_pos);
/* Go to the next line. */
openfile->current = openfile->current->next;
par_len--;
}
free(lead_string);
/* Go to the next line, if possible. If there is no next line,
* move to the end of the current line. */
if (openfile->current != openfile->filebot)
openfile->current = openfile->current->next;
else
openfile->current_x = strlen(openfile->current->data);
/* Renumber the now-justified paragraph, since both refreshing the
* edit window and finding a paragraph need correct line numbers. */
renumber(firstline);
/* We've just finished justifying the paragraph. If we're not
* justifying the entire file, break out of the loop.
* Otherwise, continue the loop so that we justify all the
* paragraphs in the file. */
if (!full_justify)
break;
}
/* We are now done justifying the paragraph or the file, so clean
* up. totsize has been maintained above. If we actually justified
* something, set last_par_line to the new end of the paragraph. */
if (first_par_line != NULL)
last_par_line = openfile->current;
/* We are now done justifying the paragraph(s), so clean
* up. totsize has been maintained above.
* Set last_par_line to the end of the paragraph(s) justified.
* If we've justified the entire file and broken out of the loop,
* this should be the last line of the file. */
last_par_line = openfile->current;
#ifndef NANO_TINY
/* Let a justification cancel a soft mark. */
@@ -2433,7 +2441,7 @@ void do_justify(bool full_justify)
/* Show "Unjustify" in the help lines. */
uncutfunc->desc = unjust_tag;
display_main_list();
bottombars(MMAIN);
#ifndef NANO_TINY
kbinput = KEY_WINCH;
@@ -2458,35 +2466,33 @@ void do_justify(bool full_justify)
|| func == do_undo
#endif
) {
/* If we actually justified something, then splice the preserved
/* Splice the preserved
* unjustified text back into the file, */
if (first_par_line != NULL) {
filestruct *trash = NULL, *dummy = NULL;
filestruct *trash = NULL, *dummy = NULL;
/* Throw away the justified paragraph, and replace it with
* the preserved unjustified text. */
extract_buffer(&trash, &dummy, first_par_line, 0, last_par_line,
/* Throw away the justified paragraph, and replace it with
* the preserved unjustified text. */
extract_buffer(&trash, &dummy, first_par_line, 0, last_par_line,
filebot_inpar ? strlen(last_par_line->data) : 0);
free_filestruct(trash);
ingraft_buffer(jusbuffer);
free_filestruct(trash);
ingraft_buffer(jusbuffer);
/* Restore the old position and the mark. */
openfile->edittop = edittop_save;
openfile->firstcolumn = firstcolumn_save;
openfile->current = current_save;
openfile->current_x = current_x_save;
/* Restore the old position and the mark. */
openfile->edittop = edittop_save;
openfile->firstcolumn = firstcolumn_save;
openfile->current = current_save;
openfile->current_x = current_x_save;
#ifndef NANO_TINY
if (openfile->mark) {
openfile->mark = was_mark;
openfile->mark_x = was_mark_x;
}
#endif
openfile->modified = modified_save;
if (!openfile->modified)
titlebar(NULL);
refresh_needed = TRUE;
if (openfile->mark) {
openfile->mark = was_mark;
openfile->mark_x = was_mark_x;
}
#endif
openfile->modified = modified_save;
if (!openfile->modified)
titlebar(NULL);
refresh_needed = TRUE;
} else {
/* Put the keystroke back into the queue. */
unget_kbinput(kbinput, meta_key);
@@ -2602,23 +2608,24 @@ bool fix_spello(const char *word)
proceed = TRUE;
napms(2800);
} else if (result == 1) {
size_t from_col = xplustabs();
size_t to_col = from_col + strlenpt(word);
spotlighted = TRUE;
light_from_col = xplustabs();
light_to_col = light_from_col + strlenpt(word);
#ifndef NANO_TINY
filestruct *saved_mark = openfile->mark;
openfile->mark = NULL;
#endif
edit_refresh();
#ifndef NANO_TINY
openfile->mark = saved_mark;
#endif
spotlight(TRUE, from_col, to_col);
/* Let the user supply a correctly spelled alternative. */
proceed = (do_prompt(FALSE, FALSE, MSPELL, word, NULL,
edit_refresh, _("Edit a replacement")) != -1);
spotlight(FALSE, from_col, to_col);
spotlighted = FALSE;
#ifndef NANO_TINY
openfile->mark = saved_mark;
#endif
/* If a replacement was given, go through all occurrences. */
if (proceed && strcmp(word, answer) != 0) {
@@ -2881,11 +2888,6 @@ const char *do_alt_speller(char *tempfile_name)
} else if (pid_spell < 0)
return _("Could not fork");
#ifndef NANO_TINY
/* Block SIGWINCHes so the spell checker doesn't get any. */
allow_sigwinch(FALSE);
#endif
/* Wait for the alternate spell checker to finish. */
wait(&alt_spell_status);
@@ -2940,11 +2942,6 @@ const char *do_alt_speller(char *tempfile_name)
adjust_viewport(STATIONARY);
}
#ifndef NANO_TINY
/* Unblock SIGWINCHes again. */
allow_sigwinch(TRUE);
#endif
return NULL;
}
@@ -2957,7 +2954,7 @@ void do_spell(void)
char *temp;
unsigned stash[sizeof(flags) / sizeof(flags[0])];
/* A storage place for the current flag settings. */
const char *spell_msg;
const char *result_msg;
if (ISSET(RESTRICTED)) {
show_restricted_warning();
@@ -2991,10 +2988,9 @@ void do_spell(void)
}
blank_bottombars();
statusbar(_("Invoking spell checker, please wait"));
spell_msg = (alt_speller != NULL) ? do_alt_speller(temp) :
do_int_speller(temp);
result_msg = (alt_speller ? do_alt_speller(temp) : do_int_speller(temp));
unlink(temp);
free(temp);
@@ -3005,12 +3001,12 @@ void do_spell(void)
* sure that they're cleared off. */
total_refresh();
if (spell_msg != NULL) {
if (result_msg != NULL) {
if (errno == 0)
/* Don't display an error message of "Success". */
statusline(ALERT, _("Spell checking failed: %s"), spell_msg);
statusline(ALERT, _("Spell checking failed: %s"), result_msg);
else
statusline(ALERT, _("Spell checking failed: %s: %s"), spell_msg,
statusline(ALERT, _("Spell checking failed: %s: %s"), result_msg,
strerror(errno));
} else
statusbar(_("Finished checking spelling"));
@@ -3027,8 +3023,10 @@ void do_linter(void)
size_t parsesuccess = 0;
int lint_status, lint_fd[2];
pid_t pid_lint;
bool helpless = ISSET(NO_HELP);
static char **lintargs = NULL;
lintstruct *lints = NULL, *tmplint = NULL, *curlint = NULL;
time_t last_wait = 0;
if (ISSET(RESTRICTED)) {
show_restricted_warning();
@@ -3200,7 +3198,15 @@ void do_linter(void)
return;
}
if (helpless && LINES > 4) {
UNSET(NO_HELP);
window_init();
}
/* Show that we are in the linter now. */
titlebar(NULL);
bottombars(MLINTER);
tmplint = NULL;
curlint = lints;
@@ -3228,11 +3234,12 @@ void do_linter(void)
sprintf(msg, _("This message is for unopened file %s,"
" open it in a new buffer?"), curlint->filename);
i = do_yesno_prompt(FALSE, msg);
currmenu = MLINTER;
free(msg);
if (i == -1) {
statusbar(_("Cancelled"));
goto free_lints_and_return;
break;
} else if (i == 1) {
open_buffer(curlint->filename, TRUE);
} else {
@@ -3263,8 +3270,7 @@ void do_linter(void)
free(dontwantfile);
if (restlint == NULL) {
statusbar(_("No more errors in unopened files, cancelling"));
napms(2400);
statusbar(_("No messages for this file"));
break;
} else {
curlint = restlint;
@@ -3284,7 +3290,7 @@ void do_linter(void)
confirm_margin();
#endif
edit_refresh();
statusbar(curlint->msg);
statusline(NOTICE, curlint->msg);
bottombars(MLINTER);
}
@@ -3301,29 +3307,33 @@ void do_linter(void)
func = func_from_key(&kbinput);
tmplint = curlint;
if (func == do_cancel)
if (func == do_cancel || func == do_enter) {
wipe_statusbar();
break;
else if (func == do_help_void) {
} else if (func == do_help_void) {
tmplint = NULL;
do_help_void();
} else if (func == do_page_down) {
if (curlint->next != NULL)
curlint = curlint->next;
else
statusbar(_("At last message"));
} else if (func == do_page_up) {
} else if (func == do_page_up || func == do_prev_block) {
if (curlint->prev != NULL)
curlint = curlint->prev;
else
else if (last_wait != time(NULL)) {
statusbar(_("At first message"));
napms(600);
last_wait = time(NULL);
statusline(NOTICE, curlint->msg);
}
} else if (func == do_page_down || func == do_next_block) {
if (curlint->next != NULL)
curlint = curlint->next;
else if (last_wait != time(NULL)) {
statusbar(_("At last message"));
napms(600);
last_wait = time(NULL);
statusline(NOTICE, curlint->msg);
}
}
}
wipe_statusbar();
#ifdef ENABLE_MULTIBUFFER
free_lints_and_return:
#endif
for (curlint = lints; curlint != NULL;) {
tmplint = curlint;
curlint = curlint->next;
@@ -3331,6 +3341,15 @@ void do_linter(void)
free(tmplint->filename);
free(tmplint);
}
if (helpless) {
SET(NO_HELP);
window_init();
refresh_needed = TRUE;
}
currmenu = MMOST;
titlebar(NULL);
}
#endif /* ENABLE_COLOR */
@@ -3368,7 +3387,7 @@ void do_wordlinechar_count(void)
* count whenever we're on a word just before moving. */
while (openfile->current != openfile->filebot ||
openfile->current->data[openfile->current_x] != '\0') {
if (do_next_word(FALSE, TRUE, FALSE))
if (do_next_word(FALSE, TRUE))
words++;
}

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;
}

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;
@@ -538,12 +533,18 @@ int parse_kbinput(WINDOW *win)
return CONTROL_HOME;
else if (retval == controlend)
return CONTROL_END;
#ifndef NANO_TINY
else if (retval == controldelete)
return CONTROL_DELETE;
#ifndef NANO_TINY
else if (retval == controlshiftdelete)
return the_code_for(do_cut_prev_word, KEY_BACKSPACE);
else if (retval == shiftcontrolleft) {
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) {
@@ -569,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;
@@ -589,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) {
@@ -707,13 +726,8 @@ int parse_kbinput(WINDOW *win)
return KEY_NPAGE;
#ifdef KEY_SDC /* Slang doesn't support KEY_SDC. */
case KEY_SDC:
return KEY_BACKSPACE;
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);
@@ -1096,17 +1110,33 @@ int convert_sequence(const int *seq, size_t length, int *consumed)
if (length > 2 && seq[2] == '~')
return KEY_DC;
if (length > 4 && seq[2] == ';' && seq[4] == '~') {
/* Esc [ 3 ; x ~ == modified Delete on xterm. */
*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
}
if (length > 2 && seq[2] == '^') {
#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. */
*consumed = 3;
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. */
@@ -1310,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);
}
}
@@ -1485,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;
}
@@ -1755,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;
}
@@ -2051,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:");
@@ -2209,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;
@@ -2763,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;
}
@@ -2829,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
@@ -3331,20 +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->linter)
set_linter_shortcut();
else
set_speller_shortcut();
#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. */
@@ -3405,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;
@@ -3416,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
@@ -3438,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);
@@ -3455,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);
@@ -3485,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);

View File

@@ -19,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

@@ -3,7 +3,7 @@
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

@@ -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

@@ -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

@@ -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

@@ -5,7 +5,7 @@ syntax nanohelp
# Key combos:
color cyan "\^[]4-8A-Z^\_◀▶▲▼]" "[◀▶▲▼]" "\<M-." "\<F1?[0-9]"
color cyan "\<(Tab|Sh-Tab|Enter|Ins|Del|Space|Bsp|Up|Down|Left|Right|Home|End|PgUp|PgDn)\>"
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,15 +4,15 @@ syntax nanorc "\.?nanorc$"
comment "#"
# Possible errors and parameters
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|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:]]|[]@\^_]|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:]]*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)\>"
@@ -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

@@ -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

@@ -10,9 +10,14 @@ 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)\>"
@@ -21,7 +26,7 @@ color brightmagenta "\<(False|None|True)\>"
color brightgreen "'([^'\]|\\.)+'"
color brightgreen ""([^"\]|\\.)+""
# Comments.
color brightred "(^|[[:blank:]])#.*$"
color brightred "(^|[[:blank:]])#.*"
# Triple-quoted strings.
color brightgreen start="'''([^'),]|$)" end="(^|[^(\])'''"
color brightgreen start="\"\"\"([^"),]|$)" end="(^|[^(\])\"\"\""

View File

@@ -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

@@ -1,7 +1,7 @@
## Here is an example for Bourne shell scripts.
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)|openrc-run|runscript)"
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

@@ -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:]]+$"