Compare commits

...

291 Commits
v5.9 ... v6.3

Author SHA1 Message Date
Benno Schulenberg
25ba7712f7 po: update translations and regenerate POT file and PO files 2022-04-28 10:36:42 +02:00
Benno Schulenberg
a6b534d760 bump version numbers and add a news item for the 6.3 release 2022-04-28 10:08:34 +02:00
Benno Schulenberg
494b191d55 gnulib: pull in the workaround for a build problem on NetBSD 2022-04-27 11:23:09 +02:00
Benno Schulenberg
450bfa7a75 build: fix compilation for --enable-{tiny,nanorc,color} 2022-04-22 11:47:21 +02:00
Benno Schulenberg
a52ac1375a formatting: change cursor position only after saving it in the undo item
When one wants an Undo to restore the cursor to where it was before an
operation, one shouldn't fiddle with the position before it is stored
in the relevant undo item.

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

Bug existed since version 4.9, commit 38af812a.

(This effectively reverts commit 38af812a from two years ago.)
2022-04-21 12:31:19 +02:00
Benno Schulenberg
4990713e9e tweaks: change the indentation of a list, to match other indentations 2022-04-19 11:15:18 +02:00
Benno Schulenberg
c022c4cc6d docs: add an example binding for copying text to the system clipboard 2022-04-12 11:18:25 +02:00
Benno Schulenberg
6257dec0a7 filtering: close all output descriptors, so that 'xsel' will terminate
For some reason, when copying something to the system clipboard
with 'xsel', it wants to see all output descriptors closed before
it will exit without requiring ^C.

This fixes https://savannah.gnu.org/bugs/?62276.
Reported-by: Shi Yanling <sylphenix@126.com>

Bug existed since version 2.9.8, since piping text through an
external command was introduced.
2022-04-12 11:09:09 +02:00
Benno Schulenberg
ea9d49b9d8 tweaks: remove some stray spaces before a comma 2022-04-11 10:31:39 +02:00
Benno Schulenberg
42c7bfcf8a verbatim: with --zero, keep cursor in viewport when it was on bottom row
This fixes https://savannah.gnu.org/bugs/?62285.

Bug existed since version 6.0, since --zero was introduced.
2022-04-11 10:28:09 +02:00
Benno Schulenberg
e67d1bfeb8 build: fix compilation when configured with --disable-color 2022-04-08 11:35:44 +02:00
Benno Schulenberg
e2f444cfdf gnulib: update to its current upstream state 2022-04-08 10:52:55 +02:00
Benno Schulenberg
03b85df4eb tweaks: remove redundant braces, and add two translator hints 2022-04-08 09:38:42 +02:00
Benno Schulenberg
7db5c2f225 files: when the working directory exists, still check its accessibility
This fixes https://savannah.gnu.org/bugs/?62258.

Bug existed since commit 940b5eaa from yesterday.
2022-04-06 16:41:45 +02:00
Benno Schulenberg
603ce231d0 tweaks: simplify a fragment of code, and fold two lines together 2022-04-05 12:40:45 +02:00
Benno Schulenberg
940b5eaad1 files: show a warning when the working directory is gone (when used)
Instead of silently opening an empty buffer when the user tries to
open a file in the current but disappeared directory, give a clear
warning about the absence of this directory.

This improves the fix for https://savannah.gnu.org/bugs/?62244.
2022-04-05 12:34:04 +02:00
Benno Schulenberg
fdd946c02c files: do not change to a higher directory when the working one is gone
When the working directory has been deleted from under nano's feet,
get_full_path() would move up in the directory tree until getcwd()
would succeed.  This meant that a filename that was specified on the
command line without any path (or with a relative path) would refer
to a different file than what the user intended.  Not good.

So, stop changing directories in get_full_path().  Use the realpath()
function with NULL as second parameter instead -- it has been part of
the POSIX standard since 2008, time enough for operating systems to
have caught up.

In the bargain, this saves seventy lines of complicated logic.

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

Bug existed since version 2.0.0, commit 85e35e67.
2022-04-04 12:52:35 +02:00
Benno Schulenberg
81e5b57d74 syntax: xml: colorize user-defined entities differently
Also improve two comments.
2022-04-04 12:08:23 +02:00
Benno Schulenberg
b568705eec syntax: xml: colorize /> properly, and colorize prolog tags differently
Use lightgrey for the prolog tags, as they normally are unimportant
boiler-plate stuff.  Comments are likely to be more relevant.

Any /> is part of the tag itself, not of the attributes.
2022-04-04 10:01:49 +02:00
Benno Schulenberg
fe42eb7a1a painting: stop coloring an extremely long line after 2000 bytes
Especially when softwrapping and when multiline regexes are involved,
colorizing takes roughly exponential time relative to the line length.
To avoid bogging down, stop colorizing a line beyond a certain point.

This mitigates https://savannah.gnu.org/bugs/?61799.
Reported-by: Devin Hussey <husseydevin@gmail.com>
2022-04-03 12:28:22 +02:00
Benno Schulenberg
df7b0a6d97 execute: clear an anchor only when the whole buffer gets filtered
Although an anchor at the top line is rather pointless, it shouldn't
get cleared when the user pipes just a part of the buffer through an
external command.
2022-03-28 11:38:22 +02:00
Benno Schulenberg
fcf598e797 execute: stay on the same line number when filtering the whole buffer
When the filter command makes just small, per-line changes, keeping the
cursor at the same line number allows the user to observe the effect of
the changes -- which is not possible when the cursor gets moved to the
end of the buffer.

This partially fulfills https://savannah.gnu.org/bugs/?57248.
2022-03-28 11:15:04 +02:00
Benno Schulenberg
d9cb12f6e3 tweaks: move the saving and restoring of flags to where it is needed 2022-03-27 18:44:48 +02:00
Benno Schulenberg
0f23729253 tweaks: prevent the adding of an unwanted newline in a different way
The prevention is needed only for temporary files, not for normal files.
2022-03-27 18:20:17 +02:00
Benno Schulenberg
3def429290 tweaks: don't leave an orphaned temporary file behind when writing fails 2022-03-27 12:37:01 +02:00
Benno Schulenberg
803ea0d7a0 justify: stay at the same line number when doing a full justification
The same line number may not be the same position in the text, but
it will be approximately -- and it is certainly better than leaving
the cursor at the end of the buffer.

This fulfills https://savannah.gnu.org/bugs/?61175.
2022-03-24 17:05:55 +01:00
Benno Schulenberg
9b014876cd tweaks: trim a few comments, rename a function, and reshuffle some code 2022-03-20 13:20:31 +01:00
Benno Schulenberg
9ccf85eaa8 tweaks: avoid a function call when two plain assignments will do 2022-03-18 11:40:03 +01:00
Benno Schulenberg
93fa53c3e8 tweaks: elide an unneeded call of strlen() 2022-03-18 11:36:10 +01:00
Benno Schulenberg
eea3e1f0b2 tweaks: make the triggering of the recalculation of multidata less eager
Also, trigger recalculation when an undo or redo causes a large enough
forward jump.
2022-03-18 11:29:18 +01:00
Benno Schulenberg
e6e22ea976 tweaks: normalize the indentation after the previous change 2022-03-17 14:09:09 +01:00
Benno Schulenberg
80c2000f87 tweaks: simplify a bit of code, eliding two labels and three gotos 2022-03-17 14:09:09 +01:00
Benno Schulenberg
15a0a129c8 painting: recalculate the multidata when making large strides or changes
When making a forward movement larger than a screenful, we cannot rely
on the multidata of the line before the new screen start to have been
set correctly by a previous screen drawing, so we need to recompute all
of the multidata, for the whole buffer, so that afterward we can freely
move around and draw the screen without having to do any backtracking.

Also when a piece of text larger than a screenful is pasted or inserted,
all the multidata needs to be recomputed.

This fixes https://savannah.gnu.org/bugs/?60041,
and fixes https://savannah.gnu.org/bugs/?62056.

First bug existed in this form since version 2.4.2, commit d49c267f
(but editing Python was incomparably slower in those days).

Second bug existed since version 5.6, commit 43d94692.
2022-03-17 14:07:42 +01:00
Benno Schulenberg
51bd04b541 painting: colorize text also after an unterminated start match
This does not waste time looking for an end match, which is especially
wasteful when there is none.  Also, it makes the coloring behavior more
consistent: any start match will cause coloring of the subsequent text,
no matter whether the user is in the middle of the file or near the end.
2022-03-14 09:12:55 +01:00
Benno Schulenberg
18ba7f60c1 painting: tighten the check for a lacking end match on a colored line
As it's possible for the start regex to match what is actually the end
match of a multiline thing (see the Python triple quotes, for example),
make sure that such a detected start match is *not* an end match, just
to avoid a needless full-screen refresh.
2022-03-08 09:47:36 +01:00
Benno Schulenberg
5c3e00d70a build: remove an obsolete check -- the dependent code was deleted
The code fragment that was conditionalized on REDEFINING_MACROS_OK
was deleted five weeks ago in commit 3f494e35.
2022-03-07 18:09:51 +01:00
Benno Schulenberg
6c4c77971e build: add the --disable-maintainer-mode option to ./configure
By passing --disable-maintainer-mode to ./configure the user can disable
autoconf build rules that would cause configure to be rebuilt and rerun.

Kind-of-requested-by: Mike Frysinger <vapier@gentoo.org>
2022-03-07 17:26:30 +01:00
Benno Schulenberg
67adef8f6c display: suppress spotlight yellow and error red when NO_COLOR is set
This makes nano conform to the https://no-color.org/ idea: suppressing
any color in the output (in the default setup) when NO_COLOR is set in
the environment.

Specifying a color for any interface element will, however, re-enable
also yellow for the spotlight and red for error messages.
2022-03-06 17:03:42 +01:00
Benno Schulenberg
ed60e16974 tweaks: exclude the extra truncation warning from the tiny version 2022-03-04 12:12:48 +01:00
Benno Schulenberg
47c11ae83d feedback: show extra warning when writing failed due to "No space left"
This mitigates https://savannah.gnu.org/bugs/?36864.
Reported-by: Clarence Risher <sparr0@gmail.com>

Problem has existed since the beginning, as nano empties the existing
file before writing the current buffer contents into it.
2022-03-03 11:12:41 +01:00
Mike Frysinger
8173b1bfbe general: fix building for Windows
Fix building with x86_64-w64-mingw32 to cross-compile native Windows
programs.  Need to:

  * add checks for missing functions
  * don't use signals that are unavailable on the platform
  * avoid useless non-Linux sys/ioctl.h include
  * use putenv instead of setenv as the latter is unavailable
2022-03-01 11:05:07 +01:00
Benno Schulenberg
93400ec8a1 execute: don't crash when an empty buffer is piped through a command
That is, take into account that the cutbuffer could be NULL
(when updating the undo item).

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

Bug existed since version 4.9, commit b15c5a7e.
2022-02-24 16:50:18 +01:00
Benno Schulenberg
0d85a798e5 painting: look for another start match only after the actual end match
The 'endmatch.rm_eo' value is relative to the end of the start match,
so to find the end of the end match, one has to add 'startmatch.rm_eo'
plus 'endmatch.rm_eo' to the starting point of the line.

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

Problem existed since version 5.6, commit 0596b875.
2022-02-21 10:46:28 +01:00
Benno Schulenberg
d4d534925f po: update translations and regenerate POT file and PO files 2022-02-18 10:58:47 +01:00
Benno Schulenberg
a1ba7ee786 bump version numbers and add a news item for the 6.2 release 2022-02-18 10:44:22 +01:00
Benno Schulenberg
756cd4a4b8 tweaks: store a result, to avoid calling a function twice 2022-02-18 10:27:47 +01:00
Benno Schulenberg
1b186fcff3 tweaks: rename two more variables, and drop unneeded initializations
Also, make sure that there is a space in the complaint so that the
later strstr() call cannot fail.  And reshuffle a line.
2022-02-17 14:20:45 +01:00
Benno Schulenberg
165da9b447 tweaks: rename a variable, reshuffle five lines, and snip two comments 2022-02-17 14:00:55 +01:00
Benno Schulenberg
aea10ed383 tweaks: rename two variables (to get rid of a prefix), and elide a third 2022-02-17 13:57:22 +01:00
Benno Schulenberg
8fccb31436 linter: adjust the parsing to accommodate for a modern 'pyflakes'
In version 2.2.0, pyflakes changed its output format,
from 'filename:line: text' to 'filename:line:column text'.

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

Problem existed since version 2.9.0, commit 5dcf375f.

(That commit tried to compensate for an introductory message from gcc
that no longer seems to exist.)
2022-02-16 15:39:01 +01:00
Benno Schulenberg
89bb88e4f5 syntaxes: fold a couple of regexes together, and improve a few comments 2022-02-16 13:07:11 +01:00
Benno Schulenberg
a58efa70bc tweaks: consistently backslash-escape the dash in M-letter keystrokes 2022-02-16 12:19:31 +01:00
Benno Schulenberg
fe1fecc5da tweaks: rename a variable, to be more correct, and adjust two comments
The new name 'gauge' more clearly indicates that it is a distance
between two "columns", two "pillars", two "piles".  Using 'longest'
was poor, because in fact it was set to 'widest + 10'.

(Also, change the type of 'piles' to an integer -- it will always
be smaller than COLS, and COLS is an integer.)
2022-02-13 13:07:52 +01:00
Benno Schulenberg
87612582ff tweaks: use an intermediate variable, to avoid using one for two purposes 2022-02-13 12:43:55 +01:00
Benno Schulenberg
c3a53cffbc tweaks: rename a variable, to be more fitting
It is about width (cells/columns), not about length (bytes).
2022-02-13 12:19:16 +01:00
Benno Schulenberg
aeea83703b tweaks: rename a misnamed variable 2022-02-13 12:04:57 +01:00
Benno Schulenberg
27c8f13fc9 tweaks: change the type of a variable, to avoid a compiler warning
A newer compiler (gcc-10.3) said: browser.c:174:34: warning:
  field width specifier '*' expects argument of type 'int'

It's fine for 'longest' to be an integer, as a filename in Unix is
at most 255 bytes long, which can occupy at most 510 columns (when
the name consists entirely of control codes), and that fits easily
within an 'int', which has at least fifteen bits, unsigned.

