Compare commits
491 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d6b5c13281 | |||
|
|
ef35ea72cf | ||
|
|
8804b6dcd4 | ||
|
|
86b8388889 | ||
|
|
812c48dde4 | ||
|
|
f0f1c94afa | ||
|
|
75b312ded1 | ||
|
|
e65b0ba654 | ||
|
|
d3dd403dc7 | ||
|
|
7f4c2c6a25 | ||
| 4fefb91028 | |||
|
|
cb1b3a28ab | ||
|
|
f7d8735b6b | ||
|
|
fc42ab9b46 | ||
|
|
7f17777a4b | ||
|
|
bcdb27416c | ||
|
|
15c6396d42 | ||
|
|
2c19345e58 | ||
|
|
69a7dd86ec | ||
| 1c4bfb6446 | |||
|
|
fdcafb83e3 | ||
|
|
b8ead3b511 | ||
|
|
ffff664918 | ||
|
|
bf984ecb9b | ||
|
|
f1e238a9af | ||
|
|
5290a85afd | ||
| 070b784a49 | |||
|
|
b5157dd9cb | ||
|
|
94812d17c8 | ||
|
|
7681090c12 | ||
|
|
866490c41f | ||
|
|
0662fc4d42 | ||
|
|
078d612b9e | ||
|
|
26025f79ce | ||
|
|
1c307bc1be | ||
|
|
7abddbd752 | ||
|
|
51c9f7270c | ||
|
|
b896670e85 | ||
|
|
69dd0c40bb | ||
|
|
c374c773ad | ||
| 18eb6bae01 | |||
|
|
2fd7888a51 | ||
|
|
d19915ea44 | ||
|
|
549e37d218 | ||
|
|
7b48a9f671 | ||
|
|
344db835e4 | ||
|
|
04353acccf | ||
|
|
c33f0b7d8d | ||
|
|
fd51fee424 | ||
|
|
c8b44816fe | ||
|
|
6e88389fb8 | ||
|
|
298447e22d | ||
|
|
a3c7de8a50 | ||
|
|
264f305d94 | ||
|
|
f8ec08a928 | ||
| b5809f3793 | |||
|
|
f09e6c183e | ||
|
|
3791ed86a3 | ||
|
|
7f772693eb | ||
|
|
5771f1ea14 | ||
|
|
0f4db1ed0d | ||
| 9980a98607 | |||
|
|
4b35626aec | ||
|
|
846588ee81 | ||
|
|
4f92b12a6a | ||
|
|
4b4b20f8a9 | ||
|
|
e26fe9bddd | ||
|
|
972be2df04 | ||
|
|
374cb6a7f8 | ||
|
|
923d6300ad | ||
| 442bd49137 | |||
|
|
baa4edc6ca | ||
|
|
9875311bcc | ||
|
|
c3a453512a | ||
|
|
e413ed8e1d | ||
|
|
858f411447 | ||
|
|
19c8cea8e5 | ||
| 263c7fefbf | |||
|
|
1ae10b1487 | ||
|
|
35cde9f8d7 | ||
|
|
d4d2840f5d | ||
|
|
119ec47072 | ||
|
|
ceb305a780 | ||
|
|
1dc2a75cb6 | ||
|
|
8d7b716ea7 | ||
|
|
034af70a65 | ||
|
|
162c213e7b | ||
|
|
6fde7d8a51 | ||
|
|
e4abef5768 | ||
|
|
3922b531a8 | ||
|
|
0d1438a731 | ||
|
|
7eb66d3e09 | ||
|
|
c7a600063d | ||
|
|
5b654ce9fb | ||
|
|
98e9a881c0 | ||
|
|
f420f7c177 | ||
|
|
50954a4b6a | ||
|
|
567310e698 | ||
|
|
f90b710c9b | ||
|
|
bdaec3f934 | ||
|
|
8198fd9c58 | ||
|
|
358a10e3cc | ||
|
|
7b935e0d40 | ||
|
|
7034c3cc47 | ||
|
|
e30eadb4de | ||
|
|
3e3f4a167a | ||
|
|
c98528f8d3 | ||
|
|
75e5f885e5 | ||
|
|
40b9e68e02 | ||
|
|
e7491920fd | ||
|
|
9904aa5538 | ||
|
|
41b89aef8c | ||
|
|
3925c137a4 | ||
|
|
97fa42c82b | ||
|
|
ccabaac5a0 | ||
|
|
80f7852941 | ||
|
|
6243831dfb | ||
|
|
4f9abb52a4 | ||
|
|
7bab8780ad | ||
|
|
d0dc270eec | ||
|
|
cd9402075a | ||
|
|
b1f3bdfcbd | ||
|
|
541a2dbc88 | ||
| 02249f1655 | |||
|
|
d1e28417d5 | ||
|
|
9410a55679 | ||
|
|
25ceefbd89 | ||
|
|
a37c4bb59e | ||
|
|
ee1f8a0494 | ||
|
|
2c5459a1b7 | ||
|
|
b561c386c3 | ||
|
|
a374dd0359 | ||
|
|
aba4f4e0e2 | ||
|
|
210c94d82f | ||
|
|
c410ba4d42 | ||
|
|
f3738fe164 | ||
|
|
04a08fe6a5 | ||
|
|
69d33ec170 | ||
|
|
40a4225ed8 | ||
|
|
801622ce19 | ||
|
|
67750a30ba | ||
|
|
2f25b6a650 | ||
|
|
5a3bd329d6 | ||
|
|
8b4bf2bb8d | ||
|
|
2a515058be | ||
|
|
3785f762fc | ||
|
|
5cee9f183b | ||
|
|
958ec294b2 | ||
|
|
3a781fd719 | ||
|
|
f4a2e7efe2 | ||
|
|
027365503f | ||
|
|
e31d59ebc8 | ||
|
|
11178e14ab | ||
|
|
0bcbd0015f | ||
|
|
271bd5d3ba | ||
|
|
74d252a68f | ||
|
|
4b928b466a | ||
|
|
10b4d0c8ad | ||
|
|
433dd92196 | ||
|
|
78d284881c | ||
|
|
a36b726bde | ||
|
|
83629b9991 | ||
|
|
405c66e864 | ||
|
|
e5df84a9ed | ||
|
|
614a977259 | ||
|
|
f1651abdac | ||
|
|
05a06048fc | ||
|
|
c599bc9bff | ||
|
|
54ded4527a | ||
|
|
4f433cd601 | ||
|
|
accecb9863 | ||
|
|
079588cac5 | ||
|
|
1d10ee71bf | ||
|
|
0520cbdccb | ||
|
|
3d3270c1b2 | ||
|
|
b60a26d40b | ||
|
|
36fcdce886 | ||
|
|
b760388bbf | ||
|
|
bb18524cce | ||
|
|
05eaa0f0d7 | ||
| ac58a97a92 | |||
| 140f2d72cb | |||
|
|
d4a1dbd4a9 | ||
|
|
0e9bef3429 | ||
| b81dca5014 | |||
| 0ac593a9ce | |||
| 8daf175b09 | |||
|
|
34238dc119 | ||
| 49935c0456 | |||
| b145ce016b | |||
| 226108a59f | |||
| 01b30a5a0e | |||
| 05fa7110ec | |||
|
|
18a40caa48 | ||
|
|
1980f1b2ba | ||
|
|
ec0c13afda | ||
|
|
ed41b3cefa | ||
|
|
80a924edfa | ||
|
|
98f9518bf2 | ||
|
|
1de47610f4 | ||
|
|
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 |
4
AUTHORS
4
AUTHORS
@ -8,7 +8,9 @@ Chris Allegretta <chrisa@asty.org>
|
||||
Benno Schulenberg <bensberg@telfort.nl>
|
||||
* An array of small bug fixes, the cut-word and block-jump
|
||||
routines, text selection by holding Shift, macro recording
|
||||
and replay, plus some key bindings. Current maintainer.
|
||||
and replay, extra key bindings, the --indicator, --minibar,
|
||||
and --zero options, and braced functions in string binds.
|
||||
Current maintainer.
|
||||
|
||||
David Lawrence Ramsey <pooka109@gmail.com>
|
||||
* Former stable series maintainer. Multiple buffer support,
|
||||
|
||||
479
ChangeLog
479
ChangeLog
@ -1,3 +1,482 @@
|
||||
Changes between v7.1 and v7.2:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (11):
|
||||
bindings: let ^/ toggle between the 'search' and 'gotoline' menus
|
||||
bump version numbers and add a news item for the 7.2 release
|
||||
copyright: update the years for the FSF
|
||||
docs: give ^K and ^U some useful function in the alternative bindings
|
||||
docs: put the binding of ^Y after its unbinding, for it to be effective
|
||||
gnulib: update to its current upstream state
|
||||
input: disallow bracketed pastes when in view mode
|
||||
syntax: html: colorize specially the other two emphasizing tags too
|
||||
tweaks: avoid warnings when compiling with -Wpedantic
|
||||
tweaks: rewrap an old news item
|
||||
tweaks: separate a special thanks from the preceding ones
|
||||
|
||||
|
||||
Changes between v7.0 and v7.1:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (8):
|
||||
build: fix compilation when configured with --disable-comment
|
||||
bump version numbers and add a news item for the 7.1 release
|
||||
copyright: update the last year for significantly changed files
|
||||
docs: say thanks to the Albanian translator
|
||||
rcfile: report an error when an included file does not exist
|
||||
text: upon Enter, eat only lefthand blanks, not any other characters
|
||||
tweaks: avoid passing NULL to access()
|
||||
tweaks: wrap overlong lines in the Tcl syntax, to make them manageable
|
||||
|
||||
|
||||
Changes between v6.4 and v7.0:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (94):
|
||||
build: add options --disable-formatter and --disable-linter to configure
|
||||
build: exclude some pieces that are not needed with --disable-nanorc
|
||||
build: exclude two unneeded functions correctly from the tiny version
|
||||
build: fix compilation when configured with --enable-tiny
|
||||
bump version numbers and add a news item for the 7.0 release
|
||||
completion: search through all open buffers for possible completions
|
||||
docs: clarify the distinction between binding a function and "{function}"
|
||||
docs: describe --disable-formatter and --disable-linter configure options
|
||||
docs: explain how to include a double quote plus space in a nanorc regex
|
||||
docs: improve the legibility of an itemized list
|
||||
docs: mention in the man page how M-V can insert any Unicode code point
|
||||
docs: mention that string binds may contain function names between braces
|
||||
docs: replace control codes in the examples with {command} cartouches
|
||||
docs: suggest a key binding for snipping trailing blanks
|
||||
execute: show "Cancelled" instead of "Error" when the user hits ^C
|
||||
extra: use the whole terminal for the crawl, and quicken it a bit
|
||||
feedback: suppress undo/redo messages when option --zero is in effect
|
||||
files: before sending data to an external command, decode LF back to NUL
|
||||
files: improve the error handling when executing an external command
|
||||
filtering: terminate also the sender process when the user hits ^C
|
||||
filtering: when returning to a line number, ensure it is within range
|
||||
gnulib: update to its current upstream state
|
||||
goto: don't center the current line when the user specified a column only
|
||||
help: don't show the New-Buffer toggle when in view mode
|
||||
help: move the M-Del item up, so that M-PgUp and M-PgDn are paired
|
||||
help: prioritize the unshifted Meta keystrokes for buffer switching
|
||||
input: allocate a small keystroke buffer, and never free it
|
||||
input: allocate two small character buffers too, and never free them
|
||||
input: give up when the capacity of the keystroke buffer overflows
|
||||
input: interpret commands of the form {functionname} inside string binds
|
||||
memory: avoid a leak when a string bind specifies an unknown menu
|
||||
prompt: allow rebinding also ^N, ^Q, and ^Y at the yes-no prompt
|
||||
prompt: ingest queued characters before handling any subsequent function
|
||||
prompt: prevent execution of inadmissible functions in view mode
|
||||
prompt: return FALSE for non-editing functions also in the tiny version
|
||||
prompt: toggle the help lines only for the 'nohelp' toggle
|
||||
search: skip a match on the magic line, as it is a just convenience line
|
||||
startup: ensure that +/string centers the match also with --linenumbers
|
||||
startup: for +/string, center the found occurrence when possible
|
||||
startup: quit when standard input is not a TTY (after handling arguments)
|
||||
startup: report an empty search string also when there is a modifier
|
||||
syntax: nanorc: colorize valid function names plus surrounding braces
|
||||
tweaks: add parentheses for consistency, and reshuffle for conciseness
|
||||
tweaks: allow the linter to be used in view mode, as it makes no changes
|
||||
tweaks: attribute some of the features that were added in the last years
|
||||
tweaks: avoid iterating over the same string twice in a row
|
||||
tweaks: avoid sometimes calling a function three times in a row
|
||||
tweaks: check the multiline regexes only for Delete and Backspace
|
||||
tweaks: condense a comment, add two small ones, and reshuffle a line
|
||||
tweaks: delete a flag that is no longer used
|
||||
tweaks: determine in another way whether a shortcut is okay in view mode
|
||||
tweaks: discard a bracketed paste in the browser more efficiently
|
||||
tweaks: don't use a pointer when the value itself is all that is needed
|
||||
tweaks: drop an unneeded check for permissibility of prompt shortcuts
|
||||
tweaks: drop a parameter that is no longer used
|
||||
tweaks: drop shunting of flags by calling the needed function directly
|
||||
tweaks: elide a function that does not need to be a separate function
|
||||
tweaks: elide an assignment by iterating with the target variable
|
||||
tweaks: elide an intermediary variable that is no longer needed
|
||||
tweaks: elide an unused parameter
|
||||
tweaks: elide an unused return value
|
||||
tweaks: elide a parameter by moving the general case one level up
|
||||
tweaks: elide a variable, rename another, and reshuffle an assignment
|
||||
tweaks: fold two cases together, because they basically do the same
|
||||
tweaks: group the special keycodes for implanted strings together
|
||||
tweaks: improve two comments, and exclude two unneeded prototypes
|
||||
tweaks: make the crawl use the whole screen also in the tiny version
|
||||
tweaks: make two error messages more succinct and easier to translate
|
||||
tweaks: move the arrays of menu names and symbols to where they are used
|
||||
tweaks: move the --magic option up, so that --zero comes last
|
||||
tweaks: move to a given line number more efficiently
|
||||
tweaks: move two checks plus corresponding calls to a better place
|
||||
tweaks: normalize the indentation after the previous change
|
||||
tweaks: reduce four variations of a message to a single common form
|
||||
tweaks: rename a macro for clarity, and normalize some indentation
|
||||
tweaks: rename a variable, away from an abbreviation
|
||||
tweaks: rename two record elements and three parameters, for clarity
|
||||
tweaks: replace sizeof(char) with 1, as that is assumed anyway
|
||||
tweaks: reshuffle a declaration, and correct the wording of a comment
|
||||
tweaks: reshuffle a line, to group things better
|
||||
tweaks: reshuffle some code and drop some comments, for conciseness
|
||||
tweaks: reshuffle some code, to not determine a shortcut twice
|
||||
tweaks: reshuffle some lines, to be more readable instead of compact
|
||||
tweaks: reshuffle two lines, for conciseness and in preparation
|
||||
tweaks: reword and/or condense four comments
|
||||
tweaks: rewrap line, improve wording, and correct typo in old news item
|
||||
tweaks: rewrap some lines, drop a redundant call, and reshuffle a line
|
||||
tweaks: simplify a function now that a Unicode code can be typed quicker
|
||||
tweaks: simplify a pasting routine, modelling it after the injection one
|
||||
tweaks: use an auxiliary variable to avoid dereferences of 'shortcut'
|
||||
undo: make sure the current line is defined before it is referenced
|
||||
verbatim: allow the user to finish Unicode input with <Enter> or <Space>
|
||||
verbatim: do not overwrite the status bar when the code is invalid
|
||||
verbatim: don't show dots during Unicode input, as they give wrong idea
|
||||
|
||||
|
||||
Changes between v6.3 and v6.4:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (24):
|
||||
bump version numbers and add a news item for the 6.4 release
|
||||
display: remember text and column positions when softwrapping a line
|
||||
docs: concisely describe how the linter behaves
|
||||
docs: remove the two notices about the changed defaults
|
||||
docs: rename README.GIT to README.hacking, so it's clearer what is meant
|
||||
docs: stop mentioning the obsoleted keywords that were removed
|
||||
files: designate the root directory with a simple "/", not with "//"
|
||||
formatter: instead of leaving curses, use full_refresh() to wipe messages
|
||||
gnulib: update to its current upstream state
|
||||
help: reshuffle two shortcuts so that more help-line items are paired
|
||||
options: stop accepting -z, as --suspendable has been dropped too
|
||||
rcfile: remove five obsolete or deprecated keywords
|
||||
syntax: default: do not colorize a square or angle bracket after a URL
|
||||
syntax: perl: add missing keywords, and reduce the length of some lines
|
||||
syntax: python: mention an alternative linter in a comment
|
||||
tweaks: add a missing word to a news item
|
||||
tweaks: add a translator hint
|
||||
tweaks: improve a comment, and reshuffle two functions plus some lines
|
||||
tweaks: put each regex on separate line, to better show many keywords
|
||||
tweaks: rename a variable, to not be the same as a function name
|
||||
tweaks: rename two variables, to not contain the name of another
|
||||
tweaks: reshuffle a description and rewrap another
|
||||
tweaks: reshuffle a few lines, to group things better
|
||||
version: condense the copyright message, to not dominate the output
|
||||
|
||||
LIU Hao (1):
|
||||
build: ignore errors from `git describe`
|
||||
|
||||
|
||||
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:
|
||||
------------------------------
|
||||
|
||||
|
||||
11
IMPROVEMENTS
11
IMPROVEMENTS
@ -1,6 +1,17 @@
|
||||
Improvements in GNU nano
|
||||
========================
|
||||
|
||||
Since 7.0:
|
||||
- String binds may contain bindable function names between braces.
|
||||
- Word completion looks for candidates in all open buffers.
|
||||
- Unicode codes can be entered without leading zeroes.
|
||||
|
||||
Since 6.0:
|
||||
- Option --zero hides the interface and uses the whole terminal for editing.
|
||||
- Colors can be given also in #rgb hexadecimal, to select the nearest color
|
||||
from the 6x6x6 color-cube palette available on 256-color terminals.
|
||||
- Fourteen new color names are available, from rosy to crimson.
|
||||
|
||||
Since 5.0:
|
||||
- A search briefly spotlights the found text, in black on yellow by default.
|
||||
- Option --minibar reduces the interface to a bottom bar with basic info.
|
||||
|
||||
181
NEWS
181
NEWS
@ -1,3 +1,75 @@
|
||||
2023.01.18 - GNU nano 7.2 "Boer doe mij 't hekke lös!"
|
||||
• <Shift+Insert> is prevented from pasting in view mode.
|
||||
|
||||
2022.12.14 - GNU nano 7.1 "And the devices shall be made of wood"
|
||||
• When --autoindent and --breaklonglines are combined, pressing
|
||||
<Enter> at a specific position no longer eats characters.
|
||||
|
||||
2022.11.15 - GNU nano 7.0 "Una existencia simple bajo el sol"
|
||||
• String binds may contain bindable function names between braces.
|
||||
For example, to move the current line down to after the next one:
|
||||
bind ^D "{cut}{down}{paste}{up}" main. Of course, braced function
|
||||
names may be mixed with literal text. If an existing string bind
|
||||
contains a literal {, replace it with {{}.
|
||||
• Unicode codes can be entered (via M-V) without leading zeroes,
|
||||
by finishing short codes with <Space> or <Enter>.
|
||||
• Word completion (^]) looks for candidates in all open buffers.
|
||||
• No regular expression matches the final empty line any more.
|
||||
|
||||
|
||||
2022.08.02 - GNU nano 6.4 "Regentag Dunkelbunt Hundertwasser"
|
||||
• The file browser does not crash when moving up to the root folder.
|
||||
• Softwrapping very long lines is done more efficiently.
|
||||
• Invoking the formatter does not blink the screen.
|
||||
|
||||
2022.04.28 - GNU nano 6.3 "Wat zullen we drinken? Wat een dorst!"
|
||||
• For multiline regexes, text is now colored as soon as a start match
|
||||
is found, also when there is no end match at all.
|
||||
• The colorizing of any line is stopped after two thousand bytes,
|
||||
to avoid frustrating delays.
|
||||
• When environment variable NO_COLOR is set, the two default colors
|
||||
(yellow for the spotlight, red for error messages) are suppressed
|
||||
when no interface colors are specified in a nanorc file.
|
||||
• Full justification and piping the whole buffer through a command
|
||||
now keep the cursor at the same line number.
|
||||
• Utility 'xsel' can be used to copy a marked region to the system's
|
||||
clipboard. See doc/sample.nanorc for an example.
|
||||
|
||||
2022.02.18 - GNU nano 6.2 "Kamperfoelie"
|
||||
• The file browser clears the prompt bar also when using --minibar.
|
||||
• Linting now works also with a newer 'pyflakes'.
|
||||
|
||||
2022.02.09 - GNU nano 6.1 "Rețelele de socializare sunt ca un frigider"
|
||||
• The behavior of ^K at a prompt has been enhanced: when there is some
|
||||
text after the cursor, just this text is erased. In the most common
|
||||
situation, when the cursor is at the end of the answer, the behavior
|
||||
is as before: the whole answer is erased.
|
||||
• At a prompt, M-6 copies the current answer into the cutbuffer.
|
||||
• Large external pastes into nano are handled more quickly.
|
||||
|
||||
2021.12.15 - GNU nano 6.0 "Humor heeft ook zijn leuke kanten"
|
||||
• Option --zero hides the title bar, status bar and help lines, and
|
||||
uses all rows of the terminal as editing area. The title bar and
|
||||
status bar can be toggled with M-Z.
|
||||
• Colors can now be specified also as three-digit hexadecimal numbers,
|
||||
in the format #rgb. This picks from the 216 index colors (that most
|
||||
terminals know) the color that is nearest to the given values.
|
||||
• For users who dislike numbers, there are fourteen new color names:
|
||||
rosy, beet, plum, sea, sky, slate, teal, sage, brown, ocher, sand,
|
||||
tawny, brick, and crimson.
|
||||
• Suspension is enabled by default, invokable with ^T^Z. The options
|
||||
-z, --suspendable, and 'set suspendable' are obsolete and ignored.
|
||||
(In case you want to be able to suspend nano with a single keystroke,
|
||||
you can put 'bind ^Z suspend main' in your nanorc.)
|
||||
• When automatic hard-wrapping is in effect, pasting just a few words
|
||||
(without a line break) will now hard-wrap the line when needed.
|
||||
• Toggling Append or Prepend clears the current filename.
|
||||
• The word count as shown by M-D is now affected by option --wordbounds;
|
||||
with it, nano counts words as 'wc' does; without it (the new default),
|
||||
words are counted in a more human way: seeing punctuation as space.
|
||||
• The YAML syntax file is now actually included in the tarball.
|
||||
|
||||
|
||||
2021.10.06 - GNU nano 5.9 "El manicomio ha decidido: mañana sol!"
|
||||
• The extension of a filename is added to the name of a corresponding
|
||||
temporary file, so that spell checking a C file, for example, will
|
||||
@ -187,7 +259,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.
|
||||
|
||||
@ -729,22 +801,22 @@
|
||||
the undo implementation and the default syntax config are
|
||||
also included. As always, Share and Enjoy!
|
||||
|
||||
2014.05.28 - GNU nano 2.3.3 is in its right place. This release contains
|
||||
many many improvements to the core system, including
|
||||
substantial improvements to the undo/redo code, UTF-8
|
||||
handling, the configure script, and display of shortcuts
|
||||
on very wide terminals. New features include the
|
||||
ability to write to named pipes (--noread), as well as
|
||||
linter support (see the nanorc man page for details). Also
|
||||
included are much improved syntax highlighting code, and
|
||||
configurations for JSON, texinfo, Go, and a default syntax
|
||||
for catch-all highlighting. Finally, nano now has the
|
||||
ability to set the color of the title bar, status bar, and
|
||||
shortcut keys (e.g. "^X") and their descriptions. Again
|
||||
see the nanorc page for details. There's much more, too
|
||||
much to include here, but please keep those reports and
|
||||
general feedback coming! Thank you for helping us help
|
||||
you help us all.
|
||||
2014.05.28 - GNU nano 2.3.3 is in its right place. This release
|
||||
contains many many improvements to the core system,
|
||||
including substantial improvements to the undo/redo code,
|
||||
UTF-8 handling, the configure script, and display of
|
||||
shortcuts on very wide terminals. New features include
|
||||
the ability to write to named pipes (--noread), as well
|
||||
as linter support (see the nanorc man page for details).
|
||||
Also included are much improved syntax highlighting code,
|
||||
and configurations for JSON, texinfo, Go, and a default
|
||||
syntax for catch-all highlighting. Finally, nano now has
|
||||
the ability to set the color of the title bar, status bar,
|
||||
and shortcut keys (e.g. "^X") and their descriptions.
|
||||
Again see the nanorc page for details. There's much more,
|
||||
too much to include here, but please keep those reports
|
||||
and general feedback coming! Thank you for helping us
|
||||
help you help us all.
|
||||
|
||||
2013.03.22 - GNU nano 2.3.2 "Annoy your coworkers for fun and profit" is
|
||||
released. This release introduces vim-style file locking
|
||||
@ -883,13 +955,13 @@
|
||||
the command line will now override any related .nanorc
|
||||
entries. Speak now or forever hold your bugs!
|
||||
|
||||
2009.11.15 - GNU nano 2.1.99pre1 "take a bow" is out there, man, it's
|
||||
out there all right. This release contains mainly
|
||||
2009.11.15 - GNU nano 2.1.99pre1 "take a bow" is out there, man,
|
||||
it's out there all right. This release contains mainly
|
||||
bugfixes, underscoring that we are preparing for the
|
||||
next stable series release. Included are many fixes
|
||||
for the new soft wrapping code, compiler warning tweaks,
|
||||
and the modification time warning no longer triggers
|
||||
when saving a file as a new name. Also include are
|
||||
when saving a file with a new name. Also included are
|
||||
some fixes for various nanorc options, and there are
|
||||
surely more bugs to find before we call the code base
|
||||
stable, so please keep those reports coming!
|
||||
@ -1001,31 +1073,31 @@
|
||||
and not saving the search history when compiled with
|
||||
configure options.
|
||||
|
||||
2008.04.24 - GNU nano 2.1.2 "New York City" is released. This release
|
||||
contains fixes for binding bad keys, some
|
||||
configure-specific compilation failures, and more issues
|
||||
with the new input back end and in particular the status
|
||||
bar. Also fixed are some long-standing issues with
|
||||
compiling on AIX, and a segfault when making the terminal
|
||||
window too small. Rest in Peace Tim and George!
|
||||
2008.06.24 - GNU nano 2.1.2 "New York City" is released. This
|
||||
release contains fixes for binding bad keys, some
|
||||
configure-specific compilation failures, and more
|
||||
issues with the new input back end and in particular
|
||||
the status bar. Also fixed are some long-standing
|
||||
issues with compiling on AIX, and a segfault when
|
||||
making the terminal window too small. Rest in Peace
|
||||
Tim and George!
|
||||
|
||||
2008.04.01 - GNU nano 2.1.1 won't get fooled again. This release contains
|
||||
fixes for the new user-rebindable keys (in particular
|
||||
bracket match which was mis-bound), and various
|
||||
problems with translations and configure-related
|
||||
compilation problems are now fixed as well.
|
||||
It also contains new syntax highlighting
|
||||
definitions for TCL, PHP, Gentoo and Debian-related
|
||||
files, and some documentation updates as well.
|
||||
Please continue to send reports with the key
|
||||
binding code to the Savannah page
|
||||
(https://savannah.gnu.org/bugs/?group=nano).
|
||||
2008.04.01 - GNU nano 2.1.1 won't get fooled again. This release
|
||||
contains fixes for the new user-rebindable keys (in
|
||||
particular bracket match which was mis-bound), and
|
||||
various problems with translations and configure-
|
||||
related compilation problems are now fixed as well.
|
||||
It also contains new syntax highlighting definitions
|
||||
for Tcl, PHP, Gentoo and Debian-related files, and
|
||||
some documentation updates as well. Please continue to
|
||||
send reports with the key binding code to the Savannah
|
||||
page (https://savannah.gnu.org/bugs/?group=nano).
|
||||
|
||||
2008.03.18 - GNU nano 2.1.0 "under old mismanagement" is released.
|
||||
This first release in the 2.1 development series
|
||||
introduces rebindable keys for most actions inside
|
||||
the editor. Please see the nanorc(5) page for
|
||||
more information on configuring key bindings. Please
|
||||
the editor. Please see the nanorc(5) page for more
|
||||
information on configuring key bindings. Please
|
||||
also report all keybinding bugs (crashes, missing
|
||||
menu functions) using the Savannah bug tracker URL,
|
||||
https://savannah.gnu.org/bugs/?group=nano and
|
||||
@ -1786,22 +1858,21 @@
|
||||
to upgrade to this release.
|
||||
|
||||
2000.11.18 - Nano 0.9.20 is finally out the door. Probably the biggest
|
||||
change is the brand new way nano displays previous
|
||||
search and replace strings (they are now editable!)
|
||||
This is a break from Pico's (inconsistent) interface, so
|
||||
if you don't like the new way, "Pico" mode (-p on the
|
||||
command line or Meta-P within nano) still works the
|
||||
"old" way.
|
||||
change is the brand new way nano displays previous search
|
||||
and replace strings (they are now editable!) This is a
|
||||
break from Pico's (inconsistent) interface, so if you
|
||||
don't like the new way, "Pico" mode (-p on the command
|
||||
line or Meta-P within nano) still works the "old" way.
|
||||
Other new features include being able to deal with
|
||||
search strings of any length, a new internal spell
|
||||
feature (courtesy of Mr. Rocco Corsi) and tab completion
|
||||
when reading in or writing out files! There's also the
|
||||
usual billion or so bug fixes. Feedback on this release
|
||||
is welcome because so much has changed, especially with
|
||||
the previous string display in search and replace.
|
||||
Email -> nano@nano-editor.org <-. If you like
|
||||
something, don't like something, or just want to order a
|
||||
pizza, let us know!
|
||||
search strings of any length, a new internal spell feature
|
||||
(courtesy of Mr. Rocco Corsi) and tab completion when
|
||||
reading in or writing out files! There's also the usual
|
||||
billion or so bug fixes. Feedback on this release is
|
||||
welcome because so much has changed, especially with the
|
||||
previous string display in search and replace. Email
|
||||
-> nano@nano-editor.org <-. If you like something,
|
||||
don't like something, or just want to order a pizza,
|
||||
let us know!
|
||||
|
||||
2000.10.02 - Nano 0.9.19 is the "Chris is getting married in less than
|
||||
a week and needs a distraction" release. There are only
|
||||
|
||||
8
README
8
README
@ -15,7 +15,7 @@ Appearance
|
||||
In rough ASCII graphics, this is what nano's screen looks like:
|
||||
|
||||
____________________________________________________________________
|
||||
| GNU nano 5.9 filename Modified |
|
||||
| GNU nano 7.2 filename Modified |
|
||||
--------------------------------------------------------------------
|
||||
| This is the text window, displaying the contents of a 'buffer', |
|
||||
| the contents of the file you are editing. |
|
||||
@ -95,13 +95,13 @@ Mailing Lists
|
||||
|
||||
There are three nano-related mailing-lists.
|
||||
|
||||
+ info-nano@gnu.org is a very low traffic list used to announce
|
||||
* <info-nano@gnu.org> is a very low traffic list used to announce
|
||||
new nano versions or other important info about the project.
|
||||
|
||||
+ help-nano@gnu.org is for those seeking to get help without
|
||||
* <help-nano@gnu.org> is for those seeking to get help without
|
||||
wanting to hear about the technical details of its development.
|
||||
|
||||
+ nano-devel@gnu.org is the list used by the people that make nano
|
||||
* <nano-devel@gnu.org> is the list used by the people that make nano
|
||||
and a general development discussion list, with moderate traffic.
|
||||
|
||||
To subscribe, send email to <name>-request@gnu.org with a subject
|
||||
|
||||
@ -8,19 +8,18 @@ building this needs a bit more care than the official tarballs.
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
To successfully compile GNU nano from git, you'll need the following
|
||||
packages:
|
||||
To successfully compile GNU nano from git, you'll need the following:
|
||||
|
||||
- autoconf (version >= 2.69)
|
||||
- automake (version >= 1.14)
|
||||
- autopoint (version >= 0.18.3)
|
||||
- gcc (version >= 5.0)
|
||||
- gettext (version >= 0.18.3)
|
||||
- git (version >= 2.7.4)
|
||||
- groff (version >= 1.12)
|
||||
- make (any version)
|
||||
- pkg-config (version >= 0.22)
|
||||
- texinfo (version >= 4.0)
|
||||
autoconf (version >= 2.69)
|
||||
automake (version >= 1.14)
|
||||
autopoint (version >= 0.18.3)
|
||||
gcc (version >= 5.0)
|
||||
gettext (version >= 0.18.3)
|
||||
git (version >= 2.7.4)
|
||||
groff (version >= 1.12)
|
||||
make (any version)
|
||||
pkg-config (version >= 0.22)
|
||||
texinfo (version >= 4.0)
|
||||
|
||||
You will also need to have the header files for ncurses installed,
|
||||
from libncurses-dev on Debian, ncurses-devel on Fedora, or similar.
|
||||
@ -29,14 +28,14 @@ These should all be available in your distro's package manager or
|
||||
software center, or otherwise on any GNU mirror.
|
||||
|
||||
|
||||
Download the source
|
||||
-------------------
|
||||
Clone the source
|
||||
----------------
|
||||
|
||||
To obtain the current nano development branch (called 'master'), use the
|
||||
following command. It will create in your current working directory a
|
||||
subdirectory called 'nano' containing a copy of all of the files:
|
||||
|
||||
$ git clone git://git.savannah.gnu.org/nano.git nano
|
||||
$ git clone git://git.savannah.gnu.org/nano.git
|
||||
|
||||
|
||||
Generate the configure script
|
||||
@ -84,6 +83,7 @@ Problems?
|
||||
Please submit any bugs you find in the code in git via the bug tracker
|
||||
on Savannah (https://savannah.gnu.org/bugs/?group=nano).
|
||||
|
||||
|
||||
Contributing something
|
||||
----------------------
|
||||
|
||||
4
THANKS
4
THANKS
@ -6,8 +6,9 @@ Translations:
|
||||
============
|
||||
Pedro Albuquerque <palbuquerque73@gmail.com> Portuguese
|
||||
Josef Andersson <josef.andersson@fripost.org> Swedish
|
||||
Laurentiu Buzdugan <buzdugan@voyager.net> Romanian
|
||||
Mario Blättermann <mario.blaettermann@gmail.com> German
|
||||
Besnik Bleta <besnik@programeshqip.org> Albanian
|
||||
Laurențiu Buzdugan <buzdugan@voyager.net> Romanian
|
||||
Ricardo Cárdenes Medina <ricardo@conisys.com> Spanish
|
||||
Antonio Ceballos <aceballos@gmail.com> Spanish
|
||||
Wei-Lun CHAO <chaoweilun@pcmail.com.tw> Chinese (traditional)
|
||||
@ -75,6 +76,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
|
||||
|
||||
26
autogen.sh
26
autogen.sh
@ -2,7 +2,7 @@
|
||||
# Generate configure & friends for GIT users.
|
||||
|
||||
gnulib_url="git://git.sv.gnu.org/gnulib.git"
|
||||
gnulib_hash="9aca7b67333fd0a90bf56104325ce96199644451"
|
||||
gnulib_hash="2cf7f442f52f70b3df6eb396eb93ea08e54883c5"
|
||||
|
||||
modules="
|
||||
futimens
|
||||
@ -36,14 +36,26 @@ fi
|
||||
cd gnulib >/dev/null || exit 1
|
||||
curr_hash=$(git log -1 --format=%H)
|
||||
if [ "${gnulib_hash}" != "${curr_hash}" ]; then
|
||||
echo "Pulling..."
|
||||
git pull
|
||||
git checkout -f ${gnulib_hash}
|
||||
git checkout --force ${gnulib_hash}
|
||||
fi
|
||||
cd .. >/dev/null || exit 1
|
||||
|
||||
rm -rf lib
|
||||
./gnulib/gnulib-tool \
|
||||
--import \
|
||||
${modules}
|
||||
echo "Autopoint..."
|
||||
autopoint --force
|
||||
|
||||
autoreconf -f -i -s
|
||||
rm -rf lib
|
||||
echo "Gnulib-tool..."
|
||||
./gnulib/gnulib-tool --import ${modules}
|
||||
echo
|
||||
|
||||
echo "Aclocal..."
|
||||
aclocal -I m4
|
||||
echo "Autoconf..."
|
||||
autoconf
|
||||
echo "Autoheader..."
|
||||
autoheader
|
||||
echo "Automake..."
|
||||
automake --add-missing
|
||||
echo "Done."
|
||||
|
||||
91
configure.ac
91
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-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2014, 2017 Mike Frysinger
|
||||
#
|
||||
# GNU nano is free software: you can redistribute it and/or modify
|
||||
@ -16,10 +16,11 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
|
||||
AC_INIT([GNU nano], [5.9], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [7.2], [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.
|
||||
@ -127,6 +128,20 @@ if test "x$enable_color" != xno; then
|
||||
color_support=yes
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(folding,
|
||||
AS_HELP_STRING([--disable-folding], [Disable line folding support]))
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
if test "x$enable_folding" = xyes; then
|
||||
AC_MSG_ERROR([
|
||||
*** --enable-folding cannot work with --enable-tiny])
|
||||
else
|
||||
enable_folding=no
|
||||
fi
|
||||
fi
|
||||
if test "x$enable_folding" != xno; then
|
||||
AC_DEFINE(ENABLE_FOLDING, 1, [Define this to have line folding support.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(comment,
|
||||
AS_HELP_STRING([--disable-comment], [Disable the comment/uncomment function]))
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
@ -152,6 +167,30 @@ if test "x$enable_extra" != xno; then
|
||||
AC_DEFINE(ENABLE_EXTRA, 1, [Define this to have an Easter egg.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(formatter,
|
||||
AS_HELP_STRING([--disable-formatter], [Disable the formatting tool]))
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
if test "x$enable_formatter" = xyes; then
|
||||
if test "x$enable_color" != xyes; then
|
||||
AC_MSG_ERROR([
|
||||
*** --enable-formatter needs both --enable-color and --enable-nanorc to work])
|
||||
fi
|
||||
else
|
||||
enable_formatter=no
|
||||
fi
|
||||
fi
|
||||
if test "x$enable_color" = xno; then
|
||||
if test "x$enable_formatter" = xyes; then
|
||||
AC_MSG_ERROR([
|
||||
*** --enable-formatter cannot work with --disable-color nor --disable-nanorc])
|
||||
else
|
||||
enable_formatter=no
|
||||
fi
|
||||
fi
|
||||
if test "x$enable_formatter" != xno; then
|
||||
AC_DEFINE(ENABLE_FORMATTER, 1, [Define this to have access to a formatter.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(help,
|
||||
AS_HELP_STRING([--disable-help], [Disable the built-in help texts]))
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
@ -205,7 +244,7 @@ if test "x$enable_libmagic" = xyes; then
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
if test "x$enable_color" != xyes; then
|
||||
AC_MSG_ERROR([
|
||||
*** --enable-libmagic needs --enable-color and --enable-nanorc to work])
|
||||
*** --enable-libmagic needs both --enable-color and --enable-nanorc to work])
|
||||
fi
|
||||
fi
|
||||
if test "x$enable_color" = xno; then
|
||||
@ -214,6 +253,30 @@ if test "x$enable_libmagic" = xyes; then
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(linter,
|
||||
AS_HELP_STRING([--disable-linter], [Disable the linting tool]))
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
if test "x$enable_linter" = xyes; then
|
||||
if test "x$enable_color" != xyes; then
|
||||
AC_MSG_ERROR([
|
||||
*** --enable-linter needs both --enable-color and --enable-nanorc to work])
|
||||
fi
|
||||
else
|
||||
enable_linter=no
|
||||
fi
|
||||
fi
|
||||
if test "x$enable_color" = xno; then
|
||||
if test "x$enable_linter" = xyes; then
|
||||
AC_MSG_ERROR([
|
||||
*** --enable-linter cannot work with --disable-color nor --disable-nanorc])
|
||||
else
|
||||
enable_linter=no
|
||||
fi
|
||||
fi
|
||||
if test "x$enable_linter" != xno; then
|
||||
AC_DEFINE(ENABLE_LINTER, 1, [Define this to have access to a linter.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(linenumbers,
|
||||
AS_HELP_STRING([--disable-linenumbers], [Disable line numbering]))
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
@ -271,14 +334,14 @@ if test "x$enable_operatingdir" != xno; then
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(speller,
|
||||
AS_HELP_STRING([--disable-speller], [Disable the spell-checker functions]))
|
||||
AS_HELP_STRING([--disable-speller], [Disable the spell-checking tool]))
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
if test "x$enable_speller" != xyes; then
|
||||
enable_speller=no
|
||||
fi
|
||||
fi
|
||||
if test "x$enable_speller" != xno; then
|
||||
AC_DEFINE(ENABLE_SPELLER, 1, [Define this to have the spell-checker functions.])
|
||||
AC_DEFINE(ENABLE_SPELLER, 1, [Define this to have access to a spell checker.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(tabcomp,
|
||||
@ -353,6 +416,9 @@ if test "x$enable_utf8" != xno; then
|
||||
AC_CHECK_FUNCS(iswalpha iswalnum iswpunct mbstowcs wctomb)
|
||||
fi
|
||||
|
||||
AC_CHECK_FUNCS_ONCE(chmod chown fchmod fchown flockfile funlockfile
|
||||
fork fsync geteuid pipe wait waitpid)
|
||||
|
||||
dnl Checks for available flags.
|
||||
|
||||
AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"], [], [])
|
||||
@ -510,21 +576,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>
|
||||
|
||||
|
||||
20
doc/faq.html
20
doc/faq.html
@ -5,7 +5,7 @@
|
||||
<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>
|
||||
<style type="text/css">
|
||||
.indented { margin-left: 2em; font-family: courier; font-size: 110%; }
|
||||
</style>
|
||||
</head>
|
||||
@ -27,7 +27,7 @@
|
||||
<a href="#2.1">2.1. FTP and WWW sites that carry nano.</a><br>
|
||||
<a href="#2.2">2.2. RedHat and derivatives (.rpm) packages.</a><br>
|
||||
<a href="#2.3">2.3. Debian (.deb) packages.</a><br>
|
||||
<a href="#2.4">2.4. By GIT (for the brave).</a>
|
||||
<a href="#2.4">2.4. By git (for the brave).</a>
|
||||
</p></blockquote>
|
||||
<h3><a href="#3">3. Installation and Configuration</a></h3>
|
||||
<blockquote><p>
|
||||
@ -72,7 +72,7 @@
|
||||
<a href="#7.2">7.2. How do I submit a bug report or patch?</a><br>
|
||||
<a href="#7.3">7.3. I want to send the development team a big load of cash (or just a thank you).</a><br>
|
||||
<a href="#7.4">7.4. How do I join the development team?</a><br>
|
||||
<a href="#7.5">7.5. Can I have write access to the GIT tree?</a>
|
||||
<a href="#7.5">7.5. Can I have write access to the git tree?</a>
|
||||
</p></blockquote>
|
||||
<hr width="100%">
|
||||
|
||||
@ -92,7 +92,7 @@
|
||||
<h3><a name="1.3"></a>1.3. Why the name change from TIP?</h3>
|
||||
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program "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.9</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
|
||||
<blockquote><p>The current version of nano <i>should</i> be <b>7.2</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%">
|
||||
@ -121,8 +121,8 @@
|
||||
</ul>
|
||||
<p>You can also have a look at the <a href="http://ftp.debian.org/debian/pool/main/n/nano/">Package Pool</a> to see all the available binary and source packages.</p>
|
||||
</blockquote>
|
||||
<h3><a name="2.4"></a>2.4. By GIT (for the brave).</h3>
|
||||
<blockquote><p>For the 'bleeding edge' current version of nano, you can use GIT to download the current source code. <b>Note:</b> believe it or not, by downloading code that has not yet stabilized into an official release, there could quite possibly be bugs, in fact the code may not even compile! Anyway, see <a href="http://git.savannah.gnu.org/cgit/nano.git/tree/README.GIT">the nano GIT document</a> for info on anonymous GIT access to the nano source.</p></blockquote>
|
||||
<h3><a name="2.4"></a>2.4. By git (for the brave).</h3>
|
||||
<blockquote><p>For the "bleeding edge" current version of nano, you can use <b>git</b> to download the current source code. <i>Note:</i> believe it or not, by downloading code that has not yet stabilized into an official release, there could quite possibly be bugs, in fact the code may not even compile! Anyway, see <a href="http://git.savannah.gnu.org/cgit/nano.git/tree/README.hacking">the hacking document</a> for info on getting and building nano from git.</p></blockquote>
|
||||
<hr width="100%">
|
||||
|
||||
<h1><a name="3"></a>3. Installation and Configuration</h1>
|
||||
@ -150,16 +150,18 @@
|
||||
<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-formatter</b> Disable the formatting tool
|
||||
<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-linter</b> Disable the linting tool
|
||||
<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-speller</b> Disable the spell-checking tool
|
||||
<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>
|
||||
@ -220,10 +222,10 @@
|
||||
<blockquote><p>Try holding down the Shift key and selecting or pasting the text as you normally would.</p></blockquote>
|
||||
<h3><a name="4.6"></a>4.6. When I paste text into a document, each line gets indented further than the last. Why? And how can I stop this?</h3>
|
||||
<blockquote><p>You have the <i>autoindent</i> feature turned on. Hit <b>Meta-I</b> to turn it off, paste your text, and then hit <b>Meta-I</b> again to turn it back on.</p>
|
||||
<p><i>Update:</i> Since version 4.8, nano will suppress auto-indentation during a paste, so you no longer need to toggle it off and on manually.</p></blockquote>
|
||||
<p><i>Update:</i> Since version 4.8, nano will suppress auto-indentation during a paste (when your terminal understands <a href="https://en.wikipedia.org/wiki/Bracketed-paste">bracketed pastes</a>), so you no longer need to toggle it off and on manually.</p></blockquote>
|
||||
<h3><a name="4.7"></a>4.7. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?</h3>
|
||||
<blockquote><p>When pasting from Windows, in some situations linefeeds are sent instead of carriage returns (Enters). And linefeeds are <b>^J</b>s, which make nano justify (rewrap) the current paragraph. To prevent these linefeeds from causing these unwanted justifications, add this line to your .nanorc on the remote Linux box: <b>unbind ^J main</b> or <b>bind ^J enter main</b>, depending on whether the paste contains CR + LF or only LF.</p>
|
||||
<p><i>Update:</i> Since version 4.8, nano will ignore linefeed characters in a paste, so you no longer need the above workaround.</p></blockquote>
|
||||
<p><i>Update:</i> Since version 4.8, nano will ignore linefeed characters in a paste (when your terminal understands <a href="https://en.wikipedia.org/wiki/Bracketed-paste">bracketed pastes</a>), so you no longer need the above workaround.</p></blockquote>
|
||||
<h3><a name="4.8"></a>4.8. I've compiled nano with color support, but I don't see any color when I run it!</h3>
|
||||
<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>
|
||||
|
||||
86
doc/nano.1
86
doc/nano.1
@ -1,4 +1,4 @@
|
||||
.\" Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc.
|
||||
.\" Copyright (C) 1999-2011, 2013-2023 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,19 +16,22 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANO 1 "version 5.9" "October 2021"
|
||||
.TH NANO 1 "version 7.2" "January 2023"
|
||||
|
||||
.SH NAME
|
||||
nano \- Nano's ANOther editor, inspired by Pico
|
||||
nano \- Nano's ANOther text editor, inspired by Pico
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B nano
|
||||
.RI [ options "] [[\fB+" line [\fB, column "]] " file ]...
|
||||
.sp
|
||||
.BR nano " [" \fIoptions "] [[" + [ crCR ]( / | ? ) \fIstring "] " \fIfile ]...
|
||||
.B nano
|
||||
.RI [ options "] [" file [\fB: line [\fB: column "]]]..."
|
||||
.sp
|
||||
.BR nano " [" \fIoptions "] [[" + [ crCR ]{ / | ? } \fIstring "] " \fIfile ]...
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fBnano\fP is a small and friendly editor. It copies the look and feel
|
||||
\fBnano\fP is a small and friendly text editor. It copies the look and feel
|
||||
of Pico, but is free software, and implements several features that Pico
|
||||
lacks, such as: opening multiple files, scrolling per line, undo/redo,
|
||||
syntax coloring, line numbering, and soft-wrapping overlong lines.
|
||||
@ -36,7 +39,11 @@ syntax coloring, line numbering, and soft-wrapping overlong lines.
|
||||
When giving a filename on the command line, the cursor can be put on a
|
||||
specific line by adding the line number with a plus sign (\fB+\fR) before
|
||||
the filename, and even in a specific column by adding it with a comma.
|
||||
(Negative numbers count from the end of the file or line.)
|
||||
Negative numbers count from the end of the file or line.
|
||||
The line and column numbers may also be specified by gluing them with colons
|
||||
after the filename. (When a filename contains a colon followed by digits,
|
||||
escape the colon by preceding it with a triple backslash.)
|
||||
.sp
|
||||
The cursor can be put on the first or last occurrence of a specific string
|
||||
by specifying that string after \fB+/\fR or \fB+?\fR before the filename.
|
||||
The string can be made case sensitive and/or caused to be interpreted as a
|
||||
@ -74,25 +81,17 @@ using the arrow keys. Holding down the Ctrl or Alt key too will increase
|
||||
the stride.
|
||||
Any cursor movement without Shift being held will cancel such a selection.
|
||||
.sp
|
||||
Any valid Unicode code point can be inserted into the buffer by typing
|
||||
\fBM\-V\fR followed by the hexadecimal digits of the code point (concluded
|
||||
with \fB<Space>\fR or \fB<Enter>\fR when it are fewer than six digits).
|
||||
A literal control code (except \fB^J\fR) can be inserted by typing
|
||||
\fBM\-V\fR followed by the pertinent keystroke.
|
||||
.sp
|
||||
The two lines at the bottom of the screen show some important commands;
|
||||
the built-in help (\fB^G\fR) lists all the available ones.
|
||||
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
|
||||
@ -120,6 +119,7 @@ nanorc file. See \fBnanorc\fR(5).
|
||||
.BR \-E ", " \-\-tabstospaces
|
||||
Convert each typed tab to spaces -- to the number of spaces
|
||||
that a tab at that position would take up.
|
||||
(Note: pasted tabs are not converted.)
|
||||
.TP
|
||||
.BR \-F ", " \-\-multibuffer
|
||||
Read a file into a new buffer by default.
|
||||
@ -140,10 +140,12 @@ text. (The color of the stripe can be changed with \fBset stripecolor\fR
|
||||
in your \fInanorc\fR file.)
|
||||
.TP
|
||||
.BR \-K ", " \-\-rawsequences
|
||||
Interpret escape sequences directly (instead of asking \fBncurses\fR to
|
||||
translate them). If you need this option to get your keyboard to work
|
||||
properly, please report a bug. Using this option disables \fBnano\fR's
|
||||
mouse support.
|
||||
Interpret escape sequences directly, instead of asking \fBncurses\fR
|
||||
to translate them. (If you need this option to get some keys to work
|
||||
properly, it means that the terminfo terminal description that is used
|
||||
does not fully match the actual behavior of your terminal. This can
|
||||
happen when you ssh into a BSD machine, for example.)
|
||||
Using this option disables \fBnano\fR's mouse support.
|
||||
.TP
|
||||
.BR \-L ", " \-\-nonewlines
|
||||
Don't automatically add a newline when a text does not end with one.
|
||||
@ -192,8 +194,11 @@ Set the size (width) of a tab to \fInumber\fP columns. The value of
|
||||
.TP
|
||||
.BR \-U ", " \-\-quickblank
|
||||
Make status-bar messages disappear after 1 keystroke instead of after 20.
|
||||
Note that options \fB\-c\fR (\fB\-\-constantshow\fR)
|
||||
and \fB\-_\fR (\fB\-\-minibar\fR) override this.
|
||||
Note that option \fB\-c\fR (\fB\-\-constantshow\fR) overrides this.
|
||||
When option \fB\-\-minibar\fR or \fB\-\-zero\fR is in effect,
|
||||
\fB\-\-quickblank\fR makes a message disappear after
|
||||
0.8 seconds instead of after the default 1.5 seconds.
|
||||
.
|
||||
.TP
|
||||
.BR \-V ", " \-\-version
|
||||
Show the current version number and exit.
|
||||
@ -304,7 +309,6 @@ using the built-in corrector that calls \fBhunspell\fR(1) or \fBspell\fR(1).
|
||||
.TP
|
||||
.BR \-t ", " \-\-saveonexit
|
||||
Save a changed buffer without prompting (when exiting with \fB^X\fR).
|
||||
(The old form of the long option, \fB\-\-tempfile\fR, is deprecated.)
|
||||
.TP
|
||||
.BR \-u ", " \-\-unix
|
||||
Save a file by default in Unix format. This overrides nano's
|
||||
@ -327,8 +331,9 @@ Don't show the two help lines at the bottom of the screen.
|
||||
.BR \-y ", " \-\-afterends
|
||||
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).
|
||||
.BR \-! ", " \-\-magic
|
||||
When neither the file's name nor its first line give a clue,
|
||||
try using libmagic to determine the applicable syntax.
|
||||
.TP
|
||||
.BR \-% ", " \-\-stateflags
|
||||
Use the top-right corner of the screen for showing some state flags:
|
||||
@ -352,12 +357,16 @@ 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 \-! ", " \-\-magic
|
||||
When neither the file's name nor its first line give a clue,
|
||||
try using libmagic to determine the applicable syntax.
|
||||
.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.
|
||||
|
||||
.SH TOGGLES
|
||||
Several of the above options can be switched on and off also while
|
||||
@ -385,6 +394,14 @@ See \fI/usr/share/nano/\fR and \fI/usr/share/nano/extra/\fR
|
||||
for available syntax-coloring definitions.
|
||||
|
||||
.SH NOTES
|
||||
Option \fB\-z\fR (\fB\-\-suspendable\fR) has been removed.
|
||||
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.)
|
||||
.sp
|
||||
When you want to copy marked text from \fBnano\fR to the system's clipboard,
|
||||
see one of the examples in the \fBnanorc\fR(5) man page.
|
||||
.sp
|
||||
If no alternative spell checker command is specified on the command
|
||||
line nor in one of the \fInanorc\fP files, \fBnano\fP will check the
|
||||
\fBSPELL\fP environment variable for one.
|
||||
@ -398,6 +415,9 @@ that name already exists in the current directory, it will add ".save"
|
||||
plus a number (e.g.\& ".save.1") to the current filename in order to make
|
||||
it unique. In multibuffer mode, \fBnano\fP will write all the open
|
||||
buffers to their respective emergency files.
|
||||
.sp
|
||||
If you have any question about how to use \fBnano\fR in some specific
|
||||
situation, you can ask on \fIhelp-nano@gnu.org\fR.
|
||||
|
||||
.SH BUGS
|
||||
The recording and playback of keyboard macros works correctly only on a
|
||||
|
||||
971
doc/nano.texi
971
doc/nano.texi
File diff suppressed because it is too large
Load Diff
154
doc/nanorc.5
154
doc/nanorc.5
@ -1,4 +1,4 @@
|
||||
.\" Copyright (C) 2003-2011, 2013-2021 Free Software Foundation, Inc.
|
||||
.\" Copyright (C) 2003-2011, 2013-2023 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,14 +16,14 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANORC 5 "version 5.9" "October 2021"
|
||||
.TH NANORC 5 "version 7.2" "January 2023"
|
||||
|
||||
.SH NAME
|
||||
nanorc \- GNU nano's configuration file
|
||||
|
||||
.SH DESCRIPTION
|
||||
The \fInanorc\fP files contain the default settings for \fBnano\fP,
|
||||
a small and friendly editor. During startup, if \fB\-\-rcfile\fR
|
||||
a small and friendly text editor. During startup, if \fB\-\-rcfile\fR
|
||||
is not given, \fBnano\fR will read two files: first the
|
||||
system-wide settings, from \fI/etc/nanorc\fP (the exact path might be
|
||||
different on your system), and then the user-specific settings, either
|
||||
@ -32,20 +32,6 @@ or from \fI~/.config/nano/nanorc\fR, whichever is encountered first.
|
||||
If \fB\-\-rcfile\fR is given, \fBnano\fR will read just the specified
|
||||
settings file.
|
||||
|
||||
.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
|
||||
To get the old, Pico behavior back, you can use \fBset breaklonglines\fR,
|
||||
\fBset emptyline\fR, and \fBset jumpyscrolling\fR.
|
||||
|
||||
.SH OPTIONS
|
||||
The configuration file accepts a series of \fBset\fP and \fBunset\fP
|
||||
commands, which can be used to configure nano on startup without using
|
||||
@ -196,7 +182,7 @@ the number of lines in the buffer is displayed after the filename.
|
||||
This number is cleared upon the next keystroke, or replaced with an
|
||||
[i/n] counter when multiple buffers are open.
|
||||
The line plus column numbers and the character code are displayed only when
|
||||
\fBset constantshow\fR is used, and can be toggled on and off with \fBM-C\fR.
|
||||
\fBset constantshow\fR is used, and can be toggled on and off with \fBM\-C\fR.
|
||||
The state flags are displayed only when \fBset stateflags\fR is used.
|
||||
.TP
|
||||
.B set minicolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
@ -258,7 +244,10 @@ specfified closing punctuation, optionally followed by closing brackets
|
||||
.TP
|
||||
.B set quickblank
|
||||
Make status-bar messages disappear after 1 keystroke instead of after 20.
|
||||
Note that options \fBconstantshow\fR and \fBminibar\fR override this.
|
||||
Note that option \fBconstantshow\fR overrides this.
|
||||
When option \fBminibar\fR or \fBzero\fR is in effect,
|
||||
\fBquickblank\fR makes a message disappear after
|
||||
0.8 seconds instead of after the default 1.5 seconds.
|
||||
.TP
|
||||
.BI "set quotestr """ regex """
|
||||
Set the regular expression for matching the quoting part of a line.
|
||||
@ -268,10 +257,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
|
||||
@ -284,7 +275,6 @@ Regular expressions in \fBnano\fR are of the extended type (ERE).
|
||||
.TP
|
||||
.B set saveonexit
|
||||
Save a changed buffer automatically on exit (\fB^X\fR); don't prompt.
|
||||
(The old form of this option, \fBset tempfile\fR, is deprecated.)
|
||||
.TP
|
||||
.B set scrollercolor \fIfgcolor\fB,\fIbgcolor\fR
|
||||
Use this color combination for the indicator alias "scrollbar".
|
||||
@ -330,7 +320,7 @@ and \fBS\fR when soft-wrapping.
|
||||
When the buffer is modified, a star (\fB*\fR) is shown after the
|
||||
filename in the center of the title bar.
|
||||
.TP
|
||||
.B set statuscolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
.B set statuscolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
Use this color combination for the status bar.
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
@ -338,9 +328,6 @@ See \fBset titlecolor\fR for more details.
|
||||
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).
|
||||
.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.
|
||||
@ -348,6 +335,7 @@ greater than 0. The default value is \fB8\fR.
|
||||
.B set tabstospaces
|
||||
Convert each typed tab to spaces -- to the number of spaces
|
||||
that a tab at that position would take up.
|
||||
(Note: pasted tabs are not converted.)
|
||||
.TP
|
||||
.B set titlecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
Use this color combination for the title bar.
|
||||
@ -361,8 +349,16 @@ as a synonym for \fBlightblack\fR.
|
||||
On terminal emulators that can do at least 256 colors,
|
||||
other valid (but unprefixable) color names are:
|
||||
.BR pink ", " purple ", " mauve ", " lagoon ", " mint ", "
|
||||
.BR lime ", " peach ", " orange ", " latte ", and " normal
|
||||
.BR lime ", " peach ", " orange ", " latte ", "
|
||||
.BR rosy ", " beet ", " plum ", " sea ", " sky ", " slate ", "
|
||||
.BR teal ", " sage ", " brown ", " ocher ", " sand ", " tawny ", "
|
||||
.BR brick ", " crimson ", and " normal
|
||||
-- where \fBnormal\fR means the default foreground or background color.
|
||||
On such emulators, the color may also be specified as a three-digit hexadecimal
|
||||
number prefixed with \fB#\fR, with the digits representing the amounts of red,
|
||||
green, and blue, respectively. This tells \fBnano\fR to select from the
|
||||
available palette the color that approximates the given values.
|
||||
|
||||
Either "\fIfgcolor\fR" or "\fB,\fIbgcolor\fR" may be left out,
|
||||
and the pair may be preceded by \fBbold\fR and/or \fBitalic\fR
|
||||
(separated by commas) to get a bold and/or slanting typeface,
|
||||
@ -394,6 +390,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
|
||||
@ -417,6 +421,14 @@ It also means that lookahead and lookbehind are not possible.
|
||||
A complete explanation can be found in the manual page of GNU grep:
|
||||
\fBman grep\fR.
|
||||
.sp
|
||||
Each regular expression in a \fBnanorc\fR file should be wrapped in
|
||||
double quotes (\fB""\fR). Multiple regular expressions can follow
|
||||
each other on a line by separating them with blanks. This means that
|
||||
a regular expression cannot contain a double quote followed by a blank.
|
||||
When you need this combination inside a regular expression,
|
||||
then either the double quote or the blank should be put
|
||||
between square brackets (\fB[]\fR).
|
||||
.sp
|
||||
For each kind of file a separate syntax can be defined
|
||||
via the following commands:
|
||||
.TP
|
||||
@ -427,9 +439,10 @@ will be added to this syntax, until a new \fBsyntax\fR
|
||||
command is encountered.
|
||||
.sp
|
||||
When \fBnano\fR is run, this syntax will be automatically
|
||||
activated if the current filename matches the extended regular
|
||||
expression \fIfileregex\fR. Or the syntax can be explicitly
|
||||
activated by using the \fB\-Y\fR or \fB\-\-syntax\fR
|
||||
activated (for the relevant buffer) if the absolute filename
|
||||
matches the extended regular expression \fIfileregex\fR.
|
||||
Or the syntax can be explicitly activated (for all buffers)
|
||||
by using the \fB\-Y\fR or \fB\-\-syntax\fR
|
||||
command-line option followed by the \fIname\fR.
|
||||
.sp
|
||||
The syntax \fBdefault\fP is special: it takes no \fIfileregex\fR,
|
||||
@ -452,9 +465,6 @@ system and will be silently ignored otherwise.)
|
||||
.TP
|
||||
.BI formatter " program " \fR[ "argument " \fR...]
|
||||
Run the given \fIprogram\fR on the full contents of the current buffer.
|
||||
(The current buffer is written out to a temporary file, the program is
|
||||
run on it, and then the temporary file is read back in, replacing the
|
||||
contents of the buffer.)
|
||||
.TP
|
||||
.BI linter " program " \fR[ "argument " \fR...]
|
||||
Use the given \fIprogram\fR to run a syntax check on the current buffer.
|
||||
@ -483,11 +493,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.
|
||||
@ -535,14 +555,23 @@ Rebinds the given \fIkey\fP to the given \fIfunction\fP in the given \fImenu\fP
|
||||
.BI bind " key " """" string """" " menu"
|
||||
Makes the given \fIkey\fR produce the given \fIstring\fR in the given
|
||||
\fImenu\fR (or in all menus where the key exists when \fBall\fR is used).
|
||||
The \fIstring\fR can consist of text or commands or a mix of them.
|
||||
(To enter a command into the \fIstring\fR, precede its keystroke
|
||||
with \fBM\-V\fR.)
|
||||
Besides literal text and/or control codes, the \fIstring\fR may contain
|
||||
function names between braces. These functions will be invoked when
|
||||
the key is typed. To include a literal opening brace, use \fB{{}\fR.
|
||||
.TP
|
||||
.BI unbind " key menu"
|
||||
Unbinds the given \fIkey\fP from the given \fImenu\fP (or from all
|
||||
menus where the key exists when \fBall\fP is used).
|
||||
.RE
|
||||
.sp
|
||||
Note that \fBbind \fIkey\fR \fB"{\fIfunction\fB}"\fR \fImenu\fR is equivalent
|
||||
to \fBbind \fIkey\fR \fIfunction\fR \fImenu\fR, except that for the latter form
|
||||
\fBnano\fR will check the availability of the \fIfunction\fR in the given \fImenu\fR
|
||||
at startup time (and report an error if it does not exist there), whereas for the
|
||||
first form \fBnano\fR will check at execution time that the \fIfunction\fR exists
|
||||
but not whether it makes any sense in the current menu. The user has to take care
|
||||
that a function name between braces (or any sequence of them) is appropriate.
|
||||
Strange behavior can result when it is not.
|
||||
|
||||
.TP
|
||||
The format of \fIkey\fP should be one of:
|
||||
@ -654,7 +683,6 @@ Or, when it is set, unsets the mark.
|
||||
.B location
|
||||
Reports the current position of the cursor in the buffer:
|
||||
the line, column, and character positions.
|
||||
(The old name of this function, 'curpos', is deprecated.)
|
||||
.TP
|
||||
.B wordcount
|
||||
Counts and reports on the status bar the number of lines, words,
|
||||
@ -662,7 +690,7 @@ and characters in the current buffer (or in the marked region).
|
||||
.TP
|
||||
.B execute
|
||||
Prompts for a program to execute. The program's output will be inserted
|
||||
into the current buffer (or into a new buffer when \fBM-F\fR is toggled).
|
||||
into the current buffer (or into a new buffer when \fBM\-F\fR is toggled).
|
||||
.TP
|
||||
.B speller
|
||||
Invokes a spell-checking program, either the default \fBhunspell\fR(1) or GNU
|
||||
@ -670,15 +698,23 @@ Invokes a spell-checking program, either the default \fBhunspell\fR(1) or GNU
|
||||
.TP
|
||||
.B formatter
|
||||
Invokes a full-buffer-processing program (if the active syntax defines one).
|
||||
(The current buffer is written out to a temporary file, the program
|
||||
is run on it, and then the temporary file is read back in, replacing
|
||||
the contents of the buffer.)
|
||||
.TP
|
||||
.B linter
|
||||
Invokes a syntax-checking program (if the active syntax defines one).
|
||||
If this program produces lines of the form "filename:linenum:charnum:
|
||||
some message", then the cursor will be put at the indicated position
|
||||
in the mentioned file while showing "some message" on the status bar.
|
||||
You can move from message to message with <PgUp> and <PgDn>,
|
||||
and leave linting mode with \fB^C\fR or <Enter>.
|
||||
.TP
|
||||
.B justify
|
||||
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
|
||||
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
|
||||
@ -788,7 +824,8 @@ Switches to editing/viewing the previous buffer when multiple buffers are open.
|
||||
Switches to editing/viewing the next buffer when multiple buffers are open.
|
||||
.TP
|
||||
.B verbatim
|
||||
Inserts the next keystroke verbatim into the file.
|
||||
Inserts the next keystroke verbatim into the file, or begins Unicode input
|
||||
when a hexadecimal digit is typed.
|
||||
.TP
|
||||
.B tab
|
||||
Inserts a tab at the current cursor location.
|
||||
@ -819,8 +856,8 @@ Redoes the last undone action (i.e., it undoes an undo).
|
||||
Refreshes the screen.
|
||||
.TP
|
||||
.B suspend
|
||||
Suspends the editor (if the suspending function is enabled, see the
|
||||
\fBsuspendable\fR toggle item below).
|
||||
Suspends the editor and returns control to the shell
|
||||
(until you tell the process to resume execution with \fBfg\fR).
|
||||
.TP
|
||||
.B casesens
|
||||
Toggles whether searching/replacing ignores or respects the case of
|
||||
@ -898,6 +935,9 @@ Toggles the presence of the two-line list of key bindings at the bottom of the s
|
||||
(This toggle is special: it is available in all menus except the help viewer
|
||||
and the linter. All further toggles are available in the main menu only.)
|
||||
.TP
|
||||
.B zero
|
||||
Toggles the presence of title bar and status bar.
|
||||
.TP
|
||||
.B constantshow
|
||||
Toggles the constant display of the current line, column, and character positions.
|
||||
.TP
|
||||
@ -934,11 +974,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
|
||||
@ -986,7 +1021,6 @@ The 'go to directory' menu in the file browser.
|
||||
The menu for inserting the output from an external command,
|
||||
or for filtering the buffer (or the marked region) through
|
||||
an external command, or for executing one of several tools.
|
||||
(The old form of this menu name, 'extcmd', is deprecated.)
|
||||
.TP
|
||||
.B spell
|
||||
The menu of the integrated spell checker where the user can edit a misspelled word.
|
||||
@ -1000,6 +1034,20 @@ For \fBbind\fR it means all menus where the specified \fIfunction\fR exists;
|
||||
for \fBunbind\fR it means all menus where the specified \fIkey\fR exists.
|
||||
.RE
|
||||
|
||||
.SH EXAMPLES
|
||||
To make \fBCtrl+Z\fR suspend nano:
|
||||
.sp
|
||||
.RS
|
||||
.B bind ^Z suspend main
|
||||
.RE
|
||||
.sp
|
||||
To make \fBShift+Alt+C\fR copy the marked region to the system's clipboard:
|
||||
.sp
|
||||
.RS
|
||||
.B bind Sh-M-C """{execute}| xsel -ib {enter}{undo}""" main
|
||||
.RE
|
||||
.sp
|
||||
|
||||
.SH FILES
|
||||
.TP
|
||||
.I /etc/nanorc
|
||||
|
||||
14
doc/rnano.1
14
doc/rnano.1
@ -1,4 +1,4 @@
|
||||
.\" Copyright (C) 2002-2007, 2014-2021 Free Software Foundation, Inc.
|
||||
.\" Copyright (C) 2002-2007, 2014-2023 Free Software Foundation, Inc.
|
||||
.\"
|
||||
.\" This document is dual-licensed. You may distribute and/or modify it
|
||||
.\" under the terms of either of the following licenses:
|
||||
@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH RNANO 1 "version 5.9" "October 2021"
|
||||
.TH RNANO 1 "version 7.2" "January 2023"
|
||||
|
||||
.SH NAME
|
||||
rnano \- a restricted nano
|
||||
@ -32,15 +32,19 @@ access to the filesystem nor to a command shell.
|
||||
.sp
|
||||
In restricted mode, \fBnano\fR will:
|
||||
.IP \[bu] 2
|
||||
not make backups;
|
||||
.IP \[bu]
|
||||
not allow suspending;
|
||||
.IP \[bu]
|
||||
not allow spell checking;
|
||||
.IP \[bu]
|
||||
not read nor write the history files;
|
||||
.IP \[bu]
|
||||
not allow saving the current buffer under a different name;
|
||||
.IP \[bu]
|
||||
not allow inserting another file or opening a new buffer;
|
||||
.IP \[bu]
|
||||
not allow appending or prepending to any file;
|
||||
.IP \[bu]
|
||||
not make backup files nor do spell checking.
|
||||
not allow appending or prepending to any file.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
|
||||
@ -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
|
||||
|
||||
@ -142,7 +146,6 @@
|
||||
|
||||
## Save a changed buffer automatically on exit; don't prompt.
|
||||
# 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
|
||||
@ -167,10 +170,6 @@
|
||||
## M = mark, L = hard-wrapping long lines, R = recording, S = soft-wrapping.
|
||||
# set stateflags
|
||||
|
||||
## Allow nano to be suspended (with ^Z by default).
|
||||
# set suspendable
|
||||
## (The old form of this option, 'set suspend', is deprecated.)
|
||||
|
||||
## Use this tab size instead of the default; it must be greater than 0.
|
||||
# set tabsize 8
|
||||
|
||||
@ -180,6 +179,9 @@
|
||||
## Snip whitespace at the end of lines when justifying or hard-wrapping.
|
||||
# set trimblanks
|
||||
|
||||
## Save files by default in Unix format (also when they were DOS or Mac).
|
||||
# set unix
|
||||
|
||||
## The two single-column characters used to display the first characters
|
||||
## of tabs and spaces. 187 in ISO 8859-1 (0000BB in Unicode) and 183 in
|
||||
## ISO-8859-1 (0000B7 in Unicode) seem to be good values for these.
|
||||
@ -201,6 +203,9 @@
|
||||
## of a single character, and without affecting the cutbuffer).
|
||||
# set zap
|
||||
|
||||
## Hide the bars plus help lines and use the whole terminal as edit area.
|
||||
# set zero
|
||||
|
||||
|
||||
## Paint the interface elements of nano. These are examples; there are
|
||||
## no colors by default, except for errorcolor and spotlightcolor.
|
||||
@ -256,6 +261,9 @@
|
||||
## === Key bindings ===
|
||||
## For all details, see 'man nanorc', section REBINDING KEYS.
|
||||
|
||||
## If you want to suspend nano with one keystroke (instead of with ^T^Z):
|
||||
# bind ^Z suspend main
|
||||
|
||||
## The <Ctrl+Delete> keystroke deletes the word to the right of the cursor.
|
||||
## On some terminals the <Ctrl+Backspace> keystroke produces ^H, which is
|
||||
## the ASCII character for backspace, so it is bound by default to the
|
||||
@ -265,19 +273,39 @@
|
||||
## <Ctrl+Backspace> delete the word to the left of the cursor with:
|
||||
# bind ^H chopwordleft main
|
||||
|
||||
## For quickly uppercasing or lowercasing the word under the cursor.
|
||||
## (These effectively do a Ctrl+Right followed by a Shift+Ctrl+Left,
|
||||
## and then pipe the selected text through a sed command.)
|
||||
#bind Sh-M-U "Oc[1;6D|sed 's/.*/\U&/'
" main
|
||||
#bind Sh-M-L "Oc[1;6D|sed 's/.*/\L&/'
" main
|
||||
## 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 or after the cursor.
|
||||
## (These effectively select a word and pipe it through a sed command.)
|
||||
#bind Sh-M-U "{nextword}{mark}{prevword}{execute}|sed 's/.*/\U&/'{enter}" main
|
||||
#bind Sh-M-L "{nextword}{mark}{prevword}{execute}|sed 's/.*/\L&/'{enter}" main
|
||||
|
||||
## For copying a marked region to the system clipboard:
|
||||
# bind Sh-M-T "{execute}|xsel -ib{enter}{undo}" main
|
||||
|
||||
## For snipping trailing blanks when you save a file:
|
||||
# bind ^S "{execute}| sed 's/\s\+$//' {enter}{savefile}" 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
|
||||
#bind ^H help all
|
||||
#bind ^H exit help
|
||||
#bind ^F whereis all
|
||||
@ -285,24 +313,19 @@
|
||||
#bind ^B wherewas all
|
||||
#bind ^D findprevious all
|
||||
#bind ^R replace main
|
||||
#bind ^X cut main
|
||||
#bind ^C copy main
|
||||
#bind ^V paste all
|
||||
#bind ^P location main
|
||||
#bind ^E execute main
|
||||
#bind ^A mark main
|
||||
#unbind ^K main
|
||||
#unbind ^U all
|
||||
#unbind ^N main
|
||||
#unbind ^Y all
|
||||
#unbind M-J main
|
||||
#unbind M-T main
|
||||
#bind ^A mark main
|
||||
#bind ^P location main
|
||||
#bind ^T gotoline main
|
||||
#bind ^T gotodir browser
|
||||
#bind ^T cutrestoffile execute
|
||||
#bind ^L linter execute
|
||||
#bind M-U undo main
|
||||
#bind M-R redo main
|
||||
#bind ^E execute main
|
||||
#bind ^K "{mark}{end}{zap}" main
|
||||
#bind ^U "{mark}{home}{zap}" main
|
||||
#bind ^Z undo main
|
||||
#bind ^Y redo main
|
||||
#set multibuffer
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
# List of available languages.
|
||||
bg ca cs da de eo es eu fi fr ga gl hr hu id is it ja ko ms nb nl pl pt pt_BR ro ru sk sl sr sv tr uk vi zh_CN zh_TW
|
||||
bg ca cs da de eo es eu fi fr ga gl hr hu id is it ja ka ko ms nb nl pl pt pt_BR ro ru sk sl sq sr sv tr uk vi zh_CN zh_TW
|
||||
|
||||
1354
po/nano.pot
1354
po/nano.pot
File diff suppressed because it is too large
Load Diff
1374
po/pt_BR.po
1374
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
1381
po/zh_CN.po
1381
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
1374
po/zh_TW.po
1374
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERSION="5.9"
|
||||
VERSION="7.2"
|
||||
|
||||
./configure -C --enable-tiny && make && ./configure -C &&
|
||||
|
||||
@ -20,7 +20,7 @@ gpg -a -b nano-$VERSION.tar.xz &&
|
||||
gpg --verify nano-$VERSION.tar.gz.asc &&
|
||||
gpg --verify nano-$VERSION.tar.xz.asc &&
|
||||
|
||||
git tag -u A0ACE884 -a v$VERSION -m "the nano $VERSION release" &&
|
||||
git tag -u B8E1961F -a v$VERSION -m "the nano $VERSION release" &&
|
||||
|
||||
make pdf && rm -rf doc/nano.t2p &&
|
||||
scp doc/nano.pdf bens@wh0rd.org:nano.pdf &&
|
||||
|
||||
@ -16,7 +16,8 @@ winio.o: revision.h
|
||||
# only when the revision actually changed.
|
||||
revision.h: FORCE
|
||||
@[ -f $@ ] || touch $@
|
||||
@echo "#define $(SOMETHING)" | cmp -s $@ - || \
|
||||
@! git describe >/dev/null 2>&1 || \
|
||||
echo "#define $(SOMETHING)" | cmp -s $@ - || \
|
||||
echo "#define $(SOMETHING)" > $@
|
||||
FORCE:
|
||||
|
||||
@ -29,6 +30,7 @@ nano_SOURCES = \
|
||||
color.c \
|
||||
cut.c \
|
||||
files.c \
|
||||
folding.c \
|
||||
global.c \
|
||||
help.c \
|
||||
history.c \
|
||||
|
||||
353
src/browser.c
353
src/browser.c
@ -1,8 +1,8 @@
|
||||
/**************************************************************************
|
||||
* browser.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2015-2016, 2020 Benno Schulenberg *
|
||||
* Copyright (C) 2001-2011, 2013-2023 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2015-2016, 2020, 2022 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 *
|
||||
@ -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,70 +248,46 @@ 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,
|
||||
* search forward in the list; otherwise, search backward. */
|
||||
/* Look for the given needle in the list of files, forwards or backwards. */
|
||||
void findfile(const char *needle, bool forwards)
|
||||
{
|
||||
size_t looking_at = selected;
|
||||
/* The location in the file list of the filename we're looking at. */
|
||||
const char *thename;
|
||||
/* The plain filename, without the path. */
|
||||
unsigned stash[sizeof(flags) / sizeof(flags[0])];
|
||||
/* A storage place for the current flag settings. */
|
||||
size_t began_at = selected;
|
||||
|
||||
/* Save the settings of all flags. */
|
||||
memcpy(stash, flags, sizeof(flags));
|
||||
|
||||
/* Search forward, case insensitive, and without regexes. */
|
||||
UNSET(BACKWARDS_SEARCH);
|
||||
UNSET(CASE_SENSITIVE);
|
||||
UNSET(USE_REGEXP);
|
||||
|
||||
/* Step through each filename in the list until a match is found or
|
||||
/* Iterate through the list of filenames, until a match is found or
|
||||
* we've come back to the point where we started. */
|
||||
while (TRUE) {
|
||||
if (forwards) {
|
||||
if (looking_at++ == list_length - 1) {
|
||||
looking_at = 0;
|
||||
if (selected++ == list_length - 1) {
|
||||
selected = 0;
|
||||
statusbar(_("Search Wrapped"));
|
||||
}
|
||||
} else {
|
||||
if (looking_at-- == 0) {
|
||||
looking_at = list_length - 1;
|
||||
if (selected-- == 0) {
|
||||
selected = list_length - 1;
|
||||
statusbar(_("Search Wrapped"));
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the bare filename, without the path. */
|
||||
thename = tail(filelist[looking_at]);
|
||||
|
||||
/* If the needle matches, we're done. And if we're back at the file
|
||||
* where we started, it is the only occurrence. */
|
||||
if (strstrwrapper(thename, needle, thename)) {
|
||||
if (looking_at == selected)
|
||||
/* When the needle occurs in the basename of the file, we have a match. */
|
||||
if (mbstrcasestr(tail(filelist[selected]), needle)) {
|
||||
if (selected == began_at)
|
||||
statusbar(_("This is the only occurrence"));
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
/* If we're back at the beginning and didn't find any match... */
|
||||
if (looking_at == selected) {
|
||||
/* When we're back at the starting point without any match... */
|
||||
if (selected == began_at) {
|
||||
not_found_msg(needle);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Restore the settings of all flags. */
|
||||
memcpy(flags, stash, sizeof(flags));
|
||||
|
||||
/* Select the one we've found. */
|
||||
selected = looking_at;
|
||||
}
|
||||
|
||||
/* Prepare the prompt and ask the user what to search for; then search for it.
|
||||
@ -355,7 +327,7 @@ void search_filename(bool forwards)
|
||||
if (*answer != '\0') {
|
||||
last_search = mallocstrcpy(last_search, answer);
|
||||
#ifdef ENABLE_HISTORIES
|
||||
update_history(&search_history, answer);
|
||||
update_history(&search_history, answer, PRUNE_DUPLICATE);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -430,7 +402,7 @@ char *browse(char *path)
|
||||
|
||||
if (path == NULL || dir == NULL) {
|
||||
statusline(ALERT, _("Cannot open directory: %s"), strerror(errno));
|
||||
/* If we don't have a file list yet, there is nothing to show. */
|
||||
/* If we don't have a file list, there is nothing to show. */
|
||||
if (filelist == NULL) {
|
||||
lastmessage = VACUUM;
|
||||
free(present_name);
|
||||
@ -443,19 +415,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;
|
||||
|
||||
@ -465,8 +436,11 @@ char *browse(char *path)
|
||||
|
||||
titlebar(path);
|
||||
|
||||
while (TRUE) {
|
||||
functionptrtype func;
|
||||
if (list_length == 0) {
|
||||
statusline(ALERT, _("No entries"));
|
||||
napms(1200);
|
||||
} else while (TRUE) {
|
||||
functionptrtype function;
|
||||
int kbinput;
|
||||
|
||||
lastmessage = VACUUM;
|
||||
@ -480,31 +454,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;
|
||||
}
|
||||
@ -514,88 +484,82 @@ char *browse(char *path)
|
||||
}
|
||||
#endif /* ENABLE_MOUSE */
|
||||
#ifndef NANO_TINY
|
||||
if (bracketed_paste || kbinput == BRACKETED_PASTE_MARKER) {
|
||||
while (bracketed_paste)
|
||||
kbinput = get_kbinput(midwin, BLIND);
|
||||
if (kbinput == BRACKETED_PASTE_MARKER) {
|
||||
beep();
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
func = interpret(&kbinput);
|
||||
function = interpret(kbinput);
|
||||
|
||||
if (func == full_refresh) {
|
||||
full_refresh();
|
||||
if (function == full_refresh || function == do_help) {
|
||||
function();
|
||||
#ifndef NANO_TINY
|
||||
/* Simulate a window resize to force a directory reread. */
|
||||
/* Simulate a terminal resize to force a directory reread,
|
||||
* or because the terminal dimensions might have changed. */
|
||||
kbinput = KEY_WINCH;
|
||||
#endif
|
||||
} else if (func == do_help) {
|
||||
do_help();
|
||||
#ifndef NANO_TINY
|
||||
/* The window dimensions might have changed, so act as if. */
|
||||
kbinput = KEY_WINCH;
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
} else if (func == do_toggle_void) {
|
||||
} else if (function == do_toggle && get_shortcut(kbinput)->toggle == NO_HELP) {
|
||||
TOGGLE(NO_HELP);
|
||||
window_init();
|
||||
kbinput = KEY_WINCH;
|
||||
#endif
|
||||
} else if (func == do_search_backward) {
|
||||
} else if (function == do_search_backward) {
|
||||
search_filename(BACKWARD);
|
||||
} else if (func == do_search_forward) {
|
||||
} else if (function == do_search_forward) {
|
||||
search_filename(FORWARD);
|
||||
} else if (func == do_findprevious) {
|
||||
} else if (function == do_findprevious) {
|
||||
research_filename(BACKWARD);
|
||||
} else if (func == do_findnext) {
|
||||
} else if (function == do_findnext) {
|
||||
research_filename(FORWARD);
|
||||
} else if (func == do_left) {
|
||||
} else if (function == do_left) {
|
||||
if (selected > 0)
|
||||
selected--;
|
||||
} else if (func == do_right) {
|
||||
} else if (function == do_right) {
|
||||
if (selected < list_length - 1)
|
||||
selected++;
|
||||
} else if (func == to_prev_word) {
|
||||
selected -= (selected % width);
|
||||
} else if (func == to_next_word) {
|
||||
selected += width - 1 - (selected % width);
|
||||
} else if (function == to_prev_word) {
|
||||
selected -= (selected % piles);
|
||||
} else if (function == to_next_word) {
|
||||
selected += piles - 1 - (selected % piles);
|
||||
if (selected >= list_length)
|
||||
selected = list_length - 1;
|
||||
} else if (func == do_up) {
|
||||
if (selected >= width)
|
||||
selected -= width;
|
||||
} else if (func == do_down) {
|
||||
if (selected + width <= list_length - 1)
|
||||
selected += width;
|
||||
} else if (func == to_prev_block) {
|
||||
selected = ((selected / (editwinrows * width)) *
|
||||
editwinrows * width) + selected % width;
|
||||
} else if (func == to_next_block) {
|
||||
selected = ((selected / (editwinrows * width)) *
|
||||
editwinrows * width) + selected % width +
|
||||
editwinrows * width - width;
|
||||
} else if (function == do_up) {
|
||||
if (selected >= piles)
|
||||
selected -= piles;
|
||||
} else if (function == do_down) {
|
||||
if (selected + piles <= list_length - 1)
|
||||
selected += piles;
|
||||
} else if (function == to_prev_block) {
|
||||
selected = ((selected / (usable_rows * piles)) * usable_rows * piles) +
|
||||
selected % piles;
|
||||
} else if (function == to_next_block) {
|
||||
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;
|
||||
} else if (func == do_page_up) {
|
||||
if (selected < width)
|
||||
selected -= piles;
|
||||
} else if (function == do_page_up) {
|
||||
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;
|
||||
} else if (func == do_page_down) {
|
||||
if (selected + width >= list_length - 1)
|
||||
selected -= usable_rows * piles;
|
||||
} else if (function == do_page_down) {
|
||||
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;
|
||||
} else if (func == to_first_file) {
|
||||
selected += usable_rows * piles;
|
||||
} else if (function == to_first_file) {
|
||||
selected = 0;
|
||||
} else if (func == to_last_file) {
|
||||
} else if (function == to_last_file) {
|
||||
selected = list_length - 1;
|
||||
} else if (func == goto_dir) {
|
||||
} else if (function == goto_dir) {
|
||||
/* Ask for the directory to go to. */
|
||||
if (do_prompt(MGOTODIR, "", NULL,
|
||||
/* TRANSLATORS: This is a prompt. */
|
||||
@ -615,8 +579,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;
|
||||
@ -634,7 +598,7 @@ char *browse(char *path)
|
||||
|
||||
/* Try opening and reading the specified directory. */
|
||||
goto read_directory_contents;
|
||||
} else if (func == do_enter) {
|
||||
} else if (function == do_enter) {
|
||||
struct stat st;
|
||||
|
||||
/* It isn't possible to move up from the root directory. */
|
||||
@ -674,24 +638,23 @@ char *browse(char *path)
|
||||
path = mallocstrcpy(path, filelist[selected]);
|
||||
goto read_directory_contents;
|
||||
#ifdef ENABLE_NANORC
|
||||
} else if (func == (functionptrtype)implant) {
|
||||
implant(first_sc_for(MBROWSER, func)->expansion);
|
||||
} else if (function == (functionptrtype)implant) {
|
||||
implant(first_sc_for(MBROWSER, function)->expansion);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
} else if (kbinput == KEY_WINCH) {
|
||||
; /* Nothing to do. */
|
||||
; /* Gets handled below. */
|
||||
#endif
|
||||
} else if (func == do_exit) {
|
||||
} else if (function == do_exit) {
|
||||
break;
|
||||
} else
|
||||
unbound_key(kbinput);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If the window resized, refresh the file list. */
|
||||
/* If the terminal resized (or might have), refresh the file list. */
|
||||
if (kbinput == KEY_WINCH) {
|
||||
/* Remember the selected file, to be able to reselect it. */
|
||||
present_name = copy_of(filelist[selected]);
|
||||
/* Reread the contents of the current directory. */
|
||||
goto read_directory_contents;
|
||||
}
|
||||
#endif
|
||||
@ -722,14 +685,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;
|
||||
}
|
||||
@ -737,8 +696,8 @@ char *browse_in(const char *inpath)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_OPERATINGDIR
|
||||
/* If the resulting path isn't in the operating directory, use
|
||||
* the operating directory instead. */
|
||||
/* If the resulting path isn't in the operating directory,
|
||||
* use the operating directory instead. */
|
||||
if (outside_of_confinement(path, FALSE))
|
||||
path = mallocstrcpy(path, operating_dir);
|
||||
#endif
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* chars.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2001-2011, 2013-2023 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2016-2021 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
|
||||
33
src/color.c
33
src/color.c
@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* color.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2001-2011, 2013-2023 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2017, 2020, 2021 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@ -53,6 +53,7 @@ void set_interface_colorpairs(void)
|
||||
}
|
||||
init_pair(index + 1, combo->fg, combo->bg);
|
||||
interface_color_pair[index] = COLOR_PAIR(index + 1) | combo->attributes;
|
||||
rescind_colors = FALSE;
|
||||
} else {
|
||||
if (index == FUNCTION_TAG || index == SCROLL_BAR)
|
||||
interface_color_pair[index] = A_NORMAL;
|
||||
@ -72,6 +73,11 @@ void set_interface_colorpairs(void)
|
||||
|
||||
free(color_combo[index]);
|
||||
}
|
||||
|
||||
if (rescind_colors) {
|
||||
interface_color_pair[SPOTLIGHTED] = A_REVERSE;
|
||||
interface_color_pair[ERROR_MESSAGE] = A_REVERSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Assign a pair number to each of the foreground/background color combinations
|
||||
@ -255,12 +261,14 @@ void check_the_multis(linestruct *line)
|
||||
if (line->multidata[ink->id] == NOTHING) {
|
||||
if (!astart)
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] & (WHOLELINE|WOULDBE)) {
|
||||
if (!astart && !anend)
|
||||
} else if (line->multidata[ink->id] == WHOLELINE) {
|
||||
/* Ensure that a detected start match is not actually an end match. */
|
||||
if (!anend && (!astart || regexec(ink->end, line->data, 1,
|
||||
&endmatch, 0) != 0))
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] == JUSTONTHIS) {
|
||||
if (astart && anend && regexec(ink->start, line->data + endmatch.rm_eo,
|
||||
1, &startmatch, 0) != 0)
|
||||
if (astart && anend && regexec(ink->start, line->data + startmatch.rm_eo +
|
||||
endmatch.rm_eo, 1, &startmatch, 0) != 0)
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] == STARTSHERE) {
|
||||
if (astart && !anend)
|
||||
@ -272,6 +280,7 @@ void check_the_multis(linestruct *line)
|
||||
|
||||
/* There is a mismatch, so something changed: repaint. */
|
||||
refresh_needed = TRUE;
|
||||
perturbed = TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -342,21 +351,17 @@ void precalc_multicolorinfo(void)
|
||||
1, &endmatch, 0) != 0)
|
||||
tailline = tailline->next;
|
||||
|
||||
/* When there is no end match, mark relevant lines as such. */
|
||||
if (tailline == NULL) {
|
||||
for (; line->next != NULL; line = line->next)
|
||||
line->multidata[ink->id] = WOULDBE;
|
||||
line->multidata[ink->id] = WOULDBE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* We found it, we found it, la lala lala. Mark the lines. */
|
||||
line->multidata[ink->id] = STARTSHERE;
|
||||
|
||||
// Note that this also advances the line in the main loop.
|
||||
for (line = line->next; line != tailline; line = line->next)
|
||||
line->multidata[ink->id] = WHOLELINE;
|
||||
|
||||
if (tailline == NULL) {
|
||||
line = openfile->filebot;
|
||||
break;
|
||||
}
|
||||
|
||||
tailline->multidata[ink->id] = ENDSHERE;
|
||||
|
||||
/* Look for a possible new start after the end match. */
|
||||
|
||||
62
src/cut.c
62
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-2023 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014 Mark Majeres *
|
||||
* Copyright (C) 2016, 2018-2020 Benno Schulenberg *
|
||||
* *
|
||||
@ -48,6 +48,7 @@ void do_deletion(undo_type action)
|
||||
memmove(&openfile->current->data[openfile->current_x],
|
||||
&openfile->current->data[openfile->current_x + charlen],
|
||||
line_len - charlen + 1);
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
#ifndef NANO_TINY
|
||||
/* When softwrapping, a changed number of chunks requires a refresh. */
|
||||
if (ISSET(SOFTWRAP) && extra_chunks_in(openfile->current) != old_amount)
|
||||
@ -62,6 +63,9 @@ void do_deletion(undo_type action)
|
||||
} else if (openfile->current != openfile->filebot) {
|
||||
linestruct *joining = openfile->current->next;
|
||||
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
UNFOLD_SEGMENT(joining);
|
||||
|
||||
/* If there is a magic line, and we're before it: don't eat it. */
|
||||
if (joining == openfile->filebot && openfile->current_x != 0 &&
|
||||
!ISSET(NO_NEWLINES)) {
|
||||
@ -97,6 +101,13 @@ void do_deletion(undo_type action)
|
||||
/* We're at the end-of-file: nothing to do. */
|
||||
return;
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
if (!refresh_needed)
|
||||
check_the_multis(openfile->current);
|
||||
#endif
|
||||
if (!refresh_needed)
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
|
||||
/* Adjust the file size, and remember it for a possible redo. */
|
||||
openfile->totsize--;
|
||||
#ifndef NANO_TINY
|
||||
@ -136,7 +147,8 @@ void do_backspace(void)
|
||||
openfile->current_x = step_left(openfile->current->data, openfile->current_x);
|
||||
do_deletion(BACK);
|
||||
} else if (openfile->current != openfile->filetop) {
|
||||
do_left();
|
||||
openfile->current = openfile->current->prev;
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
do_deletion(BACK);
|
||||
}
|
||||
}
|
||||
@ -185,7 +197,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(ALLOW_FOLDED);
|
||||
if (openfile->current != is_current) {
|
||||
if (is_current_x > 0) {
|
||||
openfile->current = is_current;
|
||||
@ -194,13 +206,14 @@ 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), ALLOW_FOLDED);
|
||||
if (openfile->current != is_current &&
|
||||
is_current->data[is_current_x] != '\0') {
|
||||
openfile->current = is_current;
|
||||
openfile->current_x = strlen(is_current->data);
|
||||
}
|
||||
}
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
|
||||
/* Set the mark at the start of that word. */
|
||||
openfile->mark = openfile->current;
|
||||
@ -255,9 +268,20 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
|
||||
if (top == bot && top_x == bot_x)
|
||||
return;
|
||||
|
||||
/* In case bot is the start of a folded segment.
|
||||
* Folds within [top, bot] are taken care of in the following loop */
|
||||
UNFOLD_SEGMENT(bot);
|
||||
|
||||
if (top != bot)
|
||||
for (linestruct *line = top->next; line != bot->next; line = line->next)
|
||||
#ifdef ENABLE_FOLDING
|
||||
top->folded = FALSE;
|
||||
#endif
|
||||
for (linestruct *line = top->next; line != bot->next; line = line->next){
|
||||
had_anchor |= line->has_anchor;
|
||||
#ifdef ENABLE_FOLDING
|
||||
line->folded = FALSE;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (top == bot) {
|
||||
@ -371,6 +395,8 @@ void ingraft_buffer(linestruct *topline)
|
||||
#endif
|
||||
linestruct *botline = topline;
|
||||
|
||||
UNFOLD_SEGMENT(line);
|
||||
|
||||
while (botline->next != NULL)
|
||||
botline = botline->next;
|
||||
|
||||
@ -435,9 +461,19 @@ void ingraft_buffer(linestruct *topline)
|
||||
/* Meld a copy of the given buffer into the current file buffer. */
|
||||
void copy_from_buffer(linestruct *somebuffer)
|
||||
{
|
||||
#ifdef ENABLE_COLOR
|
||||
size_t threshold = openfile->edittop->lineno + editwinrows - 1;
|
||||
#endif
|
||||
linestruct *the_copy = copy_buffer(somebuffer);
|
||||
|
||||
ingraft_buffer(the_copy);
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
if (openfile->current->lineno > threshold || ISSET(SOFTWRAP))
|
||||
recook = TRUE;
|
||||
else
|
||||
perturbed = TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@ -485,7 +521,7 @@ void do_snip(bool marked, bool until_eof, bool append)
|
||||
/* When not at the end of a line, move the rest of this line into
|
||||
* the cutbuffer. Otherwise, when not at the end of the buffer,
|
||||
* move just the "line separator" into the cutbuffer. */
|
||||
if (openfile->current_x < strlen(openfile->current->data))
|
||||
if (line->data[openfile->current_x] != '\0')
|
||||
extract_segment(line, openfile->current_x, line, strlen(line->data));
|
||||
else if (openfile->current != openfile->filebot) {
|
||||
extract_segment(line, openfile->current_x, line->next, 0);
|
||||
@ -509,6 +545,9 @@ void do_snip(bool marked, bool until_eof, bool append)
|
||||
|
||||
set_modified();
|
||||
refresh_needed = TRUE;
|
||||
#ifdef ENABLE_COLOR
|
||||
perturbed = TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Move text from the current buffer into the cutbuffer. */
|
||||
@ -694,9 +733,11 @@ void copy_text(void)
|
||||
/* Copy text from the cutbuffer into the current buffer. */
|
||||
void paste_text(void)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
#if defined(ENABLE_WRAPPING) || !defined(NANO_TINY)
|
||||
/* Remember where the paste started. */
|
||||
linestruct *was_current = openfile->current;
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
bool had_anchor = was_current->has_anchor;
|
||||
#endif
|
||||
ssize_t was_lineno = openfile->current->lineno;
|
||||
@ -706,6 +747,7 @@ void paste_text(void)
|
||||
statusline(AHEM, _("Cutbuffer is empty"));
|
||||
return;
|
||||
}
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(PASTE, NULL);
|
||||
@ -728,6 +770,12 @@ void paste_text(void)
|
||||
update_undo(PASTE);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WRAPPING
|
||||
/* When still on the same line and doing hard-wrapping, limit the width. */
|
||||
if (openfile->current == was_current && ISSET(BREAK_LONG_LINES))
|
||||
do_wrap();
|
||||
#endif
|
||||
|
||||
/* If we pasted less than a screenful, don't center the cursor. */
|
||||
if (less_than_a_screenful(was_lineno, was_leftedge))
|
||||
focusing = FALSE;
|
||||
|
||||
@ -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-2023 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2017 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@ -108,6 +108,14 @@
|
||||
#define BACKWARD FALSE
|
||||
#define FORWARD TRUE
|
||||
|
||||
#define YESORNO FALSE
|
||||
#define YESORALLORNO TRUE
|
||||
|
||||
#define YES 1
|
||||
#define ALL 2
|
||||
#define NO 0
|
||||
#define CANCEL -1
|
||||
|
||||
#define BLIND FALSE
|
||||
#define VISIBLE TRUE
|
||||
|
||||
@ -122,6 +130,9 @@
|
||||
#define ANNOTATE TRUE
|
||||
#define NONOTES FALSE
|
||||
|
||||
#define PRUNE_DUPLICATE TRUE
|
||||
#define IGNORE_DUPLICATES FALSE
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
/* In UTF-8 a valid character is at most four bytes long. */
|
||||
#define MAXCHARLEN 4
|
||||
@ -159,8 +170,6 @@
|
||||
/* The start regex matches on an earlier line, the end regex on this one. */
|
||||
#define JUSTONTHIS (1<<5)
|
||||
/* Both the start and end regexes match within this line. */
|
||||
#define WOULDBE (1<<6)
|
||||
/* An unpaired start match is on or before this line. */
|
||||
#endif
|
||||
|
||||
/* Basic control codes. */
|
||||
@ -205,6 +214,17 @@
|
||||
#define SHIFT_DELETE 0x45D
|
||||
#define SHIFT_TAB 0x45F
|
||||
|
||||
#define FOCUS_IN 0x491
|
||||
#define FOCUS_OUT 0x499
|
||||
|
||||
/* Special keycodes for when a string bind has been partially implanted
|
||||
* or has an unpaired opening brace, or when a function in a string bind
|
||||
* needs execution or a specified function name is invalid. */
|
||||
#define MORE_PLANTS 0x4EA
|
||||
#define MISSING_BRACE 0x4EB
|
||||
#define PLANTED_A_COMMAND 0x4EC
|
||||
#define NO_SUCH_FUNCTION 0x4EF
|
||||
|
||||
/* A special keycode for when <Tab> is pressed while the mark is on. */
|
||||
#define INDENT_KEY 0x4F1
|
||||
|
||||
@ -215,7 +235,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). */
|
||||
@ -256,6 +276,15 @@
|
||||
#define MSOME MMAIN|MBROWSER
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FOLDING
|
||||
#define UNFOLD_SEGMENT(line) unfold_folded_segment(line)
|
||||
#else
|
||||
#define UNFOLD_SEGMENT(line)
|
||||
#endif
|
||||
|
||||
#define ALLOW_FOLDED TRUE
|
||||
#define DISALLOW_FOLDED FALSE
|
||||
|
||||
/* Enumeration types. */
|
||||
typedef enum {
|
||||
UNSPECIFIED, NIX_FILE, DOS_FILE, MAC_FILE
|
||||
@ -310,7 +339,6 @@ enum {
|
||||
CASE_SENSITIVE,
|
||||
CONSTANT_SHOW,
|
||||
NO_HELP,
|
||||
SUSPENDABLE,
|
||||
NO_WRAP,
|
||||
AUTOINDENT,
|
||||
VIEW_MODE,
|
||||
@ -354,9 +382,16 @@ enum {
|
||||
BOOKSTYLE,
|
||||
STATEFLAGS,
|
||||
USE_MAGIC,
|
||||
MINIBAR
|
||||
MINIBAR,
|
||||
ZERO
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
FOUND_BRACKET = 0,
|
||||
NOT_FOUND_BRACKET,
|
||||
NOT_A_BRACKET
|
||||
} bracket_search_result;
|
||||
|
||||
/* Structure types. */
|
||||
#ifdef ENABLE_COLOR
|
||||
typedef struct colortype {
|
||||
@ -415,7 +450,7 @@ typedef struct syntaxtype {
|
||||
/* The command with which to lint this type of file. */
|
||||
char *formatter;
|
||||
/* The command with which to format/modify/arrange this type of file. */
|
||||
char *tab;
|
||||
char *tabstring;
|
||||
/* What the Tab key should produce; NULL for default behavior. */
|
||||
#ifdef ENABLE_COMMENT
|
||||
char *comment;
|
||||
@ -463,6 +498,10 @@ typedef struct linestruct {
|
||||
bool has_anchor;
|
||||
/* Whether the user has placed an anchor at this line. */
|
||||
#endif
|
||||
#ifdef ENABLE_FOLDING
|
||||
bool folded;
|
||||
/* Whether or not this line is in a fold segment */
|
||||
#endif
|
||||
} linestruct;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@ -618,17 +657,14 @@ typedef struct keystruct {
|
||||
typedef struct funcstruct {
|
||||
void (*func)(void);
|
||||
/* The actual function to call. */
|
||||
const char *desc;
|
||||
/* The function's short description, for example "Where Is". */
|
||||
const char *tag;
|
||||
/* The function's help-line label, for example "Where Is". */
|
||||
#ifdef ENABLE_HELP
|
||||
const char *help;
|
||||
/* The help-screen text for this function. */
|
||||
const char *phrase;
|
||||
/* The function's description for in the help viewer. */
|
||||
bool blank_after;
|
||||
/* Whether there should be a blank line after the help text
|
||||
* for this function. */
|
||||
/* Whether to distance this function from the next in the help viewer. */
|
||||
#endif
|
||||
bool viewok;
|
||||
/* Is this function allowed when in view mode? */
|
||||
int menus;
|
||||
/* In what menus this function applies. */
|
||||
struct funcstruct *next;
|
||||
|
||||
422
src/files.c
422
src/files.c
@ -1,8 +1,8 @@
|
||||
/**************************************************************************
|
||||
* files.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2015-2021 Benno Schulenberg *
|
||||
* Copyright (C) 1999-2011, 2013-2023 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2015-2022 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 *
|
||||
@ -33,6 +33,10 @@
|
||||
|
||||
#define RW_FOR_ALL (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
|
||||
|
||||
#ifndef HAVE_FSYNC
|
||||
# define fsync(...) 0
|
||||
#endif
|
||||
|
||||
/* Add an item to the circular list of openfile structs. */
|
||||
void make_new_buffer(void)
|
||||
{
|
||||
@ -53,7 +57,7 @@ void make_new_buffer(void)
|
||||
openfile->next = newnode;
|
||||
|
||||
/* There is more than one buffer: show "Close" in help lines. */
|
||||
exitfunc->desc = close_tag;
|
||||
exitfunc->tag = close_tag;
|
||||
more_than_one = !inhelp || more_than_one;
|
||||
}
|
||||
#endif
|
||||
@ -143,7 +147,7 @@ const char *locking_suffix = ".swp";
|
||||
* existing version of that file. Return TRUE on success; FALSE otherwise. */
|
||||
bool write_lockfile(const char *lockfilename, const char *filename, bool modified)
|
||||
{
|
||||
#ifdef HAVE_PWD_H
|
||||
#if defined(HAVE_PWD_H) && defined(HAVE_GETEUID)
|
||||
pid_t mypid = getpid();
|
||||
uid_t myuid = geteuid();
|
||||
struct passwd *mypwuid = getpwuid(myuid);
|
||||
@ -214,7 +218,7 @@ bool write_lockfile(const char *lockfilename, const char *filename, bool modifie
|
||||
strncpy(&lockdata[108], filename, 768);
|
||||
lockdata[1007] = (modified) ? 0x55 : 0x00;
|
||||
|
||||
wroteamt = fwrite(lockdata, sizeof(char), LOCKSIZE, filestream);
|
||||
wroteamt = fwrite(lockdata, 1, LOCKSIZE, filestream);
|
||||
|
||||
free(lockdata);
|
||||
|
||||
@ -303,14 +307,14 @@ char *do_lockfile(const char *filename, bool ask_the_user)
|
||||
free(postedname);
|
||||
free(pidstring);
|
||||
|
||||
choice = do_yesno_prompt(FALSE, promptstr);
|
||||
choice = ask_user(YESORNO, promptstr);
|
||||
free(promptstr);
|
||||
|
||||
/* When the user cancelled while we're still starting up, quit. */
|
||||
if (choice < 0 && !we_are_running)
|
||||
if (choice == CANCEL && !we_are_running)
|
||||
finish();
|
||||
|
||||
if (choice < 1) {
|
||||
if (choice != YES) {
|
||||
free(lockfilename);
|
||||
wipe_statusbar();
|
||||
return SKIPTHISFILE;
|
||||
@ -346,8 +350,18 @@ bool has_valid_path(const char *filename)
|
||||
char *parentdir = dirname(namecopy);
|
||||
struct stat parentinfo;
|
||||
bool validity = FALSE;
|
||||
bool gone = FALSE;
|
||||
|
||||
if (stat(parentdir, &parentinfo) == -1) {
|
||||
if (strcmp(parentdir, ".") == 0) {
|
||||
char *currentdir = realpath(".", NULL);
|
||||
|
||||
gone = (currentdir == NULL && errno == ENOENT);
|
||||
free(currentdir);
|
||||
}
|
||||
|
||||
if (gone)
|
||||
statusline(ALERT, _("The working directory has disappeared"));
|
||||
else if (stat(parentdir, &parentinfo) == -1) {
|
||||
if (errno == ENOENT)
|
||||
/* TRANSLATORS: Keep the next ten messages at most 76 characters. */
|
||||
statusline(ALERT, _("Directory '%s' does not exist"), parentdir);
|
||||
@ -411,7 +425,7 @@ bool open_buffer(const char *filename, bool new_one)
|
||||
free(realname);
|
||||
return FALSE;
|
||||
}
|
||||
#else
|
||||
#elif defined(HAVE_GETEUID)
|
||||
if (new_one && !(fileinfo.st_mode & (S_IWUSR|S_IWGRP|S_IWOTH)) &&
|
||||
geteuid() == ROOT_UID)
|
||||
statusline(ALERT, _("%s is meant to be read-only"), realname);
|
||||
@ -521,7 +535,8 @@ void mention_name_and_linecount(void)
|
||||
if (ISSET(MINIBAR)) {
|
||||
report_size = TRUE;
|
||||
return;
|
||||
}
|
||||
} else if (ISSET(ZERO))
|
||||
return;
|
||||
|
||||
if (openfile->fmt > NIX_FILE)
|
||||
/* TRANSLATORS: First %s is file name, second %s is file format. */
|
||||
@ -560,13 +575,14 @@ void redecorate_after_switch(void)
|
||||
/* Prevent a possible Shift selection from getting cancelled. */
|
||||
shift_held = TRUE;
|
||||
|
||||
/* If the switched-to buffer gave an error during opening, show the message
|
||||
* once; otherwise, indicate on the status bar which file we switched to. */
|
||||
if (openfile->errormessage) {
|
||||
statusline(ALERT, openfile->errormessage);
|
||||
free(openfile->errormessage);
|
||||
openfile->errormessage = NULL;
|
||||
} else
|
||||
/* Indicate on the status bar where we switched to. */
|
||||
mention_name_and_linecount();
|
||||
mention_name_and_linecount();
|
||||
}
|
||||
|
||||
/* Switch to the previous entry in the circular list of buffers. */
|
||||
@ -612,7 +628,7 @@ void close_buffer(void)
|
||||
|
||||
/* When just one buffer remains open, show "Exit" in the help lines. */
|
||||
if (openfile && openfile == openfile->next)
|
||||
exitfunc->desc = exit_tag;
|
||||
exitfunc->tag = exit_tag;
|
||||
}
|
||||
#endif /* ENABLE_MULTIBUFFER */
|
||||
|
||||
@ -666,6 +682,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||
if (ISSET(SOFTWRAP))
|
||||
was_leftedge = leftedge_for(xplustabs(), openfile->current);
|
||||
#endif
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
|
||||
/* Create an empty buffer. */
|
||||
topline = make_new_node(NULL);
|
||||
@ -675,9 +692,13 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||
block_sigwinch(TRUE);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FLOCKFILE
|
||||
/* Lock the file before starting to read it, to avoid the overhead
|
||||
* of locking it for each single byte that we read from it. */
|
||||
flockfile(f);
|
||||
#else
|
||||
# define getc_unlocked getc
|
||||
#endif
|
||||
|
||||
control_C_was_pressed = FALSE;
|
||||
|
||||
@ -741,8 +762,10 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||
|
||||
errornumber = errno;
|
||||
|
||||
#ifdef HAVE_FUNLOCKFILE
|
||||
/* We are done with the file, unlock it. */
|
||||
funlockfile(f);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
block_sigwinch(FALSE);
|
||||
@ -811,25 +834,29 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||
#ifndef NANO_TINY
|
||||
else if (format == MAC_FILE)
|
||||
/* TRANSLATORS: Keep the next three messages at most 78 characters. */
|
||||
statusline(HUSH, P_("Read %zu line (Converted from Mac format)",
|
||||
statusline(REMARK, P_("Read %zu line (Converted from Mac format)",
|
||||
"Read %zu lines (Converted from Mac format)",
|
||||
num_lines), num_lines);
|
||||
else if (format == DOS_FILE)
|
||||
statusline(HUSH, P_("Read %zu line (Converted from DOS format)",
|
||||
statusline(REMARK, P_("Read %zu line (Converted from DOS format)",
|
||||
"Read %zu lines (Converted from DOS format)",
|
||||
num_lines), num_lines);
|
||||
#endif
|
||||
else
|
||||
statusline(HUSH, P_("Read %zu line", "Read %zu lines",
|
||||
else if ((!ISSET(MINIBAR) && !ISSET(ZERO)) || (we_are_running && undoable))
|
||||
statusline(REMARK, P_("Read %zu line", "Read %zu lines",
|
||||
num_lines), num_lines);
|
||||
|
||||
report_size = TRUE;
|
||||
|
||||
/* If we inserted less than a screenful, don't center the cursor. */
|
||||
if (undoable && less_than_a_screenful(was_lineno, was_leftedge))
|
||||
if (undoable && less_than_a_screenful(was_lineno, was_leftedge)) {
|
||||
focusing = FALSE;
|
||||
#ifdef ENABLE_COLOR
|
||||
else if (undoable)
|
||||
precalc_multicolorinfo();
|
||||
perturbed = TRUE;
|
||||
} else if (undoable) {
|
||||
recook = TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (undoable)
|
||||
@ -898,7 +925,7 @@ int open_file(const char *filename, bool new_one, FILE **f)
|
||||
statusline(ALERT, _("Error reading %s: %s"), filename, strerror(errno));
|
||||
close(fd);
|
||||
fd = -1;
|
||||
} else
|
||||
} else if (!ISSET(ZERO) || we_are_running)
|
||||
statusbar(_("Reading..."));
|
||||
}
|
||||
|
||||
@ -944,11 +971,20 @@ char *get_next_filename(const char *name, const char *suffix)
|
||||
#ifndef NANO_TINY
|
||||
static pid_t pid_of_command = -1;
|
||||
/* The PID of a forked process -- needed when wanting to abort it. */
|
||||
static pid_t pid_of_sender = -1;
|
||||
/* The PID of the process that pipes data to the above process. */
|
||||
static bool should_pipe = FALSE;
|
||||
/* Whether we are piping data to the external command. */
|
||||
|
||||
/* Send an unconditional kill signal to the running external command. */
|
||||
void cancel_the_command(int signal)
|
||||
{
|
||||
kill(pid_of_command, SIGKILL);
|
||||
#ifdef SIGKILL
|
||||
if (pid_of_command > 0)
|
||||
kill(pid_of_command, SIGKILL);
|
||||
if (should_pipe && pid_of_sender > 0)
|
||||
kill(pid_of_sender, SIGKILL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Send the text that starts at the given line to file descriptor fd. */
|
||||
@ -961,28 +997,39 @@ void send_data(const linestruct *line, int fd)
|
||||
|
||||
/* Send each line, except a final empty line. */
|
||||
while (line != NULL && (line->next != NULL || line->data[0] != '\0')) {
|
||||
fprintf(tube, "%s%s", line->data, line->next == NULL ? "" : "\n");
|
||||
size_t length = recode_LF_to_NUL(line->data);
|
||||
|
||||
if (fwrite(line->data, 1, length, tube) < length)
|
||||
exit(5);
|
||||
|
||||
if (line->next && putc('\n', tube) == EOF)
|
||||
exit(6);
|
||||
|
||||
line = line->next;
|
||||
}
|
||||
|
||||
fclose(tube);
|
||||
}
|
||||
|
||||
/* Execute the given command in a shell. Return TRUE on success. */
|
||||
bool execute_command(const char *command)
|
||||
/* Execute the given command in a shell. */
|
||||
void execute_command(const char *command)
|
||||
{
|
||||
#if defined(HAVE_FORK) && defined(HAVE_PIPE) && defined(HAVE_WAIT)
|
||||
int from_fd[2], to_fd[2];
|
||||
/* The pipes through which text will be written and read. */
|
||||
struct sigaction oldaction, newaction = {{0}};
|
||||
/* Original and temporary handlers for SIGINT. */
|
||||
const bool should_pipe = (command[0] == '|');
|
||||
ssize_t was_lineno = (openfile->mark ? 0 : openfile->current->lineno);
|
||||
int command_status, sender_status;
|
||||
FILE *stream;
|
||||
|
||||
should_pipe = (command[0] == '|');
|
||||
|
||||
/* Create a pipe to read the command's output from, and, if needed,
|
||||
* a pipe to feed the command's input through. */
|
||||
if (pipe(from_fd) == -1 || (should_pipe && pipe(to_fd) == -1)) {
|
||||
statusline(ALERT, _("Could not create pipe: %s"), strerror(errno));
|
||||
return FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Fork a child process to run the command in. */
|
||||
@ -1006,6 +1053,7 @@ bool execute_command(const char *command)
|
||||
if (should_pipe) {
|
||||
if (dup2(to_fd[0], STDIN_FILENO) < 0)
|
||||
exit(5);
|
||||
close(from_fd[1]);
|
||||
close(to_fd[1]);
|
||||
}
|
||||
|
||||
@ -1022,7 +1070,7 @@ bool execute_command(const char *command)
|
||||
if (pid_of_command == -1) {
|
||||
statusline(ALERT, _("Could not fork: %s"), strerror(errno));
|
||||
close(from_fd[0]);
|
||||
return FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
statusbar(_("Executing..."));
|
||||
@ -1052,16 +1100,20 @@ bool execute_command(const char *command)
|
||||
}
|
||||
add_undo(CUT, NULL);
|
||||
do_snip(openfile->mark != NULL, openfile->mark == NULL, FALSE);
|
||||
openfile->filetop->has_anchor = FALSE;
|
||||
if (openfile->filetop->next == NULL)
|
||||
openfile->filetop->has_anchor = FALSE;
|
||||
update_undo(CUT);
|
||||
}
|
||||
|
||||
/* Create a separate process for piping the data to the command. */
|
||||
if (fork() == 0) {
|
||||
if ((pid_of_sender = fork()) == 0) {
|
||||
send_data(whole_buffer ? openfile->filetop : cutbuffer, to_fd[1]);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (pid_of_sender == -1)
|
||||
statusline(ALERT, _("Could not fork: %s"), strerror(errno));
|
||||
|
||||
close(to_fd[0]);
|
||||
close(to_fd[1]);
|
||||
|
||||
@ -1088,13 +1140,32 @@ bool execute_command(const char *command)
|
||||
else
|
||||
read_file(stream, 0, "pipe", TRUE);
|
||||
|
||||
if (should_pipe && !ISSET(MULTIBUFFER))
|
||||
if (should_pipe && !ISSET(MULTIBUFFER)) {
|
||||
if (was_lineno)
|
||||
goto_line_posx(was_lineno, 0);
|
||||
add_undo(COUPLE_END, N_("filtering"));
|
||||
}
|
||||
|
||||
/* Wait for the external command (and possibly data sender) to terminate. */
|
||||
wait(NULL);
|
||||
if (should_pipe)
|
||||
wait(NULL);
|
||||
waitpid(pid_of_command, &command_status, 0);
|
||||
if (should_pipe && pid_of_sender > 0)
|
||||
waitpid(pid_of_sender, &sender_status, 0);
|
||||
|
||||
/* If the command failed, show what the shell reported. */
|
||||
if (WIFEXITED(command_status) == 0 || WEXITSTATUS(command_status))
|
||||
statusline(ALERT, WIFSIGNALED(command_status) ? _("Cancelled") :
|
||||
_("Error: %s"), openfile->current->prev &&
|
||||
strstr(openfile->current->prev->data, ": ") ?
|
||||
strstr(openfile->current->prev->data, ": ") + 2 : "---");
|
||||
else if (should_pipe && pid_of_sender > 0 &&
|
||||
(WIFEXITED(sender_status) == 0 || WEXITSTATUS(sender_status)))
|
||||
statusline(ALERT, _("Piping failed"));
|
||||
|
||||
/* If there was an error, undo and discard what the command did. */
|
||||
if (lastmessage == ALERT) {
|
||||
do_undo();
|
||||
discard_until(openfile->current_undo);
|
||||
}
|
||||
|
||||
/* Restore the original handler for SIGINT. */
|
||||
sigaction(SIGINT, &oldaction, NULL);
|
||||
@ -1102,14 +1173,14 @@ bool execute_command(const char *command)
|
||||
/* Restore the terminal to its desired state, and disable
|
||||
* interpretation of the special control keys again. */
|
||||
terminal_init();
|
||||
|
||||
return TRUE;
|
||||
#endif
|
||||
}
|
||||
#endif /* NANO_TINY */
|
||||
|
||||
/* Insert a file into the current buffer, or into a new buffer when
|
||||
* the MULTIBUFFER flag is set. */
|
||||
void do_insertfile(bool execute)
|
||||
/* Insert a file into the current buffer (or into a new buffer). But when
|
||||
* execute is TRUE, run a command in the shell and insert its output into
|
||||
* the buffer, or just run one of the tools listed in the help lines. */
|
||||
void insert_a_file_or(bool execute)
|
||||
{
|
||||
int response;
|
||||
const char *msg;
|
||||
@ -1158,15 +1229,9 @@ void do_insertfile(bool execute)
|
||||
|
||||
present_path = mallocstrcpy(present_path, "./");
|
||||
|
||||
response = do_prompt(
|
||||
#ifndef NANO_TINY
|
||||
execute ? MEXECUTE :
|
||||
#endif
|
||||
MINSERTFILE, given,
|
||||
#ifndef NANO_TINY
|
||||
execute ? &execute_history :
|
||||
#endif
|
||||
NULL, edit_refresh, msg,
|
||||
response = do_prompt(execute ? MEXECUTE : MINSERTFILE, given,
|
||||
execute ? &execute_history : NULL,
|
||||
edit_refresh, msg,
|
||||
#ifdef ENABLE_OPERATINGDIR
|
||||
operating_dir != NULL ? operating_dir :
|
||||
#endif
|
||||
@ -1181,7 +1246,7 @@ void do_insertfile(bool execute)
|
||||
ssize_t was_current_lineno = openfile->current->lineno;
|
||||
size_t was_current_x = openfile->current_x;
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_BROWSER) || defined(ENABLE_MULTIBUFFER)
|
||||
functionptrtype func = func_from_key(&response);
|
||||
functionptrtype function = func_from_key(response);
|
||||
#endif
|
||||
given = mallocstrcpy(given, answer);
|
||||
|
||||
@ -1189,7 +1254,7 @@ void do_insertfile(bool execute)
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (func == flip_newbuffer) {
|
||||
if (function == flip_newbuffer) {
|
||||
/* Allow toggling only when not in view mode. */
|
||||
if (!ISSET(VIEW_MODE))
|
||||
TOGGLE(MULTIBUFFER);
|
||||
@ -1199,22 +1264,22 @@ void do_insertfile(bool execute)
|
||||
}
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
if (func == flip_convert) {
|
||||
if (function == flip_convert) {
|
||||
TOGGLE(NO_CONVERT);
|
||||
continue;
|
||||
}
|
||||
if (func == flip_execute) {
|
||||
if (function == flip_execute) {
|
||||
execute = !execute;
|
||||
continue;
|
||||
}
|
||||
if (func == flip_pipe) {
|
||||
if (function == flip_pipe) {
|
||||
add_or_remove_pipe_symbol_from_answer();
|
||||
given = mallocstrcpy(given, answer);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_BROWSER
|
||||
if (func == to_files) {
|
||||
if (function == to_files) {
|
||||
char *chosen = browse_in(answer);
|
||||
|
||||
/* If no file was chosen, go back to the prompt. */
|
||||
@ -1242,7 +1307,7 @@ void do_insertfile(bool execute)
|
||||
if (*answer != '\0') {
|
||||
execute_command(answer);
|
||||
#ifdef ENABLE_HISTORIES
|
||||
update_history(&execute_history, answer);
|
||||
update_history(&execute_history, answer, PRUNE_DUPLICATE);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1275,7 +1340,7 @@ void do_insertfile(bool execute)
|
||||
if (!execute)
|
||||
#endif
|
||||
if (has_old_position(answer, &priorline, &priorcol))
|
||||
do_gotolinecolumn(priorline, priorcol, FALSE, FALSE);
|
||||
goto_line_and_column(priorline, priorcol, FALSE, FALSE);
|
||||
}
|
||||
#endif
|
||||
/* Update title bar and color info for this new buffer. */
|
||||
@ -1306,10 +1371,10 @@ void do_insertfile(bool execute)
|
||||
}
|
||||
|
||||
/* If the current mode of operation allows it, go insert a file. */
|
||||
void do_insertfile_void(void)
|
||||
void do_insertfile(void)
|
||||
{
|
||||
if (!in_restricted_mode())
|
||||
do_insertfile(FALSE);
|
||||
insert_a_file_or(FALSE);
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@ -1317,7 +1382,7 @@ void do_insertfile_void(void)
|
||||
void do_execute(void)
|
||||
{
|
||||
if (!in_restricted_mode())
|
||||
do_insertfile(TRUE);
|
||||
insert_a_file_or(TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1325,106 +1390,37 @@ void do_execute(void)
|
||||
* absolute path (plus filename) when the path exists, and NULL when not. */
|
||||
char *get_full_path(const char *origpath)
|
||||
{
|
||||
char *allocation, *here, *target, *last_slash;
|
||||
char *just_filename = NULL;
|
||||
int attempts = 0;
|
||||
char *untilded, *target, *slash;
|
||||
struct stat fileinfo;
|
||||
bool path_only;
|
||||
|
||||
if (origpath == NULL)
|
||||
return NULL;
|
||||
|
||||
allocation = nmalloc(PATH_MAX + 1);
|
||||
here = getcwd(allocation, PATH_MAX + 1);
|
||||
untilded = real_dir_from_tilde(origpath);
|
||||
target = realpath(untilded, NULL);
|
||||
slash = strrchr(untilded, '/');
|
||||
|
||||
/* If getting the current directory failed, go up one level and try again,
|
||||
* until we find an existing directory, and use that as the current one. */
|
||||
while (here == NULL && attempts < 20) {
|
||||
IGNORE_CALL_RESULT(chdir(".."));
|
||||
here = getcwd(allocation, PATH_MAX + 1);
|
||||
attempts++;
|
||||
}
|
||||
/* If realpath() returned NULL, try without the last component,
|
||||
* as this can be a file that does not exist yet. */
|
||||
if (!target && slash && slash[1]) {
|
||||
*slash = '\0';
|
||||
target = realpath(untilded, NULL);
|
||||
|
||||
/* If we found a directory, make sure its path ends in a slash. */
|
||||
if (here != NULL) {
|
||||
if (strcmp(here, "/") != 0) {
|
||||
here = nrealloc(here, strlen(here) + 2);
|
||||
strcat(here, "/");
|
||||
}
|
||||
} else {
|
||||
here = copy_of("");
|
||||
free(allocation);
|
||||
}
|
||||
|
||||
target = real_dir_from_tilde(origpath);
|
||||
|
||||
/* Determine whether the target path refers to a directory. If statting
|
||||
* target fails, however, assume that it refers to a new, unsaved buffer. */
|
||||
path_only = (stat(target, &fileinfo) != -1 && S_ISDIR(fileinfo.st_mode));
|
||||
|
||||
/* If the target is a directory, make sure its path ends in a slash. */
|
||||
if (path_only) {
|
||||
size_t length = strlen(target);
|
||||
|
||||
if (target[length - 1] != '/') {
|
||||
target = nrealloc(target, length + 2);
|
||||
strcat(target, "/");
|
||||
/* Upon success, re-add the last component of the original path. */
|
||||
if (target) {
|
||||
target = nrealloc(target, strlen(target) + strlen(slash + 1) + 1);
|
||||
strcat(target, slash + 1);
|
||||
}
|
||||
}
|
||||
|
||||
last_slash = strrchr(target, '/');
|
||||
|
||||
/* If the target path does not contain a slash, then it is a bare filename
|
||||
* and must therefore be located in the working directory. */
|
||||
if (last_slash == NULL) {
|
||||
just_filename = target;
|
||||
target = here;
|
||||
} else {
|
||||
/* If target contains a filename, separate the two. */
|
||||
if (!path_only) {
|
||||
just_filename = copy_of(last_slash + 1);
|
||||
*(last_slash + 1) = '\0';
|
||||
}
|
||||
|
||||
/* If we can't change to the target directory, give up. Otherwise,
|
||||
* get the canonical path to this target directory. */
|
||||
if (chdir(target) == -1) {
|
||||
free(target);
|
||||
target = NULL;
|
||||
} else {
|
||||
free(target);
|
||||
|
||||
allocation = nmalloc(PATH_MAX + 1);
|
||||
target = getcwd(allocation, PATH_MAX + 1);
|
||||
|
||||
/* If we got a result, make sure it ends in a slash.
|
||||
* Otherwise, ensure that we return NULL. */
|
||||
if (target != NULL) {
|
||||
if (strcmp(target, "/") != 0) {
|
||||
target = nrealloc(target, strlen(target) + 2);
|
||||
strcat(target, "/");
|
||||
}
|
||||
} else {
|
||||
path_only = TRUE;
|
||||
free(allocation);
|
||||
}
|
||||
|
||||
/* Finally, go back to where we were before. We don't check
|
||||
* for an error, since we can't do anything if we get one. */
|
||||
IGNORE_CALL_RESULT(chdir(here));
|
||||
}
|
||||
|
||||
free(here);
|
||||
/* Ensure that a non-apex directory path ends with a slash. */
|
||||
if (target && target[1] && stat(target, &fileinfo) == 0 &&
|
||||
S_ISDIR(fileinfo.st_mode)) {
|
||||
target = nrealloc(target, strlen(target) + 2);
|
||||
strcat(target, "/");
|
||||
}
|
||||
|
||||
/* If we were given more than a bare path, concatenate the target path
|
||||
* with the filename portion to get the full, absolute file path. */
|
||||
if (!path_only && target != NULL) {
|
||||
target = nrealloc(target, strlen(target) + strlen(just_filename) + 1);
|
||||
strcat(target, just_filename);
|
||||
}
|
||||
|
||||
free(just_filename);
|
||||
free(untilded);
|
||||
|
||||
return target;
|
||||
}
|
||||
@ -1566,12 +1562,12 @@ int copy_file(FILE *inn, FILE *out, bool close_out)
|
||||
int (*flush_out_fnc)(FILE *) = (close_out) ? fclose : fflush;
|
||||
|
||||
do {
|
||||
charsread = fread(buf, sizeof(char), BUFSIZ, inn);
|
||||
charsread = fread(buf, 1, BUFSIZ, inn);
|
||||
if (charsread == 0 && ferror(inn)) {
|
||||
retval = -1;
|
||||
break;
|
||||
}
|
||||
if (fwrite(buf, sizeof(char), charsread, out) < charsread) {
|
||||
if (fwrite(buf, 1, charsread, out) < charsread) {
|
||||
retval = 2;
|
||||
break;
|
||||
}
|
||||
@ -1656,6 +1652,7 @@ bool make_backup_of(char *realname)
|
||||
if (backup_file == NULL)
|
||||
goto problem;
|
||||
|
||||
#ifdef HAVE_FCHOWN
|
||||
/* Try to change owner and group to those of the original file;
|
||||
* ignore permission errors, as a normal user cannot change the owner. */
|
||||
if (fchown(descriptor, openfile->statinfo->st_uid,
|
||||
@ -1663,7 +1660,8 @@ bool make_backup_of(char *realname)
|
||||
fclose(backup_file);
|
||||
goto problem;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef HAVE_FCHMOD
|
||||
/* Set the backup's permissions to those of the original file.
|
||||
* It is not a security issue if this fails, as we have created
|
||||
* the file with just read and write permission for the owner. */
|
||||
@ -1671,6 +1669,7 @@ bool make_backup_of(char *realname)
|
||||
fclose(backup_file);
|
||||
goto problem;
|
||||
}
|
||||
#endif
|
||||
|
||||
original = fopen(realname, "rb");
|
||||
|
||||
@ -1735,8 +1734,8 @@ bool make_backup_of(char *realname)
|
||||
* ask the user what to do, because if something goes wrong during the
|
||||
* save of the file itself, its contents may be lost. */
|
||||
/* TRANSLATORS: Try to keep this message at most 76 characters. */
|
||||
if (errno != ENOSPC && do_yesno_prompt(FALSE, _("Cannot make backup; "
|
||||
"continue and save actual file? ")) == 1)
|
||||
if (errno != ENOSPC && ask_user(YESORNO, _("Cannot make backup; "
|
||||
"continue and save actual file? ")) == YES)
|
||||
return TRUE;
|
||||
|
||||
/* TRANSLATORS: The %s is the reason of failure. */
|
||||
@ -1890,13 +1889,12 @@ bool write_file(const char *name, FILE *thefile, bool normal,
|
||||
statusbar(_("Writing..."));
|
||||
|
||||
while (TRUE) {
|
||||
size_t data_len = strlen(line->data);
|
||||
size_t wrote;
|
||||
size_t data_len, wrote;
|
||||
|
||||
/* Decode LFs as the NULs that they are, before writing to disk. */
|
||||
recode_LF_to_NUL(line->data);
|
||||
data_len = recode_LF_to_NUL(line->data);
|
||||
|
||||
wrote = fwrite(line->data, sizeof(char), data_len, thefile);
|
||||
wrote = fwrite(line->data, 1, data_len, thefile);
|
||||
|
||||
/* Re-encode any embedded NULs as LFs. */
|
||||
recode_NUL_to_LF(line->data, data_len);
|
||||
@ -1977,6 +1975,19 @@ bool write_file(const char *name, FILE *thefile, bool normal,
|
||||
statusline(ALERT, _("Error writing %s: %s"), realname, strerror(errno));
|
||||
|
||||
cleanup_and_exit:
|
||||
#ifndef NANO_TINY
|
||||
if (errno == ENOSPC && normal) {
|
||||
napms(3200); lastmessage = VACUUM;
|
||||
/* TRANSLATORS: This warns for data loss when the disk is full. */
|
||||
statusline(ALERT, _("File on disk has been truncated!"));
|
||||
napms(3200); lastmessage = VACUUM;
|
||||
/* TRANSLATORS: This is a suggestion to the user,
|
||||
* where "resume" means resuming from suspension.
|
||||
* Try to keep this at most 76 characters. */
|
||||
statusline(ALERT, _("Maybe ^T^Z, make room on disk, resume, then ^S^X"));
|
||||
stat_with_alloc(realname, &openfile->statinfo);
|
||||
}
|
||||
#endif
|
||||
free(tempname);
|
||||
free(realname);
|
||||
return FALSE;
|
||||
@ -2030,7 +2041,7 @@ bool write_file(const char *name, FILE *thefile, bool normal,
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(MINIBAR) && LINES > 1 && annotate)
|
||||
if (ISSET(MINIBAR) && !ISSET(ZERO) && LINES > 1 && annotate)
|
||||
report_size = TRUE;
|
||||
else
|
||||
#endif
|
||||
@ -2058,7 +2069,7 @@ bool write_region_to_file(const char *name, FILE *stream, bool normal,
|
||||
get_region(&topline, &top_x, &botline, &bot_x);
|
||||
|
||||
/* When needed, prepare a magic end line for the region. */
|
||||
if (bot_x > 0 && !ISSET(NO_NEWLINES)) {
|
||||
if (normal && bot_x > 0 && !ISSET(NO_NEWLINES)) {
|
||||
stopper = make_new_node(botline);
|
||||
stopper->data = copy_of("");
|
||||
} else
|
||||
@ -2089,13 +2100,12 @@ bool write_region_to_file(const char *name, FILE *stream, bool normal,
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Write the current buffer to disk. If the mark is on, write the current
|
||||
* marked selection to disk. If exiting is TRUE, write the entire buffer
|
||||
* to disk regardless of whether the mark is on. Do not ask for a name
|
||||
* when withprompt is FALSE nor when the SAVE_ON_EXIT flag is set and the
|
||||
* buffer already has a name. Return 0 on error, 1 on success, and 2 when
|
||||
/* Write the current buffer (or marked region) to disk. If exiting is TRUE,
|
||||
* write the entire buffer regardless of whether the mark is on. Do not ask
|
||||
* for a name when withprompt is FALSE (nor when doing save-on-exit and the
|
||||
* buffer already has a name). Return 0 on error, 1 on success, and 2 when
|
||||
* the buffer is to be discarded. */
|
||||
int do_writeout(bool exiting, bool withprompt)
|
||||
int write_it_out(bool exiting, bool withprompt)
|
||||
{
|
||||
char *given;
|
||||
/* The filename we offer, or what the user typed so far. */
|
||||
@ -2116,9 +2126,10 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
#endif
|
||||
|
||||
while (TRUE) {
|
||||
int response = 0, choice = 0;
|
||||
functionptrtype func;
|
||||
functionptrtype function;
|
||||
const char *msg;
|
||||
int response = 0;
|
||||
int choice = NO;
|
||||
#ifndef NANO_TINY
|
||||
const char *formatstr = (openfile->fmt == DOS_FILE) ? _(" [DOS Format]") :
|
||||
(openfile->fmt == MAC_FILE) ? _(" [Mac Format]") : "";
|
||||
@ -2162,10 +2173,10 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
return 0;
|
||||
}
|
||||
|
||||
func = func_from_key(&response);
|
||||
function = func_from_key(response);
|
||||
|
||||
/* Upon request, abandon the buffer. */
|
||||
if (func == discard_buffer) {
|
||||
if (function == discard_buffer) {
|
||||
free(given);
|
||||
return 2;
|
||||
}
|
||||
@ -2173,7 +2184,7 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
given = mallocstrcpy(given, answer);
|
||||
|
||||
#ifdef ENABLE_BROWSER
|
||||
if (func == to_files) {
|
||||
if (function == to_files) {
|
||||
char *chosen = browse_in(answer);
|
||||
|
||||
if (chosen == NULL)
|
||||
@ -2184,24 +2195,26 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
} else
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
if (func == dos_format_void) {
|
||||
if (function == dos_format) {
|
||||
openfile->fmt = (openfile->fmt == DOS_FILE) ? NIX_FILE : DOS_FILE;
|
||||
continue;
|
||||
} else if (func == mac_format_void) {
|
||||
} else if (function == mac_format) {
|
||||
openfile->fmt = (openfile->fmt == MAC_FILE) ? NIX_FILE : MAC_FILE;
|
||||
continue;
|
||||
} else if (func == backup_file_void) {
|
||||
} else if (function == back_it_up) {
|
||||
TOGGLE(MAKE_BACKUP);
|
||||
continue;
|
||||
} else if (func == prepend_void) {
|
||||
method = (method == PREPEND) ? OVERWRITE : PREPEND;
|
||||
} else if (function == prepend_it || function == append_it) {
|
||||
if (function == prepend_it)
|
||||
method = (method == PREPEND) ? OVERWRITE : PREPEND;
|
||||
else
|
||||
method = (method == APPEND) ? OVERWRITE : APPEND;
|
||||
if (strcmp(answer, openfile->filename) == 0)
|
||||
given[0] = '\0';
|
||||
continue;
|
||||
} else if (func == append_void) {
|
||||
method = (method == APPEND) ? OVERWRITE : APPEND;
|
||||
continue;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if (func == do_help)
|
||||
if (function == do_help)
|
||||
continue;
|
||||
|
||||
#ifdef ENABLE_EXTRA
|
||||
@ -2257,8 +2270,8 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
if (exiting || !openfile->mark)
|
||||
#endif
|
||||
{
|
||||
if (do_yesno_prompt(FALSE, _("Save file under "
|
||||
"DIFFERENT NAME? ")) < 1)
|
||||
if (ask_user(YESORNO, _("Save file under "
|
||||
"DIFFERENT NAME? ")) != YES)
|
||||
continue;
|
||||
maychange = TRUE;
|
||||
}
|
||||
@ -2271,12 +2284,12 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
|
||||
sprintf(message, question, name);
|
||||
|
||||
choice = do_yesno_prompt(FALSE, message);
|
||||
choice = ask_user(YESORNO, message);
|
||||
|
||||
free(message);
|
||||
free(name);
|
||||
|
||||
if (choice < 1)
|
||||
if (choice != YES)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -2292,7 +2305,7 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
warn_and_briefly_pause(_("File on disk has changed"));
|
||||
|
||||
/* TRANSLATORS: Try to keep this at most 76 characters. */
|
||||
choice = do_yesno_prompt(FALSE, _("File was modified "
|
||||
choice = ask_user(YESORNO, _("File was modified "
|
||||
"since you opened it; continue saving? "));
|
||||
wipe_statusbar();
|
||||
|
||||
@ -2300,14 +2313,16 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
* overwrite the file right here when requested. */
|
||||
if (ISSET(SAVE_ON_EXIT) && withprompt) {
|
||||
free(given);
|
||||
if (choice == 1)
|
||||
if (choice == YES)
|
||||
return write_file(openfile->filename, NULL,
|
||||
NORMAL, OVERWRITE, NONOTES);
|
||||
else if (choice == 0)
|
||||
else if (choice == NO) /* Discard buffer */
|
||||
return 2;
|
||||
else
|
||||
return 0;
|
||||
} else if (choice != 1) {
|
||||
} else if (choice == CANCEL && exiting) {
|
||||
continue;
|
||||
} else if (choice != YES) {
|
||||
free(given);
|
||||
return 1;
|
||||
}
|
||||
@ -2331,17 +2346,17 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
}
|
||||
|
||||
/* Write the current buffer to disk, or discard it. */
|
||||
void do_writeout_void(void)
|
||||
void do_writeout(void)
|
||||
{
|
||||
/* If the user chose to discard the buffer, close it. */
|
||||
if (do_writeout(FALSE, TRUE) == 2)
|
||||
if (write_it_out(FALSE, TRUE) == 2)
|
||||
close_and_go();
|
||||
}
|
||||
|
||||
/* If it has a name, write the current buffer to disk without prompting. */
|
||||
void do_savefile(void)
|
||||
{
|
||||
if (do_writeout(FALSE, FALSE) == 2)
|
||||
if (write_it_out(FALSE, FALSE) == 2)
|
||||
close_and_go();
|
||||
}
|
||||
|
||||
@ -2418,13 +2433,13 @@ int diralphasort(const void *va, const void *vb)
|
||||
/* Return TRUE when the given path is a directory. */
|
||||
bool is_dir(const char *path)
|
||||
{
|
||||
char *realpath = real_dir_from_tilde(path);
|
||||
char *thepath = real_dir_from_tilde(path);
|
||||
struct stat fileinfo;
|
||||
bool retval;
|
||||
|
||||
retval = (stat(realpath, &fileinfo) != -1 && S_ISDIR(fileinfo.st_mode));
|
||||
retval = (stat(thepath, &fileinfo) != -1 && S_ISDIR(fileinfo.st_mode));
|
||||
|
||||
free(realpath);
|
||||
free(thepath);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@ -2472,8 +2487,8 @@ char **username_completion(const char *morsel, size_t length, size_t *num_matche
|
||||
* This code is 'as is' with no warranty.
|
||||
* This code may safely be consumed by a BSD or GPL license. */
|
||||
|
||||
/* Try to complete the given fragment of given length to a filename. */
|
||||
char **filename_completion(const char *morsel, size_t length, size_t *num_matches)
|
||||
/* Try to complete the given fragment to an existing filename. */
|
||||
char **filename_completion(const char *morsel, size_t *num_matches)
|
||||
{
|
||||
char *dirname = copy_of(morsel);
|
||||
char *slash, *filename;
|
||||
@ -2566,7 +2581,7 @@ char *input_tab(char *morsel, size_t *place, void (*refresh_func)(void), bool *l
|
||||
|
||||
/* If there are no matches yet, try matching against filenames. */
|
||||
if (matches == NULL)
|
||||
matches = filename_completion(morsel, *place, &num_matches);
|
||||
matches = filename_completion(morsel, &num_matches);
|
||||
|
||||
/* If possible completions were listed before but none will be listed now... */
|
||||
if (*listed && num_matches < 2) {
|
||||
@ -2629,6 +2644,7 @@ char *input_tab(char *morsel, size_t *place, void (*refresh_func)(void), bool *l
|
||||
|
||||
/* If there is more than one possible completion, show a sorted list. */
|
||||
if (num_matches > 1) {
|
||||
int lastrow = editwinrows - 1 - (ISSET(ZERO) && LINES > 1 ? 1 : 0);
|
||||
size_t longest_name = 0;
|
||||
size_t nrows, ncols;
|
||||
int row;
|
||||
@ -2654,7 +2670,7 @@ char *input_tab(char *morsel, size_t *place, void (*refresh_func)(void), bool *l
|
||||
ncols = (COLS + 1) / (longest_name + 2);
|
||||
nrows = (num_matches + ncols - 1) / ncols;
|
||||
|
||||
row = (nrows < editwinrows - 1) ? editwinrows - nrows - 1 : 0;
|
||||
row = (nrows < lastrow) ? lastrow - nrows : 0;
|
||||
|
||||
/* Blank the edit window and hide the cursor. */
|
||||
blank_edit();
|
||||
@ -2664,23 +2680,23 @@ char *input_tab(char *morsel, size_t *place, void (*refresh_func)(void), bool *l
|
||||
for (match = 0; match < num_matches; match++) {
|
||||
char *disp;
|
||||
|
||||
wmove(edit, row, (longest_name + 2) * (match % ncols));
|
||||
wmove(midwin, row, (longest_name + 2) * (match % ncols));
|
||||
|
||||
if (row == editwinrows - 1 && (match + 1) % ncols == 0 &&
|
||||
if (row == lastrow && (match + 1) % ncols == 0 &&
|
||||
match + 1 < num_matches) {
|
||||
waddstr(edit, _("(more)"));
|
||||
waddstr(midwin, _("(more)"));
|
||||
break;
|
||||
}
|
||||
|
||||
disp = display_string(matches[match], 0, longest_name, FALSE, FALSE);
|
||||
waddstr(edit, disp);
|
||||
waddstr(midwin, disp);
|
||||
free(disp);
|
||||
|
||||
if ((match + 1) % ncols == 0)
|
||||
row++;
|
||||
}
|
||||
|
||||
wnoutrefresh(edit);
|
||||
wnoutrefresh(midwin);
|
||||
*listed = TRUE;
|
||||
}
|
||||
|
||||
|
||||
138
src/folding.c
Normal file
138
src/folding.c
Normal file
@ -0,0 +1,138 @@
|
||||
/**************************************************************************
|
||||
* folding.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2022 rexy712 *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published *
|
||||
* by the Free Software Foundation, either version 3 of the License, *
|
||||
* or (at your option) any later version. *
|
||||
* *
|
||||
* GNU nano is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty *
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see http://www.gnu.org/licenses/. *
|
||||
* *
|
||||
**************************************************************************/
|
||||
|
||||
#include "prototypes.h"
|
||||
|
||||
#include <ctype.h>
|
||||
/* isspace */
|
||||
|
||||
#ifdef ENABLE_FOLDING
|
||||
|
||||
/* Remove a folded segment from the given line until end of segment */
|
||||
void unfold_folded_segment_from(linestruct *line)
|
||||
{
|
||||
if (line != NULL)
|
||||
refresh_needed = TRUE;
|
||||
for(;line != NULL && line->folded;line = line->next)
|
||||
line->folded = FALSE;
|
||||
}
|
||||
|
||||
/* Remove a folded segment containing the given line */
|
||||
void unfold_folded_segment(linestruct *line)
|
||||
{
|
||||
unfold_folded_segment_from(get_start_of_folded_segment(line));
|
||||
}
|
||||
|
||||
/* Get the first member of the folded segment */
|
||||
linestruct *get_start_of_folded_segment(linestruct *line)
|
||||
{
|
||||
if (!line->folded)
|
||||
return line;
|
||||
|
||||
while (line->prev != NULL && line->prev->folded)
|
||||
line = line->prev;
|
||||
|
||||
return line;
|
||||
}
|
||||
/* Get the last member of the folded segment */
|
||||
linestruct *get_end_of_folded_segment(linestruct *line)
|
||||
{
|
||||
if (!line->folded)
|
||||
return line;
|
||||
|
||||
while (line->next != NULL && line->next->folded)
|
||||
line = line->next;
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
/* Get the span length of a folded_segment */
|
||||
int get_folded_segment_length(linestruct *line)
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
if (!line->folded)
|
||||
return 0;
|
||||
|
||||
line = get_start_of_folded_segment(line);
|
||||
for (;line->next != NULL && line->next->folded;line = line->next)
|
||||
++i;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/* Remove any folded_segments within the range [top, bottom].
|
||||
* Returns true if any segments are removed. */
|
||||
bool do_unfold_segment(linestruct *line)
|
||||
{
|
||||
/* Attempt to find a bracketed region first.
|
||||
* If not, top is unmodified. */
|
||||
if (!line->folded) {
|
||||
linestruct *bot;
|
||||
find_bracketed_region(openfile->current, &line, &bot);
|
||||
}
|
||||
|
||||
if (line->folded) {
|
||||
unfold_folded_segment(line);
|
||||
move_cursor_to_proper_column();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Fold the currently selected lines unless the current selection
|
||||
* already contains a folded_segment. In that case, remove any
|
||||
* segments that are selected. */
|
||||
void do_fold_segment(void)
|
||||
{
|
||||
linestruct *top, *bot;
|
||||
get_range(&top, &bot);
|
||||
|
||||
if (top == bot) {
|
||||
/* First try to unfold if this line/bracketed region is folded */
|
||||
if (do_unfold_segment(top))
|
||||
return;
|
||||
|
||||
/* When not selecting multiple lines, try to find bounding
|
||||
* brackets to act as top and bot. */
|
||||
if (!find_bracketed_region(openfile->current, &top, &bot)) {
|
||||
statusline(AHEM, _("No valid region found for automatic fold"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (linestruct* line = top;line != bot->next;line = line->next)
|
||||
line->folded = TRUE;
|
||||
|
||||
if (top->lineno < openfile->edittop->lineno &&
|
||||
bot->lineno > openfile->edittop->lineno)
|
||||
openfile->edittop = top;
|
||||
|
||||
/* Place the cursor at the start of the fold segment.
|
||||
* Anywhere else within the segment is invalid. */
|
||||
if (openfile->current->folded)
|
||||
openfile->current = get_start_of_folded_segment(top);
|
||||
openfile->mark = NULL;
|
||||
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
#endif /* ENABLE_FOLDING */
|
||||
729
src/global.c
729
src/global.c
File diff suppressed because it is too large
Load Diff
92
src/help.c
92
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-2023 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2017 Rishabh Dave *
|
||||
* Copyright (C) 2014-2019 Benno Schulenberg *
|
||||
* *
|
||||
@ -50,7 +50,7 @@ void help_init(void)
|
||||
char *ptr;
|
||||
|
||||
/* First, set up the initial help text for the current function. */
|
||||
if (currmenu & (MWHEREIS|MREPLACE|MREPLACEWITH)) {
|
||||
if (currmenu & (MWHEREIS|MREPLACE)) {
|
||||
htx[0] = N_("Search Command Help Text\n\n "
|
||||
"Enter the words or characters you would like to "
|
||||
"search for, and then press Enter. If there is a "
|
||||
@ -65,6 +65,13 @@ void help_init(void)
|
||||
"will be replaced.\n\n The following function keys are "
|
||||
"available in Search mode:\n\n");
|
||||
htx[2] = NULL;
|
||||
} else if (currmenu == MREPLACEWITH) {
|
||||
htx[0] = N_("=== Replacement ===\n\n "
|
||||
"Type the characters that should replace the characters that "
|
||||
"you typed at the previous prompt, and press Enter.\n\n");
|
||||
htx[1] = N_(" The following function keys "
|
||||
"are available at this prompt:\n\n");
|
||||
htx[2] = NULL;
|
||||
} else if (currmenu == MGOTOLINE) {
|
||||
htx[0] = N_("Go To Line Help Text\n\n "
|
||||
"Enter the line number that you wish to go to and hit "
|
||||
@ -126,8 +133,8 @@ void help_init(void)
|
||||
"shown in brackets after the search prompt. Hitting "
|
||||
"Enter without entering any text will perform the "
|
||||
"previous search.\n\n");
|
||||
htx[1] = N_(" The following function keys are available in "
|
||||
"Browser Search mode:\n\n");
|
||||
htx[1] = N_(" The following function keys "
|
||||
"are available at this prompt:\n\n");
|
||||
htx[2] = NULL;
|
||||
} else if (currmenu == MGOTODIR) {
|
||||
htx[0] = N_("Browser Go To Directory Help Text\n\n "
|
||||
@ -167,8 +174,8 @@ void help_init(void)
|
||||
htx[1] = N_("If you just need another blank buffer, do not enter any "
|
||||
"command.\n\n You can also pick one of four tools, or cut a "
|
||||
"large piece of the buffer, or put the editor to sleep.\n\n");
|
||||
htx[2] = N_(" The following function keys are "
|
||||
"available in Execute Command mode:\n\n");
|
||||
htx[2] = N_(" The following function keys "
|
||||
"are available at this prompt:\n\n");
|
||||
} else if (currmenu == MLINTER) {
|
||||
htx[0] = N_("=== Linter ===\n\n "
|
||||
"In this mode, the status bar shows an error message or "
|
||||
@ -224,7 +231,7 @@ void help_init(void)
|
||||
* plus translated text, plus one or two \n's. */
|
||||
for (f = allfuncs; f != NULL; f = f->next)
|
||||
if (f->menus & currmenu)
|
||||
allocsize += strlen(_(f->help)) + 21;
|
||||
allocsize += strlen(_(f->phrase)) + 21;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If we're on the main list, we also count the toggle help text.
|
||||
@ -234,8 +241,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
|
||||
|
||||
@ -282,7 +289,7 @@ void help_init(void)
|
||||
ptr += 10;
|
||||
|
||||
/* The shortcut's description. */
|
||||
ptr += sprintf(ptr, "%s\n", _(f->help));
|
||||
ptr += sprintf(ptr, "%s\n", _(f->phrase));
|
||||
|
||||
if (f->blank_after)
|
||||
ptr += sprintf(ptr, "\n");
|
||||
@ -303,8 +310,9 @@ void help_init(void)
|
||||
for (s = sclist; s != NULL; s = s->next)
|
||||
if (s->toggle && s->ordinal == counter) {
|
||||
ptr += sprintf(ptr, "%s\t\t %s %s\n", (s->menus & MMAIN ? s->keystr : ""),
|
||||
_(flagtostr(s->toggle)), _("enable/disable"));
|
||||
if (s->toggle == NO_SYNTAX || s->toggle == TABS_TO_SPACES)
|
||||
_(epithet_of_flag(s->toggle)), _("enable/disable"));
|
||||
/* Add a blank like between two groups. */
|
||||
if (s->toggle == NO_SYNTAX)
|
||||
ptr += sprintf(ptr, "\n");
|
||||
break;
|
||||
}
|
||||
@ -316,13 +324,20 @@ void help_init(void)
|
||||
/* Hard-wrap the concatenated help text, and write it into a new buffer. */
|
||||
void wrap_help_text_into_buffer(void)
|
||||
{
|
||||
size_t sum = 0;
|
||||
/* Avoid overtight and overwide paragraphs in the introductory text. */
|
||||
size_t wrapping_point = ((COLS < 40) ? 40 : (COLS > 74) ? 74 : COLS) - thebar;
|
||||
const char *ptr = start_of_body;
|
||||
size_t sum = 0;
|
||||
|
||||
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;
|
||||
@ -381,7 +396,7 @@ void wrap_help_text_into_buffer(void)
|
||||
void show_help(void)
|
||||
{
|
||||
int kbinput = ERR;
|
||||
functionptrtype func;
|
||||
functionptrtype function;
|
||||
/* The function of the key the user typed in. */
|
||||
int oldmenu = currmenu;
|
||||
/* The menu we were called from. */
|
||||
@ -403,8 +418,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 +431,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,41 +470,40 @@ 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();
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
func = interpret(&kbinput);
|
||||
function = interpret(kbinput);
|
||||
|
||||
if (func == full_refresh) {
|
||||
if (function == full_refresh) {
|
||||
full_refresh();
|
||||
} else if (ISSET(SHOW_CURSOR) && (func == do_left || func == do_right ||
|
||||
func == do_up || func == do_down)) {
|
||||
func();
|
||||
} else if (func == do_up || func == do_scroll_up) {
|
||||
} else if (ISSET(SHOW_CURSOR) && (function == do_left || function == do_right ||
|
||||
function == do_up || function == do_down)) {
|
||||
function();
|
||||
} else if (function == do_up || function == do_scroll_up) {
|
||||
do_scroll_up();
|
||||
} else if (func == do_down || func == do_scroll_down) {
|
||||
} else if (function == do_down || function == do_scroll_down) {
|
||||
if (openfile->edittop->lineno + editwinrows - 1 < openfile->filebot->lineno)
|
||||
do_scroll_down();
|
||||
} else if (func == do_page_up || func == do_page_down ||
|
||||
func == to_first_line || func == to_last_line) {
|
||||
func();
|
||||
} else if (func == do_search_backward || func == do_search_forward ||
|
||||
func == do_findprevious || func == do_findnext) {
|
||||
func();
|
||||
} else if (function == do_page_up || function == do_page_down ||
|
||||
function == to_first_line || function == to_last_line) {
|
||||
function();
|
||||
} else if (function == do_search_backward || function == do_search_forward ||
|
||||
function == do_findprevious || function == do_findnext) {
|
||||
function();
|
||||
bottombars(MHELP);
|
||||
#ifdef ENABLE_NANORC
|
||||
} else if (func == (functionptrtype)implant) {
|
||||
implant(first_sc_for(MHELP, func)->expansion);
|
||||
} else if (function == (functionptrtype)implant) {
|
||||
implant(first_sc_for(MHELP, function)->expansion);
|
||||
#endif
|
||||
#ifdef ENABLE_MOUSE
|
||||
} else if (kbinput == KEY_MOUSE) {
|
||||
@ -501,7 +514,7 @@ void show_help(void)
|
||||
} else if (kbinput == KEY_WINCH) {
|
||||
; /* Nothing to do. */
|
||||
#endif
|
||||
} else if (func == do_exit) {
|
||||
} else if (function == do_exit) {
|
||||
break;
|
||||
} else
|
||||
unbound_key(kbinput);
|
||||
@ -543,13 +556,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))
|
||||
|
||||
233
src/history.c
233
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-2023 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
|
||||
@ -333,12 +304,10 @@ bool write_list(const linestruct *head, FILE *histfile)
|
||||
const linestruct *item;
|
||||
|
||||
for (item = head; item != NULL; item = item->next) {
|
||||
size_t length = strlen(item->data);
|
||||
|
||||
/* Decode 0x0A bytes as embedded NULs. */
|
||||
recode_LF_to_NUL(item->data);
|
||||
size_t length = recode_LF_to_NUL(item->data);
|
||||
|
||||
if (fwrite(item->data, sizeof(char), length, histfile) < length)
|
||||
if (fwrite(item->data, 1, length, histfile) < length)
|
||||
return FALSE;
|
||||
if (putc('\n', histfile) == EOF)
|
||||
return FALSE;
|
||||
@ -394,12 +363,14 @@ void load_poshistory(void)
|
||||
if (histfile == NULL)
|
||||
return;
|
||||
|
||||
ssize_t read, count = 0;
|
||||
struct stat fileinfo;
|
||||
poshiststruct *record_ptr = NULL, *newrecord;
|
||||
poshiststruct *lastitem = NULL;
|
||||
poshiststruct *newitem;
|
||||
char *lineptr, *columnptr;
|
||||
char *stanza = NULL;
|
||||
struct stat fileinfo;
|
||||
size_t dummy = 0;
|
||||
ssize_t count = 0;
|
||||
ssize_t read;
|
||||
|
||||
/* Read and parse each line, and store the extracted data. */
|
||||
while ((read = getline(&stanza, &dummy, histfile)) > 5) {
|
||||
@ -419,19 +390,19 @@ void load_poshistory(void)
|
||||
*(lineptr++) = '\0';
|
||||
|
||||
/* Create a new position record. */
|
||||
newrecord = nmalloc(sizeof(poshiststruct));
|
||||
newrecord->filename = copy_of(stanza);
|
||||
newrecord->linenumber = atoi(lineptr);
|
||||
newrecord->columnnumber = atoi(columnptr);
|
||||
newrecord->next = NULL;
|
||||
newitem = nmalloc(sizeof(poshiststruct));
|
||||
newitem->filename = copy_of(stanza);
|
||||
newitem->linenumber = atoi(lineptr);
|
||||
newitem->columnnumber = atoi(columnptr);
|
||||
newitem->next = NULL;
|
||||
|
||||
/* Add the record to the list. */
|
||||
if (position_history == NULL)
|
||||
position_history = newrecord;
|
||||
position_history = newitem;
|
||||
else
|
||||
record_ptr->next = newrecord;
|
||||
lastitem->next = newitem;
|
||||
|
||||
record_ptr = newrecord;
|
||||
lastitem = newitem;
|
||||
|
||||
/* Impose a limit, so the file will not grow indefinitely. */
|
||||
if (++count > 200) {
|
||||
@ -456,9 +427,9 @@ void load_poshistory(void)
|
||||
/* Save the recorded cursor positions for files that were edited. */
|
||||
void save_poshistory(void)
|
||||
{
|
||||
poshiststruct *posptr;
|
||||
struct stat fileinfo;
|
||||
FILE *histfile = fopen(poshistname, "wb");
|
||||
struct stat fileinfo;
|
||||
poshiststruct *item;
|
||||
|
||||
if (histfile == NULL) {
|
||||
jot_error(N_("Error writing %s: %s"), poshistname, strerror(errno));
|
||||
@ -469,23 +440,22 @@ void save_poshistory(void)
|
||||
if (chmod(poshistname, S_IRUSR | S_IWUSR) < 0)
|
||||
jot_error(N_("Cannot limit permissions on %s: %s"), poshistname, strerror(errno));
|
||||
|
||||
for (posptr = position_history; posptr != NULL; posptr = posptr->next) {
|
||||
for (item = position_history; item != NULL; item = item->next) {
|
||||
char *path_and_place;
|
||||
size_t length;
|
||||
|
||||
/* Assume 20 decimal positions each for line and column number,
|
||||
* plus two spaces, plus the line feed, plus the null byte. */
|
||||
path_and_place = nmalloc(strlen(posptr->filename) + 44);
|
||||
path_and_place = nmalloc(strlen(item->filename) + 44);
|
||||
sprintf(path_and_place, "%s %zd %zd\n",
|
||||
posptr->filename, posptr->linenumber, posptr->columnnumber);
|
||||
length = strlen(path_and_place);
|
||||
item->filename, item->linenumber, item->columnnumber);
|
||||
|
||||
/* Encode newlines in filenames as NULs. */
|
||||
recode_LF_to_NUL(path_and_place);
|
||||
length = recode_LF_to_NUL(path_and_place);
|
||||
/* Restore the terminating newline. */
|
||||
path_and_place[length - 1] = '\n';
|
||||
|
||||
if (fwrite(path_and_place, sizeof(char), length, histfile) < length)
|
||||
if (fwrite(path_and_place, 1, length, histfile) < length)
|
||||
jot_error(N_("Error writing %s: %s"), poshistname, strerror(errno));
|
||||
|
||||
free(path_and_place);
|
||||
@ -501,29 +471,30 @@ void save_poshistory(void)
|
||||
/* Reload the position history file if it has been modified since last load. */
|
||||
void reload_positions_if_needed(void)
|
||||
{
|
||||
poshiststruct *item, *nextone;
|
||||
struct stat fileinfo;
|
||||
|
||||
if (stat(poshistname, &fileinfo) == 0 && fileinfo.st_mtime != latest_timestamp) {
|
||||
poshiststruct *item, *nextone;
|
||||
if (stat(poshistname, &fileinfo) != 0 || fileinfo.st_mtime == latest_timestamp)
|
||||
return;
|
||||
|
||||
for (item = position_history; item != NULL; item = nextone) {
|
||||
nextone = item->next;
|
||||
free(item->filename);
|
||||
free(item);
|
||||
}
|
||||
|
||||
position_history = NULL;
|
||||
|
||||
load_poshistory();
|
||||
for (item = position_history; item != NULL; item = nextone) {
|
||||
nextone = item->next;
|
||||
free(item->filename);
|
||||
free(item);
|
||||
}
|
||||
|
||||
position_history = NULL;
|
||||
|
||||
load_poshistory();
|
||||
}
|
||||
|
||||
/* Update the recorded last file positions with the current position in the
|
||||
* current buffer. If no existing entry is found, add a new one at the end. */
|
||||
void update_poshistory(void)
|
||||
{
|
||||
poshiststruct *posptr, *theone, *posprev = NULL;
|
||||
char *fullpath = get_full_path(openfile->filename);
|
||||
poshiststruct *previous = NULL;
|
||||
poshiststruct *item, *theone;
|
||||
|
||||
if (fullpath == NULL || openfile->filename[0] == '\0') {
|
||||
free(fullpath);
|
||||
@ -533,28 +504,28 @@ void update_poshistory(void)
|
||||
reload_positions_if_needed();
|
||||
|
||||
/* Look for a matching filename in the list. */
|
||||
for (posptr = position_history; posptr != NULL; posptr = posptr->next) {
|
||||
if (!strcmp(posptr->filename, fullpath))
|
||||
for (item = position_history; item != NULL; item = item->next) {
|
||||
if (!strcmp(item->filename, fullpath))
|
||||
break;
|
||||
posprev = posptr;
|
||||
previous = item;
|
||||
}
|
||||
|
||||
/* Don't record files that have the default cursor position. */
|
||||
if (openfile->current->lineno == 1 && openfile->current_x == 0) {
|
||||
if (posptr != NULL) {
|
||||
if (posprev == NULL)
|
||||
position_history = posptr->next;
|
||||
if (item != NULL) {
|
||||
if (previous == NULL)
|
||||
position_history = item->next;
|
||||
else
|
||||
posprev->next = posptr->next;
|
||||
free(posptr->filename);
|
||||
free(posptr);
|
||||
previous->next = item->next;
|
||||
free(item->filename);
|
||||
free(item);
|
||||
save_poshistory();
|
||||
}
|
||||
free(fullpath);
|
||||
return;
|
||||
}
|
||||
|
||||
theone = posptr;
|
||||
theone = item;
|
||||
|
||||
/* If we didn't find it, make a new node; otherwise, if we're
|
||||
* not at the end, move the matching one to the end. */
|
||||
@ -564,15 +535,15 @@ void update_poshistory(void)
|
||||
if (position_history == NULL)
|
||||
position_history = theone;
|
||||
else
|
||||
posprev->next = theone;
|
||||
} else if (posptr->next != NULL) {
|
||||
if (posprev == NULL)
|
||||
position_history = posptr->next;
|
||||
previous->next = theone;
|
||||
} else if (item->next != NULL) {
|
||||
if (previous == NULL)
|
||||
position_history = item->next;
|
||||
else
|
||||
posprev->next = posptr->next;
|
||||
while (posptr->next != NULL)
|
||||
posptr = posptr->next;
|
||||
posptr->next = theone;
|
||||
previous->next = item->next;
|
||||
while (item->next != NULL)
|
||||
item = item->next;
|
||||
item->next = theone;
|
||||
}
|
||||
|
||||
/* Store the last cursor position. */
|
||||
@ -590,25 +561,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 */
|
||||
|
||||
173
src/move.c
173
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-2023 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2018 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@ -37,13 +37,22 @@ void to_first_line(void)
|
||||
void to_last_line(void)
|
||||
{
|
||||
openfile->current = openfile->filebot;
|
||||
openfile->current_x = (inhelp) ? 0 : strlen(openfile->filebot->data);
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (openfile->current->folded) {
|
||||
openfile->current = get_start_of_folded_segment(openfile->current);
|
||||
openfile->current_x = 0;
|
||||
} else
|
||||
#endif
|
||||
openfile->current_x = (inhelp) ? 0 : strlen(openfile->filebot->data);
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
/* Set the last line of the screen as the target for the cursor. */
|
||||
openfile->current_y = editwinrows - 1;
|
||||
|
||||
refresh_needed = TRUE;
|
||||
#ifdef ENABLE_COLOR
|
||||
recook |= perturbed;
|
||||
#endif
|
||||
focusing = FALSE;
|
||||
}
|
||||
|
||||
@ -95,8 +104,8 @@ size_t proper_x(linestruct *line, size_t *leftedge, bool forward,
|
||||
* the middle of a tab that crosses a row boundary. */
|
||||
void set_proper_index_and_pww(size_t *leftedge, size_t target, bool forward)
|
||||
{
|
||||
bool shifted = FALSE;
|
||||
size_t was_edge = *leftedge;
|
||||
bool shifted = FALSE;
|
||||
|
||||
openfile->current_x = proper_x(openfile->current, leftedge, forward,
|
||||
actual_last_column(*leftedge, target), &shifted);
|
||||
@ -109,6 +118,15 @@ void set_proper_index_and_pww(size_t *leftedge, size_t target, bool forward)
|
||||
openfile->placewewant = *leftedge + target;
|
||||
}
|
||||
|
||||
/* Move the cursor position on the current line to the desired column */
|
||||
void move_cursor_to_proper_column(void)
|
||||
{
|
||||
size_t leftedge;
|
||||
size_t target_column;
|
||||
get_edge_and_target(&leftedge, &target_column);
|
||||
set_proper_index_and_pww(&leftedge, target_column, TRUE);
|
||||
}
|
||||
|
||||
/* Move up almost one screenful. */
|
||||
void do_page_up(void)
|
||||
{
|
||||
@ -222,6 +240,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 */
|
||||
|
||||
@ -229,19 +250,28 @@ void to_para_end(void)
|
||||
void to_prev_block(void)
|
||||
{
|
||||
linestruct *was_current = openfile->current;
|
||||
linestruct *line_step = get_prev_visible_line(openfile->current);
|
||||
bool is_text = FALSE, seen_text = FALSE;
|
||||
|
||||
/* Skip backward until first blank line after some nonblank line(s). */
|
||||
while (openfile->current->prev != NULL && (!seen_text || is_text)) {
|
||||
openfile->current = openfile->current->prev;
|
||||
while (line_step != NULL && (!seen_text || is_text)) {
|
||||
openfile->current = line_step;
|
||||
line_step = get_prev_visible_line(line_step);
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (openfile->current->folded)
|
||||
continue;
|
||||
#endif
|
||||
is_text = !white_string(openfile->current->data);
|
||||
seen_text = seen_text || is_text;
|
||||
}
|
||||
|
||||
/* Step forward one line again if we passed text but this line is blank. */
|
||||
if (seen_text && openfile->current->next != NULL &&
|
||||
white_string(openfile->current->data))
|
||||
openfile->current = openfile->current->next;
|
||||
line_step = get_next_visible_line(openfile->current);
|
||||
if (seen_text && line_step != NULL &&
|
||||
white_string(openfile->current->data)) {
|
||||
openfile->current = line_step;
|
||||
line_step = get_next_visible_line(line_step);
|
||||
}
|
||||
|
||||
openfile->current_x = 0;
|
||||
edit_redraw(was_current, CENTERING);
|
||||
@ -251,33 +281,57 @@ void to_prev_block(void)
|
||||
void to_next_block(void)
|
||||
{
|
||||
linestruct *was_current = openfile->current;
|
||||
linestruct *line_step = get_next_visible_line(openfile->current);
|
||||
bool is_white = white_string(openfile->current->data);
|
||||
bool seen_white = is_white;
|
||||
|
||||
/* Skip forward until first nonblank line after some blank line(s). */
|
||||
while (openfile->current->next != NULL && (!seen_white || is_white)) {
|
||||
openfile->current = openfile->current->next;
|
||||
while (line_step != NULL && (!seen_white || is_white)) {
|
||||
openfile->current = line_step;
|
||||
line_step = get_next_visible_line(line_step);
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (openfile->current->folded)
|
||||
continue;
|
||||
#endif
|
||||
is_white = white_string(openfile->current->data);
|
||||
seen_white = seen_white || is_white;
|
||||
}
|
||||
|
||||
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.
|
||||
* when allow_folded as true, will move to previous word even if inside
|
||||
* a folded segment */
|
||||
void do_prev_word(bool allow_folded)
|
||||
{
|
||||
bool punctuation_as_letters = ISSET(WORD_BOUNDS);
|
||||
bool seen_a_word = FALSE, step_forward = FALSE;
|
||||
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (!allow_folded && openfile->current->folded) {
|
||||
openfile->current = get_prev_visible_line(openfile->current);
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
}
|
||||
#endif
|
||||
/* Move backward until we pass over the start of a word. */
|
||||
while (TRUE) {
|
||||
/* If at the head of a line, move to the end of the preceding one. */
|
||||
if (openfile->current_x == 0) {
|
||||
if (openfile->current->prev == NULL)
|
||||
break;
|
||||
openfile->current = openfile->current->prev;
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (!allow_folded) {
|
||||
openfile->current = get_prev_visible_line(openfile->current);
|
||||
if (openfile->current->folded)
|
||||
openfile->current = openfile->current->prev;
|
||||
} else
|
||||
#endif
|
||||
openfile->current = openfile->current->prev;
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
}
|
||||
|
||||
@ -286,7 +340,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)
|
||||
@ -306,20 +360,29 @@ void do_prev_word(bool allow_punct)
|
||||
/* Move one character forward again to sit on the start of the word. */
|
||||
openfile->current_x = step_right(openfile->current->data,
|
||||
openfile->current_x);
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
}
|
||||
|
||||
/* 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. If allow_folded is true, go to next word
|
||||
* even if it's inside a folded segment.
|
||||
* Return TRUE if we started on a word. */
|
||||
bool do_next_word(bool after_ends, bool allow_folded)
|
||||
{
|
||||
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;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (!allow_folded && openfile->current->folded) {
|
||||
openfile->current = get_next_visible_line(openfile->current);
|
||||
openfile->current_x = 0;
|
||||
}
|
||||
#endif
|
||||
/* Move forward until we reach the start of a word. */
|
||||
while (TRUE) {
|
||||
/* If at the end of a line, move to the beginning of the next one. */
|
||||
@ -327,7 +390,17 @@ bool do_next_word(bool after_ends, bool allow_punct)
|
||||
/* When at end of file, stop. */
|
||||
if (openfile->current->next == NULL)
|
||||
break;
|
||||
openfile->current = openfile->current->next;
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (!allow_folded) {
|
||||
openfile->current = get_next_visible_line(openfile->current);
|
||||
if (openfile->current->folded) {
|
||||
/* get_next_visible_line() gives the start of a segment, so skip to the end */
|
||||
openfile->current = get_end_of_folded_segment(openfile->current);
|
||||
openfile->current = openfile->current->next;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
openfile->current = openfile->current->next;
|
||||
openfile->current_x = 0;
|
||||
seen_space = TRUE;
|
||||
} else {
|
||||
@ -341,7 +414,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,35 +433,35 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
|
||||
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(DISALLOW_FOLDED);
|
||||
|
||||
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), DISALLOW_FOLDED);
|
||||
|
||||
edit_redraw(was_current, FLOWING);
|
||||
}
|
||||
@ -403,12 +476,17 @@ void do_home(void)
|
||||
bool moved_off_chunk = TRUE;
|
||||
#ifndef NANO_TINY
|
||||
bool moved = FALSE;
|
||||
size_t leftedge = 0, leftedge_x = 0;
|
||||
size_t leftedge = 0;
|
||||
size_t left_x = 0;
|
||||
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (openfile->current->folded)
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
leftedge = leftedge_for(was_column, openfile->current);
|
||||
leftedge_x = proper_x(openfile->current, &leftedge, FALSE, leftedge,
|
||||
NULL);
|
||||
left_x = proper_x(openfile->current, &leftedge, FALSE, leftedge, NULL);
|
||||
}
|
||||
|
||||
if (ISSET(SMART_HOME)) {
|
||||
@ -421,7 +499,7 @@ void do_home(void)
|
||||
if (openfile->current_x == indent_x) {
|
||||
openfile->current_x = 0;
|
||||
moved = TRUE;
|
||||
} else if (!ISSET(SOFTWRAP) || leftedge_x <= indent_x) {
|
||||
} else if (left_x <= indent_x) {
|
||||
openfile->current_x = indent_x;
|
||||
moved = TRUE;
|
||||
}
|
||||
@ -431,10 +509,10 @@ void do_home(void)
|
||||
if (!moved && ISSET(SOFTWRAP)) {
|
||||
/* If already at the left edge of the screen, move fully home.
|
||||
* Otherwise, move to the left edge. */
|
||||
if (openfile->current_x == leftedge_x)
|
||||
if (openfile->current_x == left_x)
|
||||
openfile->current_x = 0;
|
||||
else {
|
||||
openfile->current_x = leftedge_x;
|
||||
openfile->current_x = left_x;
|
||||
openfile->placewewant = leftedge;
|
||||
moved_off_chunk = FALSE;
|
||||
}
|
||||
@ -463,13 +541,19 @@ void do_end(void)
|
||||
size_t line_len = strlen(openfile->current->data);
|
||||
bool moved_off_chunk = TRUE;
|
||||
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (openfile->current->folded)
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
bool kickoff = TRUE;
|
||||
bool last_chunk = FALSE;
|
||||
size_t leftedge = leftedge_for(was_column, openfile->current);
|
||||
size_t rightedge = get_softwrap_breakpoint(openfile->current->data,
|
||||
leftedge, &last_chunk);
|
||||
size_t rightedge_x;
|
||||
leftedge, &kickoff, &last_chunk);
|
||||
size_t right_x;
|
||||
|
||||
/* If we're on the last chunk, we're already at the end of the line.
|
||||
* Otherwise, we're one column past the end of the line. Shifting
|
||||
@ -478,14 +562,14 @@ void do_end(void)
|
||||
if (!last_chunk)
|
||||
rightedge--;
|
||||
|
||||
rightedge_x = actual_x(openfile->current->data, rightedge);
|
||||
right_x = actual_x(openfile->current->data, rightedge);
|
||||
|
||||
/* If already at the right edge of the screen, move fully to
|
||||
* the end of the line. Otherwise, move to the right edge. */
|
||||
if (openfile->current_x == rightedge_x)
|
||||
if (openfile->current_x == right_x)
|
||||
openfile->current_x = line_len;
|
||||
else {
|
||||
openfile->current_x = rightedge_x;
|
||||
openfile->current_x = right_x;
|
||||
openfile->placewewant = rightedge;
|
||||
moved_off_chunk = FALSE;
|
||||
}
|
||||
@ -604,7 +688,7 @@ void do_left(void)
|
||||
openfile->current_x);
|
||||
#endif
|
||||
} else if (openfile->current != openfile->filetop) {
|
||||
openfile->current = openfile->current->prev;
|
||||
openfile->current = get_prev_visible_line(openfile->current);
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
}
|
||||
|
||||
@ -616,6 +700,13 @@ void do_right(void)
|
||||
{
|
||||
linestruct *was_current = openfile->current;
|
||||
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (openfile->current->folded) {
|
||||
openfile->current = get_next_visible_line(openfile->current);
|
||||
if (openfile->current == NULL)
|
||||
openfile->current = was_current;
|
||||
} else
|
||||
#endif
|
||||
if (openfile->current->data[openfile->current_x] != '\0') {
|
||||
openfile->current_x = step_right(openfile->current->data,
|
||||
openfile->current_x);
|
||||
@ -626,7 +717,7 @@ void do_right(void)
|
||||
openfile->current_x);
|
||||
#endif
|
||||
} else if (openfile->current != openfile->filebot) {
|
||||
openfile->current = openfile->current->next;
|
||||
openfile->current = get_next_visible_line(openfile->current);
|
||||
openfile->current_x = 0;
|
||||
}
|
||||
|
||||
|
||||
515
src/nano.c
515
src/nano.c
File diff suppressed because it is too large
Load Diff
572
src/prompt.c
572
src/prompt.c
@ -1,8 +1,8 @@
|
||||
/**************************************************************************
|
||||
* prompt.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2016, 2018, 2020 Benno Schulenberg *
|
||||
* Copyright (C) 1999-2011, 2013-2023 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2016, 2018, 2020, 2022 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 *
|
||||
@ -41,6 +41,33 @@ void do_statusbar_end(void)
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Move to the previous word in the answer. */
|
||||
void do_statusbar_prev_word(void)
|
||||
{
|
||||
bool seen_a_word = FALSE, step_forward = FALSE;
|
||||
|
||||
/* Move backward until we pass over the start of a word. */
|
||||
while (typing_x != 0) {
|
||||
typing_x = step_left(answer, typing_x);
|
||||
|
||||
if (is_word_char(answer + typing_x, FALSE))
|
||||
seen_a_word = TRUE;
|
||||
#ifdef ENABLE_UTF8
|
||||
else if (is_zerowidth(answer + typing_x))
|
||||
; /* skip */
|
||||
#endif
|
||||
else if (seen_a_word) {
|
||||
/* This is space now: we've overshot the start of the word. */
|
||||
step_forward = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (step_forward)
|
||||
/* Move one character forward again to sit on the start of the word. */
|
||||
typing_x = step_right(answer, typing_x);
|
||||
}
|
||||
|
||||
/* Move to the next word in the answer. */
|
||||
void do_statusbar_next_word(void)
|
||||
{
|
||||
@ -78,33 +105,6 @@ void do_statusbar_next_word(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Move to the previous word in the answer. */
|
||||
void do_statusbar_prev_word(void)
|
||||
{
|
||||
bool seen_a_word = FALSE, step_forward = FALSE;
|
||||
|
||||
/* Move backward until we pass over the start of a word. */
|
||||
while (typing_x != 0) {
|
||||
typing_x = step_left(answer, typing_x);
|
||||
|
||||
if (is_word_char(answer + typing_x, FALSE))
|
||||
seen_a_word = TRUE;
|
||||
#ifdef ENABLE_UTF8
|
||||
else if (is_zerowidth(answer + typing_x))
|
||||
; /* skip */
|
||||
#endif
|
||||
else if (seen_a_word) {
|
||||
/* This is space now: we've overshot the start of the word. */
|
||||
step_forward = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (step_forward)
|
||||
/* Move one character forward again to sit on the start of the word. */
|
||||
typing_x = step_right(answer, typing_x);
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Move left one character in the answer. */
|
||||
@ -131,6 +131,17 @@ void do_statusbar_right(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Backspace over one character in the answer. */
|
||||
void do_statusbar_backspace(void)
|
||||
{
|
||||
if (typing_x > 0) {
|
||||
size_t was_x = typing_x;
|
||||
|
||||
typing_x = step_left(answer, typing_x);
|
||||
memmove(answer + typing_x, answer + was_x, strlen(answer) - was_x + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Delete one character in the answer. */
|
||||
void do_statusbar_delete(void)
|
||||
{
|
||||
@ -146,42 +157,40 @@ void do_statusbar_delete(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Backspace over one character in the answer. */
|
||||
void do_statusbar_backspace(void)
|
||||
/* Zap the part of the answer after the cursor, or the whole answer. */
|
||||
void lop_the_answer(void)
|
||||
{
|
||||
if (typing_x > 0) {
|
||||
size_t was_x = typing_x;
|
||||
|
||||
typing_x = step_left(answer, typing_x);
|
||||
memmove(answer + typing_x, answer + was_x, strlen(answer) - was_x + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Zap some or all text from the answer. */
|
||||
void do_statusbar_cut_text(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)
|
||||
{
|
||||
size_t pastelen = strlen(cutbuffer->data);
|
||||
char *fusion = nmalloc(strlen(answer) + pastelen + 1);
|
||||
|
||||
/* Concatenate: the current answer before the cursor, the first line
|
||||
* of the cutbuffer, plus the rest of the current answer. */
|
||||
strncpy(fusion, answer, typing_x);
|
||||
strncpy(fusion + typing_x, cutbuffer->data, pastelen);
|
||||
strcpy(fusion + typing_x + pastelen, answer + typing_x);
|
||||
answer = nrealloc(answer, strlen(answer) + pastelen + 1);
|
||||
memmove(answer + typing_x + pastelen, answer + typing_x,
|
||||
strlen(answer) - typing_x + 1);
|
||||
strncpy(answer + typing_x, cutbuffer->data, pastelen);
|
||||
|
||||
free(answer);
|
||||
answer = fusion;
|
||||
typing_x += pastelen;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_MOUSE
|
||||
/* Handle a mouse click on the status-bar prompt or the shortcut list. */
|
||||
@ -191,7 +200,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 +225,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 +236,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);
|
||||
@ -237,127 +246,92 @@ void do_statusbar_verbatim_input(void)
|
||||
free(bytes);
|
||||
}
|
||||
|
||||
/* Read in a keystroke, interpret it if it is a shortcut or toggle, and
|
||||
* return it. Set finished to TRUE if we're done after running
|
||||
* or trying to run a function associated with a shortcut key. */
|
||||
int do_statusbar_input(bool *finished)
|
||||
/* Add the given input to the input buffer when it's a normal byte,
|
||||
* and inject the gathered bytes into the answer when ready. */
|
||||
void absorb_character(int input, functionptrtype function)
|
||||
{
|
||||
int input;
|
||||
/* The character we read in. */
|
||||
static char *puddle = NULL;
|
||||
/* The input buffer. */
|
||||
static size_t capacity = 8;
|
||||
/* The size of the input buffer; gets doubled whenever needed. */
|
||||
static size_t depth = 0;
|
||||
/* The length of the input buffer. */
|
||||
const keystruct *shortcut;
|
||||
|
||||
*finished = FALSE;
|
||||
|
||||
/* Read in a character. */
|
||||
input = get_kbinput(bottomwin, VISIBLE);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (input == KEY_WINCH)
|
||||
return KEY_WINCH;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_MOUSE
|
||||
/* If we got a mouse click and it was on a shortcut, read in the
|
||||
* shortcut character. */
|
||||
if (input == KEY_MOUSE) {
|
||||
if (do_statusbar_mouse() == 1)
|
||||
input = get_kbinput(bottomwin, BLIND);
|
||||
else
|
||||
return ERR;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Check for a shortcut in the current list. */
|
||||
shortcut = get_shortcut(&input);
|
||||
|
||||
/* If not a command, discard anything that is not a normal character byte.
|
||||
* Apart from that, only accept input when not in restricted mode, or when
|
||||
* not at the "Write File" prompt, or when there is no filename yet. */
|
||||
if (shortcut == NULL) {
|
||||
if (!function) {
|
||||
if (input < 0x20 || input > 0xFF || meta_key)
|
||||
beep();
|
||||
else if (!ISSET(RESTRICTED) || currmenu != MWRITEFILE ||
|
||||
openfile->filename[0] == '\0') {
|
||||
puddle = nrealloc(puddle, depth + 2);
|
||||
/* When the input buffer (plus room for terminating NUL) is full,
|
||||
* extend it; otherwise, if it does not exist yet, create it. */
|
||||
if (depth + 1 == capacity) {
|
||||
capacity = 2 * capacity;
|
||||
puddle = nrealloc(puddle, capacity);
|
||||
} else if (!puddle)
|
||||
puddle = nmalloc(capacity);
|
||||
|
||||
puddle[depth++] = (char)input;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 there are gathered bytes and we have a command or no other key codes
|
||||
* are waiting, it's time to insert these bytes into the answer. */
|
||||
if (depth > 0 && (function || waiting_keycodes() == 0)) {
|
||||
puddle[depth] = '\0';
|
||||
|
||||
inject_into_answer(puddle, depth);
|
||||
|
||||
free(puddle);
|
||||
puddle = NULL;
|
||||
depth = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (shortcut) {
|
||||
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)
|
||||
;
|
||||
#endif
|
||||
else if (shortcut->func == do_left)
|
||||
do_statusbar_left();
|
||||
else if (shortcut->func == do_right)
|
||||
do_statusbar_right();
|
||||
/* Handle any editing shortcut, and return TRUE when handled. */
|
||||
bool handle_editing(functionptrtype function)
|
||||
{
|
||||
if (function == do_left)
|
||||
do_statusbar_left();
|
||||
else if (function == do_right)
|
||||
do_statusbar_right();
|
||||
#ifndef NANO_TINY
|
||||
else if (shortcut->func == to_prev_word)
|
||||
do_statusbar_prev_word();
|
||||
else if (shortcut->func == to_next_word)
|
||||
do_statusbar_next_word();
|
||||
else if (function == to_prev_word)
|
||||
do_statusbar_prev_word();
|
||||
else if (function == to_next_word)
|
||||
do_statusbar_next_word();
|
||||
#endif
|
||||
else if (shortcut->func == do_home)
|
||||
do_statusbar_home();
|
||||
else if (shortcut->func == do_end)
|
||||
do_statusbar_end();
|
||||
/* When in restricted mode at the "Write File" prompt and the
|
||||
* filename isn't blank, disallow any input and deletion. */
|
||||
else if (ISSET(RESTRICTED) && currmenu == MWRITEFILE &&
|
||||
openfile->filename[0] != '\0' &&
|
||||
(shortcut->func == do_verbatim_input ||
|
||||
shortcut->func == cut_text ||
|
||||
shortcut->func == paste_text ||
|
||||
shortcut->func == do_delete ||
|
||||
shortcut->func == do_backspace))
|
||||
;
|
||||
#ifdef ENABLE_NANORC
|
||||
else if (shortcut->func == (functionptrtype)implant)
|
||||
implant(shortcut->expansion);
|
||||
#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 == paste_text) {
|
||||
if (cutbuffer != NULL)
|
||||
paste_into_answer();
|
||||
} 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. */
|
||||
if (!ISSET(VIEW_MODE) || okay_for_view(shortcut))
|
||||
shortcut->func();
|
||||
*finished = TRUE;
|
||||
}
|
||||
else if (function == do_home)
|
||||
do_statusbar_home();
|
||||
else if (function == do_end)
|
||||
do_statusbar_end();
|
||||
/* When in restricted mode at the "Write File" prompt and the
|
||||
* filename isn't blank, disallow any input and deletion. */
|
||||
else if (ISSET(RESTRICTED) && currmenu == MWRITEFILE &&
|
||||
openfile->filename[0] != '\0' &&
|
||||
(function == do_verbatim_input ||
|
||||
function == do_delete || function == do_backspace ||
|
||||
function == cut_text || function == paste_text))
|
||||
;
|
||||
else if (function == do_verbatim_input)
|
||||
do_statusbar_verbatim_input();
|
||||
else if (function == do_delete)
|
||||
do_statusbar_delete();
|
||||
else if (function == do_backspace)
|
||||
do_statusbar_backspace();
|
||||
else if (function == cut_text)
|
||||
lop_the_answer();
|
||||
#ifndef NANO_TINY
|
||||
else if (function == copy_text)
|
||||
copy_the_answer();
|
||||
else if (function == paste_text) {
|
||||
if (cutbuffer != NULL)
|
||||
paste_into_answer();
|
||||
}
|
||||
#endif
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
return input;
|
||||
/* Don't handle any handled function again. */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Return the column number of the first character of the answer that is
|
||||
@ -392,33 +366,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
|
||||
@ -442,21 +416,19 @@ void add_or_remove_pipe_symbol_from_answer(void)
|
||||
functionptrtype acquire_an_answer(int *actual, bool *listed,
|
||||
linestruct **history_list, void (*refresh_func)(void))
|
||||
{
|
||||
int kbinput = ERR;
|
||||
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. */
|
||||
size_t fragment_length = 0;
|
||||
/* The length of the fragment that the user tries to tab complete. */
|
||||
#endif
|
||||
#endif /* ENABLE_HISTORIES */
|
||||
#endif
|
||||
const keystruct *shortcut;
|
||||
functionptrtype function;
|
||||
int input;
|
||||
|
||||
if (typing_x > strlen(answer))
|
||||
typing_x = strlen(answer);
|
||||
@ -464,27 +436,40 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
|
||||
while (TRUE) {
|
||||
draw_the_promptbar();
|
||||
|
||||
kbinput = do_statusbar_input(&finished);
|
||||
/* Read in one keystroke. */
|
||||
input = get_kbinput(footwin, VISIBLE);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If the window size changed, go reformat the prompt string. */
|
||||
if (kbinput == KEY_WINCH) {
|
||||
refresh_func();
|
||||
if (input == KEY_WINCH) {
|
||||
refresh_func(); /* Only needed when in file browser. */
|
||||
*actual = KEY_WINCH;
|
||||
#ifdef ENABLE_HISTORIES
|
||||
free(magichistory);
|
||||
free(stored_string);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
#endif
|
||||
#ifdef ENABLE_MOUSE
|
||||
/* For a click on a shortcut, read in the resulting keycode. */
|
||||
if (input == KEY_MOUSE && do_statusbar_mouse() == 1)
|
||||
input = get_kbinput(footwin, BLIND);
|
||||
if (input == KEY_MOUSE)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
func = func_from_key(&kbinput);
|
||||
/* Check for a shortcut in the current list. */
|
||||
shortcut = get_shortcut(input);
|
||||
function = (shortcut ? shortcut->func : NULL);
|
||||
|
||||
if (func == do_cancel || func == do_enter)
|
||||
/* When it's a normal character, add it to the answer. */
|
||||
absorb_character(input, function);
|
||||
|
||||
if (function == do_cancel || function == do_enter)
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_TABCOMP
|
||||
if (func == do_tab) {
|
||||
if (function == do_tab) {
|
||||
#ifdef ENABLE_HISTORIES
|
||||
if (history_list != NULL) {
|
||||
if (!previous_was_tab)
|
||||
@ -501,78 +486,79 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
|
||||
if ((currmenu & (MINSERTFILE|MWRITEFILE|MGOTODIR)) && !ISSET(RESTRICTED))
|
||||
answer = input_tab(answer, &typing_x, refresh_func, listed);
|
||||
} else
|
||||
#endif /* ENABLE_TABCOMP */
|
||||
#endif
|
||||
#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 (function == 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 (function == 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 */
|
||||
/* If we ran a function that should not exit from the prompt... */
|
||||
if (func == do_help || func == full_refresh)
|
||||
finished = FALSE;
|
||||
if (function == do_help || function == full_refresh)
|
||||
function();
|
||||
#ifndef NANO_TINY
|
||||
else if (func == do_nothing)
|
||||
finished = FALSE;
|
||||
else if (func == do_toggle_void) {
|
||||
else if (function == do_toggle && shortcut->toggle == NO_HELP) {
|
||||
TOGGLE(NO_HELP);
|
||||
window_init();
|
||||
focusing = FALSE;
|
||||
refresh_func();
|
||||
bottombars(currmenu);
|
||||
finished = FALSE;
|
||||
}
|
||||
} else if (function == do_nothing)
|
||||
;
|
||||
#endif
|
||||
|
||||
/* If we have a shortcut with an associated function, break out if
|
||||
* we're finished after running or trying to run the function. */
|
||||
if (finished)
|
||||
break;
|
||||
#ifdef ENABLE_NANORC
|
||||
else if (function == (functionptrtype)implant)
|
||||
implant(shortcut->expansion);
|
||||
#endif
|
||||
else if (function && !handle_editing(function)) {
|
||||
/* When it's a permissible shortcut, run it and done. */
|
||||
if (!ISSET(VIEW_MODE) || !changes_something(function)) {
|
||||
function();
|
||||
break;
|
||||
} else
|
||||
beep();
|
||||
}
|
||||
|
||||
#if defined(ENABLE_HISTORIES) && defined(ENABLE_TABCOMP)
|
||||
previous_was_tab = (func == do_tab);
|
||||
previous_was_tab = (function == do_tab);
|
||||
#endif
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
*actual = kbinput;
|
||||
*actual = input;
|
||||
|
||||
return func;
|
||||
return function;
|
||||
}
|
||||
|
||||
/* Ask a question on the status bar. Return 0 when text was entered,
|
||||
@ -582,10 +568,10 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
|
||||
int do_prompt(int menu, const char *provided, linestruct **history_list,
|
||||
void (*refresh_func)(void), const char *msg, ...)
|
||||
{
|
||||
functionptrtype function = NULL;
|
||||
bool listed = FALSE;
|
||||
va_list ap;
|
||||
int retval;
|
||||
functionptrtype func = NULL;
|
||||
bool listed = FALSE;
|
||||
/* Save a possible current status-bar x position and prompt. */
|
||||
size_t was_typing_x = typing_x;
|
||||
char *saved_prompt = prompt;
|
||||
@ -607,25 +593,23 @@ int do_prompt(int menu, const char *provided, linestruct **history_list,
|
||||
|
||||
lastmessage = VACUUM;
|
||||
|
||||
func = acquire_an_answer(&retval, &listed, history_list, refresh_func);
|
||||
function = acquire_an_answer(&retval, &listed, history_list, refresh_func);
|
||||
free(prompt);
|
||||
prompt = saved_prompt;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (retval == KEY_WINCH)
|
||||
goto redo_theprompt;
|
||||
#endif
|
||||
|
||||
/* If we're done with this prompt, restore the x position to what
|
||||
* it was at a possible previous prompt. */
|
||||
if (func == do_cancel || func == do_enter)
|
||||
/* Restore a possible previous prompt and maybe the typing position. */
|
||||
prompt = saved_prompt;
|
||||
if (function == do_cancel || function == do_enter)
|
||||
typing_x = was_typing_x;
|
||||
|
||||
/* If we left the prompt via Cancel or Enter, set the return value
|
||||
* properly. */
|
||||
if (func == do_cancel)
|
||||
/* Set the proper return value for Cancel and Enter. */
|
||||
if (function == do_cancel)
|
||||
retval = -1;
|
||||
else if (func == do_enter)
|
||||
else if (function == do_enter)
|
||||
retval = (*answer == '\0') ? -2 : 0;
|
||||
|
||||
if (lastmessage == VACUUM)
|
||||
@ -640,20 +624,24 @@ 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. */
|
||||
const char *yesstr = _("Yy");
|
||||
const char *nostr = _("Nn");
|
||||
const char *allstr = _("Aa");
|
||||
const keystruct *shortcut;
|
||||
functionptrtype function;
|
||||
|
||||
while (choice == -2) {
|
||||
while (choice == UNDECIDED) {
|
||||
#ifdef ENABLE_NLS
|
||||
char letter[MAXCHARLEN + 1];
|
||||
int index = 0;
|
||||
@ -674,42 +662,44 @@ 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)
|
||||
continue;
|
||||
|
||||
/* Accept the first character of an external paste. */
|
||||
if (bracketed_paste && kbinput == BRACKETED_PASTE_MARKER)
|
||||
kbinput = get_kbinput(bottomwin, BLIND);
|
||||
/* Accept first character of an external paste and ignore the rest. */
|
||||
if (bracketed_paste)
|
||||
kbinput = get_kbinput(footwin, BLIND);
|
||||
while (bracketed_paste)
|
||||
get_kbinput(footwin, BLIND);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
@ -720,41 +710,60 @@ 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;
|
||||
else if (func_from_key(&kbinput) == do_cancel)
|
||||
choice = -1;
|
||||
choice = NO;
|
||||
else if (withall && strchr("Aa", kbinput) != NULL)
|
||||
choice = ALL;
|
||||
|
||||
if (choice != UNDECIDED)
|
||||
break;
|
||||
|
||||
shortcut = get_shortcut(kbinput);
|
||||
function = (shortcut ? shortcut->func : NULL);
|
||||
|
||||
if (function == do_cancel)
|
||||
choice = CANCEL;
|
||||
else if (function == full_refresh)
|
||||
full_refresh();
|
||||
#ifndef NANO_TINY
|
||||
else if (function == do_toggle && shortcut->toggle == NO_HELP) {
|
||||
TOGGLE(NO_HELP);
|
||||
window_init();
|
||||
titlebar(NULL);
|
||||
focusing = FALSE;
|
||||
edit_refresh();
|
||||
focusing = TRUE;
|
||||
}
|
||||
#endif
|
||||
/* 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,30 +771,13 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
/* x == 0 means Yes or No, y == 0 means Yes or All. */
|
||||
choice = -2 * x * y + x - y + 1;
|
||||
|
||||
if (choice == 2 && !all)
|
||||
choice = -2;
|
||||
if (choice == ALL && !withall)
|
||||
choice = UNDECIDED;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else if (func_from_key(&kbinput) == full_refresh)
|
||||
full_refresh();
|
||||
#ifndef NANO_TINY
|
||||
else if (func_from_key(&kbinput) == do_toggle_void) {
|
||||
TOGGLE(NO_HELP);
|
||||
window_init();
|
||||
titlebar(NULL);
|
||||
focusing = FALSE;
|
||||
edit_refresh();
|
||||
}
|
||||
#endif
|
||||
else
|
||||
beep();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Ignore the rest of an external paste. */
|
||||
while (bracketed_paste)
|
||||
kbinput = get_kbinput(bottomwin, BLIND);
|
||||
#endif
|
||||
}
|
||||
|
||||
return choice;
|
||||
|
||||
121
src/prototypes.h
121
src/prototypes.h
@ -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-2023 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;
|
||||
|
||||
@ -81,6 +80,7 @@ extern int altinsert, altdelete;
|
||||
extern int shiftaltleft, shiftaltright;
|
||||
extern int shiftaltup, shiftaltdown;
|
||||
#endif
|
||||
extern int mousefocusin, mousefocusout;
|
||||
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
extern ssize_t fill;
|
||||
@ -88,8 +88,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 +142,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;
|
||||
@ -179,6 +182,9 @@ extern char *startup_problem;
|
||||
#endif
|
||||
#ifdef ENABLE_NANORC
|
||||
extern char *custom_nanorc;
|
||||
|
||||
extern char *commandname;
|
||||
extern keystruct *planted_shortcut;
|
||||
#endif
|
||||
|
||||
extern bool spotlighted;
|
||||
@ -282,7 +288,7 @@ void close_buffer(void);
|
||||
void read_file(FILE *f, int fd, const char *filename, bool undoable);
|
||||
int open_file(const char *filename, bool new_one, FILE **f);
|
||||
char *get_next_filename(const char *name, const char *suffix);
|
||||
void do_insertfile_void(void);
|
||||
void do_insertfile(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_execute(void);
|
||||
#endif
|
||||
@ -302,8 +308,8 @@ bool write_file(const char *name, FILE *thefile, bool normal,
|
||||
bool write_region_to_file(const char *name, FILE *stream, bool normal,
|
||||
kind_of_writing_type method);
|
||||
#endif
|
||||
int do_writeout(bool exiting, bool withprompt);
|
||||
void do_writeout_void(void);
|
||||
int write_it_out(bool exiting, bool withprompt);
|
||||
void do_writeout(void);
|
||||
void do_savefile(void);
|
||||
char *real_dir_from_tilde(const char *path);
|
||||
#if defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
|
||||
@ -314,16 +320,16 @@ char *input_tab(char *buf, size_t *place, void (*refresh_func)(void), bool *list
|
||||
#endif
|
||||
|
||||
/* Some functions in global.c. */
|
||||
const keystruct *first_sc_for(int menu, void (*func)(void));
|
||||
const keystruct *first_sc_for(int menu, void (*function)(void));
|
||||
size_t shown_entries_for(int menu);
|
||||
const keystruct *get_shortcut(int *keycode);
|
||||
functionptrtype func_from_key(int *keycode);
|
||||
const keystruct *get_shortcut(const int keycode);
|
||||
functionptrtype func_from_key(const int keycode);
|
||||
#if defined(ENABLE_BROWSER) || defined(ENABLE_HELP)
|
||||
functionptrtype interpret(int *keycode);
|
||||
functionptrtype interpret(const int keycode);
|
||||
#endif
|
||||
int keycode_from_string(const char *keystring);
|
||||
void shortcut_init(void);
|
||||
const char *flagtostr(int flag);
|
||||
const char *epithet_of_flag(int flag);
|
||||
|
||||
/* Some functions in help.c. */
|
||||
#ifdef ENABLE_HELP
|
||||
@ -334,12 +340,8 @@ void do_help(void);
|
||||
/* Most functions in history.c. */
|
||||
#ifdef ENABLE_HISTORIES
|
||||
void history_init(void);
|
||||
void history_reset(const linestruct *list);
|
||||
void update_history(linestruct **item, const char *text);
|
||||
char *get_history_older(linestruct **h);
|
||||
char *get_history_newer(linestruct **h);
|
||||
void get_history_older_void(void);
|
||||
void get_history_newer_void(void);
|
||||
void reset_history_pointer_for(const linestruct *list);
|
||||
void update_history(linestruct **item, const char *text, bool avoid_duplicates);
|
||||
#ifdef ENABLE_TABCOMP
|
||||
char *get_history_completion(linestruct **h, char *s, size_t len);
|
||||
#endif
|
||||
@ -364,8 +366,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(bool allow_folded);
|
||||
bool do_next_word(bool after_ends, bool allow_folded);
|
||||
void to_prev_word(void);
|
||||
void to_next_word(void);
|
||||
void do_home(void);
|
||||
@ -379,6 +381,7 @@ void do_center(void);
|
||||
#endif
|
||||
void do_left(void);
|
||||
void do_right(void);
|
||||
void move_cursor_to_proper_column(void);
|
||||
|
||||
/* Most functions in nano.c. */
|
||||
linestruct *make_new_node(linestruct *prevnode);
|
||||
@ -390,6 +393,9 @@ void free_lines(linestruct *src);
|
||||
void renumber_from(linestruct *line);
|
||||
void print_view_warning(void);
|
||||
bool in_restricted_mode(void);
|
||||
#ifndef NANO_TINY
|
||||
void suggest_ctrlT_ctrlZ(void);
|
||||
#endif
|
||||
void finish(void);
|
||||
void close_and_go(void);
|
||||
void do_exit(void);
|
||||
@ -404,15 +410,15 @@ void handle_hupterm(int signal);
|
||||
#ifndef DEBUG
|
||||
void handle_crash(int signal);
|
||||
#endif
|
||||
void do_suspend(int signal);
|
||||
void do_continue(int signal);
|
||||
void suspend_nano(int signal);
|
||||
void do_suspend(void);
|
||||
void continue_nano(int signal);
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_SPELLER) || defined(ENABLE_COLOR)
|
||||
void block_sigwinch(bool blockit);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
void handle_sigwinch(int signal);
|
||||
void regenerate_screen(void);
|
||||
void do_toggle(int flag);
|
||||
#endif
|
||||
void disable_kb_interrupt(void);
|
||||
void enable_kb_interrupt(void);
|
||||
@ -423,7 +429,7 @@ void terminal_init(void);
|
||||
void confirm_margin(void);
|
||||
#endif
|
||||
void unbound_key(int code);
|
||||
bool okay_for_view(const keystruct *shortcut);
|
||||
bool changes_something(functionptrtype f);
|
||||
void inject(char *burst, size_t count);
|
||||
|
||||
/* Most functions in prompt.c. */
|
||||
@ -432,7 +438,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)
|
||||
@ -440,6 +446,7 @@ void display_rcfile_errors(void);
|
||||
void jot_error(const char *msg, ...);
|
||||
#endif
|
||||
#ifdef ENABLE_NANORC
|
||||
keystruct *strtosc(const char *input);
|
||||
#ifdef ENABLE_COLOR
|
||||
void parse_one_include(char *file, syntaxtype *syntax);
|
||||
void grab_and_store(const char *kind, char *ptr, regexlisttype **storage);
|
||||
@ -464,11 +471,16 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
const linestruct *real_current, size_t *real_current_x);
|
||||
void do_replace(void);
|
||||
void ask_for_and_do_replacements(void);
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_SPELLER) || defined (ENABLE_LINTER) || defined (ENABLE_FORMATTER)
|
||||
void goto_line_posx(ssize_t line, size_t pos_x);
|
||||
void do_gotolinecolumn(ssize_t line, ssize_t column, bool retain_answer,
|
||||
#endif
|
||||
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
|
||||
int find_matching_bracket_pos(linestruct **line, size_t *xpos);
|
||||
bool find_bracketed_region(linestruct *in_region,
|
||||
linestruct **top, linestruct **bot);
|
||||
void do_find_bracket(void);
|
||||
void put_or_lift_anchor(void);
|
||||
void to_prev_anchor(void);
|
||||
@ -497,7 +509,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);
|
||||
@ -515,15 +527,19 @@ void do_full_justify(void);
|
||||
#ifdef ENABLE_SPELLER
|
||||
void do_spell(void);
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
#ifdef ENABLE_LINTER
|
||||
void do_linter(void);
|
||||
#endif
|
||||
#ifdef ENABLE_FORMATTER
|
||||
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);
|
||||
#ifdef ENABLE_WORDCOMPLETION
|
||||
void complete_a_word(void);
|
||||
#endif
|
||||
|
||||
/* All functions in utils.c. */
|
||||
void get_homedir(void);
|
||||
@ -533,7 +549,7 @@ int digits(ssize_t n);
|
||||
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);
|
||||
void recode_LF_to_NUL(char *string);
|
||||
size_t recode_LF_to_NUL(char *string);
|
||||
#if !defined(ENABLE_TINY) || defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
|
||||
void free_chararray(char **array, size_t len);
|
||||
#endif
|
||||
@ -563,18 +579,23 @@ void get_region(linestruct **top, size_t *top_x, linestruct **bot, size_t *bot_x
|
||||
void get_range(linestruct **top, linestruct **bot);
|
||||
#endif
|
||||
size_t number_of_characters_in(const linestruct *begin, const linestruct *end);
|
||||
#ifndef NANO_TINY
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_SPELLER) || defined (ENABLE_LINTER) || defined (ENABLE_FORMATTER)
|
||||
linestruct *line_from_number(ssize_t number);
|
||||
#endif
|
||||
|
||||
/* Most functions in winio.c. */
|
||||
linestruct *get_next_visible_line(linestruct *line);
|
||||
linestruct *get_prev_visible_line(linestruct *line);
|
||||
#ifndef NANO_TINY
|
||||
void record_macro(void);
|
||||
void run_macro(void);
|
||||
size_t get_key_buffer_len(void);
|
||||
#endif
|
||||
void reserve_space_for(size_t newsize);
|
||||
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
|
||||
@ -596,6 +617,7 @@ void warn_and_briefly_pause(const char *msg);
|
||||
void bottombars(int menu);
|
||||
void post_one_key(const char *keystroke, const char *tag, int width);
|
||||
void place_the_cursor(void);
|
||||
int update_line_at(linestruct *line, size_t index, int row);
|
||||
int update_line(linestruct *line, size_t index);
|
||||
#ifndef NANO_TINY
|
||||
int update_softwrapped_line(linestruct *line);
|
||||
@ -606,8 +628,8 @@ int go_forward_chunks(int nrows, linestruct **line, size_t *leftedge);
|
||||
bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge);
|
||||
void edit_scroll(bool direction);
|
||||
#ifndef NANO_TINY
|
||||
size_t get_softwrap_breakpoint(const char *text, size_t leftedge,
|
||||
bool *end_of_line);
|
||||
size_t get_softwrap_breakpoint(const char *linedata, size_t leftedge,
|
||||
bool *kickoff, bool *end_of_line);
|
||||
size_t get_chunk_and_edge(size_t column, linestruct *line, size_t *leftedge);
|
||||
size_t chunk_for(size_t column, linestruct *line);
|
||||
size_t leftedge_for(size_t column, linestruct *line);
|
||||
@ -625,7 +647,6 @@ void spotlight(size_t from_col, size_t to_col);
|
||||
#ifndef NANO_TINY
|
||||
void spotlight_softwrapped(size_t from_col, size_t to_col);
|
||||
#endif
|
||||
void do_suspend_void(void);
|
||||
#ifdef ENABLE_EXTRA
|
||||
void do_credits(void);
|
||||
#endif
|
||||
@ -634,6 +655,10 @@ void do_credits(void);
|
||||
void case_sens_void(void);
|
||||
void regexp_void(void);
|
||||
void backwards_void(void);
|
||||
#ifdef ENABLE_HISTORIES
|
||||
void get_older_item(void);
|
||||
void get_newer_item(void);
|
||||
#endif
|
||||
void flip_replace(void);
|
||||
void flip_goto(void);
|
||||
#ifdef ENABLE_BROWSER
|
||||
@ -642,12 +667,12 @@ void goto_dir(void);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
void do_nothing(void);
|
||||
void do_toggle_void(void);
|
||||
void dos_format_void(void);
|
||||
void mac_format_void(void);
|
||||
void append_void(void);
|
||||
void prepend_void(void);
|
||||
void backup_file_void(void);
|
||||
void do_toggle(void);
|
||||
void dos_format(void);
|
||||
void mac_format(void);
|
||||
void append_it(void);
|
||||
void prepend_it(void);
|
||||
void back_it_up(void);
|
||||
void flip_execute(void);
|
||||
void flip_pipe(void);
|
||||
void flip_convert(void);
|
||||
@ -657,3 +682,13 @@ void flip_newbuffer(void);
|
||||
#endif
|
||||
void discard_buffer(void);
|
||||
void do_cancel(void);
|
||||
|
||||
/* Most functions in folding.c. */
|
||||
#ifdef ENABLE_FOLDING
|
||||
void do_fold_segment(void);
|
||||
void unfold_folded_segment(linestruct *line);
|
||||
void unfold_folded_segment_from(linestruct *line);
|
||||
linestruct *get_start_of_folded_segment(linestruct* line);
|
||||
linestruct *get_end_of_folded_segment(linestruct* line);
|
||||
int get_folded_segment_length(linestruct *line);
|
||||
#endif
|
||||
|
||||
176
src/rcfile.c
176
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-2023 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 *
|
||||
@ -90,9 +90,6 @@ static const rcoption rcopts[] = {
|
||||
#ifdef ENABLE_SPELLER
|
||||
{"speller", 0},
|
||||
#endif
|
||||
{"suspend", SUSPENDABLE}, /* Deprecated; remove in 2022. */
|
||||
{"suspendable", SUSPENDABLE},
|
||||
{"tempfile", SAVE_ON_EXIT}, /* Deprecated; remove in 2022. */
|
||||
#ifndef NANO_TINY
|
||||
{"afterends", AFTER_ENDS},
|
||||
{"allow_insecure_backup", INSECURE_BACKUP},
|
||||
@ -122,6 +119,7 @@ static const rcoption rcopts[] = {
|
||||
{"wordbounds", WORD_BOUNDS},
|
||||
{"wordchars", 0},
|
||||
{"zap", LET_THEM_ZAP},
|
||||
{"zero", ZERO},
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
{"titlecolor", 0},
|
||||
@ -155,18 +153,6 @@ static bool seen_color_command = FALSE;
|
||||
static colortype *lastcolor = NULL;
|
||||
/* The end of the color list for the current syntax. */
|
||||
#endif
|
||||
|
||||
#define NUMBER_OF_MENUS 17 /* Remove the deprecated 'extcmd' in 2022. */
|
||||
char *menunames[NUMBER_OF_MENUS] = { "main", "search", "replace", "replacewith",
|
||||
"yesno", "gotoline", "writeout", "insert",
|
||||
"execute", "extcmd", "help", "spell", "linter",
|
||||
"browser", "whereisfile", "gotodir",
|
||||
"all" };
|
||||
int menusymbols[NUMBER_OF_MENUS] = { MMAIN, MWHEREIS, MREPLACE, MREPLACEWITH,
|
||||
MYESNO, MGOTOLINE, MWRITEFILE, MINSERTFILE,
|
||||
MEXECUTE, MEXECUTE, MHELP, MSPELL, MLINTER,
|
||||
MBROWSER, MWHEREISFILE, MGOTODIR,
|
||||
MMOST|MBROWSER|MHELP|MYESNO };
|
||||
#endif /* ENABLE_NANORC */
|
||||
|
||||
#if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES)
|
||||
@ -242,11 +228,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"))
|
||||
@ -278,17 +264,18 @@ keystruct *strtosc(const char *input)
|
||||
!strcmp(input, "speller"))
|
||||
s->func = do_spell;
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
#ifdef ENABLE_LINTER
|
||||
else if (!strcmp(input, "linter"))
|
||||
s->func = do_linter;
|
||||
#endif
|
||||
#ifdef ENABLE_FORMATTER
|
||||
else if (!strcmp(input, "formatter"))
|
||||
s->func = do_formatter;
|
||||
#endif
|
||||
else if (!strcmp(input, "location") ||
|
||||
!strcmp(input, "curpos")) /* Deprecated; remove in 2022. */
|
||||
else if (!strcmp(input, "location"))
|
||||
s->func = report_cursor_position;
|
||||
else if (!strcmp(input, "gotoline"))
|
||||
s->func = do_gotolinecolumn_void;
|
||||
s->func = do_gotolinecolumn;
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
else if (!strcmp(input, "justify"))
|
||||
s->func = do_justify;
|
||||
@ -312,16 +299,14 @@ keystruct *strtosc(const char *input)
|
||||
s->func = do_indent;
|
||||
else if (!strcmp(input, "unindent"))
|
||||
s->func = do_unindent;
|
||||
else if (!strcmp(input, "chopwordleft") ||
|
||||
!strcmp(input, "cutwordleft")) /* Deprecated; remove in 2021. */
|
||||
else if (!strcmp(input, "chopwordleft"))
|
||||
s->func = chop_previous_word;
|
||||
else if (!strcmp(input, "chopwordright") ||
|
||||
!strcmp(input, "cutwordright")) /* Deprecated; remove in 2021. */
|
||||
else if (!strcmp(input, "chopwordright"))
|
||||
s->func = chop_next_word;
|
||||
else if (!strcmp(input, "findbracket"))
|
||||
s->func = do_find_bracket;
|
||||
else if (!strcmp(input, "wordcount"))
|
||||
s->func = do_wordlinechar_count;
|
||||
s->func = count_lines_words_and_characters;
|
||||
else if (!strcmp(input, "recordmacro"))
|
||||
s->func = record_macro;
|
||||
else if (!strcmp(input, "runmacro"))
|
||||
@ -397,8 +382,10 @@ keystruct *strtosc(const char *input)
|
||||
s->func = do_backspace;
|
||||
else if (!strcmp(input, "refresh"))
|
||||
s->func = full_refresh;
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcmp(input, "suspend"))
|
||||
s->func = do_suspend_void;
|
||||
s->func = do_suspend;
|
||||
#endif
|
||||
else if (!strcmp(input, "casesens"))
|
||||
s->func = case_sens_void;
|
||||
else if (!strcmp(input, "regexp"))
|
||||
@ -411,21 +398,21 @@ keystruct *strtosc(const char *input)
|
||||
s->func = flip_goto;
|
||||
#ifdef ENABLE_HISTORIES
|
||||
else if (!strcmp(input, "older"))
|
||||
s->func = get_history_older_void;
|
||||
s->func = get_older_item;
|
||||
else if (!strcmp(input, "newer"))
|
||||
s->func = get_history_newer_void;
|
||||
s->func = get_newer_item;
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcmp(input, "dosformat"))
|
||||
s->func = dos_format_void;
|
||||
s->func = dos_format;
|
||||
else if (!strcmp(input, "macformat"))
|
||||
s->func = mac_format_void;
|
||||
s->func = mac_format;
|
||||
else if (!strcmp(input, "append"))
|
||||
s->func = append_void;
|
||||
s->func = append_it;
|
||||
else if (!strcmp(input, "prepend"))
|
||||
s->func = prepend_void;
|
||||
s->func = prepend_it;
|
||||
else if (!strcmp(input, "backup"))
|
||||
s->func = backup_file_void;
|
||||
s->func = back_it_up;
|
||||
else if (!strcmp(input, "flipexecute"))
|
||||
s->func = flip_execute;
|
||||
else if (!strcmp(input, "flippipe"))
|
||||
@ -450,9 +437,11 @@ keystruct *strtosc(const char *input)
|
||||
#endif
|
||||
else {
|
||||
#ifndef NANO_TINY
|
||||
s->func = do_toggle_void;
|
||||
s->func = do_toggle;
|
||||
if (!strcmp(input, "nohelp"))
|
||||
s->toggle = NO_HELP;
|
||||
else if (!strcmp(input, "zero"))
|
||||
s->toggle = ZERO;
|
||||
else if (!strcmp(input, "constantshow"))
|
||||
s->toggle = CONSTANT_SHOW;
|
||||
else if (!strcmp(input, "softwrap"))
|
||||
@ -484,9 +473,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 */
|
||||
{
|
||||
@ -497,6 +483,18 @@ keystruct *strtosc(const char *input)
|
||||
return s;
|
||||
}
|
||||
|
||||
#define NUMBER_OF_MENUS 16
|
||||
char *menunames[NUMBER_OF_MENUS] = { "main", "search", "replace", "replacewith",
|
||||
"yesno", "gotoline", "writeout", "insert",
|
||||
"execute", "help", "spell", "linter",
|
||||
"browser", "whereisfile", "gotodir",
|
||||
"all" };
|
||||
int menusymbols[NUMBER_OF_MENUS] = { MMAIN, MWHEREIS, MREPLACE, MREPLACEWITH,
|
||||
MYESNO, MGOTOLINE, MWRITEFILE, MINSERTFILE,
|
||||
MEXECUTE, MHELP, MSPELL, MLINTER,
|
||||
MBROWSER, MWHEREISFILE, MGOTODIR,
|
||||
MMOST|MBROWSER|MHELP|MYESNO };
|
||||
|
||||
/* Return the symbol that corresponds to the given menu name. */
|
||||
int name_to_menu(const char *name)
|
||||
{
|
||||
@ -506,7 +504,7 @@ int name_to_menu(const char *name)
|
||||
if (strcmp(name, menunames[index]) == 0)
|
||||
return menusymbols[index];
|
||||
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return the name that corresponds to the given menu symbol. */
|
||||
@ -676,7 +674,7 @@ void begin_new_syntax(char *ptr)
|
||||
live_syntax->magics = NULL;
|
||||
live_syntax->linter = NULL;
|
||||
live_syntax->formatter = NULL;
|
||||
live_syntax->tab = NULL;
|
||||
live_syntax->tabstring = NULL;
|
||||
#ifdef ENABLE_COMMENT
|
||||
live_syntax->comment = copy_of(GENERAL_COMMENT_CHARACTER);
|
||||
#endif
|
||||
@ -789,6 +787,12 @@ void parse_binding(char *ptr, bool dobind)
|
||||
goto free_things;
|
||||
}
|
||||
|
||||
menu = name_to_menu(menuptr);
|
||||
if (menu == 0) {
|
||||
jot_error(N_("Unknown menu: %s"), menuptr);
|
||||
goto free_things;
|
||||
}
|
||||
|
||||
if (dobind) {
|
||||
/* If the thing to bind starts with a double quote, it is a string,
|
||||
* otherwise it is the name of a function. */
|
||||
@ -803,17 +807,11 @@ void parse_binding(char *ptr, bool dobind)
|
||||
newsc = strtosc(funcptr);
|
||||
|
||||
if (newsc == NULL) {
|
||||
jot_error(N_("Cannot map name \"%s\" to a function"), funcptr);
|
||||
jot_error(N_("Unknown function: %s"), funcptr);
|
||||
goto free_things;
|
||||
}
|
||||
}
|
||||
|
||||
menu = name_to_menu(menuptr);
|
||||
if (menu < 1) {
|
||||
jot_error(N_("Cannot map name \"%s\" to a menu"), menuptr);
|
||||
goto free_things;
|
||||
}
|
||||
|
||||
/* Wipe the given shortcut from the given menu. */
|
||||
for (keystruct *s = sclist; s != NULL; s = s->next)
|
||||
if ((s->menus & menu) && s->keycode == keycode)
|
||||
@ -828,9 +826,9 @@ void parse_binding(char *ptr, bool dobind)
|
||||
if (is_universal(newsc->func))
|
||||
menu &= MMOST|MBROWSER;
|
||||
#ifndef NANO_TINY
|
||||
else if (newsc->func == do_toggle_void && newsc->toggle == NO_HELP)
|
||||
else if (newsc->func == do_toggle && newsc->toggle == NO_HELP)
|
||||
menu &= (MMOST|MBROWSER|MYESNO) & ~MFINDINHELP;
|
||||
else if (newsc->func == do_toggle_void)
|
||||
else if (newsc->func == do_toggle)
|
||||
menu &= MMAIN;
|
||||
#endif
|
||||
else if (newsc->func == full_refresh)
|
||||
@ -868,9 +866,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;
|
||||
@ -901,7 +899,7 @@ bool is_good_file(char *file)
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
/* Partially parse the syntaxes in the given file, or (when syntax
|
||||
* is not NULL) fully parse one specific syntax from the file . */
|
||||
* is not NULL) fully parse one specific syntax from the file. */
|
||||
void parse_one_include(char *file, syntaxtype *syntax)
|
||||
{
|
||||
char *was_nanorc = nanorc;
|
||||
@ -910,7 +908,7 @@ void parse_one_include(char *file, syntaxtype *syntax)
|
||||
FILE *rcstream;
|
||||
|
||||
/* Don't open directories, character files, or block files. */
|
||||
if (!is_good_file(file))
|
||||
if (access(file, R_OK) == 0 && !is_good_file(file))
|
||||
return;
|
||||
|
||||
rcstream = fopen(file, "rb");
|
||||
@ -978,7 +976,7 @@ void parse_includes(char *ptr)
|
||||
|
||||
/* Expand a tilde first, then try to match the globbing pattern. */
|
||||
expanded = real_dir_from_tilde(pattern);
|
||||
result = glob(expanded, GLOB_ERR, NULL, &files);
|
||||
result = glob(expanded, GLOB_ERR|GLOB_NOCHECK, NULL, &files);
|
||||
|
||||
/* If there are matches, process each of them. Otherwise, only
|
||||
* report an error if it's something other than zero matches. */
|
||||
@ -992,7 +990,26 @@ void parse_includes(char *ptr)
|
||||
free(expanded);
|
||||
}
|
||||
|
||||
#define COLORCOUNT 20
|
||||
/* Return the index of the color that is closest to the given RGB levels,
|
||||
* assuming that the terminal uses the 6x6x6 color cube of xterm-256color.
|
||||
* When red == green == blue, return an index in the xterm gray scale. */
|
||||
short closest_index_color(short red, short green, short blue)
|
||||
{
|
||||
/* Translation table, from 16 intended color 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 };
|
||||
|
||||
/* Translation table, from 14 intended gray levels to 24 available levels. */
|
||||
static const short gray[] = { 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 15, 18, 21, 23 };
|
||||
|
||||
if (COLORS != 256)
|
||||
return THE_DEFAULT;
|
||||
else if (red == green && green == blue && 0 < red && red < 0xF)
|
||||
return 232 + gray[red - 1];
|
||||
else
|
||||
return (36 * level[red] + 6 * level[green] + level[blue] + 16);
|
||||
}
|
||||
|
||||
#define COLORCOUNT 34
|
||||
|
||||
const char hues[COLORCOUNT][8] = { "red", "green", "blue",
|
||||
"yellow", "cyan", "magenta",
|
||||
@ -1000,12 +1017,19 @@ const char hues[COLORCOUNT][8] = { "red", "green", "blue",
|
||||
"pink", "purple", "mauve",
|
||||
"lagoon", "mint", "lime",
|
||||
"peach", "orange", "latte",
|
||||
"rosy", "beet", "plum",
|
||||
"sea", "sky", "slate",
|
||||
"teal", "sage", "brown",
|
||||
"ocher", "sand", "tawny",
|
||||
"brick", "crimson",
|
||||
"grey", "gray" };
|
||||
|
||||
short indices[COLORCOUNT] = { COLOR_RED, COLOR_GREEN, COLOR_BLUE,
|
||||
COLOR_YELLOW, COLOR_CYAN, COLOR_MAGENTA,
|
||||
COLOR_WHITE, COLOR_BLACK, THE_DEFAULT,
|
||||
204, 163, 134, 38, 48, 148, 215, 208, 137,
|
||||
175, 127, 98, 32, 111, 66, 35, 107, 100,
|
||||
142, 186, 136, 166, 161,
|
||||
COLOR_BLACK + 8, COLOR_BLACK + 8 };
|
||||
|
||||
/* Return the short value corresponding to the given color name, and set
|
||||
@ -1026,6 +1050,18 @@ short color_to_short(const char *colorname, bool *vivid, bool *thick)
|
||||
*thick = FALSE;
|
||||
}
|
||||
|
||||
if (colorname[0] == '#' && strlen(colorname) == 4) {
|
||||
unsigned short r, g, b;
|
||||
|
||||
if (*vivid) {
|
||||
jot_error(N_("Color '%s' takes no prefix"), colorname);
|
||||
return BAD_COLOR;
|
||||
}
|
||||
|
||||
if (sscanf(colorname, "#%1hX%1hX%1hX", &r, &g, &b) == 3)
|
||||
return closest_index_color(r, g, b);
|
||||
}
|
||||
|
||||
for (int index = 0; index < COLORCOUNT; index++)
|
||||
if (strcmp(colorname, hues[index]) == 0) {
|
||||
if (index > 7 && *vivid) {
|
||||
@ -1295,7 +1331,7 @@ bool parse_syntax_commands(char *keyword, char *ptr)
|
||||
pick_up_name("comment", ptr, &live_syntax->comment);
|
||||
#endif
|
||||
} else if (strcmp(keyword, "tabgives") == 0) {
|
||||
pick_up_name("tabgives", ptr, &live_syntax->tab);
|
||||
pick_up_name("tabgives", ptr, &live_syntax->tabstring);
|
||||
} else if (strcmp(keyword, "linter") == 0)
|
||||
pick_up_name("linter", ptr, &live_syntax->linter);
|
||||
else if (strcmp(keyword, "formatter") == 0)
|
||||
@ -1320,7 +1356,7 @@ static void check_vitals_mapped(void)
|
||||
if (f->func == vitals[v] && f->menus & inmenus[v]) {
|
||||
if (first_sc_for(inmenus[v], f->func) == NULL) {
|
||||
jot_error(N_("No key is bound to function '%s' in menu '%s'. "
|
||||
" Exiting.\n"), f->desc, menu_to_name(inmenus[v]));
|
||||
" Exiting.\n"), f->tag, menu_to_name(inmenus[v]));
|
||||
die(_("If needed, use nano with the -I option "
|
||||
"to adjust your nanorc settings.\n"));
|
||||
} else
|
||||
@ -1502,7 +1538,7 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
|
||||
}
|
||||
|
||||
if (rcopts[i].name == NULL) {
|
||||
jot_error(N_("Unknown option \"%s\""), option);
|
||||
jot_error(N_("Unknown option: %s"), option);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1567,7 +1603,7 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
|
||||
#endif
|
||||
#ifdef ENABLE_OPERATINGDIR
|
||||
if (strcmp(option, "operatingdir") == 0)
|
||||
operating_dir = copy_of(argument);
|
||||
operating_dir = mallocstrcpy(operating_dir, argument);
|
||||
else
|
||||
#endif
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
@ -1585,12 +1621,12 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
|
||||
else if (mbstrlen(argument) % 2 != 0)
|
||||
jot_error(N_("Even number of characters required"));
|
||||
else
|
||||
matchbrackets = copy_of(argument);
|
||||
matchbrackets = mallocstrcpy(matchbrackets, argument);
|
||||
} else if (strcmp(option, "whitespace") == 0) {
|
||||
if (mbstrlen(argument) != 2 || breadth(argument) != 2)
|
||||
jot_error(N_("Two single-column characters required"));
|
||||
else {
|
||||
whitespace = copy_of(argument);
|
||||
whitespace = mallocstrcpy(whitespace, argument);
|
||||
whitelen[0] = char_length(whitespace);
|
||||
whitelen[1] = char_length(whitespace + whitelen[0]);
|
||||
}
|
||||
@ -1601,26 +1637,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);
|
||||
@ -1677,7 +1713,7 @@ void do_rcfiles(void)
|
||||
{
|
||||
if (custom_nanorc) {
|
||||
nanorc = get_full_path(custom_nanorc);
|
||||
if (access(nanorc, F_OK) != 0)
|
||||
if (nanorc == NULL || access(nanorc, F_OK) != 0)
|
||||
die(_("Specified rcfile does not exist\n"));
|
||||
} else
|
||||
nanorc = mallocstrcpy(nanorc, SYSCONFDIR "/nanorc");
|
||||
|
||||
364
src/search.c
364
src/search.c
@ -1,8 +1,8 @@
|
||||
/**************************************************************************
|
||||
* search.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2015-2020 Benno Schulenberg *
|
||||
* Copyright (C) 1999-2011, 2013-2023 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2015-2020, 2022 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 *
|
||||
@ -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
|
||||
@ -88,7 +91,7 @@ void search_init(bool replacing, bool retain_answer)
|
||||
thedefault = copy_of("");
|
||||
|
||||
while (TRUE) {
|
||||
functionptrtype func;
|
||||
functionptrtype function;
|
||||
/* Ask the user what to search for (or replace). */
|
||||
int response = do_prompt(
|
||||
inhelp ? MFINDINHELP : (replacing ? MREPLACE : MWHEREIS),
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -135,24 +138,24 @@ void search_init(bool replacing, bool retain_answer)
|
||||
|
||||
retain_answer = TRUE;
|
||||
|
||||
func = func_from_key(&response);
|
||||
function = func_from_key(response);
|
||||
|
||||
/* If we're here, one of the five toggles was pressed, or
|
||||
* a shortcut was executed. */
|
||||
if (func == case_sens_void)
|
||||
if (function == case_sens_void)
|
||||
TOGGLE(CASE_SENSITIVE);
|
||||
else if (func == backwards_void)
|
||||
else if (function == backwards_void)
|
||||
TOGGLE(BACKWARDS_SEARCH);
|
||||
else if (func == regexp_void)
|
||||
else if (function == regexp_void)
|
||||
TOGGLE(USE_REGEXP);
|
||||
else if (func == flip_replace) {
|
||||
else if (function == flip_replace) {
|
||||
if (ISSET(VIEW_MODE)) {
|
||||
print_view_warning();
|
||||
napms(600);
|
||||
} else
|
||||
replacing = !replacing;
|
||||
} else if (func == flip_goto) {
|
||||
do_gotolinecolumn(openfile->current->lineno,
|
||||
} else if (function == flip_goto) {
|
||||
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;
|
||||
@ -219,21 +222,22 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
/* The match is valid. */
|
||||
break;
|
||||
/* When not on the magic line, the match is valid. */
|
||||
if (line->next || line->data[0])
|
||||
break;
|
||||
}
|
||||
|
||||
#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 +248,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 +272,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,12 +280,12 @@ 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;
|
||||
|
||||
if (func_from_key(&input) == do_cancel) {
|
||||
if (func_from_key(input) == do_cancel) {
|
||||
#ifndef NANO_TINY
|
||||
if (the_window_resized)
|
||||
regenerate_screen();
|
||||
@ -289,12 +293,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)
|
||||
@ -304,9 +308,11 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
}
|
||||
}
|
||||
|
||||
UNFOLD_SEGMENT(line);
|
||||
|
||||
found_x = found - line->data;
|
||||
|
||||
nodelay(edit, FALSE);
|
||||
nodelay(midwin, FALSE);
|
||||
|
||||
/* Ensure that the found occurrence is not beyond the starting x. */
|
||||
if (came_full_circle && ((!ISSET(BACKWARDS_SEARCH) && (found_x > begin_x ||
|
||||
@ -327,9 +333,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
spotlighted = TRUE;
|
||||
light_from_col = xplustabs();
|
||||
light_to_col = wideness(line->data, found_x + found_len);
|
||||
if (!ISSET(SHOW_CURSOR))
|
||||
hide_cursor = TRUE;
|
||||
edit_refresh();
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -445,8 +449,8 @@ void go_looking(void)
|
||||
* text in the passed string only when create is TRUE. */
|
||||
int replace_regexp(char *string, bool create)
|
||||
{
|
||||
const char *c = answer;
|
||||
size_t replacement_size = 0;
|
||||
const char *c = answer;
|
||||
|
||||
/* Iterate through the replacement text to handle subexpression
|
||||
* replacement using \1, \2, \3, etc. */
|
||||
@ -524,11 +528,11 @@ char *replace_line(const char *needle)
|
||||
ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
const linestruct *real_current, size_t *real_current_x)
|
||||
{
|
||||
bool skipone = ISSET(BACKWARDS_SEARCH);
|
||||
bool replaceall = FALSE;
|
||||
int modus = REPLACING;
|
||||
ssize_t numreplaced = -1;
|
||||
size_t match_len;
|
||||
bool replaceall = FALSE;
|
||||
bool skipone = ISSET(BACKWARDS_SEARCH);
|
||||
int modus = REPLACING;
|
||||
#ifndef NANO_TINY
|
||||
linestruct *was_mark = openfile->mark;
|
||||
linestruct *top, *bot;
|
||||
@ -555,7 +559,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
came_full_circle = FALSE;
|
||||
|
||||
while (TRUE) {
|
||||
int choice = 0;
|
||||
int choice = NO;
|
||||
int result = findnextstr(needle, whole_word_only, modus,
|
||||
&match_len, skipone, real_current, *real_current_x);
|
||||
|
||||
@ -591,21 +595,21 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
edit_refresh();
|
||||
|
||||
/* TRANSLATORS: This is a prompt. */
|
||||
choice = do_yesno_prompt(TRUE, _("Replace this instance?"));
|
||||
choice = ask_user(YESORALLORNO, _("Replace this instance?"));
|
||||
|
||||
spotlighted = FALSE;
|
||||
|
||||
if (choice == -1) /* The replacing was cancelled. */
|
||||
if (choice == CANCEL)
|
||||
break;
|
||||
else if (choice == 2)
|
||||
replaceall = TRUE;
|
||||
|
||||
replaceall = (choice == ALL);
|
||||
|
||||
/* When "No" or moving backwards, the search routine should
|
||||
* first move one character further before continuing. */
|
||||
skipone = (choice == 0 || ISSET(BACKWARDS_SEARCH));
|
||||
}
|
||||
|
||||
if (choice == 1 || replaceall) { /* Yes, replace it. */
|
||||
if (choice == YES || replaceall) {
|
||||
size_t length_change;
|
||||
char *altered;
|
||||
|
||||
@ -659,6 +663,10 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
free(openfile->current->data);
|
||||
openfile->current->data = altered;
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
check_the_multis(openfile->current);
|
||||
refresh_needed = FALSE;
|
||||
#endif
|
||||
set_modified();
|
||||
as_an_at = TRUE;
|
||||
numreplaced++;
|
||||
@ -706,7 +714,7 @@ void ask_for_and_do_replacements(void)
|
||||
#ifdef ENABLE_HISTORIES
|
||||
/* When not "", add the replace string to the replace history list. */
|
||||
if (response == 0)
|
||||
update_history(&replace_history, answer);
|
||||
update_history(&replace_history, answer, PRUNE_DUPLICATE);
|
||||
#endif
|
||||
|
||||
/* When cancelled, or when a function was run, get out. */
|
||||
@ -724,31 +732,41 @@ void ask_for_and_do_replacements(void)
|
||||
openfile->current = beginline;
|
||||
openfile->current_x = begin_x;
|
||||
|
||||
edit_refresh();
|
||||
refresh_needed = TRUE;
|
||||
|
||||
if (numreplaced >= 0)
|
||||
statusline(REMARK, P_("Replaced %zd occurrence",
|
||||
"Replaced %zd occurrences", numreplaced), numreplaced);
|
||||
}
|
||||
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_SPELLER) || defined (ENABLE_LINTER) || defined (ENABLE_FORMATTER)
|
||||
/* Go to the specified line and x position. */
|
||||
void goto_line_posx(ssize_t line, size_t pos_x)
|
||||
void goto_line_posx(ssize_t linenumber, size_t pos_x)
|
||||
{
|
||||
for (openfile->current = openfile->filetop; line > 1 &&
|
||||
openfile->current != openfile->filebot; line--)
|
||||
openfile->current = openfile->current->next;
|
||||
#ifdef ENABLE_COLOR
|
||||
if (linenumber > openfile->edittop->lineno + editwinrows ||
|
||||
(ISSET(SOFTWRAP) && linenumber > openfile->current->lineno))
|
||||
recook |= perturbed;
|
||||
#endif
|
||||
|
||||
if (linenumber < openfile->filebot->lineno)
|
||||
openfile->current = line_from_number(linenumber);
|
||||
else
|
||||
openfile->current = openfile->filebot;
|
||||
|
||||
openfile->current_x = pos_x;
|
||||
openfile->placewewant = xplustabs();
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* 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. */
|
||||
@ -762,7 +780,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool retain_answer,
|
||||
return;
|
||||
}
|
||||
|
||||
if (func_from_key(&response) == flip_goto) {
|
||||
if (func_from_key(response) == flip_goto) {
|
||||
UNSET(BACKWARDS_SEARCH);
|
||||
/* Switch to searching but retain what the user typed so far. */
|
||||
search_init(FALSE, TRUE);
|
||||
@ -792,11 +810,26 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool retain_answer,
|
||||
if (line < 1)
|
||||
line = 1;
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
#ifndef NANO_TINY
|
||||
linestruct *edit_bottom = openfile->edittop;
|
||||
for (int i = 0;edit_bottom != openfile->filebot && i < editwinrows;++i)
|
||||
edit_bottom = get_next_visible_line(edit_bottom);
|
||||
if (line > edit_bottom->lineno ||
|
||||
(ISSET(SOFTWRAP) && line > openfile->current->lineno))
|
||||
#else
|
||||
if (line > openfile->edittop->lineno + editwinrows)
|
||||
#endif
|
||||
recook |= perturbed;
|
||||
#endif /* ENABLE_COLOR */
|
||||
|
||||
/* Iterate to the requested line. */
|
||||
for (openfile->current = openfile->filetop; line > 1 &&
|
||||
openfile->current != openfile->filebot; line--)
|
||||
openfile->current = openfile->current->next;
|
||||
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
|
||||
/* Take a negative column number to mean: from the end of the line. */
|
||||
if (column < 0)
|
||||
column = breadth(openfile->current->data) + column + 2;
|
||||
@ -813,9 +846,9 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool retain_answer,
|
||||
openfile->placewewant = breadth(openfile->current->data);
|
||||
#endif
|
||||
|
||||
/* When the position was manually given, center the target line. */
|
||||
/* When a line number was manually given, center the target line. */
|
||||
if (interactive) {
|
||||
adjust_viewport(CENTERING);
|
||||
adjust_viewport((*answer == ',') ? STATIONARY : CENTERING);
|
||||
refresh_needed = TRUE;
|
||||
} else {
|
||||
int rows_from_tail;
|
||||
@ -844,30 +877,117 @@ 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);
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Search backwards for a line ending with a bracket, including the current line.
|
||||
* top is an in/out parameter. The passed value is the start line for searching.
|
||||
* xpos is an out parameter. It is the position in the line where the bracket is
|
||||
* found. bracket_half is the halfway mark in the matchbrackets array. This way in
|
||||
* a loop the halfway value isn't recomputed. */
|
||||
bool find_start_of_bracketed_region(linestruct **top, size_t *xpos, size_t bracket_half)
|
||||
{
|
||||
/* Search backwards for a line ending with a bracket, including the current line */
|
||||
for (;(*top) != NULL;*top = (*top)->prev) {
|
||||
char *found;
|
||||
const char *bracket;
|
||||
int len = strlen((*top)->data);
|
||||
|
||||
/* Find the last bracket on the search line */
|
||||
found = mbrevstrpbrk((*top)->data, matchbrackets, (*top)->data + len);
|
||||
if (found == NULL)
|
||||
continue;
|
||||
|
||||
*xpos = found - (*top)->data;
|
||||
bracket = mbstrchr(matchbrackets, found);
|
||||
|
||||
/* We're looking for opening braces, not closing */
|
||||
if (bracket >= matchbrackets + bracket_half)
|
||||
continue;
|
||||
|
||||
/* Check if this is the last character in the line */
|
||||
char *next = (*top)->data + step_right((*top)->data, *xpos);
|
||||
if (*next == '\0')
|
||||
return TRUE;
|
||||
}
|
||||
*xpos = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Get the halfway point in matchbrackets, where open and close
|
||||
* brackets meet. */
|
||||
size_t get_matchbrackets_halfway(void)
|
||||
{
|
||||
size_t charcount = mbstrlen(matchbrackets) / 2;
|
||||
size_t halfway = 0;
|
||||
|
||||
for (size_t i = 0;i < charcount;++i)
|
||||
halfway += char_length(matchbrackets + halfway);
|
||||
return halfway;
|
||||
}
|
||||
/* Get a region surrounding the line in_region. A region here is defined
|
||||
* as a block of text starting with an opening bracket at the end of a line,
|
||||
* and ending with a matching closing bracket.
|
||||
* top and bot are out parameters. Returns the top/bottom line of the region.
|
||||
* top_pos and bot_pos are out parameters. Returns the position within the
|
||||
* top and bottom lines where the brackets are found. */
|
||||
bool find_bracketed_region(linestruct *in_region,
|
||||
linestruct **top, linestruct **bot)
|
||||
{
|
||||
size_t bracket_half = get_matchbrackets_halfway();
|
||||
size_t top_pos;
|
||||
size_t bot_pos;
|
||||
linestruct *was_top = *top;
|
||||
linestruct *was_bot = *bot;
|
||||
*top = in_region;
|
||||
|
||||
for (;find_start_of_bracketed_region(top, &top_pos, bracket_half)
|
||||
;*top = (*top)->prev)
|
||||
{
|
||||
*bot = *top;
|
||||
bot_pos = top_pos;
|
||||
|
||||
if (!find_matching_bracket_pos(bot, &bot_pos)) {
|
||||
if ((*bot)->lineno < in_region->lineno)
|
||||
continue;
|
||||
|
||||
int linedist = (*bot)->lineno - (*top)->lineno;
|
||||
|
||||
if (linedist >= 2) {
|
||||
*top = (*top)->next;
|
||||
*bot = (*bot)->prev;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
*top = was_top;
|
||||
*bot = was_bot;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* Search, starting from the current position, for any of the two characters
|
||||
* in bracket_pair. If reverse is TRUE, search backwards, otherwise forwards.
|
||||
* Return TRUE when one of the brackets was found, and FALSE otherwise. */
|
||||
bool find_a_bracket(bool reverse, const char *bracket_pair)
|
||||
bool find_a_bracket(bool reverse, const char *bracket_pair,
|
||||
linestruct **inout_line, size_t *xpos)
|
||||
{
|
||||
linestruct *line = openfile->current;
|
||||
linestruct *line = *inout_line;
|
||||
const char *pointer, *found;
|
||||
|
||||
if (reverse) {
|
||||
/* First step away from the current bracket. */
|
||||
if (openfile->current_x == 0) {
|
||||
if (*xpos == 0) {
|
||||
line = line->prev;
|
||||
if (line == NULL)
|
||||
return FALSE;
|
||||
pointer = line->data + strlen(line->data);
|
||||
} else
|
||||
pointer = line->data + step_left(line->data, openfile->current_x);
|
||||
pointer = line->data + step_left(line->data, *xpos);
|
||||
|
||||
/* Now seek for any of the two brackets we are interested in. */
|
||||
while (!(found = mbrevstrpbrk(line->data, bracket_pair, pointer))) {
|
||||
@ -877,7 +997,7 @@ bool find_a_bracket(bool reverse, const char *bracket_pair)
|
||||
pointer = line->data + strlen(line->data);
|
||||
}
|
||||
} else {
|
||||
pointer = line->data + step_right(line->data, openfile->current_x);
|
||||
pointer = line->data + step_right(line->data, *xpos);
|
||||
|
||||
while (!(found = mbstrpbrk(pointer, bracket_pair))) {
|
||||
line = line->next;
|
||||
@ -887,45 +1007,24 @@ bool find_a_bracket(bool reverse, const char *bracket_pair)
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the current position to the found bracket. */
|
||||
openfile->current = line;
|
||||
openfile->current_x = found - line->data;
|
||||
/* Set the found position to the found bracket. */
|
||||
*inout_line = line;
|
||||
*xpos = found - line->data;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Search for a match to the bracket at the current cursor position, if
|
||||
* there is one. */
|
||||
void do_find_bracket(void)
|
||||
/* Search for the given bracket's compliment within matchbrackets.
|
||||
* ch must be a pointer to within matchbrackets.
|
||||
* reverse is true if the found compliment came before ch in matchbrackets. */
|
||||
const char *get_bracket_compliment(const char *ch, bool *reverse)
|
||||
{
|
||||
linestruct *was_current = openfile->current;
|
||||
size_t was_current_x = openfile->current_x;
|
||||
/* The current cursor position, in case we don't find a complement. */
|
||||
const char *ch;
|
||||
/* The location in matchbrackets of the bracket under the cursor. */
|
||||
int ch_len;
|
||||
/* The length of ch in bytes. */
|
||||
const char *wanted_ch;
|
||||
/* The location in matchbrackets of the complementing bracket. */
|
||||
int wanted_ch_len;
|
||||
/* The length of wanted_ch in bytes. */
|
||||
char bracket_pair[MAXCHARLEN * 2 + 1];
|
||||
/* The pair of characters in ch and wanted_ch. */
|
||||
size_t halfway = 0;
|
||||
/* The index in matchbrackets where the closing brackets start. */
|
||||
size_t charcount = mbstrlen(matchbrackets) / 2;
|
||||
/* Half the number of characters in matchbrackets. */
|
||||
size_t balance = 1;
|
||||
/* The initial bracket count. */
|
||||
bool reverse;
|
||||
/* The direction we search. */
|
||||
|
||||
ch = mbstrchr(matchbrackets, openfile->current->data + openfile->current_x);
|
||||
|
||||
if (ch == NULL) {
|
||||
statusline(AHEM, _("Not a bracket"));
|
||||
return;
|
||||
}
|
||||
const char *wanted_ch;
|
||||
/* The location in matchbrackets of the complementing bracket. */
|
||||
size_t halfway = 0;
|
||||
/* The index in matchbrackets where the closing brackets start. */
|
||||
|
||||
/* Find the halfway point in matchbrackets, where the closing ones start. */
|
||||
for (size_t i = 0; i < charcount; i++)
|
||||
@ -933,19 +1032,35 @@ void do_find_bracket(void)
|
||||
|
||||
/* When on a closing bracket, we have to search backwards for a matching
|
||||
* opening bracket; otherwise, forward for a matching closing bracket. */
|
||||
reverse = (ch >= (matchbrackets + halfway));
|
||||
*reverse = (ch >= (matchbrackets + halfway));
|
||||
|
||||
/* Step half the number of total characters either backwards or forwards
|
||||
* through matchbrackets to find the wanted complementary bracket. */
|
||||
wanted_ch = ch;
|
||||
while (charcount-- > 0) {
|
||||
if (reverse)
|
||||
if (*reverse)
|
||||
wanted_ch = matchbrackets + step_left(matchbrackets,
|
||||
wanted_ch - matchbrackets);
|
||||
else
|
||||
wanted_ch += char_length(wanted_ch);
|
||||
}
|
||||
|
||||
return wanted_ch;
|
||||
}
|
||||
|
||||
/* Create a bracket pair string from the given bracket in ch, assigning
|
||||
* the result to bracket_pair. Reverse is set to true if we need to
|
||||
* search backward for a match. */
|
||||
void create_bracket_pair(char *bracket_pair, const char *ch,
|
||||
int ch_len, bool* reverse)
|
||||
{
|
||||
const char *wanted_ch;
|
||||
/* The location in matchbrackets of the complementing bracket. */
|
||||
int wanted_ch_len;
|
||||
/* The length of wanted_ch in bytes. */
|
||||
|
||||
wanted_ch = get_bracket_compliment(ch, reverse);
|
||||
|
||||
ch_len = char_length(ch);
|
||||
wanted_ch_len = char_length(wanted_ch);
|
||||
|
||||
@ -953,24 +1068,65 @@ void do_find_bracket(void)
|
||||
strncpy(bracket_pair, ch, ch_len);
|
||||
strncpy(bracket_pair + ch_len, wanted_ch, wanted_ch_len);
|
||||
bracket_pair[ch_len + wanted_ch_len] = '\0';
|
||||
}
|
||||
|
||||
while (find_a_bracket(reverse, bracket_pair)) {
|
||||
/* Increment/decrement balance for an identical/other bracket. */
|
||||
balance += (strncmp(openfile->current->data + openfile->current_x,
|
||||
ch, ch_len) == 0) ? 1 : -1;
|
||||
/* Get the bracket match position for the character currently under the cursor.
|
||||
* If there is no bracket beneath the cursor, return NOT_A_BRACKET. If there is
|
||||
* no match found, return NOT_FOUND_BRACKET. Otherwise returns FOUND_BRACKET
|
||||
* and sets line and xpos to the found line and offset respectively. */
|
||||
int find_matching_bracket_pos(linestruct **line, size_t *xpos)
|
||||
{
|
||||
const char *br_ch;
|
||||
/* The location in matchbrackets of the bracket under the cursor. */
|
||||
int br_ch_len;
|
||||
/* The length of br_ch in bytes. */
|
||||
char bracket_pair[MAXCHARLEN * 2 + 1];
|
||||
/* The pair of characters in ch and wanted_ch. */
|
||||
size_t balance = 1;
|
||||
/* The initial bracket count. */
|
||||
bool reversed;
|
||||
/* The direction we search. */
|
||||
|
||||
/* When balance reached zero, we've found the complementary bracket. */
|
||||
if (balance == 0) {
|
||||
edit_redraw(was_current, FLOWING);
|
||||
return;
|
||||
}
|
||||
br_ch = mbstrchr(matchbrackets, (*line)->data + (*xpos));
|
||||
|
||||
if (br_ch == NULL)
|
||||
return NOT_A_BRACKET;
|
||||
|
||||
br_ch_len = char_length(br_ch);
|
||||
create_bracket_pair(bracket_pair, br_ch, br_ch_len, &reversed);
|
||||
|
||||
|
||||
while (find_a_bracket(reversed, bracket_pair, line, xpos)) {
|
||||
balance += (strncmp((*line)->data + *xpos,
|
||||
br_ch, br_ch_len) == 0) ? 1 : -1;
|
||||
if (balance == 0)
|
||||
return FOUND_BRACKET;
|
||||
|
||||
}
|
||||
return NOT_FOUND_BRACKET;
|
||||
}
|
||||
|
||||
/* Search for a match to the bracket at the current cursor position, if
|
||||
* there is one. */
|
||||
void do_find_bracket(void)
|
||||
{
|
||||
linestruct *was_current = openfile->current;
|
||||
size_t was_current_x = openfile->current_x;
|
||||
|
||||
int res = find_matching_bracket_pos(&openfile->current,
|
||||
&openfile->current_x);
|
||||
if (res == FOUND_BRACKET) {
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
edit_redraw(was_current, FLOWING);
|
||||
return;
|
||||
}
|
||||
|
||||
statusline(AHEM, _("No matching bracket"));
|
||||
|
||||
/* Restore the cursor position. */
|
||||
openfile->current = was_current;
|
||||
openfile->current_x = was_current_x;
|
||||
|
||||
statusline(AHEM, res == NOT_FOUND_BRACKET ?
|
||||
_("No matching bracket") :
|
||||
_("Not a bracket"));
|
||||
}
|
||||
|
||||
/* Place an anchor at the current line when none exists, otherwise remove it. */
|
||||
@ -994,6 +1150,12 @@ void go_to_and_confirm(linestruct *line)
|
||||
if (line != openfile->current) {
|
||||
openfile->current = line;
|
||||
openfile->current_x = 0;
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
#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)
|
||||
|
||||
299
src/text.c
299
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-2023 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-2021 Benno Schulenberg *
|
||||
* Copyright (C) 2015-2022 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 *
|
||||
@ -65,8 +65,8 @@ void do_mark(void)
|
||||
void do_tab(void)
|
||||
{
|
||||
#ifdef ENABLE_COLOR
|
||||
if (openfile->syntax && openfile->syntax->tab)
|
||||
inject(openfile->syntax->tab, strlen(openfile->syntax->tab));
|
||||
if (openfile->syntax && openfile->syntax->tabstring)
|
||||
inject(openfile->syntax->tabstring, strlen(openfile->syntax->tabstring));
|
||||
else
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
@ -96,6 +96,8 @@ void indent_a_line(linestruct *line, char *indentation)
|
||||
if (indent_len == 0)
|
||||
return;
|
||||
|
||||
UNFOLD_SEGMENT(line);
|
||||
|
||||
/* Add the fabricated indentation to the beginning of the line. */
|
||||
line->data = nrealloc(line->data, length + indent_len + 1);
|
||||
memmove(line->data + indent_len, line->data, length + 1);
|
||||
@ -117,8 +119,8 @@ void indent_a_line(linestruct *line, char *indentation)
|
||||
* depending on whether --tabstospaces is in effect. */
|
||||
void do_indent(void)
|
||||
{
|
||||
char *indentation;
|
||||
linestruct *top, *bot, *line;
|
||||
char *indentation;
|
||||
|
||||
/* Use either all the marked lines or just the current line. */
|
||||
get_range(&top, &bot);
|
||||
@ -134,8 +136,8 @@ void do_indent(void)
|
||||
indentation = nmalloc(tabsize + 1);
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
if (openfile->syntax && openfile->syntax->tab)
|
||||
indentation = mallocstrcpy(indentation, openfile->syntax->tab);
|
||||
if (openfile->syntax && openfile->syntax->tabstring)
|
||||
indentation = mallocstrcpy(indentation, openfile->syntax->tabstring);
|
||||
else
|
||||
#endif
|
||||
/* Set the indentation to either a bunch of spaces or a single tab. */
|
||||
@ -173,10 +175,10 @@ size_t length_of_white(const char *text)
|
||||
size_t white_count = 0;
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
if (openfile->syntax && openfile->syntax->tab) {
|
||||
size_t thelength = strlen(openfile->syntax->tab);
|
||||
if (openfile->syntax && openfile->syntax->tabstring) {
|
||||
size_t thelength = strlen(openfile->syntax->tabstring);
|
||||
|
||||
while (text[white_count] == openfile->syntax->tab[white_count])
|
||||
while (text[white_count] == openfile->syntax->tabstring[white_count])
|
||||
if (++white_count == thelength)
|
||||
return thelength;
|
||||
|
||||
@ -226,6 +228,8 @@ void unindent_a_line(linestruct *line, size_t indent_len)
|
||||
if (indent_len == 0)
|
||||
return;
|
||||
|
||||
UNFOLD_SEGMENT(line);
|
||||
|
||||
/* Remove the first tab's worth of whitespace from this line. */
|
||||
memmove(line->data, line->data + indent_len, length - indent_len + 1);
|
||||
|
||||
@ -317,6 +321,8 @@ bool comment_line(undo_type action, linestruct *line, const char *comment_seq)
|
||||
/* Length of postfix. */
|
||||
size_t line_len = strlen(line->data);
|
||||
|
||||
UNFOLD_SEGMENT(line);
|
||||
|
||||
if (!ISSET(NO_NEWLINES) && line == openfile->filebot)
|
||||
return FALSE;
|
||||
|
||||
@ -416,8 +422,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))
|
||||
if (comment_line(action, line, comment_seq)) {
|
||||
update_multiline_undo(line->lineno, "");
|
||||
}
|
||||
|
||||
set_modified();
|
||||
ensure_firstcolumn_is_aligned();
|
||||
@ -502,10 +509,11 @@ void redo_cut(undostruct *u)
|
||||
void do_undo(void)
|
||||
{
|
||||
undostruct *u = openfile->current_undo;
|
||||
linestruct *line = NULL, *intruder;
|
||||
linestruct *oldcutbuffer;
|
||||
char *data, *undidmsg = NULL;
|
||||
linestruct *oldcutbuffer, *intruder;
|
||||
linestruct *line = NULL;
|
||||
size_t original_x, regain_from_x;
|
||||
char *undidmsg = NULL;
|
||||
char *data;
|
||||
|
||||
if (u == NULL) {
|
||||
statusline(AHEM, _("Nothing to undo"));
|
||||
@ -539,6 +547,7 @@ void do_undo(void)
|
||||
line->has_anchor |= line->next->has_anchor;
|
||||
unlink_node(line->next);
|
||||
renumber_from(line);
|
||||
openfile->current = line;
|
||||
goto_line_posx(u->head_lineno, original_x);
|
||||
break;
|
||||
case BACK:
|
||||
@ -558,7 +567,8 @@ void do_undo(void)
|
||||
* and the nonewlines flag isn't set, do not re-add a newline that
|
||||
* wasn't actually deleted; just position the cursor. */
|
||||
if ((u->xflags & WAS_BACKSPACE_AT_EOF) && !ISSET(NO_NEWLINES)) {
|
||||
goto_line_posx(openfile->filebot->lineno, 0);
|
||||
openfile->current = openfile->filebot;
|
||||
openfile->current_x = 0;
|
||||
break;
|
||||
}
|
||||
line->data[u->tail_x] = '\0';
|
||||
@ -655,7 +665,7 @@ void do_undo(void)
|
||||
break;
|
||||
}
|
||||
|
||||
if (undidmsg && !pletion_line)
|
||||
if (undidmsg && !ISSET(ZERO) && !pletion_line)
|
||||
statusline(HUSH, _("Undid %s"), undidmsg);
|
||||
|
||||
openfile->current_undo = openfile->current_undo->next;
|
||||
@ -665,6 +675,13 @@ void do_undo(void)
|
||||
|
||||
openfile->totsize = u->wassize;
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
if (u->type <= REPLACE)
|
||||
check_the_multis(openfile->current);
|
||||
else if (u->type == INSERT)
|
||||
perturbed = TRUE;
|
||||
#endif
|
||||
|
||||
/* When at the point where the buffer was last saved, unset "Modified". */
|
||||
if (openfile->current_undo == openfile->last_saved) {
|
||||
openfile->modified = FALSE;
|
||||
@ -676,10 +693,12 @@ void do_undo(void)
|
||||
/* Redo the last thing(s) we undid. */
|
||||
void do_redo(void)
|
||||
{
|
||||
linestruct *line = NULL, *intruder;
|
||||
char *data, *redidmsg = NULL;
|
||||
bool suppress_modification = FALSE;
|
||||
undostruct *u = openfile->undotop;
|
||||
bool suppress_modification = FALSE;
|
||||
linestruct *line = NULL;
|
||||
linestruct *intruder;
|
||||
char *redidmsg = NULL;
|
||||
char *data;
|
||||
|
||||
if (u == NULL || u == openfile->current_undo) {
|
||||
statusline(AHEM, _("Nothing to redo"));
|
||||
@ -735,6 +754,7 @@ void do_redo(void)
|
||||
strcat(line->data, u->strdata);
|
||||
unlink_node(line->next);
|
||||
renumber_from(line);
|
||||
openfile->current = line;
|
||||
goto_line_posx(u->tail_lineno, u->tail_x);
|
||||
break;
|
||||
case REPLACE:
|
||||
@ -815,7 +835,7 @@ void do_redo(void)
|
||||
break;
|
||||
}
|
||||
|
||||
if (redidmsg)
|
||||
if (redidmsg && !ISSET(ZERO))
|
||||
statusline(HUSH, _("Redid %s"), redidmsg);
|
||||
|
||||
openfile->current_undo = u;
|
||||
@ -825,6 +845,13 @@ void do_redo(void)
|
||||
|
||||
openfile->totsize = u->newsize;
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
if (u->type <= REPLACE)
|
||||
check_the_multis(openfile->current);
|
||||
else if (u->type == INSERT)
|
||||
recook = TRUE;
|
||||
#endif
|
||||
|
||||
/* When at the point where the buffer was last saved, unset "Modified". */
|
||||
if (openfile->current_undo == openfile->last_saved) {
|
||||
openfile->modified = FALSE;
|
||||
@ -839,6 +866,13 @@ void do_enter(void)
|
||||
{
|
||||
linestruct *newnode = make_new_node(openfile->current);
|
||||
size_t extra = 0;
|
||||
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (openfile->current->folded) {
|
||||
newnode->folded = TRUE;
|
||||
openfile->current->folded = FALSE;
|
||||
}
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
linestruct *sampleline = openfile->current;
|
||||
bool allblanks = FALSE;
|
||||
@ -857,7 +891,7 @@ void do_enter(void)
|
||||
if (extra > openfile->current_x)
|
||||
extra = openfile->current_x;
|
||||
else if (extra == openfile->current_x)
|
||||
allblanks = TRUE;
|
||||
allblanks = (indent_length(openfile->current->data) == extra);
|
||||
}
|
||||
#endif /* NANO_TINY */
|
||||
newnode->data = nmalloc(strlen(openfile->current->data +
|
||||
@ -1177,7 +1211,8 @@ void update_undo(undo_type action)
|
||||
else if (cutbuffer != NULL) {
|
||||
free_lines(u->cutbuffer);
|
||||
u->cutbuffer = copy_buffer(cutbuffer);
|
||||
}
|
||||
} else
|
||||
break;
|
||||
if (!(u->xflags & MARK_WAS_SET)) {
|
||||
linestruct *bottomline = u->cutbuffer;
|
||||
size_t count = 0;
|
||||
@ -1212,9 +1247,9 @@ void update_undo(undo_type action)
|
||||
|
||||
#ifdef ENABLE_WRAPPING
|
||||
/* When the current line is overlong, hard-wrap it at the furthest possible
|
||||
* whitespace character, and (if possible) prepend the remainder of the line
|
||||
* to the next line. Return TRUE if wrapping occurred, and FALSE otherwise. */
|
||||
bool do_wrap(void)
|
||||
* whitespace character, and prepend the excess part to an "overflow" line
|
||||
* (when it already exists, otherwise create one). */
|
||||
void do_wrap(void)
|
||||
{
|
||||
linestruct *line = openfile->current;
|
||||
/* The line to be wrapped, if needed and possible. */
|
||||
@ -1243,7 +1278,7 @@ bool do_wrap(void)
|
||||
|
||||
/* If no wrapping point was found before end-of-line, we don't wrap. */
|
||||
if (wrap_loc < 0 || lead_len + wrap_loc == line_len)
|
||||
return FALSE;
|
||||
return;
|
||||
|
||||
/* Adjust the wrap location to its position in the full line,
|
||||
* and step forward to the character just after the blank. */
|
||||
@ -1251,7 +1286,7 @@ bool do_wrap(void)
|
||||
|
||||
/* When now at end-of-line, no need to wrap. */
|
||||
if (line->data[wrap_loc] == '\0')
|
||||
return FALSE;
|
||||
return;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(SPLIT_BEGIN, NULL);
|
||||
@ -1360,7 +1395,7 @@ bool do_wrap(void)
|
||||
add_undo(SPLIT_END, NULL);
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
#endif /* ENABLE_WRAPPING */
|
||||
|
||||
@ -1465,9 +1500,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. */
|
||||
@ -1565,6 +1599,7 @@ void concat_paragraph(linestruct *line, size_t count)
|
||||
line->data = nrealloc(line->data,
|
||||
line_len + next_line_len - next_lead_len + 1);
|
||||
strcat(line->data, next_line->data + next_lead_len);
|
||||
UNFOLD_SEGMENT(line);
|
||||
#ifndef NANO_TINY
|
||||
line->has_anchor |= next_line->has_anchor;
|
||||
#endif
|
||||
@ -1746,6 +1781,8 @@ void justify_text(bool whole_buffer)
|
||||
/* The leading part for lines after the first one. */
|
||||
size_t secondary_len = 0;
|
||||
/* The length of that later lead. */
|
||||
ssize_t was_the_linenumber = openfile->current->lineno;
|
||||
/* The line to return to after a full justification. */
|
||||
|
||||
/* TRANSLATORS: This one goes with Undid/Redid messages. */
|
||||
add_undo(COUPLE_BEGIN, N_("justification"));
|
||||
@ -1962,7 +1999,8 @@ void justify_text(bool whole_buffer)
|
||||
openfile->current_x = openfile->mark_x;
|
||||
openfile->mark = bottom;
|
||||
openfile->mark_x = bottom_x;
|
||||
}
|
||||
} else if (whole_buffer && !openfile->mark)
|
||||
goto_line_posx(was_the_linenumber, 0);
|
||||
|
||||
add_undo(COUPLE_END, N_("justification"));
|
||||
|
||||
@ -2001,7 +2039,7 @@ void do_full_justify(void)
|
||||
}
|
||||
#endif /* ENABLE_JUSTIFY */
|
||||
|
||||
#if defined(ENABLE_SPELLER) || defined (ENABLE_COLOR)
|
||||
#if defined(ENABLE_SPELLER) || defined (ENABLE_LINTER) || defined (ENABLE_FORMATTER)
|
||||
/* Set up an argument list for executing the given command. */
|
||||
void construct_argument_list(char ***arguments, char *command, char *filename)
|
||||
{
|
||||
@ -2018,7 +2056,9 @@ void construct_argument_list(char ***arguments, char *command, char *filename)
|
||||
(*arguments)[count - 2] = filename;
|
||||
(*arguments)[count - 1] = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_SPELLER) || defined (ENABLE_FORMATTER)
|
||||
/* Open the specified file, and if that succeeds, remove the text of the marked
|
||||
* region or of the entire buffer and read the file contents into its place. */
|
||||
bool replace_buffer(const char *filename, undo_type action, const char *operation)
|
||||
@ -2032,11 +2072,19 @@ bool replace_buffer(const char *filename, undo_type action, const char *operatio
|
||||
if (descriptor < 0)
|
||||
return FALSE;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(COUPLE_BEGIN, operation);
|
||||
#endif
|
||||
|
||||
/* When replacing the whole buffer, start cutting at the top. */
|
||||
if (action == CUT_TO_EOF) {
|
||||
openfile->current = openfile->filetop;
|
||||
openfile->current_x = 0;
|
||||
}
|
||||
|
||||
cutbuffer = NULL;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(COUPLE_BEGIN, operation);
|
||||
|
||||
/* Cut either the marked region or the whole buffer. */
|
||||
add_undo(action, NULL);
|
||||
do_snip(openfile->mark != NULL, openfile->mark == NULL, FALSE);
|
||||
@ -2061,6 +2109,7 @@ bool replace_buffer(const char *filename, undo_type action, const char *operatio
|
||||
/* Execute the given program, with the given temp file as last argument. */
|
||||
void treat(char *tempfile_name, char *theprogram, bool spelling)
|
||||
{
|
||||
#if defined(HAVE_FORK) && defined(HAVE_WAIT)
|
||||
ssize_t was_lineno = openfile->current->lineno;
|
||||
size_t was_pww = openfile->placewewant;
|
||||
size_t was_x = openfile->current_x;
|
||||
@ -2090,8 +2139,11 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
|
||||
timestamp_nsec = (long)fileinfo.st_mtim.tv_nsec;
|
||||
}
|
||||
|
||||
/* Exit from curses mode to give the program control of the terminal. */
|
||||
endwin();
|
||||
/* The spell checker needs the screen, so exit from curses mode. */
|
||||
if (spelling)
|
||||
endwin();
|
||||
else
|
||||
statusbar(_("Invoking formatter..."));
|
||||
|
||||
construct_argument_list(&arguments, theprogram, tempfile_name);
|
||||
|
||||
@ -2111,9 +2163,13 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
|
||||
|
||||
errornumber = errno;
|
||||
|
||||
/* Restore the terminal state and reenter curses mode. */
|
||||
terminal_init();
|
||||
doupdate();
|
||||
/* After spell checking, restore terminal state and reenter curses mode;
|
||||
* after formatting, make sure that any formatter output is wiped. */
|
||||
if (spelling) {
|
||||
terminal_init();
|
||||
doupdate();
|
||||
} else
|
||||
full_refresh();
|
||||
|
||||
if (thepid < 0) {
|
||||
statusline(ALERT, _("Could not fork: %s"), strerror(errornumber));
|
||||
@ -2155,14 +2211,9 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
|
||||
openfile->mark = line_from_number(was_mark_lineno);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
openfile->current = openfile->filetop;
|
||||
openfile->current_x = 0;
|
||||
|
||||
replaced = replace_buffer(tempfile_name, CUT_TO_EOF,
|
||||
/* TRANSLATORS: The next two go with Undid/Redid messages. */
|
||||
(spelling ? N_("spelling correction") : N_("formatting")));
|
||||
}
|
||||
|
||||
/* Go back to the old position. */
|
||||
goto_line_posx(was_lineno, was_x);
|
||||
@ -2183,8 +2234,9 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
|
||||
statusline(REMARK, _("Finished checking spelling"));
|
||||
else
|
||||
statusline(REMARK, _("Buffer has been processed"));
|
||||
#endif
|
||||
}
|
||||
#endif /* ENABLE_SPELLER || ENABLE_COLOR */
|
||||
#endif /* ENABLE_SPELLER || ENABLE_FORMATTER */
|
||||
|
||||
#ifdef ENABLE_SPELLER
|
||||
/* Let the user edit the misspelled word. Return FALSE if the user cancels. */
|
||||
@ -2295,12 +2347,14 @@ bool fix_spello(const char *word)
|
||||
* correction. */
|
||||
void do_int_speller(const char *tempfile_name)
|
||||
{
|
||||
#if defined(HAVE_FORK) && defined(HAVE_WAITPID)
|
||||
char *misspellings, *pointer, *oneword;
|
||||
long pipesize;
|
||||
size_t buffersize, bytesread, totalread;
|
||||
int spell_fd[2], sort_fd[2], uniq_fd[2], tempfile_fd = -1;
|
||||
pid_t pid_spell, pid_sort, pid_uniq;
|
||||
int spell_status, sort_status, uniq_status;
|
||||
unsigned stash[sizeof(flags) / sizeof(flags[0])];
|
||||
|
||||
/* Create all three pipes up front. */
|
||||
if (pipe(spell_fd) == -1 || pipe(sort_fd) == -1 || pipe(uniq_fd) == -1) {
|
||||
@ -2425,6 +2479,9 @@ void do_int_speller(const char *tempfile_name)
|
||||
terminal_init();
|
||||
doupdate();
|
||||
|
||||
/* Save the settings of the global flags. */
|
||||
memcpy(stash, flags, sizeof(flags));
|
||||
|
||||
/* Do any replacements case-sensitively, forward, and without regexes. */
|
||||
SET(CASE_SENSITIVE);
|
||||
UNSET(BACKWARDS_SEARCH);
|
||||
@ -2455,6 +2512,9 @@ void do_int_speller(const char *tempfile_name)
|
||||
free(misspellings);
|
||||
refresh_needed = TRUE;
|
||||
|
||||
/* Restore the settings of the global flags. */
|
||||
memcpy(flags, stash, sizeof(flags));
|
||||
|
||||
/* Process the end of the three processes. */
|
||||
waitpid(pid_spell, &spell_status, 0);
|
||||
waitpid(pid_sort, &sort_status, 0);
|
||||
@ -2468,6 +2528,7 @@ void do_int_speller(const char *tempfile_name)
|
||||
statusline(ALERT, _("Error invoking \"spell\""));
|
||||
else
|
||||
statusline(REMARK, _("Finished checking spelling"));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Spell check the current file. If an alternate spell checker is
|
||||
@ -2476,7 +2537,6 @@ void do_spell(void)
|
||||
{
|
||||
FILE *stream;
|
||||
char *temp_name;
|
||||
unsigned stash[sizeof(flags) / sizeof(flags[0])];
|
||||
bool okay;
|
||||
|
||||
ran_a_tool = TRUE;
|
||||
@ -2491,12 +2551,6 @@ void do_spell(void)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Save the settings of the global flags. */
|
||||
memcpy(stash, flags, sizeof(flags));
|
||||
|
||||
/* Don't add an extra newline when writing out the (selected) text. */
|
||||
SET(NO_NEWLINES);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->mark)
|
||||
okay = write_region_to_file(temp_name, stream, TEMPORARY, OVERWRITE);
|
||||
@ -2506,6 +2560,7 @@ void do_spell(void)
|
||||
|
||||
if (!okay) {
|
||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||
unlink(temp_name);
|
||||
free(temp_name);
|
||||
return;
|
||||
}
|
||||
@ -2520,19 +2575,17 @@ 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;
|
||||
}
|
||||
#endif /* ENABLE_SPELLER */
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
#ifdef ENABLE_LINTER
|
||||
/* Run a linting program on the current buffer. */
|
||||
void do_linter(void)
|
||||
{
|
||||
#if defined(HAVE_FORK) && defined(HAVE_WAITPID)
|
||||
char *lintings, *pointer, *onelint;
|
||||
long pipesize;
|
||||
size_t buffersize, bytesread, totalread;
|
||||
@ -2559,12 +2612,12 @@ void do_linter(void)
|
||||
edit_refresh();
|
||||
|
||||
if (openfile->modified) {
|
||||
int choice = do_yesno_prompt(FALSE, _("Save modified buffer before linting?"));
|
||||
int choice = ask_user(YESORNO, _("Save modified buffer before linting?"));
|
||||
|
||||
if (choice == -1) {
|
||||
if (choice == CANCEL) {
|
||||
statusbar(_("Cancelled"));
|
||||
return;
|
||||
} else if (choice == 1 && (do_writeout(FALSE, FALSE) != 1))
|
||||
} else if (choice == YES && (write_it_out(FALSE, FALSE) != 1))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2648,36 +2701,31 @@ void do_linter(void)
|
||||
if ((*pointer == '\r') || (*pointer == '\n')) {
|
||||
*pointer = '\0';
|
||||
if (onelint != pointer) {
|
||||
char *filename = NULL, *linestr = NULL, *maybecol = NULL;
|
||||
char *message = copy_of(onelint);
|
||||
char *filename, *linestring, *colstring;
|
||||
char *complaint = copy_of(onelint);
|
||||
char *spacer = strstr(complaint, " ");
|
||||
|
||||
/* The recognized format is "filename:line:column: message",
|
||||
* where ":column" may be absent or be ",column" instead. */
|
||||
if (strstr(message, ": ") != NULL) {
|
||||
filename = strtok(onelint, ":");
|
||||
if ((linestr = strtok(NULL, ":")) != NULL) {
|
||||
if ((maybecol = strtok(NULL, ":")) != NULL) {
|
||||
ssize_t tmplineno = 0, tmpcolno = 0;
|
||||
char *tmplinecol;
|
||||
if ((filename = strtok(onelint, ":")) && spacer) {
|
||||
if ((linestring = strtok(NULL, ":"))) {
|
||||
if ((colstring = strtok(NULL, " "))) {
|
||||
ssize_t linenumber = strtol(linestring, NULL, 10);
|
||||
ssize_t colnumber = strtol(colstring, NULL, 10);
|
||||
|
||||
tmplineno = strtol(linestr, NULL, 10);
|
||||
if (tmplineno <= 0) {
|
||||
if (linenumber <= 0) {
|
||||
free(complaint);
|
||||
pointer++;
|
||||
free(message);
|
||||
continue;
|
||||
}
|
||||
|
||||
tmpcolno = strtol(maybecol, NULL, 10);
|
||||
/* Check if the middle field is in comma format. */
|
||||
if (tmpcolno <= 0) {
|
||||
strtok(linestr, ",");
|
||||
if ((tmplinecol = strtok(NULL, ",")) != NULL)
|
||||
tmpcolno = strtol(tmplinecol, NULL, 10);
|
||||
else
|
||||
tmpcolno = 1;
|
||||
if (colnumber <= 0) {
|
||||
colnumber = 1;
|
||||
strtok(linestring, ",");
|
||||
if ((colstring = strtok(NULL, ",")))
|
||||
colnumber = strtol(colstring, NULL, 10);
|
||||
}
|
||||
|
||||
/* Nice. We have a lint message we can use. */
|
||||
parsesuccess = TRUE;
|
||||
tmplint = curlint;
|
||||
curlint = nmalloc(sizeof(lintstruct));
|
||||
@ -2685,17 +2733,17 @@ void do_linter(void)
|
||||
curlint->prev = tmplint;
|
||||
if (curlint->prev != NULL)
|
||||
curlint->prev->next = curlint;
|
||||
curlint->msg = copy_of(strstr(message, ": ") + 2);
|
||||
curlint->lineno = tmplineno;
|
||||
curlint->colno = tmpcolno;
|
||||
curlint->filename = copy_of(filename);
|
||||
curlint->lineno = linenumber;
|
||||
curlint->colno = colnumber;
|
||||
curlint->msg = copy_of(spacer + 1);
|
||||
|
||||
if (lints == NULL)
|
||||
lints = curlint;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(message);
|
||||
free(complaint);
|
||||
}
|
||||
onelint = pointer + 1;
|
||||
}
|
||||
@ -2718,7 +2766,7 @@ void do_linter(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (helpless && LINES > 4) {
|
||||
if (helpless && LINES > 5) {
|
||||
UNSET(NO_HELP);
|
||||
window_init();
|
||||
}
|
||||
@ -2732,7 +2780,7 @@ void do_linter(void)
|
||||
|
||||
while (TRUE) {
|
||||
int kbinput;
|
||||
functionptrtype func;
|
||||
functionptrtype function;
|
||||
struct stat lintfileinfo;
|
||||
|
||||
if (stat(curlint->filename, &lintfileinfo) != -1 &&
|
||||
@ -2753,14 +2801,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
|
||||
@ -2813,30 +2861,31 @@ void do_linter(void)
|
||||
confirm_margin();
|
||||
#endif
|
||||
edit_refresh();
|
||||
statusline(NOTICE, curlint->msg);
|
||||
statusline(NOTICE, "%s", curlint->msg);
|
||||
bottombars(MLINTER);
|
||||
}
|
||||
|
||||
/* Place the cursor to indicate the affected line. */
|
||||
place_the_cursor();
|
||||
wnoutrefresh(edit);
|
||||
UNFOLD_SEGMENT(openfile->current);
|
||||
wnoutrefresh(midwin);
|
||||
|
||||
kbinput = get_kbinput(bottomwin, VISIBLE);
|
||||
kbinput = get_kbinput(footwin, VISIBLE);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (kbinput == KEY_WINCH)
|
||||
continue;
|
||||
#endif
|
||||
func = func_from_key(&kbinput);
|
||||
function = func_from_key(kbinput);
|
||||
tmplint = curlint;
|
||||
|
||||
if (func == do_cancel || func == do_enter) {
|
||||
if (function == do_cancel || function == do_enter) {
|
||||
wipe_statusbar();
|
||||
break;
|
||||
} else if (func == do_help) {
|
||||
} else if (function == do_help) {
|
||||
tmplint = NULL;
|
||||
do_help();
|
||||
} else if (func == do_page_up || func == to_prev_block) {
|
||||
} else if (function == do_page_up || function == to_prev_block) {
|
||||
if (curlint->prev != NULL)
|
||||
curlint = curlint->prev;
|
||||
else if (last_wait != time(NULL)) {
|
||||
@ -2844,9 +2893,9 @@ void do_linter(void)
|
||||
beep();
|
||||
napms(600);
|
||||
last_wait = time(NULL);
|
||||
statusline(NOTICE, curlint->msg);
|
||||
statusline(NOTICE, "%s", curlint->msg);
|
||||
}
|
||||
} else if (func == do_page_down || func == to_next_block) {
|
||||
} else if (function == do_page_down || function == to_next_block) {
|
||||
if (curlint->next != NULL)
|
||||
curlint = curlint->next;
|
||||
else if (last_wait != time(NULL)) {
|
||||
@ -2854,7 +2903,7 @@ void do_linter(void)
|
||||
beep();
|
||||
napms(600);
|
||||
last_wait = time(NULL);
|
||||
statusline(NOTICE, curlint->msg);
|
||||
statusline(NOTICE, "%s", curlint->msg);
|
||||
}
|
||||
} else
|
||||
beep();
|
||||
@ -2877,8 +2926,11 @@ void do_linter(void)
|
||||
lastmessage = VACUUM;
|
||||
currmenu = MMOST;
|
||||
titlebar(NULL);
|
||||
#endif
|
||||
}
|
||||
#endif /* ENABLE_LINTER */
|
||||
|
||||
#ifdef ENABLE_FORMATTER
|
||||
/* Run a manipulation program on the contents of the buffer. */
|
||||
void do_formatter(void)
|
||||
{
|
||||
@ -2905,23 +2957,20 @@ void do_formatter(void)
|
||||
if (temp_name != NULL)
|
||||
okay = write_file(temp_name, stream, TEMPORARY, OVERWRITE, NONOTES);
|
||||
|
||||
if (!okay) {
|
||||
if (!okay)
|
||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||
free(temp_name);
|
||||
return;
|
||||
}
|
||||
|
||||
treat(temp_name, openfile->syntax->formatter, FALSE);
|
||||
else
|
||||
treat(temp_name, openfile->syntax->formatter, FALSE);
|
||||
|
||||
unlink(temp_name);
|
||||
free(temp_name);
|
||||
}
|
||||
#endif /* ENABLE_COLOR */
|
||||
#endif /* ENABLE_FORMATTER */
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Our own version of "wc". Note that its character counts are in
|
||||
/* Our own version of "wc". Note that the character count is in
|
||||
* multibyte characters instead of single-byte characters. */
|
||||
void do_wordlinechar_count(void)
|
||||
void count_lines_words_and_characters(void)
|
||||
{
|
||||
linestruct *was_current = openfile->current;
|
||||
size_t was_x = openfile->current_x;
|
||||
@ -2960,7 +3009,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, ALLOW_FOLDED))
|
||||
words++;
|
||||
}
|
||||
|
||||
@ -2983,12 +3032,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. */
|
||||
@ -2999,7 +3055,13 @@ void do_verbatim_input(void)
|
||||
if (count < 999)
|
||||
inject(bytes, count);
|
||||
|
||||
wipe_statusbar();
|
||||
#ifndef NANO_TINY
|
||||
/* Ensure that the feedback will be overwritten, or clear it. */
|
||||
if (ISSET(ZERO) && currmenu == MMAIN)
|
||||
wredrawln(midwin, editwinrows - 1, 1);
|
||||
else
|
||||
#endif
|
||||
wipe_statusbar();
|
||||
} else
|
||||
/* TRANSLATORS: An invalid verbatim Unicode code was typed. */
|
||||
statusline(AHEM, _("Invalid code"));
|
||||
@ -3027,12 +3089,14 @@ char *copy_completion(char *text)
|
||||
return word;
|
||||
}
|
||||
|
||||
/* Look at the fragment the user has typed, then search the current buffer for
|
||||
/* Look at the fragment the user has typed, then search all buffers for
|
||||
* the first word that starts with this fragment, and tentatively complete the
|
||||
* fragment. If the user types 'Complete' again, search and paste the next
|
||||
* possible completion. */
|
||||
void complete_a_word(void)
|
||||
{
|
||||
static openfilestruct *scouring = NULL;
|
||||
/* The buffer that is being searched for possible completions. */
|
||||
char *shard, *completion = NULL;
|
||||
size_t start_of_shard, shard_length = 0;
|
||||
size_t i = 0, j = 0;
|
||||
@ -3055,6 +3119,7 @@ void complete_a_word(void)
|
||||
openfile->last_action = OTHER;
|
||||
|
||||
/* Initialize the starting point for searching. */
|
||||
scouring = openfile;
|
||||
pletion_line = openfile->filetop;
|
||||
pletion_x = 0;
|
||||
|
||||
@ -3166,9 +3231,17 @@ void complete_a_word(void)
|
||||
|
||||
pletion_line = pletion_line->next;
|
||||
pletion_x = 0;
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* When at end of buffer and there is another, search that one. */
|
||||
if (pletion_line == NULL && scouring->next != openfile) {
|
||||
scouring = scouring->next;
|
||||
pletion_line = scouring->filetop;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* The search has reached the end of the file. */
|
||||
/* The search has gone through all buffers. */
|
||||
if (list_of_completions != NULL) {
|
||||
edit_refresh();
|
||||
statusline(AHEM, _("No further matches"));
|
||||
|
||||
47
src/utils.c
47
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-2023 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2016, 2017, 2019 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@ -130,14 +130,14 @@ bool parse_num(const char *string, ssize_t *result)
|
||||
* *line and *column. Return FALSE on error, and TRUE otherwise. */
|
||||
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
|
||||
{
|
||||
bool retval;
|
||||
char *firstpart;
|
||||
const char *comma;
|
||||
char *firstpart;
|
||||
bool retval;
|
||||
|
||||
while (*str == ' ')
|
||||
str++;
|
||||
|
||||
comma = strpbrk(str, "m,. /;");
|
||||
comma = strpbrk(str, ",.:");
|
||||
|
||||
if (comma == NULL)
|
||||
return parse_num(str, line);
|
||||
@ -168,14 +168,19 @@ void recode_NUL_to_LF(char *string, size_t length)
|
||||
}
|
||||
}
|
||||
|
||||
/* In the given string, recode each embedded newline as a NUL. */
|
||||
void recode_LF_to_NUL(char *string)
|
||||
/* In the given string, recode each embedded newline as a NUL,
|
||||
* and return the number of bytes in the string. */
|
||||
size_t recode_LF_to_NUL(char *string)
|
||||
{
|
||||
char *beginning = string;
|
||||
|
||||
while (*string != '\0') {
|
||||
if (*string == '\n')
|
||||
*string = '\0';
|
||||
string++;
|
||||
}
|
||||
|
||||
return (string - beginning);
|
||||
}
|
||||
|
||||
#if !defined(ENABLE_TINY) || defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
|
||||
@ -282,34 +287,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.
|
||||
@ -492,7 +489,9 @@ void get_range(linestruct **top, linestruct **bot)
|
||||
also_the_last = TRUE;
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_SPELLER) || defined (ENABLE_LINTER) || defined (ENABLE_FORMATTER)
|
||||
/* Return a pointer to the line that has the given line number. */
|
||||
linestruct *line_from_number(ssize_t number)
|
||||
{
|
||||
@ -507,7 +506,7 @@ linestruct *line_from_number(ssize_t number)
|
||||
|
||||
return line;
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
#endif
|
||||
|
||||
/* Count the number of characters from begin to end, and return it. */
|
||||
size_t number_of_characters_in(const linestruct *begin, const linestruct *end)
|
||||
|
||||
1311
src/winio.c
1311
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
|
||||
|
||||
@ -11,8 +11,8 @@ color brightyellow "\.(ascii|asciz|byte|double|float|hword|int|long|short|single
|
||||
color brightred "^[[:blank:]]*[.0-9A-Za-z_]*:"
|
||||
color brightcyan "^[[:blank:]]*#[[:blank:]]*(define|undef|include|ifn?def|endif|elif|else|if|warning|error)"
|
||||
|
||||
# Strings.
|
||||
color brightyellow "<[^= ]*>" ""(\\.|[^"])*""
|
||||
# Strings and names of included files.
|
||||
color brightyellow ""([^"\]|\\.)*"|<[^= ]*>"
|
||||
|
||||
# Comments.
|
||||
color brightblue "//.*"
|
||||
|
||||
@ -17,7 +17,7 @@ color cyan "\<[[:upper:]_[:digit:]]+\>"
|
||||
color red "\<[-_.0-9]+\>"
|
||||
|
||||
# Strings:
|
||||
color red ""[^"]*"" "'[^']*'"
|
||||
color red ""[^"]*"|'[^']*'"
|
||||
|
||||
# Backticks:
|
||||
color green "`[^`]*`"
|
||||
|
||||
@ -29,9 +29,9 @@ color magenta "\<(and|compl|lshift|or|rshift|xor)\>"
|
||||
color magenta "\<(bindtextdomain|dcgettext|dcngettext)\>"
|
||||
|
||||
# Strings.
|
||||
color brightyellow "<[^= ]*>" ""(\\.|[^"])*""
|
||||
color brightyellow ""([^"\]|\\.)*""
|
||||
# Comments.
|
||||
color brightblue "(^|[[:blank:]])#.*$"
|
||||
color brightblue "(^|[[:blank:]])#.*"
|
||||
|
||||
# Trailing whitespace.
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
@ -23,17 +23,16 @@ color brightyellow "\<(try|throw|catch|operator|new|delete)\>"
|
||||
color magenta "\<(break|continue|goto|return)\>"
|
||||
|
||||
# Single-quoted stuff (characters, backslash escapes, hex and octal byte codes).
|
||||
color brightmagenta "'([^'\]|\\(["'\abfnrtv]|x[0-9A-Fa-f]{1,2}|[0-3]?[0-7]{1,2}))'"
|
||||
color brightmagenta "'([^'\]|\\(["'\abfnrtv]|x[[:xdigit:]]{1,2}|[0-3]?[0-7]{1,2}))'"
|
||||
|
||||
# GCC builtins.
|
||||
color cyan "__attribute__[[:blank:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
|
||||
color cyan "__attribute__[[:blank:]]*\(\([^)]*\)\)|__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
|
||||
|
||||
# Strings. (In general you will want your strings and comments to come last,
|
||||
# because highlighting rules are applied in the order they are read in.)
|
||||
color brightyellow ""([^"]|\\")*"" "#[[:blank:]]*include[[:blank:]]*<[^>]+>"
|
||||
# Strings and names of included files.
|
||||
color brightyellow ""([^"]|\\")*"|#[[:blank:]]*include[[:blank:]]*<[^>]+>"
|
||||
|
||||
# Preprocessor directives.
|
||||
color brightcyan start="^[[:blank:]]*#[[:blank:]]*(if(n?def)?|elif|warning|error|pragma)\>" end="(\`|[^\\])$"
|
||||
color brightcyan start="^[[:blank:]]*#[[:blank:]]*(if(n?def)?|elif|warning|error|pragma)\>" end="(\`|[^\])$"
|
||||
color brightcyan "^[[:blank:]]*#[[:blank:]]*((define|else|endif|include(_next)?|line|undef)\>|$)"
|
||||
|
||||
# Comments.
|
||||
|
||||
@ -13,13 +13,13 @@ color red "^(19|20)[0-9-]{8}"
|
||||
color yellow "<[^>]*@[^>]*>"
|
||||
|
||||
# Command-line options.
|
||||
color cyan "[[:blank:]]-[a-zA-Z\$]" "--[8a-z-]+"
|
||||
color cyan "[[:blank:]]-[a-zA-Z\$]|--[8a-z-]+"
|
||||
# Bug and patch numbers.
|
||||
color cyan "(BZ|bug|patch)[ ]#[0-9]+" "PR [[:alnum:]]+/[0-9]+"
|
||||
color cyan "(BZ|bug|patch)[ ]#[0-9]+|PR [[:alnum:]]+/[0-9]+"
|
||||
# Probable constants, for variety.
|
||||
color brightred "\<[A-Z_][0-9A-Z_]+\>"
|
||||
# Key sequences.
|
||||
color brightblue "\^[A-Z^\]" "\<M-." "\<F1?[0-9]" "(\^|M-)Space"
|
||||
color brightblue "\^[A-Z^\]|\<M-.|\<F1?[0-9]|(\^|M-)Space"
|
||||
|
||||
# Changed files.
|
||||
color magenta start="^( | {8})\* " end="(:( |$)|^$)"
|
||||
|
||||
@ -15,5 +15,8 @@ icolor brightred "^[[:blank:]]*((end)?(function|macro)|return)"
|
||||
icolor cyan start="\$(ENV)?\{" end="\}"
|
||||
color magenta "\<(APPLE|UNIX|WIN32|CYGWIN|BORLAND|MINGW|MSVC(_IDE|60|71|80|90)?)\>"
|
||||
|
||||
# Comments.
|
||||
color brightblue "(^|[[:blank:]])#.*"
|
||||
|
||||
# Trailing whitespace.
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
@ -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 "^[[:blank:]]*#.*"
|
||||
|
||||
# Spaces in front of tabs.
|
||||
color ,red " + +"
|
||||
|
||||
# Nano's name, including version.
|
||||
color brightred "(GNU )?[Nn]ano [1-5]\.[0-9][-.[:alnum:]]*\>"
|
||||
# Nano's release motto, then name plus version.
|
||||
color italic,lime "\<[Nn]ano [1-7]\.[0-9][-.[:alnum:]]* "[^"]+""
|
||||
color brightred "\<(GNU )?[Nn]ano [1-7]\.[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 "(^|[[: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)$"
|
||||
comment "#"
|
||||
|
||||
## All the standard portage functions:
|
||||
color brightgreen "(^|\<default_)src_(unpack|prepare|configure|compile|install|test)\>"
|
||||
color brightgreen "^pkg_(config|nofetch|info|pretend|setup|(pre|post)(inst|rm))\>"
|
||||
color brightgreen "\<default(_pkg_nofetch|_src_(unpack|prepare|configure|compile|test))?\>"
|
||||
## Bash-related syntax:
|
||||
color green "\<(break|case|continue|do|done|elif|else|esac|exit|fi|for|function|if|in|read|return|select|shift|then|time|until|while)\>"
|
||||
color green "\<(declare|eval|exec|export|let|local)\>"
|
||||
color green "[{}():;|`$<>!=&\\]" "(\]|\[)"
|
||||
color green "-[defhnrsuwxzL]\>"
|
||||
color green "-(eq|ne|gt|lt|ge|le)\>"
|
||||
## Variables... official portage ones in red, all others in bright red:
|
||||
color brightred "\$[-0-9@*#?$!]" "\$[[:alpha:]_][[:alnum:]_]*"
|
||||
color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:digit:]]|@)+\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
|
||||
color red "\<(EAPI|ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|[BIPR]?DEPEND|PROVIDE|PROPERTIES|REQUIRED_USE|RESTRICT|USERLAND)\>"
|
||||
color red "\<(S|E?D|T|PV|PF|P|PN|PR|PVR|A|CATEGORY|DISTDIR|FILESDIR|EPREFIX|(B|E|E?SYS)?ROOT|WORKDIR)\>"
|
||||
color red "\<(AS|C(PP|XX)?|LD)FLAGS\>" "\<C(HOST|TARGET|BUILD)\>" "\<(MERGE_TYPE|REPLACING_VERSIONS|REPLACED_BY_VERSION)\>"
|
||||
color red "\<EBUILD_PHASE(_FUNC)?\>"
|
||||
color red "\<QA_((TEXTRELS|EXECSTACK|WX_LOAD)(_[a-zA-Z_0-9]+)?|DT_HASH|PRESTRIPPED)\>"
|
||||
color red "\<(PATCHES|(HTML_)?DOCS)\>" "\<WANT_(AUTO(CONF|MAKE)|LIBTOOL)\>" "\<AT_M4DIR\>"
|
||||
## Portage commands:
|
||||
color magenta "\<(use(_(with|enable|if_iuse)|x)?|in_iuse) [!a-zA-Z0-9_+ -]*" "inherit.*"
|
||||
color brightblue "\<e(apply(_user)?|begin|end|conf|install|make|ninja|qmake5|ant|(qa)?warn|infon?|error|log|patch(_user)?|new(group|user))\>"
|
||||
color brightblue "\<e(pause|beep|mktemp|(cvs|svn)_clean|punt_cxx)\>" "\<e(aclocal|auto(reconf|header|conf|make)|libtoolize)\>"
|
||||
color brightblue "\<e(stack|shopts|umask)_(push|pop)\>" "\<get_libdir\>" "\<ver_(cut|rs|test)\>" "\<version_is_at_least\>"
|
||||
color brightblue "\<make_desktop_entry\>" "\<unpack(_(makeself|pdv))?\>"
|
||||
color brightblue "\<(die|hasv?|inherit|nonfatal)\>" "\<(use(_(with|enable|if_iuse)|x)?|in_iuse)\>" "\<(has|best)_version\>"
|
||||
color brightblue "\<(do|new)(ins|s?bin|doc|header|lib(\.so|\.a)?|man|info|exe|initd|confd|envd|pam|menu|icon)\>"
|
||||
color brightblue "\<do(compress|dir|html|mo|strip|sym)\>" "\<keepdir\>"
|
||||
color brightblue "\<prepall(docs|info|man|strip)?\>" "\<prep(info|lib|lib\.(so|a)|man|strip)\>"
|
||||
color brightblue "\<(doc|ins|exe)?into\>" "\<f(owners|perms)\>" "\<(exe|ins|dir)opts\>"
|
||||
color brightblue "\<tc-get(BUILD_)?(AR|AS|CC|CPP|CXX|LD|NM|OBJCOPY|PKG_CONFIG|RANLIB)\>"
|
||||
color brightblue "\<tc-(arch(-kernel)?|export|has-(tls|openmp)|is-cross-compiler)\>"
|
||||
## Common commands used in ebuilds:
|
||||
color blue "\<(awk|cat|cd|chmod|chown|cp|echo|env|find|e?grep|ln|make|mkdir|mv|popd|printf|pushd|rm|rmdir|sed|set|tar|touch|unset|xargs)\>"
|
||||
## Comments (doesn't work that well):
|
||||
color yellow "(^|[[:space:]])#.*"
|
||||
## Strings (doesn't work that well):
|
||||
color brightyellow ""(\\.|[^\"])*"" "'(\\.|[^'])*'"
|
||||
## Trailing space is bad!
|
||||
color ,green "[[:space:]]+$"
|
||||
## Mixed whitespace is also bad.
|
||||
color ,green " "
|
||||
|
||||
|
||||
syntax /etc/portage "\.(accept_keywords|env|keywords|mask|unmask|use)(/.+)?$"
|
||||
comment "#"
|
||||
|
||||
## Base text:
|
||||
color green ".+"
|
||||
## Likely version and slot numbers:
|
||||
color magenta "-[[:digit:].]+(_(alpha|beta|pre|rc|p)[[:digit:]]*)*(-r[[:digit:]]+)?([:[:space:]]|$)"
|
||||
color magenta ":[^[:space:]]+([[:space:]]|$)"
|
||||
## Use flags (must come after version/slot):
|
||||
color brightred "[[:space:]]+\+?[A-Za-z0-9+_@-]+"
|
||||
color brightblue "[[:space:]]+-[A-Za-z0-9+_@-]+"
|
||||
## Accepted arches:
|
||||
color white "[~-]?\<(alpha|amd64|arm(64)?|hppa|ia64|m68k|mips|ppc(64)?|riscv|s390|sparc|x86)(-(cygwin|linux|macos|solaris|winnt))?\>"
|
||||
color white "[[:space:]][*~-]?\*"
|
||||
## Categories:
|
||||
color cyan "^[[:space:]]*[^/]*/"
|
||||
## Masking regulators:
|
||||
color brightmagenta "^[[:space:]]*(=|~|<|<=|>|>=)"
|
||||
## Comments:
|
||||
color yellow "#.*"
|
||||
## Trailing space is bad!
|
||||
color ,green "[[:space:]]+$"
|
||||
## Mixed whitespace is also bad.
|
||||
color ,green " "
|
||||
@ -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 "--.*"
|
||||
|
||||
@ -26,17 +26,16 @@ color magenta "\<(break|continue|fallthrough|goto|return)\>"
|
||||
color brightcyan "\<(package|import)\>"
|
||||
|
||||
# Literals.
|
||||
color red "\<([1-9][0-9]*|0[0-7]*|0[xX][0-9A-Fa-f]+)\>"
|
||||
color red "\<(true|false|nil|iota|_)\>"
|
||||
color red "\<([1-9][0-9]*|0[0-7]*|0[xX][[:xdigit:]]+)\>"
|
||||
color red "\<[0-9]+\.[0-9]*([eE][+-]?[0-9]+)?i?\>"
|
||||
color red "\<[0-9]+[eE][+-]?[0-9]+i?\>"
|
||||
color red "\B\.[0-9]+([eE][+-]?[0-9]+)?i?\>"
|
||||
color red "\<[0-9]+i\>"
|
||||
|
||||
# Strings and characters; slightly fuzzy.
|
||||
color red "\<(true|false|nil|iota|_)\>"
|
||||
color red "'(\\.|[^'])+'"
|
||||
color red ""(\\.|[^"])*""
|
||||
color red start=""(\\.|[^"])*\\[[:blank:]]*$" end="^(\\.|[^"])*""
|
||||
color red ""([^"\]|\\.)*"|'([^'\]|\\.)+'"
|
||||
color red start=""([^"\]|\\.)*\\[[:blank:]]*$" end="^([^"\]|\\.)*""
|
||||
|
||||
# Comments.
|
||||
color brightblue "//.*"
|
||||
|
||||
@ -1,25 +1,25 @@
|
||||
## Syntax highlighting for groff.
|
||||
|
||||
syntax groff "(/tmac\.[^/]+$|\.(m[ems]|rof|tmac)$)"
|
||||
syntax groff "\.(m[ems]|rof|tmac)$|/tmac\.[^/]+$"
|
||||
comment ".\""
|
||||
|
||||
# The argument of .ds or .nr
|
||||
# The setting of a string or register
|
||||
color cyan "^\.(ds|nr) [^[:space:]]*"
|
||||
# Single-character escapes
|
||||
color brightmagenta "\\."
|
||||
# The argument of \f or \s in the same color
|
||||
color brightmagenta "\\f(.|\(..)" "\\s(\+|\-)?[0-9]"
|
||||
# Newlines
|
||||
color brightmagenta "\\f(.|\(..)|\\s(\+|\-)?[0-9]"
|
||||
# References to registers
|
||||
color cyan "\\(\\)?n(.|\(..)"
|
||||
color cyan start="\\(\\)?n\[" end="]"
|
||||
# Requests
|
||||
color brightgreen "^\.[[:blank:]]*[^[:space:]]*"
|
||||
# Comments
|
||||
color yellow "^\.\\".*"
|
||||
# Strings
|
||||
# References to strings
|
||||
color green "\\(\\)?\*(.|\(..)"
|
||||
color green start="\\(\\)?\*\[" end="]"
|
||||
# Characters
|
||||
# Special characters
|
||||
color brightred "\\\(.."
|
||||
color brightred start="\\\[" end="]"
|
||||
# Macro arguments
|
||||
|
||||
@ -11,14 +11,13 @@ color brightcyan "\<define(-macro|-module|-public|-syntax)?\>"
|
||||
# Quoted symbols
|
||||
color brightyellow "'\<(\w|-)+\>"
|
||||
# Chars
|
||||
color brightmagenta "#\\."
|
||||
color brightmagenta "#\\\w+\>"
|
||||
color brightmagenta "#\\(.|\w+)"
|
||||
# Booleans
|
||||
color brightred "(#t|#f)\>"
|
||||
# Keywords
|
||||
color blue "#?:(\w|[?-])+"
|
||||
# Strings
|
||||
color yellow start="^[[:blank:]]+"" end="[^\]""
|
||||
color yellow ""(\\.|[^"])*""
|
||||
color yellow ""([^"\]|\\.)*""
|
||||
# Comments
|
||||
color cyan "(^|[[:blank:]]);.*"
|
||||
|
||||
@ -8,8 +8,8 @@ formatter tidy -m -q
|
||||
|
||||
# Tags:
|
||||
color cyan "<[[:alpha:]/!?][^>]*>"
|
||||
# Bold, italic, and underlined:
|
||||
color brightmagenta "</?[biu]>"
|
||||
# Bold, italic, underlined, emphasis, and importance:
|
||||
color brightmagenta "</?(b|i|u|em|strong)>"
|
||||
|
||||
# Named character references:
|
||||
color red "&[^;[:space:]]*;"
|
||||
@ -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,12 +12,12 @@ color brightyellow "\<(await|export|import|throw|try|catch|finally|new|delete)\>
|
||||
color magenta "\<(break|continue|return|yield)\>"
|
||||
|
||||
# Octal/decimal and hexadecimal numbers.
|
||||
color cyan "\<([0-9]+|0x[0-9A-Fa-f]+)\>"
|
||||
color cyan "\<([0-9]+|0x[[:xdigit:]]+)\>"
|
||||
# Special values.
|
||||
color cyan "\<(true|false|null|undefined)\>"
|
||||
|
||||
# Strings.
|
||||
color brightmagenta ""(\\.|[^"])*"" "'(\\.|[^'])*'" "`(\\.|[^`])*`"
|
||||
color brightmagenta ""([^"\]|\\.)*"|'([^'\]|\\.)*'|`([^`\]|\\.)*`"
|
||||
# Comments.
|
||||
color brightblue "(^|[[:blank:]])//.*"
|
||||
color brightblue start="/\*" end="\*/"
|
||||
|
||||
@ -12,9 +12,9 @@ color green ":[[:blank:]]*\-?(0|[1-9][0-9]*)(\.[0-9]+)?([Ee]?[-+]?[0-9]+)?"
|
||||
# Values (well, any string).
|
||||
color brightmagenta "".+""
|
||||
# Hex numbers (used as value).
|
||||
color green ":[[:blank:]]*"#[0-9abcdefABCDEF]+""
|
||||
color green ":[[:blank:]]*"#[[:xdigit:]]+""
|
||||
# Escapes.
|
||||
color green "\\\\" "\\"" "\\[bfnrt]" "\\u[0-9abcdefABCDEF]{4})"
|
||||
color green "\\(["\/bfnrt]|u[[:xdigit:]]{4})"
|
||||
# Special words.
|
||||
color green "\<(true|false|null)\>"
|
||||
|
||||
@ -22,9 +22,8 @@ color green "\<(true|false|null)\>"
|
||||
color brightblue ""[^"]+"[[:blank:]]*:"
|
||||
|
||||
# Brackets, braces, and separators.
|
||||
color brightblue "\[" "\]"
|
||||
color brightred "\{" "\}"
|
||||
color brightred "," ":"
|
||||
color brightblue "[][]"
|
||||
color brightred "[{},:]"
|
||||
|
||||
# Comments.
|
||||
color cyan "(^|[[:blank:]]+)(//|#).*"
|
||||
|
||||
@ -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 "--.*"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user