Compare commits
139 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7853df8b6 | ||
|
|
1e9d12abc5 | ||
|
|
3bce9fb755 | ||
|
|
0a57da42e0 | ||
|
|
73067e0e16 | ||
|
|
b9328d0eac | ||
|
|
0596b875f0 | ||
|
|
b94dcfd34b | ||
|
|
4238564673 | ||
|
|
764ab96bda | ||
|
|
f0cc59bead | ||
|
|
282f438967 | ||
|
|
1b01adfa9f | ||
|
|
87fe73ddaa | ||
|
|
c2746c0bb2 | ||
|
|
399a024857 | ||
|
|
d131c2d438 | ||
|
|
eb0962fb06 | ||
|
|
7bf253702e | ||
|
|
76742cc193 | ||
|
|
37717baeed | ||
|
|
ade2fafbd3 | ||
|
|
53fe7ba26a | ||
|
|
7e04fea92b | ||
|
|
1fdd23d347 | ||
|
|
5ea930e25f | ||
|
|
45defd25f3 | ||
|
|
0d11964503 | ||
|
|
7545eb5bbf | ||
|
|
878bd53d11 | ||
|
|
e0a4ee0148 | ||
|
|
d3fbc4d498 | ||
|
|
a8e2a24f60 | ||
|
|
36855544d1 | ||
|
|
dc745c0b77 | ||
|
|
a8ed1d7a9a | ||
|
|
94c371a38f | ||
|
|
36618f1dca | ||
|
|
3ea2694d9c | ||
|
|
85cc99a2a3 | ||
|
|
befe4ea5de | ||
|
|
43d94692ce | ||
|
|
1364b41dc9 | ||
|
|
7d3a555464 | ||
|
|
0508520b47 | ||
|
|
6cbb7bc443 | ||
|
|
055e262b56 | ||
|
|
9d8388e836 | ||
|
|
895de17a58 | ||
|
|
b202966d30 | ||
|
|
a19a7820f9 | ||
|
|
0122119a44 | ||
|
|
64bf03b0d9 | ||
|
|
4bc6d67052 | ||
|
|
7519a458b2 | ||
|
|
bc36813349 | ||
|
|
9bd7d62c10 | ||
|
|
735a608e80 | ||
|
|
71402bb7e9 | ||
|
|
9266fa6657 | ||
|
|
6360e4170a | ||
|
|
dcb072d04b | ||
|
|
4c6ce3c39d | ||
|
|
41fd09706d | ||
|
|
24e5f956d0 | ||
|
|
f602613a9a | ||
|
|
ba124ffa5d | ||
|
|
d30ddf0add | ||
|
|
e66c7d0f8d | ||
|
|
7b9567719c | ||
|
|
04d33e7981 | ||
|
|
c62d12ca93 | ||
|
|
297633d086 | ||
|
|
10b99d8ac0 | ||
|
|
0693d6974a | ||
|
|
5129e718d7 | ||
|
|
8c406bc875 | ||
|
|
c53da9aa5b | ||
|
|
e7a420eca7 | ||
|
|
1236341746 | ||
|
|
c96c343fac | ||
|
|
02f1fec497 | ||
|
|
a102e45e90 | ||
|
|
86c9b9b54e | ||
|
|
e14127b843 | ||
|
|
67cdd71352 | ||
|
|
6a88fe8807 | ||
|
|
90f6f25e31 | ||
|
|
0f4bb64eaf | ||
|
|
45efe28f05 | ||
|
|
c8c7986f65 | ||
|
|
f437117bf2 | ||
|
|
33e882e6f8 | ||
|
|
bad591d43d | ||
|
|
7b48458380 | ||
|
|
1e16a3f411 | ||
|
|
6a3ba2ab50 | ||
|
|
1878168ae3 | ||
|
|
545709a165 | ||
|
|
ca398fdfdf | ||
|
|
d0bceb1449 | ||
|
|
caef3128eb | ||
|
|
856a6ecde3 | ||
|
|
e353203010 | ||
|
|
f1fc66060f | ||
|
|
ba4f4bdc64 | ||
|
|
2b6c08b955 | ||
|
|
b86f7868d1 | ||
|
|
54995defd2 | ||
|
|
b89bc2cce6 | ||
|
|
8f24ffaaef | ||
|
|
d31cc373de | ||
|
|
f52f503c38 | ||
|
|
8939163659 | ||
|
|
265bdd94f1 | ||
|
|
d1c412d200 | ||
|
|
5c4c30e26b | ||
|
|
1b65d39722 | ||
|
|
96e4fec31c | ||
|
|
208146f2f2 | ||
|
|
89e84e76c3 | ||
|
|
c44a5e960e | ||
|
|
c1bd54dd47 | ||
|
|
3efb9c3a2e | ||
|
|
b87d7f69fc | ||
|
|
8ba653f395 | ||
|
|
c6501beba7 | ||
|
|
dbf522b750 | ||
|
|
651e97ceef | ||
|
|
d8500f0467 | ||
|
|
a9bc118178 | ||
|
|
903942b4f0 | ||
|
|
7ebf5f52b8 | ||
|
|
4f7593b704 | ||
|
|
2157738a18 | ||
|
|
681d11c0cf | ||
|
|
d96f296b8e | ||
|
|
048ab0ee0b | ||
|
|
16dff06a4c |
151
ChangeLog
151
ChangeLog
@@ -1,3 +1,154 @@
|
||||
Changes between v5.5 and v5.6:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (52):
|
||||
build: avoid a warning about duplicate symbol when building from tarball
|
||||
build: detect a build from git also when building out of tree
|
||||
build: include a workaround only for versions of ncurses that need it
|
||||
bump version numbers and add a news item for the 5.6 release
|
||||
color: do not look for another 'end' match after already finding one
|
||||
color: give highlighted text its own color, to not look like marked text
|
||||
color: recompile the file-probing regexes a little faster with REG_NOSUB
|
||||
color: use bright yellow to highlight a search match
|
||||
color: use inverse video for highlighting when there are no colors
|
||||
debug: add timing instruments to cache precalculation and screen refresh
|
||||
display: for a large paste or insertion, recalculate the multiline cache
|
||||
docs: correct the description of --quickblank for the changed base value
|
||||
docs: correct the formatting of a comment in the sample nanorc
|
||||
docs: correct the word order for Alt+D in the cheat sheet -- it changed
|
||||
docs: mention the new 'set highlightcolor' option
|
||||
docs: remove all mentions of --markmatch and 'set markmatch'
|
||||
docs: say that --minibar is modified by --constantshow and --stateflags
|
||||
feedback: make Full Justify show a message also when using --minibar
|
||||
gnulib: update to its current upstream state
|
||||
minibar: show a message a little longer when --quickblank isn't used
|
||||
minibar: show cursor position + character code only with --constantshow
|
||||
minibar: show the state flags only when --stateflags is used
|
||||
minibar: suppress the toggling feedback for M-C, but show it for M-Y/M-P
|
||||
options: remove --markmatch and 'set markmatch', as the behavior is gone
|
||||
painting: always do backtracking for the first row of the screen
|
||||
painting: trigger a refresh when a second start match appears on a line
|
||||
painting: trigger fewer unneeded full-screen refreshes
|
||||
painting: when finding an end match, set its multidata right away
|
||||
scrolling: keep centering after large paste, also when line numbers widen
|
||||
search: just highlight the found occurrence, instead of marking it
|
||||
search: make highlighting the standard, non-changeable behavior
|
||||
tweaks: avoid the vague possibility of advancing beyond end-of-line
|
||||
tweaks: be slightly more efficient in marking lines as WOULDBE
|
||||
tweaks: call wattron()/wattroff() only when actually painting something
|
||||
tweaks: correct a comment, improve another, and trim some verbosity
|
||||
tweaks: don't bother comparing virgin multidata with current situation
|
||||
tweaks: don't bother initializing freshly allocated multidata
|
||||
tweaks: don't bother wiping the multidata before recomputing it
|
||||
tweaks: elide a function that is now just one line
|
||||
tweaks: frob a condition, to be more concise, and reshuffle another
|
||||
tweaks: frob some comments, and adjust indentation after previous change
|
||||
tweaks: frob some comments, and reshuffle two fragments of code
|
||||
tweaks: frob two fragments of code, to be more readable
|
||||
tweaks: make a skipping condition more precise
|
||||
tweaks: remove an old fix that was made superfluous by a recent fix
|
||||
tweaks: remove a strangely placed warning
|
||||
tweaks: rename six symbols, to be more straightforward
|
||||
tweaks: reshuffle some code, and reduce the scope of a variable
|
||||
tweaks: reshuffle three conditions into a better order
|
||||
tweaks: rewrap and reindent a few lines
|
||||
tweaks: rewrap two lines, for esthetics
|
||||
tweaks: stop evaluating a rule when the match is offscreen to the right
|
||||
|
||||
|
||||
Changes between v5.4 and v5.5:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (84):
|
||||
build: fix compilation for --enable-{tiny,help,multibuffer}
|
||||
build: fix compilation when configured with --disable-utf8
|
||||
build: fix compilation when configured with --enable-tiny
|
||||
build: remove the '--with-slang' configure option
|
||||
bump version numbers and add a news item for the 5.5 release
|
||||
chars: short-circuit determining the width of characters under U+0300
|
||||
chars: speed up the handling of invalid UTF-8 starter bytes
|
||||
copyright: update the years for the FSF
|
||||
display: add code for showing minimal state-information bar at the bottom
|
||||
display: do not show the state flags in the help viewer or file browser
|
||||
docs: explain the effect of --minibar / -_ / 'set minibar'
|
||||
docs: explain the purpose of --markmatch / -^ / 'set markmatch'
|
||||
docs: insert links to the mailing-list archives into the README
|
||||
docs: mention in NEWS that some workarounds were removed
|
||||
docs: mention the new 'set promptcolor' option
|
||||
docs: remove all mentions of Slang
|
||||
feedback: differentiate between remarks, mistakes, and information
|
||||
feedback: wipe the status bar by default after 20 keystrokes
|
||||
files: when truncating a file name, give an indication of this
|
||||
general: remove support for Slang
|
||||
gnulib: update to its current upstream state
|
||||
input: intercept ^Z also when --minibar is active
|
||||
input: interpret a keystroke as Meta only when an earlier escape was solo
|
||||
memory: avoid leaking the speller or linter command string, when invoked
|
||||
minibar: add an [x/y] "counter" when multiple files are open
|
||||
minibar: add a percentage that shows how far the cursor is into the file
|
||||
minibar: allow the number-of-lines to overrule also the state flags
|
||||
minibar: allow the number-of-lines to overrule location + character code
|
||||
minibar: drop the side spaces before suppressing the state flags
|
||||
minibar: represent bytes as 0xNN and valid Unicode code points as U+NNNN
|
||||
minibar: show the info bar again some 0.8 seconds after a message
|
||||
minibar: show the line count in the bar (at startup and when saving)
|
||||
minibar: show Unicode codes when in a UTF-8 locale
|
||||
minibar: suppress some elements when there is no room to show them
|
||||
minibar: when the next character has zero width, show its code too
|
||||
minibar: when the overnext character has zero width too, show its code
|
||||
mouse: do not offset the shortcuts by 'margin' when using --linenumbers
|
||||
oops: use the correct condition for checking the last line will change
|
||||
options: accept 'set promptcolor' for setting the color of the prompt bar
|
||||
options: add --markmatch and -^ for activating the select-match behavior
|
||||
options: add --minibar and -_ for activating basic state-information bar
|
||||
prompt: restore a workaround for a cursor misplacement bug in ncurses
|
||||
prompt: suppress the ">" character always when exactly at the right edge
|
||||
rcfile: rename 'nowrap' toggle to 'breaklonglines', to match the option
|
||||
search: set the mark at the end of a found match so it gets highlighted
|
||||
search: suppress the cursor when highlighting a match
|
||||
speller: do an internal spell check when --speller is an empty string
|
||||
speller: strip leading whitespace from command, to avoid a sneaky crash
|
||||
syntax: go: add author and license line
|
||||
syntax: nanorc: colorize 'bookstyle' as a valid option
|
||||
syntax: nanorc: colorize 'set promptcolor' as valid
|
||||
syntax: sh: recognize shebangs with any shell after 'env', not just 'sh'
|
||||
tweaks: adjust the indentation after the previous change
|
||||
tweaks: avoid compilation warnings on 32-bit machine plus newer compiler
|
||||
tweaks: avoid computing the cursor column twice, and the "page" too
|
||||
tweaks: avoid hitting negative values when using size_t
|
||||
tweaks: change an intermediate variable to a better one
|
||||
tweaks: clean up after the previous change
|
||||
tweaks: condense the description of how to report a bug
|
||||
tweaks: correct a translator hint
|
||||
tweaks: correct two comments after the previous changes
|
||||
tweaks: do not change the pointer, but move the content of the string
|
||||
tweaks: drop a small optimization for invalid UTF-8 starter bytes
|
||||
tweaks: elide a variable, by using a reallocation instead
|
||||
tweaks: fold some conditions into bitwise masks, for efficiency
|
||||
tweaks: fold two similar and three identical cases together
|
||||
tweaks: move 'set indicator' to its alphabetical place in the manual
|
||||
tweaks: move the displaying of the state letters into a separate function
|
||||
tweaks: push back the deprecation of the 'set nowrap' option
|
||||
tweaks: put the new options in a consistent order in the code
|
||||
tweaks: reduce the scope of a static variable
|
||||
tweaks: remove some #ifdefs that were there only for Slang
|
||||
tweaks: rename a variable, to be similar to its sister
|
||||
tweaks: reshuffle a condition, to probably avoid an unneeded calculation
|
||||
tweaks: reshuffle an option, to have two related ones grouped together
|
||||
tweaks: reshuffle some lines, to group things better
|
||||
tweaks: reshuffle some lines, to have most #includes near the beginning
|
||||
tweaks: reshuffle some more lines, to have most #defines together
|
||||
tweaks: reshuffle two lines, and rename a variable to a plain word
|
||||
tweaks: reword the description of an option
|
||||
tweaks: simplify a bit of logic
|
||||
tweaks: use a boolean instead of an enumeration of two values
|
||||
undo: remove the added magic line when a replacement caused one
|
||||
weeding: remove some obsolete information from the README
|
||||
|
||||
OIX (1):
|
||||
mouse: update title bar (the M flag) when the click is on the cursor
|
||||
|
||||
|
||||
Changes between v5.3 and v5.4:
|
||||
------------------------------
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ Improvements in GNU nano
|
||||
========================
|
||||
|
||||
Since 5.0:
|
||||
- A search highlights the found text, in black on yellow by default.
|
||||
- Option --minibar reduces the interface to a bottom bar with basic info.
|
||||
- The cursor skips over combining characters, <Del> deletes them together
|
||||
with the character they combine with, but <Bsp> deletes them separately.
|
||||
- For using libmagic the option --magic or -! or 'set magic' is required.
|
||||
|
||||
32
NEWS
32
NEWS
@@ -1,8 +1,40 @@
|
||||
2021.02.24 - GNU nano 5.6 "Wielewaal"
|
||||
• A search match gets highlighted (in black on yellow by default),
|
||||
in addition to placing the cursor at the start of the match.
|
||||
The color combination can be changed with 'set highlightcolor'.
|
||||
By default the cursor is hidden until the next keystroke, but
|
||||
it can be forced on with --showcursor / 'set showcursor'.
|
||||
• Option --markmatch / 'set markmatch' has been removed.
|
||||
• Cursor position and character code are displayed in the minibar
|
||||
only when option --constantshow / 'set constantshow' is used,
|
||||
and their display can be toggled with M-C.
|
||||
• The state flags are displayed in the minibar only when option
|
||||
--stateflags / 'set stateflags' is used.
|
||||
|
||||
2021.01.14 - GNU nano 5.5 "Rebecca"
|
||||
• Option 'set minibar' makes nano suppress the title bar and instead
|
||||
show a bar with basic editing information at the bottom: file name
|
||||
(plus an asterisk when the buffer is modified), the cursor position
|
||||
(line,column), the character under the cursor (U+xxxx), the flags
|
||||
that --stateflags normally shows, plus the percentage of the buffer
|
||||
that is above the cursor.
|
||||
• With 'set promptcolor' the color combination of the prompt bar can
|
||||
be changed, to allow contrasting it with the mini bar (which always
|
||||
has the same color as the title bar).
|
||||
• Option 'set markmatch' highlights the result of a successful search
|
||||
by putting the mark at the end of the match, making the match more
|
||||
visible. It also suppresses the cursor until the next keystroke.
|
||||
(If you dislike the hiding of the cursor, use 'set showcursor'.)
|
||||
• The bindable toggle 'nowrap' has been renamed to 'breaklonglines',
|
||||
to match the corresponding option, like for all other toggles.
|
||||
• Support for Slang has been removed.
|
||||
|
||||
2020.12.02 - GNU nano 5.4 "Terre des hommes"
|
||||
• Moving the cursor now skips over combining characters (and other
|
||||
zero-width characters). Deleting a character deletes also any
|
||||
succeeding zero-width characters, but backspacing deletes just
|
||||
one character at a time.
|
||||
• Workarounds for older ncurses and older libvtes were removed.
|
||||
|
||||
2020.10.07 - GNU nano 5.3 "Revolution!"
|
||||
• Option 'set stateflags' makes nano show the state of auto-indenting,
|
||||
|
||||
17
README
17
README
@@ -62,18 +62,15 @@ Mailing Lists
|
||||
To subscribe, send email to <name>-request@gnu.org with a subject
|
||||
of "subscribe", where <name> is the list you want to subscribe to.
|
||||
|
||||
The archives of the development and help mailing lists are here:
|
||||
|
||||
https://lists.gnu.org/archive/html/nano-devel/
|
||||
https://lists.gnu.org/archive/html/help-nano/
|
||||
|
||||
Bug Reports
|
||||
|
||||
To report a bug, please file a description of the problem on nano's
|
||||
bug tracker (https://savannah.gnu.org/bugs/?group=nano -- hover on
|
||||
"Bugs", then click "Submit new"). The issue may have already been
|
||||
reported, so please look first.
|
||||
|
||||
Current Status
|
||||
|
||||
Since version 2.5.0, GNU nano has abandoned the distinction between
|
||||
a stable and a development branch: it is now on a "rolling" release
|
||||
-- fixing bugs and adding new features go hand in hand.
|
||||
If you find a bug, please file a detailed description of the problem
|
||||
on nano's bug tracker: https://savannah.gnu.org/bugs/?group=nano.
|
||||
|
||||
Copyright Years
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Generate configure & friends for GIT users.
|
||||
|
||||
gnulib_url="git://git.sv.gnu.org/gnulib.git"
|
||||
gnulib_hash="387d654cabd7bc1594b1fc8d195cd9b66f820296"
|
||||
gnulib_hash="c9b44f214c7c798c7701c7a281584e262b263655"
|
||||
|
||||
modules="
|
||||
futimens
|
||||
|
||||
201
configure.ac
201
configure.ac
@@ -1,6 +1,6 @@
|
||||
# Configuration for GNU nano - a small and user-friendly text editor
|
||||
#
|
||||
# Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2014, 2017 Mike Frysinger
|
||||
#
|
||||
# GNU nano is free software: you can redistribute it and/or modify
|
||||
@@ -16,7 +16,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
|
||||
AC_INIT([GNU nano], [5.4], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [5.6], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AC_CANONICAL_HOST
|
||||
AM_INIT_AUTOMAKE([1.14])
|
||||
@@ -59,7 +59,7 @@ AC_DEFINE_DIR([PKGDATADIR], [pkgdatadir], [Where data are placed to.])
|
||||
dnl Whether this is a git repository.
|
||||
|
||||
AC_MSG_CHECKING([whether building from git])
|
||||
if test -f roll-a-release.sh ; then
|
||||
if test -f "$srcdir/roll-a-release.sh" ; then
|
||||
AC_MSG_RESULT([yes])
|
||||
from_git=yes
|
||||
else
|
||||
@@ -90,13 +90,6 @@ AC_CHECK_HEADERS(libintl.h limits.h pwd.h termios.h sys/param.h)
|
||||
|
||||
dnl Checks for options.
|
||||
|
||||
if test "x$with_slang" = xyes; then
|
||||
if test "x$enable_tiny" != xyes; then
|
||||
AC_MSG_ERROR([
|
||||
*** --with-slang is supported only together with --enable-tiny])
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(browser,
|
||||
AS_HELP_STRING([--disable-browser], [Disable the built-in file browser]))
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
@@ -354,194 +347,6 @@ AS_HELP_STRING([--enable-altrcname], [Specify an alternate rcfile name (default:
|
||||
AC_DEFINE_UNQUOTED(RCFILE_NAME, "$enableval", [Specify an alternate rcfile name (default: .nanorc).]) rcfilename=$enableval
|
||||
fi])
|
||||
|
||||
|
||||
AC_MSG_CHECKING([whether to use slang])
|
||||
CURSES_LIB_NAME=""
|
||||
AC_ARG_WITH(slang,
|
||||
AS_HELP_STRING([--with-slang[=DIR]], [Use the slang library instead of curses]),
|
||||
[ case "$with_slang" in
|
||||
no)
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(yes)
|
||||
|
||||
if test x$with_slang != xyes; then
|
||||
# Add additional search path.
|
||||
LDFLAGS="-L$with_slang/lib $LDFLAGS"
|
||||
CPPFLAGS="-I$with_slang/include $CPPFLAGS"
|
||||
fi
|
||||
|
||||
if test "x$enable_utf8" != xno; then
|
||||
AC_CHECK_HEADER(slcurses.h,
|
||||
AC_MSG_CHECKING([for SLutf8_enable in -lslang])
|
||||
_libs=$LIBS
|
||||
LIBS="$LIBS -lslang"
|
||||
AC_TRY_RUN([
|
||||
#include <slcurses.h>
|
||||
int main(void)
|
||||
{
|
||||
SLutf8_enable(1);
|
||||
return 0;
|
||||
}],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
|
||||
CURSES_LIB_WIDE=yes
|
||||
if test x$with_slang != xyes; then
|
||||
CURSES_LIB="-L${with_slang}/lib -lslang"
|
||||
else
|
||||
CURSES_LIB="-lslang"
|
||||
fi
|
||||
CURSES_LIB_NAME=slang],
|
||||
[AC_MSG_RESULT(no)
|
||||
|
||||
# We might need the term library.
|
||||
for termlib in ncurses curses termcap terminfo termlib; do
|
||||
AC_CHECK_LIB([${termlib}], tputs, [tcap="-l$termlib"])
|
||||
test -n "$tcap" && break
|
||||
done
|
||||
|
||||
AC_MSG_CHECKING([for SLutf8_enable in -lslang $tcap])
|
||||
LIBS="$LIBS $tcap"
|
||||
AC_TRY_RUN([
|
||||
#include <slcurses.h>
|
||||
int main(void)
|
||||
{
|
||||
SLutf8_enable(1);
|
||||
return 0;
|
||||
}],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
|
||||
CURSES_LIB_WIDE=yes
|
||||
if test x$with_slang != xyes; then
|
||||
CURSES_LIB="-L${with_slang}/lib -lslang $tcap"
|
||||
else
|
||||
CURSES_LIB="-lslang $tcap"
|
||||
fi
|
||||
CURSES_LIB_NAME=slang],
|
||||
[AC_MSG_RESULT(no)
|
||||
|
||||
# We might need the math library.
|
||||
AC_MSG_CHECKING([for SLutf8_enable in -lslang $tcap -lm])
|
||||
LIBS="$LIBS -lm"
|
||||
AC_TRY_RUN([
|
||||
#include <slcurses.h>
|
||||
int main(void)
|
||||
{
|
||||
SLutf8_enable(1);
|
||||
return 0;
|
||||
}],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
|
||||
CURSES_LIB_WIDE=yes
|
||||
if test x$with_slang != xyes; then
|
||||
CURSES_LIB="-L${with_slang}/lib -lslang $tcap -lm"
|
||||
else
|
||||
CURSES_LIB="-lslang $tcap -lm"
|
||||
fi
|
||||
CURSES_LIB_NAME=slang],
|
||||
[AC_MSG_RESULT(no)],
|
||||
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
|
||||
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
|
||||
AC_MSG_WARN([*** Can not use slang when cross-compiling])),
|
||||
AC_MSG_ERROR([
|
||||
*** The header file slcurses.h was not found. This header file
|
||||
*** is required if you wish to use Slang support. Please either
|
||||
*** install a version of Slang that includes the slcurses.h file
|
||||
*** or do not call the configure script with --with-slang.]))
|
||||
fi
|
||||
|
||||
if eval "test x$CURSES_LIB_NAME = x"; then
|
||||
# Reset libs if the above slang tests failed.
|
||||
if test "x$enable_utf8" != xno; then
|
||||
LIBS=$_libs
|
||||
fi
|
||||
|
||||
AC_CHECK_HEADER(slcurses.h,
|
||||
AC_MSG_CHECKING([for SLtt_initialize in -lslang])
|
||||
_libs=$LIBS
|
||||
LIBS="$LIBS -lslang"
|
||||
AC_TRY_RUN([
|
||||
#include <slcurses.h>
|
||||
int main(void)
|
||||
{
|
||||
SLtt_initialize(NULL);
|
||||
return 0;
|
||||
}],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
|
||||
if test x$with_slang != xyes; then
|
||||
CURSES_LIB="-L${with_slang}/lib -lslang"
|
||||
else
|
||||
CURSES_LIB="-lslang"
|
||||
fi
|
||||
CURSES_LIB_NAME=slang],
|
||||
[AC_MSG_RESULT(no)
|
||||
|
||||
# We might need the term library.
|
||||
for termlib in ncurses curses termcap terminfo termlib; do
|
||||
AC_CHECK_LIB([${termlib}], tputs, [tcap="-l$termlib"])
|
||||
test -n "$tcap" && break
|
||||
done
|
||||
|
||||
AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap])
|
||||
LIBS="$LIBS $tcap"
|
||||
AC_TRY_RUN([
|
||||
#include <slcurses.h>
|
||||
int main(void)
|
||||
{
|
||||
SLtt_initialize(NULL);
|
||||
return 0;
|
||||
}],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
|
||||
if test x$with_slang != xyes; then
|
||||
CURSES_LIB="-L${with_slang}/lib -lslang $tcap"
|
||||
else
|
||||
CURSES_LIB="-lslang $tcap"
|
||||
fi
|
||||
CURSES_LIB_NAME=slang],
|
||||
[AC_MSG_RESULT(no)
|
||||
|
||||
# We might need the math library.
|
||||
AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap -lm])
|
||||
LIBS="$LIBS -lm"
|
||||
AC_TRY_RUN([
|
||||
#include <slcurses.h>
|
||||
int main(void)
|
||||
{
|
||||
SLtt_initialize(NULL);
|
||||
return 0;
|
||||
}],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
|
||||
if test x$with_slang != xyes; then
|
||||
CURSES_LIB="-L${with_slang}/lib -lslang $tcap -lm"
|
||||
else
|
||||
CURSES_LIB="-lslang $tcap -lm"
|
||||
fi
|
||||
CURSES_LIB_NAME=slang],
|
||||
[AC_MSG_RESULT(no)],
|
||||
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
|
||||
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
|
||||
AC_MSG_WARN([*** Can not use slang when cross-compiling])),
|
||||
AC_MSG_ERROR([
|
||||
*** The header file slcurses.h was not found. This header file
|
||||
*** is required if you wish to use Slang support. Please either
|
||||
*** install a version of Slang that includes the slcurses.h file
|
||||
*** or do not call the configure script with --with-slang.]))
|
||||
fi
|
||||
|
||||
if test "${_libs+set}" = "set"; then
|
||||
LIBS=$_libs
|
||||
fi
|
||||
|
||||
if test x$with_slang != xyes; then
|
||||
LDFLAGS=${_ldflags}
|
||||
fi
|
||||
;;
|
||||
esac], [AC_MSG_RESULT(no)])
|
||||
|
||||
dnl Checks for functions.
|
||||
|
||||
if test "x$enable_utf8" != xno; then
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
<b>Information</b>
|
||||
<table><tbody>
|
||||
<tr><td>Ctrl+C </td><td>Report cursor position</td></tr>
|
||||
<tr><td>Alt+D</td><td>Report word/line/char count</td></tr>
|
||||
<tr><td>Alt+D</td><td>Report line/word/character count</td></tr>
|
||||
<tr><td>Ctrl+G</td><td>Display help text</td></tr>
|
||||
</tbody></table>
|
||||
<br>
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
<h3><a name="1.3"></a>1.3. Why the name change from TIP?</h3>
|
||||
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program "establishes a full duplex terminal connection to a remote host", and was included with many older Unix systems (and newer ones like Solaris). The conflict was not noticed at first because there is no 'tip' utility included with most GNU/Linux distributions (where nano was developed).</p></blockquote>
|
||||
<h3><a name="1.4"></a>1.4. What is the current version of nano?</h3>
|
||||
<blockquote><p>The current version of nano <i>should</i> be <b>5.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>
|
||||
<blockquote><p>The current version of nano <i>should</i> be <b>5.6</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
|
||||
<h3><a name="1.5"></a>1.5. I want to read the man page without having to download the program!</h3>
|
||||
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="https://nano-editor.org/dist/latest/nano.1.html">here</a>.</p></blockquote>
|
||||
<hr width="100%">
|
||||
|
||||
27
doc/nano.1
27
doc/nano.1
@@ -1,4 +1,4 @@
|
||||
.\" Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc.
|
||||
.\" Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc.
|
||||
.\"
|
||||
.\" This document is dual-licensed. You may distribute and/or modify it
|
||||
.\" under the terms of either of the following licenses:
|
||||
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANO 1 "version 5.4" "December 2020"
|
||||
.TH NANO 1 "version 5.6" "February 2021"
|
||||
|
||||
.SH NAME
|
||||
nano \- Nano's ANOther editor, inspired by Pico
|
||||
@@ -190,9 +190,9 @@ Set the size (width) of a tab to \fInumber\fP columns. The value of
|
||||
\fInumber\fR must be greater than 0. The default value is \fB8\fR.
|
||||
.TP
|
||||
.BR \-U ", " \-\-quickblank
|
||||
Do quick status-bar blanking: status-bar messages will disappear after 1
|
||||
keystroke instead of 25. Note that option \fB\-c\fR (\fB\-\-constantshow\fR)
|
||||
overrides this.
|
||||
Make status-bar messages disappear after 1 keystroke instead of after 20.
|
||||
Note that options \fB\-c\fR (\fB\-\-constantshow\fR)
|
||||
and \fB\-_\fR (\fB\-\-minibar\fR) override this.
|
||||
.TP
|
||||
.BR \-V ", " \-\-version
|
||||
Show the current version number and exit.
|
||||
@@ -337,6 +337,23 @@ and \fBS\fR when soft-wrapping.
|
||||
When the buffer is modified, a star (\fB*\fR) is shown after the
|
||||
filename in the center of the title bar.
|
||||
.TP
|
||||
.BR \-_ ", " \-\-minibar
|
||||
Suppress the title bar and instead show information about
|
||||
the current buffer at the bottom of the screen, in the space
|
||||
for the status bar. In this "minibar" the file name is shown
|
||||
on the left, followed by an asterisk if the buffer has been modified.
|
||||
On the right are displayed the current line and column number, the
|
||||
code of the character under the cursor (in Unicode format: U+xxxx),
|
||||
the same flags as are shown by \fB\-\-stateflags\fR, and a percentage
|
||||
that expresses how far the cursor is into the file (linewise).
|
||||
When a file is loaded or saved, and also when switching between buffers,
|
||||
the number of lines in the buffer is displayed after the file name.
|
||||
This number is cleared upon the next keystroke, or replaced with an
|
||||
[i/n] counter when multiple buffers are open.
|
||||
The line plus column numbers and the character code are displayed only when
|
||||
\fB\-\-constantshow\fR is used, and can be toggled on and off with \fBM-C\fR.
|
||||
The state flags are displayed only when \fB\-\-stateflags\fR is used.
|
||||
.TP
|
||||
.BR \-! ", " \-\-magic
|
||||
When neither the file's name nor its first line give a clue,
|
||||
try using libmagic to determine the applicable syntax.
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
@smallbook
|
||||
@set EDITION 0.5
|
||||
@set VERSION 5.4
|
||||
@set UPDATED December 2020
|
||||
@set VERSION 5.6
|
||||
@set UPDATED February 2021
|
||||
|
||||
@dircategory Editors
|
||||
@direntry
|
||||
@@ -23,7 +23,7 @@
|
||||
@titlepage
|
||||
@title GNU @command{nano}
|
||||
@subtitle a small and friendly text editor
|
||||
@subtitle version 5.4
|
||||
@subtitle version 5.6
|
||||
|
||||
@author Chris Allegretta
|
||||
@page
|
||||
@@ -33,7 +33,7 @@ This manual documents the GNU @command{nano} editor.
|
||||
This manual is part of the GNU @command{nano} distribution.@*
|
||||
|
||||
@sp 4
|
||||
Copyright @copyright{} 1999-2009, 2014-2020 Free Software Foundation, Inc.
|
||||
Copyright @copyright{} 1999-2009, 2014-2021 Free Software Foundation, Inc.
|
||||
|
||||
@sp 1
|
||||
This document is dual-licensed. You may distribute and/or modify it
|
||||
@@ -63,7 +63,7 @@ e-mail: @email{chrisa@@asty.org}@*
|
||||
@node Top
|
||||
@top
|
||||
|
||||
This manual documents the GNU @command{nano} editor, version 5.4.
|
||||
This manual documents the GNU @command{nano} editor, version 5.6.
|
||||
|
||||
@menu
|
||||
* Introduction::
|
||||
@@ -281,9 +281,9 @@ Set the displayed tab length to @var{number} columns. The value of
|
||||
|
||||
@item -U
|
||||
@itemx --quickblank
|
||||
Do quick status-bar blanking: status-bar messages will disappear after 1
|
||||
keystroke instead of 25. Note that option @option{-c}
|
||||
(@option{--constantshow}) overrides this.
|
||||
Make status-bar messages disappear after 1 keystroke instead of after 20.
|
||||
Note that options @option{-c} (@option{--constantshow})
|
||||
and @option{-_} (@option{--minibar}) override this.
|
||||
|
||||
@item -V
|
||||
@itemx --version
|
||||
@@ -477,6 +477,24 @@ and @code{S} when soft-wrapping.
|
||||
When the buffer is modified, a star (@code{*}) is shown after the
|
||||
filename in the center of the title bar.
|
||||
|
||||
@item -_
|
||||
@itemx --minibar
|
||||
Suppress the title bar and instead show information about
|
||||
the current buffer at the bottom of the screen, in the space
|
||||
for the status bar. In this "minibar" the file name is shown
|
||||
on the left, followed by an asterisk if the buffer has been modified.
|
||||
On the right are displayed the current line and column number, the
|
||||
code of the character under the cursor (in Unicode format: U+xxxx),
|
||||
the same flags as are shown by @code{--stateflags}, and a percentage
|
||||
that expresses how far the cursor is into the file (linewise).
|
||||
When a file is loaded or saved, and also when switching between buffers,
|
||||
the number of lines in the buffer is displayed after the file name.
|
||||
This number is cleared upon the next keystroke, or replaced with an
|
||||
[i/n] counter when multiple buffers are open.
|
||||
The line plus column numbers and the character code are displayed only when
|
||||
@code{--constantshow} is used, and can be toggled on and off with @key{M-C}.
|
||||
The state flags are displayed only when @code{--stateflags} is used.
|
||||
|
||||
@item -!
|
||||
@itemx --magic
|
||||
When neither the file's name nor its first line give a clue,
|
||||
@@ -874,10 +892,20 @@ if your terminal can do those.
|
||||
Draw a vertical stripe at the given column, to help judge the width of the
|
||||
text. (The color of the stripe can be changed with @code{set stripecolor}.)
|
||||
|
||||
@item set highlightcolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
|
||||
Use this color combination for highlighting a search match.
|
||||
The default value is @t{black,lightyellow}.
|
||||
@xref{@code{set functioncolor}} for valid color names.
|
||||
|
||||
@item set historylog
|
||||
Save the last hundred search strings and replacement strings and
|
||||
executed commands, so they can be easily reused in later sessions.
|
||||
|
||||
@item set indicator
|
||||
Display a "scrollbar" on the righthand side of the edit window.
|
||||
It shows the position of the viewport in the buffer
|
||||
and how much of the buffer is covered by the viewport.
|
||||
|
||||
@item set jumpyscrolling
|
||||
Scroll the buffer contents per half-screen instead of per line.
|
||||
|
||||
@@ -906,6 +934,23 @@ searches. This may not include blank characters. The opening set must
|
||||
come before the closing set, and the two sets must be in the same order.
|
||||
The default value is "@t{(<[@{)>]@}}".
|
||||
|
||||
@item set minibar
|
||||
Suppress the title bar and instead show information about
|
||||
the current buffer at the bottom of the screen, in the space
|
||||
for the status bar. In this "minibar" the file name is shown
|
||||
on the left, followed by an asterisk if the buffer has been modified.
|
||||
On the right are displayed the current line and column number, the
|
||||
code of the character under the cursor (in Unicode format: U+xxxx),
|
||||
the same flags as are shown by @code{set stateflags}, and a percentage
|
||||
that expresses how far the cursor is into the file (linewise).
|
||||
When a file is loaded or saved, and also when switching between buffers,
|
||||
the number of lines in the buffer is displayed after the file name.
|
||||
This number is cleared upon the next keystroke, or replaced with an
|
||||
[i/n] counter when multiple buffers are open.
|
||||
The line plus column numbers and the character code are displayed only when
|
||||
@code{set constantshow} is used, and can be toggled on and off with @key{M-C}.
|
||||
The state flags are displayed only when @code{set stateflags} is used.
|
||||
|
||||
@item set morespace
|
||||
Deprecated option since it has become the default setting.
|
||||
When needed, use @code{unset emptyline} instead.
|
||||
@@ -951,10 +996,10 @@ The cursor position is remembered for the 200 most-recently edited files.
|
||||
@item set preserve
|
||||
Preserve the XON and XOFF keys (@kbd{^Q} and @kbd{^S}).
|
||||
|
||||
@item set indicator
|
||||
Display a "scrollbar" on the righthand side of the edit window.
|
||||
It shows the position of the viewport in the buffer
|
||||
and how much of the buffer is covered by the viewport.
|
||||
@item set promptcolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
|
||||
Use this color combination for the prompt bar.
|
||||
(When this option is not specified, the colors of the title bar are used.)
|
||||
@xref{@code{set functioncolor}} for valid color names.
|
||||
|
||||
@item set punct "@var{characters}"
|
||||
Set the characters treated as closing punctuation when justifying
|
||||
@@ -964,8 +1009,8 @@ specified closing punctuation, optionally followed by closing brackets
|
||||
The default value is "@t{!.?}".
|
||||
|
||||
@item set quickblank
|
||||
Do quick status-bar blanking: status-bar messages will disappear after 1
|
||||
keystroke instead of 25. Note that @option{constantshow} overrides this.
|
||||
Make status-bar messages disappear after 1 keystroke instead of after 20.
|
||||
Note that options @option{constantshow} and @option{minibar} override this.
|
||||
|
||||
@item set quotestr "@var{regex}"
|
||||
Set the regular expression for matching the quoting part of a line.
|
||||
@@ -1631,8 +1676,9 @@ is the beginning of a paragraph.
|
||||
Toggles whether cutting text will cut the whole line or just from the current cursor
|
||||
position to the end of the line.
|
||||
|
||||
@item nowrap
|
||||
@item breaklonglines
|
||||
Toggles whether long lines will be hard-wrapped to the next line.
|
||||
(The old name of this function, 'nowrap', is deprecated.)
|
||||
|
||||
@item tabstospaces
|
||||
Toggles whether typed tabs will be converted to spaces.
|
||||
@@ -1915,8 +1961,8 @@ Exclude Native Language support. This will disable the use of any
|
||||
available GNU @command{nano} translations.
|
||||
|
||||
@item --enable-utf8
|
||||
Include support for reading and writing Unicode files. This will require
|
||||
either a wide version of curses, or a UTF-8-enabled version of Slang.
|
||||
Include support for reading and writing Unicode files.
|
||||
This requires a wide version of the curses library.
|
||||
|
||||
@item --disable-utf8
|
||||
Exclude support for reading and writing Unicode files. Normally the
|
||||
@@ -1927,10 +1973,6 @@ You can use this or the previous option to override that detection.
|
||||
Use the file with the given @var{name} (in the user's home directory)
|
||||
as nano's settings file, instead of the default @code{.nanorc}.
|
||||
|
||||
@item --with-slang
|
||||
Compile @command{nano} against Slang instead of against ncurses or other
|
||||
curses libraries.
|
||||
|
||||
@end table
|
||||
|
||||
@html
|
||||
|
||||
54
doc/nanorc.5
54
doc/nanorc.5
@@ -1,4 +1,4 @@
|
||||
.\" Copyright (C) 2003-2011, 2013-2020 Free Software Foundation, Inc.
|
||||
.\" Copyright (C) 2003-2011, 2013-2021 Free Software Foundation, Inc.
|
||||
.\"
|
||||
.\" This document is dual-licensed. You may distribute and/or modify it
|
||||
.\" under the terms of either of the following licenses:
|
||||
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANORC 5 "version 5.4" "December 2020"
|
||||
.TH NANORC 5 "version 5.6" "February 2021"
|
||||
|
||||
.SH NAME
|
||||
nanorc \- GNU nano's configuration file
|
||||
@@ -138,7 +138,7 @@ point to vary along with the width of the screen if the screen is resized.
|
||||
The default value is \fB\-8\fR.
|
||||
.TP
|
||||
.B set functioncolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
Specify the color combination to use for the function descriptions
|
||||
Use this color combination for the concise function descriptions
|
||||
in the two help lines at the bottom of the screen.
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
@@ -146,6 +146,11 @@ See \fBset titlecolor\fR for more details.
|
||||
Draw a vertical stripe at the given column, to help judge the width of the
|
||||
text. (The color of the stripe can be changed with \fBset stripecolor\fR.)
|
||||
.TP
|
||||
.B set highlightcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
Use this color combination for highlighting a search match.
|
||||
The default value is \fBblack,lightyellow\fR.
|
||||
See \fBset titlecolor\fR for valid color names.
|
||||
.TP
|
||||
.B set historylog
|
||||
Save the last hundred search strings and replacement strings and
|
||||
executed commands, so they can be easily reused in later sessions.
|
||||
@@ -159,7 +164,7 @@ and how much of the buffer is covered by the viewport.
|
||||
Scroll the buffer contents per half-screen instead of per line.
|
||||
.TP
|
||||
.B set keycolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
Specify the color combination to use for the shortcut key combos
|
||||
Use this color combination for the shortcut key combos
|
||||
in the two help lines at the bottom of the screen.
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
@@ -182,6 +187,23 @@ searches. This may not include blank characters. The opening set must
|
||||
come before the closing set, and the two sets must be in the same order.
|
||||
The default value is "\fB(<[{)>]}\fP".
|
||||
.TP
|
||||
.B set minibar
|
||||
Suppress the title bar and instead show information about
|
||||
the current buffer at the bottom of the screen, in the space
|
||||
for the status bar. In this "minibar" the file name is shown
|
||||
on the left, followed by an asterisk if the buffer has been modified.
|
||||
On the right are displayed the current line and column number, the
|
||||
code of the character under the cursor (in Unicode format: U+xxxx),
|
||||
the same flags as are shown by \fBset stateflags\fR, and a percentage
|
||||
that expresses how far the cursor is into the file (linewise).
|
||||
When a file is loaded or saved, and also when switching between buffers,
|
||||
the number of lines in the buffer is displayed after the file name.
|
||||
This number is cleared upon the next keystroke, or replaced with an
|
||||
[i/n] counter when multiple buffers are open.
|
||||
The line plus column numbers and the character code are displayed only when
|
||||
\fBset constantshow\fR is used, and can be toggled on and off with \fBM-C\fR.
|
||||
The state flags are displayed only when \fBset stateflags\fR is used.
|
||||
.TP
|
||||
.B set morespace
|
||||
Deprecated option since it has become the default setting.
|
||||
When needed, use \fBunset emptyline\fR instead.
|
||||
@@ -214,7 +236,7 @@ Deprecated option since it has become the default setting.
|
||||
When needed, use \fBunset breaklonglines\fR instead.
|
||||
.TP
|
||||
.B set numbercolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
Specify the color combination to use for line numbers.
|
||||
Use this color combination for line numbers.
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
.B set operatingdir "\fIdirectory\fP"
|
||||
@@ -230,6 +252,11 @@ The cursor position is remembered for the 200 most-recently edited files.
|
||||
.B set preserve
|
||||
Preserve the XON and XOFF keys (\fB^Q\fR and \fB^S\fR).
|
||||
.TP
|
||||
.B set promptcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
Use this color combination for the prompt bar.
|
||||
(When this option is not specified, the colors of the title bar are used.)
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
.BI "set punct """ characters """
|
||||
Set the characters treated as closing punctuation when justifying
|
||||
paragraphs. This may not include blank characters. Only the
|
||||
@@ -237,8 +264,8 @@ specfified closing punctuation, optionally followed by closing brackets
|
||||
(see \fBbrackets\fP), can end sentences. The default value is "\fB!.?\fP".
|
||||
.TP
|
||||
.B set quickblank
|
||||
Do quick status-bar blanking: status-bar messages will disappear after 1
|
||||
keystroke instead of 25. The option \fBconstantshow\fR overrides this.
|
||||
Make status-bar messages disappear after 1 keystroke instead of after 20.
|
||||
Note that options \fBconstantshow\fR and \fBminibar\fR override this.
|
||||
.TP
|
||||
.BI "set quotestr """ regex """
|
||||
Set the regular expression for matching the quoting part of a line.
|
||||
@@ -267,13 +294,13 @@ Save a changed buffer automatically on exit (\fB^X\fR); don't prompt.
|
||||
(The old form of this option, \fBset tempfile\fR, is deprecated.)
|
||||
.TP
|
||||
.B set scrollercolor \fIfgcolor\fB,\fIbgcolor\fR
|
||||
Specify the color combination to use for the indicator alias "scrollbar".
|
||||
Use this color combination for the indicator alias "scrollbar".
|
||||
(On terminal emulators that link to a libvte older than version 0.55,
|
||||
using a background color here does not work correctly.)
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
.B set selectedcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
Specify the color combination to use for selected text.
|
||||
Use this color combination for selected text.
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
.B set showcursor
|
||||
@@ -309,11 +336,11 @@ When the buffer is modified, a star (\fB*\fR) is shown after the
|
||||
filename in the center of the title bar.
|
||||
.TP
|
||||
.B set statuscolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
Specify the color combination to use for the status bar.
|
||||
Use this color combination for the status bar.
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
.B set stripecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
Specify the color combination to use for the vertical guiding stripe.
|
||||
Use this color combination for the vertical guiding stripe.
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
.B set suspendable
|
||||
@@ -327,7 +354,7 @@ greater than 0. The default value is \fB8\fR.
|
||||
Convert typed tabs to spaces.
|
||||
.TP
|
||||
.B set titlecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
Specify the color combination to use for the title bar.
|
||||
Use this color combination for the title bar.
|
||||
Valid names for the foreground and background colors are:
|
||||
.BR red ", " green ", " blue ", " magenta ", " yellow ", " cyan ", "
|
||||
.BR white ", and " black .
|
||||
@@ -893,8 +920,9 @@ is the beginning of a paragraph.
|
||||
Toggles whether cutting text will cut the whole line or just from the current cursor
|
||||
position to the end of the line.
|
||||
.TP
|
||||
.B nowrap
|
||||
.B breaklonglines
|
||||
Toggles whether long lines will be hard-wrapped to the next line.
|
||||
(The old name of this function, 'nowrap', is deprecated.)
|
||||
.TP
|
||||
.B tabstospaces
|
||||
Toggles whether typed tabs will be converted to spaces.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" Copyright (C) 2002-2007, 2014-2020 Free Software Foundation, Inc.
|
||||
.\" Copyright (C) 2002-2007, 2014-2021 Free Software Foundation, Inc.
|
||||
.\"
|
||||
.\" This document is dual-licensed. You may distribute and/or modify it
|
||||
.\" under the terms of either of the following licenses:
|
||||
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH RNANO 1 "version 5.4" "December 2020"
|
||||
.TH RNANO 1 "version 5.6" "February 2021"
|
||||
|
||||
.SH NAME
|
||||
rnano \- a restricted nano
|
||||
|
||||
@@ -44,8 +44,7 @@
|
||||
## Do case-sensitive searches by default.
|
||||
# set casesensitive
|
||||
|
||||
## Constantly display the cursor position in the status bar. Note that
|
||||
## this overrides "quickblank".
|
||||
## Constantly display the cursor position in the status bar or minibar.
|
||||
# set constantshow
|
||||
|
||||
## Use cut-from-cursor-to-end-of-line by default.
|
||||
@@ -84,6 +83,9 @@
|
||||
## come before the latter set, and both must be in the same order.
|
||||
# set matchbrackets "(<[{)>]}"
|
||||
|
||||
## Suppress title bar and show file name and editor state at the bottom.
|
||||
# set minibar
|
||||
|
||||
## Enable mouse support, if available for your system. When enabled,
|
||||
## mouse clicks can be used to place the cursor, set the mark (with a
|
||||
## double click), and execute shortcuts. The mouse will work in the X
|
||||
@@ -121,8 +123,7 @@
|
||||
## sentences.
|
||||
# set punct "!.?"
|
||||
|
||||
## Do quick status-bar blanking. Status-bar messages will disappear after
|
||||
## 1 keystroke instead of 26. Note that "constantshow" overrides this.
|
||||
## Make status-bar messages disappear after 1 keystroke instead of after 20.
|
||||
# set quickblank
|
||||
|
||||
## The regular expression that matches quoting characters in email
|
||||
@@ -200,12 +201,15 @@
|
||||
## of a single character, and without affecting the cutbuffer).
|
||||
# set zap
|
||||
|
||||
## Paint the interface elements of nano. These are examples;
|
||||
## by default there are no colors, except for errorcolor.
|
||||
|
||||
## Paint the interface elements of nano. These are examples; there are
|
||||
## no colors by default, except for errorcolor and highlightcolor.
|
||||
# set titlecolor bold,lightwhite,blue
|
||||
# set promptcolor lightwhite,lightblack
|
||||
# set statuscolor bold,lightwhite,green
|
||||
# set errorcolor bold,lightwhite,red
|
||||
# set selectedcolor lightwhite,magenta
|
||||
# set highlightcolor black,lime
|
||||
# set stripecolor ,yellow
|
||||
# set scrollercolor cyan
|
||||
# set numbercolor cyan
|
||||
@@ -214,9 +218,11 @@
|
||||
|
||||
## In root's .nanorc you might want to use:
|
||||
# set titlecolor bold,lightwhite,magenta
|
||||
# set promptcolor black,yellow
|
||||
# set statuscolor bold,lightwhite,magenta
|
||||
# set errorcolor bold,lightwhite,red
|
||||
# set selectedcolor lightwhite,cyan
|
||||
# set highlightcolor black,orange
|
||||
# set stripecolor ,yellow
|
||||
# set scrollercolor magenta
|
||||
# set numbercolor magenta
|
||||
|
||||
1091
po/nano.pot
1091
po/nano.pot
File diff suppressed because it is too large
Load Diff
1114
po/pt_BR.po
1114
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
1106
po/zh_CN.po
1106
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
1096
po/zh_TW.po
1096
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERSION="5.4"
|
||||
VERSION="5.6"
|
||||
|
||||
./configure -C --enable-tiny && make && ./configure -C &&
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ CLEANFILES = revision.h
|
||||
if BUILDING_FROM_GIT
|
||||
SOMETHING = "REVISION \"`git describe --tags 2>/dev/null`\""
|
||||
else
|
||||
SOMETHING = "NOTHING \"from tarball\""
|
||||
SOMETHING = "PLAINBUILD \"from tarball\""
|
||||
endif
|
||||
|
||||
nano.o: revision.h
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* browser.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2015-2016, 2020 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
|
||||
12
src/chars.c
12
src/chars.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* chars.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2016-2020 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -179,8 +179,8 @@ char control_mbrep(const char *c, bool isdata)
|
||||
/* Return the width in columns of the given (multibyte) character. */
|
||||
int mbwidth(const char *c)
|
||||
{
|
||||
/* Ask for the width only when the character isn't plain ASCII. */
|
||||
if ((signed char)*c <= 0) {
|
||||
/* Only characters beyond U+02FF can be other than one column wide. */
|
||||
if ((unsigned char)*c > 0xCB) {
|
||||
wchar_t wc;
|
||||
int width;
|
||||
|
||||
@@ -227,7 +227,7 @@ int char_length(const char *pointer)
|
||||
{
|
||||
#ifdef ENABLE_UTF8
|
||||
/* If possibly a multibyte character, get its length; otherwise, it's 1. */
|
||||
if ((signed char)*pointer < 0) {
|
||||
if ((unsigned char)*pointer > 0xC1) {
|
||||
int length = mblen(pointer, MAXCHARLEN);
|
||||
|
||||
return (length < 0 ? 1 : length);
|
||||
@@ -243,7 +243,7 @@ size_t mbstrlen(const char *pointer)
|
||||
|
||||
while (*pointer != '\0') {
|
||||
#ifdef ENABLE_UTF8
|
||||
if ((signed char)*pointer < 0) {
|
||||
if ((unsigned char)*pointer > 0xC1) {
|
||||
int length = mblen(pointer, MAXCHARLEN);
|
||||
|
||||
pointer += (length < 0 ? 1 : length);
|
||||
@@ -265,7 +265,7 @@ int collect_char(const char *string, char *thechar)
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
/* If this is a UTF-8 starter byte, get the number of bytes of the character. */
|
||||
if ((signed char)*string < 0) {
|
||||
if ((unsigned char)*string > 0xC1) {
|
||||
charlen = mblen(string, MAXCHARLEN);
|
||||
|
||||
/* When the multibyte sequence is invalid, only take the first byte. */
|
||||
|
||||
118
src/color.c
118
src/color.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* color.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2017, 2020 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -58,6 +58,11 @@ void set_interface_colorpairs(void)
|
||||
interface_color_pair[index] = A_NORMAL;
|
||||
else if (index == GUIDE_STRIPE)
|
||||
interface_color_pair[index] = A_REVERSE;
|
||||
else if (index == HIGHLIGHTED) {
|
||||
init_pair(index + 1, COLOR_BLACK, COLOR_YELLOW + (COLORS > 15 ? 8 : 0));
|
||||
interface_color_pair[index] = COLOR_PAIR(index + 1);
|
||||
} else if (index == PROMPT_BAR)
|
||||
interface_color_pair[index] = interface_color_pair[TITLE_BAR];
|
||||
else if (index == ERROR_MESSAGE) {
|
||||
init_pair(index + 1, COLOR_WHITE, COLOR_RED);
|
||||
interface_color_pair[index] = COLOR_PAIR(index + 1) | A_BOLD;
|
||||
@@ -118,7 +123,7 @@ bool found_in_list(regexlisttype *head, const char *shibboleth)
|
||||
regex_t rgx;
|
||||
|
||||
for (item = head; item != NULL; item = item->next) {
|
||||
regcomp(&rgx, item->full_regex, NANO_REG_EXTENDED);
|
||||
regcomp(&rgx, item->full_regex, NANO_REG_EXTENDED | REG_NOSUB);
|
||||
|
||||
if (regexec(&rgx, shibboleth, 0, NULL, 0) == 0) {
|
||||
regfree(&rgx);
|
||||
@@ -229,15 +234,6 @@ void find_and_prime_applicable_syntax(void)
|
||||
openfile->syntax = sntx;
|
||||
}
|
||||
|
||||
/* Allocate and initialize (for the given line) the cache for multiline info. */
|
||||
void set_up_multicache(linestruct *line)
|
||||
{
|
||||
line->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
|
||||
for (short index = 0; index < openfile->syntax->nmultis; index++)
|
||||
line->multidata[index] = -1;
|
||||
}
|
||||
|
||||
/* Determine whether the matches of multiline regexes are still the same,
|
||||
* and if not, schedule a screen refresh, so things will be repainted. */
|
||||
void check_the_multis(linestruct *line)
|
||||
@@ -251,8 +247,10 @@ void check_the_multis(linestruct *line)
|
||||
if (openfile->syntax == NULL || openfile->syntax->nmultis == 0)
|
||||
return;
|
||||
|
||||
if (line->multidata == NULL)
|
||||
set_up_multicache(line);
|
||||
if (line->multidata == NULL) {
|
||||
refresh_needed = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
for (ink = openfile->syntax->color; ink != NULL; ink = ink->next) {
|
||||
/* If it's not a multiline regex, skip. */
|
||||
@@ -264,19 +262,22 @@ void check_the_multis(linestruct *line)
|
||||
anend = (regexec(ink->end, afterstart, 1, &endmatch, 0) == 0);
|
||||
|
||||
/* Check whether the multidata still matches the current situation. */
|
||||
if (line->multidata[ink->id] == CNONE ||
|
||||
line->multidata[ink->id] == CWHOLELINE) {
|
||||
if (line->multidata[ink->id] == NOTHING) {
|
||||
if (!astart)
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] & (WHOLELINE|WOULDBE)) {
|
||||
if (!astart && !anend)
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] == CSTARTENDHERE) {
|
||||
if (astart && anend && startmatch.rm_so < endmatch.rm_so)
|
||||
} else if (line->multidata[ink->id] == JUSTONTHIS) {
|
||||
if (astart && anend && regexec(ink->start, line->data + endmatch.rm_eo,
|
||||
1, &startmatch, 0) != 0)
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] == CBEGINBEFORE) {
|
||||
if (!astart && anend)
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] == CENDAFTER) {
|
||||
} else if (line->multidata[ink->id] == STARTSHERE) {
|
||||
if (astart && !anend)
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] == ENDSHERE) {
|
||||
if (!astart && anend)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* There is a mismatch, so something changed: repaint. */
|
||||
@@ -293,13 +294,18 @@ void precalc_multicolorinfo(void)
|
||||
regmatch_t startmatch, endmatch;
|
||||
linestruct *line, *tailline;
|
||||
|
||||
if (openfile->syntax == NULL || openfile->syntax->nmultis == 0 ||
|
||||
openfile->filetop->multidata || ISSET(NO_SYNTAX))
|
||||
if (!openfile->syntax || openfile->syntax->nmultis == 0 || ISSET(NO_SYNTAX))
|
||||
return;
|
||||
|
||||
//#define TIMEPRECALC 123
|
||||
#ifdef TIMEPRECALC
|
||||
#include <time.h>
|
||||
clock_t start = clock();
|
||||
#endif
|
||||
|
||||
/* For each line, allocate cache space for the multiline-regex info. */
|
||||
for (line = openfile->filetop; line != NULL; line = line->next)
|
||||
set_up_multicache(line);
|
||||
line->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
|
||||
for (ink = openfile->syntax->color; ink != NULL; ink = ink->next) {
|
||||
/* If this is not a multi-line regex, skip it. */
|
||||
@@ -310,66 +316,68 @@ void precalc_multicolorinfo(void)
|
||||
int index = 0;
|
||||
|
||||
/* Assume nothing applies until proven otherwise below. */
|
||||
line->multidata[ink->id] = CNONE;
|
||||
line->multidata[ink->id] = NOTHING;
|
||||
|
||||
/* For an unpaired start match, mark all remaining lines. */
|
||||
if (line->prev && line->prev->multidata[ink->id] == CWOULDBE) {
|
||||
line->multidata[ink->id] = CWOULDBE;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* When the line contains a start match, look for an end, and if
|
||||
* found, mark all the lines that are affected. */
|
||||
while (regexec(ink->start, line->data + index, 1,
|
||||
&startmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
/* When the line contains a start match, look for an end,
|
||||
* and if found, mark all the lines that are affected. */
|
||||
while (regexec(ink->start, line->data + index, 1, &startmatch,
|
||||
(index == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
/* Begin looking for an end match after the start match. */
|
||||
index += startmatch.rm_eo;
|
||||
|
||||
/* If there is an end match on this line, mark the line, but
|
||||
* continue looking for other starts after it. */
|
||||
if (regexec(ink->end, line->data + index, 1,
|
||||
&endmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
line->multidata[ink->id] = CSTARTENDHERE;
|
||||
/* If there is an end match on this same line, mark the line,
|
||||
* but continue looking for other starts after it. */
|
||||
if (regexec(ink->end, line->data + index, 1, &endmatch,
|
||||
(index == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
line->multidata[ink->id] = JUSTONTHIS;
|
||||
|
||||
index += endmatch.rm_eo;
|
||||
/* If both start and end are mere anchors, step ahead. */
|
||||
if (startmatch.rm_so == startmatch.rm_eo &&
|
||||
endmatch.rm_so == endmatch.rm_eo) {
|
||||
/* When at end-of-line, we're done. */
|
||||
|
||||
/* If the total match has zero length, force an advance. */
|
||||
if (startmatch.rm_eo - startmatch.rm_so + endmatch.rm_eo == 0) {
|
||||
/* When at end-of-line, there is no other start. */
|
||||
if (line->data[index] == '\0')
|
||||
break;
|
||||
index = step_right(line->data, index);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Look for an end match on later lines. */
|
||||
tailline = line->next;
|
||||
|
||||
while (tailline != NULL) {
|
||||
if (regexec(ink->end, tailline->data, 1, &endmatch, 0) == 0)
|
||||
break;
|
||||
while (tailline && regexec(ink->end, tailline->data,
|
||||
1, &endmatch, 0) != 0)
|
||||
tailline = tailline->next;
|
||||
}
|
||||
|
||||
/* When there is no end match, mark relevant lines as such. */
|
||||
if (tailline == NULL) {
|
||||
line->multidata[ink->id] = CWOULDBE;
|
||||
for (; line->next != NULL; line = line->next)
|
||||
line->multidata[ink->id] = WOULDBE;
|
||||
line->multidata[ink->id] = WOULDBE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* We found it, we found it, la la la la la. Mark all
|
||||
* the lines in between and the end properly. */
|
||||
line->multidata[ink->id] = CENDAFTER;
|
||||
/* We found it, we found it, la lala lala. Mark the lines. */
|
||||
line->multidata[ink->id] = STARTSHERE;
|
||||
|
||||
// Note that this also advances the line in the main loop.
|
||||
for (line = line->next; line != tailline; line = line->next)
|
||||
line->multidata[ink->id] = CWHOLELINE;
|
||||
line->multidata[ink->id] = WHOLELINE;
|
||||
|
||||
tailline->multidata[ink->id] = CBEGINBEFORE;
|
||||
tailline->multidata[ink->id] = ENDSHERE;
|
||||
|
||||
/* Begin looking for a new start after the end match. */
|
||||
/* Look for a possible new start after the end match. */
|
||||
index = endmatch.rm_eo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TIMEPRECALC
|
||||
statusline(INFO, "Precalculation: %.1f ms", 1000 * (double)(clock() - start) / CLOCKS_PER_SEC);
|
||||
napms(1200);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* ENABLE_COLOR */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* cut.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014 Mark Majeres *
|
||||
* Copyright (C) 2016, 2018-2020 Benno Schulenberg *
|
||||
* *
|
||||
@@ -712,7 +712,7 @@ void paste_text(void)
|
||||
/* The leftedge where we started the paste. */
|
||||
|
||||
if (cutbuffer == NULL) {
|
||||
statusbar(_("Cutbuffer is empty"));
|
||||
statusline(AHEM, _("Cutbuffer is empty"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -734,6 +734,10 @@ void paste_text(void)
|
||||
/* If we pasted less than a screenful, don't center the cursor. */
|
||||
if (less_than_a_screenful(was_lineno, was_leftedge))
|
||||
focusing = FALSE;
|
||||
#ifdef ENABLE_COLOR
|
||||
else
|
||||
precalc_multicolorinfo();
|
||||
#endif
|
||||
|
||||
/* Set the desired x position to where the pasted text ends. */
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* definitions.h -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2017 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -41,10 +41,55 @@
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
/* Set a default value for PATH_MAX if there isn't one. */
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 4096
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include <dirent.h>
|
||||
#include <regex.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* Prefer wide ncurses over normal ncurses over curses. */
|
||||
#if defined(HAVE_NCURSESW_NCURSES_H)
|
||||
#include <ncursesw/ncurses.h>
|
||||
#elif defined(HAVE_NCURSES_H)
|
||||
#include <ncurses.h>
|
||||
#else
|
||||
#include <curses.h>
|
||||
#endif
|
||||
|
||||
/* Native language support. */
|
||||
#ifdef ENABLE_NLS
|
||||
#ifdef HAVE_LIBINTL_H
|
||||
#include <libintl.h>
|
||||
#endif
|
||||
#define _(string) gettext(string)
|
||||
#define P_(singular, plural, number) ngettext(singular, plural, number)
|
||||
#else
|
||||
#define _(string) (string)
|
||||
#define P_(singular, plural, number) (number == 1 ? singular : plural)
|
||||
#endif
|
||||
/* For marking a string on which gettext() will be called later. */
|
||||
#define gettext_noop(string) (string)
|
||||
#define N_(string) gettext_noop(string)
|
||||
|
||||
/* If we aren't using an ncurses with mouse support, then
|
||||
* exclude the mouse routines, as they are useless then. */
|
||||
#ifndef NCURSES_MOUSE_VERSION
|
||||
#undef ENABLE_MOUSE
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_WRAPPING) || defined(ENABLE_JUSTIFY)
|
||||
#define ENABLED_WRAPORJUSTIFY 1
|
||||
#endif
|
||||
|
||||
/* Suppress warnings for __attribute__((warn_unused_result)). */
|
||||
#define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0)
|
||||
|
||||
@@ -56,66 +101,6 @@
|
||||
#define ISSET(flag) ((FLAGS(flag) & FLAGMASK(flag)) != 0)
|
||||
#define TOGGLE(flag) FLAGS(flag) ^= FLAGMASK(flag)
|
||||
|
||||
/* In UTF-8 a character is at most six bytes long. */
|
||||
#ifdef ENABLE_UTF8
|
||||
#define MAXCHARLEN 6
|
||||
#else
|
||||
#define MAXCHARLEN 1
|
||||
#endif
|
||||
|
||||
/* Set a default value for PATH_MAX if there isn't one. */
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 4096
|
||||
#endif
|
||||
|
||||
#ifdef USE_SLANG
|
||||
/* Slang support. */
|
||||
#include <slcurses.h>
|
||||
/* Slang curses emulation brain damage, part 3: Slang doesn't define the
|
||||
* curses equivalents of the Insert or Delete keys. */
|
||||
#define KEY_DC SL_KEY_DELETE
|
||||
#define KEY_IC SL_KEY_IC
|
||||
/* Ncurses support. */
|
||||
#elif defined(HAVE_NCURSESW_NCURSES_H)
|
||||
#include <ncursesw/ncurses.h>
|
||||
#elif defined(HAVE_NCURSES_H)
|
||||
#include <ncurses.h>
|
||||
#else
|
||||
/* Curses support. */
|
||||
#include <curses.h>
|
||||
#endif /* CURSES_H */
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
/* Native language support. */
|
||||
#ifdef HAVE_LIBINTL_H
|
||||
#include <libintl.h>
|
||||
#endif
|
||||
#define _(string) gettext(string)
|
||||
#define P_(singular, plural, number) ngettext(singular, plural, number)
|
||||
#else
|
||||
#define _(string) (string)
|
||||
#define P_(singular, plural, number) (number == 1 ? singular : plural)
|
||||
#endif
|
||||
#define gettext_noop(string) (string)
|
||||
#define N_(string) gettext_noop(string)
|
||||
/* Mark a string that will be sent to gettext() later. */
|
||||
|
||||
#include <dirent.h>
|
||||
#include <regex.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* If we aren't using an ncurses with mouse support, exclude any
|
||||
* mouse routines, as they are useless then. */
|
||||
#ifndef NCURSES_MOUSE_VERSION
|
||||
#undef ENABLE_MOUSE
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_WRAPPING) || defined(ENABLE_JUSTIFY)
|
||||
#define ENABLED_WRAPORJUSTIFY 1
|
||||
#endif
|
||||
|
||||
#define BACKWARD FALSE
|
||||
#define FORWARD TRUE
|
||||
|
||||
@@ -126,9 +111,137 @@
|
||||
#define REPLACING 1
|
||||
#define INREGION 2
|
||||
|
||||
/* In UTF-8 a character is at most six bytes long. */
|
||||
#ifdef ENABLE_UTF8
|
||||
#define MAXCHARLEN 6
|
||||
#else
|
||||
#define MAXCHARLEN 1
|
||||
#endif
|
||||
|
||||
/* The default width of a tab in spaces. */
|
||||
#define WIDTH_OF_TAB 8
|
||||
|
||||
/* The default number of columns from end of line where wrapping occurs. */
|
||||
#define COLUMNS_FROM_EOL 8
|
||||
|
||||
/* The default comment character when a syntax does not specify any. */
|
||||
#define GENERAL_COMMENT_CHARACTER "#"
|
||||
|
||||
/* The maximum number of search/replace history strings saved. */
|
||||
#define MAX_SEARCH_HISTORY 100
|
||||
|
||||
/* The largest size_t number that doesn't have the high bit set. */
|
||||
#define HIGHEST_POSITIVE ((~(size_t)0) >> 1)
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
#define THE_DEFAULT -1
|
||||
#define BAD_COLOR -2
|
||||
|
||||
/* Flags for indicating how a multiline regex pair apply to a line. */
|
||||
#define NOTHING (1<<1)
|
||||
/* The start/end regexes don't cover this line at all. */
|
||||
#define STARTSHERE (1<<2)
|
||||
/* The start regex matches on this line, the end regex on a later one. */
|
||||
#define WHOLELINE (1<<3)
|
||||
/* The start regex matches on an earlier line, the end regex on a later one. */
|
||||
#define ENDSHERE (1<<4)
|
||||
/* The start regex matches on an earlier line, the end regex on this one. */
|
||||
#define JUSTONTHIS (1<<5)
|
||||
/* Both the start and end regexes match within this line. */
|
||||
#define WOULDBE (1<<6)
|
||||
/* An unpaired start match is on or before this line. */
|
||||
#endif
|
||||
|
||||
/* Basic control codes. */
|
||||
#define ESC_CODE 0x1B
|
||||
#define DEL_CODE 0x7F
|
||||
|
||||
/* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */
|
||||
#define CONTROL_LEFT 0x401
|
||||
#define CONTROL_RIGHT 0x402
|
||||
#define CONTROL_UP 0x403
|
||||
#define CONTROL_DOWN 0x404
|
||||
#define CONTROL_HOME 0x405
|
||||
#define CONTROL_END 0x406
|
||||
#define CONTROL_DELETE 0x40D
|
||||
#define SHIFT_CONTROL_LEFT 0x411
|
||||
#define SHIFT_CONTROL_RIGHT 0x412
|
||||
#define SHIFT_CONTROL_UP 0x413
|
||||
#define SHIFT_CONTROL_DOWN 0x414
|
||||
#define SHIFT_CONTROL_HOME 0x415
|
||||
#define SHIFT_CONTROL_END 0x416
|
||||
#define CONTROL_SHIFT_DELETE 0x41D
|
||||
#define ALT_LEFT 0x421
|
||||
#define ALT_RIGHT 0x422
|
||||
#define ALT_UP 0x423
|
||||
#define ALT_DOWN 0x424
|
||||
#define ALT_PAGEUP 0x427
|
||||
#define ALT_PAGEDOWN 0x428
|
||||
#define ALT_INSERT 0x42C
|
||||
#define ALT_DELETE 0x42D
|
||||
#define SHIFT_ALT_LEFT 0x431
|
||||
#define SHIFT_ALT_RIGHT 0x432
|
||||
#define SHIFT_ALT_UP 0x433
|
||||
#define SHIFT_ALT_DOWN 0x434
|
||||
//#define SHIFT_LEFT 0x451
|
||||
//#define SHIFT_RIGHT 0x452
|
||||
#define SHIFT_UP 0x453
|
||||
#define SHIFT_DOWN 0x454
|
||||
#define SHIFT_HOME 0x455
|
||||
#define SHIFT_END 0x456
|
||||
#define SHIFT_PAGEUP 0x457
|
||||
#define SHIFT_PAGEDOWN 0x458
|
||||
#define SHIFT_DELETE 0x45D
|
||||
#define SHIFT_TAB 0x45F
|
||||
|
||||
/* A special keycode for when <Tab> is pressed while the mark is on. */
|
||||
#define INDENT_KEY 0x4F1
|
||||
|
||||
/* A special keycode to signal the beginning and end of a bracketed paste. */
|
||||
#define BRACKETED_PASTE_MARKER 0x4FB
|
||||
|
||||
/* A special keycode for when a key produces an unknown escape sequence. */
|
||||
#define FOREIGN_SEQUENCE 0x4FC
|
||||
|
||||
/* A special keycode for plugging into the input stream after a suspension. */
|
||||
#define KEY_FLUSH KEY_F0
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* A special keycode for when we get a SIGWINCH (a window resize). */
|
||||
#define KEY_WINCH -2
|
||||
|
||||
/* Some extra flags for the undo function. */
|
||||
#define WAS_BACKSPACE_AT_EOF (1<<1)
|
||||
#define WAS_WHOLE_LINE (1<<2)
|
||||
#define INCLUDED_LAST_LINE (1<<3)
|
||||
#define MARK_WAS_SET (1<<4)
|
||||
#define CURSOR_WAS_AT_HEAD (1<<5)
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Identifiers for the different menus. */
|
||||
#define MMAIN (1<<0)
|
||||
#define MWHEREIS (1<<1)
|
||||
#define MREPLACE (1<<2)
|
||||
#define MREPLACEWITH (1<<3)
|
||||
#define MGOTOLINE (1<<4)
|
||||
#define MWRITEFILE (1<<5)
|
||||
#define MINSERTFILE (1<<6)
|
||||
#define MEXECUTE (1<<7)
|
||||
#define MHELP (1<<8)
|
||||
#define MSPELL (1<<9)
|
||||
#define MBROWSER (1<<10)
|
||||
#define MWHEREISFILE (1<<11)
|
||||
#define MGOTODIR (1<<12)
|
||||
#define MYESNO (1<<13)
|
||||
#define MLINTER (1<<14)
|
||||
#define MFINDINHELP (1<<15)
|
||||
/* This is an abbreviation for all menus except Help and Browser and YesNo. */
|
||||
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\
|
||||
MEXECUTE|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER)
|
||||
#ifndef NANO_TINY
|
||||
#define MSOME MMOST|MBROWSER
|
||||
#else
|
||||
#define MSOME MMAIN|MBROWSER
|
||||
#endif
|
||||
|
||||
/* Enumeration types. */
|
||||
@@ -137,17 +250,13 @@ typedef enum {
|
||||
} format_type;
|
||||
|
||||
typedef enum {
|
||||
VACUUM, HUSH, NOTICE, MILD, ALERT
|
||||
VACUUM, HUSH, REMARK, INFO, NOTICE, AHEM, MILD, ALERT
|
||||
} message_type;
|
||||
|
||||
typedef enum {
|
||||
OVERWRITE, APPEND, PREPEND
|
||||
} kind_of_writing_type;
|
||||
|
||||
typedef enum {
|
||||
SOFTMARK, HARDMARK
|
||||
} mark_type;
|
||||
|
||||
typedef enum {
|
||||
CENTERING, FLOWING, STATIONARY
|
||||
} update_type;
|
||||
@@ -166,6 +275,78 @@ typedef enum {
|
||||
COUPLE_BEGIN, COUPLE_END, OTHER
|
||||
} undo_type;
|
||||
|
||||
/* The elements of the interface that can be colored differently. */
|
||||
enum {
|
||||
TITLE_BAR = 0,
|
||||
LINE_NUMBER,
|
||||
GUIDE_STRIPE,
|
||||
SCROLL_BAR,
|
||||
SELECTED_TEXT,
|
||||
HIGHLIGHTED,
|
||||
PROMPT_BAR,
|
||||
STATUS_BAR,
|
||||
ERROR_MESSAGE,
|
||||
KEY_COMBO,
|
||||
FUNCTION_TAG,
|
||||
NUMBER_OF_ELEMENTS
|
||||
};
|
||||
|
||||
/* Enumeration used in the flags array. See the definition of FLAGMASK. */
|
||||
enum {
|
||||
DONTUSE = 0,
|
||||
CASE_SENSITIVE,
|
||||
CONSTANT_SHOW,
|
||||
NO_HELP,
|
||||
SUSPENDABLE,
|
||||
NO_WRAP,
|
||||
AUTOINDENT,
|
||||
VIEW_MODE,
|
||||
USE_MOUSE,
|
||||
USE_REGEXP,
|
||||
SAVE_ON_EXIT,
|
||||
CUT_FROM_CURSOR,
|
||||
BACKWARDS_SEARCH,
|
||||
MULTIBUFFER,
|
||||
SMOOTH_SCROLL,
|
||||
REBIND_DELETE,
|
||||
RAW_SEQUENCES,
|
||||
NO_CONVERT,
|
||||
MAKE_BACKUP,
|
||||
INSECURE_BACKUP,
|
||||
NO_SYNTAX,
|
||||
PRESERVE,
|
||||
HISTORYLOG,
|
||||
RESTRICTED,
|
||||
SMART_HOME,
|
||||
WHITESPACE_DISPLAY,
|
||||
MORE_SPACE,
|
||||
TABS_TO_SPACES,
|
||||
QUICK_BLANK,
|
||||
WORD_BOUNDS,
|
||||
NO_NEWLINES,
|
||||
BOLD_TEXT,
|
||||
SOFTWRAP,
|
||||
POSITIONLOG,
|
||||
LOCKING,
|
||||
NOREAD_MODE,
|
||||
MAKE_IT_UNIX,
|
||||
TRIM_BLANKS,
|
||||
SHOW_CURSOR,
|
||||
LINE_NUMBERS,
|
||||
NO_PAUSES,
|
||||
AT_BLANKS,
|
||||
AFTER_ENDS,
|
||||
LET_THEM_ZAP,
|
||||
BREAK_LONG_LINES,
|
||||
JUMPY_SCROLLING,
|
||||
EMPTY_LINE,
|
||||
INDICATOR,
|
||||
BOOKSTYLE,
|
||||
STATEFLAGS,
|
||||
USE_MAGIC,
|
||||
MINIBAR
|
||||
};
|
||||
|
||||
/* Structure types. */
|
||||
#ifdef ENABLE_COLOR
|
||||
typedef struct colortype {
|
||||
@@ -212,7 +393,7 @@ typedef struct syntaxtype {
|
||||
/* File where the syntax is defined, or NULL if not an included file. */
|
||||
size_t lineno;
|
||||
/* The line number where the 'syntax' command was found. */
|
||||
struct augmentstruct *augmentations;
|
||||
augmentstruct *augmentations;
|
||||
/* List of extendsyntax commands to apply when loaded. */
|
||||
regexlisttype *extensions;
|
||||
/* The list of extensions that this syntax applies to. */
|
||||
@@ -252,20 +433,6 @@ typedef struct lintstruct {
|
||||
struct lintstruct *prev;
|
||||
/* Previous error. */
|
||||
} lintstruct;
|
||||
|
||||
/* Flags that indicate how a multiline regex applies to a line. */
|
||||
#define CNONE (1<<1)
|
||||
/* Yay, regex doesn't apply to this line at all! */
|
||||
#define CBEGINBEFORE (1<<2)
|
||||
/* Regex starts on an earlier line, ends on this one. */
|
||||
#define CENDAFTER (1<<3)
|
||||
/* Regex starts on this line and ends on a later one. */
|
||||
#define CWHOLELINE (1<<4)
|
||||
/* Whole line engulfed by the regex, start < me, end > me. */
|
||||
#define CSTARTENDHERE (1<<5)
|
||||
/* Regex starts and ends within this line. */
|
||||
#define CWOULDBE (1<<6)
|
||||
/* An unpaired start match on or before this line. */
|
||||
#endif /* ENABLE_COLOR */
|
||||
|
||||
/* More structure types. */
|
||||
@@ -378,8 +545,8 @@ typedef struct openfilestruct {
|
||||
/* The line in the file where the mark is set; NULL if not set. */
|
||||
size_t mark_x;
|
||||
/* The mark's x position in the above line. */
|
||||
mark_type kind_of_mark;
|
||||
/* Whether it is a soft (with Shift) or a hard mark. */
|
||||
bool softmark;
|
||||
/* Whether a marked region was made by holding Shift. */
|
||||
format_type fmt;
|
||||
/* The file's format -- Unix or DOS or Mac. */
|
||||
char *lock_filename;
|
||||
@@ -466,185 +633,3 @@ typedef struct completion_word {
|
||||
struct completion_word *next;
|
||||
} completion_word;
|
||||
#endif
|
||||
|
||||
/* The elements of the interface that can be colored differently. */
|
||||
enum
|
||||
{
|
||||
TITLE_BAR = 0,
|
||||
LINE_NUMBER,
|
||||
GUIDE_STRIPE,
|
||||
SCROLL_BAR,
|
||||
SELECTED_TEXT,
|
||||
STATUS_BAR,
|
||||
ERROR_MESSAGE,
|
||||
KEY_COMBO,
|
||||
FUNCTION_TAG,
|
||||
NUMBER_OF_ELEMENTS
|
||||
};
|
||||
|
||||
/* Enumeration used in the flags array. See the definition of FLAGMASK. */
|
||||
enum
|
||||
{
|
||||
DONTUSE,
|
||||
CASE_SENSITIVE,
|
||||
CONSTANT_SHOW,
|
||||
NO_HELP,
|
||||
SUSPENDABLE,
|
||||
NO_WRAP,
|
||||
AUTOINDENT,
|
||||
VIEW_MODE,
|
||||
USE_MOUSE,
|
||||
USE_REGEXP,
|
||||
SAVE_ON_EXIT,
|
||||
CUT_FROM_CURSOR,
|
||||
BACKWARDS_SEARCH,
|
||||
MULTIBUFFER,
|
||||
SMOOTH_SCROLL,
|
||||
REBIND_DELETE,
|
||||
RAW_SEQUENCES,
|
||||
NO_CONVERT,
|
||||
MAKE_BACKUP,
|
||||
INSECURE_BACKUP,
|
||||
NO_SYNTAX,
|
||||
PRESERVE,
|
||||
HISTORYLOG,
|
||||
RESTRICTED,
|
||||
SMART_HOME,
|
||||
WHITESPACE_DISPLAY,
|
||||
MORE_SPACE,
|
||||
TABS_TO_SPACES,
|
||||
QUICK_BLANK,
|
||||
WORD_BOUNDS,
|
||||
NO_NEWLINES,
|
||||
BOLD_TEXT,
|
||||
SOFTWRAP,
|
||||
POSITIONLOG,
|
||||
LOCKING,
|
||||
NOREAD_MODE,
|
||||
MAKE_IT_UNIX,
|
||||
TRIM_BLANKS,
|
||||
SHOW_CURSOR,
|
||||
LINE_NUMBERS,
|
||||
NO_PAUSES,
|
||||
AT_BLANKS,
|
||||
AFTER_ENDS,
|
||||
LET_THEM_ZAP,
|
||||
BREAK_LONG_LINES,
|
||||
JUMPY_SCROLLING,
|
||||
EMPTY_LINE,
|
||||
INDICATOR,
|
||||
BOOKSTYLE,
|
||||
STATEFLAGS,
|
||||
USE_MAGIC
|
||||
};
|
||||
|
||||
/* Flags for the menus in which a given function should be present. */
|
||||
#define MMAIN (1<<0)
|
||||
#define MWHEREIS (1<<1)
|
||||
#define MREPLACE (1<<2)
|
||||
#define MREPLACEWITH (1<<3)
|
||||
#define MGOTOLINE (1<<4)
|
||||
#define MWRITEFILE (1<<5)
|
||||
#define MINSERTFILE (1<<6)
|
||||
#define MEXECUTE (1<<7)
|
||||
#define MHELP (1<<8)
|
||||
#define MSPELL (1<<9)
|
||||
#define MBROWSER (1<<10)
|
||||
#define MWHEREISFILE (1<<11)
|
||||
#define MGOTODIR (1<<12)
|
||||
#define MYESNO (1<<13)
|
||||
#define MLINTER (1<<14)
|
||||
#define MFINDINHELP (1<<15)
|
||||
/* This is an abbreviation for all menus except Help and Browser and YesNo. */
|
||||
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\
|
||||
MEXECUTE|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER)
|
||||
#ifndef NANO_TINY
|
||||
#define MSOME MMOST|MBROWSER
|
||||
#else
|
||||
#define MSOME MMAIN|MBROWSER
|
||||
#endif
|
||||
|
||||
/* Basic control codes. */
|
||||
#define ESC_CODE 0x1B
|
||||
#define DEL_CODE 0x7F
|
||||
|
||||
/* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */
|
||||
#define CONTROL_LEFT 0x401
|
||||
#define CONTROL_RIGHT 0x402
|
||||
#define CONTROL_UP 0x403
|
||||
#define CONTROL_DOWN 0x404
|
||||
#define CONTROL_HOME 0x405
|
||||
#define CONTROL_END 0x406
|
||||
#define CONTROL_DELETE 0x40D
|
||||
#define SHIFT_CONTROL_LEFT 0x411
|
||||
#define SHIFT_CONTROL_RIGHT 0x412
|
||||
#define SHIFT_CONTROL_UP 0x413
|
||||
#define SHIFT_CONTROL_DOWN 0x414
|
||||
#define SHIFT_CONTROL_HOME 0x415
|
||||
#define SHIFT_CONTROL_END 0x416
|
||||
#define CONTROL_SHIFT_DELETE 0x41D
|
||||
#define ALT_LEFT 0x421
|
||||
#define ALT_RIGHT 0x422
|
||||
#define ALT_UP 0x423
|
||||
#define ALT_DOWN 0x424
|
||||
#define ALT_PAGEUP 0x427
|
||||
#define ALT_PAGEDOWN 0x428
|
||||
#define ALT_INSERT 0x42C
|
||||
#define ALT_DELETE 0x42D
|
||||
#define SHIFT_ALT_LEFT 0x431
|
||||
#define SHIFT_ALT_RIGHT 0x432
|
||||
#define SHIFT_ALT_UP 0x433
|
||||
#define SHIFT_ALT_DOWN 0x434
|
||||
//#define SHIFT_LEFT 0x451
|
||||
//#define SHIFT_RIGHT 0x452
|
||||
#define SHIFT_UP 0x453
|
||||
#define SHIFT_DOWN 0x454
|
||||
#define SHIFT_HOME 0x455
|
||||
#define SHIFT_END 0x456
|
||||
#define SHIFT_PAGEUP 0x457
|
||||
#define SHIFT_PAGEDOWN 0x458
|
||||
#define SHIFT_DELETE 0x45D
|
||||
#define SHIFT_TAB 0x45F
|
||||
|
||||
/* A special keycode for when <Tab> is pressed while the mark is on. */
|
||||
#define INDENT_KEY 0x4F1
|
||||
|
||||
/* A special keycode to signal the beginning and end of a bracketed paste. */
|
||||
#define BRACKETED_PASTE_MARKER 0x4FB
|
||||
|
||||
/* A special keycode for when a key produces an unknown escape sequence. */
|
||||
#define FOREIGN_SEQUENCE 0x4FC
|
||||
|
||||
#ifdef USE_SLANG
|
||||
#define KEY_FLUSH 0xFF /* Clipped error code. */
|
||||
#else
|
||||
#define KEY_FLUSH KEY_F0 /* Nonexistent function key. */
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* An imaginary key for when we get a SIGWINCH (window resize). */
|
||||
#define KEY_WINCH -2
|
||||
|
||||
/* Some extra flags for the undo function. */
|
||||
#define WAS_BACKSPACE_AT_EOF (1<<1)
|
||||
#define WAS_WHOLE_LINE (1<<2)
|
||||
#define INCLUDED_LAST_LINE (1<<3)
|
||||
#define MARK_WAS_SET (1<<4)
|
||||
#define CURSOR_WAS_AT_HEAD (1<<5)
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* The default number of columns from end of line where wrapping occurs. */
|
||||
#define COLUMNS_FROM_EOL 8
|
||||
|
||||
/* The default width of a tab in spaces. */
|
||||
#define WIDTH_OF_TAB 8
|
||||
|
||||
/* The default comment character when a syntax does not specify any. */
|
||||
#define GENERAL_COMMENT_CHARACTER "#"
|
||||
|
||||
/* The maximum number of search/replace history strings saved, not
|
||||
* counting the blank lines at their ends. */
|
||||
#define MAX_SEARCH_HISTORY 100
|
||||
|
||||
/* The largest size_t number that doesn't have the high bit set. */
|
||||
#define HIGHEST_POSITIVE ((~(size_t)0) >> 1)
|
||||
|
||||
72
src/files.c
72
src/files.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* files.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2015-2020 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -81,6 +81,7 @@ void make_new_buffer(void)
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
openfile->mark = NULL;
|
||||
openfile->softmark = FALSE;
|
||||
|
||||
openfile->fmt = NIX_FILE;
|
||||
|
||||
@@ -97,6 +98,26 @@ void make_new_buffer(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Return the given file name in a way that fits within the given space. */
|
||||
char *crop_to_fit(const char *name, int room)
|
||||
{
|
||||
char *clipped;
|
||||
|
||||
if (breadth(name) <= room)
|
||||
return display_string(name, 0, room, FALSE, FALSE);
|
||||
|
||||
if (room < 4)
|
||||
return copy_of("_");
|
||||
|
||||
clipped = display_string(name, breadth(name) - room + 3, room, FALSE, FALSE);
|
||||
|
||||
clipped = nrealloc(clipped, strlen(clipped) + 4);
|
||||
memmove(clipped + 3, clipped, strlen(clipped) + 1);
|
||||
clipped[0] = '.'; clipped[1] = '.'; clipped[2] = '.';
|
||||
|
||||
return clipped;
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Delete the lockfile. Return TRUE on success, and FALSE otherwise. */
|
||||
bool delete_lockfile(const char *lockfilename)
|
||||
@@ -225,7 +246,7 @@ char *do_lockfile(const char *filename, bool ask_the_user)
|
||||
else if (stat(lockfilename, &fileinfo) != -1) {
|
||||
char *lockbuf, *question, *pidstring, *postedname, *promptstr;
|
||||
static char lockprog[11], lockuser[17];
|
||||
int lockfd, lockpid, room, choice;
|
||||
int lockfd, lockpid, choice;
|
||||
ssize_t readamt;
|
||||
|
||||
if ((lockfd = open(lockfilename, O_RDONLY)) < 0) {
|
||||
@@ -266,19 +287,8 @@ char *do_lockfile(const char *filename, bool ask_the_user)
|
||||
|
||||
/* TRANSLATORS: The second %s is the name of the user, the third that of the editor. */
|
||||
question = _("File %s is being edited by %s (with %s, PID %s); open anyway?");
|
||||
room = COLS - breadth(question) + 7 - breadth(lockuser) -
|
||||
breadth(lockprog) - breadth(pidstring);
|
||||
if (room < 4)
|
||||
postedname = copy_of("_");
|
||||
else if (room < breadth(filename)) {
|
||||
char *fragment = display_string(filename,
|
||||
breadth(filename) - room + 3, room, FALSE, FALSE);
|
||||
postedname = nmalloc(strlen(fragment) + 4);
|
||||
strcpy(postedname, "...");
|
||||
strcat(postedname, fragment);
|
||||
free(fragment);
|
||||
} else
|
||||
postedname = display_string(filename, 0, room, FALSE, FALSE);
|
||||
postedname = crop_to_fit(filename, COLS - breadth(question) - breadth(lockuser) -
|
||||
breadth(lockprog) - breadth(pidstring) + 7);
|
||||
|
||||
/* Allow extra space for username (14), program name (8), PID (8),
|
||||
* and terminating \0 (1), minus the %s (2) for the file name. */
|
||||
@@ -488,7 +498,8 @@ void prepare_for_display(void)
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
/* Precalculate the data for any multiline coloring regexes. */
|
||||
precalc_multicolorinfo();
|
||||
if (!openfile->filetop->multidata)
|
||||
precalc_multicolorinfo();
|
||||
have_palette = FALSE;
|
||||
#endif
|
||||
refresh_needed = TRUE;
|
||||
@@ -500,7 +511,13 @@ void mention_name_and_linecount(void)
|
||||
{
|
||||
size_t count = openfile->filebot->lineno -
|
||||
(openfile->filebot->data[0] == '\0' ? 1 : 0);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(MINIBAR)) {
|
||||
report_size = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (openfile->fmt != NIX_FILE)
|
||||
/* TRANSLATORS: First %s is file name, second %s is file format. */
|
||||
statusline(HUSH, P_("%s -- %zu line (%s)", "%s -- %zu lines (%s)", count),
|
||||
@@ -519,7 +536,7 @@ void redecorate_after_switch(void)
|
||||
{
|
||||
/* If only one file buffer is open, there is nothing to update. */
|
||||
if (openfile == openfile->next) {
|
||||
statusbar(_("No more open file buffers"));
|
||||
statusline(AHEM, _("No more open file buffers"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -802,6 +819,10 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||
/* If we inserted less than a screenful, don't center the cursor. */
|
||||
if (undoable && less_than_a_screenful(was_lineno, was_leftedge))
|
||||
focusing = FALSE;
|
||||
#ifdef ENABLE_COLOR
|
||||
else if (undoable)
|
||||
precalc_multicolorinfo();
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (undoable)
|
||||
@@ -831,7 +852,7 @@ int open_file(const char *filename, bool new_one, FILE **f)
|
||||
free(full_filename);
|
||||
|
||||
if (new_one) {
|
||||
statusbar(_("New File"));
|
||||
statusline(REMARK, _("New File"));
|
||||
return 0;
|
||||
} else {
|
||||
statusline(ALERT, _("File \"%s\" not found"), filename);
|
||||
@@ -1981,8 +2002,13 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
titlebar(NULL);
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(MINIBAR) && fullbuffer && !tmp)
|
||||
report_size = TRUE;
|
||||
else
|
||||
#endif
|
||||
if (!tmp)
|
||||
statusline(HUSH, P_("Wrote %zu line", "Wrote %zu lines",
|
||||
statusline(REMARK, P_("Wrote %zu line", "Wrote %zu lines",
|
||||
lineswritten), lineswritten);
|
||||
retval = TRUE;
|
||||
|
||||
@@ -2164,7 +2190,7 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
did_credits = TRUE;
|
||||
} else
|
||||
/* TRANSLATORS: Concisely say the screen is too small. */
|
||||
statusbar(_("Too tiny"));
|
||||
statusline(AHEM, _("Too tiny"));
|
||||
|
||||
free(given);
|
||||
return 0;
|
||||
@@ -2216,10 +2242,8 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
|
||||
if (name_exists) {
|
||||
char *question = _("File \"%s\" exists; OVERWRITE? ");
|
||||
char *name = display_string(answer, 0,
|
||||
COLS - breadth(question) + 1, FALSE, FALSE);
|
||||
char *message = nmalloc(strlen(question) +
|
||||
strlen(name) + 1);
|
||||
char *name = crop_to_fit(answer, COLS - breadth(question) + 1);
|
||||
char *message = nmalloc(strlen(question) + strlen(name) + 1);
|
||||
|
||||
sprintf(message, question, name);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* global.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2020 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -49,7 +49,8 @@ bool we_are_running = FALSE;
|
||||
/* Becomes TRUE as soon as all options and files have been read. */
|
||||
bool more_than_one = FALSE;
|
||||
/* Whether more than one buffer is or has been open. */
|
||||
|
||||
bool report_size = TRUE;
|
||||
/* Whether to show the number of lines when the minibar is used. */
|
||||
bool ran_a_tool = FALSE;
|
||||
/* Whether a tool has been run at the Execute-Command prompt. */
|
||||
|
||||
@@ -79,6 +80,8 @@ linestruct *pletion_line = NULL;
|
||||
bool also_the_last = FALSE;
|
||||
/* Whether indenting/commenting should include the last line of
|
||||
* the marked region. */
|
||||
bool hide_cursor = FALSE;
|
||||
/* Whether to suppress the cursor when highlighting a search match. */
|
||||
|
||||
char *answer = NULL;
|
||||
/* The answer string used by the status-bar prompt. */
|
||||
@@ -946,7 +949,7 @@ void shortcut_init(void)
|
||||
N_("Next Block"), WITHORSANS(nextblock_gist), TOGETHER, VIEW);
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
add_to_funcs(to_para_begin, MMAIN|MGOTOLINE,
|
||||
/* TRANSLATORS: Try to keep these two strings at most 15 characters. */
|
||||
/* TRANSLATORS: Try to keep these two strings at most 16 characters. */
|
||||
N_("Begin of Paragr."), WITHORSANS(parabegin_gist), TOGETHER, VIEW);
|
||||
add_to_funcs(to_para_end, MMAIN|MGOTOLINE,
|
||||
N_("End of Paragraph"), WITHORSANS(paraend_gist), BLANKAFTER, VIEW);
|
||||
|
||||
12
src/help.c
12
src/help.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* help.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2000-2011, 2013-2020 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2000-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2017 Rishabh Dave *
|
||||
* Copyright (C) 2014-2019 Benno Schulenberg *
|
||||
* *
|
||||
@@ -50,7 +50,7 @@ void help_init(void)
|
||||
char *ptr;
|
||||
|
||||
/* First, set up the initial help text for the current function. */
|
||||
if (currmenu == MWHEREIS || currmenu == MREPLACE || currmenu == MREPLACEWITH) {
|
||||
if (currmenu & (MWHEREIS|MREPLACE|MREPLACEWITH)) {
|
||||
htx[0] = N_("Search Command Help Text\n\n "
|
||||
"Enter the words or characters you would like to "
|
||||
"search for, and then press Enter. If there is a "
|
||||
@@ -457,9 +457,13 @@ void show_help(void)
|
||||
|
||||
/* Show the cursor when we searched and found something. */
|
||||
kbinput = get_kbinput(edit, didfind == 1 || ISSET(SHOW_CURSOR));
|
||||
|
||||
didfind = 0;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
spotlighted = FALSE;
|
||||
hide_cursor = FALSE;
|
||||
|
||||
if (bracketed_paste || kbinput == BRACKETED_PASTE_MARKER) {
|
||||
beep();
|
||||
continue;
|
||||
@@ -548,7 +552,7 @@ void show_help(void)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_BROWSER
|
||||
if (oldmenu == MBROWSER || oldmenu == MWHEREISFILE || oldmenu == MGOTODIR)
|
||||
if (oldmenu & (MBROWSER|MWHEREISFILE|MGOTODIR))
|
||||
browser_refresh();
|
||||
else
|
||||
#endif
|
||||
@@ -566,7 +570,7 @@ void do_help(void)
|
||||
#ifdef ENABLE_HELP
|
||||
show_help();
|
||||
#else
|
||||
if (currmenu == MMAIN || currmenu == MBROWSER)
|
||||
if (currmenu & (MMAIN|MBROWSER))
|
||||
statusbar(_("^W = Ctrl+W M-W = Alt+W"));
|
||||
else
|
||||
beep();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* history.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2003-2011, 2013-2020 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2003-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2016, 2017, 2019 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* move.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2018 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
|
||||
193
src/nano.c
193
src/nano.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* nano.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2020 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -62,10 +62,6 @@ static struct termios original_state;
|
||||
|
||||
static struct sigaction oldaction, newaction;
|
||||
/* Containers for the original and the temporary handler for SIGINT. */
|
||||
#ifdef USE_SLANG
|
||||
static bool selfinduced = FALSE;
|
||||
/* Whether a suspension was caused from inside nano or from outside. */
|
||||
#endif
|
||||
|
||||
/* Create a new linestruct node. Note that we do not set prevnode->next. */
|
||||
linestruct *make_new_node(linestruct *prevnode)
|
||||
@@ -201,14 +197,14 @@ void renumber_from(linestruct *line)
|
||||
/* Display a warning about a key disabled in view mode. */
|
||||
void print_view_warning(void)
|
||||
{
|
||||
statusbar(_("Key is invalid in view mode"));
|
||||
statusline(AHEM, _("Key is invalid in view mode"));
|
||||
}
|
||||
|
||||
/* When in restricted mode, show a warning and return TRUE. */
|
||||
bool in_restricted_mode(void)
|
||||
{
|
||||
if (ISSET(RESTRICTED)) {
|
||||
statusbar(_("This function is disabled in restricted mode"));
|
||||
statusline(AHEM, _("This function is disabled in restricted mode"));
|
||||
beep();
|
||||
return TRUE;
|
||||
} else
|
||||
@@ -399,22 +395,28 @@ void window_init(void)
|
||||
delwin(bottomwin);
|
||||
}
|
||||
|
||||
topwin = NULL;
|
||||
|
||||
/* If the terminal is very flat, don't set up a title bar. */
|
||||
if (LINES < 3) {
|
||||
topwin = NULL;
|
||||
editwinrows = 1;
|
||||
/* Set up two subwindows. If the terminal is just one line,
|
||||
* edit window and status-bar window will cover each other. */
|
||||
edit = newwin(1, COLS, 0, 0);
|
||||
bottomwin = newwin(1, COLS, LINES - 1, 0);
|
||||
} else {
|
||||
int toprows = (!ISSET(EMPTY_LINE) ? 1 : (LINES < 6) ? 1 : 2);
|
||||
int bottomrows = (ISSET(NO_HELP) ? 1 : (LINES < 5) ? 1 : 3);
|
||||
int toprows = ((ISSET(EMPTY_LINE) && LINES > 5) ? 2 : 1);
|
||||
int bottomrows = ((ISSET(NO_HELP) || LINES < 5) ? 1 : 3);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(MINIBAR))
|
||||
toprows = 0;
|
||||
#endif
|
||||
editwinrows = LINES - toprows - bottomrows;
|
||||
|
||||
/* Set up the normal three subwindows. */
|
||||
topwin = newwin(toprows, COLS, 0, 0);
|
||||
if (toprows > 0)
|
||||
topwin = newwin(toprows, COLS, 0, 0);
|
||||
edit = newwin(editwinrows, COLS, toprows, 0);
|
||||
bottomwin = newwin(bottomrows, COLS, toprows + editwinrows, 0);
|
||||
}
|
||||
@@ -422,13 +424,11 @@ void window_init(void)
|
||||
/* In case the terminal shrunk, make sure the status line is clear. */
|
||||
wipe_statusbar();
|
||||
|
||||
#ifndef USE_SLANG
|
||||
/* When not disabled, turn escape-sequence translation on. */
|
||||
if (!ISSET(RAW_SEQUENCES)) {
|
||||
keypad(edit, TRUE);
|
||||
keypad(bottomwin, TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
/* Set up the wrapping point, accounting for screen width when negative. */
|
||||
@@ -526,10 +526,8 @@ void usage(void)
|
||||
print_opt(_("-J <number>"), _("--guidestripe=<number>"),
|
||||
N_("Show a guiding bar at this column"));
|
||||
#endif
|
||||
#ifndef USE_SLANG
|
||||
print_opt("-K", "--rawsequences",
|
||||
N_("Fix numeric keypad key confusion problem"));
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-L", "--nonewlines",
|
||||
N_("Don't add an automatic newline"));
|
||||
@@ -643,6 +641,7 @@ void usage(void)
|
||||
print_opt("-z", "--suspendable", N_("Enable suspension"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-%", "--stateflags", N_("Show some states on the title bar"));
|
||||
print_opt("-_", "--minibar", N_("Show a feedback bar at the bottom"));
|
||||
#endif
|
||||
#ifdef HAVE_LIBMAGIC
|
||||
print_opt("-!", "--magic", N_("Also try magic to determine syntax"));
|
||||
@@ -659,8 +658,8 @@ void version(void)
|
||||
printf(_(" GNU nano, version %s\n"), VERSION);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
printf(" (C) 1999-2011, 2013-2020 Free Software Foundation, Inc.\n");
|
||||
printf(_(" (C) 2014-%s the contributors to nano\n"), "2020");
|
||||
printf(" (C) 1999-2011, 2013-2021 Free Software Foundation, Inc.\n");
|
||||
printf(_(" (C) 2014-%s the contributors to nano\n"), "2021");
|
||||
#endif
|
||||
printf(_(" Compiled options:"));
|
||||
|
||||
@@ -775,9 +774,6 @@ void version(void)
|
||||
printf(" --enable-utf8");
|
||||
#else
|
||||
printf(" --disable-utf8");
|
||||
#endif
|
||||
#ifdef USE_SLANG
|
||||
printf(" --with-slang");
|
||||
#endif
|
||||
printf("\n");
|
||||
}
|
||||
@@ -956,18 +952,11 @@ void do_suspend(int signal)
|
||||
/* Put nano to sleep (if suspension is enabled). */
|
||||
void do_suspend_void(void)
|
||||
{
|
||||
if (ISSET(SUSPENDABLE)) {
|
||||
#ifdef USE_SLANG
|
||||
selfinduced = TRUE;
|
||||
do_suspend(0);
|
||||
selfinduced = FALSE;
|
||||
#else
|
||||
do_suspend(0);
|
||||
#endif
|
||||
} else {
|
||||
statusbar(_("Suspension is not enabled"));
|
||||
if (!ISSET(SUSPENDABLE)) {
|
||||
statusline(AHEM, _("Suspension is not enabled"));
|
||||
beep();
|
||||
}
|
||||
} else
|
||||
do_suspend(0);
|
||||
|
||||
ran_a_tool = TRUE;
|
||||
}
|
||||
@@ -987,13 +976,9 @@ void do_continue(int signal)
|
||||
/* Put the terminal in the desired state again. */
|
||||
terminal_init();
|
||||
#endif
|
||||
#ifdef USE_SLANG
|
||||
if (!selfinduced)
|
||||
full_refresh();
|
||||
#else
|
||||
|
||||
/* Insert a fake keystroke, to neutralize a key-eating issue. */
|
||||
ungetch(KEY_FLUSH);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_SPELLER) || defined(ENABLE_COLOR)
|
||||
@@ -1080,8 +1065,6 @@ void regenerate_screen(void)
|
||||
/* Handle the global toggle specified in flag. */
|
||||
void do_toggle(int flag)
|
||||
{
|
||||
bool enabled;
|
||||
|
||||
if (flag == SUSPENDABLE && in_restricted_mode())
|
||||
return;
|
||||
|
||||
@@ -1117,17 +1100,27 @@ void do_toggle(int flag)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (ISSET(STATEFLAGS) && (flag == AUTOINDENT ||
|
||||
flag == BREAK_LONG_LINES || flag == SOFTWRAP))
|
||||
titlebar(NULL);
|
||||
if (!ISSET(MINIBAR) && ISSET(STATEFLAGS))
|
||||
if (flag == AUTOINDENT || flag == BREAK_LONG_LINES || flag == SOFTWRAP)
|
||||
titlebar(NULL);
|
||||
|
||||
enabled = ISSET(flag);
|
||||
if (ISSET(MINIBAR) && (flag == NO_HELP || flag == LINE_NUMBERS ))
|
||||
return;
|
||||
|
||||
if (flag == NO_HELP || flag == NO_SYNTAX)
|
||||
enabled = !enabled;
|
||||
if (flag == CONSTANT_SHOW)
|
||||
wipe_statusbar();
|
||||
else if (!ISSET(MINIBAR) || !ISSET(STATEFLAGS) || flag == SMART_HOME ||
|
||||
flag == NO_SYNTAX || flag == WHITESPACE_DISPLAY ||
|
||||
flag == CUT_FROM_CURSOR || flag == TABS_TO_SPACES ||
|
||||
flag == USE_MOUSE || flag == SUSPENDABLE) {
|
||||
bool enabled = ISSET(flag);
|
||||
|
||||
statusline(HUSH, "%s %s", _(flagtostr(flag)),
|
||||
enabled ? _("enabled") : _("disabled"));
|
||||
if (flag == NO_HELP || flag == NO_SYNTAX)
|
||||
enabled = !enabled;
|
||||
|
||||
statusline(REMARK, "%s %s", _(flagtostr(flag)),
|
||||
enabled ? _("enabled") : _("disabled"));
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
@@ -1202,36 +1195,15 @@ void enable_flow_control(void)
|
||||
* control characters. */
|
||||
void terminal_init(void)
|
||||
{
|
||||
#ifdef USE_SLANG
|
||||
/* Slang curses emulation brain damage, part 2: Slang doesn't
|
||||
* implement raw(), nonl(), or noecho() properly, so there's no way
|
||||
* to properly reinitialize the terminal using them. We have to
|
||||
* disable the special control keys and interpretation of the flow
|
||||
* control characters using termios, save the terminal state after
|
||||
* the first call, and restore it on subsequent calls. */
|
||||
static struct termios desired_state;
|
||||
static bool have_new_state = FALSE;
|
||||
raw();
|
||||
nonl();
|
||||
noecho();
|
||||
|
||||
if (!have_new_state) {
|
||||
#endif
|
||||
raw();
|
||||
nonl();
|
||||
noecho();
|
||||
disable_extended_io();
|
||||
#ifdef USE_SLANG
|
||||
tcgetattr(0, &desired_state);
|
||||
have_new_state = TRUE;
|
||||
} else
|
||||
tcsetattr(0, TCSANOW, &desired_state);
|
||||
disable_extended_io();
|
||||
|
||||
SLang_init_tty(-1, 0, 0);
|
||||
#endif
|
||||
if (ISSET(PRESERVE))
|
||||
enable_flow_control();
|
||||
#ifdef USE_SLANG
|
||||
else
|
||||
disable_flow_control();
|
||||
#endif
|
||||
|
||||
disable_kb_interrupt();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -1268,6 +1240,8 @@ void confirm_margin(void)
|
||||
needed_margin = 0;
|
||||
|
||||
if (needed_margin != margin) {
|
||||
bool keep_focus = (margin > 0) && focusing;
|
||||
|
||||
margin = needed_margin;
|
||||
editwincols = COLS - margin - thebar;
|
||||
|
||||
@@ -1276,6 +1250,7 @@ void confirm_margin(void)
|
||||
* and ensure a proper starting column for the first screen row. */
|
||||
compute_the_extra_rows_per_line_from(openfile->filetop);
|
||||
ensure_firstcolumn_is_aligned();
|
||||
focusing = keep_focus;
|
||||
#endif
|
||||
/* The margin has changed -- schedule a full refresh. */
|
||||
refresh_needed = TRUE;
|
||||
@@ -1289,28 +1264,28 @@ void unbound_key(int code)
|
||||
if (code == FOREIGN_SEQUENCE)
|
||||
/* TRANSLATORS: This refers to a sequence of escape codes
|
||||
* (from the keyboard) that nano does not recognize. */
|
||||
statusline(ALERT, _("Unknown sequence"));
|
||||
statusline(AHEM, _("Unknown sequence"));
|
||||
else if (code > 0x7F)
|
||||
statusline(ALERT, _("Unbound key"));
|
||||
statusline(AHEM, _("Unbound key"));
|
||||
else if (meta_key) {
|
||||
#ifndef NANO_TINY
|
||||
if (code < 0x20)
|
||||
statusline(ALERT, _("Unbindable key: M-^%c"), code + 0x40);
|
||||
statusline(AHEM, _("Unbindable key: M-^%c"), code + 0x40);
|
||||
else
|
||||
#endif
|
||||
#ifdef ENABLE_NANORC
|
||||
if (shifted_metas && 'A' <= code && code <= 'Z')
|
||||
statusline(ALERT, _("Unbound key: Sh-M-%c"), code);
|
||||
statusline(AHEM, _("Unbound key: Sh-M-%c"), code);
|
||||
else
|
||||
#endif
|
||||
statusline(ALERT, _("Unbound key: M-%c"), toupper(code));
|
||||
statusline(AHEM, _("Unbound key: M-%c"), toupper(code));
|
||||
} else if (code == ESC_CODE)
|
||||
statusline(ALERT, _("Unbindable key: ^["));
|
||||
statusline(AHEM, _("Unbindable key: ^["));
|
||||
else if (code < 0x20)
|
||||
statusline(ALERT, _("Unbound key: ^%c"), code + 0x40);
|
||||
statusline(AHEM, _("Unbound key: ^%c"), code + 0x40);
|
||||
#if defined(ENABLE_BROWSER) || defined (ENABLE_HELP)
|
||||
else
|
||||
statusline(ALERT, _("Unbound key: %c"), code);
|
||||
statusline(AHEM, _("Unbound key: %c"), code);
|
||||
#endif
|
||||
set_blankdelay_to_one();
|
||||
}
|
||||
@@ -1354,9 +1329,11 @@ int do_mouse(void)
|
||||
#ifndef NANO_TINY
|
||||
/* Clicking where the cursor is toggles the mark, as does clicking
|
||||
* beyond the line length with the cursor at the end of the line. */
|
||||
if (sameline && openfile->current_x == current_x_save)
|
||||
if (sameline && openfile->current_x == current_x_save) {
|
||||
do_mark();
|
||||
else
|
||||
if (ISSET(STATEFLAGS))
|
||||
titlebar(NULL);
|
||||
} else
|
||||
#endif
|
||||
/* The cursor moved; clean the cutbuffer on the next cut. */
|
||||
keep_cutbuffer = FALSE;
|
||||
@@ -1545,6 +1522,9 @@ void process_a_keystroke(void)
|
||||
/* Read in a keystroke, and show the cursor while waiting. */
|
||||
input = get_kbinput(edit, VISIBLE);
|
||||
|
||||
lastmessage = VACUUM;
|
||||
hide_cursor = FALSE;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (input == KEY_WINCH)
|
||||
return;
|
||||
@@ -1571,7 +1551,7 @@ void process_a_keystroke(void)
|
||||
print_view_warning();
|
||||
else {
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->mark && openfile->kind_of_mark == SOFTMARK) {
|
||||
if (openfile->mark && openfile->softmark) {
|
||||
openfile->mark = NULL;
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
@@ -1645,7 +1625,7 @@ void process_a_keystroke(void)
|
||||
if (shift_held && !openfile->mark) {
|
||||
openfile->mark = openfile->current;
|
||||
openfile->mark_x = openfile->current_x;
|
||||
openfile->kind_of_mark = SOFTMARK;
|
||||
openfile->softmark = TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1657,7 +1637,7 @@ void process_a_keystroke(void)
|
||||
* discard a soft mark. And when the marked region covers a
|
||||
* different set of lines, reset the "last line too" flag. */
|
||||
if (openfile->mark) {
|
||||
if (!shift_held && openfile->kind_of_mark == SOFTMARK &&
|
||||
if (!shift_held && openfile->softmark &&
|
||||
(openfile->current != was_current ||
|
||||
openfile->current_x != was_x ||
|
||||
wanted_to_move(shortcut->func))) {
|
||||
@@ -1711,9 +1691,7 @@ int main(int argc, char **argv)
|
||||
#ifdef ENABLE_NANORC
|
||||
{"ignorercfiles", 0, NULL, 'I'},
|
||||
#endif
|
||||
#ifndef USE_SLANG
|
||||
{"rawsequences", 0, NULL, 'K'},
|
||||
#endif
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
{"trimblanks", 0, NULL, 'M'},
|
||||
#endif
|
||||
@@ -1789,6 +1767,7 @@ int main(int argc, char **argv)
|
||||
{"unix", 0, NULL, 'u'},
|
||||
{"afterends", 0, NULL, 'y'},
|
||||
{"stateflags", 0, NULL, '%'},
|
||||
{"minibar", 0, NULL, '_'},
|
||||
#endif
|
||||
#ifdef HAVE_LIBMAGIC
|
||||
{"magic", 0, NULL, '!'},
|
||||
@@ -1812,15 +1791,10 @@ int main(int argc, char **argv)
|
||||
fcntl(STDIN_FILENO, F_SETFL, stdin_flags & ~O_NONBLOCK);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
/* If setting the locale is successful and it uses UTF-8, we need
|
||||
* to use the multibyte functions for text processing. */
|
||||
if (setlocale(LC_ALL, "") != NULL &&
|
||||
strcmp(nl_langinfo(CODESET), "UTF-8") == 0) {
|
||||
#ifdef USE_SLANG
|
||||
SLutf8_enable(1);
|
||||
#endif
|
||||
/* If setting the locale is successful and it uses UTF-8, we will
|
||||
* need to use the multibyte functions for text processing. */
|
||||
if (setlocale(LC_ALL, "") && strcmp(nl_langinfo(CODESET), "UTF-8") == 0)
|
||||
utf8_init();
|
||||
}
|
||||
#else
|
||||
setlocale(LC_ALL, "");
|
||||
#endif
|
||||
@@ -1848,7 +1822,7 @@ int main(int argc, char **argv)
|
||||
SET(RESTRICTED);
|
||||
|
||||
while ((optchr = getopt_long(argc, argv, "ABC:DEFGHIJ:KLMNOPQ:RST:UVWX:Y:Z"
|
||||
"abcdef:ghijklmno:pqr:s:tuvwxyz$%!", long_options, NULL)) != -1) {
|
||||
"abcdef:ghijklmno:pqr:s:tuvwxyz$%_!", long_options, NULL)) != -1) {
|
||||
switch (optchr) {
|
||||
#ifndef NANO_TINY
|
||||
case 'A':
|
||||
@@ -1898,11 +1872,9 @@ int main(int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#ifndef USE_SLANG
|
||||
case 'K':
|
||||
SET(RAW_SEQUENCES);
|
||||
break;
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
case 'L':
|
||||
SET(NO_NEWLINES);
|
||||
@@ -2090,6 +2062,9 @@ int main(int argc, char **argv)
|
||||
case '%':
|
||||
SET(STATEFLAGS);
|
||||
break;
|
||||
case '_':
|
||||
SET(MINIBAR);
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_LIBMAGIC
|
||||
case '!':
|
||||
@@ -2195,6 +2170,9 @@ int main(int argc, char **argv)
|
||||
free(alt_speller);
|
||||
alt_speller = alt_speller_cmdline;
|
||||
}
|
||||
/* Strip leading whitespace from the speller command, if any. */
|
||||
while (alt_speller && *alt_speller && isblank(*alt_speller))
|
||||
memmove(alt_speller, alt_speller + 1, strlen(alt_speller));
|
||||
#endif
|
||||
|
||||
/* If an rcfile undid the default settings, copy it to the new flags. */
|
||||
@@ -2233,15 +2211,9 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_SLANG
|
||||
/* When using Slang, do not let Slang translate escape sequences to
|
||||
* key codes, because it does it wrong for the longer sequences. */
|
||||
SET(RAW_SEQUENCES);
|
||||
#else
|
||||
/* When getting untranslated escape sequences, the mouse cannot be used. */
|
||||
if (ISSET(RAW_SEQUENCES))
|
||||
UNSET(USE_MOUSE);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_HISTORIES
|
||||
/* Initialize the pointers for the Search/Replace/Execute histories. */
|
||||
@@ -2353,6 +2325,8 @@ int main(int argc, char **argv)
|
||||
interface_color_pair[GUIDE_STRIPE] = A_REVERSE;
|
||||
interface_color_pair[SCROLL_BAR] = A_NORMAL;
|
||||
interface_color_pair[SELECTED_TEXT] = hilite_attribute;
|
||||
interface_color_pair[HIGHLIGHTED] = A_REVERSE;
|
||||
interface_color_pair[PROMPT_BAR] = hilite_attribute;
|
||||
interface_color_pair[STATUS_BAR] = hilite_attribute;
|
||||
interface_color_pair[ERROR_MESSAGE] = hilite_attribute;
|
||||
interface_color_pair[KEY_COMBO] = hilite_attribute;
|
||||
@@ -2549,12 +2523,16 @@ int main(int argc, char **argv)
|
||||
if (currmenu != MMAIN)
|
||||
bottombars(MMAIN);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(MINIBAR) && lastmessage < REMARK)
|
||||
minibar();
|
||||
else
|
||||
#endif
|
||||
/* Update the displayed current cursor position only when there
|
||||
* is no message and no keys are waiting in the input buffer. */
|
||||
if (ISSET(CONSTANT_SHOW) && lastmessage == VACUUM && get_key_buffer_len() == 0)
|
||||
report_cursor_position();
|
||||
|
||||
lastmessage = VACUUM;
|
||||
as_an_at = TRUE;
|
||||
|
||||
/* Refresh just the cursor position or the entire edit window. */
|
||||
@@ -2564,6 +2542,11 @@ int main(int argc, char **argv)
|
||||
} else
|
||||
edit_refresh();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Let the next keystroke cancel the highlighting of a search match. */
|
||||
refresh_needed = spotlighted;
|
||||
spotlighted = FALSE;
|
||||
#endif
|
||||
errno = 0;
|
||||
focusing = TRUE;
|
||||
|
||||
|
||||
37
src/prompt.c
37
src/prompt.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* prompt.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2016, 2018, 2020 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -380,18 +380,19 @@ void put_cursor_at_end_of_answer(void)
|
||||
typing_x = HIGHEST_POSITIVE;
|
||||
}
|
||||
|
||||
/* Redraw the promptbar and place the cursor at the right spot. */
|
||||
/* Redraw the prompt bar and place the cursor at the right spot. */
|
||||
void draw_the_promptbar(void)
|
||||
{
|
||||
size_t base = breadth(prompt) + 2;
|
||||
size_t the_page, end_page, column;
|
||||
size_t column = base + wideness(answer, typing_x);
|
||||
size_t the_page, end_page;
|
||||
char *expanded;
|
||||
|
||||
the_page = get_statusbar_page_start(base, base + wideness(answer, typing_x));
|
||||
the_page = get_statusbar_page_start(base, column);
|
||||
end_page = get_statusbar_page_start(base, base + breadth(answer) - 1);
|
||||
|
||||
/* Color the promptbar over its full width. */
|
||||
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
/* Color the prompt bar over its full width. */
|
||||
wattron(bottomwin, interface_color_pair[PROMPT_BAR]);
|
||||
mvwprintw(bottomwin, 0, 0, "%*s", COLS, " ");
|
||||
|
||||
mvwaddstr(bottomwin, 0, 0, prompt);
|
||||
@@ -402,14 +403,21 @@ void draw_the_promptbar(void)
|
||||
waddstr(bottomwin, expanded);
|
||||
free(expanded);
|
||||
|
||||
if (base + breadth(answer) != COLS && the_page < end_page)
|
||||
if (the_page < end_page && base + breadth(answer) - the_page > COLS)
|
||||
mvwaddch(bottomwin, 0, COLS - 1, '>');
|
||||
|
||||
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
wattroff(bottomwin, interface_color_pair[PROMPT_BAR]);
|
||||
|
||||
#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH < 20210220)
|
||||
/* Work around a cursor-misplacement bug -- https://sv.gnu.org/bugs/?59808. */
|
||||
if (ISSET(NO_HELP)) {
|
||||
wmove(bottomwin, 0, 0);
|
||||
wrefresh(bottomwin);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Place the cursor at the right spot. */
|
||||
column = base + wideness(answer, typing_x);
|
||||
wmove(bottomwin, 0, column - get_statusbar_page_start(base, column));
|
||||
wmove(bottomwin, 0, column - the_page);
|
||||
wnoutrefresh(bottomwin);
|
||||
}
|
||||
|
||||
@@ -490,8 +498,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
|
||||
} else
|
||||
#endif
|
||||
/* Allow tab completion of filenames, but not in restricted mode. */
|
||||
if ((currmenu == MINSERTFILE || currmenu == MWRITEFILE ||
|
||||
currmenu == MGOTODIR) && !ISSET(RESTRICTED))
|
||||
if ((currmenu & (MINSERTFILE|MWRITEFILE|MGOTODIR)) && !ISSET(RESTRICTED))
|
||||
answer = input_tab(answer, &typing_x, refresh_func, listed);
|
||||
} else
|
||||
#endif /* ENABLE_TABCOMP */
|
||||
@@ -684,11 +691,11 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
post_one_key(cancelshortcut->keystr, _("Cancel"), width);
|
||||
}
|
||||
|
||||
/* Color the promptbar over its full width and display the question. */
|
||||
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
/* Color the prompt bar over its full width and display the question. */
|
||||
wattron(bottomwin, interface_color_pair[PROMPT_BAR]);
|
||||
mvwprintw(bottomwin, 0, 0, "%*s", COLS, " ");
|
||||
mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));
|
||||
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
wattroff(bottomwin, interface_color_pair[PROMPT_BAR]);
|
||||
wnoutrefresh(bottomwin);
|
||||
|
||||
currmenu = MYESNO;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* prototypes.h -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published *
|
||||
@@ -36,7 +36,7 @@ extern bool bracketed_paste;
|
||||
|
||||
extern bool we_are_running;
|
||||
extern bool more_than_one;
|
||||
|
||||
extern bool report_size;
|
||||
extern bool ran_a_tool;
|
||||
|
||||
extern bool inhelp;
|
||||
@@ -53,6 +53,7 @@ extern message_type lastmessage;
|
||||
extern linestruct *pletion_line;
|
||||
|
||||
extern bool also_the_last;
|
||||
extern bool hide_cursor;
|
||||
|
||||
extern char *answer;
|
||||
|
||||
@@ -238,7 +239,6 @@ bool is_valid_unicode(wchar_t wc);
|
||||
void set_interface_colorpairs(void);
|
||||
void prepare_palette(void);
|
||||
void find_and_prime_applicable_syntax(void);
|
||||
void set_up_multicache(linestruct *line);
|
||||
void check_the_multis(linestruct *line);
|
||||
void precalc_multicolorinfo(void);
|
||||
#endif
|
||||
@@ -594,6 +594,7 @@ void set_blankdelay_to_one(void);
|
||||
char *display_string(const char *buf, size_t column, size_t span,
|
||||
bool isdata, bool isprompt);
|
||||
void titlebar(const char *path);
|
||||
void minibar(void);
|
||||
void statusline(message_type importance, const char *msg, ...);
|
||||
void statusbar(const char *msg);
|
||||
void warn_and_briefly_pause(const char *msg);
|
||||
|
||||
14
src/rcfile.c
14
src/rcfile.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* rcfile.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014 Mike Frysinger *
|
||||
* Copyright (C) 2019 Brand Huntsman *
|
||||
* Copyright (C) 2014-2020 Benno Schulenberg *
|
||||
@@ -71,7 +71,7 @@ static const rcoption rcopts[] = {
|
||||
{"nonewlines", NO_NEWLINES},
|
||||
{"nopauses", NO_PAUSES}, /* Obsolete; remove in 2021. */
|
||||
#ifdef ENABLE_WRAPPING
|
||||
{"nowrap", NO_WRAP}, /* Deprecated; remove in 2021. */
|
||||
{"nowrap", NO_WRAP}, /* Deprecated; remove in 2024. */
|
||||
#endif
|
||||
#ifdef ENABLE_OPERATINGDIR
|
||||
{"operatingdir", 0},
|
||||
@@ -110,6 +110,7 @@ static const rcoption rcopts[] = {
|
||||
{"jumpyscrolling", JUMPY_SCROLLING},
|
||||
{"locking", LOCKING},
|
||||
{"matchbrackets", 0},
|
||||
{"minibar", MINIBAR},
|
||||
{"noconvert", NO_CONVERT},
|
||||
{"showcursor", SHOW_CURSOR},
|
||||
{"smarthome", SMART_HOME},
|
||||
@@ -131,6 +132,8 @@ static const rcoption rcopts[] = {
|
||||
{"stripecolor", 0},
|
||||
{"scrollercolor", 0},
|
||||
{"selectedcolor", 0},
|
||||
{"highlightcolor", 0},
|
||||
{"promptcolor", 0},
|
||||
{"statuscolor", 0},
|
||||
{"errorcolor", 0},
|
||||
{"keycolor", 0},
|
||||
@@ -473,7 +476,8 @@ keystruct *strtosc(const char *input)
|
||||
else if (!strcmp(input, "cutfromcursor"))
|
||||
s->toggle = CUT_FROM_CURSOR;
|
||||
#ifdef ENABLE_WRAPPING
|
||||
else if (!strcmp(input, "nowrap"))
|
||||
else if (!strcmp(input, "breaklonglines") ||
|
||||
!strcmp(input, "nowrap")) /* Deprecated; remove in 2024. */
|
||||
s->toggle = BREAK_LONG_LINES;
|
||||
#endif
|
||||
else if (!strcmp(input, "tabstospaces"))
|
||||
@@ -1554,6 +1558,10 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
|
||||
color_combo[SCROLL_BAR] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "selectedcolor") == 0)
|
||||
color_combo[SELECTED_TEXT] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "highlightcolor") == 0)
|
||||
color_combo[HIGHLIGHTED] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "promptcolor") == 0)
|
||||
color_combo[PROMPT_BAR] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "statuscolor") == 0)
|
||||
color_combo[STATUS_BAR] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "errorcolor") == 0)
|
||||
|
||||
66
src/search.c
66
src/search.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* search.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2015-2020 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -42,7 +42,7 @@ bool regexp_init(const char *regexp)
|
||||
char *str = nmalloc(len);
|
||||
|
||||
regerror(value, &search_regexp, str, len);
|
||||
statusline(ALERT, _("Bad regex \"%s\": %s"), regexp, str);
|
||||
statusline(AHEM, _("Bad regex \"%s\": %s"), regexp, str);
|
||||
free(str);
|
||||
|
||||
return FALSE;
|
||||
@@ -251,7 +251,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
line = (ISSET(BACKWARDS_SEARCH)) ? openfile->filebot : openfile->filetop;
|
||||
|
||||
if (modus == JUSTFIND) {
|
||||
statusbar(_("Search Wrapped"));
|
||||
statusline(REMARK, _("Search Wrapped"));
|
||||
/* Delay the "Searching..." message for at least two seconds. */
|
||||
feedback = -2;
|
||||
}
|
||||
@@ -322,6 +322,17 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
if (match_len != NULL)
|
||||
*match_len = found_len;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (modus == JUSTFIND && (!openfile->mark || openfile->softmark)) {
|
||||
spotlighted = TRUE;
|
||||
light_from_col = xplustabs();
|
||||
light_to_col = wideness(line->data, found_x + found_len);
|
||||
if (!ISSET(SHOW_CURSOR))
|
||||
hide_cursor = TRUE;
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Wipe the "Searching..." message and unsuppress cursor-position display. */
|
||||
if (feedback > 0) {
|
||||
wipe_statusbar();
|
||||
@@ -356,7 +367,7 @@ void do_research(void)
|
||||
#endif
|
||||
|
||||
if (*last_search == '\0') {
|
||||
statusbar(_("No current search pattern"));
|
||||
statusline(AHEM, _("No current search pattern"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -394,7 +405,7 @@ void not_found_msg(const char *str)
|
||||
char *disp = display_string(str, 0, (COLS / 2) + 1, FALSE, FALSE);
|
||||
size_t numchars = actual_x(disp, wideness(disp, COLS / 2));
|
||||
|
||||
statusline(HUSH, _("\"%.*s%s\" not found"), numchars, disp,
|
||||
statusline(AHEM, _("\"%.*s%s\" not found"), numchars, disp,
|
||||
(disp[numchars] == '\0') ? "" : "...");
|
||||
free(disp);
|
||||
}
|
||||
@@ -421,14 +432,14 @@ void go_looking(void)
|
||||
* where we started searching, then this is the only occurrence. */
|
||||
if (didfind == 1 && openfile->current == was_current &&
|
||||
openfile->current_x == was_current_x)
|
||||
statusbar(_("This is the only occurrence"));
|
||||
statusline(REMARK, _("This is the only occurrence"));
|
||||
else if (didfind == 1 && LINES == 1)
|
||||
refresh_needed = TRUE;
|
||||
else if (didfind == 0)
|
||||
not_found_msg(last_search);
|
||||
|
||||
#ifdef TIMEIT
|
||||
statusline(HUSH, "Took: %.2f", (double)(clock() - start) / CLOCKS_PER_SEC);
|
||||
statusline(INFO, "Took: %.2f", (double)(clock() - start) / CLOCKS_PER_SEC);
|
||||
#endif
|
||||
|
||||
edit_redraw(was_current, CENTERING);
|
||||
@@ -510,19 +521,6 @@ char *replace_line(const char *needle)
|
||||
return copy;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
/* Reset the multiline coloring info and then recalculate it. */
|
||||
void wipe_and_recalculate_colorinfo(void)
|
||||
{
|
||||
for (linestruct *line = openfile->filetop; line != NULL; line = line->next)
|
||||
if (line->multidata)
|
||||
for (short index = 0; index < openfile->syntax->nmultis; index++)
|
||||
line->multidata[index] = -1;
|
||||
|
||||
precalc_multicolorinfo();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Step through each occurrence of the search string and prompt the user
|
||||
* before replacing it. We seek for needle, and replace it with answer.
|
||||
* The parameters real_current and real_current_x are needed in order to
|
||||
@@ -670,13 +668,6 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP))
|
||||
openfile->current->extrarows = extra_chunks_in(openfile->current);
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
/* Check whether the replacement requires a change in the coloring. */
|
||||
check_the_multis(openfile->current);
|
||||
|
||||
if (refresh_needed && !replaceall)
|
||||
wipe_and_recalculate_colorinfo();
|
||||
#endif
|
||||
set_modified();
|
||||
as_an_at = TRUE;
|
||||
@@ -687,11 +678,6 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
if (numreplaced == -1)
|
||||
not_found_msg(needle);
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
if (refresh_needed)
|
||||
wipe_and_recalculate_colorinfo();
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
openfile->mark = was_mark;
|
||||
#endif
|
||||
@@ -750,7 +736,7 @@ void ask_for_and_do_replacements(void)
|
||||
refresh_needed = TRUE;
|
||||
|
||||
if (numreplaced >= 0)
|
||||
statusline(HUSH, P_("Replaced %zd occurrence",
|
||||
statusline(REMARK, P_("Replaced %zd occurrence",
|
||||
"Replaced %zd occurrences", numreplaced), numreplaced);
|
||||
}
|
||||
|
||||
@@ -798,7 +784,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool retain_answer,
|
||||
|
||||
/* Try to extract one or two numbers from the user's response. */
|
||||
if (!parse_line_column(answer, &line, &column)) {
|
||||
statusline(ALERT, _("Invalid line or column number"));
|
||||
statusline(AHEM, _("Invalid line or column number"));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -946,7 +932,7 @@ void do_find_bracket(void)
|
||||
ch = mbstrchr(matchbrackets, openfile->current->data + openfile->current_x);
|
||||
|
||||
if (ch == NULL) {
|
||||
statusbar(_("Not a bracket"));
|
||||
statusline(AHEM, _("Not a bracket"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -989,7 +975,7 @@ void do_find_bracket(void)
|
||||
}
|
||||
}
|
||||
|
||||
statusbar(_("No matching bracket"));
|
||||
statusline(AHEM, _("No matching bracket"));
|
||||
|
||||
/* Restore the cursor position. */
|
||||
openfile->current = was_current;
|
||||
@@ -1004,9 +990,9 @@ void put_or_lift_anchor(void)
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
|
||||
if (openfile->current->has_anchor)
|
||||
statusbar(_("Placed anchor"));
|
||||
statusline(REMARK, _("Placed anchor"));
|
||||
else
|
||||
statusbar(_("Removed anchor"));
|
||||
statusline(REMARK, _("Removed anchor"));
|
||||
}
|
||||
|
||||
/* Make the given line the current line, or report the anchoredness. */
|
||||
@@ -1020,9 +1006,9 @@ void go_to_and_confirm(linestruct *line)
|
||||
edit_redraw(was_current, CENTERING);
|
||||
statusbar(_("Jumped to anchor"));
|
||||
} else if (openfile->current->has_anchor)
|
||||
statusbar(_("This is the only anchor"));
|
||||
statusline(REMARK, _("This is the only anchor"));
|
||||
else
|
||||
statusbar(_("There are no anchors"));
|
||||
statusline(AHEM, _("There are no anchors"));
|
||||
}
|
||||
|
||||
/* Jump to the first anchor before the current line; wrap around at the top. */
|
||||
|
||||
86
src/text.c
86
src/text.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* text.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2015 Mark Majeres *
|
||||
* Copyright (C) 2016 Mike Scalora *
|
||||
* Copyright (C) 2016 Sumedh Pendurkar *
|
||||
@@ -50,8 +50,8 @@ void do_mark(void)
|
||||
if (!openfile->mark) {
|
||||
openfile->mark = openfile->current;
|
||||
openfile->mark_x = openfile->current_x;
|
||||
openfile->softmark = FALSE;
|
||||
statusbar(_("Mark Set"));
|
||||
openfile->kind_of_mark = HARDMARK;
|
||||
} else {
|
||||
openfile->mark = NULL;
|
||||
statusbar(_("Mark Unset"));
|
||||
@@ -387,7 +387,7 @@ void do_comment(void)
|
||||
comment_seq = openfile->syntax->comment;
|
||||
|
||||
if (*comment_seq == '\0') {
|
||||
statusbar(_("Commenting is not supported for this file type"));
|
||||
statusline(AHEM, _("Commenting is not supported for this file type"));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -397,7 +397,7 @@ void do_comment(void)
|
||||
|
||||
/* If only the magic line is selected, don't do anything. */
|
||||
if (top == bot && bot == openfile->filebot && !ISSET(NO_NEWLINES)) {
|
||||
statusbar(_("Cannot comment past end of file"));
|
||||
statusline(AHEM, _("Cannot comment past end of file"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -519,7 +519,7 @@ void do_undo(void)
|
||||
size_t original_x, regain_from_x;
|
||||
|
||||
if (u == NULL) {
|
||||
statusbar(_("Nothing to undo"));
|
||||
statusline(AHEM, _("Nothing to undo"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -583,6 +583,8 @@ void do_undo(void)
|
||||
break;
|
||||
case REPLACE:
|
||||
undidmsg = _("replacement");
|
||||
if ((u->xflags & INCLUDED_LAST_LINE) && !ISSET(NO_NEWLINES))
|
||||
remove_magicline();
|
||||
data = u->strdata;
|
||||
u->strdata = line->data;
|
||||
line->data = data;
|
||||
@@ -696,7 +698,7 @@ void do_redo(void)
|
||||
undostruct *u = openfile->undotop;
|
||||
|
||||
if (u == NULL || u == openfile->current_undo) {
|
||||
statusbar(_("Nothing to redo"));
|
||||
statusline(AHEM, _("Nothing to redo"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -755,6 +757,8 @@ void do_redo(void)
|
||||
break;
|
||||
case REPLACE:
|
||||
redidmsg = _("replacement");
|
||||
if ((u->xflags & INCLUDED_LAST_LINE) && !ISSET(NO_NEWLINES))
|
||||
new_magicline();
|
||||
data = u->strdata;
|
||||
u->strdata = line->data;
|
||||
line->data = data;
|
||||
@@ -1039,6 +1043,8 @@ void add_undo(undo_type action, const char *message)
|
||||
break;
|
||||
case REPLACE:
|
||||
u->strdata = copy_of(thisline->data);
|
||||
if (thisline == openfile->filebot && answer[0] != '\0')
|
||||
u->xflags |= INCLUDED_LAST_LINE;
|
||||
break;
|
||||
#ifdef ENABLE_WRAPPING
|
||||
case SPLIT_BEGIN:
|
||||
@@ -1071,9 +1077,7 @@ void add_undo(undo_type action, const char *message)
|
||||
break;
|
||||
case PASTE:
|
||||
u->cutbuffer = copy_buffer(cutbuffer);
|
||||
if (thisline == openfile->filebot)
|
||||
u->xflags |= INCLUDED_LAST_LINE;
|
||||
break;
|
||||
/* Fall-through. */
|
||||
case INSERT:
|
||||
if (thisline == openfile->filebot)
|
||||
u->xflags |= INCLUDED_LAST_LINE;
|
||||
@@ -1213,17 +1217,11 @@ void update_undo(undo_type action)
|
||||
u->tail_x = strlen(bottomline->data);
|
||||
}
|
||||
break;
|
||||
case PASTE:
|
||||
u->tail_lineno = openfile->current->lineno;
|
||||
u->tail_x = openfile->current_x;
|
||||
break;
|
||||
case INSERT:
|
||||
u->tail_lineno = openfile->current->lineno;
|
||||
u->tail_x = openfile->current_x;
|
||||
break;
|
||||
case COUPLE_BEGIN:
|
||||
break;
|
||||
case COUPLE_END:
|
||||
case PASTE:
|
||||
case INSERT:
|
||||
u->tail_lineno = openfile->current->lineno;
|
||||
u->tail_x = openfile->current_x;
|
||||
break;
|
||||
@@ -1786,7 +1784,7 @@ void do_justify(bool full_justify)
|
||||
|
||||
/* When the marked region is empty, do nothing. */
|
||||
if (startline == endline && start_x == end_x) {
|
||||
statusline(ALERT, _("Selection is empty"));
|
||||
statusline(AHEM, _("Selection is empty"));
|
||||
discard_until(openfile->undotop->next);
|
||||
return;
|
||||
}
|
||||
@@ -1998,11 +1996,11 @@ void do_justify(bool full_justify)
|
||||
/* Show what we justified on the status bar. */
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->mark)
|
||||
statusbar(_("Justified selection"));
|
||||
statusline(REMARK, _("Justified selection"));
|
||||
else
|
||||
#endif
|
||||
if (full_justify)
|
||||
statusbar(_("Justified file"));
|
||||
statusline(REMARK, _("Justified file"));
|
||||
else
|
||||
statusbar(_("Justified paragraph"));
|
||||
|
||||
@@ -2106,10 +2104,10 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
|
||||
if (fileinfo.st_size == 0) {
|
||||
#ifndef NANO_TINY
|
||||
if (spelling && openfile->mark)
|
||||
statusline(ALERT, _("Selection is empty"));
|
||||
statusline(AHEM, _("Selection is empty"));
|
||||
else
|
||||
#endif
|
||||
statusbar(_("Buffer is empty"));
|
||||
statusline(AHEM, _("Buffer is empty"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2144,18 +2142,22 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
|
||||
|
||||
if (thepid < 0) {
|
||||
statusline(ALERT, _("Could not fork: %s"), strerror(errornumber));
|
||||
free(arguments[0]);
|
||||
return;
|
||||
} else if (!WIFEXITED(program_status) || WEXITSTATUS(program_status) > 2) {
|
||||
statusline(ALERT, _("Error invoking '%s'"), arguments[0]);
|
||||
free(arguments[0]);
|
||||
return;
|
||||
} else if (WEXITSTATUS(program_status) != 0)
|
||||
statusline(ALERT, _("Program '%s' complained"), arguments[0]);
|
||||
|
||||
free(arguments[0]);
|
||||
|
||||
/* When the temporary file wasn't touched, say so and leave. */
|
||||
if (timestamp_sec > 0 && stat(tempfile_name, &fileinfo) == 0 &&
|
||||
(long)fileinfo.st_mtim.tv_sec == timestamp_sec &&
|
||||
(long)fileinfo.st_mtim.tv_nsec == timestamp_nsec) {
|
||||
statusbar(_("Nothing changed"));
|
||||
statusline(REMARK, _("Nothing changed"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2203,9 +2205,9 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
|
||||
adjust_viewport(STATIONARY);
|
||||
|
||||
if (spelling)
|
||||
statusbar(_("Finished checking spelling"));
|
||||
statusline(REMARK, _("Finished checking spelling"));
|
||||
else
|
||||
statusbar(_("Buffer has been processed"));
|
||||
statusline(REMARK, _("Buffer has been processed"));
|
||||
}
|
||||
#endif /* ENABLE_SPELLER || ENABLE_COLOR */
|
||||
|
||||
@@ -2490,7 +2492,7 @@ void do_int_speller(const char *tempfile_name)
|
||||
else if (WIFEXITED(spell_status) == 0 || WEXITSTATUS(spell_status))
|
||||
statusline(ALERT, _("Error invoking \"spell\""));
|
||||
else
|
||||
statusbar(_("Finished checking spelling"));
|
||||
statusline(REMARK, _("Finished checking spelling"));
|
||||
}
|
||||
|
||||
/* Spell check the current file. If an alternate spell checker is
|
||||
@@ -2535,7 +2537,7 @@ void do_spell(void)
|
||||
|
||||
blank_bottombars();
|
||||
|
||||
if (alt_speller)
|
||||
if (alt_speller && *alt_speller)
|
||||
treat(temp_name, alt_speller, TRUE);
|
||||
else
|
||||
do_int_speller(temp_name);
|
||||
@@ -2563,7 +2565,6 @@ void do_linter(void)
|
||||
int lint_status, lint_fd[2];
|
||||
pid_t pid_lint;
|
||||
bool helpless = ISSET(NO_HELP);
|
||||
static char **lintargs = NULL;
|
||||
lintstruct *lints = NULL, *tmplint = NULL, *curlint = NULL;
|
||||
time_t last_wait = 0;
|
||||
|
||||
@@ -2573,7 +2574,7 @@ void do_linter(void)
|
||||
return;
|
||||
|
||||
if (!openfile->syntax || !openfile->syntax->linter) {
|
||||
statusbar(_("No linter is defined for this type of file"));
|
||||
statusline(AHEM, _("No linter is defined for this type of file"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2602,10 +2603,10 @@ void do_linter(void)
|
||||
currmenu = MLINTER;
|
||||
statusbar(_("Invoking linter..."));
|
||||
|
||||
construct_argument_list(&lintargs, openfile->syntax->linter, openfile->filename);
|
||||
|
||||
/* Fork a process to run the linter in. */
|
||||
if ((pid_lint = fork()) == 0) {
|
||||
char **lintargs = NULL;
|
||||
|
||||
/* Redirect standard output and standard error into the pipe. */
|
||||
if (dup2(lint_fd[1], STDOUT_FILENO) < 0)
|
||||
exit(7);
|
||||
@@ -2615,6 +2616,8 @@ void do_linter(void)
|
||||
close(lint_fd[0]);
|
||||
close(lint_fd[1]);
|
||||
|
||||
construct_argument_list(&lintargs, openfile->syntax->linter, openfile->filename);
|
||||
|
||||
/* Start the linter program; we are using $PATH. */
|
||||
execvp(lintargs[0], lintargs);
|
||||
|
||||
@@ -2733,7 +2736,7 @@ void do_linter(void)
|
||||
}
|
||||
|
||||
if (!parsesuccess) {
|
||||
statusline(HUSH, _("Got 0 parsable lines from command: %s"),
|
||||
statusline(REMARK, _("Got 0 parsable lines from command: %s"),
|
||||
openfile->syntax->linter);
|
||||
return;
|
||||
}
|
||||
@@ -2810,7 +2813,7 @@ void do_linter(void)
|
||||
free(dontwantfile);
|
||||
|
||||
if (restlint == NULL) {
|
||||
statusbar(_("No messages for this file"));
|
||||
statusline(REMARK, _("No messages for this file"));
|
||||
break;
|
||||
} else {
|
||||
curlint = restlint;
|
||||
@@ -2894,6 +2897,7 @@ void do_linter(void)
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
lastmessage = VACUUM;
|
||||
currmenu = MMOST;
|
||||
titlebar(NULL);
|
||||
}
|
||||
@@ -2911,7 +2915,7 @@ void do_formatter(void)
|
||||
return;
|
||||
|
||||
if (!openfile->syntax || !openfile->syntax->formatter) {
|
||||
statusbar(_("No formatter is defined for this type of file"));
|
||||
statusline(AHEM, _("No formatter is defined for this type of file"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2988,7 +2992,7 @@ void do_wordlinechar_count(void)
|
||||
openfile->current_x = was_x;
|
||||
|
||||
/* Report on the status bar the number of lines, words, and characters. */
|
||||
statusline(HUSH, _("%s%zd %s, %zu %s, %zu %s"),
|
||||
statusline(INFO, _("%s%zd %s, %zu %s, %zu %s"),
|
||||
openfile->mark ? _("In Selection: ") : "",
|
||||
lines, P_("line", "lines", lines),
|
||||
words, P_("word", "words", words),
|
||||
@@ -3003,7 +3007,7 @@ void do_verbatim_input(void)
|
||||
char *bytes;
|
||||
|
||||
/* TRANSLATORS: Shown when the next keystroke will be inserted verbatim. */
|
||||
statusbar(_("Verbatim Input"));
|
||||
statusline(INFO, _("Verbatim Input"));
|
||||
place_the_cursor();
|
||||
|
||||
/* Read in the first one or two bytes of the next keystroke. */
|
||||
@@ -3012,7 +3016,7 @@ void do_verbatim_input(void)
|
||||
/* When something valid was obtained, unsuppress cursor-position display,
|
||||
* insert the bytes into the edit buffer, and blank the status bar. */
|
||||
if (count > 0) {
|
||||
if (ISSET(CONSTANT_SHOW))
|
||||
if (ISSET(CONSTANT_SHOW) || ISSET(MINIBAR))
|
||||
lastmessage = VACUUM;
|
||||
|
||||
if (count < 999)
|
||||
@@ -3021,7 +3025,7 @@ void do_verbatim_input(void)
|
||||
wipe_statusbar();
|
||||
} else
|
||||
/* TRANSLATORS: An invalid verbatim Unicode code was typed. */
|
||||
statusline(ALERT, _("Invalid code"));
|
||||
statusline(AHEM, _("Invalid code"));
|
||||
|
||||
free(bytes);
|
||||
}
|
||||
@@ -3097,7 +3101,7 @@ void complete_a_word(void)
|
||||
/* If there is no word fragment before the cursor, do nothing. */
|
||||
if (start_of_shard == openfile->current_x) {
|
||||
/* TRANSLATORS: Shown when no text is directly left of the cursor. */
|
||||
statusbar(_("No word fragment"));
|
||||
statusline(AHEM, _("No word fragment"));
|
||||
pletion_line = NULL;
|
||||
return;
|
||||
}
|
||||
@@ -3189,11 +3193,11 @@ void complete_a_word(void)
|
||||
|
||||
/* The search has reached the end of the file. */
|
||||
if (list_of_completions != NULL) {
|
||||
statusline(ALERT, _("No further matches"));
|
||||
statusline(AHEM, _("No further matches"));
|
||||
refresh_needed = TRUE;
|
||||
} else
|
||||
/* TRANSLATORS: Shown when there are zero possible completions. */
|
||||
statusline(ALERT, _("No matches"));
|
||||
statusline(AHEM, _("No matches"));
|
||||
|
||||
free(shard);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* utils.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2016, 2017, 2019 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
|
||||
540
src/winio.c
540
src/winio.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* winio.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2020 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -46,8 +46,6 @@ static int *key_buffer = NULL;
|
||||
/* A buffer for the keystrokes that haven't been handled yet. */
|
||||
static size_t key_buffer_len = 0;
|
||||
/* The length of the keystroke buffer. */
|
||||
static bool solitary = FALSE;
|
||||
/* Whether an Esc arrived by itself -- not as leader of a sequence. */
|
||||
static int digit_count = 0;
|
||||
/* How many digits of a three-digit character code we've eaten. */
|
||||
static bool reveal_cursor = FALSE;
|
||||
@@ -93,10 +91,10 @@ void record_macro(void)
|
||||
|
||||
if (recording) {
|
||||
macro_length = 0;
|
||||
statusbar(_("Recording a macro..."));
|
||||
statusline(REMARK, _("Recording a macro..."));
|
||||
} else {
|
||||
snip_last_keystroke();
|
||||
statusbar(_("Stopped recording"));
|
||||
statusline(REMARK, _("Stopped recording"));
|
||||
}
|
||||
|
||||
if (ISSET(STATEFLAGS))
|
||||
@@ -108,13 +106,13 @@ void record_macro(void)
|
||||
void run_macro(void)
|
||||
{
|
||||
if (recording) {
|
||||
statusbar(_("Cannot run macro while recording"));
|
||||
statusline(AHEM, _("Cannot run macro while recording"));
|
||||
snip_last_keystroke();
|
||||
return;
|
||||
}
|
||||
|
||||
if (macro_length == 0) {
|
||||
statusbar(_("Macro is empty"));
|
||||
statusline(REMARK, _("Macro is empty"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -176,16 +174,24 @@ void read_keys_from(WINDOW *win)
|
||||
{
|
||||
int input = ERR;
|
||||
size_t errcount = 0;
|
||||
#ifndef NANO_TINY
|
||||
bool timed = FALSE;
|
||||
#endif
|
||||
|
||||
/* Before reading the first keycode, display any pending screen updates. */
|
||||
doupdate();
|
||||
|
||||
if (reveal_cursor) {
|
||||
if (reveal_cursor && !hide_cursor)
|
||||
curs_set(1);
|
||||
#ifdef USE_SLANG
|
||||
doupdate();
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (currmenu == MMAIN && ISSET(MINIBAR) && lastmessage > HUSH &&
|
||||
lastmessage != INFO && lastmessage < ALERT) {
|
||||
timed = TRUE;
|
||||
halfdelay(ISSET(QUICK_BLANK) ? 8 : 15);
|
||||
disable_kb_interrupt();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Read in the first keycode, waiting for it to arrive. */
|
||||
while (input == ERR) {
|
||||
@@ -196,6 +202,19 @@ void read_keys_from(WINDOW *win)
|
||||
regenerate_screen();
|
||||
input = KEY_WINCH;
|
||||
}
|
||||
|
||||
if (timed) {
|
||||
timed = FALSE;
|
||||
raw();
|
||||
|
||||
if (input == ERR) {
|
||||
minibar();
|
||||
as_an_at = TRUE;
|
||||
place_the_cursor();
|
||||
doupdate();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* When we've failed to get a keycode over a hundred times in a row,
|
||||
* assume our input source is gone and die gracefully. We could
|
||||
@@ -572,11 +591,6 @@ int convert_CSI_sequence(const int *seq, size_t length, int *consumed)
|
||||
} else if (length > 4 && seq[2] == ';' && seq[4] == '~')
|
||||
/* Esc [ 1 n ; 2 ~ == F17...F20 on some terminals. */
|
||||
*consumed = 5;
|
||||
#ifdef USE_SLANG
|
||||
else if (length == 3 && seq[2] == ';')
|
||||
/* Discard broken sequences that Slang produces. */
|
||||
*consumed = 3;
|
||||
#endif
|
||||
break;
|
||||
case '2':
|
||||
if (length > 2 && seq[2] == '~') {
|
||||
@@ -607,11 +621,6 @@ int convert_CSI_sequence(const int *seq, size_t length, int *consumed)
|
||||
else if (length > 4 && seq[2] == ';' && seq[4] == '~')
|
||||
/* Esc [ 2 n ; 2 ~ == F21...F24 on some terminals. */
|
||||
*consumed = 5;
|
||||
#ifdef USE_SLANG
|
||||
else if (length == 3 && seq[2] == ';')
|
||||
/* Discard broken sequences that Slang produces. */
|
||||
*consumed = 3;
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
else if (length > 3 && seq[1] == '0' && seq[3] == '~') {
|
||||
/* Esc [ 2 0 0 ~ == start of a bracketed paste,
|
||||
@@ -891,6 +900,8 @@ int convert_to_control(int kbinput)
|
||||
* the function keys (F1-F12), and the numeric keypad with NumLock off. */
|
||||
int parse_kbinput(WINDOW *win)
|
||||
{
|
||||
static bool first_escape_was_alone = FALSE;
|
||||
static bool last_escape_was_alone = FALSE;
|
||||
static int escapes = 0;
|
||||
int keycode;
|
||||
|
||||
@@ -903,15 +914,16 @@ int parse_kbinput(WINDOW *win)
|
||||
if (keycode == ERR)
|
||||
return ERR;
|
||||
|
||||
/* Remember whether an Esc arrived by itself, and increment
|
||||
* its counter, rolling around on three escapes. */
|
||||
/* For an Esc, remember whether the last two arrived by themselves.
|
||||
* Then increment the counter, rolling around on three escapes. */
|
||||
if (keycode == ESC_CODE) {
|
||||
solitary = (key_buffer_len == 0);
|
||||
first_escape_was_alone = last_escape_was_alone;
|
||||
last_escape_was_alone = (key_buffer_len == 0);
|
||||
if (digit_count > 0) {
|
||||
digit_count = 0;
|
||||
escapes = 1;
|
||||
} else if (++escapes > 2)
|
||||
escapes = (solitary ? 0 : 1);
|
||||
escapes = (last_escape_was_alone ? 0 : 1);
|
||||
return ERR;
|
||||
}
|
||||
|
||||
@@ -937,7 +949,7 @@ int parse_kbinput(WINDOW *win)
|
||||
return FOREIGN_SEQUENCE;
|
||||
}
|
||||
#endif
|
||||
else if (!solitary && keycode < 0x20)
|
||||
else if (keycode < 0x20 && !last_escape_was_alone)
|
||||
meta_key = TRUE;
|
||||
} else if (key_buffer_len == 0 || *key_buffer == ESC_CODE ||
|
||||
(keycode != 'O' && keycode != '[')) {
|
||||
@@ -997,9 +1009,9 @@ int parse_kbinput(WINDOW *win)
|
||||
else
|
||||
return byte;
|
||||
} else if (digit_count == 0) {
|
||||
/* If the second escape did not arrive alone, it is a Meta
|
||||
* keystroke; otherwise, it is an "Esc Esc control". */
|
||||
if (!solitary) {
|
||||
/* If the first escape arrived alone but not the second, then it
|
||||
* is a Meta keystroke; otherwise, it is an "Esc Esc control". */
|
||||
if (first_escape_was_alone && !last_escape_was_alone) {
|
||||
if (!shifted_metas)
|
||||
keycode = tolower(keycode);
|
||||
meta_key = TRUE;
|
||||
@@ -1145,18 +1157,14 @@ int parse_kbinput(WINDOW *win)
|
||||
#endif
|
||||
|
||||
switch (keycode) {
|
||||
#ifdef KEY_SLEFT /* Slang doesn't support KEY_SLEFT. */
|
||||
case KEY_SLEFT:
|
||||
shift_held = TRUE;
|
||||
return KEY_LEFT;
|
||||
#endif
|
||||
#ifdef KEY_SRIGHT /* Slang doesn't support KEY_SRIGHT. */
|
||||
case KEY_SRIGHT:
|
||||
shift_held = TRUE;
|
||||
return KEY_RIGHT;
|
||||
#endif
|
||||
#ifdef KEY_SR
|
||||
#ifdef KEY_SUP /* ncurses and Slang don't support KEY_SUP. */
|
||||
#ifdef KEY_SUP /* Ncurses doesn't know Shift+Up. */
|
||||
case KEY_SUP:
|
||||
#endif
|
||||
case KEY_SR: /* Scroll backward, on Xfce4-terminal. */
|
||||
@@ -1164,21 +1172,21 @@ int parse_kbinput(WINDOW *win)
|
||||
return KEY_UP;
|
||||
#endif
|
||||
#ifdef KEY_SF
|
||||
#ifdef KEY_SDOWN /* ncurses and Slang don't support KEY_SDOWN. */
|
||||
#ifdef KEY_SDOWN /* Ncurses doesn't know Shift+Down. */
|
||||
case KEY_SDOWN:
|
||||
#endif
|
||||
case KEY_SF: /* Scroll forward, on Xfce4-terminal. */
|
||||
shift_held = TRUE;
|
||||
return KEY_DOWN;
|
||||
#endif
|
||||
#ifdef KEY_SHOME /* HP-UX 10-11 and Slang don't support KEY_SHOME. */
|
||||
#ifdef KEY_SHOME /* HP-UX 10-11 doesn't know Shift+Home. */
|
||||
case KEY_SHOME:
|
||||
#endif
|
||||
case SHIFT_HOME:
|
||||
shift_held = TRUE;
|
||||
case KEY_A1: /* Home (7) on keypad with NumLock off. */
|
||||
return KEY_HOME;
|
||||
#ifdef KEY_SEND /* HP-UX 10-11 and Slang don't support KEY_SEND. */
|
||||
#ifdef KEY_SEND /* HP-UX 10-11 doesn't know Shift+End. */
|
||||
case KEY_SEND:
|
||||
#endif
|
||||
case SHIFT_END:
|
||||
@@ -1213,28 +1221,17 @@ int parse_kbinput(WINDOW *win)
|
||||
return (ISSET(REBIND_DELETE) ? KEY_DC : KEY_BACKSPACE);
|
||||
case KEY_DC:
|
||||
return (ISSET(REBIND_DELETE) ? KEY_BACKSPACE : KEY_DC);
|
||||
#ifdef KEY_SDC /* Slang doesn't support KEY_SDC. */
|
||||
case KEY_SDC:
|
||||
return SHIFT_DELETE;
|
||||
#endif
|
||||
#if defined(KEY_CANCEL) && defined(KEY_SCANCEL) /* Slang doesn't support these. */
|
||||
case KEY_SCANCEL:
|
||||
return KEY_CANCEL;
|
||||
#endif
|
||||
#if defined(KEY_SUSPEND) && defined(KEY_SSUSPEND) /* Slang doesn't support these. */
|
||||
case KEY_SSUSPEND:
|
||||
return KEY_SUSPEND;
|
||||
#endif
|
||||
#ifdef KEY_BTAB /* Slang doesn't support KEY_BTAB. */
|
||||
case KEY_BTAB:
|
||||
return SHIFT_TAB;
|
||||
#endif
|
||||
#ifdef KEY_SBEG /* Slang doesn't support KEY_SBEG. */
|
||||
|
||||
case KEY_SBEG:
|
||||
#endif
|
||||
#ifdef KEY_BEG /* Slang doesn't support KEY_BEG. */
|
||||
case KEY_BEG:
|
||||
#endif
|
||||
case KEY_B2: /* Center (5) on keypad with NumLock off. */
|
||||
#ifdef PDCURSES
|
||||
case KEY_SHIFT_L:
|
||||
@@ -1244,7 +1241,7 @@ int parse_kbinput(WINDOW *win)
|
||||
case KEY_ALT_L:
|
||||
case KEY_ALT_R:
|
||||
#endif
|
||||
#ifdef KEY_RESIZE /* Slang and SunOS 5.7-5.9 don't support KEY_RESIZE. */
|
||||
#ifdef KEY_RESIZE /* SunOS 5.7-5.9 doesn't know KEY_RESIZE. */
|
||||
case KEY_RESIZE:
|
||||
#endif
|
||||
case KEY_FLUSH:
|
||||
@@ -1340,7 +1337,7 @@ long assemble_unicode(int symbol)
|
||||
|
||||
/* TRANSLATORS: This is shown while a six-digit hexadecimal
|
||||
* Unicode character code (%s) is being typed in. */
|
||||
statusline(HUSH, _("Unicode Input: %s"), partial);
|
||||
statusline(INFO, _("Unicode Input: %s"), partial);
|
||||
}
|
||||
|
||||
/* If we have an end result, reset the Unicode digit counter. */
|
||||
@@ -1446,10 +1443,9 @@ char *get_verbatim_kbinput(WINDOW *win, size_t *count)
|
||||
* don't get extended keypad values. */
|
||||
if (ISSET(PRESERVE))
|
||||
disable_flow_control();
|
||||
#ifndef USE_SLANG
|
||||
if (!ISSET(RAW_SEQUENCES))
|
||||
keypad(win, FALSE);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Turn bracketed-paste mode off. */
|
||||
printf("\x1B[?2004l");
|
||||
@@ -1483,14 +1479,13 @@ char *get_verbatim_kbinput(WINDOW *win, size_t *count)
|
||||
* keypad back on if necessary now that we're done. */
|
||||
if (ISSET(PRESERVE))
|
||||
enable_flow_control();
|
||||
#ifndef USE_SLANG
|
||||
|
||||
/* Use the global window pointers, because a resize may have freed
|
||||
* the data that the win parameter points to. */
|
||||
if (!ISSET(RAW_SEQUENCES)) {
|
||||
keypad(edit, TRUE);
|
||||
keypad(bottomwin, TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (*count < 999) {
|
||||
for (size_t i = 0; i < *count; i++)
|
||||
@@ -1517,21 +1512,22 @@ char *get_verbatim_kbinput(WINDOW *win, size_t *count)
|
||||
* been handled by putting back keystrokes, or 2 if it's been ignored. */
|
||||
int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
|
||||
{
|
||||
MEVENT mevent;
|
||||
bool in_bottomwin;
|
||||
bool in_editwin, in_bottomwin;
|
||||
MEVENT event;
|
||||
|
||||
/* First, get the actual mouse event. */
|
||||
if (getmouse(&mevent) == ERR)
|
||||
if (getmouse(&event) == ERR)
|
||||
return -1;
|
||||
|
||||
/* Save the screen coordinates where the mouse event took place. */
|
||||
*mouse_x = mevent.x - margin;
|
||||
*mouse_y = mevent.y;
|
||||
in_editwin = wenclose(edit, event.y, event.x);
|
||||
in_bottomwin = wenclose(bottomwin, event.y, event.x);
|
||||
|
||||
in_bottomwin = wenclose(bottomwin, *mouse_y, *mouse_x);
|
||||
/* Save the screen coordinates where the mouse event took place. */
|
||||
*mouse_x = event.x - (in_editwin ? margin : 0);
|
||||
*mouse_y = event.y;
|
||||
|
||||
/* Handle releases/clicks of the first mouse button. */
|
||||
if (mevent.bstate & (BUTTON1_RELEASED | BUTTON1_CLICKED)) {
|
||||
if (event.bstate & (BUTTON1_RELEASED | BUTTON1_CLICKED)) {
|
||||
/* If we're allowing shortcuts, and the current shortcut list is
|
||||
* being displayed on the last two lines of the screen, and the
|
||||
* first mouse button was released on/clicked inside it, we need
|
||||
@@ -1551,8 +1547,8 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
|
||||
/* Clicks on the status bar are handled elsewhere, so
|
||||
* restore the untranslated mouse-event coordinates. */
|
||||
if (*mouse_y == 0) {
|
||||
*mouse_x = mevent.x - margin;
|
||||
*mouse_y = mevent.y;
|
||||
*mouse_x = event.x;
|
||||
*mouse_y = event.y;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1603,7 +1599,7 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
|
||||
/* Handle presses of the fourth mouse button (upward rolls of the
|
||||
* mouse wheel) and presses of the fifth mouse button (downward
|
||||
* rolls of the mouse wheel) . */
|
||||
else if (mevent.bstate & (BUTTON4_PRESSED | BUTTON5_PRESSED)) {
|
||||
else if (event.bstate & (BUTTON4_PRESSED | BUTTON5_PRESSED)) {
|
||||
bool in_edit = wenclose(edit, *mouse_y, *mouse_x);
|
||||
|
||||
if (in_bottomwin)
|
||||
@@ -1611,7 +1607,7 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
|
||||
wmouse_trafo(bottomwin, mouse_y, mouse_x, FALSE);
|
||||
|
||||
if (in_edit || (in_bottomwin && *mouse_y == 0)) {
|
||||
int keycode = (mevent.bstate & BUTTON4_PRESSED) ? KEY_UP : KEY_DOWN;
|
||||
int keycode = (event.bstate & BUTTON4_PRESSED) ? KEY_UP : KEY_DOWN;
|
||||
|
||||
/* One roll of the mouse wheel should move three lines. */
|
||||
for (int count = 3; count > 0; count--)
|
||||
@@ -1897,6 +1893,19 @@ int buffer_number(openfilestruct *buffer)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Show the state of auto-indenting, the mark, hard-wrapping, macro recording,
|
||||
* and soft-wrapping by showing corresponding letters in the given window. */
|
||||
void show_states_at(WINDOW *window)
|
||||
{
|
||||
waddstr(window, ISSET(AUTOINDENT) ? "I" : " ");
|
||||
waddstr(window, openfile->mark ? "M" : " ");
|
||||
waddstr(window, ISSET(BREAK_LONG_LINES) ? "L" : " ");
|
||||
waddstr(window, recording ? "R" : " ");
|
||||
waddstr(window, ISSET(SOFTWRAP) ? "S" : " ");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If path is NULL, we're in normal editing mode, so display the current
|
||||
* version of nano, the current filename, and whether the current file
|
||||
* has been modified on the title bar. If path isn't NULL, we're either
|
||||
@@ -2034,16 +2043,12 @@ void titlebar(const char *path)
|
||||
#ifndef NANO_TINY
|
||||
/* When requested, show on the title bar the state of three options and
|
||||
* the state of the mark and whether a macro is being recorded. */
|
||||
if (ISSET(STATEFLAGS) && !ISSET(VIEW_MODE)) {
|
||||
if (*state && ISSET(STATEFLAGS) && !ISSET(VIEW_MODE)) {
|
||||
if (openfile->modified && COLS > 1)
|
||||
waddstr(topwin, " *");
|
||||
if (statelen < COLS) {
|
||||
wmove(topwin, 0, COLS + 2 - statelen);
|
||||
waddstr(topwin, ISSET(AUTOINDENT) ? "I" : " ");
|
||||
waddstr(topwin, openfile->mark ? "M" : " ");
|
||||
waddstr(topwin, ISSET(BREAK_LONG_LINES) ? "L" : " ");
|
||||
waddstr(topwin, recording ? "R" : " ");
|
||||
waddstr(topwin, ISSET(SOFTWRAP) ? "S" : " ");
|
||||
show_states_at(topwin);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
@@ -2060,6 +2065,142 @@ void titlebar(const char *path)
|
||||
wrefresh(topwin);
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Draw a bar at the bottom with some minimal state information. */
|
||||
void minibar(void)
|
||||
{
|
||||
char *thename = NULL, *number_of_lines = NULL, *ranking = NULL;
|
||||
char *location = nmalloc(44);
|
||||
char *hexadecimal = nmalloc(9);
|
||||
char *successor = NULL;
|
||||
size_t namewidth, placewidth;
|
||||
size_t tallywidth = 0;
|
||||
size_t padding = 2;
|
||||
#ifdef ENABLE_UTF8
|
||||
wchar_t widecode;
|
||||
#endif
|
||||
|
||||
/* Draw a colored bar over the full width of the screen. */
|
||||
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
mvwprintw(bottomwin, 0, 0, "%*s", COLS, " ");
|
||||
|
||||
/* Display the name of the current file, plus a star when modified. */
|
||||
if (openfile->filename[0] != '\0') {
|
||||
as_an_at = FALSE;
|
||||
thename = display_string(openfile->filename, 0, HIGHEST_POSITIVE, FALSE, FALSE);
|
||||
} else
|
||||
thename = copy_of(_("(nameless)"));
|
||||
|
||||
sprintf(location, "%zi,%zi", openfile->current->lineno, xplustabs() + 1);
|
||||
placewidth = strlen(location);
|
||||
namewidth = breadth(thename);
|
||||
|
||||
/* If the file name is relatively long, drop the side spaces. */
|
||||
if (namewidth + 19 > COLS)
|
||||
padding = 0;
|
||||
|
||||
if (COLS > 4) {
|
||||
/* If the full file name doesn't fit, dottify it. */
|
||||
if (namewidth > COLS - 2) {
|
||||
thename = display_string(thename, namewidth - COLS + 5, COLS - 5, FALSE, FALSE);
|
||||
mvwaddstr(bottomwin, 0, 0, "...");
|
||||
waddstr(bottomwin, thename);
|
||||
} else
|
||||
mvwaddstr(bottomwin, 0, padding, thename);
|
||||
|
||||
waddstr(bottomwin, openfile->modified ? " *" : " ");
|
||||
}
|
||||
|
||||
if (report_size && COLS > 35) {
|
||||
size_t count = openfile->filebot->lineno - (openfile->filebot->data[0] == '\0');
|
||||
|
||||
number_of_lines = nmalloc(44);
|
||||
sprintf(number_of_lines, P_(" (%zu line)", " (%zu lines)", count), count);
|
||||
tallywidth = breadth(number_of_lines);
|
||||
if (namewidth + tallywidth + 11 < COLS)
|
||||
waddstr(bottomwin, number_of_lines);
|
||||
else
|
||||
tallywidth = 0;
|
||||
report_size = FALSE;
|
||||
}
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
else if (openfile->next != openfile && COLS > 35) {
|
||||
ranking = nmalloc(24);
|
||||
sprintf(ranking, " [%i/%i]", buffer_number(openfile), buffer_number(startfile->prev));
|
||||
if (namewidth + placewidth + breadth(ranking) + 32 < COLS)
|
||||
waddstr(bottomwin, ranking);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Display the line/column position of the cursor. */
|
||||
if (ISSET(CONSTANT_SHOW) && namewidth + tallywidth + placewidth + 32 < COLS)
|
||||
mvwaddstr(bottomwin, 0, COLS - 27 - placewidth, location);
|
||||
|
||||
/* Display the hexadecimal code of the character under the cursor. */
|
||||
if (ISSET(CONSTANT_SHOW) && namewidth + tallywidth + 28 < COLS) {
|
||||
char *this_position = openfile->current->data + openfile->current_x;
|
||||
|
||||
if (*this_position == '\0')
|
||||
sprintf(hexadecimal, openfile->current->next ?
|
||||
#ifdef ENABLE_UTF8
|
||||
using_utf8() ? "U+000A" :
|
||||
#endif
|
||||
" 0x0A" : " ----");
|
||||
else if (*this_position == '\n')
|
||||
sprintf(hexadecimal, " 0x00");
|
||||
#ifdef ENABLE_UTF8
|
||||
else if ((unsigned char)*this_position < 0x80 && using_utf8())
|
||||
sprintf(hexadecimal, "U+%04X", (unsigned char)*this_position);
|
||||
else if (using_utf8() && mbtowc(&widecode, this_position, MAXCHARLEN) >= 0)
|
||||
sprintf(hexadecimal, "U+%04X", (int)widecode);
|
||||
#endif
|
||||
else
|
||||
sprintf(hexadecimal, " 0x%02X", (unsigned char)*this_position);
|
||||
|
||||
mvwaddstr(bottomwin, 0, COLS - 23, hexadecimal);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
successor = this_position + char_length(this_position);
|
||||
|
||||
if (*this_position && *successor && is_zerowidth(successor) &&
|
||||
mbtowc(&widecode, successor, MAXCHARLEN) >= 0) {
|
||||
sprintf(hexadecimal, "|%04X", (int)widecode);
|
||||
waddstr(bottomwin, hexadecimal);
|
||||
|
||||
successor += char_length(successor);
|
||||
|
||||
if (is_zerowidth(successor) && mbtowc(&widecode, successor, MAXCHARLEN) >= 0) {
|
||||
sprintf(hexadecimal, "|%04X", (int)widecode);
|
||||
waddstr(bottomwin, hexadecimal);
|
||||
}
|
||||
} else
|
||||
successor = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Display the state of three flags, and the state of macro and mark. */
|
||||
if (ISSET(STATEFLAGS) && !successor && namewidth + tallywidth + 14 + 2 * padding < COLS) {
|
||||
wmove(bottomwin, 0, COLS - 11 - padding);
|
||||
show_states_at(bottomwin);
|
||||
}
|
||||
|
||||
/* Display how many percent the current line is into the file. */
|
||||
if (namewidth + 6 < COLS) {
|
||||
sprintf(location, "%3zi%%", 100 * openfile->current->lineno / openfile->filebot->lineno);
|
||||
mvwaddstr(bottomwin, 0, COLS - 4 - padding, location);
|
||||
}
|
||||
|
||||
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
wrefresh(bottomwin);
|
||||
|
||||
free(number_of_lines);
|
||||
free(hexadecimal);
|
||||
free(location);
|
||||
free(thename);
|
||||
free(ranking);
|
||||
}
|
||||
#endif /* NANO_TINY */
|
||||
|
||||
/* Display the given message on the status bar, but only if its importance
|
||||
* is higher than that of a message that is already there. */
|
||||
void statusline(message_type importance, const char *msg, ...)
|
||||
@@ -2079,8 +2220,7 @@ void statusline(message_type importance, const char *msg, ...)
|
||||
#endif
|
||||
|
||||
/* Ignore a message with an importance that is lower than the last one. */
|
||||
if ((lastmessage == ALERT && importance != ALERT) ||
|
||||
(lastmessage == MILD && importance == HUSH))
|
||||
if (importance < lastmessage && lastmessage > NOTICE)
|
||||
return;
|
||||
|
||||
/* If there are multiple alert messages, add trailing dots to the first. */
|
||||
@@ -2098,8 +2238,9 @@ void statusline(message_type importance, const char *msg, ...)
|
||||
return;
|
||||
}
|
||||
|
||||
if (importance == ALERT) {
|
||||
beep();
|
||||
if (importance > NOTICE) {
|
||||
if (importance == ALERT)
|
||||
beep();
|
||||
colorpair = interface_color_pair[ERROR_MESSAGE];
|
||||
} else if (importance == NOTICE)
|
||||
colorpair = interface_color_pair[SELECTED_TEXT];
|
||||
@@ -2145,17 +2286,8 @@ void statusline(message_type importance, const char *msg, ...)
|
||||
SET(WHITESPACE_DISPLAY);
|
||||
#endif
|
||||
|
||||
/* If doing quick blanking, blank the status bar after just one keystroke.
|
||||
* Otherwise, blank it after twenty-six keystrokes, as Pico does. */
|
||||
if (ISSET(QUICK_BLANK))
|
||||
statusblank = 1;
|
||||
else
|
||||
statusblank = 26;
|
||||
|
||||
#ifdef USE_SLANG
|
||||
/* Work around a shy cursor -- https://sv.gnu.org/bugs/?59091. */
|
||||
bottombars(MGOTODIR);
|
||||
#endif
|
||||
/* When requested, wipe the status bar after just one keystroke. */
|
||||
statusblank = (ISSET(QUICK_BLANK) ? 1 : 20);
|
||||
}
|
||||
|
||||
/* Display a normal message on the status bar, quietly. */
|
||||
@@ -2300,11 +2432,10 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_COLOR)
|
||||
size_t from_x = actual_x(line->data, from_col);
|
||||
/* The position in the line's data of the leftmost character
|
||||
* that displays at least partially on the window. */
|
||||
* that is at least partially onscreen. */
|
||||
size_t till_x = actual_x(line->data, from_col + editwincols - 1) + 1;
|
||||
/* The position in the line's data of the first character that
|
||||
* is completely off the window to the right. Note that till_x
|
||||
* might be beyond the null terminator of the string. */
|
||||
/* The position in the line's data just after the start of
|
||||
* the last character that is at least partially onscreen. */
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
@@ -2351,15 +2482,15 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||
if (openfile->syntax && !ISSET(NO_SYNTAX)) {
|
||||
const colortype *varnish = openfile->syntax->color;
|
||||
|
||||
/* If there are multiline regexes, make sure there is a cache. */
|
||||
/* If there are multiline regexes, make sure this line has a cache. */
|
||||
if (openfile->syntax->nmultis > 0 && line->multidata == NULL)
|
||||
set_up_multicache(line);
|
||||
line->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
|
||||
/* Iterate through all the coloring regexes. */
|
||||
for (; varnish != NULL; varnish = varnish->next) {
|
||||
size_t index = 0;
|
||||
/* Where in the line we currently begin looking for a match. */
|
||||
int start_col;
|
||||
int start_col = 0;
|
||||
/* The starting column of a piece to paint. Zero-based. */
|
||||
int paintlen = 0;
|
||||
/* The number of characters to paint. */
|
||||
@@ -2369,87 +2500,81 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||
/* The match positions of a single-line regex. */
|
||||
const linestruct *start_line = line->prev;
|
||||
/* The first line before line that matches 'start'. */
|
||||
const linestruct *end_line = line;
|
||||
linestruct *end_line = line;
|
||||
/* The line that matches 'end'. */
|
||||
regmatch_t startmatch, endmatch;
|
||||
/* The match positions of the start and end regexes. */
|
||||
|
||||
/* Two notes about regexec(). A return value of zero means
|
||||
* that there is a match. Also, rm_eo is the first
|
||||
* non-matching character after the match. */
|
||||
|
||||
wattron(edit, varnish->attributes);
|
||||
|
||||
/* First case: varnish is a single-line expression. */
|
||||
if (varnish->end == NULL) {
|
||||
/* We increment index by rm_eo, to move past the end of the
|
||||
* last match. Even though two matches may overlap, we
|
||||
* want to ignore them, so that we can highlight e.g. C
|
||||
* strings correctly. */
|
||||
while (index < till_x) {
|
||||
/* Note the fifth parameter to regexec(). It says
|
||||
* not to match the beginning-of-line character
|
||||
* unless index is zero. If regexec() returns
|
||||
* REG_NOMATCH, there are no more matches in the
|
||||
* line. */
|
||||
/* If there is no match, go on to the next line. */
|
||||
if (regexec(varnish->start, &line->data[index], 1,
|
||||
&match, (index == 0) ? 0 : REG_NOTBOL) != 0)
|
||||
break;
|
||||
|
||||
/* If the match is of length zero, skip it. */
|
||||
if (match.rm_so == match.rm_eo) {
|
||||
index = step_right(line->data, index + match.rm_eo);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Translate the match to the beginning of the line. */
|
||||
match.rm_so += index;
|
||||
match.rm_eo += index;
|
||||
index = match.rm_eo;
|
||||
|
||||
/* If the matching part is not visible, skip it. */
|
||||
if (match.rm_eo <= from_x || match.rm_so >= till_x)
|
||||
/* If the match is offscreen to the right, this rule is done. */
|
||||
if (match.rm_so >= till_x)
|
||||
break;
|
||||
|
||||
/* If the match has length zero, advance over it. */
|
||||
if (match.rm_so == match.rm_eo) {
|
||||
if (line->data[index] == '\0')
|
||||
break;
|
||||
index = step_right(line->data, index);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If the match is offscreen to the left, skip to next. */
|
||||
if (match.rm_eo <= from_x)
|
||||
continue;
|
||||
|
||||
start_col = (match.rm_so <= from_x) ?
|
||||
0 : wideness(line->data,
|
||||
match.rm_so) - from_col;
|
||||
if (match.rm_so > from_x)
|
||||
start_col = wideness(line->data, match.rm_so) - from_col;
|
||||
|
||||
thetext = converted + actual_x(converted, start_col);
|
||||
|
||||
paintlen = actual_x(thetext, wideness(line->data,
|
||||
match.rm_eo) - from_col - start_col);
|
||||
|
||||
wattron(edit, varnish->attributes);
|
||||
mvwaddnstr(edit, row, margin + start_col, thetext, paintlen);
|
||||
wattroff(edit, varnish->attributes);
|
||||
}
|
||||
goto tail_of_loop;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Second case: varnish is a multiline expression. */
|
||||
|
||||
/* Assume nothing gets painted until proven otherwise below. */
|
||||
line->multidata[varnish->id] = CNONE;
|
||||
line->multidata[varnish->id] = NOTHING;
|
||||
|
||||
/* First check the multidata of the preceding line -- it tells
|
||||
* us about the situation so far, and thus what to do here. */
|
||||
if (start_line != NULL && start_line->multidata != NULL) {
|
||||
if (start_line->multidata[varnish->id] == CWHOLELINE ||
|
||||
start_line->multidata[varnish->id] == CENDAFTER ||
|
||||
start_line->multidata[varnish->id] == CWOULDBE)
|
||||
/* Apart from the first row, check the multidata of the preceding line:
|
||||
* it tells us about the situation so far, and thus what to do here. */
|
||||
if (row > 0 && start_line != NULL && start_line->multidata != NULL) {
|
||||
if (start_line->multidata[varnish->id] == WHOLELINE ||
|
||||
start_line->multidata[varnish->id] == STARTSHERE ||
|
||||
start_line->multidata[varnish->id] == WOULDBE)
|
||||
goto seek_an_end;
|
||||
if (start_line->multidata[varnish->id] == CNONE ||
|
||||
start_line->multidata[varnish->id] == CBEGINBEFORE ||
|
||||
start_line->multidata[varnish->id] == CSTARTENDHERE)
|
||||
if (start_line->multidata[varnish->id] == NOTHING ||
|
||||
start_line->multidata[varnish->id] == ENDSHERE ||
|
||||
start_line->multidata[varnish->id] == JUSTONTHIS)
|
||||
goto step_two;
|
||||
}
|
||||
|
||||
/* The preceding line has no precalculated multidata. So, do
|
||||
* some backtracking to find out what to paint. */
|
||||
/* The preceding line has no precalculated multidata.
|
||||
* So, do some backtracking to find out what to paint. */
|
||||
|
||||
/* First step: see if there is a line before current that
|
||||
* matches 'start' and is not complemented by an 'end'. */
|
||||
while (start_line != NULL && regexec(varnish->start,
|
||||
start_line->data, 1, &startmatch, 0) == REG_NOMATCH) {
|
||||
start_line->data, 1, &startmatch, 0) == REG_NOMATCH) {
|
||||
/* There is no start on this line; but if there is an end,
|
||||
* there is no need to look for starts on earlier lines. */
|
||||
if (regexec(varnish->end, start_line->data, 0, NULL, 0) == 0)
|
||||
@@ -2461,14 +2586,14 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||
if (start_line == NULL)
|
||||
goto step_two;
|
||||
|
||||
/* If a found start has been qualified as an end earlier,
|
||||
* believe it and skip to the next step. */
|
||||
/* If the start has been qualified as an end earlier, believe it. */
|
||||
if (start_line->multidata != NULL &&
|
||||
(start_line->multidata[varnish->id] == CBEGINBEFORE ||
|
||||
start_line->multidata[varnish->id] == CSTARTENDHERE))
|
||||
(start_line->multidata[varnish->id] == ENDSHERE ||
|
||||
start_line->multidata[varnish->id] == JUSTONTHIS))
|
||||
goto step_two;
|
||||
|
||||
/* Is there an uncomplemented start on the found line? */
|
||||
/* Maybe there is an end on that same line? If yes, maybe
|
||||
* there is another start after it? And so on, until EOL. */
|
||||
while (TRUE) {
|
||||
/* Begin searching for an end after the start match. */
|
||||
index += startmatch.rm_eo;
|
||||
@@ -2482,7 +2607,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||
if (startmatch.rm_so == startmatch.rm_eo &&
|
||||
endmatch.rm_so == endmatch.rm_eo) {
|
||||
if (start_line->data[index] == '\0')
|
||||
break;
|
||||
goto step_two;
|
||||
index = step_right(start_line->data, index);
|
||||
}
|
||||
/* If there is no later start on this line, next step. */
|
||||
@@ -2490,79 +2615,87 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||
1, &startmatch, REG_NOTBOL) == REG_NOMATCH)
|
||||
goto step_two;
|
||||
}
|
||||
/* Indeed, there is a start without an end on that line. */
|
||||
|
||||
seek_an_end:
|
||||
/* We've already checked that there is no end between the start
|
||||
* and the current line. But is there an end after the start
|
||||
* at all? We don't paint unterminated starts. */
|
||||
while (end_line != NULL && regexec(varnish->end, end_line->data,
|
||||
1, &endmatch, 0) == REG_NOMATCH)
|
||||
end_line = end_line->next;
|
||||
* at all? Because we don't paint unterminated starts. */
|
||||
if (row == 0) {
|
||||
while (end_line != NULL && regexec(varnish->end, end_line->data,
|
||||
1, &endmatch, 0) == REG_NOMATCH)
|
||||
end_line = end_line->next;
|
||||
} else if (regexec(varnish->end, line->data, 1, &endmatch, 0) != 0)
|
||||
end_line = line->next;
|
||||
|
||||
/* If there is no end, there is nothing to paint. */
|
||||
if (end_line == NULL) {
|
||||
line->multidata[varnish->id] = CWOULDBE;
|
||||
goto tail_of_loop;
|
||||
line->multidata[varnish->id] = WOULDBE;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If it was already determined that there is no end... */
|
||||
if (end_line != line && line->prev == start_line && line->prev->multidata &&
|
||||
line->prev->multidata[varnish->id] == WOULDBE) {
|
||||
line->multidata[varnish->id] = WOULDBE;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If the end is on a later line, paint whole line, and be done. */
|
||||
if (end_line != line) {
|
||||
wattron(edit, varnish->attributes);
|
||||
mvwaddnstr(edit, row, margin, converted, -1);
|
||||
line->multidata[varnish->id] = CWHOLELINE;
|
||||
goto tail_of_loop;
|
||||
wattroff(edit, varnish->attributes);
|
||||
line->multidata[varnish->id] = WHOLELINE;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Only if it is visible, paint the part to be coloured. */
|
||||
if (endmatch.rm_eo > from_x) {
|
||||
paintlen = actual_x(converted, wideness(line->data,
|
||||
endmatch.rm_eo) - from_col);
|
||||
wattron(edit, varnish->attributes);
|
||||
mvwaddnstr(edit, row, margin, converted, paintlen);
|
||||
wattroff(edit, varnish->attributes);
|
||||
}
|
||||
line->multidata[varnish->id] = CBEGINBEFORE;
|
||||
line->multidata[varnish->id] = ENDSHERE;
|
||||
|
||||
step_two:
|
||||
/* Second step: look for starts on this line, but begin
|
||||
* looking only after an end match, if there is one. */
|
||||
index = (paintlen == 0) ? 0 : endmatch.rm_eo;
|
||||
|
||||
while (regexec(varnish->start, line->data + index,
|
||||
1, &startmatch, (index == 0) ?
|
||||
0 : REG_NOTBOL) == 0) {
|
||||
/* Translate the match to be relative to the
|
||||
* beginning of the line. */
|
||||
while (regexec(varnish->start, line->data + index, 1, &startmatch,
|
||||
(index == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
/* Make the match relative to the beginning of the line. */
|
||||
startmatch.rm_so += index;
|
||||
startmatch.rm_eo += index;
|
||||
|
||||
start_col = (startmatch.rm_so <= from_x) ?
|
||||
0 : wideness(line->data,
|
||||
startmatch.rm_so) - from_col;
|
||||
if (startmatch.rm_so > from_x)
|
||||
start_col = wideness(line->data, startmatch.rm_so) - from_col;
|
||||
|
||||
thetext = converted + actual_x(converted, start_col);
|
||||
|
||||
if (regexec(varnish->end, line->data + startmatch.rm_eo,
|
||||
1, &endmatch, (startmatch.rm_eo == 0) ?
|
||||
0 : REG_NOTBOL) == 0) {
|
||||
/* Translate the end match to be relative to
|
||||
* the beginning of the line. */
|
||||
if (regexec(varnish->end, line->data + startmatch.rm_eo, 1, &endmatch,
|
||||
(startmatch.rm_eo == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
/* Make the match relative to the beginning of the line. */
|
||||
endmatch.rm_so += startmatch.rm_eo;
|
||||
endmatch.rm_eo += startmatch.rm_eo;
|
||||
/* Only paint the match if it is visible on screen and
|
||||
* it is more than zero characters long. */
|
||||
if (endmatch.rm_eo > from_x &&
|
||||
endmatch.rm_eo > startmatch.rm_so) {
|
||||
/* Only paint the match if it is visible on screen
|
||||
* and it is more than zero characters long. */
|
||||
if (endmatch.rm_eo > from_x && endmatch.rm_eo > startmatch.rm_so) {
|
||||
paintlen = actual_x(thetext, wideness(line->data,
|
||||
endmatch.rm_eo) - from_col - start_col);
|
||||
endmatch.rm_eo) - from_col - start_col);
|
||||
|
||||
mvwaddnstr(edit, row, margin + start_col,
|
||||
thetext, paintlen);
|
||||
wattron(edit, varnish->attributes);
|
||||
mvwaddnstr(edit, row, margin + start_col, thetext, paintlen);
|
||||
wattroff(edit, varnish->attributes);
|
||||
|
||||
line->multidata[varnish->id] = CSTARTENDHERE;
|
||||
line->multidata[varnish->id] = JUSTONTHIS;
|
||||
}
|
||||
index = endmatch.rm_eo;
|
||||
/* If both start and end match are anchors, advance. */
|
||||
if (startmatch.rm_so == startmatch.rm_eo &&
|
||||
endmatch.rm_so == endmatch.rm_eo) {
|
||||
endmatch.rm_so == endmatch.rm_eo) {
|
||||
if (line->data[index] == '\0')
|
||||
break;
|
||||
index = step_right(line->data, index);
|
||||
@@ -2573,23 +2706,32 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||
/* There is no end on this line. But maybe on later lines? */
|
||||
end_line = line->next;
|
||||
|
||||
while (end_line != NULL && regexec(varnish->end, end_line->data,
|
||||
0, NULL, 0) == REG_NOMATCH)
|
||||
while (end_line && regexec(varnish->end, end_line->data,
|
||||
0, NULL, 0) == REG_NOMATCH)
|
||||
end_line = end_line->next;
|
||||
|
||||
/* If there is no end, we're done with this regex. */
|
||||
if (end_line == NULL) {
|
||||
line->multidata[varnish->id] = CWOULDBE;
|
||||
line->multidata[varnish->id] = WOULDBE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Paint the rest of the line, and we're done. */
|
||||
wattron(edit, varnish->attributes);
|
||||
mvwaddnstr(edit, row, margin + start_col, thetext, -1);
|
||||
line->multidata[varnish->id] = CENDAFTER;
|
||||
wattroff(edit, varnish->attributes);
|
||||
|
||||
line->multidata[varnish->id] = STARTSHERE;
|
||||
|
||||
if (end_line->multidata == NULL) {
|
||||
end_line->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
for (short item = 0; item < openfile->syntax->nmultis; item++)
|
||||
end_line->multidata[item] = 0;
|
||||
}
|
||||
end_line->multidata[varnish->id] = ENDSHERE;
|
||||
|
||||
break;
|
||||
}
|
||||
tail_of_loop:
|
||||
wattroff(edit, varnish->attributes);
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_COLOR */
|
||||
@@ -2712,7 +2854,7 @@ int update_line(linestruct *line, size_t index)
|
||||
wattroff(edit, hilite_attribute);
|
||||
}
|
||||
|
||||
if (spotlighted && line == openfile->current && !inhelp)
|
||||
if (spotlighted && line == openfile->current)
|
||||
spotlight(light_from_col, light_to_col);
|
||||
|
||||
return 1;
|
||||
@@ -2773,7 +2915,7 @@ int update_softwrapped_line(linestruct *line)
|
||||
from_col = to_col;
|
||||
}
|
||||
|
||||
if (spotlighted && line == openfile->current && !inhelp)
|
||||
if (spotlighted && line == openfile->current)
|
||||
spotlight_softwrapped(light_from_col, light_to_col);
|
||||
|
||||
return (row - starting_row);
|
||||
@@ -3229,6 +3371,12 @@ void edit_refresh(void)
|
||||
draw_scrollbar();
|
||||
#endif
|
||||
|
||||
//#define TIMEREFRESH 123
|
||||
#ifdef TIMEREFRESH
|
||||
#include <time.h>
|
||||
clock_t start = clock();
|
||||
#endif
|
||||
|
||||
line = openfile->edittop;
|
||||
|
||||
while (row < editwinrows && line != NULL) {
|
||||
@@ -3248,6 +3396,10 @@ void edit_refresh(void)
|
||||
row++;
|
||||
}
|
||||
|
||||
#ifdef TIMEREFRESH
|
||||
statusline(INFO, "Refresh: %.1f ms", 1000 * (double)(clock() - start) / CLOCKS_PER_SEC);
|
||||
#endif
|
||||
|
||||
place_the_cursor();
|
||||
wnoutrefresh(edit);
|
||||
|
||||
@@ -3283,21 +3435,14 @@ void adjust_viewport(update_type manner)
|
||||
/* Tell curses to unconditionally redraw whatever was on the screen. */
|
||||
void full_refresh(void)
|
||||
{
|
||||
#ifdef USE_SLANG
|
||||
/* Slang curses emulation brain damage, part 4: Slang doesn't define
|
||||
* curscr. */
|
||||
SLsmg_touch_screen();
|
||||
SLsmg_refresh();
|
||||
#else
|
||||
wrefresh(curscr);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Draw all elements of the screen. That is: the title bar plus the content
|
||||
* of the edit window (when not in the file browser), and the bottom bars. */
|
||||
void draw_all_subwindows(void)
|
||||
{
|
||||
if (currmenu != MBROWSER && currmenu != MWHEREISFILE && currmenu != MGOTODIR)
|
||||
if (currmenu & ~(MBROWSER|MWHEREISFILE|MGOTODIR))
|
||||
titlebar(title);
|
||||
#ifdef ENABLE_HELP
|
||||
if (inhelp) {
|
||||
@@ -3305,7 +3450,7 @@ void draw_all_subwindows(void)
|
||||
wrap_help_text_into_buffer();
|
||||
} else
|
||||
#endif
|
||||
if (currmenu != MBROWSER && currmenu != MWHEREISFILE && currmenu != MGOTODIR)
|
||||
if (currmenu & ~(MBROWSER|MWHEREISFILE|MGOTODIR))
|
||||
edit_refresh();
|
||||
bottombars(currmenu);
|
||||
}
|
||||
@@ -3332,15 +3477,10 @@ void report_cursor_position(void)
|
||||
colpct = 100 * column / fullwidth;
|
||||
charpct = (openfile->totsize == 0) ? 0 : 100 * sum / openfile->totsize;
|
||||
|
||||
statusline(HUSH,
|
||||
statusline(INFO,
|
||||
_("line %zd/%zd (%d%%), col %zu/%zu (%d%%), char %zu/%zu (%d%%)"),
|
||||
openfile->current->lineno, openfile->filebot->lineno, linepct,
|
||||
column, fullwidth, colpct, sum, openfile->totsize, charpct);
|
||||
|
||||
#ifdef USE_SLANG
|
||||
/* Restore the help lines after the above call overwrote them. */
|
||||
bottombars(MMAIN);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Highlight the text between the given two columns on the current line. */
|
||||
@@ -3364,11 +3504,11 @@ void spotlight(size_t from_col, size_t to_col)
|
||||
word = display_string(openfile->current->data, from_col,
|
||||
to_col - from_col, FALSE, overshoots);
|
||||
|
||||
wattron(edit, interface_color_pair[SELECTED_TEXT]);
|
||||
wattron(edit, interface_color_pair[HIGHLIGHTED]);
|
||||
waddnstr(edit, word, actual_x(word, to_col));
|
||||
if (overshoots)
|
||||
mvwaddch(edit, openfile->current_y, COLS - 1 - thebar, '>');
|
||||
wattroff(edit, interface_color_pair[SELECTED_TEXT]);
|
||||
wattroff(edit, interface_color_pair[HIGHLIGHTED]);
|
||||
|
||||
free(word);
|
||||
}
|
||||
@@ -3480,7 +3620,7 @@ void do_credits(void)
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"(C) 2020",
|
||||
"(C) 2021",
|
||||
"Free Software Foundation, Inc.",
|
||||
"",
|
||||
"",
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
## Syntax highlighting for Go.
|
||||
|
||||
## Original author: Robert Clausecker
|
||||
## License: CC0 (public domain)
|
||||
|
||||
syntax go "\.go$"
|
||||
comment "//"
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ comment "#"
|
||||
color brightred ".*"
|
||||
|
||||
# Keywords
|
||||
color brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|boldtext|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|historylog|indicator|jumpyscrolling|linenumbers|locking|magic|mouse|multibuffer|noconvert|nohelp|nonewlines|positionlog|preserve|quickblank|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|softwrap|stateflags|suspendable|tabstospaces|trimblanks|unix|wordbounds|zap)\>"
|
||||
color yellow "^[[:space:]]*set[[:space:]]+((error|function|key|number|scroller|selected|status|stripe|title)color)[[:space:]]+(bold,)?(italic,)?(bright|light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte)?(,(light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte))?\>"
|
||||
color brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|scrollercolor|selectedcolor|speller|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:space:]]+"
|
||||
color brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|boldtext|bookstyle|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|historylog|indicator|jumpyscrolling|linenumbers|locking|magic|minibar|mouse|multibuffer|noconvert|nohelp|nonewlines|positionlog|preserve|quickblank|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|softwrap|stateflags|suspendable|tabstospaces|trimblanks|unix|wordbounds|zap)\>"
|
||||
color yellow "^[[:space:]]*set[[:space:]]+((error|function|highlight|key|number|prompt|scroller|selected|status|stripe|title)color)[[:space:]]+(bold,)?(italic,)?(bright|light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte)?(,(light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte))?\>"
|
||||
color brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|functioncolor|highlightcolor|keycolor|matchbrackets|numbercolor|operatingdir|promptcolor|punct|quotestr|scrollercolor|selectedcolor|speller|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:space:]]+"
|
||||
color brightgreen "^[[:space:]]*set[[:space:]]+(fill[[:space:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:space:]]+[1-9][0-9]*)\>"
|
||||
color brightgreen "^[[:space:]]*bind[[:space:]]+((\^([A-Za-z]|[]/@\^_`]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:space:]]+([a-z]+|".*")[[:space:]]+(main|help|search|replace(with)?|yesno|gotoline|writeout|insert|browser|whereisfile|gotodir|execute|spell|linter|all)([[:space:]]+#|[[:space:]]*$)"
|
||||
color brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([A-Za-z]|[]/@\^_`]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:space:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## Syntax highlighting for Bourne shell scripts.
|
||||
|
||||
syntax sh "(\.sh|(\.|/)(a|ba|c|da|k|mk|pdk|tc|z)sh(rc|_profile)?|/(etc/|\.)profile)$"
|
||||
header "^#!.*/(((a|ba|c|da|k|mk|pdk|tc|z)?sh)|(busybox|env) +sh|openrc-run|runscript)"
|
||||
header "^#!.*/((env\s+)?((a|ba|c|da|k|mk|pdk|tc|z)?sh)|busybox\s+sh|openrc-run|runscript)\>"
|
||||
header "-\*-.*shell-script.*-\*-"
|
||||
magic "(POSIX|Bourne-Again) shell script.*text"
|
||||
comment "#"
|
||||
|
||||
Reference in New Issue
Block a user