Well... in theory 'tabsize' could be set to an insanely high number,
and if a filename contains several tabs, this could cause 'longest'
to overflow.  (Why doesn't the compiler warn about that?)  If that
were to occur, and the filename with the tabs were the last in the
list, then 'longest' would get set to the minimum width: 15.  That
would not be correct, but... nothing bad would happen.

This addresses https://savannah.gnu.org/bugs/?62014.
Reported-by: Mike Frysinger <vapier@gentoo.org>
2022-02-13 11:54:14 +01:00
Benno Schulenberg
c6ddae70f7 display: suppress the bottom-bar wiping only when the user is editing
This wipe suppression is meant to prevent the last row of the edit window
getting cleared when edit window and bottom window overlap, and this is
relevant only when the user is actually editing -- the file browser and
help viewer take care not to use this bottom row for content.

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

Bug existed since version 6.0, commit be61aad9.
2022-02-11 16:46:05 +01:00
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
111 changed files with 29889 additions and 25276 deletions

315
ChangeLog
View File

@@ -1,3 +1,318 @@
Changes between v6.2 and v6.3:
------------------------------
Benno Schulenberg (41):
build: add the --disable-maintainer-mode option to ./configure
build: fix compilation for --enable-{tiny,nanorc,color}
build: fix compilation when configured with --disable-color
build: remove an obsolete check -- the dependent code was deleted
bump version numbers and add a news item for the 6.3 release
display: suppress spotlight yellow and error red when NO_COLOR is set
docs: add an example binding for copying text to the system clipboard
execute: clear an anchor only when the whole buffer gets filtered
execute: don't crash when an empty buffer is piped through a command
execute: stay on the same line number when filtering the whole buffer
feedback: show extra warning when writing failed due to "No space left"
files: do not change to a higher directory when the working one is gone
files: show a warning when the working directory is gone (when used)
files: when the working directory exists, still check its accessibility
filtering: close all output descriptors, so that 'xsel' will terminate
formatting: change cursor position only after saving it in the undo item
gnulib: pull in the workaround for a build problem on NetBSD
gnulib: update to its current upstream state
justify: stay at the same line number when doing a full justification
painting: colorize text also after an unterminated start match
painting: look for another start match only after the actual end match
painting: recalculate the multidata when making large strides or changes
painting: stop coloring an extremely long line after 2000 bytes
painting: tighten the check for a lacking end match on a colored line
syntax: xml: colorize /> properly, and colorize prolog tags differently
syntax: xml: colorize user-defined entities differently
tweaks: avoid a function call when two plain assignments will do
tweaks: change the indentation of a list, to match other indentations
tweaks: don't leave an orphaned temporary file behind when writing fails
tweaks: elide an unneeded call of strlen()
tweaks: exclude the extra truncation warning from the tiny version
tweaks: make the triggering of the recalculation of multidata less eager
tweaks: move the saving and restoring of flags to where it is needed
tweaks: normalize the indentation after the previous change
tweaks: prevent the adding of an unwanted newline in a different way
tweaks: remove redundant braces, and add two translator hints
tweaks: remove some stray spaces before a comma
tweaks: simplify a bit of code, eliding two labels and three gotos
tweaks: simplify a fragment of code, and fold two lines together
tweaks: trim a few comments, rename a function, and reshuffle some code
verbatim: with --zero, keep cursor in viewport when it was on bottom row
Mike Frysinger (1):
general: fix building for Windows
Changes between v6.1 and v6.2:
------------------------------
Benno Schulenberg (14):
bump version numbers and add a news item for the 6.2 release
display: suppress the bottom-bar wiping only when the user is editing
linter: adjust the parsing to accommodate for a modern 'pyflakes'
syntaxes: fold a couple of regexes together, and improve a few comments
tweaks: change the type of a variable, to avoid a compiler warning
tweaks: consistently backslash-escape the dash in M-letter keystrokes
tweaks: rename a misnamed variable
tweaks: rename a variable, reshuffle five lines, and snip two comments
tweaks: rename a variable, to be more correct, and adjust two comments
tweaks: rename a variable, to be more fitting
tweaks: rename two more variables, and drop unneeded initializations
tweaks: rename two variables (to get rid of a prefix), and elide a third
tweaks: store a result, to avoid calling a function twice
tweaks: use an intermediate variable, to avoid using one for two purposes
Changes between v6.0 and v6.1:
------------------------------
Benno Schulenberg (37):
build: fix compilation when configured with --enable-tiny
build: prevent autopoint from overwriting a newer M4 file from gnulib
bump version numbers and add a news item for the 6.1 release
copyright: update the last year for significantly changed files
copyright: update the years for the FSF
docs: mention bindable function 'zero', for toggling the interface bars
docs: mention 'set guidestripe' and 'set unix' in the sample nanorc
docs: remove obsolete Ctrl+Z from the cheatsheet; mention Alt+X instead
files: let ^C cancel the exiting when the file on disk was changed
gnulib: update to its current upstream state
help: make the description of <Tab> more accurate
help: update the description of M-D, to match the actual order of counts
input: instead of moving waiting keycodes, just increment a pointer
input: suppress any spotlighting when there are more keycodes waiting
menus: don't show M-6 in the help lines of any prompt
prompt: allow the user to copy the answer to the cutbuffer (with M-6)
prompt: let ^K erase text after cursor (if any), otherwise whole answer
tweaks: add some feedback to the autogen.sh script, to ease the wait
tweaks: add some small, clarifying comments
tweaks: adjust a translator hint, to fit the order in the POT file
tweaks: drop foreign M-U and M-R from among the sample CUA bindings
tweaks: remove a redundant check -- add a different one for symmetry
tweaks: remove two redundant checks
tweaks: rename a function and its two parameters, for clarity
tweaks: rename a function and reshuffle its call
tweaks: rename a function, to not contain the name of a variable
tweaks: rename another variable, to better fit in with its sisters
tweaks: rename a variable and a parameter, to be more descriptive
tweaks: rename a variable, away from an abbreviation
tweaks: rename a variable, for clarity and contrast
tweaks: rename a variable, to make it clearer it refers to a window
tweaks: rename two variables, and elide a near-enough duplicate
tweaks: reshuffle some sample bindings, to group them differently
tweaks: reword two comments, and rename a variable (away from an abbrev)
tweaks: stop asking the terminal for its new size -- let ncurses do it
tweaks: use some symbolic names instead of unclear numeric values
tweaks: when discarding keycodes, don't bother parsing them
Changes between v5.9 and v6.0:
------------------------------
Benno Schulenberg (192):
bindings: allow rebinding ^Z also on a Linux console (a VT)
bindings: allow toggling line numbers (when enabled) also in tiny version
bindings: let ^T in the tiny version invoke spell checker (when included)
browser: with --zero, do not use the bottom row for displaying filenames
build: fix compilation when configured with --disable-color
build: fix compilation when configured with --disable-nanorc
build: fix compilation when configured with --enable-tiny
build: fix compilation with --enable-tiny --enable-nanorc
build: fix compilation with --enable-tiny --enable-wrapping
build: include the YAML syntax file among the distributed files
bump version numbers and add a news item for the 6.0 release
display: clear the status bar early enough, so that --zero can show text
display: do not wipe the status bar when --zero or --minibar is active
display: ensure feedback will be cleared also on a one-row terminal
display: make sure there are at least as many text lines as help lines
display: move some code for overwriting verbatim feedback with --zero
display: redraw the screen in tiny version upon resuming from suspension
display: with --zero, redraw the bottom row instead of wiping a message
docs: add a hint about making ^L do just 'refresh' to the sample nanorc
docs: add a meta description for the HTML rendering of the manual
docs: add a suggested rebind and three suggested unbinds to the sample rc
docs: avoid large Table of Contents at top of HTML version of manual
docs: clarify that --enable options do not fully counteract --enable-tiny
docs: correct the description of the layout -- four areas, not five
docs: document the effect of --quickblank together with --zero/--minibar
docs: explain the effect of --zero / -0 / 'set zero'
docs: explain what it means when --rawsequences is needed
docs: give more examples of things that --enable-tiny excludes
docs: improve the title of the manual, away from the bare "nano"
docs: list the new color names, from 'rosy' to 'crimson'
docs: mark options -z, --suspendable, and 'set suspendable' as obsolete
docs: mention "grey" also at the other place where color names are listed
docs: mention M-Z (for toggling the interface) among the Feature Toggles
docs: mention that --zero and 'set zero' hide also the help lines
docs: move the chapter about editor basics into third position
docs: prevent a black square in the PDF after the long synopsis line
docs: reshuffle a GNU marker, to make the title clearer in search engines
docs: reword several of the descriptions in the chapter on building nano
docs: reword the beginning of the chapter on nanorc files
docs: say thanks to the Indonesian translator
feedback: give a more accurate message when the help lines won't appear
feedback: refuse the --constantshow toggle (M-C) on a one-row terminal
feedback: report an unbindable function key as an "Unknown sequence"
feedback: report the number of inserted lines also with --zero or --mini
feedback: show a relevant message for M-O when the syntax has 'tabgives'
feedback: suppress chatty messages when --zero is active
feedback: to have a status bar, suppress --zero while in the help viewer
feedback: when reporting an unbound function key, mention its number
feedback: when the user types ^Z, say they can suspend nano with ^T^Z
feedback: with --mini or --zero, suppress number of lines for new buffer
feedback: with --mini/--zero, suppress message when toggling whitespace
feedback: with --zero, drop a message in a short while, as with --minibar
files: allow inserting also when started with the --noread option
files: clear original filename when the user toggles Append or Prepend
gnulib: update to its current upstream state
help: do not show ^S when --preserve is in effect
help: ensure there is a blank line between title bar and start of text
help: group the now lone mouse toggle with the "behavioral" ones
help: remove an unneeded restriction for small terminals
help: skip the leading blank line when the terminal is very flat
help: when done, always redraw the "bottom bars", also with --zero
history: process file faster by not filtering out hypothetical duplicates
input: ensure that no more bytes are consumed than are available
justify: correctly determine whether top-of-buffer has been reached
memory: avoid a tiny leak when an option with an argument is given twice
memory: avoid leaking the filename when dottifying it on the minibar
new feature: option --zero for an interface without bars
options: make --zero imply --nohelp, and 'set zero' imply 'set nohelp'
pasting: when less than a line is pasted, allow automatic hard-wrapping
prompt: avoid resetting the history pointer when the search is cancelled
prompt: begin at bottom of history list when at secondary prompt
prompt: keep a clear answer clear also after an excursion into history
rcfile: recognize fourteen new color names, mostly for subdued shades
rcfile: remove the deprecated 'cutwordleft' and 'cutwordright' keywords
replacing: keep centering the occurrence, also after toggling help lines
replacing: keep the spotlighted occurrence in view, also with --zero
replacing: keep the spotlighting, also after toggling the help lines
search: with --zero, do not obscure an occurrence on the bottom row
search: with --zero, drop a message at the same time as the spotlight
statusbar: count words in the way that matches how Ctrl+Right moves
statusbar: overwrite a message also when using --constant with --zero
suspension: enable ^Z by default -- ignore -z option and drop M-Z toggle
suspension: leave ^Z unbound by default -- just ^T^Z will suspend nano
syntax: debian: remove file -- Debian itself will have to handle it
syntax: default: colorize comments as one of the last things
syntax: default: colorize dates, URLs, and nano's release motto
syntax: email: use a character class, as \s does not work inside brackets
syntax: gentoo: remove file -- Gentoo itself will have to handle it
syntax: nanorc: add 'execute' menu for unbind, and drop a bad constraint
syntax: nanorc: avoid colorizing #rgb codes as if they were comments
syntax: nanorc: colorize a trailing comment when it begins with non-hex
syntax: nanorc: colorize each of the fourteen new color names as valid
syntax: nanorc: improve the file-matching regex
syntax: nanorc: paint arguments of 'include' and 'extendsyntax' specially
syntax: nanorc: require whitespace before the start= and end= keywords
syntax: python: colorize backslash escapes, such as \n and \xef
syntax: ruby: colorize embedded documentation as a comment
syntax: rust: do not colorize as string the text between two strings
syntax: sql: add a few more missing keywords, like TRUE and FALSE
syntax: sql: add more missing keywords, like INNER and OUTER JOIN
syntax: sql: add some missing keywords, like ALL and ANY and OR
syntax: sql: add two missing data types -- xml and tsquery
syntax: sql: colorize as flow control only keywords that clearly are such
syntax: sql: colorize keywords regardless of case, and tweak the colors
syntax: sql: colorize only single-quoted things as strings
syntax: sql: colorize strings differently than types
syntax: sql: remove alien stuff -- it was copied mostly from ruby syntax
syntax: texinfo: be more precise in colorizing @commands
syntax: texinfo: colorize the special @-plus-punctuation commands too
syntaxes: avoid coloring "this\" as if it were a valid string
syntaxes: colorize hex more strictly by using character class [:xdigit:]
syntaxes: drop three redundant end-of-line anchors
syntaxes: undouble the backslash within bracket expressions
syntaxes: use one regex for coloring quoted strings, to avoid overlap
tabbing: also with --zero, stay one row away from the prompt bar
tweaks: add an auxiliary variable, to prepare for handling --zero
tweaks: add two spaces and two comments, and drop an internal check
tweaks: adjust two values -- help lines need at least 6 rows to be shown
tweaks: avoid a compiler warning with --enable-tiny --enable-linenumbers
tweaks: avoid redrawing the entire window when just a 'touch' will do
tweaks: condense the definitions of all the empty functions
tweaks: condense the regexes for Types in the SQL syntax
tweaks: don't redraw the help lines (if present), and normalize a brace
tweaks: drop a fragment of code that became functionless
tweaks: elevate two messages, so they get shown with --mini or --zero
tweaks: elide a variable that is confusing and has just one use case
tweaks: elide two functions that each were called just once
tweaks: elide two parameters, as they are now always the same
tweaks: exclude some hidden-interface code from the tiny version
tweaks: exclude some suspension code from the tiny version
tweaks: fix a parentheses mistake -- found by a warning from Clang
tweaks: fix a somewhat humorous typo
tweaks: fix typo, and improve description of 'set zero' in sample nanorc
tweaks: fold a special case into the general one
tweaks: fold some regexes together, and trim or improve some comments
tweaks: frob a couple of comments, and drop two, for conciseness
tweaks: improve a comment, and drop two cluttering compile conditions
tweaks: invert a condition, to get an early return instead of indentation
tweaks: just let do_wrap() set 'refresh_needed' instead of returning TRUE
tweaks: mark keystrokes consistently with @kbd in the manual
tweaks: move a translator hint to where xgettext will see it
tweaks: normalize whitespace, drop unneeded prototype, condense comment
tweaks: on one-row terminals, suppress the message for two toggles
tweaks: place the unsetting of a flag better, and rename a variable
tweaks: put three email addresses between the customary angled brackets
tweaks: reassign a copy of a string to a variable more economically
tweaks: reduce redundancy (--enable-color implies --enable-nanorc)
tweaks: remove redundant pair of parentheses, and swap two alternatives
tweaks: remove redundant parentheses, trim comments, fold some regexes
tweaks: remove two unneeded unsettings
tweaks: rename a function and its parameter, to be clearer
tweaks: rename a function, away from using an abbreviation
tweaks: rename a function, for some contrast and to get rid of a suffix
tweaks: rename a function, to describe better what it does nowadays
tweaks: rename a function, to make it make sense
tweaks: rename a variable, to be distinctive and less confusing
tweaks: rename a variable, to be easier to read and to make more sense
tweaks: rename five empty functions, to get rid of a meaningless suffix
tweaks: rename three functions, to better fit the general scheme
tweaks: rename three parameters, away from single letters
tweaks: rename two empty functions, to be more to the point
tweaks: rename two functions, to get rid of another senseless suffix
tweaks: rename two functions, to get rid of one more senseless suffix
tweaks: rename two functions, to get rid of the senseless suffix of one
tweaks: rename two more functions, to lose a senseless suffix
tweaks: rename two parameters and one variable, away from single letters
tweaks: rename two variables, away from abbreviations
tweaks: rename two variables, to fit with the names of similar ones
tweaks: replace a verbose condition with a simpler early return
tweaks: replace the obscure @* with the slightly clearer @sp
tweaks: replace two direct refreshes with two scheduled ones
tweaks: reshuffle a coloring rule, to have related ones together
tweaks: reshuffle a few lines, and rename a variable
tweaks: reshuffle a few lines, for Christmas and to group things better
tweaks: reshuffle a fragment of code to a better place
tweaks: reshuffle a line and adjust indentation after previous change
tweaks: reshuffle a line into its proper order, and improve two comments
tweaks: reshuffle some conditions, so that the ifs have similar formats
tweaks: reshuffle some conditions, to have more balanced lines
tweaks: reshuffle some lines, one for clarity, others for conciseness
tweaks: reshuffle the flag conversion into their order in the help text
tweaks: reshuffle two conditions, re-indent, and rewrap a line
tweaks: reword a paragraph, and use usual M- to depict Meta keystrokes
tweaks: rewrap an old news item, for distraction
tweaks: rewrap three old NEWS items, for esthetics, and fix a date
tweaks: shorten a comment, and drop some conditionalizing
tweaks: shorten the description of --zero in the manuals a bit
tweaks: shorten two comments, and fold two statements together
tweaks: swap two parts of specific regexes, for consistency with others
tweaks: untangle two case items, and shorten a message
tweaks: use a color closer to the rest of the string, to reduce contrast
tweaks: use a few fewer capitals, and drop an unneeded synonym
Brad Town (2):
docs: add a description of the hexadecimal #rgb color specification
rcfile: support #rgb format for specifying colors in 256-color terminals
Changes between v5.8 and v5.9:
------------------------------

View File

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

119
NEWS
View File

@@ -1,3 +1,51 @@
2022.04.28 - GNU nano 6.3 "Wat zullen we drinken? Wat een dorst!"
• For multiline regexes, text is now colored as soon a start match
is found, also when there is no end match at all.
• The colorizing of any line is stopped after two thousand bytes,
to avoid frustrating delays.
• When environment variable NO_COLOR is set, the two default colors
(yellow for the spotlight, red for error messages) are suppressed
when no interface colors are specified in a nanorc file.
• Full justification and piping the whole buffer through a command
now keep the cursor at the same line number.
• Utility 'xsel' can be used to copy a marked region to the system's
clipboard. See doc/sample.nanorc for an example.
2022.02.18 - GNU nano 6.2 "Kamperfoelie"
• The file browser clears the prompt bar also when using --minibar.
• Linting now works also with a newer 'pyflakes'.
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
@@ -187,7 +235,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.
@@ -1001,31 +1049,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
@@ -1786,22 +1834,21 @@
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

8
README
View File

@@ -15,7 +15,7 @@ Appearance
In rough ASCII graphics, this is what nano's screen looks like:
____________________________________________________________________
| GNU nano 5.9 filename Modified |
| GNU nano 6.3 filename Modified |
--------------------------------------------------------------------
| This is the text window, displaying the contents of a 'buffer', |
| the contents of the file you are editing. |
@@ -95,13 +95,13 @@ 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

View File

@@ -8,19 +8,18 @@ building this needs a bit more care than the official tarballs.
Prerequisites
-------------
To successfully compile GNU nano from git, you'll need the following
packages:
To successfully compile GNU nano from git, you'll need the following:
- autoconf (version >= 2.69)
- automake (version >= 1.14)
- autopoint (version >= 0.18.3)
- gcc (version >= 5.0)
- gettext (version >= 0.18.3)
- git (version >= 2.7.4)
- groff (version >= 1.12)
- make (any version)
- pkg-config (version >= 0.22)
- texinfo (version >= 4.0)
autoconf (version >= 2.69)
automake (version >= 1.14)
autopoint (version >= 0.18.3)
gcc (version >= 5.0)
gettext (version >= 0.18.3)
git (version >= 2.7.4)
groff (version >= 1.12)
make (any version)
pkg-config (version >= 0.22)
texinfo (version >= 4.0)
You will also need to have the header files for ncurses installed,
from libncurses-dev on Debian, ncurses-devel on Fedora, or similar.
@@ -29,14 +28,14 @@ These should all be available in your distro's package manager or
software center, or otherwise on any GNU mirror.
Download the source
-------------------
Clone the source
----------------
To obtain the current nano development branch (called 'master'), use the
following command. It will create in your current working directory a
subdirectory called 'nano' containing a copy of all of the files:
$ git clone git://git.savannah.gnu.org/nano.git nano
$ git clone git://git.savannah.gnu.org/nano.git
Generate the configure script
@@ -84,6 +83,7 @@ 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
----------------------

1
THANKS
View File

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

View File

@@ -2,7 +2,7 @@
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="9aca7b67333fd0a90bf56104325ce96199644451"
gnulib_hash="34a93be8aa8a15f5959a1b671ad1285a5d552f4b"
modules="
futimens
@@ -36,14 +36,26 @@ 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-2021 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,10 +16,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see https://www.gnu.org/licenses/.
AC_INIT([GNU nano], [5.9], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [6.3], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.14])
AM_MAINTAINER_MODE([enable])
AC_CONFIG_HEADERS([config.h])
dnl Make sure the ONCE macros are available.
@@ -353,6 +354,9 @@ if test "x$enable_utf8" != xno; then
AC_CHECK_FUNCS(iswalpha iswalnum iswpunct mbstowcs wctomb)
fi
AC_CHECK_FUNCS_ONCE(chmod chown fchmod fchown flockfile funlockfile
fork fsync geteuid pipe wait waitpid)
dnl Checks for available flags.
AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"], [], [])
@@ -510,21 +514,6 @@ int main(void)
*** Can't check need for _XOPEN_SOURCE_EXTENDED when cross-compiling.]))
fi
AC_MSG_CHECKING([whether LINES and COLS can be redefined])
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.]))
AS_IF([test "x$enable_libmagic" != "xno"], [
AC_CHECK_HEADERS([magic.h])
AC_CHECK_LIB(magic, magic_open)

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

@@ -92,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>5.9</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.3</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<h3><a name="1.5"></a>1.5. I want to read the man page without having to download the program!</h3>
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="https://nano-editor.org/dist/latest/nano.1.html">here</a>.</p></blockquote>
<hr width="100%">

View File

@@ -1,4 +1,4 @@
.\" Copyright (C) 1999-2011, 2013-2021 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 5.9" "October 2021"
.TH NANO 1 "version 6.3" "April 2022"
.SH NAME
nano \- Nano's ANOther editor, inspired by Pico
@@ -140,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.
@@ -192,8 +194,11 @@ Set the size (width) of a tab to \fInumber\fP columns. The value of
.TP
.BR \-U ", " \-\-quickblank
Make status-bar messages disappear after 1 keystroke instead of after 20.
Note that options \fB\-c\fR (\fB\-\-constantshow\fR)
and \fB\-_\fR (\fB\-\-minibar\fR) override this.
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.
@@ -328,7 +333,9 @@ Don't show the two help lines at the bottom of the screen.
Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
.TP
.BR \-z ", " \-\-suspendable
Allow the user to suspend the editor (with \fB^Z\fR by default).
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 \-% ", " \-\-stateflags
Use the top-right corner of the screen for showing some state flags:
@@ -352,9 +359,17 @@ 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.
\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.

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
.\" Copyright (C) 2003-2011, 2013-2021 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,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 5.9" "October 2021"
.TH NANORC 5 "version 6.3" "April 2022"
.SH NAME
nanorc \- GNU nano's configuration file
@@ -196,7 +196,7 @@ 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.
\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
@@ -258,7 +258,10 @@ specfified closing punctuation, optionally followed by closing brackets
.TP
.B set quickblank
Make status-bar messages disappear after 1 keystroke instead of after 20.
Note that options \fBconstantshow\fR and \fBminibar\fR override this.
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.
@@ -268,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
@@ -339,7 +344,9 @@ Use this color combination for the vertical guiding stripe.
See \fBset titlecolor\fR for more details.
.TP
.B set suspendable
Allow \fBnano\fP to be suspended (with \fB^Z\fR by default).
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
@@ -361,8 +368,16 @@ 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 ", and " normal
.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.
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,
@@ -394,6 +409,14 @@ probably want to unset \fBwordbounds\fR.
.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
@@ -483,11 +506,21 @@ one of which must be specified. Valid color names are:
.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 ", and " normal
.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.
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.
@@ -662,7 +695,7 @@ 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).
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(1) or GNU
@@ -819,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
\fBsuspendable\fR toggle item 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
@@ -898,6 +931,9 @@ Toggles the presence of the two-line list of key bindings at the bottom of the s
(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.
.TP
@@ -934,11 +970,6 @@ Toggles whether typed tabs will be converted to spaces.
.TP
.B mouse
Toggles mouse support.
.TP
.B suspendable
Toggles whether the suspend keystroke (\fB^Z\fR by default)
will actually suspend the editor.
(The old name of this function, 'suspendenable', is deprecated.)
.RE
.TP

View File

@@ -1,4 +1,4 @@
.\" Copyright (C) 2002-2007, 2014-2021 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 5.9" "October 2021"
.TH RNANO 1 "version 6.3" "April 2022"
.SH NAME
rnano \- a restricted nano

View File

@@ -58,6 +58,10 @@
## 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
@@ -167,10 +171,6 @@
## M = mark, L = hard-wrapping long lines, R = recording, S = soft-wrapping.
# set stateflags
## Allow nano to be suspended (with ^Z by default).
# set suspendable
## (The old form of this option, 'set suspend', is deprecated.)
## Use this tab size instead of the default; it must be greater than 0.
# set tabsize 8
@@ -180,6 +180,9 @@
## Snip whitespace at the end of lines when justifying or hard-wrapping.
# set trimblanks
## 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
## ISO-8859-1 (0000B7 in Unicode) seem to be good values for these.
@@ -201,6 +204,9 @@
## of a single character, and without affecting the cutbuffer).
# set zap
## 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.
@@ -256,6 +262,9 @@
## === 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
## the ASCII character for backspace, so it is bound by default to the
@@ -265,19 +274,37 @@
## <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-U "Oc|sed 's/.*/\U&/'
" main
# bind Sh-M-L "Oc|sed 's/.*/\L&/'
" main
## For copying a marked region to the system clipboard:
# bind Sh-M-T "|xsel -ib
u" 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
@@ -285,24 +312,18 @@
#bind ^H exit help
#bind ^F whereis all
#bind ^G findnext all
#bind ^D findprevious all
#bind ^R replace main
#bind ^X cut main
#bind ^C copy main
#bind ^V paste all
#bind ^P location main
#bind ^B wherewas all
#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 ^T gotoline main
#bind ^T cutrestoffile execute
#bind ^L linter execute
#bind M-U undo main
#bind M-R redo main
#bind ^Z undo main
#bind ^T gotodir browser

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 is it ja ko ms nb nl pl pt pt_BR ro ru sk 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 sq sr sv tr uk vi zh_CN zh_TW

1230
po/bg.po

File diff suppressed because it is too large Load Diff

1238
po/ca.po

File diff suppressed because it is too large Load Diff

1232
po/cs.po

File diff suppressed because it is too large Load Diff

1556
po/da.po

File diff suppressed because it is too large Load Diff

1244
po/de.po

File diff suppressed because it is too large Load Diff

1243
po/eo.po

File diff suppressed because it is too large Load Diff

1245
po/es.po

File diff suppressed because it is too large Load Diff

1230
po/eu.po

File diff suppressed because it is too large Load Diff

1318
po/fi.po

File diff suppressed because it is too large Load Diff

1246
po/fr.po

File diff suppressed because it is too large Load Diff

1232
po/ga.po

File diff suppressed because it is too large Load Diff

1232
po/gl.po

File diff suppressed because it is too large Load Diff

1292
po/hr.po

File diff suppressed because it is too large Load Diff

1238
po/hu.po

File diff suppressed because it is too large Load Diff

1551
po/id.po

File diff suppressed because it is too large Load Diff

1230
po/is.po

File diff suppressed because it is too large Load Diff

1232
po/it.po

File diff suppressed because it is too large Load Diff

1240
po/ja.po

File diff suppressed because it is too large Load Diff

1238
po/ko.po

File diff suppressed because it is too large Load Diff

1350
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1266
po/nb.po

File diff suppressed because it is too large Load Diff

1248
po/nl.po

File diff suppressed because it is too large Load Diff

1232
po/pl.po

File diff suppressed because it is too large Load Diff

1232
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1302
po/ro.po

File diff suppressed because it is too large Load Diff

1232
po/ru.po

File diff suppressed because it is too large Load Diff

1244
po/sk.po

File diff suppressed because it is too large Load Diff

1230
po/sl.po

File diff suppressed because it is too large Load Diff

3087
po/sq.po Normal file

File diff suppressed because it is too large Load Diff

1246
po/sr.po

File diff suppressed because it is too large Load Diff

1260
po/sv.po

File diff suppressed because it is too large Load Diff

1304
po/tr.po

File diff suppressed because it is too large Load Diff

1240
po/uk.po

File diff suppressed because it is too large Load Diff

1628
po/vi.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* browser.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2022 Free Software Foundation, Inc. *
* Copyright (C) 2015-2016, 2020 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -32,45 +32,45 @@ static char **filelist = NULL;
/* The list of files to display in the file browser. */
static size_t list_length = 0;
/* The number of files in the list. */
static size_t width = 0;
static size_t usable_rows = 0;
/* The number of screen rows we can use to display the list. */
static int piles = 0;
/* The number of files that we can display per screen row. */
static size_t longest = 0;
/* The number of columns in the longest filename in the list. */
static int gauge = 0;
/* The width of a 'pile' -- the widest filename plus ten. */
static size_t selected = 0;
/* The currently selected filename in the list; zero-based. */
/* Set filelist to the list of files contained in the directory path,
* set list_length to the number of files in that list, set longest to
* the width in columns of the longest filename in that list (between 15
* and COLS), and set width to the number of files that we can display
* per screen row. And sort the list too. */
/* Fill 'filelist' with the names of the files in the given directory, set
* 'list_length' to the number of names in that list, set 'gauge' to the
* width of the widest filename plus ten, and set 'piles' to the number of
* files that can be displayed per screen row. And sort the list too. */
void read_the_list(const char *path, DIR *dir)
{
size_t path_len = strlen(path), index = 0;
const struct dirent *nextdir;
size_t path_len = strlen(path);
const struct dirent *entry;
size_t widest = 0;
size_t index = 0;
longest = 0;
/* Find the width of the widest filename in the current folder. */
while ((entry = readdir(dir)) != NULL) {
size_t span = breadth(entry->d_name);
/* Find the length of the longest filename in the current folder. */
while ((nextdir = readdir(dir)) != NULL) {
size_t name_len = breadth(nextdir->d_name);
if (name_len > longest)
longest = name_len;
if (span > widest)
widest = span;
index++;
}
/* Put 10 characters' worth of blank space between columns of filenames
* in the list whenever possible, as Pico does. */
longest += 10;
/* Reserve ten columns for blanks plus file size. */
gauge = widest + 10;
/* If needed, make room for ".. (parent dir)". */
if (longest < 15)
longest = 15;
if (gauge < 15)
gauge = 15;
/* Make sure we're not wider than the window. */
if (longest > COLS)
longest = COLS;
if (gauge > COLS)
gauge = COLS;
rewinddir(dir);
@@ -81,20 +81,19 @@ void read_the_list(const char *path, DIR *dir)
filelist = nmalloc(list_length * sizeof(char *));
while ((nextdir = readdir(dir)) != NULL && index < list_length) {
/* Don't show the "." entry. */
if (strcmp(nextdir->d_name, ".") == 0)
while ((entry = readdir(dir)) != NULL && index < list_length) {
/* Don't show the useless dot item. */
if (strcmp(entry->d_name, ".") == 0)
continue;
filelist[index] = nmalloc(path_len + strlen(nextdir->d_name) + 1);
sprintf(filelist[index], "%s%s", path, nextdir->d_name);
filelist[index] = nmalloc(path_len + strlen(entry->d_name) + 1);
sprintf(filelist[index], "%s%s", path, entry->d_name);
index++;
}
/* Maybe the number of files in the directory decreased between the
* first time we scanned and the second time. index is the actual
* length of the file list, so record it. */
/* Maybe the number of files in the directory decreased between
* the first time we scanned and the second time. */
list_length = index;
/* Sort the list of names. */
@@ -103,31 +102,28 @@ void read_the_list(const char *path, DIR *dir)
/* Calculate how many files fit on a line -- feigning room for two
* spaces beyond the right edge, and adding two spaces of padding
* between columns. */
width = (COLS + 2) / (longest + 2);
piles = (COLS + 2) / (gauge + 2);
usable_rows = editwinrows - (ISSET(ZERO) && LINES > 1 ? 1 : 0);
}
/* Look for needle. If we find it, set selected to its location.
* Note that needle must be an exact match for a file in the list. */
void browser_select_dirname(const char *needle)
/* Reselect the given file or directory name, if it still exists. */
void reselect(const char *name)
{
size_t looking_at = 0;
for (; looking_at < list_length; looking_at++) {
if (strcmp(filelist[looking_at], needle) == 0) {
selected = looking_at;
break;
}
}
while (looking_at < list_length && strcmp(filelist[looking_at], name) != 0)
looking_at++;
/* If the sought name isn't found, move the highlight so that the
* changed selection will be noticed. */
if (looking_at == list_length) {
/* If the sought name was found, select it; otherwise, just move
* the highlight so that the changed selection will be noticed,
* but make sure to stay within the current available range. */
if (looking_at < list_length)
selected = looking_at;
else if (selected > list_length)
selected = list_length - 1;
else
--selected;
/* Make sure we stay within the available range. */
if (selected >= list_length)
selected = list_length - 1;
}
}
/* Display at most a screenful of filenames from the gleaned filelist. */
@@ -143,8 +139,8 @@ void browser_refresh(void)
titlebar(present_path);
blank_edit();
for (size_t index = selected - selected % (editwinrows * width);
index < list_length && row < editwinrows; index++) {
for (size_t index = selected - selected % (usable_rows * piles);
index < list_length && row < usable_rows; index++) {
const char *thename = tail(filelist[index]);
/* The filename we display, minus the path. */
size_t namelen = breadth(thename);
@@ -154,11 +150,11 @@ void browser_refresh(void)
size_t infomaxlen = 7;
/* The maximum length of the file information in columns:
* normally seven, but will be twelve for "(parent dir)". */
bool dots = (COLS >= 15 && namelen >= longest - infomaxlen);
bool dots = (COLS >= 15 && namelen >= gauge - infomaxlen);
/* Whether to put an ellipsis before the filename? We don't
* waste space on dots when there are fewer than 15 columns. */
char *disp = display_string(thename, dots ?
namelen + infomaxlen + 4 - longest : 0, longest, FALSE, FALSE);
namelen + infomaxlen + 4 - gauge : 0, gauge, FALSE, FALSE);
/* The filename (or a fragment of it) in displayable format.
* When a fragment, account for dots plus one space padding. */
struct stat state;
@@ -166,18 +162,18 @@ void browser_refresh(void)
/* If this is the selected item, draw its highlighted bar upfront, and
* remember its location to be able to place the cursor on it. */
if (index == selected) {
wattron(edit, interface_color_pair[SELECTED_TEXT]);
mvwprintw(edit, row, col, "%*s", longest, " ");
wattron(midwin, interface_color_pair[SELECTED_TEXT]);
mvwprintw(midwin, row, col, "%*s", gauge, " ");
the_row = row;
the_column = col;
}
/* If the name is too long, we display something like "...ename". */
if (dots)
mvwaddstr(edit, row, col, "...");
mvwaddstr(edit, row, dots ? col + 3 : col, disp);
mvwaddstr(midwin, row, col, "...");
mvwaddstr(midwin, row, dots ? col + 3 : col, disp);
col += longest;
col += gauge;
/* Show information about the file: "--" for symlinks (except when
* they point to a directory) and for files that have disappeared,
@@ -231,11 +227,11 @@ void browser_refresh(void)
infolen = infomaxlen;
}
mvwaddstr(edit, row, col - infolen, info);
mvwaddstr(midwin, row, col - infolen, info);
/* If this is the selected item, finish its highlighting. */
if (index == selected)
wattroff(edit, interface_color_pair[SELECTED_TEXT]);
wattroff(midwin, interface_color_pair[SELECTED_TEXT]);
free(disp);
free(info);
@@ -243,8 +239,8 @@ void browser_refresh(void)
/* Add some space between the columns. */
col += 2;
/* If the next entry will not fit on this row, move to next row. */
if (col > COLS - longest) {
/* If the next item will not fit on this row, move to next row. */
if (col > COLS - gauge) {
row++;
col = 0;
}
@@ -252,11 +248,11 @@ void browser_refresh(void)
/* If requested, put the cursor on the selected item and switch it on. */
if (ISSET(SHOW_CURSOR)) {
wmove(edit, the_row, the_column);
wmove(midwin, the_row, the_column);
curs_set(1);
}
wnoutrefresh(edit);
wnoutrefresh(midwin);
}
/* Look for the given needle in the list of files. If forwards is TRUE,
@@ -355,7 +351,7 @@ void search_filename(bool forwards)
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
}
@@ -430,7 +426,7 @@ char *browse(char *path)
if (path == NULL || dir == NULL) {
statusline(ALERT, _("Cannot open directory: %s"), strerror(errno));
/* If we don't have a file list yet, there is nothing to show. */
/* If we don't have a file list, there is nothing to show. */
if (filelist == NULL) {
lastmessage = VACUUM;
free(present_name);
@@ -443,19 +439,18 @@ char *browse(char *path)
}
if (dir != NULL) {
/* Get the file list, and set longest and width in the process. */
/* Get the file list, and set gauge and piles in the process. */
read_the_list(path, dir);
closedir(dir);
dir = NULL;
}
/* If given, reselect the present_name and then discard it. */
/* If something was selected before, reselect it;
* otherwise, just select the first item (..). */
if (present_name != NULL) {
browser_select_dirname(present_name);
reselect(present_name);
free(present_name);
present_name = NULL;
/* Otherwise, select the first file or directory in the list. */
} else
selected = 0;
@@ -480,31 +475,27 @@ char *browse(char *path)
old_selected = selected;
kbinput = get_kbinput(edit, ISSET(SHOW_CURSOR));
kbinput = get_kbinput(midwin, ISSET(SHOW_CURSOR));
#ifdef ENABLE_MOUSE
if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y;
/* We can click on the edit window to select a filename. */
/* When the user clicked in the file list, select a filename. */
if (get_mouseinput(&mouse_y, &mouse_x, TRUE) == 0 &&
wmouse_trafo(edit, &mouse_y, &mouse_x, FALSE)) {
/* longest is the width of each column. There
* are two spaces between each column. */
selected = selected - selected % (editwinrows * width) +
(mouse_y * width) + (mouse_x / (longest + 2));
wmouse_trafo(midwin, &mouse_y, &mouse_x, FALSE)) {
selected = selected - selected % (usable_rows * piles) +
(mouse_y * piles) + (mouse_x / (gauge + 2));
/* If they clicked beyond the end of a row,
* select the last filename in that row. */
if (mouse_x > width * (longest + 2))
/* When beyond end-of-row, select the preceding filename. */
if (mouse_x > piles * (gauge + 2))
selected--;
/* If we're beyond the list, select the last filename. */
/* When beyond end-of-list, select the last filename. */
if (selected > list_length - 1)
selected = list_length - 1;
/* If we selected the same filename as last time, fake a
* press of the Enter key so that the file is read in. */
/* When a filename is clicked a second time, choose it. */
if (old_selected == selected)
kbinput = KEY_ENTER;
}
@@ -524,17 +515,15 @@ char *browse(char *path)
if (func == full_refresh) {
full_refresh();
#ifndef NANO_TINY
/* Simulate a window resize to force a directory reread. */
/* Simulate a terminal resize to force a directory reread. */
kbinput = KEY_WINCH;
#endif
} else if (func == do_help) {
do_help();
#ifndef NANO_TINY
/* The window dimensions might have changed, so act as if. */
/* The terminal dimensions might have changed, so act as if. */
kbinput = KEY_WINCH;
#endif
#ifndef NANO_TINY
} else if (func == do_toggle_void) {
} else if (func == do_toggle) {
TOGGLE(NO_HELP);
window_init();
kbinput = KEY_WINCH;
@@ -554,43 +543,42 @@ char *browse(char *path)
if (selected < list_length - 1)
selected++;
} else if (func == to_prev_word) {
selected -= (selected % width);
selected -= (selected % piles);
} else if (func == to_next_word) {
selected += width - 1 - (selected % width);
selected += piles - 1 - (selected % piles);
if (selected >= list_length)
selected = list_length - 1;
} else if (func == do_up) {
if (selected >= width)
selected -= width;
if (selected >= piles)
selected -= piles;
} else if (func == do_down) {
if (selected + width <= list_length - 1)
selected += width;
if (selected + piles <= list_length - 1)
selected += piles;
} else if (func == to_prev_block) {
selected = ((selected / (editwinrows * width)) *
editwinrows * width) + selected % width;
selected = ((selected / (usable_rows * piles)) * usable_rows * piles) +
selected % piles;
} else if (func == to_next_block) {
selected = ((selected / (editwinrows * width)) *
editwinrows * width) + selected % width +
editwinrows * width - width;
selected = ((selected / (usable_rows * piles)) * usable_rows * piles) +
selected % piles + usable_rows * piles - piles;
if (selected >= list_length)
selected = (list_length / width) * width + selected % width;
selected = (list_length / piles) * piles + selected % piles;
if (selected >= list_length)
selected -= width;
selected -= piles;
} else if (func == do_page_up) {
if (selected < width)
if (selected < piles)
selected = 0;
else if (selected < editwinrows * width)
selected = selected % width;
else if (selected < usable_rows * piles)
selected = selected % piles;
else
selected -= editwinrows * width;
selected -= usable_rows * piles;
} else if (func == do_page_down) {
if (selected + width >= list_length - 1)
if (selected + piles >= list_length - 1)
selected = list_length - 1;
else if (selected + editwinrows * width >= list_length)
selected = (selected + editwinrows * width - list_length) %
width + list_length - width;
else if (selected + usable_rows * piles >= list_length)
selected = (selected + usable_rows * piles - list_length) % piles +
list_length - piles;
else
selected += editwinrows * width;
selected += usable_rows * piles;
} else if (func == to_first_file) {
selected = 0;
} else if (func == to_last_file) {
@@ -615,8 +603,8 @@ char *browse(char *path)
#ifdef ENABLE_OPERATINGDIR
if (outside_of_confinement(path, FALSE)) {
/* TRANSLATORS: This refers to the confining effect of the
* option --operatingdir, not of --restricted. */
/* TRANSLATORS: This refers to the confining effect of
* the option --operatingdir, not of --restricted. */
statusline(ALERT, _("Can't go outside of %s"), operating_dir);
path = mallocstrcpy(path, present_path);
continue;
@@ -679,7 +667,7 @@ char *browse(char *path)
#endif
#ifndef NANO_TINY
} else if (kbinput == KEY_WINCH) {
; /* Nothing to do. */
; /* Gets handled below. */
#endif
} else if (func == do_exit) {
break;
@@ -687,11 +675,10 @@ char *browse(char *path)
unbound_key(kbinput);
#ifndef NANO_TINY
/* If the window resized, refresh the file list. */
/* If the terminal resized (or might have), refresh the file list. */
if (kbinput == KEY_WINCH) {
/* Remember the selected file, to be able to reselect it. */
present_name = copy_of(filelist[selected]);
/* Reread the contents of the current directory. */
goto read_directory_contents;
}
#endif
@@ -722,14 +709,10 @@ char *browse_in(const char *inpath)
path = free_and_assign(path, strip_last_component(path));
if (stat(path, &fileinfo) == -1 || !S_ISDIR(fileinfo.st_mode)) {
char *currentdir = nmalloc(PATH_MAX + 1);
path = free_and_assign(path, getcwd(currentdir, PATH_MAX + 1));
path = free_and_assign(path, realpath(".", NULL));
if (path == NULL) {
statusline(MILD, _("The working directory has disappeared"));
free(currentdir);
beep();
statusline(ALERT, _("The working directory has disappeared"));
napms(1200);
return NULL;
}

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* chars.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
* 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 *

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* color.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
* 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 *
@@ -53,6 +53,7 @@ void set_interface_colorpairs(void)
}
init_pair(index + 1, combo->fg, combo->bg);
interface_color_pair[index] = COLOR_PAIR(index + 1) | combo->attributes;
rescind_colors = FALSE;
} else {
if (index == FUNCTION_TAG || index == SCROLL_BAR)
interface_color_pair[index] = A_NORMAL;
@@ -72,6 +73,11 @@ void set_interface_colorpairs(void)
free(color_combo[index]);
}
if (rescind_colors) {
interface_color_pair[SPOTLIGHTED] = A_REVERSE;
interface_color_pair[ERROR_MESSAGE] = A_REVERSE;
}
}
/* Assign a pair number to each of the foreground/background color combinations
@@ -255,12 +261,14 @@ void check_the_multis(linestruct *line)
if (line->multidata[ink->id] == NOTHING) {
if (!astart)
continue;
} else if (line->multidata[ink->id] & (WHOLELINE|WOULDBE)) {
if (!astart && !anend)
} else if (line->multidata[ink->id] == WHOLELINE) {
/* Ensure that a detected start match is not actually an end match. */
if (!anend && (!astart || regexec(ink->end, line->data, 1,
&endmatch, 0) != 0))
continue;
} else if (line->multidata[ink->id] == JUSTONTHIS) {
if (astart && anend && regexec(ink->start, line->data + endmatch.rm_eo,
1, &startmatch, 0) != 0)
if (astart && anend && regexec(ink->start, line->data + startmatch.rm_eo +
endmatch.rm_eo, 1, &startmatch, 0) != 0)
continue;
} else if (line->multidata[ink->id] == STARTSHERE) {
if (astart && !anend)
@@ -272,6 +280,7 @@ void check_the_multis(linestruct *line)
/* There is a mismatch, so something changed: repaint. */
refresh_needed = TRUE;
perturbed = TRUE;
return;
}
}
@@ -342,21 +351,17 @@ void precalc_multicolorinfo(void)
1, &endmatch, 0) != 0)
tailline = tailline->next;
/* When there is no end match, mark relevant lines as such. */
if (tailline == NULL) {
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 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] = WHOLELINE;
if (tailline == NULL) {
line = openfile->filebot;
break;
}
tailline->multidata[ink->id] = ENDSHERE;
/* Look for a possible new start after the end match. */

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* cut.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
* Copyright (C) 2014 Mark Majeres *
* Copyright (C) 2016, 2018-2020 Benno Schulenberg *
* *
@@ -185,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;
@@ -194,7 +194,7 @@ void chop_word(bool forward)
openfile->current_x = strlen(openfile->current->data);
}
} else {
do_next_word(ISSET(AFTER_ENDS), 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;
@@ -435,9 +435,19 @@ void ingraft_buffer(linestruct *topline)
/* Meld a copy of the given buffer into the current file buffer. */
void copy_from_buffer(linestruct *somebuffer)
{
#ifdef ENABLE_COLOR
size_t threshold = openfile->edittop->lineno + editwinrows - 1;
#endif
linestruct *the_copy = copy_buffer(somebuffer);
ingraft_buffer(the_copy);
#ifdef ENABLE_COLOR
if (openfile->current->lineno > threshold || ISSET(SOFTWRAP))
recook = TRUE;
else
perturbed = TRUE;
#endif
}
#ifndef NANO_TINY
@@ -485,7 +495,7 @@ void do_snip(bool marked, bool until_eof, bool append)
/* 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))
if (line->data[openfile->current_x] != '\0')
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);
@@ -509,6 +519,9 @@ void do_snip(bool marked, bool until_eof, bool append)
set_modified();
refresh_needed = TRUE;
#ifdef ENABLE_COLOR
perturbed = TRUE;
#endif
}
/* Move text from the current buffer into the cutbuffer. */
@@ -694,9 +707,11 @@ void copy_text(void)
/* Copy text from the cutbuffer into the current buffer. */
void paste_text(void)
{
#ifndef NANO_TINY
#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;
@@ -728,6 +743,12 @@ void paste_text(void)
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;

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* definitions.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2021 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 *
@@ -108,6 +108,14 @@
#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
@@ -122,6 +130,9 @@
#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
@@ -159,8 +170,6 @@
/* 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
/* Basic control codes. */
@@ -215,7 +224,7 @@
#define FOREIGN_SEQUENCE 0x4FC
/* A special keycode for plugging into the input stream after a suspension. */
#define KEY_FLUSH KEY_F0
#define KEY_FRESH 0x4FE
#ifndef NANO_TINY
/* A special keycode for when we get a SIGWINCH (a window resize). */
@@ -354,7 +363,8 @@ enum {
BOOKSTYLE,
STATEFLAGS,
USE_MAGIC,
MINIBAR
MINIBAR,
ZERO
};
/* Structure types. */

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* files.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
* Copyright (C) 2015-2021 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -33,6 +33,10 @@
#define RW_FOR_ALL (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
#ifndef HAVE_FSYNC
# define fsync(...) 0
#endif
/* Add an item to the circular list of openfile structs. */
void make_new_buffer(void)
{
@@ -143,7 +147,7 @@ const char *locking_suffix = ".swp";
* existing version of that file. Return TRUE on success; FALSE otherwise. */
bool write_lockfile(const char *lockfilename, const char *filename, bool modified)
{
#ifdef HAVE_PWD_H
#if defined(HAVE_PWD_H) && defined(HAVE_GETEUID)
pid_t mypid = getpid();
uid_t myuid = geteuid();
struct passwd *mypwuid = getpwuid(myuid);
@@ -303,14 +307,14 @@ char *do_lockfile(const char *filename, bool ask_the_user)
free(postedname);
free(pidstring);
choice = do_yesno_prompt(FALSE, promptstr);
choice = ask_user(YESORNO, promptstr);
free(promptstr);
/* When the user cancelled while we're still starting up, quit. */
if (choice < 0 && !we_are_running)
if (choice == CANCEL && !we_are_running)
finish();
if (choice < 1) {
if (choice != YES) {
free(lockfilename);
wipe_statusbar();
return SKIPTHISFILE;
@@ -346,8 +350,18 @@ bool has_valid_path(const char *filename)
char *parentdir = dirname(namecopy);
struct stat parentinfo;
bool validity = FALSE;
bool gone = FALSE;
if (stat(parentdir, &parentinfo) == -1) {
if (strcmp(parentdir, ".") == 0) {
char *currentdir = realpath(".", NULL);
gone = (currentdir == NULL && errno == ENOENT);
free(currentdir);
}
if (gone)
statusline(ALERT, _("The working directory has disappeared"));
else if (stat(parentdir, &parentinfo) == -1) {
if (errno == ENOENT)
/* TRANSLATORS: Keep the next ten messages at most 76 characters. */
statusline(ALERT, _("Directory '%s' does not exist"), parentdir);
@@ -411,7 +425,7 @@ bool open_buffer(const char *filename, bool new_one)
free(realname);
return FALSE;
}
#else
#elif defined(HAVE_GETEUID)
if (new_one && !(fileinfo.st_mode & (S_IWUSR|S_IWGRP|S_IWOTH)) &&
geteuid() == ROOT_UID)
statusline(ALERT, _("%s is meant to be read-only"), realname);
@@ -675,9 +689,13 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
block_sigwinch(TRUE);
#endif
#ifdef HAVE_FLOCKFILE
/* Lock the file before starting to read it, to avoid the overhead
* of locking it for each single byte that we read from it. */
flockfile(f);
#else
# define getc_unlocked getc
#endif
control_C_was_pressed = FALSE;
@@ -741,8 +759,10 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
errornumber = errno;
#ifdef HAVE_FUNLOCKFILE
/* We are done with the file, unlock it. */
funlockfile(f);
#endif
#ifndef NANO_TINY
block_sigwinch(FALSE);
@@ -811,25 +831,29 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
#ifndef NANO_TINY
else if (format == MAC_FILE)
/* TRANSLATORS: Keep the next three messages at most 78 characters. */
statusline(HUSH, P_("Read %zu line (Converted from Mac format)",
statusline(REMARK, P_("Read %zu line (Converted from Mac format)",
"Read %zu lines (Converted from Mac format)",
num_lines), num_lines);
else if (format == DOS_FILE)
statusline(HUSH, P_("Read %zu line (Converted from DOS format)",
statusline(REMARK, P_("Read %zu line (Converted from DOS format)",
"Read %zu lines (Converted from DOS format)",
num_lines), num_lines);
#endif
else
statusline(HUSH, P_("Read %zu line", "Read %zu lines",
else if ((!ISSET(MINIBAR) && !ISSET(ZERO)) || (we_are_running && undoable))
statusline(REMARK, P_("Read %zu line", "Read %zu lines",
num_lines), num_lines);
report_size = TRUE;
/* If we inserted less than a screenful, don't center the cursor. */
if (undoable && less_than_a_screenful(was_lineno, was_leftedge))
if (undoable && less_than_a_screenful(was_lineno, was_leftedge)) {
focusing = FALSE;
#ifdef ENABLE_COLOR
else if (undoable)
precalc_multicolorinfo();
perturbed = TRUE;
} else if (undoable) {
recook = TRUE;
#endif
}
#ifndef NANO_TINY
if (undoable)
@@ -898,7 +922,7 @@ int open_file(const char *filename, bool new_one, FILE **f)
statusline(ALERT, _("Error reading %s: %s"), filename, strerror(errno));
close(fd);
fd = -1;
} else
} else if (!ISSET(ZERO) || we_are_running)
statusbar(_("Reading..."));
}
@@ -948,7 +972,9 @@ static pid_t pid_of_command = -1;
/* Send an unconditional kill signal to the running external command. */
void cancel_the_command(int signal)
{
#ifdef SIGKILL
kill(pid_of_command, SIGKILL);
#endif
}
/* Send the text that starts at the given line to file descriptor fd. */
@@ -971,10 +997,12 @@ void send_data(const linestruct *line, int fd)
/* Execute the given command in a shell. Return TRUE on success. */
bool execute_command(const char *command)
{
#if defined(HAVE_FORK) && defined(HAVE_PIPE) && defined(HAVE_WAIT)
int from_fd[2], to_fd[2];
/* The pipes through which text will be written and read. */
struct sigaction oldaction, newaction = {{0}};
/* Original and temporary handlers for SIGINT. */
ssize_t was_lineno = (openfile->mark ? 0 : openfile->current->lineno);
const bool should_pipe = (command[0] == '|');
FILE *stream;
@@ -1006,6 +1034,7 @@ bool execute_command(const char *command)
if (should_pipe) {
if (dup2(to_fd[0], STDIN_FILENO) < 0)
exit(5);
close(from_fd[1]);
close(to_fd[1]);
}
@@ -1052,7 +1081,8 @@ bool execute_command(const char *command)
}
add_undo(CUT, NULL);
do_snip(openfile->mark != NULL, openfile->mark == NULL, FALSE);
openfile->filetop->has_anchor = FALSE;
if (openfile->filetop->next == NULL)
openfile->filetop->has_anchor = FALSE;
update_undo(CUT);
}
@@ -1088,8 +1118,11 @@ bool execute_command(const char *command)
else
read_file(stream, 0, "pipe", TRUE);
if (should_pipe && !ISSET(MULTIBUFFER))
if (should_pipe && !ISSET(MULTIBUFFER)) {
if (was_lineno)
goto_line_posx(was_lineno, 0);
add_undo(COUPLE_END, N_("filtering"));
}
/* Wait for the external command (and possibly data sender) to terminate. */
wait(NULL);
@@ -1104,12 +1137,16 @@ bool execute_command(const char *command)
terminal_init();
return TRUE;
#else
return FALSE;
#endif
}
#endif /* NANO_TINY */
/* Insert a file into the current buffer, or into a new buffer when
* the MULTIBUFFER flag is set. */
void do_insertfile(bool execute)
/* Insert a file into the current buffer (or into a new buffer). But when
* execute is TRUE, run a command in the shell and insert its output into
* the buffer, or just run one of the tools listed in the help lines. */
void insert_a_file_or(bool execute)
{
int response;
const char *msg;
@@ -1158,15 +1195,9 @@ void do_insertfile(bool execute)
present_path = mallocstrcpy(present_path, "./");
response = do_prompt(
#ifndef NANO_TINY
execute ? MEXECUTE :
#endif
MINSERTFILE, given,
#ifndef NANO_TINY
execute ? &execute_history :
#endif
NULL, edit_refresh, msg,
response = do_prompt(execute ? MEXECUTE : MINSERTFILE, given,
execute ? &execute_history : NULL,
edit_refresh, msg,
#ifdef ENABLE_OPERATINGDIR
operating_dir != NULL ? operating_dir :
#endif
@@ -1242,7 +1273,7 @@ void do_insertfile(bool execute)
if (*answer != '\0') {
execute_command(answer);
#ifdef ENABLE_HISTORIES
update_history(&execute_history, answer);
update_history(&execute_history, answer, PRUNE_DUPLICATE);
#endif
}
@@ -1275,7 +1306,7 @@ void do_insertfile(bool execute)
if (!execute)
#endif
if (has_old_position(answer, &priorline, &priorcol))
do_gotolinecolumn(priorline, priorcol, FALSE, FALSE);
goto_line_and_column(priorline, priorcol, FALSE, FALSE);
}
#endif
/* Update title bar and color info for this new buffer. */
@@ -1306,10 +1337,10 @@ void do_insertfile(bool execute)
}
/* If the current mode of operation allows it, go insert a file. */
void do_insertfile_void(void)
void do_insertfile(void)
{
if (!in_restricted_mode())
do_insertfile(FALSE);
insert_a_file_or(FALSE);
}
#ifndef NANO_TINY
@@ -1317,7 +1348,7 @@ void do_insertfile_void(void)
void do_execute(void)
{
if (!in_restricted_mode())
do_insertfile(TRUE);
insert_a_file_or(TRUE);
}
#endif
@@ -1325,106 +1356,36 @@ void do_execute(void)
* absolute path (plus filename) when the path exists, and NULL when not. */
char *get_full_path(const char *origpath)
{
char *allocation, *here, *target, *last_slash;
char *just_filename = NULL;
int attempts = 0;
char *untilded, *target, *slash;
struct stat fileinfo;
bool path_only;
if (origpath == NULL)
return NULL;
allocation = nmalloc(PATH_MAX + 1);
here = getcwd(allocation, PATH_MAX + 1);
untilded = real_dir_from_tilde(origpath);
target = realpath(untilded, NULL);
slash = strrchr(untilded, '/');
/* If getting the current directory failed, go up one level and try again,
* until we find an existing directory, and use that as the current one. */
while (here == NULL && attempts < 20) {
IGNORE_CALL_RESULT(chdir(".."));
here = getcwd(allocation, PATH_MAX + 1);
attempts++;
}
/* If realpath() returned NULL, try without the last component,
* as this can be a file that does not exist yet. */
if (!target && slash && slash[1]) {
*slash = '\0';
target = realpath(untilded, NULL);
/* If we found a directory, make sure its path ends in a slash. */
if (here != NULL) {
if (strcmp(here, "/") != 0) {
here = nrealloc(here, strlen(here) + 2);
strcat(here, "/");
}
} else {
here = copy_of("");
free(allocation);
}
target = real_dir_from_tilde(origpath);
/* Determine whether the target path refers to a directory. If statting
* target fails, however, assume that it refers to a new, unsaved buffer. */
path_only = (stat(target, &fileinfo) != -1 && S_ISDIR(fileinfo.st_mode));
/* If the target is a directory, make sure its path ends in a slash. */
if (path_only) {
size_t length = strlen(target);
if (target[length - 1] != '/') {
target = nrealloc(target, length + 2);
strcat(target, "/");
/* Upon success, re-add the last component of the original path. */
if (target) {
target = nrealloc(target, strlen(target) + strlen(slash + 1) + 1);
strcat(target, slash + 1);
}
}
last_slash = strrchr(target, '/');
/* If the target path does not contain a slash, then it is a bare filename
* and must therefore be located in the working directory. */
if (last_slash == NULL) {
just_filename = target;
target = here;
} else {
/* If target contains a filename, separate the two. */
if (!path_only) {
just_filename = copy_of(last_slash + 1);
*(last_slash + 1) = '\0';
}
/* If we can't change to the target directory, give up. Otherwise,
* get the canonical path to this target directory. */
if (chdir(target) == -1) {
free(target);
target = NULL;
} else {
free(target);
allocation = nmalloc(PATH_MAX + 1);
target = getcwd(allocation, PATH_MAX + 1);
/* If we got a result, make sure it ends in a slash.
* Otherwise, ensure that we return NULL. */
if (target != NULL) {
if (strcmp(target, "/") != 0) {
target = nrealloc(target, strlen(target) + 2);
strcat(target, "/");
}
} else {
path_only = TRUE;
free(allocation);
}
/* Finally, go back to where we were before. We don't check
* for an error, since we can't do anything if we get one. */
IGNORE_CALL_RESULT(chdir(here));
}
free(here);
/* Ensure that a directory path ends with a slash. */
if (target && stat(target, &fileinfo) == 0 && S_ISDIR(fileinfo.st_mode)) {
target = nrealloc(target, strlen(target) + 2);
strcat(target, "/");
}
/* If we were given more than a bare path, concatenate the target path
* with the filename portion to get the full, absolute file path. */
if (!path_only && target != NULL) {
target = nrealloc(target, strlen(target) + strlen(just_filename) + 1);
strcat(target, just_filename);
}
free(just_filename);
free(untilded);
return target;
}
@@ -1656,6 +1617,7 @@ bool make_backup_of(char *realname)
if (backup_file == NULL)
goto problem;
#ifdef HAVE_FCHOWN
/* Try to change owner and group to those of the original file;
* ignore permission errors, as a normal user cannot change the owner. */
if (fchown(descriptor, openfile->statinfo->st_uid,
@@ -1663,7 +1625,8 @@ bool make_backup_of(char *realname)
fclose(backup_file);
goto problem;
}
#endif
#ifdef HAVE_FCHMOD
/* Set the backup's permissions to those of the original file.
* It is not a security issue if this fails, as we have created
* the file with just read and write permission for the owner. */
@@ -1671,6 +1634,7 @@ bool make_backup_of(char *realname)
fclose(backup_file);
goto problem;
}
#endif
original = fopen(realname, "rb");
@@ -1735,8 +1699,8 @@ bool make_backup_of(char *realname)
* ask the user what to do, because if something goes wrong during the
* save of the file itself, its contents may be lost. */
/* TRANSLATORS: Try to keep this message at most 76 characters. */
if (errno != ENOSPC && do_yesno_prompt(FALSE, _("Cannot make backup; "
"continue and save actual file? ")) == 1)
if (errno != ENOSPC && ask_user(YESORNO, _("Cannot make backup; "
"continue and save actual file? ")) == YES)
return TRUE;
/* TRANSLATORS: The %s is the reason of failure. */
@@ -1977,6 +1941,19 @@ bool write_file(const char *name, FILE *thefile, bool normal,
statusline(ALERT, _("Error writing %s: %s"), realname, strerror(errno));
cleanup_and_exit:
#ifndef NANO_TINY
if (errno == ENOSPC && normal) {
napms(3200); lastmessage = VACUUM;
/* TRANSLATORS: This warns for data loss when the disk is full. */
statusline(ALERT, _("File on disk has been truncated!"));
napms(3200); lastmessage = VACUUM;
/* TRANSLATORS: This is a suggestion to the user,
* where "resume" means resuming from suspension.
* Try to keep this at most 76 characters. */
statusline(ALERT, _("Maybe ^T^Z, make room on disk, resume, then ^S^X"));
stat_with_alloc(realname, &openfile->statinfo);
}
#endif
free(tempname);
free(realname);
return FALSE;
@@ -2030,7 +2007,7 @@ bool write_file(const char *name, FILE *thefile, bool normal,
}
#ifndef NANO_TINY
if (ISSET(MINIBAR) && LINES > 1 && annotate)
if (ISSET(MINIBAR) && !ISSET(ZERO) && LINES > 1 && annotate)
report_size = TRUE;
else
#endif
@@ -2058,7 +2035,7 @@ bool write_region_to_file(const char *name, FILE *stream, bool normal,
get_region(&topline, &top_x, &botline, &bot_x);
/* When needed, prepare a magic end line for the region. */
if (bot_x > 0 && !ISSET(NO_NEWLINES)) {
if (normal && bot_x > 0 && !ISSET(NO_NEWLINES)) {
stopper = make_new_node(botline);
stopper->data = copy_of("");
} else
@@ -2089,13 +2066,12 @@ bool write_region_to_file(const char *name, FILE *stream, bool normal,
}
#endif /* !NANO_TINY */
/* Write the current buffer to disk. If the mark is on, write the current
* marked selection to disk. If exiting is TRUE, write the entire buffer
* to disk regardless of whether the mark is on. Do not ask for a name
* when withprompt is FALSE nor when the SAVE_ON_EXIT flag is set and the
* buffer already has a name. Return 0 on error, 1 on success, and 2 when
/* Write the current buffer (or marked region) to disk. If exiting is TRUE,
* write the entire buffer regardless of whether the mark is on. Do not ask
* for a name when withprompt is FALSE (nor when doing save-on-exit and the
* buffer already has a name). Return 0 on error, 1 on success, and 2 when
* the buffer is to be discarded. */
int do_writeout(bool exiting, bool withprompt)
int write_it_out(bool exiting, bool withprompt)
{
char *given;
/* The filename we offer, or what the user typed so far. */
@@ -2116,9 +2092,10 @@ int do_writeout(bool exiting, bool withprompt)
#endif
while (TRUE) {
int response = 0, choice = 0;
functionptrtype func;
const char *msg;
int response = 0;
int choice = NO;
#ifndef NANO_TINY
const char *formatstr = (openfile->fmt == DOS_FILE) ? _(" [DOS Format]") :
(openfile->fmt == MAC_FILE) ? _(" [Mac Format]") : "";
@@ -2184,22 +2161,24 @@ int do_writeout(bool exiting, bool withprompt)
} else
#endif
#ifndef NANO_TINY
if (func == dos_format_void) {
if (func == dos_format) {
openfile->fmt = (openfile->fmt == DOS_FILE) ? NIX_FILE : DOS_FILE;
continue;
} else if (func == mac_format_void) {
} else if (func == mac_format) {
openfile->fmt = (openfile->fmt == MAC_FILE) ? NIX_FILE : MAC_FILE;
continue;
} else if (func == backup_file_void) {
} else if (func == back_it_up) {
TOGGLE(MAKE_BACKUP);
continue;
} else if (func == prepend_void) {
method = (method == PREPEND) ? OVERWRITE : PREPEND;
} else if (func == prepend_it || func == append_it) {
if (func == prepend_it)
method = (method == PREPEND) ? OVERWRITE : PREPEND;
else
method = (method == APPEND) ? OVERWRITE : APPEND;
if (strcmp(answer, openfile->filename) == 0)
given[0] = '\0';
continue;
} else if (func == append_void) {
method = (method == APPEND) ? OVERWRITE : APPEND;
continue;
}
} else
#endif
if (func == do_help)
continue;
@@ -2257,8 +2236,8 @@ int do_writeout(bool exiting, bool withprompt)
if (exiting || !openfile->mark)
#endif
{
if (do_yesno_prompt(FALSE, _("Save file under "
"DIFFERENT NAME? ")) < 1)
if (ask_user(YESORNO, _("Save file under "
"DIFFERENT NAME? ")) != YES)
continue;
maychange = TRUE;
}
@@ -2271,12 +2250,12 @@ int do_writeout(bool exiting, bool withprompt)
sprintf(message, question, name);
choice = do_yesno_prompt(FALSE, message);
choice = ask_user(YESORNO, message);
free(message);
free(name);
if (choice < 1)
if (choice != YES)
continue;
}
}
@@ -2292,7 +2271,7 @@ int do_writeout(bool exiting, bool withprompt)
warn_and_briefly_pause(_("File on disk has changed"));
/* TRANSLATORS: Try to keep this at most 76 characters. */
choice = do_yesno_prompt(FALSE, _("File was modified "
choice = ask_user(YESORNO, _("File was modified "
"since you opened it; continue saving? "));
wipe_statusbar();
@@ -2300,14 +2279,16 @@ int do_writeout(bool exiting, bool withprompt)
* overwrite the file right here when requested. */
if (ISSET(SAVE_ON_EXIT) && withprompt) {
free(given);
if (choice == 1)
if (choice == YES)
return write_file(openfile->filename, NULL,
NORMAL, OVERWRITE, NONOTES);
else if (choice == 0)
else if (choice == NO) /* Discard buffer */
return 2;
else
return 0;
} else if (choice != 1) {
} else if (choice == CANCEL && exiting) {
continue;
} else if (choice != YES) {
free(given);
return 1;
}
@@ -2331,17 +2312,17 @@ int do_writeout(bool exiting, bool withprompt)
}
/* Write the current buffer to disk, or discard it. */
void do_writeout_void(void)
void do_writeout(void)
{
/* If the user chose to discard the buffer, close it. */
if (do_writeout(FALSE, TRUE) == 2)
if (write_it_out(FALSE, TRUE) == 2)
close_and_go();
}
/* If it has a name, write the current buffer to disk without prompting. */
void do_savefile(void)
{
if (do_writeout(FALSE, FALSE) == 2)
if (write_it_out(FALSE, FALSE) == 2)
close_and_go();
}
@@ -2629,6 +2610,7 @@ char *input_tab(char *morsel, size_t *place, void (*refresh_func)(void), bool *l
/* If there is more than one possible completion, show a sorted list. */
if (num_matches > 1) {
int lastrow = editwinrows - 1 - (ISSET(ZERO) && LINES > 1 ? 1 : 0);
size_t longest_name = 0;
size_t nrows, ncols;
int row;
@@ -2654,7 +2636,7 @@ char *input_tab(char *morsel, size_t *place, void (*refresh_func)(void), bool *l
ncols = (COLS + 1) / (longest_name + 2);
nrows = (num_matches + ncols - 1) / ncols;
row = (nrows < editwinrows - 1) ? editwinrows - nrows - 1 : 0;
row = (nrows < lastrow) ? lastrow - nrows : 0;
/* Blank the edit window and hide the cursor. */
blank_edit();
@@ -2664,23 +2646,23 @@ char *input_tab(char *morsel, size_t *place, void (*refresh_func)(void), bool *l
for (match = 0; match < num_matches; match++) {
char *disp;
wmove(edit, row, (longest_name + 2) * (match % ncols));
wmove(midwin, row, (longest_name + 2) * (match % ncols));
if (row == editwinrows - 1 && (match + 1) % ncols == 0 &&
if (row == lastrow && (match + 1) % ncols == 0 &&
match + 1 < num_matches) {
waddstr(edit, _("(more)"));
waddstr(midwin, _("(more)"));
break;
}
disp = display_string(matches[match], 0, longest_name, FALSE, FALSE);
waddstr(edit, disp);
waddstr(midwin, disp);
free(disp);
if ((match + 1) % ncols == 0)
row++;
}
wnoutrefresh(edit);
wnoutrefresh(midwin);
*listed = TRUE;
}

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* global.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014-2020 Benno Schulenberg *
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
* Copyright (C) 2014-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 *
@@ -80,8 +80,6 @@ linestruct *pletion_line = NULL;
bool also_the_last = FALSE;
/* Whether indenting/commenting should include the last line of
* the marked region. */
bool hide_cursor = FALSE;
/* Whether to suppress the cursor when highlighting a search match. */
char *answer = NULL;
/* The answer string used by the status-bar prompt. */
@@ -120,12 +118,12 @@ size_t wrap_at = 0;
WINDOW *topwin = NULL;
/* The top portion of the screen, showing the version number of nano,
* the name of the file, and whether the buffer was modified. */
WINDOW *edit = NULL;
WINDOW *midwin = NULL;
/* The middle portion of the screen: the edit window, showing the
* contents of the current buffer, the file we are editing. */
WINDOW *bottomwin = NULL;
/* The bottom portion of the screen, where we display statusbar
* messages, the status-bar prompt, and a list of shortcuts. */
WINDOW *footwin = NULL;
/* The bottom portion of the screen, where status-bar messages,
* the status-bar prompt, and a list of shortcuts are shown. */
int editwinrows = 0;
/* How many rows does the edit window take up? */
int editwincols = -1;
@@ -203,6 +201,12 @@ char *syntaxstr = NULL;
/* The color syntax name specified on the command line. */
bool have_palette = FALSE;
/* Whether the colors for the current syntax have been initialized. */
bool rescind_colors = FALSE;
/* Becomes TRUE when NO_COLOR is set in the environment. */
bool perturbed = FALSE;
/* Whether the multiline-coloring situation has changed. */
bool recook = FALSE;
/* Whether the multidata should be recalculated. */
#endif
int currmenu = MMOST;
@@ -218,15 +222,16 @@ funcstruct *exitfunc;
linestruct *search_history = NULL;
/* The current item in the list of strings that were searched for. */
linestruct *execute_history = NULL;
/* The current item in the list of commands that were run with ^R ^X. */
linestruct *replace_history = NULL;
/* The current item in the list of replace strings. */
linestruct *execute_history = NULL;
/* The current item in the list of commands that were run with ^T. */
#ifdef ENABLE_HISTORIES
linestruct *searchtop = NULL;
/* The oldest item in the list of search strings. */
linestruct *searchbot = NULL;
/* The newest item in the list of search strings. */
/* The empty item at the end of the list of search strings. */
linestruct *replacetop = NULL;
linestruct *replacebot = NULL;
@@ -282,72 +287,36 @@ size_t light_to_col = 0;
#endif
/* Empty functions, for the most part corresponding to toggles. */
void case_sens_void(void)
{
}
void regexp_void(void)
{
}
void backwards_void(void)
{
}
void flip_replace(void)
{
}
void flip_goto(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
void to_files(void)
{
}
void goto_dir(void)
{
}
void to_files(void) {;}
void goto_dir(void) {;}
#endif
#ifndef NANO_TINY
void do_nothing(void)
{
}
void do_toggle_void(void)
{
}
void dos_format_void(void)
{
}
void mac_format_void(void)
{
}
void append_void(void)
{
}
void prepend_void(void)
{
}
void backup_file_void(void)
{
}
void flip_execute(void)
{
}
void flip_pipe(void)
{
}
void flip_convert(void)
{
}
void do_nothing(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) {;}
#endif
#ifdef ENABLE_MULTIBUFFER
void flip_newbuffer(void)
{
}
void flip_newbuffer(void) {;}
#endif
void discard_buffer(void)
{
}
void do_cancel(void)
{
}
void discard_buffer(void) {;}
void do_cancel(void) {;}
/* Add a function to the linked list of functions. */
void add_to_funcs(void (*func)(void), int menus, const char *desc,
@@ -554,6 +523,14 @@ functionptrtype interpret(int *keycode)
}
#endif /* ENABLE_BROWSER || ENABLE_HELP */
#if defined(NANO_TINY) && defined(ENABLE_LINENUMBERS)
/* Allow toggling line numbers also in the tiny version. */
void toggle_numbers(void)
{
TOGGLE(LINE_NUMBERS);
}
#endif
/* These two tags are used elsewhere too, so they are global. */
/* TRANSLATORS: Try to keep the next two strings at most 10 characters. */
const char *exit_tag = N_("Exit");
@@ -631,7 +608,7 @@ void shortcut_init(void)
const char *nextfile_gist = N_("Switch to the next file buffer");
#endif
const char *verbatim_gist = N_("Insert the next keystroke verbatim");
const char *tab_gist = N_("Insert a tab at the cursor position");
const char *tab_gist = N_("Insert a tab at the cursor position (or indent marked lines)");
const char *enter_gist = N_("Insert a newline at the cursor position");
const char *delete_gist = N_("Delete the character under the cursor");
const char *backspace_gist =
@@ -650,10 +627,10 @@ void shortcut_init(void)
#endif
#ifndef NANO_TINY
const char *wordcount_gist =
N_("Count the number of words, lines, and characters");
N_("Count the number of lines, words, and characters");
const char *suspend_gist = N_("Suspend the editor (return to the shell)");
#endif
const char *refresh_gist = N_("Refresh (redraw) the current screen");
const char *suspend_gist = N_("Suspend the editor (if suspension is enabled)");
#ifdef ENABLE_WORDCOMPLETION
const char *completion_gist = N_("Try and complete the current word");
#endif
@@ -755,7 +732,7 @@ void shortcut_init(void)
add_to_funcs(flip_goto, MGOTOLINE, "Go To Text", "x", 0, VIEW);
#endif
add_to_funcs(do_writeout_void, MMAIN,
add_to_funcs(do_writeout, MMAIN,
N_("Write Out"), WITHORSANS(writeout_gist), TOGETHER, NOVIEW);
#ifdef ENABLE_JUSTIFY
@@ -763,7 +740,7 @@ void shortcut_init(void)
* otherwise, show Insert anyway, to keep the help items paired. */
if (!ISSET(RESTRICTED))
#endif
add_to_funcs(do_insertfile_void, MMAIN,
add_to_funcs(do_insertfile, MMAIN,
N_("Read File"), WITHORSANS(readfile_gist), BLANKAFTER,
/* We allow inserting files in view mode if multibuffer mode
* is available, so that the user can view multiple files. */
@@ -821,7 +798,7 @@ void shortcut_init(void)
#if defined(NANO_TINY) || defined(ENABLE_JUSTIFY)
/* Conditionally placing this one here or further on, to keep the
* help items nicely paired in most conditions. */
add_to_funcs(do_gotolinecolumn_void, MMAIN,
add_to_funcs(do_gotolinecolumn, MMAIN,
N_("Go To Line"), WITHORSANS(gotoline_gist), BLANKAFTER, VIEW);
#endif
@@ -851,9 +828,9 @@ void shortcut_init(void)
N_("No Replace"), WITHORSANS(whereis_gist), BLANKAFTER, VIEW);
#ifdef ENABLE_HISTORIES
add_to_funcs(get_history_older_void, MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE,
add_to_funcs(get_older_item, MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE,
N_("Older"), WITHORSANS(older_gist), TOGETHER, VIEW);
add_to_funcs(get_history_newer_void, MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE,
add_to_funcs(get_newer_item, MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE,
N_("Newer"), WITHORSANS(newer_gist), BLANKAFTER, VIEW);
#endif
@@ -864,7 +841,7 @@ void shortcut_init(void)
#ifdef ENABLE_BROWSER
add_to_funcs(goto_dir, MBROWSER,
/* TRANSLATORS: Try to keep the next seven strings at most 10 characters. */
/* TRANSLATORS: Try to keep the next four strings at most 10 characters. */
N_("Go To Dir"), WITHORSANS(gotodir_gist), TOGETHER, VIEW);
#ifdef ENABLE_HELP
add_to_funcs(full_refresh, MBROWSER,
@@ -968,7 +945,7 @@ void shortcut_init(void)
#endif
#if !defined(NANO_TINY) && !defined(ENABLE_JUSTIFY)
add_to_funcs(do_gotolinecolumn_void, MMAIN,
add_to_funcs(do_gotolinecolumn, MMAIN,
N_("Go To Line"), WITHORSANS(gotoline_gist), BLANKAFTER, VIEW);
#endif
@@ -1005,21 +982,22 @@ void shortcut_init(void)
#endif
#ifndef NANO_TINY
add_to_funcs(do_wordlinechar_count, MMAIN,
add_to_funcs(count_lines_words_and_characters, MMAIN,
N_("Word Count"), WITHORSANS(wordcount_gist), TOGETHER, VIEW);
#endif
add_to_funcs(do_verbatim_input, MMAIN,
N_("Verbatim"), WITHORSANS(verbatim_gist), BLANKAFTER, NOVIEW);
#ifndef NANO_TINY
add_to_funcs(do_suspend, MMAIN,
N_("Suspend"), WITHORSANS(suspend_gist), TOGETHER, VIEW);
#endif
#ifdef ENABLE_HELP
add_to_funcs(full_refresh, MMAIN,
N_("Refresh"), WITHORSANS(refresh_gist), TOGETHER, VIEW);
N_("Refresh"), WITHORSANS(refresh_gist), BLANKAFTER, VIEW);
#endif
add_to_funcs(do_suspend_void, MMAIN,
N_("Suspend"), WITHORSANS(suspend_gist), BLANKAFTER, VIEW);
#ifndef NANO_TINY
add_to_funcs(do_indent, MMAIN,
N_("Indent"), WITHORSANS(indent_gist), TOGETHER, NOVIEW);
@@ -1049,7 +1027,7 @@ void shortcut_init(void)
N_("Down to anchor"), WITHORSANS(nextanchor_gist), BLANKAFTER, VIEW);
add_to_funcs(zap_text, MMAIN,
/* TRANSLATORS: This *deletes* a line or marked region. */
/* TRANSLATORS: This refers to deleting a line or marked region. */
N_("Zap"), WITHORSANS(zap_gist), BLANKAFTER, NOVIEW);
if (!ISSET(RESTRICTED)) {
@@ -1111,9 +1089,9 @@ void shortcut_init(void)
#endif
#ifndef NANO_TINY
add_to_funcs(dos_format_void, MWRITEFILE,
add_to_funcs(dos_format, MWRITEFILE,
N_("DOS Format"), WITHORSANS(dos_gist), TOGETHER, NOVIEW);
add_to_funcs(mac_format_void, MWRITEFILE,
add_to_funcs(mac_format, MWRITEFILE,
N_("Mac Format"), WITHORSANS(mac_gist), TOGETHER, NOVIEW);
/* If we're using restricted mode, the Append, Prepend, and Backup toggles
@@ -1121,12 +1099,12 @@ void shortcut_init(void)
* reduplicating the current file, and the third is not allowed as it
* would write to a file not specified on the command line. */
if (!ISSET(RESTRICTED)) {
add_to_funcs(append_void, MWRITEFILE,
add_to_funcs(append_it, MWRITEFILE,
N_("Append"), WITHORSANS(append_gist), TOGETHER, NOVIEW);
add_to_funcs(prepend_void, MWRITEFILE,
add_to_funcs(prepend_it, MWRITEFILE,
N_("Prepend"), WITHORSANS(prepend_gist), TOGETHER, NOVIEW);
add_to_funcs(backup_file_void, MWRITEFILE,
add_to_funcs(back_it_up, MWRITEFILE,
N_("Backup File"), WITHORSANS(backup_gist), BLANKAFTER, NOVIEW);
}
@@ -1141,7 +1119,7 @@ void shortcut_init(void)
add_to_funcs(cut_till_eof, MEXECUTE,
N_("Cut Till End"), WITHORSANS(cuttilleof_gist), BLANKAFTER, NOVIEW);
add_to_funcs(do_suspend_void, MEXECUTE,
add_to_funcs(do_suspend, MEXECUTE,
N_("Suspend"), WITHORSANS(suspend_gist), BLANKAFTER, VIEW);
}
#endif /* !NANO_TINY */
@@ -1206,25 +1184,32 @@ void shortcut_init(void)
add_to_sclist(MMAIN|MBROWSER|MHELP, "^X", 0, do_exit, 0);
if (!ISSET(PRESERVE))
add_to_sclist(MMAIN, "^S", 0, do_savefile, 0);
add_to_sclist(MMAIN, "^O", 0, do_writeout_void, 0);
add_to_sclist(MMAIN, "^R", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN, "Ins", KEY_IC, do_insertfile_void, 0);
add_to_sclist(MMAIN, "^O", 0, do_writeout, 0);
add_to_sclist(MMAIN, "^R", 0, do_insertfile, 0);
add_to_sclist(MMAIN, "Ins", KEY_IC, do_insertfile, 0);
if (!ISSET(PRESERVE))
add_to_sclist(MMAIN|MBROWSER|MHELP, "^Q", 0, do_search_backward, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP, "^W", 0, do_search_forward, 0);
add_to_sclist(MMAIN, "^\\", 0, do_replace, 0);
add_to_sclist(MMAIN, "M-R", 0, do_replace, 0);
add_to_sclist(MMOST, "^K", 0, cut_text, 0);
#ifdef NANO_TINY
add_to_sclist(MMAIN, "^U", 0, paste_text, 0);
#else
add_to_sclist(MMOST, "^U", 0, paste_text, 0);
#ifndef NANO_TINY
add_to_sclist(MMAIN, "^T", 0, do_execute, 0);
#endif
#ifdef ENABLE_JUSTIFY
add_to_sclist(MMAIN, "^J", '\n', do_justify, 0);
#endif
#ifdef ENABLE_SPELLER
add_to_sclist(MEXECUTE, "^S", 0, do_spell, 0);
#ifndef NANO_TINY
if (!ISSET(PRESERVE))
add_to_sclist(MEXECUTE, "^S", 0, do_spell, 0);
add_to_sclist(MEXECUTE, "^T", 0, do_spell, 0);
#else
add_to_sclist(MMAIN, "^T", 0, do_spell, 0);
#endif
#endif
#ifdef ENABLE_COLOR
add_to_sclist(MMAIN, "M-B", 0, do_linter, 0);
@@ -1233,9 +1218,9 @@ void shortcut_init(void)
add_to_sclist(MEXECUTE, "^O", 0, do_formatter, 0);
#endif
add_to_sclist(MMAIN, "^C", 0, report_cursor_position, 0);
add_to_sclist(MMAIN, SLASH_OR_DASH, 0, do_gotolinecolumn_void, 0);
add_to_sclist(MMAIN, "M-G", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MMAIN, "^_", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MMAIN, SLASH_OR_DASH, 0, do_gotolinecolumn, 0);
add_to_sclist(MMAIN, "M-G", 0, do_gotolinecolumn, 0);
add_to_sclist(MMAIN, "^_", 0, do_gotolinecolumn, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "^Y", 0, do_page_up, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "PgUp", KEY_PPAGE, do_page_up, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "^V", 0, do_page_down, 0);
@@ -1250,19 +1235,23 @@ void shortcut_init(void)
add_to_sclist(MMAIN|MBROWSER|MHELP, "M-W", 0, do_findnext, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP, "M-Q", 0, do_findprevious, 0);
#ifdef NANO_TINY
#ifdef ENABLE_LINENUMBERS
add_to_sclist(MMAIN, "M-N", 0, toggle_numbers, 0);
#else
add_to_sclist(MMAIN, "M-B", 0, to_prev_word, 0);
add_to_sclist(MMAIN, "M-D", 0, to_prev_word, 0);
add_to_sclist(MMAIN, "M-N", 0, to_next_word, 0);
#endif
add_to_sclist(MMAIN, "M-D", 0, to_prev_word, 0);
add_to_sclist(MMAIN, "M-F", 0, to_next_word, 0);
#else
add_to_sclist(MMAIN, "M-]", 0, do_find_bracket, 0);
add_to_sclist(MMAIN, "M-A", 0, do_mark, 0);
add_to_sclist(MMAIN, "^6", 0, do_mark, 0);
add_to_sclist(MMAIN, "^^", 0, do_mark, 0);
add_to_sclist(MMAIN, "M-6", 0, copy_text, 0);
add_to_sclist(MMAIN, "M-^", 0, copy_text, 0);
add_to_sclist(MMOST, "M-6", 0, copy_text, 0);
add_to_sclist(MMOST, "M-^", 0, copy_text, 0);
add_to_sclist(MMAIN, "M-}", 0, do_indent, 0);
add_to_sclist(MMAIN, "Tab", INDENT_KEY, do_indent, 0);
add_to_sclist(MMAIN, "", INDENT_KEY, do_indent, 0);
add_to_sclist(MMAIN, "M-{", 0, do_unindent, 0);
add_to_sclist(MMAIN, "Sh-Tab", SHIFT_TAB, do_unindent, 0);
add_to_sclist(MMAIN, "M-:", 0, record_macro, 0);
@@ -1369,7 +1358,9 @@ void shortcut_init(void)
#ifndef NANO_TINY
add_to_sclist(MMAIN, "M-T", 0, cut_till_eof, 0);
add_to_sclist(MEXECUTE, "^V", 0, cut_till_eof, 0);
add_to_sclist(MMAIN, "M-D", 0, do_wordlinechar_count, 0);
add_to_sclist(MEXECUTE, "^Z", 0, do_suspend, 0);
add_to_sclist(MMAIN, "^Z", 0, suggest_ctrlT_ctrlZ, 0);
add_to_sclist(MMAIN, "M-D", 0, count_lines_words_and_characters, 0);
#else
add_to_sclist(MMAIN, "M-H", 0, do_help, 0);
#endif
@@ -1384,37 +1375,34 @@ void shortcut_init(void)
add_to_sclist(MMOST|MBROWSER|MHELP|MYESNO, "^L", 0, full_refresh, 0);
else
add_to_sclist(MMOST|MBROWSER|MYESNO, "^L", 0, full_refresh, 0);
add_to_sclist(MMAIN|MEXECUTE, "^Z", 0, do_suspend_void, 0);
#ifndef NANO_TINY
/* Group of "Appearance" toggles. */
add_to_sclist((MMOST|MBROWSER|MYESNO) & ~MFINDINHELP, "M-X", 0, do_toggle_void, NO_HELP);
add_to_sclist(MMAIN, "M-C", 0, do_toggle_void, CONSTANT_SHOW);
add_to_sclist(MMAIN, "M-S", 0, do_toggle_void, SOFTWRAP);
add_to_sclist(MMAIN, "M-$", 0, do_toggle_void, SOFTWRAP);
add_to_sclist(MMAIN, "M-Z", 0, do_toggle, ZERO);
add_to_sclist((MMOST|MBROWSER|MYESNO) & ~MFINDINHELP, "M-X", 0, do_toggle, NO_HELP);
add_to_sclist(MMAIN, "M-C", 0, do_toggle, CONSTANT_SHOW);
add_to_sclist(MMAIN, "M-S", 0, do_toggle, SOFTWRAP);
add_to_sclist(MMAIN, "M-$", 0, do_toggle, SOFTWRAP); /* Legacy keystroke. */
#ifdef ENABLE_LINENUMBERS
add_to_sclist(MMAIN, "M-N", 0, do_toggle_void, LINE_NUMBERS);
add_to_sclist(MMAIN, "M-#", 0, do_toggle_void, LINE_NUMBERS);
add_to_sclist(MMAIN, "M-N", 0, do_toggle, LINE_NUMBERS);
add_to_sclist(MMAIN, "M-#", 0, do_toggle, LINE_NUMBERS); /* Legacy keystroke. */
#endif
add_to_sclist(MMAIN, "M-P", 0, do_toggle_void, WHITESPACE_DISPLAY);
add_to_sclist(MMAIN, "M-P", 0, do_toggle, WHITESPACE_DISPLAY);
#ifdef ENABLE_COLOR
add_to_sclist(MMAIN, "M-Y", 0, do_toggle_void, NO_SYNTAX);
add_to_sclist(MMAIN, "M-Y", 0, do_toggle, NO_SYNTAX);
#endif
/* Group of "Editing-behavior" toggles. */
add_to_sclist(MMAIN, "M-H", 0, do_toggle_void, SMART_HOME);
add_to_sclist(MMAIN, "M-I", 0, do_toggle_void, AUTOINDENT);
add_to_sclist(MMAIN, "M-K", 0, do_toggle_void, CUT_FROM_CURSOR);
/* Group of "Behavior" toggles. */
add_to_sclist(MMAIN, "M-H", 0, do_toggle, SMART_HOME);
add_to_sclist(MMAIN, "M-I", 0, do_toggle, AUTOINDENT);
add_to_sclist(MMAIN, "M-K", 0, do_toggle, CUT_FROM_CURSOR);
#ifdef ENABLE_WRAPPING
add_to_sclist(MMAIN, "M-L", 0, do_toggle_void, BREAK_LONG_LINES);
add_to_sclist(MMAIN, "M-L", 0, do_toggle, BREAK_LONG_LINES);
#endif
add_to_sclist(MMAIN, "M-O", 0, do_toggle_void, TABS_TO_SPACES);
/* Group of "Peripheral-feature" toggles. */
add_to_sclist(MMAIN, "M-O", 0, do_toggle, TABS_TO_SPACES);
#ifdef ENABLE_MOUSE
add_to_sclist(MMAIN, "M-M", 0, do_toggle_void, USE_MOUSE);
add_to_sclist(MMAIN, "M-M", 0, do_toggle, USE_MOUSE);
#endif
add_to_sclist(MMAIN, "M-Z", 0, do_toggle_void, SUSPENDABLE);
#endif /* !NANO_TINY */
add_to_sclist(((MMOST & ~MMAIN) | MYESNO), "^C", 0, do_cancel, 0);
@@ -1425,17 +1413,17 @@ void shortcut_init(void)
add_to_sclist(MWHEREIS|MREPLACE, "^R", 0, flip_replace, 0);
add_to_sclist(MWHEREIS|MGOTOLINE, "^T", 0, flip_goto, 0);
#ifdef ENABLE_HISTORIES
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "^P", 0, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "^N", 0, get_history_newer_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "^P", 0, get_older_item, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "^N", 0, get_newer_item, 0);
#ifdef ENABLE_UTF8
if (using_utf8()) {
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\xb4", KEY_UP, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\xbe", KEY_DOWN, get_history_newer_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\xb4", KEY_UP, get_older_item, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\xbe", KEY_DOWN, get_newer_item, 0);
} else
#endif
{
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "Up", KEY_UP, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "Down", KEY_DOWN, get_history_newer_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "Up", KEY_UP, get_older_item, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "Down", KEY_DOWN, get_newer_item, 0);
}
#endif
#ifdef ENABLE_JUSTIFY
@@ -1461,14 +1449,14 @@ void shortcut_init(void)
if (ISSET(SAVE_ON_EXIT) && !ISSET(PRESERVE))
add_to_sclist(MWRITEFILE, "^Q", 0, discard_buffer, 0);
#ifndef NANO_TINY
add_to_sclist(MWRITEFILE, "M-D", 0, dos_format_void, 0);
add_to_sclist(MWRITEFILE, "M-M", 0, mac_format_void, 0);
add_to_sclist(MWRITEFILE, "M-D", 0, dos_format, 0);
add_to_sclist(MWRITEFILE, "M-M", 0, mac_format, 0);
/* Only when not in restricted mode, allow Appending, Prepending,
* making backups, and executing a command. */
if (!ISSET(RESTRICTED) && !ISSET(VIEW_MODE)) {
add_to_sclist(MWRITEFILE, "M-A", 0, append_void, 0);
add_to_sclist(MWRITEFILE, "M-P", 0, prepend_void, 0);
add_to_sclist(MWRITEFILE, "M-B", 0, backup_file_void, 0);
add_to_sclist(MWRITEFILE, "M-A", 0, append_it, 0);
add_to_sclist(MWRITEFILE, "M-P", 0, prepend_it, 0);
add_to_sclist(MWRITEFILE, "M-B", 0, back_it_up, 0);
add_to_sclist(MINSERTFILE|MEXECUTE, "^X", 0, flip_execute, 0);
}
add_to_sclist(MINSERTFILE, "M-N", 0, flip_convert, 0);
@@ -1504,11 +1492,11 @@ void shortcut_init(void)
#endif
add_to_sclist(MMOST & ~MFINDINHELP, "F1", KEY_F(1), do_help, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP, "F2", KEY_F(2), do_exit, 0);
add_to_sclist(MMAIN, "F3", KEY_F(3), do_writeout_void, 0);
add_to_sclist(MMAIN, "F3", KEY_F(3), do_writeout, 0);
#ifdef ENABLE_JUSTIFY
add_to_sclist(MMAIN, "F4", KEY_F(4), do_justify, 0);
#endif
add_to_sclist(MMAIN, "F5", KEY_F(5), do_insertfile_void, 0);
add_to_sclist(MMAIN, "F5", KEY_F(5), do_insertfile, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP, "F6", KEY_F(6), do_search_forward, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "F7", KEY_F(7), do_page_up, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "F8", KEY_F(8), do_page_down, 0);
@@ -1518,30 +1506,33 @@ void shortcut_init(void)
#ifdef ENABLE_SPELLER
add_to_sclist(MMAIN, "F12", KEY_F(12), do_spell, 0);
#endif
#if defined(KEY_CANCEL) && defined(KEY_SUSPEND) && defined(KEY_SIC)
add_to_sclist((MMOST & ~MMAIN) | MYESNO, "", KEY_CANCEL, do_cancel, 0);
add_to_sclist(MMAIN|MEXECUTE, "", KEY_SUSPEND, do_suspend_void, 0);
add_to_sclist(MMAIN, "", KEY_SIC, do_insertfile_void, 0);
#endif
#ifndef NANO_TINY
add_to_sclist((MMOST & ~MMAIN) | MYESNO, "", KEY_CANCEL, do_cancel, 0);
add_to_sclist(MMAIN, "", KEY_SIC, do_insertfile, 0);
/* Catch and ignore bracketed paste marker keys. */
add_to_sclist(MMOST|MBROWSER|MHELP|MYESNO, "", BRACKETED_PASTE_MARKER, do_nothing, 0);
#else
add_to_sclist(MMOST|MBROWSER|MHELP|MYESNO, "", KEY_FRESH, full_refresh, 0);
#endif
}
#ifndef NANO_TINY
/* Return the textual description that corresponds to the given flag. */
const char *flagtostr(int flag)
const char *epithet_of_flag(int flag)
{
switch (flag) {
case NO_HELP:
case ZERO:
/* TRANSLATORS: The next thirteen strings are toggle descriptions;
* they are best kept shorter than 40 characters, but may be longer. */
return N_("Hidden interface");
case NO_HELP:
return N_("Help mode");
case CONSTANT_SHOW:
return N_("Constant cursor position display");
case SOFTWRAP:
return N_("Soft wrapping of overlong lines");
case LINE_NUMBERS:
return N_("Line numbering");
case WHITESPACE_DISPLAY:
return N_("Whitespace display");
case NO_SYNTAX:
@@ -1558,13 +1549,8 @@ const char *flagtostr(int flag)
return N_("Conversion of typed tabs to spaces");
case USE_MOUSE:
return N_("Mouse support");
case SUSPENDABLE:
return N_("Suspension");
case LINE_NUMBERS:
return N_("Line numbering");
default:
die("Bad toggle -- please report a bug\n");
return "";
return "Ehm...";
}
}
#endif /* !NANO_TINY */

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* help.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2000-2011, 2013-2021 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 *
* *
@@ -234,8 +234,8 @@ 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
@@ -303,8 +303,9 @@ void help_init(void)
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_SYNTAX || s->toggle == TABS_TO_SPACES)
_(epithet_of_flag(s->toggle)), _("enable/disable"));
/* Add a blank like between two groups. */
if (s->toggle == NO_SYNTAX)
ptr += sprintf(ptr, "\n");
break;
}
@@ -323,6 +324,13 @@ void wrap_help_text_into_buffer(void)
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;
@@ -403,8 +411,9 @@ void show_help(void)
memcpy(stash, flags, sizeof(flags));
/* Ensure that the help screen's shortcut list can be displayed. */
if (ISSET(NO_HELP) && LINES > 4) {
if (ISSET(NO_HELP) || ISSET(ZERO)) {
UNSET(NO_HELP);
UNSET(ZERO);
window_init();
} else
blank_statusbar();
@@ -415,10 +424,8 @@ void show_help(void)
UNSET(USE_REGEXP);
UNSET(WHITESPACE_DISPLAY);
UNSET(NOREAD_MODE);
#ifdef ENABLE_LINENUMBERS
UNSET(LINE_NUMBERS);
editwincols = COLS - thebar;
margin = 0;
#endif
@@ -456,13 +463,12 @@ void show_help(void)
focusing = TRUE;
/* Show the cursor when we searched and found something. */
kbinput = get_kbinput(edit, didfind == 1 || ISSET(SHOW_CURSOR));
kbinput = get_kbinput(midwin, didfind == 1 || ISSET(SHOW_CURSOR));
didfind = 0;
#ifndef NANO_TINY
spotlighted = FALSE;
hide_cursor = FALSE;
if (bracketed_paste || kbinput == BRACKETED_PASTE_MARKER) {
beep();
@@ -543,13 +549,12 @@ void show_help(void)
curs_set(0);
if (ISSET(NO_HELP)) {
currmenu = oldmenu;
if (ISSET(NO_HELP) || ISSET(ZERO))
window_init();
} else {
else
blank_statusbar();
bottombars(oldmenu);
}
bottombars(oldmenu);
#ifdef ENABLE_BROWSER
if (oldmenu & (MBROWSER|MWHEREISFILE|MGOTODIR))

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* history.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2003-2011, 2013-2021 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 *
@@ -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,98 +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
/* Go backward through one of three history lists, starting at its item h,
* searching for a string that is a tab completion of the given string s,
* looking at only the first len characters of s. When found, make h point
* at it and return that string; otherwise, don't move h and return s. */
char *get_history_completion(linestruct **h, char *s, size_t len)
/* 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)
{
linestruct *htop = NULL, *hbot = NULL, *p;
linestruct *htop = NULL, *hbot = NULL;
linestruct *item;
if (*h == search_history) {
if (*here == search_history) {
htop = searchtop;
hbot = searchbot;
} else if (*h == replace_history) {
} else if (*here == replace_history) {
htop = replacetop;
hbot = replacebot;
} else if (*h == execute_history) {
} else if (*here == execute_history) {
htop = executetop;
hbot = executebot;
}
/* First search from the current position to the top of the list
* for a match of len characters. Skip over an exact match. */
p = find_history((*h)->prev, htop, s, len);
item = find_in_history((*here)->prev, htop, string, len);
while (p != NULL && strcmp(p->data, s) == 0)
p = find_history(p->prev, htop, s, len);
while (item != NULL && strcmp(item->data, string) == 0)
item = find_in_history(item->prev, htop, string, len);
if (p != NULL) {
*h = p;
return mallocstrcpy(s, (*h)->data);
if (item) {
*here = item;
return mallocstrcpy(string, item->data);
}
/* Now search from the bottom of the list to the original position. */
p = find_history(hbot, *h, s, len);
item = find_in_history(hbot, *here, string, len);
while (p != NULL && strcmp(p->data, s) == 0)
p = find_history(p->prev, *h, s, len);
while (item != NULL && strcmp(item->data, string) == 0)
item = find_in_history(item->prev, *here, string, len);
if (p != NULL) {
*h = p;
return mallocstrcpy(s, (*h)->data);
if (item) {
*here = item;
return mallocstrcpy(string, item->data);
}
/* When no useful match was found, simply return the given string. */
return (char *)s;
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;
}
@@ -253,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);
@@ -269,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"),
@@ -309,7 +280,7 @@ void load_history(void)
stanza[--read] = '\0';
if (read > 0) {
recode_NUL_to_LF(stanza, read);
update_history(history, stanza);
update_history(history, stanza, IGNORE_DUPLICATES);
} else if (history == &search_history)
history = &replace_history;
else
@@ -394,12 +365,14 @@ void load_poshistory(void)
if (histfile == NULL)
return;
ssize_t read, count = 0;
struct stat fileinfo;
poshiststruct *record_ptr = NULL, *newrecord;
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) {
@@ -419,19 +392,19 @@ void load_poshistory(void)
*(lineptr++) = '\0';
/* Create a new position record. */
newrecord = nmalloc(sizeof(poshiststruct));
newrecord->filename = copy_of(stanza);
newrecord->linenumber = atoi(lineptr);
newrecord->columnnumber = atoi(columnptr);
newrecord->next = NULL;
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 = newrecord;
position_history = newitem;
else
record_ptr->next = newrecord;
lastitem->next = newitem;
record_ptr = newrecord;
lastitem = newitem;
/* Impose a limit, so the file will not grow indefinitely. */
if (++count > 200) {
@@ -456,9 +429,9 @@ void load_poshistory(void)
/* Save the recorded cursor positions for files that were edited. */
void save_poshistory(void)
{
poshiststruct *posptr;
struct stat fileinfo;
FILE *histfile = fopen(poshistname, "wb");
struct stat fileinfo;
poshiststruct *item;
if (histfile == NULL) {
jot_error(N_("Error writing %s: %s"), poshistname, strerror(errno));
@@ -469,15 +442,15 @@ void save_poshistory(void)
if (chmod(poshistname, S_IRUSR | S_IWUSR) < 0)
jot_error(N_("Cannot limit permissions on %s: %s"), poshistname, strerror(errno));
for (posptr = position_history; posptr != NULL; posptr = posptr->next) {
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(posptr->filename) + 44);
path_and_place = nmalloc(strlen(item->filename) + 44);
sprintf(path_and_place, "%s %zd %zd\n",
posptr->filename, posptr->linenumber, posptr->columnnumber);
item->filename, item->linenumber, item->columnnumber);
length = strlen(path_and_place);
/* Encode newlines in filenames as NULs. */
@@ -501,29 +474,30 @@ void save_poshistory(void)
/* Reload the position history file if it has been modified since last load. */
void reload_positions_if_needed(void)
{
poshiststruct *item, *nextone;
struct stat fileinfo;
if (stat(poshistname, &fileinfo) == 0 && fileinfo.st_mtime != latest_timestamp) {
poshiststruct *item, *nextone;
if (stat(poshistname, &fileinfo) != 0 || fileinfo.st_mtime == latest_timestamp)
return;
for (item = position_history; item != NULL; item = nextone) {
nextone = item->next;
free(item->filename);
free(item);
}
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 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(openfile->filename);
poshiststruct *previous = NULL;
poshiststruct *item, *theone;
if (fullpath == NULL || openfile->filename[0] == '\0') {
free(fullpath);
@@ -533,28 +507,28 @@ void update_poshistory(void)
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 (openfile->current->lineno == 1 && openfile->current_x == 0) {
if (posptr != NULL) {
if (posprev == NULL)
position_history = posptr->next;
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. */
@@ -564,15 +538,15 @@ void update_poshistory(void)
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. */
@@ -590,25 +564,25 @@ void update_poshistory(void)
* 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->linenumber;
*column = posptr->columnnumber;
*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-2021 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 *
@@ -44,6 +44,9 @@ void to_last_line(void)
openfile->current_y = editwinrows - 1;
refresh_needed = TRUE;
#ifdef ENABLE_COLOR
recook |= perturbed;
#endif
focusing = FALSE;
}
@@ -222,6 +225,9 @@ void to_para_end(void)
openfile->current_x = strlen(openfile->current->data);
edit_redraw(was_current, CENTERING);
#ifdef ENABLE_COLOR
recook |= perturbed;
#endif
}
#endif /* ENABLE_JUSTIFY */
@@ -263,12 +269,15 @@ void to_next_block(void)
openfile->current_x = 0;
edit_redraw(was_current, CENTERING);
#ifdef ENABLE_COLOR
recook |= perturbed;
#endif
}
/* 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. */
@@ -286,7 +295,7 @@ void do_prev_word(bool allow_punct)
openfile->current_x);
if (is_word_char(openfile->current->data + openfile->current_x,
allow_punct)) {
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)
@@ -309,12 +318,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 punctuation_as_letters = ISSET(WORD_BOUNDS);
bool started_on_word = is_word_char(openfile->current->data +
openfile->current_x, allow_punct);
openfile->current_x, punctuation_as_letters);
bool seen_space = !started_on_word;
#ifndef NANO_TINY
bool seen_word = started_on_word;
@@ -341,7 +350,7 @@ bool do_next_word(bool after_ends, bool allow_punct)
/* If this is a word character, continue; else it's a separator,
* and if we've already seen a word, then it's a word end. */
if (is_word_char(openfile->current->data + openfile->current_x,
allow_punct))
punctuation_as_letters))
seen_word = TRUE;
#ifdef ENABLE_UTF8
else if (is_zerowidth(openfile->current->data + openfile->current_x))
@@ -360,7 +369,7 @@ bool do_next_word(bool after_ends, bool allow_punct)
/* If this is not a word character, then it's a separator; else
* if we've already seen a separator, then it's a word start. */
if (!is_word_char(openfile->current->data + openfile->current_x,
allow_punct))
punctuation_as_letters))
seen_space = TRUE;
else if (seen_space)
break;
@@ -370,25 +379,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. */
/* 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. */
* 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);
}

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* nano.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
* Copyright (C) 2014-2021 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -26,7 +26,7 @@
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#if defined(__linux__) || !defined(NANO_TINY)
#ifdef __linux__
#include <sys/ioctl.h>
#endif
#ifdef ENABLE_UTF8
@@ -212,6 +212,18 @@ bool in_restricted_mode(void)
return FALSE;
}
#ifndef NANO_TINY
/* Say how the user can achieve suspension (when they typed ^Z). */
void suggest_ctrlT_ctrlZ(void)
{
#ifdef ENABLE_NANORC
if (first_sc_for(MMAIN, do_execute) && first_sc_for(MMAIN, do_execute)->keycode == 0x14 &&
first_sc_for(MEXECUTE, do_suspend) && first_sc_for(MEXECUTE, do_suspend)->keycode == 0x1A)
#endif
statusline(AHEM, _("To suspend, type ^T^Z"));
}
#endif
/* Make sure the cursor is visible, then exit from curses mode, disable
* bracketed-paste mode, and restore the original terminal settings. */
void restore_terminal(void)
@@ -231,14 +243,14 @@ void finish(void)
/* Blank the status bar and (if applicable) the shortcut list. */
blank_statusbar();
blank_bottombars();
wrefresh(bottomwin);
wrefresh(footwin);
#ifndef NANO_TINY
/* Deallocate the two or three subwindows. */
if (topwin != NULL)
delwin(topwin);
delwin(edit);
delwin(bottomwin);
delwin(midwin);
delwin(footwin);
#endif
/* Switch the cursor on, exit from curses, and restore terminal settings. */
restore_terminal();
@@ -292,20 +304,20 @@ void do_exit(void)
/* When unmodified, simply close. Else, when doing automatic saving
* and the file has a name, simply save. Otherwise, ask the user. */
if (!openfile->modified)
choice = 0;
choice = NO;
else if (ISSET(SAVE_ON_EXIT) && openfile->filename[0] != '\0')
choice = 1;
choice = YES;
else {
if (ISSET(SAVE_ON_EXIT))
warn_and_briefly_pause(_("No file name"));
choice = do_yesno_prompt(FALSE, _("Save modified buffer? "));
choice = ask_user(YESORNO, _("Save modified buffer? "));
}
/* When not saving, or the save succeeds, close the buffer. */
if (choice == 0 || (choice == 1 && do_writeout(TRUE, TRUE) > 0))
if (choice == NO || (choice == YES && write_it_out(TRUE, TRUE) > 0))
close_and_go();
else if (choice != 1)
else if (choice != YES)
statusbar(_("Cancelled"));
}
@@ -327,7 +339,7 @@ void emergency_save(const char *filename)
fprintf(stderr, _("\nToo many .save files\n"));
else if (write_file(targetname, NULL, SPECIAL, OVERWRITE, NONOTES)) {
fprintf(stderr, _("\nBuffer written to %s\n"), targetname);
#ifndef NANO_TINY
#if !defined(NANO_TINY) && defined(HAVE_CHMOD) && defined(HAVE_CHOWN)
/* Try to chmod/chown the saved file to the values of the original file,
* but ignore any failure as we are in a hurry to get out. */
if (openfile->statinfo) {
@@ -391,46 +403,46 @@ void die(const char *msg, ...)
void window_init(void)
{
/* When resizing, first delete the existing windows. */
if (edit != NULL) {
if (midwin != NULL) {
if (topwin != NULL)
delwin(topwin);
delwin(edit);
delwin(bottomwin);
delwin(midwin);
delwin(footwin);
}
topwin = NULL;
/* If the terminal is very flat, don't set up a title bar. */
if (LINES < 3) {
editwinrows = 1;
editwinrows = (ISSET(ZERO) ? LINES : 1);
/* Set up two subwindows. If the terminal is just one line,
* edit window and status-bar window will cover each other. */
edit = newwin(1, COLS, 0, 0);
bottomwin = newwin(1, COLS, LINES - 1, 0);
midwin = newwin(editwinrows, COLS, 0, 0);
footwin = newwin(1, COLS, LINES - 1, 0);
} else {
int toprows = ((ISSET(EMPTY_LINE) && LINES > 5) ? 2 : 1);
int bottomrows = ((ISSET(NO_HELP) || LINES < 5) ? 1 : 3);
int toprows = ((ISSET(EMPTY_LINE) && LINES > 6) ? 2 : 1);
int bottomrows = ((ISSET(NO_HELP) || LINES < 6) ? 1 : 3);
#ifndef NANO_TINY
if (ISSET(MINIBAR))
if (ISSET(MINIBAR) || ISSET(ZERO))
toprows = 0;
#endif
editwinrows = LINES - toprows - bottomrows;
editwinrows = LINES - toprows - bottomrows + (ISSET(ZERO) ? 1 : 0);
/* Set up the normal three subwindows. */
if (toprows > 0)
topwin = newwin(toprows, COLS, 0, 0);
edit = newwin(editwinrows, COLS, toprows, 0);
bottomwin = newwin(bottomrows, COLS, toprows + editwinrows, 0);
midwin = newwin(editwinrows, COLS, toprows, 0);
footwin = newwin(bottomrows, COLS, LINES - bottomrows, 0);
}
/* In case the terminal shrunk, make sure the status line is clear. */
wipe_statusbar();
wnoutrefresh(footwin);
/* When not disabled, turn escape-sequence translation on. */
if (!ISSET(RAW_SEQUENCES)) {
keypad(edit, TRUE);
keypad(bottomwin, TRUE);
keypad(midwin, TRUE);
keypad(footwin, TRUE);
}
#ifdef ENABLED_WRAPORJUSTIFY
@@ -639,12 +651,9 @@ void usage(void)
print_opt("-x", "--nohelp", N_("Don't show the two help lines"));
#ifndef NANO_TINY
print_opt("-y", "--afterends", N_("Make Ctrl+Right stop at word ends"));
#endif
if (!ISSET(RESTRICTED))
print_opt("-z", "--suspendable", N_("Enable suspension"));
#ifndef NANO_TINY
print_opt("-%", "--stateflags", N_("Show some states on the title bar"));
print_opt("-_", "--minibar", N_("Show a feedback bar at the bottom"));
print_opt("-0", "--zero", N_("Hide all bars, use whole terminal"));
#endif
#ifdef HAVE_LIBMAGIC
print_opt("-!", "--magic", N_("Also try magic to determine syntax"));
@@ -661,8 +670,8 @@ void version(void)
printf(_(" GNU nano, version %s\n"), VERSION);
#endif
#ifndef NANO_TINY
printf(" (C) 1999-2011, 2013-2021 Free Software Foundation, Inc.\n");
printf(_(" (C) 2014-%s the contributors to nano\n"), "2021");
printf(" (C) 1999-2011, 2013-2022 Free Software Foundation, Inc.\n");
printf(_(" (C) 2014-%s the contributors to nano\n"), "2022");
#endif
printf(_(" Compiled options:"));
@@ -885,20 +894,21 @@ void signal_init(void)
sigaction(SIGTERM, &deed, NULL);
#ifndef NANO_TINY
#ifdef SIGWINCH
/* Trap SIGWINCH because we want to handle window resizes. */
deed.sa_handler = handle_sigwinch;
sigaction(SIGWINCH, &deed, NULL);
#endif
/* In the suspend and continue handlers, block all other signals.
* If we don't do this, other stuff interrupts them! */
sigfillset(&deed.sa_mask);
#ifdef SIGTSTP
deed.sa_handler = do_suspend;
/* Prevent the suspend handler from getting interrupted. */
sigfillset(&deed.sa_mask);
deed.sa_handler = suspend_nano;
sigaction(SIGTSTP, &deed, NULL);
#endif
#endif /* !NANO_TINY */
#ifdef SIGCONT
deed.sa_handler = do_continue;
sigfillset(&deed.sa_mask);
deed.sa_handler = continue_nano;
sigaction(SIGCONT, &deed, NULL);
#endif
@@ -929,8 +939,9 @@ void handle_crash(int signal)
}
#endif
#ifndef NANO_TINY
/* Handler for SIGTSTP (suspend). */
void do_suspend(int signal)
void suspend_nano(int signal)
{
#ifdef ENABLE_MOUSE
disable_mouse_support();
@@ -952,20 +963,20 @@ void do_suspend(int signal)
#endif
}
/* Put nano to sleep (if suspension is enabled). */
void do_suspend_void(void)
/* When permitted, put nano to sleep. */
void do_suspend(void)
{
if (!ISSET(SUSPENDABLE)) {
statusline(AHEM, _("Suspension is not enabled"));
beep();
} else
do_suspend(0);
if (in_restricted_mode())
return;
suspend_nano(0);
ran_a_tool = TRUE;
}
#endif /* !NANO_TINY */
/* Handler for SIGCONT (continue after suspend). */
void do_continue(int signal)
void continue_nano(int signal)
{
#ifdef ENABLE_MOUSE
if (ISSET(USE_MOUSE))
@@ -981,18 +992,20 @@ void do_continue(int signal)
#endif
/* Insert a fake keystroke, to neutralize a key-eating issue. */
ungetch(KEY_FLUSH);
ungetch(KEY_FRESH);
}
#if !defined(NANO_TINY) || defined(ENABLE_SPELLER) || defined(ENABLE_COLOR)
/* Block or unblock the SIGWINCH signal, depending on the blockit parameter. */
void block_sigwinch(bool blockit)
{
#ifdef SIGWINCH
sigset_t winch;
sigemptyset(&winch);
sigaddset(&winch, SIGWINCH);
sigprocmask(blockit ? SIG_BLOCK : SIG_UNBLOCK, &winch, NULL);
#endif
#ifndef NANO_TINY
if (the_window_resized)
@@ -1012,38 +1025,19 @@ void handle_sigwinch(int signal)
/* Reinitialize and redraw the screen completely. */
void regenerate_screen(void)
{
const char *tty = ttyname(0);
int fd, result = 0;
struct winsize win;
/* Reset the trigger. */
the_window_resized = FALSE;
if (tty == NULL)
return;
fd = open(tty, O_RDWR);
if (fd == -1)
return;
result = ioctl(fd, TIOCGWINSZ, &win);
close(fd);
if (result == -1)
return;
/* Leave and immediately reenter curses mode, so that ncurses notices
* the new screen dimensions and sets LINES and COLS accordingly. */
endwin();
refresh();
/* We could check whether COLS or LINES changed, and return otherwise,
* but it seems curses does not always update these global variables. */
#ifdef REDEFINING_MACROS_OK
COLS = win.ws_col;
LINES = win.ws_row;
#endif
thebar = (ISSET(INDICATOR) && LINES > 5 && COLS > 9) ? 1 : 0;
bardata = nrealloc(bardata, LINES * sizeof(int));
editwincols = COLS - margin - thebar;
/* Do as the website suggests: leave and immediately reenter curses mode. */
endwin();
doupdate();
/* Put the terminal in the desired state again, and
* recreate the subwindows with their (new) sizes. */
terminal_init();
@@ -1056,25 +1050,35 @@ void regenerate_screen(void)
}
}
/* Handle the global toggle specified in flag. */
void do_toggle(int flag)
/* Invert the given global flag and adjust things for its new value. */
void toggle_this(int flag)
{
if (flag == SUSPENDABLE && in_restricted_mode())
return;
bool enabled = !ISSET(flag);
TOGGLE(flag);
focusing = FALSE;
switch (flag) {
case ZERO:
window_init();
draw_all_subwindows();
return;
case NO_HELP:
if (LINES < 6) {
statusline(AHEM, _("Too tiny"));
TOGGLE(flag);
return;
}
window_init();
draw_all_subwindows();
break;
#ifdef ENABLE_MOUSE
case USE_MOUSE:
mouse_init();
break;
#endif
case CONSTANT_SHOW:
if (ISSET(ZERO) || LINES == 1) {
statusline(AHEM, _("Not possible"));
TOGGLE(flag);
} else if (!ISSET(MINIBAR))
wipe_statusbar();
return;
case SOFTWRAP:
if (!ISSET(SOFTWRAP))
openfile->firstcolumn = 0;
@@ -1089,30 +1093,37 @@ void do_toggle(int flag)
precalc_multicolorinfo();
refresh_needed = TRUE;
break;
case TABS_TO_SPACES:
if (openfile->syntax && openfile->syntax->tab) {
statusline(AHEM, _("Current syntax determines Tab"));
TOGGLE(flag);
return;
}
break;
#endif
#ifdef ENABLE_MOUSE
case USE_MOUSE:
mouse_init();
break;
#endif
}
if (!ISSET(MINIBAR) && ISSET(STATEFLAGS))
if (flag == AUTOINDENT || flag == BREAK_LONG_LINES || flag == SOFTWRAP)
if (flag == AUTOINDENT || flag == BREAK_LONG_LINES || flag == SOFTWRAP) {
if (ISSET(MINIBAR) && !ISSET(ZERO) && ISSET(STATEFLAGS))
return;
if (ISSET(STATEFLAGS))
titlebar(NULL);
if (ISSET(MINIBAR) && (flag == NO_HELP || flag == LINE_NUMBERS))
return;
if (flag == CONSTANT_SHOW)
wipe_statusbar();
else if (!ISSET(MINIBAR) || !ISSET(STATEFLAGS) || flag == SMART_HOME ||
flag == NO_SYNTAX || flag == WHITESPACE_DISPLAY ||
flag == CUT_FROM_CURSOR || flag == TABS_TO_SPACES ||
flag == USE_MOUSE || flag == SUSPENDABLE) {
bool enabled = ISSET(flag);
if (flag == NO_HELP || flag == NO_SYNTAX)
enabled = !enabled;
statusline(REMARK, "%s %s", _(flagtostr(flag)),
enabled ? _("enabled") : _("disabled"));
}
if (flag == NO_HELP || flag == LINE_NUMBERS || flag == WHITESPACE_DISPLAY)
if (ISSET(MINIBAR) || ISSET(ZERO) || LINES == 1)
return;
if (flag == NO_HELP || flag == NO_SYNTAX)
enabled = !enabled;
statusline(REMARK, "%s %s", _(epithet_of_flag(flag)),
enabled ? _("enabled") : _("disabled"));
}
#endif /* !NANO_TINY */
@@ -1240,8 +1251,9 @@ void confirm_margin(void)
#ifndef NANO_TINY
/* Ensure a proper starting column for the first screen row. */
ensure_firstcolumn_is_aligned();
focusing = keep_focus;
#endif
focusing = keep_focus;
/* The margin has changed -- schedule a full refresh. */
refresh_needed = TRUE;
}
@@ -1255,6 +1267,11 @@ void unbound_key(int code)
/* TRANSLATORS: This refers to a sequence of escape codes
* (from the keyboard) that nano does not recognize. */
statusline(AHEM, _("Unknown sequence"));
#ifndef NANO_TINY
else if (code > KEY_F0 && code < KEY_F0 + 25)
/* TRANSLATORS: This refers to an unbound function key. */
statusline(AHEM, _("Unbound key: F%i"), code - KEY_F0);
#endif
else if (code > 0x7F)
statusline(AHEM, _("Unbound key"));
else if (meta_key) {
@@ -1292,7 +1309,7 @@ int do_mouse(void)
return retval;
/* If the click was in the edit window, put the cursor in that spot. */
if (wmouse_trafo(edit, &click_row, &click_col, FALSE)) {
if (wmouse_trafo(midwin, &click_row, &click_col, FALSE)) {
linestruct *current_save = openfile->current;
ssize_t row_count = click_row - openfile->current_y;
size_t leftedge;
@@ -1375,7 +1392,7 @@ void suck_up_input_and_paste_it(void)
cutbuffer = line;
while (bracketed_paste) {
int input = get_kbinput(edit, BLIND);
int input = get_kbinput(midwin, BLIND);
if (input == '\r' || input == '\n') {
line->next = make_new_node(line);
@@ -1465,9 +1482,8 @@ void inject(char *burst, size_t count)
#endif
#ifdef ENABLE_WRAPPING
/* Wrap the line when needed, and if so, schedule a refresh. */
if (ISSET(BREAK_LONG_LINES) && do_wrap())
refresh_needed = TRUE;
if (ISSET(BREAK_LONG_LINES))
do_wrap();
#endif
#ifndef NANO_TINY
@@ -1508,10 +1524,9 @@ void process_a_keystroke(void)
const keystruct *shortcut;
/* Read in a keystroke, and show the cursor while waiting. */
input = get_kbinput(edit, VISIBLE);
input = get_kbinput(midwin, VISIBLE);
lastmessage = VACUUM;
hide_cursor = FALSE;
#ifndef NANO_TINY
if (input == KEY_WINCH)
@@ -1522,7 +1537,7 @@ void process_a_keystroke(void)
/* If the user clicked on a shortcut, read in the key code that it was
* converted into. Else the click has been handled or was invalid. */
if (do_mouse() == 1)
input = get_kbinput(edit, BLIND);
input = get_kbinput(midwin, BLIND);
else
return;
}
@@ -1552,7 +1567,7 @@ void process_a_keystroke(void)
/* If we have a command, or if there aren't any other key codes waiting,
* it's time to insert the gathered bytes into the edit buffer. */
if ((shortcut || get_key_buffer_len() == 0) && puddle != NULL) {
if ((shortcut || waiting_keycodes() == 0) && puddle != NULL) {
puddle[depth] = '\0';
inject(puddle, depth);
@@ -1599,8 +1614,8 @@ void process_a_keystroke(void)
}
#endif
#ifndef NANO_TINY
if (shortcut->func == do_toggle_void) {
do_toggle(shortcut->toggle);
if (shortcut->func == do_toggle) {
toggle_this(shortcut->toggle);
if (shortcut->toggle == CUT_FROM_CURSOR)
keep_cutbuffer = FALSE;
return;
@@ -1727,7 +1742,7 @@ int main(int argc, char **argv)
{"nowrap", 0, NULL, 'w'},
#endif
{"nohelp", 0, NULL, 'x'},
{"suspendable", 0, NULL, 'z'},
{"suspendable", 0, NULL, 'z'}, /* Obsolete; remove in 2022. */
#ifndef NANO_TINY
{"smarthome", 0, NULL, 'A'},
{"backup", 0, NULL, 'B'},
@@ -1756,6 +1771,7 @@ int main(int argc, char **argv)
{"afterends", 0, NULL, 'y'},
{"stateflags", 0, NULL, '%'},
{"minibar", 0, NULL, '_'},
{"zero", 0, NULL, '0'},
#endif
#ifdef HAVE_LIBMAGIC
{"magic", 0, NULL, '!'},
@@ -1773,10 +1789,12 @@ int main(int argc, char **argv)
/* Back up the terminal settings so that they can be restored. */
tcgetattr(STDIN_FILENO, &original_state);
#if defined(F_GETFL) && defined(F_SETFL)
/* Get the state of standard input and ensure it uses blocking mode. */
stdin_flags = fcntl(STDIN_FILENO, F_GETFL, 0);
if (stdin_flags != -1)
fcntl(STDIN_FILENO, F_SETFL, stdin_flags & ~O_NONBLOCK);
#endif
#ifdef ENABLE_UTF8
/* If setting the locale is successful and it uses UTF-8, we will
@@ -1799,7 +1817,7 @@ int main(int argc, char **argv)
if (*(tail(argv[0])) == 'r')
SET(RESTRICTED);
while ((optchr = getopt_long(argc, argv, "ABC:DEFGHIJ:KLMNOPQ:RST:UVWX:Y:Z"
while ((optchr = getopt_long(argc, argv, "0ABC:DEFGHIJ:KLMNOPQ:RST:UVWX:Y:Z"
"abcdef:ghijklmno:pqr:s:tuvwxyz$%_!", long_options, NULL)) != -1) {
switch (optchr) {
#ifndef NANO_TINY
@@ -2034,7 +2052,6 @@ int main(int argc, char **argv)
break;
#endif
case 'z':
SET(SUSPENDABLE);
break;
#ifndef NANO_TINY
case '%':
@@ -2043,6 +2060,9 @@ int main(int argc, char **argv)
case '_':
SET(MINIBAR);
break;
case '0':
SET(ZERO);
break;
#endif
#ifdef HAVE_LIBMAGIC
case '!':
@@ -2057,7 +2077,7 @@ int main(int argc, char **argv)
/* Curses needs TERM; if it is unset, try falling back to a VT220. */
if (getenv("TERM") == NULL)
setenv("TERM", "vt220", 0);
putenv("TERM=vt220");
/* Enter into curses mode. Abort if this fails. */
if (initscr() == NULL)
@@ -2067,6 +2087,9 @@ int main(int argc, char **argv)
/* If the terminal can do colors, tell ncurses to switch them on. */
if (has_colors())
start_color();
/* When requested, suppress the default spotlight and error colors. */
rescind_colors = (getenv("NO_COLOR") != NULL);
#endif
/* Set up the function and shortcut lists. This needs to be done
@@ -2178,11 +2201,10 @@ int main(int argc, char **argv)
if (ISSET(BOLD_TEXT))
hilite_attribute = A_BOLD;
/* When in restricted mode, disable backups, suspending, and history files,
* since they allow writing to files not specified on the command line. */
/* When in restricted mode, disable backups and history files, since they
* would allow writing to files not specified on the command line. */
if (ISSET(RESTRICTED)) {
UNSET(MAKE_BACKUP);
UNSET(SUSPENDABLE);
#ifdef ENABLE_NANORC
UNSET(HISTORYLOG);
UNSET(POSITIONLOG);
@@ -2193,6 +2215,10 @@ int main(int argc, char **argv)
if (ISSET(RAW_SEQUENCES))
UNSET(USE_MOUSE);
/* When suppressing title bar or minibar, suppress also the help lines. */
if (ISSET(ZERO))
SET(NO_HELP);
#ifdef ENABLE_HISTORIES
/* Initialize the pointers for the Search/Replace/Execute histories. */
history_init();
@@ -2432,7 +2458,7 @@ int main(int argc, char **argv)
/* If a position was given on the command line, go there. */
if (givenline != 0 || givencol != 0)
do_gotolinecolumn(givenline, givencol, FALSE, FALSE);
goto_line_and_column(givenline, givencol, FALSE, FALSE);
#ifndef NANO_TINY
else if (searchstring != NULL) {
if (ISSET(USE_REGEXP))
@@ -2455,11 +2481,14 @@ int main(int argc, char **argv)
ssize_t savedline, savedcol;
/* If edited before, restore the last cursor position. */
if (has_old_position(argv[optind - 1], &savedline, &savedcol))
do_gotolinecolumn(savedline, savedcol, FALSE, FALSE);
goto_line_and_column(savedline, savedcol, FALSE, FALSE);
}
#endif
}
/* After handling the files on the command line, allow inserting files. */
UNSET(NOREAD_MODE);
/* If no filenames were given, or all of them were invalid things like
* directories, then open a blank buffer and allow editing. Otherwise,
* switch from the last opened file to the next, that is: the first. */
@@ -2505,31 +2534,44 @@ int main(int argc, char **argv)
confirm_margin();
#endif
#ifdef __linux__
if (on_a_vt && get_key_buffer_len() == 0)
if (on_a_vt && waiting_keycodes() == 0)
mute_modifiers = FALSE;
#endif
if (currmenu != MMAIN)
bottombars(MMAIN);
#ifndef NANO_TINY
if (ISSET(MINIBAR) && LINES > 1 && lastmessage < REMARK)
if (ISSET(MINIBAR) && !ISSET(ZERO) && LINES > 1 && lastmessage < REMARK)
minibar();
else
#endif
/* Update the displayed current cursor position only when there
* is no message and no keys are waiting in the input buffer. */
if (ISSET(CONSTANT_SHOW) && lastmessage == VACUUM && LINES > 1 &&
get_key_buffer_len() == 0)
!ISSET(ZERO) && waiting_keycodes() == 0)
report_cursor_position();
as_an_at = TRUE;
/* Refresh just the cursor position or the entire edit window. */
if (!refresh_needed) {
place_the_cursor();
wnoutrefresh(edit);
} else if (LINES > 1 || lastmessage == VACUUM)
if ((refresh_needed && LINES > 1) || (LINES == 1 && lastmessage <= HUSH))
edit_refresh();
else
place_the_cursor();
#ifndef NANO_TINY
/* In barless mode, either redraw a relevant status message,
* or overwrite a minor, redundant one. */
if (ISSET(ZERO) && lastmessage > HUSH) {
if (openfile->current_y == editwinrows - 1 && LINES > 1) {
edit_scroll(FORWARD);
wnoutrefresh(midwin);
}
wredrawln(footwin, 0, 1);
wnoutrefresh(footwin);
place_the_cursor();
} else if (ISSET(ZERO) && lastmessage > VACUUM)
wredrawln(midwin, editwinrows - 1, 1);
#endif
errno = 0;
focusing = TRUE;

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* prompt.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
* Copyright (C) 2016, 2018, 2020 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -157,15 +157,27 @@ void do_statusbar_backspace(void)
}
}
/* Zap some or all text from the answer. */
void do_statusbar_cut_text(void)
/* Zap the part of the answer after the cursor, or the whole answer. */
void lop_the_answer(void)
{
if (!ISSET(CUT_FROM_CURSOR))
if (answer[typing_x] == '\0')
typing_x = 0;
answer[typing_x] = '\0';
}
#ifndef NANO_TINY
/* Copy the current answer (if any) into the cutbuffer. */
void copy_the_answer(void)
{
if (*answer) {
free_lines(cutbuffer);
cutbuffer = make_new_node(NULL);
cutbuffer->data = copy_of(answer);
typing_x = 0;
}
}
/* Paste the first line of the cutbuffer into the current answer. */
void paste_into_answer(void)
{
@@ -182,6 +194,7 @@ void paste_into_answer(void)
answer = fusion;
typing_x += pastelen;
}
#endif
#ifdef ENABLE_MOUSE
/* Handle a mouse click on the status-bar prompt or the shortcut list. */
@@ -191,7 +204,7 @@ int do_statusbar_mouse(void)
int retval = get_mouseinput(&click_row, &click_col, TRUE);
/* We can click on the status-bar window text to move the cursor. */
if (retval == 0 && wmouse_trafo(bottomwin, &click_row, &click_col, FALSE)) {
if (retval == 0 && wmouse_trafo(footwin, &click_row, &click_col, FALSE)) {
size_t start_col = breadth(prompt) + 2;
/* Move to where the click occurred. */
@@ -216,7 +229,7 @@ void inject_into_answer(char *burst, size_t count)
answer = nrealloc(answer, strlen(answer) + count + 1);
memmove(answer + typing_x + count, answer + typing_x,
strlen(answer) - typing_x + 1);
strncpy(answer + typing_x, burst , count);
strncpy(answer + typing_x, burst, count);
typing_x += count;
}
@@ -227,7 +240,7 @@ void do_statusbar_verbatim_input(void)
size_t count = 1;
char *bytes;
bytes = get_verbatim_kbinput(bottomwin, &count);
bytes = get_verbatim_kbinput(footwin, &count);
if (0 < count && count < 999)
inject_into_answer(bytes, count);
@@ -253,7 +266,7 @@ int do_statusbar_input(bool *finished)
*finished = FALSE;
/* Read in a character. */
input = get_kbinput(bottomwin, VISIBLE);
input = get_kbinput(footwin, VISIBLE);
#ifndef NANO_TINY
if (input == KEY_WINCH)
@@ -265,7 +278,7 @@ int do_statusbar_input(bool *finished)
* shortcut character. */
if (input == KEY_MOUSE) {
if (do_statusbar_mouse() == 1)
input = get_kbinput(bottomwin, BLIND);
input = get_kbinput(footwin, BLIND);
else
return ERR;
}
@@ -290,7 +303,7 @@ int do_statusbar_input(bool *finished)
/* If we got a shortcut, or if there aren't any other keystrokes waiting,
* it's time to insert all characters in the input buffer (if not empty)
* into the answer, and then clear the input buffer. */
if ((shortcut || get_key_buffer_len() == 0) && puddle != NULL) {
if ((shortcut || waiting_keycodes() == 0) && puddle != NULL) {
puddle[depth] = '\0';
inject_into_answer(puddle, depth);
@@ -304,8 +317,8 @@ int do_statusbar_input(bool *finished)
if (shortcut->func == do_tab || shortcut->func == do_enter)
;
#ifdef ENABLE_HISTORIES
else if (shortcut->func == get_history_older_void ||
shortcut->func == get_history_newer_void)
else if (shortcut->func == get_older_item ||
shortcut->func == get_newer_item)
;
#endif
else if (shortcut->func == do_left)
@@ -327,10 +340,10 @@ int do_statusbar_input(bool *finished)
else if (ISSET(RESTRICTED) && currmenu == MWRITEFILE &&
openfile->filename[0] != '\0' &&
(shortcut->func == do_verbatim_input ||
shortcut->func == cut_text ||
shortcut->func == paste_text ||
shortcut->func == do_delete ||
shortcut->func == do_backspace))
shortcut->func == do_backspace ||
shortcut->func == cut_text ||
shortcut->func == paste_text))
;
#ifdef ENABLE_NANORC
else if (shortcut->func == (functionptrtype)implant)
@@ -338,16 +351,21 @@ int do_statusbar_input(bool *finished)
#endif
else if (shortcut->func == do_verbatim_input)
do_statusbar_verbatim_input();
else if (shortcut->func == cut_text)
do_statusbar_cut_text();
else if (shortcut->func == do_delete)
do_statusbar_delete();
else if (shortcut->func == do_backspace)
do_statusbar_backspace();
else if (shortcut->func == cut_text)
lop_the_answer();
#ifndef NANO_TINY
else if (shortcut->func == copy_text)
copy_the_answer();
else if (shortcut->func == paste_text) {
if (cutbuffer != NULL)
paste_into_answer();
} else {
}
#endif
else {
/* Handle any other shortcut in the current menu, setting finished
* to TRUE to indicate that we're done after running or trying to
* run its associated function. */
@@ -392,33 +410,33 @@ void draw_the_promptbar(void)
end_page = get_statusbar_page_start(base, base + breadth(answer) - 1);
/* Color the prompt bar over its full width. */
wattron(bottomwin, interface_color_pair[PROMPT_BAR]);
mvwprintw(bottomwin, 0, 0, "%*s", COLS, " ");
wattron(footwin, interface_color_pair[PROMPT_BAR]);
mvwprintw(footwin, 0, 0, "%*s", COLS, " ");
mvwaddstr(bottomwin, 0, 0, prompt);
waddch(bottomwin, ':');
waddch(bottomwin, (the_page == 0) ? ' ' : '<');
mvwaddstr(footwin, 0, 0, prompt);
waddch(footwin, ':');
waddch(footwin, (the_page == 0) ? ' ' : '<');
expanded = display_string(answer, the_page, COLS - base, FALSE, TRUE);
waddstr(bottomwin, expanded);
waddstr(footwin, expanded);
free(expanded);
if (the_page < end_page && base + breadth(answer) - the_page > COLS)
mvwaddch(bottomwin, 0, COLS - 1, '>');
mvwaddch(footwin, 0, COLS - 1, '>');
wattroff(bottomwin, interface_color_pair[PROMPT_BAR]);
wattroff(footwin, interface_color_pair[PROMPT_BAR]);
#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH < 20210220)
/* Work around a cursor-misplacement bug -- https://sv.gnu.org/bugs/?59808. */
if (ISSET(NO_HELP)) {
wmove(bottomwin, 0, 0);
wrefresh(bottomwin);
wmove(footwin, 0, 0);
wrefresh(footwin);
}
#endif
/* Place the cursor at the right spot. */
wmove(bottomwin, 0, column - the_page);
wnoutrefresh(bottomwin);
wmove(footwin, 0, column - the_page);
wnoutrefresh(footwin);
}
#ifndef NANO_TINY
@@ -446,10 +464,8 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
bool finished;
functionptrtype func;
#ifdef ENABLE_HISTORIES
char *history = NULL;
/* The current history string. */
char *magichistory = NULL;
/* The (partial) answer that was typed at the prompt, if any. */
char *stored_string = NULL;
/* Whatever the answer was before the user foraged into history. */
#ifdef ENABLE_TABCOMP
bool previous_was_tab = FALSE;
/* Whether the previous keystroke was an attempt at tab completion. */
@@ -472,7 +488,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
refresh_func();
*actual = KEY_WINCH;
#ifdef ENABLE_HISTORIES
free(magichistory);
free(stored_string);
#endif
return NULL;
}
@@ -503,36 +519,33 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
} else
#endif /* ENABLE_TABCOMP */
#ifdef ENABLE_HISTORIES
if (func == get_history_older_void) {
if (history_list != NULL) {
/* If we're scrolling up at the bottom of the history list
* and answer isn't blank, save answer in magichistory. */
if ((*history_list)->next == NULL && *answer != '\0')
magichistory = mallocstrcpy(magichistory, answer);
if (func == get_older_item && history_list != NULL) {
/* If this is the first step into history, start at the bottom. */
if (stored_string == NULL)
reset_history_pointer_for(*history_list);
/* Get the older search from the history list and save it in
* answer. If there is no older search, don't do anything. */
if ((history = get_history_older(history_list)) != NULL) {
answer = mallocstrcpy(answer, history);
typing_x = strlen(answer);
}
/* When moving up from the bottom, remember the current answer. */
if ((*history_list)->next == NULL)
stored_string = mallocstrcpy(stored_string, answer);
/* If there is an older item, move to it and copy its string. */
if ((*history_list)->prev != NULL) {
*history_list = (*history_list)->prev;
answer = mallocstrcpy(answer, (*history_list)->data);
typing_x = strlen(answer);
}
} else if (func == get_newer_item && history_list != NULL) {
/* If there is a newer item, move to it and copy its string. */
if ((*history_list)->next != NULL) {
*history_list = (*history_list)->next;
answer = mallocstrcpy(answer, (*history_list)->data);
typing_x = strlen(answer);
}
} else if (func == get_history_newer_void) {
if (history_list != NULL) {
/* Get the newer search from the history list and save it in
* answer. If there is no newer search, don't do anything. */
if ((history = get_history_newer(history_list)) != NULL) {
answer = mallocstrcpy(answer, history);
typing_x = strlen(answer);
}
/* If we've reached the bottom of the history list, and answer
* is blank, and magichistory is set, restore the old answer. */
if ((*history_list)->next == NULL &&
*answer == '\0' && magichistory != NULL) {
answer = mallocstrcpy(answer, magichistory);
typing_x = strlen(answer);
}
/* When at the bottom of the history list, restore the old answer. */
if ((*history_list)->next == NULL && stored_string && *answer == '\0') {
answer = mallocstrcpy(answer, stored_string);
typing_x = strlen(answer);
}
} else
#endif /* ENABLE_HISTORIES */
@@ -542,7 +555,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
#ifndef NANO_TINY
else if (func == do_nothing)
finished = FALSE;
else if (func == do_toggle_void) {
else if (func == do_toggle) {
TOGGLE(NO_HELP);
window_init();
focusing = FALSE;
@@ -563,10 +576,10 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
}
#ifdef ENABLE_HISTORIES
/* Set the current position in the history list to the bottom. */
if (history_list != NULL) {
history_reset(*history_list);
free(magichistory);
/* If the history pointer was moved, point it at the bottom again. */
if (stored_string != NULL) {
reset_history_pointer_for(*history_list);
free(stored_string);
}
#endif
@@ -640,12 +653,14 @@ int do_prompt(int menu, const char *provided, linestruct **history_list,
return retval;
}
/* Ask a simple Yes/No (and optionally All) question, specified in msg,
* on the status bar. Return 1 for Yes, 0 for No, 2 for All (if all is
* TRUE when passed in), and -1 for Cancel. */
int do_yesno_prompt(bool all, const char *msg)
#define UNDECIDED -2
/* Ask a simple Yes/No (and optionally All) question on the status bar
* and return the choice -- either YES or NO or ALL or CANCEL. */
int ask_user(bool withall, const char *question)
{
int choice = -2, width = 16;
int choice = UNDECIDED;
int width = 16;
/* TRANSLATORS: For the next three strings, specify the starting letters
* of the translations for "Yes"/"No"/"All". The first letter of each of
* these strings MUST be a single-byte letter; others may be multi-byte. */
@@ -653,7 +668,7 @@ int do_yesno_prompt(bool all, const char *msg)
const char *nostr = _("Nn");
const char *allstr = _("Aa");
while (choice == -2) {
while (choice == UNDECIDED) {
#ifdef ENABLE_NLS
char letter[MAXCHARLEN + 1];
int index = 0;
@@ -674,34 +689,34 @@ int do_yesno_prompt(bool all, const char *msg)
/* Now show the ones for "Yes", "No", "Cancel" and maybe "All". */
sprintf(shortstr, " %c", yesstr[0]);
wmove(bottomwin, 1, 0);
wmove(footwin, 1, 0);
post_one_key(shortstr, _("Yes"), width);
shortstr[1] = nostr[0];
wmove(bottomwin, 2, 0);
wmove(footwin, 2, 0);
post_one_key(shortstr, _("No"), width);
if (all) {
if (withall) {
shortstr[1] = allstr[0];
wmove(bottomwin, 1, width);
wmove(footwin, 1, width);
post_one_key(shortstr, _("All"), width);
}
wmove(bottomwin, 2, width);
wmove(footwin, 2, width);
post_one_key(cancelshortcut->keystr, _("Cancel"), width);
}
/* Color the prompt bar over its full width and display the question. */
wattron(bottomwin, interface_color_pair[PROMPT_BAR]);
mvwprintw(bottomwin, 0, 0, "%*s", COLS, " ");
mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));
wattroff(bottomwin, interface_color_pair[PROMPT_BAR]);
wnoutrefresh(bottomwin);
wattron(footwin, interface_color_pair[PROMPT_BAR]);
mvwprintw(footwin, 0, 0, "%*s", COLS, " ");
mvwaddnstr(footwin, 0, 0, question, actual_x(question, COLS - 1));
wattroff(footwin, interface_color_pair[PROMPT_BAR]);
wnoutrefresh(footwin);
currmenu = MYESNO;
/* When not replacing, show the cursor while waiting for a key. */
kbinput = get_kbinput(bottomwin, !all);
kbinput = get_kbinput(footwin, !withall);
#ifndef NANO_TINY
if (kbinput == KEY_WINCH)
@@ -709,7 +724,7 @@ int do_yesno_prompt(bool all, const char *msg)
/* Accept the first character of an external paste. */
if (bracketed_paste && kbinput == BRACKETED_PASTE_MARKER)
kbinput = get_kbinput(bottomwin, BLIND);
kbinput = get_kbinput(footwin, BLIND);
#endif
#ifdef ENABLE_NLS
@@ -720,41 +735,41 @@ int do_yesno_prompt(bool all, const char *msg)
if (using_utf8() && 0xC0 <= kbinput && kbinput <= 0xF7) {
int extras = (kbinput / 16) % 4 + (kbinput <= 0xCF ? 1 : 0);
while (extras <= get_key_buffer_len() && extras-- > 0)
letter[index++] = (unsigned char)get_kbinput(bottomwin, !all);
while (extras <= waiting_keycodes() && extras-- > 0)
letter[index++] = (unsigned char)get_kbinput(footwin, !withall);
}
#endif
letter[index] = '\0';
/* See if the typed letter is in the Yes, No, or All strings. */
if (strstr(yesstr, letter) != NULL)
choice = 1;
choice = YES;
else if (strstr(nostr, letter) != NULL)
choice = 0;
else if (all && strstr(allstr, letter) != NULL)
choice = 2;
choice = NO;
else if (withall && strstr(allstr, letter) != NULL)
choice = ALL;
else
#endif /* ENABLE_NLS */
if (strchr("Yy", kbinput) != NULL)
choice = 1;
choice = YES;
else if (strchr("Nn", kbinput) != NULL)
choice = 0;
else if (all && strchr("Aa", kbinput) != NULL)
choice = 2;
choice = NO;
else if (withall && strchr("Aa", kbinput) != NULL)
choice = ALL;
else if (func_from_key(&kbinput) == do_cancel)
choice = -1;
choice = CANCEL;
/* Interpret ^N and ^Q as "No", to allow exiting in anger. */
else if (kbinput == '\x0E' || kbinput == '\x11')
choice = 0;
choice = NO;
/* And interpret ^Y as "Yes". */
else if (kbinput == '\x19')
choice = 1;
choice = YES;
#ifdef ENABLE_MOUSE
else if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y;
/* We can click on the Yes/No/All shortcuts to select an answer. */
if (get_mouseinput(&mouse_y, &mouse_x, FALSE) == 0 &&
wmouse_trafo(bottomwin, &mouse_y, &mouse_x, FALSE) &&
wmouse_trafo(footwin, &mouse_y, &mouse_x, FALSE) &&
mouse_x < (width * 2) && mouse_y > 0) {
int x = mouse_x / width;
int y = mouse_y - 1;
@@ -762,20 +777,21 @@ int do_yesno_prompt(bool all, const char *msg)
/* x == 0 means Yes or No, y == 0 means Yes or All. */
choice = -2 * x * y + x - y + 1;
if (choice == 2 && !all)
choice = -2;
if (choice == ALL && !withall)
choice = UNDECIDED;
}
}
#endif
else if (func_from_key(&kbinput) == full_refresh)
full_refresh();
#ifndef NANO_TINY
else if (func_from_key(&kbinput) == do_toggle_void) {
else if (func_from_key(&kbinput) == do_toggle) {
TOGGLE(NO_HELP);
window_init();
titlebar(NULL);
focusing = FALSE;
edit_refresh();
focusing = TRUE;
}
#endif
else
@@ -784,7 +800,7 @@ int do_yesno_prompt(bool all, const char *msg)
#ifndef NANO_TINY
/* Ignore the rest of an external paste. */
while (bracketed_paste)
kbinput = get_kbinput(bottomwin, BLIND);
kbinput = get_kbinput(footwin, BLIND);
#endif
}

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* prototypes.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2021 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 *
@@ -53,7 +53,6 @@ extern message_type lastmessage;
extern linestruct *pletion_line;
extern bool also_the_last;
extern bool hide_cursor;
extern char *answer;
@@ -88,8 +87,8 @@ 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;
@@ -142,6 +141,9 @@ extern char *alt_speller;
extern syntaxtype *syntaxes;
extern char *syntaxstr;
extern bool have_palette;
extern bool rescind_colors;
extern bool perturbed;
extern bool recook;
#endif
extern bool refresh_needed;
@@ -282,7 +284,7 @@ void close_buffer(void);
void read_file(FILE *f, int fd, const char *filename, bool undoable);
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
@@ -302,8 +304,8 @@ bool write_file(const char *name, FILE *thefile, bool normal,
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 *path);
#if defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
@@ -323,7 +325,7 @@ 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);
/* Some functions in help.c. */
#ifdef ENABLE_HELP
@@ -334,12 +336,8 @@ void do_help(void);
/* Most functions in history.c. */
#ifdef ENABLE_HISTORIES
void history_init(void);
void history_reset(const linestruct *list);
void update_history(linestruct **item, const char *text);
char *get_history_older(linestruct **h);
char *get_history_newer(linestruct **h);
void get_history_older_void(void);
void get_history_newer_void(void);
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
@@ -364,8 +362,8 @@ void to_para_end(void);
#endif
void to_prev_block(void);
void to_next_block(void);
void do_prev_word(bool allow_punct);
bool do_next_word(bool after_ends, bool allow_punct);
void 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);
@@ -390,6 +388,9 @@ void free_lines(linestruct *src);
void renumber_from(linestruct *line);
void print_view_warning(void);
bool in_restricted_mode(void);
#ifndef NANO_TINY
void suggest_ctrlT_ctrlZ(void);
#endif
void finish(void);
void close_and_go(void);
void do_exit(void);
@@ -404,15 +405,15 @@ void handle_hupterm(int signal);
#ifndef DEBUG
void handle_crash(int signal);
#endif
void do_suspend(int signal);
void do_continue(int signal);
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
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);
@@ -432,7 +433,7 @@ void put_cursor_at_end_of_answer(void);
void add_or_remove_pipe_symbol_from_answer(void);
int do_prompt(int menu, const char *provided, linestruct **history_list,
void (*refresh_func)(void), const char *msg, ...);
int do_yesno_prompt(bool all, const char *msg);
int ask_user(bool withall, const char *question);
/* Most functions in rcfile.c. */
#if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES)
@@ -465,9 +466,9 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
void do_replace(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 retain_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);
@@ -497,7 +498,7 @@ 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 *textstart, ssize_t goal, bool snap_at_nl);
@@ -520,7 +521,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);
@@ -570,11 +571,11 @@ linestruct *line_from_number(ssize_t number);
/* 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);
char *get_verbatim_kbinput(WINDOW *win, size_t *count);
#ifdef ENABLE_MOUSE
@@ -625,7 +626,6 @@ 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);
#ifdef ENABLE_EXTRA
void do_credits(void);
#endif
@@ -634,6 +634,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
@@ -642,12 +646,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);

View File

@@ -1,10 +1,10 @@
/**************************************************************************
* rcfile.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2022 Free Software Foundation, Inc. *
* Copyright (C) 2014 Mike Frysinger *
* Copyright (C) 2019 Brand Huntsman *
* Copyright (C) 2014-2020 Benno Schulenberg *
* Copyright (C) 2014-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 *
@@ -91,7 +91,7 @@ static const rcoption rcopts[] = {
{"speller", 0},
#endif
{"suspend", SUSPENDABLE}, /* Deprecated; remove in 2022. */
{"suspendable", SUSPENDABLE},
{"suspendable", SUSPENDABLE}, /* Obsolete; remove in 2022. */
{"tempfile", SAVE_ON_EXIT}, /* Deprecated; remove in 2022. */
#ifndef NANO_TINY
{"afterends", AFTER_ENDS},
@@ -122,6 +122,7 @@ static const rcoption rcopts[] = {
{"wordbounds", WORD_BOUNDS},
{"wordchars", 0},
{"zap", LET_THEM_ZAP},
{"zero", ZERO},
#endif
#ifdef ENABLE_COLOR
{"titlecolor", 0},
@@ -242,11 +243,11 @@ keystruct *strtosc(const char *input)
else if (!strcmp(input, "discardbuffer"))
s->func = discard_buffer;
else if (!strcmp(input, "writeout"))
s->func = do_writeout_void;
s->func = do_writeout;
else if (!strcmp(input, "savefile"))
s->func = do_savefile;
else if (!strcmp(input, "insert"))
s->func = do_insertfile_void;
s->func = do_insertfile;
else if (!strcmp(input, "whereis"))
s->func = do_search_forward;
else if (!strcmp(input, "wherewas"))
@@ -288,7 +289,7 @@ keystruct *strtosc(const char *input)
!strcmp(input, "curpos")) /* Deprecated; remove in 2022. */
s->func = report_cursor_position;
else if (!strcmp(input, "gotoline"))
s->func = do_gotolinecolumn_void;
s->func = do_gotolinecolumn;
#ifdef ENABLE_JUSTIFY
else if (!strcmp(input, "justify"))
s->func = do_justify;
@@ -312,16 +313,14 @@ keystruct *strtosc(const char *input)
s->func = do_indent;
else if (!strcmp(input, "unindent"))
s->func = do_unindent;
else if (!strcmp(input, "chopwordleft") ||
!strcmp(input, "cutwordleft")) /* Deprecated; remove in 2021. */
else if (!strcmp(input, "chopwordleft"))
s->func = chop_previous_word;
else if (!strcmp(input, "chopwordright") ||
!strcmp(input, "cutwordright")) /* Deprecated; remove in 2021. */
else if (!strcmp(input, "chopwordright"))
s->func = chop_next_word;
else if (!strcmp(input, "findbracket"))
s->func = do_find_bracket;
else if (!strcmp(input, "wordcount"))
s->func = do_wordlinechar_count;
s->func = count_lines_words_and_characters;
else if (!strcmp(input, "recordmacro"))
s->func = record_macro;
else if (!strcmp(input, "runmacro"))
@@ -397,8 +396,10 @@ keystruct *strtosc(const char *input)
s->func = do_backspace;
else if (!strcmp(input, "refresh"))
s->func = full_refresh;
#ifndef NANO_TINY
else if (!strcmp(input, "suspend"))
s->func = do_suspend_void;
s->func = do_suspend;
#endif
else if (!strcmp(input, "casesens"))
s->func = case_sens_void;
else if (!strcmp(input, "regexp"))
@@ -411,21 +412,21 @@ keystruct *strtosc(const char *input)
s->func = flip_goto;
#ifdef ENABLE_HISTORIES
else if (!strcmp(input, "older"))
s->func = get_history_older_void;
s->func = get_older_item;
else if (!strcmp(input, "newer"))
s->func = get_history_newer_void;
s->func = get_newer_item;
#endif
#ifndef NANO_TINY
else if (!strcmp(input, "dosformat"))
s->func = dos_format_void;
s->func = dos_format;
else if (!strcmp(input, "macformat"))
s->func = mac_format_void;
s->func = mac_format;
else if (!strcmp(input, "append"))
s->func = append_void;
s->func = append_it;
else if (!strcmp(input, "prepend"))
s->func = prepend_void;
s->func = prepend_it;
else if (!strcmp(input, "backup"))
s->func = backup_file_void;
s->func = back_it_up;
else if (!strcmp(input, "flipexecute"))
s->func = flip_execute;
else if (!strcmp(input, "flippipe"))
@@ -450,9 +451,11 @@ keystruct *strtosc(const char *input)
#endif
else {
#ifndef NANO_TINY
s->func = do_toggle_void;
s->func = do_toggle;
if (!strcmp(input, "nohelp"))
s->toggle = NO_HELP;
else if (!strcmp(input, "zero"))
s->toggle = ZERO;
else if (!strcmp(input, "constantshow"))
s->toggle = CONSTANT_SHOW;
else if (!strcmp(input, "softwrap"))
@@ -484,9 +487,6 @@ keystruct *strtosc(const char *input)
else if (!strcmp(input, "mouse"))
s->toggle = USE_MOUSE;
#endif
else if (!strcmp(input, "suspendable") ||
!strcmp(input, "suspendenable")) /* Deprecated; remove in 2022. */
s->toggle = SUSPENDABLE;
else
#endif /* !NANO_TINY */
{
@@ -828,9 +828,9 @@ void parse_binding(char *ptr, bool dobind)
if (is_universal(newsc->func))
menu &= MMOST|MBROWSER;
#ifndef NANO_TINY
else if (newsc->func == do_toggle_void && newsc->toggle == NO_HELP)
else if (newsc->func == do_toggle && newsc->toggle == NO_HELP)
menu &= (MMOST|MBROWSER|MYESNO) & ~MFINDINHELP;
else if (newsc->func == do_toggle_void)
else if (newsc->func == do_toggle)
menu &= MMAIN;
#endif
else if (newsc->func == full_refresh)
@@ -868,9 +868,9 @@ void parse_binding(char *ptr, bool dobind)
#ifndef NANO_TINY
/* If this is a toggle, find and copy its sequence number. */
if (newsc->func == do_toggle_void) {
if (newsc->func == do_toggle) {
for (keystruct *s = sclist; s != NULL; s = s->next)
if (s->func == do_toggle_void && s->toggle == newsc->toggle)
if (s->func == do_toggle && s->toggle == newsc->toggle)
newsc->ordinal = s->ordinal;
} else
newsc->ordinal = 0;
@@ -992,7 +992,20 @@ void parse_includes(char *ptr)
free(expanded);
}
#define COLORCOUNT 20
/* Return the index of the color that is closest to the given RGB levels,
* assuming that the terminal uses the 6x6x6 color cube of xterm-256color. */
short closest_index_color(short red, short green, short blue)
{
/* Translation table, from 16 intended levels to 6 available levels. */
static const short level[] = { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 };
if (COLORS == 256)
return (36 * level[red] + 6 * level[green] + level[blue] + 16);
else
return THE_DEFAULT;
}
#define COLORCOUNT 34
const char hues[COLORCOUNT][8] = { "red", "green", "blue",
"yellow", "cyan", "magenta",
@@ -1000,12 +1013,19 @@ const char hues[COLORCOUNT][8] = { "red", "green", "blue",
"pink", "purple", "mauve",
"lagoon", "mint", "lime",
"peach", "orange", "latte",
"rosy", "beet", "plum",
"sea", "sky", "slate",
"teal", "sage", "brown",
"ocher", "sand", "tawny",
"brick", "crimson",
"grey", "gray" };
short indices[COLORCOUNT] = { COLOR_RED, COLOR_GREEN, COLOR_BLUE,
COLOR_YELLOW, COLOR_CYAN, COLOR_MAGENTA,
COLOR_WHITE, COLOR_BLACK, THE_DEFAULT,
204, 163, 134, 38, 48, 148, 215, 208, 137,
175, 127, 98, 32, 111, 66, 35, 107, 100,
142, 186, 136, 166, 161,
COLOR_BLACK + 8, COLOR_BLACK + 8 };
/* Return the short value corresponding to the given color name, and set
@@ -1026,6 +1046,18 @@ short color_to_short(const char *colorname, bool *vivid, bool *thick)
*thick = FALSE;
}
if (colorname[0] == '#' && strlen(colorname) == 4) {
unsigned short r, g, b;
if (*vivid) {
jot_error(N_("Color '%s' takes no prefix"), colorname);
return BAD_COLOR;
}
if (sscanf(colorname, "#%1hX%1hX%1hX", &r, &g, &b) == 3)
return closest_index_color(r, g, b);
}
for (int index = 0; index < COLORCOUNT; index++)
if (strcmp(colorname, hues[index]) == 0) {
if (index > 7 && *vivid) {
@@ -1567,7 +1599,7 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
#endif
#ifdef ENABLE_OPERATINGDIR
if (strcmp(option, "operatingdir") == 0)
operating_dir = copy_of(argument);
operating_dir = mallocstrcpy(operating_dir, argument);
else
#endif
#ifdef ENABLED_WRAPORJUSTIFY
@@ -1585,12 +1617,12 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
else if (mbstrlen(argument) % 2 != 0)
jot_error(N_("Even number of characters required"));
else
matchbrackets = copy_of(argument);
matchbrackets = mallocstrcpy(matchbrackets, argument);
} else if (strcmp(option, "whitespace") == 0) {
if (mbstrlen(argument) != 2 || breadth(argument) != 2)
jot_error(N_("Two single-column characters required"));
else {
whitespace = copy_of(argument);
whitespace = mallocstrcpy(whitespace, argument);
whitelen[0] = char_length(whitespace);
whitelen[1] = char_length(whitespace + whitelen[0]);
}
@@ -1601,26 +1633,26 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
if (has_blank_char(argument))
jot_error(N_("Non-blank characters required"));
else
punct = copy_of(argument);
punct = mallocstrcpy(punct, argument);
} else if (strcmp(option, "brackets") == 0) {
if (has_blank_char(argument))
jot_error(N_("Non-blank characters required"));
else
brackets = copy_of(argument);
brackets = mallocstrcpy(brackets, argument);
} else if (strcmp(option, "quotestr") == 0)
quotestr = copy_of(argument);
quotestr = mallocstrcpy(quotestr, argument);
else
#endif
#ifdef ENABLE_SPELLER
if (strcmp(option, "speller") == 0)
alt_speller = copy_of(argument);
alt_speller = mallocstrcpy(alt_speller, argument);
else
#endif
#ifndef NANO_TINY
if (strcmp(option, "backupdir") == 0)
backup_dir = copy_of(argument);
backup_dir = mallocstrcpy(backup_dir, argument);
else if (strcmp(option, "wordchars") == 0)
word_chars = copy_of(argument);
word_chars = mallocstrcpy(word_chars, argument);
else if (strcmp(option, "guidestripe") == 0) {
if (!parse_num(argument, &stripe_column) || stripe_column <= 0) {
jot_error(N_("Guide column \"%s\" is invalid"), argument);

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* search.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* 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 *
@@ -65,6 +65,9 @@ void tidy_up_after_search(void)
if (openfile->mark)
refresh_needed = TRUE;
#endif
#ifdef ENABLE_COLOR
recook |= perturbed;
#endif
}
/* Prepare the prompt and ask the user what to search for. Keep looping
@@ -118,7 +121,7 @@ void search_init(bool replacing, bool retain_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
}
@@ -152,7 +155,7 @@ void search_init(bool replacing, bool retain_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
@@ -186,7 +189,7 @@ 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. */
nodelay(edit, TRUE);
nodelay(midwin, TRUE);
if (begin == NULL)
came_full_circle = FALSE;
@@ -226,14 +229,14 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
#ifndef NANO_TINY
if (the_window_resized) {
regenerate_screen();
nodelay(edit, TRUE);
nodelay(midwin, TRUE);
statusbar(_("Searching..."));
feedback = 1;
}
#endif
/* If we're back at the beginning, then there is no needle. */
if (came_full_circle) {
nodelay(edit, FALSE);
nodelay(midwin, FALSE);
return 0;
}
@@ -244,7 +247,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
* but stop when spell-checking or replacing in a region. */
if (line == NULL) {
if (whole_word_only || modus == INREGION) {
nodelay(edit, FALSE);
nodelay(midwin, FALSE);
return 0;
}
@@ -268,7 +271,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
/* Glance at the keyboard once every second, to check for a Cancel. */
if (time(NULL) - lastkbcheck > 0) {
int input = wgetch(edit);
int input = wgetch(midwin);
lastkbcheck = time(NULL);
@@ -276,7 +279,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
while (input != ERR) {
if (input == ESC_CODE) {
napms(20);
input = wgetch(edit);
input = wgetch(midwin);
meta_key = TRUE;
} else
meta_key = FALSE;
@@ -289,12 +292,12 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
statusbar(_("Cancelled"));
/* Clear out the key buffer (in case a macro is running). */
while (input != ERR)
input = parse_kbinput(NULL);
nodelay(edit, FALSE);
input = get_input(NULL);
nodelay(midwin, FALSE);
return -2;
}
input = wgetch(edit);
input = wgetch(midwin);
}
if (++feedback > 0)
@@ -306,7 +309,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
found_x = found - line->data;
nodelay(edit, FALSE);
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 ||
@@ -327,9 +330,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
spotlighted = TRUE;
light_from_col = xplustabs();
light_to_col = wideness(line->data, found_x + found_len);
if (!ISSET(SHOW_CURSOR))
hide_cursor = TRUE;
edit_refresh();
refresh_needed = TRUE;
}
#endif
@@ -555,7 +556,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
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);
@@ -591,21 +592,21 @@ 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. */
if (choice == YES || replaceall) {
size_t length_change;
char *altered;
@@ -659,6 +660,10 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
free(openfile->current->data);
openfile->current->data = altered;
#ifdef ENABLE_COLOR
check_the_multis(openfile->current);
refresh_needed = FALSE;
#endif
set_modified();
as_an_at = TRUE;
numreplaced++;
@@ -706,7 +711,7 @@ void ask_for_and_do_replacements(void)
#ifdef ENABLE_HISTORIES
/* 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. */
@@ -724,7 +729,7 @@ void ask_for_and_do_replacements(void)
openfile->current = beginline;
openfile->current_x = begin_x;
edit_refresh();
refresh_needed = TRUE;
if (numreplaced >= 0)
statusline(REMARK, P_("Replaced %zd occurrence",
@@ -734,6 +739,12 @@ void ask_for_and_do_replacements(void)
/* Go to the specified line and x position. */
void goto_line_posx(ssize_t line, size_t pos_x)
{
#ifdef ENABLE_COLOR
if (line > openfile->edittop->lineno + editwinrows ||
(ISSET(SOFTWRAP) && line > openfile->current->lineno))
recook |= perturbed;
#endif
for (openfile->current = openfile->filetop; line > 1 &&
openfile->current != openfile->filebot; line--)
openfile->current = openfile->current->next;
@@ -747,8 +758,8 @@ 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 retain_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. */
@@ -792,6 +803,12 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool retain_answer,
if (line < 1)
line = 1;
#ifdef ENABLE_COLOR
if (line > openfile->edittop->lineno + editwinrows ||
(ISSET(SOFTWRAP) && line > openfile->current->lineno))
recook |= perturbed;
#endif
/* Iterate to the requested line. */
for (openfile->current = openfile->filetop; line > 1 &&
openfile->current != openfile->filebot; line--)
@@ -844,9 +861,9 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool retain_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);
}
@@ -994,6 +1011,11 @@ void go_to_and_confirm(linestruct *line)
if (line != openfile->current) {
openfile->current = line;
openfile->current_x = 0;
#ifdef ENABLE_COLOR
if (line->lineno > openfile->edittop->lineno + editwinrows ||
(ISSET(SOFTWRAP) && line->lineno > was_current->lineno))
recook |= perturbed;
#endif
edit_redraw(was_current, CENTERING);
statusbar(_("Jumped to anchor"));
} else if (openfile->current->has_anchor)

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* text.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
* Copyright (C) 2014-2015 Mark Majeres *
* Copyright (C) 2016 Mike Scalora *
* Copyright (C) 2016 Sumedh Pendurkar *
@@ -558,7 +558,8 @@ void do_undo(void)
* and the nonewlines flag isn't set, do not re-add a newline that
* wasn't actually deleted; just position the cursor. */
if ((u->xflags & WAS_BACKSPACE_AT_EOF) && !ISSET(NO_NEWLINES)) {
goto_line_posx(openfile->filebot->lineno, 0);
openfile->current = openfile->filebot;
openfile->current_x = 0;
break;
}
line->data[u->tail_x] = '\0';
@@ -665,6 +666,13 @@ void do_undo(void)
openfile->totsize = u->wassize;
#ifdef ENABLE_COLOR
if (u->type <= REPLACE)
check_the_multis(openfile->current);
else if (u->type == INSERT)
perturbed = TRUE;
#endif
/* When at the point where the buffer was last saved, unset "Modified". */
if (openfile->current_undo == openfile->last_saved) {
openfile->modified = FALSE;
@@ -825,6 +833,13 @@ void do_redo(void)
openfile->totsize = u->newsize;
#ifdef ENABLE_COLOR
if (u->type <= REPLACE)
check_the_multis(openfile->current);
else if (u->type == INSERT)
recook = TRUE;
#endif
/* When at the point where the buffer was last saved, unset "Modified". */
if (openfile->current_undo == openfile->last_saved) {
openfile->modified = FALSE;
@@ -1177,7 +1192,8 @@ void update_undo(undo_type action)
else if (cutbuffer != NULL) {
free_lines(u->cutbuffer);
u->cutbuffer = copy_buffer(cutbuffer);
}
} else
break;
if (!(u->xflags & MARK_WAS_SET)) {
linestruct *bottomline = u->cutbuffer;
size_t count = 0;
@@ -1212,9 +1228,9 @@ void update_undo(undo_type action)
#ifdef ENABLE_WRAPPING
/* When the current line is overlong, hard-wrap it at the furthest possible
* whitespace character, and (if possible) prepend the remainder of the line
* to the next line. Return TRUE if wrapping occurred, and FALSE otherwise. */
bool do_wrap(void)
* whitespace character, and prepend the excess part to an "overflow" line
* (when it already exists, otherwise create one). */
void do_wrap(void)
{
linestruct *line = openfile->current;
/* The line to be wrapped, if needed and possible. */
@@ -1243,7 +1259,7 @@ bool do_wrap(void)
/* If no wrapping point was found before end-of-line, we don't wrap. */
if (wrap_loc < 0 || lead_len + wrap_loc == line_len)
return FALSE;
return;
/* Adjust the wrap location to its position in the full line,
* and step forward to the character just after the blank. */
@@ -1251,7 +1267,7 @@ bool do_wrap(void)
/* When now at end-of-line, no need to wrap. */
if (line->data[wrap_loc] == '\0')
return FALSE;
return;
#ifndef NANO_TINY
add_undo(SPLIT_BEGIN, NULL);
@@ -1360,7 +1376,7 @@ bool do_wrap(void)
add_undo(SPLIT_END, NULL);
#endif
return TRUE;
refresh_needed = TRUE;
}
#endif /* ENABLE_WRAPPING */
@@ -1465,9 +1481,8 @@ bool begpar(const linestruct *const line, int depth)
{
size_t quot_len, indent_len, prev_dent_len;
/* If this is the very first line of the buffer, it counts as a BOP
* even when it contains no text. */
if (line == openfile->filetop)
/* The very first line counts as a BOP, even when it contains no text. */
if (line->prev == NULL)
return TRUE;
/* If recursion is going too deep, just say it's not a BOP. */
@@ -1746,6 +1761,8 @@ void justify_text(bool whole_buffer)
/* The leading part for lines after the first one. */
size_t secondary_len = 0;
/* The length of that later lead. */
ssize_t was_the_linenumber = openfile->current->lineno;
/* The line to return to after a full justification. */
/* TRANSLATORS: This one goes with Undid/Redid messages. */
add_undo(COUPLE_BEGIN, N_("justification"));
@@ -1962,7 +1979,8 @@ void justify_text(bool whole_buffer)
openfile->current_x = openfile->mark_x;
openfile->mark = bottom;
openfile->mark_x = bottom_x;
}
} else if (whole_buffer && !openfile->mark)
goto_line_posx(was_the_linenumber, 0);
add_undo(COUPLE_END, N_("justification"));
@@ -2032,11 +2050,19 @@ bool replace_buffer(const char *filename, undo_type action, const char *operatio
if (descriptor < 0)
return FALSE;
#ifndef NANO_TINY
add_undo(COUPLE_BEGIN, operation);
#endif
/* When replacing the whole buffer, start cutting at the top. */
if (action == CUT_TO_EOF) {
openfile->current = openfile->filetop;
openfile->current_x = 0;
}
cutbuffer = NULL;
#ifndef NANO_TINY
add_undo(COUPLE_BEGIN, operation);
/* Cut either the marked region or the whole buffer. */
add_undo(action, NULL);
do_snip(openfile->mark != NULL, openfile->mark == NULL, FALSE);
@@ -2061,6 +2087,7 @@ bool replace_buffer(const char *filename, undo_type action, const char *operatio
/* Execute the given program, with the given temp file as last argument. */
void treat(char *tempfile_name, char *theprogram, bool spelling)
{
#if defined(HAVE_FORK) && defined(HAVE_WAIT)
ssize_t was_lineno = openfile->current->lineno;
size_t was_pww = openfile->placewewant;
size_t was_x = openfile->current_x;
@@ -2155,14 +2182,9 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
openfile->mark = line_from_number(was_mark_lineno);
} else
#endif
{
openfile->current = openfile->filetop;
openfile->current_x = 0;
replaced = replace_buffer(tempfile_name, CUT_TO_EOF,
/* TRANSLATORS: The next two go with Undid/Redid messages. */
(spelling ? N_("spelling correction") : N_("formatting")));
}
/* Go back to the old position. */
goto_line_posx(was_lineno, was_x);
@@ -2183,6 +2205,7 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
statusline(REMARK, _("Finished checking spelling"));
else
statusline(REMARK, _("Buffer has been processed"));
#endif
}
#endif /* ENABLE_SPELLER || ENABLE_COLOR */
@@ -2295,12 +2318,14 @@ bool fix_spello(const char *word)
* correction. */
void do_int_speller(const char *tempfile_name)
{
#if defined(HAVE_FORK) && defined(HAVE_WAITPID)
char *misspellings, *pointer, *oneword;
long pipesize;
size_t buffersize, bytesread, totalread;
int spell_fd[2], sort_fd[2], uniq_fd[2], tempfile_fd = -1;
pid_t pid_spell, pid_sort, pid_uniq;
int spell_status, sort_status, uniq_status;
unsigned stash[sizeof(flags) / sizeof(flags[0])];
/* Create all three pipes up front. */
if (pipe(spell_fd) == -1 || pipe(sort_fd) == -1 || pipe(uniq_fd) == -1) {
@@ -2425,6 +2450,9 @@ void do_int_speller(const char *tempfile_name)
terminal_init();
doupdate();
/* Save the settings of the global flags. */
memcpy(stash, flags, sizeof(flags));
/* Do any replacements case-sensitively, forward, and without regexes. */
SET(CASE_SENSITIVE);
UNSET(BACKWARDS_SEARCH);
@@ -2455,6 +2483,9 @@ void do_int_speller(const char *tempfile_name)
free(misspellings);
refresh_needed = TRUE;
/* Restore the settings of the global flags. */
memcpy(flags, stash, sizeof(flags));
/* Process the end of the three processes. */
waitpid(pid_spell, &spell_status, 0);
waitpid(pid_sort, &sort_status, 0);
@@ -2468,6 +2499,7 @@ void do_int_speller(const char *tempfile_name)
statusline(ALERT, _("Error invoking \"spell\""));
else
statusline(REMARK, _("Finished checking spelling"));
#endif
}
/* Spell check the current file. If an alternate spell checker is
@@ -2476,7 +2508,6 @@ void do_spell(void)
{
FILE *stream;
char *temp_name;
unsigned stash[sizeof(flags) / sizeof(flags[0])];
bool okay;
ran_a_tool = TRUE;
@@ -2491,12 +2522,6 @@ void do_spell(void)
return;
}
/* Save the settings of the global flags. */
memcpy(stash, flags, sizeof(flags));
/* Don't add an extra newline when writing out the (selected) text. */
SET(NO_NEWLINES);
#ifndef NANO_TINY
if (openfile->mark)
okay = write_region_to_file(temp_name, stream, TEMPORARY, OVERWRITE);
@@ -2506,6 +2531,7 @@ void do_spell(void)
if (!okay) {
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
unlink(temp_name);
free(temp_name);
return;
}
@@ -2520,9 +2546,6 @@ void do_spell(void)
unlink(temp_name);
free(temp_name);
/* Restore the settings of the global flags. */
memcpy(flags, stash, sizeof(flags));
/* Ensure the help lines will be redrawn and a selection is retained. */
currmenu = MMOST;
shift_held = TRUE;
@@ -2533,6 +2556,7 @@ void do_spell(void)
/* Run a linting program on the current buffer. */
void do_linter(void)
{
#if defined(HAVE_FORK) && defined(HAVE_WAITPID)
char *lintings, *pointer, *onelint;
long pipesize;
size_t buffersize, bytesread, totalread;
@@ -2559,12 +2583,12 @@ void do_linter(void)
edit_refresh();
if (openfile->modified) {
int choice = do_yesno_prompt(FALSE, _("Save modified buffer before linting?"));
int choice = ask_user(YESORNO, _("Save modified buffer before linting?"));
if (choice == -1) {
if (choice == CANCEL) {
statusbar(_("Cancelled"));
return;
} else if (choice == 1 && (do_writeout(FALSE, FALSE) != 1))
} else if (choice == YES && (write_it_out(FALSE, FALSE) != 1))
return;
}
@@ -2648,36 +2672,31 @@ void do_linter(void)
if ((*pointer == '\r') || (*pointer == '\n')) {
*pointer = '\0';
if (onelint != pointer) {
char *filename = NULL, *linestr = NULL, *maybecol = NULL;
char *message = copy_of(onelint);
char *filename, *linestring, *colstring;
char *complaint = copy_of(onelint);
char *spacer = strstr(complaint, " ");
/* The recognized format is "filename:line:column: message",
* where ":column" may be absent or be ",column" instead. */
if (strstr(message, ": ") != NULL) {
filename = strtok(onelint, ":");
if ((linestr = strtok(NULL, ":")) != NULL) {
if ((maybecol = strtok(NULL, ":")) != NULL) {
ssize_t tmplineno = 0, tmpcolno = 0;
char *tmplinecol;
if ((filename = strtok(onelint, ":")) && spacer) {
if ((linestring = strtok(NULL, ":"))) {
if ((colstring = strtok(NULL, " "))) {
ssize_t linenumber = strtol(linestring, NULL, 10);
ssize_t colnumber = strtol(colstring, NULL, 10);
tmplineno = strtol(linestr, NULL, 10);
if (tmplineno <= 0) {
if (linenumber <= 0) {
free(complaint);
pointer++;
free(message);
continue;
}
tmpcolno = strtol(maybecol, NULL, 10);
/* Check if the middle field is in comma format. */
if (tmpcolno <= 0) {
strtok(linestr, ",");
if ((tmplinecol = strtok(NULL, ",")) != NULL)
tmpcolno = strtol(tmplinecol, NULL, 10);
else
tmpcolno = 1;
if (colnumber <= 0) {
colnumber = 1;
strtok(linestring, ",");
if ((colstring = strtok(NULL, ",")))
colnumber = strtol(colstring, NULL, 10);
}
/* Nice. We have a lint message we can use. */
parsesuccess = TRUE;
tmplint = curlint;
curlint = nmalloc(sizeof(lintstruct));
@@ -2685,17 +2704,17 @@ void do_linter(void)
curlint->prev = tmplint;
if (curlint->prev != NULL)
curlint->prev->next = curlint;
curlint->msg = copy_of(strstr(message, ": ") + 2);
curlint->lineno = tmplineno;
curlint->colno = tmpcolno;
curlint->filename = copy_of(filename);
curlint->lineno = linenumber;
curlint->colno = colnumber;
curlint->msg = copy_of(spacer + 1);
if (lints == NULL)
lints = curlint;
}
}
}
free(message);
free(complaint);
}
onelint = pointer + 1;
}
@@ -2718,7 +2737,7 @@ void do_linter(void)
return;
}
if (helpless && LINES > 4) {
if (helpless && LINES > 5) {
UNSET(NO_HELP);
window_init();
}
@@ -2753,14 +2772,14 @@ void do_linter(void)
sprintf(msg, _("This message is for unopened file %s,"
" open it in a new buffer?"), curlint->filename);
choice = do_yesno_prompt(FALSE, msg);
choice = ask_user(YESORNO, msg);
currmenu = MLINTER;
free(msg);
if (choice == -1) {
if (choice == CANCEL) {
statusbar(_("Cancelled"));
break;
} else if (choice == 1) {
} else if (choice == YES) {
open_buffer(curlint->filename, TRUE);
} else {
#endif
@@ -2819,9 +2838,9 @@ void do_linter(void)
/* Place the cursor to indicate the affected line. */
place_the_cursor();
wnoutrefresh(edit);
wnoutrefresh(midwin);
kbinput = get_kbinput(bottomwin, VISIBLE);
kbinput = get_kbinput(footwin, VISIBLE);
#ifndef NANO_TINY
if (kbinput == KEY_WINCH)
@@ -2877,6 +2896,7 @@ void do_linter(void)
lastmessage = VACUUM;
currmenu = MMOST;
titlebar(NULL);
#endif
}
/* Run a manipulation program on the contents of the buffer. */
@@ -2905,13 +2925,10 @@ void do_formatter(void)
if (temp_name != NULL)
okay = write_file(temp_name, stream, TEMPORARY, OVERWRITE, NONOTES);
if (!okay) {
if (!okay)
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
free(temp_name);
return;
}
treat(temp_name, openfile->syntax->formatter, FALSE);
else
treat(temp_name, openfile->syntax->formatter, FALSE);
unlink(temp_name);
free(temp_name);
@@ -2919,9 +2936,9 @@ void do_formatter(void)
#endif /* ENABLE_COLOR */
#ifndef NANO_TINY
/* Our own version of "wc". Note that its character counts are in
/* Our own version of "wc". Note that the character count is in
* multibyte characters instead of single-byte characters. */
void do_wordlinechar_count(void)
void count_lines_words_and_characters(void)
{
linestruct *was_current = openfile->current;
size_t was_x = openfile->current_x;
@@ -2960,7 +2977,7 @@ void do_wordlinechar_count(void)
* incrementing the word count for each successful step. */
while (openfile->current->lineno < botline->lineno ||
(openfile->current == botline && openfile->current_x < bot_x)) {
if (do_next_word(FALSE, TRUE))
if (do_next_word(FALSE))
words++;
}
@@ -2983,12 +3000,19 @@ void do_verbatim_input(void)
size_t count = 1;
char *bytes;
#ifndef NANO_TINY
/* When barless and with cursor on bottom row, make room for the feedback. */
if (ISSET(ZERO) && openfile->current_y == editwinrows - 1 && LINES > 1) {
edit_scroll(FORWARD);
edit_refresh();
}
#endif
/* TRANSLATORS: Shown when the next keystroke will be inserted verbatim. */
statusline(INFO, _("Verbatim Input"));
place_the_cursor();
/* Read in the first one or two bytes of the next keystroke. */
bytes = get_verbatim_kbinput(edit, &count);
bytes = get_verbatim_kbinput(midwin, &count);
/* When something valid was obtained, unsuppress cursor-position display,
* insert the bytes into the edit buffer, and blank the status bar. */

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* utils.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2021 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 *
@@ -282,34 +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 (howmuch == 0)
die("Allocating zero bytes. Please report a bug.\n");
if (r == NULL)
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 (howmuch == 0)
die("Allocating zero bytes. Please report a bug.\n");
if (r == NULL)
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.

File diff suppressed because it is too large Load Diff

View File

@@ -36,13 +36,12 @@ pkgdata_DATA = asm.nanorc \
tcl.nanorc \
tex.nanorc \
texinfo.nanorc \
xml.nanorc
xml.nanorc \
yaml.nanorc
nobase_pkgdata_DATA = \
extra/ada.nanorc \
extra/debian.nanorc \
extra/fortran.nanorc \
extra/gentoo.nanorc \
extra/haskell.nanorc \
extra/povray.nanorc \
extra/spec.nanorc

View File

@@ -11,8 +11,8 @@ color brightyellow "\.(ascii|asciz|byte|double|float|hword|int|long|short|single
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 "<[^= ]*>" ""(\\.|[^"])*""
# Strings and names of included files.
color brightyellow ""([^"\]|\\.)*"|<[^= ]*>"
# Comments.
color brightblue "//.*"

View File

@@ -17,7 +17,7 @@ color cyan "\<[[:upper:]_[:digit:]]+\>"
color red "\<[-_.0-9]+\>"
# Strings:
color red ""[^"]*"" "'[^']*'"
color red ""[^"]*"|'[^']*'"
# Backticks:
color green "`[^`]*`"

View File

@@ -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 "(^|[[:blank:]])#.*$"
color brightblue "(^|[[:blank:]])#.*"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -23,17 +23,16 @@ color brightyellow "\<(try|throw|catch|operator|new|delete)\>"
color magenta "\<(break|continue|goto|return)\>"
# Single-quoted stuff (characters, backslash escapes, hex and octal byte codes).
color brightmagenta "'([^'\]|\\(["'\abfnrtv]|x[0-9A-Fa-f]{1,2}|[0-3]?[0-7]{1,2}))'"
color brightmagenta "'([^'\]|\\(["'\abfnrtv]|x[[:xdigit:]]{1,2}|[0-3]?[0-7]{1,2}))'"
# GCC builtins.
color cyan "__attribute__[[:blank:]]*\(\([^)]*\)\)" "__(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 ""([^"]|\\")*"" "#[[:blank:]]*include[[:blank:]]*<[^>]+>"
# Strings and names of included files.
color brightyellow ""([^"]|\\")*"|#[[:blank:]]*include[[:blank:]]*<[^>]+>"
# Preprocessor directives.
color brightcyan start="^[[:blank:]]*#[[:blank:]]*(if(n?def)?|elif|warning|error|pragma)\>" end="(\`|[^\\])$"
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.

View File

@@ -13,13 +13,13 @@ color red "^(19|20)[0-9-]{8}"
color yellow "<[^>]*@[^>]*>"
# Command-line options.
color cyan "[[:blank:]]-[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

@@ -15,5 +15,8 @@ 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)?)\>"
# Comments.
color brightblue "(^|[[:blank:]])#.*"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

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

View File

@@ -4,20 +4,27 @@
syntax default
comment "#"
# Comments.
color cyan "^[[:blank:]]*#.*"
# Spaces in front of tabs.
color ,red " + +"
# Nano's name, including version.
color brightred "(GNU )?[Nn]ano [1-5]\.[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 latte "[[:cntrl:]]"
color orange "[[:cntrl:]]"

View File

@@ -28,6 +28,6 @@ color brightred "\<(t|nil)\>"
color blue ":(\w|[?-])+"
# Strings
color yellow start="^[[:blank:]]+"" end="[^\]""
color yellow ""(\\.|[^"])*""
color yellow ""([^"\]|\\.)*""
# Comments
color cyan "(^|[[:blank:]]);.*"

View File

@@ -11,7 +11,7 @@ color yellow "^> ?> ?>.*"
color brightmagenta "<[^@]+@[^@]+>"
# URLs.
color brightblue "(https?|ftp)://\S+\.\S+[^\s.)]"
color brightblue "(https?|ftp)://\S+\.\S+[^[:space:].)]"
# Signatures, even quoted ones.
color yellow start="^>* ?-- $" end="^>* ?$"

View File

@@ -30,7 +30,7 @@ color cyan "'[[:alnum:]]+"
color green "\<[0-9][0-9A-Fa-f_#.+-]*"
# Characters / Strings
color red "'.'" ""[^"]*""
color red "'.'|"[^"]*""
# Comments
color brightblue "--.*"

View File

@@ -1,21 +0,0 @@
## Syntax highlighting 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

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

@@ -1,74 +0,0 @@
## Syntax highlighting for Gentoo ebuilds/eclasses,
## and (further down) for Portage control files.
syntax ebuild "\.e(build|class)$"
comment "#"
## All the standard portage functions:
color brightgreen "(^|\<default_)src_(unpack|prepare|configure|compile|install|test)\>"
color brightgreen "^pkg_(config|nofetch|info|pretend|setup|(pre|post)(inst|rm))\>"
color brightgreen "\<default(_pkg_nofetch|_src_(unpack|prepare|configure|compile|test))?\>"
## Bash-related syntax:
color green "\<(break|case|continue|do|done|elif|else|esac|exit|fi|for|function|if|in|read|return|select|shift|then|time|until|while)\>"
color green "\<(declare|eval|exec|export|let|local)\>"
color green "[{}():;|`$<>!=&\\]" "(\]|\[)"
color green "-[defhnrsuwxzL]\>"
color green "-(eq|ne|gt|lt|ge|le)\>"
## Variables... official portage ones in red, all others in bright red:
color brightred "\$[-0-9@*#?$!]" "\$[[:alpha:]_][[:alnum:]_]*"
color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:digit:]]|@)+\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
color red "\<(EAPI|ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|[BIPR]?DEPEND|PROVIDE|PROPERTIES|REQUIRED_USE|RESTRICT|USERLAND)\>"
color red "\<(S|E?D|T|PV|PF|P|PN|PR|PVR|A|CATEGORY|DISTDIR|FILESDIR|EPREFIX|(B|E|E?SYS)?ROOT|WORKDIR)\>"
color red "\<(AS|C(PP|XX)?|LD)FLAGS\>" "\<C(HOST|TARGET|BUILD)\>" "\<(MERGE_TYPE|REPLACING_VERSIONS|REPLACED_BY_VERSION)\>"
color red "\<EBUILD_PHASE(_FUNC)?\>"
color red "\<QA_((TEXTRELS|EXECSTACK|WX_LOAD)(_[a-zA-Z_0-9]+)?|DT_HASH|PRESTRIPPED)\>"
color red "\<(PATCHES|(HTML_)?DOCS)\>" "\<WANT_(AUTO(CONF|MAKE)|LIBTOOL)\>" "\<AT_M4DIR\>"
## Portage commands:
color magenta "\<(use(_(with|enable|if_iuse)|x)?|in_iuse) [!a-zA-Z0-9_+ -]*" "inherit.*"
color brightblue "\<e(apply(_user)?|begin|end|conf|install|make|ninja|qmake5|ant|(qa)?warn|infon?|error|log|patch(_user)?|new(group|user))\>"
color brightblue "\<e(pause|beep|mktemp|(cvs|svn)_clean|punt_cxx)\>" "\<e(aclocal|auto(reconf|header|conf|make)|libtoolize)\>"
color brightblue "\<e(stack|shopts|umask)_(push|pop)\>" "\<get_libdir\>" "\<ver_(cut|rs|test)\>" "\<version_is_at_least\>"
color brightblue "\<make_desktop_entry\>" "\<unpack(_(makeself|pdv))?\>"
color brightblue "\<(die|hasv?|inherit|nonfatal)\>" "\<(use(_(with|enable|if_iuse)|x)?|in_iuse)\>" "\<(has|best)_version\>"
color brightblue "\<(do|new)(ins|s?bin|doc|header|lib(\.so|\.a)?|man|info|exe|initd|confd|envd|pam|menu|icon)\>"
color brightblue "\<do(compress|dir|html|mo|strip|sym)\>" "\<keepdir\>"
color brightblue "\<prepall(docs|info|man|strip)?\>" "\<prep(info|lib|lib\.(so|a)|man|strip)\>"
color brightblue "\<(doc|ins|exe)?into\>" "\<f(owners|perms)\>" "\<(exe|ins|dir)opts\>"
color brightblue "\<tc-get(BUILD_)?(AR|AS|CC|CPP|CXX|LD|NM|OBJCOPY|PKG_CONFIG|RANLIB)\>"
color brightblue "\<tc-(arch(-kernel)?|export|has-(tls|openmp)|is-cross-compiler)\>"
## Common commands used in ebuilds:
color blue "\<(awk|cat|cd|chmod|chown|cp|echo|env|find|e?grep|ln|make|mkdir|mv|popd|printf|pushd|rm|rmdir|sed|set|tar|touch|unset|xargs)\>"
## Comments (doesn't work that well):
color yellow "(^|[[:space:]])#.*"
## Strings (doesn't work that well):
color brightyellow ""(\\.|[^\"])*"" "'(\\.|[^'])*'"
## Trailing space is bad!
color ,green "[[:space:]]+$"
## Mixed whitespace is also bad.
color ,green " "
syntax /etc/portage "\.(accept_keywords|env|keywords|mask|unmask|use)(/.+)?$"
comment "#"
## Base text:
color green ".+"
## Likely version and slot numbers:
color magenta "-[[:digit:].]+(_(alpha|beta|pre|rc|p)[[:digit:]]*)*(-r[[:digit:]]+)?([:[:space:]]|$)"
color magenta ":[^[:space:]]+([[:space:]]|$)"
## Use flags (must come after version/slot):
color brightred "[[:space:]]+\+?[A-Za-z0-9+_@-]+"
color brightblue "[[:space:]]+-[A-Za-z0-9+_@-]+"
## Accepted arches:
color white "[~-]?\<(alpha|amd64|arm(64)?|hppa|ia64|m68k|mips|ppc(64)?|riscv|s390|sparc|x86)(-(cygwin|linux|macos|solaris|winnt))?\>"
color white "[[:space:]][*~-]?\*"
## Categories:
color cyan "^[[:space:]]*[^/]*/"
## Masking regulators:
color brightmagenta "^[[:space:]]*(=|~|<|<=|>|>=)"
## Comments:
color yellow "#.*"
## Trailing space is bad!
color ,green "[[:space:]]+$"
## Mixed whitespace is also bad.
color ,green " "

View File

@@ -28,9 +28,9 @@ color magenta "\<(Bounded|Data|Enum|Eq|Floating|Fractional|Functor|Integral|Mona
color brightred "undefined"
# Strings
color yellow ""([^\"]|\\.)*""
color yellow ""([^"\]|\\.)*""
# Characters
color brightyellow "'([^\']|\\.)'"
color brightyellow "'([^'\]|\\.)'"
# Comments
color green "--.*"

View File

@@ -26,17 +26,16 @@ color magenta "\<(break|continue|fallthrough|goto|return)\>"
color brightcyan "\<(package|import)\>"
# Literals.
color red "\<([1-9][0-9]*|0[0-7]*|0[xX][0-9A-Fa-f]+)\>"
color red "\<(true|false|nil|iota|_)\>"
color red "\<([1-9][0-9]*|0[0-7]*|0[xX][[:xdigit:]]+)\>"
color red "\<[0-9]+\.[0-9]*([eE][+-]?[0-9]+)?i?\>"
color red "\<[0-9]+[eE][+-]?[0-9]+i?\>"
color red "\B\.[0-9]+([eE][+-]?[0-9]+)?i?\>"
color red "\<[0-9]+i\>"
# Strings and characters; slightly fuzzy.
color red "\<(true|false|nil|iota|_)\>"
color red "'(\\.|[^'])+'"
color red ""(\\.|[^"])*""
color red start=""(\\.|[^"])*\\[[:blank:]]*$" end="^(\\.|[^"])*""
color red ""([^"\]|\\.)*"|'([^'\]|\\.)+'"
color red start=""([^"\]|\\.)*\\[[:blank:]]*$" end="^([^"\]|\\.)*""
# Comments.
color brightblue "//.*"

View File

@@ -1,25 +1,25 @@
## Syntax highlighting for groff.
syntax groff "(/tmac\.[^/]+$|\.(m[ems]|rof|tmac)$)"
syntax groff "\.(m[ems]|rof|tmac)$|/tmac\.[^/]+$"
comment ".\""
# The argument of .ds or .nr
# The setting of a string or register
color cyan "^\.(ds|nr) [^[:space:]]*"
# Single-character escapes
color brightmagenta "\\."
# The argument of \f or \s in the same color
color brightmagenta "\\f(.|\(..)" "\\s(\+|\-)?[0-9]"
# Newlines
color brightmagenta "\\f(.|\(..)|\\s(\+|\-)?[0-9]"
# References to registers
color cyan "\\(\\)?n(.|\(..)"
color cyan start="\\(\\)?n\[" end="]"
# Requests
color brightgreen "^\.[[:blank:]]*[^[:space:]]*"
# Comments
color yellow "^\.\\".*"
# Strings
# References to strings
color green "\\(\\)?\*(.|\(..)"
color green start="\\(\\)?\*\[" end="]"
# Characters
# Special characters
color brightred "\\\(.."
color brightred start="\\\[" end="]"
# Macro arguments

View File

@@ -11,14 +11,13 @@ color brightcyan "\<define(-macro|-module|-public|-syntax)?\>"
# Quoted symbols
color brightyellow "'\<(\w|-)+\>"
# Chars
color brightmagenta "#\\."
color brightmagenta "#\\\w+\>"
color brightmagenta "#\\(.|\w+)"
# Booleans
color brightred "(#t|#f)\>"
# Keywords
color blue "#?:(\w|[?-])+"
# Strings
color yellow start="^[[:blank:]]+"" end="[^\]""
color yellow ""(\\.|[^"])*""
color yellow ""([^"\]|\\.)*""
# Comments
color cyan "(^|[[:blank:]]);.*"

View File

@@ -25,7 +25,7 @@ color red "\<(rows(pan)?|rules|scheme|scope|scrolling|selected|shape|size|span|s
color red "\<(tabindex|target|text|title|type|usemap|valign|value(type)?|vlink|vspace|width|xmlns|xml:space)="
# Strings:
color green ""(\\.|[^"])*""
color green ""([^"\]|\\.)*""
# Comments:
color yellow start="<!--" end="-->"

View File

@@ -12,12 +12,12 @@ color brightyellow "\<(await|export|import|throw|try|catch|finally|new|delete)\>
color magenta "\<(break|continue|return|yield)\>"
# Octal/decimal and hexadecimal numbers.
color cyan "\<([0-9]+|0x[0-9A-Fa-f]+)\>"
color cyan "\<([0-9]+|0x[[:xdigit:]]+)\>"
# Special values.
color cyan "\<(true|false|null|undefined)\>"
# Strings.
color brightmagenta ""(\\.|[^"])*"" "'(\\.|[^'])*'" "`(\\.|[^`])*`"
color brightmagenta ""([^"\]|\\.)*"|'([^'\]|\\.)*'|`([^`\]|\\.)*`"
# Comments.
color brightblue "(^|[[:blank:]])//.*"
color brightblue start="/\*" end="\*/"

View File

@@ -12,9 +12,9 @@ color green ":[[:blank:]]*\-?(0|[1-9][0-9]*)(\.[0-9]+)?([Ee]?[-+]?[0-9]+)?"
# Values (well, any string).
color brightmagenta "".+""
# Hex numbers (used as value).
color green ":[[:blank:]]*"#[0-9abcdefABCDEF]+""
color green ":[[:blank:]]*"#[[:xdigit:]]+""
# Escapes.
color green "\\\\" "\\"" "\\[bfnrt]" "\\u[0-9abcdefABCDEF]{4})"
color green "\\(["\/bfnrt]|u[[:xdigit:]]{4})"
# Special words.
color green "\<(true|false|null)\>"
@@ -22,9 +22,8 @@ color green "\<(true|false|null)\>"
color brightblue ""[^"]+"[[:blank:]]*:"
# Brackets, braces, and separators.
color brightblue "\[" "\]"
color brightred "\{" "\}"
color brightred "," ":"
color brightblue "[][]"
color brightred "[{},:]"
# Comments.
color cyan "(^|[[:blank:]]+)(//|#).*"

View File

@@ -45,7 +45,7 @@ color brightmagenta "\<(false|nil|true)\>"
# Decimal and hexadecimal numbers
color red "\<[0-9]+(\.[0-9]*)?([Ee][+-]?[0-9]+)?\>"
color red "\<0x[0-9A-Fa-f]+(\.[0-9A-Fa-f]*)?([Pp][+-]?[0-9]+)?\>"
color red "\<0x[[:xdigit:]]+(\.[[:xdigit:]]*)?([Pp][+-]?[0-9]+)?\>"
# Brackets
color brightmagenta "\(|\)|\[|\]|\{|\}"
@@ -54,7 +54,7 @@ color brightmagenta "\(|\)|\[|\]|\{|\}"
color brightcyan "^#!.*"
# Strings
color red ""(\\.|[^"\])*"|'(\\.|[^'\])*'"
color red ""([^"\]|\\.)*"|'([^'\]|\\.)*'"
# Simple comments and multiline comments
color green "--.*"

View File

@@ -6,10 +6,10 @@ comment ".\""
# Section headers, title line, and indented paragraphs.
color green "^\.(SH|SS|TH) .*"
color brightgreen "^\.(SH|SS|TH) " "^\.([HIT]P)"
color brightgreen "^\.((SH|SS|TH) |[HIT]P)"
# Type faces, and normal paragraphs.
color brightred "^\.(B[IR]?|I[BR]?|R[BI]|S[BM]) .*"
color brightblue "^\.(B[IR]?|I[BR]?|R[BI]|S[BM]) " "^\.([LP]?P)$"
color brightblue "^\.((B[IR]?|I[BR]?|R[BI]|S[BM]) |[LP]?P$)"
# Inline type faces.
color magenta "\\f[BIPR]"
# Relative margins, hyperlinks, and various other stuff.

View File

@@ -1,35 +1,39 @@
## Syntax highlighting for nanorc files.
syntax nanorc "\.?nanorc(\.in)?$"
syntax nanorc "[/.]nanorc(\.in)?$"
comment "#"
# Everything that does not get recolored is invalid
color brightred ".*"
# Color names
color yellow "^[[:blank:]]*(i?color|set[[:blank:]]+((error|function|key|mini|number|prompt|scroller|selected|spotlight|status|stripe|title)color))[[:blank:]]+(bold,)?(italic,)?(((bright|light)?(white|black|red|blue|green|yellow|magenta|cyan))|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte|grey|gray)?(,(((light)?(white|black|red|blue|green|yellow|magenta|cyan))|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte|grey|gray))?\>"
color yellow "^[[:blank:]]*(i?color|set[[:blank:]]+((error|function|key|mini|number|prompt|scroller|selected|spotlight|status|stripe|title)color))[[:blank:]]+(bold,)?(italic,)?(((bright|light)?(white|black|red|blue|green|yellow|magenta|cyan))|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte|rosy|beet|plum|sea|sky|slate|teal|sage|brown|ocher|sand|tawny|brick|crimson|grey|gray|#[[:xdigit:]]{3})?(,(((light)?(white|black|red|blue|green|yellow|magenta|cyan))|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte|rosy|beet|plum|sea|sky|slate|teal|sage|brown|ocher|sand|tawny|brick|crimson|grey|gray|#[[:xdigit:]]{3}))?\>"
# Keywords
color brightgreen "^[[:blank:]]*(set|unset)[[:blank:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|boldtext|bookstyle|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|historylog|indicator|jumpyscrolling|linenumbers|locking|magic|minibar|mouse|multibuffer|noconvert|nohelp|nonewlines|positionlog|preserve|quickblank|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|softwrap|stateflags|suspendable|tabstospaces|trimblanks|unix|wordbounds|zap)\>"
# The arguments of two special commands
color bold,purple "^[[:blank:]]*include[[:blank:]][^"]*([[:blank:]]|$)"
color lime "^[[:blank:]]*extendsyntax[[:blank:]]+[[:alpha:]]+[[:blank:]]+(i?color|header|magic|comment|formatter|linter|tabgives)[[:blank:]]+.*"
# The arguments of commands
color brightgreen "^[[:blank:]]*(set|unset)[[:blank:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|boldtext|bookstyle|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|historylog|indicator|jumpyscrolling|linenumbers|locking|magic|minibar|mouse|multibuffer|noconvert|nohelp|nonewlines|positionlog|preserve|quickblank|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|softwrap|stateflags|tabstospaces|trimblanks|unix|wordbounds|zap|zero)\>"
color brightgreen "^[[:blank:]]*set[[:blank:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|minicolor|numbercolor|operatingdir|promptcolor|punct|quotestr|scrollercolor|selectedcolor|speller|spotlightcolor|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:blank:]]+"
color brightgreen "^[[:blank:]]*set[[:blank:]]+(fill[[:blank:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:blank:]]+[1-9][0-9]*)\>"
color brightgreen "^[[:blank:]]*bind[[:blank:]]+((\^([A-Za-z]|[]/@\^_`-]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:blank:]]+([a-z]+|".*")[[:blank:]]+(main|help|search|replace(with)?|yesno|gotoline|writeout|insert|browser|whereisfile|gotodir|execute|spell|linter|all)([[:blank:]]+#|[[:blank:]]*$)"
color brightgreen "^[[:blank:]]*unbind[[:blank:]]+((\^([A-Za-z]|[]/@\^_`-]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:blank:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:blank:]]+#|[[:blank:]]*$)"
color brightgreen "^[[:blank:]]*extendsyntax[[:blank:]]+[[:alpha:]]+[[:blank:]]+(i?color|header|magic|comment|formatter|linter|tabgives)[[:blank:]]+.*"
color brightgreen "^[[:blank:]]*bind[[:blank:]]+((\^([A-Za-z]|[]/@\^_`-]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:blank:]]+([a-z]+|".*")[[:blank:]]+(main|help|search|replace(with)?|yesno|gotoline|writeout|insert|execute|browser|whereisfile|gotodir|spell|linter|all)\>"
color brightgreen "^[[:blank:]]*unbind[[:blank:]]+((\^([A-Za-z]|[]/@\^_`-]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:blank:]]+(main|help|search|replace(with)?|yesno|gotoline|writeout|insert|execute|browser|whereisfile|gotodir|spell|linter|all)\>"
color brightgreen "^[[:blank:]]*extendsyntax[[:blank:]]+[[:alpha:]]+[[:blank:]]+"
color brightgreen "^[[:blank:]]*(syntax[[:blank:]]+[^[:space:]]+|(formatter|linter)[[:blank:]]+.+)"
color green "^[[:blank:]]*((un)?(bind|set)|include|syntax|header|magic|comment|formatter|linter|tabgives|extendsyntax)\>"
# Strings
color brightmagenta "([[:blank:]]|(start|end)=)".+"([[:blank:]]|$)"
color brightmagenta "[[:blank:]](start=)?".+""
# Commands
color green "^[[:blank:]]*((un)?(bind|set)|include|syntax|header|magic|comment|formatter|linter|tabgives|extendsyntax)\>"
color magenta "^[[:blank:]]*i?color\>|[[:blank:]](start=|end=)"
# Control codes
color bold,pink "[[:cntrl:]]"
# Color commands
color magenta "^[[:blank:]]*i?color\>" "\<(start|end)="
# Comments
color brightblue "(^|[[:blank:]]+)#.*"
color brightblue "^[[:blank:]]*#.*|[[:blank:]]#.{0,2}[^[:xdigit:]].*"
color cyan "^[[:blank:]]*##.*"
# Trailing whitespace

View File

@@ -25,9 +25,11 @@ color cyan "(^|[[:blank:]])#.*"
# Trailing whitespace
color ,green "[[:space:]]+$"
# Strings and others
color yellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"
color green "[{}():;|`$<>!=&\\]" "(\]|\[)"
# Strings
color yellow ""([^"\]|\\.)*"|'([^'\]|\\.)*'"
# Syntactic symbols
color green "[][{}():;|`$<>!=&\]"
# Basic variable names
color brightred "(\$|@)[[:alpha:]_-][[:alnum:]_.-]*"

View File

@@ -4,7 +4,7 @@ syntax m "\.m$"
magic "Objective-C source"
comment "//"
# Stuffs,
# Stuffs.
color brightwhite "\<[A-Z_][0-9A-Z_]+\>"
color green "\<(float|double|BOOL|bool|char|int|short|long|id|sizeof|enum|void|static|const|struct|union|typedef|extern|(un)?signed|inline)\>"
color green "\<[[:alpha:]_][[:alnum:]_]*_t\>"
@@ -15,7 +15,7 @@ color brightgreen "\<(goto|continue|break|return)\>"
color brightgreen "@(encode|end|implementation|interface)|selector)\>"
# GCC builtins.
color cyan "__attribute__[[:blank:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
color cyan "__attribute__[[:blank:]]*\(\([^)]*\)\)|__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
# Selector/method.
color brightmagenta "(^|[[:blank:]])\[.*[[:blank:]].*\]"
@@ -24,9 +24,9 @@ color magenta "[[:alnum:]]*:"
color white "\[[^][:blank:]]*\]"
# Strings.
color brightblack "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
color brightblack "<[^= ]*>" ""(\\.|[^"])*""
color brightblue "@"(\\.|[^"])*""
color brightblack "'([^'\]|\\(["'\abfnrtv]|x[[:xdigit:]]{1,2}|[0-3]?[0-7]{1,2}))'"
color brightblack "<[^= ]*>|"([^"\]|\\.)*""
color brightblue "@"([^"\]|\\.)*""
# Preprocessor commands.
color brightblue "^[[:blank:]]*#[[:blank:]]*(define|include|import|(un|ifn?)def|endif|el(if|se)|if|warning|error)"

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