Compare commits

...

71 Commits

Author SHA1 Message Date
Benno Schulenberg
a7b1f0f03f po: update translations and regenerate POT file and PO files 2018-03-08 11:11:05 +01:00
Benno Schulenberg
c782b4cb72 bump version numbers and add a news item for the 2.9.4 release 2018-03-08 10:59:32 +01:00
Benno Schulenberg
5234475781 gnulib: update to its current upstream state 2018-03-06 12:07:30 +01:00
Benno Schulenberg
80605c3918 tweaks: exclude an unlikely warning from the tiny version 2018-03-06 12:05:52 +01:00
Benno Schulenberg
d3012be095 tweaks: don't call strcmp() to determine whether a string is empty 2018-03-06 11:59:03 +01:00
Brand Huntsman
03bc19fd0c color: remove unneeded bright comparision to prevent duplicate pairs
Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-03-05 20:03:03 +01:00
Benno Schulenberg
e4cef3086b tweaks: drop an assert, add a warning, and change a 'for' to a 'while' 2018-03-05 12:46:25 +01:00
Benno Schulenberg
9936a6357a tweaks: rename a parameter and a variable, to be more fitting 2018-03-05 12:46:25 +01:00
Benno Schulenberg
899bf0ae3a tweaks: exclude an unlikely error message from the tiny version 2018-03-05 12:45:19 +01:00
Benno Schulenberg
1f7384ebd2 tweaks: appease valgrind concerning syscalls with uninitialized values 2018-03-05 11:02:52 +01:00
Benno Schulenberg
95fffa99aa tweaks: adjust two comments, move two declarations, rewrap three lines 2018-03-05 10:43:05 +01:00
Benno Schulenberg
22f7861694 tweaks: reshuffle the undo types into mostly the same order everywhere
First the two that add something (ADD, ENTER), then the three that
delete something (BACK, DEL, JOIN), and then the one that changes
something (REPLACE).  Then the SPLITs, CUT, PASTE, and INSERT, and
then the INDENTs and COMMENTs, when they exist.
2018-03-05 10:05:07 +01:00
Benno Schulenberg
ba96d507dd tweaks: drop some debugging stuff, and adjust what remains of it 2018-03-05 09:42:57 +01:00
Benno Schulenberg
9bf57e5ca0 tweaks: do not needlessly renumber the lines in the buffer
For cuts, pastes, and inserts, the lines have already been renumbered;
for indents, comments, and replacements, the line numbers cannot have
changed.  (And anyway, variable 'f' is not set for those cases.)

Only when lines get split (ENTER) or fused together (JOIN) do the later
lines need to be renumbered.  This mirrors what is done for do_redo().
2018-03-04 10:27:07 +01:00
Benno Schulenberg
f9103a5cb5 tweaks: make the fsfromline() call only for the undo types that need it
The 'f' variable is used only in the ADD, BACK, DEL, ENTER, JOIN, and
REPLACE undo/redo cases.  So, avoid making a somewhat costly call when
it is entirely superfluous.  Rearrange the undo types to make checking
for the above six types easier.
2018-03-03 17:12:25 +01:00
Benno Schulenberg
e9eabdcdcb undo: when redoing, don't try to find a line number that might not exist
This fixes https://savannah.gnu.org/bugs/?53272.
2018-03-03 16:41:33 +01:00
Benno Schulenberg
a1be8b6a19 tweaks: condense a comment and elide an 'if' 2018-03-01 11:18:56 +01:00
Benno Schulenberg
de4fbadf20 tweaks: reshuffle some code, to be slightly less ugly 2018-03-01 11:08:13 +01:00
Benno Schulenberg
bdd8920081 bindings: make a key defined as string work also in browser and viewer 2018-03-01 10:55:04 +01:00
Benno Schulenberg
ae9ec6d4ad syntax: nanorc: color also bindings to a string as valid 2018-03-01 10:09:28 +01:00
Benno Schulenberg
8f1a657a37 bindings: revert the ^/ changes, as ^/ is not always Go-To-Line
On a Linux console, ^/ produces Backspace, making it unrebindable.

This fixes https://savannah.gnu.org/bugs/?53248.
2018-03-01 09:50:54 +01:00
Benno Schulenberg
7f88eff96f docs: mention that a key can be bound to a string 2018-02-28 17:28:16 +01:00
Benno Schulenberg
3b8c898880 help: tweak the descriptions of ^X and ^R
It is not a problem to say that ^X closes the current buffer
even when nano is compiled without multibuffer support.
2018-02-27 18:11:16 +01:00
Benno Schulenberg
6f4f1878fc selecting: cancel the softmark upon any attempt to move the cursor
This assumes that all movement functions are located together,
starting with to_first_line() and ending with do_right().

This fixes https://savannah.gnu.org/bugs/?53195.
Reported-by: Brand Huntsman <alpha@qzx.com>
2018-02-27 18:09:00 +01:00
Benno Schulenberg
082e5db4b7 syntax: color also ^/ in nano's help texts and in nanorc files
As of commit c79fe1a1, the more readable ^/ has replaced ^_ as the
advertised shortcut for Go-To-Line -- color it too as valid.
2018-02-27 18:06:33 +01:00
Benno Schulenberg
5eccaa7633 tweaks: refactor the implanting of a key expansion 2018-02-27 13:34:32 +01:00
Benno Schulenberg
d9ac785a07 input: handle the implant() function separately also for the prompt
To prevent getting kicked out of it.

This fixes https://savannah.gnu.org/bugs/?53234.
2018-02-27 13:20:27 +01:00
Benno Schulenberg
01457ae3d3 input: handle the implant() function separately, as it is special
The implant() function itself cannot be bound to anything, so it
is not in the linked list of functions -- trying to find it would
lead to a NULL pointer, and thus to a segfault.

This fixes https://savannah.gnu.org/bugs/?53233.
2018-02-27 11:11:02 +01:00
Benno Schulenberg
c757aee235 tweaks: correct a typo that broke binding a key to a string
Commit 0cf455bc introduced the typo.
2018-02-27 10:28:52 +01:00
Benno Schulenberg
48749a9500 docs: note also in the Info manual that text can be selected with Shift
And remove a detail that is untrue when 'set selectedcolor' is used.
2018-02-27 09:50:45 +01:00
Benno Schulenberg
4cd3987791 tweaks: correct a typo in NEWS 2018-02-27 09:45:38 +01:00
David Lawrence Ramsey
aa41eb69c0 docs: mention that errorcolor does have default colors
This fixes https://savannah.gnu.org/bugs/?53225.
2018-02-27 09:41:17 +01:00
Benno Schulenberg
54103d8ed1 tweaks: elide another variable, to call a function less often
Instead of always calling sctofunc(), it is now only called when
in view mode OR when (after the keystroke's function has been run)
no need for a refresh has been established yet.
2018-02-25 10:41:51 +01:00
Benno Schulenberg
53a10ddcaf tweaks: elide an unneeded variable
A shortcut's function must be among the existing ones, otherwise
nano's code is fundamentally broken.
2018-02-24 20:47:17 +01:00
Benno Schulenberg
65bf04060b tweaks: remove another superfluous check
Commit bb667beb removed do_gotolinecolumn_void() from the MWHEREIS
menu (replacing it with the empty flip_goto() function), so there
is no longer any need to check for this one special case.
2018-02-24 20:47:01 +01:00
Benno Schulenberg
a95fb64dd6 tweaks: remove a superfluous check
A shortcut's function can never be NULL.
2018-02-24 19:53:19 +01:00
Benno Schulenberg
b235404ade tweaks: elide an unused variable and parameter
It is only ever set and never referenced.
2018-02-24 19:42:43 +01:00
Benno Schulenberg
ffebd31cbb tweaks: shorten the name of two record elements
Exclude the confusing, pleonastic 'sc' abbreviation from their names.
2018-02-24 19:31:11 +01:00
Benno Schulenberg
e55227f65f tweaks: unabbreviate two variable names 2018-02-24 18:20:30 +01:00
Benno Schulenberg
b77b54bf73 tweaks: elide two unneeded booleans 2018-02-24 17:51:27 +01:00
Benno Schulenberg
2428620b16 prompt: disallow pasting when in restricted mode 2018-02-24 13:54:49 +01:00
Benno Schulenberg
cb0289f0dc tweaks: fix a copy-and-paste error 2018-02-24 13:31:59 +01:00
Benno Schulenberg
b027263a37 small addition: allow customizing the color of an error message
The new option 'set errorcolor' allows the user to specify the color
combination for the status bar when an error message is displayed.
2018-02-23 12:35:17 +01:00
Benno Schulenberg
1a926d79c5 help: mention that some keys work on a region when the mark is on
This fixes https://savannah.gnu.org/bugs/?53188.
Reported-by: Ken Tyler <kent@werple.net.au>
2018-02-23 12:35:12 +01:00
Benno Schulenberg
c79fe1a160 bindings: show ^/ instead of ^_ for Go-To-Line
The slash is easier to read than the underscore (which almost
disappears at the bottom of the screen), and easier to type
(no Shift needed on a US keyboard), and it kind of harmonizes
with the ^\ for Replace and the M-/ for End-of-buffer.
2018-02-23 12:26:30 +01:00
Tom Levy
fef195bce9 syntax: go: highlight also floats with leading zeroes as valid
See the discussion on the mailing list:
https://lists.gnu.org/archive/html/nano-devel/2018-01/msg00022.html
https://lists.gnu.org/archive/html/nano-devel/2018-02/msg00090.html

Signed-off-by: Tom Levy <tomlevy93@gmail.com>
2018-02-20 10:31:38 +01:00
Benno Schulenberg
dd9766c2e0 editing: when --smooth is used, make <Enter>-at-bottom scroll one row
When using --smooth or 'set smooth', the screen should scroll the
minimum amount needed to get the cursor back into view.  (The only
exceptions are search, undo, and redo -- when there the cursor goes
offscreen, the cursor line is centered.)

This change brings the behavior of pressing <Enter> on the bottom
row into line with, for example, pasting a single line.  See also
http://lists.gnu.org/archive/html/nano-devel/2018-02/msg00027.html.
2018-02-16 11:48:24 +01:00
Benno Schulenberg
5b870a7632 goto: avoid a segfault, by initializing 'answer' when it is NULL
This fixes https://savannah.gnu.org/bugs/?53157.
2018-02-14 19:40:30 +01:00
Benno Schulenberg
0cf455bc48 build: fix compilation when configured with --enable-tiny
And when configured with --enable-tiny --enable-nanorc.
2018-02-14 19:29:29 +01:00
Benno Schulenberg
3e1fc6385b syntaxes: remove quotes from each syntax name, and color it differently
The different color will make the name stand out, as it should, instead
of looking the same as all the regex strings.
2018-02-14 17:36:50 +01:00
Benno Schulenberg
544cda6a62 rcfile: allow a syntax name to be unquoted 2018-02-14 17:35:37 +01:00
Benno Schulenberg
28933cf572 tweaks: remove two superfluous checks, and restrict two others
When 'refresh_needed' is already TRUE, there is no need any more
to check whether it should be set.

[Those first two calls are leftovers from before the time that
reset_multis() morphed into check_the_multis().]
2018-02-14 17:29:59 +01:00
Benno Schulenberg
1635060ba6 tweaks: plug a memory leak when using Verbatim Input at a prompt
This fixes https://savannah.gnu.org/bugs/?53089.
2018-02-08 17:54:31 +01:00
David Lawrence Ramsey
7a038adfd4 input: don't stop prepending when the user adds text via a shortcut
When characters are added via Verbatim Input or by pressing <Tab>,
the prepend flag should be retained, just like when characters are
typed directly.

This fixes https://savannah.gnu.org/bugs/?52956.
2018-02-08 17:35:56 +01:00
Benno Schulenberg
f1b5be4bbf tweaks: elide an unneeded variable 2018-02-07 19:42:19 +01:00
Benno Schulenberg
9ceeabda38 memory: avoid a leak when toggling from Search to Goto
This fixes https://savannah.gnu.org/bugs/?53088.
2018-02-07 19:34:52 +01:00
Benno Schulenberg
204e1b8353 memory: squeal when there is something wrong, instead of stumbling on
When copying a string, source and destination may not be equal --
complain loudly when they are, instead of failing to free memory.

Also, instead of freeing the destination string and then allocating
it afresh, just reallocate it -- that should be slightly quicker.
2018-02-07 19:34:43 +01:00
Benno Schulenberg
d865d7ac8f search: clear the existing answer when starting a new search
When doing for example: ^W xx ^R ^C ^W, the "xx" would again be shown
after the prompt.  This is wrong -- when starting a new search, the
current answer should be empty.

Reported-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2018-02-05 12:47:55 +01:00
Benno Schulenberg
16d237ba1b tweaks: rename two variables, to be more meaningful 2018-02-04 22:07:33 +01:00
Benno Schulenberg
c3031b9b8f tweaks: reshuffle some of the search-and-replace cleanup calls 2018-02-04 21:31:04 +01:00
Benno Schulenberg
d289510724 tweaks: adjust comments and indentation after the previous change 2018-02-04 21:23:48 +01:00
Benno Schulenberg
60f1090da0 search: get rid of some unneeded recursion when just toggling things
Instead of weaving back and forth between do_search()/do_replace() and
search_init() every time that one of the options is toggled, just keep
looping in the latter function until the user presses <Enter>.

The weaving for the do_gotolinecolumn() function remains, but is
shortened to involve only search_init().
2018-02-04 20:26:06 +01:00
David Lawrence Ramsey
8f6ee22b41 tweaks: fix typo in rebindable function name
This fixes https://savannah.gnu.org/bugs/?53062.
2018-02-04 18:31:24 +01:00
Benno Schulenberg
a083d7f1e1 tweaks: rename a variable to be more distinct and greppable 2018-02-04 18:25:10 +01:00
Benno Schulenberg
919df09ffa general: detect in a better way whether we're running on a Linux console
Suggested-by: Mike Frysinger <vapier@gentoo.org>
2018-02-04 18:23:13 +01:00
Benno Schulenberg
ddbff6dcb2 tweaks: slightly rewrap the FAQ's table of contents 2018-02-04 18:20:13 +01:00
Benno Schulenberg
4295baa5fe tweaks: transform a 'do' to a 'while', and reshuffle a comment 2018-02-04 18:14:28 +01:00
Benno Schulenberg
467cc8edf3 tweaks: remove two deprecated options and six rebindable function names
This addresses https://savannah.gnu.org/bugs/?48992.
2018-02-04 13:51:13 +01:00
Benno Schulenberg
6d111c9343 new feature: allow binding a key to a string (in a nanorc file)
In this way a single keystroke can produce a fragment of text or a
series of commands, or a mix of the two.  It is like a prerecorded
macro.

This fulfills https://savannah.gnu.org/bugs/?52931.
2018-02-04 12:44:12 +01:00
Benno Schulenberg
bb667beb5a bindings: rename the bindable function 'gototext' to 'flipgoto'
This brings it in line with the other three "flip" toggles.
2018-02-04 10:34:39 +01:00
Benno Schulenberg
eed765f4f7 tweaks: elide an unneeded variable 2018-02-04 10:15:26 +01:00
105 changed files with 17437 additions and 17164 deletions

View File

@@ -1,3 +1,85 @@
Changes between v2.9.3 and v2.9.4:
----------------------------------
Benno Schulenberg (65):
bindings: make a key defined as string work also in browser and viewer
bindings: rename the bindable function 'gototext' to 'flipgoto'
bindings: revert the ^/ changes, as ^/ is not always Go-To-Line
bindings: show ^/ instead of ^_ for Go-To-Line
build: fix compilation when configured with --enable-tiny
bump version numbers and add a news item for the 2.9.4 release
docs: mention that a key can be bound to a string
docs: note also in the Info manual that text can be selected with Shift
editing: when --smooth is used, make <Enter>-at-bottom scroll one row
general: detect in a better way whether we're running on a Linux console
gnulib: update to its current upstream state
goto: avoid a segfault, by initializing 'answer' when it is NULL
help: mention that some keys work on a region when the mark is on
help: tweak the descriptions of ^X and ^R
input: handle the implant() function separately also for the prompt
input: handle the implant() function separately, as it is special
memory: avoid a leak when toggling from Search to Goto
memory: squeal when there is something wrong, instead of stumbling on
new feature: allow binding a key to a string (in a nanorc file)
prompt: disallow pasting when in restricted mode
rcfile: allow a syntax name to be unquoted
search: clear the existing answer when starting a new search
search: get rid of some unneeded recursion when just toggling things
selecting: cancel the softmark upon any attempt to move the cursor
small addition: allow customizing the color of an error message
syntax: color also ^/ in nano's help texts and in nanorc files
syntaxes: remove quotes from each syntax name, and color it differently
syntax: nanorc: color also bindings to a string as valid
tweaks: adjust comments and indentation after the previous change
tweaks: adjust two comments, move two declarations, rewrap three lines
tweaks: appease valgrind concerning syscalls with uninitialized values
tweaks: condense a comment and elide an 'if'
tweaks: correct a typo in NEWS
tweaks: correct a typo that broke binding a key to a string
tweaks: do not needlessly renumber the lines in the buffer
tweaks: don't call strcmp() to determine whether a string is empty
tweaks: drop an assert, add a warning, and change a 'for' to a 'while'
tweaks: drop some debugging stuff, and adjust what remains of it
tweaks: elide another variable, to call a function less often
tweaks: elide an unneeded variable
tweaks: elide an unneeded variable
tweaks: elide an unneeded variable
tweaks: elide an unused variable and parameter
tweaks: elide two unneeded booleans
tweaks: exclude an unlikely error message from the tiny version
tweaks: exclude an unlikely warning from the tiny version
tweaks: fix a copy-and-paste error
tweaks: make the fsfromline() call only for the undo types that need it
tweaks: plug a memory leak when using Verbatim Input at a prompt
tweaks: refactor the implanting of a key expansion
tweaks: remove another superfluous check
tweaks: remove a superfluous check
tweaks: remove two deprecated options and six rebindable function names
tweaks: remove two superfluous checks, and restrict two others
tweaks: rename a parameter and a variable, to be more fitting
tweaks: rename a variable to be more distinct and greppable
tweaks: rename two variables, to be more meaningful
tweaks: reshuffle some code, to be slightly less ugly
tweaks: reshuffle some of the search-and-replace cleanup calls
tweaks: reshuffle the undo types into mostly the same order everywhere
tweaks: shorten the name of two record elements
tweaks: slightly rewrap the FAQ's table of contents
tweaks: transform a 'do' to a 'while', and reshuffle a comment
tweaks: unabbreviate two variable names
undo: when redoing, don't try to find a line number that might not exist
Brand Huntsman (1):
color: remove unneeded bright comparision to prevent duplicate pairs
David Lawrence Ramsey (3):
docs: mention that errorcolor does have default colors
input: don't stop prepending when the user adds text via a shortcut
tweaks: fix typo in rebindable function name
Tom Levy (1):
syntax: go: highlight also floats with leading zeroes as valid
Changes between v2.9.2 and v2.9.3:
----------------------------------

View File

@@ -2,6 +2,8 @@ Improvements in GNU nano
========================
Since 2.9.0:
- A key can be bound to a string -- any mix of text and commands.
- Error messages are shown by default in bright white on red.
- <Tab> and <Shift+Tab> can be used to indent/unindent a marked region.
- Can snip trailing whitespace while typing, with 'set trimblanks'.
- The ability to record and replay a series of keystrokes (a macro).

15
NEWS
View File

@@ -1,3 +1,16 @@
2018.03.08 - GNU nano 2.9.4 "Isabel" allows binding a key to a string
(any piece of text and/or commands), permits customizing
the color of error messages with 'set errorcolor', colors
those error messages by default in bright white on red,
makes <Enter> at the bottom of the screen scroll just one
row when --smooth is used, does not fail when redoing a
file insertion, and cancels a Shift-selection when any
cursor key is pressed without Shift even when the cursor
cannot move. Further, it treats tabs fully the same as
spaces when doing automatic hard-wrapping, allows syntax
names to be unquoted, and removes two deprecated options
and six deprecated bindable function names.
2018.01.29 - GNU nano 2.9.3 "Córdoba" fixes a segfault with trimblanks
that could occur when a typed space caused the word after
it to be pushed to the next line. It further makes macros
@@ -5,7 +18,7 @@
adds the options -M and --trimblanks for the command line,
recognizes key combos with Shift on a few more terminals,
no longer shows dots in certain prompt texts when visible
witespace is turned on, fixes two corner cases when doing
whitespace is turned on, fixes two corner cases when doing
replacements in a marked region, allows to open a named
pipe again when using --noread, and accurately detects
a needed color change when a line contains a start match

View File

@@ -2,7 +2,7 @@
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="4a236f16ce0ef97094ff2f6538d4dba90e72a523"
gnulib_hash="59e59d99bc1ca635d178778b9b4ee544330775c4"
modules="
futimens

View File

@@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
AC_INIT([GNU nano], [2.9.3], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [2.9.4], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.14])

