Compare commits

...

1415 Commits
v4.8 ... v6.1

Author SHA1 Message Date
Benno Schulenberg
e4ecd03e3f po: update translations and regenerate POT file and PO files 2022-02-09 11:53:47 +01:00
Benno Schulenberg
a6dc5c963c bump version numbers and add a news item for the 6.1 release 2022-02-09 11:31:03 +01:00
Benno Schulenberg
989e6a9a7e tweaks: rename two variables, and elide a near-enough duplicate
(The 'in_edit' variable was a duplicate because also when the pointer is
on the line numbers, we want to scroll when the mouse wheel is rolled.)
2022-02-04 15:51:40 +01:00
Benno Schulenberg
c28048d20f tweaks: rename another variable, to better fit in with its sisters 2022-02-04 12:17:37 +01:00
Benno Schulenberg
a24e72f972 tweaks: rename a variable, to make it clearer it refers to a window 2022-02-04 12:11:05 +01:00
Benno Schulenberg
a29aa31e93 tweaks: when discarding keycodes, don't bother parsing them 2022-02-04 11:18:52 +01:00
Benno Schulenberg
8546139997 build: fix compilation when configured with --enable-tiny
Problem existed since commit 3b657a26 from five days ago.

In addition, exclude pasting-at-the-prompt from the tiny version, as
it's hardly useful when one cannot copy a selected piece of text.
2022-02-03 13:06:21 +01:00
Benno Schulenberg
a61586947e gnulib: update to its current upstream state 2022-02-03 11:20:08 +01:00
Benno Schulenberg
5e4645b082 copyright: update the last year for significantly changed files 2022-02-02 17:40:25 +01:00
Benno Schulenberg
f9f0a8fd67 copyright: update the years for the FSF 2022-02-02 17:10:09 +01:00
Benno Schulenberg
637a2eeb66 tweaks: rename a variable and a parameter, to be more descriptive
Also, improve two comments, to describe what the functions actually do.
2022-02-01 12:22:29 +01:00
Benno Schulenberg
13caef2de0 tweaks: remove two redundant checks
The checks have been there for fifteen months, and no one ever reported
seeing those messages.
2022-02-01 12:21:31 +01:00
Benno Schulenberg
61c6d43231 tweaks: adjust a translator hint, to fit the order in the POT file
Also, reword another hint.
2022-02-01 11:38:55 +01:00
Benno Schulenberg
a04f6e0165 help: update the description of M-D, to match the actual order of counts 2022-02-01 11:16:07 +01:00
Benno Schulenberg
3f494e359d tweaks: stop asking the terminal for its new size -- let ncurses do it
When re-entering curses mode, ncurses will pick up the new size of
the terminal and set the LINES and COLS variables appropriately.

(We don't ask the terminal for its size when nano starts up, so why
would we need to do it when the terminal is resized?)
2022-01-31 16:53:35 +01:00
Benno Schulenberg
8a06f70379 tweaks: rename a function and reshuffle its call 2022-01-31 12:31:03 +01:00
Benno Schulenberg
2290152743 menus: don't show M-6 in the help lines of any prompt
None of the editing keystrokes are shown in the menus -- they are
all "blind" keys.  This corrects a mistake in the previous commit.
2022-01-31 10:48:14 +01:00
Benno Schulenberg
3b657a26a6 prompt: allow the user to copy the answer to the cutbuffer (with M-6)
Since version 2.8.7 the user can paste text at the prompt (with ^U),
but the ability to copy what is present at the prompt was overlooked.

For feedback, the cursor is moved to the start of the answer -- like
it moves to the start of the next line when in the edit buffer.

This addresses https://savannah.gnu.org/bugs/?61702.
Reported-by: Tasos Papastylianou <tpapastylianou@hotmail.com>
2022-01-30 17:39:55 +01:00
Benno Schulenberg
ff5084479b prompt: let ^K erase text after cursor (if any), otherwise whole answer
In most cases, the cursor will be at the end of what the user typed
at the prompt (or retrieved from history), and ^K will work as it
always did, erasing the whole answer.  But if the user has moved the
cursor to somewhere in the middle of the answer, a ^K will now erase
just the part after the cursor.  A second ^K will erase the rest.

Inspired-by: Tasos Papastylianou <tpapastylianou@hotmail.com>
2022-01-29 17:23:42 +01:00
Benno Schulenberg
97f4a3f4eb tweaks: rename a variable, away from an abbreviation 2022-01-29 17:14:22 +01:00
Benno Schulenberg
1ca1732d32 tweaks: remove a redundant check -- add a different one for symmetry
Function get_input() with a non-null parameter will never return ERR.
2022-01-29 16:32:04 +01:00
Benno Schulenberg
accd2308f1 tweaks: reword two comments, and rename a variable (away from an abbrev) 2022-01-29 16:01:35 +01:00
Benno Schulenberg
10eec2fe17 input: suppress any spotlighting when there are more keycodes waiting
Because doing the spotlighting after those extra keycodes have been
handled will most likely spotlight the wrong piece of text.  Also,
if those keycodes hadn't arrived early, the first of them would have
cancelled the spotlighting.

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

Bug existed since version 5.8, commit 3f340836.
2022-01-29 11:16:41 +01:00
Benno Schulenberg
d69cd759cb input: instead of moving waiting keycodes, just increment a pointer
When a large piece of text was pasted into nano, then the old way of
repeatedly moving the buffered text one more position toward the head
of the keystroke buffer would waste a lot of time.  With this change,
pasting the current NEWS file into a buffer goes down (on my machine)
from around 30 seconds to just 2.

This addresses https://savannah.gnu.org/bugs/?61822.
Reported-by: Radu Caragea <rcaragea@protonmail.com>

Problem existed in this form since version 1.3.6, commit 7483571f.
2022-01-27 10:41:24 +01:00
Benno Schulenberg
f261a8aca5 tweaks: rename a function, to not contain the name of a variable 2022-01-27 09:21:21 +01:00
Benno Schulenberg
bdf64d660b tweaks: rename a variable, for clarity and contrast 2022-01-27 09:21:21 +01:00
Benno Schulenberg
2fd30ee095 tweaks: rename a function and its two parameters, for clarity 2022-01-25 12:23:14 +01:00
Benno Schulenberg
9bc6f1797e tweaks: use some symbolic names instead of unclear numeric values 2022-01-25 11:57:34 +01:00
Benno Schulenberg
32e63fe1b8 tweaks: add some small, clarifying comments
Suggested-by: Tasos Papastylianou <tpapastylianou@hotmail.com>
2022-01-22 13:12:55 +01:00
Benno Schulenberg
1c074cc8cc files: let ^C cancel the exiting when the file on disk was changed
When the user exits with ^X and gets warned that the file on disk
has changed, then typing ^C at the question whether to continue
saving should not discard the buffer and exit, but should return
the user to the filename prompt.

This fixes https://savannah.gnu.org/bugs/?61883.
Reported-by: Tasos Papastylianou <tpapastylianou@hotmail.com>

Bug existed since version 2.9.0, commit 217cfbf3.
2022-01-22 12:30:15 +01:00
Benno Schulenberg
ebf6228f21 tweaks: add some feedback to the autogen.sh script, to ease the wait 2021-12-28 15:31:23 +01:00
Benno Schulenberg
4a1db96db8 build: prevent autopoint from overwriting a newer M4 file from gnulib
For some reason, 'autopoint' (invoked by 'autoreconf') insists on
overwriting 'extern-inline.m4', even though the version from gnulib
is newer and contains a fix for a build issue on macOS with GCC 11.

So, do as the documentation says, and invoke 'autopoint' before
'gnulib-tool' (and call 'aclocal' to 'automake' afterwards).

  https://www.gnu.org/software/gnulib/manual/html_node/gettextize-and-autopoint.html

This fixes https://savannah.gnu.org/bugs/?61719.
Reported-by: Sam James <sam@cmpct.info>
2021-12-28 15:08:45 +01:00
Benno Schulenberg
16ee4636bc tweaks: reshuffle some sample bindings, to group them differently 2021-12-26 17:44:42 +01:00
Benno Schulenberg
6831b37b43 tweaks: drop foreign M-U and M-R from among the sample CUA bindings
M-U and M-R are not usual bindings for Undo and Redo.
2021-12-26 17:35:30 +01:00
Benno Schulenberg
4d16f26ba4 help: make the description of <Tab> more accurate
And don't mention <Tab> for the 'indent' function, as the keystroke
is equivalent to M-} only when lines are marked.

Reported-by: Tasos Papastylianou <tpapastylianou@hotmail.com>
2021-12-26 11:57:57 +01:00
Benno Schulenberg
4a7bc73e03 docs: mention 'set guidestripe' and 'set unix' in the sample nanorc
Somehow these entries were missed when those options were added.

Reported-by: Tasos Papastylianou <tpapastylianou@hotmail.com>
2021-12-24 17:38:10 +01:00
Benno Schulenberg
caf583ec4b docs: mention bindable function 'zero', for toggling the interface bars
This should have been part of commit a623f583 from six weeks ago.

Reported-by: Tasos Papastylianou <tpapastylianou@hotmail.com>
2021-12-23 16:14:21 +01:00
Benno Schulenberg
e20880da21 docs: remove obsolete Ctrl+Z from the cheatsheet; mention Alt+X instead
This should have been part of commit d0c2c1e6 from seven weeks ago.

Reported-by: Tasos Papastylianou <tpapastylianou@hotmail.com>
2021-12-23 15:48:15 +01:00
Benno Schulenberg
19ff9a507b po: update translations and regenerate POT file and PO files 2021-12-15 12:28:29 +01:00
Benno Schulenberg
33ba6be91f bump version numbers and add a news item for the 6.0 release 2021-12-15 12:04:56 +01:00
Benno Schulenberg
9c1c6c18ae docs: explain what it means when --rawsequences is needed 2021-12-13 16:45:42 +01:00
Benno Schulenberg
fae5f823e1 input: ensure that no more bytes are consumed than are available
The value of 'consumed' may not exceed the given 'length'.

Bug existed since version 2.9.3, commit e739448c.

(Bug was found by studying Fedora crash reports.  Thank you, Fedora!)
2021-12-12 16:45:09 +01:00
Benno Schulenberg
bdf8e41a72 syntax: nanorc: colorize each of the fourteen new color names as valid 2021-12-12 12:01:45 +01:00
Benno Schulenberg
c00c12b64b docs: list the new color names, from 'rosy' to 'crimson' 2021-12-12 12:01:45 +01:00
Benno Schulenberg
02d77ad5ad rcfile: recognize fourteen new color names, mostly for subdued shades
This is for people for whom the #rgb color codes are too cryptic.
2021-12-12 12:01:45 +01:00
Benno Schulenberg
7ab903f072 syntax: debian: remove file -- Debian itself will have to handle it
The syntax is useful only for users of Debian and its derivatives.
2021-12-12 11:45:21 +01:00
Benno Schulenberg
266ed0612f syntax: gentoo: remove file -- Gentoo itself will have to handle it
The file contained two syntaxes (each of them fairly large) that are
useful only for Gentoo users.  I don't think the file should have been
distributed with nano ever, as the syntaxes are just a dead weight for
the users of all other distributions.
2021-12-12 11:34:19 +01:00
Benno Schulenberg
27af34a853 syntax: default: colorize comments as one of the last things
So that URLs in comments don't get specially colored.
2021-12-10 12:32:17 +01:00
Benno Schulenberg
abafc2ba14 tweaks: reduce redundancy (--enable-color implies --enable-nanorc)
(To make use of color, syntaxes are needed,
and syntaxes require a nanorc for their definition.)
2021-12-08 12:11:10 +01:00
Benno Schulenberg
1f0eb8d915 build: fix compilation with --enable-tiny --enable-nanorc 2021-12-08 12:06:33 +01:00
Benno Schulenberg
48a19178b8 build: fix compilation when configured with --disable-color 2021-12-08 10:00:13 +01:00
Benno Schulenberg
e542e5943e build: fix compilation when configured with --disable-nanorc 2021-12-08 09:46:02 +01:00
Benno Schulenberg
44836e77be syntax: nanorc: colorize a trailing comment when it begins with non-hex
That is: colorize text after a blank-plus-hash as a comment when there
is at least one non-hexadecimal character among the first three.

This relaxes the demand that a trailing comment should have a blank
after the hash too, as implemented by commit 90946c5e two weeks ago.
2021-12-07 16:51:35 +01:00
Benno Schulenberg
5cec57719b syntax: sql: add a few more missing keywords, like TRUE and FALSE
Also, don't first scare-color stuff between double quotes, as it
seems some dialects put certain calculations between them too.
2021-12-07 12:27:11 +01:00
Benno Schulenberg
d6f101daef syntax: sql: colorize keywords regardless of case, and tweak the colors
Make types a bluish green, for more contrast with strings, so that the
latter can be made greener, for more contrast with the yellow keywords.
Make the main keywords bluer and less bright, and unbold and soften the
yellow ones.  Soften the comments too.

Reference for case-insensitivity:
  https://www.postgresql.org/docs/14/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
2021-12-07 10:21:23 +01:00
Benno Schulenberg
350cdd9827 syntax: sql: colorize strings differently than types
Also, colorize comments more readably (on a dark background), and
schemas less yelling, and languages more distinct from keywords.

And add a few more keywords, like IS and NULL.
2021-12-04 12:13:19 +01:00
Benno Schulenberg
5dc48d54f2 syntax: sql: add more missing keywords, like INNER and OUTER JOIN
Also, fold two other regexes together, for conciseness.
2021-12-03 12:52:05 +01:00
Benno Schulenberg
41975265bf syntax: sql: add some missing keywords, like ALL and ANY and OR
Also, combine some keywords that can only occur together.
And drop a few that are probably rare, like LARGE OBJECT.

Reference:
  https://www.postgresql.org/docs/14/bookindex.html

And use a more readable color -- blue is too dark on a black base.
2021-12-03 12:21:17 +01:00
Benno Schulenberg
598f13107d syntax: sql: add two missing data types -- xml and tsquery
References:
  https://www.postgresql.org/docs/14/datatype-xml.html
  https://www.postgresql.org/docs/14/datatype-textsearch.html#DATATYPE-TSQUERY
2021-12-03 12:21:17 +01:00
Benno Schulenberg
248ebf9117 syntax: sql: colorize only single-quoted things as strings
SQL does not know double-quoted strings.  Double quotes can be used
around identifiers, to prevent them being interpreted as keywords.

References:
  https://www.postgresql.org/docs/14/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS
  https://www.postgresql.org/docs/14/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
2021-12-03 12:21:17 +01:00
Benno Schulenberg
1c6f6ba212 tweaks: rename three parameters, away from single letters
Also, reshuffle two lines, to have the code after the declaration.
2021-12-03 12:19:58 +01:00
Benno Schulenberg
58cba6a7c6 tweaks: move a translator hint to where xgettext will see it
A translator hint needs to be placed on the line directly before
the relevant string.
2021-12-02 11:02:56 +01:00
Benno Schulenberg
b55474788b gnulib: update to its current upstream state 2021-12-02 10:24:29 +01:00
Benno Schulenberg
5c8de3e39f tweaks: put three email addresses between the customary angled brackets
So they will get colored by the default syntax.
2021-11-30 10:34:51 +01:00
Benno Schulenberg
8aaa57a573 syntax: default: colorize dates, URLs, and nano's release motto
And change the color for control codes, to be more visible.
2021-11-30 10:32:08 +01:00
Benno Schulenberg
19e743c7e4 tweaks: condense the regexes for Types in the SQL syntax 2021-11-30 10:11:21 +01:00
Benno Schulenberg
56aacb3e32 syntax: sql: colorize as flow control only keywords that clearly are such
Drop things that were recolored afterward (like CLASS and DEFAULT).
Also, move these coloring rules to after the other keywords so that
things like "END IF" will stay colored as a whole.

Reference:
  https://www.postgresql.org/docs/current/plpgsql-control-structures.html
2021-11-30 10:11:21 +01:00
Benno Schulenberg
f2c9aed16c syntax: sql: remove alien stuff -- it was copied mostly from ruby syntax
Regular expressions in SQL are not written between // or %r{},
strings are not written between <> or %Q{} or anything similar,
and comments do not start with # -- and officially not with //
either, but some dialects seem to allow it.

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

Bug existed since version 2.4.2, since the SQL syntax was included.
2021-11-30 10:11:21 +01:00
Benno Schulenberg
7c6d3942c4 tweaks: rewrap an old news item, for distraction 2021-11-29 11:24:04 +01:00
Benno Schulenberg
27aff84f74 syntax: nanorc: paint arguments of 'include' and 'extendsyntax' specially
The path after 'include' is not a regex and does not need to be quoted;
when it's unquoted, colorize it specially, instead of leaving it red.

The syntax name after 'extendsyntax' should be brightgreen, like after
'syntax', but it's better that the subsequent commands have their own
special color.
2021-11-29 11:18:15 +01:00
Benno Schulenberg
a43ee17ad0 docs: document the effect of --quickblank together with --zero/--minibar 2021-11-29 10:47:49 +01:00
Benno Schulenberg
abd4c47acf feedback: when reporting an unbound function key, mention its number
This makes it easier to figure out what to put in their nanorc file
when the user wants to bind the key.
2021-11-28 15:43:54 +01:00
Benno Schulenberg
b87722ab2d feedback: report an unbindable function key as an "Unknown sequence"
Saying "Unbound key" would imply that it could be bound in a nanorc.

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

Bug existed in this form since version 2.6.0, commit e0c4f9c5.
2021-11-28 12:31:36 +01:00
Benno Schulenberg
b5448615b9 display: redraw the screen in tiny version upon resuming from suspension
Letting the dummy key KEY_FRESH do a full refresh in the tiny version
allows a 'fg' to properly resume after an external SIGSTOP.

(Reminder: the ungetch() is needed in the normal version to prevent
the eating of a keystroke: https://savannah.gnu.org/bugs/?48331.)
2021-11-28 11:52:42 +01:00
Benno Schulenberg
d14d9069cd tweaks: exclude some suspension code from the tiny version
The SIGCONT handler needs to stay, so that also in the tiny version
a 'fg' can properly resume from an external SIGTSTP.
2021-11-28 11:08:37 +01:00
Benno Schulenberg
93df6ab385 tweaks: shorten a comment, and drop some conditionalizing
The conditionalizing was needed only for Slang -- see commit 009fb2fa.
2021-11-27 17:07:47 +01:00
Benno Schulenberg
be87f110ce bindings: allow rebinding ^Z also on a Linux console (a VT)
Achieve this by translating KEY_SUSPEND back to ^Z.

(Strictly speaking, this is incorrect, as the terminfo entry
might specify some other keystroke for 'kspd', but... meh.)

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

Bug existed since before version 2.2.0, since keys became rebindable.
2021-11-27 16:53:05 +01:00
Benno Schulenberg
9ebee362a5 tweaks: fix typo, and improve description of 'set zero' in sample nanorc 2021-11-27 16:52:54 +01:00
Benno Schulenberg
27928e47be docs: mention that --zero and 'set zero' hide also the help lines 2021-11-26 11:01:33 +01:00
Benno Schulenberg
79def643a3 options: make --zero imply --nohelp, and 'set zero' imply 'set nohelp'
This fits better with what "zero" intuitively means.
2021-11-26 10:58:17 +01:00
Benno Schulenberg
9a8d9ef496 tweaks: fix a somewhat humorous typo
The typo was found by hitting ^] several times on "spell" during
random testing and getting two suspiciously similar results.
2021-11-25 11:14:11 +01:00
Benno Schulenberg
7336c28ca8 display: clear the status bar early enough, so that --zero can show text
This fixes https://savannah.gnu.org/bugs/?61554.

Bug existed since commit be61aad9 from yesterday.
2021-11-25 11:08:21 +01:00
Benno Schulenberg
6a521da437 display: ensure feedback will be cleared also on a one-row terminal
This fixes https://savannah.gnu.org/bugs/?61548.

Bug existed since commit be61aad9 from earlier today.
2021-11-24 16:17:34 +01:00
Benno Schulenberg
6d828cf470 display: move some code for overwriting verbatim feedback with --zero
This code was meant to do just that.  So, put it where it's needed.

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

Bug existed since commit 511a2850 from earlier today.
2021-11-24 16:00:14 +01:00
Benno Schulenberg
511a2850a1 display: with --zero, redraw the bottom row instead of wiping a message
This fixes https://savannah.gnu.org/bugs/?61541.

Bug existed since commit 03637030 from two weeks ago.
2021-11-24 12:34:23 +01:00
Benno Schulenberg
be61aad935 display: do not wipe the status bar when --zero or --minibar is active
With --zero, any message that was there will get overwitten by the
text window anyway as result of the current operation.  And with
--minibar, any message will get overwritten with the minibar.

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

Bug existed since commit 03637030 from two weeks ago.
2021-11-24 12:03:29 +01:00
Benno Schulenberg
c06f7d43e9 tweaks: reshuffle a few lines, for Christmas and to group things better 2021-11-24 10:44:12 +01:00
Benno Schulenberg
3638fb9da4 tweaks: place the unsetting of a flag better, and rename a variable
The unsetting should happen after the three possible early returns,
to avoid leaving the flag unset.

Also, don't bother to exclude the setting and unsetting from the
tiny version, to get rid of some cluttering conditionals.
2021-11-24 10:40:05 +01:00
Benno Schulenberg
2fc1f08573 tweaks: fix a parentheses mistake -- found by a warning from Clang 2021-11-23 17:37:50 +01:00
Benno Schulenberg
90946c5e9e syntax: nanorc: avoid colorizing #rgb codes as if they were comments
Demand that trailing comments (which are not really supported anyway)
have a space or tab after their hash mark.
2021-11-23 12:02:03 +01:00
Brad Town
9a778f9a00 docs: add a description of the hexadecimal #rgb color specification
Also, update the syntax to colorize these codes the same as color names.

Signed-off-by: Brad Town <brad@bradtown.com>
2021-11-23 11:56:06 +01:00
Brad Town
8d6b468cdc rcfile: support #rgb format for specifying colors in 256-color terminals
Most terminal emulators support a palette of 216 indexed colors:
the 6x6x6 color cube pioneered by Xterm.  But as an index gives
little indication about what kind of color it produces, allow the
user to specify the color with three hex digits instead, one for
the level of red, green, and blue each, in the format #rgb.

One hex digit allows for sixteen values, but as there are only
six levels available, only 0, 4, 8, a, c, and e are significant
-- other values get reduced to the nearest lower one.

This fulfills https://savannah.gnu.org/bugs/?56445.
Requested-by: Peter Liscovius, Erik Lundin, Owen Maresh, Dave Lemonby

Signed-off-by: Brad Town <brad@bradtown.com>
2021-11-23 11:56:06 +01:00
Benno Schulenberg
0941185fcf tweaks: on one-row terminals, suppress the message for two toggles
Their effect is feedback enough.
2021-11-23 10:16:54 +01:00
Benno Schulenberg
8850015822 feedback: give a more accurate message when the help lines won't appear 2021-11-23 10:14:25 +01:00
Benno Schulenberg
3be4ea0dc1 tweaks: fold a special case into the general one 2021-11-23 10:10:23 +01:00
Benno Schulenberg
3eda0135bc tweaks: replace two direct refreshes with two scheduled ones
These direct calls were installed last year in commits 7303f0c7 and
b368faf1, but were made redundant by commit b741b1c9 one week later.
2021-11-22 16:41:33 +01:00
Benno Schulenberg
9c9de85afb tweaks: elide a variable that is confusing and has just one use case 2021-11-22 12:03:28 +01:00
Benno Schulenberg
addac49465 tweaks: reshuffle some conditions, to have more balanced lines 2021-11-22 11:13:02 +01:00
Benno Schulenberg
839d29be3f feedback: with --zero, drop a message in a short while, as with --minibar
Only requested information (^C, M-D) and alerts stay onscreen until the
next keystroke, but less important messages are overwritten after 1.5
seconds (or 0.8 seconds with --quick).  This makes the behavior more
consistent with dropping a message when there is a spotlighted match.
2021-11-22 11:00:11 +01:00
Benno Schulenberg
b2f0721b69 tweaks: drop a fragment of code that became functionless
This fragment suppressed the cursor when it was on the bottom row of
the terminal and a message was displayed on the status bar.  But since
commit a2a00577 from eight days ago, the cursor will be scrolled off
of the bottom row when there is a message.
2021-11-22 10:53:56 +01:00
Benno Schulenberg
b228c9fe6c tweaks: untangle two case items, and shorten a message
Also, sort the case items in the order they are listed in the help text.
2021-11-21 17:00:41 +01:00
Benno Schulenberg
8e7738e22e tweaks: adjust two values -- help lines need at least 6 rows to be shown
Commit 931bf96c from four days ago incremented the minimum height.
2021-11-21 16:52:13 +01:00
Benno Schulenberg
84f8445b7b tweaks: reshuffle some conditions, so that the ifs have similar formats 2021-11-21 11:34:42 +01:00
Benno Schulenberg
5cf412320d feedback: with --mini/--zero, suppress message when toggling whitespace
The whitespace becoming visible/invisible is feedback enough.
2021-11-21 11:24:09 +01:00
Benno Schulenberg
c9fb1cf85a tweaks: don't redraw the help lines (if present), and normalize a brace 2021-11-21 11:05:59 +01:00
Benno Schulenberg
bbed065fa8 tweaks: avoid redrawing the entire window when just a 'touch' will do 2021-11-21 10:47:44 +01:00
Benno Schulenberg
dde74dee78 docs: say thanks to the Indonesian translator 2021-11-20 16:48:28 +01:00
Benno Schulenberg
966da68228 tweaks: exclude some hidden-interface code from the tiny version
Also, reshuffle one call and drop another: the cursor has been placed
fifteen lines earlier (either directly or in edit_refresh()).

(Important test case: toggling softwrap.)
2021-11-20 16:48:28 +01:00
Benno Schulenberg
f147131e7c tweaks: elevate two messages, so they get shown with --mini or --zero
A file being in DOS or Mac format is unusual, and thus noteworthy.
2021-11-20 16:46:18 +01:00
Benno Schulenberg
7785c3f7cf feedback: with --mini or --zero, suppress number of lines for new buffer
For consistency of style, the number of lines read should only be shown
when inserting a file into the current buffer, not when reading it into
a new buffer.

This amends the fix for https://savannah.gnu.org/bugs/?61509.
2021-11-20 12:31:23 +01:00
Benno Schulenberg
9d3d354bd4 feedback: report the number of inserted lines also with --zero or --mini
Inserting another file is somewhat unusual -- it's better to give
feedback about it.

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

Bug existed since version 5.5, since the minibar was introduced.
2021-11-19 17:06:56 +01:00
Benno Schulenberg
51a5f33b5b feedback: suppress chatty messages when --zero is active
Things like "Cancelled" and "Undid addition" are not needed.  They
are nice for discovery, but become distracting once you know nano.

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

Bug existed since commit 03637030 from last week.
2021-11-19 16:17:55 +01:00
Benno Schulenberg
8aea8625be replacing: keep the spotlighted occurrence in view, also with --zero
Also when adjusting the viewport, after the cursor has gone offscreen
(by toggling the help lines, for example), should the SHIM be applied.

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

Bug existed since commit 03637030 from last week.
2021-11-18 12:32:47 +01:00
Benno Schulenberg
931bf96c1d display: make sure there are at least as many text lines as help lines
It's an editor -- the largest element should be the text to be edited,
not some part of the interface.

(It would be better if the edit window was always the largest element,
larger than or equal to all interface elements combined.  But that is
something for another time.)
2021-11-17 17:09:29 +01:00
Benno Schulenberg
956a1c2327 help: remove an unneeded restriction for small terminals
There is no need to prevent NO_HELP from being unset on terminals
with fewer than five rows, because the bottombars() routine already
automatically suppresses the help lines on such terminals.

This improves the fix for https://savannah.gnu.org/bugs/?61497.

(The problem with absent feedback is still there when the terminal
has just one row.)
2021-11-17 16:57:50 +01:00
Benno Schulenberg
4f15890105 help: when done, always redraw the "bottom bars", also with --zero
This fixes https://savannah.gnu.org/bugs/?61500.

Bug existed since commit 3dfd798d from earlier today.
2021-11-17 16:38:30 +01:00
Benno Schulenberg
0afe38d81a help: skip the leading blank line when the terminal is very flat
On very flat terminals, a leading blank line could lead to ^G showing
just a blank row instead of the first line of the help text.
2021-11-17 12:21:41 +01:00
Benno Schulenberg
3dfd798d51 feedback: to have a status bar, suppress --zero while in the help viewer
This partially fixes https://savannah.gnu.org/bugs/?61497.

(It is not fixed for when the terminal has less than five rows.)

Bug existed since commit 03637030 from last week.
2021-11-17 12:12:27 +01:00
Benno Schulenberg
1235a5a365 tweaks: reshuffle the flag conversion into their order in the help text
This should make it slightly easier for translators when they compare
their PO file to nano's main help text.

Also, drop a die() -- a forgotten toggle name is not worth dying over.
2021-11-17 11:11:05 +01:00
Benno Schulenberg
c772e1cb6b tweaks: rename a function, away from using an abbreviation
Also reshuffle a tiny fragment of code.
2021-11-17 11:01:37 +01:00
Benno Schulenberg
e35b6636ab tweaks: reshuffle a line and adjust indentation after previous change 2021-11-17 10:49:27 +01:00
Benno Schulenberg
bd4eed9cb1 tweaks: reshuffle a fragment of code to a better place 2021-11-17 10:42:21 +01:00
Benno Schulenberg
2b0bcc7cee feedback: show a relevant message for M-O when the syntax has 'tabgives'
When the syntax contains a 'tabgives' command, toggling the conversion
of tabs-to-spaces has no effect -- not for the current file.  So, tell
the user that and don't change the flag.

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

Bug existed since version 4.5, since 'tabgives' was introduced.
2021-11-17 10:25:32 +01:00
Benno Schulenberg
3b5f650621 tweaks: use a color closer to the rest of the string, to reduce contrast
On my normal machine, 'peach' harmonizes nicely with 'brightgreen',
but on another there is a large, jarring contrast.
2021-11-16 16:32:47 +01:00
Benno Schulenberg
b66a040828 tweaks: shorten the description of --zero in the manuals a bit 2021-11-16 16:23:23 +01:00
Benno Schulenberg
f757c4a512 syntaxes: colorize hex more strictly by using character class [:xdigit:]
In UTF-8 locales, the ranges A-F and a-f include several accented
characters beyond "ABCDEF" and "abcdef", such as the Croat č and ć.

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

Bug existed since the beginning of each of the syntaxes,
for the C syntax since version 1.3.6, commit 159bdfdc.
2021-11-15 16:17:31 +01:00
Benno Schulenberg
06ad77895f syntax: python: colorize backslash escapes, such as \n and \xef
Reference: https://docs.python.org/3/reference/lexical_analysis.html
2021-11-15 15:30:21 +01:00
Benno Schulenberg
2cbd4d29a0 search: with --zero, drop a message at the same time as the spotlight
Messages like "Search Wrapped" and "This is the only occurrence"
do not need to be shown until the next keystroke.  Dropping them
quickly gives a better fullscreen experience.
2021-11-15 15:10:20 +01:00
Benno Schulenberg
d93a5594cd tabbing: also with --zero, stay one row away from the prompt bar
When <Tab> at a prompt shows a list of filenames, this list should
not "sit" on the prompt bar but float one row above it.

This addresses the third issue mentioned in commit 03637030.
2021-11-15 10:44:06 +01:00
Benno Schulenberg
a2a00577cd search: with --zero, do not obscure an occurrence on the bottom row
If there is a status-bar message and the cursor happens to be on the
bottom row of the screen (in hidden-interface mode), then scroll the
viewport one row down, to keep the cursor in view.

This addresses the second issue mentioned in commit 03637030.

(The issue was rereported in https://savannah.gnu.org/bugs/?61464.)
2021-11-15 10:44:06 +01:00
Benno Schulenberg
b92b9e5cac browser: with --zero, do not use the bottom row for displaying filenames
Otherwise the prompt bar or status bar could hide the highlighted item.

This addresses the first issue mentioned in commit 03637030.
2021-11-15 10:44:06 +01:00
Benno Schulenberg
d19842ed73 tweaks: add an auxiliary variable, to prepare for handling --zero 2021-11-15 10:44:06 +01:00
Benno Schulenberg
0655c8aa6c tweaks: rename a variable, to be distinctive and less confusing
Also rewrap three lines, to keep related things closer together.
2021-11-15 10:44:06 +01:00
Benno Schulenberg
30595dd2bb tweaks: frob a couple of comments, and drop two, for conciseness 2021-11-15 10:44:06 +01:00
Benno Schulenberg
b76b5b9967 tweaks: use a few fewer capitals, and drop an unneeded synonym 2021-11-13 16:33:47 +01:00
Benno Schulenberg
1007ca5af8 docs: mention M-Z (for toggling the interface) among the Feature Toggles
And rephrase the M-Y description a bit, for shortness and variety.
2021-11-13 16:30:38 +01:00
Benno Schulenberg
f3fab1440f tweaks: shorten two comments, and fold two statements together 2021-11-11 16:06:43 +01:00
Benno Schulenberg
affca9b523 statusbar: overwrite a message also when using --constant with --zero
This needlessly wipes the status bar when --constantshow is active,
but it already needlessly wiped it when --minibar is active, so...
It is not a performance issue.  It was just a small optimization.
(Plus, with --zero, nano does a full edit_refresh() when in fact
only the bottom row needs to be redrawn, but there is no easy way
to do that when --softwrap is active, so...)

(Using --constantshow with --zero doesn't make sense, but the user
might want to have the --constantshow when they toggle --zero off.)
2021-11-11 16:02:58 +01:00
Benno Schulenberg
2f53760689 bindings: let ^T in the tiny version invoke spell checker (when included)
This fixes https://savannah.gnu.org/bugs/?61460.

Bug existed since version 5.0, commit d3954901, since in the normal
version ^T was repurposed to give direct access to the Execute menu.
2021-11-10 16:42:51 +01:00
Benno Schulenberg
3409cb2b77 files: allow inserting also when started with the --noread option
The --noread option should apply only to the files listed on the
command line, but once nano has started, it should be possible to
insert other files into the current buffer or into a new buffer.

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

Bug existed since version 2.3.3, since --noread was introduced.
2021-11-10 16:24:23 +01:00
Benno Schulenberg
be6860b33e tweaks: remove two unneeded unsettings
Before version 4.3, commit 3eab405e, nano would write a help text to
a temporary file and then read this file into a buffer.  The NOREAD
flag interfered with the latter, so needed to be reset for showing
help.  But since the mentioned commit nano writes a help text directly
into a buffer and the unsetting of the NOREAD flag is superfluous.

The display code never references the LINE_NUMBERS flag -- the trigger
for displaying line numbers in front of the text is 'margin > 0'.  So,
since commit 90bd25c1 that put help texts into a "normal" buffer, the
unsetting of the LINE_NUMBERS flag has been superfluous.
2021-11-10 16:05:40 +01:00
Benno Schulenberg
3a94a0bb89 bindings: allow toggling line numbers (when enabled) also in tiny version
As a special case, and because it doesn't need any feedback on the
status bar nor other calls, add a special function and key binding
to allow the user to flip the LINE_NUMBERS flag also in a tiny nano.

This fixes https://savannah.gnu.org/bugs/?61441.
Reported-by: Hannu Nyman <hannu.nyman@iki.fi>
2021-11-10 09:32:00 +01:00
Benno Schulenberg
8234c22c1e tweaks: avoid a compiler warning with --enable-tiny --enable-linenumbers 2021-11-10 09:11:04 +01:00
Benno Schulenberg
496dad696c build: fix compilation with --enable-tiny --enable-wrapping
Problem existed since commit 50106266 from three weeks ago.
2021-11-10 09:07:23 +01:00
Benno Schulenberg
a623f5836c docs: explain the effect of --zero / -0 / 'set zero'
Also, colorize 'set zero' as valid option in a nanorc file.
2021-11-09 16:31:04 +01:00
Benno Schulenberg
f42821293e feedback: refuse the --constantshow toggle (M-C) on a one-row terminal
When the terminal has just one row, there is no room to constantly show
the position of the cursor, so do not allow the user to switch it on.

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

Bug existed since version 5.8, commit 36ffb5f0.
2021-11-09 12:29:51 +01:00
Benno Schulenberg
0363703073 new feature: option --zero for an interface without bars
With --zero or 'set zero', nano will hide the title bar or the minibar
(whichever is active) and will use all rows of the terminal for showing
the text of the buffer.  Only when there is an important message will
it be shown on the bottom row -- until the next keystroke.

This feature can be toggled with M-Z.

The feedback at startup ("Read nnn lines") is suppressed with --zero,
because it disrupts the fullscreen experience (and is hardly useful).
The "Reading..." message then needs to be suppressed too, otherwise
it creates an annoying little flash.

There are still some issues that need to be addressed:

* In the browser, when the highlighted item is on the bottom row, it
  will get obscured by the prompt bar or the "Search Wrapped" message.

* In the edit window, when the search occurrence is on the bottom row,
  it can get obscured by the "This is the only occurrence" message.

* When tabbing at a prompt shows possible completions, they are shown
  a row too low.
2021-11-09 11:50:40 +01:00
Benno Schulenberg
dfbe3ce6dc docs: clarify that --enable options do not fully counteract --enable-tiny
This addresses https://savannah.gnu.org/bugs/?61441.
Reported-by: Hannu Nyman <hannu.nyman@iki.fi>
2021-11-09 10:50:29 +01:00
Benno Schulenberg
e4a247f7c9 tweaks: rename three functions, to better fit the general scheme 2021-11-09 10:39:31 +01:00
Benno Schulenberg
69b2467a9a tweaks: rename two more functions, to lose a senseless suffix 2021-11-09 10:18:03 +01:00
Benno Schulenberg
cc24e8b86b docs: give more examples of things that --enable-tiny excludes 2021-11-08 17:20:15 +01:00
Benno Schulenberg
27f170815f tweaks: rename two functions, to get rid of one more senseless suffix 2021-11-08 16:54:18 +01:00
Benno Schulenberg
d3c7e9d2f6 tweaks: rename two functions, to get rid of another senseless suffix 2021-11-08 16:41:44 +01:00
Benno Schulenberg
ea4bbf4285 tweaks: rename two functions, to get rid of the senseless suffix of one 2021-11-08 16:16:35 +01:00
Benno Schulenberg
308d6e73e3 tweaks: normalize whitespace, drop unneeded prototype, condense comment 2021-11-07 15:51:32 +01:00
Benno Schulenberg
167c93b85c justify: correctly determine whether top-of-buffer has been reached
The text to be justified has been excised from the buffer and is now
in the cutbuffer, so we cannot compare any of its lines to 'filetop'.

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

Bug existed since version 4.0, commit 14c08589.
2021-11-07 15:20:18 +01:00
Benno Schulenberg
13c5bcb4d8 tweaks: improve a comment, and drop two cluttering compile conditions 2021-11-07 11:33:02 +01:00
Benno Schulenberg
c692a6ca70 tweaks: reshuffle a line into its proper order, and improve two comments 2021-11-07 11:23:45 +01:00
Benno Schulenberg
0346e63c20 build: fix compilation when configured with --enable-tiny
Problem existed since commit 50106266 from two weeks ago.
2021-11-05 16:00:34 +01:00
Benno Schulenberg
9e982f3283 tweaks: rename a function, for some contrast and to get rid of a suffix 2021-11-05 15:59:32 +01:00
Benno Schulenberg
11fec6f63c feedback: when the user types ^Z, say they can suspend nano with ^T^Z
Inspired-by: Sébastien Desreux <seb@h-k.fr>
2021-11-05 15:25:03 +01:00
Benno Schulenberg
d0c2c1e6b9 suspension: leave ^Z unbound by default -- just ^T^Z will suspend nano
Suggest in the documentation how to get a one-keystroke Suspend.
2021-11-05 15:24:45 +01:00
Benno Schulenberg
fab4d0afcb tweaks: reshuffle a coloring rule, to have related ones together
(We don't want the rule for control codes after the rule for comments,
because then control codes in commented-out binds would stand out.)
2021-11-03 17:35:52 +01:00
Benno Schulenberg
d9e42cb274 syntax: nanorc: require whitespace before the start= and end= keywords
Also, drop the unneeded and mistaken 'end=' in the first regex, as
a coloring rule with just end="something" is not valid.  And drop
the requirement for having trailing whitespace or nothing at all,
as it does not constitute a useful restriction.

Also, fold two regexes together, for economy.
2021-11-03 17:33:45 +01:00
Benno Schulenberg
4d9be13316 syntax: nanorc: add 'execute' menu for unbind, and drop a bad constraint
The coloring rule for 'unbind' still checked for the old 'extcmd' and
'externalcmd' menu names.  And not coloring binds and unbinds as valid
when followed by something other than a comment was overrestrictive,
because the bind or unbind command would work just fine.

(Nano silently allows trailing garbage on any line without a regex.)

Also, take the opportunity to order the menu names in the bind and
unbind rules in the same way.

This fixes https://savannah.gnu.org/bugs/?61419,
and fixes https://savannah.gnu.org/bugs/?61420.

First bug existed since version 5.0, commit d9106abf.
Second bug existed since version 2.3.3, commit 9c11ba93.
2021-11-03 16:57:27 +01:00
Benno Schulenberg
7365ef4092 docs: mention "grey" also at the other place where color names are listed
And harmonize the wrapping of the phrase.

Indirectly-reported-by: Brad Town <brad@bradtown.com>
2021-11-03 11:21:39 +01:00
Benno Schulenberg
13edbedc79 tweaks: replace a verbose condition with a simpler early return 2021-11-01 18:17:47 +01:00
Benno Schulenberg
fc5d58ad97 tweaks: add two spaces and two comments, and drop an internal check 2021-10-31 16:45:43 +01:00
Benno Schulenberg
a373fa500a docs: add a suggested rebind and three suggested unbinds to the sample rc 2021-10-31 11:14:09 +01:00
Benno Schulenberg
8da098f5e0 help: group the now lone mouse toggle with the "behavioral" ones 2021-10-31 10:55:07 +01:00
Benno Schulenberg
52d4b96639 docs: mark options -z, --suspendable, and 'set suspendable' as obsolete 2021-10-31 10:55:07 +01:00
Benno Schulenberg
83f94a88df suspension: enable ^Z by default -- ignore -z option and drop M-Z toggle
In the beginning, the goal for nano was to be a drop-in replacement for
Pico.  Pico did not know a Suspend command, so the ^Z keystroke needed
to be conditionalized on an option (-z or --suspend or the toggle M-Z),
just like the ^S and ^Q keystrokes (for stopping and resuming terminal
output) were conditionalized on --preserve.

But nano has abandoned full Pico compatibility since version 4.0.  It
is time to unconditionalize ^Z as well.  This should not be a problem:
Debian and Ubuntu have had 'set suspend' in their /etc/nanorc for years,
so a considerable portion of nano users have had ^Z enabled by default
for a long time, and no one seems to have complained.

If the keystroke bothers some user, they can unbind it in their nanorc.
They will still be able to suspend nano through the Execute menu: ^T^Z.

This addresses https://savannah.gnu.org/bugs/?61372.
2021-10-31 10:55:07 +01:00
Benno Schulenberg
8762e04631 replacing: keep the spotlighting, also after toggling the help lines
The spotlighting should only be dropped when in the main menu, like in
the code thirty lines up, where 'timed' became TRUE only for MMAIN.

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

Bug existed since version 5.8, commit 3f340836.
2021-10-29 10:28:00 +02:00
Benno Schulenberg
256a0d670e replacing: keep centering the occurrence, also after toggling help lines
Normally, returning to the main loop will set 'focusing' back to TRUE,
but the replacement loop doesn't return until replacing is finished.

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

Bug existed since version 5.0, commit d8249917.
2021-10-29 09:35:38 +02:00
Benno Schulenberg
50106266bc pasting: when less than a line is pasted, allow automatic hard-wrapping
When --breaklonglines is in effect and the user pasted just a few words
(anything without a linebreak), then act as if this short text had been
typed by the user and hard-wrap the line when it became overlong.

This fulfills https://savannah.gnu.org/bugs/?61353.
2021-10-27 16:42:07 +02:00
Benno Schulenberg
ba093b0b48 tweaks: elide two parameters, as they are now always the same 2021-10-27 16:30:23 +02:00
Benno Schulenberg
33041d0ad5 statusbar: count words in the way that matches how Ctrl+Right moves
When --wordbounds (-W) is active, nano considers punctuation as
word-forming characters and will thus count words the same way
as 'wc -w' does.  This is how nano counted words until now.

But when --wordbounds is not active (the default), only letters
and digits will be considered word-forming and thus lone groups
of lines and dashes and other punctuation will not be counted
as words, which is more like how a human would count words.

This addresses https://savannah.gnu.org/bugs/?61367.
2021-10-27 16:23:29 +02:00
Benno Schulenberg
b46c8c586b build: include the YAML syntax file among the distributed files
(It would be much better if the build rules automatically included
any *.nanorc files in the syntax/ directory into the tarball...)

This fixes https://savannah.gnu.org/bugs/?61391.
Reported-by: John Prokos <jprokos@gmail.com>

Bug existed since version 5.9, commit c2790a8a.
2021-10-27 11:58:52 +02:00
Benno Schulenberg
0e1d45dc36 tweaks: fold some regexes together, and trim or improve some comments
Also, trim some whitespace and group one rule better.

Also, fix a stray closing parenthesis in the JSON syntax,
and add the missing slash to the possible escaped characters.
(Reference: https://www.json.org/json-en.html.)

Also, improve the ending of multiline strings in the Rust syntax.
2021-10-27 11:25:45 +02:00
Benno Schulenberg
1cd92458e9 tweaks: swap two parts of specific regexes, for consistency with others
This order makes more sense to me: first the part that allows
almost everything, and then the special case.
2021-10-27 11:20:07 +02:00
Benno Schulenberg
7bd68365ec syntaxes: avoid coloring "this\" as if it were a valid string
A backslash should not be allowed inside a quoted string unless
it is used to escape another character.

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

Bug existed since each of these syntaxes was introduced.

(Awk and Fortran do not know include files with names between
angled brackets, so those regexes are dropped in the bargain.)
2021-10-26 14:35:40 +02:00
Benno Schulenberg
485eb18d83 syntaxes: use one regex for coloring quoted strings, to avoid overlap
Quoted strings cannot start within another quoted string and end after
that other string has ended.  Therefore single-quoted and double-quoted
strings should (as much as possible) be colorized by a single rule, so
that overlapping colorations are avoided.

(This also fixes a double typo in the PHP syntax (\. --> \\.) that has
been there since the PHP syntax was added in 2008, commit 90ee8ee4.)

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

Bug existed since each of these syntaxes was introduced,
the oldest ones around 2006, a few others around 2015.

The one that got it right was the Lua syntax from 2011.
2021-10-26 13:28:33 +02:00
Benno Schulenberg
375b30507e syntax: ruby: colorize embedded documentation as a comment
Vim and Emacs do this too.

Reference:
  https://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Lexicology

Also, when colorizing double-hashed comments specially anyway,
avoid colorizing ##.* as a single-hashed comment.
2021-10-25 13:45:21 +02:00
Benno Schulenberg
7691527f35 tweaks: remove redundant parentheses, trim comments, fold some regexes 2021-10-25 12:45:45 +02:00
Benno Schulenberg
3313fac8eb tweaks: remove redundant pair of parentheses, and swap two alternatives 2021-10-25 12:45:45 +02:00
Benno Schulenberg
e52c81f5db syntax: nanorc: improve the file-matching regex
The "\.?" part was pointless.  It says that the string "nanorc"
*might* be preceded with a period.  Sure, but if the period is
absent, then anything else may be there too, so the optional
period gives zero restriction.

The restriction should be: either the filename has the extension
".nanorc" OR the full filename is "nanorc".  So the "nanorc" part
must be preceded by either a period or a slash.

(However, in the times of commits 3dc0e23e and dc9c40a5, fifteen
and eighteen years ago, it was still the user-provided filename
that was matched against the regex, not the full-path filename.
The latter method arrived in commit ec8d51be, six years ago.)
2021-10-25 12:44:28 +02:00
Benno Schulenberg
9b419d0bff tweaks: rename a function, to describe better what it does nowadays 2021-10-22 11:50:04 +02:00
Benno Schulenberg
0f40752139 docs: add a hint about making ^L do just 'refresh' to the sample nanorc
Just for the sake of completeness -- I doubt anyone ever uses Refresh.
2021-10-22 11:50:04 +02:00
Benno Schulenberg
d57bfc057f syntax: rust: do not colorize as string the text between two strings
Strings may not contain a double quote unless it is escaped.

Reference:
  https://doc.rust-lang.org/reference/tokens.html#string-literals

(This will still not colorize multi-line strings with an unescaped
newline, will still colorize "this\" as if it were a valid string,
and will still miscolor things when there is another string after
the closing quote of a two-line string.  But those things can't
be helped -- line-based regexes cannot emulate a full parser.)

This fixes https://savannah.gnu.org/bugs/?61361.
Reported-by: Elias Jonsson <e@ejon.eu>

Bug existed since version 2.6.1, since the Rust syntax was introduced.
2021-10-22 10:44:49 +02:00
Benno Schulenberg
918ce1afa3 tweaks: just let do_wrap() set 'refresh_needed' instead of returning TRUE
This gets rid of performing an action in the condition of an 'if'.
2021-10-21 11:58:43 +02:00
Benno Schulenberg
5d285ca896 tweaks: rewrap three old NEWS items, for esthetics, and fix a date
Version 2.1.2 was released in June 2008, not April.
2021-10-21 11:47:44 +02:00
Benno Schulenberg
f368e2732d docs: reword several of the descriptions in the chapter on building nano 2021-10-20 16:12:48 +02:00
Benno Schulenberg
ad13746da9 docs: reword the beginning of the chapter on nanorc files
Also, move the text about valid color names to another item,
for shorter cross references.
2021-10-20 16:05:01 +02:00
Benno Schulenberg
440f39e558 docs: correct the description of the layout -- four areas, not five
Also, remove the concept of "shortcut list", as there is no need.
Just use "two help lines" instead, like elsewhere.
2021-10-19 16:17:53 +02:00
Benno Schulenberg
108c84daf8 docs: move the chapter about editor basics into third position
Or rather, move the chapter about command-line options to between
the chapters on file browser and feature toggles.  Also, rename the
chapter about the built-in help, and move the section about screen
layout to be the first in the editor-basics chapter.
2021-10-19 15:53:49 +02:00
Benno Schulenberg
e63fe3be69 tweaks: reword a paragraph, and use usual M- to depict Meta keystrokes 2021-10-19 15:36:38 +02:00
Benno Schulenberg
bc4a141cba tweaks: mark keystrokes consistently with @kbd in the manual
The @key command has the same visual result in the Info output, but
looks different (non-italic) from @kbd in the HTML and PDF outputs.
2021-10-19 14:21:28 +02:00
Benno Schulenberg
0dbe857ba2 syntaxes: undouble the backslash within bracket expressions
Within a bracket expression, the backslash is not special,
so it does not need to be escaped.

The double backslashes within brackets were found with:

  grep -o  '\[[^][]*\\\\[^][]*\]'  syntax{,/extra}/*rc

Also, incorporate the square brackets into some bracket expressions
by listing the closing bracket first, saving a separate regex for
those two brackets.
2021-10-18 12:14:05 +02:00
Benno Schulenberg
483538f8f3 syntax: email: use a character class, as \s does not work inside brackets
This fixes https://savannah.gnu.org/bugs/?61347.

Bug existed since version 4.9.3, commit 4f9bebdd.
2021-10-18 11:52:05 +02:00
Benno Schulenberg
1f36d5411a docs: improve the title of the manual, away from the bare "nano"
Also, suppress two unwanted blank lines in the HTML output, and
use a macro to avoid repeating the same three lines eight times.
2021-10-18 10:47:32 +02:00
Benno Schulenberg
46f76ca8b8 docs: avoid large Table of Contents at top of HTML version of manual
Texinfo-6.8 (that was used to build the docs of nano-5.9) changed
the way the @contents command is processed for HTML output, with as
result a detailed table of contents at the start of the HTML page.
That is ugly and too much detail.  To avoid that, produce a table
of contents only when generating output meant for printing.

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

Bug existed since version 5.9.
2021-10-17 16:55:24 +02:00
Benno Schulenberg
3a09577e0c tweaks: replace the obscure @* with the slightly clearer @sp
What @* does is guesswork when you don't use Texinfo regularly.
That the "sp" in the @sp command refers to vertical space is not
very clear either, but the command is used on nearby lines too,
so better use it more.

Also, improve two wordings and fix a four-year old typo.
2021-10-17 12:36:57 +02:00
Benno Schulenberg
b9f472a905 syntax: texinfo: be more precise in colorizing @commands
An @command must either start at the beginning of the line and be
followed by whitespace or EOL, or it must be followed by a brace.
Colorizing just any "@text" string colored too much.
2021-10-17 12:25:01 +02:00
Benno Schulenberg
557d8131ca docs: prevent a black square in the PDF after the long synopsis line
Also, prevent an unwanted break in a keystroke.
2021-10-16 17:46:33 +02:00
Benno Schulenberg
89fd11109d docs: add a meta description for the HTML rendering of the manual
Also, drop the Emacs mode line -- we don't use Emacs,
and Emacs doesn't need it.
2021-10-16 17:03:45 +02:00
Benno Schulenberg
badf3edc55 syntax: texinfo: colorize the special @-plus-punctuation commands too
Also, allow an @} and another @command{} within a pair of braces,
colorize only the valid @-commands with uppercase in their names,
unbold enclosed command arguments, colorize the directory entries
for the manual, and properly colorize also the comments that use
the full @comment command.

Reference:
  https://www.gnu.org/software/texinfo/manual/texinfo/html_node/Command-List.html

Testing was done with:
  info texinfo @-C "Command List" --output=list
  sed -i -e "s/^'//" -e "s/'$//" list
  nano list -Ytexinfo
2021-10-16 17:03:45 +02:00
Benno Schulenberg
36e3284979 help: ensure there is a blank line between title bar and start of text
In olden times, each help text started with a title line in the text
window followed by a blank line.  But since version 2.8.2, since the
help texts have become almost regular buffers (and thus searchable),
the title of the help text is in the title bar, and since version 4.0,
since --morespace became the default, the text will start immediately
below it.  But a title line immediately followed by text, without a
blank line between them, does not look nice.  So, add such a blank
line back when not using --emptyline (and also when using --minibar,
because the top of the terminal window is like a title bar).
2021-10-15 11:29:44 +02:00
Benno Schulenberg
4ac932bd21 syntaxes: drop three redundant end-of-line anchors
Also fold two regexes into one, for conciseness.
2021-10-15 10:17:28 +02:00
Benno Schulenberg
f9468fa987 history: process file faster by not filtering out hypothetical duplicates
When the history file has been created by nano, it will not contain
any duplicate search or replace strings, nor duplicate commands, so
checking for such a duplicate for each read item was a waste of time.

And if the user edited the history file and created duplicates, who
are we to filter them out?  They will not cause the history mechanism
to malfunction; they just take a little extra memory.
2021-10-14 09:58:07 +02:00
Benno Schulenberg
fb7c12f644 tweaks: rename a function, to make it make sense 2021-10-14 09:18:28 +02:00
Benno Schulenberg
9341c96def tweaks: rename two parameters and one variable, away from single letters 2021-10-14 09:18:05 +02:00
Benno Schulenberg
74fd78adb1 tweaks: reshuffle a few lines, and rename a variable 2021-10-13 16:45:15 +02:00
Benno Schulenberg
c8ab81dd1c tweaks: rename two variables, to fit with the names of similar ones 2021-10-13 16:38:23 +02:00
Benno Schulenberg
185e4d6b12 tweaks: rename two variables, away from abbreviations
Also reshuffle a few declarations, for Christmas.
2021-10-12 18:02:24 +02:00
Benno Schulenberg
99607a5bbe tweaks: invert a condition, to get an early return instead of indentation 2021-10-12 17:52:24 +02:00
Benno Schulenberg
7e807cdd2f memory: avoid leaking the filename when dottifying it on the minibar
This fixes https://savannah.gnu.org/bugs/?61334.

Bug existed since version 5.5, since the minibar was introduced.
2021-10-12 12:49:08 +02:00
Benno Schulenberg
e51f6596d4 tweaks: reassign a copy of a string to a variable more economically 2021-10-12 09:33:08 +02:00
Benno Schulenberg
42610db847 memory: avoid a tiny leak when an option with an argument is given twice
(Aaah, being able to define a keyboard macro
came in very handy when making this edit.)

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

Bug existed since before version 2.2.0.
2021-10-11 17:18:07 +02:00
Benno Schulenberg
6018de2466 tweaks: condense the definitions of all the empty functions 2021-10-11 11:21:31 +02:00
Benno Schulenberg
af757d3b3f docs: reshuffle a GNU marker, to make the title clearer in search engines 2021-10-11 09:27:56 +02:00
Benno Schulenberg
30abc02277 tweaks: reshuffle two conditions, re-indent, and rewrap a line
If all is programmed well, then the functions 'get_older_item' and
'get_newer_item' will only occur when a history list is passed to
acquire_an_answer().  But let's keep it certain we don't dereference
a NULL pointer.
2021-10-10 11:55:15 +02:00
Benno Schulenberg
9a9714fe0c tweaks: rename a variable, to be easier to read and to make more sense
Also update and improve five comments.
2021-10-10 10:43:00 +02:00
Benno Schulenberg
77457fa6e9 prompt: avoid resetting the history pointer when the search is cancelled
When the user immediately cancels a search (^W^C), then nothing in
the history stack has changed, so then there is no need to reset the
history pointer to the bottom.

This slightly improves the fix for https://savannah.gnu.org/bugs/?61316.
2021-10-10 10:21:24 +02:00
Benno Schulenberg
9c45b5da6c tweaks: rename a function and its parameter, to be clearer 2021-10-10 10:11:47 +02:00
Benno Schulenberg
e9f0597e2e tweaks: rename two empty functions, to be more to the point
Also, move them to global.c, where all the other empty functions are.
2021-10-09 17:33:32 +02:00
Benno Schulenberg
87cde1590d tweaks: elide two functions that each were called just once
This also gets rid of an assignment in an 'if' clause (twice),
elides a local variable, and makes it clearer that a pointer
gets moved to the previous or next item (instead of hiding it
as a side effect of the function call).
2021-10-09 17:18:32 +02:00
Benno Schulenberg
65d81c60cd help: do not show ^S when --preserve is in effect
This fixes https://savannah.gnu.org/bugs/?61317.

Bug existed since version 5.0, since the Execute menu was overhauled.
2021-10-09 13:05:27 +02:00
Benno Schulenberg
3d6dcb9568 prompt: begin at bottom of history list when at secondary prompt
Whenever invoking a search prompt, calling up historical search items
should start with the newest item.

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

Bug existed since version 2.8.2, since help texts became searchable.
2021-10-09 12:15:11 +02:00
Benno Schulenberg
1ca2911b84 prompt: keep a clear answer clear also after an excursion into history
When the answer at the prompt was clear before the user went up into
the history list, the answer should be cleared again when the user
comes back down to the present.

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

Bug existed since before version 2.2.0.
2021-10-08 12:36:32 +02:00
Benno Schulenberg
8ef74b3aac tweaks: rename five empty functions, to get rid of a meaningless suffix
For consistency, these five names ought to start with "flip_", but
then the bindable functions would need to be renamed too, and that
would be annoying for the user, *and* it would create too many names
that start with "flip" -- it wouldn't be distinctive any more.
2021-10-08 10:58:47 +02:00
Benno Schulenberg
aeae4fb4b9 tweaks: reshuffle some lines, one for clarity, others for conciseness 2021-10-07 19:04:20 +02:00
Benno Schulenberg
bc22b3c876 files: clear original filename when the user toggles Append or Prepend
When the current filename is equal to the filename of the buffer,
then clear the filename, because the chances that the user wants
to append or prepend a file to itself are practically nil.

This fulfills https://savannah.gnu.org/bugs/?61243.
2021-10-07 12:38:04 +02:00
Benno Schulenberg
64c9d3c143 rcfile: remove the deprecated 'cutwordleft' and 'cutwordright' keywords 2021-10-07 12:24:38 +02:00
Benno Schulenberg
bec0cdcb54 po: update translations and regenerate POT file and PO files 2021-10-06 10:53:18 +02:00
Benno Schulenberg
ba9e5ac05d bump version numbers and add a news item for the 5.9 release 2021-10-06 10:04:22 +02:00
Benno Schulenberg
46b5f83601 tweaks: fold two lines into two others, for conciseness 2021-10-04 12:03:47 +02:00
Benno Schulenberg
6d5b16562f help: make the keystrokes ^W^Y and ^W^V work again
The keystrokes are not listed, but should work like
they do in a normal, editable buffer.

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

Bug existed since version 4.0, commit bc98dbca.
2021-10-04 11:54:02 +02:00
Benno Schulenberg
508301a2ef browser: make the keystrokes ^W^Y and ^W^V work again
The functions to_first_file() and to_last_file() can get called from
do_statusbar_input(), which is called indirectly from do_prompt(),
and are expected to make the corresponding adjustment.

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

Bug existed since version 5.0, commit 07c1ac90.
2021-10-04 11:38:30 +02:00
Benno Schulenberg
2f216281e7 syntax: yaml: allow slash and period in key names
Some Yaml files use path names and sometimes version numbers as keys,
even though / and . are not officially in the character set allowed
for key names (just like underscore is not), as far as I understand.

Also, do not colorize any backslash escapes as invalid
because some of them occur sometimes in value strings.

Also, colorize only the valid double-exclamation tags.
2021-10-03 15:38:43 +02:00
Benno Schulenberg
9459030d66 syntax: yaml: allow any character in tags except whitespace
This will colorize also invalid tags, but the rules are too complicated
to catch in a simple regex.

See https://yaml.org/spec/1.2.2/#691-node-tags.
2021-10-03 10:41:03 +02:00
Benno Schulenberg
f545735638 syntax: yaml: colorize the two known directives
See https://yaml.org/spec/1.2.2/#68-directives.

Also, recognize a Yaml file from a %YAML directive on the first line.
2021-10-03 10:14:04 +02:00
Hussam al-Homsi
bb8f40989f tweaks: change 'return ++var;' to 'return var + 1;'
This avoids an unused and misleading assignment that might make
someone think the incremented variable will be used again.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2021-10-02 17:41:03 +02:00
Benno Schulenberg
675ad6386d syntax: yaml: colorize the question mark of complex mappings too
See https://yaml.org/spec/1.2.2/#22-structures, example 2.11.

Also make the dash more visible by bolding it.
2021-10-02 17:15:50 +02:00
Benno Schulenberg
6ce3487b65 syntax: yaml: colorize backslash-escaped characters as valid or invalid
See https://yaml.org/spec/1.2.2/#57-escaped-characters.

Also prevent an escaped double quote from breaking the coloring of
a string, and allow hyphens in an anchor.
2021-10-02 17:15:32 +02:00
Benno Schulenberg
bc7e7d847e docs: list the default color combo for 'spotlightcolor' in sample nanorc
The comment says that only 'errorcolor' and 'spotlightcolor' have
a default value.  Better list the default value for both of them.
2021-10-01 09:47:45 +02:00
Benno Schulenberg
71a73a1a10 syntax: yaml: allow double colon in key & do not colorize unspaced colon
Perl keys can contain a double colon.  And unspaced colons occur
quite regularly in values (URLs, IPv6 addresses, and the like)
and should not be colored as if they were an error.
2021-10-01 09:44:43 +02:00
Benno Schulenberg
c2790a8af3 syntax: yaml: new file -- coloring rules for YAML files
This fulfills https://bugs.debian.org/982091.
Requested-by: Otto Kekäläinen <otto@debian.org>

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2021-09-29 17:14:03 +02:00
Benno Schulenberg
fde86518ae tweaks: rename a function, to be more fitting
The file wasn't marked; a piece of text was marked, resulting in
a region, and it is this region that gets written out to a file.
2021-09-29 15:37:06 +02:00
Benno Schulenberg
61b3aa6626 tweaks: use five symbolic names, to make eight function calls clearer 2021-09-29 15:35:18 +02:00
Benno Schulenberg
6799bc69a6 tweaks: adjust three parameters -- two were mistaken, one superfluous
The calls of write_file() in do_spell() and do_formatter() write out
a temporary file -- such a file does not have an 'openfile' record,
so setting 'annotate' to TRUE was pointless.  Using the correct value
for this parameter allows dropping two conditions in write_file().

And when 'exiting' is TRUE and --save-on-exit is in effect, it is
slightly wasteful to stat() the written file and store the info in
its 'openfile' record as the buffer will be closed directly after.

So, now the only place where 'annotate' is TRUE is when writing out
the full buffer to a normally named file.
2021-09-29 15:04:22 +02:00
Benno Schulenberg
0c01227d86 tweaks: rename a parameter, to fit better what it is used for 2021-09-29 12:34:04 +02:00
Benno Schulenberg
c74fd81302 tweaks: rename a parameter and invert its logic
This makes more sense (an emergency file is not a temp file) and
avoids the constant negating.
2021-09-29 12:20:21 +02:00
Benno Schulenberg
4b30cfb8f8 tweaks: rename a variable, to be more visible and to match others 2021-09-29 11:56:45 +02:00
Benno Schulenberg
36b6416a7b tweaks: reshuffle some lines and adjust some indentation 2021-09-29 11:52:23 +02:00
Benno Schulenberg
e0334e861d shutdown: when dying, do not install/restore a handler for Ctrl+C
First, we don't want the writing of an emergency file to be interrupted
by the user.  But more important: the routine for restoring the handler
also disables SIGINT, which would leave the terminal with a non-working
Ctrl+C.

Saving an emergency file calls write_file() in a unique manner: with
thefile == NULL, fullbuffer == FALSE (even though the entire buffer
will be saved, of course) and tmp == TRUE (even though it is not a
temporary file, as it will persist after nano exits).  But in fact
we want the handler for Ctrl+C installed only for normal files, not
for temporary files and not for emergency files -- the user should
not be able to interrupt the writing of those.

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

Bug existed since version 4.3, commit 8550c6bd.
2021-09-29 11:32:48 +02:00
Benno Schulenberg
b07fb5a811 files: exclude the call of fsync() from the tiny version
To avoid a spurious error message when the user chooses to write
the current buffer to a fifo.

Reported-by: André Kugland <kugland@gmail.com>
  https://lists.gnu.org/archive/html/nano-devel/2021-09/msg00031.html
2021-09-28 11:00:48 +02:00
Benno Schulenberg
9ab49658d7 files: prepending to a fifo makes no sense, so do not try that
Trying to prepend would hang nano until some other process writes
something to the fifo.

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

Bug existed since before version 2.2.4.
2021-09-28 10:10:37 +02:00
Benno Schulenberg
bb3d367716 files: making a backup of a fifo makes no sense, so do not try that
This fixes https://savannah.gnu.org/bugs/?61235.

Bug existed since version 4.3, commit 1b2018e9,
since opening a fifo was made possible again.
2021-09-28 09:45:49 +02:00
Benno Schulenberg
26c0a7962e files: check for a fifo only when it is an existing file
To avoid referencing an uninitialized value.

Reported-by: André Kugland <kugland@gmail.com>
  https://lists.gnu.org/archive/html/nano-devel/2021-09/msg00031.html
2021-09-28 09:44:52 +02:00
Benno Schulenberg
a2b20a1915 files: do not call fsync() on a fifo, to avoid a spurious error message
This fixes https://savannah.gnu.org/bugs/?61234.

The original report was in:
  https://lists.gnu.org/archive/html/nano-devel/2021-09/msg00029.html
Reported-by: André Kugland <kugland@gmail.com>

Bug existed since version 5.0, commit a84cdaaa.
2021-09-27 17:23:49 +02:00
Benno Schulenberg
2087c20a83 tweaks: in comments, say "buffer" instead of "file" where appropriate 2021-09-27 16:37:03 +02:00
Benno Schulenberg
5512c63bdd copyright: update to the current year for significantly changed files 2021-09-24 11:01:41 +02:00
Benno Schulenberg
d31cf1da68 gnulib: update to its current upstream state 2021-09-21 16:52:04 +02:00
Benno Schulenberg
ce656cfca8 docs: improve the description of the spotlighting of a search match 2021-09-21 16:49:40 +02:00
Benno Schulenberg
46cdf8b745 startup: if TERM is unset, try falling back to VT220 instead of failing
Curses cannot function if not informed via TERM which type of terminal
is being used.  As many terminals are mostly compatible with a VT220,
falling back to "vt220" when TERM is unset has a good chance of giving
the user a usable nano, instead of simply failing.

(Falling back to "vt100" is not good as it contains padding delays.)

This partially addresses https://bugs.debian.org/991982.
2021-09-20 10:38:25 +02:00
Benno Schulenberg
fdc0b0ac24 tweaks: rename three variables, to follow the general scheme
Also rewrap a line, reshuffle two others, and remove two redundant
comments.
2021-09-20 10:08:56 +02:00
Benno Schulenberg
42b7dea14b docs: add some details to the bug-reporting paragraph in the README
And add a blank line at the end, to make EOF look better.
2021-09-19 12:03:12 +02:00
Benno Schulenberg
239c794503 feedback: use a smaller diamond to represent an anchor, to not overflow
In the terminal font that I use nowadays (that deals well with
combining characters), the normal diamond exceeded the boundaries
of a single cell and thus partly covered the first character of
the relevant line.
2021-09-19 12:03:12 +02:00
Benno Schulenberg
189960c467 cutting: copy anchors into the cutbuffer, so that undo can restore them
When a segment of text is extracted, copy any anchors that it has
into the cutbuffer, so that they get saved in the undo item, so that
an undo will put these anchors back on the lines where they were,
instead of leaving an inherited anchor at the top of the segment.

And when text is pasted, clear any anchors in it, so that they will
not travel nor multiply.

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

Bug existed since version 5.0, since anchors were introduced.
2021-09-19 11:29:39 +02:00
Benno Schulenberg
04f8aa83ef tweaks: reshuffle a few lines, for esthetics and to elide an #ifdef 2021-09-17 10:06:21 +02:00
Benno Schulenberg
802a20b222 tweaks: rename a variable, to be more grammatical 2021-09-16 12:32:19 +02:00
Benno Schulenberg
88f7ec38f8 docs: spell "filename" as a single word, like in most other occurrences 2021-09-15 10:27:31 +02:00
Benno Schulenberg
baaff48547 syntax: nanorc: recognize also the template of the sample nanorc file 2021-09-15 10:00:41 +02:00
Benno Schulenberg
0010cd4443 tweaks: slightly reword or rewrap some comments in the sample nanorc 2021-09-15 09:55:14 +02:00
Benno Schulenberg
7d6ffd9e78 docs: don't use "light" after "bold", as the latter often implies "light"
On most terminals "bold" also makes the relevant text lighter (or just
makes it lighter, like on a Linux console).  Only some terminals allow
the user to switch this coupling of bold to light off.

Suggested-by: Hussam al-Homsi <sawuare@gmail.com>
2021-09-14 12:40:32 +02:00
Hussam al-Homsi
b8daf1fb0b docs: correct the default value of the errorcolor option
It should be "bold,white,red" instead of "brightwhite,red"
because "bright" is deprecated and not documented.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2021-09-14 12:03:04 +02:00
Benno Schulenberg
fe5f05f037 files: give the user time to absorb a warning about someone else editing
That is: pause a little to jolt the user, and then leave the message
on the status bar.

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

Bug existed since version 4.8, commit 416386ed.
2021-09-12 10:43:07 +02:00
Benno Schulenberg
5cedb53c62 files: write a lock file also for a freshly saved buffer
This fixes https://savannah.gnu.org/bugs/?61146

Bug existed since version 2.3.2, since --locking was introduced,
and continued to exist since version 4.8 despite commit 497f126b
claiming to have fixed it.
2021-09-12 10:00:17 +02:00
Benno Schulenberg
650dc14e0f tweaks: rename a defined type, to fit within the general pattern
So that it can be colorized as a type by a general syntax rule.

(The name is now uglier than it was, but... alas.)
2021-09-11 18:05:03 +02:00
Benno Schulenberg
43ebabe05d docs: mention how to properly colorize all types in nano's source code 2021-09-11 17:50:11 +02:00
Benno Schulenberg
b6366411dc tweaks: reshuffle a few lines to avoid an #ifdef and unbalanced braces 2021-09-11 15:07:05 +02:00
Benno Schulenberg
914921887e tweaks: rename a variable, to make more sense 2021-09-11 11:09:56 +02:00
Benno Schulenberg
64a8f1930e history: emit a warning when file cannot be made private [coverity] 2021-09-08 09:15:41 +02:00
Benno Schulenberg
0ac2dfd920 docs: refer to the FAQ when <Alt+Up> does nothing on a Linux console 2021-09-04 12:29:31 +02:00
Benno Schulenberg
aa553ee5d6 docs: correct the descriptions of how to invoke the spell checker
The keystrokes to invoke it changed in version 5.0.
2021-08-30 17:09:41 +02:00
Benno Schulenberg
a8961c561f po: permit the Indonesian PO file to come back -- there was a big update 2021-08-27 12:37:26 +02:00
Benno Schulenberg
abce19b0e4 docs: improve the recipe in the FAQ for dealing with Alt+Up on a console 2021-08-25 11:53:27 +02:00
Benno Schulenberg
fc317660cb tweaks: harmonize the indentations in the FAQ somewhat 2021-08-25 11:28:45 +02:00
Benno Schulenberg
949fcde6f7 docs: indent the paragraphs in the FAQ that list commands to be typed
And use a monospaced font for them.
2021-08-25 11:27:26 +02:00
Benno Schulenberg
9f24b6ea65 po: delete the ancient PO files for Indonesian and Nynorsk
These files haven't been updated in more than fifteen years and their
number of translated strings has dropped to below twenty percent.

Also, prevent them from coming back when next syncing with the TP.
2021-08-24 10:23:06 +02:00
Benno Schulenberg
c6ba4ae89a docs: improve the descriptions of several bindable functions
Some functions behave differently when some lines or a region is marked.
2021-08-23 10:12:55 +02:00
Benno Schulenberg
dab3f95c71 tweaks: instead of "one" use "you", like in the rest of the man page 2021-08-23 10:04:01 +02:00
Benno Schulenberg
840ad5890f docs: move the notice in the main man page, to try and catch other eyes 2021-08-23 10:00:44 +02:00
Benno Schulenberg
ae61bab60b files: when there is a slash after the dot, then there is no extension
This fixes https://savannah.gnu.org/bugs/?61071.

Bug existed since commit f429ebe3 from three days ago.
2021-08-23 09:52:32 +02:00
Benno Schulenberg
d3a7f3abed tweaks: restore a quote that was accidentally deleted four months ago
Commit a69a8ce3 unintentionally removed the double quote that should
terminate the version string.
2021-08-23 09:39:12 +02:00
Benno Schulenberg
694cd9ddd4 build: ensure that mkstemps() is available by importing the gnulib module
The mkstemps() function is not part of the POSIX standard,
so there might be some platforms that don't have it.
2021-08-22 11:42:34 +02:00
Benno Schulenberg
47c8e627f4 build: help Haiku find the header files that define mkstemps()
The documentation (https://www.haiku-os.org/docs/api/libroot.html)
says that BSD extensions are enabled by default, but somehow this
does not seem to be the case on my system.  With _DEFAULT_SOURCE
defined, though, src/files.c now compiles fine.
2021-08-22 11:42:34 +02:00
Benno Schulenberg
f429ebe34d files: add the original file's suffix to the name of a temporary file
This allows 'aspell' to recognize a C file and thus
spell check only the comments and strings.

This fulfills https://savannah.gnu.org/bugs/?61056.
2021-08-22 11:41:19 +02:00
Benno Schulenberg
083bbae0e4 tweaks: rename a variable, away form an abbreviation 2021-08-20 10:35:56 +02:00
Benno Schulenberg
eaff5ec9e5 files: check the result of fdopen(), to avoid a possible crash
When safe_tempfile() returns a valid filename, it should also
return a valid open stream.

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

Bug existed since version 1.3.8, commit 5e068c60.
2021-08-20 10:28:42 +02:00
Benno Schulenberg
51eb938fea tweaks: rewrap three lines, for esthetics 2021-08-20 10:14:21 +02:00
Benno Schulenberg
296c5a32c7 docs: replace a non-problem in the FAQ with something possibly useful
Opening a file whose name starts with a plus is not a problem at all.
Instead describe how to get the Alt+Up keystroke to scroll on a Linux
console (on Debian and friends).

This addresses https://savannah.gnu.org/bugs/?57294.
2021-08-18 11:54:54 +02:00
Hussam al-Homsi
ef6ccc47c8 syntax: perl, ruby: remove arbitrary highlighting of here documents
The rules assume that 'STOP' (for Perl) or EOT (for Ruby) is the
terminating string while it could be anything.  Also, the rules
don't take quotes nor backticks nor a tilde into account.

In short: these coloring rules are far too limited.

References:
  https://perldoc.perl.org/perlop#%3C%3CEOF
  https://docs.ruby-lang.org/en/3.0.0/doc/syntax/literals_rdoc.html#label-Here+Documents+-28heredocs-29

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2021-08-09 09:56:50 +02:00
Benno Schulenberg
eea2dfce48 tweaks: fix a typo 2021-07-31 20:48:10 +02:00
Benno Schulenberg
85682abbd5 docs: add a simulated "screenshot" of nano to the README
Suggested-by: Lars Wirzenius -- https://liw.fi/readme-review/
2021-07-21 10:15:07 +02:00
Benno Schulenberg
4005ee3284 docs: mention in the README which licenses cover nano's code and docs
Suggested-by: Lars Wirzenius -- https://liw.fi/readme-review/
2021-07-21 10:01:35 +02:00
Benno Schulenberg
9ead4c87a7 docs: add a paragraph at the start of the README about what nano is
Suggested-by: Lars Wirzenius -- https://liw.fi/readme-review/
2021-07-21 09:29:12 +02:00
Benno Schulenberg
1b5d9171f2 tweaks: try chmodding a dump file only when it was actually written 2021-07-14 10:38:02 +02:00
Benno Schulenberg
50543300d9 tweaks: reshuffle some code to elide a variable, and improve a comment 2021-07-14 10:36:15 +02:00
Benno Schulenberg
d9469b894f tweaks: remove a redundant feedback message
Any error message will already have been written to the terminal by
statusline().  Also, "Buffer not written to" looked too much like
"Buffer written to"; one had to look closely to see the difference.
2021-07-14 10:21:01 +02:00
Benno Schulenberg
6b9c24f7dd feedback: when not in curses mode, write error messages to the terminal
No errors ought to occur when not in curses mode, but when they *do*
occur, increase the chances that we can figure out what happened.
2021-07-14 10:16:31 +02:00
Benno Schulenberg
5954eeaff2 tweaks: reshuffle a fragment of code, to prepare for the next change 2021-07-14 10:08:32 +02:00
Benno Schulenberg
c84a769733 memory: free any allocated strings, also in the emergency code path 2021-07-14 10:06:04 +02:00
Benno Schulenberg
e3ef778756 files: when the buffer is nameless, include the PID in name of dump file
Make sure that when multiple nanos with nameless buffers die,
each of them tries saving those buffers to different files.

This addresses https://savannah.gnu.org/bugs/?60902.
Reported-by: Julian Rosen <julianrosen@gmail.com>
2021-07-14 10:02:44 +02:00
Benno Schulenberg
806e8e439f tweaks: reshuffle some lines to elide a variable
Having a local variable that gets assigned to just once looks rather
poor.  To me it makes more sense to have two separate exit points: one
for failure somewhere in the middle, and one for success at the end.
This way it is completely clear which value gets returned when.
2021-07-10 16:18:29 +02:00
Benno Schulenberg
30aaea2d04 tweaks: rename a variable and flip its logic, to avoid two negations
Plus, it makes more sense to start in the state "not saved" than in
the state "failed".
2021-07-10 15:56:38 +02:00
Benno Schulenberg
d0cb64650b usage: improve the description of the --positionlog option
And make the wording for the --historylog option similar.

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

Bug existed since version 2.3.0, commit 8e2a9307, since the
saving and restoring of the cursor position was introduced.
2021-07-01 16:45:49 +02:00
Benno Schulenberg
0694255893 tweaks: adjust a description of 'showcursor', to match the other ones 2021-07-01 16:12:06 +02:00
Benno Schulenberg
5563c710d0 docs: improve the description of the 'tabstospaces' option
It never mentioned to how many spaces a tab would be converted.
2021-07-01 09:52:10 +02:00
Benno Schulenberg
177e4e5805 general: prevent die() from getting recursed into
When something that is called from die() calls die() again,
there is nothing we can do any more but give up.

This would have prevented the spiralling as
seen in https://savannah.gnu.org/bugs/?60853.
2021-06-30 15:54:21 +02:00
Benno Schulenberg
8d1a666dcf input: give up on the input stream only after millions of errors
This mitigates a problem seen sometimes among the Red Hat crash reports:
somehow wgetch() keeps returning ERR, as if it were in nodelay mode.
(I've seen this happen once after nano came out of suspension.)

Using a much larger error-count value gives the user a few seconds
to type something and hopefully get out of the error condition.
2021-06-29 14:31:22 +02:00
Benno Schulenberg
fc01c5a10e feedback: when not in curses mode, just skip displaying any message
Calling die() could trigger another call of emergency_save(), which
could fail and cause another call to statusline(), which would call
die() again...  Spiralling until stack space runs out.

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

Bug existed since version 5.1, commit 7942dab0.

Original report was in https://bugzilla.redhat.com/1976410.
Reported-by: Souptik Dutta Roy <duttaroy.souptik@gmail.com>
2021-06-29 13:07:41 +02:00
Benno Schulenberg
896f174f94 syntax: rust: update the license to GPL3 or newer
With permission from the copyright holder:
    https://lists.gnu.org/archive/html/nano-devel/2021-06/msg00037.html

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2021-06-27 11:17:37 +02:00
David Michael
7b4a835df4 syntax: gentoo: remove some obsolete keywords and add some new ones
Removals:
  - All eblits were dropped from Gentoo years ago.
  - HDEPEND was never fully approved, superseded by BDEPEND.
  - Keywords 'dohard' and 'dosed' have been banned since EAPI 4:
    https://projects.gentoo.org/pms/5/pms.html#x1-130001r8
  - Several arches are dead.  For the currently supported list:
    https://gitweb.gentoo.org/repo/gentoo.git/tree/profiles/arch.list

Additions:
  - Two eapply functions replace the epatch functions, but epatch
    is still supported until EAPI 6 is banned.
  - Modern build systems (ninja and qmake5) have new functions.
  - EAPI 7 added more builtins: dostrip, get_libdir, ver_*
  - Highlight the cross-compiler boolean function.  (There are too
    many toolchain functions to add them all, but this one is very
    common and has a long name, so highlighting it is useful for
    catching typos early.)

The EAPI documentation:
    https://projects.gentoo.org/pms/8/pms.html#x1-590007

An extensive write-up on EAPI 7:
    https://mgorny.pl/articles/the-ultimate-guide-to-eapi-7.html

Signed-off-by: David Michael <fedora.dm0@gmail.com>
2021-06-25 16:37:32 +02:00
David Michael
ac85e16458 syntax: gentoo: highlight additional EAPI 7/8 variables
Add IDEPEND from EAPI 8, and also add more EAPI 7 roots so that all
of ROOT, EROOT, SYSROOT, ESYSROOT, and BROOT are supported.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
2021-06-18 11:00:35 +02:00
Benno Schulenberg
45420968ee tweaks: correct two typos and a spello [codespell] 2021-06-17 10:55:23 +02:00
Benno Schulenberg
3c35538e8b tweaks: add Schiermonnikoog to the list of friendly islands
(The commit message is a joke, of course.  Instead, this commit just
removes some unneeded comments and corrects one bit of whitespace.)
2021-06-16 11:19:23 +02:00
Benno Schulenberg
4f981cd5d9 po: update translations and regenerate POT file and PO files 2021-06-15 10:28:23 +02:00
Benno Schulenberg
44a6c4963b tweaks: avoid a compiler warning when configured with --enable-tiny 2021-06-15 10:20:28 +02:00
Benno Schulenberg
622bfb5b83 build: commit the LINGUAS file too while rolling a release 2021-06-15 10:11:19 +02:00
Benno Schulenberg
a2cb22faab bump version numbers and add a news item for the 5.8 release 2021-06-15 09:52:45 +02:00
Benno Schulenberg
9f8309fba8 help: use smaller triangles for the arrows
In Dejavu Sans Mono the old pointing triangles had a decent size,
but in Noto Mono and in Ubuntu Mono (fonts that handle combining
diacritics better) those triangles were massive, visually taking
up more than a single cell, overlapping the closing parenthesis
when they are displayed in the second column.  Not nice.

The new pointing small triangles look good in the Noto and Ubuntu
fonts, but are real tiny in Dejavu.  :|  Oh well, one can't have
everything.

(Other triangles are not an option, because they don't degrade to
actual arrows when on a Linux console.)
2021-06-14 09:29:27 +02:00
Benno Schulenberg
bf7954bdb7 tweaks: rename a variable, for contrast with the function name 2021-06-13 16:57:54 +02:00
Benno Schulenberg
0371dd1bde tweaks: rename two functions, to get rid of an ugly _void suffix
Also drop an unneeded prototype.
2021-06-13 12:17:33 +02:00
Benno Schulenberg
7c53b133a1 tweaks: use two symbolic names instead of TRUE and FALSE, for clarity 2021-06-13 12:06:24 +02:00
Benno Schulenberg
b1e5f9d9a8 docs: add a relevant item to the news for the 4.3 release
It's a low-level thing, but for the people affected it's a big deal.
2021-06-13 11:18:03 +02:00
Benno Schulenberg
424969258a docs: say thanks to the Icelandic and Slovak translators
(The Slovak file will arrive from the TP upon rolling the next release.)
2021-06-12 16:38:18 +02:00
Benno Schulenberg
6d0fc38285 gnulib: update to its current upstream state 2021-06-12 11:06:06 +02:00
Benno Schulenberg
984c9e1078 tweaks: redraw only the affected line instead of doing a full refresh
When the spotlighting needs to be cancelled, there is no need to do a
full refresh of the edit window -- redrawing just the relevant line is
enough.  (And when there is just one row, it is enough too.)
2021-06-11 16:52:56 +02:00
Benno Schulenberg
101dc4e805 docs: make ^E access the Execute menu in the example CUA bindings
Also, add the normal CUA bindings for Undo (^Z) and Redo (^Y),
and drop the M-X thinko.

With these more "usual" alternative bindings, ^X will now do a Cut
(putting the cut text into the cutbuffer) only when in the main menu
-- in the other places it did not put anything into the cutbuffer,
so it's better to have only the default ^K ("kill") for that.

Suspension is now accessible with ^E^Z, and the Speller with ^E^S.

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

Bug existed since version 3.2, commit 33d67d5c,
since the more usual example bindings were introduced.
2021-06-11 11:10:28 +02:00
Benno Schulenberg
d7e3226158 memory: move the correct number of bytes, and not one too many
We want to reduce the size of the answer by one byte,
not keep the full answer (plus terminating NUL).

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

Bug existed since version 2.9.8, commit f304b9ae,
since piping text to an external command was introduced.
2021-06-10 11:34:04 +02:00
Benno Schulenberg
74c6bdac9f docs: add example bindings for uppercasing and lowercasing a word
(The diff looks weird in 'less' -- the "c" before the "^T" hides
two escape sequences.)
2021-06-10 10:40:49 +02:00
Benno Schulenberg
73168bb1b9 docs: improve the contact info and some line spacing in the PDF 2021-06-08 11:31:18 +02:00
Benno Schulenberg
f895f1beba docs: mention the new 'set minicolor' option 2021-06-08 10:51:19 +02:00
Benno Schulenberg
e2e8bf0a3e options: accept 'set minicolor' for setting the color of the minibar
When it is not specified, it defaults to the value for 'titlecolor'.

When not using --minibar, I want the title bar to be blue (as that is
how I've always had it), but with --minibar, I want this mini bar to
be grey, as otherwise it reminds me too much of the prompt bar.

Also, colorize 'set minicolor' as valid in a nanorc file.
2021-06-08 09:25:02 +02:00
Benno Schulenberg
3f340836a6 search: automatically drop the spotlighting after a few moments
Even though I know that spotlighted text is not selected, I still
regularly think for a fleeting instant that the spotlighted text
can be cut with a ^K.  Mitigate this by dropping the spotlighting
after 1.5 seconds (or 0.8 seconds when using --quick).
2021-06-03 12:02:04 +02:00
Hussam al-Homsi
092c62ccb8 bindings: allow copying text (with M-6) also when in view mode
This can be useful when wanting to search for the other occurrences
of some (long) string in the buffer: select, M-6, ^W, ^U, <Enter>.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2021-06-02 11:09:24 +02:00
Benno Schulenberg
97dd505647 linter: strip filename and line plus column number from the message
Nano already opens the relevant file (when needed) and puts the cursor
at the relevant spot -- including this information in the message shown
on the bottom bar is just clutter and makes the message harder to read.
2021-05-30 11:30:32 +02:00
Benno Schulenberg
635977fe33 syntax: nanohelp: avoid colorizing M-) in (M-) and M-" in "M-"
Instead of quoting M- as 'M-', some translations use «M-» (Catalan),
(M-) (Croat), "M-" (Italian), „M-” (Romanian), or „М-“ (Serbian).
Those occurrences of M- nor its quotation marks should be colored.

Achieve this by excluding those quotation marks from the M- regex,
and then colorizing M-) and M-" only when at start of line (first
column of shortcuts) or when between parentheses (second column).
2021-05-30 10:44:03 +02:00
Benno Schulenberg
6ab70c2b0a tweaks: improve a comment, remove unneeded braces, reshuffle some lines 2021-05-28 16:42:56 +02:00
Benno Schulenberg
3a86b24a3e tweaks: remove a check that is not needed
The die() has been there for more than a year and no one reported a
problem.  And anyway, indenting does not create more than one group
-- this check was just to be certain.
2021-05-28 16:20:59 +02:00
Benno Schulenberg
77ca8735ab syntax: nanorc: colorize "light" as valid only for the eight basic colors
Only the basic colors (like red, blue and yellow) can take the prefix
"light" or "bright", not the extra colors (like pink, lagoon and lime).

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

Bug existed since version 5.0, since the extra colors were introduced.
2021-05-26 15:53:07 +02:00
Benno Schulenberg
3a0922799d tweaks: reshuffle the coloring of color names, to remove some duplication 2021-05-26 15:39:14 +02:00
Benno Schulenberg
b27efce732 docs: mention that "grey"/"gray" may be used as a synonym of "lightblack"
Also, colorize "grey" and "gray" as valid names in a nanorc file.
2021-05-26 15:31:04 +02:00
Benno Schulenberg
8974430c11 rcfile: allow using "grey" or "gray" as a synonym for "lightblack"
Because "lightblack" sounds strange and will not occur to many people
as a possible color name.
2021-05-26 15:31:04 +02:00
Benno Schulenberg
e044284998 rcfile: do not allow color name "normal" to have a prefix
Because "lightnormal" sounds strange, and can have unexpected effects.

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

Bug existed since version 2.9.5, since the name "normal" was introduced.
2021-05-25 15:43:06 +02:00
Benno Schulenberg
4f9d55bb15 tweaks: normalize the indentation after the previous change 2021-05-25 15:31:54 +02:00
Benno Schulenberg
89adacff3d tweaks: condense some code by putting all color names in a single array 2021-05-25 15:28:02 +02:00
Benno Schulenberg
2314a1932f tweaks: use a symbol instead of a hard-coded number 2021-05-25 15:14:10 +02:00
Benno Schulenberg
fb5eb4856b tweaks: drop an assignment that is already part of the called function 2021-05-25 15:11:33 +02:00
Benno Schulenberg
f857959b8e startup: suppress "Search Wrapped" when using +? to search from EOF
When using +/ or +?, any minor feedback should be cleared,
to not distract from the highligted search result.

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

Bug existed since version 5.5, commit b86f7868,
since the manner of grading status-bar messages changed.
2021-05-25 14:51:03 +02:00
Benno Schulenberg
405c2162b5 startup: allow using a bare "+" to mean put-cursor-on-last-line
Editors like 'vim' and 'ne' and 'uemacs' know this shorthand too.

This fulfills https://savannah.gnu.org/bugs/?60663.
2021-05-25 12:18:48 +02:00
Benno Schulenberg
8797ada815 startup: do not accept stray characters after a "+" on the command line
After a "+" only c, r, C, and R are valid characters,
and only when immediately followed by / or ?.

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

Bug existed since version 4.4, commit 2326bf6,
since searching at startup with +/ or +? was introduced.
2021-05-25 12:15:52 +02:00
Benno Schulenberg
30bafc70cc tweaks: prevent two more size_t subtractions from going negative
This fully fixes https://savannah.gnu.org/bugs/?60658.

Found by compiling with -fsanitize=undefined.
2021-05-24 11:00:29 +02:00
Benno Schulenberg
b38f0cbaf4 feedback: ensure that the reporting of DOS/Mac format is truthful
This fixes https://savannah.gnu.org/bugs/?60660.

Bug existed since version 5.7, commit 77da54c6.
2021-05-23 18:55:41 +02:00
Benno Schulenberg
ceaae49b2d tweaks: avoid the subtraction of two size_t variables becoming negative
This fixes https://savannah.gnu.org/bugs/?60658.

Found by compiling with -fsanitize=undefined.
2021-05-23 11:46:37 +02:00
Benno Schulenberg
d1957819c4 bindings: show either "^/" or "^-" in the help lines, instead of "^_"
The "^_" has always been poorly legible (the underscore melting into
the bottom of the terminal) and difficult to type (Shift+Ctrl+minus).
The "^/" is both more readable and easier to type.

In terminal emulators, "^/" is shown, but on a Linux console "^-",
as ^/ does a backspace in the default console key mapping.

Also, allow using "^-" when rebinding ^_ in a nanorc file.

This addresses https://savannah.gnu.org/bugs/?57393.
2021-05-22 16:52:56 +02:00
Benno Schulenberg
7993fc8b12 syntax: nanorc: colorize literal control codes, to make them stand out
This makes it easier to read string binds that contain control codes.
2021-05-14 15:05:05 +02:00
Benno Schulenberg
51adf02d34 wrapping: when copying the quoting part, adjust the file size accordingly
Simply adding the number of bytes in the quoting part is not entirely
correct, but... currently the indenting and commenting routines also
assume that the whitespace and commenting characters that are added or
removed are single-byte characters...  It will require another patch
to make this all fully correct, but for the default configuration
(and probably most other cases) the current fix will work fine.

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

Bug existed since version 4.4, commit 8fce33af from two years ago,
since this automatic copying of the quoting part was introduced.
2021-05-14 10:24:07 +02:00
Benno Schulenberg
f23e98dd3a memory: prevent a leak when copying the leading quoting to the next line
This fixes https://savannah.gnu.org/bugs/?60596.

Bug existed since version 4.4, commit 8fce33af from two years ago,
since this automatic copying of the quoting part was introduced.
2021-05-14 09:56:45 +02:00
Benno Schulenberg
6472a6b828 display: when a message gets overwritten, note that it is cleared
When on a one-row terminal a message gets automatically "dropped"
after a few moments, the subsequent waiting for a keystroke should
not think that there is still a message on the status bar.

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

Bug existed since commit 8d974cd2 from two days ago.
2021-05-12 16:00:11 +02:00
Benno Schulenberg
b741b1c985 startup: skip drawing edit window when having message on one-row terminal
When there is just one row and there is a message, it is not a good idea
to draw the contents of the buffer as it would overwrite the message.

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

Bug existed since version 2.7.0, since nano allows very flat terminals,
and was made worse by commit 2cf28f9d from yesterday.
2021-05-12 15:47:21 +02:00
Benno Schulenberg
5f87ed5644 statusbar: ensure that "No further matches" does not get overwritten
Redraw the content of the edit window (for the undone final completion)
before pushing out the "No further matches" message, so that the latter
will not get overwritten by the buffer content -- in case the terminal
has just one row.

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

Bug existed since commit 2cf28f9d from yesterday.
2021-05-11 15:58:21 +02:00
Benno Schulenberg
8d974cd292 statusbar: on a one-row terminal, drop light messages after a few moments
Only important error messages (ALERT) and information that the user
requested (^C, M-D) should stay put until the next keystroke.  Other
messages should be overwritten by the text of the buffer after just
a few moments, to make a one-row terminal slightly more friendly.

This addresses https://savannah.gnu.org/bugs/?60570.
2021-05-10 20:08:49 +02:00
Benno Schulenberg
2cf28f9db7 statusbar: suppress the cursor when the terminal has just one row
When showing a message on the status bar, the cursor should be off.

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

Bug existed since version 2.7.0, since nano allows very flat terminals.
2021-05-10 12:27:56 +02:00
Benno Schulenberg
36ffb5f0ac statusbar: suppress --constantshow when the terminal has just one row
When there is just one row, the text to be edited needs to be shown
there, not some meta information about the cursor position.

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

Bug existed since version 2.7.0, since nano allows very flat terminals.
2021-05-09 19:16:03 +02:00
Benno Schulenberg
07fd4c4598 tweaks: condense and correct a comment, and move another
Since commit 5dcf375f from four years ago, a linter message must
contain a colon followed by a space for it to be recognized as a
linter message.
2021-05-07 12:40:25 +02:00
Benno Schulenberg
44fb3e9991 tweaks: frob some whitespace, and rewrap a line 2021-05-07 12:33:22 +02:00
Benno Schulenberg
088557c516 tweaks: remove a check that has become superfluous
Since version 5.6, commit 76742cc1, nano highlights the search match,
which means that the screen gets refreshed anyhow, so this specific
refresh for a one-row terminal is no longer needed.
2021-05-07 12:20:50 +02:00
Benno Schulenberg
4712d46462 linter: block the resizing signal while reading output from the linter
This prevents read() from returning unexpectedly and causing a crash.

This fixes https://savannah.gnu.org/bugs/?60537.
Reported-by: Filips Romāns <frfilips@gmail.com>

Bug existed since version 2.4.2, since the handling of SIGWINCH changed.
2021-05-06 13:30:41 +02:00
Benno Schulenberg
c01b13a32c syntax: php: colorize the full short tag for echo (<?=) 2021-05-05 12:09:17 +02:00
Benno Schulenberg
b368faf11c replacing: report the number of replacements also on a one-row terminal
That is: call edit_refresh() right away, to prevent the edit_refresh()
in the main loop from overwriting the status-bar message.

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

Bug existed since version 2.7.2, commit f920e0d3.
2021-05-05 10:41:55 +02:00
Benno Schulenberg
7303f0c7b4 search: show "This is the only occurrence" also on a one-row terminal
That is: call edit_refresh() right away, to prevent the edit_refresh()
in the main loop from overwriting the status-bar message.

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

Bug existed since version 5.6, commit 76742cc1.
2021-05-05 10:36:18 +02:00
Benno Schulenberg
eb3cc3a32d minibar: stay out of sight when the terminal has just one row
When there is just one row, the user wants to see text on this row,
not a bar with some meta info.

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

Bug existed since version 5.5, since the minibar was introduced
with commit d31cc373.
2021-05-03 15:52:15 +02:00
Benno Schulenberg
02df950240 po: update translations and regenerate POT file and PO files 2021-04-29 12:57:17 +02:00
Benno Schulenberg
a69a8ce3ca bump version numbers and add a news item for the 5.7 release 2021-04-29 11:28:21 +02:00
Benno Schulenberg
8a03d55c53 gnulib: pull in the fix for a build problem on older Debian
The issue was reported here:
  https://lists.gnu.org/archive/html/bug-gnulib/2021-04/msg00198.html
2021-04-28 09:49:14 +02:00
Benno Schulenberg
544351f3be syntaxes: replace [[:space:]] with [[:blank:]] to exclude carriage return
In many places a carriage return is not valid whitespace and should
thus not be colored as such.  In some of these places a vertical tab
or form feed is maybe valid whitespace, but it would be ugly or even
wrong to color them because they are not part of the subsequent
comment or keyword.

This fixes https://savannah.gnu.org/bugs/?60456.
2021-04-27 11:18:41 +02:00
Hussam al-Homsi
96ebaf8ab4 syntax: c: make the highlighting of '#include <...>' more compliant
Changes:
  1. There may be zero spaces between 'include' and '<...>'.
  2. Blanks and '=' may occur inside '<...>' but '>' may not.
  3. There must be at least one character inside '<...>'.

References:
  Change 1:
    C:   www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf#subsection.6.10.2
    C++: www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf#section.19.2

  Changes 2 and 3:
    C:   www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf#subsection.6.4.7
    C++: www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf#section.5.8

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2021-04-26 12:14:44 +02:00
Benno Schulenberg
6b7c661fb7 syntax: po: improve the coloring of format specifiers
This now handles most of the things listed in 'man 3 printf'.
2021-04-26 11:29:05 +02:00
Benno Schulenberg
6823831c06 build: drop the check for two functions that we don't use any more
Since commits b0209374 and 1c010d8e from a month ago, nano does not use
mblen() and mbtowc() any more, so there is no need to check for their
presence.

Instead, add a check for iswalpha(), which we do use.
2021-04-25 11:55:04 +02:00
Benno Schulenberg
ec82530125 gnulib: update to its current upstream state 2021-04-25 10:48:56 +02:00
Benno Schulenberg
a45e1f89c0 oops: that doesn't work -- you can't break out of two for loops at once
This effectively reverts the previous commit.
2021-04-24 13:56:36 +02:00
Benno Schulenberg
c1cd813dcb tweaks: elide a function that is now basically just two lines 2021-04-24 11:48:04 +02:00
Benno Schulenberg
c96e62e33a startup: save the compiled file-matching regexes, to avoid recompiling
This reduces startup time by seven percent (when using the standard set
of syntaxes) when opening just one file that doesn't match any syntax,
and more than ten percent when opening multiple files.  It takes some
extra memory, but... not wasting CPU cycles is more important.

This addresses https://savannah.gnu.org/bugs/?56433.
2021-04-24 10:54:04 +02:00
Benno Schulenberg
6283557d2f memory: prevent a use-after-free when the user respects a lock file
This fixes https://savannah.gnu.org/bugs/?60447.

Bug existed since commit 2f718e11 from a month ago.
2021-04-23 12:20:45 +02:00
Benno Schulenberg
af90f03ac5 tweaks: condense three comments, drop another, and rewrap a line 2021-04-23 12:04:19 +02:00
Benno Schulenberg
588022ab8c editing: prevent the pointer for the top row from becoming dangling
When undoing several actions, it is possible for the line at the top
of the screen to be removed, leaving 'edittop' pointing to a structure
that has been freed.  Soon after, 'edittop' is referenced to determine
whether the cursor is offscreen...  Prevent this invalid reference by
stepping 'edittop' one line back in that special case.  This changes
the normal centering behavior of Undo when the cursor goes offscreen,
but... so be it.

When a single node is deleted, it is always possible to step one line
back, because a buffer contains always at least one line (even though
maybe empty), so if the current line could be deleted, there must be
one before it (when at the top of the screen).

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

Bug existed since version 2.3.3, commit 60815461,
since undoing does not always center the cursor.
2021-04-23 09:35:12 +02:00
Benno Schulenberg
cf0820549b tweaks: avoid calling extra_chunks_in() when not softwrapping
The function is somewhat costly; better avoid it whenever possible.
2021-04-22 12:19:09 +02:00
Benno Schulenberg
f54bc6c7d6 indicator: adjust the size to the number of visible lines, not chunks
Since two commits ago, the position of the indicator shows the position
of the viewport relative to the full buffer in terms of actual lines,
not of visual chunks (to avoid excessive computation).  But the size of
the indicator stayed constant, as if it always covered as many lines as
the edit window has rows.  But the latter will not be the case when
softwrapping occurs.  Therefore, when softwrapping, compute how many
actual lines are visible in the viewport, and adjust the size of the
indicator accordingly.
2021-04-22 11:52:57 +02:00
Benno Schulenberg
2cdff6c32c tweaks: adjust two comments, and reshuffle two fragments
Also rename two variables, to be more fitting.
2021-04-21 16:52:35 +02:00
Benno Schulenberg
49d8b99e4f softwrap: avoid time-consuming computations, to burden large files less
Whenever softwrap was toggled on or line numbers were toggled on/off or
the window was resized, the extra rows per line needed to be recomputed
for ALL the lines.  For large files with many long lines this was too
costly.

(This change causes the indicator to have an incorrect size when there
are many softwrapped chunks onscreen, but that will be addressed later.)

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

Problem existed since version 5.0, since the indicator was introduced.
2021-04-21 16:40:20 +02:00
Benno Schulenberg
bb81932422 chars: work around the wrong private-use-character widths on OpenBSD
This fixes https://savannah.gnu.org/bugs/?60393.
2021-04-20 11:13:08 +02:00
Benno Schulenberg
5efb6836a8 options: retire the obsolete 'smooth', 'morespace', and 'nopauses' 2021-04-15 11:43:39 +02:00
Benno Schulenberg
48fa14acc0 tweaks: simplify two fragments of code
This makes the handling of plain ASCII a tiny bit slower, but it
affects only the users of --constantshow without --minibar, so...

All other uses of mbstrlen() and collect_char() are not in speed-
critical code paths.
2021-04-13 11:19:32 +02:00
Benno Schulenberg
eb7181b35e tweaks: adjust and improve one comment, and frob another 2021-04-12 15:14:05 +02:00
Benno Schulenberg
8db42023bb files: when Mac format has been detected, stay with it
This fixes https://savannah.gnu.org/bugs/?60382.

Bug existed since commit 09b919a6 from three weeks ago.
2021-04-12 14:50:04 +02:00
Benno Schulenberg
018a8e12ca build: fix compilation for --enable-tiny plus --enable-multibuffer
This will not show the error messages for other buffers when using
a tiny build, but... one cannot have everything.
2021-04-10 12:01:34 +02:00
Benno Schulenberg
b4a5aedc6c tweaks: remove a misplaced (and nested) #ifdef
It was accidentally introduced two weeks ago by commit 1c010d8e.
2021-04-09 16:55:07 +02:00
Benno Schulenberg
d6ed174d09 tweaks: morph a function into what it is actually used for
Since the previous commit, mbwidth() is used only to determine whether
a character is either double width or zero width.  There is no need to
return the actual width of the character; a simple yes or no is enough.

Transforming mbwidth() into is_doublewidth() also allows streamlining
it and is_zerowidth() a bit, so that they become slightly faster.
2021-04-09 16:38:23 +02:00
Benno Schulenberg
78f92e044a tweaks: avoid parsing a multibyte character twice
The number of bytes in the character were determined twice: first in
mbwidth() and then in char_length().  Do it just once, in mbtowide().

Also, avoid calling is_cntrl_char(), because it does unneeded checks
when we already know that the high bit is set.

This duplicates some code, but advance_over() is called a lot, so it
is important that it is as fast as possible.

This shouldn't slow down plain ASCII, as the extra checks (use_utf8
and *string < 0xA0) are done only for non-ASCII (apart from DEL).
2021-04-09 11:32:15 +02:00
Benno Schulenberg
f11931a0dd tweaks: rename a variable, for contrast with another
The 'start_index' was in index in the given text, while 'index' is an
index in the displayable string.  Having both of them using 'index' in
their name was somewhat confusing.
2021-04-08 12:19:34 +02:00
Benno Schulenberg
31a6931be9 tweaks: elide a call of strlen() for every row
For a normal file (without overlong lines) the strlen() wasn't much
of a problem.  But when there are very long lines, it wasted time
counting stuff that wouldn't be displayed on the current row anyway,
and reserved *far* too much memory for the displayable string.

Problem existed since commit cf0eed6c from five years ago that traded
a continuous comparison (of the used space with the reserved space)
against a one-time big reservation up front involving a strlen().
In retrospect that was not a good trade-off when softwrapping.

The extra check (charwidth == 0) is incurred only by characters that
have their high bit set, so the average file (with only ASCII) is not
affected by this -- it just loses an unneeded call of strlen().
2021-04-08 12:15:12 +02:00
Benno Schulenberg
debb288115 tweaks: reduce the maximum character length from six bytes to four
In UTF-8 valid multibyte characters are at most four bytes long,
and now that we no longer make use of mblen() and mbtowc() from
the underlying system, we won't get five- or six-byte sequences
mistakenly reported as valid (by glibc).  So it is always enough
to reserve space for just four bytes per character.
2021-04-07 17:21:25 +02:00
Benno Schulenberg
c75a3839da tweaks: elide a small function that is used just once 2021-04-07 17:08:05 +02:00
Benno Schulenberg
b6a32fbd5f tweaks: elide an unneeded resetting NULL call to wctomb()
Calling wctomb() with NULL as the first parameter returns zero in a
UTF-8 locale, meaning that there is no state, so there is no point
in resetting it either.
2021-04-07 16:11:40 +02:00
Benno Schulenberg
09e4c86606 tweaks: improve a couple of comments 2021-04-07 12:28:48 +02:00
Benno Schulenberg
20eb422829 tweaks: avoid converting a file name for more than will fit on screen 2021-04-07 12:12:06 +02:00
Benno Schulenberg
90c6b572d0 display: avoid determining twice from and until where to draw each row
The two calls of draw_row() are each immediately preceded by a call to
display_string(), which has already determined from which x position
and until which x position in the relevant line the current row will
be drawn -- doing this again in draw_row() is a waste of time.  Even
though it is ugly, pass the two data points from one function to the
other via global variables.

For normal files (without overlong lines), this saves on average some
fifty calls of advance_over() per row.  When softwrapping a file with
overlong lines, the savings for each softwrapped chunk are much higher.
2021-04-07 11:27:10 +02:00
Benno Schulenberg
712b574fb7 tweaks: rename a variable, away from an abbreviation 2021-04-06 16:27:46 +02:00
Benno Schulenberg
fd023d6dcf tweaks: put the most likely condition first, for a quicker return
Also condense a comment.
2021-04-06 11:32:25 +02:00
Benno Schulenberg
9c16be32d7 tweaks: reshuffle two conditions, to have the most unlikely one first
This also better fits the preceding comment.
2021-04-05 16:10:44 +02:00
Benno Schulenberg
c3cdb099da tweaks: reshuffle a comment, and put the main extension first
And add some air to the compact file.
2021-04-05 16:06:54 +02:00
Mike Frysinger
682a088fb8 syntax: tcl: support Expect scripts too 2021-04-05 16:02:44 +02:00
Benno Schulenberg
8c25bd0e94 tweaks: elide two more instances of useless character copying
Just point at the relevant characters directly
instead of first copying them out.
2021-04-02 16:39:10 +02:00
Benno Schulenberg
20e122ef41 startup: show the helpful message only when ^G has not been rebound
(Well, it now checks that ^G is still the first shortcut that is bound
to 'do_help', but that is good enough: if the user did any rebinding,
they probably do not need any reminder about how to invoke 'Help'.)

This fixes https://savannah.gnu.org/bugs/?60315.
Reported-by: Robert Goulding <goulding.2@nd.edu>
2021-04-01 10:09:28 +02:00
Benno Schulenberg
0dcac9188f tweaks: simplify two fragments of code, eliding useless character copying 2021-03-29 20:06:05 +02:00
Benno Schulenberg
1c010d8ec9 chars: implement mbtowc() ourselves, for more efficiency
This saves a function call, and the passing and checking of the
MAXCHARLEN parameter, and the checking whether wc is maybe NULL
(which for nano is never the case), and who knows what other
overheads mbtowc() has, and our workaround for glibc.

Code was written after looking at gnulib/lib/mbrtowc-impl-utf8.h.
2021-03-29 12:36:10 +02:00
Benno Schulenberg
b020937475 chars: implement mblen() ourselves, for efficiency
Most implementations of mblen() do a call to mbtowc(), which is
a waste of time when all we want to know is the number of bytes
(and when we already know that we're using UTF-8 and that the
first byte is at least 0xC2).

(This also avoids burdening correct implementations with the
workaround that was needed only for glibc.)

Code was written after looking at gnulib/lib/mbrtowc-impl-utf8.h.
2021-03-27 14:38:28 +01:00
Benno Schulenberg
e3f46b066a build: fix compilation when configured with --disable-multibuffer 2021-03-26 12:21:44 +01:00
Benno Schulenberg
df7fe1280d tweaks: drop unneeded braces and adjust indentation after previous change 2021-03-26 12:17:44 +01:00
Benno Schulenberg
929770191e chars: work around a UTF-8 bug in glibc, to display invalid codes right
The mblen() and mbtowc() functions will happily return 4 or 5 or 6
for byte sequences that start with 0xF4 0x90 or higher.  But those
sequences encode for U+110000 or higher, which are not valid Unicode
code points.  The libc of FreeBSD and OpenBSD and Alpine correctly
return -1 for such sequences.  Make nano behave correctly also when
linked against glibc, so that invalid sequences are always presented
as a series of invalid bytes and never as a single invalid code.

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

Bug existed since before version 2.0.0.
2021-03-26 11:07:05 +01:00
Benno Schulenberg
66d9d6c6d2 tweaks: elide the pointless is_valid_unicode() function
The call of this function in make_mbchar() does not add anything,
because wctomb() already returns -1 for codes U+D800 to U+DFFF,
and parse_verbatim_kbinput() already rejects anything that starts
with U+11.... or higher, so make_mbchar() is never called for codes
beyond U+10FFFF.

And the call in display_string() just needs to check for wc <= 0x10FFFF
because mbtowc() already returns -1 for codes U+D800 to U+DFFF.
2021-03-25 11:24:41 +01:00
Benno Schulenberg
de816840cb input: accept Unicode codes for non-characters as valid, since they are
That is, accept U+FDD0 to U+FDEF, and accept U+xxFFFE and U+xxFFFF
for xx from 00 to 10 hex, being the 66 reserved "non-characters".

It may not be wise of the user to input these "things" (by typing
their code after M-V), but the codes are valid Unicode code points
and should not be rejected.

See https://www.unicode.org/faq/private_use.html#nonchar8 et al.

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

Bug existed since before version 2.0.0.
2021-03-24 17:11:05 +01:00
Benno Schulenberg
74fcc3be79 tweaks: normalize the indentation after an earlier change
(Should have been done yesterday, right after commit 2f718e11.)
2021-03-24 12:29:50 +01:00
Benno Schulenberg
b6909d3737 build: fix compilation when configured with --enable-tiny
Commit 0c1bf429 from last week added two calls to digits()
for --constantshow.
2021-03-24 12:21:50 +01:00
Benno Schulenberg
823d79b36c tweaks: shorten a comment and trim an #ifdef 2021-03-24 12:16:10 +01:00
Benno Schulenberg
735757b0c1 tweaks: set the file format only when unset, so it doesn't need saving
When inserting a file into the current buffer, the 'fmt' element will
already be set.  When we avoid overwriting the current value of 'fmt'
(when it's other than UNSPECIFIED), we don't need to save and restore
the value when inserting a file.
2021-03-24 12:00:34 +01:00
Benno Schulenberg
09b919a68f files: always register the format, also when the file is unwritable
When saving the buffer under a different name, it should by default
have the same format as the original file.

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

Bug existed since version 2.6.0, commit 0293eac1.
2021-03-24 11:53:56 +01:00
Benno Schulenberg
2f718e11a7 files: create a new buffer earlier, so that error messages can be stored
This improves the fix for https://savannah.gnu.org/bugs/?60269,
by not dropping error messages that happen before a buffer is opened.

This basically reverts commit b63c90bf from a year ago, except that
it now always deletes the created buffer when the user does not want
to override the lock file, also when it is the only buffer.
2021-03-23 16:46:37 +01:00
Benno Schulenberg
77da54c6c6 startup: do not store an error message in the record of another buffer
Set the 'format' of a file only when it has been fully read in,
so that this field can be used to indicate that any later error
message cannot be meant for this buffer.

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

Bug existed since commit 6bf52dcc from yesterday.
2021-03-23 16:19:07 +01:00
Benno Schulenberg
6bf52dcc8d startup: do not crash when trying to open a device or directory
Make sure there is an 'openfile' record before trying to save an
error message in this record.

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

Bug existed since commit ede64d7e from yesterday.
2021-03-22 15:50:31 +01:00
Benno Schulenberg
3d9e803aed syntax: c: colorize also labels that contain digits, and uncolorize colon
Labels may contain digits (after the first character).
And the colon after "default" should not be colored.

Inspired-by: Hussam al-Homsi <sawuare@gmail.com>
2021-03-22 11:41:08 +01:00
Benno Schulenberg
ede64d7ea0 feedback: upon first switch to a buffer, show its error message (if any)
When opening multiple files and some of them had an error, only the
first message was shown and the others were lost -- indicated only
by three dots.  Improve upon this by storing the first error message
for each buffer and showing this message when the buffer is first
switched to.

Requested-by: Mike Frysinger <vapier@gentoo.org>
2021-03-21 16:52:29 +01:00
Benno Schulenberg
e8db390d6f tweaks: reshuffle a fragment of code, to prepare for the next change
Also, don't reserve MAXCHARLEN bytes for the terminating NUL byte.
2021-03-21 16:52:29 +01:00
Benno Schulenberg
0c1bf429e8 display: make the output of --constantshow less jittery
That is: reserve for the current line and current character the number
of positions needed for the total number of lines and characters, and
reserve two positions for both the current column and the total number
of columns.  This will keep all nine numbers in the output in the same
place -- as long as there are no lines with more than 99 columns.  In
this latter case there will still be some jitter, but all-in-all the
output is much stabler than it was.

Suggested-by: Mike Frysinger <vapier@gentoo.org>
2021-03-18 16:20:04 +01:00
Benno Schulenberg
f6357a73f0 memory: fix an off-by-one error to free also the last line in a group
The number of lines in a group is the difference in line numbers
between the last line and the first line *plus one*.

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

Bug existed since version 2.9.0, since indenting and unindenting
became undoable, and commit f722c532 formed a part of that.
2021-03-05 18:50:34 +01:00
Benno Schulenberg
49ca7e5aa8 memory: do not allocate space for multidata when it's already allocated
Allocating it again would leak the existing space.

This fixes https://savannah.gnu.org/bugs/?60172.
Reported-by: Mike Frysinger <vapier@gentoo.org>

Bug existed since version 5.6, commit 1fdd23d3.
2021-03-05 11:25:14 +01:00
Benno Schulenberg
be9b1a1887 tweaks: avoid a warning on newer compilers, by writing an extra byte
When the version number is a trio, the version string will occupy
ten bytes and the terminating NUL byte would not be written (which
was not a problem as byte 12 of the lock data is zero anyway).
But it's better to not have the compiler complain, so allow writing
the terminating NUL byte outside of the ten bytes reserved for the
version string.
2021-03-03 10:47:41 +01:00
Benno Schulenberg
bb74aacf2d po: update translations and regenerate POT file and PO files 2021-03-03 10:11:58 +01:00
Benno Schulenberg
b72d9af52c bump version numbers and add a news item for the 5.6.1 release 2021-03-03 09:47:41 +01:00
Benno Schulenberg
a9ccd99b90 tweaks: rename a symbol, to better match the corresponding option 2021-03-03 09:39:49 +01:00
Benno Schulenberg
ac5e5179fb options: rename 'highlightcolor' to the more distinct 'spotlightcolor'
This way there cannot be any confusion with syntax highlighting,
and it indicates better that a single place will be highlighted.
2021-03-03 09:31:46 +01:00
Benno Schulenberg
a543f8cd8f search: correctly colorize a match also when softwrapping is active
This fixes https://savannah.gnu.org/bugs/?60149.
Reported-by: Peter Passchier <peter@passchier.net>
Reported-by: Liu Hao <lh_mouse@126.com>

Bug existed since version 5.6, since a special color for highlighting
search matches was introduced in commit 87fe73dd.
2021-03-01 10:43:28 +01:00
Benno Schulenberg
d7853df8b6 po: update translations and regenerate POT file and PO files 2021-02-24 11:09:56 +01:00
Benno Schulenberg
1e9d12abc5 bump version numbers and add a news item for the 5.6 release 2021-02-24 09:23:50 +01:00
Benno Schulenberg
3bce9fb755 gnulib: update to its current upstream state 2021-02-23 09:53:17 +01:00
Benno Schulenberg
0a57da42e0 docs: correct the description of --quickblank for the changed base value
And mention that --minibar overrides the option too.
2021-02-22 12:24:06 +01:00
Benno Schulenberg
73067e0e16 build: include a workaround only for versions of ncurses that need it
The cursor-misplacement bug has been fixed in ncurses-6.2-20210220:

  https://lists.gnu.org/archive/html/bug-ncurses/2021-02/msg00010.html

See also https://savannah.gnu.org/bugs/?59808.
2021-02-21 12:00:28 +01:00
Benno Schulenberg
b9328d0eac feedback: make Full Justify show a message also when using --minibar
Full justification (like justification of a selection) is probably
a rather rare action -- and possibly even an unintended action --
so it's good to give feedback about what happened also when using
the minibar.
2021-02-20 12:11:43 +01:00
Benno Schulenberg
0596b875f0 painting: trigger a refresh when a second start match appears on a line
When a line is marked as JUSTONTHIS, there should be no second start
match on that line, because otherwise the line would have been marked
as STARTSHERE (unless there is also a second end match -- but it's
fine to do unnecessary refreshes in this unlikely case, as long as
the necessary refreshes are made).

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

Bug existed since version 2.5.0, but has been masked (for the C syntax)
by unnecessary refreshes since version 4.1, commit c9605e73.
2021-02-18 17:15:24 +01:00
Benno Schulenberg
b94dcfd34b painting: trigger fewer unneeded full-screen refreshes
When a line is marked as NOTHING, then the existence or the appearance
of an end match is irrelevant: there is no unpaired start match, so no
recoloring would occur, so there is no need to refresh.

When a line is marked as WOULDBE, then the existence or the appearance
of a start match is irrelevant (for the lines after the first WOULDBE
line): there already is an unpaired start match, so another one will
not change anything, so no refresh is needed.  Only the appearance of
an end match would recolor things and thus require a refresh.  However,
start and end regexes could match the same thing, so an end might get
misinterpreted as a start.  So the rule has to check for the absence
of both a start and an end match, like for WHOLELINE.

This addresses https://savannah.gnu.org/bugs/?60072.
2021-02-18 12:21:37 +01:00
Benno Schulenberg
4238564673 tweaks: rewrap two lines, for esthetics 2021-02-16 16:52:41 +01:00
Benno Schulenberg
764ab96bda tweaks: make a skipping condition more precise
A step forward needs to be forced not when both start match and
end match have zero length, but when the "full match" (all text
from the start of the start match to the end of the end match)
covers zero bytes.  In other words: the start and end match are
both of zero length AND are at the same spot.
2021-02-16 16:12:41 +01:00
Benno Schulenberg
f0cc59bead color: use inverse video for highlighting when there are no colors
When a terminal has no colors but has the ability to hide the cursor
(like a VT320), then using --bold would make a search match too hard
to see.
2021-02-16 11:28:22 +01:00
Benno Schulenberg
282f438967 color: use bright yellow to highlight a search match
Plain yellow is too dark (more like brown) on some machines.
Lightyellow is a bit loud, but... very visible.
2021-02-15 12:29:15 +01:00
Benno Schulenberg
1b01adfa9f docs: mention the new 'set highlightcolor' option 2021-02-14 12:51:09 +01:00
Benno Schulenberg
87fe73ddaa color: give highlighted text its own color, to not look like marked text
Now that a search match gets highlighted, the unsuspecting user might
think that the text is selected, because it is colorized the same way
as selected text.  Avoid this by colorizing a highlighted search match
with its own specific color, black on yellow by default.
2021-02-14 12:51:09 +01:00
Benno Schulenberg
c2746c0bb2 tweaks: reshuffle some code, and reduce the scope of a variable 2021-02-08 12:33:10 +01:00
Benno Schulenberg
399a024857 minibar: suppress the toggling feedback for M-C, but show it for M-Y/M-P
In addition, suppress the feedback for M-C also when --minibar
isn't used, as the feedback obscures the effect of the toggle:
showing information about the cursor position on the status bar.

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

Bug existed since commit 7545eb5b from one week ago.
2021-02-08 10:27:29 +01:00
Benno Schulenberg
d131c2d438 minibar: show a message a little longer when --quickblank isn't used
The --minibar option made --quickblank a no-op.  Now the use of the
latter together with --minibar still has some effect.
2021-02-07 12:09:38 +01:00
Benno Schulenberg
eb0962fb06 docs: remove all mentions of --markmatch and 'set markmatch' 2021-02-07 09:18:15 +01:00
Benno Schulenberg
7bf253702e options: remove --markmatch and 'set markmatch', as the behavior is gone 2021-02-07 09:18:15 +01:00
Benno Schulenberg
76742cc193 search: make highlighting the standard, non-changeable behavior
Highlighting an occurrence is so much clearer than just putting the
cursor on it.  People seem to like it.  So let's make this how nano
behaves by default.
2021-02-07 09:18:15 +01:00
Benno Schulenberg
37717baeed search: just highlight the found occurrence, instead of marking it
Requested-by: Peter Passchier <peter@passchier.net>
2021-02-07 09:18:15 +01:00
Benno Schulenberg
ade2fafbd3 tweaks: remove a strangely placed warning
(After some trying, I haven't seen the warning displayed, but...
I'm not yet sure that it could never occur, so I keep the 'if'.)
2021-02-06 19:12:43 +01:00
Benno Schulenberg
53fe7ba26a tweaks: be slightly more efficient in marking lines as WOULDBE
Take two conditions that are relevant only for a rather unlikely case
(a start match without a corresponding end match) out of an inner loop.
Give the case its own, dedicated loop.
2021-02-06 17:01:02 +01:00
Benno Schulenberg
7e04fea92b painting: when finding an end match, set its multidata right away
When leaving the multidata unset (as was done until now) and the
end match is offscreen, then this could lead to miscolorings later
when jumping over this end match instead of scrolling past it.

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

Bug existed since before version 2.1.10.
2021-02-05 17:25:03 +01:00
Benno Schulenberg
1fdd23d347 display: for a large paste or insertion, recalculate the multiline cache
When a large piece of text or code is pasted or inserted, it could
contain matches for start= and end= regexes, and backtracking from
the current screen could mistake an end for a start and could thus
miscolor things.  Avoid this by recalculating the multiline cache
for pastes and insertions that cover more than a screenful.

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

Bug existed since version 2.6.0, but existed also before 2.4.3.
2021-02-03 17:00:28 +01:00
Benno Schulenberg
5ea930e25f build: detect a build from git also when building out of tree
Reported-by: Hans-Bernhard Bröker <HBBroeker@t-online.de>

Bug existed since version 2.6.0, commit ec295f5e.
2021-02-02 12:00:24 +01:00
Benno Schulenberg
45defd25f3 build: avoid a warning about duplicate symbol when building from tarball
Reported-by: Hans-Bernhard Bröker <HBBroeker@t-online.de>

Bug existed since commit 3ea2694d from last week.
2021-02-02 11:39:26 +01:00
Benno Schulenberg
0d11964503 docs: say that --minibar is modified by --constantshow and --stateflags
The previous two commits reduced what is shown by default on the minibar.
Mention which extra options are needed to show the extra information.
2021-02-02 11:10:09 +01:00
Benno Schulenberg
7545eb5bbf minibar: show the state flags only when --stateflags is used
For users who always have auto-indent or hardwrap or softwrap on
and do not need to see this continuously advertised at the bottom.
2021-02-02 11:10:09 +01:00
Benno Schulenberg
878bd53d11 minibar: show cursor position + character code only with --constantshow
This allows having an even leaner interface, and gives the M-C toggle
an appropriate function (instead of leaving it a "dead" keystroke).

Suggested-by: Sébastien Desreux <seb@h-k.fr>
2021-02-02 11:10:09 +01:00
Benno Schulenberg
e0a4ee0148 scrolling: keep centering after large paste, also when line numbers widen
If a paste (or insertion) is more than a screenful, it will not set
'focusing' to FALSE.  In that case, and when line numbers are already
active, then 'focusing' should be kept set to TRUE, despite it getting
set to FALSE by ensure_firstcolumn_is_aligned().  That latter action
is meant to cushion size changes of the edit window, but in this case
the large paste (or insertion) should trump the size change.

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

Bug existed since version 2.8.3, commit 2b385478.
2021-02-01 12:42:55 +01:00
Benno Schulenberg
d3fbc4d498 tweaks: remove an old fix that was made superfluous by a recent fix
Commit 43d94692 fixed a miscoloring bug [1] by doing proper backtracking
for multiline regexes.  But this change also solves an older miscoloring
issue [2] without needing to recalculate all the multiline data.  So...
just drop the old fix.  (This isn't perfect: it's probably possible to
cook up a replacement scheme where things get miscolored, but... until
then, this is good enough.)

  [1] https://savannah.gnu.org/bugs/?59948
  [2] https://savannah.gnu.org/bugs/?58481

Also, there is no need to set 'refresh_needed' in do_replace_loop(),
because each replacement prompt will call edit_refresh() anyway, and
the functions that call do_replace_loop() will set it afterward.
2021-01-29 16:57:11 +01:00
Benno Schulenberg
a8e2a24f60 tweaks: frob a condition, to be more concise, and reshuffle another 2021-01-29 10:58:09 +01:00
Benno Schulenberg
36855544d1 tweaks: rewrap and reindent a few lines 2021-01-29 10:52:40 +01:00
Benno Schulenberg
dc745c0b77 tweaks: elide a function that is now just one line 2021-01-29 10:30:05 +01:00
Benno Schulenberg
a8ed1d7a9a tweaks: don't bother wiping the multidata before recomputing it
The precalc_multicolorinfo() routine will assign a value to every
element for every line without looking at any current value, so
wiping the data first is a waste of time.
2021-01-29 10:25:27 +01:00
Benno Schulenberg
94c371a38f tweaks: don't bother initializing freshly allocated multidata
After having been allocated, the multidata will get computed
immediately, in precalc_multicolorinfo() and draw_row(), so
first setting each element to -1 is a small waste of time.
2021-01-29 10:18:39 +01:00
Benno Schulenberg
36618f1dca tweaks: don't bother comparing virgin multidata with current situation
The initialization of -1 cannot possibly match with NOTHING or
WHOLELINE or the other available values.

(Also, put in a warning, as I don't think an onscreen line without
a multidata cache can occur at all.)
2021-01-29 10:06:03 +01:00
Benno Schulenberg
3ea2694d9c tweaks: rename six symbols, to be more straightforward 2021-01-28 16:11:57 +01:00
Benno Schulenberg
85cc99a2a3 tweaks: frob some comments, and reshuffle two fragments of code 2021-01-28 15:44:54 +01:00
Benno Schulenberg
befe4ea5de tweaks: frob some comments, and adjust indentation after previous change 2021-01-28 11:57:33 +01:00
Benno Schulenberg
43d94692ce painting: always do backtracking for the first row of the screen
Backtracking from the first row is needed in case a start match was
added recently somewhere offscreen and the user jumped to the current
location (instead of scrolling) so that the CWOULDBE markings did not
reach the current lines.

Also, search for an end match only for the first screen row.  For the
other rows, rely on the CENDAFTER, CWHOLELINE, and CWOULDBE values to
indicate whether there *is* an end match (the first two values) or not.
This saves considerable time when there is no end match in the large
remainder of a buffer: it will search in vain for the end match just
once, instead of for every row of the screen.

This fixes https://savannah.gnu.org/bugs/?59948,
and addresses https://savannah.gnu.org/bugs/?59945.

Bug existed since version 2.7.5, commit b3bcc8ee.
2021-01-27 17:01:17 +01:00
Benno Schulenberg
1364b41dc9 debug: add timing instruments to cache precalculation and screen refresh 2021-01-26 16:06:31 +01:00
Benno Schulenberg
7d3a555464 tweaks: avoid the vague possibility of advancing beyond end-of-line
Like the other two fragments that advance over a zero-length match,
also this fragment should avoid the possibility of stepping beyond
the end of the line.
2021-01-24 17:19:44 +01:00
Benno Schulenberg
0508520b47 tweaks: reshuffle three conditions into a better order
When a zero-length match is beyond the width of the screen, there
is no point in continuing evaluating the rule, so the check for
"offscreen to the right" needs to come first.  The check for a
zero-width match needs to come second because otherwise we would
get stuck on such a match when it is offscreen to the left.
2021-01-24 17:19:37 +01:00
Benno Schulenberg
6cbb7bc443 tweaks: frob two fragments of code, to be more readable 2021-01-24 16:44:38 +01:00
Benno Schulenberg
055e262b56 tweaks: stop evaluating a rule when the match is offscreen to the right
When the match of a coloring regex is beyond the width of the screen,
there is no point in continuing to evaluate the regex for the rest of
the line, because any other matches will be offscreen too.

This will save some time when there are several overlong lines.
2021-01-24 12:40:34 +01:00
Benno Schulenberg
9d8388e836 tweaks: call wattron()/wattroff() only when actually painting something
A syntax has on average a dozen coloring rules, but on average maybe
three or four pieces of text (rough estimate) in a line get painted.
So, on average, it is cheaper to call wattron() and wattroff() only
when actually coloring a piece of text, instead of calling wattron()
before starting to evaluate each rule and wattroff() after finishing
its evaluation.
2021-01-23 19:28:08 +01:00
Benno Schulenberg
895de17a58 color: do not look for another 'end' match after already finding one
When reaching end-of-line after having found a zero-width end match,
nano should not continue at 'seek-an-end' but instead at 'step_two':
going on to seek a start match in the current line.

(There is no bug report, because I cannot figure out how to trigger
this issue and cause nano to misbehave.  The problem was found while
reviewing the comments.)

Bug existed since commit 9a4a5454 from four years ago,
but the behavior was poorer before that commit.
2021-01-22 16:40:53 +01:00
Benno Schulenberg
b202966d30 tweaks: correct a comment, improve another, and trim some verbosity 2021-01-22 11:58:53 +01:00
Benno Schulenberg
a19a7820f9 color: recompile the file-probing regexes a little faster with REG_NOSUB
When the filename, header-line, and magic regexes are first compiled
while reading in the rc files (to check their validity), REG_NOSUB is
used, but for some reason this wasn't done when each of these regexes
gets recompiled in order to be used.  Fix this oversight.  It shaves
some twenty percent off of each of these regexes' compiling time.
2021-01-21 12:35:16 +01:00
Benno Schulenberg
0122119a44 docs: correct the word order for Alt+D in the cheat sheet -- it changed 2021-01-20 19:25:29 +01:00
Benno Schulenberg
64bf03b0d9 docs: correct the formatting of a comment in the sample nanorc 2021-01-15 10:05:04 +01:00
Benno Schulenberg
4bc6d67052 po: update translations and regenerate POT file and PO files 2021-01-14 11:21:21 +01:00
Benno Schulenberg
7519a458b2 bump version numbers and add a news item for the 5.5 release 2021-01-14 11:08:05 +01:00
Benno Schulenberg
bc36813349 memory: avoid leaking the speller or linter command string, when invoked
This fixes https://savannah.gnu.org/bugs/?59854.
Reported-by: Mike Frysinger <vapier@gentoo.org>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Bug existed since version 3.0, commit ecc9211a.
2020-12-04 16:35:28 +01:00
Benno Schulenberg
048ab0ee0b tweaks: reduce the scope of a static variable 2020-12-04 16:30:28 +01:00
Benno Schulenberg
16dff06a4c tweaks: simplify a bit of logic 2020-12-04 16:27:34 +01:00
Benno Schulenberg
c3900e90f0 po: update translations and regenerate POT file and PO files 2020-12-02 11:49:28 +01:00
Benno Schulenberg
0f334f8ee4 bump the version number in configure.ac too 2020-12-02 11:39:51 +01:00
Benno Schulenberg
587e6e2c88 bump version numbers and add a news item for the 5.4 release 2020-12-02 11:15:31 +01:00
Benno Schulenberg
a3a1391a51 tweaks: rename two variables, one for contrast, another for visibility
Also normalize two bits of whitespace.
2020-11-30 13:32:22 +01:00
Benno Schulenberg
a4675acdba copyright: update to the current year for significantly changed files 2020-11-30 12:01:47 +01:00
Benno Schulenberg
00ac41f632 weeding: remove another unneeded workaround for VTE
The issue is only reproducible when lying about the width
of the terminal.

It was a workaround for https://savannah.gnu.org/bugs/?49106.
2020-11-28 16:12:20 +01:00
Benno Schulenberg
fe22da6b2a build: exclude a workaround for VTE/Konsole when using a recent ncurses
The workaround was for https://savannah.gnu.org/bugs/?51335
(a cursor-misplacement bug), but both an recent Xfce Terminal
and a recent Konsole appear unaffected by the issue.  So, drop
the workaround for modern systems.
2020-11-27 14:15:42 +01:00
Benno Schulenberg
0c87a4ba41 build: include a workaround for VTE only when using an older libvte
Checking for the actual version of libvte is too complicated, so
assume that libvte is 0.58 or newer (where the problem is fixed)
when ncurses is 6.2 or newer.
2020-11-27 12:31:41 +01:00
Benno Schulenberg
39705c60df weeding: remove a workaround for VTE that is not needed
It was only ever needed when the user lied about the size
of the terminal, which should be considered a user error.

It was a workaround for https://savannah.gnu.org/bugs/?48852.
2020-11-26 20:09:23 +01:00
Benno Schulenberg
9da23799ff tweaks: reshuffle a fragment of code, for clarity 2020-11-26 17:32:30 +01:00
Benno Schulenberg
29276d1d3a help: allow the penultimate item extra space when the number is uneven
This avoids unnecessarily truncating the last help item on the
very bottom row when there is still plenty of room.

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

Bug has been visible since at least version 2.5.1.
2020-11-26 17:12:09 +01:00
Benno Schulenberg
13b839734f hellp: show all valid help items also in the Write-Out menu
Subtract one from the count only if all possible items in the menu
have been counted (item == NULL), meaning that the last item in the
Write-Out menu (the 'discard_buffer' function) has been counted too.

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

Bug existed since version 4.5, commit b3ace4d8.
2020-11-26 15:37:21 +01:00
Benno Schulenberg
63bb1b62b7 gnulib: update to its current upstream state 2020-11-25 11:22:46 +01:00
Benno Schulenberg
743100feab options: do not spew out the help text when an option is not recognized
When getopt() does not recognize an option, it returns '?', which means
that '-?' cannot be used as a valid option because any invalid option
would be treated the same way as '-?'.

Spewing out the full help text drowns the "invalid option" message at
the beginning.

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

Bug existed since version 5.3, commit 5bd92d4c.
2020-11-24 10:09:41 +01:00
Benno Schulenberg
d3d2d324d2 statusbar: properly pluralize the line+word+character count report
This avoids poor wordings such as "Words: 1  Lines: 1  Chars: 1".

Also, display the numbers in a more logical, ascending order: lines
first, words second, characters third.  This is what 'wc' uses, too.
2020-11-21 15:25:23 +01:00
Benno Schulenberg
925a1a11f9 feedback: abort when user tries to open multiple files in tiny version
This fixes https://savannah.gnu.org/bugs/?56227.
2020-11-17 19:08:12 +01:00
Benno Schulenberg
5918ca6cab tweaks: normalize the formatting after the previous two changes 2020-11-17 10:28:28 +01:00
Benno Schulenberg
dc907bfe43 prompt: skip over combining characters also when editing a search string 2020-11-17 10:27:47 +01:00
Benno Schulenberg
687efd210c moving: skip combining characters and other zero-width characters
This makes the cursor move smoothly left and right -- instead of
"stuttering" when passing over a zero-width character.

Pressing <Delete> on a normal (spacing) character also deletes
any zero-width characters after it.  But pressing <Backspace>
while the cursor is placed after a zero-width character, just
deletes that zero-width character.  The latter behavior allows
deleting and retyping just the combining diacritic of a character
instead of the whole character.

This addresses https://savannah.gnu.org/bugs/?50773.
Requested-by: Mike Frysinger <vapier@gentoo.org>
2020-11-17 10:21:50 +01:00
Benno Schulenberg
b7539ea985 weeding: remove a workaround for versions of ncurses before 5.9
(Yes, the test is for 6.0, but the bug was actually fixed in 5.9,
as far as I remember -- I just wasn't sure and didn't want to bother
building different versions of ncurses myself.)
2020-11-15 10:27:22 +01:00
Benno Schulenberg
7d35f71c87 weeding: remove a workaround for early versions of ncurses-6.0
Those versions are more than five years old.  If there are still
machines with those versions, people should upgrade ncurses too
if they want the newest version of nano.
2020-11-15 10:27:22 +01:00
Benno Schulenberg
7f184ee2ba linting: avoid putting the cursor beyond the end of the line
Some linters report a column position (assuming a TAB to be 8 spaces)
instead of a byte index, so make sure that the cursor is not placed
out of bounds when interpreting such a column number as an index.

This fixes https://savannah.gnu.org/bugs/?59419.
Reported-by: Ava McWhorter <qwerty0s.e.m@gmail.com>

Bug existed since version 2.8.1, commit 2439e1e4.
2020-11-06 10:36:08 +01:00
Benno Schulenberg
ec9fc5d320 utils: die when trying to allocate zero bytes
This shouldn't occur, so go down when it does.
2020-10-29 16:18:03 +01:00
Benno Schulenberg
3c2eb96243 tweaks: rename two variables and improve two comments 2020-10-21 12:24:52 +02:00
Benno Schulenberg
de313586ab tweaks: reshuffle three lines and elide braces after the previous change 2020-10-21 11:39:56 +02:00
Benno Schulenberg
e96bda4b9f tweaks: avoid copying an option's argument when there is no need
This takes eight extra calls of copy_of(), but saves ten calls of
free().  But more importantly: it avoids an unneeded copying and
then freeing again of the argument after 'titlecolor' and friends.
2020-10-21 11:37:21 +02:00
Benno Schulenberg
d9944c03c4 docs: adjust for the changed name of the header-file package on Debian
Also, be more complete, reword a few things, and stop mentioning Slang.
2020-10-11 16:44:40 +02:00
Benno Schulenberg
b9d6d547b8 bindings: accept b for scrolling back up in help viewer and file browser
Like in Dillo, and because it could be mnemonic for "Back" and
is directly above the space bar (in a QWERTY layout, at least).
2020-10-11 16:11:21 +02:00
Benno Schulenberg
622b031e27 docs: use standard-compliant HTML entities for the four arrows
HTML 4 knows only the four-letter abbreviations for the arrows.
Use those, so that also browsers with very limited knowledge
(like Dillo) will show the arrows correctly.
2020-10-11 15:58:40 +02:00
Benno Schulenberg
26f5c8b9d5 rcfile: stop accepting 'set view' in a nanorc file, and undocument it
Like --restricted, --view really only makes sense on the command line.
2020-10-10 12:42:20 +02:00
Benno Schulenberg
e1601d2eb5 tweaks: use the standard symbols for the three standard file descriptors
Also, take into account (as elsewhere) that dup2() could fail,
and harmonize their error checks.
2020-10-10 12:32:02 +02:00
Benno Schulenberg
bc14fc35d7 tweaks: reshuffle a line, elide two braces, and adjust the indentation
And improve a comment.
2020-10-08 15:07:03 +02:00
Benno Schulenberg
f660f22623 tweaks: slightly shorten a loop, to place the actual action outside of it
And in the bargain elide a variable, and make it clearer
what the return value is at two early exit points.

[This change makes use of the fact that TRUE (successful write) == 1
and FALSE (failed write) == 0.  But this is already used twenty lines
earlier, for the other call of write_file().]
2020-10-08 15:07:03 +02:00
Benno Schulenberg
300f67d78f po: update translations and regenerate POT file and PO files 2020-10-07 11:07:06 +02:00
Benno Schulenberg
8a3ecfe5c1 tweaks: correct some typos and spellos in the changelog 2020-10-07 10:44:03 +02:00
Benno Schulenberg
ced0019b6c bump version numbers and add a news item for the 5.3 release 2020-10-07 10:40:12 +02:00
Benno Schulenberg
5d88528fe4 tweaks: rewrap nine more old NEWS items, for balanced line lengths 2020-10-05 17:25:05 +02:00
Benno Schulenberg
1572248866 build: exclude the three --help column headers from the tiny version 2020-10-03 12:15:38 +02:00
Benno Schulenberg
d26916199b tweaks: reshuffle some lines after the previous change 2020-10-03 11:58:43 +02:00
Benno Schulenberg
2e9fb7d840 build: exclude option --tabsize (-T) from the tiny version
An unneeded option when wanting nano to be small.  Excluding it saves
roughly 120 bytes.  It also makes the output of --help nice and clean.
2020-10-03 11:25:43 +02:00
Benno Schulenberg
7a086bef08 gnulib: update to its current upstream state 2020-10-02 10:34:54 +02:00
Benno Schulenberg
777082a7b8 docs: add a link to the website also to the info manual
And add a reference to the "cheat sheet" to the nanorc man page.
2020-10-02 10:32:44 +02:00
Benno Schulenberg
a4e3d88c67 version: remove URL and email address from the --version output
Web links and email addresses do not belong in the version information.
This has bothered me for a long time.  The URL is in the man page, and
bug reports should go to Savannah.
2020-10-02 10:23:40 +02:00
Benno Schulenberg
06b903f807 tweaks: rewrap three NEWS items, for more balanced line lengths 2020-10-01 14:56:14 +02:00
Benno Schulenberg
d2869ab348 build: include some raw sequences for the graphical Debian installer
The terminal window in the graphical Debian installer (the default)
produces the same escape sequences as xterm for F1 to F4.  Though
TERM is set to xterm, the xterm terminfo data is not available, so
ncurses is unable to translate the sequences for us.  :|  Therefore,
recognize the relevant raw escape sequences.

Also, eat all bytes of the non-recognized modified function and arrow
keys, so that they do not enter junk into the buffer.
2020-10-01 14:43:34 +02:00
Benno Schulenberg
072c8aa39b options: move --stateflags (-%) and --magic (-!) to the end of the list
It's nicer to start the list with -A, -B, -C.  And, when the user
does 'nano --help', these new flags are more likely to be noticed.
2020-10-01 11:24:39 +02:00
Benno Schulenberg
5bd92d4c60 options: add -? as a synonym of -h (--help), but leave it undocumented
This option was lost six years ago in commit 43019189, without giving a
reason for it.  It's not really needed, but it doesn't hurt to have it.
2020-10-01 10:45:22 +02:00
Benno Schulenberg
d6c194265f build: exclude excessive version information from the tiny version
The tiny version is about being tiny.  Copyright information and
website links are not essential.
2020-10-01 10:44:37 +02:00
Benno Schulenberg
3f938e29b6 build: exclude bunches of raw escape sequences from the tiny version
The tiny version is probably only ever used in the Debian installer,
on the bterm terminal, which produces escape sequences like those of
a Linux console.  So, exclude all other raw sequences.

(After support for Slang has been removed, we can maybe even exclude
ALL raw sequences from the tiny version, and the corresponding option
(-K/--rawsequences) too.)
2020-10-01 09:06:12 +02:00
Benno Schulenberg
037b77555e tweaks: condense a bit of code after the previous change 2020-09-30 19:51:29 +02:00
Benno Schulenberg
51b9e86d13 tweaks: remove mistaken escape sequences for function keys on xterm
At least since version 229 of xterm (from August 2007), the escape
sequences for F1 to F4 have been "Esc O P" to "Esc O S".  There is
no bracket in those sequences, and there probably never was -- most
likely the extra "[" in nano's code was a slip of the fingers.
2020-09-30 19:46:48 +02:00
Benno Schulenberg
cbf6fd021a tweaks: remove an usused element from 'funcstruct', saving 8 more bytes 2020-09-28 11:57:03 +02:00
Hussam al-Homsi
b093d19262 tweaks: reorder a member of 'funcstruct', to save 8 bytes of padding
Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2020-09-28 11:57:03 +02:00
Benno Schulenberg
7c698a9c3a syntax: sh: recognize some shell scripts by their Emacs modeline
This helps with recognizing most files in /usr/share/bash*/completions/,
where --magic is powerless.
2020-09-28 11:56:17 +02:00
Benno Schulenberg
17f531890a display: skip a special-case refresh when a message was written
This fixes https://savannah.gnu.org/bugs/?59188.

Bug existed since the previous commit, dac58bb6.
2020-09-27 11:23:23 +02:00
Benno Schulenberg
dac58bb651 display: do not wipe the status bar when the terminal has just one row
If there is just one row, the edit window would be wiped too.

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

Bug existed in this form since version 4.4, commit f7d5a82a.
2020-09-25 19:59:06 +02:00
Benno Schulenberg
4a403ae00f display: do not unnecessarily wipe the status bar
It would wipe the edit window if there is just one row.

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

Bug existed since version 2.9.3.
2020-09-25 16:52:31 +02:00
Benno Schulenberg
2c41600957 docs: explain the purpose of -! / --magic / 'set magic'
Also, colorize 'set magic' as valid option in a nanorc file.
2020-09-25 16:35:50 +02:00
Benno Schulenberg
58a3293efc options: require --magic or 'set magic' to enable the use of libmagic
Trying to determine which syntax to apply with the help of libmagic
can be a somewhat time-consuming and yet often still fruitless affair.
Therefore using libmagic should not be the default; it should require
an option to tell nano to try using libmagic when it can't determine
the applicable syntax from the file's name or first line.

This is better than having a --nomagic option (and using libmagic by
default), because when the user has 'set nomagic' in their nanorc or
--nomagic in their alias, then switching the use of libmagic back on
is troublesome.  But with --magic (and not using libmagic by default),
when nano fails to recognize a file, it is a simple ^X, add -! to the
command line, and restart.

The short form of the option is -! because we have run out of letters.

This addresses https://savannah.gnu.org/bugs/?59028.
2020-09-25 16:34:01 +02:00
Benno Schulenberg
0906181d75 tweaks: reshuffle a condition, to elide a blank string 2020-09-24 16:24:34 +02:00
Benno Schulenberg
d5fcc9271a tweaks: harmonize the spelling of a compound word, and rewrap a section 2020-09-24 16:11:04 +02:00
Benno Schulenberg
844c671bf1 docs: explain what the options --stateflags (-%) and 'set stateflags' do
Also, colorize 'set stateflags' as valid option in a nanorc file.
2020-09-23 19:48:03 +02:00
Benno Schulenberg
7ff6b97e5c tweaks: reshuffle some lines and adjust indentation after previous change
Also, exclude the state-flag stuff from the tiny version.
2020-09-23 19:48:03 +02:00
Benno Schulenberg
d679bbc802 new feature: option --stateflags to show some states in top-right corner
With --stateflags (short form: -%) or 'set stateflags', nano reserves
the righthand end of the title bar not for showing "Modified" but for
showing the state of auto-indentation (I), the mark (M), the breaking
of long lines (L), macro recording (R), and softwrapping (S).

When the buffer is modified, this is indicated with a star (*) after
the file name (shown in the center of the title bar).

This fulfills https://savannah.gnu.org/bugs/?57953.
Requested-by: Sébastien Desreux <seb@h-k.fr>
2020-09-23 19:48:03 +02:00
Benno Schulenberg
6d88281357 tweaks: rename another variable, away from being misnamed
It refers to a column number, not an x position.
2020-09-22 11:18:44 +02:00
Benno Schulenberg
32787a9f22 tweaks: rename two variables, to be more distinct
And for the second: to indicate that it isn't used.
2020-09-22 10:53:57 +02:00
Benno Schulenberg
9709dfd563 tweaks: rename two elements of history struct, away from abbreviations 2020-09-22 10:12:43 +02:00
Benno Schulenberg
6dd5a75d13 tweaks: add a hint for translators 2020-09-21 19:34:21 +02:00
Benno Schulenberg
9c04d0c956 tweaks: remove an inconsistent newline from the end of an error message
There are eight other occurrences without the newline.
And an error message should not end in a newline anyway.
2020-09-21 19:27:57 +02:00
Benno Schulenberg
c3e74f02c2 build: exclude --emptyline, --jumpyscrolling, and --noread from tiny nano
When looking at the output of 'nano --help', why confuse the user with
a cosmetic option, an awkward behavioral one, and an obscure one?
2020-09-21 19:02:07 +02:00
Benno Schulenberg
cb56cd70f5 syntax: nanorc: stop coloring 'quiet' and 'backwards' and 'finalnewline'
Those options have been obsolete for a long time already.
2020-09-21 10:37:48 +02:00
Benno Schulenberg
de0395bee9 syntax: nanorc: stop coloring 'nopauses' and 'nowrap' as valid
Those options are obsolete or deprecated.
2020-09-21 10:15:30 +02:00
Benno Schulenberg
abb5b14281 syntax: nanorc: stop coloring 'morespace' and 'smooth' as valid
Those options are deprecated, so should not be colored green but red.
2020-09-21 10:12:31 +02:00
Benno Schulenberg
2289bb7c19 tweaks: reshuffle two lines and a function name, for a consistent order
Also rewrap a a line.
2020-09-20 20:03:18 +02:00
Benno Schulenberg
746ef89745 docs: condense the desciptions of cutting and pasting
Mention the relevant keystroke directly (instead of the command name
followed by the default binding).
2020-09-20 19:38:52 +02:00
Benno Schulenberg
ffc0b4863b feedback: in the tiny version, let M-H show the helpful hint too 2020-09-19 12:23:16 +02:00
Benno Schulenberg
89f8d71001 feedback: don't give a hint for <Bsp>, and not after an Alt+key was used 2020-09-19 12:15:07 +02:00
Benno Schulenberg
a2878bff67 help: nicely pair menu items also when built with just --disable-help 2020-09-18 19:14:43 +02:00
Benno Schulenberg
34cfa55f58 feedback: show helpful message for the first ^H at the top of the file
Typing ^H (by default equivalent to Backspace) at the start of the file
is not useful.  When it happens, assume that the user is new and tried
to ask for Help.  So... explain what the caret and the "M-" in the help
lines mean.
2020-09-18 16:29:34 +02:00
Benno Schulenberg
7dd5484cb5 feedback: show a helpful message for ^G even when there is no help
Saying that "Help is not available" is useless.
Better say something that might help a newbie.
2020-09-18 16:24:15 +02:00
Benno Schulenberg
37f1d43ce3 tweaks: elide a one-line function, after reducing it to a single call 2020-09-18 15:22:12 +02:00
Benno Schulenberg
07b5d97a3a help: do not show "^G Help" in the tiny version when there is no help
Also, to keep menu items nicely grouped in the Main, Search, Replace,
and Goto menus, reorder a few items when no help is available.

This addresses https://savannah.gnu.org/bugs/?59110.
2020-09-18 15:21:24 +02:00
Benno Schulenberg
cb841de3fc feedback: make an "Unbound key" message disappear on the next keystroke
When nano reports "Unbound key" or "Unknown sequence", this message
should stay onscreen only for the relevant keystroke, not for any
succeeding keystroke.

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

Bug existed since before version 2.0.6.
2020-09-17 19:36:04 +02:00
Benno Schulenberg
e12f397140 build: do not let Slang translate escape sequences to key codes
Slang fails to translate the longer sequences, and then truncates
these sequences to just four bytes, effectively destroying them.

Therefore, when built with --with-slang, always activate --raw-sequences.

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

Bug was visible since version 2.5.0, since bindings
for Ctrl+Left/Ctrl+Right were added.
2020-09-17 16:54:41 +02:00
Benno Schulenberg
3a22028042 tweaks: make two of the changes that 'autoupdate' suggests
Also, normalize a bit of indentation.
2020-09-17 16:28:05 +02:00
Benno Schulenberg
f12264723d tweaks: replace two more occurrences of 'AC_TRY_RUN' with 'AC_RUN_IFELSE'
Leave the occurrences in the Slang stuff alone, as all that stuff
will be removed after the next release.
2020-09-17 13:26:24 +02:00
Benno Schulenberg
65f14624c8 tweaks: stop 'autoupdate' from failing with "end of file in string" 2020-09-17 13:17:52 +02:00
Benno Schulenberg
30016a7e19 tweaks: harmonize the style of error messages and warnings in ./configure 2020-09-17 09:49:35 +02:00
Benno Schulenberg
e8abbc7045 build: stop using an obsolete macro, and use 'void' for signal handlers
The Autoconf manual says that 'AC_TYPE_SIGNAL' is obsolete and
that it is fine to simply use 'void' instead of 'RETSIGTYPE'.
2020-09-16 16:27:32 +02:00
Benno Schulenberg
235f92ce09 build: do not accept --enable-libmagic when not having color support
When nano does not support any syntaxes, libmagic is irrelevant.

This fixes https://savannah.gnu.org/bugs/?59070.
2020-09-16 16:27:15 +02:00
Benno Schulenberg
22fc10911a tweaks: remove two stray comments and two lines that were commented out
And adjust the indentation after the latter change.
2020-09-16 16:21:37 +02:00
Ryan Westlund
11ae201d71 syntax: markdown: add author and license line
Signed-off-by: Ryan Westlund <rlwestlund@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2020-09-15 19:11:35 +02:00
Arturo Borrero González
8586efda0b syntax: nftables: include author and license lines
Signed-off-by: Arturo Borrero González <arturo@debian.org>
2020-09-14 19:52:25 +02:00
Benno Schulenberg
9e382ba691 syntaxes: add author and license lines to four of the files
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2020-09-14 19:38:29 +02:00
Benno Schulenberg
accb645d3f browser: wipe the status bar before searching again with M-W or M-Q
In this way, any message that is on the status bar after the search
will be a response to this search and not some leftover.

This fixes https://savannah.gnu.org/bugs/?59109.
2020-09-14 11:15:00 +02:00
Benno Schulenberg
620496f5cd build: avoid two compiler warnings when gnulib has been ripped out 2020-09-14 11:02:31 +02:00
Benno Schulenberg
73cd96838e help: do not leave the cursor on the status bar after a search
(This effectively reverts commit ba47abb4 from two days ago, but it
groups things better.  It makes an unnecessary call to bottombars()
for M-Q and M-W, but this hardly matters: searching in a help text
does not need to be efficient.)

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

Bug existed since commit ba47abb4 from two days ago.
2020-09-13 10:24:22 +02:00
Benno Schulenberg
82080b044b docs: mention that syntax definitions are available in /usr/share/nano/
Inspired-by: Hussam al-Homsi <sawuare@gmail.com>
2020-09-12 12:48:37 +02:00
Benno Schulenberg
93b25ce014 tweaks: adjust some whitespace in the docs, and improve a comment 2020-09-12 12:21:24 +02:00
Benno Schulenberg
f883465263 build: exclude reading a file from standard input from the tiny version
The tiny version is about being small, not about convenience features
that hardly anyone uses anyway.

Also exclude the description of the "+line[,column]" feature -- it is
unneeded verbosity.

This addresses https://savannah.gnu.org/bugs/?59101.
2020-09-12 11:44:22 +02:00
Benno Schulenberg
ba049fcaf8 tweaks: avoid a compiler warning when compiling with more than -O1 2020-09-11 18:59:04 +02:00
Benno Schulenberg
ba47abb473 help: ensure the help lines are always drawn, also when using Slang
This is needed when --enable-tiny and --with-slang are used together
with --enable-help.
2020-09-11 18:55:21 +02:00
Benno Schulenberg
b9a1a586c0 display: force the cursor to reappear in a better way (when using Slang)
The cursor would disappear after any message on the status bar --
for example, also when M-W is typed and nothing is found -- so the
mitigation trick needs to be performed in statusline() itself.

This addresses https://savannah.gnu.org/bugs/?59091.
2020-09-11 18:54:49 +02:00
Benno Schulenberg
7b19b4114c docs: improve two wordings in the sample nanorc 2020-09-11 10:45:19 +02:00
Benno Schulenberg
3e9c2ecc85 help: in the tiny version, show Prev/Next Word before Backward/Forward
In the tiny version (built with Slang and running on Debian's bterm)
the Ctrl+Left/Ctrl+Right keystrokes do not work.  When the terminal
is wide enough, instead of showing ^B + ^F for Backward and Forward
(which are unneeded because the unmodified arrow keys work fine),
show M-B + M-N for Prev Word and Next Word.

(Listing ^Space and M-Space instead would cause "Prev Word" and
"Next Word" to be truncated.  They are weird keystrokes anyway.)

Also, list M-Q + M-W for "Previous" and "Next" next to "Where Is"
and "Replace", so that it is slightly clearer what they refer to.
2020-09-11 10:00:21 +02:00
Benno Schulenberg
3940032cd3 syntax: po: do not leave the occasional tab with a red background color 2020-09-10 19:48:31 +02:00
Benno Schulenberg
d2d0c665b1 display: force the cursor to reappear after a message (when using Slang)
For some reason, when running a tiny nano built with Slang on the bterm
of a Debian installer image, the cursor disappears when certain things
are written to the status bar.  Make the cursor reappear by rewriting
the two help lines with dummy items (and then rewriting it again with
the normal menu in the central loop).  Of course, this does not help
when the user uses -x or --nohelp to suppress the help lines, but at
least in the default setup the cursor doesn't get hidden now and then.

This mitigates https://savannah.gnu.org/bugs/?59091.

Bug existed since before version 2.2.4.
2020-09-10 18:46:48 +02:00
Benno Schulenberg
50aa3587d4 build: abort the update script if a PO file contains a control character
This is to prevent the ^Q from creeping back into the Romanian PO file.
2020-09-09 16:38:39 +02:00
Benno Schulenberg
0bc834e6f3 syntax: po: highlight embedded control codes that shouldn't be there
For some reason the Romanian PO file contains a literal ^Q in one
of its translated messages -- currently at line 1984.  This stray
^Q causes 'file' to classify po/ro.po as data.

Make such mistaken control codes easier to spot when using nano.
2020-09-08 19:38:55 +02:00
Benno Schulenberg
dd24f6a18d suspension: resume properly from an external SIGSTOP (when using Slang)
Slang apparently needs a call to SLsmg_refresh() to restore the screen
content and put the cursor in the right place.  But call this function
only when the suspension was actually caused by an external SIGSTOP,
because otherwise the original screen (from which nano was invoked)
gets plastered with nano's interface and content -- upon exit, this
is annoying and confusing.

Do not stuff a dummy keystroke into the input stream, as it seems to
get placed *after* the first byte of the next keystroke from the user.
That would cause an "Unknown sequence" for some keystrokes.

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

Bug existed since version 2.8.5, commit 84ff9ebb.
2020-09-08 16:54:06 +02:00
Benno Schulenberg
462e9d4822 suspension: switch off flow control at the right moment (for Slang)
This fixes https://savannah.gnu.org/bugs/?59078.

Bug existed since version 4.8, commit c09e96f2.
2020-09-08 09:15:12 +02:00
Benno Schulenberg
48ac0a64c6 tweaks: dummy commit, to add some info about the previous one
The previous commit fixed https://savannah.gnu.org/bugs/?59071.

That bug existed since version 5.1, commit cc6d1d59.

But before that, a capital Ñ could not be typed (when built with Slang)
and would enter an invalid byte upon the next keystroke.

That bug existed since version 2.8.6, commit 43a5c876.
2020-09-08 09:05:01 +02:00
Benno Schulenberg
cf4901da2d suspension: do not enter an invalid byte upon resume (when using Slang)
Instead of stuffing 0x91 into the input stream, use 0xFF when built
with Slang -- the same code that Slang itself produces when resuming
from an externally induced suspension.  This byte is ignored.

In a UTF-8 locale, it should be safe to ignore the byte 0xFF coming
from the keyboard, as no valid UTF-8 sequence can contain 0xFF.

In an ISO8859 locale, this change prevents ÿ from being typed on the
keyboard -- it can still be entered with <Esc> <Esc> 255, though.
My apologies to the people of Pierre Louÿs and L'Haÿ-les-Roses.
2020-09-07 17:09:57 +02:00
Benno Schulenberg
9f20fadee1 tweaks: normalize the indentation after the previous change 2020-09-07 11:44:29 +02:00
Benno Schulenberg
0f7a309adc suspension: properly resume from an external SIGSTOP
Trying to ignore an external SIGSTOP/SIGTSTP with SIG_IGN does not work,
so always install the SIGCONT handler so that it is possible to continue
from a SIGSTOP.

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

Bug existed since before version 2.0.6.
2020-09-07 11:26:04 +02:00
Benno Schulenberg
c771167b6a tweaks: add some comments to the C syntax, and sort some keywords
Also, fold three regexes into one, eliding some redundant parentheses.
2020-09-06 11:14:16 +02:00
Hussam al-Homsi
e1cf93640c syntax: c: colorize also the keywords that start with an underscore
Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2020-09-06 10:48:07 +02:00
Hussam al-Homsi
1716f140b7 syntax: c: colorize also the 'restrict' keyword, and the #line directive
Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2020-09-06 10:44:43 +02:00
Benno Schulenberg
586a7d22e7 docs: add the customary (1) after the name of command-line programs
Also, don't format the wrapping quotes of strings,
and normalize the formatting of default values.

This addresses https://savannah.gnu.org/bugs/?59064.
Reported-by: Helge Kreutzmann <debian@helgefjell.de>
2020-09-05 19:43:51 +02:00
Hussam al-Homsi
cab9294f62 syntax: c: colorize also one-character constants, and the null directive
Constants that consist of a single character are valid too.
And a lone hash character on a line by itself also.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2020-09-05 13:25:54 +02:00
Benno Schulenberg
98a24fc8f9 build: to verify wide curses, probe for a function that cannot be a macro
This probing has been changed four times in the past:

    git log --grep get_wch

In March 2005, commit 2161fa62 changed the probe from get_wch() to
wget_wch(), reasoning that "get_wch() might be a macro instead of
a function".  (Four months earlier, commit 3ba9c351 changed it
from addwstr() to wget_wch(), probably for the same reason.)  But
three months later, in commit 25799f68, the probe gets changed to
get_wch() again, because "it's a more generic function"...

It seems clear that the non-macro argument is the stronger one.
See the NOTES section in 'man get_wch' for its possible macroness.

This addresses https://savannah.gnu.org/bugs/?58997.
Reported-by: Randall S. Becker <rsbecker@nexbridge.com>
2020-09-03 19:47:09 +02:00
Benno Schulenberg
bbc7c59563 browser: sort names that differ only in case with uppercase first
This is the opposite of what 'ls' does in a UTF-8 locale, but nano
has never followed the collating rules of Unicode (uppercase after
lowercase, ignoring punctuation, and so on) -- it would be strange
to change that now.

Until now, nano left such equivalent names unsorted, in a seemingly
random order.

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

Bug existed since before version 2.0.6.
2020-09-03 16:28:47 +02:00
Benno Schulenberg
b122d3b8e5 docs: explain the 'set scrollercolor' option, for coloring the indicator
And mention that a background color does not work on libvte before 0.55.

To find out the version of libvte on your system:

  ls -R1 /usr/lib | grep libvte | grep 00 | grep -o "0\..."
2020-09-02 19:55:24 +02:00
Benno Schulenberg
46e769a113 rcfile: add 'set scrollercolor', for changing the color of the indicator
This fulfills https://savannah.gnu.org/bugs/?59041.
2020-09-02 19:55:24 +02:00
Benno Schulenberg
79545187b8 tweaks: move two more functions, to before the ones that call them 2020-09-02 10:19:04 +02:00
Benno Schulenberg
413a83c2e2 tweaks: move two more functions, to before the one that calls them 2020-09-02 10:09:20 +02:00
Benno Schulenberg
ab08eebfc1 tweaks: move three functions, to before the ones that call them 2020-09-02 10:02:55 +02:00
Benno Schulenberg
ac4c56f636 tweaks: fold one function into another, to elide an unneeded return value 2020-09-02 09:55:08 +02:00
Benno Schulenberg
1db7d57a24 browser: make M-W/M-Q functional right after startup, if there is history
Do the same what the normal "research" code does: if nothing was
searched for yet during this session, and there is a history of
search items, then search for the last item in that history.
2020-09-02 09:22:50 +02:00
Benno Schulenberg
e32ca98ccf tweaks: condense a bit of code
Make it equal to what the normal search code does.
2020-09-02 09:15:23 +02:00
Benno Schulenberg
5a635db262 chars: reduce searching time with roughly 85 percent for plain ASCII
Make case-insensitive searching in a UTF-8 locale eight times faster
when the actual characters involved are plain ASCII.

This makes us faster than 'less', and as fast as Vim and Emacs.

The disadvantage of this change is that searching for a string that
begins with a multibyte character is nearly ten times slower than
searching for one that begins with an ASCII character.  This may be
unsettling when searching a huge file first for a simple ASCII string
and later for a UTF-8 one.  Doing this second search, the user might
get impatient: "Why is it taking so long?"

(This patch fell through the cracks four years ago, when I worked on
the searching code.  It sat in a branch on top of other changes that
I never applied because I made different improvements.  The speedup
at the time, on that machine, was only around sixty percent, though.
But measuring it now again on the same machine, it clocks in at an
82 percent reduction with -O0 and an 87 percent reduction with -O2.)
2020-09-01 19:35:34 +02:00
Hussam al-Homsi
c87bc1d55f tweaks: stop casting the return of malloc() and friends
Those casts are redundant, and sometimes ugly.  And as the types of
variables are extremely unlikely to change any more at this point,
the protection they offer against miscompilations is moot.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2020-08-31 12:17:27 +02:00
Benno Schulenberg
5c63975097 tweaks: rename four variables, reshuffle them, and correct one type
Also, drop three unneeded comments.
2020-08-25 12:13:55 +02:00
Benno Schulenberg
fee905a34a tweaks: drop the unneeded saving and restoring of a global variable
The two functions findnextstr() and do_replace_loop() do not change
or even touch 'last_search', so there is no need to save and then
restore its value when doing corrections of misspelled words.
2020-08-25 11:58:04 +02:00
Benno Schulenberg
070c9c60ec po: update translations and regenerate POT file and PO files 2020-08-24 11:08:23 +02:00
Benno Schulenberg
63ac050733 bump version numbers and add a news item for the 5.2 release 2020-08-24 09:53:07 +02:00
Benno Schulenberg
3ade8b29cc build: stop distributing the README.GIT file
There is no need for normal users to build from git.  Do not give
the impression that that procedure is in any way recommended.
2020-08-24 09:29:05 +02:00
Benno Schulenberg
51a6d5897e gnulib: back away from a commit that causes trouble when using clang
The issue has been reported here:
  https://lists.gnu.org/archive/html/bug-gnulib/2020-08/msg00202.html
2020-08-23 10:52:20 +02:00
Benno Schulenberg
785d28d5d1 gnulib: update to its current upstream state 2020-08-23 09:10:35 +02:00
Benno Schulenberg
4873cc26f2 build: stop mentioning Slang in two ./configure messages
Nobody ought to be using Slang, so don't give people the wrong
impression by mentioning it (and even mentioning it *first*).
2020-08-23 09:05:47 +02:00
Benno Schulenberg
0f8423eb4c tweaks: elide an unneeded variable
Storing the orientation of the marked region beforehand is not needed,
as this orientation is readily available also after the justification.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

A bookmark is not yet visible in any way.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Also remove their documentation entries.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

An enhancement added in RPM 4.13:

* Sections for file trigger stanzas

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

This fulfills https://savannah.gnu.org/bugs/?57756.
Requested-by: Matthias Aßhauer <mha1993@live.de>
2020-02-09 11:55:07 +01:00
135 changed files with 57416 additions and 47347 deletions

11
.gitignore vendored
View File

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

View File

@@ -69,6 +69,7 @@ Rishabh Dave <rishabhddave@gmail.com>
Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
* Filtering text through an external command.
* Placing anchors (bookmarks) and jumping to them.
Brand Huntsman <alpha@qzx.com>
* The delayed parsing of syntax files.

1541
ChangeLog

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@@ -1,6 +1,26 @@
Improvements in GNU nano
========================
Since 6.0:
- Option --zero hides the interface and uses the whole terminal for editing.
- Colors can be given also in #rgb hexadecimal, to select the nearest color
from the 6x6x6 color-cube palette available on 256-color terminals.
- Fourteen new color names are available, from rosy to crimson.
Since 5.0:
- A search briefly spotlights the found text, in black on yellow by default.
- Option --minibar reduces the interface to a bottom bar with basic info.
- The cursor skips over combining characters, <Del> deletes them together
with the character they combine with, but <Bsp> deletes them separately.
- For using libmagic the option --magic or -! or 'set magic' is required.
- With --stateflags the state of some things is shown in the title bar.
- M-Bsp deletes a word leftward.
- With --indicator a "scrollbar" is shown, indicating position+portion.
- M-Ins places an anchor, M-PgUp/M-PgDn jump to the nearest anchor.
- Toggling help lines (M-X) and Refresh (^L) work nearly everywhere.
- Colors can be modified with the attributes "bold," and/or "italic,".
- Nine new color names: from pink and purple to orange and latte.
Since 4.0:
- Pasting from outside into nano suppresses auto-indentation.
- Such an external paste can be undone with a single M-U.
@@ -28,7 +48,7 @@ Since 2.9.0:
- Option 'set afterends' for making Ctrl+Right stop at word ends.
- A crash handler that saves changed buffers in case of a crash.
- Addition of the color name "normal", meaning the default color.
- A key can be bound to a string -- any mix of text and commands.
- A key can be bound to a string -- any mix of text and control codes.
- Error messages are shown by default in bright white on red.
- <Tab> and <Shift+Tab> can be used to indent/unindent a marked region.
- Can snip trailing whitespace while typing, with 'set trimblanks'.
@@ -92,25 +112,19 @@ Since 2.3.0:
- The option 'positionlog' for saving/restoring the cursor position.
- The ability to read and write vim-style lock files.
Visible changes since 2.0
-------------------------
* Editor Features
- The ability to rebind (reassign) keys using the nanorc.
Since 2.0.0:
- The ability to rebind keys, via a nanorc file.
- The ability to read standard input like a pager ("nano -").
- Color syntax highlighting can be set by the first line of a file.
- The ability to silence nanorc error messages (-q).
- Undo/redo operations (-u).
- Undo/redo operations (M-U/M-E, enabled with -u).
- Soft wrapping of text (-$).
* File Handling
- Better handling of backup files: if nano can't write a backup file,
it won't try to write the original file afterward.
- Emergency savefiles retain ownerships and permissions when possible.
- Performance improvements in color syntax highlighting.
Visible changes since 1.2
-------------------------
* Editor Features
Since 1.2.0:
- Support for UTF-8.
- Moving to a specified line and column of a file, instead of just a
line (+LINE,COLUMN).
@@ -119,7 +133,7 @@ Visible changes since 1.2
- Insertion of spaces instead of a tab when Tab is pressed (-E).
- The long option for -K is now --rebindkeypad.
- Regular expression searching can now be toggled when nano is built
with --enable-tiny, so -R now means something else (see below).
with --enable-tiny, so -R now means something else (see next item).
- Restricted mode that provides more security than -o (-R).
- Blanking of the statusbar after 1 keystroke instead of 25 (-U).
- Word searches can optionally skip over punctuation (-W).
@@ -127,70 +141,58 @@ Visible changes since 1.2
- Many more options are supported in the nanorc.
- Improvements to color syntax highlighting support: case insensitive
matching, the ability to include color syntaxes in separate files,
the ability to specify background colors without foreground colors,
etc.
the ability to specify background colors without foreground colors...
- Insertion of single-byte characters via Esc Esc <000-255>.
- Insertion of all characters via "Verbatim Input" mode.
- Insertion of any character via Meta-V, "Verbatim Input".
- Workaround for the "NumLock glitch".
- Meta-W now repeats the last search. Wrapping is now toggled via
Meta-L.
- Meta-W now repeats the last search. Wrapping is toggled via Meta-L.
- Replacing and spell checking only selected text.
- Indenting lines with one keystroke.
- Copying text into the cutbuffer without cutting it.
- Scrolling the text up and down single lines without moving the
cursor.
- Scrolling the text up and down single lines without moving the cursor.
- PageUp and PageDown work more smoothly when using -S.
- Scrolling the help text up and down single lines.
- Cutting all text from the current position to the end of the file
with one keystroke.
- Justifying the entire file with one keystroke.
with one keystroke (Meta-T).
- Justifying the entire file with one keystroke (Meta-J).
- Justifying without removing spaces from the ends of lines.
- Unjustifying after justifying and immediately resizing.
- Going to the first or last line of the current paragraph.
- Going to the first or last line of the file without having to go to
the "Search" prompt.
- Searching for filenames in the file browser.
- Displaying spaces and tabs differently to make it easier to tell
them apart.
- Many more functions available at the statusbar prompt: moving to the
next or previous word, searching for matching brackets, "Verbatim
Input" mode, etc.
- The glibc 2.2.3 crashes involving extended regular expressions are
no longer worked around, as they can break anything using extended
regular expressions, and glibc 2.2.3 is old. You should upgrade to
at least glibc 2.2.4.
* File Handling
- Spaces and tabs are shown differently to make it easier to tell them apart.
- Many more functions are available at the prompt: moving to the next or
previous word, searching for matching brackets, "Verbatim Input"...
- "To Line" (^W^T) and "Read from Command" (^R^X) return to their parent
menu when their keystroke is entered again (^W^T^T and ^R^X^X).
- Automatic adding of newlines to the ends of files without them can
now be disabled (-L).
- Converting from and to DOS/Mac file format is now toggled only at
the "Write File" prompt, via Meta-D and Meta-M, and the default file
format to save in is now set depending on what format the file was
originally in. -D now makes nano use bold text instead of reverse
video text, and Meta-D at the edit window now does a
word/line/character count. -O now makes the unused second line of
the screen part of the edit window, and Meta-O at the edit window
now toggles this behavior.
- Converting from and to DOS/Mac file format is now toggled only at the
"Write File" prompt, via Meta-D and Meta-M, and the default file format
to save in is now set depending on what format the file was originally
in. -D now makes nano use bold text instead of reverse video text,
and Meta-D at the edit window now does a word/line/character count.
-O now makes the unused second line of the screen part of the edit
window, and Meta-O now toggles this behavior while editing.
- Converting files that contain a mix of DOS and Mac format lines.
- Automatic switching on of -N with binary files has been removed, as
it causes problems with UTF-8 support.
Visible changes since 1.0
-------------------------
* Editor Features
- Complete Pico compatibility (--pico has been removed, and -p means
something else, see below).
- nanorc support (see nanorc.sample included in sources).
Since 1.0
- Complete Pico compatibility (option --pico has been removed,
and -p now means something else, see below).
- Support for nanorc files.
- Smooth scrolling (-S).
- Support for searching for matching braces, brackets, etc.
- Jumping to the matching brace, bracket, etc.
- Help for all editor features.
- Color syntax highlighting support.
- Quote string support, useful for mail agents, etc. (-Q).
- Insertion of output of external commands.
- Optional enabling of XON and XOFF control characters (-p).
- Tons of bugfixes/enhancements for already existing features.
* File Handling
- Option -o (--operatingdir) implements a chroot of sorts.
- Mouse support (-m) also allows clicking on shortcuts.
- Option -r allows a negative argument.
- Overwriting and appending or prepending to files.
- Writing marked text to separate files.
- Multiple file buffers (-F).
@@ -199,4 +201,12 @@ Visible changes since 1.0
- Creation of backup files (-B).
- Search/replace history (-H).
See the nano manual for detailed information on each feature.
Available in 1.0:
- Spell checking (^T).
- Justification (^J) and unjustification (^U).
- Internationalization (more translations are welcome).
- Help texts (^G).
- Resizing in X.
- On PageUp/Down, the cursor is put on the first screen line (like Pico).
- Tab completion at the prompt (for filenames and ~user).
- Cut-to-end-of-line option (-k).

View File

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

516
NEWS
View File

@@ -1,3 +1,196 @@
2022.02.09 - GNU nano 6.1 "Rețelele de socializare sunt ca un frigider"
• The behavior of ^K at a prompt has been enhanced: when there is some
text after the cursor, just this text is erased. In the most common
situation, when the cursor is at the end of the answer, the behavior
is as before: the whole answer is erased.
• At a prompt, M-6 copies the current answer into the cutbuffer.
• Large external pastes into nano are handled more quickly.
2021.12.15 - GNU nano 6.0 "Humor heeft ook zijn leuke kanten"
• Option --zero hides the title bar, status bar and help lines, and
uses all rows of the terminal as editing area. The title bar and
status bar can be toggled with M-Z.
• Colors can now be specified also as three-digit hexadecimal numbers,
in the format #rgb. This picks from the 216 index colors (that most
terminals know) the color that is nearest to the given values.
• For users who dislike numbers, there are fourteen new color names:
rosy, beet, plum, sea, sky, slate, teal, sage, brown, ocher, sand,
tawny, brick, and crimson.
• Suspension is enabled by default, invokable with ^T^Z. The options
-z, --suspendable, and 'set suspendable' are obsolete and ignored.
(In case you want to be able to suspend nano with a single keystroke,
you can put 'bind ^Z suspend main' in your nanorc.)
• When automatic hard-wrapping is in effect, pasting just a few words
(without a line break) will now hard-wrap the line when needed.
• Toggling Append or Prepend clears the current filename.
• The word count as shown by M-D is now affected by option --wordbounds;
with it, nano counts words as 'wc' does; without it (the new default),
words are counted in a more human way: seeing punctuation as space.
• The YAML syntax file is now actually included in the tarball.
2021.10.06 - GNU nano 5.9 "El manicomio ha decidido: mañana sol!"
• The extension of a filename is added to the name of a corresponding
temporary file, so that spell checking a C file, for example, will
check only the comments and strings (when using 'aspell').
• The process number is added to the name of an emergency save file,
so that when multiple nanos die they will not fight over a filename.
• Undoing a cutting operation will restore an anchor that was located
in the cut area to its original line.
• When using --locking, saving a new buffer will create a lock file.
• Syntax highlighting for YAML files has been added.
2021.06.15 - GNU nano 5.8 "Why is it necessary to be special?"
• After a search, the spotlighting is dropped after 1.5 seconds (0.8
seconds with --quick) to avoid the idea that the text is selected.
• A + and a space before a filename on the command line will put the
cursor at the end of the corresponding buffer.
• Linter messages no longer include filename and line/column numbers.
• Color name "grey" or "gray" can be used instead of "lightblack".
• The color of the minibar can be chosen with 'set minicolor'.
2021.04.29 - GNU nano 5.7 "Toți ceilalți arau câmpurile"
• The output of --constantshow (without --minibar) is more stable.
• When opening multiple buffers and there is an error message, this
message is shown again upon first switch to the relevant buffer.
• The position and size of the indicator now follow actual lines,
instead of visual lines when in softwrap mode, meaning that the
size of the indicator can change when scrolling in softwrap mode.
2021.03.03 - GNU nano 5.6.1 "Geelgors"
• Search matches are properly colorized in softwrap mode too.
• Option 'highlightcolor' has been renamed to 'spotlightcolor'.
2021.02.24 - GNU nano 5.6 "Wielewaal"
• A search match gets highlighted (in black on yellow by default),
in addition to placing the cursor at the start of the match.
The color combination can be changed with 'set highlightcolor'.
By default the cursor is hidden until the next keystroke, but
it can be forced on with --showcursor / 'set showcursor'.
• Option --markmatch / 'set markmatch' has been removed.
• Cursor position and character code are displayed in the minibar
only when option --constantshow / 'set constantshow' is used,
and their display can be toggled with M-C.
• The state flags are displayed in the minibar only when option
--stateflags / 'set stateflags' is used.
2021.01.14 - GNU nano 5.5 "Rebecca"
• Option 'set minibar' makes nano suppress the title bar and instead
show a bar with basic editing information at the bottom: file name
(plus an asterisk when the buffer is modified), the cursor position
(line,column), the character under the cursor (U+xxxx), the flags
that --stateflags normally shows, plus the percentage of the buffer
that is above the cursor.
• With 'set promptcolor' the color combination of the prompt bar can
be changed, to allow contrasting it with the mini bar (which always
has the same color as the title bar).
• Option 'set markmatch' highlights the result of a successful search
by putting the mark at the end of the match, making the match more
visible. It also suppresses the cursor until the next keystroke.
(If you dislike the hiding of the cursor, use 'set showcursor'.)
• The bindable toggle 'nowrap' has been renamed to 'breaklonglines',
to match the corresponding option, like for all other toggles.
• Support for Slang has been removed.
2020.12.02 - GNU nano 5.4 "Terre des hommes"
• Moving the cursor now skips over combining characters (and other
zero-width characters). Deleting a character deletes also any
succeeding zero-width characters, but backspacing deletes just
one character at a time.
• Workarounds for older ncurses and older libvtes were removed.
2020.10.07 - GNU nano 5.3 "Revolution!"
• Option 'set stateflags' makes nano show the state of auto-indenting,
the mark, hard-wrapping, macro recording, and soft-wrapping in the
title bar. The flags take the place of "Modified", and a modified
buffer is instead indicated by an asterisk (*) after its name.
• Nano no longer by default tries using libmagic to determine the type
of a file (when neither filename nor first line gave a clue), because
in most cases it is a waste of time. It requires using the option
--magic or -! or 'set magic' to make nano try libmagic.
• The color of the indicator can be changed with 'set scrollercolor'.
2020.08.24 - GNU nano 5.2 "Ranrapalca"
• Making certain replacements after a large paste does not crash.
• Hitting a toggle at the Search prompt does not clear the answer.
• Using --positionlog does not complain at the first start.
• A macro containing a Search command will not sometimes fail.
2020.08.12 - GNU nano 5.1 "Cantabria"
• M-Bsp (Alt+Backspace) deletes a word backwards, like in Bash.
• M-[ has become bindable. (Be careful, though: as it is the
starting combination of many escape sequences, avoid gluing
it together with other keystrokes, like in a macro.)
• With --indicator and --softwrap, the first keystroke in an
empty buffer does not crash.
• Invoking the formatter while text is marked does not crash.
• In UTF-8 locales, an anchor is shown as a diamond.
2020.07.29 - GNU nano 5.0 "Among the fields of barley"
• With --indicator (or -q or 'set indicator') nano will show a kind
of scrollbar on the righthand side of the screen to indicate where
in the buffer the viewport is located and how much it covers.
• With <Alt+Insert> any line can be "tagged" with an anchor, and
<Alt+PageUp> and <Alt+PageDown> will jump to the nearest anchor.
When using line numbers, an anchor is shown as "+" in the margin.
• The Execute Command prompt is now directly accessible from the
main menu (with ^T, replacing the Spell Checker). The Linter,
Formatter, Spell Checker, Full Justification, Suspension, and
Cut-Till-End functions are available in this menu too.
• On terminals that support at least 256 colors, nine new color
names are available: pink, purple, mauve, lagoon, mint, lime,
peach, orange, and latte. These do not have lighter versions.
• For the color names red, green, blue, yellow, cyan, magenta,
white, and black, the prefix 'light' gives a brighter color.
Prefix 'bright' is deprecated, as it means both bold AND light.
• All color names can be preceded with "bold," and/or "italic,"
(in that order) to get a bold and/or italic typeface.
• With --bookstyle (or -O or 'set bookstyle') nano considers any
line that begins with whitespace as the start of a paragraph.
• Refreshing the screen with ^L now works in every menu.
• In the main menu, ^L also centers the line with the cursor.
• Toggling the help lines with M-X now works in all menus except
in the help viewer and the linter.
• At a filename prompt, the first <Tab> lists the possibilities,
and these are listed near the bottom instead of near the top.
• Bindable function 'curpos' has been renamed to 'location'.
• Long option --tempfile has been renamed to --saveonexit.
• Short option -S is now a synonym of --softwrap.
• The New Buffer toggle (M-F) has become non-persistent. Options
--multibuffer and 'set multibuffer' still make it default to on.
• Backup files will retain their group ownership (when possible).
• Data is synced to disk before "... lines written" is shown.
• The raw escape sequences for F13 to F16 are no longer recognized.
• Distro-specific syntaxes, and syntaxes of less common languages,
have been moved down to subdirectory syntax/extra/. The affected
distros and others may wish to move wanted syntaxes one level up.
• Syntaxes for Markdown, Haskell, and Ada were added.
2020.05.23 - GNU nano 4.9.3 "Almendras"
• One more bug introduced in version 4.9 is fixed: a crash when
the terminal screen is resized while at a lock-file prompt.
2020.04.07 - GNU nano 4.9.2 "Mali Lošinj"
• Another bug introduced in version 4.9 is fixed: a likely crash
after undoing an <Enter> at the end of leading whitespace.
2020.03.31 - GNU nano 4.9.1 "Sapperdeflap"
• Two bugs introduced in version 4.9 are fixed: the cursor
getting misplaced when undoing line cuts, and filtering
of the whole buffer to a new buffer not working.
2020.03.24 - GNU nano 4.9 "die fetten Jahre sind vorbei"
• When justifying a selection, the new paragraph and the
succeeding one get the appropriate first-line indent.
• Trying to justify an empty selection does not crash.
• Redoing the insertion of an empty file does not crash.
• On the BSDs and macOS, ^H has become rebindable again
(in most terminal emulators, not on the console).
• DOS line endings in nanorc files are accepted.
• Option --suspend / 'set suspend' has been renamed to
the more logical --suspendable / 'set suspendable'.
2020.02.07 - GNU nano 4.8 "Jaška"
• When something is pasted into nano, auto-indentation is suppressed,
and the paste can be undone as a whole with a single M-U.
@@ -25,7 +218,7 @@
It allows running a syntax-specific command on the contents of
the buffer.
• ^T will try to run 'hunspell' before 'spell', because it checks
spellling for the locale's language and understands UTF-8.
spelling for the locale's language and understands UTF-8.
• Multiple errors or warnings on startup will no longer slow nano
down but will be indicated on the status bar with trailing dots.
@@ -44,6 +237,7 @@
2019.06.18 - GNU nano 4.3 "Musa Kart"
• The ability to read from and write to a FIFO has been regained.
• Opening a file no longer triggers an inotify CLOSE_WRITE event.
• Startup time is reduced by fully parsing a syntax only when needed.
• Asking for help (^G) when using --operatingdir does not crash.
• The reading of a huge or slow file can be stopped with ^C.
@@ -448,7 +642,7 @@
2016.02.12 - GNU nano 2.5.2 is carrying too many dogs. This release
includes several fixes for various memory leaks, position-
history size growth, and a long standing issue with using
history size growth, and a long-standing issue with using
nano under sudo creating root-owned files. There are also
the usual bevy of documentation and other miscellaneous
fixes and touchups. Upgrade today while supplies last,
@@ -690,28 +884,27 @@
2009.11.30 - GNU nano 2.2.0 "Doc Brown" is released! The culmination
of almost two years of development and hot on the heels
of nano's 10th birthday is available for all your
editing needs! Bugs fixed since the last release
include several fixes for tiny mode (involving both
the help keys and replace menu text), more 'final'
fixes for soft wrapping, and several typo and documentation
updates including nanorc tweaks and a new syntax
highlighting file for makefiles. Also included is a long
standing fix for random crashing when using nanorc on
FreeBSD, and nano will no longer clear the screen on
suspend to maintain compatibility with other *nix editors.
For those who haven't been playing along at home, please
see the official web page for the summary of new
features since 2.0. Special thanks to all who have
submitted bug reports recently in support of our new
stable release, and apologies for all those bugs we
didn't yet find :-) Peace to all.
of nano's 10th birthday is available for all your editing
needs! Bugs fixed since the last release include several
fixes for tiny mode (involving both the help keys and
replace menu text), more 'final' fixes for soft wrapping,
and several typo and documentation updates including nanorc
tweaks and a new syntax highlighting file for makefiles.
Also included is a long-standing fix for random crashing
when using nanorc on FreeBSD, and nano will no longer clear
the screen on suspend to maintain compatibility with other
*nix editors. For those who haven't been playing along at
home, please see the official web page for the summary of
new features since 2.0. Special thanks to all who have
submitted bug reports recently in support of our new stable
release, and apologies for all those bugs we didn't yet
find :-) Peace to all.
2009.11.21 - GNU nano 2.1.99pre2 is available for a special pre-Black
Friday discount. Included are some (hopefully final)
fixes for issues with last page display caused by the
soft wrapping code, and a fix for a long standing issue
soft wrapping code, and a fix for a long-standing issue
with hitting the Home key when going through the search
history. On the features front, nano will now attempt to
retain the proper ownership and permissions when trying
@@ -839,31 +1032,31 @@
and not saving the search history when compiled with
configure options.
2008.04.24 - GNU nano 2.1.2 "New York City" is released. This release
contains fixes for binding bad keys, some
configure-specific compilation failures, and more issues
with the new input back end and in particular the status
bar. Also fixed are some long standing issues with
compiling on AIX, and a segfault when making the terminal
window too small. Rest in Peace Tim and George!
2008.06.24 - GNU nano 2.1.2 "New York City" is released. This
release contains fixes for binding bad keys, some
configure-specific compilation failures, and more
issues with the new input back end and in particular
the status bar. Also fixed are some long-standing
issues with compiling on AIX, and a segfault when
making the terminal window too small. Rest in Peace
Tim and George!
2008.04.01 - GNU nano 2.1.1 won't get fooled again. This release contains
fixes for the new user-rebindable keys (in particular
bracket match which was mis-bound), and various
problems with translations and configure-related
compilation problems are now fixed as well.
It also contains new syntax highlighting
definitions for TCL, PHP, Gentoo and Debian-related
files, and some documentation updates as well.
Please continue to send reports with the key
binding code to the Savannah page
(https://savannah.gnu.org/bugs/?group=nano).
2008.04.01 - GNU nano 2.1.1 won't get fooled again. This release
contains fixes for the new user-rebindable keys (in
particular bracket match which was mis-bound), and
various problems with translations and configure-
related compilation problems are now fixed as well.
It also contains new syntax highlighting definitions
for Tcl, PHP, Gentoo and Debian-related files, and
some documentation updates as well. Please continue to
send reports with the key binding code to the Savannah
page (https://savannah.gnu.org/bugs/?group=nano).
2008.03.18 - GNU nano 2.1.0 "under old mismanagement" is released.
This first release in the 2.1 development series
introduces rebindable keys for most actions inside
the editor. Please see the nanorc(5) page for
more information on configuring key bindings. Please
the editor. Please see the nanorc(5) page for more
information on configuring key bindings. Please
also report all keybinding bugs (crashes, missing
menu functions) using the Savannah bug tracker URL,
https://savannah.gnu.org/bugs/?group=nano and
@@ -1024,7 +1217,7 @@
2005.12.23 - GNU nano 1.3.10 rises to the surface. This release
contains several new features as well as fixes for
several longstanding bugs. The former include the
several long-standing bugs. The former include the
ability to scroll up or down single lines without
scrolling the cursor, reworked bracket searching code
that doesn't require regular expression support,
@@ -1061,9 +1254,9 @@
Have fun with it.
2005.06.30 - GNU nano 1.3.8 floats at its own level. This release
contains several new features. Among other things, you
can now move to a specified column number as well as
line number within a file, file backups saved in a
contains several new features. Among other things,
you can now move to a specified column number as well
as line number within a file, file backups saved in a
backup directory will have unique names, the search and
replace history routines should work more consistently,
you can get a word count by pressing Meta-D at the edit
@@ -1074,8 +1267,8 @@
screen updates, UTF-8 display, and flow control; a fix
for a segfault when displaying some lines ending with
tabs; better handling of constant cursor position
display; improved color parsing in the rcfile; and
support for the "Regexp" toggle in tiny mode
display; improved color parsing in the rcfile;
and support for the "Regexp" toggle in tiny mode
(-R/--regexp is gone, and --restricted's short option
has been changed to -R), among other things. Enjoy.
@@ -1246,38 +1439,37 @@
and enjoy GNU nano 1.2.0.
2003.02.13 - GNU nano 1.1.99pre3 "The last testing version, no
really!" is released. This release includes fixes for
wrapping (again), resizing, color syntax highlighting,
rcfile parsing, the mouse code, more memory leaks, and
some reversion of the code to get the user's home
directory (nano will now again rely on $HOME). There
are also translation updates, a new manual page for the
nanorc file, and an UPGRADE file detailing the changes
since version 1.0. Please submit reports for any bugs
you might find to the development team
(nano-devel@gnu.org), and enjoy nano almost-1.2.0 ;-)
2003.02.13 - GNU nano 1.1.99pre3 "The last testing version, no really!"
is released. This release includes fixes for wrapping
(again), resizing, color syntax highlighting, rcfile
parsing, the mouse code, more memory leaks, and some
reversion of the code to get the user's home directory
(nano will now again rely on $HOME). There are also
translation updates, a new manual page for the nanorc
file, and an UPGRADE file detailing the changes since
version 1.0. Please submit reports for any bugs you
might find to the development team (nano-devel@gnu.org),
and enjoy nano almost-1.2.0 ;-)
2003.02.03 - GNU nano 1.1.99pre2 "bugs in my pockets, bugs in my
shoes" is released. There are, not surprisingly, only
bugfixes in this release as we move toward the stable
1.2.0 release. Fixes are included for translatable
string format, subexpression replacement, constant
cursor position, invalid search regexes, justify, screen
state on SIGHUP and SIGTERM, cutting to end cuts with
long lines, many file browser and operating directory
bugs, memory and file descriptor leaks, marker code,
spell checker, the mouse code with long lines, multiple
buffers and non-file open errors, replacement string
length, and a silly but serious history message crash.
There is also a drastic improvement in CPU utilization
for the color regex code.
Depending on the number of bugs found in this
release, there may be a 1.1.99pre3 or RC1, or just a
1.2.0 release. Most of the major bugs seem to have been
worked out, so if you are waiting for a good time to
test nano before the official 1.2.0 release, this would
be the one to use. Happy bug hunting!
2003.02.03 - GNU nano 1.1.99pre2 "bugs in my pockets, bugs in my shoes"
is released. There are, not surprisingly, only bugfixes
in this release as we move toward the stable 1.2.0
release. Fixes are included for translatable string
format, subexpression replacement, constant cursor
position, invalid search regexes, justify, screen state on
SIGHUP and SIGTERM, cutting to end cuts with long lines,
many file browser and operating directory bugs, memory and
file descriptor leaks, marker code, spell checker, the
mouse code with long lines, multiple buffers and non-file
open errors, replacement string length, and a silly but
serious history message crash. There is also a drastic
improvement in CPU utilization for the color regex code.
Depending on the number of bugs found in this release,
there may be a 1.1.99pre3 or RC1, or just a 1.2.0 release.
Most of the major bugs seem to have been worked out, so if
you are waiting for a good time to test nano before the
official 1.2.0 release, this would be the one to use.
Happy bug hunting!
2003.01.17 - GNU nano 1.1.99pre1 "enough already" has been released.
This release is, barring bug fixes and documentation
@@ -1338,19 +1530,19 @@
word and next word, nanorc parser and line wrapping
code. Have fun!
2002.07.25 - At long last! GNU nano 1.1.10 "What didn't we break?" is
released. This version of GNU nano features version
2002.07.25 - At long last! GNU nano 1.1.10 "What didn't we break?"
is released. This version of GNU nano features version
0.11.2 of gettext, building with automake 1.6, some new
code for displaying control characters, browser
improvements, a new backup file option (-B, --backup), a
new option to ignore rc files (-I, --ignorercfiles),
improvements, a new backup file option (-B, --backup),
a new option to ignore rc files (-I, --ignorercfiles),
compatibility with -pedantic, handling null characters
before EOF, a slightly sportier nanorc.sample and more.
Fixes are included for justification,
the reading and writing file routines, resizing and fill
length, millions of memory leaks, the usage screen was
updated, and the --quotestr and --regexp really work
now ;-) Enjoy :)
Fixes are included for justification, the reading
and writing file routines, resizing and fill length,
millions of memory leaks, the usage screen was updated,
and the --quotestr and --regexp really work now ;-)
Enjoy :)
2002.05.12 - GNU nano 1.1.9 is released, happy Mother's Day! This
release includes many new features, including a prepend
@@ -1551,9 +1743,9 @@
some compatibility issues with older ncurses libraries
have also been fixed. All in all, a lot to see.
2001.01.31 - Nano 0.9.99pre2 is released. Not surprisingly, all that is
new is bugfixes, bugfixes, bugfixes. There were a few
cleanups in unneeded global variables and duplicate
2001.01.31 - Nano 0.9.99pre2 is released. Not surprisingly, all that
is new is bugfixes, bugfixes, bugfixes. There were a
few cleanups in unneeded global variables and duplicate
functions, but most is just fixing. Specifically, there
is now a preliminary (read: needs testing) fix for
resizing the editor in any mode other than normal edit
@@ -1597,9 +1789,9 @@
main reason for this release is the less-than-optimal
fix for the security issue in nano with following
symbolic links. Hopefully this will fix the problem
permanently. The --nofollow option also works again for
those who are real security nuts. There are also some
display and search fixes, and the --disable-spell
permanently. The --nofollow option also works again
for those who are real security nuts. There are also
some display and search fixes, and the --disable-spell
function was renamed to --disable-speller to be in line
with nano and Pico's "speller" term.
@@ -1620,27 +1812,26 @@
2000.11.23 - Happy Thanksgiving! Nano 0.9.21 is our "last version was
a big turkey" release. It fixes several bugs introduced
by the previous version, as well as a few long- standing
by the previous version, as well as a few long-standing
display bugs. All 0.9.20 users are strongly encouraged
to upgrade to this release.
2000.11.18 - Nano 0.9.20 is finally out the door. Probably the biggest
change is the brand new way nano displays previous
search and replace strings (they are now editable!)
This is a break from Pico's (inconsistent) interface, so
if you don't like the new way, "Pico" mode (-p on the
command line or Meta-P within nano) still works the
"old" way.
change is the brand new way nano displays previous search
and replace strings (they are now editable!) This is a
break from Pico's (inconsistent) interface, so if you
don't like the new way, "Pico" mode (-p on the command
line or Meta-P within nano) still works the "old" way.
Other new features include being able to deal with
search strings of any length, a new internal spell
feature (courtesy of Mr. Rocco Corsi) and tab completion
when reading in or writing out files! There's also the
usual billion or so bug fixes. Feedback on this release
is welcome because so much has changed, especially with
the previous string display in search and replace.
Email -> nano@nano-editor.org <-. If you like
something, don't like something, or just want to order a
pizza, let us know!
search strings of any length, a new internal spell feature
(courtesy of Mr. Rocco Corsi) and tab completion when
reading in or writing out files! There's also the usual
billion or so bug fixes. Feedback on this release is
welcome because so much has changed, especially with the
previous string display in search and replace. Email
-> nano@nano-editor.org <-. If you like something,
don't like something, or just want to order a pizza,
let us know!
2000.10.02 - Nano 0.9.19 is the "Chris is getting married in less than
a week and needs a distraction" release. There are only
@@ -1723,12 +1914,11 @@
(id).
2000.06.06 - Nano 0.9.10 is primarily a bugfix for the loss of SIGINT
when using "run and terminate" flags (for example,
--help). There are also some minor documentation
updates. This version of nano is the most stable in
quite some time, and is likely to be the most stable for
awhile. Users are encouraged to upgrade to this
version.
when using "run and terminate" flags (for example, --help).
There are also some minor documentation updates. This
version of nano is the most stable in quite some time,
and is likely to be the most stable for awhile. Users
are encouraged to upgrade to this version.
2000.05.31 - Nano 0.9.9 introduces much better working i18n support,
more portability, and a ton of bugfixes. While nano is
@@ -1743,10 +1933,10 @@
are also the obligatory display fixes and speedups.
Have fun with it.
2000.05.14 - Nano 0.9.7 (the Mother's Day release) continues in the long
line of display fixes, and also fixes the broken symlink
behavior (i.e. symlinks weren't being followed by
default). Hopefully all major bugs can be worked out
2000.05.14 - Nano 0.9.7 (the Mother's Day release) continues in the
long line of display fixes, and also fixes the broken
symlink behavior (i.e. symlinks weren't being followed
by default). Hopefully all major bugs can be worked out
soon and we can have a 1.0 release before the end of the
year, but who knows.
@@ -1757,15 +1947,14 @@
most stable versions of nano to date, but this one may
not be too bad =-)
2000.05.01 - Nano 0.9.5 attempts to speed up the display of text
to be at least somewhat reasonable. Much code profiling
has been done to reduce the ridiculous number of
redundant display updates. This will probably expose a
lot of bugs that can then be fixed, so this release is
probably not for the faint of heart. For anyone
curious, I would call nano 0.9.2 the most stable version
recently, so use that if you're not particularly
concerned with being on the bleeding edge.
2000.05.01 - Nano 0.9.5 attempts to speed up the display of text to be
at least somewhat reasonable. Much code profiling has been
done to reduce the ridiculous number of redundant display
updates. This will probably expose a lot of bugs that can
then be fixed, so this release is probably not for the faint
of heart. For anyone curious, I would call nano 0.9.2 the
most stable version recently, so use that if you're not
particularly concerned with being on the bleeding edge.
2000.04.25 - Nano 0.9.4 fixes some problems in 0.9.3 with the last
line code and related segfaults. It now also has much
@@ -1843,19 +2032,19 @@
it is yours to take care of and keep up to date.
2000.03.01 - Well, to continue my trend of going back on my previous
release's comments, nano 0.8.7 is released. The
crashing behavior was still occurring, and this most
recent fix also fixes some other wrapping problems, so
here you go. There may be another release soon, there
may not be, is that vague enough? =)
release's comments, nano 0.8.7 is released. The crashing
behavior was still occurring, and this most recent fix
also fixes some other wrapping problems, so here you go.
There may be another release soon, there may not be, is
that vague enough? =)
2000.02.25 - More minor bugfixes in 0.8.6, the bizarre behavior at the
end of a page has ceased, thankfully. I'm also moving
next weekend, so don't be shocked if you don't see a new
version of nano next week =-)
2000.02.11 - Okay, here we go again. Aside from a few minor fixes and
some under-the-hood changes, you won't notice much
2000.02.11 - Okay, here we go again. Aside from a few minor fixes
and some under-the-hood changes, you won't notice much
different in this version of nano. I haven't gotten
much feedback on the help feature, is it simply amazing
or does no one care? Write and let me know! =)
@@ -1870,23 +2059,22 @@
address nano@asty.org for bugs, etc.
2000.02.02 - Okay, I hate to go back on what I said in the last release,
but I may be changing jobs very soon. I will release
version 0.8.2 as is (no i18n, no help menu (yet)). I
expect things to settle down by the end of next week,
and then I can try to start on the i18n support and help
menu; look for these new features in version 0.8.5 to
0.9.0.
but I may be changing jobs very soon. I will release version
0.8.2 as is (no i18n, no help menu (yet)). I expect things
to settle down by the end of next week, and then I can try to
start on the i18n support and help menu; look for these new
features in version 0.8.5 to 0.9.0.
2000.01.28 - Nano 0.8.1 marks our first official step toward
internationalization (i18n) and the help system (^G). I
will be merging in Jordi's patches for initial i18n in
the next version, and will implement the help system
internationalization (i18n) and the help system (^G).
I will be merging in Jordi's patches for initial i18n
in the next version, and will implement the help system
with i18n built into it shortly after that. Please
don't hesitate to send bug reports, as long as you're
sure the fault lies with nano =-).
2000.01.25 - Nano 0.8.0 is officially the 'let's try and be at least a
little portable, mmmmkay?' release. There are many
2000.01.25 - Nano 0.8.0 is officially the "let's try and be at least
a little portable, mmmmkay?" release. There are many
portability checks and fixes; many thanks to Andy Kahn
for his patches. I removed the broken do_spell behavior
with the 'spell' program; for now, we only try to call
@@ -1896,31 +2084,29 @@
2000.01.24 - Nano 0.7.9 features many new features. Among them are a
new autoindent feature (-i, --autoindent), tempfile flag
like Pico's -t flag (-t, --tempfile), and preliminary
spelling program support. The spelling function tries
to run 'spell' and then 'ispell' in that order, but you
can specify another spelling program with -s or
--speller.
spelling program support. The spelling function tries to
run 'spell' and then 'ispell' in that order, but you can
specify another spelling program with -s or --speller.
2000.01.17 - Nano 0.7.7 is officially the 'way too much stuff changed this
release' release. It's the busy time at work for me, so
please don't get offended if your patch doesn't get
included in the next immediate version of nano. I'm
sure all the changes in this release will cause a few
bugs, so 0.7.8 will primarily be about fixing those
bugs.
2000.01.17 - Nano 0.7.7 is officially the "way too much stuff changed
this release" release. It's the busy time at work for me,
so please don't get offended if your patch doesn't get
included in the next immediate version of nano. I'm sure
all the changes in this release will cause a few bugs, so
0.7.8 will primarily be about fixing those bugs.
Things added this release include resizability (kinda),
new -x and -c flags (see nano -h for help), long command
line flag support, and the usual array of bugfixes.
2000.01.15 - Nano 0.7.6 is officially the 'lightning' release. It now
loads large files much faster than previous versions,
and is even much faster than Pico or vi in some rather
rudimentary tests. Many thanks to Adam Rogoyski for the
read_byte patch!
2000.01.15 - Nano 0.7.6 is officially the "lightning" release.
It now loads large files much faster than previous
versions, and is even much faster than Pico or vi
in some rather rudimentary tests. Many thanks to
Adam Rogoyski for the read_byte patch!
2000.01.09 - As of this version (0.7.4), TIP has officially been renamed
to nano. The new homepage is at
http://faculty.plattsburgh.edu/astyanax/nano. Please
update your bookmarks, tell your friends, and all that
jazz.
2000.01.09 - As of this version (0.7.4), TIP has officially
been renamed to nano. The new homepage is at
http://faculty.plattsburgh.edu/astyanax/nano.
Please update your bookmarks, tell your friends,
and all that jazz.

97
README
View File

@@ -1,10 +1,42 @@
GNU nano -- a simple editor, inspired by Pico
Overview
Purpose
The nano project was started because of a few "problems" with the
wonderfully easy-to-use and friendly Pico text editor.
Nano is a small and simple text editor for use on the terminal.
It copied the interface and key bindings of the Pico editor but
added several missing features: undo/redo, syntax highlighting,
line numbers, softwrapping, multiple buffers, selecting text by
holding Shift, search-and-replace with regular expressions, and
several other conveniences.
Appearance
In rough ASCII graphics, this is what nano's screen looks like:
____________________________________________________________________
| GNU nano 6.1 filename Modified |
--------------------------------------------------------------------
| This is the text window, displaying the contents of a 'buffer', |
| the contents of the file you are editing. |
| |
| The top row of the screen is the 'title bar'; it shows nano's |
| version, the name of the file, and whether you modified it. |
| The two bottom rows display the most important shortcuts; in |
| those lines ^ means Ctrl. The third row from the bottom shows |
| some feedback message, or gets replaced with a prompt bar when |
| you tell nano to do something that requires extra input. |
| |
--------------------------------------------------------------------
| [ Some status message ] |
|^G Help ^O Write Out ^W Where Is ^K Cut ^T Execute |
|^X Exit ^R Read File ^\ Replace ^U Paste ^J Justify |
--------------------------------------------------------------------
Origin
The nano project was started in 1999 because of a few "problems"
with the wonderfully easy-to-use and friendly Pico text editor.
First and foremost was its license: the Pine suite does not use
the GPL, and (before using the Apache License) it had unclear
@@ -23,9 +55,22 @@ Overview
The nano editor is an official GNU package. For more information on
GNU and the Free Software Foundation, please see https://www.gnu.org/.
License
Nano's code and documentation are covered by the GPL version 3 or
(at your option) any later version, except for two functions that
were copied from busybox which are under a BSD license. Nano's
documentation is additionally covered by the GNU Free Documentation
License version 1.2 or (at your option) any later version. See the
files COPYING and COPYING.DOC for the full text of these licenses.
When in any file of this package a copyright notice mentions a
year range (such as 1999-2011), it is a shorthand for a list of
all the years in that interval.
How to compile and install nano
Download the latest nano source tarball, then:
Download the latest nano source tarball, and then:
tar -xvf nano-x.y.tar.gz
cd nano-x.y
@@ -33,12 +78,13 @@ How to compile and install nano
make
make install
It's that simple. Use --prefix with configure to override the
default installation directory of /usr/local.
You will need the header files of ncurses installed for ./configure
to succeed -- get them from libncurses-dev (Debian) or ncurses-devel
(Fedora) or a similarly named package. Use --prefix with ./configure
to override the default installation directory of /usr/local.
If you haven't configured with the --disable-nanorc option, after
installation you may want to copy the doc/sample.nanorc file to
your home directory, rename it to ".nanorc", and then edit it
After installation you may want to copy the doc/sample.nanorc file
to your home directory, rename it to ".nanorc", and then edit it
according to your taste.
Web Page
@@ -49,31 +95,28 @@ Mailing Lists
There are three nano-related mailing-lists.
+ info-nano@gnu.org is a very low traffic list used to announce
* <info-nano@gnu.org> is a very low traffic list used to announce
new nano versions or other important info about the project.
+ help-nano@gnu.org is for those seeking to get help without
* <help-nano@gnu.org> is for those seeking to get help without
wanting to hear about the technical details of its development.
+ nano-devel@gnu.org is the list used by the people that make nano
* <nano-devel@gnu.org> is the list used by the people that make nano
and a general development discussion list, with moderate traffic.
To subscribe, send email to <name>-request@gnu.org with a subject
of "subscribe", where <name> is the list you want to subscribe to.
The archives of the development and help mailing lists are here:
https://lists.gnu.org/archive/html/nano-devel/
https://lists.gnu.org/archive/html/help-nano/
Bug Reports
To report a bug, please file a description of the problem on nano's
bug tracker (https://savannah.gnu.org/bugs/?group=nano -- hover on
"Bugs", then click "Submit new"). The issue may have already been
reported, so please look first.
If you find a bug, please file a detailed description of the problem
on nano's issue tracker: https://savannah.gnu.org/bugs/?group=nano
(you will need an account to be able to do so), or send an email
to the nano-devel list (no need to subscribe, but mention it if
you want to be CC'ed on an answer).
Current Status
Since version 2.5.0, GNU nano has abandoned the distinction between
a stable and a development branch: it is now on a "rolling" release
-- fixing bugs and adding new features go hand in hand.
Copyright Years
When in any file of this package a copyright notice mentions a
year range (such as 1999-2011), it is a shorthand for a list of
all the years in that interval.

View File

@@ -22,11 +22,11 @@ packages:
- pkg-config (version >= 0.22)
- texinfo (version >= 4.0)
If you want UTF-8 support, you will also need libncursesw5-dev installed
(version >= 5.7), or libslang2-dev (version >= 2.0) if you use --with-slang.
You will also need to have the header files for ncurses installed,
from libncurses-dev on Debian, ncurses-devel on Fedora, or similar.
These should all be available in your distro's package manager or software
center, or otherwise on any GNU mirror.
These should all be available in your distro's package manager or
software center, or otherwise on any GNU mirror.
Download the source
@@ -84,7 +84,6 @@ Problems?
Please submit any bugs you find in the code in git via the bug tracker
on Savannah (https://savannah.gnu.org/bugs/?group=nano).
Contributing something
----------------------
@@ -114,3 +113,11 @@ to include 'set tabsize 4', or you could use -T4 on the command line.
To make git display things as intended, you can do:
$ git config --local core.pager "less -x1,5"
To see all types that are used in nano's source code colorized as types,
you can add these lines to your ~/.nanorc:
extendsyntax c color green "\<struct (dirent|option|passwd)\>"
extendsyntax c color green "\<struct (sigaction|stat|termios)\>"
extendsyntax c color green "\<struct (timespec|vt_stat|winsize)\>"
extendsyntax c color green "\<([[:lower:]_]+(struct|type)|va_list)\>"

3
THANKS
View File

@@ -18,6 +18,8 @@ Mihai Cristescu <mihai.cristescu@archlinux.info> Romanian
Yavor Doganov <yavor@doganov.org> Bulgarian
Karl Eichwalder <keichwa@gmx.net> German
A. Murat EREN <meren@comu.edu.tr> Turkish
Sveinn í Felli <sv1@fellsnet.is> Icelandic
Marek Felšöci <marek@felsoci.sk> Slovak
Doruk Fisek <dfisek@fisek.com.tr> Turkish
Rafael Fontenelle <rffontenelle@gmail.com> Brazilian Portuguese
Pavel Fric <pavelfric@seznam.cz> Czech
@@ -73,6 +75,7 @@ Johnny A. Solbu <johnny@solbu.net> Norwegian Bokmål
Pierre Tane <tanep@bigfoot.com> French
Yasuaki Taniguchi <yasuakit@gmail.com> Japanese
Jacobo Tarrío <jtarrio@trasno.net> Galician
Andika Triwidada <andika@gmail.com> Indonesian
Francisco Javier Tsao Santín <tsao@members.fsf.org> Galician
Balázs Úr <urbalazs@gmail.com> Hungarian
Miquel Vidal <miquel@sindominio.net> Catalan

83
TODO
View File

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

View File

@@ -2,7 +2,7 @@
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="e313a5367b1e4edfa19ab5f0d001d0b060a77066"
gnulib_hash="6ef3d783333346333f35bb181ba90f5bc46c0b29"
modules="
futimens
@@ -13,6 +13,7 @@ modules="
isblank
iswblank
lstat
mkstemps
nl_langinfo
regex
sigaction
@@ -30,19 +31,31 @@ modules="
# Make sure the local gnulib git repo is up-to-date.
if [ ! -d "gnulib" ]; then
git clone --depth=123 ${gnulib_url}
git clone --depth=1111 ${gnulib_url}
fi
cd gnulib >/dev/null || exit 1
curr_hash=$(git log -1 --format=%H)
if [ "${gnulib_hash}" != "${curr_hash}" ]; then
echo "Pulling..."
git pull
git checkout -f ${gnulib_hash}
git checkout --force ${gnulib_hash}
fi
cd .. >/dev/null || exit 1
rm -rf lib
./gnulib/gnulib-tool \
--import \
${modules}
echo "Autopoint..."
autopoint --force
autoreconf -f -i -s
rm -rf lib
echo "Gnulib-tool..."
./gnulib/gnulib-tool --import ${modules}
echo
echo "Aclocal..."
aclocal -I m4
echo "Autoconf..."
autoconf
echo "Autoheader..."
autoheader
echo "Automake..."
automake --add-missing
echo "Done."

View File

@@ -1,6 +1,6 @@
# Configuration for GNU nano - a small and user-friendly text editor
#
# Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc.
# Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc.
# Copyright (C) 2014, 2017 Mike Frysinger
#
# GNU nano is free software: you can redistribute it and/or modify
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see https://www.gnu.org/licenses/.
AC_INIT([GNU nano], [4.8], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [6.1], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.14])
@@ -36,12 +36,12 @@ gl_cv_glob_lists_symlinks=yes
dnl Checks for programs.
AC_GNU_SOURCE
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
gl_EARLY
gl_INIT
AC_PROG_LN_S
AC_ISC_POSIX
AC_SEARCH_LIBS([strerror], [cposix])
AC_SYS_LARGEFILE
PKG_PROG_PKG_CONFIG
@@ -59,7 +59,7 @@ AC_DEFINE_DIR([PKGDATADIR], [pkgdatadir], [Where data are placed to.])
dnl Whether this is a git repository.
AC_MSG_CHECKING([whether building from git])
if test -d .git ; then
if test -f "$srcdir/roll-a-release.sh" ; then
AC_MSG_RESULT([yes])
from_git=yes
else
@@ -73,13 +73,14 @@ dnl Checks for pkg-config and gettext when building from git.
if test x$from_git = xyes; then
if test ! -f $(aclocal --print-ac-dir)/pkg.m4; then
AC_MSG_ERROR([
*** The pkg.m4 macros are missing. ***
*** The pkg-config package needs to be installed when building from git. ***])
*** The pkg.m4 macros are missing.
*** The pkg-config package needs to be installed when building from git.
*** After fixing this problem, rerun ./autogen.sh.])
fi
if test "$ac_cv_path_MSGFMT" = ":"; then
AC_MSG_ERROR([
*** The msgfmt program is missing. ***
*** The gettext package needs to be installed when building from git. ***])
*** The msgfmt program is missing.
*** The gettext package needs to be installed when building from git.])
fi
fi
@@ -89,12 +90,6 @@ AC_CHECK_HEADERS(libintl.h limits.h pwd.h termios.h sys/param.h)
dnl Checks for options.
if test "x$with_slang" = xyes; then
if test "x$enable_tiny" != xyes; then
AC_MSG_ERROR([--with-slang is supported only together with --enable-tiny])
fi
fi
AC_ARG_ENABLE(browser,
AS_HELP_STRING([--disable-browser], [Disable the built-in file browser]))
if test "x$enable_tiny" = xyes; then
@@ -111,7 +106,8 @@ AS_HELP_STRING([--disable-color], [Disable color and syntax highlighting]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_color" = xyes; then
if test "x$enable_nanorc" != xyes; then
AC_MSG_ERROR([--enable-color needs --enable-nanorc to work])
AC_MSG_ERROR([
*** --enable-color needs --enable-nanorc to work])
fi
else
enable_color=no
@@ -119,7 +115,8 @@ if test "x$enable_tiny" = xyes; then
fi
if test "x$enable_nanorc" = xno; then
if test "x$enable_color" = xyes; then
AC_MSG_ERROR([--enable-color cannot work with --disable-nanorc])
AC_MSG_ERROR([
*** --enable-color cannot work with --disable-nanorc])
else
# Disabling nanorc silently disables color support.
enable_color=no
@@ -134,7 +131,8 @@ AC_ARG_ENABLE(comment,
AS_HELP_STRING([--disable-comment], [Disable the comment/uncomment function]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_comment" = xyes; then
AC_MSG_ERROR([--enable-comment cannot work with --enable-tiny])
AC_MSG_ERROR([
*** --enable-comment cannot work with --enable-tiny])
else
enable_comment=no
fi
@@ -159,7 +157,8 @@ AS_HELP_STRING([--disable-help], [Disable the built-in help texts]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_help" = xyes; then
if test "x$enable_multibuffer" != xyes; then
AC_MSG_ERROR([--enable-help needs --enable-multibuffer to work])
AC_MSG_ERROR([
*** --enable-help needs --enable-multibuffer to work])
fi
else
enable_help=no
@@ -167,7 +166,8 @@ if test "x$enable_tiny" = xyes; then
fi
if test "x$enable_multibuffer" = xno; then
if test "x$enable_help" = xyes; then
AC_MSG_ERROR([--enable-help cannot work with --disable-multibuffer])
AC_MSG_ERROR([
*** --enable-help cannot work with --disable-multibuffer])
else
# Disabling multibuffer silently disables the help texts.
enable_help=no
@@ -201,6 +201,18 @@ fi
AC_ARG_ENABLE(libmagic,
AS_HELP_STRING([--disable-libmagic], [Disable detection of file types via libmagic]))
if test "x$enable_libmagic" = xyes; then
if test "x$enable_tiny" = xyes; then
if test "x$enable_color" != xyes; then
AC_MSG_ERROR([
*** --enable-libmagic needs --enable-color and --enable-nanorc to work])
fi
fi
if test "x$enable_color" = xno; then
AC_MSG_ERROR([
*** --enable-libmagic cannot work with --disable-color nor --disable-nanorc])
fi
fi
AC_ARG_ENABLE(linenumbers,
AS_HELP_STRING([--disable-linenumbers], [Disable line numbering]))
@@ -284,7 +296,8 @@ AC_ARG_ENABLE(wordcomp,
AS_HELP_STRING([--disable-wordcomp], [Disable the word-completion function]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_wordcomp" = xyes; then
AC_MSG_ERROR([--enable-wordcomp cannot work with --enable-tiny])
AC_MSG_ERROR([
*** --enable-wordcomp cannot work with --enable-tiny])
else
enable_wordcomp=no
fi
@@ -334,209 +347,16 @@ AS_HELP_STRING([--enable-altrcname], [Specify an alternate rcfile name (default:
AC_DEFINE_UNQUOTED(RCFILE_NAME, "$enableval", [Specify an alternate rcfile name (default: .nanorc).]) rcfilename=$enableval
fi])
AC_MSG_CHECKING([whether to use slang])
CURSES_LIB_NAME=""
AC_ARG_WITH(slang,
AS_HELP_STRING([--with-slang[=DIR]], [Use the slang library instead of curses]),
[ case "$with_slang" in
no)
AC_MSG_RESULT(no)
;;
*)
AC_MSG_RESULT(yes)
if test x$with_slang != xyes; then
# Add additional search path.
LDFLAGS="-L$with_slang/lib $LDFLAGS"
CPPFLAGS="-I$with_slang/include $CPPFLAGS"
fi
if test "x$enable_utf8" != xno; then
AC_CHECK_HEADER(slcurses.h,
AC_MSG_CHECKING([for SLutf8_enable in -lslang])
_libs=$LIBS
LIBS="$LIBS -lslang"
AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
SLutf8_enable(1);
return 0;
}],
[AC_MSG_RESULT(yes)
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
CURSES_LIB_WIDE=yes
if test x$with_slang != xyes; then
CURSES_LIB="-L${with_slang}/lib -lslang"
else
CURSES_LIB="-lslang"
fi
CURSES_LIB_NAME=slang],
[AC_MSG_RESULT(no)
# We might need the term library.
for termlib in ncurses curses termcap terminfo termlib; do
AC_CHECK_LIB([${termlib}], tputs, [tcap="-l$termlib"])
test -n "$tcap" && break
done
AC_MSG_CHECKING([for SLutf8_enable in -lslang $tcap])
LIBS="$LIBS $tcap"
AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
SLutf8_enable(1);
return 0;
}],
[AC_MSG_RESULT(yes)
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
CURSES_LIB_WIDE=yes
if test x$with_slang != xyes; then
CURSES_LIB="-L${with_slang}/lib -lslang $tcap"
else
CURSES_LIB="-lslang $tcap"
fi
CURSES_LIB_NAME=slang],
[AC_MSG_RESULT(no)
# We might need the math library.
AC_MSG_CHECKING([for SLutf8_enable in -lslang $tcap -lm])
LIBS="$LIBS -lm"
AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
SLutf8_enable(1);
return 0;
}],
[AC_MSG_RESULT(yes)
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
CURSES_LIB_WIDE=yes
if test x$with_slang != xyes; then
CURSES_LIB="-L${with_slang}/lib -lslang $tcap -lm"
else
CURSES_LIB="-lslang $tcap -lm"
fi
CURSES_LIB_NAME=slang],
[AC_MSG_RESULT(no)],
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
AC_MSG_WARN([*** Can not use slang when cross-compiling])),
AC_MSG_ERROR([
*** The header file slcurses.h was not found. This header file
*** is required if you wish to use Slang support. Please either
*** install a version of Slang that includes the slcurses.h file
*** or do not call the configure script with --with-slang.]))
fi
if eval "test x$CURSES_LIB_NAME = x"; then
# Reset libs if the above slang tests failed.
if test "x$enable_utf8" != xno; then
LIBS=$_libs
fi
AC_CHECK_HEADER(slcurses.h,
AC_MSG_CHECKING([for SLtt_initialize in -lslang])
_libs=$LIBS
LIBS="$LIBS -lslang"
AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
SLtt_initialize(NULL);
return 0;
}],
[AC_MSG_RESULT(yes)
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
if test x$with_slang != xyes; then
CURSES_LIB="-L${with_slang}/lib -lslang"
else
CURSES_LIB="-lslang"
fi
CURSES_LIB_NAME=slang],
[AC_MSG_RESULT(no)
# We might need the term library.
for termlib in ncurses curses termcap terminfo termlib; do
AC_CHECK_LIB([${termlib}], tputs, [tcap="-l$termlib"])
test -n "$tcap" && break
done
AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap])
LIBS="$LIBS $tcap"
AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
SLtt_initialize(NULL);
return 0;
}],
[AC_MSG_RESULT(yes)
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
if test x$with_slang != xyes; then
CURSES_LIB="-L${with_slang}/lib -lslang $tcap"
else
CURSES_LIB="-lslang $tcap"
fi
CURSES_LIB_NAME=slang],
[AC_MSG_RESULT(no)
# We might need the math library.
AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap -lm])
LIBS="$LIBS -lm"
AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
SLtt_initialize(NULL);
return 0;
}],
[AC_MSG_RESULT(yes)
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
if test x$with_slang != xyes; then
CURSES_LIB="-L${with_slang}/lib -lslang $tcap -lm"
else
CURSES_LIB="-lslang $tcap -lm"
fi
CURSES_LIB_NAME=slang],
[AC_MSG_RESULT(no)],
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
AC_MSG_WARN([*** Can not use slang when cross-compiling])),
AC_MSG_ERROR([
*** The header file slcurses.h was not found. This header file
*** is required if you wish to use Slang support. Please either
*** install a version of Slang that includes the slcurses.h file
*** or do not call the configure script with --with-slang.]))
fi
if test "${_libs+set}" = "set"; then
LIBS=$_libs
fi
if test x$with_slang != xyes; then
LDFLAGS=${_ldflags}
fi
;;
esac], [AC_MSG_RESULT(no)])
dnl Checks for functions.
if test "x$enable_utf8" != xno; then
AC_CHECK_FUNCS(iswalnum iswpunct mblen mbstowcs mbtowc wctomb)
AC_CHECK_FUNCS(iswalpha iswalnum iswpunct mbstowcs wctomb)
fi
dnl Checks for typedefs, structures, and compiler characteristics.
dnl Checks for available flags.
AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"], [], [])
dnl Checks for library functions.
AC_TYPE_SIGNAL
dnl Checks for libraries.
if eval "test x$CURSES_LIB_NAME = x"; then
@@ -566,9 +386,9 @@ if eval "test x$CURSES_LIB_NAME = x"; then
CURSES_LIB=`$NCURSESW_CONFIG --libs`
LIBS="$CURSES_LIB $LIBS"
CPPFLAGS="`$NCURSESW_CONFIG --cflags` $CPPFLAGS"
AC_CHECK_LIB(ncursesw, get_wch, [CURSES_LIB_NAME=ncursesw CURSES_LIB_WIDE=yes])
AC_CHECK_LIB(ncursesw, wget_wch, [CURSES_LIB_NAME=ncursesw CURSES_LIB_WIDE=yes])
else
AC_CHECK_LIB(ncursesw, get_wch, [CURSES_LIB="-lncursesw" CURSES_LIB_NAME=ncursesw CURSES_LIB_WIDE=yes])
AC_CHECK_LIB(ncursesw, wget_wch, [CURSES_LIB="-lncursesw" CURSES_LIB_NAME=ncursesw CURSES_LIB_WIDE=yes])
fi
LIBS="$OLDLIBS"
fi
@@ -582,7 +402,7 @@ if eval "test x$CURSES_LIB_NAME = x"; then
AC_CHECK_HEADERS(curses.h)
if test "x$enable_utf8" != xno; then
AC_CHECK_LIB(curses, get_wch, [CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses CURSES_LIB_WIDE=yes])
AC_CHECK_LIB(curses, wget_wch, [CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses CURSES_LIB_WIDE=yes])
fi
if eval "test x$CURSES_LIB_NAME = x"; then
@@ -593,10 +413,10 @@ fi
if eval "test x$CURSES_LIB_NAME = x"; then
AC_MSG_ERROR([
*** No curses lib was found. Please install the curses header files
*** from libncursesw5-dev (Debian), ncurses-devel (Fedora), or similar.
*** from libncurses-dev (Debian), ncurses-devel (Fedora), or similar.
*** (Or install ncurses from https://ftp.gnu.org/gnu/ncurses/.)])
else
AC_MSG_RESULT([Using $CURSES_LIB_NAME as the curses library])
AC_MSG_RESULT([ The curses library to be used is: $CURSES_LIB_NAME])
fi
AC_CHECK_LIB([$CURSES_LIB_NAME], [use_default_colors],
@@ -609,36 +429,31 @@ AC_CHECK_LIB([$CURSES_LIB_NAME], [key_defined],
[AC_DEFINE(HAVE_KEY_DEFINED, 1, [Define this if your curses library has the key_defined() function.])],
[], [$CURSES_LIB])
dnl Parse any configure options.
LIBS="$LIBS $CURSES_LIB"
AC_SUBST(CURSES_LIB)
if test "x$enable_utf8" != xno && \
test x$CURSES_LIB_WIDE = xyes && \
test x$ac_cv_func_iswalpha = xyes && \
test x$ac_cv_func_iswalnum = xyes && \
test x$ac_cv_func_iswpunct = xyes && \
test x$ac_cv_func_mblen = xyes && \
test x$ac_cv_func_mbstowcs = xyes && \
test x$ac_cv_func_mbtowc = xyes && \
test x$ac_cv_func_wctomb = xyes; then
AC_DEFINE(ENABLE_UTF8, 1, [Define this if your system has sufficient UTF-8 support.])
else
if test "x$enable_utf8" = xyes; then
AC_MSG_ERROR([
*** UTF-8 support was requested, but insufficient UTF-8 support was
*** detected in your curses and/or C libraries. Please verify that
*** your Slang was built with UTF-8 support or your curses was built
*** with wide-character support, and that your C library was built
*** UTF-8 support was requested, but insufficient support was
*** detected in your curses and/or C libraries. Please verify
*** that both your curses library and your C library were built
*** with wide-character support.])
elif test "x$enable_utf8" != xno; then
AC_MSG_WARN([
*** Insufficient UTF-8 support was detected in your curses and/or C
*** libraries. If you want UTF-8 support, please verify that your
*** Slang was built with UTF-8 support or your curses was built with
*** wide-character support, and that your C library was built with
*** wide-character support.])
*** Insufficient UTF-8 support was detected in your curses
*** and/or C libraries. If you want UTF-8 support, please
*** verify that both your curses library and your C library
*** were built with wide-character support.])
fi
fi
@@ -665,16 +480,16 @@ AC_DEFINE_UNQUOTED(NANO_REG_EXTENDED, $nano_reg_extended,
[Flag(s) to use to get the full range of extended regular expressions])
if test x$color_support = xyes; then
# if test x$CURSES_LIB_NAME = xcurses; then
AC_MSG_CHECKING([whether _XOPEN_SOURCE_EXTENDED is needed])
AC_TRY_RUN([
AC_MSG_CHECKING([whether _XOPEN_SOURCE_EXTENDED is needed])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <curses.h>
int main(void)
{
int testcolor = COLOR_WHITE;
return 0;
}], AC_MSG_RESULT(no),
AC_TRY_RUN([
}]])],
AC_MSG_RESULT(no),
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#ifndef _XOPEN_SOURCE_EXTENDED
#define _XOPEN_SOURCE_EXTENDED 1
#endif
@@ -683,35 +498,38 @@ int main(void)
{
int testcolor = COLOR_WHITE;
return 0;
}],
AC_DEFINE(NEED_XOPEN_SOURCE_EXTENDED, 1, [Define this if you need the _XOPEN_SOURCE_EXTENDED macro for color support.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(not sure)
AC_MSG_WARN([*** Couldn't successfully compile basic color test with or without _XOPEN_SOURCE_EXTENDED])
AC_MSG_WARN([*** This build may not compile. Consider configuring with --disable-color or installing ncurses])),
AC_MSG_WARN([*** Can't check need for _XOPEN_SOURCE_EXTENDED when cross-compiling]))
# fi
}]])],
AC_DEFINE(NEED_XOPEN_SOURCE_EXTENDED, 1, [Define this if you need the _XOPEN_SOURCE_EXTENDED macro for color support.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(not sure)
AC_MSG_WARN([
*** Couldn't successfully compile basic color test with or without
*** _XOPEN_SOURCE_EXTENDED. This build may not compile. Consider
*** configuring with --disable-color or installing ncurses.])),
AC_MSG_WARN([
*** Can't check need for _XOPEN_SOURCE_EXTENDED when cross-compiling.]))
fi
AC_MSG_CHECKING([whether LINES and COLS can be redefined])
AC_TRY_RUN([
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <curses.h>
int main(void)
{
LINES = 80;
COLS = 25;
return 0;
}],
}]])],
AC_DEFINE(REDEFINING_MACROS_OK, 1, [Define this if you know your curses library allows LINES and COLS to be redefined to deal with a resizing bug.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no),
AC_MSG_WARN([*** Can't check for macro redefinability when cross-compiling]))
AC_MSG_WARN([
*** Can't check for macro redefinability when cross-compiling.]))
AS_IF([test "x$enable_libmagic" != "xno"], [
AC_CHECK_HEADERS([magic.h])
AC_CHECK_LIB(magic, magic_open)
AC_CHECK_HEADERS([zlib.h])
AC_CHECK_LIB(z, inflate)
AC_CHECK_HEADERS([magic.h])
AC_CHECK_LIB(magic, magic_open)
AC_CHECK_HEADERS([zlib.h])
AC_CHECK_LIB(z, inflate)
])
# Check for groff html support.
@@ -720,8 +538,8 @@ groff -t -mandoc -Thtml </dev/null >/dev/null
if test $? -ne 0 ; then
AC_MSG_RESULT([no])
AC_MSG_WARN([
*** Will not generate HTML version of man pages. ***
*** Consider installing a newer version of groff with HTML support. ***])
*** Will not generate HTML version of man pages. Consider
*** installing a newer version of groff with HTML support.])
groff_html_support=no
else
AC_MSG_RESULT([yes])
@@ -738,7 +556,8 @@ m4/Makefile
po/Makefile.in
src/Makefile
syntax/Makefile
nano.spec
])
AC_OUTPUT
make showinfo

View File

@@ -2,9 +2,9 @@
<html lang="en">
<head>
<title>Cheatsheet for nano</title>
<title>Cheatsheet for GNU nano</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="A concise overview of the command shortcuts of the GNU nano editor, grouped by category.">
<meta name="description" content="A concise overview of the command shortcuts for nano, the editor, grouped by category.">
<meta name="keywords" content="cheatsheet, nano, editor, shortcuts, keystrokes, functions, operations, commands">
<meta name="author" content="Benno Schulenberg">
</head>
@@ -55,15 +55,15 @@
<table><tbody>
<tr><td>Ctrl+H</td><td>Delete character before cursor &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>
<tr><td>Ctrl+D</td><td>Delete character under cursor</td></tr>
<tr><td>Ctrl+Shift+Del &nbsp;&nbsp;</td><td>Delete word to the left</td></tr>
<tr><td>Ctrl+Del</td><td>Delete word to the right</td></tr>
<tr><td>Alt+Bsp</td><td>Delete word to the left</td></tr>
<tr><td>Ctrl+Del &nbsp;&nbsp;</td><td>Delete word to the right</td></tr>
<tr><td>Alt+Del</td><td>Delete current line</td></tr>
</tbody></table>
<br>
<b>Operations</b>
<table><tbody>
<tr><td>Ctrl+T &nbsp;&nbsp;</td><td>Run a spell check</td></tr>
<tr><td>Ctrl+T &nbsp;&nbsp;</td><td>Execute some command</td></tr>
<tr><td>Ctrl+J</td><td>Justify paragraph or region</td></tr>
<tr><td>Alt+J</td><td>Justify entire buffer</td></tr>
<tr><td>Alt+B</td><td>Run a syntax check</td></tr>
@@ -79,14 +79,14 @@
<table><tbody>
<tr><td>Ctrl+B &nbsp;&nbsp;</td><td>One character backward</td></tr>
<tr><td>Ctrl+F</td><td>One character forward</td></tr>
<tr><td>Ctrl+<b>&leftarrow;</b></td><td>One word backward</td></tr>
<tr><td>Ctrl+<b>&rightarrow;</b></td><td>One word forward</td></tr>
<tr><td>Ctrl+<b>&larr;</b></td><td>One word backward</td></tr>
<tr><td>Ctrl+<b>&rarr;</b></td><td>One word forward</td></tr>
<tr><td>Ctrl+A</td><td>To start of line</td></tr>
<tr><td>Ctrl+E</td><td>To end of line</td></tr>
<tr><td>Ctrl+P</td><td>One line up</td></tr>
<tr><td>Ctrl+N</td><td>One line down</td></tr>
<tr><td>Ctrl+<b>&uparrow;</b></td><td>To previous block</td></tr>
<tr><td>Ctrl+<b>&downarrow;</b></td><td>To next block</td></tr>
<tr><td>Ctrl+<b>&uarr;</b></td><td>To previous block</td></tr>
<tr><td>Ctrl+<b>&darr;</b></td><td>To next block</td></tr>
<tr><td>Ctrl+Y</td><td>One page up</td></tr>
<tr><td>Ctrl+V</td><td>One page down</td></tr>
<tr><td>Alt+\</td><td>To top of buffer</td></tr>
@@ -98,8 +98,8 @@
<table><tbody>
<tr><td>Alt+G &nbsp;&nbsp;&nbsp;</td><td>Go to specified line</td></tr>
<tr><td>Alt+]</td><td>Go to complementary bracket</td></tr>
<tr><td>Alt+<b>&uparrow;</b></td><td>Scroll viewport up</td></tr>
<tr><td>Alt+<b>&downarrow;</b></td><td>Scroll viewport down</td></tr>
<tr><td>Alt+<b>&uarr;</b></td><td>Scroll viewport up</td></tr>
<tr><td>Alt+<b>&darr;</b></td><td>Scroll viewport down</td></tr>
<tr><td>Alt+&lt;</td><td>Switch to preceding buffer</td></tr>
<tr><td>Alt+&gt;</td><td>Switch to succeeding buffer</td></tr>
</tbody></table>
@@ -108,7 +108,7 @@
<b>Information</b>
<table><tbody>
<tr><td>Ctrl+C &nbsp;&nbsp;</td><td>Report cursor position</td></tr>
<tr><td>Alt+D</td><td>Report word/line/char count</td></tr>
<tr><td>Alt+D</td><td>Report line/word/character count</td></tr>
<tr><td>Ctrl+G</td><td>Display help text</td></tr>
</tbody></table>
<br>
@@ -118,11 +118,11 @@
<tr><td>Alt+A</td><td>Turn the mark on/off</td></tr>
<tr><td>Tab</td><td>Indent marked region</td></tr>
<tr><td>Shift+Tab &nbsp;&nbsp;</td><td>Unindent marked region</td></tr>
<tr><td>Alt+V</td><td>Enter next keystroke verbatim</td></tr>
<tr><td>Alt+N</td><td>Turn line numbers on/off</td></tr>
<tr><td>Alt+P</td><td>Turn visible whitespace on/off</td></tr>
<tr><td>Alt+V</td><td>Enter next keystroke verbatim</td></tr>
<tr><td>Alt+X</td><td>Hide or unhide the help lines</td></tr>
<tr><td>Ctrl+L</td><td>Refresh the screen</td></tr>
<tr><td>Ctrl+Z</td><td>Suspend nano</td></tr>
</tbody></table>
<br>

View File

@@ -5,6 +5,9 @@
<title>The GNU nano editor FAQ</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="The genesis story of the nano editor, plus the solution to some common problems.">
<style>
.indented { margin-left: 2em; font-family: courier; font-size: 110%; }
</style>
</head>
<body text="#330000" bgcolor="#ffffff" link="#0000ef" vlink="#51188e" alink="#ff0000">
@@ -40,13 +43,13 @@
</p></blockquote>
<h3><a href="#4">4. Running</a></h3>
<blockquote><p>
<a href="#4.1">4.1. How do I open a file with a name beginning with '+' from the command line?</a><br>
<a href="#4.2">4.2. Ack! My Backspace/Delete/Enter/Meta/double bucky key doesn't seem to work! What can I do?</a><br>
<a href="#4.1">4.1. Alt+Up does nothing on a Linux console. How can I make it scroll?</a><br>
<a href="#4.2">4.2. How can I make Ctrl+Shift+Left/Right select words on urxvt?</a><br>
<a href="#4.3">4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</a><br>
<a href="#4.4">4.4. With what keystroke can I paste text from the clipboard into nano?</a><br>
<a href="#4.5">4.5. How do I select text for or paste text from the clipboard when nano's mouse support is turned on?</a><br>
<a href="#4.6">4.6. When I paste text into a document, each line gets indented further than the last. Why? And how can I stop this?</a><br>
<a href="#4.7">4.7. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?<a><br>
<a href="#4.7">4.7. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?</a><br>
<a href="#4.8">4.8. I've compiled nano with color support, but I don't see any color when I run it!</a><br>
<a href="#4.9">4.9. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
</p></blockquote>
@@ -89,7 +92,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>4.8</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>6.1</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%">
@@ -127,39 +130,39 @@
<blockquote><p>It's simple really! As root, type <b>rpm -Uvh nano-x.y-1*.rpm</b> if you have a RedHat-ish system or <b>dpkg -i nano_x.y-1*.deb</b> if you have a Debian-ish system, where <b>x.y</b> is the version number of nano. There are other programs to install packages, and if you wish to use those, knock yourself out.</p></blockquote>
<h3><a name="3.2"></a>3.2. Compiling from source: WHAT THE HECK DO I DO NOW?</h3>
<blockquote><p>Okay, take a deep breath, this really isn't hard. Unpack the nano source with a command like:</p>
<p><b>tar -xvf nano-x.y.tar.gz</b></p>
<p class="indented"><b>tar -xvf nano-x.y.tar.gz</b></p>
<p>Then you need to run <b>configure</b> with any options you might want (if any).</p>
<p>The average case is this:</p>
<p><b>cd nano-x.y/</b><br>
<p class="indented"><b>cd nano-x.y/</b><br>
<b>./configure</b><br>
<b>make</b><br>
<b>make install</b> (as root, of course)</p></blockquote>
<b>make install</b>&nbsp;&nbsp; #(as root, of course)</p></blockquote>
<h3><a name="3.3"></a>3.3. Why does everything go into /usr/local?</h3>
<blockquote><p>Well, that's what the <b>configure</b> script defaults to. If you wish to change this, simply do this:</p>
<p><b>./configure --prefix=/usr</b></p>
<p class="indented"><b>./configure --prefix=/usr</b></p>
<p>This will put nano into /usr/bin when you run <b>make install</b>.</p></blockquote>
<h3><a name="3.4"></a>3.4. nano should automatically run strip on the binary when installing it!</h3>
<blockquote><p>It does when you use <b>make install-strip</b>. The default <b>make install</b> does not, and will not, run strip automatically.</p></blockquote>
<h3><a name="3.5"></a>3.5. How can I make the executable smaller? This is too bloated!</h3>
<blockquote><p>Actually, there are several parts of the editor that can be disabled. You can pass arguments to the <b>configure</b> script that disable certain features. Here's a brief list:</p>
<pre>
<b>--disable-browser</b> Disable the built-in file browser
<b>--disable-color</b> Disable color and syntax highlighting
<b>--disable-comment</b> Disable the comment/uncomment function
<b>--disable-extra</b> Disable the easter egg
<b>--disable-help</b> Disable the built-in help texts
<b>--disable-histories</b> Disable the saving of search strings and cursor positions
<b>--disable-justify</b> Disable the justify/unjustify functions
<b>--disable-libmagic</b> Disable the use of libmagic for determining a file's syntax
<b>--disable-linenumbers</b> Disable line numbering
<b>--disable-mouse</b> Disable mouse support
<b>--disable-multibuffer</b> Disable the opening of multiple file buffers
<b>--disable-nanorc</b> Disable the use of .nanorc files
<b>--disable-operatingdir</b> Disable the setting of an operating directory
<b>--disable-speller</b> Disable the spell-checker functions
<b>--disable-tabcomp</b> Disable the tab-completion functions
<b>--disable-wordcomp</b> Disable the word-completion function
<b>--disable-wrapping</b> Disable all hard-wrapping of text</pre>
<b>--disable-browser</b> Disable the built-in file browser
<b>--disable-color</b> Disable color and syntax highlighting
<b>--disable-comment</b> Disable the comment/uncomment function
<b>--disable-extra</b> Disable the easter egg
<b>--disable-help</b> Disable the built-in help texts
<b>--disable-histories</b> Disable the saving of search strings and cursor positions
<b>--disable-justify</b> Disable the justify/unjustify functions
<b>--disable-libmagic</b> Disable the use of libmagic for determining a file's syntax
<b>--disable-linenumbers</b> Disable line numbering
<b>--disable-mouse</b> Disable mouse support
<b>--disable-multibuffer</b> Disable the opening of multiple file buffers
<b>--disable-nanorc</b> Disable the use of .nanorc files
<b>--disable-operatingdir</b> Disable the setting of an operating directory
<b>--disable-speller</b> Disable the spell-checker functions
<b>--disable-tabcomp</b> Disable the tab-completion functions
<b>--disable-wordcomp</b> Disable the word-completion function
<b>--disable-wrapping</b> Disable all hard-wrapping of text</pre>
<p>There's also the <b>--enable-tiny</b> option which disables everything above, as well as some larger chunks of the program (like the undo/redo code and the code for selecting text). Also, if you know you don't need other languages, you can use <b>--disable-nls</b> to disable internationalization and save a few kilobytes. And finally, there's always good old <b>strip</b> to remove all unneeded symbols.</p>
</blockquote>
<h3><a name="3.6"></a>3.6. Tell me more about this multibuffer stuff!</h3>
@@ -175,17 +178,40 @@
<hr width="100%">
<h1><a name="4"></a>4. Running</h1>
<h3><a name="4.1"></a>4.1. How do I open a file with a name beginning with '+' from the command line?</h3>
<blockquote><p>If a command-line argument that begins with '+' is followed by another argument, the former is always treated as a starting line (plus column number), and the latter always as a filename. If a command-line argument that begins with '+' isn't followed by another argument, it's treated as a filename. Examples:</p>
<p>To open '+filename.txt': <b>nano +filename.txt</b><br>
To open '+filename.txt' starting on line 10: <b>nano +10 +filename.txt</b><br>
To open '+filename.txt' starting on line 1, column 20: <b>nano +,20 +filename.txt</b><br>
To open '+filename.txt' starting on line 10, column 20: <b>nano +10,20 +filename.txt</b><br>
To open '+filename.txt' starting on line 1 and 'filename.txt' starting on line 40: <b>nano +1 +filename.txt +40 filename.txt</b></p></blockquote>
<h3><a name="4.2"></a>4.2. Ack! My Backspace/Delete/Enter/Meta/double bucky key doesn't seem to work! What can I do?</h3>
<blockquote><p>Try setting your $TERM variable to 'vt100'. nano doesn't yet support every term entry under the sun.</p>
<p>Bourne shell users (bash and sh): <b>export TERM=vt100</b><br>
C Shell users (tcsh and csh): <b>setenv TERM vt100</b></p></blockquote>
<h3><a name="4.1"></a>4.1. Alt+Up does nothing on a Linux console. How can I make it scroll?</h3>
<blockquote><p>On Debian and its derivatives, the <b>Alt+Up</b> keystroke on a Linux console
produces by default a 'KeyboardSignal', which normally does absolutely nothing and is useless
for the average user. To get the keystroke to do what it ought to do (scroll the viewport
one row up), run this in a Linux console:</p>
<p class="indented"><b>dumpkeys --full | sed s/KeyboardSignal/Up/ | sudo loadkeys -</b></p>
<p>You will need to run this command whenever you first switch to a Linux console.</p>
<p>Or you can (as root) execute the following little script just once:</p>
<p class="indented"><b>for file in /etc/console-setup/cached*.kmap.gz; do<br>
&nbsp;&nbsp;&nbsp;&nbsp;gunzip $file;<br>
&nbsp;&nbsp;&nbsp;&nbsp;sed -i 's/KeyboardSignal/Up/' ${file%.gz};<br>
&nbsp;&nbsp;&nbsp;&nbsp;gzip ${file%.gz};<br>
done</b></p></blockquote>
<h3><a name="4.2"></a>4.2. How can I make Ctrl+Shift+Left/Right select words on urxvt?</h3>
<blockquote><p>The urxvt terminal emulator produces non-standard escape sequences for the modified cursor keys. These deviant sequences are not listed in the terminfo database, which means that ncurses does not recognize them. The easiest way around this is to tell urxvt to produce xterm-compatible escape sequences for the relevant keystrokes. To achieve this, add the following lines to your ~/.Xresources file:</p>
<pre>
URxvt.iso14755_52: False
URxvt.keysym.C-S-Up: \033[1;6A
URxvt.keysym.C-S-Down: \033[1;6B
URxvt.keysym.C-S-Right: \033[1;6C
URxvt.keysym.C-S-Left: \033[1;6D
URxvt.keysym.M-Up: \033[1;3A
URxvt.keysym.M-Down: \033[1;3B
URxvt.keysym.M-Right: \033[1;3C
URxvt.keysym.M-Left: \033[1;3D
URxvt.keysym.M-Insert: \033[2;3~
URxvt.keysym.M-Delete: \033[3;3~
URxvt.keysym.M-Page_Up: \033[5;3~
URxvt.keysym.M-Page_Down: \033[6;3~</pre>
<p>Then run <b>xrdb ~/.Xresources</b> and restart your urxvt terminal. Now <b>Ctrl+Shift+Left</b> and <b>Ctrl+Shift+Right</b> will select words, <b>Alt+Up</b> and <b>Alt+Down</b> will scroll the text without moving the cursor, and several such things more.</p></blockquote>
<h3><a name="4.3"></a>4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</h3>
<blockquote><p>You can use the <b>-K</b> or <b>--rawsequences</b> option on the command line, or add the line <b>set rawsequences</b> to your .nanorc. However, nano's mouse support will be disabled if you do any of these things.</p></blockquote>
<h3><a name="4.4"></a>4.4. With what keystroke can I paste text from the clipboard into nano?</h3>
@@ -202,16 +228,16 @@
<blockquote><p>If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Several example configurations are in the <b>syntax/</b> subdirectory of the nano source, which are normally installed to <b>/usr/local/share/nano/</b>. To enable all of them, uncomment the line <b># include "/usr/local/share/nano/*.nanorc"</b> in your nanorc. See also section <a href="#3.9">3.9</a>.</p></blockquote>
<h3><a name="4.9"></a>4.9. How do I make nano my default editor (in Pine, mutt, etc.)?</h3>
<blockquote><p>You need to make nano your $EDITOR. If you want this to be saved, you should put a line like this in your <b>.bashrc</b> if you use bash (or <b>.zshrc</b> if you believe in zsh):</p>
<p><b>export EDITOR=/usr/local/bin/nano</b></p>
<p class="indented"><b>export EDITOR=/usr/local/bin/nano</b></p>
<p>or, if you use tcsh, put this in your <b>.cshrc</b> file:</p>
<p><b>setenv EDITOR /usr/local/bin/nano</b></p>
<p class="indented"><b>setenv EDITOR /usr/local/bin/nano</b></p>
<p>Change /usr/local/bin/nano to wherever nano is installed on your system. Type &quot;which nano&quot; to find out. This will not take effect until the next time you log in. So log out and back in again.</p>
<p>Then, on top of that, if you use Pine, you must go into setup (type <b>S</b> at the main menu), and then configure (type <b>C</b>). Hit Enter on the lines that say:</p>
<p><b>[ ] enable-alternate-editor-cmd</b><br>
<p class="indented"><b>[ ] enable-alternate-editor-cmd</b><br>
<b>[ ] enable-alternate-editor-implicitly</b></p>
<p>Then exit (<b>E</b>) and select Yes (<b>Y</b>).</p>
<p>If you're a mutt user, you should see an effect immediately the next time you log in. No further configuration is needed. However, if you want to let people know you use nano to compose your email messages, you can put a line like this in your <b>.muttrc</b>:</p>
<p><b>my_hdr X-Composer: nano-x.y</b></p>
<p class="indented"><b>my_hdr X-Composer: nano-x.y</b></p>
<p>Again, replace x.y with the version of nano you use.</p></blockquote>
<hr width="100%">

View File

@@ -1,4 +1,4 @@
.\" Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc.
.\" Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc.
.\"
.\" This document is dual-licensed. You may distribute and/or modify it
.\" under the terms of either of the following licenses:
@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 4.8" "February 2020"
.TH NANO 1 "version 6.1" "February 2022"
.SH NAME
nano \- Nano's ANOther editor, inspired by Pico
@@ -27,20 +27,6 @@ nano \- Nano's ANOther editor, inspired by Pico
.sp
.BR nano " [" \fIoptions "] [[" + [ crCR ]( / | ? ) \fIstring "] " \fIfile ]...
.SH NOTICE
Since version 4.0, \fBnano\fR by default:
.sp
.RS 4
\(bu does not automatically hard-wrap lines that become overlong,
.br
\(bu includes the line below the title bar in the editing area,
.br
\(bu does linewise (smooth) scrolling.
.RE
.sp
If you want the old, Pico behavior back, you can use \fB\-\-breaklonglines\fR,
\fB\-\-emptyline\fR, and \fB\-\-jumpyscrolling\fR (or \fB\-bej\fR for short).
.SH DESCRIPTION
\fBnano\fP is a small and friendly editor. It copies the look and feel
of Pico, but is free software, and implements several features that Pico
@@ -58,7 +44,7 @@ regular expression by inserting \fBc\fR and/or \fBr\fR after the \fB+\fR sign.
These search modes can be explicitly disabled by using the uppercase variant
of those letters: \fBC\fR and/or \fBR\fR. When the string contains spaces,
it needs to be enclosed in quotes. To give an example: to open a file at
the first occurrence of the word "Foo", one would do:
the first occurrence of the word "Foo", you would do:
.sp
.RS 4
.BI "nano +c/Foo " file
@@ -77,11 +63,11 @@ Any cursor movement or executing any other command will cause the next
\fB^K\fR to overwrite the cutbuffer. A \fB^U\fR will paste the current
contents of the cutbuffer at the current cursor position.
.sp
When a more precise piece of text needs to be cut or copied, one can mark
When a more precise piece of text needs to be cut or copied, you can mark
its start with \fB^6\fR, move the cursor to its end (the marked text will be
highlighted), and then use \fB^K\fR to cut it, or \fBM\-6\fR to copy it to the
cutbuffer. One can also save the marked text to a file with \fB^O\fR, or
spell check it with \fB^T\fR.
cutbuffer. You can also save the marked text to a file with \fB^O\fR, or
spell check it with \fB^T^T\fR.
.sp
On some terminals, text can be selected also by holding down Shift while
using the arrow keys. Holding down the Ctrl or Alt key too will increase
@@ -93,6 +79,20 @@ the built-in help (\fB^G\fR) lists all the available ones.
The default key bindings can be changed via a \fInanorc\fR file -- see
.BR nanorc (5).
.SH NOTICE
Since version 4.0, \fBnano\fR by default:
.sp
.RS 4
\(bu does not automatically hard-wrap lines that become overlong,
.br
\(bu includes the line below the title bar in the editing area,
.br
\(bu does linewise (smooth) scrolling.
.RE
.sp
If you want the old, Pico behavior back, you can use \fB\-\-breaklonglines\fR,
\fB\-\-emptyline\fR, and \fB\-\-jumpyscrolling\fR (or \fB\-bej\fR for short).
.SH OPTIONS
.TP
.BR \-A ", " \-\-smarthome
@@ -118,7 +118,8 @@ by setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, \fBkeycolor\fP,
nanorc file. See \fBnanorc\fR(5).
.TP
.BR \-E ", " \-\-tabstospaces
Convert typed tabs to spaces.
Convert each typed tab to spaces -- to the number of spaces
that a tab at that position would take up.
.TP
.BR \-F ", " \-\-multibuffer
Read a file into a new buffer by default.
@@ -139,10 +140,12 @@ text. (The color of the stripe can be changed with \fBset stripecolor\fR
in your \fInanorc\fR file.)
.TP
.BR \-K ", " \-\-rawsequences
Interpret escape sequences directly (instead of asking \fBncurses\fR to
translate them). If you need this option to get your keyboard to work
properly, please report a bug. Using this option disables \fBnano\fR's
mouse support.
Interpret escape sequences directly, instead of asking \fBncurses\fR
to translate them. (If you need this option to get some keys to work
properly, it means that the terminfo terminal description that is used
does not fully match the actual behavior of your terminal. This can
happen when you ssh into a BSD machine, for example.)
Using this option disables \fBnano\fR's mouse support.
.TP
.BR \-L ", " \-\-nonewlines
Don't automatically add a newline when a text does not end with one.
@@ -155,10 +158,9 @@ hard-wrapping occurs or when text is justified.
.BR \-N ", " \-\-noconvert
Disable automatic conversion of files from DOS/Mac format.
.TP
.BR \-O ", " \-\-morespace
Obsolete and ignored option, since the line below the title bar is included
into the editing space by default. If you prefer to keep this line blank,
use \fB\-e\fR or \fB\-\-emptyline\fR.
.BR \-O ", " \-\-bookstyle
When justifying, treat any line that starts with whitespace as the
beginning of a paragraph (unless auto-indenting is on).
.TP
.BR \-P ", " \-\-positionlog
For the 200 most recent files, log the last position of the cursor,
@@ -166,7 +168,7 @@ and place it at that position again upon reopening such a file.
.TP
.BR "\-Q ""\fIregex\fB""" ", " "\-\-quotestr=""" \fIregex """
Set the regular expression for matching the quoting part of a line.
The default value is \fB"^([\ \\t]*([!#%:;>|}]|//))+"\fP.
The default value is "\fB^([\ \\t]*([!#%:;>|}]|//))+\fR".
(Note that \fB\\t\fP stands for an actual Tab.)
This makes it possible to rejustify blocks of quoted text when composing
email, and to rewrap blocks of line comments when writing source code.
@@ -180,19 +182,23 @@ 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
Obsolete and ignored option, since smooth scrolling has become the default.
If you prefer the chunk-by-chunk scrolling behavior,
use \fB\-j\fR or \fB\-\-jumpyscrolling\fR.
.BR \-S ", " \-\-softwrap
Display over multiple screen rows lines that exceed the screen's width.
(You can make this soft-wrapping occur at whitespace instead of rudely at
the screen's edge, by using also \fB\-\-atblanks\fR.)
(The old short option, \fB\-$\fR, is deprecated.)
.TP
.BR \-T\ \fInumber ", " \-\-tabsize= \fInumber
Set the size (width) of a tab to \fInumber\fP columns. The value of
\fInumber\fP must be greater than 0. The default value is 8.
\fInumber\fR must be greater than 0. The default value is \fB8\fR.
.TP
.BR \-U ", " \-\-quickblank
Do quick status-bar blanking: status-bar messages will disappear after 1
keystroke instead of 25. Note that option \fB\-c\fR (\fB\-\-constantshow\fR)
overrides this.
Make status-bar messages disappear after 1 keystroke instead of after 20.
Note that option \fB\-c\fR (\fB\-\-constantshow\fR) overrides this.
When option \fB\-\-minibar\fR or \fB\-\-zero\fR is in effect,
\fB\-\-quickblank\fR makes a message disappear after
0.8 seconds instead of after the default 1.5 seconds.
.
.TP
.BR \-V ", " \-\-version
Show the current version number and exit.
@@ -203,8 +209,8 @@ characters as part of a word.
.TP
.BR "\-X ""\fIcharacters\fB""" ", " "\-\-wordchars=""" \fIcharacters """
Specify which other characters (besides the normal alphanumeric ones)
should be considered as part of a word. This overrides option
\fB\-W\fR (\fB\-\-wordbounds\fR).
should be considered as part of a word. When using this option, you
probably want to omit \fB\-W\fR (\fB\-\-wordbounds\fR).
.TP
.BR \-Y\ \fIname ", " \-\-syntax= \fIname
Specify the name of the syntax highlighting to use from among the ones
@@ -261,6 +267,7 @@ position to the end of the line, instead of cutting the entire line.
.TP
.BR \-l ", " \-\-linenumbers
Display line numbers to the left of the text area.
(Any line with an anchor additionally gets a mark in the margin.)
.TP
.BR \-m ", " \-\-mouse
Enable mouse support, if available for your system. When enabled, mouse
@@ -281,22 +288,28 @@ Set the operating directory. This makes \fBnano\fP set up something
similar to a chroot.
.TP
.BR \-p ", " \-\-preserve
Preserve the XON and XOFF sequences (^Q and ^S) so they will be caught
by the terminal.
Preserve the XON and XOFF sequences (\fB^Q\fR and \fB^S\fR) so they
will be caught by the terminal.
.TP
.BR \-q ", " \-\-indicator
Display a "scrollbar" on the righthand side of the edit window.
It shows the position of the viewport in the buffer
and how much of the buffer is covered by the viewport.
.TP
.BR \-r\ \fInumber ", " \-\-fill= \fInumber
Set the target width for justifying and automatic hard-wrapping at this
\fInumber\fR of columns. If the value is 0 or less, wrapping will occur
at the width of the screen minus \fInumber\fR columns, allowing the wrap
point to vary along with the width of the screen if the screen is resized.
The default value is \-8.
The default value is \fB\-8\fR.
.TP
.B "\-s ""\fIprogram\fR [\fIargument \fR...]\fB""\fR, \fB\-\-speller=""\fIprogram\fR [\fIargument \fR...]\fB"""
Use this command to perform spell checking and correcting, instead of
using the built-in corrector that calls \fBhunspell\fR or GNU \fBspell\fR.
using the built-in corrector that calls \fBhunspell\fR(1) or \fBspell\fR(1).
.TP
.BR \-t ", " \-\-tempfile
.BR \-t ", " \-\-saveonexit
Save a changed buffer without prompting (when exiting with \fB^X\fR).
(The old form of the long option, \fB\-\-tempfile\fR, is deprecated.)
.TP
.BR \-u ", " \-\-unix
Save a file by default in Unix format. This overrides nano's
@@ -312,24 +325,54 @@ unless \fB\-\-restricted\fR is given too.
Do not automatically hard-wrap the current line when it becomes overlong.
This is the default. (This option is the opposite of \fB\-b\fR
(\fB\-\-breaklonglines\fR) -- the last one given takes effect.)
.TP
.BR \-x ", " \-\-nohelp
Don't show the two help lines at the bottom of the screen.
.TP
.BR \-y ", " \-\-afterends
Make Ctrl+Right stop at word ends instead of beginnings.
Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
.TP
.BR \-z ", " \-\-suspend
Enable the suspend ability.
.BR \-z ", " \-\-suspendable
Obsolete option; ignored. Suspension is enabled by default,
reachable via \fB^T^Z\fR. (If you want a plain \fB^Z\fR to
suspend nano, add \fBbind ^Z suspend main\fR to your nanorc.)
.TP
.BR \-$ ", " \-\-softwrap
Enable 'soft wrapping'. This will make \fBnano\fP attempt to display the
entire contents of any line, even if it is longer than the screen width, by
continuing it over multiple screen lines. Since
\&'$' normally refers to a variable in the Unix shell, you should specify
this option last when using other options (e.g.\& 'nano \-wS$') or pass it
separately (e.g.\& 'nano \-wS \-$').
.BR \-% ", " \-\-stateflags
Use the top-right corner of the screen for showing some state flags:
\fBI\fR when auto-indenting, \fBM\fR when the mark is on, \fBL\fR when
hard-wrapping (breaking long lines), \fBR\fR when recording a macro,
and \fBS\fR when soft-wrapping.
When the buffer is modified, a star (\fB*\fR) is shown after the
filename in the center of the title bar.
.TP
.BR \-_ ", " \-\-minibar
Suppress the title bar and instead show information about
the current buffer at the bottom of the screen, in the space
for the status bar. In this "minibar" the filename is shown
on the left, followed by an asterisk if the buffer has been modified.
On the right are displayed the current line and column number, the
code of the character under the cursor (in Unicode format: U+xxxx),
the same flags as are shown by \fB\-\-stateflags\fR, and a percentage
that expresses how far the cursor is into the file (linewise).
When a file is loaded or saved, and also when switching between buffers,
the number of lines in the buffer is displayed after the filename.
This number is cleared upon the next keystroke, or replaced with an
[i/n] counter when multiple buffers are open.
The line plus column numbers and the character code are displayed only when
\fB\-\-constantshow\fR is used, and can be toggled on and off with \fBM-C\fR.
The state flags are displayed only when \fB\-\-stateflags\fR is used.
.TP
.BR \-0 ", " \-\-zero
Hide all elements of the interface (title bar, status bar, and help lines)
and use all rows of the terminal for showing the contents of the buffer.
The status bar appears only when there is a significant message,
and disappears after 1.5 seconds or upon the next keystroke.
With \fBM-Z\fR the title bar plus status bar can be toggled.
With \fBM-X\fR the help lines.
.TP
.BR \-! ", " \-\-magic
When neither the file's name nor its first line give a clue,
try using libmagic to determine the applicable syntax.
.SH TOGGLES
Several of the above options can be switched on and off also while
@@ -338,6 +381,10 @@ hard-wrapping of long lines, \fBM\-S\fR toggles soft-wrapping,
\fBM\-N\fR toggles line numbers, \fBM\-M\fR toggles the mouse,
\fBM\-I\fR auto-indentation, and \fBM\-X\fR the help lines.
See at the end of the \fB^G\fR help text for a complete list.
.sp
The \fBM\-X\fR toggle is special: it works in all menus except
the help viewer and the linter. All other toggles work in
the main menu only.
.SH FILES
When \fB\-\-rcfile\fR is given, \fBnano\fR will read just the specified file
@@ -348,6 +395,9 @@ exists), either \fI~/.nanorc\fR or \fI$XDG_CONFIG_HOME/nano/nanorc\fR
or \fI~/.config/nano/nanorc\fR, whichever is encountered first. See
.BR nanorc (5)
for more information on the possible contents of those files.
.sp
See \fI/usr/share/nano/\fR and \fI/usr/share/nano/extra/\fR
for available syntax-coloring definitions.
.SH NOTES
If no alternative spell checker command is specified on the command

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
.\" Copyright (C) 2003-2011, 2013-2020 Free Software Foundation, Inc.
.\" Copyright (C) 2003-2011, 2013-2022 Free Software Foundation, Inc.
.\"
.\" This document is dual-licensed. You may distribute and/or modify it
.\" under the terms of either of the following licenses:
@@ -16,16 +16,15 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 4.8" "February 2020"
.TH NANORC 5 "version 6.1" "February 2022"
.SH NAME
nanorc \- GNU nano's configuration file
.SH DESCRIPTION
The \fInanorc\fP files contain the default settings for \fBnano\fP, a
small and friendly editor. They should be in Unix format, not in
DOS or Mac format. During startup, if \fB\-\-rcfile\fR is not given,
\fBnano\fR will read two files: first the
The \fInanorc\fP files contain the default settings for \fBnano\fP,
a small and friendly editor. During startup, if \fB\-\-rcfile\fR
is not given, \fBnano\fR will read two files: first the
system-wide settings, from \fI/etc/nanorc\fP (the exact path might be
different on your system), and then the user-specific settings, either
from \fI~/.nanorc\fR or from \fI$XDG_CONFIG_HOME/nano/nanorc\fR
@@ -66,10 +65,9 @@ Quotes inside the \fIcharacters\fR parameters below should not be escaped.
The last double quote on the line will be seen as the closing quote.
.sp
The supported commands and arguments are:
.TP 3
.B set afterends
Make Ctrl+Right stop at word ends instead of beginnings.
Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
.TP
.B set allow_insecure_backup
When backing up files, allow the backup to succeed even if its permissions
@@ -101,11 +99,15 @@ function tags, line numbers, and selected text. This can be overridden by
setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, \fBkeycolor\fP,
\fBfunctioncolor\fP, \fBnumbercolor\fP, and \fBselectedcolor\fP.
.TP
.B set bookstyle
When justifying, treat any line that starts with whitespace as the
beginning of a paragraph (unless auto-indenting is on).
.TP
.BI "set brackets """ characters """
Set the characters treated as closing brackets when justifying
paragraphs. This may not include blank characters. Only closing
punctuation (see \fBset punct\fP), optionally followed by the specified
closing brackets, can end sentences. The default value is "\fB"')>]}\fP".
closing brackets, can end sentences. The default value is "\fB\(dq')>]}\fR".
.TP
.B set breaklonglines
Automatically hard-wrap the current line when it becomes overlong.
@@ -123,9 +125,9 @@ Use cut-from-cursor-to-end-of-line by default, instead of cutting the whole line
.B set emptyline
Do not use the line below the title bar, leaving it entirely blank.
.TP
.B set errorcolor \fIfgcolor\fR,\fIbgcolor\fR
.B set errorcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the status bar when an error message is displayed.
The default value is \fBbrightwhite,red\fR.
The default value is \fBbold,white,red\fR.
See \fBset titlecolor\fR for valid color names.
.TP
.B set fill \fInumber\fR
@@ -135,8 +137,8 @@ at the width of the screen minus \fInumber\fR columns, allowing the wrap
point to vary along with the width of the screen if the screen is resized.
The default value is \fB\-8\fR.
.TP
.B set functioncolor \fIfgcolor\fR,\fIbgcolor\fR
Specify the color combination to use for the function descriptions
.B set functioncolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the concise function descriptions
in the two help lines at the bottom of the screen.
See \fBset titlecolor\fR for more details.
.TP
@@ -148,29 +150,59 @@ text. (The color of the stripe can be changed with \fBset stripecolor\fR.)
Save the last hundred search strings and replacement strings and
executed commands, so they can be easily reused in later sessions.
.TP
.B set indicator
Display a "scrollbar" on the righthand side of the edit window.
It shows the position of the viewport in the buffer
and how much of the buffer is covered by the viewport.
.TP
.B set jumpyscrolling
Scroll the buffer contents per half-screen instead of per line.
.TP
.B set keycolor \fIfgcolor\fR,\fIbgcolor\fR
Specify the color combination to use for the shortcut key combos
.B set keycolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the shortcut key combos
in the two help lines at the bottom of the screen.
See \fBset titlecolor\fR for more details.
.TP
.B set linenumbers
Display line numbers to the left of the text area.
(Any line with an anchor additionally gets a mark in the margin.)
.TP
.B set locking
Enable vim-style lock-files for when editing files.
.TP
.B set magic
When neither the file's name nor its first line give a clue,
try using libmagic to determine the applicable syntax.
(Calling libmagic can be relatively time consuming.
It is therefore not done by default.)
.TP
.BI "set matchbrackets """ characters """
Set the opening and closing brackets that can be found by bracket
Specify the opening and closing brackets that can be found by bracket
searches. This may not include blank characters. The opening set must
come before the closing set, and the two sets must be in the same order.
The default value is "\fB(<[{)>]}\fP".
.TP
.B set morespace
Deprecated option since it has become the default setting.
When needed, use \fBunset emptyline\fR instead.
.B set minibar
Suppress the title bar and instead show information about
the current buffer at the bottom of the screen, in the space
for the status bar. In this "minibar" the filename is shown
on the left, followed by an asterisk if the buffer has been modified.
On the right are displayed the current line and column number, the
code of the character under the cursor (in Unicode format: U+xxxx),
the same flags as are shown by \fBset stateflags\fR, and a percentage
that expresses how far the cursor is into the file (linewise).
When a file is loaded or saved, and also when switching between buffers,
the number of lines in the buffer is displayed after the filename.
This number is cleared upon the next keystroke, or replaced with an
[i/n] counter when multiple buffers are open.
The line plus column numbers and the character code are displayed only when
\fBset constantshow\fR is used, and can be toggled on and off with \fBM-C\fR.
The state flags are displayed only when \fBset stateflags\fR is used.
.TP
.B set minicolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the minibar.
(When this option is not specified, the colors of the title bar are used.)
See \fBset titlecolor\fR for more details.
.TP
.B set mouse
Enable mouse support, if available for your system. When enabled, mouse
@@ -180,7 +212,7 @@ System, and on the console when gpm is running. Text can still be
selected through dragging by holding down the Shift key.
.TP
.B set multibuffer
When reading in a file with ^R, insert it into a new buffer by default.
When reading in a file with \fB^R\fR, insert it into a new buffer by default.
.TP
.B set noconvert
Don't convert files from DOS/Mac format.
@@ -192,15 +224,12 @@ Don't display the two help lines at the bottom of the screen.
Don't automatically add a newline when a text does not end with one.
(This can cause you to save non-POSIX text files.)
.TP
.B set nopauses
Obsolete option. Ignored.
.TP
.B set nowrap
Deprecated option since it has become the default setting.
When needed, use \fBunset breaklonglines\fR instead.
.TP
.B set numbercolor \fIfgcolor\fR,\fIbgcolor\fR
Specify the color combination to use for line numbers.
.B set numbercolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for line numbers.
See \fBset titlecolor\fR for more details.
.TP
.B set operatingdir "\fIdirectory\fP"
@@ -214,7 +243,12 @@ Save the cursor position of files between editing sessions.
The cursor position is remembered for the 200 most-recently edited files.
.TP
.B set preserve
Preserve the XON and XOFF keys (^Q and ^S).
Preserve the XON and XOFF keys (\fB^Q\fR and \fB^S\fR).
.TP
.B set promptcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the prompt bar.
(When this option is not specified, the colors of the title bar are used.)
See \fBset titlecolor\fR for more details.
.TP
.BI "set punct """ characters """
Set the characters treated as closing punctuation when justifying
@@ -223,8 +257,11 @@ specfified closing punctuation, optionally followed by closing brackets
(see \fBbrackets\fP), can end sentences. The default value is "\fB!.?\fP".
.TP
.B set quickblank
Do quick status-bar blanking: status-bar messages will disappear after 1
keystroke instead of 25. The option \fBconstantshow\fR overrides this.
Make status-bar messages disappear after 1 keystroke instead of after 20.
Note that option \fBconstantshow\fR overrides this.
When option \fBminibar\fR or \fBzero\fR is in effect,
\fBquickblank\fR makes a message disappear after
0.8 seconds instead of after the default 1.5 seconds.
.TP
.BI "set quotestr """ regex """
Set the regular expression for matching the quoting part of a line.
@@ -234,10 +271,12 @@ This makes it possible to rejustify blocks of quoted text when composing
email, and to rewrap blocks of line comments when writing source code.
.TP
.B set rawsequences
Interpret escape sequences directly (instead of asking \fBncurses\fR to
translate them). If you need this option to get your keyboard to work
properly, please report a bug. Using this option disables \fBnano\fR's
mouse support.
Interpret escape sequences directly, instead of asking \fBncurses\fR
to translate them. (If you need this option to get some keys to work
properly, it means that the terminfo terminal description that is used
does not fully match the actual behavior of your terminal. This can
happen when you ssh into a BSD machine, for example.)
Using this option disables \fBnano\fR's mouse support.
.TP
.B set rebinddelete
Interpret the Delete and Backspace keys differently so that both Backspace
@@ -248,13 +287,24 @@ system either Backspace acts like Delete or Delete acts like Backspace.
Do regular-expression searches by default.
Regular expressions in \fBnano\fR are of the extended type (ERE).
.TP
.B set selectedcolor \fIfgcolor\fR,\fIbgcolor\fR
Specify the color combination to use for selected text.
.B set saveonexit
Save a changed buffer automatically on exit (\fB^X\fR); don't prompt.
(The old form of this option, \fBset tempfile\fR, is deprecated.)
.TP
.B set scrollercolor \fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the indicator alias "scrollbar".
(On terminal emulators that link to a libvte older than version 0.55,
using a background color here does not work correctly.)
See \fBset titlecolor\fR for more details.
.TP
.B set selectedcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for selected text.
See \fBset titlecolor\fR for more details.
.TP
.B 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.
.TP
.B set smarthome
Make the Home key smarter. When Home is pressed anywhere but at the
@@ -263,46 +313,75 @@ jump to that beginning (either forwards or backwards). If the cursor is
already at that position, it will jump to the true beginning of the
line.
.TP
.B set smooth
Deprecated option since it has become the default setting.
When needed, use \fBunset jumpyscrolling\fR instead.
.TP
.B set softwrap
Enable soft line wrapping for easier viewing of very long lines.
Display lines that exceed the screen's width over multiple screen lines.
(You can make this soft-wrapping occur at whitespace instead of rudely at
the screen's edge, by using also \fBset atblanks\fR.)
.TP
.B set speller """\fIprogram\fR [\fIargument \fR...]\fB"""
Use the given \fIprogram\fR to do spell checking and correcting, instead of
using the built-in corrector that calls \fBhunspell\fR or GNU \fBspell\fR.
using the built-in corrector that calls \fBhunspell\fR(1) or \fBspell\fR(1).
.TP
.B set statuscolor \fIfgcolor\fR,\fIbgcolor\fR
Specify the color combination to use for the status bar.
.B set spotlightcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for highlighting a search match.
The default value is \fBblack,lightyellow\fR.
See \fBset titlecolor\fR for valid color names.
.TP
.B set stateflags
Use the top-right corner of the screen for showing some state flags:
\fBI\fR when auto-indenting, \fBM\fR when the mark is on, \fBL\fR when
hard-wrapping (breaking long lines), \fBR\fR when recording a macro,
and \fBS\fR when soft-wrapping.
When the buffer is modified, a star (\fB*\fR) is shown after the
filename in the center of the title bar.
.TP
.B set statuscolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the status bar.
See \fBset titlecolor\fR for more details.
.TP
.B set stripecolor \fIfgcolor\fR,\fIbgcolor\fR
Specify the color combination to use for the vertical guiding stripe.
.B set stripecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the vertical guiding stripe.
See \fBset titlecolor\fR for more details.
.TP
.B set suspend
Allow \fBnano\fP to be suspended.
.B set suspendable
Obsolete option; ignored. Suspension is enabled by default,
reachable via \fB^T^Z\fR. (If you want a plain \fB^Z\fR to
suspend nano, add \fBbind ^Z suspend main\fR to your nanorc.)
.TP
.B set tabsize \fInumber\fR
Use a tab size of \fInumber\fR columns. The value of \fInumber\fP must be
greater than 0. The default value is \fB8\fR.
.TP
.B set tabstospaces
Convert typed tabs to spaces.
Convert each typed tab to spaces -- to the number of spaces
that a tab at that position would take up.
.TP
.B set tempfile
Save automatically on exit, don't prompt.
.TP
.B set titlecolor \fIfgcolor\fR,\fIbgcolor\fR
Specify the color combination to use for the title bar.
.B set titlecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the title bar.
Valid names for the foreground and background colors are:
.BR white ", " black ", " blue ", " green ", " red ", "
.BR cyan ", " yellow ", " magenta ", and " normal
.BR red ", " green ", " blue ", " magenta ", " yellow ", " cyan ", "
.BR white ", and " black .
Each of these eight names may be prefixed with the word \fBlight\fR
to get a brighter version of that color.
The word \fBgrey\fR or \fBgray\fR may be used
as a synonym for \fBlightblack\fR.
On terminal emulators that can do at least 256 colors,
other valid (but unprefixable) color names are:
.BR pink ", " purple ", " mauve ", " lagoon ", " mint ", "
.BR lime ", " peach ", " orange ", " latte ", "
.BR rosy ", " beet ", " plum ", " sea ", " sky ", " slate ", "
.BR teal ", " sage ", " brown ", " ocher ", " sand ", " tawny ", "
.BR brick ", " crimson ", and " normal
-- where \fBnormal\fR means the default foreground or background color.
The name of the foreground color may be prefixed with \fBbright\fR.
And either "\fIfgcolor\fR" or ",\fIbgcolor\fR" may be left out.
On such emulators, the color may also be specified as a three-digit hexadecimal
number prefixed with \fB#\fR, with the digits representing the amounts of red,
green, and blue, respectively. This tells \fBnano\fR to select from the
available palette the color that approximates the given values.
Either "\fIfgcolor\fR" or "\fB,\fIbgcolor\fR" may be left out,
and the pair may be preceded by \fBbold\fR and/or \fBitalic\fR
(separated by commas) to get a bold and/or slanting typeface,
if your terminal can do those.
.TP
.B set trimblanks
Remove trailing whitespace from wrapped lines when automatic
@@ -313,11 +392,6 @@ Save a file by default in Unix format. This overrides nano's
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: 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
.BI "set whitespace """ characters """
Set the two characters used to indicate the presence of tabs and
spaces. They must be single-column characters. The default pair
@@ -329,12 +403,20 @@ characters as parts of words.
.TP
.BI "set wordchars """ characters """
Specify which other characters (besides the normal alphanumeric ones)
should be considered as parts of words. This overrides the option
\fBwordbounds\fR.
should be considered as parts of words. When using this option, you
probably want to unset \fBwordbounds\fR.
.TP
.B set zap
Let an unmodified Backspace or Delete erase the marked region
(instead of a single character, and without affecting the cutbuffer).
.TP
.B set zero
Hide all elements of the interface (title bar, status bar, and help lines)
and use all rows of the terminal for showing the contents of the buffer.
The status bar appears only when there is a significant message,
and disappears after 1.5 seconds or upon the next keystroke.
With \fBM-Z\fR the title bar plus status bar can be toggled.
With \fBM-X\fR the help lines.
.SH SYNTAX HIGHLIGHTING
Coloring the different syntactic elements of a file
@@ -366,13 +448,13 @@ Start the definition of a syntax with this \fIname\fR.
All subsequent \fBcolor\fR and other such commands
will be added to this syntax, until a new \fBsyntax\fR
command is encountered.
.sp
When \fBnano\fR is run, this syntax will be automatically
activated if the current filename matches the extended regular
expression \fIfileregex\fR. Or the syntax can be explicitly
activated by using the \fB\-Y\fR or \fB\-\-syntax\fR
command-line option followed by the \fIname\fR.
.sp
The syntax \fBdefault\fP is special: it takes no \fIfileregex\fR,
and applies to files that don't match any syntax's regexes.
The syntax \fBnone\fP is reserved; specifying it on the command line
@@ -416,24 +498,40 @@ Make the <Tab> key produce the given \fIstring\fR. Useful for languages like
Python that want to see only spaces for indentation.
This overrides the setting of the \fBtabstospaces\fR option.
.TP
.BI "color " fgcolor , bgcolor " """ regex """ " \fR...
.BI "color \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " """ regex """ " \fR...
Paint all pieces of text that match the extended regular expression
\fIregex\fP with the given foreground and background colors, at least
one of which must be specified. Valid color names are:
.BR white ", " black ", " blue ", " green ", " red ", "
.BR cyan ", " yellow ", " magenta ", and " normal
.BR red ", " green ", " blue ", " magenta ", " yellow ", " cyan ", "
.BR white ", and " black .
Each of these eight names may be prefixed with the word \fBlight\fR
to get a brighter version of that color.
The word \fBgrey\fR or \fBgray\fR may be used
as a synonym for \fBlightblack\fR.
On terminal emulators that can do at least 256 colors,
other valid (but unprefixable) color names are:
.BR pink ", " purple ", " mauve ", " lagoon ", " mint ", "
.BR lime ", " peach ", " orange ", " latte ", "
.BR rosy ", " beet ", " plum ", " sea ", " sky ", " slate ", "
.BR teal ", " sage ", " brown ", " ocher ", " sand ", " tawny ", "
.BR brick ", " crimson ", and " normal
-- where \fBnormal\fR means the default foreground or background color.
You may use the prefix \fBbright\fR for the foreground color to get a
stronger highlight. If your terminal supports transparency, not specifying
a \fIbgcolor\fP tells \fBnano\fP to attempt to use a transparent background.
On such emulators, the color may also be specified as a three-digit hexadecimal
number prefixed with \fB#\fR, with the digits representing the amounts of red,
green, and blue, respectively. This tells \fBnano\fR to select from the
available palette the color that approximates the given values.
The color pair may be preceded by \fBbold\fR and/or \fBitalic\fR
(separated by commas) to get a bold and/or slanting typeface,
if your terminal can do those.
.sp
All coloring commands are applied in the order in which they are specified,
which means that later commands can recolor stuff that was colored earlier.
.TP
.BI "icolor " fgcolor , bgcolor " """ regex """ " \fR...
.BI "icolor \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " """ regex """ " \fR...
Same as above, except that the matching is case insensitive.
.TP
.BI "color " fgcolor , bgcolor " start=""" fromrx """ end=""" torx """
.BI "color \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " start=""" fromrx """ end=""" torx """
Paint all pieces of text whose start matches extended regular expression
\fIfromrx\fP and whose end matches extended regular expression \fItorx\fP
with the given foreground and background colors,
@@ -442,7 +540,7 @@ initial instance of \fIfromrx\fP, all text until the first instance of
\fItorx\fP will be colored. This allows syntax highlighting to span
multiple lines.
.TP
.BI "icolor " fgcolor , bgcolor " start=""" fromrx """ end=""" torx """
.BI "icolor \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " start=""" fromrx """ end=""" torx """
Same as above, except that the matching is case insensitive.
.TP
.BI "include """ syntaxfile """
@@ -503,12 +601,15 @@ no longer be the case, for all letters.
where \fIN\fR is a numeric value from 1 to 24.
Example: F10.
(Often, \fBF13\fR to \fBF24\fR can be typed as \fBF1\fR to \fBF12\fR with Shift.)
.TP
.BR Ins " or " Del .
.RE
.sp
Rebinding \fB^M\fR (Enter) or \fB^I\fR (Tab) is probably not a good idea.
Rebinding \fB^[\fR (Esc) is not possible, because its keycode
is the starter byte of Meta keystrokes and escape sequences.
Rebinding any of the dedicated cursor-moving keys (the arrows, Home, End,
PageUp and PageDown) is not possible.
On some terminals it's not possible to rebind \fB^H\fR (unless \fB\-\-raw\fR
is used) because its keycode is identical to that of the Backspace key.
@@ -523,7 +624,7 @@ Invokes the help viewer.
Cancels the current command.
.TP
.B exit
Exits from the program (or from the help viewer or the file browser).
Exits from the program (or from the help viewer or file browser).
.TP
.B writeout
Writes the current buffer to disk, asking for a name.
@@ -570,7 +671,7 @@ Throws away the current line (or the marked region).
Deletes from the cursor position to the beginning of the preceding word.
(This function is bound by default to <Shift+Ctrl+Delete>. If your terminal
produces \fB^H\fR for <Ctrl+Backspace>, you can make <Ctrl+Backspace> delete
the word to the left of the cursor by rebinding ^H to this function.)
the word to the left of the cursor by rebinding \fB^H\fR to this function.)
.TP
.B chopwordright
Deletes from the cursor position to the beginning of the next word.
@@ -583,15 +684,22 @@ Cuts all text from the cursor position till the end of the buffer.
Sets the mark at the current position, to start selecting text.
Or, when it is set, unsets the mark.
.TP
.B curpos
Shows the current cursor position: the line, column, and character positions.
.B location
Reports the current position of the cursor in the buffer:
the line, column, and character positions.
(The old name of this function, 'curpos', is deprecated.)
.TP
.B wordcount
Counts the number of words, lines and characters in the current buffer.
Counts and reports on the status bar the number of lines, words,
and characters in the current buffer (or in the marked region).
.TP
.B execute
Prompts for a program to execute. The program's output will be inserted
into the current buffer (or into a new buffer when \fBM-F\fR is toggled).
.TP
.B speller
Invokes a spell-checking program, either the default \fBhunspell\fR or GNU
\fBspell\fR, or the one defined by \fB\-\-speller\fR or \fBset speller\fR.
Invokes a spell-checking program, either the default \fBhunspell\fR(1) or GNU
\fBspell\fR(1), or the one defined by \fB\-\-speller\fR or \fBset speller\fR.
.TP
.B formatter
Invokes a full-buffer-processing program (if the active syntax defines one).
@@ -600,27 +708,28 @@ Invokes a full-buffer-processing program (if the active syntax defines one).
Invokes a syntax-checking program (if the active syntax defines one).
.TP
.B justify
Justifies the current paragraph. A paragraph is a group of contiguous lines
Justifies the current paragraph (or the marked region).
A paragraph is a group of contiguous lines
that, apart from possibly the first line, all have the same indentation. The
beginning of a paragraph is detected by either this lone line with a differing
indentation or by a preceding blank line.
.TP
.B fulljustify
Justifies the entire current buffer.
Justifies the entire current buffer (or the marked region).
.TP
.B indent
Indents (shifts to the right) the currently marked text.
Indents (shifts to the right) the current line or the marked lines.
.TP
.B unindent
Unindents (shifts to the left) the currently marked text.
Unindents (shifts to the left) the current line or the marked lines.
.TP
.B comment
Comments or uncomments the current line or marked lines, using the comment
style specified in the active syntax.
Comments or uncomments the current line or the marked lines,
using the comment style specified in the active syntax.
.TP
.B complete
Completes the fragment before the cursor to a full word found elsewhere
in the current buffer.
Completes (when possible) the fragment before the cursor
to a full word found elsewhere in the current buffer.
.TP
.B left
Goes left one position (in the editor or browser).
@@ -637,10 +746,18 @@ Goes one line down (in the editor or browser).
.B scrollup
Scrolls the viewport up one row (meaning that the text slides down)
while keeping the cursor in the same text position, if possible.
(This function is bound by default to <Alt+Up>.
If <Alt+Up> does nothing on your Linux console, see the FAQ:
.UR https://nano\-editor.org/dist/latest/faq.html#4.1
.UE .)
.TP
.B scrolldown
Scrolls the viewport down one row (meaning that the text slides up)
while keeping the cursor in the same text position, if possible.
(This function is bound by default to <Alt+Down>.)
.TP
.B center
Scrolls the line with the cursor to the middle of the screen.
.TP
.B prevword
Moves the cursor to the beginning of the previous word.
@@ -684,8 +801,18 @@ Goes to a specific line (and column if specified). Negative numbers count
from the end of the file (and end of the line).
.TP
.B findbracket
Moves the cursor to the bracket (brace, parenthesis, etc.) that matches
(pairs) with the one under the cursor.
Moves the cursor to the bracket (or brace or parenthesis, etc.) that matches
(pairs) with the one under the cursor. See \fBset matchbrackets\fR.
.TP
.B anchor
Places an anchor at the current line, or removes it when already present.
(An anchor is visible when line numbers are activated.)
.TP
.B prevanchor
Goes to the first anchor before the current line.
.TP
.B nextanchor
Goes to the first anchor after the current line.
.TP
.B prevbuf
Switches to editing/viewing the previous buffer when multiple buffers are open.
@@ -725,8 +852,8 @@ Redoes the last undone action (i.e., it undoes an undo).
Refreshes the screen.
.TP
.B suspend
Suspends the editor (if the suspending function is enabled, see the
"suspendenable" entry below).
Suspends the editor and returns control to the shell
(until you tell the process to resume execution with \fBfg\fR).
.TP
.B casesens
Toggles whether searching/replacing ignores or respects the case of
@@ -782,24 +909,30 @@ When writing a file, creates a backup of the current file.
.TP
.B discardbuffer
When about to write a file, discard the current buffer without saving.
(This function is bound by default only when option \fB\-\-tempfile\fR
(This function is bound by default only when option \fB\-\-saveonexit\fR
is in effect.)
.TP
.B browser
Starts the file browser, allowing to select a file from a list.
Starts the file browser (in the Read File and Write Out menus),
allowing to select a file from a list.
.TP
.B gotodir
Goes to a directory to be specified, allowing to browse anywhere
in the filesystem.
.TP
.B firstfile
Goes to the first file when using the file browser (reading or writing files).
Goes to the first file in the list when using the file browser.
.TP
.B lastfile
Goes to the last file when using the file browser (reading or writing files).
Goes to the last file in the list when using the file browser.
.TP
.B nohelp
Toggles the presence of the two-line list of key bindings at the bottom of the screen.
(This toggle is special: it is available in all menus except the help viewer
and the linter. All further toggles are available in the main menu only.)
.TP
.B zero
Toggles the presence of title bar and status bar.
.TP
.B constantshow
Toggles the constant display of the current line, column, and character positions.
@@ -828,17 +961,15 @@ is the beginning of a paragraph.
Toggles whether cutting text will cut the whole line or just from the current cursor
position to the end of the line.
.TP
.B nowrap
.B breaklonglines
Toggles whether long lines will be hard-wrapped to the next line.
(The old name of this function, 'nowrap', is deprecated.)
.TP
.B tabstospaces
Toggles whether typed tabs will be converted to spaces.
.TP
.B mouse
Toggles mouse support.
.TP
.B suspendenable
Toggles whether the suspend sequence (normally ^Z) will suspend the editor window.
.RE
.TP
@@ -848,6 +979,9 @@ Valid \fImenu\fP sections are:
.B main
The main editor window where text is entered and edited.
.TP
.B help
The help-viewer menu.
.TP
.B search
The search menu (AKA whereis).
.TP
@@ -869,20 +1003,9 @@ The 'write file' menu.
.B insert
The 'insert file' menu.
.TP
.B extcmd
The menu for inserting output from an external command, reached from the insert menu.
.TP
.B help
The help-viewer menu.
.TP
.B spell
The menu of the integrated spell checker where the user can edit a misspelled word.
.TP
.B linter
The linter menu.
.TP
.B browser
The file browser for inserting or writing a file.
The 'file browser' menu, for selecting a file to be opened or
inserted or written to.
.TP
.B whereisfile
The 'search for a file' menu in the file browser.
@@ -890,6 +1013,18 @@ The 'search for a file' menu in the file browser.
.B gotodir
The 'go to directory' menu in the file browser.
.TP
.B execute
The menu for inserting the output from an external command,
or for filtering the buffer (or the marked region) through
an external command, or for executing one of several tools.
(The old form of this menu name, 'extcmd', is deprecated.)
.TP
.B spell
The menu of the integrated spell checker where the user can edit a misspelled word.
.TP
.B linter
The linter menu, which allows jumping through the linting messages.
.TP
.B all
A special name that encompasses all menus.
For \fBbind\fR it means all menus where the specified \fIfunction\fR exists;
@@ -903,6 +1038,13 @@ System-wide configuration file.
.TP
.IR ~/.nanorc " or " $XDG_CONFIG_HOME/nano/nanorc " or " ~/.config/nano/nanorc
Per-user configuration file.
.TP
.I /usr/share/nano/*
Syntax definitions for the syntax coloring of common file types
(and for less common file types in the \fIextra/\fR subdirectory).
.SH SEE ALSO
.BR nano (1)
.TP
.I https://nano-editor.org/cheatsheet.html
An overview of the default key bindings.

View File

@@ -1,4 +1,4 @@
.\" Copyright (C) 2002-2007, 2014-2020 Free Software Foundation, Inc.
.\" Copyright (C) 2002-2007, 2014-2022 Free Software Foundation, Inc.
.\"
.\" This document is dual-licensed. You may distribute and/or modify it
.\" under the terms of either of the following licenses:
@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH RNANO 1 "version 4.8" "February 2020"
.TH RNANO 1 "version 6.1" "February 2022"
.SH NAME
rnano \- a restricted nano

View File

@@ -1,18 +1,15 @@
## Sample initialization file for GNU nano.
##
## This file should not be in DOS or Mac format, and characters
## specially interpreted by the shell should not be escaped here.
## For the options that take parameters, the default value is shown.
## Other options are unset by default. To make sure that an option
## is disabled, you can use "unset <option>".
##
## To make sure an option is disabled, use "unset <option>".
##
## For the options that take parameters, the default value is given.
## Other options are unset by default.
##
## Inside string parameters, quotes should not be escaped. The last
## Characters that are special in a shell should not be escaped here.
## Inside string parameters, quotes should not be escaped -- the last
## double quote on the line will be seen as the closing quote.
## Make the 'nextword' function (Ctrl+Right) stop at word ends
## instead of at beginnings.
## Make 'nextword' (Ctrl+Right) and 'chopwordright' (Ctrl+Delete)
## stop at word ends instead of at beginnings.
# set afterends
## When soft line wrapping is enabled, make it wrap lines at blanks
@@ -33,6 +30,9 @@
## Use bold text instead of reverse video text.
# set boldtext
## Treat any line with leading whitespace as the beginning of a paragraph.
# set bookstyle
## The characters treated as closing brackets when justifying paragraphs.
## This may not include any blank characters. Only closing punctuation,
## optionally followed by these closing brackets, can end sentences.
@@ -44,8 +44,7 @@
## Do case-sensitive searches by default.
# set casesensitive
## Constantly display the cursor position in the status bar. Note that
## this overrides "quickblank".
## Constantly display the cursor position in the status bar or minibar.
# set constantshow
## Use cut-from-cursor-to-end-of-line by default.
@@ -59,13 +58,20 @@
## will be the terminal's width minus this number.
# set fill -8
## Draw a vertical stripe at the given column, to help judge text width.
## (This option does not have a default value.)
# set guidestripe 75
## Remember the used search/replace strings for the next session.
# set historylog
## Display a "scrollbar" on the righthand side of the edit window.
# set indicator
## Scroll the buffer contents per half-screen instead of per line.
# set jumpyscrolling
## Display line numbers to the left of the text.
## Display line numbers to the left (and any anchors in the margin).
# set linenumbers
## Enable vim-style lock-files. This is just to let a vim user know you
@@ -73,15 +79,22 @@
## no plans to implement vim-style undo state in these files.
# set locking
## The opening and closing brackets that can be found by bracket
## searches. They cannot contain blank characters. The former set must
## come before the latter set, and both must be in the same order.
## Fall back to slow libmagic to try and determine an applicable syntax.
# set magic
## The opening and closing brackets that are found by a matching-bracket
## search. This may not contain blank characters. The opening brackets
## must come before the closing ones, and they must be in the same order.
# set matchbrackets "(<[{)>]}"
## Suppress the title bar and show the filename plus a cursor-position
## percentage in the space of the status bar.
# set minibar
## Enable mouse support, if available for your system. When enabled,
## mouse clicks can be used to place the cursor, set the mark (with a
## double click), and execute shortcuts. The mouse will work in the X
## Window System, and on the console when gpm is running.
## double click), and execute shortcuts. The mouse will work in the
## X Window System, and on the console when gpm is running.
# set mouse
## Switch on multiple file buffers (inserting a file will put it into
@@ -109,14 +122,12 @@
## Preserve the XON and XOFF keys (^Q and ^S).
# set preserve
## The characters treated as closing punctuation when justifying
## paragraphs. They cannot contain blank characters. Only closing
## punctuation, optionally followed by closing brackets, can end
## sentences.
## The characters treated as closing punctuation when justifying paragraphs.
## This may not contain blank characters. Only these closing punctuations,
## optionally followed by closing brackets, can end sentences.
# set punct "!.?"
## Do quick status-bar blanking. Status-bar messages will disappear after
## 1 keystroke instead of 26. Note that "constantshow" overrides this.
## Make status-bar messages disappear after 1 keystroke instead of after 20.
# set quickblank
## The regular expression that matches quoting characters in email
@@ -133,42 +144,44 @@
## Regular expressions are of the extended type (ERE).
# set regexp
## 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.
## Save a changed buffer automatically on exit; don't prompt.
# set saveonexit
## (The old form of this option, 'set tempfile', is deprecated.)
## Put the cursor on the highlighted item in the file browser, and
## show the cursor in the help viewer; useful for people who use a
## braille display and people with poor vision.
# set showcursor
## Make the Home key smarter. When Home is pressed anywhere but at the
## Make the Home key smarter: when Home is pressed anywhere but at the
## very beginning of non-whitespace characters on a line, the cursor
## will jump to that beginning (either forwards or backwards). If the
## cursor is already at that position, it will jump to the true
## beginning of the line.
## cursor is already at that position, it will jump to the true start
## of the line (the left edge).
# set smarthome
## Enable soft line wrapping (AKA full-line display).
## Spread overlong lines over multiple screen lines.
# set softwrap
## Use this spelling checker instead of the internal one. This option
## does not have a default value.
# set speller "aspell -x -c"
## Allow nano to be suspended.
# set suspend
## Use the end of the title bar for some state flags: I = auto-indenting,
## M = mark, L = hard-wrapping long lines, R = recording, S = soft-wrapping.
# set stateflags
## Use this tab size instead of the default; it must be greater than 0.
# set tabsize 8
## Convert typed tabs to spaces.
## Convert each typed tab to the fitting number of spaces.
# set tabstospaces
## Save automatically on exit; don't prompt.
# set tempfile
## Snip whitespace at the end of lines when justifying or hard-wrapping.
# set trimblanks
## Disallow file modification. Why would you want this in an rcfile? ;)
# set view
## Save files by default in Unix format (also when they were DOS or Mac).
# set unix
## The two single-column characters used to display the first characters
## of tabs and spaces. 187 in ISO 8859-1 (0000BB in Unicode) and 183 in
@@ -191,58 +204,52 @@
## of a single character, and without affecting the cutbuffer).
# set zap
## Paint the interface elements of nano. These are examples;
## by default there are no colors, except for errorcolor.
# set titlecolor brightwhite,blue
# set statuscolor brightwhite,green
# set errorcolor brightwhite,red
# set selectedcolor brightwhite,magenta
## Hide the bars plus help lines and use the whole terminal as edit area.
# set zero
## Paint the interface elements of nano. These are examples; there are
## no colors by default, except for errorcolor and spotlightcolor.
# set titlecolor bold,white,blue
# set promptcolor lightwhite,grey
# set statuscolor bold,white,green
# set errorcolor bold,white,red
# set spotlightcolor black,lightyellow
# set selectedcolor lightwhite,magenta
# set stripecolor ,yellow
# set scrollercolor cyan
# set numbercolor cyan
# set keycolor cyan
# set functioncolor green
## In root's .nanorc you might want to use:
# set titlecolor brightwhite,magenta
# set statuscolor brightwhite,magenta
# set errorcolor brightwhite,red
# set selectedcolor brightwhite,cyan
# set titlecolor bold,white,magenta
# set promptcolor black,yellow
# set statuscolor bold,white,magenta
# set errorcolor bold,white,red
# set spotlightcolor black,orange
# set selectedcolor lightwhite,cyan
# set stripecolor ,yellow
# set scrollercolor magenta
# set numbercolor magenta
# set keycolor brightmagenta
# set keycolor lightmagenta
# set functioncolor magenta
## Setup of syntax coloring.
##
## syntax "name" ["filename regex" ...]
##
## color|icolor foreground,background "regex" ["regex"...]
## [...]
##
## 'color' will do case-sensitive matches, while 'icolor' will do
## case-insensitive matches.
##
## All color commands are applied in the order in which they are specified,
## meaning that later commands can recolor stuff that was colored earlier.
##
## Valid color names for foreground and background are: white, black, normal,
## red, blue, green, yellow, magenta, cyan. For foreground colors, you may
## use the prefix "bright" to get a stronger highlight.
##
## All regexes (regular expressions) are of the extended type (ERE).
##
## If the coloring rule should span multiple lines, use the following format:
##
## color fg,bg start="regex" end="regex"
##
## If you wish, you may put your syntax definitions in separate files.
## You can make use of such files as follows:
##
## include "/path/to/syntax_file.nanorc"
## === Syntax coloring ===
## For all details, see 'man nanorc', section SYNTAX HIGHLIGHTING.
## To include all existing syntax definitions, you can do:
## To include most of the existing syntax definitions, you can do:
# include "@PKGDATADIR@/*.nanorc"
## Or you can select just the ones you need. For example:
# include "@PKGDATADIR@/html.nanorc"
# include "@PKGDATADIR@/python.nanorc"
# include "@PKGDATADIR@/sh.nanorc"
## In @PKGDATADIR@/extra/ you can find some syntaxes that are
## specific for certain distros or for some less common languages.
## If <Tab> should always produce four spaces when editing a Python file,
## independent of the settings of 'tabsize' and 'tabstospaces':
@@ -252,8 +259,11 @@
# extendsyntax makefile tabgives " "
## Key bindings.
## See nanorc(5) (section REBINDING KEYS) for more details on this.
## === Key bindings ===
## For all details, see 'man nanorc', section REBINDING KEYS.
## If you want to suspend nano with one keystroke (instead of with ^T^Z):
# bind ^Z suspend main
## The <Ctrl+Delete> keystroke deletes the word to the right of the cursor.
## On some terminals the <Ctrl+Backspace> keystroke produces ^H, which is
@@ -264,13 +274,34 @@
## <Ctrl+Backspace> delete the word to the left of the cursor with:
# bind ^H chopwordleft main
## For a more mnemonic Comment keystroke (overriding Cut-from-cursor):
# bind M-K comment main
## If you want ^L to just refresh the screen and not center the cursor:
# bind ^L refresh main
## When you sometimes type M-J instead of M-K, or M-T instead of M-R:
# unbind M-J main
# unbind M-T main
## (Those functions are still accessible through ^T^J and ^T^V.)
## For quickly uppercasing or lowercasing the word under the cursor.
## (These effectively do a Ctrl+Right followed by a Shift+Ctrl+Left,
## and then pipe the selected text through a sed command.)
# bind Sh-M-U "Oc|sed 's/.*/\U&/'
" main
# bind Sh-M-L "Oc|sed 's/.*/\L&/'
" 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 ^X cut main
#bind ^C copy main
#bind ^V paste all
#bind ^Q exit all
#bind ^S savefile main
#bind ^W writeout main
#bind ^O insert main
#set multibuffer
#bind ^H help all
@@ -278,23 +309,18 @@
#bind ^F whereis all
#bind ^G findnext all
#bind ^B wherewas all
#bind M-X flipnewbuffer all
#bind ^X cut all
#bind ^C copy main
#bind ^V paste all
#bind ^P curpos main
#bind ^A mark main
#bind ^D findprevious all
#bind ^R replace main
#bind ^Z undo main
#bind ^Y redo main
#unbind ^K main
#unbind ^U all
#unbind ^N main
#unbind ^Y all
#unbind M-J main
#unbind M-T main
#bind ^A mark main
#bind ^P location main
#bind ^Y speller main
#bind M-U undo main
#bind M-R redo main
#bind ^U undo main
#bind ^E redo main
#set multibuffer
#bind ^T gotoline main
#bind ^T gotodir browser
#bind ^T cutrestoffile execute

View File

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

View File

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

View File

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

View File

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

2018
po/bg.po

File diff suppressed because it is too large Load Diff

2095
po/ca.po

File diff suppressed because it is too large Load Diff

2323
po/cs.po

File diff suppressed because it is too large Load Diff

2051
po/da.po

File diff suppressed because it is too large Load Diff

2156
po/de.po

File diff suppressed because it is too large Load Diff

2037
po/eo.po

File diff suppressed because it is too large Load Diff

2031
po/es.po

File diff suppressed because it is too large Load Diff

2024
po/eu.po

File diff suppressed because it is too large Load Diff

1939
po/fi.po

File diff suppressed because it is too large Load Diff

2080
po/fr.po

File diff suppressed because it is too large Load Diff

2074
po/ga.po

File diff suppressed because it is too large Load Diff

2389
po/gl.po

File diff suppressed because it is too large Load Diff

2546
po/hr.po

File diff suppressed because it is too large Load Diff

2058
po/hu.po

File diff suppressed because it is too large Load Diff

3143
po/id.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2059
po/it.po

File diff suppressed because it is too large Load Diff

2071
po/ja.po

File diff suppressed because it is too large Load Diff

2119
po/ko.po

File diff suppressed because it is too large Load Diff

2202
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2187
po/nb.po

File diff suppressed because it is too large Load Diff

2039
po/nl.po

File diff suppressed because it is too large Load Diff

2142
po/pl.po

File diff suppressed because it is too large Load Diff

2037
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2209
po/ro.po

File diff suppressed because it is too large Load Diff

2637
po/ru.po

File diff suppressed because it is too large Load Diff

3068
po/sk.po Normal file

File diff suppressed because it is too large Load Diff

2030
po/sl.po

File diff suppressed because it is too large Load Diff

2335
po/sr.po

File diff suppressed because it is too large Load Diff

2145
po/sv.po

File diff suppressed because it is too large Load Diff

2049
po/tr.po

File diff suppressed because it is too large Load Diff

2069
po/uk.po

File diff suppressed because it is too large Load Diff

View File

@@ -9,6 +9,9 @@ rm *.po
wget --recursive --level=1 --accept=po --no-directories --no-verbose \
https://translationproject.org/latest/nano/ || exit 2
# This PO file is less than twenty percent translated:
rm -v nn.po
# Are there now PO files that are not in git yet?
NEWSTUFF=$(git status --porcelain *.po | grep "^??")
@@ -26,6 +29,11 @@ for pofile in *.po; do
msgattrib --no-obsolete --no-fuzzy $pofile >trimmed.po || exit 4
mv trimmed.po $pofile || exit 4
done
echo
if grep "[[:cntrl:]]" ./*.po; then
echo "*** PO file contains control character"; exit 5;
fi
# If needed, fix a problem in the Makefile template.
grep -q '^datarootdir' Makefile.in.in || \

2049
po/vi.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
#!/bin/bash
VERSION="4.8"
VERSION="6.1"
./configure -C --enable-tiny && make && ./configure -C &&
@@ -12,7 +12,7 @@ po/update_linguas.sh &&
make distcheck && make dist-xz &&
git add po/*.po po/nano.pot &&
git add po/*.po po/nano.pot po/LINGUAS &&
git commit -m "$(git log -1 --grep 'po: up' | grep o: | sed 's/^ //')" &&
gpg -a -b nano-$VERSION.tar.gz &&

View File

@@ -6,7 +6,7 @@ CLEANFILES = revision.h
if BUILDING_FROM_GIT
SOMETHING = "REVISION \"`git describe --tags 2>/dev/null`\""
else
SOMETHING = "NOTHING \"from tarball\""
SOMETHING = "PLAINBUILD \"from tarball\""
endif
nano.o: revision.h
@@ -21,7 +21,10 @@ revision.h: FORCE
FORCE:
bin_PROGRAMS = nano
nano_SOURCES = browser.c \
nano_SOURCES = \
definitions.h \
prototypes.h \
browser.c \
chars.c \
color.c \
cut.c \
@@ -31,9 +34,7 @@ nano_SOURCES = browser.c \
history.c \
move.c \
nano.c \
nano.h \
prompt.c \
proto.h \
rcfile.c \
search.c \
text.c \

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* chars.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2016-2019 Benno Schulenberg *
* Copyright (C) 2001-2011, 2013-2022 Free Software Foundation, Inc. *
* Copyright (C) 2016-2021 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -19,7 +19,7 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#include <ctype.h>
#include <string.h>
@@ -44,118 +44,94 @@ bool using_utf8(void)
}
#endif /* ENABLE_UTF8 */
/* Concatenate two allocated strings, and free the second. */
char *addstrings(char* str1, size_t len1, char* str2, size_t len2)
{
str1 = charealloc(str1, len1 + len2 + 1);
str1[len1] = '\0';
strncat(&str1[len1], str2, len2);
free(str2);
return str1;
}
/* Return TRUE if the value of c is in byte range, and FALSE otherwise. */
bool is_byte(int c)
{
return ((unsigned int)c == (unsigned char)c);
}
/* This function is equivalent to isalpha() for multibyte characters. */
bool is_alpha_mbchar(const char *c)
#ifdef ENABLE_SPELLER
/* Return TRUE when the given character is some kind of letter. */
bool is_alpha_char(const char *c)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return FALSE;
if (mbtowide(&wc, c) < 0)
return FALSE;
return iswalpha(wc);
} else
return iswalpha(wc);
#else
return isalpha((unsigned char)*c);
#endif
return isalpha((unsigned char)*c);
}
#endif /* ENABLE_SPELLER */
/* This function is equivalent to isalnum() for multibyte characters. */
bool is_alnum_mbchar(const char *c)
/* Return TRUE when the given character is some kind of letter or a digit. */
bool is_alnum_char(const char *c)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return FALSE;
if (mbtowide(&wc, c) < 0)
return FALSE;
return iswalnum(wc);
} else
return iswalnum(wc);
#else
return isalnum((unsigned char)*c);
#endif
return isalnum((unsigned char)*c);
}
/* This function is equivalent to isblank() for multibyte characters. */
bool is_blank_mbchar(const char *c)
/* Return TRUE when the given character is space or tab or other whitespace. */
bool is_blank_char(const char *c)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return FALSE;
if ((signed char)*c >= 0)
return (*c == ' ' || *c == '\t');
return iswblank(wc);
} else
if (mbtowide(&wc, c) < 0)
return FALSE;
return iswblank(wc);
#else
return isblank((unsigned char)*c);
#endif
return isblank((unsigned char)*c);
}
/* This function is equivalent to iscntrl(), except in that it only
* handles non-high-bit control characters. */
bool is_ascii_cntrl_char(int c)
{
return (0 <= c && c < 32);
}
/* This function is equivalent to iscntrl() for multibyte characters,
* except in that it also handles multibyte control characters with
* their high bits set. */
bool is_cntrl_mbchar(const char *c)
/* Return TRUE when the given character is a control character. */
bool is_cntrl_char(const char *c)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
return ((c[0] & 0xE0) == 0 || c[0] == 127 ||
return ((c[0] & 0xE0) == 0 || c[0] == DEL_CODE ||
((signed char)c[0] == -62 && (signed char)c[1] < -96));
} else
#endif
return (((unsigned char)*c & 0x60) == 0 || (unsigned char)*c == 127);
return ((*c & 0x60) == 0 || *c == DEL_CODE);
}
/* This function is equivalent to ispunct() for multibyte characters. */
bool is_punct_mbchar(const char *c)
/* Return TRUE when the given character is a punctuation character. */
bool is_punct_char(const char *c)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return FALSE;
if (mbtowide(&wc, c) < 0)
return FALSE;
return iswpunct(wc);
} else
return iswpunct(wc);
#else
return ispunct((unsigned char)*c);
#endif
return ispunct((unsigned char)*c);
}
/* Return TRUE when the given multibyte character c is a word-forming
* character (that is: alphanumeric, or specified in wordchars, or
* punctuation when allow_punct is TRUE), and FALSE otherwise. */
bool is_word_mbchar(const char *c, bool allow_punct)
/* Return TRUE when the given character is word-forming (it is alphanumeric or
* specified in 'wordchars', or it is punctuation when allow_punct is TRUE). */
bool is_word_char(const char *c, bool allow_punct)
{
if (*c == '\0')
return FALSE;
if (is_alnum_mbchar(c))
if (is_alnum_char(c))
return TRUE;
if (allow_punct && is_punct_char(c))
return TRUE;
if (word_chars != NULL && *word_chars != '\0') {
@@ -164,9 +140,8 @@ bool is_word_mbchar(const char *c, bool allow_punct)
symbol[symlen] = '\0';
return (strstr(word_chars, symbol) != NULL);
}
return (allow_punct && is_punct_mbchar(c));
} else
return FALSE;
}
/* Return the visible representation of control character c. */
@@ -201,66 +176,123 @@ char control_mbrep(const char *c, bool isdata)
}
#ifdef ENABLE_UTF8
/* Return the width in columns of the given (multibyte) character. */
int mbwidth(const char *c)
/* Convert the given multibyte sequence c to wide character wc, and return
* the number of bytes in the sequence, or -1 for an invalid sequence. */
int mbtowide(wchar_t *wc, const char *c)
{
/* Ask for the width only when the character isn't plain ASCII. */
if ((signed char)*c <= 0) {
wchar_t wc;
int width;
if ((signed char)*c < 0 && use_utf8) {
unsigned char v1 = (unsigned char)c[0];
unsigned char v2 = (unsigned char)c[1] ^ 0x80;
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return 1;
if (v2 > 0x3F || v1 < 0xC2)
return -1;
width = wcwidth(wc);
if (width < 0)
return 1;
return width;
} else
return 1;
}
#endif
/* Convert the Unicode value in code to a multibyte character, if possible.
* If the conversion succeeds, return the (dynamically allocated) multibyte
* character and its length. Otherwise, return an undefined (dynamically
* allocated) multibyte character and a length of zero. */
char *make_mbchar(long code, int *length)
{
char *mb_char;
#ifdef ENABLE_UTF8
if (use_utf8) {
mb_char = charalloc(MAXCHARLEN);
*length = wctomb(mb_char, (wchar_t)code);
/* Reject invalid Unicode characters. */
if (*length < 0 || !is_valid_unicode((wchar_t)code)) {
IGNORE_CALL_RESULT(wctomb(NULL, 0));
*length = 0;
if (v1 < 0xE0) {
*wc = (((unsigned int)(v1 & 0x1F) << 6) | (unsigned int)v2);
return 2;
}
} else
#endif
{
mb_char = measured_copy((char *)&code, 1);
*length = 1;
unsigned char v3 = (unsigned char)c[2] ^ 0x80;
if (v3 > 0x3F)
return -1;
if (v1 < 0xF0) {
if ((v1 > 0xE0 || v2 >= 0x20) && (v1 != 0xED || v2 < 0x20)) {
*wc = (((unsigned int)(v1 & 0x0F) << 12) |
((unsigned int)v2 << 6) | (unsigned int)v3);
return 3;
} else
return -1;
}
unsigned char v4 = (unsigned char)c[3] ^ 0x80;
if (v4 > 0x3F || v1 > 0xF4)
return -1;
if ((v1 > 0xF0 || v2 >= 0x10) && (v1 != 0xF4 || v2 < 0x10)) {
*wc = (((unsigned int)(v1 & 0x07) << 18) | ((unsigned int)v2 << 12) |
((unsigned int)v3 << 6) | (unsigned int)v4);
return 4;
} else
return -1;
}
return mb_char;
*wc = (unsigned int)*c;
return 1;
}
/* Return the length (in bytes) of the character located at *pointer. */
/* Return TRUE when the given character occupies two cells. */
bool is_doublewidth(const char *ch)
{
wchar_t wc;
/* Only from U+1100 can code points have double width. */
if ((unsigned char)*ch < 0xE1 || !use_utf8)
return FALSE;
if (mbtowide(&wc, ch) < 0)
return FALSE;
return (wcwidth(wc) == 2);
}
/* Return TRUE when the given character occupies zero cells. */
bool is_zerowidth(const char *ch)
{
wchar_t wc;
/* Only from U+0300 can code points have zero width. */
if ((unsigned char)*ch < 0xCC || !use_utf8)
return FALSE;
if (mbtowide(&wc, ch) < 0)
return FALSE;
#if defined(__OpenBSD__)
/* Work around an OpenBSD bug -- see https://sv.gnu.org/bugs/?60393. */
if (wc >= 0xF0000)
return FALSE;
#endif
return (wcwidth(wc) == 0);
}
#endif /* ENABLE_UTF8 */
/* Return the number of bytes in the character that starts at *pointer. */
int char_length(const char *pointer)
{
#ifdef ENABLE_UTF8
/* If possibly a multibyte character, get its length; otherwise, it's 1. */
if ((signed char)*pointer < 0) {
int length = mblen(pointer, MAXCHARLEN);
if ((unsigned char)*pointer > 0xC1 && use_utf8) {
unsigned char c1 = (unsigned char)pointer[0];
unsigned char c2 = (unsigned char)pointer[1];
return (length < 0 ? 1 : length);
} else
if ((c2 ^ 0x80) > 0x3F)
return 1;
if (c1 < 0xE0)
return 2;
if (((unsigned char)pointer[2] ^ 0x80) > 0x3F)
return 1;
if (c1 < 0xF0) {
if ((c1 > 0xE0 || c2 >= 0xA0) && (c1 != 0xED || c2 < 0xA0))
return 3;
else
return 1;
}
if (((unsigned char)pointer[3] ^ 0x80) > 0x3F)
return 1;
if (c1 > 0xF4)
return 1;
if ((c1 > 0xF0 || c2 >= 0x90) && (c1 != 0xF4 || c2 < 0x90))
return 4;
}
#endif
return 1;
}
@@ -271,15 +303,7 @@ size_t mbstrlen(const char *pointer)
size_t count = 0;
while (*pointer != '\0') {
#ifdef ENABLE_UTF8
if ((signed char)*pointer < 0) {
int length = mblen(pointer, MAXCHARLEN);
pointer += (length < 0 ? 1 : length);
} else
#endif
pointer++;
pointer += char_length(pointer);
count++;
}
@@ -290,19 +314,7 @@ size_t mbstrlen(const char *pointer)
* given string, and return a copy of this character in *thechar. */
int collect_char(const char *string, char *thechar)
{
int charlen;
#ifdef ENABLE_UTF8
/* If this is a UTF-8 starter byte, get the number of bytes of the character. */
if ((signed char)*string < 0) {
charlen = mblen(string, MAXCHARLEN);
/* When the multibyte sequence is invalid, only take the first byte. */
if (charlen <= 0)
charlen = 1;
} else
#endif
charlen = 1;
int charlen = char_length(string);
for (int i = 0; i < charlen; i++)
thechar[i] = string[i];
@@ -315,20 +327,29 @@ int collect_char(const char *string, char *thechar)
int advance_over(const char *string, size_t *column)
{
#ifdef ENABLE_UTF8
if ((signed char)*string < 0) {
int charlen = mblen(string, MAXCHARLEN);
if (charlen > 0) {
if (is_cntrl_mbchar(string))
*column += 2;
else
*column += mbwidth(string);
if ((signed char)*string < 0 && use_utf8) {
/* A UTF-8 upper control code has two bytes and takes two columns. */
if (((unsigned char)string[0] == 0xC2 && (signed char)string[1] < -96)) {
*column += 2;
return 2;
} else {
charlen = 1;
*column += 1;
}
wchar_t wc;
int charlen = mbtowide(&wc, string);
return charlen;
if (charlen < 0) {
*column += 1;
return 1;
}
int width = wcwidth(wc);
#if defined(__OpenBSD__)
*column += (width < 0 || wc >= 0xF0000) ? 1 : width;
#else
*column += (width < 0) ? 1 : width;
#endif
return charlen;
}
}
#endif
@@ -337,12 +358,8 @@ int advance_over(const char *string, size_t *column)
*column += tabsize - *column % tabsize;
else
*column += 2;
} else if (*string == 0x7F)
} else if (0x7E < (unsigned char)*string && (unsigned char)*string < 0xA0)
*column += 2;
#ifndef ENABLE_UTF8
else if (0x7F < (unsigned char)*string && (unsigned char)*string < 0xA0)
*column += 2;
#endif
else
*column += 1;
@@ -409,8 +426,24 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
wchar_t wc1, wc2;
while (*s1 != '\0' && *s2 != '\0' && n > 0) {
bool bad1 = (mbtowc(&wc1, s1, MAXCHARLEN) < 0);
bool bad2 = (mbtowc(&wc2, s2, MAXCHARLEN) < 0);
if ((signed char)*s1 >= 0 && (signed char)*s2 >= 0) {
if ('A' <= (*s1 & 0x5F) && (*s1 & 0x5F) <= 'Z') {
if ('A' <= (*s2 & 0x5F) && (*s2 & 0x5F) <= 'Z') {
if ((*s1 & 0x5F) != (*s2 & 0x5F))
return ((*s1 & 0x5F) - (*s2 & 0x5F));
} else
return ((*s1 | 0x20) - *s2);
} else if ('A' <= (*s2 & 0x5F) && (*s2 & 0x5F) <= 'Z')
return (*s1 - (*s2 | 0x20));
else if (*s1 != *s2)
return (*s1 - *s2);
s1++; s2++; n--;
continue;
}
bool bad1 = (mbtowide(&wc1, s1) < 0);
bool bad2 = (mbtowide(&wc2, s2) < 0);
if (bad1 || bad2) {
if (*s1 != *s2)
@@ -465,7 +498,7 @@ char *revstrstr(const char *haystack, const char *needle,
size_t tail_len = strlen(pointer);
if (tail_len < needle_len)
pointer += tail_len - needle_len;
pointer -= (needle_len - tail_len);
while (pointer >= haystack) {
if (strncmp(pointer, needle, needle_len) == 0)
@@ -485,7 +518,7 @@ char *revstrcasestr(const char *haystack, const char *needle,
size_t tail_len = strlen(pointer);
if (tail_len < needle_len)
pointer += tail_len - needle_len;
pointer -= (needle_len - tail_len);
while (pointer >= haystack) {
if (strncasecmp(pointer, needle, needle_len) == 0)
@@ -507,7 +540,7 @@ char *mbrevstrcasestr(const char *haystack, const char *needle,
size_t tail_len = mbstrlen(pointer);
if (tail_len < needle_len)
pointer += tail_len - needle_len;
pointer -= (needle_len - tail_len);
if (pointer < haystack)
return NULL;
@@ -535,13 +568,13 @@ char *mbstrchr(const char *string, const char *chr)
bool bad_s = FALSE, bad_c = FALSE;
wchar_t ws, wc;
if (mbtowc(&wc, chr, MAXCHARLEN) < 0) {
if (mbtowide(&wc, chr) < 0) {
wc = (unsigned char)*chr;
bad_c = TRUE;
}
while (*string != '\0') {
int symlen = mbtowc(&ws, string, MAXCHARLEN);
int symlen = mbtowide(&ws, string);
if (symlen < 0) {
ws = (unsigned char)*string;
@@ -603,39 +636,21 @@ char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer)
#endif /* !NANO_TINY */
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || defined(ENABLE_JUSTIFY))
/* Return TRUE if the given string contains at least one blank character,
* and FALSE otherwise. */
/* Return TRUE if the given string contains at least one blank character. */
bool has_blank_char(const char *string)
{
char symbol[MAXCHARLEN];
while (*string != '\0' && !is_blank_char(string))
string += char_length(string);
while (*string != '\0') {
string += collect_char(string, symbol);
if (is_blank_mbchar(symbol))
return TRUE;
}
return FALSE;
return *string;
}
#endif /* ENABLE_NANORC && (!NANO_TINY || ENABLE_JUSTIFY) */
#endif
/* Return TRUE when the given string is empty or consists of only blanks. */
bool white_string(const char *string)
{
while (*string != '\0' && (is_blank_mbchar(string) || *string == '\r'))
while (*string != '\0' && (is_blank_char(string) || *string == '\r'))
string += char_length(string);
return !*string;
}
#ifdef ENABLE_UTF8
/* Return TRUE if wc is valid Unicode, and FALSE otherwise. */
bool is_valid_unicode(wchar_t wc)
{
return ((0 <= wc && wc <= 0xD7FF) ||
(0xE000 <= wc && wc <= 0xFDCF) ||
(0xFDF0 <= wc && wc <= 0xFFFD) ||
(0xFFFF < wc && wc <= 0x10FFFF && (wc & 0xFFFF) <= 0xFFFD));
}
#endif

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* color.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017 Benno Schulenberg *
* Copyright (C) 2001-2011, 2013-2022 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017, 2020, 2021 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -19,7 +19,7 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#ifdef ENABLE_COLOR
@@ -29,51 +29,15 @@
#endif
#include <string.h>
/* For early versions of ncurses-6.0, use an additional A_PROTECT attribute
* for all colors, in order to work around an ncurses miscoloring bug. */
#if defined(NCURSES_VERSION_MAJOR) && (NCURSES_VERSION_MAJOR == 6) && \
(NCURSES_VERSION_MINOR == 0) && (NCURSES_VERSION_PATCH < 20151017)
#define A_BANDAID A_PROTECT
#else
#define A_BANDAID A_NORMAL
#endif
static bool defaults_allowed = FALSE;
/* Whether ncurses accepts -1 to mean "default color". */
/* Assign pair numbers for the colors in the given syntax, giving identical
* color pairs the same number. */
void set_syntax_colorpairs(syntaxtype *sint)
/* Initialize the color pairs for nano's interface. */
void set_interface_colorpairs(void)
{
int new_number = NUMBER_OF_ELEMENTS + 1;
colortype *ink;
for (ink = sint->color; ink != NULL; ink = ink->next) {
const colortype *beforenow = sint->color;
while (beforenow != ink && (beforenow->fg != ink->fg ||
beforenow->bg != ink->bg))
beforenow = beforenow->next;
if (beforenow != ink)
ink->pairnum = beforenow->pairnum;
else
ink->pairnum = new_number++;
ink->attributes |= COLOR_PAIR(ink->pairnum) | A_BANDAID;
}
}
/* Initialize the colors for nano's interface, and assign pair numbers
* for the colors in each loaded syntax. */
void set_colorpairs(void)
{
syntaxtype *sint;
bool using_defaults = FALSE;
/* Tell ncurses to enable colors. */
start_color();
#ifdef HAVE_USE_DEFAULT_COLORS
/* Allow using the default colors, if available. */
using_defaults = (use_default_colors() != ERR);
/* Ask ncurses to allow -1 to mean "default color". */
defaults_allowed = (use_default_colors() == OK);
#endif
/* Initialize the color pairs for nano's interface elements. */
@@ -81,64 +45,72 @@ void set_colorpairs(void)
colortype *combo = color_combo[index];
if (combo != NULL) {
if (combo->fg == USE_THE_DEFAULT && !using_defaults)
combo->fg = COLOR_WHITE;
if (combo->bg == USE_THE_DEFAULT && !using_defaults)
combo->bg = COLOR_BLACK;
if (!defaults_allowed) {
if (combo->fg == THE_DEFAULT)
combo->fg = COLOR_WHITE;
if (combo->bg == THE_DEFAULT)
combo->bg = COLOR_BLACK;
}
init_pair(index + 1, combo->fg, combo->bg);
interface_color_pair[index] = COLOR_PAIR(index + 1) | A_BANDAID |
combo->attributes;
interface_color_pair[index] = COLOR_PAIR(index + 1) | combo->attributes;
} else {
if (index == FUNCTION_TAG)
if (index == FUNCTION_TAG || index == SCROLL_BAR)
interface_color_pair[index] = A_NORMAL;
else if (index == GUIDE_STRIPE)
interface_color_pair[index] = A_REVERSE;
else if (index == SPOTLIGHTED) {
init_pair(index + 1, COLOR_BLACK, COLOR_YELLOW + (COLORS > 15 ? 8 : 0));
interface_color_pair[index] = COLOR_PAIR(index + 1);
} else if (index == MINI_INFOBAR || index == PROMPT_BAR)
interface_color_pair[index] = interface_color_pair[TITLE_BAR];
else if (index == ERROR_MESSAGE) {
init_pair(index + 1, COLOR_WHITE, COLOR_RED);
interface_color_pair[index] = COLOR_PAIR(index + 1) |
A_BOLD | A_BANDAID;
interface_color_pair[index] = COLOR_PAIR(index + 1) | A_BOLD;
} else
interface_color_pair[index] = hilite_attribute;
}
free(color_combo[index]);
}
/* For each loaded syntax, assign pair numbers to color combinations. */
for (sint = syntaxes; sint != NULL; sint = sint->next)
if (sint->filename == NULL)
set_syntax_colorpairs(sint);
}
/* Initialize the color information. */
void color_init(void)
/* Assign a pair number to each of the foreground/background color combinations
* in the given syntax, giving identical combinations the same number. */
void set_syntax_colorpairs(syntaxtype *sntx)
{
const colortype *ink;
bool using_defaults = FALSE;
short foreground, background;
short number = NUMBER_OF_ELEMENTS;
colortype *older;
/* If the terminal is not capable of colors, forget it. */
if (!has_colors())
return;
for (colortype *ink = sntx->color; ink != NULL; ink = ink->next) {
if (!defaults_allowed) {
if (ink->fg == THE_DEFAULT)
ink->fg = COLOR_WHITE;
if (ink->bg == THE_DEFAULT)
ink->bg = COLOR_BLACK;
}
#ifdef HAVE_USE_DEFAULT_COLORS
/* Allow using the default colors, if available. */
using_defaults = (use_default_colors() != ERR);
#endif
older = sntx->color;
/* For each coloring expression, initialize the color pair. */
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
foreground = ink->fg;
background = ink->bg;
while (older != ink && (older->fg != ink->fg || older->bg != ink->bg))
older = older->next;
if (foreground == USE_THE_DEFAULT && !using_defaults)
foreground = COLOR_WHITE;
ink->pairnum = (older != ink) ? older->pairnum : ++number;
if (background == USE_THE_DEFAULT && !using_defaults)
background = COLOR_BLACK;
init_pair(ink->pairnum, foreground, background);
ink->attributes |= COLOR_PAIR(ink->pairnum);
}
}
/* Initialize the color pairs for the current syntax. */
void prepare_palette(void)
{
short number = NUMBER_OF_ELEMENTS;
/* For each unique pair number, tell ncurses the combination of colors. */
for (colortype *ink = openfile->syntax->color; ink != NULL; ink = ink->next)
if (ink->pairnum > number) {
init_pair(ink->pairnum, ink->fg, ink->bg);
number = ink->pairnum;
}
have_palette = TRUE;
}
@@ -147,27 +119,18 @@ void color_init(void)
* the list starting at head. Return TRUE upon success. */
bool found_in_list(regexlisttype *head, const char *shibboleth)
{
regexlisttype *item;
regex_t rgx;
for (item = head; item != NULL; item = item->next) {
regcomp(&rgx, item->full_regex, NANO_REG_EXTENDED);
if (regexec(&rgx, shibboleth, 0, NULL, 0) == 0) {
regfree(&rgx);
for (regexlisttype *item = head; item != NULL; item = item->next)
if (regexec(item->one_rgx, shibboleth, 0, NULL, 0) == 0)
return TRUE;
}
regfree(&rgx);
}
return FALSE;
}
/* Update the color information based on the current filename and content. */
void color_update(void)
/* Find a syntax that applies to the current buffer, based upon filename
* or buffer content, and load and prime this syntax when needed. */
void find_and_prime_applicable_syntax(void)
{
syntaxtype *sint = NULL;
syntaxtype *sntx = NULL;
/* If the rcfiles were not read, or contained no syntaxes, get out. */
if (syntaxes == NULL)
@@ -179,42 +142,39 @@ void color_update(void)
if (strcmp(syntaxstr, "none") == 0)
return;
for (sint = syntaxes; sint != NULL; sint = sint->next) {
if (strcmp(sint->name, syntaxstr) == 0)
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
if (strcmp(sntx->name, syntaxstr) == 0)
break;
}
if (sint == NULL && !inhelp)
if (sntx == NULL && !inhelp)
statusline(ALERT, _("Unknown syntax name: %s"), syntaxstr);
}
/* If no syntax-override string was specified, or it didn't match,
* try finding a syntax based on the filename (extension). */
if (sint == NULL && !inhelp) {
if (sntx == NULL && !inhelp) {
char *fullname = get_full_path(openfile->filename);
if (fullname == NULL)
fullname = mallocstrcpy(fullname, openfile->filename);
for (sint = syntaxes; sint != NULL; sint = sint->next) {
if (found_in_list(sint->extensions, fullname))
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
if (found_in_list(sntx->extensions, fullname))
break;
}
free(fullname);
}
/* If the filename didn't match anything, try the first line. */
if (sint == NULL && !inhelp) {
for (sint = syntaxes; sint != NULL; sint = sint->next) {
if (found_in_list(sint->headers, openfile->filetop->data))
if (sntx == NULL && !inhelp) {
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
if (found_in_list(sntx->headers, openfile->filetop->data))
break;
}
}
#ifdef HAVE_LIBMAGIC
/* If we still don't have an answer, try using magic. */
if (sint == NULL && !inhelp) {
/* If we still don't have an answer, try using magic (when requested). */
if (sntx == NULL && !inhelp && ISSET(USE_MAGIC)) {
struct stat fileinfo;
magic_t cookie = NULL;
const char *magicstring = NULL;
@@ -238,10 +198,9 @@ void color_update(void)
/* Now try and find a syntax that matches the magic string. */
if (magicstring != NULL) {
for (sint = syntaxes; sint != NULL; sint = sint->next) {
if (found_in_list(sint->magics, magicstring))
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
if (found_in_list(sntx->magics, magicstring))
break;
}
}
if (stat(openfile->filename, &fileinfo) == 0)
@@ -250,30 +209,19 @@ void color_update(void)
#endif /* HAVE_LIBMAGIC */
/* If nothing at all matched, see if there is a default syntax. */
if (sint == NULL && !inhelp) {
for (sint = syntaxes; sint != NULL; sint = sint->next) {
if (strcmp(sint->name, "default") == 0)
if (sntx == NULL && !inhelp) {
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
if (strcmp(sntx->name, "default") == 0)
break;
}
}
/* When the syntax isn't loaded yet, parse it and initialize its colors. */
if (sint != NULL && sint->filename != NULL) {
parse_one_include(sint->filename, sint);
set_syntax_colorpairs(sint);
if (sntx != NULL && sntx->filename != NULL) {
parse_one_include(sntx->filename, sntx);
set_syntax_colorpairs(sntx);
}
openfile->syntax = sint;
openfile->colorstrings = (sint == NULL ? NULL : sint->color);
}
/* Allocate and initialize (for the given line) the cache for multiline info. */
void set_up_multicache(linestruct *line)
{
line->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short));
for (int index = 0; index < openfile->syntax->nmultis; index++)
line->multidata[index] = -1;
openfile->syntax = sntx;
}
/* Determine whether the matches of multiline regexes are still the same,
@@ -289,10 +237,12 @@ void check_the_multis(linestruct *line)
if (openfile->syntax == NULL || openfile->syntax->nmultis == 0)
return;
if (line->multidata == NULL)
set_up_multicache(line);
if (line->multidata == NULL) {
refresh_needed = TRUE;
return;
}
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
for (ink = openfile->syntax->color; ink != NULL; ink = ink->next) {
/* If it's not a multiline regex, skip. */
if (ink->end == NULL)
continue;
@@ -302,19 +252,22 @@ void check_the_multis(linestruct *line)
anend = (regexec(ink->end, afterstart, 1, &endmatch, 0) == 0);
/* Check whether the multidata still matches the current situation. */
if (line->multidata[ink->id] == CNONE ||
line->multidata[ink->id] == CWHOLELINE) {
if (line->multidata[ink->id] == NOTHING) {
if (!astart)
continue;
} else if (line->multidata[ink->id] & (WHOLELINE|WOULDBE)) {
if (!astart && !anend)
continue;
} else if (line->multidata[ink->id] == CSTARTENDHERE) {
if (astart && anend && startmatch.rm_so < endmatch.rm_so)
} else if (line->multidata[ink->id] == JUSTONTHIS) {
if (astart && anend && regexec(ink->start, line->data + endmatch.rm_eo,
1, &startmatch, 0) != 0)
continue;
} else if (line->multidata[ink->id] == CBEGINBEFORE) {
if (!astart && anend)
continue;
} else if (line->multidata[ink->id] == CENDAFTER) {
} else if (line->multidata[ink->id] == STARTSHERE) {
if (astart && !anend)
continue;
} else if (line->multidata[ink->id] == ENDSHERE) {
if (!astart && anend)
continue;
}
/* There is a mismatch, so something changed: repaint. */
@@ -331,14 +284,21 @@ void precalc_multicolorinfo(void)
regmatch_t startmatch, endmatch;
linestruct *line, *tailline;
if (openfile->colorstrings == NULL || ISSET(NO_COLOR_SYNTAX))
if (!openfile->syntax || openfile->syntax->nmultis == 0 || ISSET(NO_SYNTAX))
return;
//#define TIMEPRECALC 123
#ifdef TIMEPRECALC
#include <time.h>
clock_t start = clock();
#endif
/* For each line, allocate cache space for the multiline-regex info. */
for (line = openfile->filetop; line != NULL; line = line->next)
set_up_multicache(line);
if (!line->multidata)
line->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short));
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
for (ink = openfile->syntax->color; ink != NULL; ink = ink->next) {
/* If this is not a multi-line regex, skip it. */
if (ink->end == NULL)
continue;
@@ -347,66 +307,68 @@ void precalc_multicolorinfo(void)
int index = 0;
/* Assume nothing applies until proven otherwise below. */
line->multidata[ink->id] = CNONE;
line->multidata[ink->id] = NOTHING;
/* For an unpaired start match, mark all remaining lines. */
if (line->prev && line->prev->multidata[ink->id] == CWOULDBE) {
line->multidata[ink->id] = CWOULDBE;
continue;
}
/* When the line contains a start match, look for an end, and if
* found, mark all the lines that are affected. */
while (regexec(ink->start, line->data + index, 1,
&startmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
/* When the line contains a start match, look for an end,
* and if found, mark all the lines that are affected. */
while (regexec(ink->start, line->data + index, 1, &startmatch,
(index == 0) ? 0 : REG_NOTBOL) == 0) {
/* Begin looking for an end match after the start match. */
index += startmatch.rm_eo;
/* If there is an end match on this line, mark the line, but
* continue looking for other starts after it. */
if (regexec(ink->end, line->data + index, 1,
&endmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
line->multidata[ink->id] = CSTARTENDHERE;
/* If there is an end match on this same line, mark the line,
* but continue looking for other starts after it. */
if (regexec(ink->end, line->data + index, 1, &endmatch,
(index == 0) ? 0 : REG_NOTBOL) == 0) {
line->multidata[ink->id] = JUSTONTHIS;
index += endmatch.rm_eo;
/* If both start and end are mere anchors, step ahead. */
if (startmatch.rm_so == startmatch.rm_eo &&
endmatch.rm_so == endmatch.rm_eo) {
/* When at end-of-line, we're done. */
/* If the total match has zero length, force an advance. */
if (startmatch.rm_eo - startmatch.rm_so + endmatch.rm_eo == 0) {
/* When at end-of-line, there is no other start. */
if (line->data[index] == '\0')
break;
index = step_right(line->data, index);
}
continue;
}
/* Look for an end match on later lines. */
tailline = line->next;
while (tailline != NULL) {
if (regexec(ink->end, tailline->data, 1, &endmatch, 0) == 0)
break;
while (tailline && regexec(ink->end, tailline->data,
1, &endmatch, 0) != 0)
tailline = tailline->next;
}
/* When there is no end match, mark relevant lines as such. */
if (tailline == NULL) {
line->multidata[ink->id] = CWOULDBE;
for (; line->next != NULL; line = line->next)
line->multidata[ink->id] = WOULDBE;
line->multidata[ink->id] = WOULDBE;
break;
}
/* We found it, we found it, la la la la la. Mark all
* the lines in between and the end properly. */
line->multidata[ink->id] = CENDAFTER;
/* We found it, we found it, la lala lala. Mark the lines. */
line->multidata[ink->id] = STARTSHERE;
// Note that this also advances the line in the main loop.
for (line = line->next; line != tailline; line = line->next)
line->multidata[ink->id] = CWHOLELINE;
line->multidata[ink->id] = WHOLELINE;
tailline->multidata[ink->id] = CBEGINBEFORE;
tailline->multidata[ink->id] = ENDSHERE;
/* Begin looking for a new start after the end match. */
/* Look for a possible new start after the end match. */
index = endmatch.rm_eo;
}
}
}
#ifdef TIMEPRECALC
statusline(INFO, "Precalculation: %.1f ms", 1000 * (double)(clock() - start) / CLOCKS_PER_SEC);
napms(1200);
#endif
}
#endif /* ENABLE_COLOR */

672
src/cut.c
View File

@@ -1,9 +1,9 @@
/**************************************************************************
* cut.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
* Copyright (C) 2014 Mark Majeres *
* Copyright (C) 2016, 2018, 2019 Benno Schulenberg *
* Copyright (C) 2016, 2018-2020 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -20,17 +20,13 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#include <string.h>
/* Delete the character under the cursor. */
void do_deletion(undo_type action)
{
#ifndef NANO_TINY
size_t old_amount = 0;
#endif
openfile->placewewant = xplustabs();
/* When in the middle of a line, delete the current character. */
@@ -38,22 +34,25 @@ void do_deletion(undo_type action)
int charlen = char_length(openfile->current->data + openfile->current_x);
size_t line_len = strlen(openfile->current->data + openfile->current_x);
#ifndef NANO_TINY
size_t old_amount = ISSET(SOFTWRAP) ? extra_chunks_in(openfile->current) : 0;
/* 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)
openfile->current->lineno != openfile->current_undo->head_lineno)
add_undo(action, NULL);
else
update_undo(action);
if (ISSET(SOFTWRAP))
old_amount = number_of_chunks_in(openfile->current);
#endif
/* Move the remainder of the line "in", over the current character. */
memmove(&openfile->current->data[openfile->current_x],
&openfile->current->data[openfile->current_x + charlen],
line_len - charlen + 1);
#ifndef NANO_TINY
/* When softwrapping, a changed number of chunks requires a refresh. */
if (ISSET(SOFTWRAP) && extra_chunks_in(openfile->current) != old_amount)
refresh_needed = TRUE;
/* Adjust the mark if it is after the cursor on the current line. */
if (openfile->mark == openfile->current &&
openfile->mark_x > openfile->current_x)
@@ -65,7 +64,7 @@ void do_deletion(undo_type action)
/* If there is a magic line, and we're before it: don't eat it. */
if (joining == openfile->filebot && openfile->current_x != 0 &&
!ISSET(NO_NEWLINES)) {
!ISSET(NO_NEWLINES)) {
#ifndef NANO_TINY
if (action == BACK)
add_undo(BACK, NULL);
@@ -75,23 +74,24 @@ void do_deletion(undo_type action)
#ifndef NANO_TINY
add_undo(action, NULL);
#endif
/* Add the contents of the next line to those of the current one. */
openfile->current->data = charealloc(openfile->current->data,
strlen(openfile->current->data) + strlen(joining->data) + 1);
strcat(openfile->current->data, joining->data);
#ifndef NANO_TINY
/* Adjust the mark if it was on the line that was "eaten". */
/* Adjust the mark if it is on the line that will be "eaten". */
if (openfile->mark == joining) {
openfile->mark = openfile->current;
openfile->mark_x += openfile->current_x;
}
#endif
unlink_node(joining);
renumber_from(openfile->current);
/* Two lines were joined, so we need to refresh the screen. */
openfile->current->has_anchor |= joining->has_anchor;
#endif
/* Add the content of the next line to that of the current one. */
openfile->current->data = nrealloc(openfile->current->data,
strlen(openfile->current->data) + strlen(joining->data) + 1);
strcat(openfile->current->data, joining->data);
unlink_node(joining);
/* Two lines were joined, so do a renumbering and refresh the screen. */
renumber_from(openfile->current);
refresh_needed = TRUE;
} else
/* We're at the end-of-file: nothing to do. */
@@ -101,14 +101,7 @@ void do_deletion(undo_type action)
openfile->totsize--;
#ifndef NANO_TINY
openfile->current_undo->newsize = openfile->totsize;
/* If the number of screen rows that a softwrapped line occupies
* has changed, we need a full refresh. */
if (ISSET(SOFTWRAP) && refresh_needed == FALSE &&
number_of_chunks_in(openfile->current) != old_amount)
refresh_needed = TRUE;
#endif
set_modified();
}
@@ -120,7 +113,14 @@ void do_delete(void)
zap_text();
else
#endif
do_deletion(DEL);
{
do_deletion(DEL);
#ifdef ENABLE_UTF8
while (openfile->current->data[openfile->current_x] != '\0' &&
is_zerowidth(openfile->current->data + openfile->current_x))
do_deletion(DEL);
#endif
}
}
/* Backspace over one character. That is, move the cursor left one
@@ -132,12 +132,41 @@ void do_backspace(void)
zap_text();
else
#endif
if (openfile->current != openfile->filetop || openfile->current_x > 0) {
if (openfile->current_x > 0) {
openfile->current_x = step_left(openfile->current->data, openfile->current_x);
do_deletion(BACK);
} else if (openfile->current != openfile->filetop) {
do_left();
do_deletion(BACK);
}
}
/* Return FALSE when a cut command would not actually cut anything: when
* on an empty line at EOF, or when the mark covers zero characters, or
* (when test_cliff is TRUE) when the magic line would be cut. */
bool is_cuttable(bool test_cliff)
{
size_t from = (test_cliff) ? openfile->current_x : 0;
if ((openfile->current->next == NULL && openfile->current->data[from] == '\0'
#ifndef NANO_TINY
&& openfile->mark == NULL) ||
(openfile->mark == openfile->current &&
openfile->mark_x == openfile->current_x) ||
(from > 0 && !ISSET(NO_NEWLINES) &&
openfile->current->data[from] == '\0' &&
openfile->current->next == openfile->filebot
#endif
)) {
#ifndef NANO_TINY
statusbar(_("Nothing was cut"));
openfile->mark = NULL;
#endif
return FALSE;
} else
return TRUE;
}
#ifndef NANO_TINY
/* Delete text from the cursor until the first start of a word to
* the left, or to the right when forward is TRUE. */
@@ -156,7 +185,7 @@ void chop_word(bool forward)
* on the edge of the original line, then put the cursor on that
* edge instead, so that lines will not be joined unexpectedly. */
if (!forward) {
do_prev_word(ISSET(WORD_BOUNDS));
do_prev_word();
if (openfile->current != is_current) {
if (is_current_x > 0) {
openfile->current = is_current;
@@ -165,7 +194,7 @@ void chop_word(bool forward)
openfile->current_x = strlen(openfile->current->data);
}
} else {
do_next_word(FALSE, ISSET(WORD_BOUNDS));
do_next_word(ISSET(AFTER_ENDS));
if (openfile->current != is_current &&
is_current->data[is_current_x] != '\0') {
openfile->current = is_current;
@@ -183,7 +212,7 @@ void chop_word(bool forward)
/* Now kill the marked region and a word is gone. */
add_undo(CUT, NULL);
do_snip(FALSE, TRUE, FALSE, FALSE);
do_snip(TRUE, FALSE, FALSE);
update_undo(CUT);
/* Discard the cut word and restore the cutbuffer. */
@@ -205,86 +234,119 @@ void chop_next_word(void)
{
openfile->mark = NULL;
if (is_cuttable(openfile->current_x > 0))
if (is_cuttable(TRUE))
chop_word(FORWARD);
}
#endif /* !NANO_TINY */
/* Move all text between (top, top_x) and (bot, bot_x) from the current buffer
* into the cutbuffer. */
/* Excise the text between the given two points and add it to the cutbuffer. */
void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_x)
{
linestruct *taken, *last;
bool edittop_inside = (openfile->edittop->lineno >= top->lineno &&
openfile->edittop->lineno <= bot->lineno);
#ifndef NANO_TINY
bool mark_inside = (openfile->mark &&
openfile->mark->lineno >= top->lineno &&
openfile->mark->lineno <= bot->lineno &&
(openfile->mark != top || openfile->mark_x >= top_x) &&
(openfile->mark != bot || openfile->mark_x <= bot_x));
bool same_line = (openfile->mark == top);
bool post_marked = (openfile->mark && (openfile->mark->lineno > top->lineno ||
(same_line && openfile->mark_x > top_x)));
static bool inherited_anchor = FALSE;
bool had_anchor = top->has_anchor;
if (top == bot && top_x == bot_x)
return;
if (top != bot)
for (linestruct *line = top->next; line != bot->next; line = line->next)
had_anchor |= line->has_anchor;
#endif
/* Reduce the buffer to cover just the text that needs to be extracted. */
partition_buffer(top, top_x, bot, bot_x);
if (top == bot) {
taken = make_new_node(NULL);
taken->data = measured_copy(top->data + top_x, bot_x - top_x);
memmove(top->data + top_x, top->data + bot_x, strlen(top->data + bot_x) + 1);
last = taken;
} else if (top_x == 0 && bot_x == 0) {
taken = top;
last = make_new_node(NULL);
last->data = copy_of("");
#ifndef NANO_TINY
last->has_anchor = bot->has_anchor;
#endif
last->prev = bot->prev;
bot->prev->next = last;
last->next = NULL;
/* Subtract the number of characters in that text from the file size. */
openfile->totsize -= get_totsize(top, bot);
bot->prev = top->prev;
if (top->prev)
top->prev->next = bot;
else
openfile->filetop = bot;
openfile->current = bot;
} else {
taken = make_new_node(NULL);
taken->data = copy_of(top->data + top_x);
taken->next = top->next;
top->next->prev = taken;
top->next = bot->next;
if (bot->next)
bot->next->prev = top;
top->data = nrealloc(top->data, top_x + strlen(bot->data + bot_x) + 1);
strcpy(top->data + top_x, bot->data + bot_x);
last = bot;
last->data[bot_x] = '\0';
last->next = NULL;
openfile->current = top;
}
/* Subtract the size of the excised text from the buffer size. */
openfile->totsize -= number_of_characters_in(taken, last);
/* If the cutbuffer is currently empty, just move all the text directly
* into it; otherwise, append the text to what is already there. */
if (cutbuffer == NULL) {
cutbuffer = openfile->filetop;
cutbottom = openfile->filebot;
cutbuffer = taken;
cutbottom = last;
#ifndef NANO_TINY
inherited_anchor = taken->has_anchor;
#endif
} else {
/* Tack the data of the first line of the text onto the data of
* the last line in the given buffer. */
cutbottom->data = charealloc(cutbottom->data,
strlen(cutbottom->data) +
strlen(openfile->filetop->data) + 1);
strcat(cutbottom->data, openfile->filetop->data);
cutbottom->data = nrealloc(cutbottom->data,
strlen(cutbottom->data) + strlen(taken->data) + 1);
strcat(cutbottom->data, taken->data);
#ifndef NANO_TINY
cutbottom->has_anchor = taken->has_anchor && !inherited_anchor;
inherited_anchor |= taken->has_anchor;
#endif
cutbottom->next = taken->next;
delete_node(taken);
/* Attach the second line of the text (if any) to the last line
* of the buffer, then remove the now superfluous first line. */
cutbottom->next = openfile->filetop->next;
delete_node(openfile->filetop);
/* If there is a second line, make the reverse attachment too and
* update the buffer pointer to point at the end of the text. */
if (cutbottom->next != NULL) {
cutbottom->next->prev = cutbottom;
cutbottom = openfile->filebot;
cutbottom = last;
}
}
/* Since the text has now been saved, remove it from the file buffer. */
openfile->filetop = make_new_node(NULL);
openfile->filetop->data = copy_of("");
openfile->filebot = openfile->filetop;
/* Set the cursor at the point where the text was removed. */
openfile->current = openfile->filetop;
openfile->current_x = top_x;
#ifndef NANO_TINY
/* If the mark was inside the partition, put it where the cursor now is. */
if (mark_inside) {
openfile->mark = openfile->current;
openfile->mark_x = openfile->current_x;
} else if (same_line)
/* Update the pointer to this partially cut line. */
openfile->mark = openfile->current;
#endif
/* Glue the texts before and after the extraction together. */
unpartition_buffer();
#ifndef NANO_TINY
openfile->current->has_anchor = had_anchor;
if (post_marked || same_line)
openfile->mark = openfile->current;
if (post_marked)
openfile->mark_x = openfile->current_x;
#endif
if (openfile->filebot == bot)
openfile->filebot = openfile->current;
renumber_from(openfile->current);
/* If the top of the edit window was inside the old partition, put
* it in range of current. */
/* When the beginning of the viewport was inside the excision, adjust. */
if (edittop_inside) {
adjust_viewport(STATIONARY);
refresh_needed = TRUE;
@@ -299,61 +361,71 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
* at the current cursor position. */
void ingraft_buffer(linestruct *topline)
{
size_t current_x_save = openfile->current_x;
/* Remember whether the current line is at the top of the edit window. */
bool edittop_inside = (openfile->edittop == openfile->current);
linestruct *line = openfile->current;
size_t length = strlen(line->data);
size_t extralen = strlen(topline->data);
size_t xpos = openfile->current_x;
char *tailtext = copy_of(line->data + xpos);
#ifndef NANO_TINY
/* Remember whether mark and cursor are on the same line, and their order. */
bool same_line = (openfile->mark == openfile->current);
bool right_side_up = (openfile->mark &&
(openfile->mark->lineno < openfile->current->lineno ||
(same_line && openfile->mark_x <= openfile->current_x)));
bool mark_follows = (openfile->mark == line && !mark_is_before_cursor());
#endif
linestruct *botline = topline;
/* Partition the buffer so that it contains no text, then delete it.*/
partition_buffer(openfile->current, openfile->current_x,
openfile->current, openfile->current_x);
delete_node(openfile->filetop);
while (botline->next != NULL)
botline = botline->next;
/* Replace the current buffer with the passed buffer. */
openfile->filetop = topline;
openfile->filebot = topline;
while (openfile->filebot->next != NULL)
openfile->filebot = openfile->filebot->next;
/* Add the size of the text to be grafted to the buffer size. */
openfile->totsize += number_of_characters_in(topline, botline);
/* Put the cursor at the end of the pasted text. */
openfile->current = openfile->filebot;
openfile->current_x = strlen(openfile->filebot->data);
if (topline != botline)
length = xpos;
/* When the pasted stuff contains no newline, adjust the cursor's
* x coordinate for the text that is before the pasted stuff. */
if (openfile->filetop == openfile->filebot)
openfile->current_x += current_x_save;
#ifndef NANO_TINY
/* When needed, refresh the mark's pointer and compensate the mark's
* x coordinate for the change in the current line. */
if (same_line) {
if (!right_side_up) {
openfile->mark = openfile->filebot;
openfile->mark_x += openfile->current_x - current_x_save;
} else
openfile->mark = openfile->filetop;
if (extralen > 0) {
/* Insert the text of topline at the current cursor position. */
line->data = nrealloc(line->data, length + extralen + 1);
memmove(line->data + xpos + extralen, line->data + xpos, length - xpos + 1);
strncpy(line->data + xpos, topline->data, extralen);
}
if (topline != botline) {
/* When inserting at end-of-buffer, update the relevant pointer. */
if (line->next == NULL)
openfile->filebot = botline;
line->data[xpos + extralen] = '\0';
/* Hook the grafted lines in after the current one. */
botline->next = openfile->current->next;
if (botline->next)
botline->next->prev = botline;
openfile->current->next = topline->next;
topline->next->prev = openfile->current;
/* Add the text after the cursor position at the end of botline. */
length = strlen(botline->data);
extralen = strlen(tailtext);
botline->data = nrealloc(botline->data, length + extralen + 1);
strcpy(botline->data + length, tailtext);
/* Put the cursor at the end of the grafted text. */
openfile->current = botline;
openfile->current_x = length;
} else
openfile->current_x += extralen;
#ifndef NANO_TINY
/* When needed, update the mark's pointer and position. */
if (mark_follows && topline != botline) {
openfile->mark = botline;
openfile->mark_x += length - xpos;
} else if (mark_follows)
openfile->mark_x += extralen;
#endif
/* Add the number of characters in the copied text to the file size. */
openfile->totsize += get_totsize(openfile->filetop, openfile->filebot);
delete_node(topline);
free(tailtext);
/* If we pasted onto the first line of the edit window, the corresponding
* record has been freed, so... point at the start of the copied text. */
if (edittop_inside)
openfile->edittop = openfile->filetop;
/* Weld the pasted text into the surrounding content of the buffer. */
unpartition_buffer();
renumber_from(topline);
renumber_from(line);
/* If the text doesn't end with a newline, and it should, add one. */
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
@@ -368,170 +440,77 @@ void copy_from_buffer(linestruct *somebuffer)
ingraft_buffer(the_copy);
}
/* Move the whole current line from the current buffer to the cutbuffer. */
void cut_line(void)
{
/* When not on the last line of the buffer, move the text from the
* head of this line to the head of the next line into the cutbuffer;
* otherwise, move all of the text of this line into the cutbuffer. */
if (openfile->current != openfile->filebot)
extract_segment(openfile->current, 0, openfile->current->next, 0);
else
extract_segment(openfile->current, 0,
openfile->current, strlen(openfile->current->data));
openfile->placewewant = 0;
}
#ifndef NANO_TINY
/* Move all text from the cursor position until the end of this line into
* the cutbuffer. But when already at the end of a line, then move this
* "newline" to the cutbuffer. */
void cut_to_eol(void)
{
size_t data_len = strlen(openfile->current->data);
/* When not at the end of a line, move the rest of this line into
* the cutbuffer. Otherwise, when not at the end of the buffer,
* move the line separation into the cutbuffer. */
if (openfile->current_x < data_len)
extract_segment(openfile->current, openfile->current_x,
openfile->current, data_len);
else if (openfile->current != openfile->filebot) {
extract_segment(openfile->current, openfile->current_x,
openfile->current->next, 0);
openfile->placewewant = xplustabs();
}
}
/* Move all marked text from the current buffer into the cutbuffer. */
void cut_marked(bool *right_side_up)
void cut_marked_region(void)
{
linestruct *top, *bot;
size_t top_x, bot_x;
get_region((const linestruct **)&top, &top_x,
(const linestruct **)&bot, &bot_x, right_side_up);
get_region(&top, &top_x, &bot, &bot_x);
extract_segment(top, top_x, bot, bot_x);
openfile->placewewant = xplustabs();
}
#endif
/* Move all text from the cursor position to end-of-file into the cutbuffer. */
void cut_to_eof(void)
{
extract_segment(openfile->current, openfile->current_x,
openfile->filebot, strlen(openfile->filebot->data));
}
#endif /* !NANO_TINY */
/* Move text from the current buffer into the cutbuffer. If
* copying is TRUE, copy the text back into the buffer afterward.
/* Move text from the current buffer into the cutbuffer.
* If until_eof is TRUE, move all text from the current cursor
* position to the end of the file into the cutbuffer. If append
* is TRUE (when zapping), always append the cut to the cutbuffer. */
void do_snip(bool copying, bool marked, bool until_eof, bool append)
void do_snip(bool marked, bool until_eof, bool append)
{
linestruct *line = openfile->current;
#ifndef NANO_TINY
linestruct *was_bottom = NULL;
/* The current end of the cutbuffer, before we add text to it. */
size_t botlen = 0;
/* The length of the string at the current end of the cutbuffer,
* before we add text to it. */
bool using_magicline = !ISSET(NO_NEWLINES);
/* Whether an automatic newline should be added at end-of-buffer. */
bool right_side_up = TRUE;
/* There *is* no region, *or* it is marked forward. */
keep_cutbuffer &= (openfile->last_action != COPY);
#endif
static bool precedent = FALSE;
/* Whether the previous operation was a copying operation. */
/* If cuts were not continuous, or when cutting a region, clear the slate. */
if ((!keep_cutbuffer || marked || until_eof || copying != precedent) &&
!append) {
if ((marked || until_eof || !keep_cutbuffer) && !append) {
free_lines(cutbuffer);
cutbuffer = NULL;
}
/* After a line operation, future ones should add to the cutbuffer. */
keep_cutbuffer = !marked && !until_eof;
precedent = copying;
#ifndef NANO_TINY
if (copying) {
/* If the cutbuffer isn't empty, remember where it currently ends. */
if (cutbuffer != NULL) {
was_bottom = cutbottom;
botlen = strlen(cutbottom->data);
}
/* Don't add a magic line when moving text to the cutbuffer. */
SET(NO_NEWLINES);
}
/* Now move the relevant piece of text into the cutbuffer. */
if (until_eof)
cut_to_eof();
extract_segment(openfile->current, openfile->current_x,
openfile->filebot, strlen(openfile->filebot->data));
else if (openfile->mark) {
cut_marked(&right_side_up);
cut_marked_region();
openfile->mark = NULL;
} else if (ISSET(CUT_FROM_CURSOR))
cut_to_eol();
else
#endif
cut_line();
#ifndef NANO_TINY
if (copying) {
/* Copy the text that was put into the cutbuffer back into the current
* file buffer, so that in the end nothing has been deleted. */
if (cutbuffer != NULL) {
if (was_bottom != NULL) {
was_bottom->data += botlen;
copy_from_buffer(was_bottom);
was_bottom->data -= botlen;
} else
copy_from_buffer(cutbuffer);
/* If the copied region was marked forward, put the new desired
* x position at its end; otherwise, leave it at its beginning. */
if (right_side_up)
openfile->placewewant = xplustabs();
} else if (ISSET(CUT_FROM_CURSOR)) {
/* When not at the end of a line, move the rest of this line into
* the cutbuffer. Otherwise, when not at the end of the buffer,
* move just the "line separator" into the cutbuffer. */
if (openfile->current_x < strlen(openfile->current->data))
extract_segment(line, openfile->current_x, line, strlen(line->data));
else if (openfile->current != openfile->filebot) {
extract_segment(line, openfile->current_x, line->next, 0);
openfile->placewewant = xplustabs();
}
/* Restore the magic-line behavior now that we're done fiddling. */
if (using_magicline)
UNSET(NO_NEWLINES);
} else
#endif
set_modified();
{
/* When not at end-of-buffer, move one full line into the cutbuffer;
* otherwise, move all text until end-of-line into the cutbuffer. */
if (openfile->current != openfile->filebot)
extract_segment(line, 0, line->next, 0);
else
extract_segment(line, 0, line, strlen(line->data));
openfile->placewewant = 0;
}
/* After a line operation, future ones should add to the cutbuffer. */
keep_cutbuffer = !marked && !until_eof;
set_modified();
refresh_needed = TRUE;
}
/* Return FALSE when a cut command would not actually cut anything: when
* on an empty line at EOF, or when the mark covers zero characters, or
* (when test_cliff is TRUE) when the magic line would be cut. */
bool is_cuttable(bool test_cliff)
{
if ((openfile->current->next == NULL && openfile->current->data[0] == '\0'
#ifndef NANO_TINY
&& openfile->mark == NULL) ||
(openfile->mark == openfile->current &&
openfile->mark_x == openfile->current_x) ||
(test_cliff && openfile->current->data[openfile->current_x] == '\0' &&
((ISSET(NO_NEWLINES) && openfile->current == openfile->filebot) ||
(!ISSET(NO_NEWLINES) && openfile->current == openfile->filebot->prev))
#endif
)) {
#ifndef NANO_TINY
statusbar(_("Nothing was cut"));
openfile->mark = NULL;
#endif
return FALSE;
} else
return TRUE;
}
/* Move text from the current buffer into the cutbuffer. */
void cut_text(void)
{
@@ -546,56 +525,32 @@ void cut_text(void)
add_undo(CUT, NULL);
}
do_snip(FALSE, openfile->mark != NULL, FALSE, FALSE);
do_snip(openfile->mark != NULL, FALSE, FALSE);
update_undo(CUT);
#else
if (is_cuttable(FALSE))
do_snip(FALSE, FALSE, FALSE, FALSE);
do_snip(FALSE, FALSE, FALSE);
#endif
wipe_statusbar();
}
#ifndef NANO_TINY
/* Move text from the current buffer into the cutbuffer, and copy it
* back into the buffer afterward. If the mark is set or the cursor
* was moved, blow away previous contents of the cutbuffer. */
void copy_text(void)
{
bool mark_is_set = (openfile->mark != NULL);
/* Remember the current viewport and cursor position. */
ssize_t is_edittop_lineno = openfile->edittop->lineno;
size_t is_firstcolumn = openfile->firstcolumn;
ssize_t is_current_lineno = openfile->current->lineno;
size_t is_current_x = openfile->current_x;
do_snip(TRUE, mark_is_set, FALSE, FALSE);
/* If the mark was set, restore the viewport and cursor position. */
if (mark_is_set) {
openfile->edittop = line_from_number(is_edittop_lineno);
openfile->firstcolumn = is_firstcolumn;
openfile->current = line_from_number(is_current_lineno);
openfile->current_x = is_current_x;
} else
focusing = FALSE;
openfile->last_action = OTHER;
}
/* Cut from the current cursor position to the end of the file. */
void cut_till_eof(void)
{
if ((openfile->current == openfile->filebot && openfile->current->data[0] == '\0') ||
(!ISSET(NO_NEWLINES) && openfile->current->next == openfile->filebot &&
openfile->current->data[openfile->current_x] == '\0')) {
ran_a_tool = TRUE;
if (openfile->current->data[openfile->current_x] == '\0' &&
(openfile->current->next == NULL ||
(!ISSET(NO_NEWLINES) && openfile->current_x > 0 &&
openfile->current->next == openfile->filebot))) {
statusbar(_("Nothing was cut"));
return;
}
add_undo(CUT_TO_EOF, NULL);
do_snip(FALSE, FALSE, TRUE, FALSE);
do_snip(FALSE, TRUE, FALSE);
update_undo(CUT_TO_EOF);
wipe_statusbar();
}
@@ -617,25 +572,140 @@ void zap_text(void)
/* Use the cutbuffer from the ZAP undo item, so the cut can be undone. */
cutbuffer = openfile->current_undo->cutbuffer;
do_snip(FALSE, openfile->mark != NULL, FALSE, TRUE);
do_snip(openfile->mark != NULL, FALSE, TRUE);
update_undo(ZAP);
wipe_statusbar();
cutbuffer = was_cutbuffer;
}
/* Make a copy of the marked region, putting it in the cutbuffer. */
void copy_marked_region(void)
{
linestruct *topline, *botline, *afterline;
char *was_datastart, saved_byte;
size_t top_x, bot_x;
get_region(&topline, &top_x, &botline, &bot_x);
openfile->last_action = OTHER;
keep_cutbuffer = FALSE;
openfile->mark = NULL;
refresh_needed = TRUE;
if (topline == botline && top_x == bot_x) {
statusbar(_("Copied nothing"));
return;
}
/* Make the area that was marked look like a separate buffer. */
afterline = botline->next;
botline->next = NULL;
saved_byte = botline->data[bot_x];
botline->data[bot_x] = '\0';
was_datastart = topline->data;
topline->data += top_x;
cutbuffer = copy_buffer(topline);
/* Restore the proper state of the buffer. */
topline->data = was_datastart;
botline->data[bot_x] = saved_byte;
botline->next = afterline;
}
/* Copy text from the current buffer into the cutbuffer. The text is either
* the marked region, the whole line, the text from cursor to end-of-line,
* just the line break, or nothing, depending on mode and cursor position. */
void copy_text(void)
{
bool at_eol = (openfile->current->data[openfile->current_x] == '\0');
bool sans_newline = (ISSET(NO_NEWLINES) && openfile->current->next == NULL);
size_t from_x = (ISSET(CUT_FROM_CURSOR)) ? openfile->current_x : 0;
linestruct *was_current = openfile->current;
linestruct *addition;
if (openfile->mark || openfile->last_action != COPY || !keep_cutbuffer) {
free_lines(cutbuffer);
cutbuffer = NULL;
}
wipe_statusbar();
if (openfile->mark) {
copy_marked_region();
return;
}
/* When at the very end of the buffer, there is nothing to do. */
if (openfile->current->next == NULL && at_eol && (ISSET(CUT_FROM_CURSOR) ||
openfile->current_x == 0 || cutbuffer)) {
statusbar(_("Copied nothing"));
return;
}
addition = make_new_node(NULL);
addition->data = copy_of(openfile->current->data + from_x);
if (ISSET(CUT_FROM_CURSOR))
sans_newline = !at_eol;
/* Create the cutbuffer OR add to it, depending on the mode, the position
* of the cursor, and whether or not the cutbuffer is currently empty. */
if (cutbuffer == NULL && sans_newline) {
cutbuffer = addition;
cutbottom = addition;
} else if (cutbuffer == NULL) {
cutbuffer = addition;
cutbottom = make_new_node(cutbuffer);
cutbottom->data = copy_of("");
cutbuffer->next = cutbottom;
} else if (sans_newline) {
addition->prev = cutbottom->prev;
addition->prev->next = addition;
delete_node(cutbottom);
cutbottom = addition;
} else if (ISSET(CUT_FROM_CURSOR)) {
addition->prev = cutbottom;
cutbottom->next = addition;
cutbottom = addition;
} else {
addition->prev = cutbottom->prev;
addition->prev->next = addition;
addition->next = cutbottom;
cutbottom->prev = addition;
}
/* When needed and possible, move the cursor to the next line. */
if ((!ISSET(CUT_FROM_CURSOR) || at_eol) && openfile->current->next) {
openfile->current = openfile->current->next;
openfile->current_x = 0;
} else
openfile->current_x = strlen(openfile->current->data);
edit_redraw(was_current, FLOWING);
openfile->last_action = COPY;
keep_cutbuffer = TRUE;
}
#endif /* !NANO_TINY */
/* Copy text from the cutbuffer into the current buffer. */
void paste_text(void)
{
#if defined(ENABLE_WRAPPING) || !defined(NANO_TINY)
/* Remember where the paste started. */
linestruct *was_current = openfile->current;
#endif
#ifndef NANO_TINY
bool had_anchor = was_current->has_anchor;
#endif
ssize_t was_lineno = openfile->current->lineno;
/* The line number where we started the paste. */
size_t was_leftedge = 0;
/* The leftedge where we started the paste. */
if (cutbuffer == NULL) {
statusbar(_("Cutbuffer is empty"));
statusline(AHEM, _("Cutbuffer is empty"));
return;
}
@@ -651,12 +721,28 @@ void paste_text(void)
copy_from_buffer(cutbuffer);
#ifndef NANO_TINY
/* Wipe any anchors in the pasted text, so that they don't proliferate. */
for (linestruct *line = was_current; line != openfile->current->next; line = line->next)
line->has_anchor = FALSE;
was_current->has_anchor = had_anchor;
update_undo(PASTE);
#endif
#ifdef ENABLE_WRAPPING
/* When still on the same line and doing hard-wrapping, limit the width. */
if (openfile->current == was_current && ISSET(BREAK_LONG_LINES))
do_wrap();
#endif
/* If we pasted less than a screenful, don't center the cursor. */
if (less_than_a_screenful(was_lineno, was_leftedge))
focusing = FALSE;
#ifdef ENABLE_COLOR
else
precalc_multicolorinfo();
#endif
/* Set the desired x position to where the pasted text ends. */
openfile->placewewant = xplustabs();

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* nano.h -- This file is part of GNU nano. *
* definitions.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -25,139 +25,261 @@
#ifdef NEED_XOPEN_SOURCE_EXTENDED
#ifndef _XOPEN_SOURCE_EXTENDED
#define _XOPEN_SOURCE_EXTENDED 1
#define _XOPEN_SOURCE_EXTENDED 1
#endif
#endif
#if defined(__HAIKU__) && !defined(_DEFAULT_SOURCE)
#define _DEFAULT_SOURCE 1
#endif
#ifdef __TANDEM
/* Tandem NonStop Kernel support. */
#include <floss.h>
#define NANO_ROOT_UID 65535
#define ROOT_UID 65535
#else
#define NANO_ROOT_UID 0
#define ROOT_UID 0
#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
/* Set a default value for PATH_MAX if there isn't one. */
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
/* Suppress warnings for __attribute__((warn_unused_result)). */
#define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0)
/* Macros for flags, indexing each bit in a small array. */
#define FLAGS(flag) flags[((flag) / (sizeof(unsigned) * 8))]
#define FLAGMASK(flag) ((unsigned)1 << ((flag) % (sizeof(unsigned) * 8)))
#define SET(flag) FLAGS(flag) |= FLAGMASK(flag)
#define UNSET(flag) FLAGS(flag) &= ~FLAGMASK(flag)
#define ISSET(flag) ((FLAGS(flag) & FLAGMASK(flag)) != 0)
#define TOGGLE(flag) FLAGS(flag) ^= FLAGMASK(flag)
/* Macros for allocation of character strings. */
#define charalloc(howmuch) (char *)nmalloc(howmuch)
#define charealloc(ptr, howmuch) (char *)nrealloc(ptr, howmuch)
/* In UTF-8 a character is at most six bytes long. */
#ifdef ENABLE_UTF8
#define MAXCHARLEN 6
#else
#define MAXCHARLEN 1
#endif
/* Set a default value for PATH_MAX if there isn't one. */
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
#ifdef USE_SLANG
/* Slang support. */
#include <slcurses.h>
/* Slang curses emulation brain damage, part 3: Slang doesn't define the
* curses equivalents of the Insert or Delete keys. */
#define KEY_DC SL_KEY_DELETE
#define KEY_IC SL_KEY_IC
/* Ncurses support. */
#elif defined(HAVE_NCURSESW_NCURSES_H)
#include <ncursesw/ncurses.h>
#elif defined(HAVE_NCURSES_H)
#include <ncurses.h>
#else
/* Curses support. */
#include <curses.h>
#endif /* CURSES_H */
#if defined(NCURSES_VERSION_MAJOR) && (NCURSES_VERSION_MAJOR < 6)
#define USING_OLD_NCURSES yes
#endif
#ifdef ENABLE_NLS
/* Native language support. */
#ifdef HAVE_LIBINTL_H
#include <libintl.h>
#endif
#define _(string) gettext(string)
#define P_(singular, plural, number) ngettext(singular, plural, number)
#else
#define _(string) (string)
#define P_(singular, plural, number) (number == 1 ? singular : plural)
#endif
#define gettext_noop(string) (string)
#define N_(string) gettext_noop(string)
/* Mark a string that will be sent to gettext() later. */
#include <dirent.h>
#include <regex.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/stat.h>
/* If we aren't using an ncurses with mouse support, exclude any
* mouse routines, as they are useless then. */
/* Prefer wide ncurses over normal ncurses over curses. */
#if defined(HAVE_NCURSESW_NCURSES_H)
#include <ncursesw/ncurses.h>
#elif defined(HAVE_NCURSES_H)
#include <ncurses.h>
#else
#include <curses.h>
#endif
/* Native language support. */
#ifdef ENABLE_NLS
#ifdef HAVE_LIBINTL_H
#include <libintl.h>
#endif
#define _(string) gettext(string)
#define P_(singular, plural, number) ngettext(singular, plural, number)
#else
#define _(string) (string)
#define P_(singular, plural, number) (number == 1 ? singular : plural)
#endif
/* For marking a string on which gettext() will be called later. */
#define gettext_noop(string) (string)
#define N_(string) gettext_noop(string)
/* If we aren't using an ncurses with mouse support, then
* exclude the mouse routines, as they are useless then. */
#ifndef NCURSES_MOUSE_VERSION
#undef ENABLE_MOUSE
#endif
#if defined(ENABLE_WRAPPING) || defined(ENABLE_JUSTIFY)
#define ENABLED_WRAPORJUSTIFY 1
#define ENABLED_WRAPORJUSTIFY 1
#endif
#define BACKWARD FALSE
#define FORWARD TRUE
/* Suppress warnings for __attribute__((warn_unused_result)). */
#define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0)
#define BLIND FALSE
#define VISIBLE TRUE
/* Macros for flags, indexing each bit in a small array. */
#define FLAGS(flag) flags[((flag) / (sizeof(unsigned) * 8))]
#define FLAGMASK(flag) ((unsigned)1 << ((flag) % (sizeof(unsigned) * 8)))
#define SET(flag) FLAGS(flag) |= FLAGMASK(flag)
#define UNSET(flag) FLAGS(flag) &= ~FLAGMASK(flag)
#define ISSET(flag) ((FLAGS(flag) & FLAGMASK(flag)) != 0)
#define TOGGLE(flag) FLAGS(flag) ^= FLAGMASK(flag)
#define JUSTFIND 0
#define REPLACING 1
#define INREGION 2
#define BACKWARD FALSE
#define FORWARD TRUE
#define YESORNO FALSE
#define YESORALLORNO TRUE
#define YES 1
#define ALL 2
#define NO 0
#define CANCEL -1
#define BLIND FALSE
#define VISIBLE TRUE
#define JUSTFIND 0
#define REPLACING 1
#define INREGION 2
#define NORMAL TRUE
#define SPECIAL FALSE
#define TEMPORARY FALSE
#define ANNOTATE TRUE
#define NONOTES FALSE
#define PRUNE_DUPLICATE TRUE
#define IGNORE_DUPLICATES FALSE
#ifdef ENABLE_UTF8
/* In UTF-8 a valid character is at most four bytes long. */
#define MAXCHARLEN 4
#else
#define MAXCHARLEN 1
#endif
/* The default width of a tab in spaces. */
#define WIDTH_OF_TAB 8
/* The default number of columns from end of line where wrapping occurs. */
#define COLUMNS_FROM_EOL 8
/* The default comment character when a syntax does not specify any. */
#define GENERAL_COMMENT_CHARACTER "#"
/* The maximum number of search/replace history strings saved. */
#define MAX_SEARCH_HISTORY 100
/* The largest size_t number that doesn't have the high bit set. */
#define HIGHEST_POSITIVE ((~(size_t)0) >> 1)
#ifdef ENABLE_COLOR
#define USE_THE_DEFAULT -1
#define BAD_COLOR -2
#define THE_DEFAULT -1
#define BAD_COLOR -2
/* Flags for indicating how a multiline regex pair apply to a line. */
#define NOTHING (1<<1)
/* The start/end regexes don't cover this line at all. */
#define STARTSHERE (1<<2)
/* The start regex matches on this line, the end regex on a later one. */
#define WHOLELINE (1<<3)
/* The start regex matches on an earlier line, the end regex on a later one. */
#define ENDSHERE (1<<4)
/* The start regex matches on an earlier line, the end regex on this one. */
#define JUSTONTHIS (1<<5)
/* Both the start and end regexes match within this line. */
#define WOULDBE (1<<6)
/* An unpaired start match is on or before this line. */
#endif
#define STANDARD_INPUT 0
/* Basic control codes. */
#define ESC_CODE 0x1B
#define DEL_CODE 0x7F
/* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */
#define CONTROL_LEFT 0x401
#define CONTROL_RIGHT 0x402
#define CONTROL_UP 0x403
#define CONTROL_DOWN 0x404
#define CONTROL_HOME 0x405
#define CONTROL_END 0x406
#define CONTROL_DELETE 0x40D
#define SHIFT_CONTROL_LEFT 0x411
#define SHIFT_CONTROL_RIGHT 0x412
#define SHIFT_CONTROL_UP 0x413
#define SHIFT_CONTROL_DOWN 0x414
#define SHIFT_CONTROL_HOME 0x415
#define SHIFT_CONTROL_END 0x416
#define CONTROL_SHIFT_DELETE 0x41D
#define ALT_LEFT 0x421
#define ALT_RIGHT 0x422
#define ALT_UP 0x423
#define ALT_DOWN 0x424
#define ALT_PAGEUP 0x427
#define ALT_PAGEDOWN 0x428
#define ALT_INSERT 0x42C
#define ALT_DELETE 0x42D
#define SHIFT_ALT_LEFT 0x431
#define SHIFT_ALT_RIGHT 0x432
#define SHIFT_ALT_UP 0x433
#define SHIFT_ALT_DOWN 0x434
//#define SHIFT_LEFT 0x451
//#define SHIFT_RIGHT 0x452
#define SHIFT_UP 0x453
#define SHIFT_DOWN 0x454
#define SHIFT_HOME 0x455
#define SHIFT_END 0x456
#define SHIFT_PAGEUP 0x457
#define SHIFT_PAGEDOWN 0x458
#define SHIFT_DELETE 0x45D
#define SHIFT_TAB 0x45F
/* A special keycode for when <Tab> is pressed while the mark is on. */
#define INDENT_KEY 0x4F1
/* A special keycode to signal the beginning and end of a bracketed paste. */
#define BRACKETED_PASTE_MARKER 0x4FB
/* A special keycode for when a key produces an unknown escape sequence. */
#define FOREIGN_SEQUENCE 0x4FC
/* A special keycode for plugging into the input stream after a suspension. */
#define KEY_FRESH 0x4FE
#ifndef NANO_TINY
/* A special keycode for when we get a SIGWINCH (a window resize). */
#define KEY_WINCH -2
/* Some extra flags for the undo function. */
#define WAS_BACKSPACE_AT_EOF (1<<1)
#define WAS_WHOLE_LINE (1<<2)
#define INCLUDED_LAST_LINE (1<<3)
#define MARK_WAS_SET (1<<4)
#define CURSOR_WAS_AT_HEAD (1<<5)
#define HAD_ANCHOR_AT_START (1<<6)
#endif /* !NANO_TINY */
/* Identifiers for the different menus. */
#define MMAIN (1<<0)
#define MWHEREIS (1<<1)
#define MREPLACE (1<<2)
#define MREPLACEWITH (1<<3)
#define MGOTOLINE (1<<4)
#define MWRITEFILE (1<<5)
#define MINSERTFILE (1<<6)
#define MEXECUTE (1<<7)
#define MHELP (1<<8)
#define MSPELL (1<<9)
#define MBROWSER (1<<10)
#define MWHEREISFILE (1<<11)
#define MGOTODIR (1<<12)
#define MYESNO (1<<13)
#define MLINTER (1<<14)
#define MFINDINHELP (1<<15)
/* This is an abbreviation for all menus except Help and Browser and YesNo. */
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\
MEXECUTE|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER)
#ifndef NANO_TINY
#define MSOME MMOST|MBROWSER
#else
#define MSOME MMAIN|MBROWSER
#endif
/* Enumeration types. */
typedef enum {
NIX_FILE, DOS_FILE, MAC_FILE
UNSPECIFIED, NIX_FILE, DOS_FILE, MAC_FILE
} format_type;
typedef enum {
HUSH, NOTICE, MILD, ALERT
VACUUM, HUSH, REMARK, INFO, NOTICE, AHEM, MILD, ALERT
} message_type;
typedef enum {
OVERWRITE, APPEND, PREPEND
} kind_of_writing_type;
typedef enum {
SOFTMARK, HARDMARK
} mark_type;
typedef enum {
CENTERING, FLOWING, STATIONARY
} update_type;
@@ -172,16 +294,90 @@ typedef enum {
#ifdef ENABLE_COMMENT
COMMENT, UNCOMMENT, PREFLIGHT,
#endif
ZAP, CUT, CUT_TO_EOF, PASTE, INSERT, COUPLE_BEGIN, COUPLE_END, OTHER
ZAP, CUT, CUT_TO_EOF, COPY, PASTE, INSERT,
COUPLE_BEGIN, COUPLE_END, OTHER
} undo_type;
/* The elements of the interface that can be colored differently. */
enum {
TITLE_BAR = 0,
LINE_NUMBER,
GUIDE_STRIPE,
SCROLL_BAR,
SELECTED_TEXT,
SPOTLIGHTED,
MINI_INFOBAR,
PROMPT_BAR,
STATUS_BAR,
ERROR_MESSAGE,
KEY_COMBO,
FUNCTION_TAG,
NUMBER_OF_ELEMENTS
};
/* Enumeration used in the flags array. See the definition of FLAGMASK. */
enum {
DONTUSE = 0,
CASE_SENSITIVE,
CONSTANT_SHOW,
NO_HELP,
SUSPENDABLE,
NO_WRAP,
AUTOINDENT,
VIEW_MODE,
USE_MOUSE,
USE_REGEXP,
SAVE_ON_EXIT,
CUT_FROM_CURSOR,
BACKWARDS_SEARCH,
MULTIBUFFER,
REBIND_DELETE,
RAW_SEQUENCES,
NO_CONVERT,
MAKE_BACKUP,
INSECURE_BACKUP,
NO_SYNTAX,
PRESERVE,
HISTORYLOG,
RESTRICTED,
SMART_HOME,
WHITESPACE_DISPLAY,
TABS_TO_SPACES,
QUICK_BLANK,
WORD_BOUNDS,
NO_NEWLINES,
BOLD_TEXT,
SOFTWRAP,
POSITIONLOG,
LOCKING,
NOREAD_MODE,
MAKE_IT_UNIX,
TRIM_BLANKS,
SHOW_CURSOR,
LINE_NUMBERS,
AT_BLANKS,
AFTER_ENDS,
LET_THEM_ZAP,
BREAK_LONG_LINES,
JUMPY_SCROLLING,
EMPTY_LINE,
INDICATOR,
BOOKSTYLE,
STATEFLAGS,
USE_MAGIC,
MINIBAR,
ZERO
};
/* Structure types. */
#ifdef ENABLE_COLOR
typedef struct colortype {
short id;
/* An ordinal number (if this color combo is for a multiline regex). */
short fg;
/* This syntax's foreground color. */
/* This combo's foreground color. */
short bg;
/* This syntax's background color. */
/* This combo's background color. */
short pairnum;
/* The pair number for this foreground/background color combination. */
int attributes;
@@ -191,14 +387,12 @@ typedef struct colortype {
regex_t *end;
/* The compiled regular expression for 'end=', if any. */
struct colortype *next;
/* Next set of colors. */
int id;
/* Basic id for assigning to lines later. */
/* Next color combination. */
} colortype;
typedef struct regexlisttype {
char *full_regex;
/* A regex string to match things that imply a certain syntax. */
regex_t *one_rgx;
/* A regex to match things that imply a certain syntax. */
struct regexlisttype *next;
/* The next regex. */
} regexlisttype;
@@ -221,7 +415,7 @@ typedef struct syntaxtype {
/* File where the syntax is defined, or NULL if not an included file. */
size_t lineno;
/* The line number where the 'syntax' command was found. */
struct augmentstruct *augmentations;
augmentstruct *augmentations;
/* List of extendsyntax commands to apply when loaded. */
regexlisttype *extensions;
/* The list of extensions that this syntax applies to. */
@@ -241,7 +435,7 @@ typedef struct syntaxtype {
#endif
colortype *color;
/* The colors and their regexes used in this syntax. */
int nmultis;
short nmultis;
/* How many multiline regex strings this syntax has. */
struct syntaxtype *next;
/* Next syntax. */
@@ -261,20 +455,6 @@ typedef struct lintstruct {
struct lintstruct *prev;
/* Previous error. */
} lintstruct;
/* Flags that indicate how a multiline regex applies to a line. */
#define CNONE (1<<1)
/* Yay, regex doesn't apply to this line at all! */
#define CBEGINBEFORE (1<<2)
/* Regex starts on an earlier line, ends on this one. */
#define CENDAFTER (1<<3)
/* Regex starts on this line and ends on a later one. */
#define CWHOLELINE (1<<4)
/* Whole line engulfed by the regex, start < me, end > me. */
#define CSTARTENDHERE (1<<5)
/* Regex starts and ends within this line. */
#define CWOULDBE (1<<6)
/* An unpaired start match on or before this line. */
#endif /* ENABLE_COLOR */
/* More structure types. */
@@ -291,6 +471,10 @@ typedef struct linestruct {
short *multidata;
/* Array of which multi-line regexes apply to this line. */
#endif
#ifndef NANO_TINY
bool has_anchor;
/* Whether the user has placed an anchor at this line. */
#endif
} linestruct;
#ifndef NANO_TINY
@@ -310,9 +494,9 @@ typedef struct undostruct {
/* The operation type that this undo item is for. */
int xflags;
/* Some flag data to mark certain corner cases. */
ssize_t lineno;
ssize_t head_lineno;
/* The line number where the operation began or ended. */
size_t begin;
size_t head_x;
/* The x position where the operation began or ended. */
char *strdata;
/* String data to help restore the affected line. */
@@ -324,9 +508,9 @@ typedef struct undostruct {
/* Undo info specific to groups of lines. */
linestruct *cutbuffer;
/* A copy of the cutbuffer. */
ssize_t mark_begin_lineno;
ssize_t tail_lineno;
/* Mostly the line number of the current line; sometimes something else. */
size_t mark_begin_x;
size_t tail_x;
/* The x position corresponding to the above line number. */
struct undostruct *next;
/* A pointer to the undo item of the preceding action. */
@@ -336,11 +520,11 @@ typedef struct undostruct {
#ifdef ENABLE_HISTORIES
typedef struct poshiststruct {
char *filename;
/* The file. */
ssize_t lineno;
/* Line number we left off on. */
ssize_t xno;
/* The x position in the file we left off on. */
/* The full path plus name of the file. */
ssize_t linenumber;
/* The line where the cursor was when we closed the file. */
ssize_t columnnumber;
/* The column where the cursor was. */
struct poshiststruct *next;
/* The next item of position history. */
} poshiststruct;
@@ -368,8 +552,8 @@ typedef struct openfilestruct {
/* The file's x position we would like. */
ssize_t current_y;
/* The file's y-coordinate position. */
struct stat *current_stat;
/* The file's current stat information. */
struct stat *statinfo;
/* The file's stat information from when it was opened or last saved. */
#ifdef ENABLE_WRAPPING
linestruct *spillage_line;
/* The line for prepending stuff to during automatic hard-wrapping. */
@@ -379,10 +563,10 @@ typedef struct openfilestruct {
/* The line in the file where the mark is set; NULL if not set. */
size_t mark_x;
/* The mark's x position in the above line. */
mark_type kind_of_mark;
/* Whether it is a soft (with Shift) or a hard mark. */
bool softmark;
/* Whether a marked region was made by holding Shift. */
format_type fmt;
/* The file's format -- Unix or DOS or Mac or mixed. */
/* The file's format -- Unix or DOS or Mac. */
char *lock_filename;
/* The path of the lockfile, if we created one. */
undostruct *undotop;
@@ -398,11 +582,11 @@ typedef struct openfilestruct {
/* Whether the file has been modified. */
#ifdef ENABLE_COLOR
syntaxtype *syntax;
/* The syntax struct for this file, if any. */
colortype *colorstrings;
/* The file's associated colors. */
/* The syntax that applies to this file, if any. */
#endif
#ifdef ENABLE_MULTIBUFFER
char *errormessage;
/* The ALERT message (if any) that occurred when opening the file. */
struct openfilestruct *next;
/* The next open file, if any. */
struct openfilestruct *prev;
@@ -446,8 +630,6 @@ typedef struct keystruct {
typedef struct funcstruct {
void (*func)(void);
/* The actual function to call. */
int menus;
/* In what menus this function applies. */
const char *desc;
/* The function's short description, for example "Where Is". */
#ifdef ENABLE_HELP
@@ -459,195 +641,15 @@ typedef struct funcstruct {
#endif
bool viewok;
/* Is this function allowed when in view mode? */
long toggle;
/* If this is a toggle, which toggle to affect. */
int menus;
/* In what menus this function applies. */
struct funcstruct *next;
/* Next item in the list. */
} funcstruct;
#ifdef ENABLE_WORDCOMPLETION
typedef struct completion_word {
typedef struct completionstruct {
char *word;
struct completion_word *next;
} completion_word;
struct completionstruct *next;
} completionstruct;
#endif
/* The elements of the interface that can be colored differently. */
enum
{
TITLE_BAR = 0,
LINE_NUMBER,
GUIDE_STRIPE,
SELECTED_TEXT,
STATUS_BAR,
ERROR_MESSAGE,
KEY_COMBO,
FUNCTION_TAG,
NUMBER_OF_ELEMENTS
};
/* Enumeration used in the flags array. See the definition of FLAGMASK. */
enum
{
DONTUSE,
CASE_SENSITIVE,
CONSTANT_SHOW,
NO_HELP,
SUSPEND,
NO_WRAP,
AUTOINDENT,
VIEW_MODE,
USE_MOUSE,
USE_REGEXP,
TEMP_FILE,
CUT_FROM_CURSOR,
BACKWARDS_SEARCH,
MULTIBUFFER,
SMOOTH_SCROLL,
REBIND_DELETE,
RAW_SEQUENCES,
NO_CONVERT,
BACKUP_FILE,
INSECURE_BACKUP,
NO_COLOR_SYNTAX,
PRESERVE,
HISTORYLOG,
RESTRICTED,
SMART_HOME,
WHITESPACE_DISPLAY,
MORE_SPACE,
TABS_TO_SPACES,
QUICK_BLANK,
WORD_BOUNDS,
NO_NEWLINES,
BOLD_TEXT,
SOFTWRAP,
POSITIONLOG,
LOCKING,
NOREAD_MODE,
MAKE_IT_UNIX,
TRIM_BLANKS,
SHOW_CURSOR,
LINE_NUMBERS,
NO_PAUSES,
AT_BLANKS,
AFTER_ENDS,
LET_THEM_ZAP,
BREAK_LONG_LINES,
JUMPY_SCROLLING,
EMPTY_LINE
};
/* Flags for the menus in which a given function should be present. */
#define MMAIN (1<<0)
#define MWHEREIS (1<<1)
#define MREPLACE (1<<2)
#define MREPLACEWITH (1<<3)
#define MGOTOLINE (1<<4)
#define MWRITEFILE (1<<5)
#define MINSERTFILE (1<<6)
#define MEXTCMD (1<<7)
#define MHELP (1<<8)
#define MSPELL (1<<9)
#define MBROWSER (1<<10)
#define MWHEREISFILE (1<<11)
#define MGOTODIR (1<<12)
#define MYESNO (1<<13)
#define MLINTER (1<<14)
#define MFINDINHELP (1<<15)
/* This is an abbreviation for all menus except Help and Browser and YesNo. */
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\
MEXTCMD|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER)
#ifndef NANO_TINY
#define MSOME MMOST|MBROWSER
#else
#define MSOME MMAIN|MBROWSER
#endif
/* Basic control codes. */
#define BS_CODE 0x08
#define TAB_CODE 0x09
#define CR_CODE 0x0D
#define ESC_CODE 0x1B
#define DEL_CODE 0x7F
/* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */
#define CONTROL_LEFT 0x401
#define CONTROL_RIGHT 0x402
#define CONTROL_UP 0x403
#define CONTROL_DOWN 0x404
#define CONTROL_HOME 0x405
#define CONTROL_END 0x406
#define CONTROL_DELETE 0x40D
#define SHIFT_CONTROL_LEFT 0x411
#define SHIFT_CONTROL_RIGHT 0x412
#define SHIFT_CONTROL_UP 0x413
#define SHIFT_CONTROL_DOWN 0x414
#define SHIFT_CONTROL_HOME 0x415
#define SHIFT_CONTROL_END 0x416
#define CONTROL_SHIFT_DELETE 0x41D
#define ALT_LEFT 0x421
#define ALT_RIGHT 0x422
#define ALT_UP 0x423
#define ALT_DOWN 0x424
#define ALT_DELETE 0x42D
#define SHIFT_ALT_LEFT 0x431
#define SHIFT_ALT_RIGHT 0x432
#define SHIFT_ALT_UP 0x433
#define SHIFT_ALT_DOWN 0x434
//#define SHIFT_LEFT 0x451
//#define SHIFT_RIGHT 0x452
#define SHIFT_UP 0x453
#define SHIFT_DOWN 0x454
#define SHIFT_HOME 0x455
#define SHIFT_END 0x456
#define SHIFT_PAGEUP 0x457
#define SHIFT_PAGEDOWN 0x458
#define SHIFT_DELETE 0x45D
#define SHIFT_TAB 0x45F
/* A special keycode for when <Tab> is pressed while the mark is on. */
#define INDENT_KEY 0x4F1
/* A special keycode to signal the beginning and end of a bracketed paste. */
#define BRACKETED_PASTE_MARKER 0x4FB
#ifdef USE_SLANG
#ifdef ENABLE_UTF8
#define KEY_BAD 0xFF /* Clipped error code. */
#endif
#define KEY_FLUSH 0x91 /* User-definable control code. */
#else
#define KEY_FLUSH KEY_F0 /* Nonexistent function key. */
#endif
#ifndef NANO_TINY
/* An imaginary key for when we get a SIGWINCH (window resize). */
#define KEY_WINCH -2
/* Some extra flags for the undo function. */
#define WAS_FINAL_BACKSPACE (1<<1)
#define WAS_WHOLE_LINE (1<<2)
#define WAS_FINAL_LINE (1<<3)
#define MARK_WAS_SET (1<<4)
#define WAS_MARKED_FORWARD (1<<5)
#endif /* !NANO_TINY */
/* The default number of columns from end of line where wrapping occurs. */
#define COLUMNS_FROM_EOL 8
/* The default width of a tab in spaces. */
#define WIDTH_OF_TAB 8
/* The default comment character when a syntax does not specify any. */
#define GENERAL_COMMENT_CHARACTER "#"
/* The maximum number of search/replace history strings saved, not
* counting the blank lines at their ends. */
#define MAX_SEARCH_HISTORY 100
/* The maximum number of bytes buffered at one time. */
#define MAX_BUF_SIZE 128
/* The largest size_t number that doesn't have the high bit set. */
#define HIGHEST_POSITIVE ((~(size_t)0) >> 1)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* help.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2000-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2000-2011, 2013-2022 Free Software Foundation, Inc. *
* Copyright (C) 2017 Rishabh Dave *
* Copyright (C) 2014-2019 Benno Schulenberg *
* *
@@ -20,7 +20,7 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#ifdef ENABLE_HELP
@@ -29,267 +29,15 @@
static char *help_text = NULL;
/* The text displayed in the help window. */
static const char *start_of_body = NULL;
/* The point in the help text just after the title. */
static char *end_of_intro = NULL;
/* The point in the help text where the shortcut descriptions begin. */
static size_t location;
/* The offset (in bytes) of the topleft of the shown help text. */
/* Hard-wrap the concatenated help text, and write it into a new buffer. */
void wrap_help_text_into_buffer(void)
{
size_t sum = 0;
/* Avoid overtight and overwide paragraphs in the introductory text. */
size_t wrapping_point = (COLS < 32) ? 32 : (COLS > 74) ? 74 : COLS;
const char *ptr = start_of_body;
make_new_buffer();
/* Copy the help text into the just-created new buffer. */
while (*ptr != '\0') {
int length, shim;
char *oneline;
if (ptr == end_of_intro)
wrapping_point = (COLS < 32) ? 32 : COLS;
if (ptr > end_of_intro && *(ptr - 1) != '\n') {
length = break_line(ptr, (COLS < 32) ? 14 : COLS - 18, TRUE);
oneline = nmalloc(length + 5);
snprintf(oneline, length + 5, "\t\t %s", ptr);
} else {
length = break_line(ptr, wrapping_point, TRUE);
oneline = nmalloc(length + 1);
shim = (*(ptr + length - 1) == ' ') ? 0 : 1;
snprintf(oneline, length + shim, "%s", ptr);
}
free(openfile->current->data);
openfile->current->data = oneline;
ptr += length;
if (*ptr != '\n')
ptr--;
/* Create a new line, and then one more for each extra \n. */
do {
openfile->current->next = make_new_node(openfile->current);
openfile->current = openfile->current->next;
openfile->current->data = copy_of("");
} while (*(++ptr) == '\n');
}
openfile->filebot = openfile->current;
openfile->current = openfile->filetop;
remove_magicline();
#ifdef ENABLE_COLOR
color_update();
#endif
prepare_for_display();
/* Move to the position in the file where we were before. */
while (TRUE) {
sum += strlen(openfile->current->data);
if (sum > location)
break;
openfile->current = openfile->current->next;
}
openfile->edittop = openfile->current;
}
/* Assemble a help text, display it, and allow scrolling through it. */
void show_help(void)
{
int kbinput = ERR;
functionptrtype func;
/* The function of the key the user typed in. */
int oldmenu = currmenu;
/* The menu we were called from. */
#ifdef ENABLE_LINENUMBERS
int was_margin = margin;
#endif
ssize_t was_tabsize = tabsize;
#ifdef ENABLE_COLOR
char *was_syntax = syntaxstr;
#endif
char *saved_answer = (answer != NULL) ? copy_of(answer) : NULL;
/* The current answer when the user invokes help at the prompt. */
unsigned stash[sizeof(flags) / sizeof(flags[0])];
/* A storage place for the current flag settings. */
linestruct *line;
int length;
blank_statusbar();
/* Save the settings of all flags. */
memcpy(stash, flags, sizeof(flags));
/* Ensure that the help screen's shortcut list can be displayed. */
if (ISSET(NO_HELP) && LINES > 4) {
UNSET(NO_HELP);
window_init();
}
/* When searching, do it forward, case insensitive, and without regexes. */
UNSET(BACKWARDS_SEARCH);
UNSET(CASE_SENSITIVE);
UNSET(USE_REGEXP);
UNSET(WHITESPACE_DISPLAY);
UNSET(NOREAD_MODE);
#ifdef ENABLE_LINENUMBERS
UNSET(LINE_NUMBERS);
editwincols = COLS;
margin = 0;
#endif
tabsize = 8;
#ifdef ENABLE_COLOR
syntaxstr = "nanohelp";
#endif
curs_set(0);
/* Compose the help text from all the relevant pieces. */
help_init();
inhelp = TRUE;
location = 0;
didfind = 0;
bottombars(MHELP);
/* Extract the title from the head of the help text. */
length = break_line(help_text, MAX_BUF_SIZE, TRUE);
title = measured_copy(help_text, length + 1);
title[length] = '\0';
titlebar(title);
/* Skip over the title to point at the start of the body text. */
start_of_body = help_text + length;
while (*start_of_body == '\n')
start_of_body++;
wrap_help_text_into_buffer();
edit_refresh();
while (TRUE) {
lastmessage = HUSH;
focusing = TRUE;
/* Show the cursor when we searched and found something. */
kbinput = get_kbinput(edit, didfind == 1 || ISSET(SHOW_CURSOR));
didfind = 0;
#ifndef NANO_TINY
if (bracketed_paste || kbinput == BRACKETED_PASTE_MARKER) {
beep();
continue;
}
#endif
func = interpret(&kbinput);
if (func == 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 || func == do_scroll_up) {
do_scroll_up();
} else if (func == do_down || func == do_scroll_down) {
if (openfile->edittop->lineno + editwinrows - 1 <
openfile->filebot->lineno)
do_scroll_down();
} else if (func == do_page_up || func == do_page_down ||
func == to_first_line || func == to_last_line ||
func == do_findprevious || func == do_findnext) {
func();
} else if (func == do_search_forward || func == do_search_backward) {
func();
bottombars(MHELP);
#ifdef ENABLE_NANORC
} else if (func == (functionptrtype)implant) {
implant(first_sc_for(MHELP, func)->expansion);
#endif
#ifdef ENABLE_MOUSE
} else if (kbinput == KEY_MOUSE) {
int dummy_row, dummy_col;
get_mouseinput(&dummy_row, &dummy_col, TRUE);
#endif
#ifndef NANO_TINY
} else if (kbinput == KEY_WINCH) {
; /* Nothing to do. */
#endif
} else if (func == do_exit) {
break;
} else
unbound_key(kbinput);
currmenu = MHELP;
edit_refresh();
location = 0;
line = openfile->filetop;
/* Count how far (in bytes) edittop is into the file. */
while (line != openfile->edittop) {
location += strlen(line->data);
line = line->next;
}
}
/* Discard the help-text buffer. */
close_buffer();
/* Restore the settings of all flags. */
memcpy(flags, stash, sizeof(flags));
#ifdef ENABLE_LINENUMBERS
margin = was_margin;
editwincols = COLS - margin;
#endif
tabsize = was_tabsize;
#ifdef ENABLE_COLOR
syntaxstr = was_syntax;
have_palette = FALSE;
#endif
free(title);
title = NULL;
free(answer);
answer = saved_answer;
free(help_text);
inhelp = FALSE;
curs_set(0);
if (ISSET(NO_HELP)) {
currmenu = oldmenu;
window_init();
} else {
wipe_statusbar();
bottombars(oldmenu);
}
#ifdef ENABLE_BROWSER
if (oldmenu == MBROWSER || oldmenu == MWHEREISFILE || oldmenu == MGOTODIR)
browser_refresh();
else
#endif
{
titlebar(NULL);
edit_refresh();
}
}
/* Allocate space for the help text for the current menu, and concatenate
* the different pieces of text into it. */
/* Allocate space for the help text for the current menu,
* and concatenate the different pieces of text into it. */
void help_init(void)
{
size_t allocsize = 0;
@@ -297,12 +45,12 @@ void help_init(void)
const char *htx[3];
/* Untranslated help introduction. We break it up into three chunks
* in case the full string is too long for the compiler to handle. */
char *ptr;
const funcstruct *f;
const keystruct *s;
char *ptr;
/* First, set up the initial help text for the current function. */
if (currmenu == MWHEREIS || currmenu == MREPLACE || currmenu == MREPLACEWITH) {
if (currmenu & (MWHEREIS|MREPLACE|MREPLACEWITH)) {
htx[0] = N_("Search Command Help Text\n\n "
"Enter the words or characters you would like to "
"search for, and then press Enter. If there is a "
@@ -409,7 +157,7 @@ void help_init(void)
}
#endif /* ENABLE_SPELLER */
#ifndef NANO_TINY
else if (currmenu == MEXTCMD) {
else if (currmenu == MEXECUTE) {
htx[0] = N_("Execute Command Help Text\n\n "
"This mode allows you to insert the output of a "
"command run by the shell into the current buffer (or "
@@ -417,7 +165,8 @@ void help_init(void)
"(the pipe symbol), the current contents of the buffer "
"(or marked region) will be piped to the command. ");
htx[1] = N_("If you just need another blank buffer, do not enter any "
"command.\n\n");
"command.\n\n You can also pick one of four tools, or cut a "
"large piece of the buffer, or put the editor to sleep.\n\n");
htx[2] = N_(" The following function keys are "
"available in Execute Command mode:\n\n");
} else if (currmenu == MLINTER) {
@@ -470,9 +219,9 @@ void help_init(void)
if (htx[2] != NULL)
allocsize += strlen(htx[2]);
/* Calculate the length of the shortcut help text. Each entry has
* one or two keys, which fill 17 cells, plus translated text,
* plus one or two \n's. */
/* Calculate the length of the descriptions of the shortcuts.
* Each entry has one or two keystrokes, which fill 17 cells,
* plus translated text, plus one or two \n's. */
for (f = allfuncs; f != NULL; f = f->next)
if (f->menus & currmenu)
allocsize += strlen(_(f->help)) + 21;
@@ -485,13 +234,13 @@ void help_init(void)
size_t onoff_len = strlen(_("enable/disable"));
for (s = sclist; s != NULL; s = s->next)
if (s->func == do_toggle_void)
allocsize += strlen(_(flagtostr(s->toggle))) + onoff_len + 9;
if (s->func == do_toggle)
allocsize += strlen(_(epithet_of_flag(s->toggle))) + onoff_len + 9;
}
#endif
/* Allocate memory for the help text. */
help_text = charalloc(allocsize + 1);
help_text = nmalloc(allocsize + 1);
/* Now add the text we want. */
strcpy(help_text, htx[0]);
@@ -513,7 +262,7 @@ void help_init(void)
/* Show the first two shortcuts (if any) for each function. */
for (s = sclist; s != NULL; s = s->next) {
if ((s->menus & currmenu) && s->func == f->func) {
if ((s->menus & currmenu) && s->func == f->func && s->keystr[0]) {
/* Make the first column 7 cells wide and the second 10. */
if (++tally == 1) {
sprintf(ptr, "%s ", s->keystr);
@@ -553,16 +302,271 @@ void help_init(void)
counter++;
for (s = sclist; s != NULL; s = s->next)
if (s->toggle && s->ordinal == counter) {
ptr += sprintf(ptr, "%s\t\t %s %s\n", (s->menus == MMAIN ? s->keystr : ""),
_(flagtostr(s->toggle)), _("enable/disable"));
if (s->toggle == NO_COLOR_SYNTAX || s->toggle == TABS_TO_SPACES)
ptr += sprintf(ptr, "%s\t\t %s %s\n", (s->menus & MMAIN ? s->keystr : ""),
_(epithet_of_flag(s->toggle)), _("enable/disable"));
/* Add a blank like between two groups. */
if (s->toggle == NO_SYNTAX)
ptr += sprintf(ptr, "\n");
break;
}
}
}
#endif /* !NANO_TINY */
#endif
}
/* Hard-wrap the concatenated help text, and write it into a new buffer. */
void wrap_help_text_into_buffer(void)
{
size_t sum = 0;
/* Avoid overtight and overwide paragraphs in the introductory text. */
size_t wrapping_point = ((COLS < 40) ? 40 : (COLS > 74) ? 74 : COLS) - thebar;
const char *ptr = start_of_body;
make_new_buffer();
/* Ensure there is a blank line at the top of the text, for esthetics. */
if ((ISSET(MINIBAR) || !ISSET(EMPTY_LINE)) && LINES > 6) {
openfile->current->data = mallocstrcpy(openfile->current->data, " ");
openfile->current->next = make_new_node(openfile->current);
openfile->current = openfile->current->next;
}
/* Copy the help text into the just-created new buffer. */
while (*ptr != '\0') {
int length, shim;
char *oneline;
if (ptr == end_of_intro)
wrapping_point = ((COLS < 40) ? 40 : COLS) - thebar;
if (ptr < end_of_intro || *(ptr - 1) == '\n') {
length = break_line(ptr, wrapping_point, TRUE);
oneline = nmalloc(length + 1);
shim = (*(ptr + length - 1) == ' ') ? 0 : 1;
snprintf(oneline, length + shim, "%s", ptr);
} else {
length = break_line(ptr, ((COLS < 40) ? 22 : COLS - 18) - thebar, TRUE);
oneline = nmalloc(length + 5);
snprintf(oneline, length + 5, "\t\t %s", ptr);
}
free(openfile->current->data);
openfile->current->data = oneline;
ptr += length;
if (*ptr != '\n')
ptr--;
/* Create a new line, and then one more for each extra \n. */
do {
openfile->current->next = make_new_node(openfile->current);
openfile->current = openfile->current->next;
openfile->current->data = copy_of("");
} while (*(++ptr) == '\n');
}
openfile->filebot = openfile->current;
openfile->current = openfile->filetop;
remove_magicline();
#ifdef ENABLE_COLOR
find_and_prime_applicable_syntax();
#endif
prepare_for_display();
/* Move to the position in the file where we were before. */
while (TRUE) {
sum += strlen(openfile->current->data);
if (sum > location)
break;
openfile->current = openfile->current->next;
}
openfile->edittop = openfile->current;
}
/* Assemble a help text, display it, and allow scrolling through it. */
void show_help(void)
{
int kbinput = ERR;
functionptrtype func;
/* The function of the key the user typed in. */
int oldmenu = currmenu;
/* The menu we were called from. */
#ifdef ENABLE_LINENUMBERS
int was_margin = margin;
#endif
ssize_t was_tabsize = tabsize;
#ifdef ENABLE_COLOR
char *was_syntax = syntaxstr;
#endif
char *saved_answer = (answer != NULL) ? copy_of(answer) : NULL;
/* The current answer when the user invokes help at the prompt. */
unsigned stash[sizeof(flags) / sizeof(flags[0])];
/* A storage place for the current flag settings. */
linestruct *line;
int length;
/* Save the settings of all flags. */
memcpy(stash, flags, sizeof(flags));
/* Ensure that the help screen's shortcut list can be displayed. */
if (ISSET(NO_HELP) || ISSET(ZERO)) {
UNSET(NO_HELP);
UNSET(ZERO);
window_init();
} else
blank_statusbar();
/* When searching, do it forward, case insensitive, and without regexes. */
UNSET(BACKWARDS_SEARCH);
UNSET(CASE_SENSITIVE);
UNSET(USE_REGEXP);
UNSET(WHITESPACE_DISPLAY);
#ifdef ENABLE_LINENUMBERS
editwincols = COLS - thebar;
margin = 0;
#endif
tabsize = 8;
#ifdef ENABLE_COLOR
syntaxstr = "nanohelp";
#endif
curs_set(0);
/* Compose the help text from all the relevant pieces. */
help_init();
inhelp = TRUE;
location = 0;
didfind = 0;
bottombars(MHELP);
/* Extract the title from the head of the help text. */
length = break_line(help_text, HIGHEST_POSITIVE, TRUE);
title = measured_copy(help_text, length);
titlebar(title);
/* Skip over the title to point at the start of the body text. */
start_of_body = help_text + length;
while (*start_of_body == '\n')
start_of_body++;
wrap_help_text_into_buffer();
edit_refresh();
while (TRUE) {
lastmessage = VACUUM;
focusing = TRUE;
/* Show the cursor when we searched and found something. */
kbinput = get_kbinput(midwin, didfind == 1 || ISSET(SHOW_CURSOR));
didfind = 0;
#ifndef NANO_TINY
spotlighted = FALSE;
if (bracketed_paste || kbinput == BRACKETED_PASTE_MARKER) {
beep();
continue;
}
#endif
func = interpret(&kbinput);
if (func == full_refresh) {
full_refresh();
} else if (ISSET(SHOW_CURSOR) && (func == do_left || func == do_right ||
func == do_up || func == do_down)) {
func();
} else if (func == do_up || func == do_scroll_up) {
do_scroll_up();
} else if (func == do_down || func == do_scroll_down) {
if (openfile->edittop->lineno + editwinrows - 1 < openfile->filebot->lineno)
do_scroll_down();
} else if (func == do_page_up || func == do_page_down ||
func == to_first_line || func == to_last_line) {
func();
} else if (func == do_search_backward || func == do_search_forward ||
func == do_findprevious || func == do_findnext) {
func();
bottombars(MHELP);
#ifdef ENABLE_NANORC
} else if (func == (functionptrtype)implant) {
implant(first_sc_for(MHELP, func)->expansion);
#endif
#ifdef ENABLE_MOUSE
} else if (kbinput == KEY_MOUSE) {
int dummy_row, dummy_col;
get_mouseinput(&dummy_row, &dummy_col, TRUE);
#endif
#ifndef NANO_TINY
} else if (kbinput == KEY_WINCH) {
; /* Nothing to do. */
#endif
} else if (func == do_exit) {
break;
} else
unbound_key(kbinput);
edit_refresh();
location = 0;
line = openfile->filetop;
/* Count how far (in bytes) edittop is into the file. */
while (line != openfile->edittop) {
location += strlen(line->data);
line = line->next;
}
}
/* Discard the help-text buffer. */
close_buffer();
/* Restore the settings of all flags. */
memcpy(flags, stash, sizeof(flags));
#ifdef ENABLE_LINENUMBERS
margin = was_margin;
editwincols = COLS - margin - thebar;
#endif
tabsize = was_tabsize;
#ifdef ENABLE_COLOR
syntaxstr = was_syntax;
have_palette = FALSE;
#endif
free(title);
title = NULL;
free(answer);
answer = saved_answer;
free(help_text);
inhelp = FALSE;
curs_set(0);
if (ISSET(NO_HELP) || ISSET(ZERO))
window_init();
else
blank_statusbar();
bottombars(oldmenu);
#ifdef ENABLE_BROWSER
if (oldmenu & (MBROWSER|MWHEREISFILE|MGOTODIR))
browser_refresh();
else
#endif
{
titlebar(NULL);
edit_refresh();
}
}
#endif /* ENABLE_HELP */
/* Start the help viewer, or indicate that there is no help. */
@@ -571,8 +575,8 @@ void do_help(void)
#ifdef ENABLE_HELP
show_help();
#else
if (currmenu == MMAIN)
say_there_is_no_help();
if (currmenu & (MMAIN|MBROWSER))
statusbar(_("^W = Ctrl+W M-W = Alt+W"));
else
beep();
#endif

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* history.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2003-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2003-2011, 2013-2022 Free Software Foundation, Inc. *
* Copyright (C) 2016, 2017, 2019 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -19,7 +19,7 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#ifdef ENABLE_HISTORIES
@@ -27,19 +27,19 @@
#include <string.h>
#ifndef SEARCH_HISTORY
#define SEARCH_HISTORY "search_history"
#define SEARCH_HISTORY "search_history"
#endif
#ifndef POSITION_HISTORY
#define POSITION_HISTORY "filepos_history"
#define POSITION_HISTORY "filepos_history"
#endif
static bool history_changed = FALSE;
/* Whether any of the history lists has changed. */
static struct stat stat_of_positions_file;
/* The last-obtained stat information of the positions file. */
static char *poshistname = NULL;
/* The name of the positions-history file. */
static time_t latest_timestamp = 942927132;
/* The last time the positions-history file was written. */
static poshiststruct *position_history = NULL;
/* The list of filenames with their last cursor positions. */
@@ -63,21 +63,21 @@ void history_init(void)
executebot = execute_history;
}
/* Set the current position in the given history list to the bottom. */
void history_reset(const linestruct *list)
/* Reset the pointer into the history list that contains item to the bottom. */
void reset_history_pointer_for(const linestruct *item)
{
if (list == search_history)
if (item == search_history)
search_history = searchbot;
else if (list == replace_history)
else if (item == replace_history)
replace_history = replacebot;
else if (list == execute_history)
else if (item == execute_history)
execute_history = executebot;
}
/* Return from the history list that starts at start and ends at end
* the first node that contains the first len characters of the given
* text, or NULL if there is no such node. */
linestruct *find_history(const linestruct *start, const linestruct *end,
linestruct *find_in_history(const linestruct *start, const linestruct *end,
const char *text, size_t len)
{
const linestruct *item;
@@ -92,9 +92,10 @@ linestruct *find_history(const linestruct *start, const linestruct *end,
/* Update a history list (the one in which item is the current position)
* with a fresh string text. That is: add text, or move it to the end. */
void update_history(linestruct **item, const char *text)
void update_history(linestruct **item, const char *text, bool avoid_duplicates)
{
linestruct **htop = NULL, **hbot = NULL, *thesame;
linestruct **htop = NULL, **hbot = NULL;
linestruct *thesame = NULL;
if (*item == search_history) {
htop = &searchtop;
@@ -107,11 +108,12 @@ void update_history(linestruct **item, const char *text)
hbot = &executebot;
}
/* See if the string is already in the history. */
thesame = find_history(*hbot, *htop, text, HIGHEST_POSITIVE);
/* When requested, check if the string is already in the history. */
if (avoid_duplicates)
thesame = find_in_history(*hbot, *htop, text, HIGHEST_POSITIVE);
/* If an identical string was found, delete that item. */
if (thesame != NULL) {
if (thesame) {
linestruct *after = thesame->next;
/* If the string is at the head of the list, move the head. */
@@ -145,102 +147,67 @@ void update_history(linestruct **item, const char *text)
*item = *hbot;
}
/* Move h to the string in the history list just before it, and return
* that string. If there isn't one, don't move h and return NULL. */
char *get_history_older(linestruct **h)
{
if ((*h)->prev == NULL)
return NULL;
*h = (*h)->prev;
return (*h)->data;
}
/* Move h to the string in the history list just after it, and return
* that string. If there isn't one, don't move h and return NULL. */
char *get_history_newer(linestruct **h)
{
if ((*h)->next == NULL)
return NULL;
*h = (*h)->next;
return (*h)->data;
}
/* Two empty placeholder functions. */
void get_history_older_void(void)
{
}
void get_history_newer_void(void)
{
}
#ifdef ENABLE_TABCOMP
/* Move h to the next string that's a tab completion of the string s,
* looking at only the first len characters of s, and return that
* string. If there isn't one, or if len is 0, don't move h and return
* s. */
char *get_history_completion(linestruct **h, char *s, size_t len)
/* Go backward through one of three history lists, starting at item *here,
* searching for a string that is a tab completion of the given string,
* looking at only its first len characters. When found, make *here point
* at the item and return its string; otherwise, just return the string. */
char *get_history_completion(linestruct **here, char *string, size_t len)
{
if (len > 0) {
linestruct *htop = NULL, *hbot = NULL, *p;
linestruct *htop = NULL, *hbot = NULL;
linestruct *item;
if (*h == search_history) {
htop = searchtop;
hbot = searchbot;
} else if (*h == replace_history) {
htop = replacetop;
hbot = replacebot;
} else if (*h == execute_history) {
htop = executetop;
hbot = executebot;
}
/* Search the history list from the current position to the top
* for a match of len characters. Skip over an exact match. */
p = find_history((*h)->prev, htop, s, len);
while (p != NULL && strcmp(p->data, s) == 0)
p = find_history(p->prev, htop, s, len);
if (p != NULL) {
*h = p;
return mallocstrcpy(s, (*h)->data);
}
/* Search the history list from the bottom to the current position
* for a match of len characters. Skip over an exact match. */
p = find_history(hbot, *h, s, len);
while (p != NULL && strcmp(p->data, s) == 0)
p = find_history(p->prev, *h, s, len);
if (p != NULL) {
*h = p;
return mallocstrcpy(s, (*h)->data);
}
if (*here == search_history) {
htop = searchtop;
hbot = searchbot;
} else if (*here == replace_history) {
htop = replacetop;
hbot = replacebot;
} else if (*here == execute_history) {
htop = executetop;
hbot = executebot;
}
/* If we're here, we didn't find a match, we didn't find an inexact
* match, or len is 0. Return s. */
return (char *)s;
/* First search from the current position to the top of the list
* for a match of len characters. Skip over an exact match. */
item = find_in_history((*here)->prev, htop, string, len);
while (item != NULL && strcmp(item->data, string) == 0)
item = find_in_history(item->prev, htop, string, len);
if (item) {
*here = item;
return mallocstrcpy(string, item->data);
}
/* Now search from the bottom of the list to the original position. */
item = find_in_history(hbot, *here, string, len);
while (item != NULL && strcmp(item->data, string) == 0)
item = find_in_history(item->prev, *here, string, len);
if (item) {
*here = item;
return mallocstrcpy(string, item->data);
}
/* When no useful match was found, simply return the given string. */
return (char *)string;
}
#endif /* ENABLE_TABCOMP */
/* Check whether we have or could make a directory for history files. */
bool have_statedir(void)
{
struct stat dirstat;
const char *xdgdatadir;
struct stat dirinfo;
get_homedir();
if (homedir != NULL) {
statedir = concatenate(homedir, "/.nano/");
if (stat(statedir, &dirstat) == 0 && S_ISDIR(dirstat.st_mode)) {
if (stat(statedir, &dirinfo) == 0 && S_ISDIR(dirinfo.st_mode)) {
poshistname = concatenate(statedir, POSITION_HISTORY);
return TRUE;
}
@@ -257,7 +224,7 @@ bool have_statedir(void)
else
statedir = concatenate(homedir, "/.local/share/nano/");
if (stat(statedir, &dirstat) == -1) {
if (stat(statedir, &dirinfo) == -1) {
if (xdgdatadir == NULL) {
char *statepath = concatenate(homedir, "/.local");
mkdir(statepath, S_IRWXU | S_IRWXG | S_IRWXO);
@@ -273,7 +240,7 @@ bool have_statedir(void)
statedir, strerror(errno));
return FALSE;
}
} else if (!S_ISDIR(dirstat.st_mode)) {
} else if (!S_ISDIR(dirinfo.st_mode)) {
jot_error(N_("Path %s is not a directory and needs to be.\n"
"Nano will be unable to load or save "
"search history or cursor positions.\n"),
@@ -285,53 +252,54 @@ bool have_statedir(void)
return TRUE;
}
/* Load the histories for Search and Replace and Execute Command. */
/* Load the histories for Search, Replace With, and Execute Command. */
void load_history(void)
{
char *histname = concatenate(statedir, SEARCH_HISTORY);
FILE *hisfile = fopen(histname, "rb");
FILE *histfile = fopen(histname, "rb");
if (hisfile == NULL) {
if (errno != ENOENT) {
/* When reading failed, don't save history when we quit. */
UNSET(HISTORYLOG);
jot_error(N_("Error reading %s: %s"), histname,
strerror(errno));
}
} else {
/* Load the three history lists -- first search, then replace,
* then execute -- from oldest entry to newest. Between two
* lists there is an empty line. */
linestruct **history = &search_history;
char *line = NULL;
size_t buf_len = 0;
ssize_t read;
while ((read = getline(&line, &buf_len, hisfile)) > 0) {
line[--read] = '\0';
if (read > 0) {
/* Encode any embedded NUL as 0x0A. */
unsunder(line, read);
update_history(history, line);
} else if (history == &search_history)
history = &replace_history;
else
history = &execute_history;
}
fclose(hisfile);
free(line);
/* If reading an existing file failed, don't save history when we quit. */
if (histfile == NULL && errno != ENOENT) {
jot_error(N_("Error reading %s: %s"), histname, strerror(errno));
UNSET(HISTORYLOG);
}
/* After reading them in, set the status of the lists to "unchanged". */
history_changed = FALSE;
if (histfile == NULL) {
free(histname);
return;
}
linestruct **history = &search_history;
char *stanza = NULL;
size_t dummy = 0;
ssize_t read;
/* Load the three history lists (first search, then replace, then execute)
* from oldest entry to newest. Between two lists there is an empty line. */
while ((read = getline(&stanza, &dummy, histfile)) > 0) {
stanza[--read] = '\0';
if (read > 0) {
recode_NUL_to_LF(stanza, read);
update_history(history, stanza, IGNORE_DUPLICATES);
} else if (history == &search_history)
history = &replace_history;
else
history = &execute_history;
}
if (fclose(histfile) == EOF)
jot_error(N_("Error reading %s: %s"), histname, strerror(errno));
free(histname);
free(stanza);
/* Reading in the lists has marked them as changed; undo this side effect. */
history_changed = FALSE;
}
/* Write the lines of a history list, starting at head, from oldest to newest,
* to the given file. Return TRUE if writing succeeded, and FALSE otherwise. */
bool write_list(const linestruct *head, FILE *hisfile)
bool write_list(const linestruct *head, FILE *histfile)
{
const linestruct *item;
@@ -339,183 +307,199 @@ bool write_list(const linestruct *head, FILE *hisfile)
size_t length = strlen(item->data);
/* Decode 0x0A bytes as embedded NULs. */
sunder(item->data);
recode_LF_to_NUL(item->data);
if (fwrite(item->data, sizeof(char), length, hisfile) < length)
if (fwrite(item->data, sizeof(char), length, histfile) < length)
return FALSE;
if (putc('\n', hisfile) == EOF)
if (putc('\n', histfile) == EOF)
return FALSE;
}
return TRUE;
}
/* Save the histories for Search and Replace and Execute Command. */
/* Save the histories for Search, Replace With, and Execute Command. */
void save_history(void)
{
char *histname;
FILE *hisfile;
FILE *histfile;
/* If the histories are unchanged, don't bother saving them. */
if (!history_changed)
return;
histname = concatenate(statedir, SEARCH_HISTORY);
hisfile = fopen(histname, "wb");
histfile = fopen(histname, "wb");
if (hisfile == NULL)
fprintf(stderr, _("Error writing %s: %s\n"), histname,
strerror(errno));
else {
/* Don't allow others to read or write the history file. */
chmod(histname, S_IRUSR | S_IWUSR);
if (!write_list(searchtop, hisfile) ||
!write_list(replacetop, hisfile) ||
!write_list(executetop, hisfile))
fprintf(stderr, _("Error writing %s: %s\n"), histname,
strerror(errno));
fclose(hisfile);
if (histfile == NULL) {
jot_error(N_("Error writing %s: %s"), histname, strerror(errno));
free(histname);
return;
}
/* Don't allow others to read or write the history file. */
if (chmod(histname, S_IRUSR | S_IWUSR) < 0)
jot_error(N_("Cannot limit permissions on %s: %s"), histname, strerror(errno));
if (!write_list(searchtop, histfile) || !write_list(replacetop, histfile) ||
!write_list(executetop, histfile))
jot_error(N_("Error writing %s: %s"), histname, strerror(errno));
if (fclose(histfile) == EOF)
jot_error(N_("Error writing %s: %s"), histname, strerror(errno));
free(histname);
}
/* Load the recorded cursor positions for files that were edited. */
void load_poshistory(void)
{
FILE *hisfile = fopen(poshistname, "rb");
FILE *histfile = fopen(poshistname, "rb");
if (hisfile == NULL) {
if (errno != ENOENT) {
/* When reading failed, don't save history when we quit. */
UNSET(POSITIONLOG);
jot_error(N_("Error reading %s: %s"), poshistname, strerror(errno));
}
} else {
char *line = NULL, *lineptr, *xptr;
size_t buf_len = 0;
ssize_t read, count = 0;
poshiststruct *record_ptr = NULL, *newrecord;
/* Read and parse each line, and store the extracted data. */
while ((read = getline(&line, &buf_len, hisfile)) > 5) {
/* Decode NULs as embedded newlines. */
unsunder(line, read);
/* Find where the x index and line number are in the line. */
xptr = revstrstr(line, " ", line + read - 3);
if (xptr == NULL)
continue;
lineptr = revstrstr(line, " ", xptr - 2);
if (lineptr == NULL)
continue;
/* Now separate the three elements of the line. */
*(xptr++) = '\0';
*(lineptr++) = '\0';
/* Create a new position record. */
newrecord = (poshiststruct *)nmalloc(sizeof(poshiststruct));
newrecord->filename = copy_of(line);
newrecord->lineno = atoi(lineptr);
newrecord->xno = atoi(xptr);
newrecord->next = NULL;
/* Add the record to the list. */
if (position_history == NULL)
position_history = newrecord;
else
record_ptr->next = newrecord;
record_ptr = newrecord;
/* Impose a limit, so the file will not grow indefinitely. */
if (++count > 200) {
poshiststruct *drop_record = position_history;
position_history = position_history->next;
free(drop_record->filename);
free(drop_record);
}
}
fclose(hisfile);
free(line);
stat(poshistname, &stat_of_positions_file);
/* If reading an existing file failed, don't save history when we quit. */
if (histfile == NULL && errno != ENOENT) {
jot_error(N_("Error reading %s: %s"), poshistname, strerror(errno));
UNSET(POSITIONLOG);
}
if (histfile == NULL)
return;
poshiststruct *lastitem = NULL;
poshiststruct *newitem;
char *lineptr, *columnptr;
char *stanza = NULL;
struct stat fileinfo;
size_t dummy = 0;
ssize_t count = 0;
ssize_t read;
/* Read and parse each line, and store the extracted data. */
while ((read = getline(&stanza, &dummy, histfile)) > 5) {
/* Decode NULs as embedded newlines. */
recode_NUL_to_LF(stanza, read);
/* Find the spaces before column number and line number. */
columnptr = revstrstr(stanza, " ", stanza + read - 3);
if (columnptr == NULL)
continue;
lineptr = revstrstr(stanza, " ", columnptr - 2);
if (lineptr == NULL)
continue;
/* Now separate the three elements of the line. */
*(columnptr++) = '\0';
*(lineptr++) = '\0';
/* Create a new position record. */
newitem = nmalloc(sizeof(poshiststruct));
newitem->filename = copy_of(stanza);
newitem->linenumber = atoi(lineptr);
newitem->columnnumber = atoi(columnptr);
newitem->next = NULL;
/* Add the record to the list. */
if (position_history == NULL)
position_history = newitem;
else
lastitem->next = newitem;
lastitem = newitem;
/* Impose a limit, so the file will not grow indefinitely. */
if (++count > 200) {
poshiststruct *drop_record = position_history;
position_history = position_history->next;
free(drop_record->filename);
free(drop_record);
}
}
if (fclose(histfile) == EOF)
jot_error(N_("Error reading %s: %s"), poshistname, strerror(errno));
free(stanza);
if (stat(poshistname, &fileinfo) == 0)
latest_timestamp = fileinfo.st_mtime;
}
/* Save the recorded cursor positions for files that were edited. */
void save_poshistory(void)
{
poshiststruct *posptr;
FILE *hisfile = fopen(poshistname, "wb");
FILE *histfile = fopen(poshistname, "wb");
struct stat fileinfo;
poshiststruct *item;
if (hisfile == NULL)
fprintf(stderr, _("Error writing %s: %s\n"), poshistname, strerror(errno));
else {
/* Don't allow others to read or write the history file. */
chmod(poshistname, S_IRUSR | S_IWUSR);
for (posptr = position_history; posptr != NULL; posptr = posptr->next) {
char *path_and_place;
size_t length;
/* Assume 20 decimal positions each for line and column number,
* plus two spaces, plus the line feed, plus the null byte. */
path_and_place = charalloc(strlen(posptr->filename) + 44);
sprintf(path_and_place, "%s %zd %zd\n",
posptr->filename, posptr->lineno, posptr->xno);
length = strlen(path_and_place);
/* Encode newlines in filenames as NULs. */
sunder(path_and_place);
/* Restore the terminating newline. */
path_and_place[length - 1] = '\n';
if (fwrite(path_and_place, sizeof(char), length, hisfile) < length)
fprintf(stderr, _("Error writing %s: %s\n"),
poshistname, strerror(errno));
free(path_and_place);
}
fclose(hisfile);
stat(poshistname, &stat_of_positions_file);
if (histfile == NULL) {
jot_error(N_("Error writing %s: %s"), poshistname, strerror(errno));
return;
}
/* Don't allow others to read or write the history file. */
if (chmod(poshistname, S_IRUSR | S_IWUSR) < 0)
jot_error(N_("Cannot limit permissions on %s: %s"), poshistname, strerror(errno));
for (item = position_history; item != NULL; item = item->next) {
char *path_and_place;
size_t length;
/* Assume 20 decimal positions each for line and column number,
* plus two spaces, plus the line feed, plus the null byte. */
path_and_place = nmalloc(strlen(item->filename) + 44);
sprintf(path_and_place, "%s %zd %zd\n",
item->filename, item->linenumber, item->columnnumber);
length = strlen(path_and_place);
/* Encode newlines in filenames as NULs. */
recode_LF_to_NUL(path_and_place);
/* Restore the terminating newline. */
path_and_place[length - 1] = '\n';
if (fwrite(path_and_place, sizeof(char), length, histfile) < length)
jot_error(N_("Error writing %s: %s"), poshistname, strerror(errno));
free(path_and_place);
}
if (fclose(histfile) == EOF)
jot_error(N_("Error writing %s: %s"), poshistname, strerror(errno));
if (stat(poshistname, &fileinfo) == 0)
latest_timestamp = fileinfo.st_mtime;
}
/* Reload the position history file if it has been modified since last load. */
void reload_positions_if_needed(void)
{
struct stat newstat;
poshiststruct *item, *nextone;
struct stat fileinfo;
stat(poshistname, &newstat);
if (stat(poshistname, &fileinfo) != 0 || fileinfo.st_mtime == latest_timestamp)
return;
if (newstat.st_mtime != stat_of_positions_file.st_mtime) {
poshiststruct *ptr, *nextone;
for (ptr = position_history; ptr != NULL; ptr = nextone) {
nextone = ptr->next;
free(ptr->filename);
free(ptr);
}
position_history = NULL;
load_poshistory();
for (item = position_history; item != NULL; item = nextone) {
nextone = item->next;
free(item->filename);
free(item);
}
position_history = NULL;
load_poshistory();
}
/* Update the recorded last file positions, given a filename, a line
* and a column. If no entry is found, add a new one at the end. */
void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
/* Update the recorded last file positions with the current position in the
* current buffer. If no existing entry is found, add a new one at the end. */
void update_poshistory(void)
{
poshiststruct *posptr, *theone, *posprev = NULL;
char *fullpath = get_full_path(filename);
char *fullpath = get_full_path(openfile->filename);
poshiststruct *previous = NULL;
poshiststruct *item, *theone;
if (fullpath == NULL || *filename == '\0') {
if (fullpath == NULL || openfile->filename[0] == '\0') {
free(fullpath);
return;
}
@@ -523,51 +507,51 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
reload_positions_if_needed();
/* Look for a matching filename in the list. */
for (posptr = position_history; posptr != NULL; posptr = posptr->next) {
if (!strcmp(posptr->filename, fullpath))
for (item = position_history; item != NULL; item = item->next) {
if (!strcmp(item->filename, fullpath))
break;
posprev = posptr;
previous = item;
}
/* Don't record files that have the default cursor position. */
if (lineno == 1 && xpos == 1) {
if (posptr != NULL) {
if (posprev == NULL)
position_history = posptr->next;
if (openfile->current->lineno == 1 && openfile->current_x == 0) {
if (item != NULL) {
if (previous == NULL)
position_history = item->next;
else
posprev->next = posptr->next;
free(posptr->filename);
free(posptr);
previous->next = item->next;
free(item->filename);
free(item);
save_poshistory();
}
free(fullpath);
return;
}
theone = posptr;
theone = item;
/* If we didn't find it, make a new node; otherwise, if we're
* not at the end, move the matching one to the end. */
if (theone == NULL) {
theone = (poshiststruct *)nmalloc(sizeof(poshiststruct));
theone = nmalloc(sizeof(poshiststruct));
theone->filename = copy_of(fullpath);
if (position_history == NULL)
position_history = theone;
else
posprev->next = theone;
} else if (posptr->next != NULL) {
if (posprev == NULL)
position_history = posptr->next;
previous->next = theone;
} else if (item->next != NULL) {
if (previous == NULL)
position_history = item->next;
else
posprev->next = posptr->next;
while (posptr->next != NULL)
posptr = posptr->next;
posptr->next = theone;
previous->next = item->next;
while (item->next != NULL)
item = item->next;
item->next = theone;
}
/* Store the last cursor position. */
theone->lineno = lineno;
theone->xno = xpos;
theone->linenumber = openfile->current->lineno;
theone->columnnumber = xplustabs() + 1;
theone->next = NULL;
free(fullpath);
@@ -580,25 +564,25 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
* set line and column to the retrieved values. */
bool has_old_position(const char *file, ssize_t *line, ssize_t *column)
{
poshiststruct *posptr;
char *fullpath = get_full_path(file);
poshiststruct *item;
if (fullpath == NULL)
return FALSE;
reload_positions_if_needed();
posptr = position_history;
while (posptr != NULL && strcmp(posptr->filename, fullpath) != 0)
posptr = posptr->next;
item = position_history;
while (item != NULL && strcmp(item->filename, fullpath) != 0)
item = item->next;
free(fullpath);
if (posptr == NULL)
if (item == NULL)
return FALSE;
*line = posptr->lineno;
*column = posptr->xno;
*line = item->linenumber;
*column = item->columnnumber;
return TRUE;
}
#endif /* ENABLE_HISTORIES */

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* move.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
* Copyright (C) 2014-2018 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -19,7 +19,7 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#include <string.h>
@@ -37,7 +37,7 @@ void to_first_line(void)
void to_last_line(void)
{
openfile->current = openfile->filebot;
openfile->current_x = strlen(openfile->filebot->data);
openfile->current_x = (inhelp) ? 0 : strlen(openfile->filebot->data);
openfile->placewewant = xplustabs();
/* Set the last line of the screen as the target for the cursor. */
@@ -115,6 +115,7 @@ void do_page_up(void)
int mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
size_t leftedge, target_column;
#ifndef NANO_TINY
/* If we're not in smooth scrolling mode, put the cursor at the
* beginning of the top line of the edit window, as Pico does. */
if (ISSET(JUMPY_SCROLLING)) {
@@ -123,6 +124,7 @@ void do_page_up(void)
openfile->current_y = 0;
target_column = 0;
} else
#endif
get_edge_and_target(&leftedge, &target_column);
/* Move up the required number of lines or chunks. If we can't, we're
@@ -145,6 +147,7 @@ void do_page_down(void)
int mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
size_t leftedge, target_column;
#ifndef NANO_TINY
/* If we're not in smooth scrolling mode, put the cursor at the
* beginning of the top line of the edit window, as Pico does. */
if (ISSET(JUMPY_SCROLLING)) {
@@ -153,6 +156,7 @@ void do_page_down(void)
openfile->current_y = 0;
target_column = 0;
} else
#endif
get_edge_and_target(&leftedge, &target_column);
/* Move down the required number of lines or chunks. If we can't, we're
@@ -192,7 +196,7 @@ void do_para_end(linestruct **line)
}
/* Move up to first start of a paragraph before the current line. */
void do_para_begin_void(void)
void to_para_begin(void)
{
linestruct *was_current = openfile->current;
@@ -203,7 +207,7 @@ void do_para_begin_void(void)
}
/* Move down to just after the first found end of a paragraph. */
void do_para_end_void(void)
void to_para_end(void)
{
linestruct *was_current = openfile->current;
@@ -222,7 +226,7 @@ void do_para_end_void(void)
#endif /* ENABLE_JUSTIFY */
/* Move to the preceding block of text. */
void do_prev_block(void)
void to_prev_block(void)
{
linestruct *was_current = openfile->current;
bool is_text = FALSE, seen_text = FALSE;
@@ -234,8 +238,8 @@ void do_prev_block(void)
seen_text = seen_text || is_text;
}
/* Step forward one line again if this one is blank. */
if (openfile->current->next != NULL &&
/* Step forward one line again if we passed text but this line is blank. */
if (seen_text && openfile->current->next != NULL &&
white_string(openfile->current->data))
openfile->current = openfile->current->next;
@@ -244,7 +248,7 @@ void do_prev_block(void)
}
/* Move to the next block of text. */
void do_next_block(void)
void to_next_block(void)
{
linestruct *was_current = openfile->current;
bool is_white = white_string(openfile->current->data);
@@ -261,10 +265,10 @@ void do_next_block(void)
edit_redraw(was_current, CENTERING);
}
/* Move to the previous word. If allow_punct is TRUE, treat punctuation
* as part of a word. */
void do_prev_word(bool allow_punct)
/* Move to the previous word. */
void do_prev_word(void)
{
bool punctuation_as_letters = ISSET(WORD_BOUNDS);
bool seen_a_word = FALSE, step_forward = FALSE;
/* Move backward until we pass over the start of a word. */
@@ -281,12 +285,16 @@ void do_prev_word(bool allow_punct)
openfile->current_x = step_left(openfile->current->data,
openfile->current_x);
if (is_word_mbchar(openfile->current->data + openfile->current_x,
allow_punct)) {
if (is_word_char(openfile->current->data + openfile->current_x,
punctuation_as_letters)) {
seen_a_word = TRUE;
/* If at the head of a line now, this surely is a word start. */
if (openfile->current_x == 0)
break;
#ifdef ENABLE_UTF8
} else if (is_zerowidth(openfile->current->data + openfile->current_x)) {
; /* skip */
#endif
} else if (seen_a_word) {
/* This is space now: we've overshot the start of the word. */
step_forward = TRUE;
@@ -301,12 +309,12 @@ void do_prev_word(bool allow_punct)
}
/* Move to the next word. If after_ends is TRUE, stop at the ends of words
* instead of their beginnings. If allow_punct is TRUE, treat punctuation as
* part of a word. Return TRUE if we started on a word, and FALSE otherwise. */
bool do_next_word(bool after_ends, bool allow_punct)
* instead of at their beginnings. Return TRUE if we started on a word. */
bool do_next_word(bool after_ends)
{
bool started_on_word = is_word_mbchar(openfile->current->data +
openfile->current_x, allow_punct);
bool punctuation_as_letters = ISSET(WORD_BOUNDS);
bool started_on_word = is_word_char(openfile->current->data +
openfile->current_x, punctuation_as_letters);
bool seen_space = !started_on_word;
#ifndef NANO_TINY
bool seen_word = started_on_word;
@@ -332,18 +340,27 @@ bool do_next_word(bool after_ends, bool allow_punct)
if (after_ends) {
/* If this is a word character, continue; else it's a separator,
* and if we've already seen a word, then it's a word end. */
if (is_word_mbchar(openfile->current->data + openfile->current_x,
allow_punct))
if (is_word_char(openfile->current->data + openfile->current_x,
punctuation_as_letters))
seen_word = TRUE;
#ifdef ENABLE_UTF8
else if (is_zerowidth(openfile->current->data + openfile->current_x))
; /* skip */
#endif
else if (seen_word)
break;
} else
#endif
{
#ifdef ENABLE_UTF8
if (is_zerowidth(openfile->current->data + openfile->current_x))
; /* skip */
else
#endif
/* If this is not a word character, then it's a separator; else
* if we've already seen a separator, then it's a word start. */
if (!is_word_mbchar(openfile->current->data + openfile->current_x,
allow_punct))
if (!is_word_char(openfile->current->data + openfile->current_x,
punctuation_as_letters))
seen_space = TRUE;
else if (seen_space)
break;
@@ -353,25 +370,23 @@ bool do_next_word(bool after_ends, bool allow_punct)
return started_on_word;
}
/* Move to the previous word in the file, treating punctuation as part of a
* word if the WORD_BOUNDS flag is set, and update the screen afterwards. */
void do_prev_word_void(void)
/* Move to the previous word in the file, and update the screen afterwards. */
void to_prev_word(void)
{
linestruct *was_current = openfile->current;
do_prev_word(ISSET(WORD_BOUNDS));
do_prev_word();
edit_redraw(was_current, FLOWING);
}
/* Move to the next word in the file. If the AFTER_ENDS flag is set, stop
* at word ends instead of beginnings. If the WORD_BOUNDS flag is set, treat
* punctuation as part of a word. Update the screen afterwards. */
void do_next_word_void(void)
* at word ends instead of beginnings. Update the screen afterwards. */
void to_next_word(void)
{
linestruct *was_current = openfile->current;
do_next_word(ISSET(AFTER_ENDS), ISSET(WORD_BOUNDS));
do_next_word(ISSET(AFTER_ENDS));
edit_redraw(was_current, FLOWING);
}
@@ -437,7 +452,7 @@ void do_home(void)
}
/* Move to the end of the current line (or softwrapped chunk).
* When softwrapping and alredy at the end of a chunk, go to the
* When softwrapping and already at the end of a chunk, go to the
* end of the full line. */
void do_end(void)
{
@@ -556,23 +571,37 @@ void do_scroll_down(void)
if (editwinrows > 1 && (openfile->edittop->next != NULL
#ifndef NANO_TINY
|| chunk_for(openfile->firstcolumn, openfile->edittop) <
number_of_chunks_in(openfile->edittop)
|| (ISSET(SOFTWRAP) && (extra_chunks_in(openfile->edittop) >
chunk_for(openfile->firstcolumn, openfile->edittop)))
#endif
))
edit_scroll(FORWARD);
}
#endif
/* Scroll the line with the cursor to the center of the screen. */
void do_center(void)
{
adjust_viewport(CENTERING);
draw_all_subwindows();
full_refresh();
}
#endif /* !NANO_TINY || ENABLE_HELP */
/* Move left one character. */
void do_left(void)
{
linestruct *was_current = openfile->current;
if (openfile->current_x > 0)
if (openfile->current_x > 0) {
openfile->current_x = step_left(openfile->current->data,
openfile->current_x);
else if (openfile->current != openfile->filetop) {
#ifdef ENABLE_UTF8
while (openfile->current_x > 0 &&
is_zerowidth(openfile->current->data + openfile->current_x))
openfile->current_x = step_left(openfile->current->data,
openfile->current_x);
#endif
} else if (openfile->current != openfile->filetop) {
openfile->current = openfile->current->prev;
openfile->current_x = strlen(openfile->current->data);
}
@@ -585,10 +614,16 @@ void do_right(void)
{
linestruct *was_current = openfile->current;
if (openfile->current->data[openfile->current_x] != '\0')
if (openfile->current->data[openfile->current_x] != '\0') {
openfile->current_x = step_right(openfile->current->data,
openfile->current_x);
else if (openfile->current != openfile->filebot) {
#ifdef ENABLE_UTF8
while (openfile->current->data[openfile->current_x] != '\0' &&
is_zerowidth(openfile->current->data + openfile->current_x))
openfile->current_x = step_right(openfile->current->data,
openfile->current_x);
#endif
} else if (openfile->current != openfile->filebot) {
openfile->current = openfile->current->next;
openfile->current_x = 0;
}

1330
src/nano.c

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* proto.h -- This file is part of GNU nano. *
* prototypes.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -18,7 +18,7 @@
* *
**************************************************************************/
#include "nano.h"
#include "definitions.h"
/* All external variables. See global.c for their descriptions. */
@@ -34,9 +34,10 @@ extern bool shift_held;
extern bool mute_modifiers;
extern bool bracketed_paste;
extern bool started_curses;
extern bool we_are_running;
extern bool more_than_one;
extern bool report_size;
extern bool ran_a_tool;
extern bool inhelp;
extern char *title;
@@ -47,8 +48,6 @@ extern bool as_an_at;
extern bool control_C_was_pressed;
extern bool suppress_cursorpos;
extern message_type lastmessage;
extern linestruct *pletion_line;
@@ -76,7 +75,8 @@ extern int shiftcontrolup, shiftcontroldown;
extern int shiftcontrolhome, shiftcontrolend;
extern int altleft, altright;
extern int altup, altdown;
extern int altdelete;
extern int altpageup, altpagedown;
extern int altinsert, altdelete;
extern int shiftaltleft, shiftaltright;
extern int shiftaltup, shiftaltdown;
#endif
@@ -87,12 +87,14 @@ extern size_t wrap_at;
#endif
extern WINDOW *topwin;
extern WINDOW *edit;
extern WINDOW *bottomwin;
extern WINDOW *midwin;
extern WINDOW *footwin;
extern int editwinrows;
extern int editwincols;
extern int margin;
extern int thebar;
#ifndef NANO_TINY
extern int *bardata;
extern ssize_t stripe_column;
#endif
@@ -184,18 +186,12 @@ extern size_t light_to_col;
typedef void (*functionptrtype)(void);
/* Most functions in browser.c. */
/* The two needed functions from browser.c. */
#ifdef ENABLE_BROWSER
char *do_browse_from(const char *inpath);
void read_the_list(const char *path, DIR *dir);
functionptrtype parse_browser_input(int *kbinput);
void browser_refresh(void);
void browser_select_dirname(const char *needle);
void do_filesearch(bool forwards);
void do_fileresearch(bool forwards);
char *browse_in(const char *inpath);
void to_first_file(void);
void to_last_file(void);
char *strip_last_component(const char *path);
#endif
/* Most functions in chars.c. */
@@ -203,51 +199,44 @@ char *strip_last_component(const char *path);
void utf8_init(void);
bool using_utf8(void);
#endif
char *addstrings(char* str1, size_t len1, char* str2, size_t len2);
bool is_byte(int c);
bool is_alpha_mbchar(const char *c);
bool is_blank_mbchar(const char *c);
bool is_ascii_cntrl_char(int c);
bool is_cntrl_mbchar(const char *c);
bool is_word_mbchar(const char *c, bool allow_punct);
bool is_alpha_char(const char *c);
bool is_blank_char(const char *c);
bool is_cntrl_char(const char *c);
bool is_word_char(const char *c, bool allow_punct);
char control_mbrep(const char *c, bool isdata);
#ifdef ENABLE_UTF8
int mbwidth(const char *c);
int mbtowide(wchar_t *wc, const char *c);
bool is_doublewidth(const char *ch);
bool is_zerowidth(const char *ch);
#endif
char *make_mbchar(long chr, int *chr_mb_len);
int char_length(const char *pointer);
size_t mbstrlen(const char *s);
int collect_char(const char *buf, char *chr);
size_t mbstrlen(const char *pointer);
int collect_char(const char *string, char *thechar);
int advance_over(const char *string, size_t *column);
size_t step_left(const char *buf, size_t pos);
size_t step_right(const char *buf, size_t pos);
int mbstrcasecmp(const char *s1, const char *s2);
int mbstrncasecmp(const char *s1, const char *s2, size_t n);
char *mbstrcasestr(const char *haystack, const char *needle);
char *revstrstr(const char *haystack, const char *needle, const char *index);
char *mbrevstrcasestr(const char *haystack, const char *needle, const char *index);
char *revstrstr(const char *haystack, const char *needle, const char *pointer);
char *mbrevstrcasestr(const char *haystack, const char *needle, const char *pointer);
#if !defined(NANO_TINY) || defined(ENABLE_JUSTIFY)
char *mbstrchr(const char *s, const char *c);
char *mbstrchr(const char *string, const char *chr);
#endif
#ifndef NANO_TINY
char *mbstrpbrk(const char *s, const char *accept);
char *revstrpbrk(const char *head, const char *accept, const char *index);
char *mbrevstrpbrk(const char *head, const char *accept, const char *index);
char *mbstrpbrk(const char *string, const char *accept);
char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer);
#endif
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || defined(ENABLE_JUSTIFY))
bool has_blank_char(const char *s);
#endif
bool white_string(const char *s);
#ifdef ENABLE_UTF8
bool is_valid_unicode(wchar_t wc);
bool has_blank_char(const char *string);
#endif
bool white_string(const char *string);
/* Most functions in color.c. */
#ifdef ENABLE_COLOR
void set_colorpairs(void);
void color_init(void);
void color_update(void);
void set_up_multicache(linestruct *line);
void set_interface_colorpairs(void);
void prepare_palette(void);
void find_and_prime_applicable_syntax(void);
void check_the_multis(linestruct *line);
void precalc_multicolorinfo(void);
#endif
@@ -259,33 +248,28 @@ void do_backspace(void);
void chop_previous_word(void);
void chop_next_word(void);
#endif
void extract_segment(linestruct *top, size_t top_x,
linestruct *bot, size_t bot_x);
void ingraft_buffer(linestruct *somebuffer);
void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_x);
void ingraft_buffer(linestruct *topline);
void copy_from_buffer(linestruct *somebuffer);
#ifndef NANO_TINY
void cut_marked(bool *right_side_up);
void cut_marked_region(void);
#endif
void do_snip(bool copying, bool marked, bool until_eof, bool append);
bool is_cuttable(bool test_cliff);
void do_snip(bool marked, bool until_eof, bool append);
void cut_text(void);
#ifndef NANO_TINY
void copy_text(void);
void cut_till_eof(void);
void zap_text(void);
void copy_marked_region(void);
void copy_text(void);
#endif
void paste_text(void);
/* Most functions in files.c. */
void make_new_buffer(void);
#ifndef NANO_TINY
int delete_lockfile(const char *lockfilename);
#endif
bool open_buffer(const char *filename, bool new_buffer);
#ifdef ENABLE_SPELLER
bool replace_buffer(const char *filename, undo_type action, bool marked,
const char *operation);
bool delete_lockfile(const char *lockfilename);
#endif
bool open_buffer(const char *filename, bool new_one);
void set_modified(void);
void prepare_for_display(void);
#ifdef ENABLE_MULTIBUFFER
@@ -295,11 +279,14 @@ void switch_to_next_buffer(void);
void close_buffer(void);
#endif
void read_file(FILE *f, int fd, const char *filename, bool undoable);
int open_file(const char *filename, bool newfie, FILE **f);
int open_file(const char *filename, bool new_one, FILE **f);
char *get_next_filename(const char *name, const char *suffix);
void do_insertfile_void(void);
void do_insertfile(void);
#ifndef NANO_TINY
void do_execute(void);
#endif
char *get_full_path(const char *origpath);
char *safe_tempfile(FILE **f);
char *safe_tempfile(FILE **stream);
#ifdef ENABLE_OPERATINGDIR
void init_operating_dir(void);
bool outside_of_confinement(const char *currpath, bool allow_tabcomp);
@@ -308,54 +295,46 @@ bool outside_of_confinement(const char *currpath, bool allow_tabcomp);
void init_backup_dir(void);
#endif
int copy_file(FILE *inn, FILE *out, bool close_out);
bool write_file(const char *name, FILE *f_open, bool tmp,
kind_of_writing_type method, bool fullbuffer);
bool write_file(const char *name, FILE *thefile, bool normal,
kind_of_writing_type method, bool annotate);
#ifndef NANO_TINY
bool write_marked_file(const char *name, FILE *f_open, bool tmp,
kind_of_writing_type method);
bool write_region_to_file(const char *name, FILE *stream, bool normal,
kind_of_writing_type method);
#endif
int do_writeout(bool exiting, bool withprompt);
void do_writeout_void(void);
int write_it_out(bool exiting, bool withprompt);
void do_writeout(void);
void do_savefile(void);
char *real_dir_from_tilde(const char *buf);
char *real_dir_from_tilde(const char *path);
#if defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
int diralphasort(const void *va, const void *vb);
#endif
#ifdef ENABLE_TABCOMP
char *input_tab(char *buf, bool allow_files, size_t *place,
bool *lastwastab, void (*refresh_func)(void), bool *listed);
char *input_tab(char *buf, size_t *place, void (*refresh_func)(void), bool *listed);
#endif
/* Some functions in global.c. */
const keystruct *first_sc_for(int menu, void (*func)(void));
int the_code_for(void (*func)(void), int defaultval);
size_t shown_entries_for(int menu);
const keystruct *get_shortcut(int *kbinput);
functionptrtype func_from_key(int *kbinput);
const keystruct *get_shortcut(int *keycode);
functionptrtype func_from_key(int *keycode);
#if defined(ENABLE_BROWSER) || defined(ENABLE_HELP)
functionptrtype interpret(int *keycode);
#endif
int keycode_from_string(const char *keystring);
void shortcut_init(void);
const char *flagtostr(int flag);
const char *epithet_of_flag(int flag);
/* All functions in help.c. */
/* Some functions in help.c. */
#ifdef ENABLE_HELP
void wrap_help_text_into_buffer(void);
void help_init(void);
functionptrtype parse_help_input(int *kbinput);
#endif
void do_help(void);
/* Most functions in history.c. */
#ifdef ENABLE_HISTORIES
void history_init(void);
void history_reset(const linestruct *h);
void update_history(linestruct **h, const char *s);
char *get_history_older(linestruct **h);
char *get_history_newer(linestruct **h);
void get_history_older_void(void);
void get_history_newer_void(void);
void reset_history_pointer_for(const linestruct *list);
void update_history(linestruct **item, const char *text, bool avoid_duplicates);
#ifdef ENABLE_TABCOMP
char *get_history_completion(linestruct **h, char *s, size_t len);
#endif
@@ -363,7 +342,7 @@ bool have_statedir(void);
void load_history(void);
void save_history(void);
void load_poshistory(void);
void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos);
void update_poshistory(void);
bool has_old_position(const char *file, ssize_t *line, ssize_t *column);
#endif
@@ -375,15 +354,15 @@ void do_page_down(void);
#ifdef ENABLE_JUSTIFY
void do_para_begin(linestruct **line);
void do_para_end(linestruct **line);
void do_para_begin_void(void);
void do_para_end_void(void);
void to_para_begin(void);
void to_para_end(void);
#endif
void do_prev_block(void);
void do_next_block(void);
void do_prev_word(bool allow_punct);
bool do_next_word(bool after_ends, bool allow_punct);
void do_prev_word_void(void);
void do_next_word_void(void);
void to_prev_block(void);
void to_next_block(void);
void do_prev_word(void);
bool do_next_word(bool after_ends);
void to_prev_word(void);
void to_next_word(void);
void do_home(void);
void do_end(void);
void do_up(void);
@@ -391,6 +370,7 @@ void do_down(void);
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
void do_scroll_up(void);
void do_scroll_down(void);
void do_center(void);
#endif
void do_left(void);
void do_right(void);
@@ -398,41 +378,39 @@ void do_right(void);
/* Most functions in nano.c. */
linestruct *make_new_node(linestruct *prevnode);
void splice_node(linestruct *afterthis, linestruct *newnode);
void unlink_node(linestruct *fileptr);
void delete_node(linestruct *fileptr);
void unlink_node(linestruct *line);
void delete_node(linestruct *line);
linestruct *copy_buffer(const linestruct *src);
void free_lines(linestruct *src);
void renumber_from(linestruct *line);
void partition_buffer(linestruct *top, size_t top_x,
linestruct *bot, size_t bot_x);
void unpartition_buffer(void);
void print_view_warning(void);
bool in_restricted_mode(void);
#ifndef ENABLE_HELP
void say_there_is_no_help(void);
#ifndef NANO_TINY
void suggest_ctrlT_ctrlZ(void);
#endif
void finish(void);
void die(const char *msg, ...);
void emergency_save(const char *die_filename, struct stat *die_stat);
void window_init(void);
void do_exit(void);
void close_and_go(void);
void do_exit(void);
void die(const char *msg, ...);
void window_init(void);
void install_handler_for_Ctrl_C(void);
void restore_handler_for_Ctrl_C(void);
#ifndef NANO_TINY
void reconnect_and_store_state(void);
RETSIGTYPE handle_hupterm(int signal);
#ifndef DEBUG
RETSIGTYPE handle_crash(int signal);
#endif
RETSIGTYPE do_suspend(int signal);
RETSIGTYPE do_continue(int signal);
#if !defined(NANO_TINY) || defined(ENABLE_SPELLER)
void handle_hupterm(int signal);
#ifndef DEBUG
void handle_crash(int signal);
#endif
void suspend_nano(int signal);
void do_suspend(void);
void continue_nano(int signal);
#if !defined(NANO_TINY) || defined(ENABLE_SPELLER) || defined(ENABLE_COLOR)
void block_sigwinch(bool blockit);
#endif
#ifndef NANO_TINY
RETSIGTYPE handle_sigwinch(int signal);
void handle_sigwinch(int signal);
void regenerate_screen(void);
void do_toggle(int flag);
#endif
void disable_kb_interrupt(void);
void enable_kb_interrupt(void);
@@ -444,30 +422,15 @@ void confirm_margin(void);
#endif
void unbound_key(int code);
bool okay_for_view(const keystruct *shortcut);
void inject(char *output, size_t output_len, bool filtering);
void inject(char *burst, size_t count);
/* Most functions in prompt.c. */
void inject_into_answer(int *the_input, size_t input_len, bool filtering);
void do_statusbar_home(void);
void do_statusbar_end(void);
void do_statusbar_left(void);
void do_statusbar_right(void);
void do_statusbar_backspace(void);
void do_statusbar_delete(void);
void do_statusbar_cut_text(void);
void do_statusbar_uncut_text(void);
#ifndef NANO_TINY
void do_statusbar_prev_word(void);
void do_statusbar_next_word(void);
#endif
void do_statusbar_verbatim_input(void);
size_t get_statusbar_page_start(size_t start_col, size_t column);
size_t get_statusbar_page_start(size_t base, size_t column);
void put_cursor_at_end_of_answer(void);
void add_or_remove_pipe_symbol_from_answer(void);
int do_prompt(bool allow_tabs, bool allow_files,
int menu, const char *curranswer, linestruct **history_list,
int do_prompt(int menu, const char *provided, linestruct **history_list,
void (*refresh_func)(void), const char *msg, ...);
int do_yesno_prompt(bool all, const char *msg);
int ask_user(bool withall, const char *question);
/* Most functions in rcfile.c. */
#if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES)
@@ -489,7 +452,6 @@ bool regexp_init(const char *regexp);
void tidy_up_after_search(void);
int findnextstr(const char *needle, bool whole_word_only, int modus,
size_t *match_len, bool skipone, const linestruct *begin, size_t begin_x);
void do_search(void);
void do_search_forward(void);
void do_search_backward(void);
void do_findprevious(void);
@@ -499,13 +461,16 @@ void go_looking(void);
ssize_t do_replace_loop(const char *needle, bool whole_word_only,
const linestruct *real_current, size_t *real_current_x);
void do_replace(void);
void ask_for_replacement(void);
void ask_for_and_do_replacements(void);
void goto_line_posx(ssize_t line, size_t pos_x);
void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
void goto_line_and_column(ssize_t line, ssize_t column, bool retain_answer,
bool interactive);
void do_gotolinecolumn_void(void);
void do_gotolinecolumn(void);
#ifndef NANO_TINY
void do_find_bracket(void);
void put_or_lift_anchor(void);
void to_prev_anchor(void);
void to_next_anchor(void);
#endif
/* Most functions in text.c. */
@@ -524,28 +489,25 @@ void do_undo(void);
void do_redo(void);
void do_enter(void);
#ifndef NANO_TINY
RETSIGTYPE cancel_command(int signal);
bool execute_command(const char *command);
void discard_until(const undostruct *thisitem, openfilestruct *thefile, bool keep);
void discard_until(const undostruct *thisitem);
void add_undo(undo_type action, const char *message);
void update_multiline_undo(ssize_t lineno, char *indentation);
void update_undo(undo_type action);
#endif /* !NANO_TINY */
#ifdef ENABLE_WRAPPING
bool do_wrap(void);
void do_wrap(void);
#endif
#if defined(ENABLE_HELP) || defined(ENABLED_WRAPORJUSTIFY)
ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl);
ssize_t break_line(const char *textstart, ssize_t goal, bool snap_at_nl);
#endif
#if !defined(NANO_TINY) || defined(ENABLED_WRAPORJUSTIFY)
size_t indent_length(const char *line);
#endif
#ifdef ENABLE_JUSTIFY
size_t quote_length(const char *line);
bool begpar(const linestruct *const foo, int depth);
bool inpar(const linestruct *const foo);
void do_justify(bool full_justify);
void do_justify_void(void);
bool begpar(const linestruct *const line, int depth);
bool inpar(const linestruct *const line);
void do_justify(void);
void do_full_justify(void);
#endif
#ifdef ENABLE_SPELLER
@@ -556,7 +518,7 @@ void do_linter(void);
void do_formatter(void);
#endif
#ifndef NANO_TINY
void do_wordlinechar_count(void);
void count_lines_words_and_characters(void);
#endif
void do_verbatim_input(void);
void complete_a_word(void);
@@ -565,13 +527,11 @@ void complete_a_word(void);
void get_homedir(void);
const char *tail(const char *path);
char *concatenate(const char *path, const char *name);
#ifdef ENABLE_LINENUMBERS
int digits(ssize_t n);
#endif
bool parse_num(const char *str, ssize_t *val);
bool parse_num(const char *str, ssize_t *result);
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column);
void unsunder(char *string, size_t length);
void sunder(char *string);
void recode_NUL_to_LF(char *string, size_t length);
void recode_LF_to_NUL(char *string);
#if !defined(ENABLE_TINY) || defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
void free_chararray(char **array, size_t len);
#endif
@@ -582,7 +542,7 @@ const char *strstrwrapper(const char *haystack, const char *needle,
const char *start);
void *nmalloc(size_t howmuch);
void *nrealloc(void *ptr, size_t howmuch);
char *measured_copy(const char *src, size_t n);
char *measured_copy(const char *string, size_t count);
char *mallocstrcpy(char *dest, const char *src);
char *copy_of(const char *string);
char *free_and_assign(char *dest, char *src);
@@ -596,48 +556,47 @@ void new_magicline(void);
void remove_magicline(void);
#endif
#ifndef NANO_TINY
void get_region(const linestruct **top, size_t *top_x,
const linestruct **bot, size_t *bot_x, bool *right_side_up);
void get_range(const linestruct **top, const linestruct **bot);
bool mark_is_before_cursor(void);
void get_region(linestruct **top, size_t *top_x, linestruct **bot, size_t *bot_x);
void get_range(linestruct **top, linestruct **bot);
#endif
size_t get_totsize(const linestruct *begin, const linestruct *end);
size_t number_of_characters_in(const linestruct *begin, const linestruct *end);
#ifndef NANO_TINY
linestruct *line_from_number(ssize_t lineno);
linestruct *line_from_number(ssize_t number);
#endif
/* Most functions in winio.c. */
void record_macro(void);
void run_macro(void);
size_t get_key_buffer_len(void);
size_t waiting_keycodes(void);
#ifdef ENABLE_NANORC
void implant(const char *string);
#endif
int parse_kbinput(WINDOW *win);
int get_input(WINDOW *win);
int get_kbinput(WINDOW *win, bool showcursor);
int get_byte_kbinput(int kbinput);
int get_control_kbinput(int kbinput);
int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len);
int *parse_verbatim_kbinput(WINDOW *win, size_t *count);
char *get_verbatim_kbinput(WINDOW *win, size_t *count);
#ifdef ENABLE_MOUSE
int get_mouseinput(int *mouse_row, int *mouse_col, bool allow_shortcuts);
int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts);
#endif
void blank_edit(void);
void blank_statusbar(void);
void wipe_statusbar(void);
void blank_bottombars(void);
void check_statusblank(void);
void set_blankdelay_to_one(void);
char *display_string(const char *buf, size_t column, size_t span,
bool isdata, bool isprompt);
void titlebar(const char *path);
void minibar(void);
void statusline(message_type importance, const char *msg, ...);
void statusbar(const char *msg);
void warn_and_shortly_pause(const char *msg);
void warn_and_briefly_pause(const char *msg);
void bottombars(int menu);
void post_one_key(const char *keystroke, const char *tag, int width);
void place_the_cursor(void);
int update_line(linestruct *fileptr, size_t index);
int update_line(linestruct *line, size_t index);
#ifndef NANO_TINY
int update_softwrapped_line(linestruct *fileptr);
int update_softwrapped_line(linestruct *line);
#endif
bool line_needs_update(const size_t old_column, const size_t new_column);
int go_back_chunks(int nrows, linestruct **line, size_t *leftedge);
@@ -650,24 +609,20 @@ size_t get_softwrap_breakpoint(const char *text, size_t leftedge,
size_t get_chunk_and_edge(size_t column, linestruct *line, size_t *leftedge);
size_t chunk_for(size_t column, linestruct *line);
size_t leftedge_for(size_t column, linestruct *line);
size_t number_of_chunks_in(linestruct *line);
size_t extra_chunks_in(linestruct *line);
void ensure_firstcolumn_is_aligned(void);
#endif
size_t actual_last_column(size_t leftedge, size_t column);
void edit_redraw(linestruct *old_current, update_type manner);
void edit_refresh(void);
void adjust_viewport(update_type location);
void total_redraw(void);
void total_refresh(void);
void do_cursorpos(bool force);
void do_cursorpos_void(void);
void adjust_viewport(update_type manner);
void full_refresh(void);
void draw_all_subwindows(void);
void report_cursor_position(void);
void spotlight(size_t from_col, size_t to_col);
#ifndef NANO_TINY
void spotlight_softwrapped(size_t from_col, size_t to_col);
#endif
void do_suspend_void(void);
void disable_waiting(void);
void enable_waiting(void);
#ifdef ENABLE_EXTRA
void do_credits(void);
#endif
@@ -676,6 +631,10 @@ void do_credits(void);
void case_sens_void(void);
void regexp_void(void);
void backwards_void(void);
#ifdef ENABLE_HISTORIES
void get_older_item(void);
void get_newer_item(void);
#endif
void flip_replace(void);
void flip_goto(void);
#ifdef ENABLE_BROWSER
@@ -684,12 +643,12 @@ void goto_dir(void);
#endif
#ifndef NANO_TINY
void do_nothing(void);
void do_toggle_void(void);
void dos_format_void(void);
void mac_format_void(void);
void append_void(void);
void prepend_void(void);
void backup_file_void(void);
void do_toggle(void);
void dos_format(void);
void mac_format(void);
void append_it(void);
void prepend_it(void);
void back_it_up(void);
void flip_execute(void);
void flip_pipe(void);
void flip_convert(void);

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* search.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2015-2019 Benno Schulenberg *
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
* Copyright (C) 2015-2020 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -19,9 +19,10 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#include <string.h>
#include <time.h>
static bool came_full_circle = FALSE;
/* Have we reached the starting line again while searching? */
@@ -38,10 +39,10 @@ bool regexp_init(const char *regexp)
/* If regex compilation failed, show the error message. */
if (value != 0) {
size_t len = regerror(value, &search_regexp, NULL, 0);
char *str = charalloc(len);
char *str = nmalloc(len);
regerror(value, &search_regexp, str, len);
statusline(ALERT, _("Bad regex \"%s\": %s"), regexp, str);
statusline(AHEM, _("Bad regex \"%s\": %s"), regexp, str);
free(str);
return FALSE;
@@ -69,23 +70,19 @@ void tidy_up_after_search(void)
/* Prepare the prompt and ask the user what to search for. Keep looping
* as long as the user presses a toggle, and only take action and exit
* when <Enter> is pressed or a non-toggle shortcut was executed. */
void search_init(bool replacing, bool keep_the_answer)
void search_init(bool replacing, bool retain_answer)
{
char *thedefault;
/* What will be searched for when the user typed nothing. */
/* When starting a new search, clear the current answer. */
if (!keep_the_answer)
answer = mallocstrcpy(answer, "");
/* What will be searched for when the user types just <Enter>. */
/* If something was searched for earlier, include it in the prompt. */
if (*last_search != '\0') {
char *disp = display_string(last_search, 0, COLS / 3, FALSE, FALSE);
thedefault = charalloc(strlen(disp) + 7);
thedefault = nmalloc(strlen(disp) + 7);
/* We use (COLS / 3) here because we need to see more on the line. */
sprintf(thedefault, " [%s%s]", disp,
(breadth(last_search) > COLS / 3) ? "..." : "");
(breadth(last_search) > COLS / 3) ? "..." : "");
free(disp);
} else
thedefault = copy_of("");
@@ -93,9 +90,9 @@ void search_init(bool replacing, bool keep_the_answer)
while (TRUE) {
functionptrtype func;
/* Ask the user what to search for (or replace). */
int response = do_prompt(FALSE, FALSE,
int response = do_prompt(
inhelp ? MFINDINHELP : (replacing ? MREPLACE : MWHEREIS),
answer, &search_history, edit_refresh,
retain_answer ? answer : "", &search_history, edit_refresh,
/* TRANSLATORS: This is the main search prompt. */
"%s%s%s%s%s%s", _("Search"),
/* TRANSLATORS: The next four modify the search prompt. */
@@ -121,23 +118,23 @@ void search_init(bool replacing, bool keep_the_answer)
if (*answer != '\0') {
last_search = mallocstrcpy(last_search, answer);
#ifdef ENABLE_HISTORIES
update_history(&search_history, answer);
update_history(&search_history, answer, PRUNE_DUPLICATE);
#endif
}
/* When not doing a regular-expression search, just search;
* otherwise compile the search string, and only search when
* the expression is valid. */
if (!ISSET(USE_REGEXP) || regexp_init(last_search)) {
if (replacing)
ask_for_replacement();
else
go_looking();
}
if (ISSET(USE_REGEXP) && !regexp_init(last_search))
break;
if (replacing)
ask_for_and_do_replacements();
else
go_looking();
break;
}
retain_answer = TRUE;
func = func_from_key(&response);
/* If we're here, one of the five toggles was pressed, or
@@ -155,7 +152,7 @@ void search_init(bool replacing, bool keep_the_answer)
} else
replacing = !replacing;
} else if (func == flip_goto) {
do_gotolinecolumn(openfile->current->lineno,
goto_line_and_column(openfile->current->lineno,
openfile->placewewant + 1, TRUE, TRUE);
break;
} else
@@ -189,35 +186,12 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
/* The time we last looked at the keyboard. */
/* Set non-blocking input so that we can just peek for a Cancel. */
disable_waiting();
nodelay(midwin, TRUE);
if (begin == NULL)
came_full_circle = FALSE;
/* Start searching through the lines, looking for the needle. */
while (TRUE) {
/* Glance at the keyboard once every second. */
if (time(NULL) - lastkbcheck > 0) {
int input = parse_kbinput(edit);
lastkbcheck = time(NULL);
/* Consume all waiting keystrokes until a Cancel. */
while (input != ERR) {
if (func_from_key(&input) == do_cancel) {
statusbar(_("Cancelled"));
enable_waiting();
return -2;
}
input = parse_kbinput(NULL);
}
if (++feedback > 0)
/* TRANSLATORS: This is shown when searching takes
* more than half a second. */
statusbar(_("Searching..."));
}
/* When starting a new search, skip the first character, then
* (in either case) search for the needle in the current line. */
if (skipone) {
@@ -249,33 +223,35 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
break;
}
#ifndef NANO_TINY
if (the_window_resized) {
regenerate_screen();
nodelay(midwin, TRUE);
statusbar(_("Searching..."));
feedback = 1;
}
#endif
/* If we're back at the beginning, then there is no needle. */
if (came_full_circle) {
enable_waiting();
nodelay(midwin, FALSE);
return 0;
}
/* Move to the previous or next line in the file. */
if (ISSET(BACKWARDS_SEARCH))
line = line->prev;
else
line = line->next;
line = (ISSET(BACKWARDS_SEARCH)) ? line->prev : line->next;
/* If we've reached the start or end of the buffer, wrap around;
* but stop when spell-checking or replacing in a region. */
if (line == NULL) {
if (whole_word_only || modus == INREGION) {
enable_waiting();
nodelay(midwin, FALSE);
return 0;
}
if (ISSET(BACKWARDS_SEARCH))
line = openfile->filebot;
else
line = openfile->filetop;
line = (ISSET(BACKWARDS_SEARCH)) ? openfile->filebot : openfile->filetop;
if (modus == JUSTFIND) {
statusbar(_("Search Wrapped"));
statusline(REMARK, _("Search Wrapped"));
/* Delay the "Searching..." message for at least two seconds. */
feedback = -2;
}
@@ -289,11 +265,48 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
from = line->data;
if (ISSET(BACKWARDS_SEARCH))
from += strlen(line->data);
/* Glance at the keyboard once every second, to check for a Cancel. */
if (time(NULL) - lastkbcheck > 0) {
int input = wgetch(midwin);
lastkbcheck = time(NULL);
/* Consume any queued-up keystrokes, until a Cancel or nothing. */
while (input != ERR) {
if (input == ESC_CODE) {
napms(20);
input = wgetch(midwin);
meta_key = TRUE;
} else
meta_key = FALSE;
if (func_from_key(&input) == do_cancel) {
#ifndef NANO_TINY
if (the_window_resized)
regenerate_screen();
#endif
statusbar(_("Cancelled"));
/* Clear out the key buffer (in case a macro is running). */
while (input != ERR)
input = get_input(NULL);
nodelay(midwin, FALSE);
return -2;
}
input = wgetch(midwin);
}
if (++feedback > 0)
/* TRANSLATORS: This is shown when searching takes
* more than half a second. */
statusbar(_("Searching..."));
}
}
found_x = found - line->data;
enable_waiting();
nodelay(midwin, FALSE);
/* Ensure that the found occurrence is not beyond the starting x. */
if (came_full_circle && ((!ISSET(BACKWARDS_SEARCH) && (found_x > begin_x ||
@@ -309,33 +322,33 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
if (match_len != NULL)
*match_len = found_len;
/* Wipe the "Searching..." message and unset the suppression flag. */
if (feedback > 0) {
wipe_statusbar();
suppress_cursorpos = FALSE;
#ifndef NANO_TINY
if (modus == JUSTFIND && (!openfile->mark || openfile->softmark)) {
spotlighted = TRUE;
light_from_col = xplustabs();
light_to_col = wideness(line->data, found_x + found_len);
refresh_needed = TRUE;
}
#endif
if (feedback > 0)
wipe_statusbar();
return 1;
}
/* Ask what to search for and then go looking for it. */
void do_search(void)
{
search_init(FALSE, FALSE);
}
/* Search forward for a string. */
/* Ask for a string and then search forward for it. */
void do_search_forward(void)
{
UNSET(BACKWARDS_SEARCH);
do_search();
search_init(FALSE, FALSE);
}
/* Search backwards for a string. */
/* Ask for a string and then search backwards for it. */
void do_search_backward(void)
{
SET(BACKWARDS_SEARCH);
do_search();
search_init(FALSE, FALSE);
}
/* Search for the last string without prompting. */
@@ -349,7 +362,7 @@ void do_research(void)
#endif
if (*last_search == '\0') {
statusbar(_("No current search pattern"));
statusline(AHEM, _("No current search pattern"));
return;
}
@@ -359,7 +372,8 @@ void do_research(void)
/* Use the search-menu key bindings, to allow cancelling. */
currmenu = MWHEREIS;
wipe_statusbar();
if (LINES > 1)
wipe_statusbar();
go_looking();
@@ -386,7 +400,7 @@ void not_found_msg(const char *str)
char *disp = display_string(str, 0, (COLS / 2) + 1, FALSE, FALSE);
size_t numchars = actual_x(disp, wideness(disp, COLS / 2));
statusline(HUSH, _("\"%.*s%s\" not found"), numchars, disp,
statusline(AHEM, _("\"%.*s%s\" not found"), numchars, disp,
(disp[numchars] == '\0') ? "" : "...");
free(disp);
}
@@ -398,7 +412,7 @@ void go_looking(void)
linestruct *was_current = openfile->current;
size_t was_current_x = openfile->current_x;
//#define TIMEIT 12
//#define TIMEIT 12
#ifdef TIMEIT
#include <time.h>
clock_t start = clock();
@@ -412,13 +426,13 @@ void go_looking(void)
/* If we found something, and we're back at the exact same spot
* where we started searching, then this is the only occurrence. */
if (didfind == 1 && openfile->current == was_current &&
openfile->current_x == was_current_x)
statusbar(_("This is the only occurrence"));
openfile->current_x == was_current_x)
statusline(REMARK, _("This is the only occurrence"));
else if (didfind == 0)
not_found_msg(last_search);
#ifdef TIMEIT
statusline(HUSH, "Took: %.2f", (double)(clock() - start) / CLOCKS_PER_SEC);
statusline(INFO, "Took: %.2f", (double)(clock() - start) / CLOCKS_PER_SEC);
#endif
edit_redraw(was_current, CENTERING);
@@ -454,8 +468,7 @@ int replace_regexp(char *string, bool create)
/* And if create is TRUE, append the result of the
* subexpression match to the new line. */
if (create) {
strncpy(string, openfile->current->data +
regmatches[num].rm_so, i);
strncpy(string, openfile->current->data + regmatches[num].rm_so, i);
string += i;
}
}
@@ -483,7 +496,7 @@ char *replace_line(const char *needle)
new_size += strlen(answer) - match_len;
}
copy = charalloc(new_size);
copy = nmalloc(new_size);
/* Copy the head of the original line. */
strncpy(copy, openfile->current->data, openfile->current_x);
@@ -518,14 +531,11 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
linestruct *was_mark = openfile->mark;
linestruct *top, *bot;
size_t top_x, bot_x;
bool right_side_up = FALSE;
/* TRUE if (mark_begin, mark_begin_x) is the top of the mark,
* FALSE if (current, current_x) is. */
bool right_side_up = (openfile->mark && mark_is_before_cursor());
/* If the mark is on, frame the region, and turn the mark off. */
if (openfile->mark) {
get_region((const linestruct **)&top, &top_x,
(const linestruct **)&bot, &bot_x, &right_side_up);
get_region(&top, &top_x, &bot, &bot_x);
openfile->mark = NULL;
modus = INREGION;
@@ -538,12 +548,12 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
openfile->current_x = bot_x;
}
}
#endif /* !NANO_TINY */
#endif
came_full_circle = FALSE;
while (TRUE) {
int choice = 0;
int choice = NO;
int result = findnextstr(needle, whole_word_only, modus,
&match_len, skipone, real_current, *real_current_x);
@@ -579,32 +589,31 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
edit_refresh();
/* TRANSLATORS: This is a prompt. */
choice = do_yesno_prompt(TRUE, _("Replace this instance?"));
choice = ask_user(YESORALLORNO, _("Replace this instance?"));
spotlighted = FALSE;
if (choice == -1) /* The replacing was cancelled. */
if (choice == CANCEL)
break;
else if (choice == 2)
replaceall = TRUE;
replaceall = (choice == ALL);
/* When "No" or moving backwards, the search routine should
* first move one character further before continuing. */
skipone = (choice == 0 || ISSET(BACKWARDS_SEARCH));
}
if (choice == 1 || replaceall) { /* Yes, replace it. */
char *copy;
if (choice == YES || replaceall) {
size_t length_change;
char *altered;
altered = replace_line(needle);
length_change = strlen(altered) - strlen(openfile->current->data);
#ifndef NANO_TINY
add_undo(REPLACE, NULL);
#endif
copy = replace_line(needle);
length_change = strlen(copy) - strlen(openfile->current->data);
#ifndef NANO_TINY
/* If the mark was on and it was located after the cursor,
* then adjust its x position for any text length changes. */
if (was_mark && !right_side_up) {
@@ -620,8 +629,9 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
/* If the mark was not on or it was before the cursor, then
* adjust the cursor's x position for any text length changes. */
if (!was_mark || right_side_up) {
if (!was_mark || right_side_up)
#endif
{
if (openfile->current == real_current &&
openfile->current_x < *real_current_x) {
if (*real_current_x < openfile->current_x + match_len)
@@ -629,8 +639,8 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
*real_current_x += length_change;
#ifndef NANO_TINY
bot_x = *real_current_x;
}
#endif
}
}
/* Don't find the same zero-length or BOL match again. */
@@ -643,20 +653,9 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
openfile->current_x += match_len + length_change;
/* Update the file size, and put the changed line into place. */
openfile->totsize += mbstrlen(copy) - mbstrlen(openfile->current->data);
openfile->totsize += mbstrlen(altered) - mbstrlen(openfile->current->data);
free(openfile->current->data);
openfile->current->data = copy;
if (!replaceall) {
#ifdef ENABLE_COLOR
/* When doing syntax coloring, the replacement might require
* a change of colors, so refresh the whole edit window. */
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX))
edit_refresh();
else
#endif
update_line(openfile->current, openfile->current_x);
}
openfile->current->data = altered;
set_modified();
as_an_at = TRUE;
@@ -666,10 +665,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
if (numreplaced == -1)
not_found_msg(needle);
#ifdef ENABLE_COLOR
else if (numreplaced > 0)
refresh_needed = TRUE;
#endif
#ifndef NANO_TINY
openfile->mark = was_mark;
#endif
@@ -693,20 +689,22 @@ void do_replace(void)
}
}
/* Ask the user what the already given search string should be replaced with. */
void ask_for_replacement(void)
/* Ask the user what to replace the search string with, and do the replacements. */
void ask_for_and_do_replacements(void)
{
linestruct *edittop_save, *begin;
size_t firstcolumn_save, begin_x;
linestruct *was_edittop = openfile->edittop;
size_t was_firstcolumn = openfile->firstcolumn;
linestruct *beginline = openfile->current;
size_t begin_x = openfile->current_x;
ssize_t numreplaced;
int response = do_prompt(FALSE, FALSE, MREPLACEWITH, "",
/* TRANSLATORS: This is a prompt. */
&replace_history, edit_refresh, _("Replace with"));
int response = do_prompt(MREPLACEWITH, "", &replace_history,
/* TRANSLATORS: This is a prompt. */
edit_refresh, _("Replace with"));
#ifdef ENABLE_HISTORIES
/* If the replace string is not "", add it to the replace history list. */
/* When not "", add the replace string to the replace history list. */
if (response == 0)
update_history(&replace_history, answer);
update_history(&replace_history, answer, PRUNE_DUPLICATE);
#endif
/* When cancelled, or when a function was run, get out. */
@@ -716,24 +714,19 @@ void ask_for_replacement(void)
} else if (response > 0)
return;
/* Save where we are. */
edittop_save = openfile->edittop;
firstcolumn_save = openfile->firstcolumn;
begin = openfile->current;
begin_x = openfile->current_x;
numreplaced = do_replace_loop(last_search, FALSE, begin, &begin_x);
numreplaced = do_replace_loop(last_search, FALSE, beginline, &begin_x);
/* Restore where we were. */
openfile->edittop = edittop_save;
openfile->firstcolumn = firstcolumn_save;
openfile->current = begin;
openfile->edittop = was_edittop;
openfile->firstcolumn = was_firstcolumn;
openfile->current = beginline;
openfile->current_x = begin_x;
refresh_needed = TRUE;
if (numreplaced >= 0)
statusline(HUSH, P_("Replaced %zd occurrence",
"Replaced %zd occurrences", numreplaced), numreplaced);
statusline(REMARK, P_("Replaced %zd occurrence",
"Replaced %zd occurrences", numreplaced), numreplaced);
}
/* Go to the specified line and x position. */
@@ -752,15 +745,14 @@ void goto_line_posx(ssize_t line, size_t pos_x)
/* Go to the specified line and column, or ask for them if interactive
* is TRUE. In the latter case also update the screen afterwards.
* Note that both the line and column number should be one-based. */
void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
bool interactive)
void goto_line_and_column(ssize_t line, ssize_t column, bool retain_answer,
bool interactive)
{
if (interactive) {
/* Ask for the line and column. */
int response = do_prompt(FALSE, FALSE, MGOTOLINE,
use_answer ? answer : "", NULL, edit_refresh,
int response = do_prompt(MGOTOLINE, retain_answer ? answer : "", NULL,
/* TRANSLATORS: This is a prompt. */
_("Enter line number, column number"));
edit_refresh, _("Enter line number, column number"));
/* If the user cancelled or gave a blank answer, get out. */
if (response < 0) {
@@ -770,7 +762,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
if (func_from_key(&response) == flip_goto) {
UNSET(BACKWARDS_SEARCH);
/* Retain what the user typed so far and switch to searching. */
/* Switch to searching but retain what the user typed so far. */
search_init(FALSE, TRUE);
return;
}
@@ -781,7 +773,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
/* Try to extract one or two numbers from the user's response. */
if (!parse_line_column(answer, &line, &column)) {
statusline(ALERT, _("Invalid line or column number"));
statusline(AHEM, _("Invalid line or column number"));
return;
}
} else {
@@ -850,9 +842,9 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
}
/* Go to the specified line and column, asking for them beforehand. */
void do_gotolinecolumn_void(void)
void do_gotolinecolumn(void)
{
do_gotolinecolumn(openfile->current->lineno,
goto_line_and_column(openfile->current->lineno,
openfile->placewewant + 1, FALSE, TRUE);
}
@@ -865,8 +857,8 @@ bool find_a_bracket(bool reverse, const char *bracket_pair)
linestruct *line = openfile->current;
const char *pointer, *found;
/* Step away from the current bracket, either backwards or forwards. */
if (reverse) {
/* First step away from the current bracket. */
if (openfile->current_x == 0) {
line = line->prev;
if (line == NULL)
@@ -874,31 +866,23 @@ bool find_a_bracket(bool reverse, const char *bracket_pair)
pointer = line->data + strlen(line->data);
} else
pointer = line->data + step_left(line->data, openfile->current_x);
} else
/* Now seek for any of the two brackets we are interested in. */
while (!(found = mbrevstrpbrk(line->data, bracket_pair, pointer))) {
line = line->prev;
if (line == NULL)
return FALSE;
pointer = line->data + strlen(line->data);
}
} else {
pointer = line->data + step_right(line->data, openfile->current_x);
/* Now seek for any of the two brackets, either backwards or forwards. */
while (TRUE) {
if (reverse)
found = mbrevstrpbrk(line->data, bracket_pair, pointer);
else
found = mbstrpbrk(pointer, bracket_pair);
if (found)
break;
if (reverse)
line = line->prev;
else
while (!(found = mbstrpbrk(pointer, bracket_pair))) {
line = line->next;
/* If we've reached the start or end of the buffer, get out. */
if (line == NULL)
return FALSE;
pointer = line->data;
if (reverse)
pointer += strlen(line->data);
if (line == NULL)
return FALSE;
pointer = line->data;
}
}
/* Set the current position to the found bracket. */
@@ -937,7 +921,7 @@ void do_find_bracket(void)
ch = mbstrchr(matchbrackets, openfile->current->data + openfile->current_x);
if (ch == NULL) {
statusbar(_("Not a bracket"));
statusline(AHEM, _("Not a bracket"));
return;
}
@@ -980,10 +964,61 @@ void do_find_bracket(void)
}
}
statusbar(_("No matching bracket"));
statusline(AHEM, _("No matching bracket"));
/* Restore the cursor position. */
openfile->current = was_current;
openfile->current_x = was_current_x;
}
/* Place an anchor at the current line when none exists, otherwise remove it. */
void put_or_lift_anchor(void)
{
openfile->current->has_anchor = !openfile->current->has_anchor;
update_line(openfile->current, openfile->current_x);
if (openfile->current->has_anchor)
statusline(REMARK, _("Placed anchor"));
else
statusline(REMARK, _("Removed anchor"));
}
/* Make the given line the current line, or report the anchoredness. */
void go_to_and_confirm(linestruct *line)
{
linestruct *was_current = openfile->current;
if (line != openfile->current) {
openfile->current = line;
openfile->current_x = 0;
edit_redraw(was_current, CENTERING);
statusbar(_("Jumped to anchor"));
} else if (openfile->current->has_anchor)
statusline(REMARK, _("This is the only anchor"));
else
statusline(AHEM, _("There are no anchors"));
}
/* Jump to the first anchor before the current line; wrap around at the top. */
void to_prev_anchor(void)
{
linestruct *line = openfile->current;
do { line = (line->prev) ? line->prev : openfile->filebot;
} while (!line->has_anchor && line != openfile->current);
go_to_and_confirm(line);
}
/* Jump to the first anchor after the current line; wrap around at the bottom. */
void to_next_anchor(void)
{
linestruct *line = openfile->current;
do { line = (line->next) ? line->next : openfile->filetop;
} while (!line->has_anchor && line != openfile->current);
go_to_and_confirm(line);
}
#endif /* !NANO_TINY */

2122
src/text.c

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* utils.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
* Copyright (C) 2016, 2017, 2019 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -19,7 +19,7 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#include <errno.h>
#ifdef HAVE_PWD_H
@@ -38,7 +38,7 @@ void get_homedir(void)
#ifdef HAVE_PWD_H
/* When HOME isn't set, or when we're root, get the home directory
* from the password file instead. */
if (homenv == NULL || geteuid() == 0) {
if (homenv == NULL || geteuid() == ROOT_UID) {
const struct passwd *userage = getpwuid(geteuid());
if (userage != NULL)
@@ -61,14 +61,14 @@ const char *tail(const char *path)
if (slash == NULL)
return path;
else
return ++slash;
return slash + 1;
}
/* Return a copy of the two given strings, welded together. */
char *concatenate(const char *path, const char *name)
{
size_t pathlen = strlen(path);
char *joined = charalloc(pathlen + strlen(name) + 1);
char *joined = nmalloc(pathlen + strlen(name) + 1);
strcpy(joined, path);
strcpy(joined + pathlen, name);
@@ -76,7 +76,6 @@ char *concatenate(const char *path, const char *name)
return joined;
}
#ifdef ENABLE_LINENUMBERS
/* Return the number of digits that the given integer n takes up. */
int digits(ssize_t n)
{
@@ -106,21 +105,20 @@ int digits(ssize_t n)
}
}
}
#endif
/* Read an integer from str. If it parses okay, store it in *result
* and return TRUE; otherwise, return FALSE. */
bool parse_num(const char *str, ssize_t *result)
/* Read an integer from the given string. If it parses okay,
* store it in *result and return TRUE; otherwise, return FALSE. */
bool parse_num(const char *string, ssize_t *result)
{
char *first_error;
ssize_t value;
char *excess;
/* The manual page for strtol() says this is required. */
/* Clear the error number so that we can check it afterward. */
errno = 0;
value = (ssize_t)strtol(str, &first_error, 10);
value = (ssize_t)strtol(string, &excess, 10);
if (errno == ERANGE || *str == '\0' || *first_error != '\0')
if (errno == ERANGE || *string == '\0' || *excess != '\0')
return FALSE;
*result = value;
@@ -160,7 +158,7 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
}
/* In the given string, recode each embedded NUL as a newline. */
void unsunder(char *string, size_t length)
void recode_NUL_to_LF(char *string, size_t length)
{
while (length > 0) {
if (*string == '\0')
@@ -171,7 +169,7 @@ void unsunder(char *string, size_t length)
}
/* In the given string, recode each embedded newline as a NUL. */
void sunder(char *string)
void recode_LF_to_NUL(char *string)
{
while (*string != '\0') {
if (*string == '\n')
@@ -195,22 +193,18 @@ void free_chararray(char **array, size_t len)
#endif
#ifdef ENABLE_SPELLER
/* Is the word starting at the given position in buf and of the given length
* a separate word? That is: is it not part of a longer word?*/
bool is_separate_word(size_t position, size_t length, const char *buf)
/* Is the word starting at the given position in 'text' and of the given
* length a separate word? That is: is it not part of a longer word? */
bool is_separate_word(size_t position, size_t length, const char *text)
{
char before[MAXCHARLEN], after[MAXCHARLEN];
size_t word_end = position + length;
/* Get the characters before and after the word, if any. */
collect_char(buf + step_left(buf, position), before);
collect_char(buf + word_end, after);
const char *before = text + step_left(text, position);
const char *after = text + position + length;
/* If the word starts at the beginning of the line OR the character before
* the word isn't a letter, and if the word ends at the end of the line OR
* the character after the word isn't a letter, we have a whole word. */
return ((position == 0 || !is_alpha_mbchar(before)) &&
(buf[word_end] == '\0' || !is_alpha_mbchar(after)));
return ((position == 0 || !is_alpha_char(before)) &&
(*after == '\0' || !is_alpha_char(after)));
}
#endif /* ENABLE_SPELLER */
@@ -288,28 +282,26 @@ const char *strstrwrapper(const char *haystack, const char *needle,
return mbstrcasestr(start, needle);
}
/* This is a wrapper for the malloc() function that properly handles
* things when we run out of memory. */
/* Allocate the given amount of memory and return a pointer to it. */
void *nmalloc(size_t howmuch)
{
void *r = malloc(howmuch);
void *section = malloc(howmuch);
if (r == NULL && howmuch != 0)
if (section == NULL)
die(_("Nano is out of memory!\n"));
return r;
return section;
}
/* This is a wrapper for the realloc() function that properly handles
* things when we run out of memory. */
void *nrealloc(void *ptr, size_t howmuch)
/* Reallocate the given section of memory to have the given size. */
void *nrealloc(void *section, size_t howmuch)
{
void *r = realloc(ptr, howmuch);
section = realloc(section, howmuch);
if (r == NULL && howmuch != 0)
if (section == NULL)
die(_("Nano is out of memory!\n"));
return r;
return section;
}
/* Return an appropriately reallocated dest string holding a copy of src.
@@ -318,18 +310,20 @@ char *mallocstrcpy(char *dest, const char *src)
{
size_t count = strlen(src) + 1;
dest = charealloc(dest, count);
dest = nrealloc(dest, count);
strncpy(dest, src, count);
return dest;
}
/* Return an allocated copy of the first count characters of the given string. */
/* Return an allocated copy of the first count characters
* of the given string, and NUL-terminate the copy. */
char *measured_copy(const char *string, size_t count)
{
char *thecopy = charalloc(count);
char *thecopy = nmalloc(count + 1);
strncpy(thecopy, string, count);
memcpy(thecopy, string, count);
thecopy[count] = '\0';
return thecopy;
}
@@ -337,7 +331,7 @@ char *measured_copy(const char *string, size_t count)
/* Return an allocated copy of the given string. */
char *copy_of(const char *string)
{
return measured_copy(string, strlen(string) + 1);
return measured_copy(string, strlen(string));
}
/* Free the string at dest and return the string at src. */
@@ -347,14 +341,12 @@ char *free_and_assign(char *dest, char *src)
return src;
}
/* When not in softwrap mode, nano scrolls horizontally within a line in
* chunks (a bit smaller than the chunks used in softwrapping). Return the
* column number of the first character displayed in the edit window when the
* cursor is at the given column. Note that (0 <= column -
* get_page_start(column) < COLS). */
/* When not softwrapping, nano scrolls the current line horizontally by
* chunks ("pages"). Return the column number of the first character
* displayed in the edit window when the cursor is at the given column. */
size_t get_page_start(size_t column)
{
if (column + 2 < editwincols || ISSET(SOFTWRAP) || column == 0)
if (column == 0 || column + 2 < editwincols || ISSET(SOFTWRAP))
return 0;
else if (editwincols > 8)
return column - 6 - (column - 6) % (editwincols - 8);
@@ -448,35 +440,35 @@ void remove_magicline(void)
#endif
#ifndef NANO_TINY
/* Return in (top, top_x) and (bot, bot_x) the start and end "coordinates"
* of the marked region. If right_side_up isn't NULL, set it to TRUE when
* the mark is at the top of the marked region, and to FALSE otherwise. */
void get_region(const linestruct **top, size_t *top_x,
const linestruct **bot, size_t *bot_x, bool *right_side_up)
/* Return TRUE when the mark is before or at the cursor, and FALSE otherwise. */
bool mark_is_before_cursor(void)
{
if (openfile->mark->lineno < openfile->current->lineno ||
(openfile->mark == openfile->current &&
openfile->mark_x < openfile->current_x)) {
return (openfile->mark->lineno < openfile->current->lineno ||
(openfile->mark == openfile->current &&
openfile->mark_x <= openfile->current_x));
}
/* Return in (top, top_x) and (bot, bot_x) the start and end "coordinates"
* of the marked region. */
void get_region(linestruct **top, size_t *top_x, linestruct **bot, size_t *bot_x)
{
if (mark_is_before_cursor()) {
*top = openfile->mark;
*top_x = openfile->mark_x;
*bot = openfile->current;
*bot_x = openfile->current_x;
if (right_side_up != NULL)
*right_side_up = TRUE;
} else {
*bot = openfile->mark;
*bot_x = openfile->mark_x;
*top = openfile->current;
*top_x = openfile->current_x;
if (right_side_up != NULL)
*right_side_up = FALSE;
}
}
/* Get the set of lines to work on -- either just the current line, or the
* first to last lines of the marked region. When the cursor (or mark) is
* at the start of the last line of the region, exclude that line. */
void get_range(const linestruct **top, const linestruct **bot)
void get_range(linestruct **top, linestruct **bot)
{
if (!openfile->mark) {
*top = openfile->current;
@@ -484,7 +476,7 @@ void get_range(const linestruct **top, const linestruct **bot)
} else {
size_t top_x, bot_x;
get_region(top, &top_x, bot, &bot_x, NULL);
get_region(top, &top_x, bot, &bot_x);
if (bot_x == 0 && *bot != *top && !also_the_last)
*bot = (*bot)->prev;
@@ -510,19 +502,15 @@ linestruct *line_from_number(ssize_t number)
#endif /* !NANO_TINY */
/* Count the number of characters from begin to end, and return it. */
size_t get_totsize(const linestruct *begin, const linestruct *end)
size_t number_of_characters_in(const linestruct *begin, const linestruct *end)
{
const linestruct *line;
size_t totsize = 0;
size_t count = 0;
/* Sum the number of characters (plus a newline) in each line. */
for (line = begin; line != end->next; line = line->next)
totsize += mbstrlen(line->data) + 1;
count += mbstrlen(line->data) + 1;
/* The last line of a file doesn't have a newline -- otherwise it
* wouldn't be the last line -- so subtract 1 when at EOF. */
if (line == NULL)
totsize--;
return totsize;
/* Do not count the final newline. */
return (count - 1);
}

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
## Here is an example for awk.
## Syntax highlighting for AWK scripts.
syntax awk "\.awk$"
header "^#!.*awk"
@@ -14,7 +14,7 @@ color red "\<(PROCINFO|RS|RT|RSTART|RLENGTH|SUBSEP|TEXTDOMAIN)\>"
# Function declarations and special patterns.
color brightgreen "\<(function|extension|BEGIN|END)\>"
# Operators.
color green "(\{|\}|\(|\)|\;|\]|\[|\\|<|>|!|=|&|\+|-|\*|%|/|\?:|\^|\|)"
color green "\{|\}|\(|\)|\;|\[|\]|\\|<|>|!|=|&|\+|-|\*|%|/|\?:|\^|\|"
# Flow control.
color brightyellow "\<(for|if|while|do|else|in|delete|exit)\>"
color brightyellow "\<(break|continue|return)\>"
@@ -29,9 +29,9 @@ color magenta "\<(and|compl|lshift|or|rshift|xor)\>"
color magenta "\<(bindtextdomain|dcgettext|dcngettext)\>"
# Strings.
color brightyellow "<[^= ]*>" ""(\\.|[^"])*""
color brightyellow ""([^"\]|\\.)*""
# Comments.
color brightblue "(^|[[:space:]])#.*$"
color brightblue "(^|[[:blank:]])#.*"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -1,36 +1,39 @@
## Here is an example for C/C++.
## Syntax highlighting for C and C++ files.
syntax c "\.([ch](pp|xx)?|C|cc|c\+\+|cu|H|hh|ii?)$"
header "-\*-.*\<C(\+\+)?((;|\s).*)?-\*-"
header "-\*-.*\<C(\+\+)?((;|[[:blank:]]).*)?-\*-"
magic "^(C|C\+\+) (source|program)"
comment "//"
# Constants.
color brightred "\<[A-Z_][0-9A-Z_]+\>"
color brightred "\<[A-Z_][0-9A-Z_]*\>"
# Labels.
color brightmagenta "^[[:space:]]*[A-Z_a-z]+:[[:space:]]*$"
color brightmagenta "^[[:blank:]]*[A-Z_a-z][0-9A-Z_a-z]*:[[:blank:]]*$"
color normal ":[[:blank:]]*$"
color green "\<(float|double|bool|char|int|short|long|sizeof|enum|void|auto|static|const|struct|union|typedef|extern|(un)?signed|inline)\>"
# Types and related keywords.
color green "\<(auto|bool|char|const|double|enum|extern|float|inline|int|long|restrict|short|signed|sizeof|static|struct|typedef|union|unsigned|void)\>"
color green "\<([[:lower:]][[:lower:]_]*|(u_?)?int(8|16|32|64))_t\>"
color green "\<(class|namespace|template|public|protected|private|typename|this|friend|virtual|override|using|mutable|volatile|register|explicit)\>"
color brightyellow "\<(for|if|while|do|else|case|default|switch)\>"
color green "\<(_(Alignas|Alignof|Atomic|Bool|Complex|Generic|Imaginary|Noreturn|Static_assert|Thread_local))\>"
color green "\<(class|explicit|friend|mutable|namespace|override|private|protected|public|register|template|this|typename|using|virtual|volatile)\>"
# Flow control.
color brightyellow "\<(if|else|for|while|do|switch|case|default)\>"
color brightyellow "\<(try|throw|catch|operator|new|delete)\>"
color magenta "\<(goto|continue|break|return)\>"
color brightmagenta "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
color magenta "\<(break|continue|goto|return)\>"
# Single-quoted stuff (characters, backslash escapes, hex and octal byte codes).
color brightmagenta "'([^'\]|\\(["'\abfnrtv]|x[[:xdigit:]]{1,2}|[0-3]?[0-7]{1,2}))'"
# GCC builtins.
color cyan "__attribute__[[:space:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
color cyan "__attribute__[[:blank:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
# Strings. In general you will want your strings and comments to come last,
# because highlighting rules are applied in the order they are read in.
color brightyellow ""([^"]|\\")*"" "#[[:space:]]*include[[:space:]]+<[^[:blank:]=]*>"
# Multiline strings. This regex is VERY resource intensive,
# and sometimes colours things that shouldn't be coloured.
###color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
# Strings and names of included files.
color brightyellow ""([^"]|\\")*"" "#[[:blank:]]*include[[:blank:]]*<[^>]+>"
# Preprocessor directives.
color brightcyan start="^[[:space:]]*#[[:space:]]*(if(n?def)?|elif|warning|error|pragma)\>" end="(\`|[^\\])$"
color brightcyan "^[[:space:]]*#[[:space:]]*(define|else|endif|include(_next)?|undef)\>"
color brightcyan start="^[[:blank:]]*#[[:blank:]]*(if(n?def)?|elif|warning|error|pragma)\>" end="(\`|[^\])$"
color brightcyan "^[[:blank:]]*#[[:blank:]]*((define|else|endif|include(_next)?|line|undef)\>|$)"
# Comments.
color brightblue "//.*"

View File

@@ -1,4 +1,7 @@
## Colouring for Changelogs.
## Syntax highlighting for Changelogs.
## Original author: Benno Schulenberg
## License: GPL version 3 or newer
syntax changelog "Change[Ll]og[^/]*$"
@@ -10,13 +13,13 @@ color red "^(19|20)[0-9-]{8}"
color yellow "<[^>]*@[^>]*>"
# Command-line options.
color cyan "[[:space:]]-[a-zA-Z\$]" "--[8a-z-]+"
color cyan "[[:blank:]]-[a-zA-Z\$]|--[8a-z-]+"
# Bug and patch numbers.
color cyan "(BZ|bug|patch) #[0-9]+" "PR [[:alnum:]]+/[0-9]+"
color cyan "(BZ|bug|patch)[ ]#[0-9]+|PR [[:alnum:]]+/[0-9]+"
# Probable constants, for variety.
color brightred "\<[A-Z_][0-9A-Z_]+\>"
# Key sequences.
color brightblue "\^[A-Z^\]" "\<M-." "\<F1?[0-9]" "(\^|M-)Space"
color brightblue "\^[A-Z^\]|\<M-.|\<F1?[0-9]|(\^|M-)Space"
# Changed files.
color magenta start="^( | {8})\* " end="(:( |$)|^$)"

View File

@@ -3,17 +3,20 @@
syntax cmake "(CMakeLists\.txt|\.cmake)$"
comment "#"
color green "^[[:space:]]*[0-9A-Za-z_]+"
icolor brightyellow "^[[:space:]]*(include|include_directories|include_external_msproject)\>"
color green "^[[:blank:]]*[0-9A-Za-z_]+"
icolor brightyellow "^[[:blank:]]*(include|include_directories|include_external_msproject)\>"
icolor brightgreen "^[[:space:]]*((else|end)?if|else|(end)?while|(end)?foreach|break)\>"
color brightgreen "\<(NOT|COMMAND|POLICY|TARGET|EXISTS|IS_(DIRECTORY|ABSOLUTE)|DEFINED)[[:space:]]"
color brightgreen "[[:space:]](OR|AND|IS_NEWER_THAN|MATCHES|(STR|VERSION_)?(LESS|GREATER|EQUAL))[[:space:]]"
icolor brightgreen "^[[:blank:]]*((else|end)?if|else|(end)?while|(end)?foreach|break)\>"
color brightgreen "\<(NOT|COMMAND|POLICY|TARGET|EXISTS|IS_(DIRECTORY|ABSOLUTE)|DEFINED)[[:blank:]]"
color brightgreen "[[:blank:]](OR|AND|IS_NEWER_THAN|MATCHES|(STR|VERSION_)?(LESS|GREATER|EQUAL))[[:blank:]]"
icolor brightred "^[[:space:]]*((end)?(function|macro)|return)"
icolor brightred "^[[:blank:]]*((end)?(function|macro)|return)"
icolor cyan start="\$(ENV)?\{" end="\}"
color magenta "\<(APPLE|UNIX|WIN32|CYGWIN|BORLAND|MINGW|MSVC(_IDE|60|71|80|90)?)\>"
color brightblue "(^|[[:space:]])#.*"
# Comments.
color brightblue "(^|[[:blank:]])#.*"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -1,11 +1,20 @@
## Here is an example for CSS files.
## Syntax highlighting for CSS files.
syntax css "\.css$"
comment "/*|*/"
color brightred "."
color brightyellow start="\{" end="\}"
color brightwhite start=":" end="([;^\{]|$)"
color brightblue ":active|:focus|:hover|:link|:visited|:link|:after|:before|$"
color brightblue start="\/\*" end="\\*/"
color green ";|:|\{|\}"
# First make everything red:
color brightred "."
# Then everything between braces yellow:
color brightyellow start="\{" end="\}"
# Then everything after a colon white:
color brightwhite start=":" end="([;^{]|$)"
# Pseudo-classes:
color brightcyan ":(active|checked|focus|hover|link|visited|after|before)\>"
# Comments:
color brightblue start="/\*" end="\*/"
# Syntactic characters:
color green ";|:|\{|\}"

View File

@@ -1,21 +0,0 @@
## Here is an example for apt's sources.list.
syntax sources.list "sources\.list(\.d/.*\.list)?(~|\.old|\.save)?$"
comment "#"
# Coloring the deb lines, working from tail to head. First the
# components -- well, everything, and thus also the components.
color brightmagenta "^deb.*"
# Distribution -- well, everything, except the components.
color brightred "^deb(-src)?\s+.*((ftp|https?|rsh|ssh|copy|file|spacewalk|tor):/\S+|cdrom:\[.+\]/)\s+\S+"
# URIs.
color brightgreen "^deb(-src)?\s+.*(ftp|https?|rsh|ssh|copy|file|spacewalk|tor):/\S+"
# CDroms.
color brightgreen "^deb(-src)?\s+.*cdrom:\[.+\]/"
# Options.
color brightcyan "^deb(-src)?\s+\[.+\]\s+"
# And finally the initial deb tag.
color yellow "^deb(-src)?"
# Comments.
color brightblue "#.*"

View File

@@ -1,20 +1,30 @@
## An example of a default syntax. The default syntax is used for
## This is an example of a default syntax. The default syntax is used for
## files that do not match any other syntax.
syntax default
comment "#"
# Comments.
color cyan "^[[:space:]]*#.*"
# Spaces in front of tabs.
color ,red " + +"
# Nano's name, including version.
color brightred "(GNU )?[Nn]ano [1-4]\.[0-9][-.[:alnum:]]*\>"
# Nano's release motto, then name plus version.
color italic,lime "\<[Nn]ano [1-6]\.[0-9][-.[:alnum:]]* "[^"]+""
color brightred "\<(GNU )?[Nn]ano [1-6]\.[0-9][-.[:alnum:]]*\>"
# Dates
color latte "\<[12][0-9]{3}\.(0[1-9]|1[012])\.(0[1-9]|[12][0-9]|3[01])\>"
# Email addresses.
color magenta "<[[:alnum:].%_+-]+@[[:alnum:].-]+\.[[:alpha:]]{2,}>"
# URLs.
color lightblue "\<https?://\S+\.\S+[^[:space:],.)]"
# Bracketed captions in certain config files.
color brightgreen "^\[[^][]+\]$"
# Comments.
color cyan "^[[:blank:]]*#.*"
# Control codes.
color orange "[[:cntrl:]]"

View File

@@ -1,4 +1,4 @@
## Here is an example for Emacs Lisp.
## Syntax highlighting for Emacs Lisp.
syntax elisp "\.el$"
magic "Lisp/Scheme program"
@@ -27,7 +27,7 @@ color brightred "\<(t|nil)\>"
# Keywords
color blue ":(\w|[?-])+"
# Strings
color yellow start="^[[:blank:]]+\"" end="[^\]\""
color yellow ""(\\.|[^"])*""
color yellow start="^[[:blank:]]+"" end="[^\]""
color yellow ""([^"\]|\\.)*""
# Comments
color cyan "(^|[[:space:]]);.*"
color cyan "(^|[[:blank:]]);.*"

17
syntax/email.nanorc Normal file
View File

@@ -0,0 +1,17 @@
## Syntax highlighting for emails.
syntax email "\.eml$"
# Quoted lines.
color green "^>.*"
color cyan "^> ?>.*"
color yellow "^> ?> ?>.*"
# Email addresses.
color brightmagenta "<[^@]+@[^@]+>"
# URLs.
color brightblue "(https?|ftp)://\S+\.\S+[^[:space:].)]"
# Signatures, even quoted ones.
color yellow start="^>* ?-- $" end="^>* ?$"

39
syntax/extra/ada.nanorc Normal file
View File

@@ -0,0 +1,39 @@
## Syntax highlighting for Ada.
## Original author: Andreas K. Foerster
## License: GPL version 3 or newer
## Language reference: http://www.ada-auth.org/standards/12rm/html/RM-TTL.html
syntax ada "\.ad[abcs]$"
comment "--"
# This linter command leaves an ALI file in the working directory.
linter gcc -c -gnatc
# Reserved Words (RM 2.9)
icolor yellow "\<(abort|abs|abstract|accept|access|aliased|all|and|array|at)\>"
icolor yellow "\<(begin|body|case|constant|declare|delay|delta|do)\>"
icolor yellow "\<(else|elsif|end|entry|exception|exit|for|function|generic|goto)\>"
icolor yellow "\<(if|in|interface|is|limited|loop|mod|new|not|null|of|or|others|out|overriding)\>"
icolor yellow "\<(package|pragma|private|procedure|protected|raise|range|record|rem|renames)\>"
icolor yellow "\<(requeue|return|reverse|select|separate|some|subtype|synchronized)\>"
icolor yellow "\<(tagged|task|terminate|then|type|until|use|when|while|with|xor)\>"
# Separators / Operators
color magenta "'|&|\*|\+|\-|\.|\,|\/|:|;|\(|\)|<|>|\||="
# Attributes
color cyan "'[[:alnum:]]+"
# Numbers (RM 2.4)
color green "\<[0-9][0-9A-Fa-f_#.+-]*"
# Characters / Strings
color red "'.'|"[^"]*""
# Comments
color brightblue "--.*"
# Trailing whitespace
color ,blue "[[:space:]]+$"

View File

@@ -1,6 +1,6 @@
## Here is an example for Fortran 90/95.
## Syntax highlighting for Fortran 90/95.
syntax fortran "\.(f|f90|f95)$"
syntax fortran "\.(f|for|f90|f95)$"
comment "!"
color red "\<[0-9]+\>"
@@ -34,7 +34,7 @@ icolor yellow "\<(.or.|repeat|select case|then|where|while)\>"
icolor magenta "\<(continue|cycle|exit|go?to|result|return)\>"
# Strings.
color yellow "<[^= ]*>" ""(\\.|[^"])*""
color yellow ""([^"\]|\\.)*""
# Comments.
color blue "!.*"

View File

@@ -0,0 +1,40 @@
## Syntax highlighting for Haskell files.
## Original author: Alex Taber
## License: GPL version 3
syntax "haskell" "\.hs$"
comment "--"
# Keywords
color red "\<(as|case|of|class|data|default|deriving|do|forall|foreign|hiding|if|then|else|import|infix(l|r)?|instance|let|in|mdo|module|newtype|qualified|type|where)\>"
# Various symbols
color cyan "\||@|!|:|_|~|=|\\|;|\(\)|,|\[|\]|\{|\}"
# Operators
color magenta "==|/=|&&|\|\||<|>|<=|>="
# More symbols
color cyan "->|<-|=>"
color magenta "\.|\$"
# Data constructors
color magenta "\<(True|False|Nothing|Just|Left|Right|LT|EQ|GT)\>"
# Data classes
color magenta "\<(Bounded|Data|Enum|Eq|Floating|Fractional|Functor|Integral|Monad|MonadPlus|Num|Ord|Read|Real|RealFloat|RealFrac|Show|Typeable)\>"
# Special keyword
color brightred "undefined"
# Strings
color yellow ""([^"\]|\\.)*""
# Characters
color brightyellow "'([^'\]|\\.)'"
# Comments
color green "--.*"
color green start="\{-" end="-\}"
# Trailing whitespace
color ,green "[[:space:]]+$"

View File

@@ -1,4 +1,4 @@
## Here is an example for POV-Ray.
## Syntax highlighting for POV-Ray files.
syntax pov "\.(pov|POV|povray|POVRAY)$"
comment "//"
@@ -8,7 +8,7 @@ color brightyellow "\<(sphere|cylinder|translate|matrix|rotate|scale)\>"
color brightyellow "\<(orthographic|location|up|right|direction|clipped_by)\>"
color brightyellow "\<(fog_type|fog_offset|fog_alt|rgb|distance|transform)\>"
color brightred "\<(background|camera|fog|light_source|object|texture)\>"
color green "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)"
color green "\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|"
color brightmagenta "\<(union|group|subgroup)\>"
# Comments.

41
syntax/extra/spec.nanorc Normal file
View File

@@ -0,0 +1,41 @@
## Syntax highlighting for RPM spec files.
syntax spec "\.spec(\.[^/]+)?$"
comment "#"
# Main tags.
color brightblue "\<(Name|Version|Release|Summary|Group|URL|Url|Epoch|Icon|Serial)[[:space:]]*:"
color brightblue "\<(BuildArch(itectures)?|Exclusive(Arch|OS)|Exclude(Arch|OS))[[:space:]]*:"
color brightblue "\<(Provides|Requires(\(.*\))?|Obsoletes|Conflicts|Recommends|Suggests|Supplements|Enhances|PreReq)[[:space:]]*:"
color brightblue "\<(BuildRoot|BuildRequires|BuildConflicts|Prefix|RemovePathPostfixes)[[:space:]]*:"
color brightblue "\<(AutoReq|AutoProv|AutoReqProv)[[:space:]]*:"
color brightblue "\<(License|Copyright|Distribution|Vendor|Packager)[[:space:]]*:"
color brightblue "\<((Source|Patch)[0-9]*|Nosource|Nopatch)[[:space:]]*:"
# Architectures.
color brightred "\<(i386|i486|i586|i686|athlon|ia64|alpha|alphaev5|alphaev56|alphapca56|alphaev6|alphaev67|sparc|sparcv9|sparc64armv3l|armv4b|armv4lm|ips|mipsel|ppc|ppciseries|ppcpseries|ppc64|m68k|m68kmint|Sgi|rs6000|i370|s390x?|noarch)\>"
# Architecture and OS conditionals.
color brightred "%(ifarch|elifarch|ifnarch|ifos|elifos|ifnos)\>"
# %* strings.
color green "%([A-Z_a-z_0-9_]*)"
color magenta "%_([A-Z_a-z_0-9_]*)"
color yellow start="%__" end="\ "
color magenta start="%\{" end="\}"
color yellow start="%\{__" end="\}"
# Sections.
color red "^%((prep|build|install|check|clean)$|(description|files|package|changelog)\>)"
color red "^%((pre|post)(trans|un)?|trigger(prein|in|un|postun)?)\>"
color red "^%(trans)?filetrigger(in|un|postun)\>"
color red "^%(sourcelist|patchlist|generate_buildrequires|verifyscript)\>"
# Conditionals and defines.
color brightred "%(if|elif|else|endif|define|global|undefine)\>"
# Comments.
color cyan "(#|%dnl[[:space:]]).*"
# Special case: "# norootforbuild" is handled as main tag.
color brightblue "^# norootforbuild"
# For %changelog entries: first the author, then just the date.
color yellow "^\* .+>"
color brightyellow "^\* [[:alnum:] ]+ [0-9]{4} "
# Trailing whitespace.
color ,green "[[:space:]]+$"

Some files were not shown because too many files have changed in this diff Show More