Compare commits
512 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25ba7712f7 | ||
|
|
a6b534d760 | ||
|
|
494b191d55 | ||
|
|
450bfa7a75 | ||
|
|
a52ac1375a | ||
|
|
4990713e9e | ||
|
|
c022c4cc6d | ||
|
|
6257dec0a7 | ||
|
|
ea9d49b9d8 | ||
|
|
42c7bfcf8a | ||
|
|
e67d1bfeb8 | ||
|
|
e2f444cfdf | ||
|
|
03b85df4eb | ||
|
|
7db5c2f225 | ||
|
|
603ce231d0 | ||
|
|
940b5eaad1 | ||
|
|
fdd946c02c | ||
|
|
81e5b57d74 | ||
|
|
b568705eec | ||
|
|
fe42eb7a1a | ||
|
|
df7b0a6d97 | ||
|
|
fcf598e797 | ||
|
|
d9cb12f6e3 | ||
|
|
0f23729253 | ||
|
|
3def429290 | ||
|
|
803ea0d7a0 | ||
|
|
9b014876cd | ||
|
|
9ccf85eaa8 | ||
|
|
93fa53c3e8 | ||
|
|
eea3e1f0b2 | ||
|
|
e6e22ea976 | ||
|
|
80c2000f87 | ||
|
|
15a0a129c8 | ||
|
|
51bd04b541 | ||
|
|
18ba7f60c1 | ||
|
|
5c3e00d70a | ||
|
|
6c4c77971e | ||
|
|
67adef8f6c | ||
|
|
ed60e16974 | ||
|
|
47c11ae83d | ||
|
|
8173b1bfbe | ||
|
|
93400ec8a1 | ||
|
|
0d85a798e5 | ||
|
|
d4d534925f | ||
|
|
a1ba7ee786 | ||
|
|
756cd4a4b8 | ||
|
|
1b186fcff3 | ||
|
|
165da9b447 | ||
|
|
aea10ed383 | ||
|
|
8fccb31436 | ||
|
|
89bb88e4f5 | ||
|
|
a58efa70bc | ||
|
|
fe1fecc5da | ||
|
|
87612582ff | ||
|
|
c3a53cffbc | ||
|
|
aeea83703b | ||
|
|
27c8f13fc9 | ||
|
|
c6ddae70f7 | ||
|
|
e4ecd03e3f | ||
|
|
a6dc5c963c | ||
|
|
989e6a9a7e | ||
|
|
c28048d20f | ||
|
|
a24e72f972 | ||
|
|
a29aa31e93 | ||
|
|
8546139997 | ||
|
|
a61586947e | ||
|
|
5e4645b082 | ||
|
|
f9f0a8fd67 | ||
|
|
637a2eeb66 | ||
|
|
13caef2de0 | ||
|
|
61c6d43231 | ||
|
|
a04f6e0165 | ||
|
|
3f494e359d | ||
|
|
8a06f70379 | ||
|
|
2290152743 | ||
|
|
3b657a26a6 | ||
|
|
ff5084479b | ||
|
|
97f4a3f4eb | ||
|
|
1ca1732d32 | ||
|
|
accd2308f1 | ||
|
|
10eec2fe17 | ||
|
|
d69cd759cb | ||
|
|
f261a8aca5 | ||
|
|
bdf64d660b | ||
|
|
2fd30ee095 | ||
|
|
9bc6f1797e | ||
|
|
32e63fe1b8 | ||
|
|
1c074cc8cc | ||
|
|
ebf6228f21 | ||
|
|
4a1db96db8 | ||
|
|
16ee4636bc | ||
|
|
6831b37b43 | ||
|
|
4d16f26ba4 | ||
|
|
4a7bc73e03 | ||
|
|
caf583ec4b | ||
|
|
e20880da21 | ||
|
|
19ff9a507b | ||
|
|
33ba6be91f | ||
|
|
9c1c6c18ae | ||
|
|
fae5f823e1 | ||
|
|
bdf8e41a72 | ||
|
|
c00c12b64b | ||
|
|
02d77ad5ad | ||
|
|
7ab903f072 | ||
|
|
266ed0612f | ||
|
|
27af34a853 | ||
|
|
abafc2ba14 | ||
|
|
1f0eb8d915 | ||
|
|
48a19178b8 | ||
|
|
e542e5943e | ||
|
|
44836e77be | ||
|
|
5cec57719b | ||
|
|
d6f101daef | ||
|
|
350cdd9827 | ||
|
|
5dc48d54f2 | ||
|
|
41975265bf | ||
|
|
598f13107d | ||
|
|
248ebf9117 | ||
|
|
1c6f6ba212 | ||
|
|
58cba6a7c6 | ||
|
|
b55474788b | ||
|
|
5c8de3e39f | ||
|
|
8aaa57a573 | ||
|
|
19e743c7e4 | ||
|
|
56aacb3e32 | ||
|
|
f2c9aed16c | ||
|
|
7c6d3942c4 | ||
|
|
27aff84f74 | ||
|
|
a43ee17ad0 | ||
|
|
abd4c47acf | ||
|
|
b87722ab2d | ||
|
|
b5448615b9 | ||
|
|
d14d9069cd | ||
|
|
93df6ab385 | ||
|
|
be87f110ce | ||
|
|
9ebee362a5 | ||
|
|
27928e47be | ||
|
|
79def643a3 | ||
|
|
9a8d9ef496 | ||
|
|
7336c28ca8 | ||
|
|
6a521da437 | ||
|
|
6d828cf470 | ||
|
|
511a2850a1 | ||
|
|
be61aad935 | ||
|
|
c06f7d43e9 | ||
|
|
3638fb9da4 | ||
|
|
2fc1f08573 | ||
|
|
90946c5e9e | ||
|
|
9a778f9a00 | ||
|
|
8d6b468cdc | ||
|
|
0941185fcf | ||
|
|
8850015822 | ||
|
|
3be4ea0dc1 | ||
|
|
3eda0135bc | ||
|
|
9c9de85afb | ||
|
|
addac49465 | ||
|
|
839d29be3f | ||
|
|
b2f0721b69 | ||
|
|
b228c9fe6c | ||
|
|
8e7738e22e | ||
|
|
84f8445b7b | ||
|
|
5cf412320d | ||
|
|
c9fb1cf85a | ||
|
|
bbed065fa8 | ||
|
|
dde74dee78 | ||
|
|
966da68228 | ||
|
|
f147131e7c | ||
|
|
7785c3f7cf | ||
|
|
9d3d354bd4 | ||
|
|
51a5f33b5b | ||
|
|
8aea8625be | ||
|
|
931bf96c1d | ||
|
|
956a1c2327 | ||
|
|
4f15890105 | ||
|
|
0afe38d81a | ||
|
|
3dfd798d51 | ||
|
|
1235a5a365 | ||
|
|
c772e1cb6b | ||
|
|
e35b6636ab | ||
|
|
bd4eed9cb1 | ||
|
|
2b0bcc7cee | ||
|
|
3b5f650621 | ||
|
|
b66a040828 | ||
|
|
f757c4a512 | ||
|
|
06ad77895f | ||
|
|
2cbd4d29a0 | ||
|
|
d93a5594cd | ||
|
|
a2a00577cd | ||
|
|
b92b9e5cac | ||
|
|
d19842ed73 | ||
|
|
0655c8aa6c | ||
|
|
30595dd2bb | ||
|
|
b76b5b9967 | ||
|
|
1007ca5af8 | ||
|
|
f3fab1440f | ||
|
|
affca9b523 | ||
|
|
2f53760689 | ||
|
|
3409cb2b77 | ||
|
|
be6860b33e | ||
|
|
3a94a0bb89 | ||
|
|
8234c22c1e | ||
|
|
496dad696c | ||
|
|
a623f5836c | ||
|
|
f42821293e | ||
|
|
0363703073 | ||
|
|
dfbe3ce6dc | ||
|
|
e4a247f7c9 | ||
|
|
69b2467a9a | ||
|
|
cc24e8b86b | ||
|
|
27f170815f | ||
|
|
d3c7e9d2f6 | ||
|
|
ea4bbf4285 | ||
|
|
308d6e73e3 | ||
|
|
167c93b85c | ||
|
|
13c5bcb4d8 | ||
|
|
c692a6ca70 | ||
|
|
0346e63c20 | ||
|
|
9e982f3283 | ||
|
|
11fec6f63c | ||
|
|
d0c2c1e6b9 | ||
|
|
fab4d0afcb | ||
|
|
d9e42cb274 | ||
|
|
4d9be13316 | ||
|
|
7365ef4092 | ||
|
|
13edbedc79 | ||
|
|
fc5d58ad97 | ||
|
|
a373fa500a | ||
|
|
8da098f5e0 | ||
|
|
52d4b96639 | ||
|
|
83f94a88df | ||
|
|
8762e04631 | ||
|
|
256a0d670e | ||
|
|
50106266bc | ||
|
|
ba093b0b48 | ||
|
|
33041d0ad5 | ||
|
|
b46c8c586b | ||
|
|
0e1d45dc36 | ||
|
|
1cd92458e9 | ||
|
|
7bd68365ec | ||
|
|
485eb18d83 | ||
|
|
375b30507e | ||
|
|
7691527f35 | ||
|
|
3313fac8eb | ||
|
|
e52c81f5db | ||
|
|
9b419d0bff | ||
|
|
0f40752139 | ||
|
|
d57bfc057f | ||
|
|
918ce1afa3 | ||
|
|
5d285ca896 | ||
|
|
f368e2732d | ||
|
|
ad13746da9 | ||
|
|
440f39e558 | ||
|
|
108c84daf8 | ||
|
|
e63fe3be69 | ||
|
|
bc4a141cba | ||
|
|
0dbe857ba2 | ||
|
|
483538f8f3 | ||
|
|
1f36d5411a | ||
|
|
46f76ca8b8 | ||
|
|
3a09577e0c | ||
|
|
b9f472a905 | ||
|
|
557d8131ca | ||
|
|
89fd11109d | ||
|
|
badf3edc55 | ||
|
|
36e3284979 | ||
|
|
4ac932bd21 | ||
|
|
f9468fa987 | ||
|
|
fb7c12f644 | ||
|
|
9341c96def | ||
|
|
74fd78adb1 | ||
|
|
c8ab81dd1c | ||
|
|
185e4d6b12 | ||
|
|
99607a5bbe | ||
|
|
7e807cdd2f | ||
|
|
e51f6596d4 | ||
|
|
42610db847 | ||
|
|
6018de2466 | ||
|
|
af757d3b3f | ||
|
|
30abc02277 | ||
|
|
9a9714fe0c | ||
|
|
77457fa6e9 | ||
|
|
9c45b5da6c | ||
|
|
e9f0597e2e | ||
|
|
87cde1590d | ||
|
|
65d81c60cd | ||
|
|
3d6dcb9568 | ||
|
|
1ca2911b84 | ||
|
|
8ef74b3aac | ||
|
|
aeae4fb4b9 | ||
|
|
bc22b3c876 | ||
|
|
64c9d3c143 | ||
|
|
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 |
564
ChangeLog
564
ChangeLog
@@ -1,3 +1,567 @@
|
||||
Changes between v6.2 and v6.3:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (41):
|
||||
build: add the --disable-maintainer-mode option to ./configure
|
||||
build: fix compilation for --enable-{tiny,nanorc,color}
|
||||
build: fix compilation when configured with --disable-color
|
||||
build: remove an obsolete check -- the dependent code was deleted
|
||||
bump version numbers and add a news item for the 6.3 release
|
||||
display: suppress spotlight yellow and error red when NO_COLOR is set
|
||||
docs: add an example binding for copying text to the system clipboard
|
||||
execute: clear an anchor only when the whole buffer gets filtered
|
||||
execute: don't crash when an empty buffer is piped through a command
|
||||
execute: stay on the same line number when filtering the whole buffer
|
||||
feedback: show extra warning when writing failed due to "No space left"
|
||||
files: do not change to a higher directory when the working one is gone
|
||||
files: show a warning when the working directory is gone (when used)
|
||||
files: when the working directory exists, still check its accessibility
|
||||
filtering: close all output descriptors, so that 'xsel' will terminate
|
||||
formatting: change cursor position only after saving it in the undo item
|
||||
gnulib: pull in the workaround for a build problem on NetBSD
|
||||
gnulib: update to its current upstream state
|
||||
justify: stay at the same line number when doing a full justification
|
||||
painting: colorize text also after an unterminated start match
|
||||
painting: look for another start match only after the actual end match
|
||||
painting: recalculate the multidata when making large strides or changes
|
||||
painting: stop coloring an extremely long line after 2000 bytes
|
||||
painting: tighten the check for a lacking end match on a colored line
|
||||
syntax: xml: colorize /> properly, and colorize prolog tags differently
|
||||
syntax: xml: colorize user-defined entities differently
|
||||
tweaks: avoid a function call when two plain assignments will do
|
||||
tweaks: change the indentation of a list, to match other indentations
|
||||
tweaks: don't leave an orphaned temporary file behind when writing fails
|
||||
tweaks: elide an unneeded call of strlen()
|
||||
tweaks: exclude the extra truncation warning from the tiny version
|
||||
tweaks: make the triggering of the recalculation of multidata less eager
|
||||
tweaks: move the saving and restoring of flags to where it is needed
|
||||
tweaks: normalize the indentation after the previous change
|
||||
tweaks: prevent the adding of an unwanted newline in a different way
|
||||
tweaks: remove redundant braces, and add two translator hints
|
||||
tweaks: remove some stray spaces before a comma
|
||||
tweaks: simplify a bit of code, eliding two labels and three gotos
|
||||
tweaks: simplify a fragment of code, and fold two lines together
|
||||
tweaks: trim a few comments, rename a function, and reshuffle some code
|
||||
verbatim: with --zero, keep cursor in viewport when it was on bottom row
|
||||
|
||||
Mike Frysinger (1):
|
||||
general: fix building for Windows
|
||||
|
||||
|
||||
Changes between v6.1 and v6.2:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (14):
|
||||
bump version numbers and add a news item for the 6.2 release
|
||||
display: suppress the bottom-bar wiping only when the user is editing
|
||||
linter: adjust the parsing to accommodate for a modern 'pyflakes'
|
||||
syntaxes: fold a couple of regexes together, and improve a few comments
|
||||
tweaks: change the type of a variable, to avoid a compiler warning
|
||||
tweaks: consistently backslash-escape the dash in M-letter keystrokes
|
||||
tweaks: rename a misnamed variable
|
||||
tweaks: rename a variable, reshuffle five lines, and snip two comments
|
||||
tweaks: rename a variable, to be more correct, and adjust two comments
|
||||
tweaks: rename a variable, to be more fitting
|
||||
tweaks: rename two more variables, and drop unneeded initializations
|
||||
tweaks: rename two variables (to get rid of a prefix), and elide a third
|
||||
tweaks: store a result, to avoid calling a function twice
|
||||
tweaks: use an intermediate variable, to avoid using one for two purposes
|
||||
|
||||
|
||||
Changes between v6.0 and v6.1:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (37):
|
||||
build: fix compilation when configured with --enable-tiny
|
||||
build: prevent autopoint from overwriting a newer M4 file from gnulib
|
||||
bump version numbers and add a news item for the 6.1 release
|
||||
copyright: update the last year for significantly changed files
|
||||
copyright: update the years for the FSF
|
||||
docs: mention bindable function 'zero', for toggling the interface bars
|
||||
docs: mention 'set guidestripe' and 'set unix' in the sample nanorc
|
||||
docs: remove obsolete Ctrl+Z from the cheatsheet; mention Alt+X instead
|
||||
files: let ^C cancel the exiting when the file on disk was changed
|
||||
gnulib: update to its current upstream state
|
||||
help: make the description of <Tab> more accurate
|
||||
help: update the description of M-D, to match the actual order of counts
|
||||
input: instead of moving waiting keycodes, just increment a pointer
|
||||
input: suppress any spotlighting when there are more keycodes waiting
|
||||
menus: don't show M-6 in the help lines of any prompt
|
||||
prompt: allow the user to copy the answer to the cutbuffer (with M-6)
|
||||
prompt: let ^K erase text after cursor (if any), otherwise whole answer
|
||||
tweaks: add some feedback to the autogen.sh script, to ease the wait
|
||||
tweaks: add some small, clarifying comments
|
||||
tweaks: adjust a translator hint, to fit the order in the POT file
|
||||
tweaks: drop foreign M-U and M-R from among the sample CUA bindings
|
||||
tweaks: remove a redundant check -- add a different one for symmetry
|
||||
tweaks: remove two redundant checks
|
||||
tweaks: rename a function and its two parameters, for clarity
|
||||
tweaks: rename a function and reshuffle its call
|
||||
tweaks: rename a function, to not contain the name of a variable
|
||||
tweaks: rename another variable, to better fit in with its sisters
|
||||
tweaks: rename a variable and a parameter, to be more descriptive
|
||||
tweaks: rename a variable, away from an abbreviation
|
||||
tweaks: rename a variable, for clarity and contrast
|
||||
tweaks: rename a variable, to make it clearer it refers to a window
|
||||
tweaks: rename two variables, and elide a near-enough duplicate
|
||||
tweaks: reshuffle some sample bindings, to group them differently
|
||||
tweaks: reword two comments, and rename a variable (away from an abbrev)
|
||||
tweaks: stop asking the terminal for its new size -- let ncurses do it
|
||||
tweaks: use some symbolic names instead of unclear numeric values
|
||||
tweaks: when discarding keycodes, don't bother parsing them
|
||||
|
||||
|
||||
Changes between v5.9 and v6.0:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (192):
|
||||
bindings: allow rebinding ^Z also on a Linux console (a VT)
|
||||
bindings: allow toggling line numbers (when enabled) also in tiny version
|
||||
bindings: let ^T in the tiny version invoke spell checker (when included)
|
||||
browser: with --zero, do not use the bottom row for displaying filenames
|
||||
build: fix compilation when configured with --disable-color
|
||||
build: fix compilation when configured with --disable-nanorc
|
||||
build: fix compilation when configured with --enable-tiny
|
||||
build: fix compilation with --enable-tiny --enable-nanorc
|
||||
build: fix compilation with --enable-tiny --enable-wrapping
|
||||
build: include the YAML syntax file among the distributed files
|
||||
bump version numbers and add a news item for the 6.0 release
|
||||
display: clear the status bar early enough, so that --zero can show text
|
||||
display: do not wipe the status bar when --zero or --minibar is active
|
||||
display: ensure feedback will be cleared also on a one-row terminal
|
||||
display: make sure there are at least as many text lines as help lines
|
||||
display: move some code for overwriting verbatim feedback with --zero
|
||||
display: redraw the screen in tiny version upon resuming from suspension
|
||||
display: with --zero, redraw the bottom row instead of wiping a message
|
||||
docs: add a hint about making ^L do just 'refresh' to the sample nanorc
|
||||
docs: add a meta description for the HTML rendering of the manual
|
||||
docs: add a suggested rebind and three suggested unbinds to the sample rc
|
||||
docs: avoid large Table of Contents at top of HTML version of manual
|
||||
docs: clarify that --enable options do not fully counteract --enable-tiny
|
||||
docs: correct the description of the layout -- four areas, not five
|
||||
docs: document the effect of --quickblank together with --zero/--minibar
|
||||
docs: explain the effect of --zero / -0 / 'set zero'
|
||||
docs: explain what it means when --rawsequences is needed
|
||||
docs: give more examples of things that --enable-tiny excludes
|
||||
docs: improve the title of the manual, away from the bare "nano"
|
||||
docs: list the new color names, from 'rosy' to 'crimson'
|
||||
docs: mark options -z, --suspendable, and 'set suspendable' as obsolete
|
||||
docs: mention "grey" also at the other place where color names are listed
|
||||
docs: mention M-Z (for toggling the interface) among the Feature Toggles
|
||||
docs: mention that --zero and 'set zero' hide also the help lines
|
||||
docs: move the chapter about editor basics into third position
|
||||
docs: prevent a black square in the PDF after the long synopsis line
|
||||
docs: reshuffle a GNU marker, to make the title clearer in search engines
|
||||
docs: reword several of the descriptions in the chapter on building nano
|
||||
docs: reword the beginning of the chapter on nanorc files
|
||||
docs: say thanks to the Indonesian translator
|
||||
feedback: give a more accurate message when the help lines won't appear
|
||||
feedback: refuse the --constantshow toggle (M-C) on a one-row terminal
|
||||
feedback: report an unbindable function key as an "Unknown sequence"
|
||||
feedback: report the number of inserted lines also with --zero or --mini
|
||||
feedback: show a relevant message for M-O when the syntax has 'tabgives'
|
||||
feedback: suppress chatty messages when --zero is active
|
||||
feedback: to have a status bar, suppress --zero while in the help viewer
|
||||
feedback: when reporting an unbound function key, mention its number
|
||||
feedback: when the user types ^Z, say they can suspend nano with ^T^Z
|
||||
feedback: with --mini or --zero, suppress number of lines for new buffer
|
||||
feedback: with --mini/--zero, suppress message when toggling whitespace
|
||||
feedback: with --zero, drop a message in a short while, as with --minibar
|
||||
files: allow inserting also when started with the --noread option
|
||||
files: clear original filename when the user toggles Append or Prepend
|
||||
gnulib: update to its current upstream state
|
||||
help: do not show ^S when --preserve is in effect
|
||||
help: ensure there is a blank line between title bar and start of text
|
||||
help: group the now lone mouse toggle with the "behavioral" ones
|
||||
help: remove an unneeded restriction for small terminals
|
||||
help: skip the leading blank line when the terminal is very flat
|
||||
help: when done, always redraw the "bottom bars", also with --zero
|
||||
history: process file faster by not filtering out hypothetical duplicates
|
||||
input: ensure that no more bytes are consumed than are available
|
||||
justify: correctly determine whether top-of-buffer has been reached
|
||||
memory: avoid a tiny leak when an option with an argument is given twice
|
||||
memory: avoid leaking the filename when dottifying it on the minibar
|
||||
new feature: option --zero for an interface without bars
|
||||
options: make --zero imply --nohelp, and 'set zero' imply 'set nohelp'
|
||||
pasting: when less than a line is pasted, allow automatic hard-wrapping
|
||||
prompt: avoid resetting the history pointer when the search is cancelled
|
||||
prompt: begin at bottom of history list when at secondary prompt
|
||||
prompt: keep a clear answer clear also after an excursion into history
|
||||
rcfile: recognize fourteen new color names, mostly for subdued shades
|
||||
rcfile: remove the deprecated 'cutwordleft' and 'cutwordright' keywords
|
||||
replacing: keep centering the occurrence, also after toggling help lines
|
||||
replacing: keep the spotlighted occurrence in view, also with --zero
|
||||
replacing: keep the spotlighting, also after toggling the help lines
|
||||
search: with --zero, do not obscure an occurrence on the bottom row
|
||||
search: with --zero, drop a message at the same time as the spotlight
|
||||
statusbar: count words in the way that matches how Ctrl+Right moves
|
||||
statusbar: overwrite a message also when using --constant with --zero
|
||||
suspension: enable ^Z by default -- ignore -z option and drop M-Z toggle
|
||||
suspension: leave ^Z unbound by default -- just ^T^Z will suspend nano
|
||||
syntax: debian: remove file -- Debian itself will have to handle it
|
||||
syntax: default: colorize comments as one of the last things
|
||||
syntax: default: colorize dates, URLs, and nano's release motto
|
||||
syntax: email: use a character class, as \s does not work inside brackets
|
||||
syntax: gentoo: remove file -- Gentoo itself will have to handle it
|
||||
syntax: nanorc: add 'execute' menu for unbind, and drop a bad constraint
|
||||
syntax: nanorc: avoid colorizing #rgb codes as if they were comments
|
||||
syntax: nanorc: colorize a trailing comment when it begins with non-hex
|
||||
syntax: nanorc: colorize each of the fourteen new color names as valid
|
||||
syntax: nanorc: improve the file-matching regex
|
||||
syntax: nanorc: paint arguments of 'include' and 'extendsyntax' specially
|
||||
syntax: nanorc: require whitespace before the start= and end= keywords
|
||||
syntax: python: colorize backslash escapes, such as \n and \xef
|
||||
syntax: ruby: colorize embedded documentation as a comment
|
||||
syntax: rust: do not colorize as string the text between two strings
|
||||
syntax: sql: add a few more missing keywords, like TRUE and FALSE
|
||||
syntax: sql: add more missing keywords, like INNER and OUTER JOIN
|
||||
syntax: sql: add some missing keywords, like ALL and ANY and OR
|
||||
syntax: sql: add two missing data types -- xml and tsquery
|
||||
syntax: sql: colorize as flow control only keywords that clearly are such
|
||||
syntax: sql: colorize keywords regardless of case, and tweak the colors
|
||||
syntax: sql: colorize only single-quoted things as strings
|
||||
syntax: sql: colorize strings differently than types
|
||||
syntax: sql: remove alien stuff -- it was copied mostly from ruby syntax
|
||||
syntax: texinfo: be more precise in colorizing @commands
|
||||
syntax: texinfo: colorize the special @-plus-punctuation commands too
|
||||
syntaxes: avoid coloring "this\" as if it were a valid string
|
||||
syntaxes: colorize hex more strictly by using character class [:xdigit:]
|
||||
syntaxes: drop three redundant end-of-line anchors
|
||||
syntaxes: undouble the backslash within bracket expressions
|
||||
syntaxes: use one regex for coloring quoted strings, to avoid overlap
|
||||
tabbing: also with --zero, stay one row away from the prompt bar
|
||||
tweaks: add an auxiliary variable, to prepare for handling --zero
|
||||
tweaks: add two spaces and two comments, and drop an internal check
|
||||
tweaks: adjust two values -- help lines need at least 6 rows to be shown
|
||||
tweaks: avoid a compiler warning with --enable-tiny --enable-linenumbers
|
||||
tweaks: avoid redrawing the entire window when just a 'touch' will do
|
||||
tweaks: condense the definitions of all the empty functions
|
||||
tweaks: condense the regexes for Types in the SQL syntax
|
||||
tweaks: don't redraw the help lines (if present), and normalize a brace
|
||||
tweaks: drop a fragment of code that became functionless
|
||||
tweaks: elevate two messages, so they get shown with --mini or --zero
|
||||
tweaks: elide a variable that is confusing and has just one use case
|
||||
tweaks: elide two functions that each were called just once
|
||||
tweaks: elide two parameters, as they are now always the same
|
||||
tweaks: exclude some hidden-interface code from the tiny version
|
||||
tweaks: exclude some suspension code from the tiny version
|
||||
tweaks: fix a parentheses mistake -- found by a warning from Clang
|
||||
tweaks: fix a somewhat humorous typo
|
||||
tweaks: fix typo, and improve description of 'set zero' in sample nanorc
|
||||
tweaks: fold a special case into the general one
|
||||
tweaks: fold some regexes together, and trim or improve some comments
|
||||
tweaks: frob a couple of comments, and drop two, for conciseness
|
||||
tweaks: improve a comment, and drop two cluttering compile conditions
|
||||
tweaks: invert a condition, to get an early return instead of indentation
|
||||
tweaks: just let do_wrap() set 'refresh_needed' instead of returning TRUE
|
||||
tweaks: mark keystrokes consistently with @kbd in the manual
|
||||
tweaks: move a translator hint to where xgettext will see it
|
||||
tweaks: normalize whitespace, drop unneeded prototype, condense comment
|
||||
tweaks: on one-row terminals, suppress the message for two toggles
|
||||
tweaks: place the unsetting of a flag better, and rename a variable
|
||||
tweaks: put three email addresses between the customary angled brackets
|
||||
tweaks: reassign a copy of a string to a variable more economically
|
||||
tweaks: reduce redundancy (--enable-color implies --enable-nanorc)
|
||||
tweaks: remove redundant pair of parentheses, and swap two alternatives
|
||||
tweaks: remove redundant parentheses, trim comments, fold some regexes
|
||||
tweaks: remove two unneeded unsettings
|
||||
tweaks: rename a function and its parameter, to be clearer
|
||||
tweaks: rename a function, away from using an abbreviation
|
||||
tweaks: rename a function, for some contrast and to get rid of a suffix
|
||||
tweaks: rename a function, to describe better what it does nowadays
|
||||
tweaks: rename a function, to make it make sense
|
||||
tweaks: rename a variable, to be distinctive and less confusing
|
||||
tweaks: rename a variable, to be easier to read and to make more sense
|
||||
tweaks: rename five empty functions, to get rid of a meaningless suffix
|
||||
tweaks: rename three functions, to better fit the general scheme
|
||||
tweaks: rename three parameters, away from single letters
|
||||
tweaks: rename two empty functions, to be more to the point
|
||||
tweaks: rename two functions, to get rid of another senseless suffix
|
||||
tweaks: rename two functions, to get rid of one more senseless suffix
|
||||
tweaks: rename two functions, to get rid of the senseless suffix of one
|
||||
tweaks: rename two more functions, to lose a senseless suffix
|
||||
tweaks: rename two parameters and one variable, away from single letters
|
||||
tweaks: rename two variables, away from abbreviations
|
||||
tweaks: rename two variables, to fit with the names of similar ones
|
||||
tweaks: replace a verbose condition with a simpler early return
|
||||
tweaks: replace the obscure @* with the slightly clearer @sp
|
||||
tweaks: replace two direct refreshes with two scheduled ones
|
||||
tweaks: reshuffle a coloring rule, to have related ones together
|
||||
tweaks: reshuffle a few lines, and rename a variable
|
||||
tweaks: reshuffle a few lines, for Christmas and to group things better
|
||||
tweaks: reshuffle a fragment of code to a better place
|
||||
tweaks: reshuffle a line and adjust indentation after previous change
|
||||
tweaks: reshuffle a line into its proper order, and improve two comments
|
||||
tweaks: reshuffle some conditions, so that the ifs have similar formats
|
||||
tweaks: reshuffle some conditions, to have more balanced lines
|
||||
tweaks: reshuffle some lines, one for clarity, others for conciseness
|
||||
tweaks: reshuffle the flag conversion into their order in the help text
|
||||
tweaks: reshuffle two conditions, re-indent, and rewrap a line
|
||||
tweaks: reword a paragraph, and use usual M- to depict Meta keystrokes
|
||||
tweaks: rewrap an old news item, for distraction
|
||||
tweaks: rewrap three old NEWS items, for esthetics, and fix a date
|
||||
tweaks: shorten a comment, and drop some conditionalizing
|
||||
tweaks: shorten the description of --zero in the manuals a bit
|
||||
tweaks: shorten two comments, and fold two statements together
|
||||
tweaks: swap two parts of specific regexes, for consistency with others
|
||||
tweaks: untangle two case items, and shorten a message
|
||||
tweaks: use a color closer to the rest of the string, to reduce contrast
|
||||
tweaks: use a few fewer capitals, and drop an unneeded synonym
|
||||
|
||||
Brad Town (2):
|
||||
docs: add a description of the hexadecimal #rgb color specification
|
||||
rcfile: support #rgb format for specifying colors in 256-color terminals
|
||||
|
||||
|
||||
Changes between v5.8 and v5.9:
|
||||
------------------------------
|
||||
|
||||
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:
|
||||
------------------------------
|
||||
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
Improvements in GNU nano
|
||||
========================
|
||||
|
||||
Since 6.0:
|
||||
- Option --zero hides the interface and uses the whole terminal for editing.
|
||||
- Colors can be given also in #rgb hexadecimal, to select the nearest color
|
||||
from the 6x6x6 color-cube palette available on 256-color terminals.
|
||||
- Fourteen new color names are available, from rosy to crimson.
|
||||
|
||||
Since 5.0:
|
||||
- A search highlights the found text, in black on yellow by default.
|
||||
- A search briefly spotlights the found text, in black on yellow by default.
|
||||
- Option --minibar reduces the interface to a bottom bar with basic info.
|
||||
- The cursor skips over combining characters, <Del> deletes them together
|
||||
with the character they combine with, but <Bsp> deletes them separately.
|
||||
|
||||
162
NEWS
162
NEWS
@@ -1,3 +1,83 @@
|
||||
2022.04.28 - GNU nano 6.3 "Wat zullen we drinken? Wat een dorst!"
|
||||
• For multiline regexes, text is now colored as soon a start match
|
||||
is found, also when there is no end match at all.
|
||||
• The colorizing of any line is stopped after two thousand bytes,
|
||||
to avoid frustrating delays.
|
||||
• When environment variable NO_COLOR is set, the two default colors
|
||||
(yellow for the spotlight, red for error messages) are suppressed
|
||||
when no interface colors are specified in a nanorc file.
|
||||
• Full justification and piping the whole buffer through a command
|
||||
now keep the cursor at the same line number.
|
||||
• Utility 'xsel' can be used to copy a marked region to the system's
|
||||
clipboard. See doc/sample.nanorc for an example.
|
||||
|
||||
2022.02.18 - GNU nano 6.2 "Kamperfoelie"
|
||||
• The file browser clears the prompt bar also when using --minibar.
|
||||
• Linting now works also with a newer 'pyflakes'.
|
||||
|
||||
2022.02.09 - GNU nano 6.1 "Rețelele de socializare sunt ca un frigider"
|
||||
• The behavior of ^K at a prompt has been enhanced: when there is some
|
||||
text after the cursor, just this text is erased. In the most common
|
||||
situation, when the cursor is at the end of the answer, the behavior
|
||||
is as before: the whole answer is erased.
|
||||
• At a prompt, M-6 copies the current answer into the cutbuffer.
|
||||
• Large external pastes into nano are handled more quickly.
|
||||
|
||||
2021.12.15 - GNU nano 6.0 "Humor heeft ook zijn leuke kanten"
|
||||
• Option --zero hides the title bar, status bar and help lines, and
|
||||
uses all rows of the terminal as editing area. The title bar and
|
||||
status bar can be toggled with M-Z.
|
||||
• Colors can now be specified also as three-digit hexadecimal numbers,
|
||||
in the format #rgb. This picks from the 216 index colors (that most
|
||||
terminals know) the color that is nearest to the given values.
|
||||
• For users who dislike numbers, there are fourteen new color names:
|
||||
rosy, beet, plum, sea, sky, slate, teal, sage, brown, ocher, sand,
|
||||
tawny, brick, and crimson.
|
||||
• Suspension is enabled by default, invokable with ^T^Z. The options
|
||||
-z, --suspendable, and 'set suspendable' are obsolete and ignored.
|
||||
(In case you want to be able to suspend nano with a single keystroke,
|
||||
you can put 'bind ^Z suspend main' in your nanorc.)
|
||||
• When automatic hard-wrapping is in effect, pasting just a few words
|
||||
(without a line break) will now hard-wrap the line when needed.
|
||||
• Toggling Append or Prepend clears the current filename.
|
||||
• The word count as shown by M-D is now affected by option --wordbounds;
|
||||
with it, nano counts words as 'wc' does; without it (the new default),
|
||||
words are counted in a more human way: seeing punctuation as space.
|
||||
• The YAML syntax file is now actually included in the tarball.
|
||||
|
||||
|
||||
2021.10.06 - GNU nano 5.9 "El manicomio ha decidido: mañana sol!"
|
||||
• The extension of a filename is added to the name of a corresponding
|
||||
temporary file, so that spell checking a C file, for example, will
|
||||
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.
|
||||
@@ -155,7 +235,7 @@
|
||||
It allows running a syntax-specific command on the contents of
|
||||
the buffer.
|
||||
• ^T will try to run 'hunspell' before 'spell', because it checks
|
||||
spellling for the locale's language and understands UTF-8.
|
||||
spelling for the locale's language and understands UTF-8.
|
||||
• Multiple errors or warnings on startup will no longer slow nano
|
||||
down but will be indicated on the status bar with trailing dots.
|
||||
|
||||
@@ -174,6 +254,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.
|
||||
@@ -968,31 +1049,31 @@
|
||||
and not saving the search history when compiled with
|
||||
configure options.
|
||||
|
||||
2008.04.24 - GNU nano 2.1.2 "New York City" is released. This release
|
||||
contains fixes for binding bad keys, some
|
||||
configure-specific compilation failures, and more issues
|
||||
with the new input back end and in particular the status
|
||||
bar. Also fixed are some long-standing issues with
|
||||
compiling on AIX, and a segfault when making the terminal
|
||||
window too small. Rest in Peace Tim and George!
|
||||
2008.06.24 - GNU nano 2.1.2 "New York City" is released. This
|
||||
release contains fixes for binding bad keys, some
|
||||
configure-specific compilation failures, and more
|
||||
issues with the new input back end and in particular
|
||||
the status bar. Also fixed are some long-standing
|
||||
issues with compiling on AIX, and a segfault when
|
||||
making the terminal window too small. Rest in Peace
|
||||
Tim and George!
|
||||
|
||||
2008.04.01 - GNU nano 2.1.1 won't get fooled again. This release contains
|
||||
fixes for the new user-rebindable keys (in particular
|
||||
bracket match which was mis-bound), and various
|
||||
problems with translations and configure-related
|
||||
compilation problems are now fixed as well.
|
||||
It also contains new syntax highlighting
|
||||
definitions for TCL, PHP, Gentoo and Debian-related
|
||||
files, and some documentation updates as well.
|
||||
Please continue to send reports with the key
|
||||
binding code to the Savannah page
|
||||
(https://savannah.gnu.org/bugs/?group=nano).
|
||||
2008.04.01 - GNU nano 2.1.1 won't get fooled again. This release
|
||||
contains fixes for the new user-rebindable keys (in
|
||||
particular bracket match which was mis-bound), and
|
||||
various problems with translations and configure-
|
||||
related compilation problems are now fixed as well.
|
||||
It also contains new syntax highlighting definitions
|
||||
for Tcl, PHP, Gentoo and Debian-related files, and
|
||||
some documentation updates as well. Please continue to
|
||||
send reports with the key binding code to the Savannah
|
||||
page (https://savannah.gnu.org/bugs/?group=nano).
|
||||
|
||||
2008.03.18 - GNU nano 2.1.0 "under old mismanagement" is released.
|
||||
This first release in the 2.1 development series
|
||||
introduces rebindable keys for most actions inside
|
||||
the editor. Please see the nanorc(5) page for
|
||||
more information on configuring key bindings. Please
|
||||
the editor. Please see the nanorc(5) page for more
|
||||
information on configuring key bindings. Please
|
||||
also report all keybinding bugs (crashes, missing
|
||||
menu functions) using the Savannah bug tracker URL,
|
||||
https://savannah.gnu.org/bugs/?group=nano and
|
||||
@@ -1190,9 +1271,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
|
||||
@@ -1203,8 +1284,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.
|
||||
|
||||
@@ -1753,22 +1834,21 @@
|
||||
to upgrade to this release.
|
||||
|
||||
2000.11.18 - Nano 0.9.20 is finally out the door. Probably the biggest
|
||||
change is the brand new way nano displays previous
|
||||
search and replace strings (they are now editable!)
|
||||
This is a break from Pico's (inconsistent) interface, so
|
||||
if you don't like the new way, "Pico" mode (-p on the
|
||||
command line or Meta-P within nano) still works the
|
||||
"old" way.
|
||||
change is the brand new way nano displays previous search
|
||||
and replace strings (they are now editable!) This is a
|
||||
break from Pico's (inconsistent) interface, so if you
|
||||
don't like the new way, "Pico" mode (-p on the command
|
||||
line or Meta-P within nano) still works the "old" way.
|
||||
Other new features include being able to deal with
|
||||
search strings of any length, a new internal spell
|
||||
feature (courtesy of Mr. Rocco Corsi) and tab completion
|
||||
when reading in or writing out files! There's also the
|
||||
usual billion or so bug fixes. Feedback on this release
|
||||
is welcome because so much has changed, especially with
|
||||
the previous string display in search and replace.
|
||||
Email -> nano@nano-editor.org <-. If you like
|
||||
something, don't like something, or just want to order a
|
||||
pizza, let us know!
|
||||
search strings of any length, a new internal spell feature
|
||||
(courtesy of Mr. Rocco Corsi) and tab completion when
|
||||
reading in or writing out files! There's also the usual
|
||||
billion or so bug fixes. Feedback on this release is
|
||||
welcome because so much has changed, especially with the
|
||||
previous string display in search and replace. Email
|
||||
-> nano@nano-editor.org <-. If you like something,
|
||||
don't like something, or just want to order a pizza,
|
||||
let us know!
|
||||
|
||||
2000.10.02 - Nano 0.9.19 is the "Chris is getting married in less than
|
||||
a week and needs a distraction" release. There are only
|
||||
|
||||
67
README
67
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 6.3 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:
|
||||
@@ -50,13 +95,13 @@ Mailing Lists
|
||||
|
||||
There are three nano-related mailing-lists.
|
||||
|
||||
+ info-nano@gnu.org is a very low traffic list used to announce
|
||||
* <info-nano@gnu.org> is a very low traffic list used to announce
|
||||
new nano versions or other important info about the project.
|
||||
|
||||
+ help-nano@gnu.org is for those seeking to get help without
|
||||
* <help-nano@gnu.org> is for those seeking to get help without
|
||||
wanting to hear about the technical details of its development.
|
||||
|
||||
+ nano-devel@gnu.org is the list used by the people that make nano
|
||||
* <nano-devel@gnu.org> is the list used by the people that make nano
|
||||
and a general development discussion list, with moderate traffic.
|
||||
|
||||
To subscribe, send email to <name>-request@gnu.org with a subject
|
||||
@@ -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.
|
||||
|
||||
37
README.GIT
37
README.GIT
@@ -8,19 +8,18 @@ building this needs a bit more care than the official tarballs.
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
To successfully compile GNU nano from git, you'll need the following
|
||||
packages:
|
||||
To successfully compile GNU nano from git, you'll need the following:
|
||||
|
||||
- autoconf (version >= 2.69)
|
||||
- automake (version >= 1.14)
|
||||
- autopoint (version >= 0.18.3)
|
||||
- gcc (version >= 5.0)
|
||||
- gettext (version >= 0.18.3)
|
||||
- git (version >= 2.7.4)
|
||||
- groff (version >= 1.12)
|
||||
- make (any version)
|
||||
- pkg-config (version >= 0.22)
|
||||
- texinfo (version >= 4.0)
|
||||
autoconf (version >= 2.69)
|
||||
automake (version >= 1.14)
|
||||
autopoint (version >= 0.18.3)
|
||||
gcc (version >= 5.0)
|
||||
gettext (version >= 0.18.3)
|
||||
git (version >= 2.7.4)
|
||||
groff (version >= 1.12)
|
||||
make (any version)
|
||||
pkg-config (version >= 0.22)
|
||||
texinfo (version >= 4.0)
|
||||
|
||||
You will also need to have the header files for ncurses installed,
|
||||
from libncurses-dev on Debian, ncurses-devel on Fedora, or similar.
|
||||
@@ -29,14 +28,14 @@ These should all be available in your distro's package manager or
|
||||
software center, or otherwise on any GNU mirror.
|
||||
|
||||
|
||||
Download the source
|
||||
-------------------
|
||||
Clone the source
|
||||
----------------
|
||||
|
||||
To obtain the current nano development branch (called 'master'), use the
|
||||
following command. It will create in your current working directory a
|
||||
subdirectory called 'nano' containing a copy of all of the files:
|
||||
|
||||
$ git clone git://git.savannah.gnu.org/nano.git nano
|
||||
$ git clone git://git.savannah.gnu.org/nano.git
|
||||
|
||||
|
||||
Generate the configure script
|
||||
@@ -114,3 +113,11 @@ to include 'set tabsize 4', or you could use -T4 on the command line.
|
||||
To make git display things as intended, you can do:
|
||||
|
||||
$ git config --local core.pager "less -x1,5"
|
||||
|
||||
To see all types that are used in nano's source code colorized as types,
|
||||
you can add these lines to your ~/.nanorc:
|
||||
|
||||
extendsyntax c color green "\<struct (dirent|option|passwd)\>"
|
||||
extendsyntax c color green "\<struct (sigaction|stat|termios)\>"
|
||||
extendsyntax c color green "\<struct (timespec|vt_stat|winsize)\>"
|
||||
extendsyntax c color green "\<([[:lower:]_]+(struct|type)|va_list)\>"
|
||||
|
||||
3
THANKS
3
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
|
||||
@@ -73,6 +75,7 @@ Johnny A. Solbu <johnny@solbu.net> Norwegian Bokmål
|
||||
Pierre Tane <tanep@bigfoot.com> French
|
||||
Yasuaki Taniguchi <yasuakit@gmail.com> Japanese
|
||||
Jacobo Tarrío <jtarrio@trasno.net> Galician
|
||||
Andika Triwidada <andika@gmail.com> Indonesian
|
||||
Francisco Javier Tsao Santín <tsao@members.fsf.org> Galician
|
||||
Balázs Úr <urbalazs@gmail.com> Hungarian
|
||||
Miquel Vidal <miquel@sindominio.net> Catalan
|
||||
|
||||
27
autogen.sh
27
autogen.sh
@@ -2,7 +2,7 @@
|
||||
# Generate configure & friends for GIT users.
|
||||
|
||||
gnulib_url="git://git.sv.gnu.org/gnulib.git"
|
||||
gnulib_hash="c9b44f214c7c798c7701c7a281584e262b263655"
|
||||
gnulib_hash="34a93be8aa8a15f5959a1b671ad1285a5d552f4b"
|
||||
|
||||
modules="
|
||||
futimens
|
||||
@@ -13,6 +13,7 @@ modules="
|
||||
isblank
|
||||
iswblank
|
||||
lstat
|
||||
mkstemps
|
||||
nl_langinfo
|
||||
regex
|
||||
sigaction
|
||||
@@ -35,14 +36,26 @@ fi
|
||||
cd gnulib >/dev/null || exit 1
|
||||
curr_hash=$(git log -1 --format=%H)
|
||||
if [ "${gnulib_hash}" != "${curr_hash}" ]; then
|
||||
echo "Pulling..."
|
||||
git pull
|
||||
git checkout -f ${gnulib_hash}
|
||||
git checkout --force ${gnulib_hash}
|
||||
fi
|
||||
cd .. >/dev/null || exit 1
|
||||
|
||||
rm -rf lib
|
||||
./gnulib/gnulib-tool \
|
||||
--import \
|
||||
${modules}
|
||||
echo "Autopoint..."
|
||||
autopoint --force
|
||||
|
||||
autoreconf -f -i -s
|
||||
rm -rf lib
|
||||
echo "Gnulib-tool..."
|
||||
./gnulib/gnulib-tool --import ${modules}
|
||||
echo
|
||||
|
||||
echo "Aclocal..."
|
||||
aclocal -I m4
|
||||
echo "Autoconf..."
|
||||
autoconf
|
||||
echo "Autoheader..."
|
||||
autoheader
|
||||
echo "Automake..."
|
||||
automake --add-missing
|
||||
echo "Done."
|
||||
|
||||
28
configure.ac
28
configure.ac
@@ -1,6 +1,6 @@
|
||||
# Configuration for GNU nano - a small and user-friendly text editor
|
||||
#
|
||||
# Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2014, 2017 Mike Frysinger
|
||||
#
|
||||
# GNU nano is free software: you can redistribute it and/or modify
|
||||
@@ -16,10 +16,11 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
|
||||
AC_INIT([GNU nano], [5.6], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [6.3], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AC_CANONICAL_HOST
|
||||
AM_INIT_AUTOMAKE([1.14])
|
||||
AM_MAINTAINER_MODE([enable])
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
|
||||
dnl Make sure the ONCE macros are available.
|
||||
@@ -350,9 +351,12 @@ 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
|
||||
|
||||
AC_CHECK_FUNCS_ONCE(chmod chown fchmod fchown flockfile funlockfile
|
||||
fork fsync geteuid pipe wait waitpid)
|
||||
|
||||
dnl Checks for available flags.
|
||||
|
||||
AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"], [], [])
|
||||
@@ -435,11 +439,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
|
||||
@@ -511,21 +514,6 @@ int main(void)
|
||||
*** Can't check need for _XOPEN_SOURCE_EXTENDED when cross-compiling.]))
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([whether LINES and COLS can be redefined])
|
||||
AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
||||
#include <curses.h>
|
||||
int main(void)
|
||||
{
|
||||
LINES = 80;
|
||||
COLS = 25;
|
||||
return 0;
|
||||
}]])],
|
||||
AC_DEFINE(REDEFINING_MACROS_OK, 1, [Define this if you know your curses library allows LINES and COLS to be redefined to deal with a resizing bug.])
|
||||
AC_MSG_RESULT(yes),
|
||||
AC_MSG_RESULT(no),
|
||||
AC_MSG_WARN([
|
||||
*** Can't check for macro redefinability when cross-compiling.]))
|
||||
|
||||
AS_IF([test "x$enable_libmagic" != "xno"], [
|
||||
AC_CHECK_HEADERS([magic.h])
|
||||
AC_CHECK_LIB(magic, magic_open)
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>Cheatsheet for nano</title>
|
||||
<title>Cheatsheet for GNU nano</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="description" content="A concise overview of the command shortcuts of the GNU nano editor, grouped by category.">
|
||||
<meta name="description" content="A concise overview of the command shortcuts for nano, the editor, grouped by category.">
|
||||
<meta name="keywords" content="cheatsheet, nano, editor, shortcuts, keystrokes, functions, operations, commands">
|
||||
<meta name="author" content="Benno Schulenberg">
|
||||
</head>
|
||||
@@ -118,11 +118,11 @@
|
||||
<tr><td>Alt+A</td><td>Turn the mark on/off</td></tr>
|
||||
<tr><td>Tab</td><td>Indent marked region</td></tr>
|
||||
<tr><td>Shift+Tab </td><td>Unindent marked region</td></tr>
|
||||
<tr><td>Alt+V</td><td>Enter next keystroke verbatim</td></tr>
|
||||
<tr><td>Alt+N</td><td>Turn line numbers on/off</td></tr>
|
||||
<tr><td>Alt+P</td><td>Turn visible whitespace on/off</td></tr>
|
||||
<tr><td>Alt+V</td><td>Enter next keystroke verbatim</td></tr>
|
||||
<tr><td>Alt+X</td><td>Hide or unhide the help lines</td></tr>
|
||||
<tr><td>Ctrl+L</td><td>Refresh the screen</td></tr>
|
||||
<tr><td>Ctrl+Z</td><td>Suspend nano</td></tr>
|
||||
</tbody></table>
|
||||
<br>
|
||||
|
||||
|
||||
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.6</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
|
||||
<blockquote><p>The current version of nano <i>should</i> be <b>6.3</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
|
||||
<h3><a name="1.5"></a>1.5. I want to read the man page without having to download the program!</h3>
|
||||
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="https://nano-editor.org/dist/latest/nano.1.html">here</a>.</p></blockquote>
|
||||
<hr width="100%">
|
||||
@@ -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%">
|
||||
|
||||
|
||||
78
doc/nano.1
78
doc/nano.1
@@ -1,4 +1,4 @@
|
||||
.\" Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc.
|
||||
.\" Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc.
|
||||
.\"
|
||||
.\" This document is dual-licensed. You may distribute and/or modify it
|
||||
.\" under the terms of either of the following licenses:
|
||||
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANO 1 "version 5.6" "February 2021"
|
||||
.TH NANO 1 "version 6.3" "April 2022"
|
||||
|
||||
.SH NAME
|
||||
nano \- Nano's ANOther editor, inspired by Pico
|
||||
@@ -27,20 +27,6 @@ nano \- Nano's ANOther editor, inspired by Pico
|
||||
.sp
|
||||
.BR nano " [" \fIoptions "] [[" + [ crCR ]( / | ? ) \fIstring "] " \fIfile ]...
|
||||
|
||||
.SH NOTICE
|
||||
Since version 4.0, \fBnano\fR by default:
|
||||
.sp
|
||||
.RS 4
|
||||
\(bu does not automatically hard-wrap lines that become overlong,
|
||||
.br
|
||||
\(bu includes the line below the title bar in the editing area,
|
||||
.br
|
||||
\(bu does linewise (smooth) scrolling.
|
||||
.RE
|
||||
.sp
|
||||
If you want the old, Pico behavior back, you can use \fB\-\-breaklonglines\fR,
|
||||
\fB\-\-emptyline\fR, and \fB\-\-jumpyscrolling\fR (or \fB\-bej\fR for short).
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fBnano\fP is a small and friendly editor. It copies the look and feel
|
||||
of Pico, but is free software, and implements several features that Pico
|
||||
@@ -58,7 +44,7 @@ regular expression by inserting \fBc\fR and/or \fBr\fR after the \fB+\fR sign.
|
||||
These search modes can be explicitly disabled by using the uppercase variant
|
||||
of those letters: \fBC\fR and/or \fBR\fR. When the string contains spaces,
|
||||
it needs to be enclosed in quotes. To give an example: to open a file at
|
||||
the first occurrence of the word "Foo", one would do:
|
||||
the first occurrence of the word "Foo", you would do:
|
||||
.sp
|
||||
.RS 4
|
||||
.BI "nano +c/Foo " file
|
||||
@@ -77,11 +63,11 @@ Any cursor movement or executing any other command will cause the next
|
||||
\fB^K\fR to overwrite the cutbuffer. A \fB^U\fR will paste the current
|
||||
contents of the cutbuffer at the current cursor position.
|
||||
.sp
|
||||
When a more precise piece of text needs to be cut or copied, one can mark
|
||||
When a more precise piece of text needs to be cut or copied, you can mark
|
||||
its start with \fB^6\fR, move the cursor to its end (the marked text will be
|
||||
highlighted), and then use \fB^K\fR to cut it, or \fBM\-6\fR to copy it to the
|
||||
cutbuffer. One can also save the marked text to a file with \fB^O\fR, or
|
||||
spell check it with \fB^T\fR.
|
||||
cutbuffer. You can also save the marked text to a file with \fB^O\fR, or
|
||||
spell check it with \fB^T^T\fR.
|
||||
.sp
|
||||
On some terminals, text can be selected also by holding down Shift while
|
||||
using the arrow keys. Holding down the Ctrl or Alt key too will increase
|
||||
@@ -93,6 +79,20 @@ the built-in help (\fB^G\fR) lists all the available ones.
|
||||
The default key bindings can be changed via a \fInanorc\fR file -- see
|
||||
.BR nanorc (5).
|
||||
|
||||
.SH NOTICE
|
||||
Since version 4.0, \fBnano\fR by default:
|
||||
.sp
|
||||
.RS 4
|
||||
\(bu does not automatically hard-wrap lines that become overlong,
|
||||
.br
|
||||
\(bu includes the line below the title bar in the editing area,
|
||||
.br
|
||||
\(bu does linewise (smooth) scrolling.
|
||||
.RE
|
||||
.sp
|
||||
If you want the old, Pico behavior back, you can use \fB\-\-breaklonglines\fR,
|
||||
\fB\-\-emptyline\fR, and \fB\-\-jumpyscrolling\fR (or \fB\-bej\fR for short).
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.BR \-A ", " \-\-smarthome
|
||||
@@ -118,7 +118,8 @@ by setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, \fBkeycolor\fP,
|
||||
nanorc file. See \fBnanorc\fR(5).
|
||||
.TP
|
||||
.BR \-E ", " \-\-tabstospaces
|
||||
Convert typed tabs to spaces.
|
||||
Convert each typed tab to spaces -- to the number of spaces
|
||||
that a tab at that position would take up.
|
||||
.TP
|
||||
.BR \-F ", " \-\-multibuffer
|
||||
Read a file into a new buffer by default.
|
||||
@@ -139,10 +140,12 @@ text. (The color of the stripe can be changed with \fBset stripecolor\fR
|
||||
in your \fInanorc\fR file.)
|
||||
.TP
|
||||
.BR \-K ", " \-\-rawsequences
|
||||
Interpret escape sequences directly (instead of asking \fBncurses\fR to
|
||||
translate them). If you need this option to get your keyboard to work
|
||||
properly, please report a bug. Using this option disables \fBnano\fR's
|
||||
mouse support.
|
||||
Interpret escape sequences directly, instead of asking \fBncurses\fR
|
||||
to translate them. (If you need this option to get some keys to work
|
||||
properly, it means that the terminfo terminal description that is used
|
||||
does not fully match the actual behavior of your terminal. This can
|
||||
happen when you ssh into a BSD machine, for example.)
|
||||
Using this option disables \fBnano\fR's mouse support.
|
||||
.TP
|
||||
.BR \-L ", " \-\-nonewlines
|
||||
Don't automatically add a newline when a text does not end with one.
|
||||
@@ -191,8 +194,11 @@ Set the size (width) of a tab to \fInumber\fP columns. The value of
|
||||
.TP
|
||||
.BR \-U ", " \-\-quickblank
|
||||
Make status-bar messages disappear after 1 keystroke instead of after 20.
|
||||
Note that options \fB\-c\fR (\fB\-\-constantshow\fR)
|
||||
and \fB\-_\fR (\fB\-\-minibar\fR) override this.
|
||||
Note that option \fB\-c\fR (\fB\-\-constantshow\fR) overrides this.
|
||||
When option \fB\-\-minibar\fR or \fB\-\-zero\fR is in effect,
|
||||
\fB\-\-quickblank\fR makes a message disappear after
|
||||
0.8 seconds instead of after the default 1.5 seconds.
|
||||
.
|
||||
.TP
|
||||
.BR \-V ", " \-\-version
|
||||
Show the current version number and exit.
|
||||
@@ -327,7 +333,9 @@ Don't show the two help lines at the bottom of the screen.
|
||||
Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
|
||||
.TP
|
||||
.BR \-z ", " \-\-suspendable
|
||||
Allow the user to suspend the editor (with \fB^Z\fR by default).
|
||||
Obsolete option; ignored. Suspension is enabled by default,
|
||||
reachable via \fB^T^Z\fR. (If you want a plain \fB^Z\fR to
|
||||
suspend nano, add \fBbind ^Z suspend main\fR to your nanorc.)
|
||||
.TP
|
||||
.BR \-% ", " \-\-stateflags
|
||||
Use the top-right corner of the screen for showing some state flags:
|
||||
@@ -340,20 +348,28 @@ 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.
|
||||
\fB\-\-constantshow\fR is used, and can be toggled on and off with \fBM\-C\fR.
|
||||
The state flags are displayed only when \fB\-\-stateflags\fR is used.
|
||||
.TP
|
||||
.BR \-0 ", " \-\-zero
|
||||
Hide all elements of the interface (title bar, status bar, and help lines)
|
||||
and use all rows of the terminal for showing the contents of the buffer.
|
||||
The status bar appears only when there is a significant message,
|
||||
and disappears after 1.5 seconds or upon the next keystroke.
|
||||
With \fBM\-Z\fR the title bar plus status bar can be toggled.
|
||||
With \fBM\-X\fR the help lines.
|
||||
.TP
|
||||
.BR \-! ", " \-\-magic
|
||||
When neither the file's name nor its first line give a clue,
|
||||
try using libmagic to determine the applicable syntax.
|
||||
|
||||
886
doc/nano.texi
886
doc/nano.texi
File diff suppressed because it is too large
Load Diff
134
doc/nanorc.5
134
doc/nanorc.5
@@ -1,4 +1,4 @@
|
||||
.\" Copyright (C) 2003-2011, 2013-2021 Free Software Foundation, Inc.
|
||||
.\" Copyright (C) 2003-2011, 2013-2022 Free Software Foundation, Inc.
|
||||
.\"
|
||||
.\" This document is dual-licensed. You may distribute and/or modify it
|
||||
.\" under the terms of either of the following licenses:
|
||||
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANORC 5 "version 5.6" "February 2021"
|
||||
.TH NANORC 5 "version 6.3" "April 2022"
|
||||
|
||||
.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
|
||||
@@ -146,11 +146,6 @@ See \fBset titlecolor\fR for more details.
|
||||
Draw a vertical stripe at the given column, to help judge the width of the
|
||||
text. (The color of the stripe can be changed with \fBset stripecolor\fR.)
|
||||
.TP
|
||||
.B set highlightcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
Use this color combination for highlighting a search match.
|
||||
The default value is \fBblack,lightyellow\fR.
|
||||
See \fBset titlecolor\fR for valid color names.
|
||||
.TP
|
||||
.B set historylog
|
||||
Save the last hundred search strings and replacement strings and
|
||||
executed commands, so they can be easily reused in later sessions.
|
||||
@@ -190,23 +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.
|
||||
\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
|
||||
@@ -228,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.
|
||||
@@ -265,7 +258,10 @@ specfified closing punctuation, optionally followed by closing brackets
|
||||
.TP
|
||||
.B set quickblank
|
||||
Make status-bar messages disappear after 1 keystroke instead of after 20.
|
||||
Note that options \fBconstantshow\fR and \fBminibar\fR override this.
|
||||
Note that option \fBconstantshow\fR overrides this.
|
||||
When option \fBminibar\fR or \fBzero\fR is in effect,
|
||||
\fBquickblank\fR makes a message disappear after
|
||||
0.8 seconds instead of after the default 1.5 seconds.
|
||||
.TP
|
||||
.BI "set quotestr """ regex """
|
||||
Set the regular expression for matching the quoting part of a line.
|
||||
@@ -275,10 +271,12 @@ This makes it possible to rejustify blocks of quoted text when composing
|
||||
email, and to rewrap blocks of line comments when writing source code.
|
||||
.TP
|
||||
.B set rawsequences
|
||||
Interpret escape sequences directly (instead of asking \fBncurses\fR to
|
||||
translate them). If you need this option to get your keyboard to work
|
||||
properly, please report a bug. Using this option disables \fBnano\fR's
|
||||
mouse support.
|
||||
Interpret escape sequences directly, instead of asking \fBncurses\fR
|
||||
to translate them. (If you need this option to get some keys to work
|
||||
properly, it means that the terminfo terminal description that is used
|
||||
does not fully match the actual behavior of your terminal. This can
|
||||
happen when you ssh into a BSD machine, for example.)
|
||||
Using this option disables \fBnano\fR's mouse support.
|
||||
.TP
|
||||
.B set rebinddelete
|
||||
Interpret the Delete and Backspace keys differently so that both Backspace
|
||||
@@ -304,8 +302,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
|
||||
@@ -314,10 +313,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
|
||||
@@ -327,6 +322,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
|
||||
@@ -344,14 +344,17 @@ Use this color combination for the vertical guiding stripe.
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
.B set suspendable
|
||||
Allow \fBnano\fP to be suspended (with \fB^Z\fR by default).
|
||||
Obsolete option; ignored. Suspension is enabled by default,
|
||||
reachable via \fB^T^Z\fR. (If you want a plain \fB^Z\fR to
|
||||
suspend nano, add \fBbind ^Z suspend main\fR to your nanorc.)
|
||||
.TP
|
||||
.B set tabsize \fInumber\fR
|
||||
Use a tab size of \fInumber\fR columns. The value of \fInumber\fP must be
|
||||
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.
|
||||
@@ -360,11 +363,21 @@ 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 ", "
|
||||
.BR lime ", " peach ", " orange ", " latte ", and " normal
|
||||
.BR lime ", " peach ", " orange ", " latte ", "
|
||||
.BR rosy ", " beet ", " plum ", " sea ", " sky ", " slate ", "
|
||||
.BR teal ", " sage ", " brown ", " ocher ", " sand ", " tawny ", "
|
||||
.BR brick ", " crimson ", and " normal
|
||||
-- where \fBnormal\fR means the default foreground or background color.
|
||||
On such emulators, the color may also be specified as a three-digit hexadecimal
|
||||
number prefixed with \fB#\fR, with the digits representing the amounts of red,
|
||||
green, and blue, respectively. This tells \fBnano\fR to select from the
|
||||
available palette the color that approximates the given values.
|
||||
|
||||
Either "\fIfgcolor\fR" or "\fB,\fIbgcolor\fR" may be left out,
|
||||
and the pair may be preceded by \fBbold\fR and/or \fBitalic\fR
|
||||
(separated by commas) to get a bold and/or slanting typeface,
|
||||
@@ -396,6 +409,14 @@ probably want to unset \fBwordbounds\fR.
|
||||
.B set zap
|
||||
Let an unmodified Backspace or Delete erase the marked region
|
||||
(instead of a single character, and without affecting the cutbuffer).
|
||||
.TP
|
||||
.B set zero
|
||||
Hide all elements of the interface (title bar, status bar, and help lines)
|
||||
and use all rows of the terminal for showing the contents of the buffer.
|
||||
The status bar appears only when there is a significant message,
|
||||
and disappears after 1.5 seconds or upon the next keystroke.
|
||||
With \fBM\-Z\fR the title bar plus status bar can be toggled.
|
||||
With \fBM\-X\fR the help lines.
|
||||
|
||||
.SH SYNTAX HIGHLIGHTING
|
||||
Coloring the different syntactic elements of a file
|
||||
@@ -485,11 +506,21 @@ one of which must be specified. Valid color names are:
|
||||
.BR white ", and " black .
|
||||
Each of these eight names may be prefixed with the word \fBlight\fR
|
||||
to get a brighter version of that color.
|
||||
The word \fBgrey\fR or \fBgray\fR may be used
|
||||
as a synonym for \fBlightblack\fR.
|
||||
On terminal emulators that can do at least 256 colors,
|
||||
other valid (but unprefixable) color names are:
|
||||
.BR pink ", " purple ", " mauve ", " lagoon ", " mint ", "
|
||||
.BR lime ", " peach ", " orange ", " latte ", and " normal
|
||||
.BR lime ", " peach ", " orange ", " latte ", "
|
||||
.BR rosy ", " beet ", " plum ", " sea ", " sky ", " slate ", "
|
||||
.BR teal ", " sage ", " brown ", " ocher ", " sand ", " tawny ", "
|
||||
.BR brick ", " crimson ", and " normal
|
||||
-- where \fBnormal\fR means the default foreground or background color.
|
||||
On such emulators, the color may also be specified as a three-digit hexadecimal
|
||||
number prefixed with \fB#\fR, with the digits representing the amounts of red,
|
||||
green, and blue, respectively. This tells \fBnano\fR to select from the
|
||||
available palette the color that approximates the given values.
|
||||
|
||||
The color pair may be preceded by \fBbold\fR and/or \fBitalic\fR
|
||||
(separated by commas) to get a bold and/or slanting typeface,
|
||||
if your terminal can do those.
|
||||
@@ -659,11 +690,12 @@ the line, column, and character positions.
|
||||
(The old name of this function, 'curpos', is deprecated.)
|
||||
.TP
|
||||
.B wordcount
|
||||
Counts the number of words, lines and characters in the current buffer.
|
||||
Counts and reports on the status bar the number of lines, words,
|
||||
and characters in the current buffer (or in the marked region).
|
||||
.TP
|
||||
.B execute
|
||||
Prompts for a program to execute. The program's output will be inserted
|
||||
into the current buffer (or into a new buffer when \fBM-F\fR is toggled).
|
||||
into the current buffer (or into a new buffer when \fBM\-F\fR is toggled).
|
||||
.TP
|
||||
.B speller
|
||||
Invokes a spell-checking program, either the default \fBhunspell\fR(1) or GNU
|
||||
@@ -676,27 +708,28 @@ Invokes a full-buffer-processing program (if the active syntax defines one).
|
||||
Invokes a syntax-checking program (if the active syntax defines one).
|
||||
.TP
|
||||
.B justify
|
||||
Justifies the current paragraph. A paragraph is a group of contiguous lines
|
||||
Justifies the current paragraph (or the marked region).
|
||||
A paragraph is a group of contiguous lines
|
||||
that, apart from possibly the first line, all have the same indentation. The
|
||||
beginning of a paragraph is detected by either this lone line with a differing
|
||||
indentation or by a preceding blank line.
|
||||
.TP
|
||||
.B fulljustify
|
||||
Justifies the entire current buffer.
|
||||
Justifies the entire current buffer (or the marked region).
|
||||
.TP
|
||||
.B indent
|
||||
Indents (shifts to the right) the currently marked text.
|
||||
Indents (shifts to the right) the current line or the marked lines.
|
||||
.TP
|
||||
.B unindent
|
||||
Unindents (shifts to the left) the currently marked text.
|
||||
Unindents (shifts to the left) the current line or the marked lines.
|
||||
.TP
|
||||
.B comment
|
||||
Comments or uncomments the current line or marked lines, using the comment
|
||||
style specified in the active syntax.
|
||||
Comments or uncomments the current line or the marked lines,
|
||||
using the comment style specified in the active syntax.
|
||||
.TP
|
||||
.B complete
|
||||
Completes the fragment before the cursor to a full word found elsewhere
|
||||
in the current buffer.
|
||||
Completes (when possible) the fragment before the cursor
|
||||
to a full word found elsewhere in the current buffer.
|
||||
.TP
|
||||
.B left
|
||||
Goes left one position (in the editor or browser).
|
||||
@@ -713,10 +746,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.
|
||||
@@ -814,8 +852,8 @@ Redoes the last undone action (i.e., it undoes an undo).
|
||||
Refreshes the screen.
|
||||
.TP
|
||||
.B suspend
|
||||
Suspends the editor (if the suspending function is enabled, see the
|
||||
\fBsuspendable\fR toggle item below).
|
||||
Suspends the editor and returns control to the shell
|
||||
(until you tell the process to resume execution with \fBfg\fR).
|
||||
.TP
|
||||
.B casesens
|
||||
Toggles whether searching/replacing ignores or respects the case of
|
||||
@@ -893,6 +931,9 @@ Toggles the presence of the two-line list of key bindings at the bottom of the s
|
||||
(This toggle is special: it is available in all menus except the help viewer
|
||||
and the linter. All further toggles are available in the main menu only.)
|
||||
.TP
|
||||
.B zero
|
||||
Toggles the presence of title bar and status bar.
|
||||
.TP
|
||||
.B constantshow
|
||||
Toggles the constant display of the current line, column, and character positions.
|
||||
.TP
|
||||
@@ -929,11 +970,6 @@ Toggles whether typed tabs will be converted to spaces.
|
||||
.TP
|
||||
.B mouse
|
||||
Toggles mouse support.
|
||||
.TP
|
||||
.B suspendable
|
||||
Toggles whether the suspend keystroke (\fB^Z\fR by default)
|
||||
will actually suspend the editor.
|
||||
(The old name of this function, 'suspendenable', is deprecated.)
|
||||
.RE
|
||||
|
||||
.TP
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" Copyright (C) 2002-2007, 2014-2021 Free Software Foundation, Inc.
|
||||
.\" Copyright (C) 2002-2007, 2014-2022 Free Software Foundation, Inc.
|
||||
.\"
|
||||
.\" This document is dual-licensed. You may distribute and/or modify it
|
||||
.\" under the terms of either of the following licenses:
|
||||
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH RNANO 1 "version 5.6" "February 2021"
|
||||
.TH RNANO 1 "version 6.3" "April 2022"
|
||||
|
||||
.SH NAME
|
||||
rnano \- a restricted nano
|
||||
|
||||
@@ -58,6 +58,10 @@
|
||||
## will be the terminal's width minus this number.
|
||||
# set fill -8
|
||||
|
||||
## Draw a vertical stripe at the given column, to help judge text width.
|
||||
## (This option does not have a default value.)
|
||||
# set guidestripe 75
|
||||
|
||||
## Remember the used search/replace strings for the next session.
|
||||
# set historylog
|
||||
|
||||
@@ -78,18 +82,19 @@
|
||||
## Fall back to slow libmagic to try and determine an applicable syntax.
|
||||
# set magic
|
||||
|
||||
## 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
|
||||
@@ -117,10 +122,9 @@
|
||||
## 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 "!.?"
|
||||
|
||||
## Make status-bar messages disappear after 1 keystroke instead of after 20.
|
||||
@@ -144,16 +148,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.
|
||||
@@ -167,19 +171,18 @@
|
||||
## M = mark, L = hard-wrapping long lines, R = recording, S = soft-wrapping.
|
||||
# set stateflags
|
||||
|
||||
## Allow nano to be suspended (with ^Z by default).
|
||||
# set suspendable
|
||||
## (The old form of this option, 'set suspend', is deprecated.)
|
||||
|
||||
## Use this tab size instead of the default; it must be greater than 0.
|
||||
# set tabsize 8
|
||||
|
||||
## 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.
|
||||
# set trimblanks
|
||||
|
||||
## Save files by default in Unix format (also when they were DOS or Mac).
|
||||
# set unix
|
||||
|
||||
## The two single-column characters used to display the first characters
|
||||
## of tabs and spaces. 187 in ISO 8859-1 (0000BB in Unicode) and 183 in
|
||||
## ISO-8859-1 (0000B7 in Unicode) seem to be good values for these.
|
||||
@@ -201,15 +204,18 @@
|
||||
## of a single character, and without affecting the cutbuffer).
|
||||
# set zap
|
||||
|
||||
## Hide the bars plus help lines and use the whole terminal as edit area.
|
||||
# set zero
|
||||
|
||||
|
||||
## Paint the interface elements of nano. These are examples; there are
|
||||
## no colors by default, except for errorcolor and highlightcolor.
|
||||
# set titlecolor bold,lightwhite,blue
|
||||
# set promptcolor lightwhite,lightblack
|
||||
# set statuscolor bold,lightwhite,green
|
||||
# set errorcolor bold,lightwhite,red
|
||||
## 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 highlightcolor black,lime
|
||||
# set stripecolor ,yellow
|
||||
# set scrollercolor cyan
|
||||
# set numbercolor cyan
|
||||
@@ -217,12 +223,12 @@
|
||||
# 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 highlightcolor black,orange
|
||||
# set stripecolor ,yellow
|
||||
# set scrollercolor magenta
|
||||
# set numbercolor magenta
|
||||
@@ -256,6 +262,9 @@
|
||||
## === Key bindings ===
|
||||
## For all details, see 'man nanorc', section REBINDING KEYS.
|
||||
|
||||
## If you want to suspend nano with one keystroke (instead of with ^T^Z):
|
||||
# bind ^Z suspend main
|
||||
|
||||
## The <Ctrl+Delete> keystroke deletes the word to the right of the cursor.
|
||||
## On some terminals the <Ctrl+Backspace> keystroke produces ^H, which is
|
||||
## the ASCII character for backspace, so it is bound by default to the
|
||||
@@ -265,13 +274,37 @@
|
||||
## <Ctrl+Backspace> delete the word to the left of the cursor with:
|
||||
# bind ^H chopwordleft main
|
||||
|
||||
## For a more mnemonic Comment keystroke (overriding Cut-from-cursor):
|
||||
# bind M-K comment main
|
||||
|
||||
## If you want ^L to just refresh the screen and not center the cursor:
|
||||
# bind ^L refresh main
|
||||
|
||||
## When you sometimes type M-J instead of M-K, or M-T instead of M-R:
|
||||
# unbind M-J main
|
||||
# unbind M-T main
|
||||
## (Those functions are still accessible through ^T^J and ^T^V.)
|
||||
|
||||
## For quickly uppercasing or lowercasing the word under the cursor.
|
||||
## (These effectively do a Ctrl+Right followed by a Shift+Ctrl+Left,
|
||||
## and then pipe the selected text through a sed command.)
|
||||
# bind Sh-M-U "Oc[1;6D|sed 's/.*/\U&/'
|
||||
" main
|
||||
# bind Sh-M-L "Oc[1;6D|sed 's/.*/\L&/'
|
||||
" main
|
||||
|
||||
## For copying a marked region to the system clipboard:
|
||||
# bind Sh-M-T "|xsel -ib
|
||||
u" main
|
||||
|
||||
## If you would like nano to have keybindings that are more "usual",
|
||||
## such as ^O for Open, ^F for Find, ^H for Help, and ^Q for Quit,
|
||||
## then uncomment these:
|
||||
#bind ^X cut main
|
||||
#bind ^C copy main
|
||||
#bind ^V paste all
|
||||
#bind ^Q exit all
|
||||
#bind ^S savefile main
|
||||
#bind ^W writeout main
|
||||
#bind ^O insert main
|
||||
#set multibuffer
|
||||
@@ -279,23 +312,18 @@
|
||||
#bind ^H exit help
|
||||
#bind ^F whereis all
|
||||
#bind ^G findnext all
|
||||
#bind M-X flipnewbuffer all
|
||||
#bind ^X cut all
|
||||
#bind ^C copy main
|
||||
#bind ^V paste all
|
||||
#bind ^P location main
|
||||
#bind ^A mark main
|
||||
#bind ^B wherewas all
|
||||
#bind ^D findprevious all
|
||||
#bind ^R replace main
|
||||
#bind ^Z undo main
|
||||
#bind ^Y redo main
|
||||
#unbind ^K main
|
||||
#unbind ^U all
|
||||
#unbind ^N main
|
||||
#unbind ^Y all
|
||||
#unbind M-J main
|
||||
#unbind M-T main
|
||||
#bind ^A mark main
|
||||
#bind ^Y speller main
|
||||
#bind M-U undo main
|
||||
#bind M-R redo main
|
||||
#bind ^U undo main
|
||||
#bind ^E redo main
|
||||
#set multibuffer
|
||||
#bind ^P location main
|
||||
#bind ^T gotoline main
|
||||
#bind ^T gotodir browser
|
||||
|
||||
@@ -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 sq sr sv tr uk vi zh_CN zh_TW
|
||||
|
||||
2018
po/nn.po → po/is.po
2018
po/nn.po → po/is.po
File diff suppressed because it is too large
Load Diff
1315
po/nano.pot
1315
po/nano.pot
File diff suppressed because it is too large
Load Diff
1337
po/pt_BR.po
1337
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 "^??")
|
||||
|
||||
|
||||
1353
po/zh_CN.po
1353
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
1343
po/zh_TW.po
1343
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERSION="5.6"
|
||||
VERSION="6.3"
|
||||
|
||||
./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 &&
|
||||
|
||||
246
src/browser.c
246
src/browser.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* browser.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2001-2011, 2013-2022 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2015-2016, 2020 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -32,45 +32,45 @@ static char **filelist = NULL;
|
||||
/* The list of files to display in the file browser. */
|
||||
static size_t list_length = 0;
|
||||
/* The number of files in the list. */
|
||||
static size_t width = 0;
|
||||
static size_t usable_rows = 0;
|
||||
/* The number of screen rows we can use to display the list. */
|
||||
static int piles = 0;
|
||||
/* The number of files that we can display per screen row. */
|
||||
static size_t longest = 0;
|
||||
/* The number of columns in the longest filename in the list. */
|
||||
static int gauge = 0;
|
||||
/* The width of a 'pile' -- the widest filename plus ten. */
|
||||
static size_t selected = 0;
|
||||
/* The currently selected filename in the list; zero-based. */
|
||||
|
||||
/* Set filelist to the list of files contained in the directory path,
|
||||
* set list_length to the number of files in that list, set longest to
|
||||
* the width in columns of the longest filename in that list (between 15
|
||||
* and COLS), and set width to the number of files that we can display
|
||||
* per screen row. And sort the list too. */
|
||||
/* Fill 'filelist' with the names of the files in the given directory, set
|
||||
* 'list_length' to the number of names in that list, set 'gauge' to the
|
||||
* width of the widest filename plus ten, and set 'piles' to the number of
|
||||
* files that can be displayed per screen row. And sort the list too. */
|
||||
void read_the_list(const char *path, DIR *dir)
|
||||
{
|
||||
size_t path_len = strlen(path), index = 0;
|
||||
const struct dirent *nextdir;
|
||||
size_t path_len = strlen(path);
|
||||
const struct dirent *entry;
|
||||
size_t widest = 0;
|
||||
size_t index = 0;
|
||||
|
||||
longest = 0;
|
||||
/* Find the width of the widest filename in the current folder. */
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
size_t span = breadth(entry->d_name);
|
||||
|
||||
/* Find the length of the longest filename in the current folder. */
|
||||
while ((nextdir = readdir(dir)) != NULL) {
|
||||
size_t name_len = breadth(nextdir->d_name);
|
||||
|
||||
if (name_len > longest)
|
||||
longest = name_len;
|
||||
if (span > widest)
|
||||
widest = span;
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
/* Put 10 characters' worth of blank space between columns of filenames
|
||||
* in the list whenever possible, as Pico does. */
|
||||
longest += 10;
|
||||
/* Reserve ten columns for blanks plus file size. */
|
||||
gauge = widest + 10;
|
||||
|
||||
/* If needed, make room for ".. (parent dir)". */
|
||||
if (longest < 15)
|
||||
longest = 15;
|
||||
if (gauge < 15)
|
||||
gauge = 15;
|
||||
/* Make sure we're not wider than the window. */
|
||||
if (longest > COLS)
|
||||
longest = COLS;
|
||||
if (gauge > COLS)
|
||||
gauge = COLS;
|
||||
|
||||
rewinddir(dir);
|
||||
|
||||
@@ -81,20 +81,19 @@ void read_the_list(const char *path, DIR *dir)
|
||||
|
||||
filelist = nmalloc(list_length * sizeof(char *));
|
||||
|
||||
while ((nextdir = readdir(dir)) != NULL && index < list_length) {
|
||||
/* Don't show the "." entry. */
|
||||
if (strcmp(nextdir->d_name, ".") == 0)
|
||||
while ((entry = readdir(dir)) != NULL && index < list_length) {
|
||||
/* Don't show the useless dot item. */
|
||||
if (strcmp(entry->d_name, ".") == 0)
|
||||
continue;
|
||||
|
||||
filelist[index] = nmalloc(path_len + strlen(nextdir->d_name) + 1);
|
||||
sprintf(filelist[index], "%s%s", path, nextdir->d_name);
|
||||
filelist[index] = nmalloc(path_len + strlen(entry->d_name) + 1);
|
||||
sprintf(filelist[index], "%s%s", path, entry->d_name);
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
/* Maybe the number of files in the directory decreased between the
|
||||
* first time we scanned and the second time. index is the actual
|
||||
* length of the file list, so record it. */
|
||||
/* Maybe the number of files in the directory decreased between
|
||||
* the first time we scanned and the second time. */
|
||||
list_length = index;
|
||||
|
||||
/* Sort the list of names. */
|
||||
@@ -103,31 +102,28 @@ void read_the_list(const char *path, DIR *dir)
|
||||
/* Calculate how many files fit on a line -- feigning room for two
|
||||
* spaces beyond the right edge, and adding two spaces of padding
|
||||
* between columns. */
|
||||
width = (COLS + 2) / (longest + 2);
|
||||
piles = (COLS + 2) / (gauge + 2);
|
||||
|
||||
usable_rows = editwinrows - (ISSET(ZERO) && LINES > 1 ? 1 : 0);
|
||||
}
|
||||
|
||||
/* Look for needle. If we find it, set selected to its location.
|
||||
* Note that needle must be an exact match for a file in the list. */
|
||||
void browser_select_dirname(const char *needle)
|
||||
/* Reselect the given file or directory name, if it still exists. */
|
||||
void reselect(const char *name)
|
||||
{
|
||||
size_t looking_at = 0;
|
||||
|
||||
for (; looking_at < list_length; looking_at++) {
|
||||
if (strcmp(filelist[looking_at], needle) == 0) {
|
||||
selected = looking_at;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (looking_at < list_length && strcmp(filelist[looking_at], name) != 0)
|
||||
looking_at++;
|
||||
|
||||
/* If the sought name isn't found, move the highlight so that the
|
||||
* changed selection will be noticed. */
|
||||
if (looking_at == list_length) {
|
||||
/* If the sought name was found, select it; otherwise, just move
|
||||
* the highlight so that the changed selection will be noticed,
|
||||
* but make sure to stay within the current available range. */
|
||||
if (looking_at < list_length)
|
||||
selected = looking_at;
|
||||
else if (selected > list_length)
|
||||
selected = list_length - 1;
|
||||
else
|
||||
--selected;
|
||||
|
||||
/* Make sure we stay within the available range. */
|
||||
if (selected >= list_length)
|
||||
selected = list_length - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Display at most a screenful of filenames from the gleaned filelist. */
|
||||
@@ -143,8 +139,8 @@ void browser_refresh(void)
|
||||
titlebar(present_path);
|
||||
blank_edit();
|
||||
|
||||
for (size_t index = selected - selected % (editwinrows * width);
|
||||
index < list_length && row < editwinrows; index++) {
|
||||
for (size_t index = selected - selected % (usable_rows * piles);
|
||||
index < list_length && row < usable_rows; index++) {
|
||||
const char *thename = tail(filelist[index]);
|
||||
/* The filename we display, minus the path. */
|
||||
size_t namelen = breadth(thename);
|
||||
@@ -154,11 +150,11 @@ void browser_refresh(void)
|
||||
size_t infomaxlen = 7;
|
||||
/* The maximum length of the file information in columns:
|
||||
* normally seven, but will be twelve for "(parent dir)". */
|
||||
bool dots = (COLS >= 15 && namelen >= longest - infomaxlen);
|
||||
bool dots = (COLS >= 15 && namelen >= gauge - infomaxlen);
|
||||
/* Whether to put an ellipsis before the filename? We don't
|
||||
* waste space on dots when there are fewer than 15 columns. */
|
||||
char *disp = display_string(thename, dots ?
|
||||
namelen + infomaxlen + 4 - longest : 0, longest, FALSE, FALSE);
|
||||
namelen + infomaxlen + 4 - gauge : 0, gauge, FALSE, FALSE);
|
||||
/* The filename (or a fragment of it) in displayable format.
|
||||
* When a fragment, account for dots plus one space padding. */
|
||||
struct stat state;
|
||||
@@ -166,18 +162,18 @@ void browser_refresh(void)
|
||||
/* If this is the selected item, draw its highlighted bar upfront, and
|
||||
* remember its location to be able to place the cursor on it. */
|
||||
if (index == selected) {
|
||||
wattron(edit, interface_color_pair[SELECTED_TEXT]);
|
||||
mvwprintw(edit, row, col, "%*s", longest, " ");
|
||||
wattron(midwin, interface_color_pair[SELECTED_TEXT]);
|
||||
mvwprintw(midwin, row, col, "%*s", gauge, " ");
|
||||
the_row = row;
|
||||
the_column = col;
|
||||
}
|
||||
|
||||
/* If the name is too long, we display something like "...ename". */
|
||||
if (dots)
|
||||
mvwaddstr(edit, row, col, "...");
|
||||
mvwaddstr(edit, row, dots ? col + 3 : col, disp);
|
||||
mvwaddstr(midwin, row, col, "...");
|
||||
mvwaddstr(midwin, row, dots ? col + 3 : col, disp);
|
||||
|
||||
col += longest;
|
||||
col += gauge;
|
||||
|
||||
/* Show information about the file: "--" for symlinks (except when
|
||||
* they point to a directory) and for files that have disappeared,
|
||||
@@ -231,11 +227,11 @@ void browser_refresh(void)
|
||||
infolen = infomaxlen;
|
||||
}
|
||||
|
||||
mvwaddstr(edit, row, col - infolen, info);
|
||||
mvwaddstr(midwin, row, col - infolen, info);
|
||||
|
||||
/* If this is the selected item, finish its highlighting. */
|
||||
if (index == selected)
|
||||
wattroff(edit, interface_color_pair[SELECTED_TEXT]);
|
||||
wattroff(midwin, interface_color_pair[SELECTED_TEXT]);
|
||||
|
||||
free(disp);
|
||||
free(info);
|
||||
@@ -243,8 +239,8 @@ void browser_refresh(void)
|
||||
/* Add some space between the columns. */
|
||||
col += 2;
|
||||
|
||||
/* If the next entry will not fit on this row, move to next row. */
|
||||
if (col > COLS - longest) {
|
||||
/* If the next item will not fit on this row, move to next row. */
|
||||
if (col > COLS - gauge) {
|
||||
row++;
|
||||
col = 0;
|
||||
}
|
||||
@@ -252,11 +248,11 @@ void browser_refresh(void)
|
||||
|
||||
/* If requested, put the cursor on the selected item and switch it on. */
|
||||
if (ISSET(SHOW_CURSOR)) {
|
||||
wmove(edit, the_row, the_column);
|
||||
wmove(midwin, the_row, the_column);
|
||||
curs_set(1);
|
||||
}
|
||||
|
||||
wnoutrefresh(edit);
|
||||
wnoutrefresh(midwin);
|
||||
}
|
||||
|
||||
/* Look for the given needle in the list of files. If forwards is TRUE,
|
||||
@@ -355,11 +351,12 @@ void search_filename(bool forwards)
|
||||
if (*answer != '\0') {
|
||||
last_search = mallocstrcpy(last_search, answer);
|
||||
#ifdef ENABLE_HISTORIES
|
||||
update_history(&search_history, answer);
|
||||
update_history(&search_history, answer, PRUNE_DUPLICATE);
|
||||
#endif
|
||||
}
|
||||
|
||||
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 +377,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)
|
||||
@@ -417,7 +426,7 @@ char *browse(char *path)
|
||||
|
||||
if (path == NULL || dir == NULL) {
|
||||
statusline(ALERT, _("Cannot open directory: %s"), strerror(errno));
|
||||
/* If we don't have a file list yet, there is nothing to show. */
|
||||
/* If we don't have a file list, there is nothing to show. */
|
||||
if (filelist == NULL) {
|
||||
lastmessage = VACUUM;
|
||||
free(present_name);
|
||||
@@ -430,19 +439,18 @@ char *browse(char *path)
|
||||
}
|
||||
|
||||
if (dir != NULL) {
|
||||
/* Get the file list, and set longest and width in the process. */
|
||||
/* Get the file list, and set gauge and piles in the process. */
|
||||
read_the_list(path, dir);
|
||||
closedir(dir);
|
||||
dir = NULL;
|
||||
}
|
||||
|
||||
/* If given, reselect the present_name and then discard it. */
|
||||
/* If something was selected before, reselect it;
|
||||
* otherwise, just select the first item (..). */
|
||||
if (present_name != NULL) {
|
||||
browser_select_dirname(present_name);
|
||||
|
||||
reselect(present_name);
|
||||
free(present_name);
|
||||
present_name = NULL;
|
||||
/* Otherwise, select the first file or directory in the list. */
|
||||
} else
|
||||
selected = 0;
|
||||
|
||||
@@ -467,31 +475,27 @@ char *browse(char *path)
|
||||
|
||||
old_selected = selected;
|
||||
|
||||
kbinput = get_kbinput(edit, ISSET(SHOW_CURSOR));
|
||||
kbinput = get_kbinput(midwin, ISSET(SHOW_CURSOR));
|
||||
|
||||
#ifdef ENABLE_MOUSE
|
||||
if (kbinput == KEY_MOUSE) {
|
||||
int mouse_x, mouse_y;
|
||||
|
||||
/* We can click on the edit window to select a filename. */
|
||||
/* When the user clicked in the file list, select a filename. */
|
||||
if (get_mouseinput(&mouse_y, &mouse_x, TRUE) == 0 &&
|
||||
wmouse_trafo(edit, &mouse_y, &mouse_x, FALSE)) {
|
||||
/* longest is the width of each column. There
|
||||
* are two spaces between each column. */
|
||||
selected = selected - selected % (editwinrows * width) +
|
||||
(mouse_y * width) + (mouse_x / (longest + 2));
|
||||
wmouse_trafo(midwin, &mouse_y, &mouse_x, FALSE)) {
|
||||
selected = selected - selected % (usable_rows * piles) +
|
||||
(mouse_y * piles) + (mouse_x / (gauge + 2));
|
||||
|
||||
/* If they clicked beyond the end of a row,
|
||||
* select the last filename in that row. */
|
||||
if (mouse_x > width * (longest + 2))
|
||||
/* When beyond end-of-row, select the preceding filename. */
|
||||
if (mouse_x > piles * (gauge + 2))
|
||||
selected--;
|
||||
|
||||
/* If we're beyond the list, select the last filename. */
|
||||
/* When beyond end-of-list, select the last filename. */
|
||||
if (selected > list_length - 1)
|
||||
selected = list_length - 1;
|
||||
|
||||
/* If we selected the same filename as last time, fake a
|
||||
* press of the Enter key so that the file is read in. */
|
||||
/* When a filename is clicked a second time, choose it. */
|
||||
if (old_selected == selected)
|
||||
kbinput = KEY_ENTER;
|
||||
}
|
||||
@@ -511,17 +515,15 @@ char *browse(char *path)
|
||||
if (func == full_refresh) {
|
||||
full_refresh();
|
||||
#ifndef NANO_TINY
|
||||
/* Simulate a window resize to force a directory reread. */
|
||||
/* Simulate a terminal resize to force a directory reread. */
|
||||
kbinput = KEY_WINCH;
|
||||
#endif
|
||||
} else if (func == do_help) {
|
||||
do_help();
|
||||
#ifndef NANO_TINY
|
||||
/* The window dimensions might have changed, so act as if. */
|
||||
/* The terminal dimensions might have changed, so act as if. */
|
||||
kbinput = KEY_WINCH;
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
} else if (func == do_toggle_void) {
|
||||
} else if (func == do_toggle) {
|
||||
TOGGLE(NO_HELP);
|
||||
window_init();
|
||||
kbinput = KEY_WINCH;
|
||||
@@ -541,43 +543,42 @@ char *browse(char *path)
|
||||
if (selected < list_length - 1)
|
||||
selected++;
|
||||
} else if (func == to_prev_word) {
|
||||
selected -= (selected % width);
|
||||
selected -= (selected % piles);
|
||||
} else if (func == to_next_word) {
|
||||
selected += width - 1 - (selected % width);
|
||||
selected += piles - 1 - (selected % piles);
|
||||
if (selected >= list_length)
|
||||
selected = list_length - 1;
|
||||
} else if (func == do_up) {
|
||||
if (selected >= width)
|
||||
selected -= width;
|
||||
if (selected >= piles)
|
||||
selected -= piles;
|
||||
} else if (func == do_down) {
|
||||
if (selected + width <= list_length - 1)
|
||||
selected += width;
|
||||
if (selected + piles <= list_length - 1)
|
||||
selected += piles;
|
||||
} else if (func == to_prev_block) {
|
||||
selected = ((selected / (editwinrows * width)) *
|
||||
editwinrows * width) + selected % width;
|
||||
selected = ((selected / (usable_rows * piles)) * usable_rows * piles) +
|
||||
selected % piles;
|
||||
} else if (func == to_next_block) {
|
||||
selected = ((selected / (editwinrows * width)) *
|
||||
editwinrows * width) + selected % width +
|
||||
editwinrows * width - width;
|
||||
selected = ((selected / (usable_rows * piles)) * usable_rows * piles) +
|
||||
selected % piles + usable_rows * piles - piles;
|
||||
if (selected >= list_length)
|
||||
selected = (list_length / width) * width + selected % width;
|
||||
selected = (list_length / piles) * piles + selected % piles;
|
||||
if (selected >= list_length)
|
||||
selected -= width;
|
||||
selected -= piles;
|
||||
} else if (func == do_page_up) {
|
||||
if (selected < width)
|
||||
if (selected < piles)
|
||||
selected = 0;
|
||||
else if (selected < editwinrows * width)
|
||||
selected = selected % width;
|
||||
else if (selected < usable_rows * piles)
|
||||
selected = selected % piles;
|
||||
else
|
||||
selected -= editwinrows * width;
|
||||
selected -= usable_rows * piles;
|
||||
} else if (func == do_page_down) {
|
||||
if (selected + width >= list_length - 1)
|
||||
if (selected + piles >= list_length - 1)
|
||||
selected = list_length - 1;
|
||||
else if (selected + editwinrows * width >= list_length)
|
||||
selected = (selected + editwinrows * width - list_length) %
|
||||
width + list_length - width;
|
||||
else if (selected + usable_rows * piles >= list_length)
|
||||
selected = (selected + usable_rows * piles - list_length) % piles +
|
||||
list_length - piles;
|
||||
else
|
||||
selected += editwinrows * width;
|
||||
selected += usable_rows * piles;
|
||||
} else if (func == to_first_file) {
|
||||
selected = 0;
|
||||
} else if (func == to_last_file) {
|
||||
@@ -602,8 +603,8 @@ char *browse(char *path)
|
||||
|
||||
#ifdef ENABLE_OPERATINGDIR
|
||||
if (outside_of_confinement(path, FALSE)) {
|
||||
/* TRANSLATORS: This refers to the confining effect of the
|
||||
* option --operatingdir, not of --restricted. */
|
||||
/* TRANSLATORS: This refers to the confining effect of
|
||||
* the option --operatingdir, not of --restricted. */
|
||||
statusline(ALERT, _("Can't go outside of %s"), operating_dir);
|
||||
path = mallocstrcpy(path, present_path);
|
||||
continue;
|
||||
@@ -666,7 +667,7 @@ char *browse(char *path)
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
} else if (kbinput == KEY_WINCH) {
|
||||
; /* Nothing to do. */
|
||||
; /* Gets handled below. */
|
||||
#endif
|
||||
} else if (func == do_exit) {
|
||||
break;
|
||||
@@ -674,11 +675,10 @@ char *browse(char *path)
|
||||
unbound_key(kbinput);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If the window resized, refresh the file list. */
|
||||
/* If the terminal resized (or might have), refresh the file list. */
|
||||
if (kbinput == KEY_WINCH) {
|
||||
/* Remember the selected file, to be able to reselect it. */
|
||||
present_name = copy_of(filelist[selected]);
|
||||
/* Reread the contents of the current directory. */
|
||||
goto read_directory_contents;
|
||||
}
|
||||
#endif
|
||||
@@ -709,14 +709,10 @@ char *browse_in(const char *inpath)
|
||||
path = free_and_assign(path, strip_last_component(path));
|
||||
|
||||
if (stat(path, &fileinfo) == -1 || !S_ISDIR(fileinfo.st_mode)) {
|
||||
char *currentdir = nmalloc(PATH_MAX + 1);
|
||||
|
||||
path = free_and_assign(path, getcwd(currentdir, PATH_MAX + 1));
|
||||
path = free_and_assign(path, realpath(".", NULL));
|
||||
|
||||
if (path == NULL) {
|
||||
statusline(MILD, _("The working directory has disappeared"));
|
||||
free(currentdir);
|
||||
beep();
|
||||
statusline(ALERT, _("The working directory has disappeared"));
|
||||
napms(1200);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
248
src/chars.c
248
src/chars.c
@@ -1,8 +1,8 @@
|
||||
/**************************************************************************
|
||||
* 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) 2001-2011, 2013-2022 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2016-2021 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published *
|
||||
@@ -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
|
||||
|
||||
56
src/color.c
56
src/color.c
@@ -1,8 +1,8 @@
|
||||
/**************************************************************************
|
||||
* 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) 2001-2011, 2013-2022 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2017, 2020, 2021 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published *
|
||||
@@ -53,15 +53,16 @@ void set_interface_colorpairs(void)
|
||||
}
|
||||
init_pair(index + 1, combo->fg, combo->bg);
|
||||
interface_color_pair[index] = COLOR_PAIR(index + 1) | combo->attributes;
|
||||
rescind_colors = FALSE;
|
||||
} else {
|
||||
if (index == FUNCTION_TAG || index == SCROLL_BAR)
|
||||
interface_color_pair[index] = A_NORMAL;
|
||||
else if (index == GUIDE_STRIPE)
|
||||
interface_color_pair[index] = A_REVERSE;
|
||||
else if (index == HIGHLIGHTED) {
|
||||
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 == PROMPT_BAR)
|
||||
} 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);
|
||||
@@ -72,6 +73,11 @@ void set_interface_colorpairs(void)
|
||||
|
||||
free(color_combo[index]);
|
||||
}
|
||||
|
||||
if (rescind_colors) {
|
||||
interface_color_pair[SPOTLIGHTED] = A_REVERSE;
|
||||
interface_color_pair[ERROR_MESSAGE] = A_REVERSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Assign a pair number to each of the foreground/background color combinations
|
||||
@@ -119,19 +125,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 | REG_NOSUB);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -265,12 +261,14 @@ void check_the_multis(linestruct *line)
|
||||
if (line->multidata[ink->id] == NOTHING) {
|
||||
if (!astart)
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] & (WHOLELINE|WOULDBE)) {
|
||||
if (!astart && !anend)
|
||||
} else if (line->multidata[ink->id] == WHOLELINE) {
|
||||
/* Ensure that a detected start match is not actually an end match. */
|
||||
if (!anend && (!astart || regexec(ink->end, line->data, 1,
|
||||
&endmatch, 0) != 0))
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] == JUSTONTHIS) {
|
||||
if (astart && anend && regexec(ink->start, line->data + endmatch.rm_eo,
|
||||
1, &startmatch, 0) != 0)
|
||||
if (astart && anend && regexec(ink->start, line->data + startmatch.rm_eo +
|
||||
endmatch.rm_eo, 1, &startmatch, 0) != 0)
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] == STARTSHERE) {
|
||||
if (astart && !anend)
|
||||
@@ -282,6 +280,7 @@ void check_the_multis(linestruct *line)
|
||||
|
||||
/* There is a mismatch, so something changed: repaint. */
|
||||
refresh_needed = TRUE;
|
||||
perturbed = TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -305,7 +304,8 @@ void precalc_multicolorinfo(void)
|
||||
|
||||
/* For each line, allocate cache space for the multiline-regex info. */
|
||||
for (line = openfile->filetop; line != NULL; line = line->next)
|
||||
line->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
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. */
|
||||
@@ -351,21 +351,17 @@ void precalc_multicolorinfo(void)
|
||||
1, &endmatch, 0) != 0)
|
||||
tailline = tailline->next;
|
||||
|
||||
/* When there is no end match, mark relevant lines as such. */
|
||||
if (tailline == NULL) {
|
||||
for (; line->next != NULL; line = line->next)
|
||||
line->multidata[ink->id] = WOULDBE;
|
||||
line->multidata[ink->id] = WOULDBE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* We found it, we found it, la lala lala. Mark the lines. */
|
||||
line->multidata[ink->id] = STARTSHERE;
|
||||
|
||||
// Note that this also advances the line in the main loop.
|
||||
for (line = line->next; line != tailline; line = line->next)
|
||||
line->multidata[ink->id] = WHOLELINE;
|
||||
|
||||
if (tailline == NULL) {
|
||||
line = openfile->filebot;
|
||||
break;
|
||||
}
|
||||
|
||||
tailline->multidata[ink->id] = ENDSHERE;
|
||||
|
||||
/* Look for a possible new start after the end match. */
|
||||
|
||||
92
src/cut.c
92
src/cut.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* cut.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014 Mark Majeres *
|
||||
* Copyright (C) 2016, 2018-2020 Benno Schulenberg *
|
||||
* *
|
||||
@@ -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;
|
||||
@@ -193,7 +185,7 @@ void chop_word(bool forward)
|
||||
* on the edge of the original line, then put the cursor on that
|
||||
* edge instead, so that lines will not be joined unexpectedly. */
|
||||
if (!forward) {
|
||||
do_prev_word(ISSET(WORD_BOUNDS));
|
||||
do_prev_word();
|
||||
if (openfile->current != is_current) {
|
||||
if (is_current_x > 0) {
|
||||
openfile->current = is_current;
|
||||
@@ -202,7 +194,7 @@ void chop_word(bool forward)
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
}
|
||||
} else {
|
||||
do_next_word(ISSET(AFTER_ENDS), ISSET(WORD_BOUNDS));
|
||||
do_next_word(ISSET(AFTER_ENDS));
|
||||
if (openfile->current != is_current &&
|
||||
is_current->data[is_current_x] != '\0') {
|
||||
openfile->current = is_current;
|
||||
@@ -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);
|
||||
@@ -447,9 +435,19 @@ void ingraft_buffer(linestruct *topline)
|
||||
/* Meld a copy of the given buffer into the current file buffer. */
|
||||
void copy_from_buffer(linestruct *somebuffer)
|
||||
{
|
||||
#ifdef ENABLE_COLOR
|
||||
size_t threshold = openfile->edittop->lineno + editwinrows - 1;
|
||||
#endif
|
||||
linestruct *the_copy = copy_buffer(somebuffer);
|
||||
|
||||
ingraft_buffer(the_copy);
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
if (openfile->current->lineno > threshold || ISSET(SOFTWRAP))
|
||||
recook = TRUE;
|
||||
else
|
||||
perturbed = TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -497,7 +495,7 @@ void do_snip(bool marked, bool until_eof, bool append)
|
||||
/* When not at the end of a line, move the rest of this line into
|
||||
* the cutbuffer. Otherwise, when not at the end of the buffer,
|
||||
* move just the "line separator" into the cutbuffer. */
|
||||
if (openfile->current_x < strlen(openfile->current->data))
|
||||
if (line->data[openfile->current_x] != '\0')
|
||||
extract_segment(line, openfile->current_x, line, strlen(line->data));
|
||||
else if (openfile->current != openfile->filebot) {
|
||||
extract_segment(line, openfile->current_x, line->next, 0);
|
||||
@@ -521,6 +519,9 @@ void do_snip(bool marked, bool until_eof, bool append)
|
||||
|
||||
set_modified();
|
||||
refresh_needed = TRUE;
|
||||
#ifdef ENABLE_COLOR
|
||||
perturbed = TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Move text from the current buffer into the cutbuffer. */
|
||||
@@ -706,10 +707,15 @@ void copy_text(void)
|
||||
/* Copy text from the cutbuffer into the current buffer. */
|
||||
void paste_text(void)
|
||||
{
|
||||
#if defined(ENABLE_WRAPPING) || !defined(NANO_TINY)
|
||||
/* Remember where the paste started. */
|
||||
linestruct *was_current = openfile->current;
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
bool had_anchor = was_current->has_anchor;
|
||||
#endif
|
||||
ssize_t was_lineno = openfile->current->lineno;
|
||||
/* The line number where we started the paste. */
|
||||
size_t was_leftedge = 0;
|
||||
/* The leftedge where we started the paste. */
|
||||
|
||||
if (cutbuffer == NULL) {
|
||||
statusline(AHEM, _("Cutbuffer is empty"));
|
||||
@@ -728,9 +734,21 @@ void paste_text(void)
|
||||
copy_from_buffer(cutbuffer);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Wipe any anchors in the pasted text, so that they don't proliferate. */
|
||||
for (linestruct *line = was_current; line != openfile->current->next; line = line->next)
|
||||
line->has_anchor = FALSE;
|
||||
|
||||
was_current->has_anchor = had_anchor;
|
||||
|
||||
update_undo(PASTE);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WRAPPING
|
||||
/* When still on the same line and doing hard-wrapping, limit the width. */
|
||||
if (openfile->current == was_current && ISSET(BREAK_LONG_LINES))
|
||||
do_wrap();
|
||||
#endif
|
||||
|
||||
/* If we pasted less than a screenful, don't center the cursor. */
|
||||
if (less_than_a_screenful(was_lineno, was_leftedge))
|
||||
focusing = FALSE;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* definitions.h -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2017 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -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>
|
||||
@@ -104,6 +108,14 @@
|
||||
#define BACKWARD FALSE
|
||||
#define FORWARD TRUE
|
||||
|
||||
#define YESORNO FALSE
|
||||
#define YESORALLORNO TRUE
|
||||
|
||||
#define YES 1
|
||||
#define ALL 2
|
||||
#define NO 0
|
||||
#define CANCEL -1
|
||||
|
||||
#define BLIND FALSE
|
||||
#define VISIBLE TRUE
|
||||
|
||||
@@ -111,9 +123,19 @@
|
||||
#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
|
||||
|
||||
#define PRUNE_DUPLICATE TRUE
|
||||
#define IGNORE_DUPLICATES 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
|
||||
@@ -148,8 +170,6 @@
|
||||
/* The start regex matches on an earlier line, the end regex on this one. */
|
||||
#define JUSTONTHIS (1<<5)
|
||||
/* Both the start and end regexes match within this line. */
|
||||
#define WOULDBE (1<<6)
|
||||
/* An unpaired start match is on or before this line. */
|
||||
#endif
|
||||
|
||||
/* Basic control codes. */
|
||||
@@ -204,7 +224,7 @@
|
||||
#define FOREIGN_SEQUENCE 0x4FC
|
||||
|
||||
/* A special keycode for plugging into the input stream after a suspension. */
|
||||
#define KEY_FLUSH KEY_F0
|
||||
#define KEY_FRESH 0x4FE
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* A special keycode for when we get a SIGWINCH (a window resize). */
|
||||
@@ -216,6 +236,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 +267,7 @@
|
||||
|
||||
/* Enumeration types. */
|
||||
typedef enum {
|
||||
NIX_FILE, DOS_FILE, MAC_FILE
|
||||
UNSPECIFIED, NIX_FILE, DOS_FILE, MAC_FILE
|
||||
} format_type;
|
||||
|
||||
typedef enum {
|
||||
@@ -282,7 +303,8 @@ enum {
|
||||
GUIDE_STRIPE,
|
||||
SCROLL_BAR,
|
||||
SELECTED_TEXT,
|
||||
HIGHLIGHTED,
|
||||
SPOTLIGHTED,
|
||||
MINI_INFOBAR,
|
||||
PROMPT_BAR,
|
||||
STATUS_BAR,
|
||||
ERROR_MESSAGE,
|
||||
@@ -307,7 +329,6 @@ enum {
|
||||
CUT_FROM_CURSOR,
|
||||
BACKWARDS_SEARCH,
|
||||
MULTIBUFFER,
|
||||
SMOOTH_SCROLL,
|
||||
REBIND_DELETE,
|
||||
RAW_SEQUENCES,
|
||||
NO_CONVERT,
|
||||
@@ -319,7 +340,6 @@ enum {
|
||||
RESTRICTED,
|
||||
SMART_HOME,
|
||||
WHITESPACE_DISPLAY,
|
||||
MORE_SPACE,
|
||||
TABS_TO_SPACES,
|
||||
QUICK_BLANK,
|
||||
WORD_BOUNDS,
|
||||
@@ -333,7 +353,6 @@ enum {
|
||||
TRIM_BLANKS,
|
||||
SHOW_CURSOR,
|
||||
LINE_NUMBERS,
|
||||
NO_PAUSES,
|
||||
AT_BLANKS,
|
||||
AFTER_ENDS,
|
||||
LET_THEM_ZAP,
|
||||
@@ -344,7 +363,8 @@ enum {
|
||||
BOOKSTYLE,
|
||||
STATEFLAGS,
|
||||
USE_MAGIC,
|
||||
MINIBAR
|
||||
MINIBAR,
|
||||
ZERO
|
||||
};
|
||||
|
||||
/* Structure types. */
|
||||
@@ -369,8 +389,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 +461,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 +583,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 +646,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
|
||||
|
||||
582
src/files.c
582
src/files.c
File diff suppressed because it is too large
Load Diff
344
src/global.c
344
src/global.c
@@ -1,8 +1,8 @@
|
||||
/**************************************************************************
|
||||
* global.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2020 Benno Schulenberg *
|
||||
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2021 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published *
|
||||
@@ -80,8 +80,6 @@ linestruct *pletion_line = NULL;
|
||||
bool also_the_last = FALSE;
|
||||
/* Whether indenting/commenting should include the last line of
|
||||
* the marked region. */
|
||||
bool hide_cursor = FALSE;
|
||||
/* Whether to suppress the cursor when highlighting a search match. */
|
||||
|
||||
char *answer = NULL;
|
||||
/* The answer string used by the status-bar prompt. */
|
||||
@@ -120,12 +118,12 @@ size_t wrap_at = 0;
|
||||
WINDOW *topwin = NULL;
|
||||
/* The top portion of the screen, showing the version number of nano,
|
||||
* the name of the file, and whether the buffer was modified. */
|
||||
WINDOW *edit = NULL;
|
||||
WINDOW *midwin = NULL;
|
||||
/* The middle portion of the screen: the edit window, showing the
|
||||
* contents of the current buffer, the file we are editing. */
|
||||
WINDOW *bottomwin = NULL;
|
||||
/* The bottom portion of the screen, where we display statusbar
|
||||
* messages, the status-bar prompt, and a list of shortcuts. */
|
||||
WINDOW *footwin = NULL;
|
||||
/* The bottom portion of the screen, where status-bar messages,
|
||||
* the status-bar prompt, and a list of shortcuts are shown. */
|
||||
int editwinrows = 0;
|
||||
/* How many rows does the edit window take up? */
|
||||
int editwincols = -1;
|
||||
@@ -203,6 +201,12 @@ char *syntaxstr = NULL;
|
||||
/* The color syntax name specified on the command line. */
|
||||
bool have_palette = FALSE;
|
||||
/* Whether the colors for the current syntax have been initialized. */
|
||||
bool rescind_colors = FALSE;
|
||||
/* Becomes TRUE when NO_COLOR is set in the environment. */
|
||||
bool perturbed = FALSE;
|
||||
/* Whether the multiline-coloring situation has changed. */
|
||||
bool recook = FALSE;
|
||||
/* Whether the multidata should be recalculated. */
|
||||
#endif
|
||||
|
||||
int currmenu = MMOST;
|
||||
@@ -218,15 +222,16 @@ funcstruct *exitfunc;
|
||||
|
||||
linestruct *search_history = NULL;
|
||||
/* The current item in the list of strings that were searched for. */
|
||||
linestruct *execute_history = NULL;
|
||||
/* The current item in the list of commands that were run with ^R ^X. */
|
||||
linestruct *replace_history = NULL;
|
||||
/* The current item in the list of replace strings. */
|
||||
linestruct *execute_history = NULL;
|
||||
/* The current item in the list of commands that were run with ^T. */
|
||||
|
||||
#ifdef ENABLE_HISTORIES
|
||||
linestruct *searchtop = NULL;
|
||||
/* The oldest item in the list of search strings. */
|
||||
linestruct *searchbot = NULL;
|
||||
/* The newest item in the list of search strings. */
|
||||
/* The empty item at the end of the list of search strings. */
|
||||
|
||||
linestruct *replacetop = NULL;
|
||||
linestruct *replacebot = NULL;
|
||||
@@ -282,78 +287,36 @@ size_t light_to_col = 0;
|
||||
#endif
|
||||
|
||||
/* Empty functions, for the most part corresponding to toggles. */
|
||||
void case_sens_void(void)
|
||||
{
|
||||
}
|
||||
void regexp_void(void)
|
||||
{
|
||||
}
|
||||
void backwards_void(void)
|
||||
{
|
||||
}
|
||||
void flip_replace(void)
|
||||
{
|
||||
}
|
||||
void flip_goto(void)
|
||||
{
|
||||
}
|
||||
void case_sens_void(void) {;}
|
||||
void regexp_void(void) {;}
|
||||
void backwards_void(void) {;}
|
||||
#ifdef ENABLE_HISTORIES
|
||||
void get_older_item(void) {;}
|
||||
void get_newer_item(void) {;}
|
||||
#endif
|
||||
void flip_replace(void) {;}
|
||||
void flip_goto(void) {;}
|
||||
#ifdef ENABLE_BROWSER
|
||||
void to_files(void)
|
||||
{
|
||||
}
|
||||
void to_first_file(void)
|
||||
{
|
||||
}
|
||||
void to_last_file(void)
|
||||
{
|
||||
}
|
||||
void goto_dir(void)
|
||||
{
|
||||
}
|
||||
void to_files(void) {;}
|
||||
void goto_dir(void) {;}
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
void do_nothing(void)
|
||||
{
|
||||
}
|
||||
void do_toggle_void(void)
|
||||
{
|
||||
}
|
||||
void dos_format_void(void)
|
||||
{
|
||||
}
|
||||
void mac_format_void(void)
|
||||
{
|
||||
}
|
||||
void append_void(void)
|
||||
{
|
||||
}
|
||||
void prepend_void(void)
|
||||
{
|
||||
}
|
||||
void backup_file_void(void)
|
||||
{
|
||||
}
|
||||
void flip_execute(void)
|
||||
{
|
||||
}
|
||||
void flip_pipe(void)
|
||||
{
|
||||
}
|
||||
void flip_convert(void)
|
||||
{
|
||||
}
|
||||
void do_nothing(void) {;}
|
||||
void do_toggle(void) {;}
|
||||
void dos_format(void) {;}
|
||||
void mac_format(void) {;}
|
||||
void append_it(void) {;}
|
||||
void prepend_it(void) {;}
|
||||
void back_it_up(void) {;}
|
||||
void flip_execute(void) {;}
|
||||
void flip_pipe(void) {;}
|
||||
void flip_convert(void) {;}
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
void flip_newbuffer(void)
|
||||
{
|
||||
}
|
||||
void flip_newbuffer(void) {;}
|
||||
#endif
|
||||
void discard_buffer(void)
|
||||
{
|
||||
}
|
||||
void do_cancel(void)
|
||||
{
|
||||
}
|
||||
void discard_buffer(void) {;}
|
||||
void do_cancel(void) {;}
|
||||
|
||||
/* Add a function to the linked list of functions. */
|
||||
void add_to_funcs(void (*func)(void), int menus, const char *desc,
|
||||
@@ -384,7 +347,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;
|
||||
@@ -560,6 +523,14 @@ functionptrtype interpret(int *keycode)
|
||||
}
|
||||
#endif /* ENABLE_BROWSER || ENABLE_HELP */
|
||||
|
||||
#if defined(NANO_TINY) && defined(ENABLE_LINENUMBERS)
|
||||
/* Allow toggling line numbers also in the tiny version. */
|
||||
void toggle_numbers(void)
|
||||
{
|
||||
TOGGLE(LINE_NUMBERS);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* These two tags are used elsewhere too, so they are global. */
|
||||
/* TRANSLATORS: Try to keep the next two strings at most 10 characters. */
|
||||
const char *exit_tag = N_("Exit");
|
||||
@@ -637,7 +608,7 @@ void shortcut_init(void)
|
||||
const char *nextfile_gist = N_("Switch to the next file buffer");
|
||||
#endif
|
||||
const char *verbatim_gist = N_("Insert the next keystroke verbatim");
|
||||
const char *tab_gist = N_("Insert a tab at the cursor position");
|
||||
const char *tab_gist = N_("Insert a tab at the cursor position (or indent marked lines)");
|
||||
const char *enter_gist = N_("Insert a newline at the cursor position");
|
||||
const char *delete_gist = N_("Delete the character under the cursor");
|
||||
const char *backspace_gist =
|
||||
@@ -656,10 +627,10 @@ void shortcut_init(void)
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
const char *wordcount_gist =
|
||||
N_("Count the number of words, lines, and characters");
|
||||
N_("Count the number of lines, words, and characters");
|
||||
const char *suspend_gist = N_("Suspend the editor (return to the shell)");
|
||||
#endif
|
||||
const char *refresh_gist = N_("Refresh (redraw) the current screen");
|
||||
const char *suspend_gist = N_("Suspend the editor (if suspension is enabled)");
|
||||
#ifdef ENABLE_WORDCOMPLETION
|
||||
const char *completion_gist = N_("Try and complete the current word");
|
||||
#endif
|
||||
@@ -761,7 +732,7 @@ void shortcut_init(void)
|
||||
add_to_funcs(flip_goto, MGOTOLINE, "Go To Text", "x", 0, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(do_writeout_void, MMAIN,
|
||||
add_to_funcs(do_writeout, MMAIN,
|
||||
N_("Write Out"), WITHORSANS(writeout_gist), TOGETHER, NOVIEW);
|
||||
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
@@ -769,14 +740,14 @@ void shortcut_init(void)
|
||||
* otherwise, show Insert anyway, to keep the help items paired. */
|
||||
if (!ISSET(RESTRICTED))
|
||||
#endif
|
||||
add_to_funcs(do_insertfile_void, MMAIN,
|
||||
add_to_funcs(do_insertfile, MMAIN,
|
||||
N_("Read File"), WITHORSANS(readfile_gist), BLANKAFTER,
|
||||
/* We allow inserting files in view mode if multibuffer mode
|
||||
* is available, so that the user can view multiple files. */
|
||||
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 +786,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
|
||||
}
|
||||
@@ -827,7 +798,7 @@ void shortcut_init(void)
|
||||
#if defined(NANO_TINY) || defined(ENABLE_JUSTIFY)
|
||||
/* Conditionally placing this one here or further on, to keep the
|
||||
* help items nicely paired in most conditions. */
|
||||
add_to_funcs(do_gotolinecolumn_void, MMAIN,
|
||||
add_to_funcs(do_gotolinecolumn, MMAIN,
|
||||
N_("Go To Line"), WITHORSANS(gotoline_gist), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
@@ -841,7 +812,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,
|
||||
@@ -857,9 +828,9 @@ void shortcut_init(void)
|
||||
N_("No Replace"), WITHORSANS(whereis_gist), BLANKAFTER, VIEW);
|
||||
|
||||
#ifdef ENABLE_HISTORIES
|
||||
add_to_funcs(get_history_older_void, MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE,
|
||||
add_to_funcs(get_older_item, MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE,
|
||||
N_("Older"), WITHORSANS(older_gist), TOGETHER, VIEW);
|
||||
add_to_funcs(get_history_newer_void, MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE,
|
||||
add_to_funcs(get_newer_item, MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE,
|
||||
N_("Newer"), WITHORSANS(newer_gist), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
@@ -870,7 +841,7 @@ void shortcut_init(void)
|
||||
|
||||
#ifdef ENABLE_BROWSER
|
||||
add_to_funcs(goto_dir, MBROWSER,
|
||||
/* TRANSLATORS: Try to keep the next seven strings at most 10 characters. */
|
||||
/* TRANSLATORS: Try to keep the next four strings at most 10 characters. */
|
||||
N_("Go To Dir"), WITHORSANS(gotodir_gist), TOGETHER, VIEW);
|
||||
#ifdef ENABLE_HELP
|
||||
add_to_funcs(full_refresh, MBROWSER,
|
||||
@@ -974,7 +945,7 @@ void shortcut_init(void)
|
||||
#endif
|
||||
|
||||
#if !defined(NANO_TINY) && !defined(ENABLE_JUSTIFY)
|
||||
add_to_funcs(do_gotolinecolumn_void, MMAIN,
|
||||
add_to_funcs(do_gotolinecolumn, MMAIN,
|
||||
N_("Go To Line"), WITHORSANS(gotoline_gist), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
@@ -1011,21 +982,22 @@ void shortcut_init(void)
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(do_wordlinechar_count, MMAIN,
|
||||
add_to_funcs(count_lines_words_and_characters, MMAIN,
|
||||
N_("Word Count"), WITHORSANS(wordcount_gist), TOGETHER, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(do_verbatim_input, MMAIN,
|
||||
N_("Verbatim"), WITHORSANS(verbatim_gist), BLANKAFTER, NOVIEW);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(do_suspend, MMAIN,
|
||||
N_("Suspend"), WITHORSANS(suspend_gist), TOGETHER, VIEW);
|
||||
#endif
|
||||
#ifdef ENABLE_HELP
|
||||
add_to_funcs(full_refresh, MMAIN,
|
||||
N_("Refresh"), WITHORSANS(refresh_gist), TOGETHER, VIEW);
|
||||
N_("Refresh"), WITHORSANS(refresh_gist), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(do_suspend_void, MMAIN,
|
||||
N_("Suspend"), WITHORSANS(suspend_gist), BLANKAFTER, VIEW);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(do_indent, MMAIN,
|
||||
N_("Indent"), WITHORSANS(indent_gist), TOGETHER, NOVIEW);
|
||||
@@ -1055,7 +1027,7 @@ void shortcut_init(void)
|
||||
N_("Down to anchor"), WITHORSANS(nextanchor_gist), BLANKAFTER, VIEW);
|
||||
|
||||
add_to_funcs(zap_text, MMAIN,
|
||||
/* TRANSLATORS: This *deletes* a line or marked region. */
|
||||
/* TRANSLATORS: This refers to deleting a line or marked region. */
|
||||
N_("Zap"), WITHORSANS(zap_gist), BLANKAFTER, NOVIEW);
|
||||
|
||||
if (!ISSET(RESTRICTED)) {
|
||||
@@ -1117,9 +1089,9 @@ void shortcut_init(void)
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(dos_format_void, MWRITEFILE,
|
||||
add_to_funcs(dos_format, MWRITEFILE,
|
||||
N_("DOS Format"), WITHORSANS(dos_gist), TOGETHER, NOVIEW);
|
||||
add_to_funcs(mac_format_void, MWRITEFILE,
|
||||
add_to_funcs(mac_format, MWRITEFILE,
|
||||
N_("Mac Format"), WITHORSANS(mac_gist), TOGETHER, NOVIEW);
|
||||
|
||||
/* If we're using restricted mode, the Append, Prepend, and Backup toggles
|
||||
@@ -1127,12 +1099,12 @@ void shortcut_init(void)
|
||||
* reduplicating the current file, and the third is not allowed as it
|
||||
* would write to a file not specified on the command line. */
|
||||
if (!ISSET(RESTRICTED)) {
|
||||
add_to_funcs(append_void, MWRITEFILE,
|
||||
add_to_funcs(append_it, MWRITEFILE,
|
||||
N_("Append"), WITHORSANS(append_gist), TOGETHER, NOVIEW);
|
||||
add_to_funcs(prepend_void, MWRITEFILE,
|
||||
add_to_funcs(prepend_it, MWRITEFILE,
|
||||
N_("Prepend"), WITHORSANS(prepend_gist), TOGETHER, NOVIEW);
|
||||
|
||||
add_to_funcs(backup_file_void, MWRITEFILE,
|
||||
add_to_funcs(back_it_up, MWRITEFILE,
|
||||
N_("Backup File"), WITHORSANS(backup_gist), BLANKAFTER, NOVIEW);
|
||||
}
|
||||
|
||||
@@ -1147,7 +1119,7 @@ void shortcut_init(void)
|
||||
add_to_funcs(cut_till_eof, MEXECUTE,
|
||||
N_("Cut Till End"), WITHORSANS(cuttilleof_gist), BLANKAFTER, NOVIEW);
|
||||
|
||||
add_to_funcs(do_suspend_void, MEXECUTE,
|
||||
add_to_funcs(do_suspend, MEXECUTE,
|
||||
N_("Suspend"), WITHORSANS(suspend_gist), BLANKAFTER, VIEW);
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
@@ -1192,6 +1164,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);
|
||||
@@ -1206,25 +1184,32 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "^X", 0, do_exit, 0);
|
||||
if (!ISSET(PRESERVE))
|
||||
add_to_sclist(MMAIN, "^S", 0, do_savefile, 0);
|
||||
add_to_sclist(MMAIN, "^O", 0, do_writeout_void, 0);
|
||||
add_to_sclist(MMAIN, "^R", 0, do_insertfile_void, 0);
|
||||
add_to_sclist(MMAIN, "Ins", KEY_IC, do_insertfile_void, 0);
|
||||
add_to_sclist(MMAIN, "^O", 0, do_writeout, 0);
|
||||
add_to_sclist(MMAIN, "^R", 0, do_insertfile, 0);
|
||||
add_to_sclist(MMAIN, "Ins", KEY_IC, do_insertfile, 0);
|
||||
if (!ISSET(PRESERVE))
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "^Q", 0, do_search_backward, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "^W", 0, do_search_forward, 0);
|
||||
add_to_sclist(MMAIN, "^\\", 0, do_replace, 0);
|
||||
add_to_sclist(MMAIN, "M-R", 0, do_replace, 0);
|
||||
add_to_sclist(MMOST, "^K", 0, cut_text, 0);
|
||||
#ifdef NANO_TINY
|
||||
add_to_sclist(MMAIN, "^U", 0, paste_text, 0);
|
||||
#else
|
||||
add_to_sclist(MMOST, "^U", 0, paste_text, 0);
|
||||
#ifndef NANO_TINY
|
||||
add_to_sclist(MMAIN, "^T", 0, do_execute, 0);
|
||||
#endif
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
add_to_sclist(MMAIN, "^J", '\n', do_justify_void, 0);
|
||||
add_to_sclist(MMAIN, "^J", '\n', do_justify, 0);
|
||||
#endif
|
||||
#ifdef ENABLE_SPELLER
|
||||
add_to_sclist(MEXECUTE, "^S", 0, do_spell, 0);
|
||||
#ifndef NANO_TINY
|
||||
if (!ISSET(PRESERVE))
|
||||
add_to_sclist(MEXECUTE, "^S", 0, do_spell, 0);
|
||||
add_to_sclist(MEXECUTE, "^T", 0, do_spell, 0);
|
||||
#else
|
||||
add_to_sclist(MMAIN, "^T", 0, do_spell, 0);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
add_to_sclist(MMAIN, "M-B", 0, do_linter, 0);
|
||||
@@ -1233,8 +1218,9 @@ void shortcut_init(void)
|
||||
add_to_sclist(MEXECUTE, "^O", 0, do_formatter, 0);
|
||||
#endif
|
||||
add_to_sclist(MMAIN, "^C", 0, report_cursor_position, 0);
|
||||
add_to_sclist(MMAIN, "^_", 0, do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN, "M-G", 0, do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN, SLASH_OR_DASH, 0, do_gotolinecolumn, 0);
|
||||
add_to_sclist(MMAIN, "M-G", 0, do_gotolinecolumn, 0);
|
||||
add_to_sclist(MMAIN, "^_", 0, do_gotolinecolumn, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "^Y", 0, do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "PgUp", KEY_PPAGE, do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "^V", 0, do_page_down, 0);
|
||||
@@ -1249,19 +1235,23 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "M-W", 0, do_findnext, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "M-Q", 0, do_findprevious, 0);
|
||||
#ifdef NANO_TINY
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
add_to_sclist(MMAIN, "M-N", 0, toggle_numbers, 0);
|
||||
#else
|
||||
add_to_sclist(MMAIN, "M-B", 0, to_prev_word, 0);
|
||||
add_to_sclist(MMAIN, "M-D", 0, to_prev_word, 0);
|
||||
add_to_sclist(MMAIN, "M-N", 0, to_next_word, 0);
|
||||
#endif
|
||||
add_to_sclist(MMAIN, "M-D", 0, to_prev_word, 0);
|
||||
add_to_sclist(MMAIN, "M-F", 0, to_next_word, 0);
|
||||
#else
|
||||
add_to_sclist(MMAIN, "M-]", 0, do_find_bracket, 0);
|
||||
add_to_sclist(MMAIN, "M-A", 0, do_mark, 0);
|
||||
add_to_sclist(MMAIN, "^6", 0, do_mark, 0);
|
||||
add_to_sclist(MMAIN, "^^", 0, do_mark, 0);
|
||||
add_to_sclist(MMAIN, "M-6", 0, copy_text, 0);
|
||||
add_to_sclist(MMAIN, "M-^", 0, copy_text, 0);
|
||||
add_to_sclist(MMOST, "M-6", 0, copy_text, 0);
|
||||
add_to_sclist(MMOST, "M-^", 0, copy_text, 0);
|
||||
add_to_sclist(MMAIN, "M-}", 0, do_indent, 0);
|
||||
add_to_sclist(MMAIN, "Tab", INDENT_KEY, do_indent, 0);
|
||||
add_to_sclist(MMAIN, "", INDENT_KEY, do_indent, 0);
|
||||
add_to_sclist(MMAIN, "M-{", 0, do_unindent, 0);
|
||||
add_to_sclist(MMAIN, "Sh-Tab", SHIFT_TAB, do_unindent, 0);
|
||||
add_to_sclist(MMAIN, "M-:", 0, record_macro, 0);
|
||||
@@ -1286,14 +1276,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 +1310,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 +1333,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
|
||||
{
|
||||
@@ -1368,7 +1358,9 @@ void shortcut_init(void)
|
||||
#ifndef NANO_TINY
|
||||
add_to_sclist(MMAIN, "M-T", 0, cut_till_eof, 0);
|
||||
add_to_sclist(MEXECUTE, "^V", 0, cut_till_eof, 0);
|
||||
add_to_sclist(MMAIN, "M-D", 0, do_wordlinechar_count, 0);
|
||||
add_to_sclist(MEXECUTE, "^Z", 0, do_suspend, 0);
|
||||
add_to_sclist(MMAIN, "^Z", 0, suggest_ctrlT_ctrlZ, 0);
|
||||
add_to_sclist(MMAIN, "M-D", 0, count_lines_words_and_characters, 0);
|
||||
#else
|
||||
add_to_sclist(MMAIN, "M-H", 0, do_help, 0);
|
||||
#endif
|
||||
@@ -1383,37 +1375,34 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMOST|MBROWSER|MHELP|MYESNO, "^L", 0, full_refresh, 0);
|
||||
else
|
||||
add_to_sclist(MMOST|MBROWSER|MYESNO, "^L", 0, full_refresh, 0);
|
||||
add_to_sclist(MMAIN|MEXECUTE, "^Z", 0, do_suspend_void, 0);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Group of "Appearance" toggles. */
|
||||
add_to_sclist((MMOST|MBROWSER|MYESNO) & ~MFINDINHELP, "M-X", 0, do_toggle_void, NO_HELP);
|
||||
add_to_sclist(MMAIN, "M-C", 0, do_toggle_void, CONSTANT_SHOW);
|
||||
add_to_sclist(MMAIN, "M-S", 0, do_toggle_void, SOFTWRAP);
|
||||
add_to_sclist(MMAIN, "M-$", 0, do_toggle_void, SOFTWRAP);
|
||||
add_to_sclist(MMAIN, "M-Z", 0, do_toggle, ZERO);
|
||||
add_to_sclist((MMOST|MBROWSER|MYESNO) & ~MFINDINHELP, "M-X", 0, do_toggle, NO_HELP);
|
||||
add_to_sclist(MMAIN, "M-C", 0, do_toggle, CONSTANT_SHOW);
|
||||
add_to_sclist(MMAIN, "M-S", 0, do_toggle, SOFTWRAP);
|
||||
add_to_sclist(MMAIN, "M-$", 0, do_toggle, SOFTWRAP); /* Legacy keystroke. */
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
add_to_sclist(MMAIN, "M-N", 0, do_toggle_void, LINE_NUMBERS);
|
||||
add_to_sclist(MMAIN, "M-#", 0, do_toggle_void, LINE_NUMBERS);
|
||||
add_to_sclist(MMAIN, "M-N", 0, do_toggle, LINE_NUMBERS);
|
||||
add_to_sclist(MMAIN, "M-#", 0, do_toggle, LINE_NUMBERS); /* Legacy keystroke. */
|
||||
#endif
|
||||
add_to_sclist(MMAIN, "M-P", 0, do_toggle_void, WHITESPACE_DISPLAY);
|
||||
add_to_sclist(MMAIN, "M-P", 0, do_toggle, WHITESPACE_DISPLAY);
|
||||
#ifdef ENABLE_COLOR
|
||||
add_to_sclist(MMAIN, "M-Y", 0, do_toggle_void, NO_SYNTAX);
|
||||
add_to_sclist(MMAIN, "M-Y", 0, do_toggle, NO_SYNTAX);
|
||||
#endif
|
||||
|
||||
/* Group of "Editing-behavior" toggles. */
|
||||
add_to_sclist(MMAIN, "M-H", 0, do_toggle_void, SMART_HOME);
|
||||
add_to_sclist(MMAIN, "M-I", 0, do_toggle_void, AUTOINDENT);
|
||||
add_to_sclist(MMAIN, "M-K", 0, do_toggle_void, CUT_FROM_CURSOR);
|
||||
/* Group of "Behavior" toggles. */
|
||||
add_to_sclist(MMAIN, "M-H", 0, do_toggle, SMART_HOME);
|
||||
add_to_sclist(MMAIN, "M-I", 0, do_toggle, AUTOINDENT);
|
||||
add_to_sclist(MMAIN, "M-K", 0, do_toggle, CUT_FROM_CURSOR);
|
||||
#ifdef ENABLE_WRAPPING
|
||||
add_to_sclist(MMAIN, "M-L", 0, do_toggle_void, BREAK_LONG_LINES);
|
||||
add_to_sclist(MMAIN, "M-L", 0, do_toggle, BREAK_LONG_LINES);
|
||||
#endif
|
||||
add_to_sclist(MMAIN, "M-O", 0, do_toggle_void, TABS_TO_SPACES);
|
||||
|
||||
/* Group of "Peripheral-feature" toggles. */
|
||||
add_to_sclist(MMAIN, "M-O", 0, do_toggle, TABS_TO_SPACES);
|
||||
#ifdef ENABLE_MOUSE
|
||||
add_to_sclist(MMAIN, "M-M", 0, do_toggle_void, USE_MOUSE);
|
||||
add_to_sclist(MMAIN, "M-M", 0, do_toggle, USE_MOUSE);
|
||||
#endif
|
||||
add_to_sclist(MMAIN, "M-Z", 0, do_toggle_void, SUSPENDABLE);
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
add_to_sclist(((MMOST & ~MMAIN) | MYESNO), "^C", 0, do_cancel, 0);
|
||||
@@ -1424,28 +1413,26 @@ void shortcut_init(void)
|
||||
add_to_sclist(MWHEREIS|MREPLACE, "^R", 0, flip_replace, 0);
|
||||
add_to_sclist(MWHEREIS|MGOTOLINE, "^T", 0, flip_goto, 0);
|
||||
#ifdef ENABLE_HISTORIES
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "^P", 0, get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "^N", 0, get_history_newer_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "^P", 0, get_older_item, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "^N", 0, get_newer_item, 0);
|
||||
#ifdef ENABLE_UTF8
|
||||
if (using_utf8()) {
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\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_older_item, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\xbe", KEY_DOWN, get_newer_item, 0);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "Up", KEY_UP, get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "Down", KEY_DOWN, get_history_newer_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "Up", KEY_UP, get_older_item, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "Down", KEY_DOWN, get_newer_item, 0);
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
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,20 +1442,21 @@ 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);
|
||||
#ifndef NANO_TINY
|
||||
add_to_sclist(MWRITEFILE, "M-D", 0, dos_format_void, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-M", 0, mac_format_void, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-D", 0, dos_format, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-M", 0, mac_format, 0);
|
||||
/* Only when not in restricted mode, allow Appending, Prepending,
|
||||
* making backups, and executing a command. */
|
||||
if (!ISSET(RESTRICTED) && !ISSET(VIEW_MODE)) {
|
||||
add_to_sclist(MWRITEFILE, "M-A", 0, append_void, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-P", 0, prepend_void, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-B", 0, backup_file_void, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-A", 0, append_it, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-P", 0, prepend_it, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-B", 0, back_it_up, 0);
|
||||
add_to_sclist(MINSERTFILE|MEXECUTE, "^X", 0, flip_execute, 0);
|
||||
}
|
||||
add_to_sclist(MINSERTFILE, "M-N", 0, flip_convert, 0);
|
||||
@@ -1504,11 +1492,11 @@ void shortcut_init(void)
|
||||
#endif
|
||||
add_to_sclist(MMOST & ~MFINDINHELP, "F1", KEY_F(1), do_help, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "F2", KEY_F(2), do_exit, 0);
|
||||
add_to_sclist(MMAIN, "F3", KEY_F(3), do_writeout_void, 0);
|
||||
add_to_sclist(MMAIN, "F3", KEY_F(3), do_writeout, 0);
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
add_to_sclist(MMAIN, "F4", KEY_F(4), do_justify_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, "F5", KEY_F(5), do_insertfile, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "F6", KEY_F(6), do_search_forward, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "F7", KEY_F(7), do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "F8", KEY_F(8), do_page_down, 0);
|
||||
@@ -1518,30 +1506,33 @@ void shortcut_init(void)
|
||||
#ifdef ENABLE_SPELLER
|
||||
add_to_sclist(MMAIN, "F12", KEY_F(12), do_spell, 0);
|
||||
#endif
|
||||
#if defined(KEY_CANCEL) && defined(KEY_SUSPEND) && defined(KEY_SIC)
|
||||
add_to_sclist((MMOST & ~MMAIN) | MYESNO, "", KEY_CANCEL, do_cancel, 0);
|
||||
add_to_sclist(MMAIN|MEXECUTE, "", KEY_SUSPEND, do_suspend_void, 0);
|
||||
add_to_sclist(MMAIN, "", KEY_SIC, do_insertfile_void, 0);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
add_to_sclist((MMOST & ~MMAIN) | MYESNO, "", KEY_CANCEL, do_cancel, 0);
|
||||
add_to_sclist(MMAIN, "", KEY_SIC, do_insertfile, 0);
|
||||
/* Catch and ignore bracketed paste marker keys. */
|
||||
add_to_sclist(MMOST|MBROWSER|MHELP|MYESNO, "", BRACKETED_PASTE_MARKER, do_nothing, 0);
|
||||
#else
|
||||
add_to_sclist(MMOST|MBROWSER|MHELP|MYESNO, "", KEY_FRESH, full_refresh, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Return the textual description that corresponds to the given flag. */
|
||||
const char *flagtostr(int flag)
|
||||
const char *epithet_of_flag(int flag)
|
||||
{
|
||||
switch (flag) {
|
||||
case NO_HELP:
|
||||
case ZERO:
|
||||
/* TRANSLATORS: The next thirteen strings are toggle descriptions;
|
||||
* they are best kept shorter than 40 characters, but may be longer. */
|
||||
return N_("Hidden interface");
|
||||
case NO_HELP:
|
||||
return N_("Help mode");
|
||||
case CONSTANT_SHOW:
|
||||
return N_("Constant cursor position display");
|
||||
case SOFTWRAP:
|
||||
return N_("Soft wrapping of overlong lines");
|
||||
case LINE_NUMBERS:
|
||||
return N_("Line numbering");
|
||||
case WHITESPACE_DISPLAY:
|
||||
return N_("Whitespace display");
|
||||
case NO_SYNTAX:
|
||||
@@ -1558,13 +1549,8 @@ const char *flagtostr(int flag)
|
||||
return N_("Conversion of typed tabs to spaces");
|
||||
case USE_MOUSE:
|
||||
return N_("Mouse support");
|
||||
case SUSPENDABLE:
|
||||
return N_("Suspension");
|
||||
case LINE_NUMBERS:
|
||||
return N_("Line numbering");
|
||||
default:
|
||||
die("Bad toggle -- please report a bug\n");
|
||||
return "";
|
||||
return "Ehm...";
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
37
src/help.c
37
src/help.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* help.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2000-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2000-2011, 2013-2022 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2017 Rishabh Dave *
|
||||
* Copyright (C) 2014-2019 Benno Schulenberg *
|
||||
* *
|
||||
@@ -234,8 +234,8 @@ void help_init(void)
|
||||
size_t onoff_len = strlen(_("enable/disable"));
|
||||
|
||||
for (s = sclist; s != NULL; s = s->next)
|
||||
if (s->func == do_toggle_void)
|
||||
allocsize += strlen(_(flagtostr(s->toggle))) + onoff_len + 9;
|
||||
if (s->func == do_toggle)
|
||||
allocsize += strlen(_(epithet_of_flag(s->toggle))) + onoff_len + 9;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -303,14 +303,15 @@ void help_init(void)
|
||||
for (s = sclist; s != NULL; s = s->next)
|
||||
if (s->toggle && s->ordinal == counter) {
|
||||
ptr += sprintf(ptr, "%s\t\t %s %s\n", (s->menus & MMAIN ? s->keystr : ""),
|
||||
_(flagtostr(s->toggle)), _("enable/disable"));
|
||||
if (s->toggle == NO_SYNTAX || s->toggle == TABS_TO_SPACES)
|
||||
_(epithet_of_flag(s->toggle)), _("enable/disable"));
|
||||
/* Add a blank like between two groups. */
|
||||
if (s->toggle == NO_SYNTAX)
|
||||
ptr += sprintf(ptr, "\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Hard-wrap the concatenated help text, and write it into a new buffer. */
|
||||
@@ -323,6 +324,13 @@ void wrap_help_text_into_buffer(void)
|
||||
|
||||
make_new_buffer();
|
||||
|
||||
/* Ensure there is a blank line at the top of the text, for esthetics. */
|
||||
if ((ISSET(MINIBAR) || !ISSET(EMPTY_LINE)) && LINES > 6) {
|
||||
openfile->current->data = mallocstrcpy(openfile->current->data, " ");
|
||||
openfile->current->next = make_new_node(openfile->current);
|
||||
openfile->current = openfile->current->next;
|
||||
}
|
||||
|
||||
/* Copy the help text into the just-created new buffer. */
|
||||
while (*ptr != '\0') {
|
||||
int length, shim;
|
||||
@@ -403,8 +411,9 @@ void show_help(void)
|
||||
memcpy(stash, flags, sizeof(flags));
|
||||
|
||||
/* Ensure that the help screen's shortcut list can be displayed. */
|
||||
if (ISSET(NO_HELP) && LINES > 4) {
|
||||
if (ISSET(NO_HELP) || ISSET(ZERO)) {
|
||||
UNSET(NO_HELP);
|
||||
UNSET(ZERO);
|
||||
window_init();
|
||||
} else
|
||||
blank_statusbar();
|
||||
@@ -415,10 +424,8 @@ void show_help(void)
|
||||
UNSET(USE_REGEXP);
|
||||
|
||||
UNSET(WHITESPACE_DISPLAY);
|
||||
UNSET(NOREAD_MODE);
|
||||
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
UNSET(LINE_NUMBERS);
|
||||
editwincols = COLS - thebar;
|
||||
margin = 0;
|
||||
#endif
|
||||
@@ -456,13 +463,12 @@ void show_help(void)
|
||||
focusing = TRUE;
|
||||
|
||||
/* Show the cursor when we searched and found something. */
|
||||
kbinput = get_kbinput(edit, didfind == 1 || ISSET(SHOW_CURSOR));
|
||||
kbinput = get_kbinput(midwin, didfind == 1 || ISSET(SHOW_CURSOR));
|
||||
|
||||
didfind = 0;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
spotlighted = FALSE;
|
||||
hide_cursor = FALSE;
|
||||
|
||||
if (bracketed_paste || kbinput == BRACKETED_PASTE_MARKER) {
|
||||
beep();
|
||||
@@ -543,13 +549,12 @@ void show_help(void)
|
||||
|
||||
curs_set(0);
|
||||
|
||||
if (ISSET(NO_HELP)) {
|
||||
currmenu = oldmenu;
|
||||
if (ISSET(NO_HELP) || ISSET(ZERO))
|
||||
window_init();
|
||||
} else {
|
||||
else
|
||||
blank_statusbar();
|
||||
bottombars(oldmenu);
|
||||
}
|
||||
|
||||
bottombars(oldmenu);
|
||||
|
||||
#ifdef ENABLE_BROWSER
|
||||
if (oldmenu & (MBROWSER|MWHEREISFILE|MGOTODIR))
|
||||
|
||||
228
src/history.c
228
src/history.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* history.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2003-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2003-2011, 2013-2022 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2016, 2017, 2019 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -63,21 +63,21 @@ void history_init(void)
|
||||
executebot = execute_history;
|
||||
}
|
||||
|
||||
/* Set the current position in the given history list to the bottom. */
|
||||
void history_reset(const linestruct *list)
|
||||
/* Reset the pointer into the history list that contains item to the bottom. */
|
||||
void reset_history_pointer_for(const linestruct *item)
|
||||
{
|
||||
if (list == search_history)
|
||||
if (item == search_history)
|
||||
search_history = searchbot;
|
||||
else if (list == replace_history)
|
||||
else if (item == replace_history)
|
||||
replace_history = replacebot;
|
||||
else if (list == execute_history)
|
||||
else if (item == execute_history)
|
||||
execute_history = executebot;
|
||||
}
|
||||
|
||||
/* Return from the history list that starts at start and ends at end
|
||||
* the first node that contains the first len characters of the given
|
||||
* text, or NULL if there is no such node. */
|
||||
linestruct *find_history(const linestruct *start, const linestruct *end,
|
||||
linestruct *find_in_history(const linestruct *start, const linestruct *end,
|
||||
const char *text, size_t len)
|
||||
{
|
||||
const linestruct *item;
|
||||
@@ -92,9 +92,10 @@ linestruct *find_history(const linestruct *start, const linestruct *end,
|
||||
|
||||
/* Update a history list (the one in which item is the current position)
|
||||
* with a fresh string text. That is: add text, or move it to the end. */
|
||||
void update_history(linestruct **item, const char *text)
|
||||
void update_history(linestruct **item, const char *text, bool avoid_duplicates)
|
||||
{
|
||||
linestruct **htop = NULL, **hbot = NULL, *thesame;
|
||||
linestruct **htop = NULL, **hbot = NULL;
|
||||
linestruct *thesame = NULL;
|
||||
|
||||
if (*item == search_history) {
|
||||
htop = &searchtop;
|
||||
@@ -107,11 +108,12 @@ void update_history(linestruct **item, const char *text)
|
||||
hbot = &executebot;
|
||||
}
|
||||
|
||||
/* See if the string is already in the history. */
|
||||
thesame = find_history(*hbot, *htop, text, HIGHEST_POSITIVE);
|
||||
/* When requested, check if the string is already in the history. */
|
||||
if (avoid_duplicates)
|
||||
thesame = find_in_history(*hbot, *htop, text, HIGHEST_POSITIVE);
|
||||
|
||||
/* If an identical string was found, delete that item. */
|
||||
if (thesame != NULL) {
|
||||
if (thesame) {
|
||||
linestruct *after = thesame->next;
|
||||
|
||||
/* If the string is at the head of the list, move the head. */
|
||||
@@ -145,98 +147,67 @@ void update_history(linestruct **item, const char *text)
|
||||
*item = *hbot;
|
||||
}
|
||||
|
||||
/* Move h to the string in the history list just before it, and return
|
||||
* that string. If there isn't one, don't move h and return NULL. */
|
||||
char *get_history_older(linestruct **h)
|
||||
{
|
||||
if ((*h)->prev == NULL)
|
||||
return NULL;
|
||||
|
||||
*h = (*h)->prev;
|
||||
|
||||
return (*h)->data;
|
||||
}
|
||||
|
||||
/* Move h to the string in the history list just after it, and return
|
||||
* that string. If there isn't one, don't move h and return NULL. */
|
||||
char *get_history_newer(linestruct **h)
|
||||
{
|
||||
if ((*h)->next == NULL)
|
||||
return NULL;
|
||||
|
||||
*h = (*h)->next;
|
||||
|
||||
return (*h)->data;
|
||||
}
|
||||
|
||||
/* Two empty placeholder functions. */
|
||||
void get_history_older_void(void)
|
||||
{
|
||||
}
|
||||
void get_history_newer_void(void)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef ENABLE_TABCOMP
|
||||
/* Go backward through one of three history lists, starting at its item h,
|
||||
* searching for a string that is a tab completion of the given string s,
|
||||
* looking at only the first len characters of s. When found, make h point
|
||||
* at it and return that string; otherwise, don't move h and return s. */
|
||||
char *get_history_completion(linestruct **h, char *s, size_t len)
|
||||
/* Go backward through one of three history lists, starting at item *here,
|
||||
* searching for a string that is a tab completion of the given string,
|
||||
* looking at only its first len characters. When found, make *here point
|
||||
* at the item and return its string; otherwise, just return the string. */
|
||||
char *get_history_completion(linestruct **here, char *string, size_t len)
|
||||
{
|
||||
linestruct *htop = NULL, *hbot = NULL, *p;
|
||||
linestruct *htop = NULL, *hbot = NULL;
|
||||
linestruct *item;
|
||||
|
||||
if (*h == search_history) {
|
||||
if (*here == search_history) {
|
||||
htop = searchtop;
|
||||
hbot = searchbot;
|
||||
} else if (*h == replace_history) {
|
||||
} else if (*here == replace_history) {
|
||||
htop = replacetop;
|
||||
hbot = replacebot;
|
||||
} else if (*h == execute_history) {
|
||||
} else if (*here == execute_history) {
|
||||
htop = executetop;
|
||||
hbot = executebot;
|
||||
}
|
||||
|
||||
/* First search from the current position to the top of the list
|
||||
* for a match of len characters. Skip over an exact match. */
|
||||
p = find_history((*h)->prev, htop, s, len);
|
||||
item = find_in_history((*here)->prev, htop, string, len);
|
||||
|
||||
while (p != NULL && strcmp(p->data, s) == 0)
|
||||
p = find_history(p->prev, htop, s, len);
|
||||
while (item != NULL && strcmp(item->data, string) == 0)
|
||||
item = find_in_history(item->prev, htop, string, len);
|
||||
|
||||
if (p != NULL) {
|
||||
*h = p;
|
||||
return mallocstrcpy(s, (*h)->data);
|
||||
if (item) {
|
||||
*here = item;
|
||||
return mallocstrcpy(string, item->data);
|
||||
}
|
||||
|
||||
/* Now search from the bottom of the list to the original position. */
|
||||
p = find_history(hbot, *h, s, len);
|
||||
item = find_in_history(hbot, *here, string, len);
|
||||
|
||||
while (p != NULL && strcmp(p->data, s) == 0)
|
||||
p = find_history(p->prev, *h, s, len);
|
||||
while (item != NULL && strcmp(item->data, string) == 0)
|
||||
item = find_in_history(item->prev, *here, string, len);
|
||||
|
||||
if (p != NULL) {
|
||||
*h = p;
|
||||
return mallocstrcpy(s, (*h)->data);
|
||||
if (item) {
|
||||
*here = item;
|
||||
return mallocstrcpy(string, item->data);
|
||||
}
|
||||
|
||||
/* When no useful match was found, simply return the given string. */
|
||||
return (char *)s;
|
||||
return (char *)string;
|
||||
}
|
||||
#endif /* ENABLE_TABCOMP */
|
||||
|
||||
/* Check whether we have or could make a directory for history files. */
|
||||
bool have_statedir(void)
|
||||
{
|
||||
struct stat dirstat;
|
||||
const char *xdgdatadir;
|
||||
struct stat dirinfo;
|
||||
|
||||
get_homedir();
|
||||
|
||||
if (homedir != NULL) {
|
||||
statedir = concatenate(homedir, "/.nano/");
|
||||
|
||||
if (stat(statedir, &dirstat) == 0 && S_ISDIR(dirstat.st_mode)) {
|
||||
if (stat(statedir, &dirinfo) == 0 && S_ISDIR(dirinfo.st_mode)) {
|
||||
poshistname = concatenate(statedir, POSITION_HISTORY);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -253,7 +224,7 @@ bool have_statedir(void)
|
||||
else
|
||||
statedir = concatenate(homedir, "/.local/share/nano/");
|
||||
|
||||
if (stat(statedir, &dirstat) == -1) {
|
||||
if (stat(statedir, &dirinfo) == -1) {
|
||||
if (xdgdatadir == NULL) {
|
||||
char *statepath = concatenate(homedir, "/.local");
|
||||
mkdir(statepath, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
@@ -269,7 +240,7 @@ bool have_statedir(void)
|
||||
statedir, strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
} else if (!S_ISDIR(dirstat.st_mode)) {
|
||||
} else if (!S_ISDIR(dirinfo.st_mode)) {
|
||||
jot_error(N_("Path %s is not a directory and needs to be.\n"
|
||||
"Nano will be unable to load or save "
|
||||
"search history or cursor positions.\n"),
|
||||
@@ -309,7 +280,7 @@ void load_history(void)
|
||||
stanza[--read] = '\0';
|
||||
if (read > 0) {
|
||||
recode_NUL_to_LF(stanza, read);
|
||||
update_history(history, stanza);
|
||||
update_history(history, stanza, IGNORE_DUPLICATES);
|
||||
} else if (history == &search_history)
|
||||
history = &replace_history;
|
||||
else
|
||||
@@ -367,7 +338,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))
|
||||
@@ -393,12 +365,14 @@ void load_poshistory(void)
|
||||
if (histfile == NULL)
|
||||
return;
|
||||
|
||||
ssize_t read, count = 0;
|
||||
struct stat fileinfo;
|
||||
poshiststruct *record_ptr = NULL, *newrecord;
|
||||
poshiststruct *lastitem = NULL;
|
||||
poshiststruct *newitem;
|
||||
char *lineptr, *columnptr;
|
||||
char *stanza = NULL;
|
||||
struct stat fileinfo;
|
||||
size_t dummy = 0;
|
||||
ssize_t count = 0;
|
||||
ssize_t read;
|
||||
|
||||
/* Read and parse each line, and store the extracted data. */
|
||||
while ((read = getline(&stanza, &dummy, histfile)) > 5) {
|
||||
@@ -418,19 +392,19 @@ void load_poshistory(void)
|
||||
*(lineptr++) = '\0';
|
||||
|
||||
/* Create a new position record. */
|
||||
newrecord = nmalloc(sizeof(poshiststruct));
|
||||
newrecord->filename = copy_of(stanza);
|
||||
newrecord->linenumber = atoi(lineptr);
|
||||
newrecord->columnnumber = atoi(columnptr);
|
||||
newrecord->next = NULL;
|
||||
newitem = nmalloc(sizeof(poshiststruct));
|
||||
newitem->filename = copy_of(stanza);
|
||||
newitem->linenumber = atoi(lineptr);
|
||||
newitem->columnnumber = atoi(columnptr);
|
||||
newitem->next = NULL;
|
||||
|
||||
/* Add the record to the list. */
|
||||
if (position_history == NULL)
|
||||
position_history = newrecord;
|
||||
position_history = newitem;
|
||||
else
|
||||
record_ptr->next = newrecord;
|
||||
lastitem->next = newitem;
|
||||
|
||||
record_ptr = newrecord;
|
||||
lastitem = newitem;
|
||||
|
||||
/* Impose a limit, so the file will not grow indefinitely. */
|
||||
if (++count > 200) {
|
||||
@@ -455,9 +429,9 @@ void load_poshistory(void)
|
||||
/* Save the recorded cursor positions for files that were edited. */
|
||||
void save_poshistory(void)
|
||||
{
|
||||
poshiststruct *posptr;
|
||||
struct stat fileinfo;
|
||||
FILE *histfile = fopen(poshistname, "wb");
|
||||
struct stat fileinfo;
|
||||
poshiststruct *item;
|
||||
|
||||
if (histfile == NULL) {
|
||||
jot_error(N_("Error writing %s: %s"), poshistname, strerror(errno));
|
||||
@@ -465,17 +439,18 @@ 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) {
|
||||
for (item = position_history; item != NULL; item = item->next) {
|
||||
char *path_and_place;
|
||||
size_t length;
|
||||
|
||||
/* Assume 20 decimal positions each for line and column number,
|
||||
* plus two spaces, plus the line feed, plus the null byte. */
|
||||
path_and_place = nmalloc(strlen(posptr->filename) + 44);
|
||||
path_and_place = nmalloc(strlen(item->filename) + 44);
|
||||
sprintf(path_and_place, "%s %zd %zd\n",
|
||||
posptr->filename, posptr->linenumber, posptr->columnnumber);
|
||||
item->filename, item->linenumber, item->columnnumber);
|
||||
length = strlen(path_and_place);
|
||||
|
||||
/* Encode newlines in filenames as NULs. */
|
||||
@@ -499,29 +474,30 @@ void save_poshistory(void)
|
||||
/* Reload the position history file if it has been modified since last load. */
|
||||
void reload_positions_if_needed(void)
|
||||
{
|
||||
poshiststruct *item, *nextone;
|
||||
struct stat fileinfo;
|
||||
|
||||
if (stat(poshistname, &fileinfo) == 0 && fileinfo.st_mtime != latest_timestamp) {
|
||||
poshiststruct *item, *nextone;
|
||||
if (stat(poshistname, &fileinfo) != 0 || fileinfo.st_mtime == latest_timestamp)
|
||||
return;
|
||||
|
||||
for (item = position_history; item != NULL; item = nextone) {
|
||||
nextone = item->next;
|
||||
free(item->filename);
|
||||
free(item);
|
||||
}
|
||||
|
||||
position_history = NULL;
|
||||
|
||||
load_poshistory();
|
||||
for (item = position_history; item != NULL; item = nextone) {
|
||||
nextone = item->next;
|
||||
free(item->filename);
|
||||
free(item);
|
||||
}
|
||||
|
||||
position_history = NULL;
|
||||
|
||||
load_poshistory();
|
||||
}
|
||||
|
||||
/* Update the recorded last file positions with the current position in the
|
||||
* current buffer. If no existing entry is found, add a new one at the end. */
|
||||
void update_poshistory(void)
|
||||
{
|
||||
poshiststruct *posptr, *theone, *posprev = NULL;
|
||||
char *fullpath = get_full_path(openfile->filename);
|
||||
poshiststruct *previous = NULL;
|
||||
poshiststruct *item, *theone;
|
||||
|
||||
if (fullpath == NULL || openfile->filename[0] == '\0') {
|
||||
free(fullpath);
|
||||
@@ -531,28 +507,28 @@ void update_poshistory(void)
|
||||
reload_positions_if_needed();
|
||||
|
||||
/* Look for a matching filename in the list. */
|
||||
for (posptr = position_history; posptr != NULL; posptr = posptr->next) {
|
||||
if (!strcmp(posptr->filename, fullpath))
|
||||
for (item = position_history; item != NULL; item = item->next) {
|
||||
if (!strcmp(item->filename, fullpath))
|
||||
break;
|
||||
posprev = posptr;
|
||||
previous = item;
|
||||
}
|
||||
|
||||
/* Don't record files that have the default cursor position. */
|
||||
if (openfile->current->lineno == 1 && openfile->current_x == 0) {
|
||||
if (posptr != NULL) {
|
||||
if (posprev == NULL)
|
||||
position_history = posptr->next;
|
||||
if (item != NULL) {
|
||||
if (previous == NULL)
|
||||
position_history = item->next;
|
||||
else
|
||||
posprev->next = posptr->next;
|
||||
free(posptr->filename);
|
||||
free(posptr);
|
||||
previous->next = item->next;
|
||||
free(item->filename);
|
||||
free(item);
|
||||
save_poshistory();
|
||||
}
|
||||
free(fullpath);
|
||||
return;
|
||||
}
|
||||
|
||||
theone = posptr;
|
||||
theone = item;
|
||||
|
||||
/* If we didn't find it, make a new node; otherwise, if we're
|
||||
* not at the end, move the matching one to the end. */
|
||||
@@ -562,15 +538,15 @@ void update_poshistory(void)
|
||||
if (position_history == NULL)
|
||||
position_history = theone;
|
||||
else
|
||||
posprev->next = theone;
|
||||
} else if (posptr->next != NULL) {
|
||||
if (posprev == NULL)
|
||||
position_history = posptr->next;
|
||||
previous->next = theone;
|
||||
} else if (item->next != NULL) {
|
||||
if (previous == NULL)
|
||||
position_history = item->next;
|
||||
else
|
||||
posprev->next = posptr->next;
|
||||
while (posptr->next != NULL)
|
||||
posptr = posptr->next;
|
||||
posptr->next = theone;
|
||||
previous->next = item->next;
|
||||
while (item->next != NULL)
|
||||
item = item->next;
|
||||
item->next = theone;
|
||||
}
|
||||
|
||||
/* Store the last cursor position. */
|
||||
@@ -588,25 +564,25 @@ void update_poshistory(void)
|
||||
* set line and column to the retrieved values. */
|
||||
bool has_old_position(const char *file, ssize_t *line, ssize_t *column)
|
||||
{
|
||||
poshiststruct *posptr;
|
||||
char *fullpath = get_full_path(file);
|
||||
poshiststruct *item;
|
||||
|
||||
if (fullpath == NULL)
|
||||
return FALSE;
|
||||
|
||||
reload_positions_if_needed();
|
||||
|
||||
posptr = position_history;
|
||||
while (posptr != NULL && strcmp(posptr->filename, fullpath) != 0)
|
||||
posptr = posptr->next;
|
||||
item = position_history;
|
||||
while (item != NULL && strcmp(item->filename, fullpath) != 0)
|
||||
item = item->next;
|
||||
|
||||
free(fullpath);
|
||||
|
||||
if (posptr == NULL)
|
||||
if (item == NULL)
|
||||
return FALSE;
|
||||
|
||||
*line = posptr->linenumber;
|
||||
*column = posptr->columnnumber;
|
||||
*line = item->linenumber;
|
||||
*column = item->columnnumber;
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* ENABLE_HISTORIES */
|
||||
|
||||
41
src/move.c
41
src/move.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* move.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2018 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -44,6 +44,9 @@ void to_last_line(void)
|
||||
openfile->current_y = editwinrows - 1;
|
||||
|
||||
refresh_needed = TRUE;
|
||||
#ifdef ENABLE_COLOR
|
||||
recook |= perturbed;
|
||||
#endif
|
||||
focusing = FALSE;
|
||||
}
|
||||
|
||||
@@ -222,6 +225,9 @@ void to_para_end(void)
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
|
||||
edit_redraw(was_current, CENTERING);
|
||||
#ifdef ENABLE_COLOR
|
||||
recook |= perturbed;
|
||||
#endif
|
||||
}
|
||||
#endif /* ENABLE_JUSTIFY */
|
||||
|
||||
@@ -263,12 +269,15 @@ void to_next_block(void)
|
||||
|
||||
openfile->current_x = 0;
|
||||
edit_redraw(was_current, CENTERING);
|
||||
#ifdef ENABLE_COLOR
|
||||
recook |= perturbed;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Move to the previous word. If allow_punct is TRUE, treat punctuation
|
||||
* as part of a word. */
|
||||
void do_prev_word(bool allow_punct)
|
||||
/* Move to the previous word. */
|
||||
void do_prev_word(void)
|
||||
{
|
||||
bool punctuation_as_letters = ISSET(WORD_BOUNDS);
|
||||
bool seen_a_word = FALSE, step_forward = FALSE;
|
||||
|
||||
/* Move backward until we pass over the start of a word. */
|
||||
@@ -286,7 +295,7 @@ void do_prev_word(bool allow_punct)
|
||||
openfile->current_x);
|
||||
|
||||
if (is_word_char(openfile->current->data + openfile->current_x,
|
||||
allow_punct)) {
|
||||
punctuation_as_letters)) {
|
||||
seen_a_word = TRUE;
|
||||
/* If at the head of a line now, this surely is a word start. */
|
||||
if (openfile->current_x == 0)
|
||||
@@ -309,12 +318,12 @@ void do_prev_word(bool allow_punct)
|
||||
}
|
||||
|
||||
/* Move to the next word. If after_ends is TRUE, stop at the ends of words
|
||||
* instead of their beginnings. If allow_punct is TRUE, treat punctuation as
|
||||
* part of a word. Return TRUE if we started on a word, and FALSE otherwise. */
|
||||
bool do_next_word(bool after_ends, bool allow_punct)
|
||||
* instead of at their beginnings. Return TRUE if we started on a word. */
|
||||
bool do_next_word(bool after_ends)
|
||||
{
|
||||
bool punctuation_as_letters = ISSET(WORD_BOUNDS);
|
||||
bool started_on_word = is_word_char(openfile->current->data +
|
||||
openfile->current_x, allow_punct);
|
||||
openfile->current_x, punctuation_as_letters);
|
||||
bool seen_space = !started_on_word;
|
||||
#ifndef NANO_TINY
|
||||
bool seen_word = started_on_word;
|
||||
@@ -341,7 +350,7 @@ bool do_next_word(bool after_ends, bool allow_punct)
|
||||
/* If this is a word character, continue; else it's a separator,
|
||||
* and if we've already seen a word, then it's a word end. */
|
||||
if (is_word_char(openfile->current->data + openfile->current_x,
|
||||
allow_punct))
|
||||
punctuation_as_letters))
|
||||
seen_word = TRUE;
|
||||
#ifdef ENABLE_UTF8
|
||||
else if (is_zerowidth(openfile->current->data + openfile->current_x))
|
||||
@@ -360,7 +369,7 @@ bool do_next_word(bool after_ends, bool allow_punct)
|
||||
/* If this is not a word character, then it's a separator; else
|
||||
* if we've already seen a separator, then it's a word start. */
|
||||
if (!is_word_char(openfile->current->data + openfile->current_x,
|
||||
allow_punct))
|
||||
punctuation_as_letters))
|
||||
seen_space = TRUE;
|
||||
else if (seen_space)
|
||||
break;
|
||||
@@ -370,25 +379,23 @@ bool do_next_word(bool after_ends, bool allow_punct)
|
||||
return started_on_word;
|
||||
}
|
||||
|
||||
/* Move to the previous word in the file, treating punctuation as part of a
|
||||
* word if the WORD_BOUNDS flag is set, and update the screen afterwards. */
|
||||
/* Move to the previous word in the file, and update the screen afterwards. */
|
||||
void to_prev_word(void)
|
||||
{
|
||||
linestruct *was_current = openfile->current;
|
||||
|
||||
do_prev_word(ISSET(WORD_BOUNDS));
|
||||
do_prev_word();
|
||||
|
||||
edit_redraw(was_current, FLOWING);
|
||||
}
|
||||
|
||||
/* Move to the next word in the file. If the AFTER_ENDS flag is set, stop
|
||||
* at word ends instead of beginnings. If the WORD_BOUNDS flag is set, treat
|
||||
* punctuation as part of a word. Update the screen afterwards. */
|
||||
* at word ends instead of beginnings. Update the screen afterwards. */
|
||||
void to_next_word(void)
|
||||
{
|
||||
linestruct *was_current = openfile->current;
|
||||
|
||||
do_next_word(ISSET(AFTER_ENDS), ISSET(WORD_BOUNDS));
|
||||
do_next_word(ISSET(AFTER_ENDS));
|
||||
|
||||
edit_redraw(was_current, FLOWING);
|
||||
}
|
||||
|
||||
440
src/nano.c
440
src/nano.c
@@ -1,8 +1,8 @@
|
||||
/**************************************************************************
|
||||
* 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) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2021 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published *
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#if defined(__linux__) || !defined(NANO_TINY)
|
||||
#ifdef __linux__
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
#ifdef ENABLE_UTF8
|
||||
@@ -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;
|
||||
@@ -211,6 +212,18 @@ bool in_restricted_mode(void)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Say how the user can achieve suspension (when they typed ^Z). */
|
||||
void suggest_ctrlT_ctrlZ(void)
|
||||
{
|
||||
#ifdef ENABLE_NANORC
|
||||
if (first_sc_for(MMAIN, do_execute) && first_sc_for(MMAIN, do_execute)->keycode == 0x14 &&
|
||||
first_sc_for(MEXECUTE, do_suspend) && first_sc_for(MEXECUTE, do_suspend)->keycode == 0x1A)
|
||||
#endif
|
||||
statusline(AHEM, _("To suspend, type ^T^Z"));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make sure the cursor is visible, then exit from curses mode, disable
|
||||
* bracketed-paste mode, and restore the original terminal settings. */
|
||||
void restore_terminal(void)
|
||||
@@ -230,14 +243,14 @@ void finish(void)
|
||||
/* Blank the status bar and (if applicable) the shortcut list. */
|
||||
blank_statusbar();
|
||||
blank_bottombars();
|
||||
wrefresh(bottomwin);
|
||||
wrefresh(footwin);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Deallocate the two or three subwindows. */
|
||||
if (topwin != NULL)
|
||||
delwin(topwin);
|
||||
delwin(edit);
|
||||
delwin(bottomwin);
|
||||
delwin(midwin);
|
||||
delwin(footwin);
|
||||
#endif
|
||||
/* Switch the cursor on, exit from curses, and restore terminal settings. */
|
||||
restore_terminal();
|
||||
@@ -291,57 +304,54 @@ void do_exit(void)
|
||||
/* When unmodified, simply close. Else, when doing automatic saving
|
||||
* and the file has a name, simply save. Otherwise, ask the user. */
|
||||
if (!openfile->modified)
|
||||
choice = 0;
|
||||
choice = NO;
|
||||
else if (ISSET(SAVE_ON_EXIT) && openfile->filename[0] != '\0')
|
||||
choice = 1;
|
||||
choice = YES;
|
||||
else {
|
||||
if (ISSET(SAVE_ON_EXIT))
|
||||
warn_and_briefly_pause(_("No file name"));
|
||||
|
||||
choice = do_yesno_prompt(FALSE, _("Save modified buffer? "));
|
||||
choice = ask_user(YESORNO, _("Save modified buffer? "));
|
||||
}
|
||||
|
||||
/* When not saving, or the save succeeds, close the buffer. */
|
||||
if (choice == 0 || (choice == 1 && do_writeout(TRUE, TRUE) > 0))
|
||||
if (choice == NO || (choice == YES && write_it_out(TRUE, TRUE) > 0))
|
||||
close_and_go();
|
||||
else if (choice != 1)
|
||||
else if (choice != YES)
|
||||
statusbar(_("Cancelled"));
|
||||
}
|
||||
|
||||
/* 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));
|
||||
}
|
||||
#if !defined(NANO_TINY) && defined(HAVE_CHMOD) && defined(HAVE_CHOWN)
|
||||
/* Try to chmod/chown the saved file to the values of the original file,
|
||||
* but ignore any failure as we are in a hurry to get out. */
|
||||
if (openfile->statinfo) {
|
||||
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 +360,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 +379,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
|
||||
@@ -388,46 +403,46 @@ void die(const char *msg, ...)
|
||||
void window_init(void)
|
||||
{
|
||||
/* When resizing, first delete the existing windows. */
|
||||
if (edit != NULL) {
|
||||
if (midwin != NULL) {
|
||||
if (topwin != NULL)
|
||||
delwin(topwin);
|
||||
delwin(edit);
|
||||
delwin(bottomwin);
|
||||
delwin(midwin);
|
||||
delwin(footwin);
|
||||
}
|
||||
|
||||
topwin = NULL;
|
||||
|
||||
/* If the terminal is very flat, don't set up a title bar. */
|
||||
if (LINES < 3) {
|
||||
editwinrows = 1;
|
||||
editwinrows = (ISSET(ZERO) ? LINES : 1);
|
||||
/* Set up two subwindows. If the terminal is just one line,
|
||||
* edit window and status-bar window will cover each other. */
|
||||
edit = newwin(1, COLS, 0, 0);
|
||||
bottomwin = newwin(1, COLS, LINES - 1, 0);
|
||||
midwin = newwin(editwinrows, COLS, 0, 0);
|
||||
footwin = newwin(1, COLS, LINES - 1, 0);
|
||||
} else {
|
||||
int toprows = ((ISSET(EMPTY_LINE) && LINES > 5) ? 2 : 1);
|
||||
int bottomrows = ((ISSET(NO_HELP) || LINES < 5) ? 1 : 3);
|
||||
int toprows = ((ISSET(EMPTY_LINE) && LINES > 6) ? 2 : 1);
|
||||
int bottomrows = ((ISSET(NO_HELP) || LINES < 6) ? 1 : 3);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(MINIBAR))
|
||||
if (ISSET(MINIBAR) || ISSET(ZERO))
|
||||
toprows = 0;
|
||||
#endif
|
||||
editwinrows = LINES - toprows - bottomrows;
|
||||
editwinrows = LINES - toprows - bottomrows + (ISSET(ZERO) ? 1 : 0);
|
||||
|
||||
/* Set up the normal three subwindows. */
|
||||
if (toprows > 0)
|
||||
topwin = newwin(toprows, COLS, 0, 0);
|
||||
edit = newwin(editwinrows, COLS, toprows, 0);
|
||||
bottomwin = newwin(bottomrows, COLS, toprows + editwinrows, 0);
|
||||
midwin = newwin(editwinrows, COLS, toprows, 0);
|
||||
footwin = newwin(bottomrows, COLS, LINES - bottomrows, 0);
|
||||
}
|
||||
|
||||
/* In case the terminal shrunk, make sure the status line is clear. */
|
||||
wipe_statusbar();
|
||||
wnoutrefresh(footwin);
|
||||
|
||||
/* When not disabled, turn escape-sequence translation on. */
|
||||
if (!ISSET(RAW_SEQUENCES)) {
|
||||
keypad(edit, TRUE);
|
||||
keypad(bottomwin, TRUE);
|
||||
keypad(midwin, TRUE);
|
||||
keypad(footwin, TRUE);
|
||||
}
|
||||
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
@@ -517,7 +532,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 +560,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>"),
|
||||
@@ -636,12 +651,9 @@ void usage(void)
|
||||
print_opt("-x", "--nohelp", N_("Don't show the two help lines"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-y", "--afterends", N_("Make Ctrl+Right stop at word ends"));
|
||||
#endif
|
||||
if (!ISSET(RESTRICTED))
|
||||
print_opt("-z", "--suspendable", N_("Enable suspension"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-%", "--stateflags", N_("Show some states on the title bar"));
|
||||
print_opt("-_", "--minibar", N_("Show a feedback bar at the bottom"));
|
||||
print_opt("-0", "--zero", N_("Hide all bars, use whole terminal"));
|
||||
#endif
|
||||
#ifdef HAVE_LIBMAGIC
|
||||
print_opt("-!", "--magic", N_("Also try magic to determine syntax"));
|
||||
@@ -658,8 +670,8 @@ void version(void)
|
||||
printf(_(" GNU nano, version %s\n"), VERSION);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
printf(" (C) 1999-2011, 2013-2021 Free Software Foundation, Inc.\n");
|
||||
printf(_(" (C) 2014-%s the contributors to nano\n"), "2021");
|
||||
printf(" (C) 1999-2011, 2013-2022 Free Software Foundation, Inc.\n");
|
||||
printf(_(" (C) 2014-%s the contributors to nano\n"), "2022");
|
||||
#endif
|
||||
printf(_(" Compiled options:"));
|
||||
|
||||
@@ -882,20 +894,21 @@ void signal_init(void)
|
||||
sigaction(SIGTERM, &deed, NULL);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
#ifdef SIGWINCH
|
||||
/* Trap SIGWINCH because we want to handle window resizes. */
|
||||
deed.sa_handler = handle_sigwinch;
|
||||
sigaction(SIGWINCH, &deed, NULL);
|
||||
#endif
|
||||
|
||||
/* In the suspend and continue handlers, block all other signals.
|
||||
* If we don't do this, other stuff interrupts them! */
|
||||
sigfillset(&deed.sa_mask);
|
||||
#ifdef SIGTSTP
|
||||
deed.sa_handler = do_suspend;
|
||||
/* Prevent the suspend handler from getting interrupted. */
|
||||
sigfillset(&deed.sa_mask);
|
||||
deed.sa_handler = suspend_nano;
|
||||
sigaction(SIGTSTP, &deed, NULL);
|
||||
#endif
|
||||
#endif /* !NANO_TINY */
|
||||
#ifdef SIGCONT
|
||||
deed.sa_handler = do_continue;
|
||||
sigfillset(&deed.sa_mask);
|
||||
deed.sa_handler = continue_nano;
|
||||
sigaction(SIGCONT, &deed, NULL);
|
||||
#endif
|
||||
|
||||
@@ -926,8 +939,9 @@ void handle_crash(int signal)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Handler for SIGTSTP (suspend). */
|
||||
void do_suspend(int signal)
|
||||
void suspend_nano(int signal)
|
||||
{
|
||||
#ifdef ENABLE_MOUSE
|
||||
disable_mouse_support();
|
||||
@@ -949,20 +963,20 @@ void do_suspend(int signal)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Put nano to sleep (if suspension is enabled). */
|
||||
void do_suspend_void(void)
|
||||
/* When permitted, put nano to sleep. */
|
||||
void do_suspend(void)
|
||||
{
|
||||
if (!ISSET(SUSPENDABLE)) {
|
||||
statusline(AHEM, _("Suspension is not enabled"));
|
||||
beep();
|
||||
} else
|
||||
do_suspend(0);
|
||||
if (in_restricted_mode())
|
||||
return;
|
||||
|
||||
suspend_nano(0);
|
||||
|
||||
ran_a_tool = TRUE;
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Handler for SIGCONT (continue after suspend). */
|
||||
void do_continue(int signal)
|
||||
void continue_nano(int signal)
|
||||
{
|
||||
#ifdef ENABLE_MOUSE
|
||||
if (ISSET(USE_MOUSE))
|
||||
@@ -978,18 +992,20 @@ void do_continue(int signal)
|
||||
#endif
|
||||
|
||||
/* Insert a fake keystroke, to neutralize a key-eating issue. */
|
||||
ungetch(KEY_FLUSH);
|
||||
ungetch(KEY_FRESH);
|
||||
}
|
||||
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_SPELLER) || defined(ENABLE_COLOR)
|
||||
/* Block or unblock the SIGWINCH signal, depending on the blockit parameter. */
|
||||
void block_sigwinch(bool blockit)
|
||||
{
|
||||
#ifdef SIGWINCH
|
||||
sigset_t winch;
|
||||
|
||||
sigemptyset(&winch);
|
||||
sigaddset(&winch, SIGWINCH);
|
||||
sigprocmask(blockit ? SIG_BLOCK : SIG_UNBLOCK, &winch, NULL);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (the_window_resized)
|
||||
@@ -1006,49 +1022,22 @@ 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)
|
||||
{
|
||||
const char *tty = ttyname(0);
|
||||
int fd, result = 0;
|
||||
struct winsize win;
|
||||
|
||||
/* Reset the trigger. */
|
||||
the_window_resized = FALSE;
|
||||
|
||||
if (tty == NULL)
|
||||
return;
|
||||
fd = open(tty, O_RDWR);
|
||||
if (fd == -1)
|
||||
return;
|
||||
result = ioctl(fd, TIOCGWINSZ, &win);
|
||||
close(fd);
|
||||
if (result == -1)
|
||||
return;
|
||||
/* Leave and immediately reenter curses mode, so that ncurses notices
|
||||
* the new screen dimensions and sets LINES and COLS accordingly. */
|
||||
endwin();
|
||||
refresh();
|
||||
|
||||
/* We could check whether COLS or LINES changed, and return otherwise,
|
||||
* but it seems curses does not always update these global variables. */
|
||||
#ifdef REDEFINING_MACROS_OK
|
||||
COLS = win.ws_col;
|
||||
LINES = win.ws_row;
|
||||
#endif
|
||||
thebar = (ISSET(INDICATOR) && LINES > 5 && COLS > 9) ? 1 : 0;
|
||||
bardata = nrealloc(bardata, LINES * sizeof(int));
|
||||
|
||||
editwincols = COLS - margin - thebar;
|
||||
|
||||
/* Do as the website suggests: leave and immediately reenter curses mode. */
|
||||
endwin();
|
||||
doupdate();
|
||||
|
||||
/* Put the terminal in the desired state again, and
|
||||
* recreate the subwindows with their (new) sizes. */
|
||||
terminal_init();
|
||||
@@ -1056,35 +1045,42 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle the global toggle specified in flag. */
|
||||
void do_toggle(int flag)
|
||||
/* Invert the given global flag and adjust things for its new value. */
|
||||
void toggle_this(int flag)
|
||||
{
|
||||
if (flag == SUSPENDABLE && in_restricted_mode())
|
||||
return;
|
||||
bool enabled = !ISSET(flag);
|
||||
|
||||
TOGGLE(flag);
|
||||
focusing = FALSE;
|
||||
|
||||
switch (flag) {
|
||||
case ZERO:
|
||||
window_init();
|
||||
draw_all_subwindows();
|
||||
return;
|
||||
case NO_HELP:
|
||||
if (LINES < 6) {
|
||||
statusline(AHEM, _("Too tiny"));
|
||||
TOGGLE(flag);
|
||||
return;
|
||||
}
|
||||
window_init();
|
||||
draw_all_subwindows();
|
||||
break;
|
||||
#ifdef ENABLE_MOUSE
|
||||
case USE_MOUSE:
|
||||
mouse_init();
|
||||
break;
|
||||
#endif
|
||||
case CONSTANT_SHOW:
|
||||
if (ISSET(ZERO) || LINES == 1) {
|
||||
statusline(AHEM, _("Not possible"));
|
||||
TOGGLE(flag);
|
||||
} else if (!ISSET(MINIBAR))
|
||||
wipe_statusbar();
|
||||
return;
|
||||
case SOFTWRAP:
|
||||
if (ISSET(SOFTWRAP))
|
||||
compute_the_extra_rows_per_line_from(openfile->filetop);
|
||||
else
|
||||
if (!ISSET(SOFTWRAP))
|
||||
openfile->firstcolumn = 0;
|
||||
refresh_needed = TRUE;
|
||||
break;
|
||||
@@ -1097,30 +1093,37 @@ void do_toggle(int flag)
|
||||
precalc_multicolorinfo();
|
||||
refresh_needed = TRUE;
|
||||
break;
|
||||
case TABS_TO_SPACES:
|
||||
if (openfile->syntax && openfile->syntax->tab) {
|
||||
statusline(AHEM, _("Current syntax determines Tab"));
|
||||
TOGGLE(flag);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#ifdef ENABLE_MOUSE
|
||||
case USE_MOUSE:
|
||||
mouse_init();
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!ISSET(MINIBAR) && ISSET(STATEFLAGS))
|
||||
if (flag == AUTOINDENT || flag == BREAK_LONG_LINES || flag == SOFTWRAP)
|
||||
if (flag == AUTOINDENT || flag == BREAK_LONG_LINES || flag == SOFTWRAP) {
|
||||
if (ISSET(MINIBAR) && !ISSET(ZERO) && ISSET(STATEFLAGS))
|
||||
return;
|
||||
if (ISSET(STATEFLAGS))
|
||||
titlebar(NULL);
|
||||
|
||||
if (ISSET(MINIBAR) && (flag == NO_HELP || flag == LINE_NUMBERS ))
|
||||
return;
|
||||
|
||||
if (flag == CONSTANT_SHOW)
|
||||
wipe_statusbar();
|
||||
else if (!ISSET(MINIBAR) || !ISSET(STATEFLAGS) || flag == SMART_HOME ||
|
||||
flag == NO_SYNTAX || flag == WHITESPACE_DISPLAY ||
|
||||
flag == CUT_FROM_CURSOR || flag == TABS_TO_SPACES ||
|
||||
flag == USE_MOUSE || flag == SUSPENDABLE) {
|
||||
bool enabled = ISSET(flag);
|
||||
|
||||
if (flag == NO_HELP || flag == NO_SYNTAX)
|
||||
enabled = !enabled;
|
||||
|
||||
statusline(REMARK, "%s %s", _(flagtostr(flag)),
|
||||
enabled ? _("enabled") : _("disabled"));
|
||||
}
|
||||
|
||||
if (flag == NO_HELP || flag == LINE_NUMBERS || flag == WHITESPACE_DISPLAY)
|
||||
if (ISSET(MINIBAR) || ISSET(ZERO) || LINES == 1)
|
||||
return;
|
||||
|
||||
if (flag == NO_HELP || flag == NO_SYNTAX)
|
||||
enabled = !enabled;
|
||||
|
||||
statusline(REMARK, "%s %s", _(epithet_of_flag(flag)),
|
||||
enabled ? _("enabled") : _("disabled"));
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
@@ -1246,12 +1249,11 @@ void confirm_margin(void)
|
||||
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
|
||||
focusing = keep_focus;
|
||||
|
||||
/* The margin has changed -- schedule a full refresh. */
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
@@ -1265,6 +1267,11 @@ void unbound_key(int code)
|
||||
/* TRANSLATORS: This refers to a sequence of escape codes
|
||||
* (from the keyboard) that nano does not recognize. */
|
||||
statusline(AHEM, _("Unknown sequence"));
|
||||
#ifndef NANO_TINY
|
||||
else if (code > KEY_F0 && code < KEY_F0 + 25)
|
||||
/* TRANSLATORS: This refers to an unbound function key. */
|
||||
statusline(AHEM, _("Unbound key: F%i"), code - KEY_F0);
|
||||
#endif
|
||||
else if (code > 0x7F)
|
||||
statusline(AHEM, _("Unbound key"));
|
||||
else if (meta_key) {
|
||||
@@ -1302,7 +1309,7 @@ int do_mouse(void)
|
||||
return retval;
|
||||
|
||||
/* If the click was in the edit window, put the cursor in that spot. */
|
||||
if (wmouse_trafo(edit, &click_row, &click_col, FALSE)) {
|
||||
if (wmouse_trafo(midwin, &click_row, &click_col, FALSE)) {
|
||||
linestruct *current_save = openfile->current;
|
||||
ssize_t row_count = click_row - openfile->current_y;
|
||||
size_t leftedge;
|
||||
@@ -1385,7 +1392,7 @@ void suck_up_input_and_paste_it(void)
|
||||
cutbuffer = line;
|
||||
|
||||
while (bracketed_paste) {
|
||||
int input = get_kbinput(edit, BLIND);
|
||||
int input = get_kbinput(midwin, BLIND);
|
||||
|
||||
if (input == '\r' || input == '\n') {
|
||||
line->next = make_new_node(line);
|
||||
@@ -1414,12 +1421,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
|
||||
|
||||
@@ -1474,23 +1482,19 @@ void inject(char *burst, size_t count)
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WRAPPING
|
||||
/* Wrap the line when needed, and if so, schedule a refresh. */
|
||||
if (ISSET(BREAK_LONG_LINES) && do_wrap())
|
||||
refresh_needed = TRUE;
|
||||
if (ISSET(BREAK_LONG_LINES))
|
||||
do_wrap();
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* 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
|
||||
|
||||
@@ -1520,10 +1524,9 @@ void process_a_keystroke(void)
|
||||
const keystruct *shortcut;
|
||||
|
||||
/* Read in a keystroke, and show the cursor while waiting. */
|
||||
input = get_kbinput(edit, VISIBLE);
|
||||
input = get_kbinput(midwin, VISIBLE);
|
||||
|
||||
lastmessage = VACUUM;
|
||||
hide_cursor = FALSE;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (input == KEY_WINCH)
|
||||
@@ -1534,7 +1537,7 @@ void process_a_keystroke(void)
|
||||
/* If the user clicked on a shortcut, read in the key code that it was
|
||||
* converted into. Else the click has been handled or was invalid. */
|
||||
if (do_mouse() == 1)
|
||||
input = get_kbinput(edit, BLIND);
|
||||
input = get_kbinput(midwin, BLIND);
|
||||
else
|
||||
return;
|
||||
}
|
||||
@@ -1564,7 +1567,7 @@ void process_a_keystroke(void)
|
||||
|
||||
/* If we have a command, or if there aren't any other key codes waiting,
|
||||
* it's time to insert the gathered bytes into the edit buffer. */
|
||||
if ((shortcut || get_key_buffer_len() == 0) && puddle != NULL) {
|
||||
if ((shortcut || waiting_keycodes() == 0) && puddle != NULL) {
|
||||
puddle[depth] = '\0';
|
||||
|
||||
inject(puddle, depth);
|
||||
@@ -1611,8 +1614,8 @@ void process_a_keystroke(void)
|
||||
}
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
if (shortcut->func == do_toggle_void) {
|
||||
do_toggle(shortcut->toggle);
|
||||
if (shortcut->func == do_toggle) {
|
||||
toggle_this(shortcut->toggle);
|
||||
if (shortcut->toggle == CUT_FROM_CURSOR)
|
||||
keep_cutbuffer = FALSE;
|
||||
return;
|
||||
@@ -1739,7 +1742,7 @@ int main(int argc, char **argv)
|
||||
{"nowrap", 0, NULL, 'w'},
|
||||
#endif
|
||||
{"nohelp", 0, NULL, 'x'},
|
||||
{"suspendable", 0, NULL, 'z'},
|
||||
{"suspendable", 0, NULL, 'z'}, /* Obsolete; remove in 2022. */
|
||||
#ifndef NANO_TINY
|
||||
{"smarthome", 0, NULL, 'A'},
|
||||
{"backup", 0, NULL, 'B'},
|
||||
@@ -1768,6 +1771,7 @@ int main(int argc, char **argv)
|
||||
{"afterends", 0, NULL, 'y'},
|
||||
{"stateflags", 0, NULL, '%'},
|
||||
{"minibar", 0, NULL, '_'},
|
||||
{"zero", 0, NULL, '0'},
|
||||
#endif
|
||||
#ifdef HAVE_LIBMAGIC
|
||||
{"magic", 0, NULL, '!'},
|
||||
@@ -1785,10 +1789,12 @@ int main(int argc, char **argv)
|
||||
/* Back up the terminal settings so that they can be restored. */
|
||||
tcgetattr(STDIN_FILENO, &original_state);
|
||||
|
||||
#if defined(F_GETFL) && defined(F_SETFL)
|
||||
/* Get the state of standard input and ensure it uses blocking mode. */
|
||||
stdin_flags = fcntl(STDIN_FILENO, F_GETFL, 0);
|
||||
if (stdin_flags != -1)
|
||||
fcntl(STDIN_FILENO, F_SETFL, stdin_flags & ~O_NONBLOCK);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
/* If setting the locale is successful and it uses UTF-8, we will
|
||||
@@ -1804,24 +1810,14 @@ 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"
|
||||
while ((optchr = getopt_long(argc, argv, "0ABC:DEFGHIJ:KLMNOPQ:RST:UVWX:Y:Z"
|
||||
"abcdef:ghijklmno:pqr:s:tuvwxyz$%_!", long_options, NULL)) != -1) {
|
||||
switch (optchr) {
|
||||
#ifndef NANO_TINY
|
||||
@@ -2056,7 +2052,6 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
#endif
|
||||
case 'z':
|
||||
SET(SUSPENDABLE);
|
||||
break;
|
||||
#ifndef NANO_TINY
|
||||
case '%':
|
||||
@@ -2065,6 +2060,9 @@ int main(int argc, char **argv)
|
||||
case '_':
|
||||
SET(MINIBAR);
|
||||
break;
|
||||
case '0':
|
||||
SET(ZERO);
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_LIBMAGIC
|
||||
case '!':
|
||||
@@ -2077,6 +2075,10 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* Curses needs TERM; if it is unset, try falling back to a VT220. */
|
||||
if (getenv("TERM") == NULL)
|
||||
putenv("TERM=vt220");
|
||||
|
||||
/* Enter into curses mode. Abort if this fails. */
|
||||
if (initscr() == NULL)
|
||||
exit(1);
|
||||
@@ -2085,6 +2087,9 @@ int main(int argc, char **argv)
|
||||
/* If the terminal can do colors, tell ncurses to switch them on. */
|
||||
if (has_colors())
|
||||
start_color();
|
||||
|
||||
/* When requested, suppress the default spotlight and error colors. */
|
||||
rescind_colors = (getenv("NO_COLOR") != NULL);
|
||||
#endif
|
||||
|
||||
/* Set up the function and shortcut lists. This needs to be done
|
||||
@@ -2175,13 +2180,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++)
|
||||
@@ -2200,11 +2201,10 @@ int main(int argc, char **argv)
|
||||
if (ISSET(BOLD_TEXT))
|
||||
hilite_attribute = A_BOLD;
|
||||
|
||||
/* When in restricted mode, disable backups, suspending, and history files,
|
||||
* since they allow writing to files not specified on the command line. */
|
||||
/* When in restricted mode, disable backups and history files, since they
|
||||
* would allow writing to files not specified on the command line. */
|
||||
if (ISSET(RESTRICTED)) {
|
||||
UNSET(MAKE_BACKUP);
|
||||
UNSET(SUSPENDABLE);
|
||||
#ifdef ENABLE_NANORC
|
||||
UNSET(HISTORYLOG);
|
||||
UNSET(POSITIONLOG);
|
||||
@@ -2215,6 +2215,10 @@ int main(int argc, char **argv)
|
||||
if (ISSET(RAW_SEQUENCES))
|
||||
UNSET(USE_MOUSE);
|
||||
|
||||
/* When suppressing title bar or minibar, suppress also the help lines. */
|
||||
if (ISSET(ZERO))
|
||||
SET(NO_HELP);
|
||||
|
||||
#ifdef ENABLE_HISTORIES
|
||||
/* Initialize the pointers for the Search/Replace/Execute histories. */
|
||||
history_init();
|
||||
@@ -2231,7 +2235,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,
|
||||
@@ -2265,7 +2269,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
|
||||
@@ -2325,7 +2329,8 @@ int main(int argc, char **argv)
|
||||
interface_color_pair[GUIDE_STRIPE] = A_REVERSE;
|
||||
interface_color_pair[SCROLL_BAR] = A_NORMAL;
|
||||
interface_color_pair[SELECTED_TEXT] = hilite_attribute;
|
||||
interface_color_pair[HIGHLIGHTED] = A_REVERSE;
|
||||
interface_color_pair[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;
|
||||
@@ -2406,9 +2411,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;
|
||||
@@ -2431,7 +2436,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"));
|
||||
}
|
||||
|
||||
@@ -2449,7 +2458,7 @@ int main(int argc, char **argv)
|
||||
|
||||
/* If a position was given on the command line, go there. */
|
||||
if (givenline != 0 || givencol != 0)
|
||||
do_gotolinecolumn(givenline, givencol, FALSE, FALSE);
|
||||
goto_line_and_column(givenline, givencol, FALSE, FALSE);
|
||||
#ifndef NANO_TINY
|
||||
else if (searchstring != NULL) {
|
||||
if (ISSET(USE_REGEXP))
|
||||
@@ -2457,7 +2466,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))
|
||||
@@ -2472,11 +2481,14 @@ int main(int argc, char **argv)
|
||||
ssize_t savedline, savedcol;
|
||||
/* If edited before, restore the last cursor position. */
|
||||
if (has_old_position(argv[optind - 1], &savedline, &savedcol))
|
||||
do_gotolinecolumn(savedline, savedcol, FALSE, FALSE);
|
||||
goto_line_and_column(savedline, savedcol, FALSE, FALSE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* After handling the files on the command line, allow inserting files. */
|
||||
UNSET(NOREAD_MODE);
|
||||
|
||||
/* If no filenames were given, or all of them were invalid things like
|
||||
* directories, then open a blank buffer and allow editing. Otherwise,
|
||||
* switch from the last opened file to the next, that is: the first. */
|
||||
@@ -2502,11 +2514,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
|
||||
|
||||
@@ -2517,36 +2534,45 @@ int main(int argc, char **argv)
|
||||
confirm_margin();
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
if (on_a_vt && get_key_buffer_len() == 0)
|
||||
if (on_a_vt && waiting_keycodes() == 0)
|
||||
mute_modifiers = FALSE;
|
||||
#endif
|
||||
if (currmenu != MMAIN)
|
||||
bottombars(MMAIN);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(MINIBAR) && lastmessage < REMARK)
|
||||
if (ISSET(MINIBAR) && !ISSET(ZERO) && LINES > 1 && lastmessage < REMARK)
|
||||
minibar();
|
||||
else
|
||||
#endif
|
||||
/* Update the displayed current cursor position only when there
|
||||
* is no message and no keys are waiting in the input buffer. */
|
||||
if (ISSET(CONSTANT_SHOW) && lastmessage == VACUUM && get_key_buffer_len() == 0)
|
||||
if (ISSET(CONSTANT_SHOW) && lastmessage == VACUUM && LINES > 1 &&
|
||||
!ISSET(ZERO) && waiting_keycodes() == 0)
|
||||
report_cursor_position();
|
||||
|
||||
as_an_at = TRUE;
|
||||
|
||||
/* Refresh just the cursor position or the entire edit window. */
|
||||
if (!refresh_needed) {
|
||||
place_the_cursor();
|
||||
wnoutrefresh(edit);
|
||||
} else
|
||||
if ((refresh_needed && LINES > 1) || (LINES == 1 && lastmessage <= HUSH))
|
||||
edit_refresh();
|
||||
else
|
||||
place_the_cursor();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Let the next keystroke cancel the highlighting of a search match. */
|
||||
refresh_needed = spotlighted;
|
||||
spotlighted = FALSE;
|
||||
/* In barless mode, either redraw a relevant status message,
|
||||
* or overwrite a minor, redundant one. */
|
||||
if (ISSET(ZERO) && lastmessage > HUSH) {
|
||||
if (openfile->current_y == editwinrows - 1 && LINES > 1) {
|
||||
edit_scroll(FORWARD);
|
||||
wnoutrefresh(midwin);
|
||||
}
|
||||
wredrawln(footwin, 0, 1);
|
||||
wnoutrefresh(footwin);
|
||||
place_the_cursor();
|
||||
} else if (ISSET(ZERO) && lastmessage > VACUUM)
|
||||
wredrawln(midwin, editwinrows - 1, 1);
|
||||
#endif
|
||||
|
||||
errno = 0;
|
||||
focusing = TRUE;
|
||||
|
||||
|
||||
226
src/prompt.c
226
src/prompt.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* prompt.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2016, 2018, 2020 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -157,15 +157,27 @@ void do_statusbar_backspace(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Zap some or all text from the answer. */
|
||||
void do_statusbar_cut_text(void)
|
||||
/* Zap the part of the answer after the cursor, or the whole answer. */
|
||||
void lop_the_answer(void)
|
||||
{
|
||||
if (!ISSET(CUT_FROM_CURSOR))
|
||||
if (answer[typing_x] == '\0')
|
||||
typing_x = 0;
|
||||
|
||||
answer[typing_x] = '\0';
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Copy the current answer (if any) into the cutbuffer. */
|
||||
void copy_the_answer(void)
|
||||
{
|
||||
if (*answer) {
|
||||
free_lines(cutbuffer);
|
||||
cutbuffer = make_new_node(NULL);
|
||||
cutbuffer->data = copy_of(answer);
|
||||
typing_x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Paste the first line of the cutbuffer into the current answer. */
|
||||
void paste_into_answer(void)
|
||||
{
|
||||
@@ -182,6 +194,7 @@ void paste_into_answer(void)
|
||||
answer = fusion;
|
||||
typing_x += pastelen;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_MOUSE
|
||||
/* Handle a mouse click on the status-bar prompt or the shortcut list. */
|
||||
@@ -191,7 +204,7 @@ int do_statusbar_mouse(void)
|
||||
int retval = get_mouseinput(&click_row, &click_col, TRUE);
|
||||
|
||||
/* We can click on the status-bar window text to move the cursor. */
|
||||
if (retval == 0 && wmouse_trafo(bottomwin, &click_row, &click_col, FALSE)) {
|
||||
if (retval == 0 && wmouse_trafo(footwin, &click_row, &click_col, FALSE)) {
|
||||
size_t start_col = breadth(prompt) + 2;
|
||||
|
||||
/* Move to where the click occurred. */
|
||||
@@ -216,7 +229,7 @@ void inject_into_answer(char *burst, size_t count)
|
||||
answer = nrealloc(answer, strlen(answer) + count + 1);
|
||||
memmove(answer + typing_x + count, answer + typing_x,
|
||||
strlen(answer) - typing_x + 1);
|
||||
strncpy(answer + typing_x, burst , count);
|
||||
strncpy(answer + typing_x, burst, count);
|
||||
|
||||
typing_x += count;
|
||||
}
|
||||
@@ -227,7 +240,7 @@ void do_statusbar_verbatim_input(void)
|
||||
size_t count = 1;
|
||||
char *bytes;
|
||||
|
||||
bytes = get_verbatim_kbinput(bottomwin, &count);
|
||||
bytes = get_verbatim_kbinput(footwin, &count);
|
||||
|
||||
if (0 < count && count < 999)
|
||||
inject_into_answer(bytes, count);
|
||||
@@ -253,7 +266,7 @@ int do_statusbar_input(bool *finished)
|
||||
*finished = FALSE;
|
||||
|
||||
/* Read in a character. */
|
||||
input = get_kbinput(bottomwin, VISIBLE);
|
||||
input = get_kbinput(footwin, VISIBLE);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (input == KEY_WINCH)
|
||||
@@ -265,7 +278,7 @@ int do_statusbar_input(bool *finished)
|
||||
* shortcut character. */
|
||||
if (input == KEY_MOUSE) {
|
||||
if (do_statusbar_mouse() == 1)
|
||||
input = get_kbinput(bottomwin, BLIND);
|
||||
input = get_kbinput(footwin, BLIND);
|
||||
else
|
||||
return ERR;
|
||||
}
|
||||
@@ -290,7 +303,7 @@ int do_statusbar_input(bool *finished)
|
||||
/* If we got a shortcut, or if there aren't any other keystrokes waiting,
|
||||
* it's time to insert all characters in the input buffer (if not empty)
|
||||
* into the answer, and then clear the input buffer. */
|
||||
if ((shortcut || get_key_buffer_len() == 0) && puddle != NULL) {
|
||||
if ((shortcut || waiting_keycodes() == 0) && puddle != NULL) {
|
||||
puddle[depth] = '\0';
|
||||
|
||||
inject_into_answer(puddle, depth);
|
||||
@@ -304,8 +317,8 @@ int do_statusbar_input(bool *finished)
|
||||
if (shortcut->func == do_tab || shortcut->func == do_enter)
|
||||
;
|
||||
#ifdef ENABLE_HISTORIES
|
||||
else if (shortcut->func == get_history_older_void ||
|
||||
shortcut->func == get_history_newer_void)
|
||||
else if (shortcut->func == get_older_item ||
|
||||
shortcut->func == get_newer_item)
|
||||
;
|
||||
#endif
|
||||
else if (shortcut->func == do_left)
|
||||
@@ -327,10 +340,10 @@ int do_statusbar_input(bool *finished)
|
||||
else if (ISSET(RESTRICTED) && currmenu == MWRITEFILE &&
|
||||
openfile->filename[0] != '\0' &&
|
||||
(shortcut->func == do_verbatim_input ||
|
||||
shortcut->func == cut_text ||
|
||||
shortcut->func == paste_text ||
|
||||
shortcut->func == do_delete ||
|
||||
shortcut->func == do_backspace))
|
||||
shortcut->func == do_backspace ||
|
||||
shortcut->func == cut_text ||
|
||||
shortcut->func == paste_text))
|
||||
;
|
||||
#ifdef ENABLE_NANORC
|
||||
else if (shortcut->func == (functionptrtype)implant)
|
||||
@@ -338,16 +351,21 @@ int do_statusbar_input(bool *finished)
|
||||
#endif
|
||||
else if (shortcut->func == do_verbatim_input)
|
||||
do_statusbar_verbatim_input();
|
||||
else if (shortcut->func == cut_text)
|
||||
do_statusbar_cut_text();
|
||||
else if (shortcut->func == do_delete)
|
||||
do_statusbar_delete();
|
||||
else if (shortcut->func == do_backspace)
|
||||
do_statusbar_backspace();
|
||||
else if (shortcut->func == cut_text)
|
||||
lop_the_answer();
|
||||
#ifndef NANO_TINY
|
||||
else if (shortcut->func == copy_text)
|
||||
copy_the_answer();
|
||||
else if (shortcut->func == paste_text) {
|
||||
if (cutbuffer != NULL)
|
||||
paste_into_answer();
|
||||
} else {
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
/* Handle any other shortcut in the current menu, setting finished
|
||||
* to TRUE to indicate that we're done after running or trying to
|
||||
* run its associated function. */
|
||||
@@ -392,33 +410,33 @@ void draw_the_promptbar(void)
|
||||
end_page = get_statusbar_page_start(base, base + breadth(answer) - 1);
|
||||
|
||||
/* Color the prompt bar over its full width. */
|
||||
wattron(bottomwin, interface_color_pair[PROMPT_BAR]);
|
||||
mvwprintw(bottomwin, 0, 0, "%*s", COLS, " ");
|
||||
wattron(footwin, interface_color_pair[PROMPT_BAR]);
|
||||
mvwprintw(footwin, 0, 0, "%*s", COLS, " ");
|
||||
|
||||
mvwaddstr(bottomwin, 0, 0, prompt);
|
||||
waddch(bottomwin, ':');
|
||||
waddch(bottomwin, (the_page == 0) ? ' ' : '<');
|
||||
mvwaddstr(footwin, 0, 0, prompt);
|
||||
waddch(footwin, ':');
|
||||
waddch(footwin, (the_page == 0) ? ' ' : '<');
|
||||
|
||||
expanded = display_string(answer, the_page, COLS - base, FALSE, TRUE);
|
||||
waddstr(bottomwin, expanded);
|
||||
waddstr(footwin, expanded);
|
||||
free(expanded);
|
||||
|
||||
if (the_page < end_page && base + breadth(answer) - the_page > COLS)
|
||||
mvwaddch(bottomwin, 0, COLS - 1, '>');
|
||||
mvwaddch(footwin, 0, COLS - 1, '>');
|
||||
|
||||
wattroff(bottomwin, interface_color_pair[PROMPT_BAR]);
|
||||
wattroff(footwin, interface_color_pair[PROMPT_BAR]);
|
||||
|
||||
#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH < 20210220)
|
||||
/* Work around a cursor-misplacement bug -- https://sv.gnu.org/bugs/?59808. */
|
||||
if (ISSET(NO_HELP)) {
|
||||
wmove(bottomwin, 0, 0);
|
||||
wrefresh(bottomwin);
|
||||
wmove(footwin, 0, 0);
|
||||
wrefresh(footwin);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Place the cursor at the right spot. */
|
||||
wmove(bottomwin, 0, column - the_page);
|
||||
wnoutrefresh(bottomwin);
|
||||
wmove(footwin, 0, column - the_page);
|
||||
wnoutrefresh(footwin);
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -426,7 +444,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 {
|
||||
@@ -446,10 +464,8 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
|
||||
bool finished;
|
||||
functionptrtype func;
|
||||
#ifdef ENABLE_HISTORIES
|
||||
char *history = NULL;
|
||||
/* The current history string. */
|
||||
char *magichistory = NULL;
|
||||
/* The (partial) answer that was typed at the prompt, if any. */
|
||||
char *stored_string = NULL;
|
||||
/* Whatever the answer was before the user foraged into history. */
|
||||
#ifdef ENABLE_TABCOMP
|
||||
bool previous_was_tab = FALSE;
|
||||
/* Whether the previous keystroke was an attempt at tab completion. */
|
||||
@@ -472,7 +488,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
|
||||
refresh_func();
|
||||
*actual = KEY_WINCH;
|
||||
#ifdef ENABLE_HISTORIES
|
||||
free(magichistory);
|
||||
free(stored_string);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
@@ -503,36 +519,33 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
|
||||
} else
|
||||
#endif /* ENABLE_TABCOMP */
|
||||
#ifdef ENABLE_HISTORIES
|
||||
if (func == get_history_older_void) {
|
||||
if (history_list != NULL) {
|
||||
/* If we're scrolling up at the bottom of the history list
|
||||
* and answer isn't blank, save answer in magichistory. */
|
||||
if ((*history_list)->next == NULL && *answer != '\0')
|
||||
magichistory = mallocstrcpy(magichistory, answer);
|
||||
if (func == get_older_item && history_list != NULL) {
|
||||
/* If this is the first step into history, start at the bottom. */
|
||||
if (stored_string == NULL)
|
||||
reset_history_pointer_for(*history_list);
|
||||
|
||||
/* Get the older search from the history list and save it in
|
||||
* answer. If there is no older search, don't do anything. */
|
||||
if ((history = get_history_older(history_list)) != NULL) {
|
||||
answer = mallocstrcpy(answer, history);
|
||||
typing_x = strlen(answer);
|
||||
}
|
||||
/* When moving up from the bottom, remember the current answer. */
|
||||
if ((*history_list)->next == NULL)
|
||||
stored_string = mallocstrcpy(stored_string, answer);
|
||||
|
||||
/* If there is an older item, move to it and copy its string. */
|
||||
if ((*history_list)->prev != NULL) {
|
||||
*history_list = (*history_list)->prev;
|
||||
answer = mallocstrcpy(answer, (*history_list)->data);
|
||||
typing_x = strlen(answer);
|
||||
}
|
||||
} else if (func == get_newer_item && history_list != NULL) {
|
||||
/* If there is a newer item, move to it and copy its string. */
|
||||
if ((*history_list)->next != NULL) {
|
||||
*history_list = (*history_list)->next;
|
||||
answer = mallocstrcpy(answer, (*history_list)->data);
|
||||
typing_x = strlen(answer);
|
||||
}
|
||||
} else if (func == get_history_newer_void) {
|
||||
if (history_list != NULL) {
|
||||
/* Get the newer search from the history list and save it in
|
||||
* answer. If there is no newer search, don't do anything. */
|
||||
if ((history = get_history_newer(history_list)) != NULL) {
|
||||
answer = mallocstrcpy(answer, history);
|
||||
typing_x = strlen(answer);
|
||||
}
|
||||
|
||||
/* If we've reached the bottom of the history list, and answer
|
||||
* is blank, and magichistory is set, restore the old answer. */
|
||||
if ((*history_list)->next == NULL &&
|
||||
*answer == '\0' && magichistory != NULL) {
|
||||
answer = mallocstrcpy(answer, magichistory);
|
||||
typing_x = strlen(answer);
|
||||
}
|
||||
/* When at the bottom of the history list, restore the old answer. */
|
||||
if ((*history_list)->next == NULL && stored_string && *answer == '\0') {
|
||||
answer = mallocstrcpy(answer, stored_string);
|
||||
typing_x = strlen(answer);
|
||||
}
|
||||
} else
|
||||
#endif /* ENABLE_HISTORIES */
|
||||
@@ -542,7 +555,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
|
||||
#ifndef NANO_TINY
|
||||
else if (func == do_nothing)
|
||||
finished = FALSE;
|
||||
else if (func == do_toggle_void) {
|
||||
else if (func == do_toggle) {
|
||||
TOGGLE(NO_HELP);
|
||||
window_init();
|
||||
focusing = FALSE;
|
||||
@@ -563,10 +576,10 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
|
||||
}
|
||||
|
||||
#ifdef ENABLE_HISTORIES
|
||||
/* Set the current position in the history list to the bottom. */
|
||||
if (history_list != NULL) {
|
||||
history_reset(*history_list);
|
||||
free(magichistory);
|
||||
/* If the history pointer was moved, point it at the bottom again. */
|
||||
if (stored_string != NULL) {
|
||||
reset_history_pointer_for(*history_list);
|
||||
free(stored_string);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -640,12 +653,14 @@ int do_prompt(int menu, const char *provided, linestruct **history_list,
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Ask a simple Yes/No (and optionally All) question, specified in msg,
|
||||
* on the status bar. Return 1 for Yes, 0 for No, 2 for All (if all is
|
||||
* TRUE when passed in), and -1 for Cancel. */
|
||||
int do_yesno_prompt(bool all, const char *msg)
|
||||
#define UNDECIDED -2
|
||||
|
||||
/* Ask a simple Yes/No (and optionally All) question on the status bar
|
||||
* and return the choice -- either YES or NO or ALL or CANCEL. */
|
||||
int ask_user(bool withall, const char *question)
|
||||
{
|
||||
int choice = -2, width = 16;
|
||||
int choice = UNDECIDED;
|
||||
int width = 16;
|
||||
/* TRANSLATORS: For the next three strings, specify the starting letters
|
||||
* of the translations for "Yes"/"No"/"All". The first letter of each of
|
||||
* these strings MUST be a single-byte letter; others may be multi-byte. */
|
||||
@@ -653,7 +668,7 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
const char *nostr = _("Nn");
|
||||
const char *allstr = _("Aa");
|
||||
|
||||
while (choice == -2) {
|
||||
while (choice == UNDECIDED) {
|
||||
#ifdef ENABLE_NLS
|
||||
char letter[MAXCHARLEN + 1];
|
||||
int index = 0;
|
||||
@@ -674,34 +689,34 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
|
||||
/* Now show the ones for "Yes", "No", "Cancel" and maybe "All". */
|
||||
sprintf(shortstr, " %c", yesstr[0]);
|
||||
wmove(bottomwin, 1, 0);
|
||||
wmove(footwin, 1, 0);
|
||||
post_one_key(shortstr, _("Yes"), width);
|
||||
|
||||
shortstr[1] = nostr[0];
|
||||
wmove(bottomwin, 2, 0);
|
||||
wmove(footwin, 2, 0);
|
||||
post_one_key(shortstr, _("No"), width);
|
||||
|
||||
if (all) {
|
||||
if (withall) {
|
||||
shortstr[1] = allstr[0];
|
||||
wmove(bottomwin, 1, width);
|
||||
wmove(footwin, 1, width);
|
||||
post_one_key(shortstr, _("All"), width);
|
||||
}
|
||||
|
||||
wmove(bottomwin, 2, width);
|
||||
wmove(footwin, 2, width);
|
||||
post_one_key(cancelshortcut->keystr, _("Cancel"), width);
|
||||
}
|
||||
|
||||
/* Color the prompt bar over its full width and display the question. */
|
||||
wattron(bottomwin, interface_color_pair[PROMPT_BAR]);
|
||||
mvwprintw(bottomwin, 0, 0, "%*s", COLS, " ");
|
||||
mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));
|
||||
wattroff(bottomwin, interface_color_pair[PROMPT_BAR]);
|
||||
wnoutrefresh(bottomwin);
|
||||
wattron(footwin, interface_color_pair[PROMPT_BAR]);
|
||||
mvwprintw(footwin, 0, 0, "%*s", COLS, " ");
|
||||
mvwaddnstr(footwin, 0, 0, question, actual_x(question, COLS - 1));
|
||||
wattroff(footwin, interface_color_pair[PROMPT_BAR]);
|
||||
wnoutrefresh(footwin);
|
||||
|
||||
currmenu = MYESNO;
|
||||
|
||||
/* When not replacing, show the cursor while waiting for a key. */
|
||||
kbinput = get_kbinput(bottomwin, !all);
|
||||
kbinput = get_kbinput(footwin, !withall);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (kbinput == KEY_WINCH)
|
||||
@@ -709,7 +724,7 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
|
||||
/* Accept the first character of an external paste. */
|
||||
if (bracketed_paste && kbinput == BRACKETED_PASTE_MARKER)
|
||||
kbinput = get_kbinput(bottomwin, BLIND);
|
||||
kbinput = get_kbinput(footwin, BLIND);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
@@ -720,41 +735,41 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
if (using_utf8() && 0xC0 <= kbinput && kbinput <= 0xF7) {
|
||||
int extras = (kbinput / 16) % 4 + (kbinput <= 0xCF ? 1 : 0);
|
||||
|
||||
while (extras <= get_key_buffer_len() && extras-- > 0)
|
||||
letter[index++] = (unsigned char)get_kbinput(bottomwin, !all);
|
||||
while (extras <= waiting_keycodes() && extras-- > 0)
|
||||
letter[index++] = (unsigned char)get_kbinput(footwin, !withall);
|
||||
}
|
||||
#endif
|
||||
letter[index] = '\0';
|
||||
|
||||
/* See if the typed letter is in the Yes, No, or All strings. */
|
||||
if (strstr(yesstr, letter) != NULL)
|
||||
choice = 1;
|
||||
choice = YES;
|
||||
else if (strstr(nostr, letter) != NULL)
|
||||
choice = 0;
|
||||
else if (all && strstr(allstr, letter) != NULL)
|
||||
choice = 2;
|
||||
choice = NO;
|
||||
else if (withall && strstr(allstr, letter) != NULL)
|
||||
choice = ALL;
|
||||
else
|
||||
#endif /* ENABLE_NLS */
|
||||
if (strchr("Yy", kbinput) != NULL)
|
||||
choice = 1;
|
||||
choice = YES;
|
||||
else if (strchr("Nn", kbinput) != NULL)
|
||||
choice = 0;
|
||||
else if (all && strchr("Aa", kbinput) != NULL)
|
||||
choice = 2;
|
||||
choice = NO;
|
||||
else if (withall && strchr("Aa", kbinput) != NULL)
|
||||
choice = ALL;
|
||||
else if (func_from_key(&kbinput) == do_cancel)
|
||||
choice = -1;
|
||||
choice = CANCEL;
|
||||
/* Interpret ^N and ^Q as "No", to allow exiting in anger. */
|
||||
else if (kbinput == '\x0E' || kbinput == '\x11')
|
||||
choice = 0;
|
||||
choice = NO;
|
||||
/* And interpret ^Y as "Yes". */
|
||||
else if (kbinput == '\x19')
|
||||
choice = 1;
|
||||
choice = YES;
|
||||
#ifdef ENABLE_MOUSE
|
||||
else if (kbinput == KEY_MOUSE) {
|
||||
int mouse_x, mouse_y;
|
||||
/* We can click on the Yes/No/All shortcuts to select an answer. */
|
||||
if (get_mouseinput(&mouse_y, &mouse_x, FALSE) == 0 &&
|
||||
wmouse_trafo(bottomwin, &mouse_y, &mouse_x, FALSE) &&
|
||||
wmouse_trafo(footwin, &mouse_y, &mouse_x, FALSE) &&
|
||||
mouse_x < (width * 2) && mouse_y > 0) {
|
||||
int x = mouse_x / width;
|
||||
int y = mouse_y - 1;
|
||||
@@ -762,20 +777,21 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
/* x == 0 means Yes or No, y == 0 means Yes or All. */
|
||||
choice = -2 * x * y + x - y + 1;
|
||||
|
||||
if (choice == 2 && !all)
|
||||
choice = -2;
|
||||
if (choice == ALL && !withall)
|
||||
choice = UNDECIDED;
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_MOUSE */
|
||||
#endif
|
||||
else if (func_from_key(&kbinput) == full_refresh)
|
||||
full_refresh();
|
||||
#ifndef NANO_TINY
|
||||
else if (func_from_key(&kbinput) == do_toggle_void) {
|
||||
else if (func_from_key(&kbinput) == do_toggle) {
|
||||
TOGGLE(NO_HELP);
|
||||
window_init();
|
||||
titlebar(NULL);
|
||||
focusing = FALSE;
|
||||
edit_refresh();
|
||||
focusing = TRUE;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
@@ -784,7 +800,7 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
#ifndef NANO_TINY
|
||||
/* Ignore the rest of an external paste. */
|
||||
while (bracketed_paste)
|
||||
kbinput = get_kbinput(bottomwin, BLIND);
|
||||
kbinput = get_kbinput(footwin, BLIND);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* prototypes.h -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published *
|
||||
@@ -53,7 +53,6 @@ extern message_type lastmessage;
|
||||
extern linestruct *pletion_line;
|
||||
|
||||
extern bool also_the_last;
|
||||
extern bool hide_cursor;
|
||||
|
||||
extern char *answer;
|
||||
|
||||
@@ -88,8 +87,8 @@ extern size_t wrap_at;
|
||||
#endif
|
||||
|
||||
extern WINDOW *topwin;
|
||||
extern WINDOW *edit;
|
||||
extern WINDOW *bottomwin;
|
||||
extern WINDOW *midwin;
|
||||
extern WINDOW *footwin;
|
||||
extern int editwinrows;
|
||||
extern int editwincols;
|
||||
extern int margin;
|
||||
@@ -142,6 +141,9 @@ extern char *alt_speller;
|
||||
extern syntaxtype *syntaxes;
|
||||
extern char *syntaxstr;
|
||||
extern bool have_palette;
|
||||
extern bool rescind_colors;
|
||||
extern bool perturbed;
|
||||
extern bool recook;
|
||||
#endif
|
||||
|
||||
extern bool refresh_needed;
|
||||
@@ -191,6 +193,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 +208,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,9 +234,6 @@ 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
|
||||
@@ -283,7 +284,7 @@ void close_buffer(void);
|
||||
void read_file(FILE *f, int fd, const char *filename, bool undoable);
|
||||
int open_file(const char *filename, bool new_one, FILE **f);
|
||||
char *get_next_filename(const char *name, const char *suffix);
|
||||
void do_insertfile_void(void);
|
||||
void do_insertfile(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_execute(void);
|
||||
#endif
|
||||
@@ -297,14 +298,14 @@ 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);
|
||||
int write_it_out(bool exiting, bool withprompt);
|
||||
void do_writeout(void);
|
||||
void do_savefile(void);
|
||||
char *real_dir_from_tilde(const char *path);
|
||||
#if defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
|
||||
@@ -324,7 +325,7 @@ functionptrtype interpret(int *keycode);
|
||||
#endif
|
||||
int keycode_from_string(const char *keystring);
|
||||
void shortcut_init(void);
|
||||
const char *flagtostr(int flag);
|
||||
const char *epithet_of_flag(int flag);
|
||||
|
||||
/* Some functions in help.c. */
|
||||
#ifdef ENABLE_HELP
|
||||
@@ -335,12 +336,8 @@ void do_help(void);
|
||||
/* Most functions in history.c. */
|
||||
#ifdef ENABLE_HISTORIES
|
||||
void history_init(void);
|
||||
void history_reset(const linestruct *list);
|
||||
void update_history(linestruct **item, const char *text);
|
||||
char *get_history_older(linestruct **h);
|
||||
char *get_history_newer(linestruct **h);
|
||||
void get_history_older_void(void);
|
||||
void get_history_newer_void(void);
|
||||
void reset_history_pointer_for(const linestruct *list);
|
||||
void update_history(linestruct **item, const char *text, bool avoid_duplicates);
|
||||
#ifdef ENABLE_TABCOMP
|
||||
char *get_history_completion(linestruct **h, char *s, size_t len);
|
||||
#endif
|
||||
@@ -365,8 +362,8 @@ void to_para_end(void);
|
||||
#endif
|
||||
void to_prev_block(void);
|
||||
void to_next_block(void);
|
||||
void do_prev_word(bool allow_punct);
|
||||
bool do_next_word(bool after_ends, bool allow_punct);
|
||||
void do_prev_word(void);
|
||||
bool do_next_word(bool after_ends);
|
||||
void to_prev_word(void);
|
||||
void to_next_word(void);
|
||||
void do_home(void);
|
||||
@@ -391,6 +388,9 @@ void free_lines(linestruct *src);
|
||||
void renumber_from(linestruct *line);
|
||||
void print_view_warning(void);
|
||||
bool in_restricted_mode(void);
|
||||
#ifndef NANO_TINY
|
||||
void suggest_ctrlT_ctrlZ(void);
|
||||
#endif
|
||||
void finish(void);
|
||||
void close_and_go(void);
|
||||
void do_exit(void);
|
||||
@@ -405,16 +405,15 @@ void handle_hupterm(int signal);
|
||||
#ifndef DEBUG
|
||||
void handle_crash(int signal);
|
||||
#endif
|
||||
void do_suspend(int signal);
|
||||
void do_continue(int signal);
|
||||
void suspend_nano(int signal);
|
||||
void do_suspend(void);
|
||||
void continue_nano(int signal);
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_SPELLER) || defined(ENABLE_COLOR)
|
||||
void block_sigwinch(bool blockit);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
void handle_sigwinch(int signal);
|
||||
void compute_the_extra_rows_per_line_from(linestruct *fromline);
|
||||
void regenerate_screen(void);
|
||||
void do_toggle(int flag);
|
||||
#endif
|
||||
void disable_kb_interrupt(void);
|
||||
void enable_kb_interrupt(void);
|
||||
@@ -434,7 +433,7 @@ void put_cursor_at_end_of_answer(void);
|
||||
void add_or_remove_pipe_symbol_from_answer(void);
|
||||
int do_prompt(int menu, const char *provided, linestruct **history_list,
|
||||
void (*refresh_func)(void), const char *msg, ...);
|
||||
int do_yesno_prompt(bool all, const char *msg);
|
||||
int ask_user(bool withall, const char *question);
|
||||
|
||||
/* Most functions in rcfile.c. */
|
||||
#if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES)
|
||||
@@ -467,9 +466,9 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
void do_replace(void);
|
||||
void ask_for_and_do_replacements(void);
|
||||
void goto_line_posx(ssize_t line, size_t pos_x);
|
||||
void do_gotolinecolumn(ssize_t line, ssize_t column, bool retain_answer,
|
||||
void goto_line_and_column(ssize_t line, ssize_t column, bool retain_answer,
|
||||
bool interactive);
|
||||
void do_gotolinecolumn_void(void);
|
||||
void do_gotolinecolumn(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_find_bracket(void);
|
||||
void put_or_lift_anchor(void);
|
||||
@@ -499,7 +498,7 @@ void update_multiline_undo(ssize_t lineno, char *indentation);
|
||||
void update_undo(undo_type action);
|
||||
#endif /* !NANO_TINY */
|
||||
#ifdef ENABLE_WRAPPING
|
||||
bool do_wrap(void);
|
||||
void do_wrap(void);
|
||||
#endif
|
||||
#if defined(ENABLE_HELP) || defined(ENABLED_WRAPORJUSTIFY)
|
||||
ssize_t break_line(const char *textstart, ssize_t goal, bool snap_at_nl);
|
||||
@@ -511,8 +510,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
|
||||
@@ -523,7 +521,7 @@ void do_linter(void);
|
||||
void do_formatter(void);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
void do_wordlinechar_count(void);
|
||||
void count_lines_words_and_characters(void);
|
||||
#endif
|
||||
void do_verbatim_input(void);
|
||||
void complete_a_word(void);
|
||||
@@ -532,9 +530,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);
|
||||
@@ -575,11 +571,11 @@ linestruct *line_from_number(ssize_t number);
|
||||
/* Most functions in winio.c. */
|
||||
void record_macro(void);
|
||||
void run_macro(void);
|
||||
size_t get_key_buffer_len(void);
|
||||
size_t waiting_keycodes(void);
|
||||
#ifdef ENABLE_NANORC
|
||||
void implant(const char *string);
|
||||
#endif
|
||||
int parse_kbinput(WINDOW *win);
|
||||
int get_input(WINDOW *win);
|
||||
int get_kbinput(WINDOW *win, bool showcursor);
|
||||
char *get_verbatim_kbinput(WINDOW *win, size_t *count);
|
||||
#ifdef ENABLE_MOUSE
|
||||
@@ -630,7 +626,6 @@ void spotlight(size_t from_col, size_t to_col);
|
||||
#ifndef NANO_TINY
|
||||
void spotlight_softwrapped(size_t from_col, size_t to_col);
|
||||
#endif
|
||||
void do_suspend_void(void);
|
||||
#ifdef ENABLE_EXTRA
|
||||
void do_credits(void);
|
||||
#endif
|
||||
@@ -639,22 +634,24 @@ void do_credits(void);
|
||||
void case_sens_void(void);
|
||||
void regexp_void(void);
|
||||
void backwards_void(void);
|
||||
#ifdef ENABLE_HISTORIES
|
||||
void get_older_item(void);
|
||||
void get_newer_item(void);
|
||||
#endif
|
||||
void flip_replace(void);
|
||||
void flip_goto(void);
|
||||
#ifdef ENABLE_BROWSER
|
||||
void to_files(void);
|
||||
void to_first_file(void);
|
||||
void to_last_file(void);
|
||||
void goto_dir(void);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
void do_nothing(void);
|
||||
void do_toggle_void(void);
|
||||
void dos_format_void(void);
|
||||
void mac_format_void(void);
|
||||
void append_void(void);
|
||||
void prepend_void(void);
|
||||
void backup_file_void(void);
|
||||
void do_toggle(void);
|
||||
void dos_format(void);
|
||||
void mac_format(void);
|
||||
void append_it(void);
|
||||
void prepend_it(void);
|
||||
void back_it_up(void);
|
||||
void flip_execute(void);
|
||||
void flip_pipe(void);
|
||||
void flip_convert(void);
|
||||
|
||||
183
src/rcfile.c
183
src/rcfile.c
@@ -1,10 +1,10 @@
|
||||
/**************************************************************************
|
||||
* rcfile.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2001-2011, 2013-2022 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014 Mike Frysinger *
|
||||
* Copyright (C) 2019 Brand Huntsman *
|
||||
* Copyright (C) 2014-2020 Benno Schulenberg *
|
||||
* Copyright (C) 2014-2021 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published *
|
||||
@@ -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
|
||||
@@ -93,7 +91,7 @@ static const rcoption rcopts[] = {
|
||||
{"speller", 0},
|
||||
#endif
|
||||
{"suspend", SUSPENDABLE}, /* Deprecated; remove in 2022. */
|
||||
{"suspendable", SUSPENDABLE},
|
||||
{"suspendable", SUSPENDABLE}, /* Obsolete; remove in 2022. */
|
||||
{"tempfile", SAVE_ON_EXIT}, /* Deprecated; remove in 2022. */
|
||||
#ifndef NANO_TINY
|
||||
{"afterends", AFTER_ENDS},
|
||||
@@ -114,7 +112,6 @@ static const rcoption rcopts[] = {
|
||||
{"noconvert", NO_CONVERT},
|
||||
{"showcursor", SHOW_CURSOR},
|
||||
{"smarthome", SMART_HOME},
|
||||
{"smooth", SMOOTH_SCROLL}, /* Deprecated; remove in 2021. */
|
||||
{"softwrap", SOFTWRAP},
|
||||
{"stateflags", STATEFLAGS},
|
||||
{"tabsize", 0},
|
||||
@@ -125,6 +122,7 @@ static const rcoption rcopts[] = {
|
||||
{"wordbounds", WORD_BOUNDS},
|
||||
{"wordchars", 0},
|
||||
{"zap", LET_THEM_ZAP},
|
||||
{"zero", ZERO},
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
{"titlecolor", 0},
|
||||
@@ -132,7 +130,8 @@ static const rcoption rcopts[] = {
|
||||
{"stripecolor", 0},
|
||||
{"scrollercolor", 0},
|
||||
{"selectedcolor", 0},
|
||||
{"highlightcolor", 0},
|
||||
{"spotlightcolor", 0},
|
||||
{"minicolor", 0},
|
||||
{"promptcolor", 0},
|
||||
{"statuscolor", 0},
|
||||
{"errorcolor", 0},
|
||||
@@ -244,11 +243,11 @@ keystruct *strtosc(const char *input)
|
||||
else if (!strcmp(input, "discardbuffer"))
|
||||
s->func = discard_buffer;
|
||||
else if (!strcmp(input, "writeout"))
|
||||
s->func = do_writeout_void;
|
||||
s->func = do_writeout;
|
||||
else if (!strcmp(input, "savefile"))
|
||||
s->func = do_savefile;
|
||||
else if (!strcmp(input, "insert"))
|
||||
s->func = do_insertfile_void;
|
||||
s->func = do_insertfile;
|
||||
else if (!strcmp(input, "whereis"))
|
||||
s->func = do_search_forward;
|
||||
else if (!strcmp(input, "wherewas"))
|
||||
@@ -290,10 +289,10 @@ keystruct *strtosc(const char *input)
|
||||
!strcmp(input, "curpos")) /* Deprecated; remove in 2022. */
|
||||
s->func = report_cursor_position;
|
||||
else if (!strcmp(input, "gotoline"))
|
||||
s->func = do_gotolinecolumn_void;
|
||||
s->func = do_gotolinecolumn;
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
else if (!strcmp(input, "justify"))
|
||||
s->func = do_justify_void;
|
||||
s->func = do_justify;
|
||||
else if (!strcmp(input, "fulljustify"))
|
||||
s->func = do_full_justify;
|
||||
else if (!strcmp(input, "beginpara"))
|
||||
@@ -314,16 +313,14 @@ keystruct *strtosc(const char *input)
|
||||
s->func = do_indent;
|
||||
else if (!strcmp(input, "unindent"))
|
||||
s->func = do_unindent;
|
||||
else if (!strcmp(input, "chopwordleft") ||
|
||||
!strcmp(input, "cutwordleft")) /* Deprecated; remove in 2021. */
|
||||
else if (!strcmp(input, "chopwordleft"))
|
||||
s->func = chop_previous_word;
|
||||
else if (!strcmp(input, "chopwordright") ||
|
||||
!strcmp(input, "cutwordright")) /* Deprecated; remove in 2021. */
|
||||
else if (!strcmp(input, "chopwordright"))
|
||||
s->func = chop_next_word;
|
||||
else if (!strcmp(input, "findbracket"))
|
||||
s->func = do_find_bracket;
|
||||
else if (!strcmp(input, "wordcount"))
|
||||
s->func = do_wordlinechar_count;
|
||||
s->func = count_lines_words_and_characters;
|
||||
else if (!strcmp(input, "recordmacro"))
|
||||
s->func = record_macro;
|
||||
else if (!strcmp(input, "runmacro"))
|
||||
@@ -399,8 +396,10 @@ keystruct *strtosc(const char *input)
|
||||
s->func = do_backspace;
|
||||
else if (!strcmp(input, "refresh"))
|
||||
s->func = full_refresh;
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcmp(input, "suspend"))
|
||||
s->func = do_suspend_void;
|
||||
s->func = do_suspend;
|
||||
#endif
|
||||
else if (!strcmp(input, "casesens"))
|
||||
s->func = case_sens_void;
|
||||
else if (!strcmp(input, "regexp"))
|
||||
@@ -413,21 +412,21 @@ keystruct *strtosc(const char *input)
|
||||
s->func = flip_goto;
|
||||
#ifdef ENABLE_HISTORIES
|
||||
else if (!strcmp(input, "older"))
|
||||
s->func = get_history_older_void;
|
||||
s->func = get_older_item;
|
||||
else if (!strcmp(input, "newer"))
|
||||
s->func = get_history_newer_void;
|
||||
s->func = get_newer_item;
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcmp(input, "dosformat"))
|
||||
s->func = dos_format_void;
|
||||
s->func = dos_format;
|
||||
else if (!strcmp(input, "macformat"))
|
||||
s->func = mac_format_void;
|
||||
s->func = mac_format;
|
||||
else if (!strcmp(input, "append"))
|
||||
s->func = append_void;
|
||||
s->func = append_it;
|
||||
else if (!strcmp(input, "prepend"))
|
||||
s->func = prepend_void;
|
||||
s->func = prepend_it;
|
||||
else if (!strcmp(input, "backup"))
|
||||
s->func = backup_file_void;
|
||||
s->func = back_it_up;
|
||||
else if (!strcmp(input, "flipexecute"))
|
||||
s->func = flip_execute;
|
||||
else if (!strcmp(input, "flippipe"))
|
||||
@@ -452,9 +451,11 @@ keystruct *strtosc(const char *input)
|
||||
#endif
|
||||
else {
|
||||
#ifndef NANO_TINY
|
||||
s->func = do_toggle_void;
|
||||
s->func = do_toggle;
|
||||
if (!strcmp(input, "nohelp"))
|
||||
s->toggle = NO_HELP;
|
||||
else if (!strcmp(input, "zero"))
|
||||
s->toggle = ZERO;
|
||||
else if (!strcmp(input, "constantshow"))
|
||||
s->toggle = CONSTANT_SHOW;
|
||||
else if (!strcmp(input, "softwrap"))
|
||||
@@ -486,9 +487,6 @@ keystruct *strtosc(const char *input)
|
||||
else if (!strcmp(input, "mouse"))
|
||||
s->toggle = USE_MOUSE;
|
||||
#endif
|
||||
else if (!strcmp(input, "suspendable") ||
|
||||
!strcmp(input, "suspendenable")) /* Deprecated; remove in 2022. */
|
||||
s->toggle = SUSPENDABLE;
|
||||
else
|
||||
#endif /* !NANO_TINY */
|
||||
{
|
||||
@@ -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
|
||||
@@ -832,9 +828,9 @@ void parse_binding(char *ptr, bool dobind)
|
||||
if (is_universal(newsc->func))
|
||||
menu &= MMOST|MBROWSER;
|
||||
#ifndef NANO_TINY
|
||||
else if (newsc->func == do_toggle_void && newsc->toggle == NO_HELP)
|
||||
else if (newsc->func == do_toggle && newsc->toggle == NO_HELP)
|
||||
menu &= (MMOST|MBROWSER|MYESNO) & ~MFINDINHELP;
|
||||
else if (newsc->func == do_toggle_void)
|
||||
else if (newsc->func == do_toggle)
|
||||
menu &= MMAIN;
|
||||
#endif
|
||||
else if (newsc->func == full_refresh)
|
||||
@@ -872,9 +868,9 @@ void parse_binding(char *ptr, bool dobind)
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If this is a toggle, find and copy its sequence number. */
|
||||
if (newsc->func == do_toggle_void) {
|
||||
if (newsc->func == do_toggle) {
|
||||
for (keystruct *s = sclist; s != NULL; s = s->next)
|
||||
if (s->func == do_toggle_void && s->toggle == newsc->toggle)
|
||||
if (s->func == do_toggle && s->toggle == newsc->toggle)
|
||||
newsc->ordinal = s->ordinal;
|
||||
} else
|
||||
newsc->ordinal = 0;
|
||||
@@ -996,9 +992,41 @@ 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 };
|
||||
/* Return the index of the color that is closest to the given RGB levels,
|
||||
* assuming that the terminal uses the 6x6x6 color cube of xterm-256color. */
|
||||
short closest_index_color(short red, short green, short blue)
|
||||
{
|
||||
/* Translation table, from 16 intended levels to 6 available levels. */
|
||||
static const short level[] = { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 };
|
||||
|
||||
if (COLORS == 256)
|
||||
return (36 * level[red] + 6 * level[green] + level[blue] + 16);
|
||||
else
|
||||
return THE_DEFAULT;
|
||||
}
|
||||
|
||||
#define COLORCOUNT 34
|
||||
|
||||
const char hues[COLORCOUNT][8] = { "red", "green", "blue",
|
||||
"yellow", "cyan", "magenta",
|
||||
"white", "black", "normal",
|
||||
"pink", "purple", "mauve",
|
||||
"lagoon", "mint", "lime",
|
||||
"peach", "orange", "latte",
|
||||
"rosy", "beet", "plum",
|
||||
"sea", "sky", "slate",
|
||||
"teal", "sage", "brown",
|
||||
"ocher", "sand", "tawny",
|
||||
"brick", "crimson",
|
||||
"grey", "gray" };
|
||||
|
||||
short indices[COLORCOUNT] = { COLOR_RED, COLOR_GREEN, COLOR_BLUE,
|
||||
COLOR_YELLOW, COLOR_CYAN, COLOR_MAGENTA,
|
||||
COLOR_WHITE, COLOR_BLACK, THE_DEFAULT,
|
||||
204, 163, 134, 38, 48, 148, 215, 208, 137,
|
||||
175, 127, 98, 32, 111, 66, 35, 107, 100,
|
||||
142, 186, 136, 166, 161,
|
||||
COLOR_BLACK + 8, COLOR_BLACK + 8 };
|
||||
|
||||
/* Return the short value corresponding to the given color name, and set
|
||||
* vivid to TRUE for a lighter color, and thick for a heavier typeface. */
|
||||
@@ -1018,35 +1046,28 @@ 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];
|
||||
}
|
||||
if (colorname[0] == '#' && strlen(colorname) == 4) {
|
||||
unsigned short r, g, b;
|
||||
|
||||
if (*vivid) {
|
||||
jot_error(N_("Color '%s' takes no prefix"), colorname);
|
||||
return BAD_COLOR;
|
||||
}
|
||||
|
||||
if (sscanf(colorname, "#%1hX%1hX%1hX", &r, &g, &b) == 3)
|
||||
return closest_index_color(r, g, b);
|
||||
}
|
||||
|
||||
for (int index = 0; index < COLORCOUNT; index++)
|
||||
if (strcmp(colorname, hues[index]) == 0) {
|
||||
if (index > 7 && *vivid) {
|
||||
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 +1263,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 +1272,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,8 +1581,10 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
|
||||
color_combo[SCROLL_BAR] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "selectedcolor") == 0)
|
||||
color_combo[SELECTED_TEXT] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "highlightcolor") == 0)
|
||||
color_combo[HIGHLIGHTED] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "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)
|
||||
@@ -1574,7 +1599,7 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
|
||||
#endif
|
||||
#ifdef ENABLE_OPERATINGDIR
|
||||
if (strcmp(option, "operatingdir") == 0)
|
||||
operating_dir = copy_of(argument);
|
||||
operating_dir = mallocstrcpy(operating_dir, argument);
|
||||
else
|
||||
#endif
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
@@ -1592,12 +1617,12 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
|
||||
else if (mbstrlen(argument) % 2 != 0)
|
||||
jot_error(N_("Even number of characters required"));
|
||||
else
|
||||
matchbrackets = copy_of(argument);
|
||||
matchbrackets = mallocstrcpy(matchbrackets, argument);
|
||||
} else if (strcmp(option, "whitespace") == 0) {
|
||||
if (mbstrlen(argument) != 2 || breadth(argument) != 2)
|
||||
jot_error(N_("Two single-column characters required"));
|
||||
else {
|
||||
whitespace = copy_of(argument);
|
||||
whitespace = mallocstrcpy(whitespace, argument);
|
||||
whitelen[0] = char_length(whitespace);
|
||||
whitelen[1] = char_length(whitespace + whitelen[0]);
|
||||
}
|
||||
@@ -1608,26 +1633,26 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
|
||||
if (has_blank_char(argument))
|
||||
jot_error(N_("Non-blank characters required"));
|
||||
else
|
||||
punct = copy_of(argument);
|
||||
punct = mallocstrcpy(punct, argument);
|
||||
} else if (strcmp(option, "brackets") == 0) {
|
||||
if (has_blank_char(argument))
|
||||
jot_error(N_("Non-blank characters required"));
|
||||
else
|
||||
brackets = copy_of(argument);
|
||||
brackets = mallocstrcpy(brackets, argument);
|
||||
} else if (strcmp(option, "quotestr") == 0)
|
||||
quotestr = copy_of(argument);
|
||||
quotestr = mallocstrcpy(quotestr, argument);
|
||||
else
|
||||
#endif
|
||||
#ifdef ENABLE_SPELLER
|
||||
if (strcmp(option, "speller") == 0)
|
||||
alt_speller = copy_of(argument);
|
||||
alt_speller = mallocstrcpy(alt_speller, argument);
|
||||
else
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
if (strcmp(option, "backupdir") == 0)
|
||||
backup_dir = copy_of(argument);
|
||||
backup_dir = mallocstrcpy(backup_dir, argument);
|
||||
else if (strcmp(option, "wordchars") == 0)
|
||||
word_chars = copy_of(argument);
|
||||
word_chars = mallocstrcpy(word_chars, argument);
|
||||
else if (strcmp(option, "guidestripe") == 0) {
|
||||
if (!parse_num(argument, &stripe_column) || stripe_column <= 0) {
|
||||
jot_error(N_("Guide column \"%s\" is invalid"), argument);
|
||||
|
||||
119
src/search.c
119
src/search.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* search.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2015-2020 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -65,6 +65,9 @@ void tidy_up_after_search(void)
|
||||
if (openfile->mark)
|
||||
refresh_needed = TRUE;
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
recook |= perturbed;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Prepare the prompt and ask the user what to search for. Keep looping
|
||||
@@ -82,7 +85,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("");
|
||||
@@ -118,7 +121,7 @@ void search_init(bool replacing, bool retain_answer)
|
||||
if (*answer != '\0') {
|
||||
last_search = mallocstrcpy(last_search, answer);
|
||||
#ifdef ENABLE_HISTORIES
|
||||
update_history(&search_history, answer);
|
||||
update_history(&search_history, answer, PRUNE_DUPLICATE);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -152,7 +155,7 @@ void search_init(bool replacing, bool retain_answer)
|
||||
} else
|
||||
replacing = !replacing;
|
||||
} else if (func == flip_goto) {
|
||||
do_gotolinecolumn(openfile->current->lineno,
|
||||
goto_line_and_column(openfile->current->lineno,
|
||||
openfile->placewewant + 1, TRUE, TRUE);
|
||||
break;
|
||||
} else
|
||||
@@ -186,7 +189,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
/* The time we last looked at the keyboard. */
|
||||
|
||||
/* Set non-blocking input so that we can just peek for a Cancel. */
|
||||
nodelay(edit, TRUE);
|
||||
nodelay(midwin, TRUE);
|
||||
|
||||
if (begin == NULL)
|
||||
came_full_circle = FALSE;
|
||||
@@ -226,14 +229,14 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
#ifndef NANO_TINY
|
||||
if (the_window_resized) {
|
||||
regenerate_screen();
|
||||
nodelay(edit, TRUE);
|
||||
nodelay(midwin, TRUE);
|
||||
statusbar(_("Searching..."));
|
||||
feedback = 1;
|
||||
}
|
||||
#endif
|
||||
/* If we're back at the beginning, then there is no needle. */
|
||||
if (came_full_circle) {
|
||||
nodelay(edit, FALSE);
|
||||
nodelay(midwin, FALSE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -244,7 +247,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
* but stop when spell-checking or replacing in a region. */
|
||||
if (line == NULL) {
|
||||
if (whole_word_only || modus == INREGION) {
|
||||
nodelay(edit, FALSE);
|
||||
nodelay(midwin, FALSE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -268,7 +271,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
|
||||
/* Glance at the keyboard once every second, to check for a Cancel. */
|
||||
if (time(NULL) - lastkbcheck > 0) {
|
||||
int input = wgetch(edit);
|
||||
int input = wgetch(midwin);
|
||||
|
||||
lastkbcheck = time(NULL);
|
||||
|
||||
@@ -276,7 +279,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
while (input != ERR) {
|
||||
if (input == ESC_CODE) {
|
||||
napms(20);
|
||||
input = wgetch(edit);
|
||||
input = wgetch(midwin);
|
||||
meta_key = TRUE;
|
||||
} else
|
||||
meta_key = FALSE;
|
||||
@@ -289,12 +292,12 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
statusbar(_("Cancelled"));
|
||||
/* Clear out the key buffer (in case a macro is running). */
|
||||
while (input != ERR)
|
||||
input = parse_kbinput(NULL);
|
||||
nodelay(edit, FALSE);
|
||||
input = get_input(NULL);
|
||||
nodelay(midwin, FALSE);
|
||||
return -2;
|
||||
}
|
||||
|
||||
input = wgetch(edit);
|
||||
input = wgetch(midwin);
|
||||
}
|
||||
|
||||
if (++feedback > 0)
|
||||
@@ -306,7 +309,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
|
||||
found_x = found - line->data;
|
||||
|
||||
nodelay(edit, FALSE);
|
||||
nodelay(midwin, FALSE);
|
||||
|
||||
/* Ensure that the found occurrence is not beyond the starting x. */
|
||||
if (came_full_circle && ((!ISSET(BACKWARDS_SEARCH) && (found_x > begin_x ||
|
||||
@@ -327,17 +330,12 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
spotlighted = TRUE;
|
||||
light_from_col = xplustabs();
|
||||
light_to_col = wideness(line->data, found_x + found_len);
|
||||
if (!ISSET(SHOW_CURSOR))
|
||||
hide_cursor = TRUE;
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Wipe the "Searching..." message and unsuppress cursor-position display. */
|
||||
if (feedback > 0) {
|
||||
if (feedback > 0)
|
||||
wipe_statusbar();
|
||||
lastmessage = VACUUM;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -431,10 +429,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 +471,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;
|
||||
}
|
||||
}
|
||||
@@ -556,12 +551,12 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
openfile->current_x = bot_x;
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
#endif
|
||||
|
||||
came_full_circle = FALSE;
|
||||
|
||||
while (TRUE) {
|
||||
int choice = 0;
|
||||
int choice = NO;
|
||||
int result = findnextstr(needle, whole_word_only, modus,
|
||||
&match_len, skipone, real_current, *real_current_x);
|
||||
|
||||
@@ -597,32 +592,31 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
edit_refresh();
|
||||
|
||||
/* TRANSLATORS: This is a prompt. */
|
||||
choice = do_yesno_prompt(TRUE, _("Replace this instance?"));
|
||||
choice = ask_user(YESORALLORNO, _("Replace this instance?"));
|
||||
|
||||
spotlighted = FALSE;
|
||||
|
||||
if (choice == -1) /* The replacing was cancelled. */
|
||||
if (choice == CANCEL)
|
||||
break;
|
||||
else if (choice == 2)
|
||||
replaceall = TRUE;
|
||||
|
||||
replaceall = (choice == ALL);
|
||||
|
||||
/* When "No" or moving backwards, the search routine should
|
||||
* first move one character further before continuing. */
|
||||
skipone = (choice == 0 || ISSET(BACKWARDS_SEARCH));
|
||||
}
|
||||
|
||||
if (choice == 1 || replaceall) { /* Yes, replace it. */
|
||||
char *copy;
|
||||
if (choice == YES || replaceall) {
|
||||
size_t length_change;
|
||||
char *altered;
|
||||
|
||||
altered = replace_line(needle);
|
||||
|
||||
length_change = strlen(altered) - strlen(openfile->current->data);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(REPLACE, NULL);
|
||||
#endif
|
||||
copy = replace_line(needle);
|
||||
|
||||
length_change = strlen(copy) - strlen(openfile->current->data);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If the mark was on and it was located after the cursor,
|
||||
* then adjust its x position for any text length changes. */
|
||||
if (was_mark && !right_side_up) {
|
||||
@@ -638,8 +632,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)
|
||||
@@ -647,8 +642,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. */
|
||||
@@ -661,13 +656,13 @@ 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);
|
||||
#ifdef ENABLE_COLOR
|
||||
check_the_multis(openfile->current);
|
||||
refresh_needed = FALSE;
|
||||
#endif
|
||||
set_modified();
|
||||
as_an_at = TRUE;
|
||||
@@ -710,13 +705,13 @@ 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. */
|
||||
if (response == 0)
|
||||
update_history(&replace_history, answer);
|
||||
update_history(&replace_history, answer, PRUNE_DUPLICATE);
|
||||
#endif
|
||||
|
||||
/* When cancelled, or when a function was run, get out. */
|
||||
@@ -733,16 +728,23 @@ void ask_for_and_do_replacements(void)
|
||||
openfile->firstcolumn = was_firstcolumn;
|
||||
openfile->current = beginline;
|
||||
openfile->current_x = begin_x;
|
||||
|
||||
refresh_needed = TRUE;
|
||||
|
||||
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. */
|
||||
void goto_line_posx(ssize_t line, size_t pos_x)
|
||||
{
|
||||
#ifdef ENABLE_COLOR
|
||||
if (line > openfile->edittop->lineno + editwinrows ||
|
||||
(ISSET(SOFTWRAP) && line > openfile->current->lineno))
|
||||
recook |= perturbed;
|
||||
#endif
|
||||
|
||||
for (openfile->current = openfile->filetop; line > 1 &&
|
||||
openfile->current != openfile->filebot; line--)
|
||||
openfile->current = openfile->current->next;
|
||||
@@ -756,8 +758,8 @@ void goto_line_posx(ssize_t line, size_t pos_x)
|
||||
/* Go to the specified line and column, or ask for them if interactive
|
||||
* is TRUE. In the latter case also update the screen afterwards.
|
||||
* Note that both the line and column number should be one-based. */
|
||||
void do_gotolinecolumn(ssize_t line, ssize_t column, bool retain_answer,
|
||||
bool interactive)
|
||||
void goto_line_and_column(ssize_t line, ssize_t column, bool retain_answer,
|
||||
bool interactive)
|
||||
{
|
||||
if (interactive) {
|
||||
/* Ask for the line and column. */
|
||||
@@ -801,6 +803,12 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool retain_answer,
|
||||
if (line < 1)
|
||||
line = 1;
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
if (line > openfile->edittop->lineno + editwinrows ||
|
||||
(ISSET(SOFTWRAP) && line > openfile->current->lineno))
|
||||
recook |= perturbed;
|
||||
#endif
|
||||
|
||||
/* Iterate to the requested line. */
|
||||
for (openfile->current = openfile->filetop; line > 1 &&
|
||||
openfile->current != openfile->filebot; line--)
|
||||
@@ -853,9 +861,9 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool retain_answer,
|
||||
}
|
||||
|
||||
/* Go to the specified line and column, asking for them beforehand. */
|
||||
void do_gotolinecolumn_void(void)
|
||||
void do_gotolinecolumn(void)
|
||||
{
|
||||
do_gotolinecolumn(openfile->current->lineno,
|
||||
goto_line_and_column(openfile->current->lineno,
|
||||
openfile->placewewant + 1, FALSE, TRUE);
|
||||
}
|
||||
|
||||
@@ -1003,6 +1011,11 @@ void go_to_and_confirm(linestruct *line)
|
||||
if (line != openfile->current) {
|
||||
openfile->current = line;
|
||||
openfile->current_x = 0;
|
||||
#ifdef ENABLE_COLOR
|
||||
if (line->lineno > openfile->edittop->lineno + editwinrows ||
|
||||
(ISSET(SOFTWRAP) && line->lineno > was_current->lineno))
|
||||
recook |= perturbed;
|
||||
#endif
|
||||
edit_redraw(was_current, CENTERING);
|
||||
statusbar(_("Jumped to anchor"));
|
||||
} else if (openfile->current->has_anchor)
|
||||
|
||||
343
src/text.c
343
src/text.c
@@ -1,12 +1,12 @@
|
||||
/**************************************************************************
|
||||
* text.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2015 Mark Majeres *
|
||||
* Copyright (C) 2016 Mike Scalora *
|
||||
* Copyright (C) 2016 Sumedh Pendurkar *
|
||||
* 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);
|
||||
|
||||
@@ -569,12 +558,11 @@ void do_undo(void)
|
||||
* and the nonewlines flag isn't set, do not re-add a newline that
|
||||
* wasn't actually deleted; just position the cursor. */
|
||||
if ((u->xflags & WAS_BACKSPACE_AT_EOF) && !ISSET(NO_NEWLINES)) {
|
||||
goto_line_posx(openfile->filebot->lineno, 0);
|
||||
openfile->current = openfile->filebot;
|
||||
openfile->current_x = 0;
|
||||
break;
|
||||
}
|
||||
line->data[u->tail_x] = '\0';
|
||||
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 +664,16 @@ 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". */
|
||||
#ifdef ENABLE_COLOR
|
||||
if (u->type <= REPLACE)
|
||||
check_the_multis(openfile->current);
|
||||
else if (u->type == INSERT)
|
||||
perturbed = TRUE;
|
||||
#endif
|
||||
|
||||
/* When at the point where the buffer was last saved, unset "Modified". */
|
||||
if (openfile->current_undo == openfile->last_saved) {
|
||||
openfile->modified = FALSE;
|
||||
titlebar(NULL);
|
||||
@@ -725,8 +717,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 +831,16 @@ 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". */
|
||||
#ifdef ENABLE_COLOR
|
||||
if (u->type <= REPLACE)
|
||||
check_the_multis(openfile->current);
|
||||
else if (u->type == INSERT)
|
||||
recook = TRUE;
|
||||
#endif
|
||||
|
||||
/* When at the point where the buffer was last saved, unset "Modified". */
|
||||
if (openfile->current_undo == openfile->last_saved) {
|
||||
openfile->modified = FALSE;
|
||||
titlebar(NULL);
|
||||
@@ -907,11 +901,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 +940,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 +1042,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 +1065,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 +1106,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. */
|
||||
@@ -1198,7 +1192,8 @@ void update_undo(undo_type action)
|
||||
else if (cutbuffer != NULL) {
|
||||
free_lines(u->cutbuffer);
|
||||
u->cutbuffer = copy_buffer(cutbuffer);
|
||||
}
|
||||
} else
|
||||
break;
|
||||
if (!(u->xflags & MARK_WAS_SET)) {
|
||||
linestruct *bottomline = u->cutbuffer;
|
||||
size_t count = 0;
|
||||
@@ -1233,9 +1228,9 @@ void update_undo(undo_type action)
|
||||
|
||||
#ifdef ENABLE_WRAPPING
|
||||
/* When the current line is overlong, hard-wrap it at the furthest possible
|
||||
* whitespace character, and (if possible) prepend the remainder of the line
|
||||
* to the next line. Return TRUE if wrapping occurred, and FALSE otherwise. */
|
||||
bool do_wrap(void)
|
||||
* whitespace character, and prepend the excess part to an "overflow" line
|
||||
* (when it already exists, otherwise create one). */
|
||||
void do_wrap(void)
|
||||
{
|
||||
linestruct *line = openfile->current;
|
||||
/* The line to be wrapped, if needed and possible. */
|
||||
@@ -1264,7 +1259,7 @@ bool do_wrap(void)
|
||||
|
||||
/* If no wrapping point was found before end-of-line, we don't wrap. */
|
||||
if (wrap_loc < 0 || lead_len + wrap_loc == line_len)
|
||||
return FALSE;
|
||||
return;
|
||||
|
||||
/* Adjust the wrap location to its position in the full line,
|
||||
* and step forward to the character just after the blank. */
|
||||
@@ -1272,7 +1267,7 @@ bool do_wrap(void)
|
||||
|
||||
/* When now at end-of-line, no need to wrap. */
|
||||
if (line->data[wrap_loc] == '\0')
|
||||
return FALSE;
|
||||
return;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(SPLIT_BEGIN, NULL);
|
||||
@@ -1357,7 +1352,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)
|
||||
@@ -1379,7 +1376,7 @@ bool do_wrap(void)
|
||||
add_undo(SPLIT_END, NULL);
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
#endif /* ENABLE_WRAPPING */
|
||||
|
||||
@@ -1453,21 +1450,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
|
||||
|
||||
@@ -1493,9 +1481,8 @@ bool begpar(const linestruct *const line, int depth)
|
||||
{
|
||||
size_t quot_len, indent_len, prev_dent_len;
|
||||
|
||||
/* If this is the very first line of the buffer, it counts as a BOP
|
||||
* even when it contains no text. */
|
||||
if (line == openfile->filetop)
|
||||
/* The very first line counts as a BOP, even when it contains no text. */
|
||||
if (line->prev == NULL)
|
||||
return TRUE;
|
||||
|
||||
/* If recursion is going too deep, just say it's not a BOP. */
|
||||
@@ -1741,9 +1728,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. */
|
||||
@@ -1771,6 +1761,8 @@ void do_justify(bool full_justify)
|
||||
/* The leading part for lines after the first one. */
|
||||
size_t secondary_len = 0;
|
||||
/* The length of that later lead. */
|
||||
ssize_t was_the_linenumber = openfile->current->lineno;
|
||||
/* The line to return to after a full justification. */
|
||||
|
||||
/* TRANSLATORS: This one goes with Undid/Redid messages. */
|
||||
add_undo(COUPLE_BEGIN, N_("justification"));
|
||||
@@ -1859,7 +1851,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 +1873,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 +1948,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 +1959,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);
|
||||
@@ -1985,25 +1979,24 @@ void do_justify(bool full_justify)
|
||||
openfile->current_x = openfile->mark_x;
|
||||
openfile->mark = bottom;
|
||||
openfile->mark_x = bottom_x;
|
||||
}
|
||||
} else if (whole_buffer && !openfile->mark)
|
||||
goto_line_posx(was_the_linenumber, 0);
|
||||
|
||||
add_undo(COUPLE_END, N_("justification"));
|
||||
#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)
|
||||
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 +2006,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 */
|
||||
@@ -2057,11 +2050,19 @@ bool replace_buffer(const char *filename, undo_type action, const char *operatio
|
||||
if (descriptor < 0)
|
||||
return FALSE;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(COUPLE_BEGIN, operation);
|
||||
#endif
|
||||
|
||||
/* When replacing the whole buffer, start cutting at the top. */
|
||||
if (action == CUT_TO_EOF) {
|
||||
openfile->current = openfile->filetop;
|
||||
openfile->current_x = 0;
|
||||
}
|
||||
|
||||
cutbuffer = NULL;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(COUPLE_BEGIN, operation);
|
||||
|
||||
/* Cut either the marked region or the whole buffer. */
|
||||
add_undo(action, NULL);
|
||||
do_snip(openfile->mark != NULL, openfile->mark == NULL, FALSE);
|
||||
@@ -2086,9 +2087,10 @@ 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;
|
||||
#if defined(HAVE_FORK) && defined(HAVE_WAIT)
|
||||
ssize_t was_lineno = openfile->current->lineno;
|
||||
size_t was_pww = openfile->placewewant;
|
||||
size_t was_x = openfile->current_x;
|
||||
bool was_at_eol = (openfile->current->data[openfile->current_x] == '\0');
|
||||
struct stat fileinfo;
|
||||
long timestamp_sec = 0;
|
||||
@@ -2172,7 +2174,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;
|
||||
|
||||
@@ -2180,17 +2182,12 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
|
||||
openfile->mark = line_from_number(was_mark_lineno);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
openfile->current = openfile->filetop;
|
||||
openfile->current_x = 0;
|
||||
|
||||
replaced = replace_buffer(tempfile_name, CUT_TO_EOF,
|
||||
/* TRANSLATORS: The next two go with Undid/Redid messages. */
|
||||
(spelling ? N_("spelling correction") : N_("formatting")));
|
||||
}
|
||||
|
||||
/* Go back to the old position. */
|
||||
goto_line_posx(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,13 +2198,14 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
|
||||
#endif
|
||||
}
|
||||
|
||||
openfile->placewewant = pww_save;
|
||||
openfile->placewewant = was_pww;
|
||||
adjust_viewport(STATIONARY);
|
||||
|
||||
if (spelling)
|
||||
statusline(REMARK, _("Finished checking spelling"));
|
||||
else
|
||||
statusline(REMARK, _("Buffer has been processed"));
|
||||
#endif
|
||||
}
|
||||
#endif /* ENABLE_SPELLER || ENABLE_COLOR */
|
||||
|
||||
@@ -2320,12 +2318,14 @@ bool fix_spello(const char *word)
|
||||
* correction. */
|
||||
void do_int_speller(const char *tempfile_name)
|
||||
{
|
||||
#if defined(HAVE_FORK) && defined(HAVE_WAITPID)
|
||||
char *misspellings, *pointer, *oneword;
|
||||
long pipesize;
|
||||
size_t buffersize, bytesread, totalread;
|
||||
int spell_fd[2], sort_fd[2], uniq_fd[2], tempfile_fd = -1;
|
||||
pid_t pid_spell, pid_sort, pid_uniq;
|
||||
int spell_status, sort_status, uniq_status;
|
||||
unsigned stash[sizeof(flags) / sizeof(flags[0])];
|
||||
|
||||
/* Create all three pipes up front. */
|
||||
if (pipe(spell_fd) == -1 || pipe(sort_fd) == -1 || pipe(uniq_fd) == -1) {
|
||||
@@ -2450,6 +2450,9 @@ void do_int_speller(const char *tempfile_name)
|
||||
terminal_init();
|
||||
doupdate();
|
||||
|
||||
/* Save the settings of the global flags. */
|
||||
memcpy(stash, flags, sizeof(flags));
|
||||
|
||||
/* Do any replacements case-sensitively, forward, and without regexes. */
|
||||
SET(CASE_SENSITIVE);
|
||||
UNSET(BACKWARDS_SEARCH);
|
||||
@@ -2480,6 +2483,9 @@ void do_int_speller(const char *tempfile_name)
|
||||
free(misspellings);
|
||||
refresh_needed = TRUE;
|
||||
|
||||
/* Restore the settings of the global flags. */
|
||||
memcpy(flags, stash, sizeof(flags));
|
||||
|
||||
/* Process the end of the three processes. */
|
||||
waitpid(pid_spell, &spell_status, 0);
|
||||
waitpid(pid_sort, &sort_status, 0);
|
||||
@@ -2493,6 +2499,7 @@ void do_int_speller(const char *tempfile_name)
|
||||
statusline(ALERT, _("Error invoking \"spell\""));
|
||||
else
|
||||
statusline(REMARK, _("Finished checking spelling"));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Spell check the current file. If an alternate spell checker is
|
||||
@@ -2501,7 +2508,6 @@ void do_spell(void)
|
||||
{
|
||||
FILE *stream;
|
||||
char *temp_name;
|
||||
unsigned stash[sizeof(flags) / sizeof(flags[0])];
|
||||
bool okay;
|
||||
|
||||
ran_a_tool = TRUE;
|
||||
@@ -2516,21 +2522,16 @@ void do_spell(void)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Save the settings of the global flags. */
|
||||
memcpy(stash, flags, sizeof(flags));
|
||||
|
||||
/* Don't add an extra newline when writing out the (selected) text. */
|
||||
SET(NO_NEWLINES);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->mark)
|
||||
okay = write_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));
|
||||
unlink(temp_name);
|
||||
free(temp_name);
|
||||
return;
|
||||
}
|
||||
@@ -2545,9 +2546,6 @@ void do_spell(void)
|
||||
unlink(temp_name);
|
||||
free(temp_name);
|
||||
|
||||
/* Restore the settings of the global flags. */
|
||||
memcpy(flags, stash, sizeof(flags));
|
||||
|
||||
/* Ensure the help lines will be redrawn and a selection is retained. */
|
||||
currmenu = MMOST;
|
||||
shift_held = TRUE;
|
||||
@@ -2558,6 +2556,7 @@ void do_spell(void)
|
||||
/* Run a linting program on the current buffer. */
|
||||
void do_linter(void)
|
||||
{
|
||||
#if defined(HAVE_FORK) && defined(HAVE_WAITPID)
|
||||
char *lintings, *pointer, *onelint;
|
||||
long pipesize;
|
||||
size_t buffersize, bytesread, totalread;
|
||||
@@ -2584,12 +2583,12 @@ void do_linter(void)
|
||||
edit_refresh();
|
||||
|
||||
if (openfile->modified) {
|
||||
int choice = do_yesno_prompt(FALSE, _("Save modified buffer before linting?"));
|
||||
int choice = ask_user(YESORNO, _("Save modified buffer before linting?"));
|
||||
|
||||
if (choice == -1) {
|
||||
if (choice == CANCEL) {
|
||||
statusbar(_("Cancelled"));
|
||||
return;
|
||||
} else if (choice == 1 && (do_writeout(FALSE, FALSE) != 1))
|
||||
} else if (choice == YES && (write_it_out(FALSE, FALSE) != 1))
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2644,6 +2643,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,47 +2662,41 @@ 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';
|
||||
if (onelint != pointer) {
|
||||
char *filename = NULL, *linestr = NULL, *maybecol = NULL;
|
||||
char *message = copy_of(onelint);
|
||||
char *filename, *linestring, *colstring;
|
||||
char *complaint = copy_of(onelint);
|
||||
char *spacer = strstr(complaint, " ");
|
||||
|
||||
/* 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) */
|
||||
if (strstr(message, ": ") != NULL) {
|
||||
filename = strtok(onelint, ":");
|
||||
if ((linestr = strtok(NULL, ":")) != NULL) {
|
||||
if ((maybecol = strtok(NULL, ":")) != NULL) {
|
||||
ssize_t tmplineno = 0, tmpcolno = 0;
|
||||
char *tmplinecol;
|
||||
/* The recognized format is "filename:line:column: message",
|
||||
* where ":column" may be absent or be ",column" instead. */
|
||||
if ((filename = strtok(onelint, ":")) && spacer) {
|
||||
if ((linestring = strtok(NULL, ":"))) {
|
||||
if ((colstring = strtok(NULL, " "))) {
|
||||
ssize_t linenumber = strtol(linestring, NULL, 10);
|
||||
ssize_t colnumber = strtol(colstring, NULL, 10);
|
||||
|
||||
tmplineno = strtol(linestr, NULL, 10);
|
||||
if (tmplineno <= 0) {
|
||||
if (linenumber <= 0) {
|
||||
free(complaint);
|
||||
pointer++;
|
||||
free(message);
|
||||
continue;
|
||||
}
|
||||
|
||||
tmpcolno = strtol(maybecol, NULL, 10);
|
||||
/* Check if the middle field is in comma format. */
|
||||
if (tmpcolno <= 0) {
|
||||
strtok(linestr, ",");
|
||||
if ((tmplinecol = strtok(NULL, ",")) != NULL)
|
||||
tmpcolno = strtol(tmplinecol, NULL, 10);
|
||||
else
|
||||
tmpcolno = 1;
|
||||
if (colnumber <= 0) {
|
||||
colnumber = 1;
|
||||
strtok(linestring, ",");
|
||||
if ((colstring = strtok(NULL, ",")))
|
||||
colnumber = strtol(colstring, NULL, 10);
|
||||
}
|
||||
|
||||
/* Nice. We have a lint message we can use. */
|
||||
parsesuccess = TRUE;
|
||||
tmplint = curlint;
|
||||
curlint = nmalloc(sizeof(lintstruct));
|
||||
@@ -2708,17 +2704,17 @@ void do_linter(void)
|
||||
curlint->prev = tmplint;
|
||||
if (curlint->prev != NULL)
|
||||
curlint->prev->next = curlint;
|
||||
curlint->msg = copy_of(message);
|
||||
curlint->lineno = tmplineno;
|
||||
curlint->colno = tmpcolno;
|
||||
curlint->filename = copy_of(filename);
|
||||
curlint->lineno = linenumber;
|
||||
curlint->colno = colnumber;
|
||||
curlint->msg = copy_of(spacer + 1);
|
||||
|
||||
if (lints == NULL)
|
||||
lints = curlint;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(message);
|
||||
free(complaint);
|
||||
}
|
||||
onelint = pointer + 1;
|
||||
}
|
||||
@@ -2741,7 +2737,7 @@ void do_linter(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (helpless && LINES > 4) {
|
||||
if (helpless && LINES > 5) {
|
||||
UNSET(NO_HELP);
|
||||
window_init();
|
||||
}
|
||||
@@ -2776,14 +2772,14 @@ void do_linter(void)
|
||||
|
||||
sprintf(msg, _("This message is for unopened file %s,"
|
||||
" open it in a new buffer?"), curlint->filename);
|
||||
choice = do_yesno_prompt(FALSE, msg);
|
||||
choice = ask_user(YESORNO, msg);
|
||||
currmenu = MLINTER;
|
||||
free(msg);
|
||||
|
||||
if (choice == -1) {
|
||||
if (choice == CANCEL) {
|
||||
statusbar(_("Cancelled"));
|
||||
break;
|
||||
} else if (choice == 1) {
|
||||
} else if (choice == YES) {
|
||||
open_buffer(curlint->filename, TRUE);
|
||||
} else {
|
||||
#endif
|
||||
@@ -2842,9 +2838,9 @@ void do_linter(void)
|
||||
|
||||
/* Place the cursor to indicate the affected line. */
|
||||
place_the_cursor();
|
||||
wnoutrefresh(edit);
|
||||
wnoutrefresh(midwin);
|
||||
|
||||
kbinput = get_kbinput(bottomwin, VISIBLE);
|
||||
kbinput = get_kbinput(footwin, VISIBLE);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (kbinput == KEY_WINCH)
|
||||
@@ -2900,6 +2896,7 @@ void do_linter(void)
|
||||
lastmessage = VACUUM;
|
||||
currmenu = MMOST;
|
||||
titlebar(NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Run a manipulation program on the contents of the buffer. */
|
||||
@@ -2926,15 +2923,12 @@ 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) {
|
||||
if (!okay)
|
||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||
free(temp_name);
|
||||
return;
|
||||
}
|
||||
|
||||
treat(temp_name, openfile->syntax->formatter, FALSE);
|
||||
else
|
||||
treat(temp_name, openfile->syntax->formatter, FALSE);
|
||||
|
||||
unlink(temp_name);
|
||||
free(temp_name);
|
||||
@@ -2942,9 +2936,9 @@ void do_formatter(void)
|
||||
#endif /* ENABLE_COLOR */
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Our own version of "wc". Note that its character counts are in
|
||||
/* Our own version of "wc". Note that the character count is in
|
||||
* multibyte characters instead of single-byte characters. */
|
||||
void do_wordlinechar_count(void)
|
||||
void count_lines_words_and_characters(void)
|
||||
{
|
||||
linestruct *was_current = openfile->current;
|
||||
size_t was_x = openfile->current_x;
|
||||
@@ -2983,7 +2977,7 @@ void do_wordlinechar_count(void)
|
||||
* incrementing the word count for each successful step. */
|
||||
while (openfile->current->lineno < botline->lineno ||
|
||||
(openfile->current == botline && openfile->current_x < bot_x)) {
|
||||
if (do_next_word(FALSE, TRUE))
|
||||
if (do_next_word(FALSE))
|
||||
words++;
|
||||
}
|
||||
|
||||
@@ -3006,12 +3000,19 @@ void do_verbatim_input(void)
|
||||
size_t count = 1;
|
||||
char *bytes;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* When barless and with cursor on bottom row, make room for the feedback. */
|
||||
if (ISSET(ZERO) && openfile->current_y == editwinrows - 1 && LINES > 1) {
|
||||
edit_scroll(FORWARD);
|
||||
edit_refresh();
|
||||
}
|
||||
#endif
|
||||
/* TRANSLATORS: Shown when the next keystroke will be inserted verbatim. */
|
||||
statusline(INFO, _("Verbatim Input"));
|
||||
place_the_cursor();
|
||||
|
||||
/* Read in the first one or two bytes of the next keystroke. */
|
||||
bytes = get_verbatim_kbinput(edit, &count);
|
||||
bytes = get_verbatim_kbinput(midwin, &count);
|
||||
|
||||
/* When something valid was obtained, unsuppress cursor-position display,
|
||||
* insert the bytes into the edit buffer, and blank the status bar. */
|
||||
@@ -3059,7 +3060,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 +3069,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 +3162,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 +3194,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"));
|
||||
|
||||
61
src/utils.c
61
src/utils.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* utils.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2022 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2016, 2017, 2019 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -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 */
|
||||
|
||||
@@ -288,34 +282,26 @@ const char *strstrwrapper(const char *haystack, const char *needle,
|
||||
return mbstrcasestr(start, needle);
|
||||
}
|
||||
|
||||
/* This is a wrapper for the malloc() function that properly handles
|
||||
* things when we run out of memory. */
|
||||
/* Allocate the given amount of memory and return a pointer to it. */
|
||||
void *nmalloc(size_t howmuch)
|
||||
{
|
||||
void *r = malloc(howmuch);
|
||||
void *section = malloc(howmuch);
|
||||
|
||||
if (howmuch == 0)
|
||||
die("Allocating zero bytes. Please report a bug.\n");
|
||||
|
||||
if (r == NULL)
|
||||
if (section == NULL)
|
||||
die(_("Nano is out of memory!\n"));
|
||||
|
||||
return r;
|
||||
return section;
|
||||
}
|
||||
|
||||
/* This is a wrapper for the realloc() function that properly handles
|
||||
* things when we run out of memory. */
|
||||
void *nrealloc(void *ptr, size_t howmuch)
|
||||
/* Reallocate the given section of memory to have the given size. */
|
||||
void *nrealloc(void *section, size_t howmuch)
|
||||
{
|
||||
void *r = realloc(ptr, howmuch);
|
||||
section = realloc(section, howmuch);
|
||||
|
||||
if (howmuch == 0)
|
||||
die("Allocating zero bytes. Please report a bug.\n");
|
||||
|
||||
if (r == NULL)
|
||||
if (section == NULL)
|
||||
die(_("Nano is out of memory!\n"));
|
||||
|
||||
return r;
|
||||
return section;
|
||||
}
|
||||
|
||||
/* Return an appropriately reallocated dest string holding a copy of src.
|
||||
@@ -355,14 +341,12 @@ char *free_and_assign(char *dest, char *src)
|
||||
return src;
|
||||
}
|
||||
|
||||
/* When not in softwrap mode, nano scrolls horizontally within a line in
|
||||
* chunks (a bit smaller than the chunks used in softwrapping). Return the
|
||||
* column number of the first character displayed in the edit window when the
|
||||
* cursor is at the given column. Note that (0 <= column -
|
||||
* get_page_start(column) < COLS). */
|
||||
/* When not softwrapping, nano scrolls the current line horizontally by
|
||||
* chunks ("pages"). Return the column number of the first character
|
||||
* displayed in the edit window when the cursor is at the given column. */
|
||||
size_t get_page_start(size_t column)
|
||||
{
|
||||
if (column + 2 < editwincols || ISSET(SOFTWRAP) || column == 0)
|
||||
if (column == 0 || column + 2 < editwincols || ISSET(SOFTWRAP))
|
||||
return 0;
|
||||
else if (editwincols > 8)
|
||||
return column - 6 - (column - 6) % (editwincols - 8);
|
||||
@@ -437,9 +421,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++;
|
||||
}
|
||||
|
||||
|
||||
895
src/winio.c
895
src/winio.c
File diff suppressed because it is too large
Load Diff
@@ -36,13 +36,12 @@ pkgdata_DATA = asm.nanorc \
|
||||
tcl.nanorc \
|
||||
tex.nanorc \
|
||||
texinfo.nanorc \
|
||||
xml.nanorc
|
||||
xml.nanorc \
|
||||
yaml.nanorc
|
||||
|
||||
nobase_pkgdata_DATA = \
|
||||
extra/ada.nanorc \
|
||||
extra/debian.nanorc \
|
||||
extra/fortran.nanorc \
|
||||
extra/gentoo.nanorc \
|
||||
extra/haskell.nanorc \
|
||||
extra/povray.nanorc \
|
||||
extra/spec.nanorc
|
||||
|
||||
@@ -8,11 +8,11 @@ color red "\<[A-Z_]{2,}\>"
|
||||
color brightgreen "\.(data|subsection|text)"
|
||||
color green "\.(align|file|globl|global|hidden|section|size|type|weak)"
|
||||
color brightyellow "\.(ascii|asciz|byte|double|float|hword|int|long|short|single|struct|word)"
|
||||
color brightred "^[[:space:]]*[.0-9A-Za-z_]*:"
|
||||
color brightcyan "^[[:space:]]*#[[:space:]]*(define|undef|include|ifn?def|endif|elif|else|if|warning|error)"
|
||||
color brightred "^[[:blank:]]*[.0-9A-Za-z_]*:"
|
||||
color brightcyan "^[[:blank:]]*#[[:blank:]]*(define|undef|include|ifn?def|endif|elif|else|if|warning|error)"
|
||||
|
||||
# Strings.
|
||||
color brightyellow "<[^= ]*>" ""(\\.|[^"])*""
|
||||
# Strings and names of included files.
|
||||
color brightyellow ""([^"\]|\\.)*"|<[^= ]*>"
|
||||
|
||||
# Comments.
|
||||
color brightblue "//.*"
|
||||
|
||||
@@ -17,13 +17,13 @@ color cyan "\<[[:upper:]_[:digit:]]+\>"
|
||||
color red "\<[-_.0-9]+\>"
|
||||
|
||||
# Strings:
|
||||
color red ""[^"]*"" "'[^']*'"
|
||||
color red ""[^"]*"|'[^']*'"
|
||||
|
||||
# Backticks:
|
||||
color green "`[^`]*`"
|
||||
|
||||
# Error lines:
|
||||
color brightred "^[[:space:]]*\*\*\*.*"
|
||||
color brightred "^[[:blank:]]*\*\*\*.*"
|
||||
|
||||
# Brackets:
|
||||
color magenta "\[|\]|\(|\)"
|
||||
|
||||
@@ -29,9 +29,9 @@ color magenta "\<(and|compl|lshift|or|rshift|xor)\>"
|
||||
color magenta "\<(bindtextdomain|dcgettext|dcngettext)\>"
|
||||
|
||||
# Strings.
|
||||
color brightyellow "<[^= ]*>" ""(\\.|[^"])*""
|
||||
color brightyellow ""([^"\]|\\.)*""
|
||||
# Comments.
|
||||
color brightblue "(^|[[:space:]])#.*$"
|
||||
color brightblue "(^|[[:blank:]])#.*"
|
||||
|
||||
# Trailing whitespace.
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
@@ -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)\>"
|
||||
@@ -22,18 +23,17 @@ color brightyellow "\<(try|throw|catch|operator|new|delete)\>"
|
||||
color magenta "\<(break|continue|goto|return)\>"
|
||||
|
||||
# Single-quoted stuff (characters, backslash escapes, hex and octal byte codes).
|
||||
color brightmagenta "'([^'\]|\\(["'\abfnrtv]|x[0-9A-Fa-f]{1,2}|[0-3]?[0-7]{1,2}))'"
|
||||
color brightmagenta "'([^'\]|\\(["'\abfnrtv]|x[[:xdigit:]]{1,2}|[0-3]?[0-7]{1,2}))'"
|
||||
|
||||
# GCC builtins.
|
||||
color cyan "__attribute__[[: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:]=]*>"
|
||||
# Strings and names of included files.
|
||||
color brightyellow ""([^"]|\\")*"|#[[:blank:]]*include[[:blank:]]*<[^>]+>"
|
||||
|
||||
# Preprocessor directives.
|
||||
color brightcyan start="^[[:space:]]*#[[:space:]]*(if(n?def)?|elif|warning|error|pragma)\>" end="(\`|[^\\])$"
|
||||
color brightcyan "^[[:space:]]*#[[:space:]]*((define|else|endif|include(_next)?|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,13 +13,13 @@ color red "^(19|20)[0-9-]{8}"
|
||||
color yellow "<[^>]*@[^>]*>"
|
||||
|
||||
# Command-line options.
|
||||
color cyan "[[:space:]]-[a-zA-Z\$]" "--[8a-z-]+"
|
||||
color cyan "[[:blank:]]-[a-zA-Z\$]|--[8a-z-]+"
|
||||
# Bug and patch numbers.
|
||||
color cyan "(BZ|bug|patch)[ ]#[0-9]+" "PR [[:alnum:]]+/[0-9]+"
|
||||
color cyan "(BZ|bug|patch)[ ]#[0-9]+|PR [[:alnum:]]+/[0-9]+"
|
||||
# Probable constants, for variety.
|
||||
color brightred "\<[A-Z_][0-9A-Z_]+\>"
|
||||
# Key sequences.
|
||||
color brightblue "\^[A-Z^\]" "\<M-." "\<F1?[0-9]" "(\^|M-)Space"
|
||||
color brightblue "\^[A-Z^\]|\<M-.|\<F1?[0-9]|(\^|M-)Space"
|
||||
|
||||
# Changed files.
|
||||
color magenta start="^( | {8})\* " end="(:( |$)|^$)"
|
||||
|
||||
@@ -3,17 +3,20 @@
|
||||
syntax cmake "(CMakeLists\.txt|\.cmake)$"
|
||||
comment "#"
|
||||
|
||||
color green "^[[:space:]]*[0-9A-Za-z_]+"
|
||||
icolor brightyellow "^[[:space:]]*(include|include_directories|include_external_msproject)\>"
|
||||
color green "^[[:blank:]]*[0-9A-Za-z_]+"
|
||||
icolor brightyellow "^[[:blank:]]*(include|include_directories|include_external_msproject)\>"
|
||||
|
||||
icolor brightgreen "^[[:space:]]*((else|end)?if|else|(end)?while|(end)?foreach|break)\>"
|
||||
color brightgreen "\<(NOT|COMMAND|POLICY|TARGET|EXISTS|IS_(DIRECTORY|ABSOLUTE)|DEFINED)[[:space:]]"
|
||||
color brightgreen "[[:space:]](OR|AND|IS_NEWER_THAN|MATCHES|(STR|VERSION_)?(LESS|GREATER|EQUAL))[[:space:]]"
|
||||
icolor brightgreen "^[[:blank:]]*((else|end)?if|else|(end)?while|(end)?foreach|break)\>"
|
||||
color brightgreen "\<(NOT|COMMAND|POLICY|TARGET|EXISTS|IS_(DIRECTORY|ABSOLUTE)|DEFINED)[[:blank:]]"
|
||||
color brightgreen "[[:blank:]](OR|AND|IS_NEWER_THAN|MATCHES|(STR|VERSION_)?(LESS|GREATER|EQUAL))[[:blank:]]"
|
||||
|
||||
icolor brightred "^[[:space:]]*((end)?(function|macro)|return)"
|
||||
icolor brightred "^[[:blank:]]*((end)?(function|macro)|return)"
|
||||
|
||||
icolor cyan start="\$(ENV)?\{" end="\}"
|
||||
color magenta "\<(APPLE|UNIX|WIN32|CYGWIN|BORLAND|MINGW|MSVC(_IDE|60|71|80|90)?)\>"
|
||||
|
||||
color brightblue "(^|[[:space:]])#.*"
|
||||
# Comments.
|
||||
color brightblue "(^|[[:blank:]])#.*"
|
||||
|
||||
# Trailing whitespace.
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
@@ -4,17 +4,17 @@ syntax css "\.css$"
|
||||
comment "/*|*/"
|
||||
|
||||
# First make everything red:
|
||||
color brightred "."
|
||||
color brightred "."
|
||||
# Then everything between braces yellow:
|
||||
color brightyellow start="\{" end="\}"
|
||||
color brightyellow start="\{" end="\}"
|
||||
# Then everything after a colon white:
|
||||
color brightwhite start=":" end="([;^{]|$)"
|
||||
color brightwhite start=":" end="([;^{]|$)"
|
||||
|
||||
# Pseudo-classes:
|
||||
color brightcyan ":(active|checked|focus|hover|link|visited|after|before)\>"
|
||||
color brightcyan ":(active|checked|focus|hover|link|visited|after|before)\>"
|
||||
|
||||
# Comments:
|
||||
color brightblue start="/\*" end="\*/"
|
||||
color brightblue start="/\*" end="\*/"
|
||||
|
||||
# Syntactic characters:
|
||||
color green ";|:|\{|\}"
|
||||
color green ";|:|\{|\}"
|
||||
|
||||
@@ -4,20 +4,27 @@
|
||||
syntax default
|
||||
comment "#"
|
||||
|
||||
# Comments.
|
||||
color cyan "^[[:space:]]*#.*"
|
||||
|
||||
# Spaces in front of tabs.
|
||||
color ,red " + +"
|
||||
|
||||
# Nano's name, including version.
|
||||
color brightred "(GNU )?[Nn]ano [1-5]\.[0-9][-.[:alnum:]]*\>"
|
||||
# Nano's release motto, then name plus version.
|
||||
color italic,lime "\<[Nn]ano [1-6]\.[0-9][-.[:alnum:]]* "[^"]+""
|
||||
color brightred "\<(GNU )?[Nn]ano [1-6]\.[0-9][-.[:alnum:]]*\>"
|
||||
|
||||
# Dates
|
||||
color latte "\<[12][0-9]{3}\.(0[1-9]|1[012])\.(0[1-9]|[12][0-9]|3[01])\>"
|
||||
|
||||
# Email addresses.
|
||||
color magenta "<[[:alnum:].%_+-]+@[[:alnum:].-]+\.[[:alpha:]]{2,}>"
|
||||
|
||||
# URLs.
|
||||
color lightblue "\<https?://\S+\.\S+[^[:space:],.)]"
|
||||
|
||||
# Bracketed captions in certain config files.
|
||||
color brightgreen "^\[[^][]+\]$"
|
||||
|
||||
# Comments.
|
||||
color cyan "^[[:blank:]]*#.*"
|
||||
|
||||
# Control codes.
|
||||
color latte "[[:cntrl:]]"
|
||||
color orange "[[:cntrl:]]"
|
||||
|
||||
@@ -28,6 +28,6 @@ color brightred "\<(t|nil)\>"
|
||||
color blue ":(\w|[?-])+"
|
||||
# Strings
|
||||
color yellow start="^[[:blank:]]+"" end="[^\]""
|
||||
color yellow ""(\\.|[^"])*""
|
||||
color yellow ""([^"\]|\\.)*""
|
||||
# Comments
|
||||
color cyan "(^|[[:space:]]);.*"
|
||||
color cyan "(^|[[:blank:]]);.*"
|
||||
|
||||
@@ -11,7 +11,7 @@ color yellow "^> ?> ?>.*"
|
||||
color brightmagenta "<[^@]+@[^@]+>"
|
||||
|
||||
# URLs.
|
||||
color brightblue "(https?|ftp)://\S+\.\S+[^\s.)]"
|
||||
color brightblue "(https?|ftp)://\S+\.\S+[^[:space:].)]"
|
||||
|
||||
# Signatures, even quoted ones.
|
||||
color yellow start="^>* ?-- $" end="^>* ?$"
|
||||
|
||||
@@ -30,7 +30,7 @@ color cyan "'[[:alnum:]]+"
|
||||
color green "\<[0-9][0-9A-Fa-f_#.+-]*"
|
||||
|
||||
# Characters / Strings
|
||||
color red "'.'" ""[^"]*""
|
||||
color red "'.'|"[^"]*""
|
||||
|
||||
# Comments
|
||||
color brightblue "--.*"
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
## Syntax highlighting for apt's sources.list.
|
||||
|
||||
syntax sources.list "sources\.list(\.d/.*\.list)?(~|\.old|\.save)?$"
|
||||
comment "#"
|
||||
|
||||
# Coloring the deb lines, working from tail to head. First the
|
||||
# components -- well, everything, and thus also the components.
|
||||
color brightmagenta "^deb.*"
|
||||
# Distribution -- well, everything, except the components.
|
||||
color brightred "^deb(-src)?\s+.*((ftp|https?|rsh|ssh|copy|file|spacewalk|tor):/\S+|cdrom:\[.+\]/)\s+\S+"
|
||||
# URIs.
|
||||
color brightgreen "^deb(-src)?\s+.*(ftp|https?|rsh|ssh|copy|file|spacewalk|tor):/\S+"
|
||||
# CDroms.
|
||||
color brightgreen "^deb(-src)?\s+.*cdrom:\[.+\]/"
|
||||
# Options.
|
||||
color brightcyan "^deb(-src)?\s+\[.+\]\s+"
|
||||
# And finally the initial deb tag.
|
||||
color yellow "^deb(-src)?"
|
||||
|
||||
# Comments.
|
||||
color brightblue "#.*"
|
||||
@@ -34,7 +34,7 @@ icolor yellow "\<(.or.|repeat|select case|then|where|while)\>"
|
||||
icolor magenta "\<(continue|cycle|exit|go?to|result|return)\>"
|
||||
|
||||
# Strings.
|
||||
color yellow "<[^= ]*>" ""(\\.|[^"])*""
|
||||
color yellow ""([^"\]|\\.)*""
|
||||
|
||||
# Comments.
|
||||
color blue "!.*"
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
## Syntax highlighting for Gentoo ebuilds/eclasses,
|
||||
## and (further down) for Portage control files.
|
||||
|
||||
syntax ebuild "\.e(build|class|blit)$"
|
||||
comment "#"
|
||||
|
||||
## All the standard portage functions:
|
||||
color brightgreen "(^|\<default_)src_(unpack|prepare|configure|compile|install|test)\>"
|
||||
color brightgreen "^pkg_(config|nofetch|info|pretend|setup|(pre|post)(inst|rm))\>"
|
||||
color brightgreen "\<default(_pkg_nofetch|_src_(unpack|prepare|configure|compile|test))?\>"
|
||||
## Bash-related syntax:
|
||||
color green "\<(break|case|continue|do|done|elif|else|esac|exit|fi|for|function|if|in|read|return|select|shift|then|time|until|while)\>"
|
||||
color green "\<(declare|eval|exec|export|let|local)\>"
|
||||
color green "[{}():;|`$<>!=&\\]" "(\]|\[)"
|
||||
color green "-[defhnrsuwxzL]\>"
|
||||
color green "-(eq|ne|gt|lt|ge|le)\>"
|
||||
## Variables... official portage ones in red, all others in bright red:
|
||||
color brightred "\$[-0-9@*#?$!]" "\$[[:alpha:]_][[:alnum:]_]*"
|
||||
color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:digit:]]|@)+\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
|
||||
color red "\<(EAPI|ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|[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 "\<(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(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 "\<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 "\<tc-get(BUILD_)?(AR|AS|CC|CPP|CXX|LD|NM|OBJCOPY|PKG_CONFIG|RANLIB)\>"
|
||||
color brightblue "\<tc-(arch(-kernel)?|export|has-(tls|openmp))\>"
|
||||
## Common commands used in ebuilds:
|
||||
color blue "\<(awk|cat|cd|chmod|chown|cp|echo|env|find|e?grep|ln|make|mkdir|mv|popd|printf|pushd|rm|rmdir|sed|set|tar|touch|unset|xargs)\>"
|
||||
## Comments (doesn't work that well):
|
||||
color yellow "(^|[[:space:]])#.*"
|
||||
## Strings (doesn't work that well):
|
||||
color brightyellow ""(\\.|[^\"])*"" "'(\\.|[^'])*'"
|
||||
## Trailing space is bad!
|
||||
color ,green "[[:space:]]+$"
|
||||
## Mixed whitespace is also bad.
|
||||
color ,green " "
|
||||
|
||||
|
||||
syntax /etc/portage "\.(accept_keywords|env|keywords|mask|unmask|use)(/.+)?$"
|
||||
comment "#"
|
||||
|
||||
## Base text:
|
||||
color green ".+"
|
||||
## Likely version and slot numbers:
|
||||
color magenta "-[[:digit:].]+(_(alpha|beta|pre|rc|p)[[:digit:]]*)*(-r[[:digit:]]+)?([:[:space:]]|$)"
|
||||
color magenta ":[^[:space:]]+([[:space:]]|$)"
|
||||
## Use flags (must come after version/slot):
|
||||
color brightred "[[:space:]]+\+?[A-Za-z0-9+_@-]+"
|
||||
color brightblue "[[:space:]]+-[A-Za-z0-9+_@-]+"
|
||||
## Accepted arches:
|
||||
color white "[~-]?\<(alpha|amd64|arm(64)?|hppa|ia64|m68k|mips|nios2|ppc(64)?|riscv|s390|sh|sparc|x86)(-(aix|(f|free|net|open)bsd|cygwin|hpux|interix|linux|macos|mint|solaris|winnt))?\>"
|
||||
color white "[[:space:]][*~-]?\*"
|
||||
## Categories:
|
||||
color cyan "^[[:space:]]*[^/]*/"
|
||||
## Masking regulators:
|
||||
color brightmagenta "^[[:space:]]*(=|~|<|<=|>|>=)"
|
||||
## Comments:
|
||||
color yellow "#.*"
|
||||
## Trailing space is bad!
|
||||
color ,green "[[:space:]]+$"
|
||||
## Mixed whitespace is also bad.
|
||||
color ,green " "
|
||||
@@ -28,9 +28,9 @@ color magenta "\<(Bounded|Data|Enum|Eq|Floating|Fractional|Functor|Integral|Mona
|
||||
color brightred "undefined"
|
||||
|
||||
# Strings
|
||||
color yellow ""([^\"]|\\.)*""
|
||||
color yellow ""([^"\]|\\.)*""
|
||||
# Characters
|
||||
color brightyellow "'([^\']|\\.)'"
|
||||
color brightyellow "'([^'\]|\\.)'"
|
||||
|
||||
# Comments
|
||||
color green "--.*"
|
||||
|
||||
@@ -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)\>"
|
||||
@@ -26,24 +26,23 @@ color magenta "\<(break|continue|fallthrough|goto|return)\>"
|
||||
color brightcyan "\<(package|import)\>"
|
||||
|
||||
# Literals.
|
||||
color red "\<([1-9][0-9]*|0[0-7]*|0[xX][0-9A-Fa-f]+)\>"
|
||||
color red "\<(true|false|nil|iota|_)\>"
|
||||
color red "\<([1-9][0-9]*|0[0-7]*|0[xX][[:xdigit:]]+)\>"
|
||||
color red "\<[0-9]+\.[0-9]*([eE][+-]?[0-9]+)?i?\>"
|
||||
color red "\<[0-9]+[eE][+-]?[0-9]+i?\>"
|
||||
color red "\B\.[0-9]+([eE][+-]?[0-9]+)?i?\>"
|
||||
color red "\<[0-9]+i\>"
|
||||
|
||||
# Strings and characters; slightly fuzzy.
|
||||
color red "\<(true|false|nil|iota|_)\>"
|
||||
color red "'(\\.|[^'])+'"
|
||||
color red ""(\\.|[^"])*""
|
||||
color red start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
|
||||
color red ""([^"\]|\\.)*"|'([^'\]|\\.)+'"
|
||||
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:]]+$"
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
## Syntax highlighting for groff.
|
||||
|
||||
syntax groff "(/tmac\.[^/]+$|\.(m[ems]|rof|tmac)$)"
|
||||
syntax groff "\.(m[ems]|rof|tmac)$|/tmac\.[^/]+$"
|
||||
comment ".\""
|
||||
|
||||
# The argument of .ds or .nr
|
||||
# The setting of a string or register
|
||||
color cyan "^\.(ds|nr) [^[:space:]]*"
|
||||
# Single-character escapes
|
||||
color brightmagenta "\\."
|
||||
# The argument of \f or \s in the same color
|
||||
color brightmagenta "\\f(.|\(..)" "\\s(\+|\-)?[0-9]"
|
||||
# Newlines
|
||||
color brightmagenta "\\f(.|\(..)|\\s(\+|\-)?[0-9]"
|
||||
# References to registers
|
||||
color cyan "\\(\\)?n(.|\(..)"
|
||||
color cyan start="\\(\\)?n\[" end="]"
|
||||
# Requests
|
||||
color brightgreen "^\.[[:space:]]*[^[:space:]]*"
|
||||
color brightgreen "^\.[[:blank:]]*[^[:space:]]*"
|
||||
# Comments
|
||||
color yellow "^\.\\".*"
|
||||
# Strings
|
||||
# References to strings
|
||||
color green "\\(\\)?\*(.|\(..)"
|
||||
color green start="\\(\\)?\*\[" end="]"
|
||||
# Characters
|
||||
# Special characters
|
||||
color brightred "\\\(.."
|
||||
color brightred start="\\\[" end="]"
|
||||
# Macro arguments
|
||||
|
||||
@@ -11,14 +11,13 @@ color brightcyan "\<define(-macro|-module|-public|-syntax)?\>"
|
||||
# Quoted symbols
|
||||
color brightyellow "'\<(\w|-)+\>"
|
||||
# Chars
|
||||
color brightmagenta "#\\."
|
||||
color brightmagenta "#\\\w+\>"
|
||||
color brightmagenta "#\\(.|\w+)"
|
||||
# Booleans
|
||||
color brightred "(#t|#f)\>"
|
||||
# Keywords
|
||||
color blue "#?:(\w|[?-])+"
|
||||
# Strings
|
||||
color yellow start="^[[:blank:]]+"" end="[^\]""
|
||||
color yellow ""(\\.|[^"])*""
|
||||
color yellow ""([^"\]|\\.)*""
|
||||
# Comments
|
||||
color cyan "(^|[[:space:]]);.*"
|
||||
color cyan "(^|[[:blank:]]);.*"
|
||||
|
||||
@@ -25,7 +25,7 @@ color red "\<(rows(pan)?|rules|scheme|scope|scrolling|selected|shape|size|span|s
|
||||
color red "\<(tabindex|target|text|title|type|usemap|valign|value(type)?|vlink|vspace|width|xmlns|xml:space)="
|
||||
|
||||
# Strings:
|
||||
color green ""(\\.|[^"])*""
|
||||
color green ""([^"\]|\\.)*""
|
||||
|
||||
# Comments:
|
||||
color yellow start="<!--" end="-->"
|
||||
|
||||
@@ -12,14 +12,14 @@ color brightyellow "\<(await|export|import|throw|try|catch|finally|new|delete)\>
|
||||
color magenta "\<(break|continue|return|yield)\>"
|
||||
|
||||
# Octal/decimal and hexadecimal numbers.
|
||||
color cyan "\<([0-9]+|0x[0-9A-Fa-f]+)\>"
|
||||
color cyan "\<([0-9]+|0x[[:xdigit:]]+)\>"
|
||||
# Special values.
|
||||
color cyan "\<(true|false|null|undefined)\>"
|
||||
|
||||
# Strings.
|
||||
color brightmagenta ""(\\.|[^"])*"" "'(\\.|[^'])*'" "`(\\.|[^`])*`"
|
||||
color brightmagenta ""([^"\]|\\.)*"|'([^'\]|\\.)*'|`([^`\]|\\.)*`"
|
||||
# Comments.
|
||||
color brightblue "(^|[[:space:]])//.*"
|
||||
color brightblue "(^|[[:blank:]])//.*"
|
||||
color brightblue start="/\*" end="\*/"
|
||||
|
||||
# Trailing whitespace.
|
||||
|
||||
@@ -8,26 +8,25 @@ 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:]]*"#[[:xdigit:]]+""
|
||||
# Escapes.
|
||||
color green "\\\\" "\\"" "\\[bfnrt]" "\\u[0-9abcdefABCDEF]{4})"
|
||||
color green "\\(["\/bfnrt]|u[[:xdigit:]]{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 "\[" "\]"
|
||||
color brightred "\{" "\}"
|
||||
color brightred "," ":"
|
||||
color brightblue "[][]"
|
||||
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)\>"
|
||||
@@ -45,7 +45,7 @@ color brightmagenta "\<(false|nil|true)\>"
|
||||
|
||||
# Decimal and hexadecimal numbers
|
||||
color red "\<[0-9]+(\.[0-9]*)?([Ee][+-]?[0-9]+)?\>"
|
||||
color red "\<0x[0-9A-Fa-f]+(\.[0-9A-Fa-f]*)?([Pp][+-]?[0-9]+)?\>"
|
||||
color red "\<0x[[:xdigit:]]+(\.[[:xdigit:]]*)?([Pp][+-]?[0-9]+)?\>"
|
||||
|
||||
# Brackets
|
||||
color brightmagenta "\(|\)|\[|\]|\{|\}"
|
||||
@@ -54,7 +54,7 @@ color brightmagenta "\(|\)|\[|\]|\{|\}"
|
||||
color brightcyan "^#!.*"
|
||||
|
||||
# Strings
|
||||
color red ""(\\.|[^"\])*"|'(\\.|[^'\])*'"
|
||||
color red ""([^"\]|\\.)*"|'([^'\]|\\.)*'"
|
||||
|
||||
# Simple comments and multiline comments
|
||||
color green "--.*"
|
||||
|
||||
@@ -18,7 +18,7 @@ color blue "\$+[{(][a-zA-Z0-9_-]+[})]"
|
||||
color brightblue "^[^ ]+:"
|
||||
|
||||
# Comments.
|
||||
color green "(^|[[:space:]]+)#.*"
|
||||
color green "(^|[[:blank:]]+)#.*"
|
||||
|
||||
# Trailing whitespace.
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
@@ -6,10 +6,10 @@ comment ".\""
|
||||
|
||||
# Section headers, title line, and indented paragraphs.
|
||||
color green "^\.(SH|SS|TH) .*"
|
||||
color brightgreen "^\.(SH|SS|TH) " "^\.([HIT]P)"
|
||||
color brightgreen "^\.((SH|SS|TH) |[HIT]P)"
|
||||
# Type faces, and normal paragraphs.
|
||||
color brightred "^\.(B[IR]?|I[BR]?|R[BI]|S[BM]) .*"
|
||||
color brightblue "^\.(B[IR]?|I[BR]?|R[BI]|S[BM]) " "^\.([LP]?P)$"
|
||||
color brightblue "^\.((B[IR]?|I[BR]?|R[BI]|S[BM]) |[LP]?P$)"
|
||||
# Inline type faces.
|
||||
color magenta "\\f[BIPR]"
|
||||
# Relative margins, hyperlinks, and various other stuff.
|
||||
|
||||
@@ -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-)'"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user