View File

@@ -14,13 +14,15 @@
<a href="#1.2">1.2. What is the history behind nano?</a><br>
<a href="#1.3">1.3. Why the name change from TIP?</a><br>
<a href="#1.4">1.4. What is the current version of nano?</a><br>
<a href="#1.5">1.5. I want to read the manpage without having to download the program!</a></p></blockquote>
<a href="#1.5">1.5. I want to read the manpage without having to download the program!</a>
</p></blockquote>
<h2><a href="#2">2. Where to get GNU nano.</a></h2>
<blockquote><p>
<a href="#2.1">2.1. FTP and WWW sites that carry nano.</a><br>
<a href="#2.2">2.2. RedHat and derivatives (.rpm) packages.</a><br>
<a href="#2.3">2.3. Debian (.deb) packages.</a><br>
<a href="#2.4">2.4. By GIT (for the brave).</a></p></blockquote>
<a href="#2.4">2.4. By GIT (for the brave).</a>
</p></blockquote>
<h2><a href="#3">3. Installation and Configuration</a></h2>
<blockquote><p>
<a href="#3.1">3.1. How do I install the RPM or DEB package?</a><br>
@@ -31,7 +33,8 @@
<a href="#3.7">3.7. Tell me more about this multibuffer stuff!</a><br>
<a href="#3.8">3.8. Tell me more about this verbatim input stuff!</a><br>
<a href="#3.9a">3.9a. How do I make a .nanorc file that nano will read when I start it?</a><br>
<a href="#3.9b">3.9b. How about in Win32?</a></p></blockquote>
<a href="#3.9b">3.9b. How about in Win32?</a>
</p></blockquote>
<h2><a href="#4">4. Running</a></h2>
<blockquote><p>
<a href="#4.1">4.1. How do I open a file with a name beginning with '+' from the command line?</a><br>
@@ -46,25 +49,29 @@
<a href="#4.9">4.9. I've compiled nano with color support, but I don't see any color when I run it!</a><br>
<a href="#4.10">4.10. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
<a href="#4.11">4.11. How do I select text for or paste text from the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?</a><br>
<a href="#4.12">4.12. On startup I get a message that says "Detected a legacy nano history file". Now older nano versions can't find my search history!</a></p></blockquote>
<a href="#4.12">4.12. On startup I get a message that says "Detected a legacy nano history file". Now older nano versions can't find my search history!</a>
</p></blockquote>
<h2><a href="#5">5. Internationalization</a></h2>
<blockquote><p>
<a href="#5.1">5.1. There's no translation for my language!</a><br>
<a href="#5.2">5.2. I don't like the translation for &lt;x&gt; in my language. How can I fix it?</a><br>
<a href="#5.3">5.3. What is the status of Unicode support?</a></p></blockquote>
<a href="#5.3">5.3. What is the status of Unicode support?</a>
</p></blockquote>
<h2><a href="#6">6. Advocacy and Licensing</a></h2>
<blockquote><p>
<a href="#6.1">6.1. Why should I use nano instead of Pico?</a><br>
<a href="#6.2">6.2. Why should I use Pico instead of nano?</a><br>
<a href="#6.3">6.3. What is so bad about the older Pine license?</a><br>
<a href="#6.4">6.4. Okay, well, what mail program should I use then?</a></p></blockquote>
<a href="#6.4">6.4. Okay, well, what mail program should I use then?</a>
</p></blockquote>
<h2><a href="#7">7. Miscellaneous</a></h2>
<blockquote><p>
<a href="#7.1">7.1. Where can I ask questions or send suggestions?</a><br>
<a href="#7.2">7.2. How do I submit a bug report or patch?</a><br>
<a href="#7.3">7.3. I want to send the development team a big load of cash (or just a thank you).</a><br>
<a href="#7.4">7.4. How do I join the development team?</a><br>
<a href="#7.5">7.5. Can I have write access to the GIT tree?</a></p></blockquote>
<a href="#7.5">7.5. Can I have write access to the GIT tree?</a>
</p></blockquote>
<hr width="100%">
<h1><a name="1"></a>1. General</h1>
@@ -83,7 +90,7 @@
<h2><a name="1.3"></a>1.3. Why the name change from TIP?</h2>
<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>
<h2><a name="1.4"></a>1.4. What is the current version of nano?</h2>
<blockquote><p>The current version of nano <i>should</i> be <b>2.9.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>
<blockquote><p>The current version of nano <i>should</i> be <b>2.9.4</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<h2><a name="1.5"></a>1.5. I want to read the man page without having to download the program!</h2>
<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

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 2.9.3" "January 2018"
.TH NANO 1 "version 2.9.4" "March 2018"
.SH NAME
nano \- Nano's ANOther editor, an enhanced free Pico clone
@@ -54,9 +54,9 @@ highlighted), and then use \fB^K\fR to cut it, or \fBM\-6\fR to copy it to the
cutbuffer. One can also save the marked text to a file with \fB^O\fR, or
spell check it with \fB^T\fR.
.PP
Since nano-2.7.0, text can also be selected by holding Shift and moving the
cursor with the arrow keys. Holding down the Alt key too will increase the
stride.
On some terminals, text can be selected also by holding down Shift while
using the arrow keys. Holding down the Alt key too will increase the stride.
Any cursor movement without Shift being held will cancel such a selection.
.PP
The two lines at the bottom of the screen show some important commands;
the built-in help (\fB^G\fR) lists all the available ones.
@@ -121,7 +121,6 @@ Use the blank line below the title bar as extra editing space.
.BR \-P ", " \-\-positionlog
For the 200 most recent files, log the last position of the cursor,
and place it at that position again upon reopening such a file.
(The old form of this option, \fB\-\-poslog\fR, is deprecated.)
.TP
.BR "\-Q ""\fIcharacters\fB""" ", " "\-\-quotestr=""" \fIcharacters """
Set the quoting string for justifying. The default is

View File

@@ -8,8 +8,8 @@
@smallbook
@set EDITION 0.5
@set VERSION 2.9.3
@set UPDATED January 2018
@set VERSION 2.9.4
@set UPDATED March 2018
@dircategory Editors
@direntry
@@ -23,7 +23,7 @@
@titlepage
@title GNU @command{nano}
@subtitle a small and friendly text editor
@subtitle version 2.9.3
@subtitle version 2.9.4
@author Chris Allegretta
@page
@@ -63,7 +63,7 @@ e-mail: @email{chrisa@@asty.org}@*
@node Top
@top
This manual documents the GNU @command{nano} editor, version 2.9.3.
This manual documents the GNU @command{nano} editor, version 2.9.4.
@menu
* Introduction::
@@ -217,7 +217,6 @@ Use the blank line below the title bar as extra editing space.
@itemx --positionlog
For the 200 most recent files, log the last position of the cursor,
and place it at that position again upon reopening such a file.
(The old form of this option, @option{--poslog}, is deprecated.)
@item -Q "@var{characters}"
@itemx --quotestr="@var{characters}"
@@ -498,12 +497,15 @@ the 'Copy Text' command (default key binding: @kbd{M-6}).
Text can be selected by first 'setting the Mark' (default key bindings:
@kbd{^6} and @kbd{M-A}) and then moving the cursor to the other end of the portion
to be selected. The selected portion of text will be highlighted in
reverse video (or in bold if you set the boldtext option).
to be selected. The selected portion of text will be highlighted.
This selection can now be cut or copied in its entirety with a single
@kbd{^K} or @kbd{M-6}. Or the selection can be used to limit the scope of
a search-and-replace (@kbd{^\}) or spell-checking session (@kbd{^T}).
On some terminals, it is also possible to select text by holding down
@kbd{Shift} together with the cursor keys. Such a selection is cancelled
upon any cursor movement where @kbd{Shift} isn't held.
Cutting or copying selected text will toggle the mark off automatically.
If necessary, it can be toggled off manually with another @kbd{^6} or @kbd{M-A}.
@@ -731,13 +733,16 @@ Do case-sensitive searches by default.
@item set constantshow
Constantly display the cursor position on the status bar.
(The old form of this option, @code{set const}, is deprecated.)
Note that this overrides @option{quickblank}.
@item set cutfromcursor
Use cut-from-cursor-to-end-of-line by default, instead of cutting the whole line.
(The old form of this option, @code{set cut}, is deprecated.)
@item set errorcolor @var{fgcolor},@var{bgcolor}
Use this color combination for the status bar when an error message is displayed.
@xref{@code{set functioncolor}} for valid color names.
@item set fill @var{number}
Hard-wrap lines at column number @var{number}. If @var{number} is 0 or less,
the maximum line length will be the screen width less @var{number} columns.
@@ -815,7 +820,6 @@ directory feature is turned off.
@item set positionlog
Save the cursor position of files between editing sessions.
The cursor position is remembered for the 200 most-recently edited files.
(The old form of this option, @code{set poslog}, is deprecated.)
@item set preserve
Preserve the XON and XOFF keys (@kbd{^Q} and @kbd{^S}).
@@ -1037,7 +1041,7 @@ in one of the system-installed files (which normally are not writable).
@node Rebinding Keys
@section Rebinding Keys
Key bindings can be changed via the following two commands in a
Key bindings can be changed via the following three commands in a
nanorc file:
@table @code
@@ -1046,6 +1050,13 @@ nanorc file:
Rebinds @code{key} to @code{function} in the context of @code{menu}
(or in all menus where the function exists by using @code{all}).
@item bind key "string" menu
Makes @code{key} produce @code{string} in the context of @code{menu}
(or in all menus where the key exists when @code{all} is used).
The @code{string} can consist of text or commands or a mix of them.
(To enter a command into the @code{string}, precede its keystroke
with @kbd{M-V}.)
@item unbind key menu
Unbinds @code{key} from @code{menu}
(or from all menus where it exists by using @code{all}).
@@ -1102,7 +1113,6 @@ Starts a backward search for text in the current buffer.
@item searchagain
Repeats the last search command without prompting.
(The form @code{research} is deprecated.)
@item findprevious
As @code{searchagain}, but always in the backward direction.
@@ -1137,7 +1147,6 @@ Cuts all text from the cursor position till the end of the buffer.
@item curpos
Shows the current cursor position: the line, column, and character positions.
(The form @code{cursorpos} is deprecated.)
@item wordcount
Counts the number of words, lines and characters in the current buffer.
@@ -1225,9 +1234,6 @@ Goes to the last line of the file.
Goes to a specific line (and column if specified). Negative numbers count
from the end of the file (and end of the line).
@item gototext
Switches from targeting a line number to searching for text.
@item findbracket
Moves the cursor to the bracket (brace, parenthesis, etc.) that matches
(pairs) with the one under the cursor.
@@ -1278,7 +1284,6 @@ Toggles case sensitivity in searching (search/replace menus only).
@item regexp
Toggles whether searching/replacing is based on literal strings or regular expressions.
(The form @code{regex} is deprecated.)
@item backwards
Toggles whether searching/replacing goes forward or backward.
@@ -1291,7 +1296,10 @@ Shows the next history entry in the prompt menus (e.g.@: search).
@item flipreplace
Toggles between searching for something and replacing something.
(The form @code{dontreplace} is deprecated.)
@item flipgoto
Toggles between searching for text and targeting a line number.
(The form @code{gototext} is deprecated.)
@item flipexecute
Toggles between inserting a file and executing a command.
@@ -1299,7 +1307,6 @@ Toggles between inserting a file and executing a command.
@item flipnewbuffer
Toggles between inserting into the current buffer and into a new
empty buffer.
(The form @code{newbuffer} is deprecated.)
@item dosformat
When writing a file, switches to writing a DOS format (CR/LF).
@@ -1405,7 +1412,6 @@ The 'search to replace' menu.
@item replacewith
The 'replace with' menu, which comes up after 'search to replace'.
(The form @code{replace2} is deprecated.)
@item gotoline
The 'goto line (and column)' menu.

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 2.9.3" "January 2018"
.TH NANORC 5 "version 2.9.4" "March 2018"
.SH NAME
nanorc \- GNU nano's configuration file
@@ -96,13 +96,16 @@ Do case-sensitive searches by default.
.TP
.B set constantshow
Constantly display the cursor position in the status bar.
(The old form of this option, '\fBset const\fR', is deprecated.)
This overrides the option \fBquickblank\fR.
.TP
.B set cutfromcursor
Use cut-from-cursor-to-end-of-line by default, instead of cutting the whole line.
(The old form of this option, '\fBset cut\fR', is deprecated.)
.TP
.B set errorcolor \fIfgcolor\fR,\fIbgcolor\fR
Use this color combination for the status bar when an error message is displayed.
See \fBset titlecolor\fR for valid color names.
.TP
.B set fill \fInumber\fR
Hard-wrap lines at column number \fInumber\fR. If \fInumber\fR is 0 or less,
the maximum line length will be the screen width less \fInumber\fP columns.
@@ -178,7 +181,6 @@ directory feature is turned off.
.B set positionlog
Save the cursor position of files between editing sessions.
The cursor position is remembered for the 200 most-recently edited files.
(The old form of this option, '\fBset poslog\fR', is deprecated.)
.TP
.B set preserve
Preserve the XON and XOFF keys (^Q and ^S).
@@ -393,16 +395,26 @@ slightly improve a syntax defined in one of the system-installed
files (which normally are not writable).
.SH REBINDING KEYS
Key bindings can be changed via the following two commands:
Key bindings can be changed via the following three commands:
.RS 3
.TP
.BI bind " key function menu"
Rebinds the key \fIkey\fP to a new function named \fIfunction\fP in the
context of menu \fImenu\fP (or in all menus where the function exists
by using \fBall\fP).
.TP
.BI bind " key " """" string """" " menu"
Makes the given \fIkey\fR produce the given \fIstring\fR in the given
\fImenu\fR (or in all menus where the key exists when \fBall\fR is used).
The \fIstring\fR can consist of text or commands or a mix of them.
(To enter a command into the \fIstring\fR, precede its keystroke
with \fBM-V\fR.)
.TP
.BI unbind " key menu"
Unbinds the key \fIkey\fP from the menu named \fImenu\fP (or from all
menus where it exists by using \fBall\fP).
.RE
.TP
The format of \fIkey\fP should be one of:
@@ -453,7 +465,6 @@ Starts a backward search for text in the current buffer.
.TP
.B searchagain
Repeats the last search command without prompting.
(The form 'research' is deprecated.)
.TP
.B findprevious
As \fBsearchagain\fR, but always in the backward direction.
@@ -488,7 +499,6 @@ Cuts all text from the cursor position till the end of the buffer.
.TP
.B curpos
Shows the current cursor position: the line, column, and character positions.
(The form 'cursorpos' is deprecated.)
.TP
.B wordcount
Counts the number of words, lines and characters in the current buffer.
@@ -579,9 +589,6 @@ Goes to the last line of the file.
Goes to a specific line (and column if specified). Negative numbers count
from the end of the file (and end of the line).
.TP
.B gototext
Switches from targeting a line number to searching for text.
.TP
.B findbracket
Moves the cursor to the bracket (brace, parenthesis, etc.) that matches
(pairs) with the one under the cursor.
@@ -632,7 +639,6 @@ Toggles case sensitivity in searching (search/replace menus only).
.TP
.B regexp
Toggles whether searching/replacing is based on literal strings or regular expressions.
(The form 'regex' is deprecated.)
.TP
.B backwards
Toggles whether searching/replacing goes forward or backward.
@@ -645,7 +651,10 @@ Shows the next history entry in the prompt menus (e.g. search).
.TP
.B flipreplace
Toggles between searching for something and replacing something.
(The form 'dontreplace' is deprecated.)
.TP
.B flipgoto
Toggles between searching for text and targeting a line number.
(The form 'gototext' is deprecated.)
.TP
.B flipexecute
Toggles between inserting a file and executing a command.
@@ -653,7 +662,6 @@ Toggles between inserting a file and executing a command.
.B flipnewbuffer
Toggles between inserting into the current buffer and into a new
empty buffer.
(The form 'newbuffer' is deprecated.)
.TP
.B dosformat
When writing a file, switches to writing a DOS format (CR/LF).
@@ -757,7 +765,6 @@ The 'search to replace' menu.
.TP
.B replacewith
The 'replace with' menu, which comes up after 'search to replace'.
(The form 'replace2' is deprecated.)
.TP
.B gotoline
The 'goto line (and column)' menu.

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH RNANO 1 "version 2.9.3" "January 2018"
.TH RNANO 1 "version 2.9.4" "March 2018"
.SH NAME
rnano \- a restricted nano

View File

@@ -196,17 +196,19 @@
# set wordchars "<_>."
## Paint the interface elements of nano.
## These are examples; by default there are no colors.
## Paint the interface elements of nano. These are examples;
## by default there are no colors, except for errorcolor.
# set titlecolor brightwhite,blue
# set statuscolor brightwhite,green
# set errorcolor brightwhite,red
# set selectedcolor brightwhite,magenta
# set numbercolor cyan
# set keycolor cyan
# set functioncolor green
## In root's .nanorc you might want to use:
# set titlecolor brightwhite,red
# set statuscolor brightwhite,red
# set titlecolor brightwhite,magenta
# set statuscolor brightwhite,magenta
# set errorcolor brightwhite,red
# set selectedcolor brightwhite,cyan
# set numbercolor magenta
# set keycolor brightmagenta

933
po/bg.po

File diff suppressed because it is too large Load Diff

954
po/ca.po

File diff suppressed because it is too large Load Diff

934
po/cs.po

File diff suppressed because it is too large Load Diff

944
po/da.po

File diff suppressed because it is too large Load Diff

954
po/de.po

File diff suppressed because it is too large Load Diff

954
po/eo.po

File diff suppressed because it is too large Load Diff

944
po/es.po

File diff suppressed because it is too large Load Diff

933
po/eu.po

File diff suppressed because it is too large Load Diff

934
po/fi.po

File diff suppressed because it is too large Load Diff

971
po/fr.po

File diff suppressed because it is too large Load Diff

951
po/ga.po

File diff suppressed because it is too large Load Diff

934
po/gl.po

File diff suppressed because it is too large Load Diff

1079
po/hr.po

File diff suppressed because it is too large Load Diff

942
po/hu.po

File diff suppressed because it is too large Load Diff

931
po/id.po

File diff suppressed because it is too large Load Diff

936
po/it.po

File diff suppressed because it is too large Load Diff

962
po/ja.po

File diff suppressed because it is too large Load Diff

931
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

957
po/nb.po

File diff suppressed because it is too large Load Diff

951
po/nl.po

File diff suppressed because it is too large Load Diff

928
po/nn.po

File diff suppressed because it is too large Load Diff

934
po/pl.po

File diff suppressed because it is too large Load Diff

953
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

942
po/ro.po

File diff suppressed because it is too large Load Diff

931
po/ru.po

File diff suppressed because it is too large Load Diff

931
po/sl.po

File diff suppressed because it is too large Load Diff

934
po/sr.po

File diff suppressed because it is too large Load Diff

942
po/sv.po

File diff suppressed because it is too large Load Diff

950
po/tr.po

File diff suppressed because it is too large Load Diff

958
po/uk.po

File diff suppressed because it is too large Load Diff

958
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

@@ -303,6 +303,10 @@ char *do_browser(char *path)
/* Try opening and reading the selected directory. */
path = mallocstrcpy(path, filelist[selected]);
goto read_directory_contents;
#ifdef ENABLE_NANORC
} else if (func == (void *)implant) {
implant(first_sc_for(MBROWSER, func)->expansion);
#endif
} else if (func == do_exit) {
/* Exit from the file browser. */
break;

View File

@@ -68,10 +68,13 @@ void set_colorpairs(void)
interface_color_pair[i] = COLOR_PAIR(i + 1) | A_BANDAID |
(combo->bright ? A_BOLD : A_NORMAL);
} else {
if (i != FUNCTION_TAG)
interface_color_pair[i] = hilite_attribute;
else
if (i == FUNCTION_TAG)
interface_color_pair[i] = A_NORMAL;
else if (i == ERROR_MESSAGE) {
init_pair(i + 1, COLOR_WHITE, COLOR_RED);
interface_color_pair[i] = COLOR_PAIR(i + 1) | A_BOLD | A_BANDAID;
} else
interface_color_pair[i] = hilite_attribute;
}
free(color_combo[i]);
@@ -87,8 +90,7 @@ void set_colorpairs(void)
const colortype *beforenow = sint->color;
while (beforenow != ink && (beforenow->fg != ink->fg ||
beforenow->bg != ink->bg ||
beforenow->bright != ink->bright))
beforenow->bg != ink->bg))
beforenow = beforenow->next;
if (beforenow != ink)

View File

@@ -188,10 +188,6 @@ void do_cut_text(bool copy_text, bool cut_till_eof)
refresh_needed = TRUE;
#ifdef ENABLE_COLOR
check_the_multis(openfile->current);
#endif
#ifdef DEBUG
dump_filestruct(cutbuffer);
#endif
@@ -286,8 +282,4 @@ void do_uncut_text(void)
set_modified();
refresh_needed = TRUE;
#ifdef ENABLE_COLOR
check_the_multis(openfile->current);
#endif
}

View File

@@ -435,7 +435,7 @@ bool open_buffer(const char *filename, bool undoable)
/* When the specified filename is not empty, and the corresponding
* file exists, verify that it is a normal file. */
if (strcmp(filename, "") != 0) {
if (*filename != '\0') {
struct stat fileinfo;
if (stat(realname, &fileinfo) == 0 && !(S_ISREG(fileinfo.st_mode) ||

View File

@@ -32,8 +32,8 @@ volatile sig_atomic_t the_window_resized = FALSE;
#endif
#ifdef __linux__
bool console;
/* Whether we're running on a Linux VC (TRUE) or under X (FALSE). */
bool on_a_vt;
/* Whether we're running on a Linux VT or on something else. */
#endif
bool meta_key;
@@ -254,7 +254,7 @@ size_t length_of_list(int menu)
size_t i = 0;
for (f = allfuncs; f != NULL; f = f->next)
if ((f->menus & menu) && first_sc_for(menu, f->scfunc) != NULL)
if ((f->menus & menu) && first_sc_for(menu, f->func) != NULL)
i++;
return i;
@@ -279,7 +279,7 @@ void backwards_void(void)
void flip_replace(void)
{
}
void gototext_void(void)
void flip_goto(void)
{
}
#ifdef ENABLE_BROWSER
@@ -332,7 +332,7 @@ void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *h
tailfunc = f;
f->next = NULL;
f->scfunc = func;
f->func = func;
f->menus = menus;
f->desc = desc;
f->viewok = viewok;
@@ -366,7 +366,7 @@ void add_to_sclist(int menus, const char *scstring, const int keycode,
/* Fill in the data. */
s->menus = menus;
s->scfunc = func;
s->func = func;
#ifndef NANO_TINY
s->toggle = toggle;
if (toggle)
@@ -386,7 +386,7 @@ const sc *first_sc_for(int menu, void (*func)(void))
const sc *s;
for (s = sclist; s != NULL; s = s->next)
if ((s->menus & menu) && s->scfunc == func)
if ((s->menus & menu) && s->func == func)
return s;
#ifdef DEBUG
@@ -415,7 +415,7 @@ functionptrtype func_from_key(int *kbinput)
const sc *s = get_shortcut(kbinput);
if (s)
return s->scfunc;
return s->func;
else
return NULL;
}
@@ -515,16 +515,11 @@ void shortcut_init(void)
const char *cancel_gist = N_("Cancel the current function");
const char *help_gist = N_("Display this help text");
const char *exit_gist =
#ifdef ENABLE_MULTIBUFFER
N_("Close the current file buffer / Exit from nano")
#else
N_("Exit from nano")
#endif
;
N_("Close the current buffer / Exit from nano");
const char *writeout_gist =
N_("Write the current file to disk");
N_("Write the current buffer (or the marked region) to disk");
const char *readfile_gist =
N_("Insert another file into the current one");
N_("Insert another file into current buffer (or into new buffer)");
const char *whereis_gist =
N_("Search forward for a string or a regular expression");
const char *wherewas_gist =
@@ -542,7 +537,7 @@ void shortcut_init(void)
const char *prevpage_gist = N_("Go one screenful up");
const char *nextpage_gist = N_("Go one screenful down");
const char *cut_gist =
N_("Cut the current line and store it in the cutbuffer");
N_("Cut current line (or marked region) and store it in cutbuffer");
const char *uncut_gist =
N_("Uncut from the cutbuffer into the current line");
const char *cursorpos_gist = N_("Display the position of the cursor");
@@ -555,7 +550,7 @@ void shortcut_init(void)
#ifndef NANO_TINY
const char *mark_gist = N_("Mark text starting from the cursor position");
const char *copy_gist =
N_("Copy the current line and store it in the cutbuffer");
N_("Copy current line (or marked region) and store it in cutbuffer");
const char *indent_gist = N_("Indent the current line (or marked lines)");
const char *unindent_gist = N_("Unindent the current line (or marked lines)");
const char *undo_gist = N_("Undo the last operation");
@@ -822,7 +817,7 @@ void shortcut_init(void)
add_to_funcs(do_full_justify, MWHEREIS,
fulljustify_tag, WITHORSANS(fulljustify_gist), TOGETHER, NOVIEW);
add_to_funcs(do_gotolinecolumn_void, MWHEREIS,
add_to_funcs(flip_goto, MWHEREIS,
gotoline_tag, WITHORSANS(gotoline_gist), BLANKAFTER, VIEW);
#endif
@@ -991,11 +986,11 @@ void shortcut_init(void)
#endif
#ifndef ENABLE_JUSTIFY
add_to_funcs(do_gotolinecolumn_void, MWHEREIS,
add_to_funcs(flip_goto, MWHEREIS,
gotoline_tag, WITHORSANS(gotoline_gist), BLANKAFTER, VIEW);
#endif
add_to_funcs(gototext_void, MGOTOLINE,
add_to_funcs(flip_goto, MGOTOLINE,
N_("Go To Text"), WITHORSANS(whereis_gist), BLANKAFTER, VIEW);
#ifndef NANO_TINY
@@ -1281,8 +1276,7 @@ void shortcut_init(void)
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH, "^W", 0, do_para_begin_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH, "^O", 0, do_para_end_void, 0);
#endif
add_to_sclist(MWHEREIS, "^T", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MGOTOLINE, "^T", 0, gototext_void, 0);
add_to_sclist(MWHEREIS|MGOTOLINE, "^T", 0, flip_goto, 0);
#ifdef ENABLE_HISTORIES
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "^P", 0, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "^N", 0, get_history_newer_void, 0);
@@ -1358,8 +1352,8 @@ void shortcut_init(void)
void replace_scs_for(void (*oldfunc)(void), void (*newfunc)(void))
{
for (sc *s = sclist; s != NULL; s = s->next)
if (s->scfunc == oldfunc)
s->scfunc = newfunc;
if (s->func == oldfunc)
s->func = newfunc;
}
void set_lint_or_format_shortcuts(void)
@@ -1384,7 +1378,7 @@ const subnfunc *sctofunc(const sc *s)
{
subnfunc *f = allfuncs;
while (f != NULL && f->scfunc != s->scfunc)
while (f != NULL && f->func != s->func)
f = f->next;
return f;
@@ -1453,211 +1447,207 @@ sc *strtosc(const char *input)
#ifdef ENABLE_HELP
if (!strcasecmp(input, "help"))
s->scfunc = do_help_void;
s->func = do_help_void;
else
#endif
if (!strcasecmp(input, "cancel"))
s->scfunc = do_cancel;
s->func = do_cancel;
else if (!strcasecmp(input, "exit"))
s->scfunc = do_exit;
s->func = do_exit;
else if (!strcasecmp(input, "discardbuffer"))
s->scfunc = discard_buffer;
s->func = discard_buffer;
else if (!strcasecmp(input, "writeout"))
s->scfunc = do_writeout_void;
s->func = do_writeout_void;
else if (!strcasecmp(input, "savefile"))
s->scfunc = do_savefile;
s->func = do_savefile;
else if (!strcasecmp(input, "insert"))
s->scfunc = do_insertfile_void;
s->func = do_insertfile_void;
else if (!strcasecmp(input, "whereis"))
s->scfunc = do_search_forward;
s->func = do_search_forward;
else if (!strcasecmp(input, "wherewas"))
s->scfunc = do_search_backward;
else if (!strcasecmp(input, "searchagain") ||
!strcasecmp(input, "research")) /* Deprecated. Remove in 2018. */
s->scfunc = do_research;
s->func = do_search_backward;
else if (!strcasecmp(input, "searchagain"))
s->func = do_research;
#ifndef NANO_TINY
else if (!strcasecmp(input, "findprevious"))
s->scfunc = do_findprevious;
s->func = do_findprevious;
else if (!strcasecmp(input, "findnext"))
s->scfunc = do_findnext;
s->func = do_findnext;
#endif
else if (!strcasecmp(input, "replace"))
s->scfunc = do_replace;
s->func = do_replace;
else if (!strcasecmp(input, "cut"))
s->scfunc = do_cut_text_void;
s->func = do_cut_text_void;
else if (!strcasecmp(input, "uncut"))
s->scfunc = do_uncut_text;
s->func = do_uncut_text;
#ifndef NANO_TINY
else if (!strcasecmp(input, "cutrestoffile"))
s->scfunc = do_cut_till_eof;
s->func = do_cut_till_eof;
else if (!strcasecmp(input, "copytext"))
s->scfunc = do_copy_text;
s->func = do_copy_text;
else if (!strcasecmp(input, "mark"))
s->scfunc = do_mark;
s->func = do_mark;
#endif
#ifdef ENABLE_SPELLER
else if (!strcasecmp(input, "tospell") ||
!strcasecmp(input, "speller"))
s->scfunc = do_spell;
s->func = do_spell;
#endif
#ifdef ENABLE_COLOR
else if (!strcasecmp(input, "linter"))
s->scfunc = do_linter;
s->func = do_linter;
#endif
else if (!strcasecmp(input, "curpos") ||
!strcasecmp(input, "cursorpos")) /* Deprecated. Remove in 2018. */
s->scfunc = do_cursorpos_void;
else if (!strcasecmp(input, "curpos"))
s->func = do_cursorpos_void;
else if (!strcasecmp(input, "gotoline"))
s->scfunc = do_gotolinecolumn_void;
s->func = do_gotolinecolumn_void;
#ifdef ENABLE_JUSTIFY
else if (!strcasecmp(input, "justify"))
s->scfunc = do_justify_void;
s->func = do_justify_void;
else if (!strcasecmp(input, "fulljustify"))
s->scfunc = do_full_justify;
s->func = do_full_justify;
else if (!strcasecmp(input, "beginpara"))
s->scfunc = do_para_begin_void;
s->func = do_para_begin_void;
else if (!strcasecmp(input, "endpara"))
s->scfunc = do_para_end_void;
s->func = do_para_end_void;
#endif
#ifdef ENABLE_COMMENT
else if (!strcasecmp(input, "comment"))
s->scfunc = do_comment;
s->func = do_comment;
#endif
#ifdef ENABLE_WORDCOMPLETION
else if (!strcasecmp(input, "complete"))
s->scfunc = complete_a_word;
s->func = complete_a_word;
#endif
#ifndef NANO_TINY
else if (!strcasecmp(input, "indent"))
s->scfunc = do_indent;
s->func = do_indent;
else if (!strcasecmp(input, "unindent"))
s->scfunc = do_unindent;
s->func = do_unindent;
else if (!strcasecmp(input, "scrollup"))
s->scfunc = do_scroll_up;
s->func = do_scroll_up;
else if (!strcasecmp(input, "scrolldown"))
s->scfunc = do_scroll_down;
s->func = do_scroll_down;
else if (!strcasecmp(input, "cutwordleft"))
s->scfunc = do_cut_prev_word;
s->func = do_cut_prev_word;
else if (!strcasecmp(input, "cutwordright"))
s->scfunc = do_cut_next_word;
s->func = do_cut_next_word;
else if (!strcasecmp(input, "findbracket"))
s->scfunc = do_find_bracket;
s->func = do_find_bracket;
else if (!strcasecmp(input, "wordcount"))
s->scfunc = do_wordlinechar_count;
s->func = do_wordlinechar_count;
else if (!strcasecmp(input, "recordmacro"))
s->scfunc = record_macro;
s->func = record_macro;
else if (!strcasecmp(input, "runmacro"))
s->scfunc = run_macro;
s->func = run_macro;
else if (!strcasecmp(input, "undo"))
s->scfunc = do_undo;
s->func = do_undo;
else if (!strcasecmp(input, "redo"))
s->scfunc = do_redo;
s->func = do_redo;
#endif
else if (!strcasecmp(input, "left") ||
!strcasecmp(input, "back"))
s->scfunc = do_left;
s->func = do_left;
else if (!strcasecmp(input, "right") ||
!strcasecmp(input, "forward"))
s->scfunc = do_right;
s->func = do_right;
else if (!strcasecmp(input, "up") ||
!strcasecmp(input, "prevline"))
s->scfunc = do_up_void;
s->func = do_up_void;
else if (!strcasecmp(input, "down") ||
!strcasecmp(input, "nextline"))
s->scfunc = do_down_void;
s->func = do_down_void;
else if (!strcasecmp(input, "prevword"))
s->scfunc = do_prev_word_void;
s->func = do_prev_word_void;
else if (!strcasecmp(input, "nextword"))
s->scfunc = do_next_word_void;
s->func = do_next_word_void;
else if (!strcasecmp(input, "home"))
s->scfunc = do_home;
s->func = do_home;
else if (!strcasecmp(input, "end"))
s->scfunc = do_end;
s->func = do_end;
else if (!strcasecmp(input, "prevblock"))
s->scfunc = do_prev_block;
s->func = do_prev_block;
else if (!strcasecmp(input, "nextblock"))
s->scfunc = do_next_block;
s->func = do_next_block;
else if (!strcasecmp(input, "pageup") ||
!strcasecmp(input, "prevpage"))
s->scfunc = do_page_up;
s->func = do_page_up;
else if (!strcasecmp(input, "pagedown") ||
!strcasecmp(input, "nextpage"))
s->scfunc = do_page_down;
s->func = do_page_down;
else if (!strcasecmp(input, "firstline"))
s->scfunc = to_first_line;
s->func = to_first_line;
else if (!strcasecmp(input, "lastline"))
s->scfunc = to_last_line;
s->func = to_last_line;
#ifdef ENABLE_MULTIBUFFER
else if (!strcasecmp(input, "prevbuf"))
s->scfunc = switch_to_prev_buffer;
s->func = switch_to_prev_buffer;
else if (!strcasecmp(input, "nextbuf"))
s->scfunc = switch_to_next_buffer;
s->func = switch_to_next_buffer;
#endif
else if (!strcasecmp(input, "verbatim"))
s->scfunc = do_verbatim_input;
s->func = do_verbatim_input;
else if (!strcasecmp(input, "tab"))
s->scfunc = do_tab;
s->func = do_tab;
else if (!strcasecmp(input, "enter"))
s->scfunc = do_enter;
s->func = do_enter;
else if (!strcasecmp(input, "delete"))
s->scfunc = do_delete;
s->func = do_delete;
else if (!strcasecmp(input, "backspace"))
s->scfunc = do_backspace;
s->func = do_backspace;
else if (!strcasecmp(input, "refresh"))
s->scfunc = total_refresh;
s->func = total_refresh;
else if (!strcasecmp(input, "suspend"))
s->scfunc = do_suspend_void;
s->func = do_suspend_void;
else if (!strcasecmp(input, "casesens"))
s->scfunc = case_sens_void;
else if (!strcasecmp(input, "regexp") ||
!strcasecmp(input, "regex")) /* Deprecated. Remove in 2018. */
s->scfunc = regexp_void;
s->func = case_sens_void;
else if (!strcasecmp(input, "regexp"))
s->func = regexp_void;
else if (!strcasecmp(input, "backwards"))
s->scfunc = backwards_void;
else if (!strcasecmp(input, "flipreplace") ||
!strcasecmp(input, "dontreplace")) /* Deprecated. Remove in 2018. */
s->scfunc = flip_replace;
else if (!strcasecmp(input, "gototext"))
s->scfunc = gototext_void;
s->func = backwards_void;
else if (!strcasecmp(input, "flipreplace"))
s->func = flip_replace;
else if (!strcasecmp(input, "flipgoto") ||
!strcasecmp(input, "gototext")) /* Deprecated. Remove end of 2018. */
s->func = flip_goto;
#ifdef ENABLE_HISTORIES
else if (!strcasecmp(input, "prevhistory"))
s->scfunc = get_history_older_void;
s->func = get_history_older_void;
else if (!strcasecmp(input, "nexthistory"))
s->scfunc = get_history_newer_void;
s->func = get_history_newer_void;
#endif
#ifndef NANO_TINY
else if (!strcasecmp(input, "dosformat"))
s->scfunc = dos_format_void;
s->func = dos_format_void;
else if (!strcasecmp(input, "macformat"))
s->scfunc = mac_format_void;
s->func = mac_format_void;
else if (!strcasecmp(input, "append"))
s->scfunc = append_void;
s->func = append_void;
else if (!strcasecmp(input, "prepend"))
s->scfunc = prepend_void;
s->func = prepend_void;
else if (!strcasecmp(input, "backup"))
s->scfunc = backup_file_void;
s->func = backup_file_void;
else if (!strcasecmp(input, "flipexecute"))
s->scfunc = flip_execute;
s->func = flip_execute;
#endif
#ifdef ENABLE_MULTIBUFFER
else if (!strcasecmp(input, "flipnewbuffer") ||
!strcasecmp(input, "newbuffer")) /* Deprecated. Remove in 2018. */
s->scfunc = flip_newbuffer;
else if (!strcasecmp(input, "flipnewbuffer"))
s->func = flip_newbuffer;
#endif
#ifdef ENABLE_BROWSER
else if (!strcasecmp(input, "tofiles") ||
!strcasecmp(input, "browser"))
s->scfunc = to_files_void;
s->func = to_files_void;
else if (!strcasecmp(input, "gotodir"))
s->scfunc = goto_dir_void;
s->func = goto_dir_void;
else if (!strcasecmp(input, "firstfile"))
s->scfunc = to_first_file;
s->func = to_first_file;
else if (!strcasecmp(input, "lastfile"))
s->scfunc = to_last_file;
s->func = to_last_file;
#endif
else {
#ifndef NANO_TINY
s->scfunc = do_toggle_void;
s->func = do_toggle_void;
if (!strcasecmp(input, "nohelp"))
s->toggle = NO_HELP;
else if (!strcasecmp(input, "constupdate"))
@@ -1721,8 +1711,7 @@ int strtomenu(const char *input)
return MWHEREIS;
else if (!strcasecmp(input, "replace"))
return MREPLACE;
else if (!strcasecmp(input, "replace2") || /* Deprecated. Remove in 2018. */
!strcasecmp(input, "replacewith"))
else if (!strcasecmp(input, "replacewith"))
return MREPLACEWITH;
else if (!strcasecmp(input, "gotoline"))
return MGOTOLINE;

View File

@@ -215,6 +215,10 @@ void do_help(void)
do_findprevious();
} else if (func == do_findnext) {
do_findnext();
#ifdef ENABLE_NANORC
} else if (func == (void *)implant) {
implant(first_sc_for(MHELP, func)->expansion);
#endif
} else if (kbinput == KEY_WINCH) {
; /* Nothing to do. */
#endif
@@ -471,7 +475,7 @@ void help_init(void)
size_t endis_len = strlen(_("enable/disable"));
for (s = sclist; s != NULL; s = s->next)
if (s->scfunc == do_toggle_void)
if (s->func == do_toggle_void)
allocsize += strlen(_(flagtostr(s->toggle))) + endis_len + 8;
}
#endif
@@ -504,7 +508,7 @@ void help_init(void)
if ((s->menus & currmenu) == 0)
continue;
if (s->scfunc == f->scfunc) {
if (s->func == f->func) {
scsfound++;
/* Make the first column narrower (6) than the second (10),
* but allow it to spill into the second, for "M-Space". */

View File

@@ -26,7 +26,7 @@
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#ifndef NANO_TINY
#if defined(__linux__) || !defined(NANO_TINY)
#include <sys/ioctl.h>
#endif
#ifdef ENABLE_UTF8
@@ -38,6 +38,9 @@
#include <termios.h>
#endif
#include <unistd.h>
#ifdef __linux__
#include <sys/vt.h>
#endif
#ifdef ENABLE_MOUSE
static int oldinterval = -1;
@@ -171,20 +174,24 @@ void free_filestruct(filestruct *src)
delete_node(src);
}
/* Renumber the lines in a buffer, starting with fileptr. */
void renumber(filestruct *fileptr)
/* Renumber the lines in a buffer, starting with the given line. */
void renumber(filestruct *line)
{
ssize_t line;
ssize_t number;
if (fileptr == NULL)
if (line == NULL) {
#ifndef NANO_TINY
statusline(ALERT, "Trying to renumber nothing -- please report a bug");
#endif
return;
}
line = (fileptr->prev == NULL) ? 0 : fileptr->prev->lineno;
number = (line->prev == NULL) ? 0 : line->prev->lineno;
assert(fileptr != fileptr->next);
for (; fileptr != NULL; fileptr = fileptr->next)
fileptr->lineno = ++line;
while (line != NULL) {
line->lineno = ++number;
line = line->next;
}
}
/* Partition the current buffer so that it appears to begin at (top, top_x)
@@ -1426,7 +1433,7 @@ void do_toggle_void(void)
void disable_extended_io(void)
{
#ifdef HAVE_TERMIOS_H
struct termios term;
struct termios term = {0};
tcgetattr(0, &term);
term.c_lflag &= ~IEXTEN;
@@ -1440,7 +1447,7 @@ void disable_extended_io(void)
void disable_signals(void)
{
#ifdef HAVE_TERMIOS_H
struct termios term;
struct termios term = {0};
tcgetattr(0, &term);
term.c_lflag &= ~ISIG;
@@ -1454,7 +1461,7 @@ void disable_signals(void)
void enable_signals(void)
{
#ifdef HAVE_TERMIOS_H
struct termios term;
struct termios term = {0};
tcgetattr(0, &term);
term.c_lflag |= ISIG;
@@ -1627,8 +1634,7 @@ int do_input(bool allow_funcs)
/* The length of the input buffer. */
bool retain_cuts = FALSE;
/* Whether to conserve the current contents of the cutbuffer. */
const sc *s;
bool have_shortcut;
const sc *shortcut;
/* Read in a keystroke, and show the cursor while waiting. */
input = get_kbinput(edit, VISIBLE);
@@ -1652,15 +1658,11 @@ int do_input(bool allow_funcs)
#endif
/* Check for a shortcut in the main list. */
s = get_shortcut(&input);
/* If we got a shortcut from the main list, or a "universal"
* edit window shortcut, set have_shortcut to TRUE. */
have_shortcut = (s != NULL);
shortcut = get_shortcut(&input);
/* If we got a non-high-bit control key, a meta key sequence, or a
* function key, and it's not a shortcut or toggle, throw it out. */
if (!have_shortcut) {
if (shortcut == NULL) {
if (is_ascii_cntrl_char(input) || meta_key || !is_byte(input)) {
unbound_key(input);
input = ERR;
@@ -1673,7 +1675,7 @@ int do_input(bool allow_funcs)
/* If the keystroke isn't a shortcut nor a toggle, it's a normal text
* character: add the character to the input buffer -- or display a
* warning when we're in view mode. */
if (input != ERR && !have_shortcut) {
if (input != ERR && shortcut == NULL) {
if (ISSET(VIEW_MODE))
print_view_warning();
else {
@@ -1693,7 +1695,7 @@ int do_input(bool allow_funcs)
* characters waiting after the one we read in, we need to output
* all available characters in the input puddle. Note that this
* puddle will be empty if we're in view mode. */
if (have_shortcut || get_key_buffer_len() == 0) {
if (shortcut || get_key_buffer_len() == 0) {
if (puddle != NULL) {
/* Insert all bytes in the input buffer into the edit buffer
* at once, filtering out any low control codes. */
@@ -1707,33 +1709,38 @@ int do_input(bool allow_funcs)
}
}
if (!have_shortcut)
if (shortcut == NULL)
pletion_line = NULL;
else {
const subnfunc *f = sctofunc(s);
if (ISSET(VIEW_MODE) && f && !f->viewok) {
if (ISSET(VIEW_MODE) && !sctofunc(shortcut)->viewok) {
print_view_warning();
return ERR;
}
/* If the function associated with this shortcut is
* cutting or copying text, remember this. */
if (s->scfunc == do_cut_text_void
if (shortcut->func == do_cut_text_void
#ifndef NANO_TINY
|| s->scfunc == do_copy_text || s->scfunc == do_cut_till_eof
|| shortcut->func == do_copy_text
|| shortcut->func == do_cut_till_eof
#endif
)
retain_cuts = TRUE;
#ifdef ENABLE_WORDCOMPLETION
if (s->scfunc != complete_a_word)
if (shortcut->func != complete_a_word)
pletion_line = NULL;
#endif
#ifdef ENABLE_NANORC
if (shortcut->func == (void *)implant) {
implant(shortcut->expansion);
return 42;
}
#endif
#ifndef NANO_TINY
if (s->scfunc == do_toggle_void) {
do_toggle(s->toggle);
if (s->toggle != CUT_FROM_CURSOR)
if (shortcut->func == do_toggle_void) {
do_toggle(shortcut->toggle);
if (shortcut->toggle != CUT_FROM_CURSOR)
retain_cuts = TRUE;
} else
#endif
@@ -1753,14 +1760,18 @@ int do_input(bool allow_funcs)
}
#endif
/* Execute the function of the shortcut. */
s->scfunc();
shortcut->func();
#ifndef NANO_TINY
/* When the marked region changes without Shift being held,
* discard a soft mark. And when the marked region covers a
* different set of lines, reset the "last line too" flag. */
if (openfile->mark && (openfile->current != was_current ||
openfile->current_x != was_x)) {
if (!shift_held && openfile->kind_of_mark == SOFTMARK) {
if (openfile->mark) {
if (!shift_held && openfile->kind_of_mark == SOFTMARK &&
(openfile->current != was_current ||
openfile->current_x != was_x ||
(shortcut->func >= to_first_line &&
shortcut->func <= do_right))) {
openfile->mark = NULL;
refresh_needed = TRUE;
} else if (openfile->current != was_current)
@@ -1768,15 +1779,19 @@ int do_input(bool allow_funcs)
}
#endif
#ifdef ENABLE_WRAPPING
/* If the cursor moved to another line, clear the prepend flag. */
if (openfile->current->next != was_next)
/* If the cursor moved to another line and this was not caused
* by adding characters to the buffer, clear the prepend flag. */
if (openfile->current->next != was_next &&
shortcut->func != do_tab &&
shortcut->func != do_verbatim_input)
wrap_reset();
#endif
#ifdef ENABLE_COLOR
if (f && !f->viewok)
if (!refresh_needed && !sctofunc(shortcut)->viewok)
check_the_multis(openfile->current);
#endif
if (!refresh_needed && (s->scfunc == do_delete || s->scfunc == do_backspace))
if (!refresh_needed && (shortcut->func == do_delete ||
shortcut->func == do_backspace))
update_line(openfile->current, openfile->current_x);
}
}
@@ -1887,7 +1902,8 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
openfile->placewewant = xplustabs();
#ifdef ENABLE_COLOR
check_the_multis(openfile->current);
if (!refresh_needed)
check_the_multis(openfile->current);
#endif
if (!refresh_needed)
@@ -1973,7 +1989,6 @@ int main(int argc, char **argv)
{"locking", 0, NULL, 'G'},
{"historylog", 0, NULL, 'H'},
{"noconvert", 0, NULL, 'N'},
{"poslog", 0, NULL, 'P'}, /* deprecated form, remove in 2018 */
{"positionlog", 0, NULL, 'P'},
{"smooth", 0, NULL, 'S'},
{"wordbounds", 0, NULL, 'W'},
@@ -1988,8 +2003,10 @@ int main(int argc, char **argv)
};
#ifdef __linux__
struct vt_stat dummy;
/* Check whether we're running on a Linux console. */
console = (getenv("DISPLAY") == NULL);
on_a_vt = (ioctl(0, VT_GETSTATE, &dummy) == 0);
#endif
/* Back up the terminal settings so that they can be restored. */
@@ -2492,6 +2509,7 @@ int main(int argc, char **argv)
interface_color_pair[LINE_NUMBER] = hilite_attribute;
interface_color_pair[SELECTED_TEXT] = hilite_attribute;
interface_color_pair[STATUS_BAR] = hilite_attribute;
interface_color_pair[ERROR_MESSAGE] = hilite_attribute;
interface_color_pair[KEY_COMBO] = hilite_attribute;
interface_color_pair[FUNCTION_TAG] = A_NORMAL;
#endif

View File

@@ -163,8 +163,9 @@ typedef enum {
CENTERING, FLOWING, STATIONARY
} update_type;
/* The kinds of undo actions. ADD...REPLACE must come first. */
typedef enum {
ADD, DEL, BACK, CUT, CUT_TO_EOF, REPLACE,
ADD, ENTER, BACK, DEL, JOIN, REPLACE,
#ifdef ENABLE_WRAPPING
SPLIT_BEGIN, SPLIT_END,
#endif
@@ -172,7 +173,7 @@ typedef enum {
#ifdef ENABLE_COMMENT
COMMENT, UNCOMMENT, PREFLIGHT,
#endif
JOIN, PASTE, INSERT, ENTER, OTHER
CUT, CUT_TO_EOF, PASTE, INSERT, OTHER
} undo_type;
/* Structure types. */
@@ -431,7 +432,7 @@ typedef struct sc {
/* The integer that, together with meta, identifies the keystroke. */
int menus;
/* Which menus this applies to. */
void (*scfunc)(void);
void (*func)(void);
/* The function we're going to run. */
#ifndef NANO_TINY
int toggle;
@@ -439,13 +440,17 @@ typedef struct sc {
int ordinal;
/* The how-manieth toggle this is, in order to be able to
* keep them in sequence. */
#endif
#ifdef ENABLE_NANORC
char *expansion;
/* The string of keycodes to which this shortcut is expanded. */
#endif
struct sc *next;
/* Next in the list. */
} sc;
typedef struct subnfunc {
void (*scfunc)(void);
void (*func)(void);
/* The actual function to call. */
int menus;
/* In what menus this function applies. */
@@ -480,6 +485,7 @@ enum
LINE_NUMBER,
SELECTED_TEXT,
STATUS_BAR,
ERROR_MESSAGE,
KEY_COMBO,
FUNCTION_TAG,
NUMBER_OF_ELEMENTS

View File

@@ -53,10 +53,9 @@ int do_statusbar_mouse(void)
#endif
/* Read in a keystroke, interpret it if it is a shortcut or toggle, and
* return it. Set ran_func to TRUE if we ran a function associated with
* a shortcut key, and set finished to TRUE if we're done after running
* return it. Set finished to TRUE if we're done after running
* or trying to run a function associated with a shortcut key. */
int do_statusbar_input(bool *ran_func, bool *finished)
int do_statusbar_input(bool *finished)
{
int input;
/* The character we read in. */
@@ -64,11 +63,8 @@ int do_statusbar_input(bool *ran_func, bool *finished)
/* The input buffer. */
static size_t kbinput_len = 0;
/* The length of the input buffer. */
const sc *s;
bool have_shortcut = FALSE;
const subnfunc *f;
const sc *shortcut;
*ran_func = FALSE;
*finished = FALSE;
/* Read in a character. */
@@ -91,15 +87,11 @@ int do_statusbar_input(bool *ran_func, bool *finished)
#endif
/* Check for a shortcut in the current list. */
s = get_shortcut(&input);
/* If we got a shortcut from the current list, or a "universal"
* statusbar prompt shortcut, set have_shortcut to TRUE. */
have_shortcut = (s != NULL);
shortcut = get_shortcut(&input);
/* If we got a non-high-bit control key, a meta key sequence, or a
* function key, and it's not a shortcut or toggle, throw it out. */
if (!have_shortcut) {
if (shortcut == NULL) {
if (is_ascii_cntrl_char(input) || meta_key || !is_byte(input)) {
beep();
input = ERR;
@@ -108,7 +100,7 @@ int do_statusbar_input(bool *ran_func, bool *finished)
/* If the keystroke isn't a shortcut nor a toggle, it's a normal text
* character: add the it to the input buffer, when allowed. */
if (input != ERR && !have_shortcut) {
if (input != ERR && shortcut == NULL) {
/* Only accept input when not in restricted mode, or when not at
* the "Write File" prompt, or when there is no filename yet. */
if (!ISSET(RESTRICTED) || currmenu != MWRITEFILE ||
@@ -122,7 +114,7 @@ int do_statusbar_input(bool *ran_func, bool *finished)
/* If we got a shortcut, or if there aren't any other keystrokes waiting
* after the one we read in, we need to insert all the characters in the
* input buffer (if not empty) into the answer. */
if ((have_shortcut || get_key_buffer_len() == 0) && kbinput != NULL) {
if ((shortcut || get_key_buffer_len() == 0) && kbinput != NULL) {
/* Inject all characters in the input buffer at once, filtering out
* control characters. */
do_statusbar_output(kbinput, kbinput_len, TRUE);
@@ -133,55 +125,54 @@ int do_statusbar_input(bool *ran_func, bool *finished)
kbinput = NULL;
}
if (have_shortcut) {
if (s->scfunc == do_tab || s->scfunc == do_enter)
if (shortcut) {
if (shortcut->func == do_tab || shortcut->func == do_enter)
;
else if (s->scfunc == do_left)
else if (shortcut->func == do_left)
do_statusbar_left();
else if (s->scfunc == do_right)
else if (shortcut->func == do_right)
do_statusbar_right();
#ifndef NANO_TINY
else if (s->scfunc == do_prev_word_void)
else if (shortcut->func == do_prev_word_void)
do_statusbar_prev_word();
else if (s->scfunc == do_next_word_void)
else if (shortcut->func == do_next_word_void)
do_statusbar_next_word();
#endif
else if (s->scfunc == do_home)
else if (shortcut->func == do_home)
do_statusbar_home();
else if (s->scfunc == do_end)
else if (shortcut->func == do_end)
do_statusbar_end();
/* When in restricted mode at the "Write File" prompt and the
* filename isn't blank, disallow any input and deletion. */
else if (ISSET(RESTRICTED) && currmenu == MWRITEFILE &&
openfile->filename[0] != '\0' &&
(s->scfunc == do_verbatim_input ||
s->scfunc == do_cut_text_void ||
s->scfunc == do_delete ||
s->scfunc == do_backspace))
(shortcut->func == do_verbatim_input ||
shortcut->func == do_cut_text_void ||
shortcut->func == do_uncut_text ||
shortcut->func == do_delete ||
shortcut->func == do_backspace))
;
else if (s->scfunc == do_verbatim_input)
#ifdef ENABLE_NANORC
else if (shortcut->func == (void *)implant)
implant(shortcut->expansion);
#endif
else if (shortcut->func == do_verbatim_input)
do_statusbar_verbatim_input();
else if (s->scfunc == do_cut_text_void)
else if (shortcut->func == do_cut_text_void)
do_statusbar_cut_text();
else if (s->scfunc == do_delete)
else if (shortcut->func == do_delete)
do_statusbar_delete();
else if (s->scfunc == do_backspace)
else if (shortcut->func == do_backspace)
do_statusbar_backspace();
else if (s->scfunc == do_uncut_text) {
else if (shortcut->func == do_uncut_text) {
if (cutbuffer != NULL)
do_statusbar_uncut_text();
} else {
/* Handle any other shortcut in the current menu, setting
* ran_func to TRUE if we try to run their associated functions,
* and setting finished to TRUE to indicatethat we're done after
* running or trying to run their associated functions. */
f = sctofunc(s);
if (s->scfunc != NULL) {
*ran_func = TRUE;
if (f && (!ISSET(VIEW_MODE) || f->viewok) &&
f->scfunc != do_gotolinecolumn_void)
f->scfunc();
}
/* 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. */
if (!ISSET(VIEW_MODE) || sctofunc(shortcut)->viewok)
shortcut->func();
*finished = TRUE;
}
}
@@ -354,6 +345,8 @@ void do_statusbar_verbatim_input(void)
kbinput = get_verbatim_kbinput(bottomwin, &kbinput_len);
do_statusbar_output(kbinput, kbinput_len, FALSE);
free(kbinput);
}
/* Return the zero-based column position of the cursor in the answer. */
@@ -441,7 +434,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
void (*refresh_func)(void))
{
int kbinput = ERR;
bool ran_func, finished;
bool finished;
functionptrtype func;
#ifdef ENABLE_TABCOMP
bool tabbed = FALSE;
@@ -468,7 +461,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
update_the_statusbar();
while (TRUE) {
kbinput = do_statusbar_input(&ran_func, &finished);
kbinput = do_statusbar_input(&finished);
#ifndef NANO_TINY
/* If the window size changed, go reformat the prompt string. */
@@ -615,7 +608,8 @@ int do_prompt(bool allow_tabs, bool allow_files,
bottombars(menu);
answer = mallocstrcpy(answer, curranswer);
if (answer != curranswer || answer == NULL)
answer = mallocstrcpy(answer, curranswer);
#ifndef NANO_TINY
redo_theprompt:

View File

@@ -30,7 +30,7 @@ extern volatile sig_atomic_t the_window_resized;
#endif
#ifdef __linux__
extern bool console;
extern bool on_a_vt;
#endif
extern bool meta_key;
@@ -404,7 +404,7 @@ void unlink_node(filestruct *fileptr);
void delete_node(filestruct *fileptr);
filestruct *copy_filestruct(const filestruct *src);
void free_filestruct(filestruct *src);
void renumber(filestruct *fileptr);
void renumber(filestruct *line);
partition *partition_filestruct(filestruct *top, size_t top_x,
filestruct *bot, size_t bot_x);
void unpartition_filestruct(partition **p);
@@ -495,6 +495,7 @@ void go_looking(void);
ssize_t do_replace_loop(const char *needle, bool whole_word_only,
const filestruct *real_current, size_t *real_current_x);
void do_replace(void);
void ask_for_replacement(void);
void goto_line_posx(ssize_t line, size_t pos_x);
void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
bool interactive);
@@ -619,7 +620,11 @@ void dump_filestruct(const filestruct *inptr);
void record_macro(void);
void run_macro(void);
size_t get_key_buffer_len(void);
void put_back(int keycode);
void unget_kbinput(int kbinput, bool metakey);
#ifdef ENABLE_NANORC
void implant(const char *string);
#endif
int get_kbinput(WINDOW *win, bool showcursor);
int parse_kbinput(WINDOW *win);
int arrow_from_abcd(int kbinput);
@@ -692,7 +697,7 @@ void case_sens_void(void);
void regexp_void(void);
void backwards_void(void);
void flip_replace(void);
void gototext_void(void);
void flip_goto(void);
#ifdef ENABLE_BROWSER
void to_files_void(void);
void goto_dir_void(void);

View File

@@ -42,7 +42,6 @@ static const rcoption rcopts[] = {
#ifdef ENABLE_JUSTIFY
{"brackets", 0},
#endif
{"const", CONSTANT_SHOW}, /* deprecated form, remove in 2018 */
{"constantshow", CONSTANT_SHOW},
#ifdef ENABLED_WRAPORJUSTIFY
{"fill", 0},
@@ -67,7 +66,6 @@ static const rcoption rcopts[] = {
{"operatingdir", 0},
#endif
#ifdef ENABLE_HISTORIES
{"poslog", POS_HISTORY}, /* deprecated form, remove in 2018 */
{"positionlog", POS_HISTORY},
#endif
{"preserve", PRESERVE},
@@ -117,6 +115,7 @@ static const rcoption rcopts[] = {
{"numbercolor", 0},
{"selectedcolor", 0},
{"statuscolor", 0},
{"errorcolor", 0},
{"keycolor", 0},
{"functioncolor", 0},
#endif
@@ -260,8 +259,7 @@ bool nregcomp(const char *regex, int compile_flags)
* line at ptr, and add it to the global linked list of color syntaxes. */
void parse_syntax(char *ptr)
{
char *nameptr;
/* A pointer to what should be the name of the syntax. */
char *nameptr = ptr;
opensyntax = FALSE;
@@ -272,17 +270,19 @@ void parse_syntax(char *ptr)
return;
}
nameptr = ++ptr;
ptr = parse_next_word(ptr);
/* Check that the name starts and ends with a double quote. */
if (*(nameptr - 1) != '\x22' || nameptr[strlen(nameptr) - 1] != '\x22') {
rcfile_error(N_("A syntax name must be quoted"));
/* Check that quotes around the name are either paired or absent. */
if ((*nameptr == '\x22') ^ (nameptr[strlen(nameptr) - 1] == '\x22')) {
rcfile_error(N_("Unpaired quote in syntax name"));
return;
}
/* Strip the end quote. */
nameptr[strlen(nameptr) - 1] = '\0';
/* If the name is quoted, strip the quotes. */
if (*nameptr == '\x22') {
nameptr++;
nameptr[strlen(nameptr) - 1] = '\0';
}
/* Redefining the "none" syntax is not allowed. */
if (strcmp(nameptr, "none") == 0) {
@@ -327,22 +327,17 @@ void parse_syntax(char *ptr)
}
#endif /* ENABLE_COLOR */
/* Check whether the given executable function is "universal" (meaning
* any horizontal movement or deletion) and thus is present in almost
* all menus. */
/* Return TRUE when the given function is present in almost all menus. */
bool is_universal(void (*func)(void))
{
if (func == do_left || func == do_right ||
return (func == do_left || func == do_right ||
func == do_home || func == do_end ||
#ifndef NANO_TINY
func == do_prev_word_void || func == do_next_word_void ||
#endif
func == do_delete || func == do_backspace ||
func == do_cut_text_void || func == do_uncut_text ||
func == do_tab || func == do_enter || func == do_verbatim_input)
return TRUE;
else
return FALSE;
func == do_tab || func == do_enter || func == do_verbatim_input);
}
/* Bind or unbind a key combo, to or from a function. */
@@ -396,7 +391,7 @@ void parse_binding(char *ptr, bool dobind)
if (dobind) {
funcptr = ptr;
ptr = parse_next_word(ptr);
ptr = parse_argument(ptr);
if (funcptr[0] == '\0') {
rcfile_error(N_("Must specify a function to bind the key to"));
@@ -414,7 +409,18 @@ void parse_binding(char *ptr, bool dobind)
}
if (dobind) {
newsc = strtosc(funcptr);
/* If the thing to bind starts with a double quote, it is a string,
* otherwise it is the name of a function. */
if (*funcptr == '"') {
newsc = nmalloc(sizeof(sc));
newsc->func = (void *)implant;
newsc->expansion = mallocstrcpy(NULL, funcptr + 1);
#ifndef NANO_TINY
newsc->toggle = 0;
#endif
} else
newsc = strtosc(funcptr);
if (newsc == NULL) {
rcfile_error(N_("Cannot map name \"%s\" to a function"), funcptr);
goto free_things;
@@ -433,20 +439,21 @@ void parse_binding(char *ptr, bool dobind)
/* Tally up the menus where the function exists. */
for (f = allfuncs; f != NULL; f = f->next)
if (f->scfunc == newsc->scfunc)
if (f->func == newsc->func)
mask = mask | f->menus;
#ifndef NANO_TINY
/* Handle the special case of the toggles. */
if (newsc->scfunc == do_toggle_void)
if (newsc->func == do_toggle_void)
mask = MMAIN;
#endif
#ifdef ENABLE_NANORC
/* Handle the special case of a key defined as a string. */
if (newsc->func == (void *)implant)
mask = MMOST | MHELP;
#endif
/* Now limit the given menu to those where the function exists. */
if (is_universal(newsc->scfunc))
menu = menu & MMOST;
else
menu = menu & mask;
menu = menu & (is_universal(newsc->func) ? MMOST : mask);
if (!menu) {
rcfile_error(N_("Function '%s' does not exist in menu '%s'"), funcptr, menuptr);
@@ -472,9 +479,9 @@ void parse_binding(char *ptr, bool dobind)
if (dobind) {
#ifndef NANO_TINY
/* If this is a toggle, copy its sequence number. */
if (newsc->scfunc == do_toggle_void) {
if (newsc->func == do_toggle_void) {
for (s = sclist; s != NULL; s = s->next)
if (s->scfunc == do_toggle_void && s->toggle == newsc->toggle)
if (s->func == do_toggle_void && s->toggle == newsc->toggle)
newsc->ordinal = s->ordinal;
} else
newsc->ordinal = 0;
@@ -877,8 +884,8 @@ static void check_vitals_mapped(void)
for (v = 0; v < VITALS; v++) {
for (f = allfuncs; f != NULL; f = f->next) {
if (f->scfunc == vitals[v] && f->menus & inmenus[v]) {
const sc *s = first_sc_for(inmenus[v], f->scfunc);
if (f->func == vitals[v] && f->menus & inmenus[v]) {
const sc *s = first_sc_for(inmenus[v], f->func);
if (!s) {
fprintf(stderr, _("Fatal error: no keys mapped for function "
"\"%s\". Exiting.\n"), f->desc);
@@ -1085,6 +1092,8 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
color_combo[SELECTED_TEXT] = parse_interface_color(option);
else if (strcasecmp(rcopts[i].name, "statuscolor") == 0)
color_combo[STATUS_BAR] = parse_interface_color(option);
else if (strcasecmp(rcopts[i].name, "errorcolor") == 0)
color_combo[ERROR_MESSAGE] = parse_interface_color(option);
else if (strcasecmp(rcopts[i].name, "keycolor") == 0)
color_combo[KEY_COMBO] = parse_interface_color(option);
else if (strcasecmp(rcopts[i].name, "functioncolor") == 0)

View File

@@ -89,113 +89,106 @@ void search_replace_abort(void)
regexp_cleanup();
}
/* Set up the system variables for a search or replace. If use_answer
* is TRUE, only set backupstring to answer. Return -2 to run the
* opposite program (search -> replace, replace -> search), return -1 if
* the search should be canceled (due to Cancel, a blank search string,
* Go to Line, or a failed regcomp()), return 0 on success, and return 1
* on rerun calling program.
*
* replacing is TRUE if we call from do_replace(), and FALSE if called
* from do_search(). */
int search_init(bool replacing, bool use_answer)
/* Prepare the prompt and ask the user what to search for. Keep looping
* as long as the user presses a toggle, and only take action and exit
* when <Enter> is pressed or a non-toggle shortcut was executed. */
void search_init(bool replacing, bool keep_the_answer)
{
int i = 0;
char *buf;
static char *backupstring = NULL;
/* The search string we'll be using. */
functionptrtype func;
char *thedefault;
/* What will be searched for when the user typed nothing. */
/* If use_answer is TRUE, set backupstring to answer and get out. */
if (use_answer) {
backupstring = mallocstrcpy(backupstring, answer);
return 0;
}
/* We display the search prompt below. If the user types a partial
* search string and then Replace or a toggle, we will return to
* do_search() or do_replace() and be called again. In that case,
* we should put the same search string back up. */
/* When starting a new search, clear the current answer. */
if (!keep_the_answer)
answer = mallocstrcpy(answer, NULL);
/* If something was searched for earlier, include it in the prompt. */
if (*last_search != '\0') {
char *disp = display_string(last_search, 0, COLS / 3, FALSE);
buf = charalloc(strlen(disp) + 7);
thedefault = charalloc(strlen(disp) + 7);
/* We use (COLS / 3) here because we need to see more on the line. */
sprintf(buf, " [%s%s]", disp,
sprintf(thedefault, " [%s%s]", disp,
(strlenpt(last_search) > COLS / 3) ? "..." : "");
free(disp);
} else
buf = mallocstrcpy(NULL, "");
thedefault = mallocstrcpy(NULL, "");
/* This is now one simple call. It just does a lot. */
i = do_prompt(FALSE, FALSE,
inhelp ? MFINDINHELP : (replacing ? MREPLACE : MWHEREIS),
backupstring, &search_history,
/* TRANSLATORS: This is the main search prompt. */
edit_refresh, "%s%s%s%s%s%s", _("Search"),
/* TRANSLATORS: The next three modify the search prompt. */
ISSET(CASE_SENSITIVE) ? _(" [Case Sensitive]") : "",
ISSET(USE_REGEXP) ? _(" [Regexp]") : "",
ISSET(BACKWARDS_SEARCH) ? _(" [Backwards]") : "", replacing ?
while (TRUE) {
functionptrtype func;
/* Ask the user what to search for (or replace). */
int i = do_prompt(FALSE, FALSE,
inhelp ? MFINDINHELP : (replacing ? MREPLACE : MWHEREIS),
answer, &search_history,
/* TRANSLATORS: This is the main search prompt. */
edit_refresh, "%s%s%s%s%s%s", _("Search"),
/* TRANSLATORS: The next three modify the search prompt. */
ISSET(CASE_SENSITIVE) ? _(" [Case Sensitive]") : "",
ISSET(USE_REGEXP) ? _(" [Regexp]") : "",
ISSET(BACKWARDS_SEARCH) ? _(" [Backwards]") : "", replacing ?
#ifndef NANO_TINY
/* TRANSLATORS: The next two modify the search prompt. */
openfile->mark ? _(" (to replace) in selection") :
/* TRANSLATORS: The next two modify the search prompt. */
openfile->mark ? _(" (to replace) in selection") :
#endif
_(" (to replace)") : "", buf);
_(" (to replace)") : "", thedefault);
/* Release buf now that we don't need it anymore. */
free(buf);
free(backupstring);
backupstring = NULL;
/* If the search was cancelled, or we have a blank answer and
* nothing was searched for yet during this session, get out. */
if (i == -1 || (i == -2 && *last_search == '\0')) {
statusbar(_("Cancelled"));
return -1;
}
/* If Enter was pressed, see what we got. */
if (i == 0 || i == -2) {
/* If an answer was given, remember it. */
if (*answer != '\0') {
last_search = mallocstrcpy(last_search, answer);
#ifdef ENABLE_HISTORIES
update_history(&search_history, answer);
#endif
/* If the search was cancelled, or we have a blank answer and
* nothing was searched for yet during this session, get out. */
if (i == -1 || (i == -2 && *last_search == '\0')) {
statusbar(_("Cancelled"));
search_replace_abort();
free(thedefault);
return;
}
/* If Enter was pressed, prepare to do a replace or a search. */
if (i == 0 || i == -2) {
/* If an actual answer was typed, remember it. */
if (*answer != '\0') {
last_search = mallocstrcpy(last_search, answer);
#ifdef ENABLE_HISTORIES
update_history(&search_history, answer);
#endif
}
free(thedefault);
/* If doing a regular-expression search, compile the
* search string, and get out when it's invalid. */
if (ISSET(USE_REGEXP) && !regexp_init(last_search)) {
search_replace_abort();
return;
}
if (replacing)
ask_for_replacement();
else
go_looking();
search_replace_abort();
return;
}
func = func_from_key(&i);
/* If we're here, one of the five toggles was pressed, or
* a shortcut was executed. */
if (func == case_sens_void) {
TOGGLE(CASE_SENSITIVE);
} else if (func == backwards_void) {
TOGGLE(BACKWARDS_SEARCH);
} else if (func == regexp_void) {
TOGGLE(USE_REGEXP);
} else if (func == flip_replace) {
replacing = !replacing;
} else {
if (func == flip_goto)
do_gotolinecolumn(openfile->current->lineno,
openfile->placewewant + 1, TRUE, TRUE);
search_replace_abort();
free(thedefault);
return;
}
if (ISSET(USE_REGEXP) && !regexp_init(last_search))
return -1;
else
return 0; /* We have a valid string or regex. */
}
func = func_from_key(&i);
if (func == case_sens_void) {
TOGGLE(CASE_SENSITIVE);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
} else if (func == backwards_void) {
TOGGLE(BACKWARDS_SEARCH);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
} else if (func == regexp_void) {
TOGGLE(USE_REGEXP);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
} else if (func == flip_replace) {
backupstring = mallocstrcpy(backupstring, answer);
return -2; /* Call the opposite search function. */
} else if (func == do_gotolinecolumn_void) {
do_gotolinecolumn(openfile->current->lineno,
openfile->placewewant + 1, TRUE, TRUE);
return 3;
}
return -1;
}
/* Look for needle, starting at (current, current_x). begin is the line
@@ -353,17 +346,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
/* Ask what to search for and then go looking for it. */
void do_search(void)
{
int i = search_init(FALSE, FALSE);
if (i == -1) /* Cancelled, or some other exit reason. */
search_replace_abort();
else if (i == -2) /* Do a replace instead. */
do_replace();
else if (i == 1) /* Toggled something. */
do_search();
if (i == 0)
go_looking();
search_init(FALSE, FALSE);
}
/* Search forward for a string. */
@@ -418,6 +401,8 @@ void do_research(void)
currmenu = MWHEREIS;
go_looking();
search_replace_abort();
}
/* Search for the global string 'last_search'. Inform the user when
@@ -448,7 +433,6 @@ void go_looking(void)
#endif
edit_redraw(was_current, CENTERING);
search_replace_abort();
}
/* Calculate the size of the replacement text, taking possible
@@ -715,30 +699,20 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
/* Replace a string. */
void do_replace(void)
{
if (ISSET(VIEW_MODE))
print_view_warning();
else
search_init(TRUE, FALSE);
}
/* Ask the user what the already given search string should be replaced with. */
void ask_for_replacement(void)
{
filestruct *edittop_save, *begin;
size_t firstcolumn_save, begin_x;
ssize_t numreplaced;
int i;
if (ISSET(VIEW_MODE)) {
print_view_warning();
return;
}
i = search_init(TRUE, FALSE);
if (i == -1) /* Cancelled, or some other exit reason. */
search_replace_abort();
else if (i == -2) /* Do a search instead. */
do_search();
else if (i == 1) /* Toggled something. */
do_replace();
if (i != 0)
return;
i = do_prompt(FALSE, FALSE, MREPLACEWITH, NULL, &replace_history,
int i = do_prompt(FALSE, FALSE, MREPLACEWITH, NULL, &replace_history,
/* TRANSLATORS: This is a prompt. */
edit_refresh, _("Replace with"));
@@ -752,7 +726,6 @@ void do_replace(void)
if (i == -1 || i > 0) {
if (i == -1)
statusbar(_("Cancelled"));
search_replace_abort();
return;
}
@@ -774,8 +747,6 @@ void do_replace(void)
if (numreplaced >= 0)
statusline(HUSH, P_("Replaced %zd occurrence",
"Replaced %zd occurrences", numreplaced), numreplaced);
search_replace_abort();
}
/* Go to the specified line and x position. */
@@ -798,8 +769,6 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
bool interactive)
{
if (interactive) {
functionptrtype func;
/* Ask for the line and column. */
int i = do_prompt(FALSE, FALSE, MGOTOLINE,
use_answer ? answer : NULL, NULL,
@@ -812,12 +781,10 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
return;
}
func = func_from_key(&i);
if (func == gototext_void) {
if (func_from_key(&i) == flip_goto) {
/* Retain what the user typed so far and switch to searching. */
search_init(TRUE, TRUE);
do_search();
search_init(FALSE, TRUE);
return;
}
/* If a function was executed, we're done here. */

View File

@@ -678,7 +678,7 @@ void redo_cut(undo *u)
void do_undo(void)
{
undo *u = openfile->current_undo;
filestruct *f, *t = NULL;
filestruct *f = NULL, *t = NULL;
filestruct *oldcutbuffer, *oldcutbottom;
char *data, *undidmsg = NULL;
size_t from_x, to_x;
@@ -688,13 +688,14 @@ void do_undo(void)
return;
}
f = fsfromline(u->mark_begin_lineno);
if (!f)
return;
if (u->type <= REPLACE) {
f = fsfromline(u->mark_begin_lineno);
if (f == NULL)
return;
}
#ifdef DEBUG
fprintf(stderr, " >> Undoing a type %d...\n", u->type);
fprintf(stderr, " >> Data we're about to undo = \"%s\"\n", f->data);
#endif
openfile->current_x = u->begin;
@@ -712,6 +713,21 @@ void do_undo(void)
f->data = data;
goto_line_posx(u->lineno, u->begin);
break;
case ENTER:
if (f->next == NULL) {
statusline(ALERT, "Missing break line -- please report a bug");
break;
}
undidmsg = _("line break");
from_x = (u->begin == 0) ? 0 : u->mark_begin_x;
to_x = (u->begin == 0) ? u->mark_begin_x : u->begin;
f->data = charealloc(f->data, strlen(f->data) +
strlen(&u->strdata[from_x]) + 1);
strcat(f->data, &u->strdata[from_x]);
unlink_node(f->next);
renumber(f);
goto_line_posx(u->lineno, to_x);
break;
case BACK:
case DEL:
undidmsg = _("text delete");
@@ -723,19 +739,6 @@ void do_undo(void)
f->data = data;
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
break;
#ifdef ENABLE_WRAPPING
case SPLIT_END:
goto_line_posx(u->lineno, u->begin);
openfile->current_undo = openfile->current_undo->next;
openfile->last_action = OTHER;
while (openfile->current_undo->type != SPLIT_BEGIN)
do_undo();
u = openfile->current_undo;
f = openfile->current;
case SPLIT_BEGIN:
undidmsg = _("text add");
break;
#endif
case JOIN:
undidmsg = _("line join");
/* When the join was done by a Backspace at the tail of the file,
@@ -752,32 +755,52 @@ void do_undo(void)
free(f->data);
f->data = data;
splice_node(f, t);
renumber(t);
goto_line_posx(u->lineno, u->begin);
break;
case REPLACE:
undidmsg = _("text replace");
goto_line_posx(u->lineno, u->begin);
data = u->strdata;
u->strdata = f->data;
f->data = data;
break;
#ifdef ENABLE_WRAPPING
case SPLIT_END:
goto_line_posx(u->lineno, u->begin);
openfile->current_undo = openfile->current_undo->next;
openfile->last_action = OTHER;
while (openfile->current_undo->type != SPLIT_BEGIN)
do_undo();
u = openfile->current_undo;
case SPLIT_BEGIN:
undidmsg = _("text add");
break;
#endif
case CUT_TO_EOF:
case CUT:
undidmsg = _("text cut");
undo_cut(u);
f = fsfromline(u->lineno);
break;
case PASTE:
undidmsg = _("text uncut");
undo_paste(u);
f = fsfromline(u->mark_begin_lineno);
break;
case ENTER:
if (f->next == NULL) {
statusline(ALERT, "Missing break line -- please report a bug");
break;
}
undidmsg = _("line break");
from_x = (u->begin == 0) ? 0 : u->mark_begin_x;
to_x = (u->begin == 0) ? u->mark_begin_x : u->begin;
f->data = charealloc(f->data, strlen(f->data) +
strlen(&u->strdata[from_x]) + 1);
strcat(f->data, &u->strdata[from_x]);
unlink_node(f->next);
goto_line_posx(u->lineno, to_x);
case INSERT:
undidmsg = _("text insert");
oldcutbuffer = cutbuffer;
oldcutbottom = cutbottom;
cutbuffer = NULL;
cutbottom = NULL;
openfile->mark = fsfromline(u->mark_begin_lineno);
openfile->mark_x = u->mark_begin_x;
goto_line_posx(u->lineno, u->begin);
cut_marked(NULL);
free_filestruct(u->cutbuffer);
u->cutbuffer = cutbuffer;
u->cutbottom = cutbottom;
cutbuffer = oldcutbuffer;
cutbottom = oldcutbottom;
break;
case INDENT:
handle_indent_action(u, TRUE, TRUE);
@@ -797,29 +820,6 @@ void do_undo(void)
undidmsg = _("uncomment");
break;
#endif
case INSERT:
undidmsg = _("text insert");
oldcutbuffer = cutbuffer;
oldcutbottom = cutbottom;
cutbuffer = NULL;
cutbottom = NULL;
openfile->mark = fsfromline(u->mark_begin_lineno);
openfile->mark_x = u->mark_begin_x;
goto_line_posx(u->lineno, u->begin);
cut_marked(NULL);
free_filestruct(u->cutbuffer);
u->cutbuffer = cutbuffer;
u->cutbottom = cutbottom;
cutbuffer = oldcutbuffer;
cutbottom = oldcutbottom;
break;
case REPLACE:
undidmsg = _("text replace");
goto_line_posx(u->lineno, u->begin);
data = u->strdata;
u->strdata = f->data;
f->data = data;
break;
default:
statusline(ALERT, "Wrong undo type -- please report a bug");
break;
@@ -828,8 +828,6 @@ void do_undo(void)
if (undidmsg && !pletion_line)
statusline(HUSH, _("Undid action (%s)"), undidmsg);
renumber(f);
openfile->current_undo = openfile->current_undo->next;
openfile->last_action = OTHER;
openfile->mark = NULL;
@@ -848,7 +846,7 @@ void do_undo(void)
/* Redo the last thing(s) we undid. */
void do_redo(void)
{
filestruct *f, *shoveline;
filestruct *f = NULL, *shoveline;
char *data, *redidmsg = NULL;
undo *u = openfile->undotop;
@@ -866,13 +864,14 @@ void do_redo(void)
return;
}
f = fsfromline(u->mark_begin_lineno);
if (!f)
return;
if (u->type <= REPLACE) {
f = fsfromline(u->mark_begin_lineno);
if (f == NULL)
return;
}
#ifdef DEBUG
fprintf(stderr, " >> Redo running for type %d\n", u->type);
fprintf(stderr, " >> Data we're about to redo = \"%s\"\n", f->data);
fprintf(stderr, " >> Redoing a type %d...\n", u->type);
#endif
switch (u->type) {
@@ -888,16 +887,6 @@ void do_redo(void)
f->data = data;
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
break;
case BACK:
case DEL:
redidmsg = _("text delete");
data = charalloc(strlen(f->data) + strlen(u->strdata) + 1);
strncpy(data, f->data, u->begin);
strcpy(&data[u->begin], &f->data[u->begin + strlen(u->strdata)]);
free(f->data);
f->data = data;
goto_line_posx(u->lineno, u->begin);
break;
case ENTER:
redidmsg = _("line break");
shoveline = make_new_node(f);
@@ -910,19 +899,16 @@ void do_redo(void)
renumber(shoveline);
goto_line_posx(u->lineno + 1, u->mark_begin_x);
break;
#ifdef ENABLE_WRAPPING
case SPLIT_BEGIN:
case BACK:
case DEL:
redidmsg = _("text delete");
data = charalloc(strlen(f->data) + strlen(u->strdata) + 1);
strncpy(data, f->data, u->begin);
strcpy(&data[u->begin], &f->data[u->begin + strlen(u->strdata)]);
free(f->data);
f->data = data;
goto_line_posx(u->lineno, u->begin);
openfile->current_undo = u;
openfile->last_action = OTHER;
while (openfile->current_undo->type != SPLIT_END)
do_redo();
u = openfile->current_undo;
goto_line_posx(u->lineno, u->begin);
case SPLIT_END:
redidmsg = _("text add");
break;
#endif
case JOIN:
if (f->next == NULL) {
statusline(ALERT, "Missing join line -- please report a bug");
@@ -942,6 +928,26 @@ void do_redo(void)
renumber(f);
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
break;
case REPLACE:
redidmsg = _("text replace");
data = u->strdata;
u->strdata = f->data;
f->data = data;
goto_line_posx(u->lineno, u->begin);
break;
#ifdef ENABLE_WRAPPING
case SPLIT_BEGIN:
goto_line_posx(u->lineno, u->begin);
openfile->current_undo = u;
openfile->last_action = OTHER;
while (openfile->current_undo->type != SPLIT_END)
do_redo();
u = openfile->current_undo;
goto_line_posx(u->lineno, u->begin);
case SPLIT_END:
redidmsg = _("text add");
break;
#endif
case CUT_TO_EOF:
case CUT:
redidmsg = _("text cut");
@@ -951,13 +957,6 @@ void do_redo(void)
redidmsg = _("text uncut");
redo_paste(u);
break;
case REPLACE:
redidmsg = _("text replace");
data = u->strdata;
u->strdata = f->data;
f->data = data;
goto_line_posx(u->lineno, u->begin);
break;
case INSERT:
redidmsg = _("text insert");
goto_line_posx(u->lineno, u->begin);
@@ -1070,6 +1069,7 @@ void do_enter(void)
#endif
refresh_needed = TRUE;
focusing = FALSE;
}
#ifndef NANO_TINY
@@ -1216,7 +1216,7 @@ void add_undo(undo_type action)
discard_until(u, openfile, TRUE);
#ifdef DEBUG
fprintf(stderr, " >> Adding an undo...\n");
fprintf(stderr, " >> Adding an undo... action = %d\n", action);
#endif
/* Allocate and initialize a new undo type. */
@@ -1256,6 +1256,8 @@ void add_undo(undo_type action)
u->xflags = WAS_FINAL_LINE;
u->wassize--;
break;
case ENTER:
break;
case BACK:
/* If the next line is the magic line, don't ever undo this
* backspace, as it won't actually have deleted anything. */
@@ -1284,6 +1286,9 @@ void add_undo(undo_type action)
}
action = u->type = JOIN;
break;
case REPLACE:
u->strdata = mallocstrcpy(NULL, openfile->current->data);
break;
#ifdef ENABLE_WRAPPING
case SPLIT_BEGIN:
action = openfile->undotop->type;
@@ -1291,11 +1296,6 @@ void add_undo(undo_type action)
case SPLIT_END:
break;
#endif
case INSERT:
break;
case REPLACE:
u->strdata = mallocstrcpy(NULL, openfile->current->data);
break;
case CUT_TO_EOF:
cutbuffer_reset();
break;
@@ -1315,7 +1315,7 @@ void add_undo(undo_type action)
u->cutbuffer = copy_filestruct(cutbuffer);
u->lineno += cutbottom->lineno - cutbuffer->lineno;
break;
case ENTER:
case INSERT:
break;
case INDENT:
case UNINDENT:
@@ -1368,25 +1368,19 @@ void update_multiline_undo(ssize_t lineno, char *indentation)
u->newsize = openfile->totsize;
}
/* Update an undo item, or determine whether a new one is really needed
* and bounce the data to add_undo instead. The latter functionality
* just feels gimmicky and may just be more hassle than it's worth,
* so it should be axed if needed. */
/* Update an undo record, after checking that a new one is not needed. */
void update_undo(undo_type action)
{
undo *u;
undo *u = openfile->undotop;
char *char_buf;
int char_len;
#ifdef DEBUG
fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openfile->current->lineno = %ld",
action, openfile->last_action, (long)openfile->current->lineno);
if (openfile->current_undo)
fprintf(stderr, ", openfile->current_undo->lineno = %ld\n", (long)openfile->current_undo->lineno);
else
fprintf(stderr, "\n");
fprintf(stderr, " >> Updating an undo... action = %d\n", action);
#endif
/* Change to an add if we're not using the same undo struct
* that we should be using. */
/* If the action is different or the position changed, don't update the
* current record but add a new one instead. */
if (action != openfile->last_action ||
(action != ENTER && action != CUT && action != INSERT &&
openfile->current->lineno != openfile->current_undo->lineno)) {
@@ -1394,30 +1388,27 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
return;
}
u = openfile->undotop;
u->newsize = openfile->totsize;
switch (u->type) {
case ADD: {
#ifdef DEBUG
fprintf(stderr, " >> openfile->current->data = \"%s\", current_x = %lu, u->begin = %lu\n",
openfile->current->data, (unsigned long)openfile->current_x, (unsigned long)u->begin);
#endif
char *char_buf = charalloc(MAXCHARLEN);
int char_len = parse_mbchar(&openfile->current->data[u->mark_begin_x], char_buf, NULL);
u->strdata = addstrings(u->strdata, u->strdata ? strlen(u->strdata) : 0, char_buf, char_len);
#ifdef DEBUG
fprintf(stderr, " >> current undo data is \"%s\"\n", u->strdata);
#endif
case ADD:
char_buf = charalloc(MAXCHARLEN);
char_len = parse_mbchar(&openfile->current->data[u->mark_begin_x],
char_buf, NULL);
u->strdata = addstrings(u->strdata, u->strdata ? strlen(u->strdata) : 0,
char_buf, char_len);
u->mark_begin_lineno = openfile->current->lineno;
u->mark_begin_x = openfile->current_x;
break;
}
case ENTER:
u->strdata = mallocstrcpy(NULL, openfile->current->data);
u->mark_begin_x = openfile->current_x;
break;
case BACK:
case DEL: {
char *char_buf = charalloc(MAXCHARLEN);
int char_len = parse_mbchar(&openfile->current->data[openfile->current_x], char_buf, NULL);
case DEL:
char_buf = charalloc(MAXCHARLEN);
char_len = parse_mbchar(&openfile->current->data[openfile->current_x],
char_buf, NULL);
if (openfile->current_x == u->begin) {
/* They deleted more: add removed character after earlier stuff. */
u->strdata = addstrings(u->strdata, strlen(u->strdata), char_buf, char_len);
@@ -1432,11 +1423,19 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
add_undo(u->type);
return;
}
#ifdef DEBUG
fprintf(stderr, " >> current undo data is \"%s\"\nu->begin = %lu\n", u->strdata, (unsigned long)u->begin);
#endif
break;
}
case JOIN:
break;
case REPLACE:
case PASTE:
u->begin = openfile->current_x;
u->lineno = openfile->current->lineno;
break;
#ifdef ENABLE_WRAPPING
case SPLIT_BEGIN:
case SPLIT_END:
break;
#endif
case CUT_TO_EOF:
case CUT:
if (!cutbuffer)
@@ -1474,34 +1473,14 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
u->begin = strlen(u->cutbottom->data);
}
break;
case REPLACE:
case PASTE:
u->begin = openfile->current_x;
u->lineno = openfile->current->lineno;
break;
case INSERT:
u->mark_begin_lineno = openfile->current->lineno;
u->mark_begin_x = openfile->current_x;
break;
case ENTER:
u->strdata = mallocstrcpy(NULL, openfile->current->data);
u->mark_begin_x = openfile->current_x;
break;
#ifdef ENABLE_WRAPPING
case SPLIT_BEGIN:
case SPLIT_END:
#endif
case JOIN:
/* These cases are handled by the earlier check for a new line and action. */
break;
default:
statusline(ALERT, "Wrong undo update type -- please report a bug");
break;
}
#ifdef DEBUG
fprintf(stderr, " >> Done in update_undo (type was %d)\n", action);
#endif
}
#endif /* !NANO_TINY */
@@ -2435,23 +2414,24 @@ void do_justify(bool full_justify)
uncutfunc->desc = unjust_tag;
display_main_list();
/* Now get a keystroke and see if it's unjustify. If not, put back
* the keystroke and return. */
#ifndef NANO_TINY
do {
kbinput = KEY_WINCH;
/* Now wait for the next keystroke. */
while (kbinput == KEY_WINCH)
#endif
{
statusbar(_("Can now UnJustify!"));
place_the_cursor();
kbinput = do_input(FALSE);
#ifndef NANO_TINY
} while (kbinput == KEY_WINCH);
#endif
}
/* Unset the suppression flag after showing the Unjustify message. */
suppress_cursorpos = FALSE;
func = func_from_key(&kbinput);
/* If the keystroke was Unjustify or Undo, then undo the justification. */
if (func == do_uncut_text
#ifndef NANO_TINY
|| func == do_undo

View File

@@ -48,7 +48,7 @@ void get_homedir(void)
/* Only set homedir if some home directory could be determined,
* otherwise keep homedir NULL. */
if (homenv != NULL && strcmp(homenv, "") != 0)
if (homenv != NULL && *homenv != '\0')
homedir = mallocstrcpy(NULL, homenv);
}
}
@@ -378,10 +378,11 @@ char *mallocstrncpy(char *dest, const char *src, size_t n)
if (src == NULL)
src = "";
if (src != dest)
free(dest);
dest = charalloc(n);
#ifndef NANO_TINY
if (src == dest)
fprintf(stderr, "\r*** Copying a string to itself -- please report a bug ***");
#endif
dest = charealloc(dest, n);
strncpy(dest, src, n);
return dest;

View File

@@ -286,6 +286,15 @@ void unget_kbinput(int kbinput, bool metakey)
put_back(ESC_CODE);
}
#ifdef ENABLE_NANORC
/* Insert the given string into the keyboard buffer. */
void implant(const char *string)
{
for (int i = strlen(string); i > 0; i--)
put_back(string[i - 1]);
}
#endif
/* Try to read input_len codes from the keystroke buffer. If the
* keystroke buffer is empty and win isn't NULL, try to read in more
* codes from win and add them to the keystroke buffer before doing
@@ -573,7 +582,7 @@ int parse_kbinput(WINDOW *win)
* Shift/Ctrl/Alt are being held together with them. */
unsigned char modifiers = 6;
if (console && ioctl(0, TIOCLINUX, &modifiers) >= 0) {
if (on_a_vt && ioctl(0, TIOCLINUX, &modifiers) >= 0) {
#ifndef NANO_TINY
/* Is Shift being held? */
if (modifiers & 0x01) {
@@ -1660,7 +1669,7 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
for (f = allfuncs; f != NULL; f = f->next) {
if ((f->menus & currmenu) == 0)
continue;
if (first_sc_for(currmenu, f->scfunc) == NULL)
if (first_sc_for(currmenu, f->func) == NULL)
continue;
/* Tick off an actually shown shortcut. */
j -= 1;
@@ -1670,7 +1679,7 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
/* And put the corresponding key into the keyboard buffer. */
if (f != NULL) {
const sc *s = first_sc_for(currmenu, f->scfunc);
const sc *s = first_sc_for(currmenu, f->func);
unget_kbinput(s->keycode, s->meta);
}
return 1;
@@ -2131,6 +2140,7 @@ void statusline(message_type importance, const char *msg, ...)
{
va_list ap;
static int alerts = 0;
int colorpair;
char *compound, *message;
size_t start_col;
bool bracketed;
@@ -2169,7 +2179,9 @@ void statusline(message_type importance, const char *msg, ...)
msg = _("Further warnings were suppressed");
else if (alerts < 4)
beep();
}
colorpair = interface_color_pair[ERROR_MESSAGE];
} else
colorpair = interface_color_pair[STATUS_BAR];
lastmessage = importance;
@@ -2186,14 +2198,14 @@ void statusline(message_type importance, const char *msg, ...)
bracketed = (start_col > 1);
wmove(bottomwin, 0, (bracketed ? start_col - 2 : start_col));
wattron(bottomwin, interface_color_pair[STATUS_BAR]);
wattron(bottomwin, colorpair);
if (bracketed)
waddstr(bottomwin, "[ ");
waddstr(bottomwin, message);
free(message);
if (bracketed)
waddstr(bottomwin, " ]");
wattroff(bottomwin, interface_color_pair[STATUS_BAR]);
wattroff(bottomwin, colorpair);
/* Defeat a VTE/Konsole bug, where the cursor can go off-limits. */
if (ISSET(CONSTANT_SHOW) && ISSET(NO_HELP))
@@ -2252,7 +2264,7 @@ void bottombars(int menu)
if ((f->menus & menu) == 0)
continue;
s = first_sc_for(menu, f->scfunc);
s = first_sc_for(menu, f->func);
if (s == NULL)
continue;

View File

@@ -1,6 +1,6 @@
## Here is an example for assembler.
syntax "asm" "\.(S|s|asm)$"
syntax asm "\.(S|s|asm)$"
magic "assembler source"
comment "//"

View File

@@ -1,6 +1,6 @@
## Here is an example for Autoconf.
syntax "autoconf" "\.(ac|m4)$"
syntax autoconf "\.(ac|m4)$"
comment "#"
# Keywords:

View File

@@ -1,6 +1,6 @@
## Here is an example for awk.
syntax "awk" "\.awk$"
syntax awk "\.awk$"
magic "awk script"
comment "#"

View File

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

View File

@@ -1,6 +1,6 @@
## Colouring for Changelogs.
syntax "changelog" "Change[Ll]og.*"
syntax changelog "Change[Ll]og.*"
# Author lines.
color green "^(19|20).*$"

View File

@@ -1,6 +1,6 @@
## Syntax highlighting for CMake files.
syntax "cmake" "(CMakeLists\.txt|\.cmake)$"
syntax cmake "(CMakeLists\.txt|\.cmake)$"
comment "#"
icolor green "^[[:space:]]*[A-Z0-9_]+"

View File

@@ -1,6 +1,6 @@
## Here is an example for CSS files.
syntax "css" "\.css$"
syntax css "\.css$"
comment "/*|*/"
color brightred "."

View File

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

View File

@@ -1,7 +1,7 @@
## An example of a default syntax. The default syntax is used for
## files that do not match any other syntax.
syntax "default"
syntax default
comment "#"
# Comments.

View File

@@ -1,6 +1,6 @@
## Here is an example for Emacs Lisp.
syntax "elisp" "\.el$"
syntax elisp "\.el$"
magic "Lisp/Scheme program"
comment ";"

View File

@@ -1,6 +1,6 @@
## Here is an example for Fortran 90/95.
syntax "fortran" "\.(f|f90|f95)$"
syntax fortran "\.(f|f90|f95)$"
comment "!"
color red "\<[0-9]+\>"

View File

@@ -1,7 +1,7 @@
## Here is an example for Gentoo ebuilds/eclasses,
## and (further down) one for Portage control files.
syntax "ebuild" "\.e(build|class|blit)$"
syntax ebuild "\.e(build|class|blit)$"
comment "#"
## All the standard portage functions:
@@ -48,7 +48,7 @@ color ,green "[[:space:]]+$"
color ,green " "
syntax "/etc/portage" "\.(accept_keywords|env|keywords|mask|unmask|use)(/.+)?$"
syntax /etc/portage "\.(accept_keywords|env|keywords|mask|unmask|use)(/.+)?$"
comment "#"
## Base text:

View File

@@ -1,6 +1,6 @@
## Here is an example for Go.
syntax "go" "\.go$"
syntax go "\.go$"
comment "//"
# Set up a formatter since spelling is probably useless...
@@ -24,9 +24,11 @@ color brightcyan "\<(package|import)\>"
color brightcyan "//[[:space:]]*\+build[[:space:]]+(([a-zA-Z_0-9]+[[:space:]]*)+,[[:space:]]*)*[a-zA-Z_0-9]+"
# Literals.
color red "\<0([0-7]*|[xX][0-9a-fA-F]+)\>"
color red "(\<0+|\B)\.[0-9]+([Ee][+-]?[0-9]+)?i?\>"
color red "\<[1-9][0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?i?\>"
color red "\<([1-9][0-9]*|0[0-7]*|0[xX][0-9A-Fa-f]+)\>"
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|_)\>"

View File

@@ -1,6 +1,6 @@
## Here is an example for groff.
syntax "groff" "\.m[ems]$" "\.rof" "\.tmac$" "^tmac."
syntax groff "\.m[ems]$" "\.rof" "\.tmac$" "^tmac."
comment ".\""
# The argument of .ds or .nr

View File

@@ -1,6 +1,6 @@
## Here is an example for Guile Scheme.
syntax "guile" "\.scm$"
syntax guile "\.scm$"
header "^#!.*guile"
comment ";"

View File

@@ -1,6 +1,6 @@
## Here is an example for HTML.
syntax "html" "\.html?$"
syntax html "\.html?$"
magic "HTML document"
comment "<!--|-->"

View File

@@ -1,6 +1,6 @@
## Here is an example for Java.
syntax "java" "\.java$"
syntax java "\.java$"
magic "Java "
comment "//"

View File

@@ -1,6 +1,6 @@
## Syntax highlighting for Javascript.
syntax "javascript" "\.js$"
syntax javascript "\.js$"
comment "//"
# Declarational stuff.

View File

@@ -4,7 +4,7 @@
# Original author: Aapo Rantalainen
# License: GPLv3 or newer
syntax "json" "\.json$"
syntax json "\.json$"
# No comments are permitted in JSON.
comment ""

View File

@@ -3,7 +3,7 @@
## Original author: Matthew Wild <mwild1 (at) gmail.com>
## License: GPL 3 or later
syntax "lua" "\.lua$"
syntax lua "\.lua$"
magic "Lua script"
comment "--"

View File

@@ -1,6 +1,6 @@
## Here is an example for Makefiles.
syntax "makefile" "Makefile[^/]*$" "\.(make|mk)$"
syntax makefile "Makefile[^/]*$" "\.(make|mk)$"
magic "makefile script"
comment "#"

View File

@@ -1,6 +1,6 @@
## Here is an example for manpages.
syntax "man" "\.[1-9]x?$"
syntax man "\.[1-9]x?$"
magic "troff or preprocessor input"
comment ".\""

View File

@@ -1,6 +1,6 @@
## Here is an example for Magicpoint presentations.
syntax "mgp" "\.mgp$"
syntax mgp "\.mgp$"
header "^%include.*"
comment "#"

View File

@@ -1,6 +1,6 @@
## Here is an example for quoted emails (under e.g. mutt).
syntax "mutt"
syntax mutt
# Quoted lines.
color green "^>.*"

View File

@@ -1,7 +1,7 @@
## This is meant for highlighting key combos in a nano help text.
# It should not apply to any normal file, so no fileregex.
syntax "nanohelp"
syntax nanohelp
# Key combos:
color cyan "\^[]4-8A-Z^\_◀▶▲▼]" "[◀▶▲▼]" "(\^|M-)Space" "\<M-." "\<F1?[0-9]"

View File

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

View File

@@ -1,6 +1,6 @@
## Here is an example for nftables.
syntax "nftables" "\.(nft|nftables)$"
syntax nftables "\.(nft|nftables)$"
header "^#!.*(nft|nftables)"
comment "#"

View File

@@ -1,6 +1,6 @@
## Here is an example for C/C++/Obj-C.
syntax "m" "\.m$"
syntax m "\.m$"
magic "Objective-C source"
comment "//"

View File

@@ -1,6 +1,6 @@
## Syntax highlighting for OCaml.
syntax "ocaml" "\.mli?$"
syntax ocaml "\.mli?$"
magic "OCaml"
comment "(*|*)"

View File

@@ -1,6 +1,6 @@
## Here is an example for patch files.
syntax "patch" "\.(patch|diff|debdiff)$"
syntax patch "\.(patch|diff|debdiff)$"
magic "diff output"
# There is no official support for comments in patch files.
comment ""

View File

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

View File

@@ -1,6 +1,6 @@
## Here is an example for PHP.
syntax "php" "\.ph(p[23457s~]?|tml)$"
syntax php "\.ph(p[23457s~]?|tml)$"
magic "PHP script"
comment "//"

View File

@@ -1,6 +1,6 @@
## Colouring for PO files.
syntax "po" "\.pot?$"
syntax po "\.pot?$"
comment "#"
# Comments.

View File

@@ -1,6 +1,6 @@
## Here is an example for PostgreSQL.
syntax "sql" "\.sql[2345s~]?$"
syntax sql "\.sql[2345s~]?$"
comment "-- "
# Functions.

View File

@@ -1,6 +1,6 @@
## Here is an example for POV-Ray.
syntax "pov" "\.(pov|POV|povray|POVRAY)$"
syntax pov "\.(pov|POV|povray|POVRAY)$"
comment "//"
color brightcyan "^[[:space:]]*#[[:space:]]*(declare)"

View File

@@ -1,6 +1,6 @@
## Here is an example for Python.
syntax "python" "\.py$"
syntax python "\.py$"
header "^#!.*python[-0-9._]*"
magic "Python script"
linter pyflakes

View File

@@ -1,6 +1,6 @@
## Here is an example for Ruby.
syntax "ruby" "\.rb$"
syntax ruby "\.rb$"
header "^#!.*ruby[-0-9._]*"
magic "Ruby script"
linter ruby -w -c

View File

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

View File

@@ -1,6 +1,6 @@
## Here is an example for Bourne shell scripts.
syntax "sh" "\.sh$"
syntax sh "\.sh$"
header "^#!.*((ba|da|k|pdk)?sh[-0-9_]*|openrc-run|runscript)"
magic "(POSIX|Bourne-Again) shell script.*text"
linter dash -n

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