Compare commits
274 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bec0cdcb54 | ||
|
|
ba9e5ac05d | ||
|
|
46b5f83601 | ||
|
|
6d5b16562f | ||
|
|
508301a2ef | ||
|
|
2f216281e7 | ||
|
|
9459030d66 | ||
|
|
f545735638 | ||
|
|
bb8f40989f | ||
|
|
675ad6386d | ||
|
|
6ce3487b65 | ||
|
|
bc7e7d847e | ||
|
|
71a73a1a10 | ||
|
|
c2790a8af3 | ||
|
|
fde86518ae | ||
|
|
61b3aa6626 | ||
|
|
6799bc69a6 | ||
|
|
0c01227d86 | ||
|
|
c74fd81302 | ||
|
|
4b30cfb8f8 | ||
|
|
36b6416a7b | ||
|
|
e0334e861d | ||
|
|
b07fb5a811 | ||
|
|
9ab49658d7 | ||
|
|
bb3d367716 | ||
|
|
26c0a7962e | ||
|
|
a2b20a1915 | ||
|
|
2087c20a83 | ||
|
|
5512c63bdd | ||
|
|
d31cf1da68 | ||
|
|
ce656cfca8 | ||
|
|
46cdf8b745 | ||
|
|
fdc0b0ac24 | ||
|
|
42b7dea14b | ||
|
|
239c794503 | ||
|
|
189960c467 | ||
|
|
04f8aa83ef | ||
|
|
802a20b222 | ||
|
|
88f7ec38f8 | ||
|
|
baaff48547 | ||
|
|
0010cd4443 | ||
|
|
7d6ffd9e78 | ||
|
|
b8daf1fb0b | ||
|
|
fe5f05f037 | ||
|
|
5cedb53c62 | ||
|
|
650dc14e0f | ||
|
|
43ebabe05d | ||
|
|
b6366411dc | ||
|
|
914921887e | ||
|
|
64a8f1930e | ||
|
|
0ac2dfd920 | ||
|
|
aa553ee5d6 | ||
|
|
a8961c561f | ||
|
|
abce19b0e4 | ||
|
|
fc317660cb | ||
|
|
949fcde6f7 | ||
|
|
9f24b6ea65 | ||
|
|
c6ba4ae89a | ||
|
|
dab3f95c71 | ||
|
|
840ad5890f | ||
|
|
ae61bab60b | ||
|
|
d3a7f3abed | ||
|
|
694cd9ddd4 | ||
|
|
47c8e627f4 | ||
|
|
f429ebe34d | ||
|
|
083bbae0e4 | ||
|
|
eaff5ec9e5 | ||
|
|
51eb938fea | ||
|
|
296c5a32c7 | ||
|
|
ef6ccc47c8 | ||
|
|
eea2dfce48 | ||
|
|
85682abbd5 | ||
|
|
4005ee3284 | ||
|
|
9ead4c87a7 | ||
|
|
1b5d9171f2 | ||
|
|
50543300d9 | ||
|
|
d9469b894f | ||
|
|
6b9c24f7dd | ||
|
|
5954eeaff2 | ||
|
|
c84a769733 | ||
|
|
e3ef778756 | ||
|
|
806e8e439f | ||
|
|
30aaea2d04 | ||
|
|
d0cb64650b | ||
|
|
0694255893 | ||
|
|
5563c710d0 | ||
|
|
177e4e5805 | ||
|
|
8d1a666dcf | ||
|
|
fc01c5a10e | ||
|
|
896f174f94 | ||
|
|
7b4a835df4 | ||
|
|
ac85e16458 | ||
|
|
45420968ee | ||
|
|
3c35538e8b | ||
|
|
4f981cd5d9 | ||
|
|
44a6c4963b | ||
|
|
622bfb5b83 | ||
|
|
a2cb22faab | ||
|
|
9f8309fba8 | ||
|
|
bf7954bdb7 | ||
|
|
0371dd1bde | ||
|
|
7c53b133a1 | ||
|
|
b1e5f9d9a8 | ||
|
|
424969258a | ||
|
|
6d0fc38285 | ||
|
|
984c9e1078 | ||
|
|
101dc4e805 | ||
|
|
d7e3226158 | ||
|
|
74c6bdac9f | ||
|
|
73168bb1b9 | ||
|
|
f895f1beba | ||
|
|
e2e8bf0a3e | ||
|
|
3f340836a6 | ||
|
|
092c62ccb8 | ||
|
|
97dd505647 | ||
|
|
635977fe33 | ||
|
|
6ab70c2b0a | ||
|
|
3a86b24a3e | ||
|
|
77ca8735ab | ||
|
|
3a0922799d | ||
|
|
b27efce732 | ||
|
|
8974430c11 | ||
|
|
e044284998 | ||
|
|
4f9d55bb15 | ||
|
|
89adacff3d | ||
|
|
2314a1932f | ||
|
|
fb5eb4856b | ||
|
|
f857959b8e | ||
|
|
405c2162b5 | ||
|
|
8797ada815 | ||
|
|
30bafc70cc | ||
|
|
b38f0cbaf4 | ||
|
|
ceaae49b2d | ||
|
|
d1957819c4 | ||
|
|
7993fc8b12 | ||
|
|
51adf02d34 | ||
|
|
f23e98dd3a | ||
|
|
6472a6b828 | ||
|
|
b741b1c985 | ||
|
|
5f87ed5644 | ||
|
|
8d974cd292 | ||
|
|
2cf28f9db7 | ||
|
|
36ffb5f0ac | ||
|
|
07fd4c4598 | ||
|
|
44fb3e9991 | ||
|
|
088557c516 | ||
|
|
4712d46462 | ||
|
|
c01b13a32c | ||
|
|
b368faf11c | ||
|
|
7303f0c7b4 | ||
|
|
eb3cc3a32d | ||
|
|
02df950240 | ||
|
|
a69a8ce3ca | ||
|
|
8a03d55c53 | ||
|
|
544351f3be | ||
|
|
96ebaf8ab4 | ||
|
|
6b7c661fb7 | ||
|
|
6823831c06 | ||
|
|
ec82530125 | ||
|
|
a45e1f89c0 | ||
|
|
c1cd813dcb | ||
|
|
c96e62e33a | ||
|
|
6283557d2f | ||
|
|
af90f03ac5 | ||
|
|
588022ab8c | ||
|
|
cf0820549b | ||
|
|
f54bc6c7d6 | ||
|
|
2cdff6c32c | ||
|
|
49d8b99e4f | ||
|
|
bb81932422 | ||
|
|
5efb6836a8 | ||
|
|
48fa14acc0 | ||
|
|
eb7181b35e | ||
|
|
8db42023bb | ||
|
|
018a8e12ca | ||
|
|
b4a5aedc6c | ||
|
|
d6ed174d09 | ||
|
|
78f92e044a | ||
|
|
f11931a0dd | ||
|
|
31a6931be9 | ||
|
|
debb288115 | ||
|
|
c75a3839da | ||
|
|
b6a32fbd5f | ||
|
|
09e4c86606 | ||
|
|
20eb422829 | ||
|
|
90c6b572d0 | ||
|
|
712b574fb7 | ||
|
|
fd023d6dcf | ||
|
|
9c16be32d7 | ||
|
|
c3cdb099da | ||
|
|
682a088fb8 | ||
|
|
8c25bd0e94 | ||
|
|
20e122ef41 | ||
|
|
0dcac9188f | ||
|
|
1c010d8ec9 | ||
|
|
b020937475 | ||
|
|
e3f46b066a | ||
|
|
df7fe1280d | ||
|
|
929770191e | ||
|
|
66d9d6c6d2 | ||
|
|
de816840cb | ||
|
|
74fcc3be79 | ||
|
|
b6909d3737 | ||
|
|
823d79b36c | ||
|
|
735757b0c1 | ||
|
|
09b919a68f | ||
|
|
2f718e11a7 | ||
|
|
77da54c6c6 | ||
|
|
6bf52dcc8d | ||
|
|
3d9e803aed | ||
|
|
ede64d7ea0 | ||
|
|
e8db390d6f | ||
|
|
0c1bf429e8 | ||
|
|
f6357a73f0 | ||
|
|
49ca7e5aa8 | ||
|
|
be9b1a1887 | ||
|
|
bb74aacf2d | ||
|
|
b72d9af52c | ||
|
|
a9ccd99b90 | ||
|
|
ac5e5179fb | ||
|
|
a543f8cd8f | ||
|
|
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 |
307
ChangeLog
307
ChangeLog
@@ -1,3 +1,310 @@
|
||||
Changes between v5.8 and v5.9:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (88):
|
||||
browser: make the keystrokes ^W^Y and ^W^V work again
|
||||
build: ensure that mkstemps() is available by importing the gnulib module
|
||||
build: help Haiku find the header files that define mkstemps()
|
||||
bump version numbers and add a news item for the 5.9 release
|
||||
copyright: update to the current year for significantly changed files
|
||||
cutting: copy anchors into the cutbuffer, so that undo can restore them
|
||||
docs: add a paragraph at the start of the README about what nano is
|
||||
docs: add a simulated "screenshot" of nano to the README
|
||||
docs: add some details to the bug-reporting paragraph in the README
|
||||
docs: correct the descriptions of how to invoke the spell checker
|
||||
docs: don't use "light" after "bold", as the latter often implies "light"
|
||||
docs: improve the description of the spotlighting of a search match
|
||||
docs: improve the description of the 'tabstospaces' option
|
||||
docs: improve the descriptions of several bindable functions
|
||||
docs: improve the recipe in the FAQ for dealing with Alt+Up on a console
|
||||
docs: indent the paragraphs in the FAQ that list commands to be typed
|
||||
docs: list the default color combo for 'spotlightcolor' in sample nanorc
|
||||
docs: mention how to properly colorize all types in nano's source code
|
||||
docs: mention in the README which licenses cover nano's code and docs
|
||||
docs: move the notice in the main man page, to try and catch other eyes
|
||||
docs: refer to the FAQ when <Alt+Up> does nothing on a Linux console
|
||||
docs: replace a non-problem in the FAQ with something possibly useful
|
||||
docs: spell "filename" as a single word, like in most other occurrences
|
||||
feedback: use a smaller diamond to represent an anchor, to not overflow
|
||||
feedback: when not in curses mode, just skip displaying any message
|
||||
feedback: when not in curses mode, write error messages to the terminal
|
||||
files: add the original file's suffix to the name of a temporary file
|
||||
files: check for a fifo only when it is an existing file
|
||||
files: check the result of fdopen(), to avoid a possible crash
|
||||
files: do not call fsync() on a fifo, to avoid a spurious error message
|
||||
files: exclude the call of fsync() from the tiny version
|
||||
files: give the user time to absorb a warning about someone else editing
|
||||
files: making a backup of a fifo makes no sense, so do not try that
|
||||
files: prepending to a fifo makes no sense, so do not try that
|
||||
files: when the buffer is nameless, include the PID in name of dump file
|
||||
files: when there is a slash after the dot, then there is no extension
|
||||
files: write a lock file also for a freshly saved buffer
|
||||
general: prevent die() from getting recursed into
|
||||
gnulib: update to its current upstream state
|
||||
help: make the keystrokes ^W^Y and ^W^V work again
|
||||
history: emit a warning when file cannot be made private [coverity]
|
||||
input: give up on the input stream only after millions of errors
|
||||
memory: free any allocated strings, also in the emergency code path
|
||||
po: delete the ancient PO files for Indonesian and Nynorsk
|
||||
po: permit the Indonesian PO file to come back -- there was a big update
|
||||
shutdown: when dying, do not install/restore a handler for Ctrl+C
|
||||
startup: if TERM is unset, try falling back to VT220 instead of failing
|
||||
syntax: nanorc: recognize also the template of the sample nanorc file
|
||||
syntax: rust: update the license to GPL3 or newer
|
||||
syntax: yaml: allow any character in tags except whitespace
|
||||
syntax: yaml: allow double colon in key & do not colorize unspaced colon
|
||||
syntax: yaml: allow slash and period in key names
|
||||
syntax: yaml: colorize backslash-escaped characters as valid or invalid
|
||||
syntax: yaml: colorize the question mark of complex mappings too
|
||||
syntax: yaml: colorize the two known directives
|
||||
syntax: yaml: new file -- coloring rules for YAML files
|
||||
tweaks: add Schiermonnikoog to the list of friendly islands
|
||||
tweaks: adjust a description of 'showcursor', to match the other ones
|
||||
tweaks: adjust three parameters -- two were mistaken, one superfluous
|
||||
tweaks: correct two typos and a spello [codespell]
|
||||
tweaks: fix a typo
|
||||
tweaks: fold two lines into two others, for conciseness
|
||||
tweaks: harmonize the indentations in the FAQ somewhat
|
||||
tweaks: in comments, say "buffer" instead of "file" where appropriate
|
||||
tweaks: instead of "one" use "you", like in the rest of the man page
|
||||
tweaks: remove a redundant feedback message
|
||||
tweaks: rename a defined type, to fit within the general pattern
|
||||
tweaks: rename a function, to be more fitting
|
||||
tweaks: rename a parameter and invert its logic
|
||||
tweaks: rename a parameter, to fit better what it is used for
|
||||
tweaks: rename a variable and flip its logic, to avoid two negations
|
||||
tweaks: rename a variable, away form an abbreviation
|
||||
tweaks: rename a variable, to be more grammatical
|
||||
tweaks: rename a variable, to be more visible and to match others
|
||||
tweaks: rename a variable, to make more sense
|
||||
tweaks: rename three variables, to follow the general scheme
|
||||
tweaks: reshuffle a few lines, for esthetics and to elide an #ifdef
|
||||
tweaks: reshuffle a few lines to avoid an #ifdef and unbalanced braces
|
||||
tweaks: reshuffle a fragment of code, to prepare for the next change
|
||||
tweaks: reshuffle some code to elide a variable, and improve a comment
|
||||
tweaks: reshuffle some lines and adjust some indentation
|
||||
tweaks: reshuffle some lines to elide a variable
|
||||
tweaks: restore a quote that was accidentally deleted four months ago
|
||||
tweaks: rewrap three lines, for esthetics
|
||||
tweaks: slightly reword or rewrap some comments in the sample nanorc
|
||||
tweaks: try chmodding a dump file only when it was actually written
|
||||
tweaks: use five symbolic names, to make eight function calls clearer
|
||||
usage: improve the description of the --positionlog option
|
||||
|
||||
David Michael (2):
|
||||
syntax: gentoo: highlight additional EAPI 7/8 variables
|
||||
syntax: gentoo: remove some obsolete keywords and add some new ones
|
||||
|
||||
Hussam al-Homsi (3):
|
||||
docs: correct the default value of the errorcolor option
|
||||
syntax: perl, ruby: remove arbitrary highlighting of here documents
|
||||
tweaks: change 'return ++var;' to 'return var + 1;'
|
||||
|
||||
|
||||
Changes between v5.7 and v5.8:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (53):
|
||||
bindings: show either "^/" or "^-" in the help lines, instead of "^_"
|
||||
bump version numbers and add a news item for the 5.8 release
|
||||
display: when a message gets overwritten, note that it is cleared
|
||||
docs: add a relevant item to the news for the 4.3 release
|
||||
docs: add example bindings for uppercasing and lowercasing a word
|
||||
docs: improve the contact info and some line spacing in the PDF
|
||||
docs: make ^E access the Execute menu in the example CUA bindings
|
||||
docs: mention that "grey"/"gray" may be used as a synonym of "lightblack"
|
||||
docs: mention the new 'set minicolor' option
|
||||
docs: say thanks to the Icelandic and Slovak translators
|
||||
feedback: ensure that the reporting of DOS/Mac format is truthful
|
||||
gnulib: update to its current upstream state
|
||||
help: use smaller triangles for the arrows
|
||||
linter: block the resizing signal while reading output from the linter
|
||||
linter: strip filename and line plus column number from the message
|
||||
memory: move the correct number of bytes, and not one too many
|
||||
memory: prevent a leak when copying the leading quoting to the next line
|
||||
minibar: stay out of sight when the terminal has just one row
|
||||
options: accept 'set minicolor' for setting the color of the minibar
|
||||
rcfile: allow using "grey" or "gray" as a synonym for "lightblack"
|
||||
rcfile: do not allow color name "normal" to have a prefix
|
||||
replacing: report the number of replacements also on a one-row terminal
|
||||
search: automatically drop the spotlighting after a few moments
|
||||
search: show "This is the only occurrence" also on a one-row terminal
|
||||
startup: allow using a bare "+" to mean put-cursor-on-last-line
|
||||
startup: do not accept stray characters after a "+" on the command line
|
||||
startup: skip drawing edit window when having message on one-row terminal
|
||||
startup: suppress "Search Wrapped" when using +? to search from EOF
|
||||
statusbar: ensure that "No further matches" does not get overwritten
|
||||
statusbar: on a one-row terminal, drop light messages after a few moments
|
||||
statusbar: suppress --constantshow when the terminal has just one row
|
||||
statusbar: suppress the cursor when the terminal has just one row
|
||||
syntax: nanohelp: avoid colorizing M-) in (M-) and M-" in "M-"
|
||||
syntax: nanorc: colorize "light" as valid only for the eight basic colors
|
||||
syntax: nanorc: colorize literal control codes, to make them stand out
|
||||
syntax: php: colorize the full short tag for echo (<?=)
|
||||
tweaks: avoid the subtraction of two size_t variables becoming negative
|
||||
tweaks: condense and correct a comment, and move another
|
||||
tweaks: condense some code by putting all color names in a single array
|
||||
tweaks: drop an assignment that is already part of the called function
|
||||
tweaks: frob some whitespace, and rewrap a line
|
||||
tweaks: improve a comment, remove unneeded braces, reshuffle some lines
|
||||
tweaks: normalize the indentation after the previous change
|
||||
tweaks: prevent two more size_t subtractions from going negative
|
||||
tweaks: redraw only the affected line instead of doing a full refresh
|
||||
tweaks: remove a check that has become superfluous
|
||||
tweaks: remove a check that is not needed
|
||||
tweaks: rename a variable, for contrast with the function name
|
||||
tweaks: rename two functions, to get rid of an ugly _void suffix
|
||||
tweaks: reshuffle the coloring of color names, to remove some duplication
|
||||
tweaks: use a symbol instead of a hard-coded number
|
||||
tweaks: use two symbolic names instead of TRUE and FALSE, for clarity
|
||||
wrapping: when copying the quoting part, adjust the file size accordingly
|
||||
|
||||
Hussam al-Homsi (1):
|
||||
bindings: allow copying text (with M-6) also when in view mode
|
||||
|
||||
|
||||
Changes between v5.6.1 and v5.7:
|
||||
--------------------------------
|
||||
|
||||
Benno Schulenberg (62):
|
||||
build: drop the check for two functions that we don't use any more
|
||||
build: fix compilation for --enable-tiny plus --enable-multibuffer
|
||||
build: fix compilation when configured with --disable-multibuffer
|
||||
build: fix compilation when configured with --enable-tiny
|
||||
bump version numbers and add a news item for the 5.7 release
|
||||
chars: implement mblen() ourselves, for efficiency
|
||||
chars: implement mbtowc() ourselves, for more efficiency
|
||||
chars: work around a UTF-8 bug in glibc, to display invalid codes right
|
||||
chars: work around the wrong private-use-character widths on OpenBSD
|
||||
display: avoid determining twice from and until where to draw each row
|
||||
display: make the output of --constantshow less jittery
|
||||
editing: prevent the pointer for the top row from becoming dangling
|
||||
feedback: upon first switch to a buffer, show its error message (if any)
|
||||
files: always register the format, also when the file is unwritable
|
||||
files: create a new buffer earlier, so that error messages can be stored
|
||||
files: when Mac format has been detected, stay with it
|
||||
gnulib: pull in the fix for a build problem on older Debian
|
||||
gnulib: update to its current upstream state
|
||||
indicator: adjust the size to the number of visible lines, not chunks
|
||||
input: accept Unicode codes for non-characters as valid, since they are
|
||||
memory: do not allocate space for multidata when it's already allocated
|
||||
memory: fix an off-by-one error to free also the last line in a group
|
||||
memory: prevent a use-after-free when the user respects a lock file
|
||||
oops: that doesn't work -- you can't break out of two for loops at once
|
||||
options: retire the obsolete 'smooth', 'morespace', and 'nopauses'
|
||||
softwrap: avoid time-consuming computations, to burden large files less
|
||||
startup: do not crash when trying to open a device or directory
|
||||
startup: do not store an error message in the record of another buffer
|
||||
startup: save the compiled file-matching regexes, to avoid recompiling
|
||||
startup: show the helpful message only when ^G has not been rebound
|
||||
syntax: c: colorize also labels that contain digits, and uncolorize colon
|
||||
syntax: po: improve the coloring of format specifiers
|
||||
syntaxes: replace [[:space:]] with [[:blank:]] to exclude carriage return
|
||||
tweaks: adjust and improve one comment, and frob another
|
||||
tweaks: adjust two comments, and reshuffle two fragments
|
||||
tweaks: avoid a warning on newer compilers, by writing an extra byte
|
||||
tweaks: avoid calling extra_chunks_in() when not softwrapping
|
||||
tweaks: avoid converting a file name for more than will fit on screen
|
||||
tweaks: avoid parsing a multibyte character twice
|
||||
tweaks: condense three comments, drop another, and rewrap a line
|
||||
tweaks: drop unneeded braces and adjust indentation after previous change
|
||||
tweaks: elide a call of strlen() for every row
|
||||
tweaks: elide a function that is now basically just two lines
|
||||
tweaks: elide an unneeded resetting NULL call to wctomb()
|
||||
tweaks: elide a small function that is used just once
|
||||
tweaks: elide the pointless is_valid_unicode() function
|
||||
tweaks: elide two more instances of useless character copying
|
||||
tweaks: improve a couple of comments
|
||||
tweaks: morph a function into what it is actually used for
|
||||
tweaks: normalize the indentation after an earlier change
|
||||
tweaks: put the most likely condition first, for a quicker return
|
||||
tweaks: reduce the maximum character length from six bytes to four
|
||||
tweaks: remove a misplaced (and nested) #ifdef
|
||||
tweaks: rename a variable, away from an abbreviation
|
||||
tweaks: rename a variable, for contrast with another
|
||||
tweaks: reshuffle a comment, and put the main extension first
|
||||
tweaks: reshuffle a fragment of code, to prepare for the next change
|
||||
tweaks: reshuffle two conditions, to have the most unlikely one first
|
||||
tweaks: set the file format only when unset, so it doesn't need saving
|
||||
tweaks: shorten a comment and trim an #ifdef
|
||||
tweaks: simplify two fragments of code
|
||||
tweaks: simplify two fragments of code, eliding useless character copying
|
||||
|
||||
Hussam al-Homsi (1):
|
||||
syntax: c: make the highlighting of '#include <...>' more compliant
|
||||
|
||||
Mike Frysinger (1):
|
||||
syntax: tcl: support Expect scripts too
|
||||
|
||||
|
||||
Changes between v5.6 and v5.6.1:
|
||||
--------------------------------
|
||||
|
||||
Benno Schulenberg (4):
|
||||
bump version numbers and add a news item for the 5.6.1 release
|
||||
options: rename 'highlightcolor' to the more distinct 'spotlightcolor'
|
||||
search: correctly colorize a match also when softwrapping is active
|
||||
tweaks: rename a symbol, to better match the corresponding option
|
||||
|
||||
|
||||
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:
|
||||
------------------------------
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ Improvements in GNU nano
|
||||
========================
|
||||
|
||||
Since 5.0:
|
||||
- A search briefly spotlights the found text, in black on yellow by default.
|
||||
- Option --minibar reduces the interface to a bottom bar with basic info.
|
||||
- Option --markmatch marks the search result, for better visibility.
|
||||
- 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.
|
||||
|
||||
56
NEWS
56
NEWS
@@ -1,3 +1,48 @@
|
||||
2021.10.06 - GNU nano 5.9 "El manicomio ha decidido: mañana sol!"
|
||||
• The extension of a filename is added to the name of a corresponding
|
||||
temporary file, so that spell checking a C file, for example, will
|
||||
check only the comments and strings (when using 'aspell').
|
||||
• The process number is added to the name of an emergency save file,
|
||||
so that when multiple nanos die they will not fight over a filename.
|
||||
• Undoing a cutting operation will restore an anchor that was located
|
||||
in the cut area to its original line.
|
||||
• When using --locking, saving a new buffer will create a lock file.
|
||||
• Syntax highlighting for YAML files has been added.
|
||||
|
||||
2021.06.15 - GNU nano 5.8 "Why is it necessary to be special?"
|
||||
• After a search, the spotlighting is dropped after 1.5 seconds (0.8
|
||||
seconds with --quick) to avoid the idea that the text is selected.
|
||||
• A + and a space before a filename on the command line will put the
|
||||
cursor at the end of the corresponding buffer.
|
||||
• Linter messages no longer include filename and line/column numbers.
|
||||
• Color name "grey" or "gray" can be used instead of "lightblack".
|
||||
• The color of the minibar can be chosen with 'set minicolor'.
|
||||
|
||||
2021.04.29 - GNU nano 5.7 "Toți ceilalți arau câmpurile"
|
||||
• The output of --constantshow (without --minibar) is more stable.
|
||||
• When opening multiple buffers and there is an error message, this
|
||||
message is shown again upon first switch to the relevant buffer.
|
||||
• The position and size of the indicator now follow actual lines,
|
||||
instead of visual lines when in softwrap mode, meaning that the
|
||||
size of the indicator can change when scrolling in softwrap mode.
|
||||
|
||||
2021.03.03 - GNU nano 5.6.1 "Geelgors"
|
||||
• Search matches are properly colorized in softwrap mode too.
|
||||
• Option 'highlightcolor' has been renamed to 'spotlightcolor'.
|
||||
|
||||
2021.02.24 - GNU nano 5.6 "Wielewaal"
|
||||
• A search match gets highlighted (in black on yellow by default),
|
||||
in addition to placing the cursor at the start of the match.
|
||||
The color combination can be changed with 'set highlightcolor'.
|
||||
By default the cursor is hidden until the next keystroke, but
|
||||
it can be forced on with --showcursor / 'set showcursor'.
|
||||
• Option --markmatch / 'set markmatch' has been removed.
|
||||
• Cursor position and character code are displayed in the minibar
|
||||
only when option --constantshow / 'set constantshow' is used,
|
||||
and their display can be toggled with M-C.
|
||||
• The state flags are displayed in the minibar only when option
|
||||
--stateflags / 'set stateflags' is used.
|
||||
|
||||
2021.01.14 - GNU nano 5.5 "Rebecca"
|
||||
• Option 'set minibar' makes nano suppress the title bar and instead
|
||||
show a bar with basic editing information at the bottom: file name
|
||||
@@ -161,6 +206,7 @@
|
||||
|
||||
2019.06.18 - GNU nano 4.3 "Musa Kart"
|
||||
• The ability to read from and write to a FIFO has been regained.
|
||||
• Opening a file no longer triggers an inotify CLOSE_WRITE event.
|
||||
• Startup time is reduced by fully parsing a syntax only when needed.
|
||||
• Asking for help (^G) when using --operatingdir does not crash.
|
||||
• The reading of a huge or slow file can be stopped with ^C.
|
||||
@@ -1177,9 +1223,9 @@
|
||||
Have fun with it.
|
||||
|
||||
2005.06.30 - GNU nano 1.3.8 floats at its own level. This release
|
||||
contains several new features. Among other things, you
|
||||
can now move to a specified column number as well as
|
||||
line number within a file, file backups saved in a
|
||||
contains several new features. Among other things,
|
||||
you can now move to a specified column number as well
|
||||
as line number within a file, file backups saved in a
|
||||
backup directory will have unique names, the search and
|
||||
replace history routines should work more consistently,
|
||||
you can get a word count by pressing Meta-D at the edit
|
||||
@@ -1190,8 +1236,8 @@
|
||||
screen updates, UTF-8 display, and flow control; a fix
|
||||
for a segfault when displaying some lines ending with
|
||||
tabs; better handling of constant cursor position
|
||||
display; improved color parsing in the rcfile; and
|
||||
support for the "Regexp" toggle in tiny mode
|
||||
display; improved color parsing in the rcfile;
|
||||
and support for the "Regexp" toggle in tiny mode
|
||||
(-R/--regexp is gone, and --restricted's short option
|
||||
has been changed to -R), among other things. Enjoy.
|
||||
|
||||
|
||||
61
README
61
README
@@ -1,10 +1,42 @@
|
||||
|
||||
GNU nano -- a simple editor, inspired by Pico
|
||||
|
||||
Overview
|
||||
Purpose
|
||||
|
||||
The nano project was started because of a few "problems" with the
|
||||
wonderfully easy-to-use and friendly Pico text editor.
|
||||
Nano is a small and simple text editor for use on the terminal.
|
||||
It copied the interface and key bindings of the Pico editor but
|
||||
added several missing features: undo/redo, syntax highlighting,
|
||||
line numbers, softwrapping, multiple buffers, selecting text by
|
||||
holding Shift, search-and-replace with regular expressions, and
|
||||
several other conveniences.
|
||||
|
||||
Appearance
|
||||
|
||||
In rough ASCII graphics, this is what nano's screen looks like:
|
||||
|
||||
____________________________________________________________________
|
||||
| GNU nano 5.9 filename Modified |
|
||||
--------------------------------------------------------------------
|
||||
| This is the text window, displaying the contents of a 'buffer', |
|
||||
| the contents of the file you are editing. |
|
||||
| |
|
||||
| The top row of the screen is the 'title bar'; it shows nano's |
|
||||
| version, the name of the file, and whether you modified it. |
|
||||
| The two bottom rows display the most important shortcuts; in |
|
||||
| those lines ^ means Ctrl. The third row from the bottom shows |
|
||||
| some feedback message, or gets replaced with a prompt bar when |
|
||||
| you tell nano to do something that requires extra input. |
|
||||
| |
|
||||
--------------------------------------------------------------------
|
||||
| [ Some status message ] |
|
||||
|^G Help ^O Write Out ^W Where Is ^K Cut ^T Execute |
|
||||
|^X Exit ^R Read File ^\ Replace ^U Paste ^J Justify |
|
||||
--------------------------------------------------------------------
|
||||
|
||||
Origin
|
||||
|
||||
The nano project was started in 1999 because of a few "problems"
|
||||
with the wonderfully easy-to-use and friendly Pico text editor.
|
||||
|
||||
First and foremost was its license: the Pine suite does not use
|
||||
the GPL, and (before using the Apache License) it had unclear
|
||||
@@ -23,6 +55,19 @@ Overview
|
||||
The nano editor is an official GNU package. For more information on
|
||||
GNU and the Free Software Foundation, please see https://www.gnu.org/.
|
||||
|
||||
License
|
||||
|
||||
Nano's code and documentation are covered by the GPL version 3 or
|
||||
(at your option) any later version, except for two functions that
|
||||
were copied from busybox which are under a BSD license. Nano's
|
||||
documentation is additionally covered by the GNU Free Documentation
|
||||
License version 1.2 or (at your option) any later version. See the
|
||||
files COPYING and COPYING.DOC for the full text of these licenses.
|
||||
|
||||
When in any file of this package a copyright notice mentions a
|
||||
year range (such as 1999-2011), it is a shorthand for a list of
|
||||
all the years in that interval.
|
||||
|
||||
How to compile and install nano
|
||||
|
||||
Download the latest nano source tarball, and then:
|
||||
@@ -70,10 +115,8 @@ Mailing Lists
|
||||
Bug Reports
|
||||
|
||||
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.
|
||||
on nano's issue tracker: https://savannah.gnu.org/bugs/?group=nano
|
||||
(you will need an account to be able to do so), or send an email
|
||||
to the nano-devel list (no need to subscribe, but mention it if
|
||||
you want to be CC'ed on an answer).
|
||||
|
||||
Copyright Years
|
||||
|
||||
When in any file of this package a copyright notice mentions a
|
||||
year range (such as 1999-2011), it is a shorthand for a list of
|
||||
all the years in that interval.
|
||||
|
||||
@@ -84,7 +84,6 @@ Problems?
|
||||
Please submit any bugs you find in the code in git via the bug tracker
|
||||
on Savannah (https://savannah.gnu.org/bugs/?group=nano).
|
||||
|
||||
|
||||
Contributing something
|
||||
----------------------
|
||||
|
||||
@@ -114,3 +113,11 @@ to include 'set tabsize 4', or you could use -T4 on the command line.
|
||||
To make git display things as intended, you can do:
|
||||
|
||||
$ git config --local core.pager "less -x1,5"
|
||||
|
||||
To see all types that are used in nano's source code colorized as types,
|
||||
you can add these lines to your ~/.nanorc:
|
||||
|
||||
extendsyntax c color green "\<struct (dirent|option|passwd)\>"
|
||||
extendsyntax c color green "\<struct (sigaction|stat|termios)\>"
|
||||
extendsyntax c color green "\<struct (timespec|vt_stat|winsize)\>"
|
||||
extendsyntax c color green "\<([[:lower:]_]+(struct|type)|va_list)\>"
|
||||
|
||||
2
THANKS
2
THANKS
@@ -18,6 +18,8 @@ Mihai Cristescu <mihai.cristescu@archlinux.info> Romanian
|
||||
Yavor Doganov <yavor@doganov.org> Bulgarian
|
||||
Karl Eichwalder <keichwa@gmx.net> German
|
||||
A. Murat EREN <meren@comu.edu.tr> Turkish
|
||||
Sveinn í Felli <sv1@fellsnet.is> Icelandic
|
||||
Marek Felšöci <marek@felsoci.sk> Slovak
|
||||
Doruk Fisek <dfisek@fisek.com.tr> Turkish
|
||||
Rafael Fontenelle <rffontenelle@gmail.com> Brazilian Portuguese
|
||||
Pavel Fric <pavelfric@seznam.cz> Czech
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Generate configure & friends for GIT users.
|
||||
|
||||
gnulib_url="git://git.sv.gnu.org/gnulib.git"
|
||||
gnulib_hash="30820c2d7c9f04a6a0aa6cdaaea09c9672f502a1"
|
||||
gnulib_hash="9aca7b67333fd0a90bf56104325ce96199644451"
|
||||
|
||||
modules="
|
||||
futimens
|
||||
@@ -13,6 +13,7 @@ modules="
|
||||
isblank
|
||||
iswblank
|
||||
lstat
|
||||
mkstemps
|
||||
nl_langinfo
|
||||
regex
|
||||
sigaction
|
||||
|
||||
@@ -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.5], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [5.9], [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
|
||||
@@ -350,7 +350,7 @@ fi])
|
||||
dnl Checks for functions.
|
||||
|
||||
if test "x$enable_utf8" != xno; then
|
||||
AC_CHECK_FUNCS(iswalnum iswpunct mblen mbstowcs mbtowc wctomb)
|
||||
AC_CHECK_FUNCS(iswalpha iswalnum iswpunct mbstowcs wctomb)
|
||||
fi
|
||||
|
||||
dnl Checks for available flags.
|
||||
@@ -435,11 +435,10 @@ AC_SUBST(CURSES_LIB)
|
||||
|
||||
if test "x$enable_utf8" != xno && \
|
||||
test x$CURSES_LIB_WIDE = xyes && \
|
||||
test x$ac_cv_func_iswalpha = xyes && \
|
||||
test x$ac_cv_func_iswalnum = xyes && \
|
||||
test x$ac_cv_func_iswpunct = xyes && \
|
||||
test x$ac_cv_func_mblen = xyes && \
|
||||
test x$ac_cv_func_mbstowcs = xyes && \
|
||||
test x$ac_cv_func_mbtowc = xyes && \
|
||||
test x$ac_cv_func_wctomb = xyes; then
|
||||
AC_DEFINE(ENABLE_UTF8, 1, [Define this if your system has sufficient UTF-8 support.])
|
||||
else
|
||||
|
||||
@@ -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>
|
||||
|
||||
77
doc/faq.html
77
doc/faq.html
@@ -5,6 +5,9 @@
|
||||
<title>The GNU nano editor FAQ</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="description" content="The genesis story of the nano editor, plus the solution to some common problems.">
|
||||
<style>
|
||||
.indented { margin-left: 2em; font-family: courier; font-size: 110%; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body text="#330000" bgcolor="#ffffff" link="#0000ef" vlink="#51188e" alink="#ff0000">
|
||||
@@ -40,7 +43,7 @@
|
||||
</p></blockquote>
|
||||
<h3><a href="#4">4. Running</a></h3>
|
||||
<blockquote><p>
|
||||
<a href="#4.1">4.1. How do I open a file with a name beginning with '+' from the command line?</a><br>
|
||||
<a href="#4.1">4.1. Alt+Up does nothing on a Linux console. How can I make it scroll?</a><br>
|
||||
<a href="#4.2">4.2. How can I make Ctrl+Shift+Left/Right select words on urxvt?</a><br>
|
||||
<a href="#4.3">4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</a><br>
|
||||
<a href="#4.4">4.4. With what keystroke can I paste text from the clipboard into nano?</a><br>
|
||||
@@ -89,7 +92,7 @@
|
||||
<h3><a name="1.3"></a>1.3. Why the name change from TIP?</h3>
|
||||
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program "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.5</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.9</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
|
||||
<h3><a name="1.5"></a>1.5. I want to read the man page without having to download the program!</h3>
|
||||
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="https://nano-editor.org/dist/latest/nano.1.html">here</a>.</p></blockquote>
|
||||
<hr width="100%">
|
||||
@@ -127,39 +130,39 @@
|
||||
<blockquote><p>It's simple really! As root, type <b>rpm -Uvh nano-x.y-1*.rpm</b> if you have a RedHat-ish system or <b>dpkg -i nano_x.y-1*.deb</b> if you have a Debian-ish system, where <b>x.y</b> is the version number of nano. There are other programs to install packages, and if you wish to use those, knock yourself out.</p></blockquote>
|
||||
<h3><a name="3.2"></a>3.2. Compiling from source: WHAT THE HECK DO I DO NOW?</h3>
|
||||
<blockquote><p>Okay, take a deep breath, this really isn't hard. Unpack the nano source with a command like:</p>
|
||||
<p><b>tar -xvf nano-x.y.tar.gz</b></p>
|
||||
<p class="indented"><b>tar -xvf nano-x.y.tar.gz</b></p>
|
||||
<p>Then you need to run <b>configure</b> with any options you might want (if any).</p>
|
||||
<p>The average case is this:</p>
|
||||
<p><b>cd nano-x.y/</b><br>
|
||||
<p class="indented"><b>cd nano-x.y/</b><br>
|
||||
<b>./configure</b><br>
|
||||
<b>make</b><br>
|
||||
<b>make install</b> (as root, of course)</p></blockquote>
|
||||
<b>make install</b> #(as root, of course)</p></blockquote>
|
||||
<h3><a name="3.3"></a>3.3. Why does everything go into /usr/local?</h3>
|
||||
<blockquote><p>Well, that's what the <b>configure</b> script defaults to. If you wish to change this, simply do this:</p>
|
||||
<p><b>./configure --prefix=/usr</b></p>
|
||||
<p class="indented"><b>./configure --prefix=/usr</b></p>
|
||||
<p>This will put nano into /usr/bin when you run <b>make install</b>.</p></blockquote>
|
||||
<h3><a name="3.4"></a>3.4. nano should automatically run strip on the binary when installing it!</h3>
|
||||
<blockquote><p>It does when you use <b>make install-strip</b>. The default <b>make install</b> does not, and will not, run strip automatically.</p></blockquote>
|
||||
<h3><a name="3.5"></a>3.5. How can I make the executable smaller? This is too bloated!</h3>
|
||||
<blockquote><p>Actually, there are several parts of the editor that can be disabled. You can pass arguments to the <b>configure</b> script that disable certain features. Here's a brief list:</p>
|
||||
<pre>
|
||||
<b>--disable-browser</b> Disable the built-in file browser
|
||||
<b>--disable-color</b> Disable color and syntax highlighting
|
||||
<b>--disable-comment</b> Disable the comment/uncomment function
|
||||
<b>--disable-extra</b> Disable the easter egg
|
||||
<b>--disable-help</b> Disable the built-in help texts
|
||||
<b>--disable-histories</b> Disable the saving of search strings and cursor positions
|
||||
<b>--disable-justify</b> Disable the justify/unjustify functions
|
||||
<b>--disable-libmagic</b> Disable the use of libmagic for determining a file's syntax
|
||||
<b>--disable-linenumbers</b> Disable line numbering
|
||||
<b>--disable-mouse</b> Disable mouse support
|
||||
<b>--disable-multibuffer</b> Disable the opening of multiple file buffers
|
||||
<b>--disable-nanorc</b> Disable the use of .nanorc files
|
||||
<b>--disable-operatingdir</b> Disable the setting of an operating directory
|
||||
<b>--disable-speller</b> Disable the spell-checker functions
|
||||
<b>--disable-tabcomp</b> Disable the tab-completion functions
|
||||
<b>--disable-wordcomp</b> Disable the word-completion function
|
||||
<b>--disable-wrapping</b> Disable all hard-wrapping of text</pre>
|
||||
<b>--disable-browser</b> Disable the built-in file browser
|
||||
<b>--disable-color</b> Disable color and syntax highlighting
|
||||
<b>--disable-comment</b> Disable the comment/uncomment function
|
||||
<b>--disable-extra</b> Disable the easter egg
|
||||
<b>--disable-help</b> Disable the built-in help texts
|
||||
<b>--disable-histories</b> Disable the saving of search strings and cursor positions
|
||||
<b>--disable-justify</b> Disable the justify/unjustify functions
|
||||
<b>--disable-libmagic</b> Disable the use of libmagic for determining a file's syntax
|
||||
<b>--disable-linenumbers</b> Disable line numbering
|
||||
<b>--disable-mouse</b> Disable mouse support
|
||||
<b>--disable-multibuffer</b> Disable the opening of multiple file buffers
|
||||
<b>--disable-nanorc</b> Disable the use of .nanorc files
|
||||
<b>--disable-operatingdir</b> Disable the setting of an operating directory
|
||||
<b>--disable-speller</b> Disable the spell-checker functions
|
||||
<b>--disable-tabcomp</b> Disable the tab-completion functions
|
||||
<b>--disable-wordcomp</b> Disable the word-completion function
|
||||
<b>--disable-wrapping</b> Disable all hard-wrapping of text</pre>
|
||||
<p>There's also the <b>--enable-tiny</b> option which disables everything above, as well as some larger chunks of the program (like the undo/redo code and the code for selecting text). Also, if you know you don't need other languages, you can use <b>--disable-nls</b> to disable internationalization and save a few kilobytes. And finally, there's always good old <b>strip</b> to remove all unneeded symbols.</p>
|
||||
</blockquote>
|
||||
<h3><a name="3.6"></a>3.6. Tell me more about this multibuffer stuff!</h3>
|
||||
@@ -175,13 +178,19 @@
|
||||
<hr width="100%">
|
||||
|
||||
<h1><a name="4"></a>4. Running</h1>
|
||||
<h3><a name="4.1"></a>4.1. How do I open a file with a name beginning with '+' from the command line?</h3>
|
||||
<blockquote><p>If a command-line argument that begins with '+' is followed by another argument, the former is always treated as a starting line (plus column number), and the latter always as a filename. If a command-line argument that begins with '+' isn't followed by another argument, it's treated as a filename. Examples:</p>
|
||||
<p>To open '+filename.txt': <b>nano +filename.txt</b><br>
|
||||
To open '+filename.txt' starting on line 10: <b>nano +10 +filename.txt</b><br>
|
||||
To open '+filename.txt' starting on line 1, column 20: <b>nano +,20 +filename.txt</b><br>
|
||||
To open '+filename.txt' starting on line 10, column 20: <b>nano +10,20 +filename.txt</b><br>
|
||||
To open '+filename.txt' starting on line 1 and 'filename.txt' starting on line 40: <b>nano +1 +filename.txt +40 filename.txt</b></p></blockquote>
|
||||
<h3><a name="4.1"></a>4.1. Alt+Up does nothing on a Linux console. How can I make it scroll?</h3>
|
||||
<blockquote><p>On Debian and its derivatives, the <b>Alt+Up</b> keystroke on a Linux console
|
||||
produces by default a 'KeyboardSignal', which normally does absolutely nothing and is useless
|
||||
for the average user. To get the keystroke to do what it ought to do (scroll the viewport
|
||||
one row up), run this in a Linux console:</p>
|
||||
<p class="indented"><b>dumpkeys --full | sed s/KeyboardSignal/Up/ | sudo loadkeys -</b></p>
|
||||
<p>You will need to run this command whenever you first switch to a Linux console.</p>
|
||||
<p>Or you can (as root) execute the following little script just once:</p>
|
||||
<p class="indented"><b>for file in /etc/console-setup/cached*.kmap.gz; do<br>
|
||||
gunzip $file;<br>
|
||||
sed -i 's/KeyboardSignal/Up/' ${file%.gz};<br>
|
||||
gzip ${file%.gz};<br>
|
||||
done</b></p></blockquote>
|
||||
<h3><a name="4.2"></a>4.2. How can I make Ctrl+Shift+Left/Right select words on urxvt?</h3>
|
||||
<blockquote><p>The urxvt terminal emulator produces non-standard escape sequences for the modified cursor keys. These deviant sequences are not listed in the terminfo database, which means that ncurses does not recognize them. The easiest way around this is to tell urxvt to produce xterm-compatible escape sequences for the relevant keystrokes. To achieve this, add the following lines to your ~/.Xresources file:</p>
|
||||
<pre>
|
||||
@@ -219,16 +228,16 @@
|
||||
<blockquote><p>If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Several example configurations are in the <b>syntax/</b> subdirectory of the nano source, which are normally installed to <b>/usr/local/share/nano/</b>. To enable all of them, uncomment the line <b># include "/usr/local/share/nano/*.nanorc"</b> in your nanorc. See also section <a href="#3.9">3.9</a>.</p></blockquote>
|
||||
<h3><a name="4.9"></a>4.9. How do I make nano my default editor (in Pine, mutt, etc.)?</h3>
|
||||
<blockquote><p>You need to make nano your $EDITOR. If you want this to be saved, you should put a line like this in your <b>.bashrc</b> if you use bash (or <b>.zshrc</b> if you believe in zsh):</p>
|
||||
<p><b>export EDITOR=/usr/local/bin/nano</b></p>
|
||||
<p class="indented"><b>export EDITOR=/usr/local/bin/nano</b></p>
|
||||
<p>or, if you use tcsh, put this in your <b>.cshrc</b> file:</p>
|
||||
<p><b>setenv EDITOR /usr/local/bin/nano</b></p>
|
||||
<p class="indented"><b>setenv EDITOR /usr/local/bin/nano</b></p>
|
||||
<p>Change /usr/local/bin/nano to wherever nano is installed on your system. Type "which nano" to find out. This will not take effect until the next time you log in. So log out and back in again.</p>
|
||||
<p>Then, on top of that, if you use Pine, you must go into setup (type <b>S</b> at the main menu), and then configure (type <b>C</b>). Hit Enter on the lines that say:</p>
|
||||
<p><b>[ ] enable-alternate-editor-cmd</b><br>
|
||||
<p class="indented"><b>[ ] enable-alternate-editor-cmd</b><br>
|
||||
<b>[ ] enable-alternate-editor-implicitly</b></p>
|
||||
<p>Then exit (<b>E</b>) and select Yes (<b>Y</b>).</p>
|
||||
<p>If you're a mutt user, you should see an effect immediately the next time you log in. No further configuration is needed. However, if you want to let people know you use nano to compose your email messages, you can put a line like this in your <b>.muttrc</b>:</p>
|
||||
<p><b>my_hdr X-Composer: nano-x.y</b></p>
|
||||
<p class="indented"><b>my_hdr X-Composer: nano-x.y</b></p>
|
||||
<p>Again, replace x.y with the version of nano you use.</p></blockquote>
|
||||
<hr width="100%">
|
||||
|
||||
|
||||
60
doc/nano.1
60
doc/nano.1
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANO 1 "version 5.5" "January 2021"
|
||||
.TH NANO 1 "version 5.9" "October 2021"
|
||||
|
||||
.SH NAME
|
||||
nano \- Nano's ANOther editor, inspired by Pico
|
||||
@@ -27,20 +27,6 @@ nano \- Nano's ANOther editor, inspired by Pico
|
||||
.sp
|
||||
.BR nano " [" \fIoptions "] [[" + [ crCR ]( / | ? ) \fIstring "] " \fIfile ]...
|
||||
|
||||
.SH NOTICE
|
||||
Since version 4.0, \fBnano\fR by default:
|
||||
.sp
|
||||
.RS 4
|
||||
\(bu does not automatically hard-wrap lines that become overlong,
|
||||
.br
|
||||
\(bu includes the line below the title bar in the editing area,
|
||||
.br
|
||||
\(bu does linewise (smooth) scrolling.
|
||||
.RE
|
||||
.sp
|
||||
If you want the old, Pico behavior back, you can use \fB\-\-breaklonglines\fR,
|
||||
\fB\-\-emptyline\fR, and \fB\-\-jumpyscrolling\fR (or \fB\-bej\fR for short).
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fBnano\fP is a small and friendly editor. It copies the look and feel
|
||||
of Pico, but is free software, and implements several features that Pico
|
||||
@@ -58,7 +44,7 @@ regular expression by inserting \fBc\fR and/or \fBr\fR after the \fB+\fR sign.
|
||||
These search modes can be explicitly disabled by using the uppercase variant
|
||||
of those letters: \fBC\fR and/or \fBR\fR. When the string contains spaces,
|
||||
it needs to be enclosed in quotes. To give an example: to open a file at
|
||||
the first occurrence of the word "Foo", one would do:
|
||||
the first occurrence of the word "Foo", you would do:
|
||||
.sp
|
||||
.RS 4
|
||||
.BI "nano +c/Foo " file
|
||||
@@ -77,11 +63,11 @@ Any cursor movement or executing any other command will cause the next
|
||||
\fB^K\fR to overwrite the cutbuffer. A \fB^U\fR will paste the current
|
||||
contents of the cutbuffer at the current cursor position.
|
||||
.sp
|
||||
When a more precise piece of text needs to be cut or copied, one can mark
|
||||
When a more precise piece of text needs to be cut or copied, you can mark
|
||||
its start with \fB^6\fR, move the cursor to its end (the marked text will be
|
||||
highlighted), and then use \fB^K\fR to cut it, or \fBM\-6\fR to copy it to the
|
||||
cutbuffer. One can also save the marked text to a file with \fB^O\fR, or
|
||||
spell check it with \fB^T\fR.
|
||||
cutbuffer. You can also save the marked text to a file with \fB^O\fR, or
|
||||
spell check it with \fB^T^T\fR.
|
||||
.sp
|
||||
On some terminals, text can be selected also by holding down Shift while
|
||||
using the arrow keys. Holding down the Ctrl or Alt key too will increase
|
||||
@@ -93,6 +79,20 @@ the built-in help (\fB^G\fR) lists all the available ones.
|
||||
The default key bindings can be changed via a \fInanorc\fR file -- see
|
||||
.BR nanorc (5).
|
||||
|
||||
.SH NOTICE
|
||||
Since version 4.0, \fBnano\fR by default:
|
||||
.sp
|
||||
.RS 4
|
||||
\(bu does not automatically hard-wrap lines that become overlong,
|
||||
.br
|
||||
\(bu includes the line below the title bar in the editing area,
|
||||
.br
|
||||
\(bu does linewise (smooth) scrolling.
|
||||
.RE
|
||||
.sp
|
||||
If you want the old, Pico behavior back, you can use \fB\-\-breaklonglines\fR,
|
||||
\fB\-\-emptyline\fR, and \fB\-\-jumpyscrolling\fR (or \fB\-bej\fR for short).
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.BR \-A ", " \-\-smarthome
|
||||
@@ -118,7 +118,8 @@ by setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, \fBkeycolor\fP,
|
||||
nanorc file. See \fBnanorc\fR(5).
|
||||
.TP
|
||||
.BR \-E ", " \-\-tabstospaces
|
||||
Convert typed tabs to spaces.
|
||||
Convert each typed tab to spaces -- to the number of spaces
|
||||
that a tab at that position would take up.
|
||||
.TP
|
||||
.BR \-F ", " \-\-multibuffer
|
||||
Read a file into a new buffer by default.
|
||||
@@ -190,9 +191,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.
|
||||
@@ -329,12 +330,6 @@ Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
|
||||
.BR \-z ", " \-\-suspendable
|
||||
Allow the user to suspend the editor (with \fB^Z\fR by default).
|
||||
.TP
|
||||
.BR \-^ ", " \-\-markmatch
|
||||
After a search, set the mark at the end of the found match
|
||||
(if there is any) so that it gets highlighted. This makes
|
||||
the match more visible, but also allows deleting the match
|
||||
with a single keystroke.
|
||||
.TP
|
||||
.BR \-% ", " \-\-stateflags
|
||||
Use the top-right corner of the screen for showing some state flags:
|
||||
\fBI\fR when auto-indenting, \fBM\fR when the mark is on, \fBL\fR when
|
||||
@@ -346,16 +341,19 @@ filename in the center of the title bar.
|
||||
.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
|
||||
for the status bar. In this "minibar" the filename is shown
|
||||
on the left, followed by an asterisk if the buffer has been modified.
|
||||
On the right are displayed the current line and column number, the
|
||||
code of the character under the cursor (in Unicode format: U+xxxx),
|
||||
the same flags as are shown by \fB\-\-stateflags\fR, and a percentage
|
||||
that expresses how far the cursor is into the file (linewise).
|
||||
When a file is loaded or saved, and also when switching between buffers,
|
||||
the number of lines in the buffer is displayed after the file name.
|
||||
the number of lines in the buffer is displayed after the filename.
|
||||
This number is cleared upon the next keystroke, or replaced with an
|
||||
[i/n] counter when multiple buffers are open.
|
||||
The line plus column numbers and the character code are displayed only when
|
||||
\fB\-\-constantshow\fR is used, and can be toggled on and off with \fBM-C\fR.
|
||||
The state flags are displayed only when \fB\-\-stateflags\fR is used.
|
||||
.TP
|
||||
.BR \-! ", " \-\-magic
|
||||
When neither the file's name nor its first line give a clue,
|
||||
|
||||
110
doc/nano.texi
110
doc/nano.texi
@@ -7,9 +7,9 @@
|
||||
@documentencoding UTF-8
|
||||
|
||||
@smallbook
|
||||
@set EDITION 0.5
|
||||
@set VERSION 5.5
|
||||
@set UPDATED January 2021
|
||||
@set EDITION 0.6
|
||||
@set VERSION 5.9
|
||||
@set UPDATED October 2021
|
||||
|
||||
@dircategory Editors
|
||||
@direntry
|
||||
@@ -23,7 +23,7 @@
|
||||
@titlepage
|
||||
@title GNU @command{nano}
|
||||
@subtitle a small and friendly text editor
|
||||
@subtitle version 5.5
|
||||
@subtitle version 5.9
|
||||
|
||||
@author Chris Allegretta
|
||||
@page
|
||||
@@ -53,8 +53,10 @@ under the terms of either of the following licenses:
|
||||
along with this program. If not, see @url{https://www.gnu.org/licenses/}.
|
||||
|
||||
@sp 1
|
||||
You may contact the author by
|
||||
You may contact the original author by
|
||||
e-mail: @email{chrisa@@asty.org}@*
|
||||
|
||||
For suggesting improvements: @email{nano-devel@@gnu.org}@*
|
||||
@end titlepage
|
||||
|
||||
@ifnottex
|
||||
@@ -63,7 +65,7 @@ e-mail: @email{chrisa@@asty.org}@*
|
||||
@node Top
|
||||
@top
|
||||
|
||||
This manual documents the GNU @command{nano} editor, version 5.5.
|
||||
This manual documents the GNU @command{nano} editor, version 5.9.
|
||||
|
||||
@menu
|
||||
* Introduction::
|
||||
@@ -103,9 +105,9 @@ If you want the old, Pico behavior back, you can use the
|
||||
following options: @option{--breaklonglines},
|
||||
@option{--jumpyscrolling}, and @option{--emptyline}
|
||||
(or @option{-bje}).
|
||||
|
||||
@sp 1
|
||||
Please report bugs via @url{https://savannah.gnu.org/bugs/?group=nano}.
|
||||
|
||||
@sp 1
|
||||
For background information see @url{https://nano-editor.org/}.
|
||||
|
||||
@node Invoking
|
||||
@@ -193,7 +195,8 @@ nanorc file. @xref{@code{set functioncolor}} for details.
|
||||
|
||||
@item -E
|
||||
@itemx --tabstospaces
|
||||
Convert typed tabs to spaces.
|
||||
Convert each typed tab to spaces --- to the number of spaces
|
||||
that a tab at that position would take up.
|
||||
|
||||
@item -F
|
||||
@itemx --multibuffer
|
||||
@@ -281,9 +284,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
|
||||
@@ -468,13 +471,6 @@ Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
|
||||
Enable the ability to suspend @command{nano} using the system's suspend
|
||||
keystroke (usually @kbd{^Z}).
|
||||
|
||||
@item -^
|
||||
@itemx --markmatch
|
||||
After a search, set the mark at the end of the found match
|
||||
(if there is any) so that it gets highlighted. This makes
|
||||
the match more visible, but also allows deleting the match
|
||||
with a single keystroke.
|
||||
|
||||
@item -%
|
||||
@itemx --stateflags
|
||||
Use the top-right corner of the screen for showing some state flags:
|
||||
@@ -488,16 +484,19 @@ filename in the center of the title bar.
|
||||
@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
|
||||
for the status bar. In this "minibar" the filename is shown
|
||||
on the left, followed by an asterisk if the buffer has been modified.
|
||||
On the right are displayed the current line and column number, the
|
||||
code of the character under the cursor (in Unicode format: U+xxxx),
|
||||
the same flags as are shown by @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.
|
||||
the number of lines in the buffer is displayed after the filename.
|
||||
This number is cleared upon the next keystroke, or replaced with an
|
||||
[i/n] counter when multiple buffers are open.
|
||||
The line plus column numbers and the character code are displayed only when
|
||||
@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
|
||||
@@ -592,7 +591,7 @@ or @kbd{M-A} and then moving the cursor to the other end of the portion
|
||||
to be selected. The selected portion of text will be highlighted.
|
||||
This selection can now be cut or copied in its entirety with a single
|
||||
@kbd{^K} or @kbd{M-6}. Or the selection can be used to limit the scope of
|
||||
a search-and-replace (@kbd{^\}) or spell-checking session (@kbd{^T}).
|
||||
a search-and-replace (@kbd{^\}) or spell-checking session (@kbd{^T^T}).
|
||||
|
||||
On some terminals, text can be selected also by holding down @kbd{Shift}
|
||||
while using the cursor keys. Holding down the @kbd{Ctrl} or @kbd{Alt}
|
||||
@@ -860,7 +859,7 @@ Do not use the line below the title bar, leaving it entirely blank.
|
||||
|
||||
@item set errorcolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
|
||||
Use this color combination for the status bar when an error message is displayed.
|
||||
The default value is @t{brightwhite,red}.
|
||||
The default value is @t{bold,white,red}.
|
||||
@xref{@code{set functioncolor}} for valid color names.
|
||||
|
||||
@item set fill @var{number}
|
||||
@@ -880,6 +879,8 @@ Valid names for the foreground and background colors are:
|
||||
@code{white}, and @code{black}.
|
||||
Each of these eight names may be prefixed with the word
|
||||
@code{light} to get a brighter version of that color.
|
||||
The word @code{grey} or @code{gray} may be used as
|
||||
a synonym for @code{lightblack}.
|
||||
|
||||
On terminal emulators that can do at least 256 colors,
|
||||
other valid (but unprefixable) color names are:
|
||||
@@ -926,12 +927,6 @@ try using libmagic to determine the applicable syntax.
|
||||
(Calling libmagic can be relatively time consuming.
|
||||
It is therefore not done by default.)
|
||||
|
||||
@item set markmatch
|
||||
After a search, set the mark at the end of the found match
|
||||
(if there is any) so that it gets highlighted. This makes
|
||||
the match more visible, but also allows deleting the match
|
||||
with a single keystroke.
|
||||
|
||||
@anchor{@code{set matchbrackets}}
|
||||
@item set matchbrackets "@var{characters}"
|
||||
Specify the opening and closing brackets that can be found by bracket
|
||||
@@ -942,20 +937,24 @@ 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
|
||||
for the status bar. In this "minibar" the filename is shown
|
||||
on the left, followed by an asterisk if the buffer has been modified.
|
||||
On the right are displayed the current line and column number, the
|
||||
code of the character under the cursor (in Unicode format: U+xxxx),
|
||||
the same flags as are shown by @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.
|
||||
the number of lines in the buffer is displayed after the filename.
|
||||
This number is cleared upon the next keystroke, or replaced with an
|
||||
[i/n] counter when multiple buffers are open.
|
||||
The line plus column numbers and the character code are displayed only when
|
||||
@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.
|
||||
@item set minicolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
|
||||
Use this color combination for the minibar.
|
||||
(When this option is not specified, the colors of the title bar are used.)
|
||||
@xref{@code{set functioncolor}} for valid color names.
|
||||
|
||||
@item set mouse
|
||||
Enable mouse support, so that mouse clicks can be used to place the
|
||||
@@ -974,9 +973,6 @@ Don't display the help lists at the bottom of the screen.
|
||||
Don't automatically add a newline when a text does not end with one.
|
||||
(This can cause you to save non-POSIX text files.)
|
||||
|
||||
@item set nopauses
|
||||
Obsolete option. Ignored.
|
||||
|
||||
@item set nowrap
|
||||
Deprecated option since it has become the default setting.
|
||||
When needed, use @code{unset breaklonglines} instead.
|
||||
@@ -1011,8 +1007,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.
|
||||
@@ -1062,10 +1058,6 @@ jump to that beginning (either forwards or backwards). If the cursor is
|
||||
already at that position, it will jump to the true beginning of the
|
||||
line.
|
||||
|
||||
@item set smooth
|
||||
Deprecated option since it has become the default setting.
|
||||
When needed, use @code{unset jumpyscrolling} instead.
|
||||
|
||||
@item set softwrap
|
||||
Display lines that exceed the screen's width over multiple screen lines.
|
||||
(You can make this soft-wrapping occur at whitespace instead of rudely at
|
||||
@@ -1075,6 +1067,11 @@ the screen's edge, by using also @code{set atblanks}.)
|
||||
Use the given program to do spell checking and correcting.
|
||||
@xref{@option{--speller}} for details.
|
||||
|
||||
@item set spotlightcolor [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 stateflags
|
||||
Use the top-right corner of the screen for showing some state flags:
|
||||
@code{I} when auto-indenting, @code{M} when the mark is on, @code{L} when
|
||||
@@ -1099,7 +1096,8 @@ Use a tab size of @var{number} columns. The value of @var{number} must be
|
||||
greater than 0. The default value is @t{8}.
|
||||
|
||||
@item set tabstospaces
|
||||
Convert typed tabs to spaces.
|
||||
Convert each typed tab to spaces --- to the number of spaces
|
||||
that a tab at that position would take up.
|
||||
|
||||
@item set titlecolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
|
||||
Use this color combination for the title bar.
|
||||
@@ -1416,7 +1414,8 @@ the line, column, and character positions.
|
||||
(The old name of this function, 'curpos', is deprecated.)
|
||||
|
||||
@item wordcount
|
||||
Counts the number of words, lines and characters in the current buffer.
|
||||
Counts and reports on the status bar the number of lines, words,
|
||||
and characters in the current buffer (or in the marked region).
|
||||
|
||||
@item execute
|
||||
Prompts for a program to execute. The program's output will be inserted
|
||||
@@ -1434,27 +1433,28 @@ Invokes a full-buffer-processing program (if the active syntax defines one).
|
||||
Invokes a syntax-checking program (if the active syntax defines one).
|
||||
|
||||
@item justify
|
||||
Justifies the current paragraph. A paragraph is a group of contiguous lines
|
||||
Justifies the current paragraph (or the marked region).
|
||||
A paragraph is a group of contiguous lines
|
||||
that, apart from possibly the first line, all have the same indentation. The
|
||||
beginning of a paragraph is detected by either this lone line with a differing
|
||||
indentation or by a preceding blank line.
|
||||
|
||||
@item fulljustify
|
||||
Justifies the entire current buffer.
|
||||
Justifies the entire current buffer (or the marked region).
|
||||
|
||||
@item indent
|
||||
Indents (shifts to the right) the currently marked text.
|
||||
Indents (shifts to the right) the current line or the marked lines.
|
||||
|
||||
@item unindent
|
||||
Unindents (shifts to the left) the currently marked text.
|
||||
Unindents (shifts to the left) the current line or the marked lines.
|
||||
|
||||
@item comment
|
||||
Comments or uncomments the current line or marked lines, using the comment
|
||||
style specified in the active syntax.
|
||||
Comments or uncomments the current line or the marked lines,
|
||||
using the comment style specified in the active syntax.
|
||||
|
||||
@item complete
|
||||
Completes the fragment before the cursor to a full word found elsewhere
|
||||
in the current buffer.
|
||||
Completes (when possible) the fragment before the cursor
|
||||
to a full word found elsewhere in the current buffer.
|
||||
|
||||
@item left
|
||||
Goes left one position (in the editor or browser).
|
||||
@@ -1471,10 +1471,14 @@ Goes one line down (in the editor or browser).
|
||||
@item scrollup
|
||||
Scrolls the viewport up one row (meaning that the text slides down)
|
||||
while keeping the cursor in the same text position, if possible.
|
||||
(This function is bound by default to <Alt+Up>.
|
||||
If <Alt+Up> does nothing on your Linux console, see the FAQ:
|
||||
@url{https://nano-editor.org/dist/latest/faq.html#4.1}.)
|
||||
|
||||
@item scrolldown
|
||||
Scrolls the viewport down one row (meaning that the text slides up)
|
||||
while keeping the cursor in the same text position, if possible.
|
||||
(This function is bound by default to <Alt+Down>.)
|
||||
|
||||
@item center
|
||||
Scrolls the line with the cursor to the middle of the screen.
|
||||
|
||||
75
doc/nanorc.5
75
doc/nanorc.5
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANORC 5 "version 5.5" "January 2021"
|
||||
.TH NANORC 5 "version 5.9" "October 2021"
|
||||
|
||||
.SH NAME
|
||||
nanorc \- GNU nano's configuration file
|
||||
@@ -127,7 +127,7 @@ Do not use the line below the title bar, leaving it entirely blank.
|
||||
.TP
|
||||
.B set errorcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
Use this color combination for the status bar when an error message is displayed.
|
||||
The default value is \fBbrightwhite,red\fR.
|
||||
The default value is \fBbold,white,red\fR.
|
||||
See \fBset titlecolor\fR for valid color names.
|
||||
.TP
|
||||
.B set fill \fInumber\fR
|
||||
@@ -176,12 +176,6 @@ try using libmagic to determine the applicable syntax.
|
||||
(Calling libmagic can be relatively time consuming.
|
||||
It is therefore not done by default.)
|
||||
.TP
|
||||
.B set markmatch
|
||||
After a search, set the mark at the end of the found match
|
||||
(if there is any) so that it gets highlighted. This makes
|
||||
the match more visible, but also allows deleting the match
|
||||
with a single keystroke.
|
||||
.TP
|
||||
.BI "set matchbrackets """ characters """
|
||||
Specify the opening and closing brackets that can be found by bracket
|
||||
searches. This may not include blank characters. The opening set must
|
||||
@@ -191,20 +185,24 @@ The default value is "\fB(<[{)>]}\fP".
|
||||
.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
|
||||
for the status bar. In this "minibar" the filename is shown
|
||||
on the left, followed by an asterisk if the buffer has been modified.
|
||||
On the right are displayed the current line and column number, the
|
||||
code of the character under the cursor (in Unicode format: U+xxxx),
|
||||
the same flags as are shown by \fBset stateflags\fR, and a percentage
|
||||
that expresses how far the cursor is into the file (linewise).
|
||||
When a file is loaded or saved, and also when switching between buffers,
|
||||
the number of lines in the buffer is displayed after the file name.
|
||||
the number of lines in the buffer is displayed after the filename.
|
||||
This number is cleared upon the next keystroke, or replaced with an
|
||||
[i/n] counter when multiple buffers are open.
|
||||
The line plus column numbers and the character code are displayed only when
|
||||
\fBset constantshow\fR is used, and can be toggled on and off with \fBM-C\fR.
|
||||
The state flags are displayed only when \fBset stateflags\fR is used.
|
||||
.TP
|
||||
.B set morespace
|
||||
Deprecated option since it has become the default setting.
|
||||
When needed, use \fBunset emptyline\fR instead.
|
||||
.B set minicolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
Use this color combination for the minibar.
|
||||
(When this option is not specified, the colors of the title bar are used.)
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
.B set mouse
|
||||
Enable mouse support, if available for your system. When enabled, mouse
|
||||
@@ -226,9 +224,6 @@ Don't display the two help lines at the bottom of the screen.
|
||||
Don't automatically add a newline when a text does not end with one.
|
||||
(This can cause you to save non-POSIX text files.)
|
||||
.TP
|
||||
.B set nopauses
|
||||
Obsolete option. Ignored.
|
||||
.TP
|
||||
.B set nowrap
|
||||
Deprecated option since it has become the default setting.
|
||||
When needed, use \fBunset breaklonglines\fR instead.
|
||||
@@ -262,8 +257,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.
|
||||
@@ -302,8 +297,9 @@ Use this color combination for selected text.
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
.B set showcursor
|
||||
Put the cursor on the highlighted item in the file browser, to aid
|
||||
braille users.
|
||||
Put the cursor on the highlighted item in the file browser, and show
|
||||
the cursor in the help viewer, to aid braille users and people with
|
||||
poor vision.
|
||||
.TP
|
||||
.B set smarthome
|
||||
Make the Home key smarter. When Home is pressed anywhere but at the
|
||||
@@ -312,10 +308,6 @@ jump to that beginning (either forwards or backwards). If the cursor is
|
||||
already at that position, it will jump to the true beginning of the
|
||||
line.
|
||||
.TP
|
||||
.B set smooth
|
||||
Deprecated option since it has become the default setting.
|
||||
When needed, use \fBunset jumpyscrolling\fR instead.
|
||||
.TP
|
||||
.B set softwrap
|
||||
Display lines that exceed the screen's width over multiple screen lines.
|
||||
(You can make this soft-wrapping occur at whitespace instead of rudely at
|
||||
@@ -325,6 +317,11 @@ the screen's edge, by using also \fBset atblanks\fR.)
|
||||
Use the given \fIprogram\fR to do spell checking and correcting, instead of
|
||||
using the built-in corrector that calls \fBhunspell\fR(1) or \fBspell\fR(1).
|
||||
.TP
|
||||
.B set spotlightcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
Use this color combination for highlighting a search match.
|
||||
The default value is \fBblack,lightyellow\fR.
|
||||
See \fBset titlecolor\fR for valid color names.
|
||||
.TP
|
||||
.B set stateflags
|
||||
Use the top-right corner of the screen for showing some state flags:
|
||||
\fBI\fR when auto-indenting, \fBM\fR when the mark is on, \fBL\fR when
|
||||
@@ -349,7 +346,8 @@ Use a tab size of \fInumber\fR columns. The value of \fInumber\fP must be
|
||||
greater than 0. The default value is \fB8\fR.
|
||||
.TP
|
||||
.B set tabstospaces
|
||||
Convert typed tabs to spaces.
|
||||
Convert each typed tab to spaces -- to the number of spaces
|
||||
that a tab at that position would take up.
|
||||
.TP
|
||||
.B set titlecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
Use this color combination for the title bar.
|
||||
@@ -358,6 +356,8 @@ Valid names for the foreground and background colors are:
|
||||
.BR white ", and " black .
|
||||
Each of these eight names may be prefixed with the word \fBlight\fR
|
||||
to get a brighter version of that color.
|
||||
The word \fBgrey\fR or \fBgray\fR may be used
|
||||
as a synonym for \fBlightblack\fR.
|
||||
On terminal emulators that can do at least 256 colors,
|
||||
other valid (but unprefixable) color names are:
|
||||
.BR pink ", " purple ", " mauve ", " lagoon ", " mint ", "
|
||||
@@ -657,7 +657,8 @@ the line, column, and character positions.
|
||||
(The old name of this function, 'curpos', is deprecated.)
|
||||
.TP
|
||||
.B wordcount
|
||||
Counts the number of words, lines and characters in the current buffer.
|
||||
Counts and reports on the status bar the number of lines, words,
|
||||
and characters in the current buffer (or in the marked region).
|
||||
.TP
|
||||
.B execute
|
||||
Prompts for a program to execute. The program's output will be inserted
|
||||
@@ -674,27 +675,28 @@ Invokes a full-buffer-processing program (if the active syntax defines one).
|
||||
Invokes a syntax-checking program (if the active syntax defines one).
|
||||
.TP
|
||||
.B justify
|
||||
Justifies the current paragraph. A paragraph is a group of contiguous lines
|
||||
Justifies the current paragraph (or the marked region).
|
||||
A paragraph is a group of contiguous lines
|
||||
that, apart from possibly the first line, all have the same indentation. The
|
||||
beginning of a paragraph is detected by either this lone line with a differing
|
||||
indentation or by a preceding blank line.
|
||||
.TP
|
||||
.B fulljustify
|
||||
Justifies the entire current buffer.
|
||||
Justifies the entire current buffer (or the marked region).
|
||||
.TP
|
||||
.B indent
|
||||
Indents (shifts to the right) the currently marked text.
|
||||
Indents (shifts to the right) the current line or the marked lines.
|
||||
.TP
|
||||
.B unindent
|
||||
Unindents (shifts to the left) the currently marked text.
|
||||
Unindents (shifts to the left) the current line or the marked lines.
|
||||
.TP
|
||||
.B comment
|
||||
Comments or uncomments the current line or marked lines, using the comment
|
||||
style specified in the active syntax.
|
||||
Comments or uncomments the current line or the marked lines,
|
||||
using the comment style specified in the active syntax.
|
||||
.TP
|
||||
.B complete
|
||||
Completes the fragment before the cursor to a full word found elsewhere
|
||||
in the current buffer.
|
||||
Completes (when possible) the fragment before the cursor
|
||||
to a full word found elsewhere in the current buffer.
|
||||
.TP
|
||||
.B left
|
||||
Goes left one position (in the editor or browser).
|
||||
@@ -711,10 +713,15 @@ Goes one line down (in the editor or browser).
|
||||
.B scrollup
|
||||
Scrolls the viewport up one row (meaning that the text slides down)
|
||||
while keeping the cursor in the same text position, if possible.
|
||||
(This function is bound by default to <Alt+Up>.
|
||||
If <Alt+Up> does nothing on your Linux console, see the FAQ:
|
||||
.UR https://nano\-editor.org/dist/latest/faq.html#4.1
|
||||
.UE .)
|
||||
.TP
|
||||
.B scrolldown
|
||||
Scrolls the viewport down one row (meaning that the text slides up)
|
||||
while keeping the cursor in the same text position, if possible.
|
||||
(This function is bound by default to <Alt+Down>.)
|
||||
.TP
|
||||
.B center
|
||||
Scrolls the line with the cursor to the middle of the screen.
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH RNANO 1 "version 5.5" "January 2021"
|
||||
.TH RNANO 1 "version 5.9" "October 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.
|
||||
@@ -79,21 +78,19 @@
|
||||
## Fall back to slow libmagic to try and determine an applicable syntax.
|
||||
# set magic
|
||||
|
||||
# After a search, set the mark at the end of the found match (if any).
|
||||
# set markmatch
|
||||
|
||||
## The opening and closing brackets that can be found by bracket
|
||||
## searches. They cannot contain blank characters. The former set must
|
||||
## come before the latter set, and both must be in the same order.
|
||||
## The opening and closing brackets that are found by a matching-bracket
|
||||
## search. This may not contain blank characters. The opening brackets
|
||||
## must come before the closing ones, and they must be in the same order.
|
||||
# set matchbrackets "(<[{)>]}"
|
||||
|
||||
## Suppress title bar and show file name and editor state at the bottom.
|
||||
## Suppress the title bar and show the filename plus a cursor-position
|
||||
## percentage in the space of the status bar.
|
||||
# set minibar
|
||||
|
||||
## Enable mouse support, if available for your system. When enabled,
|
||||
## mouse clicks can be used to place the cursor, set the mark (with a
|
||||
## double click), and execute shortcuts. The mouse will work in the X
|
||||
## Window System, and on the console when gpm is running.
|
||||
## double click), and execute shortcuts. The mouse will work in the
|
||||
## X Window System, and on the console when gpm is running.
|
||||
# set mouse
|
||||
|
||||
## Switch on multiple file buffers (inserting a file will put it into
|
||||
@@ -121,14 +118,12 @@
|
||||
## Preserve the XON and XOFF keys (^Q and ^S).
|
||||
# set preserve
|
||||
|
||||
## The characters treated as closing punctuation when justifying
|
||||
## paragraphs. They cannot contain blank characters. Only closing
|
||||
## punctuation, optionally followed by closing brackets, can end
|
||||
## sentences.
|
||||
## The characters treated as closing punctuation when justifying paragraphs.
|
||||
## This may not contain blank characters. Only these closing punctuations,
|
||||
## optionally followed by closing brackets, can end sentences.
|
||||
# set punct "!.?"
|
||||
|
||||
## Do quick status-bar blanking. Status-bar messages will disappear after
|
||||
## 1 keystroke instead of 26. Note that "constantshow" overrides this.
|
||||
## Make status-bar messages disappear after 1 keystroke instead of after 20.
|
||||
# set quickblank
|
||||
|
||||
## The regular expression that matches quoting characters in email
|
||||
@@ -149,16 +144,16 @@
|
||||
# set saveonexit
|
||||
## (The old form of this option, 'set tempfile', is deprecated.)
|
||||
|
||||
## Put the cursor on the highlighted item in the file browser, and show
|
||||
## the cursor in the help viewer; useful for people who use a braille
|
||||
## display and people with poor vision.
|
||||
## Put the cursor on the highlighted item in the file browser, and
|
||||
## show the cursor in the help viewer; useful for people who use a
|
||||
## braille display and people with poor vision.
|
||||
# set showcursor
|
||||
|
||||
## Make the Home key smarter. When Home is pressed anywhere but at the
|
||||
## Make the Home key smarter: when Home is pressed anywhere but at the
|
||||
## very beginning of non-whitespace characters on a line, the cursor
|
||||
## will jump to that beginning (either forwards or backwards). If the
|
||||
## cursor is already at that position, it will jump to the true
|
||||
## beginning of the line.
|
||||
## cursor is already at that position, it will jump to the true start
|
||||
## of the line (the left edge).
|
||||
# set smarthome
|
||||
|
||||
## Spread overlong lines over multiple screen lines.
|
||||
@@ -179,7 +174,7 @@
|
||||
## Use this tab size instead of the default; it must be greater than 0.
|
||||
# set tabsize 8
|
||||
|
||||
## Convert typed tabs to spaces.
|
||||
## Convert each typed tab to the fitting number of spaces.
|
||||
# set tabstospaces
|
||||
|
||||
## Snip whitespace at the end of lines when justifying or hard-wrapping.
|
||||
@@ -206,12 +201,14 @@
|
||||
## of a single character, and without affecting the cutbuffer).
|
||||
# set zap
|
||||
|
||||
## Paint the interface elements of nano. These are examples;
|
||||
## by default there are no colors, except for errorcolor.
|
||||
# set titlecolor bold,lightwhite,blue
|
||||
# set promptcolor lightwhite,lightblack
|
||||
# set statuscolor bold,lightwhite,green
|
||||
# set errorcolor bold,lightwhite,red
|
||||
|
||||
## Paint the interface elements of nano. These are examples; there are
|
||||
## no colors by default, except for errorcolor and spotlightcolor.
|
||||
# set titlecolor bold,white,blue
|
||||
# set promptcolor lightwhite,grey
|
||||
# set statuscolor bold,white,green
|
||||
# set errorcolor bold,white,red
|
||||
# set spotlightcolor black,lightyellow
|
||||
# set selectedcolor lightwhite,magenta
|
||||
# set stripecolor ,yellow
|
||||
# set scrollercolor cyan
|
||||
@@ -220,10 +217,11 @@
|
||||
# set functioncolor green
|
||||
|
||||
## In root's .nanorc you might want to use:
|
||||
# set titlecolor bold,lightwhite,magenta
|
||||
# set titlecolor bold,white,magenta
|
||||
# set promptcolor black,yellow
|
||||
# set statuscolor bold,lightwhite,magenta
|
||||
# set errorcolor bold,lightwhite,red
|
||||
# set statuscolor bold,white,magenta
|
||||
# set errorcolor bold,white,red
|
||||
# set spotlightcolor black,orange
|
||||
# set selectedcolor lightwhite,cyan
|
||||
# set stripecolor ,yellow
|
||||
# set scrollercolor magenta
|
||||
@@ -267,6 +265,12 @@
|
||||
## <Ctrl+Backspace> delete the word to the left of the cursor with:
|
||||
# bind ^H chopwordleft main
|
||||
|
||||
## For quickly uppercasing or lowercasing the word under the cursor.
|
||||
## (These effectively do a Ctrl+Right followed by a Shift+Ctrl+Left,
|
||||
## and then pipe the selected text through a sed command.)
|
||||
#bind Sh-M-U "Oc[1;6D|sed 's/.*/\U&/'
|
||||
" main
|
||||
#bind Sh-M-L "Oc[1;6D|sed 's/.*/\L&/'
|
||||
" main
|
||||
|
||||
## If you would like nano to have keybindings that are more "usual",
|
||||
@@ -281,11 +285,11 @@
|
||||
#bind ^F whereis all
|
||||
#bind ^G findnext all
|
||||
#bind ^B wherewas all
|
||||
#bind M-X flipnewbuffer all
|
||||
#bind ^X cut all
|
||||
#bind ^D findprevious all
|
||||
#bind ^R replace main
|
||||
#bind ^X cut main
|
||||
#bind ^C copy main
|
||||
#bind ^V paste all
|
||||
#bind ^P location main
|
||||
#bind ^E execute main
|
||||
#bind ^A mark main
|
||||
@@ -295,9 +299,10 @@
|
||||
#unbind ^Y all
|
||||
#unbind M-J main
|
||||
#unbind M-T main
|
||||
#bind ^Y speller main
|
||||
#bind ^T gotoline main
|
||||
#bind ^T gotodir browser
|
||||
#bind ^T cutrestoffile execute
|
||||
#bind ^L linter execute
|
||||
#bind ^U undo main
|
||||
#bind ^E redo main
|
||||
#bind M-U undo main
|
||||
#bind M-R redo main
|
||||
#bind ^Z undo main
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# List of available languages.
|
||||
bg ca cs da de eo es eu fi fr ga gl hr hu id it ja ko ms nb nl nn pl pt pt_BR ro ru sl sr sv tr uk vi zh_CN zh_TW
|
||||
bg ca cs da de eo es eu fi fr ga gl hr hu id is it ja ko ms nb nl pl pt pt_BR ro ru sk sl sr sv tr uk vi zh_CN zh_TW
|
||||
|
||||
1992
po/nn.po → po/is.po
1992
po/nn.po → po/is.po
File diff suppressed because it is too large
Load Diff
1179
po/nano.pot
1179
po/nano.pot
File diff suppressed because it is too large
Load Diff
1183
po/pt_BR.po
1183
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,9 @@ rm *.po
|
||||
wget --recursive --level=1 --accept=po --no-directories --no-verbose \
|
||||
https://translationproject.org/latest/nano/ || exit 2
|
||||
|
||||
# This PO file is less than twenty percent translated:
|
||||
rm -v nn.po
|
||||
|
||||
# Are there now PO files that are not in git yet?
|
||||
NEWSTUFF=$(git status --porcelain *.po | grep "^??")
|
||||
|
||||
|
||||
1193
po/zh_CN.po
1193
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
1187
po/zh_TW.po
1187
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERSION="5.5"
|
||||
VERSION="5.9"
|
||||
|
||||
./configure -C --enable-tiny && make && ./configure -C &&
|
||||
|
||||
@@ -12,7 +12,7 @@ po/update_linguas.sh &&
|
||||
|
||||
make distcheck && make dist-xz &&
|
||||
|
||||
git add po/*.po po/nano.pot &&
|
||||
git add po/*.po po/nano.pot po/LINGUAS &&
|
||||
git commit -m "$(git log -1 --grep 'po: up' | grep o: | sed 's/^ //')" &&
|
||||
|
||||
gpg -a -b nano-$VERSION.tar.gz &&
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -359,7 +359,8 @@ void search_filename(bool forwards)
|
||||
#endif
|
||||
}
|
||||
|
||||
findfile(last_search, forwards);
|
||||
if (response == 0 || response == -2)
|
||||
findfile(last_search, forwards);
|
||||
}
|
||||
|
||||
/* Search again without prompting for the last given search string,
|
||||
@@ -380,6 +381,18 @@ void research_filename(bool forwards)
|
||||
}
|
||||
}
|
||||
|
||||
/* Select the first file in the list -- called by ^W^Y. */
|
||||
void to_first_file(void)
|
||||
{
|
||||
selected = 0;
|
||||
}
|
||||
|
||||
/* Select the last file in the list -- called by ^W^V. */
|
||||
void to_last_file(void)
|
||||
{
|
||||
selected = list_length - 1;
|
||||
}
|
||||
|
||||
/* Strip one element from the end of path, and return the stripped path.
|
||||
* The returned string is dynamically allocated, and should be freed. */
|
||||
char *strip_last_component(const char *path)
|
||||
|
||||
246
src/chars.c
246
src/chars.c
@@ -2,7 +2,7 @@
|
||||
* chars.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2016-2020 Benno Schulenberg *
|
||||
* Copyright (C) 2016-2021 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published *
|
||||
@@ -51,7 +51,7 @@ bool is_alpha_char(const char *c)
|
||||
#ifdef ENABLE_UTF8
|
||||
wchar_t wc;
|
||||
|
||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
|
||||
if (mbtowide(&wc, c) < 0)
|
||||
return FALSE;
|
||||
|
||||
return iswalpha(wc);
|
||||
@@ -67,7 +67,7 @@ bool is_alnum_char(const char *c)
|
||||
#ifdef ENABLE_UTF8
|
||||
wchar_t wc;
|
||||
|
||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
|
||||
if (mbtowide(&wc, c) < 0)
|
||||
return FALSE;
|
||||
|
||||
return iswalnum(wc);
|
||||
@@ -85,7 +85,7 @@ bool is_blank_char(const char *c)
|
||||
if ((signed char)*c >= 0)
|
||||
return (*c == ' ' || *c == '\t');
|
||||
|
||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
|
||||
if (mbtowide(&wc, c) < 0)
|
||||
return FALSE;
|
||||
|
||||
return iswblank(wc);
|
||||
@@ -112,7 +112,7 @@ bool is_punct_char(const char *c)
|
||||
#ifdef ENABLE_UTF8
|
||||
wchar_t wc;
|
||||
|
||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
|
||||
if (mbtowide(&wc, c) < 0)
|
||||
return FALSE;
|
||||
|
||||
return iswpunct(wc);
|
||||
@@ -176,62 +176,123 @@ char control_mbrep(const char *c, bool isdata)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
/* Return the width in columns of the given (multibyte) character. */
|
||||
int mbwidth(const char *c)
|
||||
/* Convert the given multibyte sequence c to wide character wc, and return
|
||||
* the number of bytes in the sequence, or -1 for an invalid sequence. */
|
||||
int mbtowide(wchar_t *wc, const char *c)
|
||||
{
|
||||
/* Only characters beyond U+02FF can be other than one column wide. */
|
||||
if ((unsigned char)*c > 0xCB) {
|
||||
wchar_t wc;
|
||||
int width;
|
||||
if ((signed char)*c < 0 && use_utf8) {
|
||||
unsigned char v1 = (unsigned char)c[0];
|
||||
unsigned char v2 = (unsigned char)c[1] ^ 0x80;
|
||||
|
||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
|
||||
return 1;
|
||||
if (v2 > 0x3F || v1 < 0xC2)
|
||||
return -1;
|
||||
|
||||
width = wcwidth(wc);
|
||||
if (v1 < 0xE0) {
|
||||
*wc = (((unsigned int)(v1 & 0x1F) << 6) | (unsigned int)v2);
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (width < 0)
|
||||
return 1;
|
||||
unsigned char v3 = (unsigned char)c[2] ^ 0x80;
|
||||
|
||||
return width;
|
||||
} else
|
||||
return 1;
|
||||
if (v3 > 0x3F)
|
||||
return -1;
|
||||
|
||||
if (v1 < 0xF0) {
|
||||
if ((v1 > 0xE0 || v2 >= 0x20) && (v1 != 0xED || v2 < 0x20)) {
|
||||
*wc = (((unsigned int)(v1 & 0x0F) << 12) |
|
||||
((unsigned int)v2 << 6) | (unsigned int)v3);
|
||||
return 3;
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
unsigned char v4 = (unsigned char)c[3] ^ 0x80;
|
||||
|
||||
if (v4 > 0x3F || v1 > 0xF4)
|
||||
return -1;
|
||||
|
||||
if ((v1 > 0xF0 || v2 >= 0x10) && (v1 != 0xF4 || v2 < 0x10)) {
|
||||
*wc = (((unsigned int)(v1 & 0x07) << 18) | ((unsigned int)v2 << 12) |
|
||||
((unsigned int)v3 << 6) | (unsigned int)v4);
|
||||
return 4;
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
*wc = (unsigned int)*c;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Return TRUE when the given character occupies two cells. */
|
||||
bool is_doublewidth(const char *ch)
|
||||
{
|
||||
wchar_t wc;
|
||||
|
||||
/* Only from U+1100 can code points have double width. */
|
||||
if ((unsigned char)*ch < 0xE1 || !use_utf8)
|
||||
return FALSE;
|
||||
|
||||
if (mbtowide(&wc, ch) < 0)
|
||||
return FALSE;
|
||||
|
||||
return (wcwidth(wc) == 2);
|
||||
}
|
||||
|
||||
/* Return TRUE when the given character occupies zero cells. */
|
||||
bool is_zerowidth(const char *ch)
|
||||
{
|
||||
return (use_utf8 && mbwidth(ch) == 0);
|
||||
}
|
||||
wchar_t wc;
|
||||
|
||||
/* Convert the given Unicode value to a multibyte character, if possible.
|
||||
* If the conversion succeeds, return the (dynamically allocated) multibyte
|
||||
* character and its length. Otherwise, return a length of zero. */
|
||||
char *make_mbchar(long code, int *length)
|
||||
{
|
||||
char *mb_char = nmalloc(MAXCHARLEN);
|
||||
/* Only from U+0300 can code points have zero width. */
|
||||
if ((unsigned char)*ch < 0xCC || !use_utf8)
|
||||
return FALSE;
|
||||
|
||||
*length = wctomb(mb_char, (wchar_t)code);
|
||||
if (mbtowide(&wc, ch) < 0)
|
||||
return FALSE;
|
||||
|
||||
/* Reject invalid Unicode characters. */
|
||||
if (*length < 0 || !is_valid_unicode((wchar_t)code)) {
|
||||
IGNORE_CALL_RESULT(wctomb(NULL, 0));
|
||||
*length = 0;
|
||||
}
|
||||
#if defined(__OpenBSD__)
|
||||
/* Work around an OpenBSD bug -- see https://sv.gnu.org/bugs/?60393. */
|
||||
if (wc >= 0xF0000)
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
return mb_char;
|
||||
return (wcwidth(wc) == 0);
|
||||
}
|
||||
#endif /* ENABLE_UTF8 */
|
||||
|
||||
/* Return the length (in bytes) of the character located at *pointer. */
|
||||
/* Return the number of bytes in the character that starts at *pointer. */
|
||||
int char_length(const char *pointer)
|
||||
{
|
||||
#ifdef ENABLE_UTF8
|
||||
/* If possibly a multibyte character, get its length; otherwise, it's 1. */
|
||||
if ((unsigned char)*pointer > 0xC1) {
|
||||
int length = mblen(pointer, MAXCHARLEN);
|
||||
if ((unsigned char)*pointer > 0xC1 && use_utf8) {
|
||||
unsigned char c1 = (unsigned char)pointer[0];
|
||||
unsigned char c2 = (unsigned char)pointer[1];
|
||||
|
||||
return (length < 0 ? 1 : length);
|
||||
} else
|
||||
if ((c2 ^ 0x80) > 0x3F)
|
||||
return 1;
|
||||
|
||||
if (c1 < 0xE0)
|
||||
return 2;
|
||||
|
||||
if (((unsigned char)pointer[2] ^ 0x80) > 0x3F)
|
||||
return 1;
|
||||
|
||||
if (c1 < 0xF0) {
|
||||
if ((c1 > 0xE0 || c2 >= 0xA0) && (c1 != 0xED || c2 < 0xA0))
|
||||
return 3;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (((unsigned char)pointer[3] ^ 0x80) > 0x3F)
|
||||
return 1;
|
||||
|
||||
if (c1 > 0xF4)
|
||||
return 1;
|
||||
|
||||
if ((c1 > 0xF0 || c2 >= 0x90) && (c1 != 0xF4 || c2 < 0x90))
|
||||
return 4;
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -242,15 +303,7 @@ size_t mbstrlen(const char *pointer)
|
||||
size_t count = 0;
|
||||
|
||||
while (*pointer != '\0') {
|
||||
#ifdef ENABLE_UTF8
|
||||
if ((unsigned char)*pointer > 0xC1) {
|
||||
int length = mblen(pointer, MAXCHARLEN);
|
||||
|
||||
pointer += (length < 0 ? 1 : length);
|
||||
} else
|
||||
#endif
|
||||
pointer++;
|
||||
|
||||
pointer += char_length(pointer);
|
||||
count++;
|
||||
}
|
||||
|
||||
@@ -261,19 +314,7 @@ size_t mbstrlen(const char *pointer)
|
||||
* given string, and return a copy of this character in *thechar. */
|
||||
int collect_char(const char *string, char *thechar)
|
||||
{
|
||||
int charlen;
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
/* If this is a UTF-8 starter byte, get the number of bytes of the character. */
|
||||
if ((unsigned char)*string > 0xC1) {
|
||||
charlen = mblen(string, MAXCHARLEN);
|
||||
|
||||
/* When the multibyte sequence is invalid, only take the first byte. */
|
||||
if (charlen <= 0)
|
||||
charlen = 1;
|
||||
} else
|
||||
#endif
|
||||
charlen = 1;
|
||||
int charlen = char_length(string);
|
||||
|
||||
for (int i = 0; i < charlen; i++)
|
||||
thechar[i] = string[i];
|
||||
@@ -286,20 +327,29 @@ int collect_char(const char *string, char *thechar)
|
||||
int advance_over(const char *string, size_t *column)
|
||||
{
|
||||
#ifdef ENABLE_UTF8
|
||||
if ((signed char)*string < 0) {
|
||||
int charlen = mblen(string, MAXCHARLEN);
|
||||
|
||||
if (charlen > 0) {
|
||||
if (is_cntrl_char(string))
|
||||
*column += 2;
|
||||
else
|
||||
*column += mbwidth(string);
|
||||
if ((signed char)*string < 0 && use_utf8) {
|
||||
/* A UTF-8 upper control code has two bytes and takes two columns. */
|
||||
if (((unsigned char)string[0] == 0xC2 && (signed char)string[1] < -96)) {
|
||||
*column += 2;
|
||||
return 2;
|
||||
} else {
|
||||
charlen = 1;
|
||||
*column += 1;
|
||||
}
|
||||
wchar_t wc;
|
||||
int charlen = mbtowide(&wc, string);
|
||||
|
||||
return charlen;
|
||||
if (charlen < 0) {
|
||||
*column += 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int width = wcwidth(wc);
|
||||
|
||||
#if defined(__OpenBSD__)
|
||||
*column += (width < 0 || wc >= 0xF0000) ? 1 : width;
|
||||
#else
|
||||
*column += (width < 0) ? 1 : width;
|
||||
#endif
|
||||
return charlen;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -308,12 +358,8 @@ int advance_over(const char *string, size_t *column)
|
||||
*column += tabsize - *column % tabsize;
|
||||
else
|
||||
*column += 2;
|
||||
} else if (*string == 0x7F)
|
||||
} else if (0x7E < (unsigned char)*string && (unsigned char)*string < 0xA0)
|
||||
*column += 2;
|
||||
#ifndef ENABLE_UTF8
|
||||
else if (0x7F < (unsigned char)*string && (unsigned char)*string < 0xA0)
|
||||
*column += 2;
|
||||
#endif
|
||||
else
|
||||
*column += 1;
|
||||
|
||||
@@ -396,8 +442,8 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
|
||||
continue;
|
||||
}
|
||||
|
||||
bool bad1 = (mbtowc(&wc1, s1, MAXCHARLEN) < 0);
|
||||
bool bad2 = (mbtowc(&wc2, s2, MAXCHARLEN) < 0);
|
||||
bool bad1 = (mbtowide(&wc1, s1) < 0);
|
||||
bool bad2 = (mbtowide(&wc2, s2) < 0);
|
||||
|
||||
if (bad1 || bad2) {
|
||||
if (*s1 != *s2)
|
||||
@@ -452,7 +498,7 @@ char *revstrstr(const char *haystack, const char *needle,
|
||||
size_t tail_len = strlen(pointer);
|
||||
|
||||
if (tail_len < needle_len)
|
||||
pointer += tail_len - needle_len;
|
||||
pointer -= (needle_len - tail_len);
|
||||
|
||||
while (pointer >= haystack) {
|
||||
if (strncmp(pointer, needle, needle_len) == 0)
|
||||
@@ -472,7 +518,7 @@ char *revstrcasestr(const char *haystack, const char *needle,
|
||||
size_t tail_len = strlen(pointer);
|
||||
|
||||
if (tail_len < needle_len)
|
||||
pointer += tail_len - needle_len;
|
||||
pointer -= (needle_len - tail_len);
|
||||
|
||||
while (pointer >= haystack) {
|
||||
if (strncasecmp(pointer, needle, needle_len) == 0)
|
||||
@@ -494,7 +540,7 @@ char *mbrevstrcasestr(const char *haystack, const char *needle,
|
||||
size_t tail_len = mbstrlen(pointer);
|
||||
|
||||
if (tail_len < needle_len)
|
||||
pointer += tail_len - needle_len;
|
||||
pointer -= (needle_len - tail_len);
|
||||
|
||||
if (pointer < haystack)
|
||||
return NULL;
|
||||
@@ -522,13 +568,13 @@ char *mbstrchr(const char *string, const char *chr)
|
||||
bool bad_s = FALSE, bad_c = FALSE;
|
||||
wchar_t ws, wc;
|
||||
|
||||
if (mbtowc(&wc, chr, MAXCHARLEN) < 0) {
|
||||
if (mbtowide(&wc, chr) < 0) {
|
||||
wc = (unsigned char)*chr;
|
||||
bad_c = TRUE;
|
||||
}
|
||||
|
||||
while (*string != '\0') {
|
||||
int symlen = mbtowc(&ws, string, MAXCHARLEN);
|
||||
int symlen = mbtowide(&ws, string);
|
||||
|
||||
if (symlen < 0) {
|
||||
ws = (unsigned char)*string;
|
||||
@@ -590,22 +636,15 @@ char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer)
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || defined(ENABLE_JUSTIFY))
|
||||
/* Return TRUE if the given string contains at least one blank character,
|
||||
* and FALSE otherwise. */
|
||||
/* Return TRUE if the given string contains at least one blank character. */
|
||||
bool has_blank_char(const char *string)
|
||||
{
|
||||
char symbol[MAXCHARLEN];
|
||||
while (*string != '\0' && !is_blank_char(string))
|
||||
string += char_length(string);
|
||||
|
||||
while (*string != '\0') {
|
||||
string += collect_char(string, symbol);
|
||||
|
||||
if (is_blank_char(symbol))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return *string;
|
||||
}
|
||||
#endif /* ENABLE_NANORC && (!NANO_TINY || ENABLE_JUSTIFY) */
|
||||
#endif
|
||||
|
||||
/* Return TRUE when the given string is empty or consists of only blanks. */
|
||||
bool white_string(const char *string)
|
||||
@@ -615,14 +654,3 @@ bool white_string(const char *string)
|
||||
|
||||
return !*string;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
/* Return TRUE if wc is valid Unicode, and FALSE otherwise. */
|
||||
bool is_valid_unicode(wchar_t wc)
|
||||
{
|
||||
return ((0 <= wc && wc <= 0xD7FF) ||
|
||||
(0xE000 <= wc && wc <= 0xFDCF) ||
|
||||
(0xFDF0 <= wc && wc <= 0xFFFD) ||
|
||||
(0xFFFF < wc && wc <= 0x10FFFF && (wc & 0xFFFF) <= 0xFFFD));
|
||||
}
|
||||
#endif
|
||||
|
||||
131
src/color.c
131
src/color.c
@@ -2,7 +2,7 @@
|
||||
* color.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2017, 2020 Benno Schulenberg *
|
||||
* Copyright (C) 2014-2017, 2020, 2021 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published *
|
||||
@@ -58,7 +58,10 @@ 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 == PROMPT_BAR)
|
||||
else if (index == SPOTLIGHTED) {
|
||||
init_pair(index + 1, COLOR_BLACK, COLOR_YELLOW + (COLORS > 15 ? 8 : 0));
|
||||
interface_color_pair[index] = COLOR_PAIR(index + 1);
|
||||
} else if (index == MINI_INFOBAR || index == PROMPT_BAR)
|
||||
interface_color_pair[index] = interface_color_pair[TITLE_BAR];
|
||||
else if (index == ERROR_MESSAGE) {
|
||||
init_pair(index + 1, COLOR_WHITE, COLOR_RED);
|
||||
@@ -116,19 +119,9 @@ void prepare_palette(void)
|
||||
* the list starting at head. Return TRUE upon success. */
|
||||
bool found_in_list(regexlisttype *head, const char *shibboleth)
|
||||
{
|
||||
regexlisttype *item;
|
||||
regex_t rgx;
|
||||
|
||||
for (item = head; item != NULL; item = item->next) {
|
||||
regcomp(&rgx, item->full_regex, NANO_REG_EXTENDED);
|
||||
|
||||
if (regexec(&rgx, shibboleth, 0, NULL, 0) == 0) {
|
||||
regfree(&rgx);
|
||||
for (regexlisttype *item = head; item != NULL; item = item->next)
|
||||
if (regexec(item->one_rgx, shibboleth, 0, NULL, 0) == 0)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
regfree(&rgx);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -231,15 +224,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)
|
||||
@@ -253,8 +237,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. */
|
||||
@@ -266,19 +252,22 @@ void check_the_multis(linestruct *line)
|
||||
anend = (regexec(ink->end, afterstart, 1, &endmatch, 0) == 0);
|
||||
|
||||
/* Check whether the multidata still matches the current situation. */
|
||||
if (line->multidata[ink->id] == CNONE ||
|
||||
line->multidata[ink->id] == CWHOLELINE) {
|
||||
if (line->multidata[ink->id] == NOTHING) {
|
||||
if (!astart)
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] & (WHOLELINE|WOULDBE)) {
|
||||
if (!astart && !anend)
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] == CSTARTENDHERE) {
|
||||
if (astart && anend && startmatch.rm_so < endmatch.rm_so)
|
||||
} else if (line->multidata[ink->id] == JUSTONTHIS) {
|
||||
if (astart && anend && regexec(ink->start, line->data + endmatch.rm_eo,
|
||||
1, &startmatch, 0) != 0)
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] == CBEGINBEFORE) {
|
||||
if (!astart && anend)
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] == CENDAFTER) {
|
||||
} else if (line->multidata[ink->id] == STARTSHERE) {
|
||||
if (astart && !anend)
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] == ENDSHERE) {
|
||||
if (!astart && anend)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* There is a mismatch, so something changed: repaint. */
|
||||
@@ -295,13 +284,19 @@ 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);
|
||||
if (!line->multidata)
|
||||
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. */
|
||||
@@ -312,66 +307,68 @@ void precalc_multicolorinfo(void)
|
||||
int index = 0;
|
||||
|
||||
/* Assume nothing applies until proven otherwise below. */
|
||||
line->multidata[ink->id] = CNONE;
|
||||
line->multidata[ink->id] = NOTHING;
|
||||
|
||||
/* For an unpaired start match, mark all remaining lines. */
|
||||
if (line->prev && line->prev->multidata[ink->id] == CWOULDBE) {
|
||||
line->multidata[ink->id] = CWOULDBE;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* When the line contains a start match, look for an end, and if
|
||||
* found, mark all the lines that are affected. */
|
||||
while (regexec(ink->start, line->data + index, 1,
|
||||
&startmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
/* When the line contains a start match, look for an end,
|
||||
* and if found, mark all the lines that are affected. */
|
||||
while (regexec(ink->start, line->data + index, 1, &startmatch,
|
||||
(index == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
/* Begin looking for an end match after the start match. */
|
||||
index += startmatch.rm_eo;
|
||||
|
||||
/* If there is an end match on this line, mark the line, but
|
||||
* continue looking for other starts after it. */
|
||||
if (regexec(ink->end, line->data + index, 1,
|
||||
&endmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
line->multidata[ink->id] = CSTARTENDHERE;
|
||||
/* If there is an end match on this same line, mark the line,
|
||||
* but continue looking for other starts after it. */
|
||||
if (regexec(ink->end, line->data + index, 1, &endmatch,
|
||||
(index == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
line->multidata[ink->id] = JUSTONTHIS;
|
||||
|
||||
index += endmatch.rm_eo;
|
||||
/* If both start and end are mere anchors, step ahead. */
|
||||
if (startmatch.rm_so == startmatch.rm_eo &&
|
||||
endmatch.rm_so == endmatch.rm_eo) {
|
||||
/* When at end-of-line, we're done. */
|
||||
|
||||
/* If the total match has zero length, force an advance. */
|
||||
if (startmatch.rm_eo - startmatch.rm_so + endmatch.rm_eo == 0) {
|
||||
/* When at end-of-line, there is no other start. */
|
||||
if (line->data[index] == '\0')
|
||||
break;
|
||||
index = step_right(line->data, index);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Look for an end match on later lines. */
|
||||
tailline = line->next;
|
||||
|
||||
while (tailline != NULL) {
|
||||
if (regexec(ink->end, tailline->data, 1, &endmatch, 0) == 0)
|
||||
break;
|
||||
while (tailline && regexec(ink->end, tailline->data,
|
||||
1, &endmatch, 0) != 0)
|
||||
tailline = tailline->next;
|
||||
}
|
||||
|
||||
/* When there is no end match, mark relevant lines as such. */
|
||||
if (tailline == NULL) {
|
||||
line->multidata[ink->id] = CWOULDBE;
|
||||
for (; line->next != NULL; line = line->next)
|
||||
line->multidata[ink->id] = WOULDBE;
|
||||
line->multidata[ink->id] = WOULDBE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* We found it, we found it, la la la la la. Mark all
|
||||
* the lines in between and the end properly. */
|
||||
line->multidata[ink->id] = CENDAFTER;
|
||||
/* We found it, we found it, la lala lala. Mark the lines. */
|
||||
line->multidata[ink->id] = STARTSHERE;
|
||||
|
||||
// Note that this also advances the line in the main loop.
|
||||
for (line = line->next; line != tailline; line = line->next)
|
||||
line->multidata[ink->id] = CWHOLELINE;
|
||||
line->multidata[ink->id] = WHOLELINE;
|
||||
|
||||
tailline->multidata[ink->id] = CBEGINBEFORE;
|
||||
tailline->multidata[ink->id] = ENDSHERE;
|
||||
|
||||
/* Begin looking for a new start after the end match. */
|
||||
/* Look for a possible new start after the end match. */
|
||||
index = endmatch.rm_eo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TIMEPRECALC
|
||||
statusline(INFO, "Precalculation: %.1f ms", 1000 * (double)(clock() - start) / CLOCKS_PER_SEC);
|
||||
napms(1200);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* ENABLE_COLOR */
|
||||
|
||||
67
src/cut.c
67
src/cut.c
@@ -34,7 +34,7 @@ void do_deletion(undo_type action)
|
||||
int charlen = char_length(openfile->current->data + openfile->current_x);
|
||||
size_t line_len = strlen(openfile->current->data + openfile->current_x);
|
||||
#ifndef NANO_TINY
|
||||
size_t old_amount = openfile->current->extrarows;
|
||||
size_t old_amount = ISSET(SOFTWRAP) ? extra_chunks_in(openfile->current) : 0;
|
||||
|
||||
/* If the type of action changed or the cursor moved to a different
|
||||
* line, create a new undo item, otherwise update the existing item. */
|
||||
@@ -49,13 +49,9 @@ void do_deletion(undo_type action)
|
||||
&openfile->current->data[openfile->current_x + charlen],
|
||||
line_len - charlen + 1);
|
||||
#ifndef NANO_TINY
|
||||
/* When softwrapping, recompute the number of chunks in the line,
|
||||
* and schedule a refresh if the number changed. */
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
openfile->current->extrarows = extra_chunks_in(openfile->current);
|
||||
if (openfile->current->extrarows != old_amount)
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
/* When softwrapping, a changed number of chunks requires a refresh. */
|
||||
if (ISSET(SOFTWRAP) && extra_chunks_in(openfile->current) != old_amount)
|
||||
refresh_needed = TRUE;
|
||||
|
||||
/* Adjust the mark if it is after the cursor on the current line. */
|
||||
if (openfile->mark == openfile->current &&
|
||||
@@ -94,10 +90,6 @@ void do_deletion(undo_type action)
|
||||
|
||||
unlink_node(joining);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP))
|
||||
openfile->current->extrarows = extra_chunks_in(openfile->current);
|
||||
#endif
|
||||
/* Two lines were joined, so do a renumbering and refresh the screen. */
|
||||
renumber_from(openfile->current);
|
||||
refresh_needed = TRUE;
|
||||
@@ -257,27 +249,29 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
|
||||
bool same_line = (openfile->mark == top);
|
||||
bool post_marked = (openfile->mark && (openfile->mark->lineno > top->lineno ||
|
||||
(same_line && openfile->mark_x > top_x)));
|
||||
bool was_anchored = top->has_anchor;
|
||||
static bool inherited_anchor = FALSE;
|
||||
bool had_anchor = top->has_anchor;
|
||||
|
||||
if (top == bot && top_x == bot_x)
|
||||
return;
|
||||
|
||||
if (top != bot)
|
||||
for (linestruct *line = top->next; line != bot->next; line = line->next)
|
||||
was_anchored |= line->has_anchor;
|
||||
had_anchor |= line->has_anchor;
|
||||
#endif
|
||||
|
||||
if (top == bot) {
|
||||
taken = make_new_node(NULL);
|
||||
taken->data = measured_copy(top->data + top_x, bot_x - top_x);
|
||||
memmove(top->data + top_x, top->data + bot_x,
|
||||
strlen(top->data + bot_x) + 1);
|
||||
memmove(top->data + top_x, top->data + bot_x, strlen(top->data + bot_x) + 1);
|
||||
last = taken;
|
||||
} else if (top_x == 0 && bot_x == 0) {
|
||||
taken = top;
|
||||
last = make_new_node(NULL);
|
||||
last->data = copy_of("");
|
||||
|
||||
#ifndef NANO_TINY
|
||||
last->has_anchor = bot->has_anchor;
|
||||
#endif
|
||||
last->prev = bot->prev;
|
||||
bot->prev->next = last;
|
||||
last->next = NULL;
|
||||
@@ -317,11 +311,17 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
|
||||
if (cutbuffer == NULL) {
|
||||
cutbuffer = taken;
|
||||
cutbottom = last;
|
||||
#ifndef NANO_TINY
|
||||
inherited_anchor = taken->has_anchor;
|
||||
#endif
|
||||
} else {
|
||||
cutbottom->data = nrealloc(cutbottom->data,
|
||||
strlen(cutbottom->data) + strlen(taken->data) + 1);
|
||||
strcat(cutbottom->data, taken->data);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
cutbottom->has_anchor = taken->has_anchor && !inherited_anchor;
|
||||
inherited_anchor |= taken->has_anchor;
|
||||
#endif
|
||||
cutbottom->next = taken->next;
|
||||
delete_node(taken);
|
||||
|
||||
@@ -334,10 +334,7 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
|
||||
openfile->current_x = top_x;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
openfile->current->has_anchor = was_anchored;
|
||||
|
||||
if (ISSET(SOFTWRAP))
|
||||
openfile->current->extrarows = extra_chunks_in(openfile->current);
|
||||
openfile->current->has_anchor = had_anchor;
|
||||
|
||||
if (post_marked || same_line)
|
||||
openfile->mark = openfile->current;
|
||||
@@ -391,10 +388,6 @@ void ingraft_buffer(linestruct *topline)
|
||||
}
|
||||
|
||||
if (topline != botline) {
|
||||
#ifndef NANO_TINY
|
||||
/* First compute the softwrapped chunks for each line in the graft. */
|
||||
compute_the_extra_rows_per_line_from(topline);
|
||||
#endif
|
||||
/* When inserting at end-of-buffer, update the relevant pointer. */
|
||||
if (line->next == NULL)
|
||||
openfile->filebot = botline;
|
||||
@@ -427,11 +420,6 @@ void ingraft_buffer(linestruct *topline)
|
||||
openfile->mark_x += length - xpos;
|
||||
} else if (mark_follows)
|
||||
openfile->mark_x += extralen;
|
||||
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
line->extrarows = extra_chunks_in(line);
|
||||
openfile->current->extrarows = extra_chunks_in(openfile->current);
|
||||
}
|
||||
#endif
|
||||
|
||||
delete_node(topline);
|
||||
@@ -706,10 +694,13 @@ void copy_text(void)
|
||||
/* Copy text from the cutbuffer into the current buffer. */
|
||||
void paste_text(void)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
/* Remember where the paste started. */
|
||||
linestruct *was_current = openfile->current;
|
||||
bool had_anchor = was_current->has_anchor;
|
||||
#endif
|
||||
ssize_t was_lineno = openfile->current->lineno;
|
||||
/* The line number where we started the paste. */
|
||||
size_t was_leftedge = 0;
|
||||
/* The leftedge where we started the paste. */
|
||||
|
||||
if (cutbuffer == NULL) {
|
||||
statusline(AHEM, _("Cutbuffer is empty"));
|
||||
@@ -728,12 +719,22 @@ void paste_text(void)
|
||||
copy_from_buffer(cutbuffer);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Wipe any anchors in the pasted text, so that they don't proliferate. */
|
||||
for (linestruct *line = was_current; line != openfile->current->next; line = line->next)
|
||||
line->has_anchor = FALSE;
|
||||
|
||||
was_current->has_anchor = had_anchor;
|
||||
|
||||
update_undo(PASTE);
|
||||
#endif
|
||||
|
||||
/* 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();
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__HAIKU__) && !defined(_DEFAULT_SOURCE)
|
||||
#define _DEFAULT_SOURCE 1
|
||||
#endif
|
||||
|
||||
#ifdef __TANDEM
|
||||
/* Tandem NonStop Kernel support. */
|
||||
#include <floss.h>
|
||||
@@ -111,9 +115,16 @@
|
||||
#define REPLACING 1
|
||||
#define INREGION 2
|
||||
|
||||
/* In UTF-8 a character is at most six bytes long. */
|
||||
#define NORMAL TRUE
|
||||
#define SPECIAL FALSE
|
||||
#define TEMPORARY FALSE
|
||||
|
||||
#define ANNOTATE TRUE
|
||||
#define NONOTES FALSE
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
#define MAXCHARLEN 6
|
||||
/* In UTF-8 a valid character is at most four bytes long. */
|
||||
#define MAXCHARLEN 4
|
||||
#else
|
||||
#define MAXCHARLEN 1
|
||||
#endif
|
||||
@@ -138,17 +149,17 @@
|
||||
#define BAD_COLOR -2
|
||||
|
||||
/* Flags for indicating how a multiline regex pair apply to a line. */
|
||||
#define CNONE (1<<1)
|
||||
#define NOTHING (1<<1)
|
||||
/* The start/end regexes don't cover this line at all. */
|
||||
#define CBEGINBEFORE (1<<2)
|
||||
/* The start regex matches on an earlier line, the end regex on this one. */
|
||||
#define CENDAFTER (1<<3)
|
||||
#define STARTSHERE (1<<2)
|
||||
/* The start regex matches on this line, the end regex on a later one. */
|
||||
#define CWHOLELINE (1<<4)
|
||||
#define WHOLELINE (1<<3)
|
||||
/* The start regex matches on an earlier line, the end regex on a later one. */
|
||||
#define CSTARTENDHERE (1<<5)
|
||||
#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 CWOULDBE (1<<6)
|
||||
#define WOULDBE (1<<6)
|
||||
/* An unpaired start match is on or before this line. */
|
||||
#endif
|
||||
|
||||
@@ -216,6 +227,7 @@
|
||||
#define INCLUDED_LAST_LINE (1<<3)
|
||||
#define MARK_WAS_SET (1<<4)
|
||||
#define CURSOR_WAS_AT_HEAD (1<<5)
|
||||
#define HAD_ANCHOR_AT_START (1<<6)
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Identifiers for the different menus. */
|
||||
@@ -246,7 +258,7 @@
|
||||
|
||||
/* Enumeration types. */
|
||||
typedef enum {
|
||||
NIX_FILE, DOS_FILE, MAC_FILE
|
||||
UNSPECIFIED, NIX_FILE, DOS_FILE, MAC_FILE
|
||||
} format_type;
|
||||
|
||||
typedef enum {
|
||||
@@ -282,6 +294,8 @@ enum {
|
||||
GUIDE_STRIPE,
|
||||
SCROLL_BAR,
|
||||
SELECTED_TEXT,
|
||||
SPOTLIGHTED,
|
||||
MINI_INFOBAR,
|
||||
PROMPT_BAR,
|
||||
STATUS_BAR,
|
||||
ERROR_MESSAGE,
|
||||
@@ -306,7 +320,6 @@ enum {
|
||||
CUT_FROM_CURSOR,
|
||||
BACKWARDS_SEARCH,
|
||||
MULTIBUFFER,
|
||||
SMOOTH_SCROLL,
|
||||
REBIND_DELETE,
|
||||
RAW_SEQUENCES,
|
||||
NO_CONVERT,
|
||||
@@ -318,7 +331,6 @@ enum {
|
||||
RESTRICTED,
|
||||
SMART_HOME,
|
||||
WHITESPACE_DISPLAY,
|
||||
MORE_SPACE,
|
||||
TABS_TO_SPACES,
|
||||
QUICK_BLANK,
|
||||
WORD_BOUNDS,
|
||||
@@ -332,7 +344,6 @@ enum {
|
||||
TRIM_BLANKS,
|
||||
SHOW_CURSOR,
|
||||
LINE_NUMBERS,
|
||||
NO_PAUSES,
|
||||
AT_BLANKS,
|
||||
AFTER_ENDS,
|
||||
LET_THEM_ZAP,
|
||||
@@ -343,8 +354,7 @@ enum {
|
||||
BOOKSTYLE,
|
||||
STATEFLAGS,
|
||||
USE_MAGIC,
|
||||
MINIBAR,
|
||||
MARK_MATCH
|
||||
MINIBAR
|
||||
};
|
||||
|
||||
/* Structure types. */
|
||||
@@ -369,8 +379,8 @@ typedef struct colortype {
|
||||
} colortype;
|
||||
|
||||
typedef struct regexlisttype {
|
||||
char *full_regex;
|
||||
/* A regex string to match things that imply a certain syntax. */
|
||||
regex_t *one_rgx;
|
||||
/* A regex to match things that imply a certain syntax. */
|
||||
struct regexlisttype *next;
|
||||
/* The next regex. */
|
||||
} regexlisttype;
|
||||
@@ -441,10 +451,6 @@ typedef struct linestruct {
|
||||
/* The text of this line. */
|
||||
ssize_t lineno;
|
||||
/* The number of this line. */
|
||||
#ifndef NANO_TINY
|
||||
ssize_t extrarows;
|
||||
/* The extra rows that this line occupies when softwrapping. */
|
||||
#endif
|
||||
struct linestruct *next;
|
||||
/* Next node. */
|
||||
struct linestruct *prev;
|
||||
@@ -567,6 +573,8 @@ typedef struct openfilestruct {
|
||||
/* The syntax that applies to this file, if any. */
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
char *errormessage;
|
||||
/* The ALERT message (if any) that occurred when opening the file. */
|
||||
struct openfilestruct *next;
|
||||
/* The next open file, if any. */
|
||||
struct openfilestruct *prev;
|
||||
@@ -628,8 +636,8 @@ typedef struct funcstruct {
|
||||
} funcstruct;
|
||||
|
||||
#ifdef ENABLE_WORDCOMPLETION
|
||||
typedef struct completion_word {
|
||||
typedef struct completionstruct {
|
||||
char *word;
|
||||
struct completion_word *next;
|
||||
} completion_word;
|
||||
struct completionstruct *next;
|
||||
} completionstruct;
|
||||
#endif
|
||||
|
||||
297
src/files.c
297
src/files.c
@@ -2,7 +2,7 @@
|
||||
* files.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2015-2020 Benno Schulenberg *
|
||||
* Copyright (C) 2015-2021 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published *
|
||||
@@ -40,19 +40,19 @@ void make_new_buffer(void)
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (openfile == NULL) {
|
||||
/* Make the first open file the only element in the list. */
|
||||
/* Make the first buffer the only element in the list. */
|
||||
newnode->prev = newnode;
|
||||
newnode->next = newnode;
|
||||
|
||||
startfile = newnode;
|
||||
} else {
|
||||
/* Add the new open file after the current one in the list. */
|
||||
/* Add the new buffer after the current one in the list. */
|
||||
newnode->prev = openfile;
|
||||
newnode->next = openfile->next;
|
||||
openfile->next->prev = newnode;
|
||||
openfile->next = newnode;
|
||||
|
||||
/* There is more than one file open: show "Close" in help lines. */
|
||||
/* There is more than one buffer: show "Close" in help lines. */
|
||||
exitfunc->desc = close_tag;
|
||||
more_than_one = !inhelp || more_than_one;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ void make_new_buffer(void)
|
||||
openfile->mark = NULL;
|
||||
openfile->softmark = FALSE;
|
||||
|
||||
openfile->fmt = NIX_FILE;
|
||||
openfile->fmt = UNSPECIFIED;
|
||||
|
||||
openfile->undotop = NULL;
|
||||
openfile->current_undo = NULL;
|
||||
@@ -93,6 +93,9 @@ void make_new_buffer(void)
|
||||
openfile->statinfo = NULL;
|
||||
openfile->lock_filename = NULL;
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
openfile->errormessage = NULL;
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
openfile->syntax = NULL;
|
||||
#endif
|
||||
@@ -119,7 +122,7 @@ char *crop_to_fit(const char *name, int room)
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Delete the lockfile. Return TRUE on success, and FALSE otherwise. */
|
||||
/* Delete the lock file. Return TRUE on success, and FALSE otherwise. */
|
||||
bool delete_lockfile(const char *lockfilename)
|
||||
{
|
||||
if (unlink(lockfilename) < 0 && errno != ENOENT) {
|
||||
@@ -200,7 +203,8 @@ bool write_lockfile(const char *lockfilename, const char *filename, bool modifie
|
||||
* some byte-order-checking numbers (bytes 1008-1022). */
|
||||
lockdata[0] = 0x62;
|
||||
lockdata[1] = 0x30;
|
||||
snprintf(&lockdata[2], 10, "nano %s", VERSION);
|
||||
/* It's fine to overwrite byte 12 with the \0 as it is 0x00 anyway. */
|
||||
snprintf(&lockdata[2], 11, "nano %s", VERSION);
|
||||
lockdata[24] = mypid % 256;
|
||||
lockdata[25] = (mypid / 256) % 256;
|
||||
lockdata[26] = (mypid / (256 * 256)) % 256;
|
||||
@@ -241,9 +245,11 @@ char *do_lockfile(const char *filename, bool ask_the_user)
|
||||
free(secondcopy);
|
||||
free(namecopy);
|
||||
|
||||
if (!ask_the_user && stat(lockfilename, &fileinfo) != -1)
|
||||
warn_and_briefly_pause(_("Someone else is also editing this file"));
|
||||
else if (stat(lockfilename, &fileinfo) != -1) {
|
||||
if (!ask_the_user && stat(lockfilename, &fileinfo) != -1) {
|
||||
blank_bottombars();
|
||||
statusline(ALERT, _("Someone else is also editing this file"));
|
||||
napms(1200);
|
||||
} else if (stat(lockfilename, &fileinfo) != -1) {
|
||||
char *lockbuf, *question, *pidstring, *postedname, *promptstr;
|
||||
static char lockprog[11], lockuser[17];
|
||||
int lockfd, lockpid, choice;
|
||||
@@ -370,9 +376,6 @@ bool open_buffer(const char *filename, bool new_one)
|
||||
{
|
||||
char *realname;
|
||||
/* The filename after tilde expansion. */
|
||||
#ifndef NANO_TINY
|
||||
char *thelocksname = NULL;
|
||||
#endif
|
||||
struct stat fileinfo;
|
||||
int descriptor = 0;
|
||||
/* Code 0 means new file, -1 means failure, and else it's the fd. */
|
||||
@@ -417,23 +420,28 @@ bool open_buffer(const char *filename, bool new_one)
|
||||
|
||||
/* When loading into a new buffer, first check the file's path is valid,
|
||||
* and then (if requested and possible) create a lock file for it. */
|
||||
if (new_one && has_valid_path(realname)) {
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(LOCKING) && !ISSET(VIEW_MODE) && filename[0] != '\0') {
|
||||
thelocksname = do_lockfile(realname, TRUE);
|
||||
|
||||
/* When not overriding an existing lock, don't open a buffer. */
|
||||
if (thelocksname == SKIPTHISFILE) {
|
||||
free(realname);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (new_one)
|
||||
if (new_one) {
|
||||
make_new_buffer();
|
||||
|
||||
if (has_valid_path(realname)) {
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(LOCKING) && !ISSET(VIEW_MODE) && filename[0] != '\0') {
|
||||
char *thelocksname = do_lockfile(realname, TRUE);
|
||||
|
||||
/* When not overriding an existing lock, discard the buffer. */
|
||||
if (thelocksname == SKIPTHISFILE) {
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
close_buffer();
|
||||
#endif
|
||||
free(realname);
|
||||
return FALSE;
|
||||
} else
|
||||
openfile->lock_filename = thelocksname;
|
||||
}
|
||||
#endif /* NANO_TINY */
|
||||
}
|
||||
}
|
||||
|
||||
/* If we have a filename and are not in NOREAD mode, open the file. */
|
||||
if (filename[0] != '\0' && !ISSET(NOREAD_MODE))
|
||||
descriptor = open_file(realname, new_one, &f);
|
||||
@@ -452,13 +460,9 @@ bool open_buffer(const char *filename, bool new_one)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* When we've loaded a file into a new buffer, set the filename
|
||||
* and put the cursor at the start of the buffer. */
|
||||
/* For a new buffer, store filename and put cursor at start of buffer. */
|
||||
if (descriptor >= 0 && new_one) {
|
||||
openfile->filename = mallocstrcpy(openfile->filename, realname);
|
||||
#ifndef NANO_TINY
|
||||
openfile->lock_filename = thelocksname;
|
||||
#endif
|
||||
openfile->current = openfile->filetop;
|
||||
openfile->current_x = 0;
|
||||
openfile->placewewant = 0;
|
||||
@@ -469,12 +473,13 @@ bool open_buffer(const char *filename, bool new_one)
|
||||
if (new_one)
|
||||
find_and_prime_applicable_syntax();
|
||||
#endif
|
||||
|
||||
free(realname);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Mark the current file as modified if it isn't already, and
|
||||
* then update the title bar to display the file's new status. */
|
||||
/* Mark the current buffer as modified if it isn't already, and
|
||||
* then update the title bar to display the buffer's new status. */
|
||||
void set_modified(void)
|
||||
{
|
||||
if (openfile->modified)
|
||||
@@ -498,7 +503,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;
|
||||
@@ -517,7 +523,7 @@ void mention_name_and_linecount(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (openfile->fmt != NIX_FILE)
|
||||
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),
|
||||
openfile->filename[0] == '\0' ?
|
||||
@@ -540,10 +546,8 @@ void redecorate_after_switch(void)
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* While in a different buffer, the effective width of the screen may
|
||||
* have changed, so make sure that the softwrapped chunks per line and
|
||||
* the starting column for the first row get corresponding values. */
|
||||
compute_the_extra_rows_per_line_from(openfile->filetop);
|
||||
/* While in a different buffer, the width of the screen may have changed,
|
||||
* so make sure that the starting column for the first row is fitting. */
|
||||
ensure_firstcolumn_is_aligned();
|
||||
#endif
|
||||
|
||||
@@ -556,18 +560,23 @@ void redecorate_after_switch(void)
|
||||
/* Prevent a possible Shift selection from getting cancelled. */
|
||||
shift_held = TRUE;
|
||||
|
||||
if (openfile->errormessage) {
|
||||
statusline(ALERT, openfile->errormessage);
|
||||
free(openfile->errormessage);
|
||||
openfile->errormessage = NULL;
|
||||
} else
|
||||
/* Indicate on the status bar where we switched to. */
|
||||
mention_name_and_linecount();
|
||||
}
|
||||
|
||||
/* Switch to the previous entry in the list of open files. */
|
||||
/* Switch to the previous entry in the circular list of buffers. */
|
||||
void switch_to_prev_buffer(void)
|
||||
{
|
||||
openfile = openfile->prev;
|
||||
redecorate_after_switch();
|
||||
}
|
||||
|
||||
/* Switch to the next entry in the list of open files. */
|
||||
/* Switch to the next entry in the circular list of buffers. */
|
||||
void switch_to_next_buffer(void)
|
||||
{
|
||||
openfile = openfile->next;
|
||||
@@ -593,12 +602,16 @@ void close_buffer(void)
|
||||
/* Free the undo stack. */
|
||||
discard_until(NULL);
|
||||
#endif
|
||||
free(orphan->errormessage);
|
||||
|
||||
openfile = orphan->prev;
|
||||
if (openfile == orphan)
|
||||
openfile = NULL;
|
||||
|
||||
free(orphan);
|
||||
|
||||
/* When just one buffer remains open, show "Exit" in the help lines. */
|
||||
if (openfile == openfile->next)
|
||||
if (openfile && openfile == openfile->next)
|
||||
exitfunc->desc = exit_tag;
|
||||
}
|
||||
#endif /* ENABLE_MULTIBUFFER */
|
||||
@@ -644,11 +657,9 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||
bool writable = TRUE;
|
||||
/* Whether the file is writable (in case we care). */
|
||||
#ifndef NANO_TINY
|
||||
int format = 0;
|
||||
/* 0 = Unix, 1 = DOS, 2 = Mac. */
|
||||
#endif
|
||||
format_type format = NIX_FILE;
|
||||
/* The type of line ending the file uses: Unix, DOS, or Mac. */
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (undoable)
|
||||
add_undo(INSERT, NULL);
|
||||
|
||||
@@ -677,20 +688,20 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||
if (control_C_was_pressed)
|
||||
break;
|
||||
|
||||
/* When the byte before the current one is a CR and we're doing
|
||||
* format conversion, then strip this CR when it's before a LF
|
||||
* OR when the file is in Mac format. Also, when still on the
|
||||
* first line, set the format to either DOS (1) or Mac (2). */
|
||||
/* When the byte before the current one is a CR and automatic format
|
||||
* conversion has not been switched off, then strip this CR when it's
|
||||
* before a LF OR when the file is in Mac format. Also, when this is
|
||||
* the first line break, make a note of the format. */
|
||||
if (input == '\n') {
|
||||
#ifndef NANO_TINY
|
||||
if (len > 0 && buf[len - 1] == '\r' && !ISSET(NO_CONVERT)) {
|
||||
if (num_lines == 0)
|
||||
format = 1;
|
||||
format = DOS_FILE;
|
||||
len--;
|
||||
}
|
||||
} else if ((num_lines == 0 || format == 2) &&
|
||||
} else if ((num_lines == 0 || format == MAC_FILE) &&
|
||||
len > 0 && buf[len - 1] == '\r' && !ISSET(NO_CONVERT)) {
|
||||
format = 2;
|
||||
format = MAC_FILE;
|
||||
len--;
|
||||
#endif
|
||||
} else {
|
||||
@@ -757,7 +768,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||
if (fd > 0 && !undoable && !ISSET(VIEW_MODE))
|
||||
writable = (access(filename, W_OK) == 0);
|
||||
|
||||
/* If the file ended with newline, or it was entirely empty, make the
|
||||
/* If the file ended with a newline, or it was entirely empty, make the
|
||||
* last line blank. Otherwise, put the last read data in. */
|
||||
if (len == 0)
|
||||
bottomline->data = copy_of("");
|
||||
@@ -769,7 +780,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||
* strip this CR and indicate that an extra blank line is needed. */
|
||||
if (buf[len - 1] == '\r' && !ISSET(NO_CONVERT)) {
|
||||
if (num_lines == 0)
|
||||
format = 2;
|
||||
format = MAC_FILE;
|
||||
buf[--len] = '\0';
|
||||
mac_line_needs_newline = TRUE;
|
||||
}
|
||||
@@ -798,18 +809,15 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||
if (!writable)
|
||||
statusline(ALERT, _("File '%s' is unwritable"), filename);
|
||||
#ifndef NANO_TINY
|
||||
else if (format == 2) {
|
||||
else if (format == MAC_FILE)
|
||||
/* TRANSLATORS: Keep the next three messages at most 78 characters. */
|
||||
openfile->fmt = MAC_FILE;
|
||||
statusline(HUSH, P_("Read %zu line (Converted from Mac format)",
|
||||
"Read %zu lines (Converted from Mac format)",
|
||||
num_lines), num_lines);
|
||||
} else if (format == 1) {
|
||||
openfile->fmt = DOS_FILE;
|
||||
else if (format == DOS_FILE)
|
||||
statusline(HUSH, P_("Read %zu line (Converted from DOS format)",
|
||||
"Read %zu lines (Converted from DOS format)",
|
||||
num_lines), num_lines);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
statusline(HUSH, P_("Read %zu line", "Read %zu lines",
|
||||
@@ -818,6 +826,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)
|
||||
@@ -825,6 +837,8 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||
|
||||
if (ISSET(MAKE_IT_UNIX))
|
||||
openfile->fmt = NIX_FILE;
|
||||
else if (openfile->fmt == UNSPECIFIED)
|
||||
openfile->fmt = format;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -959,10 +973,10 @@ bool execute_command(const char *command)
|
||||
{
|
||||
int from_fd[2], to_fd[2];
|
||||
/* The pipes through which text will be written and read. */
|
||||
const bool should_pipe = (command[0] == '|');
|
||||
FILE *stream;
|
||||
struct sigaction oldaction, newaction = {{0}};
|
||||
/* Original and temporary handlers for SIGINT. */
|
||||
const bool should_pipe = (command[0] == '|');
|
||||
FILE *stream;
|
||||
|
||||
/* Create a pipe to read the command's output from, and, if needed,
|
||||
* a pipe to feed the command's input through. */
|
||||
@@ -1104,9 +1118,6 @@ void do_insertfile(bool execute)
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
bool was_multibuffer = ISSET(MULTIBUFFER);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
format_type was_fmt = openfile->fmt;
|
||||
#endif
|
||||
|
||||
/* Display newlines in filenames as ^J. */
|
||||
as_an_at = FALSE;
|
||||
@@ -1272,14 +1283,11 @@ void do_insertfile(bool execute)
|
||||
} else
|
||||
#endif /* ENABLE_MULTIBUFFER */
|
||||
{
|
||||
/* If the file actually changed, mark it as modified. */
|
||||
/* If the buffer actually changed, mark it as modified. */
|
||||
if (openfile->current->lineno != was_current_lineno ||
|
||||
openfile->current_x != was_current_x)
|
||||
openfile->current_x != was_current_x)
|
||||
set_modified();
|
||||
#ifndef NANO_TINY
|
||||
/* Ensure that the buffer retains the format that it had. */
|
||||
openfile->fmt = was_fmt;
|
||||
#endif
|
||||
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
@@ -1351,7 +1359,7 @@ char *get_full_path(const char *origpath)
|
||||
target = real_dir_from_tilde(origpath);
|
||||
|
||||
/* Determine whether the target path refers to a directory. If statting
|
||||
* target fails, however, assume that it refers to a new, unsaved file. */
|
||||
* target fails, however, assume that it refers to a new, unsaved buffer. */
|
||||
path_only = (stat(target, &fileinfo) != -1 && S_ISDIR(fileinfo.st_mode));
|
||||
|
||||
/* If the target is a directory, make sure its path ends in a slash. */
|
||||
@@ -1445,7 +1453,8 @@ char *safe_tempfile(FILE **stream)
|
||||
{
|
||||
const char *env_dir = getenv("TMPDIR");
|
||||
char *tempdir = NULL, *tempfile_name = NULL;
|
||||
int fd;
|
||||
char *extension;
|
||||
int descriptor;
|
||||
|
||||
/* Get the absolute path for the first directory among $TMPDIR
|
||||
* and P_tmpdir that is writable, otherwise use /tmp/. */
|
||||
@@ -1458,18 +1467,26 @@ char *safe_tempfile(FILE **stream)
|
||||
if (tempdir == NULL)
|
||||
tempdir = copy_of("/tmp/");
|
||||
|
||||
tempfile_name = nrealloc(tempdir, strlen(tempdir) + 12);
|
||||
extension = strrchr(openfile->filename, '.');
|
||||
|
||||
if (!extension || strchr(extension, '/'))
|
||||
extension = openfile->filename + strlen(openfile->filename);
|
||||
|
||||
tempfile_name = nrealloc(tempdir, strlen(tempdir) + 12 + strlen(extension));
|
||||
strcat(tempfile_name, "nano.XXXXXX");
|
||||
strcat(tempfile_name, extension);
|
||||
|
||||
fd = mkstemp(tempfile_name);
|
||||
descriptor = mkstemps(tempfile_name, strlen(extension));
|
||||
|
||||
if (fd == -1) {
|
||||
*stream = (descriptor > 0) ? fdopen(descriptor, "r+b") : NULL;
|
||||
|
||||
if (*stream == NULL) {
|
||||
if (descriptor > 0)
|
||||
close(descriptor);
|
||||
free(tempfile_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*stream = fdopen(fd, "r+b");
|
||||
|
||||
return tempfile_name;
|
||||
}
|
||||
|
||||
@@ -1729,19 +1746,19 @@ bool make_backup_of(char *realname)
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Write the current buffer to disk. If thefile isn't NULL, we write to a
|
||||
* temporary file that is already open. If tmp is TRUE (when spell checking
|
||||
* or emergency dumping, for example), we don't make a backup and don't give
|
||||
* temporary file that is already open. If normal is FALSE (for a spellcheck
|
||||
* or an emergency save, for example), we don't make a backup and don't give
|
||||
* feedback. If method is APPEND or PREPEND, it means we will be appending
|
||||
* or prepending instead of overwriting the given file. If fullbuffer is TRUE
|
||||
* and when writing normally, we set the current filename and stat info.
|
||||
* or prepending instead of overwriting the given file. If annotate is TRUE
|
||||
* and when writing a normal file, we set the current filename and stat info.
|
||||
* Return TRUE on success, and FALSE otherwise. */
|
||||
bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
kind_of_writing_type method, bool fullbuffer)
|
||||
bool write_file(const char *name, FILE *thefile, bool normal,
|
||||
kind_of_writing_type method, bool annotate)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
bool is_existing_file;
|
||||
/* Becomes TRUE when the file is non-temporary and exists. */
|
||||
struct stat st;
|
||||
struct stat fileinfo;
|
||||
/* The status fields filled in by statting the file. */
|
||||
#endif
|
||||
char *realname = real_dir_from_tilde(name);
|
||||
@@ -1752,20 +1769,18 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
/* An iterator for moving through the lines of the buffer. */
|
||||
size_t lineswritten = 0;
|
||||
/* The number of lines written, for feedback on the status bar. */
|
||||
bool retval = FALSE;
|
||||
/* The return value, to become TRUE when writing has succeeded. */
|
||||
|
||||
#ifdef ENABLE_OPERATINGDIR
|
||||
/* If we're writing a temporary file, we're probably going outside
|
||||
* the operating directory, so skip the operating directory test. */
|
||||
if (!tmp && outside_of_confinement(realname, FALSE)) {
|
||||
if (normal && outside_of_confinement(realname, FALSE)) {
|
||||
statusline(ALERT, _("Can't write outside of %s"), operating_dir);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
/* Check whether the file (at the end of the symlink) exists. */
|
||||
is_existing_file = (!tmp) && (stat(realname, &st) != -1);
|
||||
is_existing_file = normal && (stat(realname, &fileinfo) != -1);
|
||||
|
||||
/* If we haven't statted this file before (say, the user just specified
|
||||
* it interactively), stat and save the value now, or else we will chase
|
||||
@@ -1776,8 +1791,9 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
/* When the user requested a backup, we do this only if the file exists and
|
||||
* isn't temporary AND the file has not been modified by someone else since
|
||||
* we opened it (or we are appending/prepending or writing a selection). */
|
||||
if (ISSET(MAKE_BACKUP) && is_existing_file && openfile->statinfo &&
|
||||
(openfile->statinfo->st_mtime == st.st_mtime ||
|
||||
if (ISSET(MAKE_BACKUP) && is_existing_file && !S_ISFIFO(fileinfo.st_mode) &&
|
||||
openfile->statinfo &&
|
||||
(openfile->statinfo->st_mtime == fileinfo.st_mtime ||
|
||||
method != OVERWRITE || openfile->mark)) {
|
||||
if (!make_backup_of(realname))
|
||||
goto cleanup_and_exit;
|
||||
@@ -1785,10 +1801,17 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
|
||||
/* When prepending, first copy the existing file to a temporary file. */
|
||||
if (method == PREPEND) {
|
||||
FILE *source = fopen(realname, "rb");
|
||||
FILE *source = NULL;
|
||||
FILE *target = NULL;
|
||||
int verdict;
|
||||
|
||||
if (is_existing_file && S_ISFIFO(fileinfo.st_mode)) {
|
||||
statusline(ALERT, _("Error writing %s: %s"), realname, "FIFO");
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
source = fopen(realname, "rb");
|
||||
|
||||
if (source == NULL) {
|
||||
statusline(ALERT, _("Error reading %s: %s"), realname, strerror(errno));
|
||||
goto cleanup_and_exit;
|
||||
@@ -1815,27 +1838,29 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
}
|
||||
}
|
||||
|
||||
if (is_existing_file && S_ISFIFO(st.st_mode))
|
||||
if (is_existing_file && S_ISFIFO(fileinfo.st_mode))
|
||||
statusbar(_("Writing to FIFO..."));
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* When it's not a temporary file, this is where we open or create it.
|
||||
* For an emergency file, access is restricted to just the owner. */
|
||||
if (thefile == NULL) {
|
||||
mode_t permissions = (tmp ? S_IRUSR|S_IWUSR : RW_FOR_ALL);
|
||||
mode_t permissions = (normal ? RW_FOR_ALL : S_IRUSR|S_IWUSR);
|
||||
int fd;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
block_sigwinch(TRUE);
|
||||
install_handler_for_Ctrl_C();
|
||||
if (normal)
|
||||
install_handler_for_Ctrl_C();
|
||||
#endif
|
||||
|
||||
/* Now open the file. Use O_EXCL for an emergency file. */
|
||||
fd = open(realname, O_WRONLY | O_CREAT | ((method == APPEND) ?
|
||||
O_APPEND : (tmp ? O_EXCL : O_TRUNC)), permissions);
|
||||
O_APPEND : (normal ? O_TRUNC : O_EXCL)), permissions);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
restore_handler_for_Ctrl_C();
|
||||
if (normal)
|
||||
restore_handler_for_Ctrl_C();
|
||||
block_sigwinch(FALSE);
|
||||
#endif
|
||||
|
||||
@@ -1861,7 +1886,7 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
}
|
||||
}
|
||||
|
||||
if (!tmp)
|
||||
if (normal)
|
||||
statusbar(_("Writing..."));
|
||||
|
||||
while (TRUE) {
|
||||
@@ -1938,22 +1963,27 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
|
||||
unlink(tempname);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Ensure the data has reached the disk before reporting it as written. */
|
||||
if (fflush(thefile) != 0 || fsync(fileno(thefile)) != 0) {
|
||||
statusline(ALERT, _("Error writing %s: %s"), realname, strerror(errno));
|
||||
fclose(thefile);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
if (!is_existing_file || !S_ISFIFO(fileinfo.st_mode))
|
||||
/* Ensure the data has reached the disk before reporting it as written. */
|
||||
if (fflush(thefile) != 0 || fsync(fileno(thefile)) != 0) {
|
||||
statusline(ALERT, _("Error writing %s: %s"), realname, strerror(errno));
|
||||
fclose(thefile);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fclose(thefile) != 0) {
|
||||
statusline(ALERT, _("Error writing %s: %s"), realname, strerror(errno));
|
||||
goto cleanup_and_exit;
|
||||
|
||||
cleanup_and_exit:
|
||||
free(tempname);
|
||||
free(realname);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* When having written an entire buffer, update some administrivia. */
|
||||
if (fullbuffer && method == OVERWRITE && !tmp) {
|
||||
if (annotate && method == OVERWRITE) {
|
||||
/* If the filename was changed, write a new lockfile when needed,
|
||||
* and check whether it means a different syntax gets used. */
|
||||
if (strcmp(openfile->filename, realname) != 0) {
|
||||
@@ -1961,8 +1991,10 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
if (openfile->lock_filename != NULL) {
|
||||
delete_lockfile(openfile->lock_filename);
|
||||
free(openfile->lock_filename);
|
||||
openfile->lock_filename = do_lockfile(realname, FALSE);
|
||||
}
|
||||
|
||||
if (ISSET(LOCKING))
|
||||
openfile->lock_filename = do_lockfile(realname, FALSE);
|
||||
#endif
|
||||
openfile->filename = mallocstrcpy(openfile->filename, realname);
|
||||
#ifdef ENABLE_COLOR
|
||||
@@ -1989,7 +2021,7 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
/* Get or update the stat info to reflect the current state. */
|
||||
stat_with_alloc(realname, &openfile->statinfo);
|
||||
|
||||
/* Record at which point in the undo stack the file was saved. */
|
||||
/* Record at which point in the undo stack the buffer was saved. */
|
||||
openfile->last_saved = openfile->current_undo;
|
||||
openfile->last_action = OTHER;
|
||||
#endif
|
||||
@@ -1998,26 +2030,24 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(MINIBAR) && fullbuffer && !tmp)
|
||||
if (ISSET(MINIBAR) && LINES > 1 && annotate)
|
||||
report_size = TRUE;
|
||||
else
|
||||
#endif
|
||||
if (!tmp)
|
||||
if (normal)
|
||||
statusline(REMARK, P_("Wrote %zu line", "Wrote %zu lines",
|
||||
lineswritten), lineswritten);
|
||||
retval = TRUE;
|
||||
|
||||
cleanup_and_exit:
|
||||
free(tempname);
|
||||
free(realname);
|
||||
|
||||
return retval;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Write the marked region of the current buffer out to disk.
|
||||
* Return TRUE on success and FALSE on error. */
|
||||
bool write_marked_file(const char *name, FILE *stream, bool tmp,
|
||||
bool write_region_to_file(const char *name, FILE *stream, bool normal,
|
||||
kind_of_writing_type method)
|
||||
{
|
||||
linestruct *birthline, *topline, *botline, *stopper, *afterline;
|
||||
@@ -2044,7 +2074,7 @@ bool write_marked_file(const char *name, FILE *stream, bool tmp,
|
||||
birthline = openfile->filetop;
|
||||
openfile->filetop = topline;
|
||||
|
||||
retval = write_file(name, stream, tmp, method, FALSE);
|
||||
retval = write_file(name, stream, normal, method, NONOTES);
|
||||
|
||||
/* Restore the proper state of the buffer. */
|
||||
openfile->filetop = birthline;
|
||||
@@ -2059,18 +2089,18 @@ bool write_marked_file(const char *name, FILE *stream, bool tmp,
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Write the current file to disk. If the mark is on, write the current
|
||||
* marked selection to disk. If exiting is TRUE, write the entire file
|
||||
/* Write the current buffer to disk. If the mark is on, write the current
|
||||
* marked selection to disk. If exiting is TRUE, write the entire buffer
|
||||
* to disk regardless of whether the mark is on. Do not ask for a name
|
||||
* when withprompt is FALSE nor when the SAVE_ON_EXIT flag is set and the
|
||||
* file already has a name. Return 0 on error, 1 on success, and 2 when
|
||||
* buffer already has a name. Return 0 on error, 1 on success, and 2 when
|
||||
* the buffer is to be discarded. */
|
||||
int do_writeout(bool exiting, bool withprompt)
|
||||
{
|
||||
char *given;
|
||||
/* The filename we offer, or what the user typed so far. */
|
||||
bool maychange = (openfile->filename[0] == '\0');
|
||||
/* Whether it's okay to save the file under a different name. */
|
||||
/* Whether it's okay to save the buffer under a different name. */
|
||||
kind_of_writing_type method = OVERWRITE;
|
||||
#ifdef ENABLE_EXTRA
|
||||
static bool did_credits = FALSE;
|
||||
@@ -2195,12 +2225,12 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
if (method == OVERWRITE) {
|
||||
bool name_exists, do_warning;
|
||||
char *full_answer, *full_filename;
|
||||
struct stat st;
|
||||
struct stat fileinfo;
|
||||
|
||||
full_answer = get_full_path(answer);
|
||||
full_filename = get_full_path(openfile->filename);
|
||||
name_exists = (stat((full_answer == NULL) ?
|
||||
answer : full_answer, &st) != -1);
|
||||
answer : full_answer, &fileinfo) != -1);
|
||||
|
||||
if (openfile->filename[0] == '\0')
|
||||
do_warning = name_exists;
|
||||
@@ -2215,11 +2245,10 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
if (do_warning) {
|
||||
/* When in restricted mode, we aren't allowed to overwrite
|
||||
* an existing file with the current buffer, nor to change
|
||||
* the name of the current file if it already has one. */
|
||||
* the name of the current buffer if it already has one. */
|
||||
if (ISSET(RESTRICTED)) {
|
||||
/* TRANSLATORS: Restricted mode forbids overwriting. */
|
||||
warn_and_briefly_pause(_("File exists -- "
|
||||
"cannot overwrite"));
|
||||
warn_and_briefly_pause(_("File exists -- cannot overwrite"));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2256,9 +2285,9 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
* and the stat information we had before does not match
|
||||
* what we have now. */
|
||||
else if (name_exists && openfile->statinfo &&
|
||||
(openfile->statinfo->st_mtime < st.st_mtime ||
|
||||
openfile->statinfo->st_dev != st.st_dev ||
|
||||
openfile->statinfo->st_ino != st.st_ino)) {
|
||||
(openfile->statinfo->st_mtime < fileinfo.st_mtime ||
|
||||
openfile->statinfo->st_dev != fileinfo.st_dev ||
|
||||
openfile->statinfo->st_ino != fileinfo.st_ino)) {
|
||||
|
||||
warn_and_briefly_pause(_("File on disk has changed"));
|
||||
|
||||
@@ -2273,7 +2302,7 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
free(given);
|
||||
if (choice == 1)
|
||||
return write_file(openfile->filename, NULL,
|
||||
FALSE, OVERWRITE, TRUE);
|
||||
NORMAL, OVERWRITE, NONOTES);
|
||||
else if (choice == 0)
|
||||
return 2;
|
||||
else
|
||||
@@ -2295,10 +2324,10 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
* the marked region; otherwise, write out the whole buffer. */
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->mark && withprompt && !exiting && !ISSET(RESTRICTED))
|
||||
return write_marked_file(answer, NULL, FALSE, method);
|
||||
return write_region_to_file(answer, NULL, NORMAL, method);
|
||||
else
|
||||
#endif
|
||||
return write_file(answer, NULL, FALSE, method, TRUE);
|
||||
return write_file(answer, NULL, NORMAL, method, ANNOTATE);
|
||||
}
|
||||
|
||||
/* Write the current buffer to disk, or discard it. */
|
||||
@@ -2309,7 +2338,7 @@ void do_writeout_void(void)
|
||||
close_and_go();
|
||||
}
|
||||
|
||||
/* If it has a name, write the current file to disk without prompting. */
|
||||
/* If it has a name, write the current buffer to disk without prompting. */
|
||||
void do_savefile(void)
|
||||
{
|
||||
if (do_writeout(FALSE, FALSE) == 2)
|
||||
|
||||
64
src/global.c
64
src/global.c
@@ -301,12 +301,6 @@ void flip_goto(void)
|
||||
void to_files(void)
|
||||
{
|
||||
}
|
||||
void to_first_file(void)
|
||||
{
|
||||
}
|
||||
void to_last_file(void)
|
||||
{
|
||||
}
|
||||
void goto_dir(void)
|
||||
{
|
||||
}
|
||||
@@ -384,7 +378,7 @@ int keycode_from_string(const char *keystring)
|
||||
{
|
||||
if (keystring[0] == '^') {
|
||||
if (keystring[2] == '\0') {
|
||||
if (keystring[1] == '/')
|
||||
if (keystring[1] == '/' || keystring[1] == '-')
|
||||
return 31;
|
||||
if (keystring[1] <= '_')
|
||||
return keystring[1] - 64;
|
||||
@@ -776,7 +770,7 @@ void shortcut_init(void)
|
||||
CAN_OPEN_OTHER_BUFFER);
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
else
|
||||
add_to_funcs(do_justify_void, MMAIN,
|
||||
add_to_funcs(do_justify, MMAIN,
|
||||
N_("Justify"), WITHORSANS(justify_gist), BLANKAFTER, NOVIEW);
|
||||
#endif
|
||||
|
||||
@@ -815,7 +809,7 @@ void shortcut_init(void)
|
||||
N_("Execute"), WITHORSANS(execute_gist), TOGETHER, NOVIEW);
|
||||
#endif
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
add_to_funcs(do_justify_void, MMAIN,
|
||||
add_to_funcs(do_justify, MMAIN,
|
||||
N_("Justify"), WITHORSANS(justify_gist), BLANKAFTER, NOVIEW);
|
||||
#endif
|
||||
}
|
||||
@@ -841,7 +835,7 @@ void shortcut_init(void)
|
||||
add_to_funcs(do_mark, MMAIN,
|
||||
N_("Set Mark"), WITHORSANS(mark_gist), TOGETHER, VIEW);
|
||||
add_to_funcs(copy_text, MMAIN,
|
||||
N_("Copy"), WITHORSANS(copy_gist), BLANKAFTER, NOVIEW);
|
||||
N_("Copy"), WITHORSANS(copy_gist), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(case_sens_void, MWHEREIS|MREPLACE,
|
||||
@@ -1192,6 +1186,12 @@ void shortcut_init(void)
|
||||
N_("Next Linter message"), WITHORSANS(nextlint_gist), TOGETHER, VIEW);
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#define SLASH_OR_DASH (on_a_vt) ? "^-" : "^/"
|
||||
#else
|
||||
#define SLASH_OR_DASH "^/"
|
||||
#endif
|
||||
|
||||
/* Link key combos to functions in certain menus. */
|
||||
add_to_sclist(MMOST|MBROWSER, "^M", '\r', do_enter, 0);
|
||||
add_to_sclist(MMOST|MBROWSER, "Enter", KEY_ENTER, do_enter, 0);
|
||||
@@ -1220,7 +1220,7 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN, "^T", 0, do_execute, 0);
|
||||
#endif
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
add_to_sclist(MMAIN, "^J", '\n', do_justify_void, 0);
|
||||
add_to_sclist(MMAIN, "^J", '\n', do_justify, 0);
|
||||
#endif
|
||||
#ifdef ENABLE_SPELLER
|
||||
add_to_sclist(MEXECUTE, "^S", 0, do_spell, 0);
|
||||
@@ -1233,8 +1233,9 @@ void shortcut_init(void)
|
||||
add_to_sclist(MEXECUTE, "^O", 0, do_formatter, 0);
|
||||
#endif
|
||||
add_to_sclist(MMAIN, "^C", 0, report_cursor_position, 0);
|
||||
add_to_sclist(MMAIN, "^_", 0, do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN, SLASH_OR_DASH, 0, do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN, "M-G", 0, do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN, "^_", 0, do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "^Y", 0, do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "PgUp", KEY_PPAGE, do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "^V", 0, do_page_down, 0);
|
||||
@@ -1286,14 +1287,14 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMOST|MBROWSER, "^F", 0, do_right, 0);
|
||||
#ifdef ENABLE_UTF8
|
||||
if (using_utf8()) {
|
||||
add_to_sclist(MMOST|MBROWSER|MHELP, "\xE2\x97\x80", KEY_LEFT, do_left, 0);
|
||||
add_to_sclist(MMOST|MBROWSER|MHELP, "\xE2\x96\xb6", KEY_RIGHT, do_right, 0);
|
||||
add_to_sclist(MSOME, "^\xE2\x97\x80", CONTROL_LEFT, to_prev_word, 0);
|
||||
add_to_sclist(MSOME, "^\xE2\x96\xb6", CONTROL_RIGHT, to_next_word, 0);
|
||||
add_to_sclist(MMOST|MBROWSER|MHELP, "\xE2\x97\x82", KEY_LEFT, do_left, 0);
|
||||
add_to_sclist(MMOST|MBROWSER|MHELP, "\xE2\x96\xb8", KEY_RIGHT, do_right, 0);
|
||||
add_to_sclist(MSOME, "^\xE2\x97\x82", CONTROL_LEFT, to_prev_word, 0);
|
||||
add_to_sclist(MSOME, "^\xE2\x96\xb8", CONTROL_RIGHT, to_next_word, 0);
|
||||
#if !defined(NANO_TINY) && defined(ENABLE_MULTIBUFFER)
|
||||
if (!on_a_vt) {
|
||||
add_to_sclist(MMAIN, "M-\xE2\x97\x80", ALT_LEFT, switch_to_prev_buffer, 0);
|
||||
add_to_sclist(MMAIN, "M-\xE2\x96\xb6", ALT_RIGHT, switch_to_next_buffer, 0);
|
||||
add_to_sclist(MMAIN, "M-\xE2\x97\x82", ALT_LEFT, switch_to_prev_buffer, 0);
|
||||
add_to_sclist(MMAIN, "M-\xE2\x96\xb8", ALT_RIGHT, switch_to_next_buffer, 0);
|
||||
}
|
||||
#endif
|
||||
} else
|
||||
@@ -1320,10 +1321,10 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "^N", 0, do_down, 0);
|
||||
#ifdef ENABLE_UTF8
|
||||
if (using_utf8()) {
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "\xE2\x96\xb2", KEY_UP, do_up, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "\xE2\x96\xbc", KEY_DOWN, do_down, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MLINTER, "^\xE2\x96\xb2", CONTROL_UP, to_prev_block, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MLINTER, "^\xE2\x96\xbc", CONTROL_DOWN, to_next_block, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "\xE2\x96\xb4", KEY_UP, do_up, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "\xE2\x96\xbe", KEY_DOWN, do_down, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MLINTER, "^\xE2\x96\xb4", CONTROL_UP, to_prev_block, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MLINTER, "^\xE2\x96\xbe", CONTROL_DOWN, to_next_block, 0);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
@@ -1343,8 +1344,8 @@ void shortcut_init(void)
|
||||
#ifndef NANO_TINY
|
||||
#ifdef ENABLE_UTF8
|
||||
if (using_utf8()) {
|
||||
add_to_sclist(MMAIN|MHELP, "M-\xE2\x96\xb2", ALT_UP, do_scroll_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-\xE2\x96\xbc", ALT_DOWN, do_scroll_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-\xE2\x96\xb4", ALT_UP, do_scroll_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-\xE2\x96\xbe", ALT_DOWN, do_scroll_down, 0);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
@@ -1428,8 +1429,8 @@ void shortcut_init(void)
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "^N", 0, get_history_newer_void, 0);
|
||||
#ifdef ENABLE_UTF8
|
||||
if (using_utf8()) {
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\xb2", KEY_UP, get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\xbc", KEY_DOWN, get_history_newer_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\xb4", KEY_UP, get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\xbe", KEY_DOWN, get_history_newer_void, 0);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
@@ -1441,11 +1442,9 @@ void shortcut_init(void)
|
||||
add_to_sclist(MGOTOLINE, "^W", 0, to_para_begin, 0);
|
||||
add_to_sclist(MGOTOLINE, "^O", 0, to_para_end, 0);
|
||||
#endif
|
||||
add_to_sclist(MGOTOLINE, "^Y", 0, to_first_line, 0);
|
||||
add_to_sclist(MGOTOLINE, "^V", 0, to_last_line, 0);
|
||||
/* Some people are used to having these keystrokes in the Search menu. */
|
||||
add_to_sclist(MWHEREIS, "^Y", 0, to_first_line, 0);
|
||||
add_to_sclist(MWHEREIS, "^V", 0, to_last_line, 0);
|
||||
add_to_sclist(MGOTOLINE|MWHEREIS|MFINDINHELP, "^Y", 0, to_first_line, 0);
|
||||
add_to_sclist(MGOTOLINE|MWHEREIS|MFINDINHELP, "^V", 0, to_last_line, 0);
|
||||
#ifdef ENABLE_BROWSER
|
||||
add_to_sclist(MWHEREISFILE, "^Y", 0, to_first_file, 0);
|
||||
add_to_sclist(MWHEREISFILE, "^V", 0, to_last_file, 0);
|
||||
@@ -1455,8 +1454,9 @@ void shortcut_init(void)
|
||||
add_to_sclist(MBROWSER, "End", KEY_END, to_last_file, 0);
|
||||
add_to_sclist(MBROWSER, "^Home", CONTROL_HOME, to_first_file, 0);
|
||||
add_to_sclist(MBROWSER, "^End", CONTROL_END, to_last_file, 0);
|
||||
add_to_sclist(MBROWSER, "^_", 0, goto_dir, 0);
|
||||
add_to_sclist(MBROWSER, SLASH_OR_DASH, 0, goto_dir, 0);
|
||||
add_to_sclist(MBROWSER, "M-G", 0, goto_dir, 0);
|
||||
add_to_sclist(MBROWSER, "^_", 0, goto_dir, 0);
|
||||
#endif
|
||||
if (ISSET(SAVE_ON_EXIT) && !ISSET(PRESERVE))
|
||||
add_to_sclist(MWRITEFILE, "^Q", 0, discard_buffer, 0);
|
||||
@@ -1506,7 +1506,7 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "F2", KEY_F(2), do_exit, 0);
|
||||
add_to_sclist(MMAIN, "F3", KEY_F(3), do_writeout_void, 0);
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
add_to_sclist(MMAIN, "F4", KEY_F(4), do_justify_void, 0);
|
||||
add_to_sclist(MMAIN, "F4", KEY_F(4), do_justify, 0);
|
||||
#endif
|
||||
add_to_sclist(MMAIN, "F5", KEY_F(5), do_insertfile_void, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "F6", KEY_F(6), do_search_forward, 0);
|
||||
|
||||
@@ -310,7 +310,7 @@ void help_init(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Hard-wrap the concatenated help text, and write it into a new buffer. */
|
||||
@@ -461,7 +461,7 @@ void show_help(void)
|
||||
didfind = 0;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
openfile->mark = NULL;
|
||||
spotlighted = FALSE;
|
||||
hide_cursor = FALSE;
|
||||
|
||||
if (bracketed_paste || kbinput == BRACKETED_PASTE_MARKER) {
|
||||
|
||||
@@ -367,7 +367,8 @@ void save_history(void)
|
||||
}
|
||||
|
||||
/* Don't allow others to read or write the history file. */
|
||||
chmod(histname, S_IRUSR | S_IWUSR);
|
||||
if (chmod(histname, S_IRUSR | S_IWUSR) < 0)
|
||||
jot_error(N_("Cannot limit permissions on %s: %s"), histname, strerror(errno));
|
||||
|
||||
if (!write_list(searchtop, histfile) || !write_list(replacetop, histfile) ||
|
||||
!write_list(executetop, histfile))
|
||||
@@ -465,7 +466,8 @@ void save_poshistory(void)
|
||||
}
|
||||
|
||||
/* Don't allow others to read or write the history file. */
|
||||
chmod(poshistname, S_IRUSR | S_IWUSR);
|
||||
if (chmod(poshistname, S_IRUSR | S_IWUSR) < 0)
|
||||
jot_error(N_("Cannot limit permissions on %s: %s"), poshistname, strerror(errno));
|
||||
|
||||
for (posptr = position_history; posptr != NULL; posptr = posptr->next) {
|
||||
char *path_and_place;
|
||||
|
||||
186
src/nano.c
186
src/nano.c
@@ -2,7 +2,7 @@
|
||||
* nano.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2020 Benno Schulenberg *
|
||||
* Copyright (C) 2014-2021 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published *
|
||||
@@ -76,7 +76,6 @@ linestruct *make_new_node(linestruct *prevnode)
|
||||
#endif
|
||||
newnode->lineno = (prevnode) ? prevnode->lineno + 1 : 1;
|
||||
#ifndef NANO_TINY
|
||||
newnode->extrarows = -2; /* Bad value, to make it easier to find bugs. */
|
||||
newnode->has_anchor = FALSE;
|
||||
#endif
|
||||
|
||||
@@ -100,6 +99,9 @@ void splice_node(linestruct *afterthis, linestruct *newnode)
|
||||
/* Free the data structures in the given node. */
|
||||
void delete_node(linestruct *line)
|
||||
{
|
||||
/* If the first line on the screen gets deleted, step one back. */
|
||||
if (line == openfile->edittop)
|
||||
openfile->edittop = line->prev;
|
||||
#ifdef ENABLE_WRAPPING
|
||||
/* If the spill-over line for hard-wrapping is deleted... */
|
||||
if (line == openfile->spillage_line)
|
||||
@@ -152,8 +154,7 @@ linestruct *copy_node(const linestruct *src)
|
||||
#endif
|
||||
dst->lineno = src->lineno;
|
||||
#ifndef NANO_TINY
|
||||
dst->extrarows = src->extrarows;
|
||||
dst->has_anchor = FALSE;
|
||||
dst->has_anchor = src->has_anchor;
|
||||
#endif
|
||||
|
||||
return dst;
|
||||
@@ -308,40 +309,37 @@ void do_exit(void)
|
||||
statusbar(_("Cancelled"));
|
||||
}
|
||||
|
||||
/* Save the current buffer under the given name (or under the name "nano"
|
||||
* for a nameless buffer). If needed, the name is modified to be unique. */
|
||||
void emergency_save(const char *plainname)
|
||||
/* Save the current buffer under the given name (or "nano.<pid>" when nameless)
|
||||
* with suffix ".save". If needed, the name is further suffixed to be unique. */
|
||||
void emergency_save(const char *filename)
|
||||
{
|
||||
bool failed = TRUE;
|
||||
char *targetname;
|
||||
char *plainname, *targetname;
|
||||
|
||||
if (*plainname == '\0')
|
||||
plainname = "nano";
|
||||
if (*filename == '\0') {
|
||||
plainname = nmalloc(28);
|
||||
sprintf(plainname, "nano.%u", getpid());
|
||||
} else
|
||||
plainname = copy_of(filename);
|
||||
|
||||
targetname = get_next_filename(plainname, ".save");
|
||||
|
||||
if (*targetname != '\0')
|
||||
failed = !write_file(targetname, NULL, TRUE, OVERWRITE, FALSE);
|
||||
|
||||
if (!failed)
|
||||
if (*targetname == '\0')
|
||||
fprintf(stderr, _("\nToo many .save files\n"));
|
||||
else if (write_file(targetname, NULL, SPECIAL, OVERWRITE, NONOTES)) {
|
||||
fprintf(stderr, _("\nBuffer written to %s\n"), targetname);
|
||||
else if (*targetname != '\0')
|
||||
fprintf(stderr, _("\nBuffer not written to %s: %s\n"),
|
||||
targetname, strerror(errno));
|
||||
else
|
||||
fprintf(stderr, _("\nToo many .save files"));
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Try to chmod/chown the saved file to the values of the original file,
|
||||
* but ignore any failure as we are in a hurry to get out. */
|
||||
if (openfile->statinfo) {
|
||||
IGNORE_CALL_RESULT(chmod(targetname, openfile->statinfo->st_mode));
|
||||
IGNORE_CALL_RESULT(chown(targetname, openfile->statinfo->st_uid,
|
||||
openfile->statinfo->st_gid));
|
||||
}
|
||||
/* Try to chmod/chown the saved file to the values of the original file,
|
||||
* but ignore any failure as we are in a hurry to get out. */
|
||||
if (openfile->statinfo) {
|
||||
IGNORE_CALL_RESULT(chmod(targetname, openfile->statinfo->st_mode));
|
||||
IGNORE_CALL_RESULT(chown(targetname, openfile->statinfo->st_uid,
|
||||
openfile->statinfo->st_gid));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
free(targetname);
|
||||
free(plainname);
|
||||
}
|
||||
|
||||
/* Die gracefully -- by restoring the terminal state and saving any buffers
|
||||
@@ -350,6 +348,11 @@ void die(const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
openfilestruct *firstone = openfile;
|
||||
static int stabs = 0;
|
||||
|
||||
/* When dying for a second time, just give up. */
|
||||
if (++stabs > 1)
|
||||
exit(11);
|
||||
|
||||
restore_terminal();
|
||||
|
||||
@@ -364,7 +367,7 @@ void die(const char *msg, ...)
|
||||
|
||||
while (openfile) {
|
||||
#ifndef NANO_TINY
|
||||
/* If the current buffer has a lockfile, remove it. */
|
||||
/* If the current buffer has a lock file, remove it. */
|
||||
if (openfile->lock_filename)
|
||||
delete_lockfile(openfile->lock_filename);
|
||||
#endif
|
||||
@@ -517,7 +520,7 @@ void usage(void)
|
||||
#ifdef ENABLE_HISTORIES
|
||||
if (!ISSET(RESTRICTED))
|
||||
print_opt("-H", "--historylog",
|
||||
N_("Log & read search/replace string history"));
|
||||
N_("Save & reload old search/replace strings"));
|
||||
#endif
|
||||
#ifdef ENABLE_NANORC
|
||||
print_opt("-I", "--ignorercfiles", N_("Don't look at nanorc files"));
|
||||
@@ -545,7 +548,7 @@ void usage(void)
|
||||
#ifdef ENABLE_HISTORIES
|
||||
if (!ISSET(RESTRICTED))
|
||||
print_opt("-P", "--positionlog",
|
||||
N_("Log & read location of cursor position"));
|
||||
N_("Save & restore position of the cursor"));
|
||||
#endif
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
print_opt(_("-Q <regex>"), _("--quotestr=<regex>"),
|
||||
@@ -640,7 +643,6 @@ void usage(void)
|
||||
if (!ISSET(RESTRICTED))
|
||||
print_opt("-z", "--suspendable", N_("Enable suspension"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-^", "--markmatch", N_("Select the match of a search"));
|
||||
print_opt("-%", "--stateflags", N_("Show some states on the title bar"));
|
||||
print_opt("-_", "--minibar", N_("Show a feedback bar at the bottom"));
|
||||
#endif
|
||||
@@ -1007,14 +1009,6 @@ void handle_sigwinch(int signal)
|
||||
the_window_resized = TRUE;
|
||||
}
|
||||
|
||||
/* Compute and store how many extra rows each line needs when softwrapping. */
|
||||
void compute_the_extra_rows_per_line_from(linestruct *fromline)
|
||||
{
|
||||
if (ISSET(SOFTWRAP))
|
||||
for (linestruct *line = fromline; line != NULL; line = line->next)
|
||||
line->extrarows = extra_chunks_in(line);
|
||||
}
|
||||
|
||||
/* Reinitialize and redraw the screen completely. */
|
||||
void regenerate_screen(void)
|
||||
{
|
||||
@@ -1057,7 +1051,6 @@ void regenerate_screen(void)
|
||||
|
||||
/* If we have an open buffer, redraw the contents of the subwindows. */
|
||||
if (openfile) {
|
||||
compute_the_extra_rows_per_line_from(openfile->filetop);
|
||||
ensure_firstcolumn_is_aligned();
|
||||
draw_all_subwindows();
|
||||
}
|
||||
@@ -1066,8 +1059,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;
|
||||
|
||||
@@ -1085,9 +1076,7 @@ void do_toggle(int flag)
|
||||
break;
|
||||
#endif
|
||||
case SOFTWRAP:
|
||||
if (ISSET(SOFTWRAP))
|
||||
compute_the_extra_rows_per_line_from(openfile->filetop);
|
||||
else
|
||||
if (!ISSET(SOFTWRAP))
|
||||
openfile->firstcolumn = 0;
|
||||
refresh_needed = TRUE;
|
||||
break;
|
||||
@@ -1103,19 +1092,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);
|
||||
|
||||
if (flag == NO_HELP || flag == NO_SYNTAX)
|
||||
enabled = !enabled;
|
||||
|
||||
if (!ISSET(MINIBAR) || flag == SMART_HOME || flag == CUT_FROM_CURSOR ||
|
||||
flag == TABS_TO_SPACES || flag == USE_MOUSE || flag == SUSPENDABLE)
|
||||
statusline(REMARK, "%s %s", _(flagtostr(flag)),
|
||||
enabled ? _("enabled") : _("disabled"));
|
||||
enabled ? _("enabled") : _("disabled"));
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
@@ -1235,14 +1232,15 @@ void confirm_margin(void)
|
||||
needed_margin = 0;
|
||||
|
||||
if (needed_margin != margin) {
|
||||
bool keep_focus = (margin > 0) && focusing;
|
||||
|
||||
margin = needed_margin;
|
||||
editwincols = COLS - margin - thebar;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Recompute the softwrapped chunks for each line in the buffer,
|
||||
* and ensure a proper starting column for the first screen row. */
|
||||
compute_the_extra_rows_per_line_from(openfile->filetop);
|
||||
/* Ensure a proper starting column for the first screen row. */
|
||||
ensure_firstcolumn_is_aligned();
|
||||
focusing = keep_focus;
|
||||
#endif
|
||||
/* The margin has changed -- schedule a full refresh. */
|
||||
refresh_needed = TRUE;
|
||||
@@ -1406,12 +1404,13 @@ void inject(char *burst, size_t count)
|
||||
linestruct *thisline = openfile->current;
|
||||
size_t datalen = strlen(thisline->data);
|
||||
#ifndef NANO_TINY
|
||||
size_t old_amount = openfile->current->extrarows;
|
||||
size_t original_row = 0;
|
||||
size_t old_amount = 0;
|
||||
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
if (openfile->current_y == editwinrows - 1)
|
||||
original_row = chunk_for(xplustabs(), thisline);
|
||||
old_amount = extra_chunks_in(thisline);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1475,14 +1474,11 @@ void inject(char *burst, size_t count)
|
||||
/* When softwrapping and the number of chunks in the current line changed,
|
||||
* or we were on the last row of the edit window and moved to a new chunk,
|
||||
* we need a full refresh. */
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
openfile->current->extrarows = extra_chunks_in(openfile->current);
|
||||
if (openfile->current->extrarows != old_amount ||
|
||||
if (ISSET(SOFTWRAP) && (extra_chunks_in(openfile->current) != old_amount ||
|
||||
(openfile->current_y == editwinrows - 1 &&
|
||||
chunk_for(xplustabs(), openfile->current) > original_row)) {
|
||||
refresh_needed = TRUE;
|
||||
focusing = FALSE;
|
||||
}
|
||||
chunk_for(xplustabs(), openfile->current) > original_row))) {
|
||||
refresh_needed = TRUE;
|
||||
focusing = FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1758,7 +1754,6 @@ int main(int argc, char **argv)
|
||||
{"indicator", 0, NULL, 'q'},
|
||||
{"unix", 0, NULL, 'u'},
|
||||
{"afterends", 0, NULL, 'y'},
|
||||
{"markmatch", 0, NULL, '^'},
|
||||
{"stateflags", 0, NULL, '%'},
|
||||
{"minibar", 0, NULL, '_'},
|
||||
#endif
|
||||
@@ -1797,25 +1792,15 @@ int main(int argc, char **argv)
|
||||
textdomain(PACKAGE);
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_UTF8) && !defined(NANO_TINY)
|
||||
if (MB_CUR_MAX > MAXCHARLEN)
|
||||
fprintf(stderr, "Unexpected large character size: %i bytes"
|
||||
" -- please report a bug\n", (int)MB_CUR_MAX);
|
||||
#endif
|
||||
|
||||
/* Set sensible defaults, different from what Pico does. */
|
||||
/* Set a sensible default, different from what Pico does. */
|
||||
SET(NO_WRAP);
|
||||
SET(SMOOTH_SCROLL);
|
||||
|
||||
/* Give a small visual hint that nano has changed. */
|
||||
SET(MORE_SPACE);
|
||||
|
||||
/* If the executable's name starts with 'r', activate restricted mode. */
|
||||
if (*(tail(argv[0])) == 'r')
|
||||
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':
|
||||
@@ -2052,9 +2037,6 @@ int main(int argc, char **argv)
|
||||
SET(SUSPENDABLE);
|
||||
break;
|
||||
#ifndef NANO_TINY
|
||||
case '^':
|
||||
SET(MARK_MATCH);
|
||||
break;
|
||||
case '%':
|
||||
SET(STATEFLAGS);
|
||||
break;
|
||||
@@ -2073,6 +2055,10 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* Curses needs TERM; if it is unset, try falling back to a VT220. */
|
||||
if (getenv("TERM") == NULL)
|
||||
setenv("TERM", "vt220", 0);
|
||||
|
||||
/* Enter into curses mode. Abort if this fails. */
|
||||
if (initscr() == NULL)
|
||||
exit(1);
|
||||
@@ -2171,13 +2157,9 @@ int main(int argc, char **argv)
|
||||
memmove(alt_speller, alt_speller + 1, strlen(alt_speller));
|
||||
#endif
|
||||
|
||||
/* If an rcfile undid the default settings, copy it to the new flags. */
|
||||
/* If an rcfile undid the default setting, copy it to the new flag. */
|
||||
if (!ISSET(NO_WRAP))
|
||||
SET(BREAK_LONG_LINES);
|
||||
if (!ISSET(SMOOTH_SCROLL))
|
||||
SET(JUMPY_SCROLLING);
|
||||
if (!ISSET(MORE_SPACE))
|
||||
SET(EMPTY_LINE);
|
||||
|
||||
/* Simply OR the boolean flags from rcfile and command line. */
|
||||
for (size_t i = 0; i < sizeof(flags) / sizeof(flags[0]); i++)
|
||||
@@ -2227,7 +2209,7 @@ int main(int argc, char **argv)
|
||||
load_history();
|
||||
if (ISSET(POSITIONLOG))
|
||||
load_poshistory();
|
||||
#endif /* ENABLE_HISTORIES */
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If a backup directory was specified and we're not in restricted mode,
|
||||
@@ -2261,7 +2243,7 @@ int main(int argc, char **argv)
|
||||
die(_("Bad quoting regex \"%s\": %s\n"), quotestr, message);
|
||||
} else
|
||||
free(quotestr);
|
||||
#endif /* ENABLE_JUSTIFY */
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SPELLER
|
||||
/* If we don't have an alternative spell checker after reading the
|
||||
@@ -2321,6 +2303,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[SPOTLIGHTED] = A_REVERSE;
|
||||
interface_color_pair[MINI_INFOBAR] = hilite_attribute;
|
||||
interface_color_pair[PROMPT_BAR] = hilite_attribute;
|
||||
interface_color_pair[STATUS_BAR] = hilite_attribute;
|
||||
interface_color_pair[ERROR_MESSAGE] = hilite_attribute;
|
||||
@@ -2401,9 +2385,9 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
/* If there's a +LINE[,COLUMN] argument here, eat it up. */
|
||||
if (optind < argc - 1 && argv[optind][0] == '+') {
|
||||
#ifndef NANO_TINY
|
||||
int n = 1;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
while (isalpha(argv[optind][n])) {
|
||||
switch (argv[optind][n++]) {
|
||||
case 'c': SET(CASE_SENSITIVE); break;
|
||||
@@ -2426,7 +2410,11 @@ int main(int argc, char **argv)
|
||||
optind++;
|
||||
} else
|
||||
#endif
|
||||
if (!parse_line_column(&argv[optind++][n], &givenline, &givencol))
|
||||
/* When there is nothing after the "+", understand it as go-to-EOF,
|
||||
* otherwise parse and store the given number(s).*/
|
||||
if (argv[optind++][1] == '\0')
|
||||
givenline = -1;
|
||||
else if (!parse_line_column(&argv[optind - 1][1], &givenline, &givencol))
|
||||
statusline(ALERT, _("Invalid line or column number"));
|
||||
}
|
||||
|
||||
@@ -2452,7 +2440,7 @@ int main(int argc, char **argv)
|
||||
if (!findnextstr(searchstring, FALSE, JUSTFIND, NULL,
|
||||
ISSET(BACKWARDS_SEARCH), openfile->filetop, 0))
|
||||
not_found_msg(searchstring);
|
||||
else if (lastmessage == HUSH)
|
||||
else if (lastmessage <= REMARK)
|
||||
wipe_statusbar();
|
||||
openfile->placewewant = xplustabs();
|
||||
if (ISSET(USE_REGEXP))
|
||||
@@ -2497,11 +2485,16 @@ int main(int argc, char **argv)
|
||||
#ifdef ENABLE_NANORC
|
||||
if (startup_problem != NULL)
|
||||
statusline(ALERT, startup_problem);
|
||||
|
||||
#define NOTREBOUND first_sc_for(MMAIN, do_help) && \
|
||||
first_sc_for(MMAIN, do_help)->keycode == 0x07
|
||||
#else
|
||||
#define NOTREBOUND TRUE
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_HELP
|
||||
if (*openfile->filename == '\0' && openfile->totsize == 0 &&
|
||||
openfile->next == openfile && !ISSET(NO_HELP))
|
||||
openfile->next == openfile && !ISSET(NO_HELP) && NOTREBOUND)
|
||||
statusbar(_("Welcome to nano. For basic help, type Ctrl+G."));
|
||||
#endif
|
||||
|
||||
@@ -2519,13 +2512,14 @@ int main(int argc, char **argv)
|
||||
bottombars(MMAIN);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(MINIBAR) && lastmessage < REMARK)
|
||||
if (ISSET(MINIBAR) && LINES > 1 && lastmessage < REMARK)
|
||||
minibar();
|
||||
else
|
||||
#endif
|
||||
/* Update the displayed current cursor position only when there
|
||||
* is no message and no keys are waiting in the input buffer. */
|
||||
if (ISSET(CONSTANT_SHOW) && lastmessage == VACUUM && get_key_buffer_len() == 0)
|
||||
if (ISSET(CONSTANT_SHOW) && lastmessage == VACUUM && LINES > 1 &&
|
||||
get_key_buffer_len() == 0)
|
||||
report_cursor_position();
|
||||
|
||||
as_an_at = TRUE;
|
||||
@@ -2534,7 +2528,7 @@ int main(int argc, char **argv)
|
||||
if (!refresh_needed) {
|
||||
place_the_cursor();
|
||||
wnoutrefresh(edit);
|
||||
} else
|
||||
} else if (LINES > 1 || lastmessage == VACUUM)
|
||||
edit_refresh();
|
||||
|
||||
errno = 0;
|
||||
|
||||
@@ -408,11 +408,13 @@ void draw_the_promptbar(void)
|
||||
|
||||
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. */
|
||||
wmove(bottomwin, 0, column - the_page);
|
||||
@@ -424,7 +426,7 @@ void draw_the_promptbar(void)
|
||||
void add_or_remove_pipe_symbol_from_answer(void)
|
||||
{
|
||||
if (answer[0] == '|') {
|
||||
memmove(answer, answer + 1, strlen(answer) + 1);
|
||||
memmove(answer, answer + 1, strlen(answer));
|
||||
if (typing_x > 0)
|
||||
typing_x--;
|
||||
} else {
|
||||
@@ -764,7 +766,7 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
choice = -2;
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_MOUSE */
|
||||
#endif
|
||||
else if (func_from_key(&kbinput) == full_refresh)
|
||||
full_refresh();
|
||||
#ifndef NANO_TINY
|
||||
|
||||
@@ -191,6 +191,8 @@ typedef void (*functionptrtype)(void);
|
||||
#ifdef ENABLE_BROWSER
|
||||
void browser_refresh(void);
|
||||
char *browse_in(const char *inpath);
|
||||
void to_first_file(void);
|
||||
void to_last_file(void);
|
||||
#endif
|
||||
|
||||
/* Most functions in chars.c. */
|
||||
@@ -204,9 +206,9 @@ bool is_cntrl_char(const char *c);
|
||||
bool is_word_char(const char *c, bool allow_punct);
|
||||
char control_mbrep(const char *c, bool isdata);
|
||||
#ifdef ENABLE_UTF8
|
||||
int mbwidth(const char *c);
|
||||
int mbtowide(wchar_t *wc, const char *c);
|
||||
bool is_doublewidth(const char *ch);
|
||||
bool is_zerowidth(const char *ch);
|
||||
char *make_mbchar(long code, int *length);
|
||||
#endif
|
||||
int char_length(const char *pointer);
|
||||
size_t mbstrlen(const char *pointer);
|
||||
@@ -230,16 +232,12 @@ char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer);
|
||||
bool has_blank_char(const char *string);
|
||||
#endif
|
||||
bool white_string(const char *string);
|
||||
#ifdef ENABLE_UTF8
|
||||
bool is_valid_unicode(wchar_t wc);
|
||||
#endif
|
||||
|
||||
/* Most functions in color.c. */
|
||||
#ifdef ENABLE_COLOR
|
||||
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
|
||||
@@ -298,11 +296,11 @@ bool outside_of_confinement(const char *currpath, bool allow_tabcomp);
|
||||
void init_backup_dir(void);
|
||||
#endif
|
||||
int copy_file(FILE *inn, FILE *out, bool close_out);
|
||||
bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
kind_of_writing_type method, bool fullbuffer);
|
||||
bool write_file(const char *name, FILE *thefile, bool normal,
|
||||
kind_of_writing_type method, bool annotate);
|
||||
#ifndef NANO_TINY
|
||||
bool write_marked_file(const char *name, FILE *stream, bool tmp,
|
||||
kind_of_writing_type method);
|
||||
bool write_region_to_file(const char *name, FILE *stream, bool normal,
|
||||
kind_of_writing_type method);
|
||||
#endif
|
||||
int do_writeout(bool exiting, bool withprompt);
|
||||
void do_writeout_void(void);
|
||||
@@ -413,7 +411,6 @@ void block_sigwinch(bool blockit);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
void handle_sigwinch(int signal);
|
||||
void compute_the_extra_rows_per_line_from(linestruct *fromline);
|
||||
void regenerate_screen(void);
|
||||
void do_toggle(int flag);
|
||||
#endif
|
||||
@@ -512,8 +509,7 @@ size_t indent_length(const char *line);
|
||||
size_t quote_length(const char *line);
|
||||
bool begpar(const linestruct *const line, int depth);
|
||||
bool inpar(const linestruct *const line);
|
||||
void do_justify(bool full_justify);
|
||||
void do_justify_void(void);
|
||||
void do_justify(void);
|
||||
void do_full_justify(void);
|
||||
#endif
|
||||
#ifdef ENABLE_SPELLER
|
||||
@@ -533,9 +529,7 @@ void complete_a_word(void);
|
||||
void get_homedir(void);
|
||||
const char *tail(const char *path);
|
||||
char *concatenate(const char *path, const char *name);
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
int digits(ssize_t n);
|
||||
#endif
|
||||
bool parse_num(const char *str, ssize_t *result);
|
||||
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column);
|
||||
void recode_NUL_to_LF(char *string, size_t length);
|
||||
@@ -644,8 +638,6 @@ void flip_replace(void);
|
||||
void flip_goto(void);
|
||||
#ifdef ENABLE_BROWSER
|
||||
void to_files(void);
|
||||
void to_first_file(void);
|
||||
void to_last_file(void);
|
||||
void goto_dir(void);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
|
||||
77
src/rcfile.c
77
src/rcfile.c
@@ -60,7 +60,6 @@ static const rcoption rcopts[] = {
|
||||
#ifdef HAVE_LIBMAGIC
|
||||
{"magic", USE_MAGIC},
|
||||
#endif
|
||||
{"morespace", MORE_SPACE}, /* Deprecated; remove in 2021. */
|
||||
#ifdef ENABLE_MOUSE
|
||||
{"mouse", USE_MOUSE},
|
||||
#endif
|
||||
@@ -69,7 +68,6 @@ static const rcoption rcopts[] = {
|
||||
#endif
|
||||
{"nohelp", NO_HELP},
|
||||
{"nonewlines", NO_NEWLINES},
|
||||
{"nopauses", NO_PAUSES}, /* Obsolete; remove in 2021. */
|
||||
#ifdef ENABLE_WRAPPING
|
||||
{"nowrap", NO_WRAP}, /* Deprecated; remove in 2024. */
|
||||
#endif
|
||||
@@ -109,13 +107,11 @@ static const rcoption rcopts[] = {
|
||||
{"indicator", INDICATOR},
|
||||
{"jumpyscrolling", JUMPY_SCROLLING},
|
||||
{"locking", LOCKING},
|
||||
{"markmatch", MARK_MATCH},
|
||||
{"matchbrackets", 0},
|
||||
{"minibar", MINIBAR},
|
||||
{"noconvert", NO_CONVERT},
|
||||
{"showcursor", SHOW_CURSOR},
|
||||
{"smarthome", SMART_HOME},
|
||||
{"smooth", SMOOTH_SCROLL}, /* Deprecated; remove in 2021. */
|
||||
{"softwrap", SOFTWRAP},
|
||||
{"stateflags", STATEFLAGS},
|
||||
{"tabsize", 0},
|
||||
@@ -133,6 +129,8 @@ static const rcoption rcopts[] = {
|
||||
{"stripecolor", 0},
|
||||
{"scrollercolor", 0},
|
||||
{"selectedcolor", 0},
|
||||
{"spotlightcolor", 0},
|
||||
{"minicolor", 0},
|
||||
{"promptcolor", 0},
|
||||
{"statuscolor", 0},
|
||||
{"errorcolor", 0},
|
||||
@@ -293,7 +291,7 @@ keystruct *strtosc(const char *input)
|
||||
s->func = do_gotolinecolumn_void;
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
else if (!strcmp(input, "justify"))
|
||||
s->func = do_justify_void;
|
||||
s->func = do_justify;
|
||||
else if (!strcmp(input, "fulljustify"))
|
||||
s->func = do_full_justify;
|
||||
else if (!strcmp(input, "beginpara"))
|
||||
@@ -625,9 +623,7 @@ bool compile(const char *expression, int rex_flags, regex_t **packed)
|
||||
regerror(outcome, compiled, message, length);
|
||||
jot_error(N_("Bad regex \"%s\": %s"), expression, message);
|
||||
free(message);
|
||||
}
|
||||
|
||||
if (packed == NULL || outcome != 0) {
|
||||
regfree(compiled);
|
||||
free(compiled);
|
||||
} else
|
||||
@@ -996,9 +992,21 @@ void parse_includes(char *ptr)
|
||||
free(expanded);
|
||||
}
|
||||
|
||||
const char hues[9][7] = { "pink", "purple", "mauve", "lagoon", "mint",
|
||||
"lime", "peach", "orange", "latte" };
|
||||
short indices[9] = { 204, 163, 134, 38, 48, 148, 215, 208, 137 };
|
||||
#define COLORCOUNT 20
|
||||
|
||||
const char hues[COLORCOUNT][8] = { "red", "green", "blue",
|
||||
"yellow", "cyan", "magenta",
|
||||
"white", "black", "normal",
|
||||
"pink", "purple", "mauve",
|
||||
"lagoon", "mint", "lime",
|
||||
"peach", "orange", "latte",
|
||||
"grey", "gray" };
|
||||
|
||||
short indices[COLORCOUNT] = { COLOR_RED, COLOR_GREEN, COLOR_BLUE,
|
||||
COLOR_YELLOW, COLOR_CYAN, COLOR_MAGENTA,
|
||||
COLOR_WHITE, COLOR_BLACK, THE_DEFAULT,
|
||||
204, 163, 134, 38, 48, 148, 215, 208, 137,
|
||||
COLOR_BLACK + 8, COLOR_BLACK + 8 };
|
||||
|
||||
/* Return the short value corresponding to the given color name, and set
|
||||
* vivid to TRUE for a lighter color, and thick for a heavier typeface. */
|
||||
@@ -1018,35 +1026,16 @@ short color_to_short(const char *colorname, bool *vivid, bool *thick)
|
||||
*thick = FALSE;
|
||||
}
|
||||
|
||||
if (strcmp(colorname, "green") == 0)
|
||||
return COLOR_GREEN;
|
||||
else if (strcmp(colorname, "red") == 0)
|
||||
return COLOR_RED;
|
||||
else if (strcmp(colorname, "blue") == 0)
|
||||
return COLOR_BLUE;
|
||||
else if (strcmp(colorname, "white") == 0)
|
||||
return COLOR_WHITE;
|
||||
else if (strcmp(colorname, "yellow") == 0)
|
||||
return COLOR_YELLOW;
|
||||
else if (strcmp(colorname, "cyan") == 0)
|
||||
return COLOR_CYAN;
|
||||
else if (strcmp(colorname, "magenta") == 0)
|
||||
return COLOR_MAGENTA;
|
||||
else if (strcmp(colorname, "black") == 0)
|
||||
return COLOR_BLACK;
|
||||
else if (strcmp(colorname, "normal") == 0)
|
||||
return THE_DEFAULT;
|
||||
else
|
||||
for (int index = 0; index < 9; index++)
|
||||
if (strcmp(colorname, hues[index]) == 0) {
|
||||
if (*vivid) {
|
||||
jot_error(N_("Color '%s' takes no prefix"), colorname);
|
||||
return BAD_COLOR;
|
||||
} else if (COLORS < 255)
|
||||
return THE_DEFAULT;
|
||||
else
|
||||
return indices[index];
|
||||
}
|
||||
for (int index = 0; index < COLORCOUNT; index++)
|
||||
if (strcmp(colorname, hues[index]) == 0) {
|
||||
if (index > 7 && *vivid) {
|
||||
jot_error(N_("Color '%s' takes no prefix"), colorname);
|
||||
return BAD_COLOR;
|
||||
} else if (index > 8 && COLORS < 255)
|
||||
return THE_DEFAULT;
|
||||
else
|
||||
return indices[index];
|
||||
}
|
||||
|
||||
jot_error(N_("Color \"%s\" not understood"), colorname);
|
||||
return BAD_COLOR;
|
||||
@@ -1242,6 +1231,8 @@ void grab_and_store(const char *kind, char *ptr, regexlisttype **storage)
|
||||
|
||||
/* Now gather any valid regexes and add them to the linked list. */
|
||||
while (*ptr != '\0') {
|
||||
regex_t *packed_rgx = NULL;
|
||||
|
||||
regexstring = ++ptr;
|
||||
ptr = parse_next_regex(ptr);
|
||||
|
||||
@@ -1249,12 +1240,12 @@ void grab_and_store(const char *kind, char *ptr, regexlisttype **storage)
|
||||
return;
|
||||
|
||||
/* If the regex string is malformed, skip it. */
|
||||
if (!compile(regexstring, NANO_REG_EXTENDED | REG_NOSUB, NULL))
|
||||
if (!compile(regexstring, NANO_REG_EXTENDED | REG_NOSUB, &packed_rgx))
|
||||
continue;
|
||||
|
||||
/* Copy the regex into a struct, and hook this in at the end. */
|
||||
newthing = nmalloc(sizeof(regexlisttype));
|
||||
newthing->full_regex = copy_of(regexstring);
|
||||
newthing->one_rgx = packed_rgx;
|
||||
newthing->next = NULL;
|
||||
|
||||
if (lastthing == NULL)
|
||||
@@ -1558,6 +1549,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, "spotlightcolor") == 0)
|
||||
color_combo[SPOTLIGHTED] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "minicolor") == 0)
|
||||
color_combo[MINI_INFOBAR] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "promptcolor") == 0)
|
||||
color_combo[PROMPT_BAR] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "statuscolor") == 0)
|
||||
|
||||
84
src/search.c
84
src/search.c
@@ -82,7 +82,7 @@ void search_init(bool replacing, bool retain_answer)
|
||||
thedefault = nmalloc(strlen(disp) + 7);
|
||||
/* We use (COLS / 3) here because we need to see more on the line. */
|
||||
sprintf(thedefault, " [%s%s]", disp,
|
||||
(breadth(last_search) > COLS / 3) ? "..." : "");
|
||||
(breadth(last_search) > COLS / 3) ? "..." : "");
|
||||
free(disp);
|
||||
} else
|
||||
thedefault = copy_of("");
|
||||
@@ -323,21 +323,18 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
*match_len = found_len;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (modus == JUSTFIND && ISSET(MARK_MATCH) && (!openfile->mark || openfile->softmark)) {
|
||||
openfile->mark = line;
|
||||
openfile->mark_x = found_x + found_len;
|
||||
openfile->softmark = TRUE;
|
||||
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;
|
||||
shift_held = TRUE;
|
||||
edit_refresh();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Wipe the "Searching..." message and unsuppress cursor-position display. */
|
||||
if (feedback > 0) {
|
||||
if (feedback > 0)
|
||||
wipe_statusbar();
|
||||
lastmessage = VACUUM;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -431,10 +428,8 @@ void go_looking(void)
|
||||
/* If we found something, and we're back at the exact same spot
|
||||
* where we started searching, then this is the only occurrence. */
|
||||
if (didfind == 1 && openfile->current == was_current &&
|
||||
openfile->current_x == was_current_x)
|
||||
openfile->current_x == was_current_x)
|
||||
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);
|
||||
|
||||
@@ -475,8 +470,7 @@ int replace_regexp(char *string, bool create)
|
||||
/* And if create is TRUE, append the result of the
|
||||
* subexpression match to the new line. */
|
||||
if (create) {
|
||||
strncpy(string, openfile->current->data +
|
||||
regmatches[num].rm_so, i);
|
||||
strncpy(string, openfile->current->data + regmatches[num].rm_so, i);
|
||||
string += i;
|
||||
}
|
||||
}
|
||||
@@ -521,19 +515,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
|
||||
@@ -569,7 +550,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
openfile->current_x = bot_x;
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
#endif
|
||||
|
||||
came_full_circle = FALSE;
|
||||
|
||||
@@ -625,17 +606,16 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
}
|
||||
|
||||
if (choice == 1 || replaceall) { /* Yes, replace it. */
|
||||
char *copy;
|
||||
size_t length_change;
|
||||
char *altered;
|
||||
|
||||
altered = replace_line(needle);
|
||||
|
||||
length_change = strlen(altered) - strlen(openfile->current->data);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(REPLACE, NULL);
|
||||
#endif
|
||||
copy = replace_line(needle);
|
||||
|
||||
length_change = strlen(copy) - strlen(openfile->current->data);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If the mark was on and it was located after the cursor,
|
||||
* then adjust its x position for any text length changes. */
|
||||
if (was_mark && !right_side_up) {
|
||||
@@ -651,8 +631,9 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
|
||||
/* If the mark was not on or it was before the cursor, then
|
||||
* adjust the cursor's x position for any text length changes. */
|
||||
if (!was_mark || right_side_up) {
|
||||
if (!was_mark || right_side_up)
|
||||
#endif
|
||||
{
|
||||
if (openfile->current == real_current &&
|
||||
openfile->current_x < *real_current_x) {
|
||||
if (*real_current_x < openfile->current_x + match_len)
|
||||
@@ -660,8 +641,8 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
*real_current_x += length_change;
|
||||
#ifndef NANO_TINY
|
||||
bot_x = *real_current_x;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't find the same zero-length or BOL match again. */
|
||||
@@ -674,21 +655,10 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
openfile->current_x += match_len + length_change;
|
||||
|
||||
/* Update the file size, and put the changed line into place. */
|
||||
openfile->totsize += mbstrlen(copy) - mbstrlen(openfile->current->data);
|
||||
openfile->totsize += mbstrlen(altered) - mbstrlen(openfile->current->data);
|
||||
free(openfile->current->data);
|
||||
openfile->current->data = copy;
|
||||
openfile->current->data = altered;
|
||||
|
||||
#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;
|
||||
numreplaced++;
|
||||
@@ -698,11 +668,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
|
||||
@@ -735,8 +700,8 @@ void ask_for_and_do_replacements(void)
|
||||
size_t begin_x = openfile->current_x;
|
||||
ssize_t numreplaced;
|
||||
int response = do_prompt(MREPLACEWITH, "", &replace_history,
|
||||
/* TRANSLATORS: This is a prompt. */
|
||||
edit_refresh, _("Replace with"));
|
||||
/* TRANSLATORS: This is a prompt. */
|
||||
edit_refresh, _("Replace with"));
|
||||
|
||||
#ifdef ENABLE_HISTORIES
|
||||
/* When not "", add the replace string to the replace history list. */
|
||||
@@ -758,11 +723,12 @@ void ask_for_and_do_replacements(void)
|
||||
openfile->firstcolumn = was_firstcolumn;
|
||||
openfile->current = beginline;
|
||||
openfile->current_x = begin_x;
|
||||
refresh_needed = TRUE;
|
||||
|
||||
edit_refresh();
|
||||
|
||||
if (numreplaced >= 0)
|
||||
statusline(REMARK, P_("Replaced %zd occurrence",
|
||||
"Replaced %zd occurrences", numreplaced), numreplaced);
|
||||
"Replaced %zd occurrences", numreplaced), numreplaced);
|
||||
}
|
||||
|
||||
/* Go to the specified line and x position. */
|
||||
|
||||
177
src/text.c
177
src/text.c
@@ -6,7 +6,7 @@
|
||||
* Copyright (C) 2016 Mike Scalora *
|
||||
* Copyright (C) 2016 Sumedh Pendurkar *
|
||||
* Copyright (C) 2018 Marco Diego Aurélio Mesquita *
|
||||
* Copyright (C) 2015-2020 Benno Schulenberg *
|
||||
* Copyright (C) 2015-2021 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published *
|
||||
@@ -39,7 +39,7 @@
|
||||
#ifdef ENABLE_WORDCOMPLETION
|
||||
static int pletion_x = 0;
|
||||
/* The x position in pletion_line of the last found completion. */
|
||||
static completion_word *list_of_completions;
|
||||
static completionstruct *list_of_completions;
|
||||
/* A linked list of the completions that have been attempted. */
|
||||
#endif
|
||||
|
||||
@@ -58,10 +58,10 @@ void do_mark(void)
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
#endif
|
||||
|
||||
/* Insert a tab. If the TABS_TO_SPACES flag is set, insert the number
|
||||
* of spaces that a tab would normally take up. */
|
||||
/* Insert a tab. Or, if --tabstospaces is in effect, insert the number
|
||||
* of spaces that a tab would normally take up at this position. */
|
||||
void do_tab(void)
|
||||
{
|
||||
#ifdef ENABLE_COLOR
|
||||
@@ -103,9 +103,6 @@ void indent_a_line(linestruct *line, char *indentation)
|
||||
|
||||
openfile->totsize += indent_len;
|
||||
|
||||
if (ISSET(SOFTWRAP))
|
||||
line->extrarows = extra_chunks_in(line);
|
||||
|
||||
/* Compensate for the change in the current line. */
|
||||
if (line == openfile->mark && openfile->mark_x > 0)
|
||||
openfile->mark_x += indent_len;
|
||||
@@ -136,12 +133,12 @@ void do_indent(void)
|
||||
|
||||
indentation = nmalloc(tabsize + 1);
|
||||
|
||||
/* Set the indentation to either a bunch of spaces or a single tab. */
|
||||
#ifdef ENABLE_COLOR
|
||||
if (openfile->syntax && openfile->syntax->tab)
|
||||
indentation = mallocstrcpy(indentation, openfile->syntax->tab);
|
||||
else
|
||||
#endif
|
||||
/* Set the indentation to either a bunch of spaces or a single tab. */
|
||||
if (ISSET(TABS_TO_SPACES)) {
|
||||
memset(indentation, ' ', tabsize);
|
||||
indentation[tabsize] = '\0';
|
||||
@@ -189,7 +186,7 @@ size_t length_of_white(const char *text)
|
||||
|
||||
while (TRUE) {
|
||||
if (*text == '\t')
|
||||
return ++white_count;
|
||||
return white_count + 1;
|
||||
|
||||
if (*text != ' ')
|
||||
return white_count;
|
||||
@@ -234,9 +231,6 @@ void unindent_a_line(linestruct *line, size_t indent_len)
|
||||
|
||||
openfile->totsize -= indent_len;
|
||||
|
||||
if (ISSET(SOFTWRAP))
|
||||
line->extrarows = extra_chunks_in(line);
|
||||
|
||||
/* Adjust the positions of mark and cursor, when they are affected. */
|
||||
compensate_leftward(line, indent_len);
|
||||
}
|
||||
@@ -284,9 +278,6 @@ void handle_indent_action(undostruct *u, bool undoing, bool add_indent)
|
||||
groupstruct *group = u->grouping;
|
||||
linestruct *line = line_from_number(group->top_line);
|
||||
|
||||
if (group->next != NULL)
|
||||
die("Multiple groups -- please report a bug\n");
|
||||
|
||||
/* When redoing, reposition the cursor and let the indenter adjust it. */
|
||||
if (!undoing)
|
||||
goto_line_posx(u->head_lineno, u->head_x);
|
||||
@@ -424,15 +415,9 @@ void do_comment(void)
|
||||
|
||||
/* Comment/uncomment each of the selected lines when possible, and
|
||||
* store undo data when a line changed. */
|
||||
for (line = top; line != bot->next; line = line->next) {
|
||||
if (comment_line(action, line, comment_seq)) {
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP))
|
||||
line->extrarows = extra_chunks_in(line);
|
||||
#endif
|
||||
for (line = top; line != bot->next; line = line->next)
|
||||
if (comment_line(action, line, comment_seq))
|
||||
update_multiline_undo(line->lineno, "");
|
||||
}
|
||||
}
|
||||
|
||||
set_modified();
|
||||
ensure_firstcolumn_is_aligned();
|
||||
@@ -478,6 +463,10 @@ void undo_cut(undostruct *u)
|
||||
{
|
||||
goto_line_posx(u->head_lineno, (u->xflags & WAS_WHOLE_LINE) ? 0 : u->head_x);
|
||||
|
||||
/* Clear an inherited anchor but not a user-placed one. */
|
||||
if (!(u->xflags & HAD_ANCHOR_AT_START))
|
||||
openfile->current->has_anchor = FALSE;
|
||||
|
||||
if (u->cutbuffer)
|
||||
copy_from_buffer(u->cutbuffer);
|
||||
|
||||
@@ -573,8 +562,6 @@ void do_undo(void)
|
||||
break;
|
||||
}
|
||||
line->data[u->tail_x] = '\0';
|
||||
if (ISSET(SOFTWRAP))
|
||||
line->extrarows = extra_chunks_in(line);
|
||||
intruder = make_new_node(line);
|
||||
intruder->data = copy_of(u->strdata);
|
||||
splice_node(line, intruder);
|
||||
@@ -676,12 +663,9 @@ void do_undo(void)
|
||||
openfile->mark = NULL;
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
if (ISSET(SOFTWRAP))
|
||||
openfile->current->extrarows = extra_chunks_in(openfile->current);
|
||||
|
||||
openfile->totsize = u->wassize;
|
||||
|
||||
/* When at the point where the file was last saved, unset "Modified". */
|
||||
/* When at the point where the buffer was last saved, unset "Modified". */
|
||||
if (openfile->current_undo == openfile->last_saved) {
|
||||
openfile->modified = FALSE;
|
||||
titlebar(NULL);
|
||||
@@ -725,8 +709,6 @@ void do_redo(void)
|
||||
case ENTER:
|
||||
redidmsg = _("line break");
|
||||
line->data[u->head_x] = '\0';
|
||||
if (ISSET(SOFTWRAP))
|
||||
line->extrarows = extra_chunks_in(line);
|
||||
intruder = make_new_node(line);
|
||||
intruder->data = copy_of(u->strdata);
|
||||
splice_node(line, intruder);
|
||||
@@ -841,12 +823,9 @@ void do_redo(void)
|
||||
openfile->mark = NULL;
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
if (ISSET(SOFTWRAP))
|
||||
openfile->current->extrarows = extra_chunks_in(openfile->current);
|
||||
|
||||
openfile->totsize = u->newsize;
|
||||
|
||||
/* When at the point where the file was last saved, unset "Modified". */
|
||||
/* When at the point where the buffer was last saved, unset "Modified". */
|
||||
if (openfile->current_undo == openfile->last_saved) {
|
||||
openfile->modified = FALSE;
|
||||
titlebar(NULL);
|
||||
@@ -907,11 +886,6 @@ void do_enter(void)
|
||||
openfile->mark = newnode;
|
||||
openfile->mark_x += extra - openfile->current_x;
|
||||
}
|
||||
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
openfile->current->extrarows = extra_chunks_in(openfile->current);
|
||||
newnode->extrarows = extra_chunks_in(newnode);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Insert the newly created line after the current one and renumber. */
|
||||
@@ -951,7 +925,7 @@ void discard_until(const undostruct *thisitem)
|
||||
while (group != NULL) {
|
||||
groupstruct *next = group->next;
|
||||
free_chararray(group->indentations,
|
||||
group->bottom_line - group->top_line);
|
||||
group->bottom_line - group->top_line + 1);
|
||||
free(group);
|
||||
group = next;
|
||||
}
|
||||
@@ -1053,6 +1027,8 @@ void add_undo(undo_type action, const char *message)
|
||||
#endif
|
||||
case CUT_TO_EOF:
|
||||
u->xflags |= (INCLUDED_LAST_LINE | CURSOR_WAS_AT_HEAD);
|
||||
if (openfile->current->has_anchor)
|
||||
u->xflags |= HAD_ANCHOR_AT_START;
|
||||
break;
|
||||
case ZAP:
|
||||
case CUT:
|
||||
@@ -1074,6 +1050,9 @@ void add_undo(undo_type action, const char *message)
|
||||
u->tail_x = 0;
|
||||
} else
|
||||
u->xflags |= CURSOR_WAS_AT_HEAD;
|
||||
if ((openfile->mark && mark_is_before_cursor() && openfile->mark->has_anchor) ||
|
||||
((!openfile->mark || !mark_is_before_cursor()) && openfile->current->has_anchor))
|
||||
u->xflags |= HAD_ANCHOR_AT_START;
|
||||
break;
|
||||
case PASTE:
|
||||
u->cutbuffer = copy_buffer(cutbuffer);
|
||||
@@ -1112,24 +1091,24 @@ void update_multiline_undo(ssize_t lineno, char *indentation)
|
||||
/* If there already is a group and the current line is contiguous with it,
|
||||
* extend the group; otherwise, create a new group. */
|
||||
if (u->grouping && u->grouping->bottom_line + 1 == lineno) {
|
||||
size_t number_of_lines;
|
||||
size_t number_of_lines = lineno - u->grouping->top_line + 1;
|
||||
|
||||
u->grouping->bottom_line++;
|
||||
u->grouping->bottom_line = lineno;
|
||||
|
||||
number_of_lines = u->grouping->bottom_line - u->grouping->top_line + 1;
|
||||
u->grouping->indentations = nrealloc(u->grouping->indentations,
|
||||
number_of_lines * sizeof(char *));
|
||||
u->grouping->indentations[number_of_lines - 1] = copy_of(indentation);
|
||||
} else {
|
||||
groupstruct *born = nmalloc(sizeof(groupstruct));
|
||||
|
||||
born->next = u->grouping;
|
||||
u->grouping = born;
|
||||
born->top_line = lineno;
|
||||
born->bottom_line = lineno;
|
||||
|
||||
u->grouping->indentations = nmalloc(sizeof(char *));
|
||||
u->grouping->indentations[0] = copy_of(indentation);
|
||||
born->indentations = nmalloc(sizeof(char *));
|
||||
born->indentations[0] = copy_of(indentation);
|
||||
|
||||
born->next = u->grouping;
|
||||
u->grouping = born;
|
||||
}
|
||||
|
||||
/* Store the file size after the change, to be used when redoing. */
|
||||
@@ -1357,7 +1336,9 @@ bool do_wrap(void)
|
||||
strncpy(line->data, line->prev->data, lead_len);
|
||||
|
||||
openfile->current_x += lead_len;
|
||||
openfile->totsize += lead_len;
|
||||
#ifndef NANO_TINY
|
||||
free(openfile->undotop->strdata);
|
||||
update_undo(ENTER);
|
||||
#endif
|
||||
if (autowhite)
|
||||
@@ -1453,21 +1434,12 @@ ssize_t break_line(const char *textstart, ssize_t goal, bool snap_at_nl)
|
||||
* "indentation" of a line is the leading consecutive whitespace. */
|
||||
size_t indent_length(const char *line)
|
||||
{
|
||||
size_t len = 0;
|
||||
char onechar[MAXCHARLEN];
|
||||
int charlen;
|
||||
const char *start = line;
|
||||
|
||||
while (*line != '\0') {
|
||||
charlen = collect_char(line, onechar);
|
||||
while (*line != '\0' && is_blank_char(line))
|
||||
line += char_length(line);
|
||||
|
||||
if (!is_blank_char(onechar))
|
||||
break;
|
||||
|
||||
line += charlen;
|
||||
len += charlen;
|
||||
}
|
||||
|
||||
return len;
|
||||
return (line - start);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1741,9 +1713,12 @@ void justify_paragraph(linestruct **line, size_t count)
|
||||
free(lead_string);
|
||||
}
|
||||
|
||||
/* Justify the current paragraph, or the entire buffer when full_justify is
|
||||
#define ONE_PARAGRAPH FALSE
|
||||
#define WHOLE_BUFFER TRUE
|
||||
|
||||
/* Justify the current paragraph, or the entire buffer when whole_buffer is
|
||||
* TRUE. But if the mark is on, justify only the marked text instead. */
|
||||
void do_justify(bool full_justify)
|
||||
void justify_text(bool whole_buffer)
|
||||
{
|
||||
size_t linecount;
|
||||
/* The number of lines in the original paragraph. */
|
||||
@@ -1859,7 +1834,7 @@ void do_justify(bool full_justify)
|
||||
{
|
||||
/* When justifying the entire buffer, start at the top. Otherwise, when
|
||||
* in a paragraph but not at its beginning, move back to its first line. */
|
||||
if (full_justify)
|
||||
if (whole_buffer)
|
||||
openfile->current = openfile->filetop;
|
||||
else if (inpar(openfile->current) && !begpar(openfile->current, 0))
|
||||
do_para_begin(&openfile->current);
|
||||
@@ -1881,7 +1856,7 @@ void do_justify(bool full_justify)
|
||||
start_x = 0;
|
||||
|
||||
/* Set the end point of the paragraph. */
|
||||
if (full_justify)
|
||||
if (whole_buffer)
|
||||
endline = openfile->filebot;
|
||||
else {
|
||||
endline = startline;
|
||||
@@ -1956,7 +1931,7 @@ void do_justify(bool full_justify)
|
||||
justify_paragraph(&jusline, linecount);
|
||||
|
||||
/* When justifying the entire buffer, find and justify all paragraphs. */
|
||||
if (full_justify) {
|
||||
if (whole_buffer) {
|
||||
while (find_paragraph(&jusline, &linecount)) {
|
||||
justify_paragraph(&jusline, linecount);
|
||||
|
||||
@@ -1967,9 +1942,11 @@ void do_justify(bool full_justify)
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(PASTE, NULL);
|
||||
if (full_justify && !openfile->mark && !cutbuffer->has_anchor)
|
||||
/* Wipe an anchor on the first paragraph if it was only inherited. */
|
||||
if (whole_buffer && !openfile->mark && !cutbuffer->has_anchor)
|
||||
openfile->current->has_anchor = FALSE;
|
||||
|
||||
add_undo(PASTE, NULL);
|
||||
#endif
|
||||
/* Do the equivalent of a paste of the justified text. */
|
||||
ingraft_buffer(cutbuffer);
|
||||
@@ -1988,22 +1965,20 @@ void do_justify(bool full_justify)
|
||||
}
|
||||
|
||||
add_undo(COUPLE_END, N_("justification"));
|
||||
#endif
|
||||
|
||||
/* We're done justifying. Restore the old cutbuffer. */
|
||||
cutbuffer = was_cutbuffer;
|
||||
|
||||
/* Show what we justified on the status bar. */
|
||||
#ifndef NANO_TINY
|
||||
/* Report on the status bar what we justified. */
|
||||
if (openfile->mark)
|
||||
statusline(REMARK, _("Justified selection"));
|
||||
else
|
||||
#endif
|
||||
if (full_justify)
|
||||
statusbar(_("Justified file"));
|
||||
if (whole_buffer)
|
||||
statusline(REMARK, _("Justified file"));
|
||||
else
|
||||
statusbar(_("Justified paragraph"));
|
||||
|
||||
/* We're done justifying. Restore the cutbuffer. */
|
||||
cutbuffer = was_cutbuffer;
|
||||
|
||||
/* Set the desired screen column (always zero, except at EOF). */
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
@@ -2013,15 +1988,15 @@ void do_justify(bool full_justify)
|
||||
}
|
||||
|
||||
/* Justify the current paragraph. */
|
||||
void do_justify_void(void)
|
||||
void do_justify(void)
|
||||
{
|
||||
do_justify(FALSE);
|
||||
justify_text(ONE_PARAGRAPH);
|
||||
}
|
||||
|
||||
/* Justify the entire file. */
|
||||
void do_full_justify(void)
|
||||
{
|
||||
do_justify(TRUE);
|
||||
justify_text(WHOLE_BUFFER);
|
||||
ran_a_tool = TRUE;
|
||||
}
|
||||
#endif /* ENABLE_JUSTIFY */
|
||||
@@ -2086,9 +2061,9 @@ bool replace_buffer(const char *filename, undo_type action, const char *operatio
|
||||
/* Execute the given program, with the given temp file as last argument. */
|
||||
void treat(char *tempfile_name, char *theprogram, bool spelling)
|
||||
{
|
||||
ssize_t lineno_save = openfile->current->lineno;
|
||||
size_t current_x_save = openfile->current_x;
|
||||
size_t pww_save = openfile->placewewant;
|
||||
ssize_t was_lineno = openfile->current->lineno;
|
||||
size_t was_pww = openfile->placewewant;
|
||||
size_t was_x = openfile->current_x;
|
||||
bool was_at_eol = (openfile->current->data[openfile->current_x] == '\0');
|
||||
struct stat fileinfo;
|
||||
long timestamp_sec = 0;
|
||||
@@ -2172,7 +2147,7 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
|
||||
/* Adjust the end point of the marked region for any change in
|
||||
* length of the region's last line. */
|
||||
if (upright)
|
||||
current_x_save = openfile->current_x;
|
||||
was_x = openfile->current_x;
|
||||
else
|
||||
openfile->mark_x = openfile->current_x;
|
||||
|
||||
@@ -2190,7 +2165,7 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
|
||||
}
|
||||
|
||||
/* Go back to the old position. */
|
||||
goto_line_posx(lineno_save, current_x_save);
|
||||
goto_line_posx(was_lineno, was_x);
|
||||
if (was_at_eol || openfile->current_x > strlen(openfile->current->data))
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
|
||||
@@ -2201,7 +2176,7 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
|
||||
#endif
|
||||
}
|
||||
|
||||
openfile->placewewant = pww_save;
|
||||
openfile->placewewant = was_pww;
|
||||
adjust_viewport(STATIONARY);
|
||||
|
||||
if (spelling)
|
||||
@@ -2524,10 +2499,10 @@ void do_spell(void)
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->mark)
|
||||
okay = write_marked_file(temp_name, stream, TRUE, OVERWRITE);
|
||||
okay = write_region_to_file(temp_name, stream, TEMPORARY, OVERWRITE);
|
||||
else
|
||||
#endif
|
||||
okay = write_file(temp_name, stream, TRUE, OVERWRITE, TRUE);
|
||||
okay = write_file(temp_name, stream, TEMPORARY, OVERWRITE, NONOTES);
|
||||
|
||||
if (!okay) {
|
||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||
@@ -2644,6 +2619,9 @@ void do_linter(void)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Block resizing signals while reading from the pipe. */
|
||||
block_sigwinch(TRUE);
|
||||
|
||||
/* Read in the returned syntax errors. */
|
||||
totalread = 0;
|
||||
buffersize = pipesize + 1;
|
||||
@@ -2660,10 +2638,12 @@ void do_linter(void)
|
||||
*pointer = '\0';
|
||||
close(lint_fd[0]);
|
||||
|
||||
/* Process the linter output. */
|
||||
block_sigwinch(FALSE);
|
||||
|
||||
pointer = lintings;
|
||||
onelint = lintings;
|
||||
|
||||
/* Now parse the output of the linter. */
|
||||
while (*pointer != '\0') {
|
||||
if ((*pointer == '\r') || (*pointer == '\n')) {
|
||||
*pointer = '\0';
|
||||
@@ -2671,11 +2651,8 @@ void do_linter(void)
|
||||
char *filename = NULL, *linestr = NULL, *maybecol = NULL;
|
||||
char *message = copy_of(onelint);
|
||||
|
||||
/* At the moment we handle the following formats:
|
||||
*
|
||||
* filenameorcategory:line:column:message (e.g. splint)
|
||||
* filenameorcategory:line,column:message (e.g. pylint)
|
||||
* filenameorcategory:line:message (e.g. pyflakes) */
|
||||
/* The recognized format is "filename:line:column: message",
|
||||
* where ":column" may be absent or be ",column" instead. */
|
||||
if (strstr(message, ": ") != NULL) {
|
||||
filename = strtok(onelint, ":");
|
||||
if ((linestr = strtok(NULL, ":")) != NULL) {
|
||||
@@ -2708,7 +2685,7 @@ void do_linter(void)
|
||||
curlint->prev = tmplint;
|
||||
if (curlint->prev != NULL)
|
||||
curlint->prev->next = curlint;
|
||||
curlint->msg = copy_of(message);
|
||||
curlint->msg = copy_of(strstr(message, ": ") + 2);
|
||||
curlint->lineno = tmplineno;
|
||||
curlint->colno = tmpcolno;
|
||||
curlint->filename = copy_of(filename);
|
||||
@@ -2926,7 +2903,7 @@ void do_formatter(void)
|
||||
temp_name = safe_tempfile(&stream);
|
||||
|
||||
if (temp_name != NULL)
|
||||
okay = write_file(temp_name, stream, TRUE, OVERWRITE, TRUE);
|
||||
okay = write_file(temp_name, stream, TEMPORARY, OVERWRITE, NONOTES);
|
||||
|
||||
if (!okay) {
|
||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||
@@ -3059,7 +3036,7 @@ void complete_a_word(void)
|
||||
char *shard, *completion = NULL;
|
||||
size_t start_of_shard, shard_length = 0;
|
||||
size_t i = 0, j = 0;
|
||||
completion_word *some_word;
|
||||
completionstruct *some_word;
|
||||
#ifdef ENABLE_WRAPPING
|
||||
bool was_set_wrapping = ISSET(BREAK_LONG_LINES);
|
||||
#endif
|
||||
@@ -3068,7 +3045,7 @@ void complete_a_word(void)
|
||||
if (pletion_line == NULL) {
|
||||
/* Clear the list of words of a previous completion run. */
|
||||
while (list_of_completions != NULL) {
|
||||
completion_word *dropit = list_of_completions;
|
||||
completionstruct *dropit = list_of_completions;
|
||||
list_of_completions = list_of_completions->next;
|
||||
free(dropit->word);
|
||||
free(dropit);
|
||||
@@ -3161,7 +3138,7 @@ void complete_a_word(void)
|
||||
}
|
||||
|
||||
/* Add the found word to the list of completions. */
|
||||
some_word = nmalloc(sizeof(completion_word));
|
||||
some_word = nmalloc(sizeof(completionstruct));
|
||||
some_word->word = completion;
|
||||
some_word->next = list_of_completions;
|
||||
list_of_completions = some_word;
|
||||
@@ -3193,8 +3170,8 @@ void complete_a_word(void)
|
||||
|
||||
/* The search has reached the end of the file. */
|
||||
if (list_of_completions != NULL) {
|
||||
edit_refresh();
|
||||
statusline(AHEM, _("No further matches"));
|
||||
refresh_needed = TRUE;
|
||||
} else
|
||||
/* TRANSLATORS: Shown when there are zero possible completions. */
|
||||
statusline(AHEM, _("No matches"));
|
||||
|
||||
33
src/utils.c
33
src/utils.c
@@ -61,7 +61,7 @@ const char *tail(const char *path)
|
||||
if (slash == NULL)
|
||||
return path;
|
||||
else
|
||||
return ++slash;
|
||||
return slash + 1;
|
||||
}
|
||||
|
||||
/* Return a copy of the two given strings, welded together. */
|
||||
@@ -76,7 +76,6 @@ char *concatenate(const char *path, const char *name)
|
||||
return joined;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
/* Return the number of digits that the given integer n takes up. */
|
||||
int digits(ssize_t n)
|
||||
{
|
||||
@@ -106,7 +105,6 @@ int digits(ssize_t n)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Read an integer from the given string. If it parses okay,
|
||||
* store it in *result and return TRUE; otherwise, return FALSE. */
|
||||
@@ -195,22 +193,18 @@ void free_chararray(char **array, size_t len)
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SPELLER
|
||||
/* Is the word starting at the given position in buf and of the given length
|
||||
* a separate word? That is: is it not part of a longer word?*/
|
||||
bool is_separate_word(size_t position, size_t length, const char *buf)
|
||||
/* Is the word starting at the given position in 'text' and of the given
|
||||
* length a separate word? That is: is it not part of a longer word? */
|
||||
bool is_separate_word(size_t position, size_t length, const char *text)
|
||||
{
|
||||
char before[MAXCHARLEN], after[MAXCHARLEN];
|
||||
size_t word_end = position + length;
|
||||
|
||||
/* Get the characters before and after the word, if any. */
|
||||
collect_char(buf + step_left(buf, position), before);
|
||||
collect_char(buf + word_end, after);
|
||||
const char *before = text + step_left(text, position);
|
||||
const char *after = text + position + length;
|
||||
|
||||
/* If the word starts at the beginning of the line OR the character before
|
||||
* the word isn't a letter, and if the word ends at the end of the line OR
|
||||
* the character after the word isn't a letter, we have a whole word. */
|
||||
return ((position == 0 || !is_alpha_char(before)) &&
|
||||
(buf[word_end] == '\0' || !is_alpha_char(after)));
|
||||
(*after == '\0' || !is_alpha_char(after)));
|
||||
}
|
||||
#endif /* ENABLE_SPELLER */
|
||||
|
||||
@@ -355,14 +349,12 @@ char *free_and_assign(char *dest, char *src)
|
||||
return src;
|
||||
}
|
||||
|
||||
/* When not in softwrap mode, nano scrolls horizontally within a line in
|
||||
* chunks (a bit smaller than the chunks used in softwrapping). Return the
|
||||
* column number of the first character displayed in the edit window when the
|
||||
* cursor is at the given column. Note that (0 <= column -
|
||||
* get_page_start(column) < COLS). */
|
||||
/* When not softwrapping, nano scrolls the current line horizontally by
|
||||
* chunks ("pages"). Return the column number of the first character
|
||||
* displayed in the edit window when the cursor is at the given column. */
|
||||
size_t get_page_start(size_t column)
|
||||
{
|
||||
if (column + 2 < editwincols || ISSET(SOFTWRAP) || column == 0)
|
||||
if (column == 0 || column + 2 < editwincols || ISSET(SOFTWRAP))
|
||||
return 0;
|
||||
else if (editwincols > 8)
|
||||
return column - 6 - (column - 6) % (editwincols - 8);
|
||||
@@ -437,9 +429,6 @@ void new_magicline(void)
|
||||
openfile->filebot->next = make_new_node(openfile->filebot);
|
||||
openfile->filebot->next->data = copy_of("");
|
||||
openfile->filebot = openfile->filebot->next;
|
||||
#ifndef NANO_TINY
|
||||
openfile->filebot->extrarows = 0;
|
||||
#endif
|
||||
openfile->totsize++;
|
||||
}
|
||||
|
||||
|
||||
466
src/winio.c
466
src/winio.c
@@ -2,7 +2,7 @@
|
||||
* winio.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2020 Benno Schulenberg *
|
||||
* Copyright (C) 2014-2021 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published *
|
||||
@@ -54,6 +54,10 @@ static bool linger_after_escape = FALSE;
|
||||
/* Whether to give ncurses some time to get the next code. */
|
||||
static int statusblank = 0;
|
||||
/* The number of keystrokes left before we blank the status bar. */
|
||||
size_t from_x = 0;
|
||||
/* From where in the relevant line the current row is drawn. */
|
||||
size_t till_x = 0;
|
||||
/* Until where in the relevant line the current row is drawn. */
|
||||
static bool has_more = FALSE;
|
||||
/* Whether the current line has more text after the displayed part. */
|
||||
static bool is_shorter = TRUE;
|
||||
@@ -178,17 +182,22 @@ void read_keys_from(WINDOW *win)
|
||||
bool timed = FALSE;
|
||||
#endif
|
||||
|
||||
/* On a one-row terminal, overwrite an unimportant message. */
|
||||
if (LINES == 1 && currmenu == MMAIN && lastmessage == HUSH)
|
||||
edit_refresh();
|
||||
|
||||
/* Before reading the first keycode, display any pending screen updates. */
|
||||
doupdate();
|
||||
|
||||
if (reveal_cursor && !hide_cursor)
|
||||
if (reveal_cursor && !hide_cursor && (LINES > 1 || lastmessage <= HUSH))
|
||||
curs_set(1);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (currmenu == MMAIN && ISSET(MINIBAR) && lastmessage > HUSH &&
|
||||
lastmessage != INFO && lastmessage < ALERT) {
|
||||
if (currmenu == MMAIN && (spotlighted || ((ISSET(MINIBAR) || LINES == 1) &&
|
||||
lastmessage > HUSH &&
|
||||
lastmessage != INFO && lastmessage < ALERT))) {
|
||||
timed = TRUE;
|
||||
halfdelay(8);
|
||||
halfdelay(ISSET(QUICK_BLANK) ? 8 : 15);
|
||||
disable_kb_interrupt();
|
||||
}
|
||||
#endif
|
||||
@@ -208,7 +217,15 @@ void read_keys_from(WINDOW *win)
|
||||
raw();
|
||||
|
||||
if (input == ERR) {
|
||||
minibar();
|
||||
if (spotlighted || LINES == 1) {
|
||||
lastmessage = VACUUM;
|
||||
spotlighted = FALSE;
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
wnoutrefresh(edit);
|
||||
curs_set(1);
|
||||
}
|
||||
if (ISSET(MINIBAR) && LINES > 1)
|
||||
minibar();
|
||||
as_an_at = TRUE;
|
||||
place_the_cursor();
|
||||
doupdate();
|
||||
@@ -216,11 +233,11 @@ void read_keys_from(WINDOW *win)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* When we've failed to get a keycode over a hundred times in a row,
|
||||
/* When we've failed to get a keycode millions of times in a row,
|
||||
* assume our input source is gone and die gracefully. We could
|
||||
* check if errno is set to EIO ("Input/output error") and die in
|
||||
* that case, but it's not always set properly. Argh. */
|
||||
if (input == ERR && ++errcount == 123)
|
||||
if (input == ERR && ++errcount == 12345678)
|
||||
die(_("Too many errors from stdin\n"));
|
||||
}
|
||||
|
||||
@@ -232,6 +249,10 @@ void read_keys_from(WINDOW *win)
|
||||
key_buffer_len = 1;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Cancel the highlighting of a search match, if there still is one. */
|
||||
refresh_needed |= spotlighted;
|
||||
spotlighted = FALSE;
|
||||
|
||||
/* If we got a SIGWINCH, get out as the win argument is no longer valid. */
|
||||
if (input == KEY_WINCH)
|
||||
return;
|
||||
@@ -1377,7 +1398,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
|
||||
* commence Unicode input. Otherwise, put the code back. */
|
||||
if (using_utf8() && (keycode == '0' || keycode == '1')) {
|
||||
long unicode = assemble_unicode(keycode);
|
||||
char *multibyte;
|
||||
char multibyte[MB_CUR_MAX];
|
||||
|
||||
reveal_cursor = FALSE;
|
||||
|
||||
@@ -1407,14 +1428,15 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
|
||||
}
|
||||
|
||||
/* Convert the Unicode value to a multibyte sequence. */
|
||||
multibyte = make_mbchar(unicode, (int *)count);
|
||||
*count = wctomb(multibyte, unicode);
|
||||
|
||||
if (*count > MAXCHARLEN)
|
||||
*count = 0;
|
||||
|
||||
/* Change the multibyte character into a series of integers. */
|
||||
for (size_t i = 0; i < *count; i++)
|
||||
yield[i] = (int)multibyte[i];
|
||||
|
||||
free(multibyte);
|
||||
|
||||
return yield;
|
||||
}
|
||||
#endif /* ENABLE_UTF8 */
|
||||
@@ -1656,6 +1678,7 @@ void wipe_statusbar(void)
|
||||
{
|
||||
blank_row(bottomwin, 0);
|
||||
wnoutrefresh(bottomwin);
|
||||
lastmessage = VACUUM;
|
||||
}
|
||||
|
||||
/* Blank out the two help lines (when they are present). */
|
||||
@@ -1678,7 +1701,7 @@ void check_statusblank(void)
|
||||
statusblank--;
|
||||
|
||||
/* When editing and 'constantshow' is active, skip the blanking. */
|
||||
if (currmenu == MMAIN && ISSET(CONSTANT_SHOW))
|
||||
if (currmenu == MMAIN && ISSET(CONSTANT_SHOW) && LINES > 1)
|
||||
return;
|
||||
|
||||
if (statusblank == 0)
|
||||
@@ -1695,32 +1718,35 @@ void set_blankdelay_to_one(void)
|
||||
statusblank = 1;
|
||||
}
|
||||
|
||||
/* Convert buf into a string that can be displayed on screen. The caller
|
||||
* wants to display buf starting with the given column, and extending for
|
||||
/* Convert text into a string that can be displayed on screen. The caller
|
||||
* wants to display text starting with the given column, and extending for
|
||||
* at most span columns. column is zero-based, and span is one-based, so
|
||||
* span == 0 means you get "" returned. The returned string is dynamically
|
||||
* allocated, and should be freed. If isdata is TRUE, the caller might put
|
||||
* "<" at the beginning or ">" at the end of the line if it's too long. If
|
||||
* isprompt is TRUE, the caller might put ">" at the end of the line if it's
|
||||
* too long. */
|
||||
char *display_string(const char *buf, size_t column, size_t span,
|
||||
char *display_string(const char *text, size_t column, size_t span,
|
||||
bool isdata, bool isprompt)
|
||||
{
|
||||
size_t start_index = actual_x(buf, column);
|
||||
const char *origin = text;
|
||||
/* The beginning of the text, to later determine the covered part. */
|
||||
size_t start_x = actual_x(text, column);
|
||||
/* The index of the first character that the caller wishes to show. */
|
||||
size_t start_col = wideness(buf, start_index);
|
||||
size_t start_col = wideness(text, start_x);
|
||||
/* The actual column where that first character starts. */
|
||||
char *converted;
|
||||
/* The expanded string we will return. */
|
||||
size_t stowaways = 20;
|
||||
/* The number of zero-width characters for which to reserve space. */
|
||||
size_t allocsize = (COLS + stowaways) * MAXCHARLEN + 1;
|
||||
/* The amount of memory to reserve for the displayable string. */
|
||||
char *converted = nmalloc(allocsize);
|
||||
/* The displayable string we will return. */
|
||||
size_t index = 0;
|
||||
/* Current position in converted. */
|
||||
size_t beyond = column + span;
|
||||
/* The column number just beyond the last shown character. */
|
||||
|
||||
buf += start_index;
|
||||
|
||||
/* Allocate enough space for converting the relevant part of the line. */
|
||||
converted = nmalloc(strlen(buf) * (MAXCHARLEN + tabsize) + 1);
|
||||
text += start_x;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (span > HIGHEST_POSITIVE) {
|
||||
@@ -1731,17 +1757,17 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||
#endif
|
||||
/* If the first character starts before the left edge, or would be
|
||||
* overwritten by a "<" token, then show placeholders instead. */
|
||||
if (*buf != '\0' && *buf != '\t' && (start_col < column ||
|
||||
(start_col > 0 && isdata && !ISSET(SOFTWRAP)))) {
|
||||
if (is_cntrl_char(buf)) {
|
||||
if ((start_col < column || (start_col > 0 && isdata && !ISSET(SOFTWRAP))) &&
|
||||
*text != '\0' && *text != '\t') {
|
||||
if (is_cntrl_char(text)) {
|
||||
if (start_col < column) {
|
||||
converted[index++] = control_mbrep(buf, isdata);
|
||||
converted[index++] = control_mbrep(text, isdata);
|
||||
column++;
|
||||
buf += char_length(buf);
|
||||
text += char_length(text);
|
||||
}
|
||||
}
|
||||
#ifdef ENABLE_UTF8
|
||||
else if (mbwidth(buf) == 2) {
|
||||
else if (is_doublewidth(text)) {
|
||||
if (start_col == column) {
|
||||
converted[index++] = ' ';
|
||||
column++;
|
||||
@@ -1750,29 +1776,29 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||
/* Display the right half of a two-column character as ']'. */
|
||||
converted[index++] = ']';
|
||||
column++;
|
||||
buf += char_length(buf);
|
||||
text += char_length(text);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
#define ISO8859_CHAR FALSE
|
||||
#define ZEROWIDTH_CHAR (mbwidth(buf) == 0)
|
||||
#define ZEROWIDTH_CHAR (is_zerowidth(text))
|
||||
#else
|
||||
#define ISO8859_CHAR ((unsigned char)*buf > 0x9F)
|
||||
#define ISO8859_CHAR ((unsigned char)*text > 0x9F)
|
||||
#define ZEROWIDTH_CHAR FALSE
|
||||
#endif
|
||||
|
||||
while (*buf != '\0' && (column < beyond || ZEROWIDTH_CHAR)) {
|
||||
while (*text != '\0' && (column < beyond || ZEROWIDTH_CHAR)) {
|
||||
/* A plain printable ASCII character is one byte, one column. */
|
||||
if (((signed char)*buf > 0x20 && *buf != DEL_CODE) || ISO8859_CHAR) {
|
||||
converted[index++] = *(buf++);
|
||||
if (((signed char)*text > 0x20 && *text != DEL_CODE) || ISO8859_CHAR) {
|
||||
converted[index++] = *(text++);
|
||||
column++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Show a space as a visible character, or as a space. */
|
||||
if (*buf == ' ') {
|
||||
if (*text == ' ') {
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(WHITESPACE_DISPLAY)) {
|
||||
for (int i = whitelen[0]; i < whitelen[0] + whitelen[1];)
|
||||
@@ -1781,12 +1807,12 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||
#endif
|
||||
converted[index++] = ' ';
|
||||
column++;
|
||||
buf++;
|
||||
text++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Show a tab as a visible character plus spaces, or as just spaces. */
|
||||
if (*buf == '\t') {
|
||||
if (*text == '\t') {
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(WHITESPACE_DISPLAY) && (index > 0 || !isdata ||
|
||||
!ISSET(SOFTWRAP) || column % tabsize == 0 ||
|
||||
@@ -1802,15 +1828,15 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||
converted[index++] = ' ';
|
||||
column++;
|
||||
}
|
||||
buf++;
|
||||
text++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Represent a control character with a leading caret. */
|
||||
if (is_cntrl_char(buf)) {
|
||||
if (is_cntrl_char(text)) {
|
||||
converted[index++] = '^';
|
||||
converted[index++] = control_mbrep(buf, isdata);
|
||||
buf += char_length(buf);
|
||||
converted[index++] = control_mbrep(text, isdata);
|
||||
text += char_length(text);
|
||||
column += 2;
|
||||
continue;
|
||||
}
|
||||
@@ -1820,14 +1846,14 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||
wchar_t wc;
|
||||
|
||||
/* Convert a multibyte character to a single code. */
|
||||
charlength = mbtowc(&wc, buf, MAXCHARLEN);
|
||||
charlength = mbtowide(&wc, text);
|
||||
|
||||
/* Represent an invalid character with the Replacement Character. */
|
||||
if (charlength < 0 || !is_valid_unicode(wc)) {
|
||||
if (charlength < 0) {
|
||||
converted[index++] = '\xEF';
|
||||
converted[index++] = '\xBF';
|
||||
converted[index++] = '\xBD';
|
||||
buf += (charlength > 0 ? charlength : 1);
|
||||
text++;
|
||||
column++;
|
||||
continue;
|
||||
}
|
||||
@@ -1835,17 +1861,24 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||
/* Determine whether the character takes zero, one, or two columns. */
|
||||
charwidth = wcwidth(wc);
|
||||
|
||||
/* Watch the number of zero-widths, to keep ample memory reserved. */
|
||||
if (charwidth == 0 && --stowaways == 0) {
|
||||
stowaways = 40;
|
||||
allocsize += stowaways * MAXCHARLEN;
|
||||
converted = nrealloc(converted, allocsize);
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
/* On a Linux console, skip zero-width characters, as it would show
|
||||
* them WITH a width, thus messing up the display. See bug #52954. */
|
||||
if (on_a_vt && charwidth == 0) {
|
||||
buf += charlength;
|
||||
text += charlength;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
/* For any valid character, just copy its bytes. */
|
||||
for (; charlength > 0; charlength--)
|
||||
converted[index++] = *(buf++);
|
||||
converted[index++] = *(text++);
|
||||
|
||||
/* If the codepoint is unassigned, assume a width of one. */
|
||||
column += (charwidth < 0 ? 1 : charwidth);
|
||||
@@ -1853,15 +1886,15 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||
}
|
||||
|
||||
/* If there is more text than can be shown, make room for the ">". */
|
||||
if (column > beyond || (*buf != '\0' && (isprompt ||
|
||||
if (column > beyond || (*text != '\0' && (isprompt ||
|
||||
(isdata && !ISSET(SOFTWRAP))))) {
|
||||
#ifdef ENABLE_UTF8
|
||||
do {
|
||||
index = step_left(converted, index);
|
||||
} while (mbwidth(converted + index) == 0);
|
||||
} while (is_zerowidth(converted + index));
|
||||
|
||||
/* Display the left half of a two-column character as '['. */
|
||||
if (mbwidth(converted + index) == 2)
|
||||
if (is_doublewidth(converted + index))
|
||||
converted[index++] = '[';
|
||||
#else
|
||||
index--;
|
||||
@@ -1875,6 +1908,10 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||
/* Null-terminate the converted string. */
|
||||
converted[index] = '\0';
|
||||
|
||||
/* Remember what part of the original text is covered by converted. */
|
||||
from_x = start_x;
|
||||
till_x = text - origin;
|
||||
|
||||
return converted;
|
||||
}
|
||||
|
||||
@@ -2081,13 +2118,12 @@ void minibar(void)
|
||||
#endif
|
||||
|
||||
/* Draw a colored bar over the full width of the screen. */
|
||||
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
wattron(bottomwin, interface_color_pair[MINI_INFOBAR]);
|
||||
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);
|
||||
thename = display_string(openfile->filename, 0, COLS, FALSE, FALSE);
|
||||
} else
|
||||
thename = copy_of(_("(nameless)"));
|
||||
|
||||
@@ -2099,8 +2135,9 @@ void minibar(void)
|
||||
if (namewidth + 19 > COLS)
|
||||
padding = 0;
|
||||
|
||||
/* Display the name of the current file (dottifying it if it doesn't fit),
|
||||
* plus a star when the file has been modified. */
|
||||
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, "...");
|
||||
@@ -2111,6 +2148,8 @@ void minibar(void)
|
||||
waddstr(bottomwin, openfile->modified ? " *" : " ");
|
||||
}
|
||||
|
||||
/* Right after reading or writing a file, display its number of lines;
|
||||
* otherwise, when there are multiple buffers, display an [x/n] counter. */
|
||||
if (report_size && COLS > 35) {
|
||||
size_t count = openfile->filebot->lineno - (openfile->filebot->data[0] == '\0');
|
||||
|
||||
@@ -2133,11 +2172,12 @@ void minibar(void)
|
||||
#endif
|
||||
|
||||
/* Display the line/column position of the cursor. */
|
||||
if (namewidth + tallywidth + placewidth + 32 < COLS)
|
||||
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 (namewidth + tallywidth + 28 < COLS) {
|
||||
/* Display the hexadecimal code of the character under the cursor,
|
||||
* plus the codes of up to two succeeding zero-width characters. */
|
||||
if (ISSET(CONSTANT_SHOW) && namewidth + tallywidth + 28 < COLS) {
|
||||
char *this_position = openfile->current->data + openfile->current_x;
|
||||
|
||||
if (*this_position == '\0')
|
||||
@@ -2151,7 +2191,7 @@ void minibar(void)
|
||||
#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)
|
||||
else if (using_utf8() && mbtowide(&widecode, this_position) > 0)
|
||||
sprintf(hexadecimal, "U+%04X", (int)widecode);
|
||||
#endif
|
||||
else
|
||||
@@ -2163,13 +2203,13 @@ void minibar(void)
|
||||
successor = this_position + char_length(this_position);
|
||||
|
||||
if (*this_position && *successor && is_zerowidth(successor) &&
|
||||
mbtowc(&widecode, successor, MAXCHARLEN) >= 0) {
|
||||
mbtowide(&widecode, successor) > 0) {
|
||||
sprintf(hexadecimal, "|%04X", (int)widecode);
|
||||
waddstr(bottomwin, hexadecimal);
|
||||
|
||||
successor += char_length(successor);
|
||||
|
||||
if (is_zerowidth(successor) && mbtowc(&widecode, successor, MAXCHARLEN) >= 0) {
|
||||
if (is_zerowidth(successor) && mbtowide(&widecode, successor) > 0) {
|
||||
sprintf(hexadecimal, "|%04X", (int)widecode);
|
||||
waddstr(bottomwin, hexadecimal);
|
||||
}
|
||||
@@ -2179,7 +2219,7 @@ void minibar(void)
|
||||
}
|
||||
|
||||
/* Display the state of three flags, and the state of macro and mark. */
|
||||
if (!successor && namewidth + tallywidth + 14 + 2 * padding < COLS) {
|
||||
if (ISSET(STATEFLAGS) && !successor && namewidth + tallywidth + 14 + 2 * padding < COLS) {
|
||||
wmove(bottomwin, 0, COLS - 11 - padding);
|
||||
show_states_at(bottomwin);
|
||||
}
|
||||
@@ -2190,7 +2230,7 @@ void minibar(void)
|
||||
mvwaddstr(bottomwin, 0, COLS - 4 - padding, location);
|
||||
}
|
||||
|
||||
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
wattroff(bottomwin, interface_color_pair[MINI_INFOBAR]);
|
||||
wrefresh(bottomwin);
|
||||
|
||||
free(number_of_lines);
|
||||
@@ -2214,15 +2254,36 @@ void statusline(message_type importance, const char *msg, ...)
|
||||
bool old_whitespace = ISSET(WHITESPACE_DISPLAY);
|
||||
|
||||
UNSET(WHITESPACE_DISPLAY);
|
||||
|
||||
if (isendwin())
|
||||
die("Out of curses -- please report a bug\n");
|
||||
#endif
|
||||
|
||||
/* Ignore a message with an importance that is lower than the last one. */
|
||||
if (importance < lastmessage && lastmessage > NOTICE)
|
||||
return;
|
||||
|
||||
/* Construct the message out of all the arguments. */
|
||||
compound = nmalloc(MAXCHARLEN * COLS + 1);
|
||||
va_start(ap, msg);
|
||||
vsnprintf(compound, MAXCHARLEN * COLS + 1, msg, ap);
|
||||
va_end(ap);
|
||||
|
||||
/* When not in curses mode, write the message to standard error. */
|
||||
if (isendwin()) {
|
||||
fprintf(stderr, "\n%s\n", compound);
|
||||
free(compound);
|
||||
return;
|
||||
}
|
||||
|
||||
#if !defined(NANO_TINY) && defined(ENABLE_MULTIBUFFER)
|
||||
if (!we_are_running && importance == ALERT && openfile && !openfile->fmt &&
|
||||
!openfile->errormessage && openfile->next != openfile)
|
||||
openfile->errormessage = copy_of(compound);
|
||||
#endif
|
||||
|
||||
/* On a one-row terminal, ensure that any changes in the edit window are
|
||||
* written out first, to prevent them from overwriting the message. */
|
||||
if (LINES == 1 && importance < INFO)
|
||||
wnoutrefresh(edit);
|
||||
|
||||
/* If there are multiple alert messages, add trailing dots to the first. */
|
||||
if (lastmessage == ALERT) {
|
||||
if (start_col > 4) {
|
||||
@@ -2235,6 +2296,7 @@ void statusline(message_type importance, const char *msg, ...)
|
||||
napms(100);
|
||||
beep();
|
||||
}
|
||||
free(compound);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2251,11 +2313,6 @@ void statusline(message_type importance, const char *msg, ...)
|
||||
|
||||
blank_statusbar();
|
||||
|
||||
/* Construct the message out of all the arguments. */
|
||||
compound = nmalloc(MAXCHARLEN * (COLS + 1));
|
||||
va_start(ap, msg);
|
||||
vsnprintf(compound, MAXCHARLEN * (COLS + 1), msg, ap);
|
||||
va_end(ap);
|
||||
message = display_string(compound, 0, COLS, FALSE, FALSE);
|
||||
free(compound);
|
||||
|
||||
@@ -2267,7 +2324,6 @@ void statusline(message_type importance, const char *msg, ...)
|
||||
if (bracketed)
|
||||
waddstr(bottomwin, "[ ");
|
||||
waddstr(bottomwin, message);
|
||||
free(message);
|
||||
if (bracketed)
|
||||
waddstr(bottomwin, " ]");
|
||||
wattroff(bottomwin, colorpair);
|
||||
@@ -2280,6 +2336,7 @@ void statusline(message_type importance, const char *msg, ...)
|
||||
|
||||
/* Push the message to the screen straightaway. */
|
||||
wrefresh(bottomwin);
|
||||
free(message);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (old_whitespace)
|
||||
@@ -2429,16 +2486,6 @@ void place_the_cursor(void)
|
||||
* from_col is the column number of the first character of this "page". */
|
||||
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. */
|
||||
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. */
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
/* If line numbering is switched on, put a line number in front of
|
||||
* the text -- but only for the parts that are not softwrapped. */
|
||||
@@ -2455,7 +2502,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||
if (line->has_anchor && (from_col == 0 || !ISSET(SOFTWRAP)))
|
||||
#ifdef ENABLE_UTF8
|
||||
if (using_utf8())
|
||||
wprintw(edit, "\xE2\x97\x86"); /* black diamond */
|
||||
wprintw(edit, "\xE2\xAC\xA5"); /* black medium diamond */
|
||||
else
|
||||
#endif
|
||||
wprintw(edit, "+");
|
||||
@@ -2483,15 +2530,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. */
|
||||
@@ -2501,87 +2548,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)
|
||||
@@ -2593,14 +2634,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;
|
||||
@@ -2614,7 +2655,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. */
|
||||
@@ -2622,79 +2663,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);
|
||||
@@ -2705,23 +2754,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 */
|
||||
@@ -2844,7 +2902,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;
|
||||
@@ -2905,7 +2963,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);
|
||||
@@ -3024,22 +3082,26 @@ bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge)
|
||||
/* Draw a scroll bar on the righthand side of the screen. */
|
||||
void draw_scrollbar(void)
|
||||
{
|
||||
int totalrows = openfile->filebot->lineno;
|
||||
int first_row = openfile->edittop->lineno;
|
||||
int totallines = openfile->filebot->lineno;
|
||||
int fromline = openfile->edittop->lineno - 1;
|
||||
int coveredlines = editwinrows;
|
||||
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
for (linestruct *ln = openfile->filetop; ln != openfile->edittop; ln = ln->next)
|
||||
first_row += ln->extrarows;
|
||||
first_row += chunk_for(openfile->firstcolumn, openfile->edittop);
|
||||
linestruct *line = openfile->edittop;
|
||||
int extras = extra_chunks_in(line) - chunk_for(openfile->firstcolumn, line);
|
||||
|
||||
for (linestruct *ln = openfile->filetop; ln != NULL; ln = ln->next)
|
||||
totalrows += ln->extrarows;
|
||||
while (line->lineno + extras < fromline + editwinrows && line->next) {
|
||||
line = line->next;
|
||||
extras += extra_chunks_in(line);
|
||||
}
|
||||
|
||||
coveredlines = line->lineno - fromline;
|
||||
}
|
||||
|
||||
int lowest = ((first_row - 1) * editwinrows) / totalrows;
|
||||
int highest = lowest + (editwinrows * editwinrows) / totalrows;
|
||||
int lowest = (fromline * editwinrows) / totallines;
|
||||
int highest = lowest + (editwinrows * coveredlines) / totallines;
|
||||
|
||||
if (editwinrows > totalrows)
|
||||
if (editwinrows > totallines)
|
||||
highest = editwinrows;
|
||||
|
||||
for (int row = 0; row < editwinrows; row++) {
|
||||
@@ -3253,14 +3315,11 @@ size_t actual_last_column(size_t leftedge, size_t column)
|
||||
return leftedge + column;
|
||||
}
|
||||
|
||||
/* Return TRUE if current[current_x] is above the top of the screen, and FALSE
|
||||
* otherwise. */
|
||||
/* Return TRUE if current[current_x] is before the viewport. */
|
||||
bool current_is_above_screen(void)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP))
|
||||
/* The cursor is above screen when current[current_x] is before edittop
|
||||
* at column firstcolumn. */
|
||||
return (openfile->current->lineno < openfile->edittop->lineno ||
|
||||
(openfile->current->lineno == openfile->edittop->lineno &&
|
||||
xplustabs() < openfile->firstcolumn));
|
||||
@@ -3269,8 +3328,7 @@ bool current_is_above_screen(void)
|
||||
return (openfile->current->lineno < openfile->edittop->lineno);
|
||||
}
|
||||
|
||||
/* Return TRUE if current[current_x] is below the bottom of the screen, and
|
||||
* FALSE otherwise. */
|
||||
/* Return TRUE if current[current_x] is beyond the viewport. */
|
||||
bool current_is_below_screen(void)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
@@ -3283,16 +3341,14 @@ bool current_is_below_screen(void)
|
||||
return (go_forward_chunks(editwinrows - 1, &line, &leftedge) == 0 &&
|
||||
(line->lineno < openfile->current->lineno ||
|
||||
(line->lineno == openfile->current->lineno &&
|
||||
leftedge < leftedge_for(xplustabs(),
|
||||
openfile->current))));
|
||||
leftedge < leftedge_for(xplustabs(), openfile->current))));
|
||||
} else
|
||||
#endif
|
||||
return (openfile->current->lineno >=
|
||||
openfile->edittop->lineno + editwinrows);
|
||||
}
|
||||
|
||||
/* Return TRUE if current[current_x] is offscreen relative to edittop, and
|
||||
* FALSE otherwise. */
|
||||
/* Return TRUE if current[current_x] is outside the viewport. */
|
||||
bool current_is_offscreen(void)
|
||||
{
|
||||
return (current_is_above_screen() || current_is_below_screen());
|
||||
@@ -3361,6 +3417,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) {
|
||||
@@ -3380,6 +3442,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);
|
||||
|
||||
@@ -3458,9 +3524,11 @@ void report_cursor_position(void)
|
||||
charpct = (openfile->totsize == 0) ? 0 : 100 * sum / openfile->totsize;
|
||||
|
||||
statusline(INFO,
|
||||
_("line %zd/%zd (%d%%), col %zu/%zu (%d%%), char %zu/%zu (%d%%)"),
|
||||
_("line %*zd/%zd (%2d%%), col %2zu/%2zu (%3d%%), char %*zu/%zu (%2d%%)"),
|
||||
digits(openfile->filebot->lineno),
|
||||
openfile->current->lineno, openfile->filebot->lineno, linepct,
|
||||
column, fullwidth, colpct, sum, openfile->totsize, charpct);
|
||||
column, fullwidth, colpct,
|
||||
digits(openfile->totsize), sum, openfile->totsize, charpct);
|
||||
}
|
||||
|
||||
/* Highlight the text between the given two columns on the current line. */
|
||||
@@ -3484,11 +3552,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[SPOTLIGHTED]);
|
||||
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[SPOTLIGHTED]);
|
||||
|
||||
free(word);
|
||||
}
|
||||
@@ -3524,9 +3592,9 @@ void spotlight_softwrapped(size_t from_col, size_t to_col)
|
||||
word = display_string(openfile->current->data, from_col,
|
||||
break_col - from_col, FALSE, FALSE);
|
||||
|
||||
wattron(edit, interface_color_pair[SELECTED_TEXT]);
|
||||
wattron(edit, interface_color_pair[SPOTLIGHTED]);
|
||||
waddnstr(edit, word, actual_x(word, break_col));
|
||||
wattroff(edit, interface_color_pair[SELECTED_TEXT]);
|
||||
wattroff(edit, interface_color_pair[SPOTLIGHTED]);
|
||||
|
||||
free(word);
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ color red "\<[A-Z_]{2,}\>"
|
||||
color brightgreen "\.(data|subsection|text)"
|
||||
color green "\.(align|file|globl|global|hidden|section|size|type|weak)"
|
||||
color brightyellow "\.(ascii|asciz|byte|double|float|hword|int|long|short|single|struct|word)"
|
||||
color brightred "^[[:space:]]*[.0-9A-Za-z_]*:"
|
||||
color brightcyan "^[[:space:]]*#[[:space:]]*(define|undef|include|ifn?def|endif|elif|else|if|warning|error)"
|
||||
color brightred "^[[:blank:]]*[.0-9A-Za-z_]*:"
|
||||
color brightcyan "^[[:blank:]]*#[[:blank:]]*(define|undef|include|ifn?def|endif|elif|else|if|warning|error)"
|
||||
|
||||
# Strings.
|
||||
color brightyellow "<[^= ]*>" ""(\\.|[^"])*""
|
||||
|
||||
@@ -23,7 +23,7 @@ color red ""[^"]*"" "'[^']*'"
|
||||
color green "`[^`]*`"
|
||||
|
||||
# Error lines:
|
||||
color brightred "^[[:space:]]*\*\*\*.*"
|
||||
color brightred "^[[:blank:]]*\*\*\*.*"
|
||||
|
||||
# Brackets:
|
||||
color magenta "\[|\]|\(|\)"
|
||||
|
||||
@@ -31,7 +31,7 @@ color magenta "\<(bindtextdomain|dcgettext|dcngettext)\>"
|
||||
# Strings.
|
||||
color brightyellow "<[^= ]*>" ""(\\.|[^"])*""
|
||||
# Comments.
|
||||
color brightblue "(^|[[:space:]])#.*$"
|
||||
color brightblue "(^|[[:blank:]])#.*$"
|
||||
|
||||
# Trailing whitespace.
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
## Syntax highlighting for C and C++ files.
|
||||
|
||||
syntax c "\.([ch](pp|xx)?|C|cc|c\+\+|cu|H|hh|ii?)$"
|
||||
header "-\*-.*\<C(\+\+)?((;|\s).*)?-\*-"
|
||||
header "-\*-.*\<C(\+\+)?((;|[[:blank:]]).*)?-\*-"
|
||||
magic "^(C|C\+\+) (source|program)"
|
||||
comment "//"
|
||||
|
||||
# Constants.
|
||||
color brightred "\<[A-Z_][0-9A-Z_]*\>"
|
||||
# Labels.
|
||||
color brightmagenta "^[[:space:]]*[A-Z_a-z]+:[[:space:]]*$"
|
||||
color brightmagenta "^[[:blank:]]*[A-Z_a-z][0-9A-Z_a-z]*:[[:blank:]]*$"
|
||||
color normal ":[[:blank:]]*$"
|
||||
|
||||
# Types and related keywords.
|
||||
color green "\<(auto|bool|char|const|double|enum|extern|float|inline|int|long|restrict|short|signed|sizeof|static|struct|typedef|union|unsigned|void)\>"
|
||||
@@ -25,15 +26,15 @@ color magenta "\<(break|continue|goto|return)\>"
|
||||
color brightmagenta "'([^'\]|\\(["'\abfnrtv]|x[0-9A-Fa-f]{1,2}|[0-3]?[0-7]{1,2}))'"
|
||||
|
||||
# GCC builtins.
|
||||
color cyan "__attribute__[[:space:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
|
||||
color cyan "__attribute__[[:blank:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
|
||||
|
||||
# Strings. (In general you will want your strings and comments to come last,
|
||||
# because highlighting rules are applied in the order they are read in.)
|
||||
color brightyellow ""([^"]|\\")*"" "#[[:space:]]*include[[:space:]]+<[^[:blank:]=]*>"
|
||||
color brightyellow ""([^"]|\\")*"" "#[[:blank:]]*include[[:blank:]]*<[^>]+>"
|
||||
|
||||
# Preprocessor directives.
|
||||
color brightcyan start="^[[:space:]]*#[[:space:]]*(if(n?def)?|elif|warning|error|pragma)\>" end="(\`|[^\\])$"
|
||||
color brightcyan "^[[:space:]]*#[[:space:]]*((define|else|endif|include(_next)?|line|undef)\>|$)"
|
||||
color brightcyan start="^[[:blank:]]*#[[:blank:]]*(if(n?def)?|elif|warning|error|pragma)\>" end="(\`|[^\\])$"
|
||||
color brightcyan "^[[:blank:]]*#[[:blank:]]*((define|else|endif|include(_next)?|line|undef)\>|$)"
|
||||
|
||||
# Comments.
|
||||
color brightblue "//.*"
|
||||
|
||||
@@ -13,7 +13,7 @@ color red "^(19|20)[0-9-]{8}"
|
||||
color yellow "<[^>]*@[^>]*>"
|
||||
|
||||
# Command-line options.
|
||||
color cyan "[[:space:]]-[a-zA-Z\$]" "--[8a-z-]+"
|
||||
color cyan "[[:blank:]]-[a-zA-Z\$]" "--[8a-z-]+"
|
||||
# Bug and patch numbers.
|
||||
color cyan "(BZ|bug|patch)[ ]#[0-9]+" "PR [[:alnum:]]+/[0-9]+"
|
||||
# Probable constants, for variety.
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
syntax cmake "(CMakeLists\.txt|\.cmake)$"
|
||||
comment "#"
|
||||
|
||||
color green "^[[:space:]]*[0-9A-Za-z_]+"
|
||||
icolor brightyellow "^[[:space:]]*(include|include_directories|include_external_msproject)\>"
|
||||
color green "^[[:blank:]]*[0-9A-Za-z_]+"
|
||||
icolor brightyellow "^[[:blank:]]*(include|include_directories|include_external_msproject)\>"
|
||||
|
||||
icolor brightgreen "^[[:space:]]*((else|end)?if|else|(end)?while|(end)?foreach|break)\>"
|
||||
color brightgreen "\<(NOT|COMMAND|POLICY|TARGET|EXISTS|IS_(DIRECTORY|ABSOLUTE)|DEFINED)[[:space:]]"
|
||||
color brightgreen "[[:space:]](OR|AND|IS_NEWER_THAN|MATCHES|(STR|VERSION_)?(LESS|GREATER|EQUAL))[[:space:]]"
|
||||
icolor brightgreen "^[[:blank:]]*((else|end)?if|else|(end)?while|(end)?foreach|break)\>"
|
||||
color brightgreen "\<(NOT|COMMAND|POLICY|TARGET|EXISTS|IS_(DIRECTORY|ABSOLUTE)|DEFINED)[[:blank:]]"
|
||||
color brightgreen "[[:blank:]](OR|AND|IS_NEWER_THAN|MATCHES|(STR|VERSION_)?(LESS|GREATER|EQUAL))[[:blank:]]"
|
||||
|
||||
icolor brightred "^[[:space:]]*((end)?(function|macro)|return)"
|
||||
icolor brightred "^[[:blank:]]*((end)?(function|macro)|return)"
|
||||
|
||||
icolor cyan start="\$(ENV)?\{" end="\}"
|
||||
color magenta "\<(APPLE|UNIX|WIN32|CYGWIN|BORLAND|MINGW|MSVC(_IDE|60|71|80|90)?)\>"
|
||||
|
||||
color brightblue "(^|[[:space:]])#.*"
|
||||
color brightblue "(^|[[:blank:]])#.*"
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
@@ -5,7 +5,7 @@ syntax default
|
||||
comment "#"
|
||||
|
||||
# Comments.
|
||||
color cyan "^[[:space:]]*#.*"
|
||||
color cyan "^[[:blank:]]*#.*"
|
||||
|
||||
# Spaces in front of tabs.
|
||||
color ,red " + +"
|
||||
|
||||
@@ -30,4 +30,4 @@ color blue ":(\w|[?-])+"
|
||||
color yellow start="^[[:blank:]]+"" end="[^\]""
|
||||
color yellow ""(\\.|[^"])*""
|
||||
# Comments
|
||||
color cyan "(^|[[:space:]]);.*"
|
||||
color cyan "(^|[[:blank:]]);.*"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## Syntax highlighting for Gentoo ebuilds/eclasses,
|
||||
## and (further down) for Portage control files.
|
||||
|
||||
syntax ebuild "\.e(build|class|blit)$"
|
||||
syntax ebuild "\.e(build|class)$"
|
||||
comment "#"
|
||||
|
||||
## All the standard portage functions:
|
||||
@@ -17,25 +17,25 @@ color green "-(eq|ne|gt|lt|ge|le)\>"
|
||||
## Variables... official portage ones in red, all others in bright red:
|
||||
color brightred "\$[-0-9@*#?$!]" "\$[[:alpha:]_][[:alnum:]_]*"
|
||||
color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:digit:]]|@)+\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
|
||||
color red "\<(EAPI|ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|[BHPR]?DEPEND|PROVIDE|PROPERTIES|REQUIRED_USE|RESTRICT|USERLAND)\>"
|
||||
color red "\<(S|E?D|T|PV|PF|P|PN|PR|PVR|A|CATEGORY|DISTDIR|FILESDIR|EPREFIX|E?ROOT|WORKDIR)\>"
|
||||
color red "\<(EAPI|ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|[BIPR]?DEPEND|PROVIDE|PROPERTIES|REQUIRED_USE|RESTRICT|USERLAND)\>"
|
||||
color red "\<(S|E?D|T|PV|PF|P|PN|PR|PVR|A|CATEGORY|DISTDIR|FILESDIR|EPREFIX|(B|E|E?SYS)?ROOT|WORKDIR)\>"
|
||||
color red "\<(AS|C(PP|XX)?|LD)FLAGS\>" "\<C(HOST|TARGET|BUILD)\>" "\<(MERGE_TYPE|REPLACING_VERSIONS|REPLACED_BY_VERSION)\>"
|
||||
color red "\<EBUILD_PHASE(_FUNC)?\>"
|
||||
color red "\<QA_((TEXTRELS|EXECSTACK|WX_LOAD)(_[a-zA-Z_0-9]+)?|DT_HASH|PRESTRIPPED)\>"
|
||||
color red "\<(PATCHES|(HTML_)?DOCS)\>" "\<WANT_(AUTO(CONF|MAKE)|LIBTOOL)\>" "\<AT_M4DIR\>"
|
||||
## Portage commands:
|
||||
color magenta "\<(use(_(with|enable|if_iuse)|x)?|in_iuse) [!a-zA-Z0-9_+ -]*" "inherit.*"
|
||||
color brightblue "\<e(begin|end|conf|install|make|qmake4|ant|(qa)?warn|infon?|error|log|patch(_user)?|new(group|user))\>"
|
||||
color brightblue "\<e(apply(_user)?|begin|end|conf|install|make|ninja|qmake5|ant|(qa)?warn|infon?|error|log|patch(_user)?|new(group|user))\>"
|
||||
color brightblue "\<e(pause|beep|mktemp|(cvs|svn)_clean|punt_cxx)\>" "\<e(aclocal|auto(reconf|header|conf|make)|libtoolize)\>"
|
||||
color brightblue "\<e(stack|shopts|umask)_(push|pop)\>" "\<version_is_at_least\>"
|
||||
color brightblue "\<e(stack|shopts|umask)_(push|pop)\>" "\<get_libdir\>" "\<ver_(cut|rs|test)\>" "\<version_is_at_least\>"
|
||||
color brightblue "\<make_desktop_entry\>" "\<unpack(_(makeself|pdv))?\>"
|
||||
color brightblue "\<(die|hasv?|inherit|nonfatal)\>" "\<(use(_(with|enable|if_iuse)|x)?|in_iuse)\>" "\<(has|best)_version\>"
|
||||
color brightblue "\<(do|new)(ins|(games)?s?bin|doc|lib(\.so|\.a)?|man|info|exe|initd|confd|envd|pam|menu|icon)\>"
|
||||
color brightblue "\<do(compress|header|python|sed|dir|hard|sym|html|jar|mo)\>" "\<keepdir\>"
|
||||
color brightblue "\<prepall(docs|info|man|strip)?\>" "\<prep(info|lib|lib\.(so|a)|man|strip|gamesdirs)\>"
|
||||
color brightblue "\<(doc|ins|exe)?into\>" "\<(f|games)(owners|perms)\>" "\<(exe|ins|dir)opts\>"
|
||||
color brightblue "\<(do|new)(ins|s?bin|doc|header|lib(\.so|\.a)?|man|info|exe|initd|confd|envd|pam|menu|icon)\>"
|
||||
color brightblue "\<do(compress|dir|html|mo|strip|sym)\>" "\<keepdir\>"
|
||||
color brightblue "\<prepall(docs|info|man|strip)?\>" "\<prep(info|lib|lib\.(so|a)|man|strip)\>"
|
||||
color brightblue "\<(doc|ins|exe)?into\>" "\<f(owners|perms)\>" "\<(exe|ins|dir)opts\>"
|
||||
color brightblue "\<tc-get(BUILD_)?(AR|AS|CC|CPP|CXX|LD|NM|OBJCOPY|PKG_CONFIG|RANLIB)\>"
|
||||
color brightblue "\<tc-(arch(-kernel)?|export|has-(tls|openmp))\>"
|
||||
color brightblue "\<tc-(arch(-kernel)?|export|has-(tls|openmp)|is-cross-compiler)\>"
|
||||
## Common commands used in ebuilds:
|
||||
color blue "\<(awk|cat|cd|chmod|chown|cp|echo|env|find|e?grep|ln|make|mkdir|mv|popd|printf|pushd|rm|rmdir|sed|set|tar|touch|unset|xargs)\>"
|
||||
## Comments (doesn't work that well):
|
||||
@@ -60,7 +60,7 @@ color magenta ":[^[:space:]]+([[:space:]]|$)"
|
||||
color brightred "[[:space:]]+\+?[A-Za-z0-9+_@-]+"
|
||||
color brightblue "[[:space:]]+-[A-Za-z0-9+_@-]+"
|
||||
## Accepted arches:
|
||||
color white "[~-]?\<(alpha|amd64|arm(64)?|hppa|ia64|m68k|mips|nios2|ppc(64)?|riscv|s390|sh|sparc|x86)(-(aix|(f|free|net|open)bsd|cygwin|hpux|interix|linux|macos|mint|solaris|winnt))?\>"
|
||||
color white "[~-]?\<(alpha|amd64|arm(64)?|hppa|ia64|m68k|mips|ppc(64)?|riscv|s390|sparc|x86)(-(cygwin|linux|macos|solaris|winnt))?\>"
|
||||
color white "[[:space:]][*~-]?\*"
|
||||
## Categories:
|
||||
color cyan "^[[:space:]]*[^/]*/"
|
||||
|
||||
@@ -11,7 +11,7 @@ formatter gofmt -w
|
||||
# Types.
|
||||
color green "\<(bool|u?int(8|16|32|64)?|float(32|64)|complex(64|128)|byte|rune|uintptr|string|error)\>"
|
||||
color green "\<(chan|const|func|interface|map|struct|type|var)\>"
|
||||
color green "<-[[:space:]]*chan\>|\<chan[[:space:]]*<-"
|
||||
color green "<-[[:blank:]]*chan\>|\<chan[[:blank:]]*<-"
|
||||
|
||||
# Predefined functions.
|
||||
color blue "\<(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)\>"
|
||||
@@ -36,14 +36,14 @@ color red "\<[0-9]+i\>"
|
||||
color red "\<(true|false|nil|iota|_)\>"
|
||||
color red "'(\\.|[^'])+'"
|
||||
color red ""(\\.|[^"])*""
|
||||
color red start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
|
||||
color red start=""(\\.|[^"])*\\[[:blank:]]*$" end="^(\\.|[^"])*""
|
||||
|
||||
# Comments.
|
||||
color brightblue "//.*"
|
||||
color brightblue start="/\*" end="\*/"
|
||||
|
||||
# Special comments.
|
||||
color brightcyan "//[[:space:]]*\+build[[:space:]]+(([a-zA-Z_0-9]+[[:space:]]*)+,[[:space:]]*)*[a-zA-Z_0-9]+"
|
||||
color brightcyan "//[[:blank:]]*\+build[[:blank:]]+(([a-zA-Z_0-9]+[[:blank:]]*)+,[[:blank:]]*)*[a-zA-Z_0-9]+"
|
||||
|
||||
# Trailing whitespace.
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
@@ -13,7 +13,7 @@ color brightmagenta "\\f(.|\(..)" "\\s(\+|\-)?[0-9]"
|
||||
color cyan "\\(\\)?n(.|\(..)"
|
||||
color cyan start="\\(\\)?n\[" end="]"
|
||||
# Requests
|
||||
color brightgreen "^\.[[:space:]]*[^[:space:]]*"
|
||||
color brightgreen "^\.[[:blank:]]*[^[:space:]]*"
|
||||
# Comments
|
||||
color yellow "^\.\\".*"
|
||||
# Strings
|
||||
|
||||
@@ -21,4 +21,4 @@ color blue "#?:(\w|[?-])+"
|
||||
color yellow start="^[[:blank:]]+"" end="[^\]""
|
||||
color yellow ""(\\.|[^"])*""
|
||||
# Comments
|
||||
color cyan "(^|[[:space:]]);.*"
|
||||
color cyan "(^|[[:blank:]]);.*"
|
||||
|
||||
@@ -19,7 +19,7 @@ color cyan "\<(true|false|null|undefined)\>"
|
||||
# Strings.
|
||||
color brightmagenta ""(\\.|[^"])*"" "'(\\.|[^'])*'" "`(\\.|[^`])*`"
|
||||
# Comments.
|
||||
color brightblue "(^|[[:space:]])//.*"
|
||||
color brightblue "(^|[[:blank:]])//.*"
|
||||
color brightblue start="/\*" end="\*/"
|
||||
|
||||
# Trailing whitespace.
|
||||
|
||||
@@ -8,18 +8,18 @@ syntax json "\.json$"
|
||||
comment ""
|
||||
|
||||
# Numbers (used as value).
|
||||
color green ":[[:space:]]*\-?(0|[1-9][0-9]*)(\.[0-9]+)?([Ee]?[-+]?[0-9]+)?"
|
||||
color green ":[[:blank:]]*\-?(0|[1-9][0-9]*)(\.[0-9]+)?([Ee]?[-+]?[0-9]+)?"
|
||||
# Values (well, any string).
|
||||
color brightmagenta "".+""
|
||||
# Hex numbers (used as value).
|
||||
color green ":[[:space:]]*"#[0-9abcdefABCDEF]+""
|
||||
color green ":[[:blank:]]*"#[0-9abcdefABCDEF]+""
|
||||
# Escapes.
|
||||
color green "\\\\" "\\"" "\\[bfnrt]" "\\u[0-9abcdefABCDEF]{4})"
|
||||
# Special words.
|
||||
color green "\<(true|false|null)\>"
|
||||
|
||||
# Names (very unlikely to contain a quote).
|
||||
color brightblue ""[^"]+"[[:space:]]*:"
|
||||
color brightblue ""[^"]+"[[:blank:]]*:"
|
||||
|
||||
# Brackets, braces, and separators.
|
||||
color brightblue "\[" "\]"
|
||||
@@ -27,7 +27,7 @@ color brightred "\{" "\}"
|
||||
color brightred "," ":"
|
||||
|
||||
# Comments.
|
||||
color cyan "(^|[[:space:]]+)(//|#).*"
|
||||
color cyan "(^|[[:blank:]]+)(//|#).*"
|
||||
|
||||
# Trailing whitespace.
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
@@ -20,7 +20,7 @@ color normal "\.\.\."
|
||||
color brightblue "\<(do|end|while|repeat|until|if|elseif|then|else|for|in|function|local|return|break)\>"
|
||||
|
||||
# Keywords
|
||||
color brightyellow "\<(_G|_VERSION|assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|module|next|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\s*\("
|
||||
color brightyellow "\<(_G|_VERSION|assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|module|next|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)[[:blank:]]*\("
|
||||
|
||||
# Standard library
|
||||
color brightyellow "\<coroutine\.(create|isyieldable|resume|running|status|wrap|yield)\>"
|
||||
|
||||
@@ -18,7 +18,7 @@ color blue "\$+[{(][a-zA-Z0-9_-]+[})]"
|
||||
color brightblue "^[^ ]+:"
|
||||
|
||||
# Comments.
|
||||
color green "(^|[[:space:]]+)#.*"
|
||||
color green "(^|[[:blank:]]+)#.*"
|
||||
|
||||
# Trailing whitespace.
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
@@ -4,8 +4,14 @@
|
||||
syntax nanohelp
|
||||
|
||||
# Key combos:
|
||||
color cyan "\^[]/4-8@A-Z\^_`◀▶▲▼]" "[◀▶▲▼]" "\<(M|S[Hh]-[Mm])-." "\<F([1-9]|1[0-9]|2[0-4])"
|
||||
color cyan "\^[]/4-8@A-Z\^_`◂▸▴▾-]" "[◂▸▴▾]" "\<(M|S[Hh]-[Mm])-[^")”»“」]" "\<F([1-9]|1[0-9]|2[0-4])"
|
||||
color cyan "\<((Sh-)?Tab|Enter|Ins|(Sh-\^?)?Del|Space|Bsp|Up|Down|Left|Right|Home|End|PgUp|PgDn)\>"
|
||||
|
||||
# Colorize M-) and M-" only when between parentheses...
|
||||
color cyan "\(M-(\)|")\)"
|
||||
color normal " \(|\) "
|
||||
# ...or when at start of line.
|
||||
color cyan "^M-(\)|")"
|
||||
|
||||
# Quoted indicators:
|
||||
color brightred "'(\^|M-)'"
|
||||
|
||||
@@ -1,32 +1,36 @@
|
||||
## Syntax highlighting for nanorc files.
|
||||
|
||||
syntax nanorc "\.?nanorc$"
|
||||
syntax nanorc "\.?nanorc(\.in)?$"
|
||||
comment "#"
|
||||
|
||||
# Everything that does not get recolored is invalid
|
||||
color brightred ".*"
|
||||
|
||||
# Color names
|
||||
color yellow "^[[:blank:]]*(i?color|set[[:blank:]]+((error|function|key|mini|number|prompt|scroller|selected|spotlight|status|stripe|title)color))[[:blank:]]+(bold,)?(italic,)?(((bright|light)?(white|black|red|blue|green|yellow|magenta|cyan))|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte|grey|gray)?(,(((light)?(white|black|red|blue|green|yellow|magenta|cyan))|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte|grey|gray))?\>"
|
||||
|
||||
# Keywords
|
||||
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|markmatch|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|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|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:]]*$)"
|
||||
color brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|comment|formatter|linter|tabgives)[[:space:]]+.*"
|
||||
color brightgreen "^[[:space:]]*(syntax[[:space:]]+[^[:blank:]]+|(formatter|linter)[[:space:]]+.+)"
|
||||
color green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|formatter|linter|tabgives|extendsyntax)\>"
|
||||
color brightgreen "^[[:blank:]]*(set|unset)[[:blank:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|boldtext|bookstyle|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|historylog|indicator|jumpyscrolling|linenumbers|locking|magic|minibar|mouse|multibuffer|noconvert|nohelp|nonewlines|positionlog|preserve|quickblank|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|softwrap|stateflags|suspendable|tabstospaces|trimblanks|unix|wordbounds|zap)\>"
|
||||
color brightgreen "^[[:blank:]]*set[[:blank:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|minicolor|numbercolor|operatingdir|promptcolor|punct|quotestr|scrollercolor|selectedcolor|speller|spotlightcolor|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:blank:]]+"
|
||||
color brightgreen "^[[:blank:]]*set[[:blank:]]+(fill[[:blank:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:blank:]]+[1-9][0-9]*)\>"
|
||||
color brightgreen "^[[:blank:]]*bind[[:blank:]]+((\^([A-Za-z]|[]/@\^_`-]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:blank:]]+([a-z]+|".*")[[:blank:]]+(main|help|search|replace(with)?|yesno|gotoline|writeout|insert|browser|whereisfile|gotodir|execute|spell|linter|all)([[:blank:]]+#|[[:blank:]]*$)"
|
||||
color brightgreen "^[[:blank:]]*unbind[[:blank:]]+((\^([A-Za-z]|[]/@\^_`-]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:blank:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:blank:]]+#|[[:blank:]]*$)"
|
||||
color brightgreen "^[[:blank:]]*extendsyntax[[:blank:]]+[[:alpha:]]+[[:blank:]]+(i?color|header|magic|comment|formatter|linter|tabgives)[[:blank:]]+.*"
|
||||
color brightgreen "^[[:blank:]]*(syntax[[:blank:]]+[^[:space:]]+|(formatter|linter)[[:blank:]]+.+)"
|
||||
color green "^[[:blank:]]*((un)?(bind|set)|include|syntax|header|magic|comment|formatter|linter|tabgives|extendsyntax)\>"
|
||||
|
||||
# Strings
|
||||
color brightmagenta "([[:space:]]|(start|end)=)".+"([[:space:]]|$)"
|
||||
color brightmagenta "([[:blank:]]|(start|end)=)".+"([[:blank:]]|$)"
|
||||
|
||||
# Colors
|
||||
color yellow "^[[:space:]]*i?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 magenta "^[[:space:]]*i?color\>" "\<(start|end)="
|
||||
# Control codes
|
||||
color bold,pink "[[:cntrl:]]"
|
||||
|
||||
# Color commands
|
||||
color magenta "^[[:blank:]]*i?color\>" "\<(start|end)="
|
||||
|
||||
# Comments
|
||||
color brightblue "(^|[[:space:]]+)#.*"
|
||||
color cyan "^[[:space:]]*##.*"
|
||||
color brightblue "(^|[[:blank:]]+)#.*"
|
||||
color cyan "^[[:blank:]]*##.*"
|
||||
|
||||
# Trailing whitespace
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
@@ -20,7 +20,7 @@ color red "\<(drop|reject)\>"
|
||||
color brightblue "\<(accept|continue|(d|s)nat|goto|jump|masquerade|return)\>"
|
||||
|
||||
# Comments
|
||||
color cyan "(^|[[:space:]])#.*"
|
||||
color cyan "(^|[[:blank:]])#.*"
|
||||
|
||||
# Trailing whitespace
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
@@ -15,13 +15,13 @@ color brightgreen "\<(goto|continue|break|return)\>"
|
||||
color brightgreen "@(encode|end|implementation|interface)|selector)\>"
|
||||
|
||||
# GCC builtins.
|
||||
color cyan "__attribute__[[:space:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
|
||||
color cyan "__attribute__[[:blank:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
|
||||
|
||||
# Selector/method.
|
||||
color brightmagenta "(^|[[:space:]])\[.*[[:space:]].*\]"
|
||||
color brightmagenta "(^|[[:blank:]])\[.*[[:blank:]].*\]"
|
||||
color white ":[[:alnum:]]*"
|
||||
color magenta "[[:alnum:]]*:"
|
||||
color white "\[[^][:space:]]*\]"
|
||||
color white "\[[^][:blank:]]*\]"
|
||||
|
||||
# Strings.
|
||||
color brightblack "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
|
||||
@@ -29,7 +29,7 @@ color brightblack "<[^= ]*>" ""(\\.|[^"])*""
|
||||
color brightblue "@"(\\.|[^"])*""
|
||||
|
||||
# Preprocessor commands.
|
||||
color brightblue "^[[:space:]]*#[[:space:]]*(define|include|import|(un|ifn?)def|endif|el(if|se)|if|warning|error)"
|
||||
color brightblue "^[[:blank:]]*#[[:blank:]]*(define|include|import|(un|ifn?)def|endif|el(if|se)|if|warning|error)"
|
||||
|
||||
# Comments.
|
||||
color yellow "//.*"
|
||||
|
||||
@@ -12,13 +12,11 @@ color magenta "\<(continue|else|elsif|do|for|foreach|if|unless|until|while|eq|ne
|
||||
color cyan "[$%&@]([A-Za-z_][0-9A-Za-z_]*|\^[][A-Z?\^_]|[0-9]+)\>"
|
||||
color cyan "[$%&@]\{(\^?[A-Za-z_][0-9A-Za-z_]*|\^[][?\^][0-9]+)\}"
|
||||
color cyan "[$%&@]([][!"#'()*+,.:;<=>?`|~-]|\{[][!-/:-@\`|~]\})|\$[$%&@]"
|
||||
color cyan "(^|[[:space:]])[$%@][/\]"
|
||||
color cyan "(^|[[:blank:]])[$%@][/\]"
|
||||
|
||||
color yellow "".*"|qq\|.*\|"
|
||||
color white "[sm]/.*/"
|
||||
color white start="(^use| = new)" end=";"
|
||||
|
||||
# Comments.
|
||||
color green "(^|[[:space:]])#.*"
|
||||
|
||||
color yellow start="<< 'STOP'" end="STOP"
|
||||
color green "(^|[[:blank:]])#.*"
|
||||
|
||||
@@ -5,7 +5,7 @@ magic "PHP script"
|
||||
comment "//"
|
||||
|
||||
# PHP markings.
|
||||
color brightgreen "(<\?(php)?|\?>)"
|
||||
color brightgreen "(<\?(php|=)?|\?>)"
|
||||
|
||||
# Function names.
|
||||
color white "\<[A-Za-z_][A-Za-z_0-9]*\("
|
||||
@@ -28,7 +28,7 @@ color magenta "\<(break|continue|goto|return)\>"
|
||||
color brightyellow ""(\.|[^"])*"" "'(\.|[^'])*'"
|
||||
|
||||
# Comments.
|
||||
color brightblue "(^|[[:space:]]+)//.*"
|
||||
color brightblue "(^|[[:blank:]]+)//.*"
|
||||
color brightblue start="/\*" end="\*/"
|
||||
|
||||
# Trailing whitespace.
|
||||
|
||||
@@ -22,7 +22,7 @@ color brightblue "^(msgid|msgid_plural|msgstr)\>"
|
||||
color red " fuzzy(,|$)"
|
||||
color yellow " (no-)?[-[:alpha:]]+-format(,|$)"
|
||||
# Format specifiers.
|
||||
color brightmagenta "%([1-9]\$)?[a-z]*"
|
||||
color brightmagenta "%([1-9]\$)?[#0 +'I-]?(\*([1-9]\$)?|[1-9](\.[0-9]?)?)?[hlLjzt]?[diouxXeEfFgGaAcspnm%]"
|
||||
# Quotes and escaped characters.
|
||||
color yellow """
|
||||
color cyan "\\([abcefnrtv"\]|x[0-9abcdefABCDEF]{2}|[0-7]{3})"
|
||||
|
||||
@@ -31,7 +31,5 @@ color green "'([^']|(\\'))*'" "%[qw]\{[^}]*\}" "%[qw]\([^)]*\)" "%[qw]<[^>]*>" "
|
||||
# Comments.
|
||||
color cyan "#[^{].*" "#$"
|
||||
color brightcyan "##[^{].*" "##$"
|
||||
# "Here" docs.
|
||||
color green start="<<-?'?EOT'?" end="^EOT"
|
||||
# Some common markers.
|
||||
color brightcyan "XXX|TODO|FIXME|\?\?\?"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## Syntax highlighting for Rust.
|
||||
|
||||
## Copyright 2015 Luke Francl.
|
||||
## Licensed under GPL version 3.
|
||||
## Licensed under GPL version 3 or newer.
|
||||
|
||||
syntax rust "\.(rlib|rs)$"
|
||||
comment "//"
|
||||
|
||||
@@ -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 "^#!.*/((env\s+)?((a|ba|c|da|k|mk|pdk|tc|z)?sh)|busybox\s+sh|openrc-run|runscript)\>"
|
||||
header "^#!.*/((env[[:blank:]]+)?((a|ba|c|da|k|mk|pdk|tc|z)?sh)|busybox[[:blank:]]+sh|openrc-run|runscript)\>"
|
||||
header "-\*-.*shell-script.*-\*-"
|
||||
magic "(POSIX|Bourne-Again) shell script.*text"
|
||||
comment "#"
|
||||
@@ -27,10 +27,10 @@ color normal "[.-]tar\>"
|
||||
# Basic variable names (no braces).
|
||||
color brightred "\$[-0-9@*#?$!]" "\$[[:alpha:]_][[:alnum:]_]*"
|
||||
# More complicated variable names; handles braces and replacements and arrays.
|
||||
color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:space:]]*[[:alnum:]_]+[[:space:]]*|@)\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
|
||||
color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:blank:]]*[[:alnum:]_]+[[:blank:]]*|@)\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
|
||||
|
||||
# Comments.
|
||||
color cyan "(^|[[:space:]])#.*"
|
||||
color cyan "(^|[[:blank:]])#.*"
|
||||
|
||||
# Strings.
|
||||
color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"
|
||||
|
||||
@@ -1,22 +1,27 @@
|
||||
## Syntax highlighting for Tcl files.
|
||||
## Syntax highlighting for Tcl and Expect scripts.
|
||||
|
||||
syntax tcl "\.tcl$"
|
||||
syntax tcl "\.(tcl|exp)$"
|
||||
magic "Tcl(/Tk)? script"
|
||||
comment "#"
|
||||
|
||||
# Standard Tcl [info commands]:
|
||||
color green "\<(after|append|array|auto_execok|auto_import|auto_load|auto_load_index|auto_qualify|binary|break|case|catch|cd|clock|close|concat|continue|encoding|eof|error|eval|exec|exit|expr|fblocked|fconfigure|fcopy|file|fileevent|flush|for|foreach|format|gets|glob|global|history|if|incr|info|interp|join|lappend|lindex|linsert|list|llength|load|lrange|lreplace|lsearch|lset|lsort|namespace|open|package|pid|puts|pwd|read|regexp|regsub|rename|return|scan|seek|set|socket|source|split|string|subst|switch|tclLog|tell|time|trace|unknown|unset|update|uplevel|upvar|variable|vwait|while)\>"
|
||||
|
||||
# Basic Tcl subcommands:
|
||||
color green "\<array (anymore|donesearch|exists|get|names|nextelement|set|size|startsearch|statistics|unset)\>"
|
||||
color green "\<string (bytelength|compare|equal|first|index|is|last|length|map|match|range|repeat|replace|to|tolower|totitle|toupper|trim|trimleft|trimright|will|wordend|wordstart)\>"
|
||||
|
||||
# Extended TclX [info commands]:
|
||||
color green "\<(alarm|auto_load_pkg|bsearch|catclose|catgets|catopen|ccollate|cconcat|cequal|chgrp|chmod|chown|chroot|cindex|clength|cmdtrace|commandloop|crange|csubstr|ctoken|ctype|dup|echo|execl|fcntl|flock|fork|fstat|ftruncate|funlock|host_info|id|infox|keyldel|keylget|keylkeys|keylset|kill|lassign|lcontain|lempty|lgets|link|lmatch|loadlibindex|loop|lvarcat|lvarpop|lvarpush|max|min|nice|pipe|profile|random|readdir|replicate|scancontext|scanfile|scanmatch|select|server_accept|server_create|signal|sleep|sync|system|tclx_findinit|tclx_fork|tclx_load_tndxs|tclx_sleep|tclx_system|tclx_wait|times|translit|try_eval|umask|wait)\>"
|
||||
|
||||
# Syntax:
|
||||
color brightblue "\<proc[[:space:]]|\{|\}"
|
||||
color brightblue "\<proc[[:blank:]]|\{|\}"
|
||||
color green "\(|\)|\;|`|\\|\$|<|>|!|=|&|\|"
|
||||
color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"
|
||||
color brightred "\$\{?[0-9A-Za-z_!@#$*?-]+\}?"
|
||||
|
||||
# Trailing whitespace:
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
# Comments:
|
||||
color cyan "^[[:space:]]*#.*"
|
||||
color cyan "^[[:blank:]]*#.*"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user