Compare commits
228 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7a5bacf15 | ||
|
|
20facb40c3 | ||
|
|
a5498feea6 | ||
|
|
3e4edb2a5a | ||
|
|
92ad431be4 | ||
|
|
123a102c52 | ||
|
|
37477bfbb5 | ||
|
|
bc40dd645a | ||
|
|
e02c8aeb20 | ||
|
|
003ddc763e | ||
|
|
1c3953705c | ||
|
|
b58418b32f | ||
|
|
23190aa60f | ||
|
|
01e6d435fe | ||
|
|
2b21d53857 | ||
|
|
cddfcb1b9d | ||
|
|
6755b7c0a0 | ||
|
|
aac4fc46e9 | ||
|
|
04cfe5a258 | ||
|
|
954cab81b4 | ||
|
|
69601315c4 | ||
|
|
43c6bc6619 | ||
|
|
e0fab690cc | ||
|
|
513d2ae905 | ||
|
|
47f3dc75d8 | ||
|
|
5f529a48e6 | ||
|
|
d9faac618d | ||
|
|
93ee0a8a65 | ||
|
|
15959346fb | ||
|
|
902b4674f9 | ||
|
|
37be9b54ca | ||
|
|
19a833c94e | ||
|
|
169da8aec0 | ||
|
|
20514eca19 | ||
|
|
f54f122637 | ||
|
|
d5b21d7bd0 | ||
|
|
4240423b9c | ||
|
|
74752686f4 | ||
|
|
4205567bb1 | ||
|
|
a20340b5a8 | ||
|
|
932a35c072 | ||
|
|
877a649819 | ||
|
|
5d7b723c16 | ||
|
|
053244db70 | ||
|
|
f7f5514eef | ||
|
|
afa0097ceb | ||
|
|
6e960012c2 | ||
|
|
311a7138b2 | ||
|
|
0ac04347d5 | ||
|
|
610be482fa | ||
|
|
9ad3a17954 | ||
|
|
6e04d697a1 | ||
|
|
916b4d81d0 | ||
|
|
66c6eb5166 | ||
|
|
43b42246d3 | ||
|
|
40a74e46e6 | ||
|
|
c3cd0f3411 | ||
|
|
85e895508b | ||
|
|
37c8232f4d | ||
|
|
f13dd140eb | ||
|
|
de47b58dc1 | ||
|
|
a5ef013e82 | ||
|
|
70da1889ee | ||
|
|
1eb639d55e | ||
|
|
79ca3ceabf | ||
|
|
b5ca8a00af | ||
|
|
2c7d336711 | ||
|
|
15c3e924b8 | ||
|
|
1053a3c440 | ||
|
|
7c30d1fa69 | ||
|
|
031166c34d | ||
|
|
5e769686fb | ||
|
|
df4d181987 | ||
|
|
7fcf6e6068 | ||
|
|
0f9d60a386 | ||
|
|
11a66d74b8 | ||
|
|
d3fdd20471 | ||
|
|
82492ead47 | ||
|
|
00713a7c47 | ||
|
|
420fe4d1e6 | ||
|
|
322a6f46fa | ||
|
|
b6a762232e | ||
|
|
54055b6174 | ||
|
|
3270250184 | ||
|
|
cb7c8255f4 | ||
|
|
60bdac2bbc | ||
|
|
f6c767a372 | ||
|
|
6c89815e8b | ||
|
|
894aff0816 | ||
|
|
556c0a3865 | ||
|
|
4d40bea58a | ||
|
|
ee979ae7b3 | ||
|
|
401e43969c | ||
|
|
5dbd9c0043 | ||
|
|
cd9328fbf5 | ||
|
|
7811f3fc5a | ||
|
|
5f07b96d47 | ||
|
|
bc98dbcab4 | ||
|
|
252bb60036 | ||
|
|
6d34b8a5cd | ||
|
|
ad505e7fff | ||
|
|
e7557a9293 | ||
|
|
757d223064 | ||
|
|
ea4ba3a150 | ||
|
|
32d7d3900d | ||
|
|
b57336ad00 | ||
|
|
ebfe752841 | ||
|
|
14f32577ee | ||
|
|
5618189643 | ||
|
|
cf634d1aff | ||
|
|
edc0d6280a | ||
|
|
6470106eef | ||
|
|
b89540218d | ||
|
|
77c60201d5 | ||
|
|
2482cfca56 | ||
|
|
946755a307 | ||
|
|
98b1f8f059 | ||
|
|
38e3318e5f | ||
|
|
6aad99bd81 | ||
|
|
4b8bd27d08 | ||
|
|
757f558f3b | ||
|
|
1f9283ec82 | ||
|
|
2eb1960523 | ||
|
|
4bf650f021 | ||
|
|
63db58cbfd | ||
|
|
c5a72103bf | ||
|
|
da4b7e430f | ||
|
|
e771503ee5 | ||
|
|
194d18586c | ||
|
|
e1a6f58da6 | ||
|
|
0ae80ce362 | ||
|
|
0c42c51aa4 | ||
|
|
f74a120803 | ||
|
|
911eb0cf2a | ||
|
|
67873e961b | ||
|
|
50e8f8aab9 | ||
|
|
ce6f320947 | ||
|
|
4104376e7c | ||
|
|
ffa0a9ef64 | ||
|
|
eef6b2b442 | ||
|
|
16c20ad873 | ||
|
|
f9bb5382aa | ||
|
|
329b82d284 | ||
|
|
b596639f95 | ||
|
|
d0982536a7 | ||
|
|
798695ff1e | ||
|
|
15320d3b96 | ||
|
|
0e9fb6a0da | ||
|
|
34b8d58871 | ||
|
|
fb4ce71cfc | ||
|
|
7a2c851dfc | ||
|
|
4d55748999 | ||
|
|
e7198f49a4 | ||
|
|
125cc0cd74 | ||
|
|
afab65e8a8 | ||
|
|
7e152f2a48 | ||
|
|
8854ddb728 | ||
|
|
0213f412d1 | ||
|
|
dc99610c36 | ||
|
|
d3c0fe3923 | ||
|
|
997826d794 | ||
|
|
67c69b2298 | ||
|
|
72a49dbbb4 | ||
|
|
0946153b47 | ||
|
|
9b2c2697cb | ||
|
|
a57c6a6763 | ||
|
|
597d90207e | ||
|
|
b1b2369541 | ||
|
|
8a88cea256 | ||
|
|
6f23d9c18c | ||
|
|
dfbffff4b0 | ||
|
|
ea73d7fd70 | ||
|
|
55c52c50d0 | ||
|
|
77bd8c2630 | ||
|
|
3121ee4b2e | ||
|
|
762cee242a | ||
|
|
3a170d2c3e | ||
|
|
e8751d1d5c | ||
|
|
9dd6407bea | ||
|
|
670dd9bbe0 | ||
|
|
9cdc64c97a | ||
|
|
5acfa5bb7b | ||
|
|
38ca2a41f4 | ||
|
|
6e3b9ac058 | ||
|
|
41c561c5cf | ||
|
|
c0abcc6018 | ||
|
|
55537dc218 | ||
|
|
3a79766da6 | ||
|
|
0f79a42333 | ||
|
|
3b79c7168e | ||
|
|
a9b4430888 | ||
|
|
7ca20711a2 | ||
|
|
cad8493e24 | ||
|
|
6bead051d2 | ||
|
|
ac8bd2a227 | ||
|
|
0d96df7a91 | ||
|
|
e2c61d83ef | ||
|
|
9a77c997e2 | ||
|
|
2cee79fbbf | ||
|
|
2c126b201f | ||
|
|
2500debbd2 | ||
|
|
500c41b83b | ||
|
|
2c83047842 | ||
|
|
5f5682240a | ||
|
|
4a70c1393f | ||
|
|
66cd897dc4 | ||
|
|
67e6eee26e | ||
|
|
7ccdb1970a | ||
|
|
539a18e4c7 | ||
|
|
a7083d632b | ||
|
|
44ea37573a | ||
|
|
d54840c152 | ||
|
|
14c085898b | ||
|
|
fb38995d36 | ||
|
|
2cdb87ee62 | ||
|
|
ba8462a458 | ||
|
|
4af81823e2 | ||
|
|
2c28a22971 | ||
|
|
c8e5c85113 | ||
|
|
4c0572a799 | ||
|
|
9aa382e69e | ||
|
|
929e1b6809 | ||
|
|
d3f0d32e16 | ||
|
|
3f309bc36a | ||
|
|
2516b64046 | ||
|
|
0ad0dcc926 | ||
|
|
f81d174f11 | ||
|
|
4fc728b405 |
235
ChangeLog
235
ChangeLog
@@ -1,3 +1,238 @@
|
||||
Changes between v3.2 and v4.0:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (190):
|
||||
bindings: change the action of <Alt+Up>/<Alt+Down> to 'scroll linewise'
|
||||
bindings: hard-bind ASCII code 0x08 (BS) to the backspace function
|
||||
bindings: make the normal scrolling keystrokes work also in help viewer
|
||||
bindings: provide usable shortcuts for prevword/nextword in tiny version
|
||||
bindings: rename 'cutwordleft' to 'chopwordleft', and similar for right
|
||||
browser, help: make <Bsp> page up also when terminfo mismatches terminal
|
||||
browser: say "Close" instead of "Exit" for the ^X shortcut
|
||||
browser: show the ^G item again in the help lines
|
||||
build: eradicate the --disable-wrapping-as-root configure option
|
||||
build: fix compilation when configured with --disable-utf8
|
||||
build: use wget over https (instead of plain rsync) to fetch PO files
|
||||
build: verify that 'pkg.m4' is available when building from git
|
||||
bump version numbers and add a news item for the 4.0 release
|
||||
copyright: update the years for significantly changed files
|
||||
copyright: update the years for the FSF
|
||||
copyright: update the years for the FSF in the documentation too
|
||||
cutting: cover the corner cases where cut commands do not cut anything
|
||||
cutting: give feedback when otherwise nothing happens
|
||||
cutting: when ^K does not actually cut anything, do not add an undo item
|
||||
display: account for horizontal scrolling when drawing the guide stripe
|
||||
display: account for zero-width characters when reserving space for '>'
|
||||
display: change the "$" continuation character to ">" and "<"
|
||||
display: dot the stripe when it's in the last column, to defeat a VTE bug
|
||||
display: ensure that spotlighted text is not treated as a prompt answer
|
||||
display: highlight the ">"/"<" continuation characters in reverse video
|
||||
display: represent half of a double-width character with "[" and "]"
|
||||
display: scroll horizontally one column earlier
|
||||
display: show "[" for half of two-column character also when softwrapping
|
||||
display: show it in title bar when starting up in restricted mode
|
||||
display: use non-breaking space instead of dot for VTE-bug workaround
|
||||
docs: add notes to draw attention to the changed defaults
|
||||
docs: adjust and extend the Pico-compatibility section in the manual
|
||||
docs: adjust for the enhancement of the default quoting regex
|
||||
docs: correct the descriptions of 'speller' and 'linter' functions
|
||||
docs: deprecate the use of morespace, smooth, nonewlines, and nowrap
|
||||
docs: describe breaklonglines, emptyline, finalnewline, jumpyscrolling
|
||||
docs: describe the four new options (-b, -f, -j, -e)
|
||||
docs: describe the new options -J, --guidestripe, and 'set stripecolor'
|
||||
docs: harmonize the style of bindable-function descriptions
|
||||
docs: mention nano's major features directly instead of referring
|
||||
docs: mention that 'cutwordleft' is bound to <Shift+Ctrl+Delete>
|
||||
docs: mention that --morespace and --smooth are obsolete and ignored
|
||||
docs: mention that 'quotestr' enables the rewrapping of comment blocks
|
||||
docs: mention three features in their proper place
|
||||
docs: remove from the FAQ some items that are no longer relevant
|
||||
docs: remove the mentioning of --disable-wrapping-as-root from the FAQ
|
||||
docs: reword and reshuffle the description of --rawsequences
|
||||
docs: say that --rebinddelete can correct both <Backspace> and <Delete>
|
||||
docs: stop implying that nano wants to be fully compatible with Pico
|
||||
docs: stop saying that --fill switches on automatic hard-wrapping
|
||||
docs: suggest a setting for 'stripecolor' in the sample nanorc
|
||||
docs: update the links in the FAQ to the mailing-list info pages
|
||||
feedback: complete the removal of some superfluous words
|
||||
feedback: make two error messages better match the option
|
||||
feedback: remove some superfluous words from Undid/Redid messages
|
||||
files: retain a Shift-selected region when switching between buffers
|
||||
gnulib: update to its current upstream state
|
||||
help, docs: say "Delete" when things don't go into the cutbuffer
|
||||
help: don't advertise ^S and ^Q when --preserve is used
|
||||
help: don't list the obsoleted -O and -S options in the --help output
|
||||
help: don't list the unbound <Alt+Up> and <Alt+Down> in the tiny version
|
||||
help: in the tiny version, don't list an option that is the default
|
||||
help: reword the description of ^U to avoid the impression of "Undo"
|
||||
help: reword the tags for deleting a word left and right
|
||||
justify: correctly detect when we've reached end of buffer
|
||||
justify: extend the quoting regex, to cover more types of comments
|
||||
justify: move the check for a bad quoting regex to a better place
|
||||
menus: don't show ^S and ^Q in the help lines in the tiny version
|
||||
menus: move the paragraph-jumping functions from Search to Goto-Line
|
||||
menus: put the ^T toggle in Search in the same position as in Goto-Line
|
||||
menus: remove the ^Y and ^V shortcuts from the Search menus
|
||||
new feature: option --guidestripe that shows a vertical guiding bar
|
||||
options: actually rename --rebindkeypad to --rawsequences (-K)
|
||||
options: add -b, --breaklonglines, the counterpart of --nowrap
|
||||
options: add -e, --emptyline, the counterpart of --morespace
|
||||
options: add -f, --finalnewline, the counterpart of --nonewlines
|
||||
options: add -j, --jumpyscrolling, the counterpart of --smooth
|
||||
options: disable hard-wrapping and automatic newlines by default
|
||||
options: let --fill no longer imply automatic hard-wrapping
|
||||
options: make -d (--rebinddelete) work without -K (--rebindkeypad)
|
||||
options: make --rawsequences disable --mouse, to prevent entering junk
|
||||
options: rename long version of -K from --rebindkeypad to --rawsequences
|
||||
options: stop recognizing and ignoring -b, -e, -f, -j, and -q
|
||||
options: stop recognizing and mentioning --quiet and 'set quiet'
|
||||
options: warn when option -O or -S is given, and ignore them
|
||||
prompt: trim a double-width character at the screen's edge
|
||||
rcfile: add 'stripecolor' for changing the color of the guiding stripe
|
||||
rcfile: add the options that correspond to -b, -f, -j, and -e
|
||||
rcfile, docs: remove deprecated forms of two options and five bindables
|
||||
rcfile: don't report an error when the globbing pattern matches nothing
|
||||
rcfile: reject an attempt to bind ^[
|
||||
rcfile: when a keystroke is rebound, don't bother unbinding it
|
||||
rcfile: when an old flag is unset, set the corresponding new flag
|
||||
rcfile: when rebound, DO unbind a keystroke from its earlier function
|
||||
startup: check again for a Linux console after reading all files
|
||||
startup: check that a backup directory is valid also when backups are off
|
||||
startup: improve two error messages by mentioning the invalid operand
|
||||
syntax: nanorc: stop coloring 'unset fill ...' as if it were valid
|
||||
syntax: tcl: colorize comments normally, not with a background hue
|
||||
text: turn the mark off when justifying, to not confuse an undo
|
||||
tweaks: add a consistency check plus a corresponding warning
|
||||
tweaks: add an alias for a string variable, so the code makes more sense
|
||||
tweaks: add deprecation comments to the four superseded options
|
||||
tweaks: add two comments, and reduce the scope of another variable
|
||||
tweaks: adjust indentation after previous change, and rename a parameter
|
||||
tweaks: adjust the indentation after the previous change
|
||||
tweaks: avoid parsing the same character twice
|
||||
tweaks: calculate the length of a completion word in a more direct way
|
||||
tweaks: change do_para_end() to not step beyond end of paragraph
|
||||
tweaks: condense a comment, and drop two others
|
||||
tweaks: condense a couple of comments and rewrap a few lines
|
||||
tweaks: condense a handful of comments
|
||||
tweaks: condense and correct a comment
|
||||
tweaks: condense and improve a couple of comments
|
||||
tweaks: condense and improve a handful of comments, and rewrap two lines
|
||||
tweaks: condense the logic of find_paragraph()
|
||||
tweaks: condense two regexes in the Tcl syntax, and add a comment
|
||||
tweaks: correct a comment typo, and trim a few other comments
|
||||
tweaks: don't bother executing two functions that are empty
|
||||
tweaks: don't bother special-casing non-UTF8 when checking for a blank
|
||||
tweaks: don't bother trying to draw characters beyond the screen's edge
|
||||
tweaks: don't bother zeroing the x position when doing a full justify
|
||||
tweaks: don't pass a pointer when a boolean is expected
|
||||
tweaks: elide a function that is called just once
|
||||
tweaks: elide an unneeded intermediate variable
|
||||
tweaks: elide a one-line function that is used just twice
|
||||
tweaks: elide a parameter -- do the NULL checks in the caller
|
||||
tweaks: elide a parameter that is always TRUE
|
||||
tweaks: elide a tiny function by making a variable global
|
||||
tweaks: elide a variable that is a copy of another
|
||||
tweaks: elide two unneeded intermediate variables
|
||||
tweaks: escape hyphens that must be hard hyphens in the man pages
|
||||
tweaks: exclude the guide-stripe code from the tiny version
|
||||
tweaks: hard-bind ASCII DEL in a slightly more economical way
|
||||
tweaks: improve a comment, and add an intermediate variable for clarity
|
||||
tweaks: improve a comment, to better match the changed code
|
||||
tweaks: improve and condense some comments, and remove an unneeded one
|
||||
tweaks: make an assignment only when the option is valid, like elsewhere
|
||||
tweaks: move declaration of variable that does not need to be global
|
||||
tweaks: move the character/word-deletion functions to a better location
|
||||
tweaks: move the check for beginning-of-paragraph to a better place
|
||||
tweaks: move the checks for git and gettext to a far earlier point
|
||||
tweaks: reduce a bunch of repetitious comments to their essence
|
||||
tweaks: reduce the scope of a variable, and rename it
|
||||
tweaks: reduce the scope of two variables, and rename one of them
|
||||
tweaks: reduce two parameters to a single one by summing them
|
||||
tweaks: refer to the magic line as "magic line", not as "magicline"
|
||||
tweaks: remove a superfluous check for a special case
|
||||
tweaks: remove a superfluous incrementing and decrementing of a variable
|
||||
tweaks: remove a variable that is no longer used
|
||||
tweaks: remove two tag definitions that are no longer needed
|
||||
tweaks: rename a function for aptness, and two variables for shortness
|
||||
tweaks: rename a function, to be simpler and more accurate
|
||||
tweaks: rename and invert a function, to avoid double negatives
|
||||
tweaks: rename an overlooked variable from a single letter to a word
|
||||
tweaks: rename a parameter plus a variable, and reshuffle an assignment
|
||||
tweaks: rename a struct element, to make sense
|
||||
tweaks: rename a symbol, to match its corresponding option
|
||||
tweaks: rename a type, to make more sense
|
||||
tweaks: rename a variable, because it also serves as "last line"
|
||||
tweaks: rename a variable, elide another, and adjust two comments
|
||||
tweaks: rename a variable, to be more distinct
|
||||
tweaks: rename four functions, to make more sense
|
||||
tweaks: rename some variables from a single letter to meaningful word
|
||||
tweaks: rename some variables, to match others that have the same task
|
||||
tweaks: rename three functions and two symbols, to match the new wording
|
||||
tweaks: rename three variables, and reshuffle two declarations
|
||||
tweaks: rename two parameters to be more descriptive
|
||||
tweaks: rename two variables, to be less confusing
|
||||
tweaks: rename two variables, to be more descriptive
|
||||
tweaks: rename two variables, to indicate better what they mean
|
||||
tweaks: renumber some FAQ items, to compensate for the deleted ones
|
||||
tweaks: reorder some ifs, to reduce the average number of comparisons
|
||||
tweaks: reshuffle a bit of code, to have the exit point near the end
|
||||
tweaks: reshuffle a few lines, and condense some comments
|
||||
tweaks: reshuffle and frob a couple of comments, and reindent two lines
|
||||
tweaks: reshuffle some code, to require two fewer ifs
|
||||
tweaks: reword the description of the disadvantages of Pico
|
||||
tweaks: rewrap a line and improve a few comments
|
||||
tweaks: schedule a call of edit_refresh() instead calling it directly
|
||||
tweaks: slightly indent warnings and errors during the configure phase
|
||||
tweaks: slightly reword, for esthetics of the resulting Info document
|
||||
tweaks: split a variable into two, as they have different roles
|
||||
tweaks: switch from checking MORE_SPACE to checking EMPTY_LINE
|
||||
tweaks: switch from checking SMOOTH_SCROLL to checking JUMPY_SCROLLING
|
||||
tweaks: switch from referencing NO_NEWLINES to referencing FINAL_NEWLINE
|
||||
tweaks: switch from referencing NO_WRAP to referencing BREAK_LONG_LINES
|
||||
tweaks: word some comments more concisely
|
||||
undo: set the correct file size for a redo of a character deletion
|
||||
utils: retire the fixbounds() function -- it is no longer needed
|
||||
|
||||
Brand Huntsman (1):
|
||||
history: use an unfreed 'position_history' to avoid a possible crash
|
||||
|
||||
David Lawrence Ramsey (34):
|
||||
display: correctly trim an overshooting character from a prompt answer
|
||||
display: correct the logic for making room for the ">" character
|
||||
display: properly handle double-width characters when spotlighting
|
||||
display: properly trim double-width characters at the edit window's edge
|
||||
display: show the guide stripe for double-width/multi-byte characters
|
||||
docs: remove references to not being able to undo justifications
|
||||
input: properly handle <Escape>s followed by a shifted Meta+letter
|
||||
justify: handle the leading part when justifying a marked region
|
||||
justify: initialize a variable before making use of its value
|
||||
justify: put a mid-line marked region onto separate lines
|
||||
justify: when justifying a marked region, strip whitespace after the lead
|
||||
moving: make the generic paragraph movement functions work on any buffer
|
||||
new feature: marked text gets justified into a single, new paragraph
|
||||
options: exit on a bad quoting regex, instead of crashing later
|
||||
text: hook the new justify mechanism up to the undo system
|
||||
text: make do_justify() use the cutbuffer
|
||||
text: make find_paragraph() work on any buffer
|
||||
text: make justify_format() work on any buffer
|
||||
text: make justify_paragraph() work on any buffer
|
||||
text: prepare to make find_paragraph() work on any buffer
|
||||
text: properly check again for no paragraphs after the current line
|
||||
text: remove the old unjustify mechanism, to prepare for the new justify
|
||||
tweaks: adapt find_paragraph()/justify_paragraph() for multiple quotes
|
||||
tweaks: adjust indentation after the previous commit
|
||||
tweaks: adjust some indentation after the previous change
|
||||
tweaks: normalize the indentation, and remove unneeded braces
|
||||
tweaks: remove unnecessary variable initializations
|
||||
tweaks: rename a variable, to prepare for its new role
|
||||
tweaks: split justify_paragraph() into three separate functions
|
||||
tweaks: swap the names of the variables 'wrap_at' and 'fill'
|
||||
tweaks: use proper variable types in the word-completion functions
|
||||
undo: after undoing a cut, don't remove the magicline if we're on it
|
||||
undo: set and check 'xflags' in a bitwise manner
|
||||
undo: when undoing a cut, remove also the magicline if it added one
|
||||
|
||||
|
||||
Changes between v3.1 and v3.2:
|
||||
------------------------------
|
||||
|
||||
|
||||
15
IMPROVEMENTS
15
IMPROVEMENTS
@@ -1,6 +1,14 @@
|
||||
Improvements in GNU nano
|
||||
========================
|
||||
|
||||
Since 4.0:
|
||||
- Automatic hard-wrapping is no longer the default.
|
||||
- Addition of --guidestripe to draw a helpful vertical bar.
|
||||
- Meta-Up and Meta-Down scroll the screen linewise.
|
||||
- Continuation is shown with a highlighted ">" instead of a plain "$".
|
||||
- A marked region gets justified into a single, separate paragraph.
|
||||
- Any number of justifications can be undone.
|
||||
|
||||
Since 3.0:
|
||||
- Addition of --zap to make <Del> and <Bsp> obliterate marked text.
|
||||
- <Ctrl+Delete> wipes next word and <Shift+Ctrl+Delete> preceding word.
|
||||
@@ -23,7 +31,6 @@ Since 2.9.0:
|
||||
for the history files (of search strings and cursor positions).
|
||||
|
||||
Since 2.8.0:
|
||||
- Meta-Up/Meta-Down will search the previous/next occurrence.
|
||||
- ^U pastes the first line of the cutbuffer at a prompt.
|
||||
- Softwrapping can be done at whitespace (with --soft --atblanks).
|
||||
- The ^G help texts have become searchable (with ^W and M-W).
|
||||
@@ -54,6 +61,9 @@ Since 2.5.0:
|
||||
- On most terminals Ctrl+Left / Ctrl+Right now work for PrevWord/NextWord.
|
||||
- When in the middle of a word, PrevWord now jumps to the start of this
|
||||
word (like Pico does) instead of to the start of the preceding word.
|
||||
- The ability to delete whole words with 'cutwordleft' and 'cutwordright'.
|
||||
- The ability to save a file without prompting for its name ('savefile').
|
||||
- The ability to search backward without having to toggle the direction.
|
||||
|
||||
Since 2.4.0:
|
||||
- Replacing things in a marked region now takes place in situ, in context,
|
||||
@@ -63,9 +73,6 @@ Since 2.4.0:
|
||||
|
||||
Since 2.3.0:
|
||||
- System syntaxes can be improved upon with the 'extendsyntax' command.
|
||||
- The ability to delete whole words with 'cutwordleft' and 'cutwordright'.
|
||||
- The ability to save a file without prompting for its name ('savefile').
|
||||
- The ability to search backward without having to toggle the direction.
|
||||
- Whitespace display (M-P) does not require configuration to be useful.
|
||||
- Undo/redo is enabled by default (M-U/M-E) and works nearly everywhere
|
||||
-- just not yet for justifying and indenting/unindenting.
|
||||
|
||||
25
NEWS
25
NEWS
@@ -1,3 +1,28 @@
|
||||
2019.03.24 - GNU nano 4.0 "Thy Rope of Sands"
|
||||
• An overlong line is no longer automatically hard-wrapped.
|
||||
• Smooth scrolling (one line at a time) has become the default.
|
||||
• A newline character is no longer automatically added at end of buffer.
|
||||
• The line below the title bar is by default part of the editing space.
|
||||
• Option --breaklonglines (-b) turns automatic hard-wrapping back on.
|
||||
• Option --jumpyscrolling (-j) gives the chunky, half-screen scrolling.
|
||||
• Option --finalnewline (-f) brings back the automatic newline at EOF.
|
||||
• Option --emptyline (-e) leaves the line below the title bar unused.
|
||||
• <Alt+Up> and <Alt+Down> now do a linewise scroll instead of a findnext.
|
||||
• Any number of justifications can be undone (like all other operations).
|
||||
• When marked text is justified, it becomes a single, separate paragraph.
|
||||
• Option --guidestripe=<number> draws a vertical bar at the given column.
|
||||
• Option --fill=<number> no longer turns on automatic hard-wrapping.
|
||||
• When a line continues offscreen, it now ends with a highlighted ">".
|
||||
• The halfs of a split two-column character are shown as "[" and "]".
|
||||
• A line now scrolls horizontally one column earlier.
|
||||
• The bindable functions 'cutwordleft' and 'cutwordright' were renamed
|
||||
to 'chopwordleft' and 'chopwordright' as they don't use the cutbuffer.
|
||||
• The paragraph-jumping functions were moved from Search to Go-to-Line.
|
||||
• Option --rebinddelete is able to compensate for more misbindings.
|
||||
• Options --morespace and --smooth are obsolete and thus ignored.
|
||||
• The --disable-wrapping-as-root configure option was removed.
|
||||
|
||||
|
||||
2018.11.11 - GNU nano 3.2 "Het kromme hout" changes the default binding
|
||||
for the linter to M-B so that the spell checker (^T) can
|
||||
always be used, and changes (when linting) the text in the
|
||||
|
||||
21
README
21
README
@@ -1,5 +1,5 @@
|
||||
|
||||
GNU nano -- an enhanced clone of the Pico text editor
|
||||
GNU nano -- a simple editor, inspired by Pico
|
||||
|
||||
Overview
|
||||
|
||||
@@ -7,15 +7,18 @@ Overview
|
||||
wonderfully easy-to-use and friendly Pico text editor.
|
||||
|
||||
First and foremost was its license: the Pine suite does not use
|
||||
the GPL or a GPL-friendly license, and has unclear restrictions on
|
||||
redistribution. Because of this, Pine and Pico are not included
|
||||
with many GNU/Linux distributions. Also, other features (like
|
||||
go-to-line-number or search-and-replace) were unavailable until
|
||||
recently or require a command-line flag. Yuck.
|
||||
the GPL, and (before using the Apache License) it had unclear
|
||||
restrictions on redistribution. Because of this, Pine and Pico
|
||||
were not included in many GNU/Linux distributions. Furthermore,
|
||||
some features (like go-to-line-number or search-and-replace) were
|
||||
unavailable for a long time or require a command-line flag. Yuck.
|
||||
|
||||
nano aims to solve these problems by emulating the functionality of
|
||||
Pico as closely as possible while addressing the problems above and
|
||||
providing other extra functionality.
|
||||
Nano aimed to solve these problems by: 1) being truly free software
|
||||
by using the GPL, 2) emulating the functionality of Pico as closely
|
||||
as is reasonable, and 3) include extra functionality by default.
|
||||
|
||||
Nowadays, nano wants to be a generally useful editor, with default
|
||||
settings that do not change the file contents automatically.
|
||||
|
||||
The nano editor is an official GNU package. For more information on
|
||||
GNU and the Free Software Foundation, please see https://www.gnu.org/.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Generate configure & friends for GIT users.
|
||||
|
||||
gnulib_url="git://git.sv.gnu.org/gnulib.git"
|
||||
gnulib_hash="6ccfbb4ce5d4fa79f7afb48f3648f2e0401523c3"
|
||||
gnulib_hash="69c4509f33c6a6ac159f3429d4150bf119ac4d76"
|
||||
|
||||
modules="
|
||||
futimens
|
||||
|
||||
152
configure.ac
152
configure.ac
@@ -1,6 +1,6 @@
|
||||
# Configuration for GNU nano - a small and user-friendly text editor
|
||||
#
|
||||
# Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2011, 2013-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2014, 2017 Mike Frysinger
|
||||
#
|
||||
# GNU nano is free software: you can redistribute it and/or modify
|
||||
@@ -16,7 +16,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
|
||||
AC_INIT([GNU nano], [3.2], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [4.0], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AC_CANONICAL_HOST
|
||||
AM_INIT_AUTOMAKE([1.14])
|
||||
@@ -56,6 +56,33 @@ dnl Data location.
|
||||
pkgdatadir=${datadir}/${PACKAGE}
|
||||
AC_DEFINE_DIR([PKGDATADIR], [pkgdatadir], [Where data are placed to.])
|
||||
|
||||
dnl Whether this is a git repository.
|
||||
|
||||
AC_MSG_CHECKING([whether building from git])
|
||||
if test -d .git ; then
|
||||
AC_MSG_RESULT([yes])
|
||||
from_git=yes
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
from_git=no
|
||||
fi
|
||||
AM_CONDITIONAL(BUILDING_FROM_GIT, test x$from_git = xyes)
|
||||
|
||||
dnl Checks for pkg-config and gettext when building from git.
|
||||
|
||||
if test x$from_git = xyes; then
|
||||
if test ! -f $(aclocal --print-ac-dir)/pkg.m4; then
|
||||
AC_MSG_ERROR([
|
||||
*** The pkg.m4 macros are missing. ***
|
||||
*** The pkg-config package needs to be installed when building from git. ***])
|
||||
fi
|
||||
if test "$ac_cv_path_MSGFMT" = ":"; then
|
||||
AC_MSG_ERROR([
|
||||
*** The msgfmt program is missing. ***
|
||||
*** The gettext package needs to be installed when building from git. ***])
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl Checks for header files.
|
||||
|
||||
AC_CHECK_HEADERS(libintl.h limits.h pwd.h termios.h sys/param.h)
|
||||
@@ -271,12 +298,6 @@ if test "x$enable_wrapping" != xno; then
|
||||
AC_DEFINE(ENABLE_WRAPPING, 1, [Define this to have hard text wrapping.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(wrapping-as-root,
|
||||
AS_HELP_STRING([--disable-wrapping-as-root], [Disable wrapping of text as root by default]))
|
||||
if test "x$enable_wrapping_as_root" = xno; then
|
||||
AC_DEFINE(DISABLE_ROOTWRAPPING, 1, [Define this to disable text wrapping as root by default.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(debug,
|
||||
AS_HELP_STRING([--enable-debug], [Enable debugging (disabled by default)]))
|
||||
if test "x$enable_debug" = xyes; then
|
||||
@@ -398,10 +419,10 @@ int main(void)
|
||||
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
|
||||
AC_MSG_WARN([*** Can not use slang when cross-compiling])),
|
||||
AC_MSG_ERROR([
|
||||
*** The header file slcurses.h was not found. If you wish to use
|
||||
*** slang support this header file is required. Please either
|
||||
*** install a version of slang that includes the slcurses.h file or
|
||||
*** do not call the configure script with --with-slang.]))
|
||||
*** The header file slcurses.h was not found. This header file
|
||||
*** is required if you wish to use Slang support. Please either
|
||||
*** install a version of Slang that includes the slcurses.h file
|
||||
*** or do not call the configure script with --with-slang.]))
|
||||
fi
|
||||
|
||||
if eval "test x$CURSES_LIB_NAME = x"; then
|
||||
@@ -479,10 +500,10 @@ int main(void)
|
||||
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
|
||||
AC_MSG_WARN([*** Can not use slang when cross-compiling])),
|
||||
AC_MSG_ERROR([
|
||||
*** The header file slcurses.h was not found. If you wish to use
|
||||
*** slang support this header file is required. Please either
|
||||
*** install a version of slang that includes the slcurses.h file or
|
||||
*** do not call the configure script with --with-slang.]))
|
||||
*** The header file slcurses.h was not found. This header file
|
||||
*** is required if you wish to use Slang support. Please either
|
||||
*** install a version of Slang that includes the slcurses.h file
|
||||
*** or do not call the configure script with --with-slang.]))
|
||||
fi
|
||||
|
||||
if test "${_libs+set}" = "set"; then
|
||||
@@ -566,9 +587,9 @@ fi
|
||||
|
||||
if eval "test x$CURSES_LIB_NAME = x"; then
|
||||
AC_MSG_ERROR([
|
||||
*** No curses lib was found. Please install the curses header files
|
||||
*** from libncursesw5-dev (Debian), ncurses-devel (Fedora), or similar.
|
||||
*** (Or install ncurses from https://ftp.gnu.org/gnu/ncurses/.)])
|
||||
*** No curses lib was found. Please install the curses header files
|
||||
*** from libncursesw5-dev (Debian), ncurses-devel (Fedora), or similar.
|
||||
*** (Or install ncurses from https://ftp.gnu.org/gnu/ncurses/.)])
|
||||
else
|
||||
AC_MSG_RESULT([Using $CURSES_LIB_NAME as the curses library])
|
||||
fi
|
||||
@@ -601,18 +622,18 @@ if test "x$enable_utf8" != xno && \
|
||||
else
|
||||
if test "x$enable_utf8" = xyes; then
|
||||
AC_MSG_ERROR([
|
||||
*** UTF-8 support was requested, but insufficient UTF-8 support was
|
||||
*** detected in your curses and/or C libraries. Please verify that your
|
||||
*** slang was built with UTF-8 support or your curses was built with
|
||||
*** wide character support, and that your C library was built with wide
|
||||
*** character support.])
|
||||
*** UTF-8 support was requested, but insufficient UTF-8 support was
|
||||
*** detected in your curses and/or C libraries. Please verify that
|
||||
*** your Slang was built with UTF-8 support or your curses was built
|
||||
*** with wide-character support, and that your C library was built
|
||||
*** with wide-character support.])
|
||||
elif test "x$enable_utf8" != xno; then
|
||||
AC_MSG_WARN([
|
||||
*** Insufficient UTF-8 support was detected in your curses and/or C
|
||||
*** libraries. If you want UTF-8 support, please verify that your slang
|
||||
*** was built with UTF-8 support or your curses was built with wide
|
||||
*** character support, and that your C library was built with wide
|
||||
*** character support.])
|
||||
*** Insufficient UTF-8 support was detected in your curses and/or C
|
||||
*** libraries. If you want UTF-8 support, please verify that your
|
||||
*** Slang was built with UTF-8 support or your curses was built with
|
||||
*** wide-character support, and that your C library was built with
|
||||
*** wide-character support.])
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -638,55 +659,6 @@ fi
|
||||
AC_DEFINE_UNQUOTED(NANO_REG_EXTENDED, $nano_reg_extended,
|
||||
[Flag(s) to use to get the full range of extended regular expressions])
|
||||
|
||||
# Check for word-boundary support (/< and />).
|
||||
AC_MSG_CHECKING([for GNU-style word boundary regex support])
|
||||
AC_ARG_WITH(wordbounds,
|
||||
AS_HELP_STRING([--with-wordbounds], [Use GNU-style word boundary delimiters]),
|
||||
[with_wordbounds=$withval], [with_wordbounds=auto])
|
||||
if test "$with_wordbounds" != "no"; then
|
||||
dnl If we're using the bundled gnulib regex module, we know it's supported.
|
||||
if test "$ac_use_included_regex" = "yes"; then
|
||||
with_wordbounds="yes"
|
||||
fi
|
||||
|
||||
dnl We explicitly don't check if the user forced the option, because
|
||||
dnl this is needed for cross compilers and we can't test the target.
|
||||
if test "$with_wordbounds" != "yes"; then
|
||||
AC_TRY_RUN([
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <regex.h>
|
||||
int main(void)
|
||||
{
|
||||
regex_t r;
|
||||
size_t nmatch;
|
||||
regmatch_t pmatch;
|
||||
|
||||
if (regcomp(&r, "\\\\>", $nano_reg_extended|REG_NOSUB))
|
||||
return 1;
|
||||
if (regexec(&r, "word boundary", nmatch, &pmatch, 0))
|
||||
return 1;
|
||||
return 0;
|
||||
}],
|
||||
with_wordbounds="yes",
|
||||
with_wordbounds="no",
|
||||
with_wordbounds="cross")
|
||||
fi
|
||||
fi
|
||||
case $with_wordbounds in
|
||||
yes)
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(GNU_WORDBOUNDS, 1, [Define this if the system supports GNU-style word boundaries in regexes.])
|
||||
;;
|
||||
no)
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
cross)
|
||||
AC_MSG_WARN([*** Can't check for GNU-style word boundary support when cross-compiling])
|
||||
;;
|
||||
esac
|
||||
|
||||
if test x$color_support = xyes; then
|
||||
# if test x$CURSES_LIB_NAME = xcurses; then
|
||||
AC_MSG_CHECKING([whether _XOPEN_SOURCE_EXTENDED is needed])
|
||||
@@ -742,8 +714,9 @@ AC_MSG_CHECKING([for HTML support in groff])
|
||||
groff -t -mandoc -Thtml </dev/null >/dev/null
|
||||
if test $? -ne 0 ; then
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_WARN([*** Will not generate HTML version of man pages ***
|
||||
*** Consider installing a newer version of groff with HTML support ***])
|
||||
AC_MSG_WARN([
|
||||
*** Will not generate HTML version of man pages. ***
|
||||
*** Consider installing a newer version of groff with HTML support. ***])
|
||||
groff_html_support=no
|
||||
else
|
||||
AC_MSG_RESULT([yes])
|
||||
@@ -751,25 +724,6 @@ else
|
||||
fi
|
||||
AM_CONDITIONAL(GROFF_HTML, test x$groff_html_support = xyes)
|
||||
|
||||
# Check whether this is a git repository.
|
||||
AC_MSG_CHECKING([whether building from git])
|
||||
if test -d .git ; then
|
||||
AC_MSG_RESULT([yes])
|
||||
from_git=yes
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
from_git=no
|
||||
fi
|
||||
AM_CONDITIONAL(BUILDING_FROM_GIT, test x$from_git = xyes)
|
||||
|
||||
if test x$from_git = xyes; then
|
||||
if test "$ac_cv_path_MSGFMT" = ":"; then
|
||||
AC_MSG_ERROR([
|
||||
*** The msgfmt program is missing. ***
|
||||
*** The gettext package needs to be installed when building from git. ***])
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
doc/Makefile
|
||||
|
||||
72
doc/faq.html
72
doc/faq.html
@@ -32,25 +32,19 @@
|
||||
<a href="#3.6">3.6. How can I make the executable smaller? This is too bloated!</a><br>
|
||||
<a href="#3.7">3.7. Tell me more about this multibuffer stuff!</a><br>
|
||||
<a href="#3.8">3.8. Tell me more about this verbatim input stuff!</a><br>
|
||||
<a href="#3.9a">3.9a. How do I make a .nanorc file that nano will read when I start it?</a><br>
|
||||
<a href="#3.9b">3.9b. How about in Win32?</a>
|
||||
<a href="#3.9">3.9. How do I make a .nanorc file that nano will read when I start it?</a><br>
|
||||
</p></blockquote>
|
||||
<h3><a href="#4">4. Running</a></h3>
|
||||
<blockquote><p>
|
||||
<a href="#4.1">4.1. How do I open a file with a name beginning with '+' from the command line?</a><br>
|
||||
<a href="#4.2">4.2. Ack! My Backspace/Delete/Enter/Meta/double bucky key doesn't seem to work! What can I do?</a><br>
|
||||
<a href="#4.3">4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</a><br>
|
||||
<a href="#4.4">4.4. Ack! When I hold down a Meta key combination for a while, the character of the held key gets inserted now and then. What gives?</a><br>
|
||||
<a href="#4.5">4.5. How do I type the F13-F16 keys listed in the help viewer? My keyboard only has F1-F12!</a><br>
|
||||
<a href="#4.6">4.6. nano crashes when I type <insert keystrokes here>!</a><br>
|
||||
<a href="#4.7">4.7. nano crashes when I resize my window. How can I fix that?</a><br>
|
||||
<a href="#4.8a">4.8a. With what keystroke can I paste text from the clipboard into nano?</a><br>
|
||||
<a href="#4.8b">4.8b. When I paste text into a document, each line gets indented further than the last. Why? And how can I stop this?</a><br>
|
||||
<a href="#4.8c">4.8c. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?<a><br>
|
||||
<a href="#4.9">4.9. I've compiled nano with color support, but I don't see any color when I run it!</a><br>
|
||||
<a href="#4.10">4.10. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
|
||||
<a href="#4.11">4.11. How do I select text for or paste text from the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?</a><br>
|
||||
<a href="#4.12">4.12. On startup I get a message that says "Detected a legacy nano history file". Now older nano versions can't find my search history!</a>
|
||||
<a href="#4.4">4.4. With what keystroke can I paste text from the clipboard into nano?</a><br>
|
||||
<a href="#4.5">4.5. How do I select text for or paste text from the clipboard when nano's mouse support is turned on?</a><br>
|
||||
<a href="#4.6">4.6. When I paste text into a document, each line gets indented further than the last. Why? And how can I stop this?</a><br>
|
||||
<a href="#4.7">4.7. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?<a><br>
|
||||
<a href="#4.8">4.8. I've compiled nano with color support, but I don't see any color when I run it!</a><br>
|
||||
<a href="#4.9">4.9. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
|
||||
</p></blockquote>
|
||||
<h3><a href="#5">5. Internationalization</a></h3>
|
||||
<blockquote><p>
|
||||
@@ -77,7 +71,7 @@
|
||||
|
||||
<h1><a name="1"></a>1. General</h1>
|
||||
<h3><a name="1.1"></a>1.1. What is GNU nano?</h3>
|
||||
<blockquote><p>GNU nano is designed to be a free replacement for the Pico text editor, part of the Pine email suite from <a href="http://www.washington.edu/pine/">The University of Washington</a>. It aims to "emulate Pico as closely as possible and then include extra functionality".</p></blockquote>
|
||||
<blockquote><p>GNU nano was designed to be a free replacement for the Pico text editor, part of the Pine email suite from <a href="http://www.washington.edu/pine/">The University of Washington</a>. It aimed to "emulate Pico as closely as is reasonable and then include extra functionality".</p></blockquote>
|
||||
<h3><a name="1.2"></a>1.2. What is the history behind nano?</h3>
|
||||
<blockquote><p>Funny you should ask!</p>
|
||||
<p><b>In the beginning...</b></p>
|
||||
@@ -91,7 +85,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>3.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>
|
||||
<blockquote><p>The current version of nano <i>should</i> be <b>4.0</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%">
|
||||
@@ -163,7 +157,6 @@
|
||||
<b>--disable-wordcomp</b> Disable the word-completion function
|
||||
<b>--disable-wrapping</b> Disable all hard-wrapping of text</pre>
|
||||
<p>There's also the <b>--enable-tiny</b> option which disables everything above, as well as some larger chunks of the program (like the marker code that you use with Control-^ to select text). Also, if you know you aren't going to be using other languages, you can use <b>--disable-nls</b> to disable internationalization and save a few K to a few dozen K depending on whether you have locale support on your system. And finally, there's always good old <b>strip</b> to strip all debugging code and code that exists in libraries on your system.</p>
|
||||
<p>With <b>--disable-wrapping-as-root</b> you can disable any hard-wrapping by default when the user is root, useful to prevent accidentally changing long lines in system configuration files.</p>
|
||||
</blockquote>
|
||||
<h3><a name="3.7"></a>3.7. Tell me more about this multibuffer stuff!</h3>
|
||||
<blockquote><p>To use multiple file buffers, you must not have configured nano with <b>--disable-multibuffer</b> nor with <b>--enable-tiny</b> (use <b>nano -V</b> to check the compilation options). Then when you want to insert a file into its own buffer instead of into the current file, just hit <b>Meta-F</b> after typing <b>^R</b>. If you always want files to be loaded into their own buffers, use the <b>-F</b> or <b>--multibuffer</b> flag when you invoke nano, or add <b>set multibuffer</b> to your .nanorc file.</p>
|
||||
@@ -171,12 +164,8 @@
|
||||
<h3><a name="3.8"></a>3.8. Tell me more about this verbatim input stuff!</h3>
|
||||
<blockquote><p>When you want to insert a literal character into the file you're editing, such as a control character that nano usually treats as a command, first press <b>Meta-V</b> (if you're not at a prompt, you'll get the message "Verbatim Input" on the status bar), then press the key(s) that generate the character you want.</p>
|
||||
<p>Alternatively, if Unicode support is enabled (see section <a href="#5.3">5.3</a>), you can press <b>Meta-V</b> and then type a six-digit hexadecimal code (from 000000 to 10FFFF, case-insensitive), and the character with the corresponding value will be inserted. The status bar will change to "Unicode Input: ......" when you do this.</p></blockquote>
|
||||
<h3><a name="3.9a"></a>3.9a. How do I make a .nanorc file that will be read when I start nano?</h3>
|
||||
<h3><a name="3.9"></a>3.9. How do I make a .nanorc file that will be read when I start nano?</h3>
|
||||
<blockquote><p>It's not hard at all! But, your nano must <b>not</b> have been compiled with <b>--disable-nanorc</b>. Then simply copy the <b>sample.nanorc</b> that came with the nano source or your nano package (most likely in /usr/doc/nano) to .nanorc in your home directory. If you didn't get one, the syntax of the file is simple. Flags are turned on and off by using the words <b>set</b> and <b>unset</b> plus the long option name for the feature. For example, "set nowrap" or "set smarthome".</p></blockquote>
|
||||
<h3><a name="3.9b"></a>3.9b. How about in Win32?</h3>
|
||||
<blockquote><p>If you're using the official nano .zip file and have extracted all the files, you should take the file nano.rc and place it somewhere on your Win32 system (for example, if you have write permission to do so, at the top of C:\). Then you must create an Environment variable called HOME which points to the directory where you put nano.rc. In Windows XP, you can get to Environment variables by right-clicking "My Computer" either on the desktop or in the Start Menu, and selecting Properties. This should bring up the System Properties panel. Then click the Advanced Tab, and there should be a button called Environment Variables. Click that to bring up the Environment Variables section. Now, under User Variables you should be able to click the New button, and make a new Variables Name called HOME, with the Variable Value of whatever path you copied nano.rc into (just the directory name; don't add nano.rc onto the end).</p>
|
||||
<p>We're still working on documentation for enabling syntax highlighting on Win32; please bear with us.</p>
|
||||
<p>Note that the nano.rc file must remain Unix-formatted in order for nano to understand it. In other words, you should probably use only nano to edit its config file. Other programs like Wordpad and Notepad will convert the file to DOS format when saving, and the latter does not even properly read Unix-formatted files to begin with.</p></blockquote>
|
||||
<hr width="100%">
|
||||
|
||||
<h1><a name="4"></a>4. Running</h1>
|
||||
@@ -192,24 +181,18 @@
|
||||
<p>Bourne shell users (bash and sh): <b>export TERM=vt100</b><br>
|
||||
C Shell users (tcsh and csh): <b>setenv TERM vt100</b></p></blockquote>
|
||||
<h3><a name="4.3"></a>4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</h3>
|
||||
<blockquote><p>You can use the <b>-K</b> or <b>--rebindkeypad</b> option on the command line, or add the line <b>set rebindkeypad</b> to your .nanorc. However, nano's mouse support won't work properly if you do any of these things.</p></blockquote>
|
||||
<h3><a name="4.4"></a>4.4. Ack! When I hold down a Meta key combination for a while, the character of the held key gets inserted now and then. What gives?</h3>
|
||||
<blockquote><p>This was a bug in how nano handled consecutive escape sequences. It should be fixed since version 2.6.0.</p></blockquote>
|
||||
<h3><a name="4.5"></a>4.5. How do I type the F13-F16 keys listed in the help viewer? My keyboard only has F1-F12!</h3>
|
||||
<blockquote><p>It depends on the terminal type you're using. On some terminals, such as the FreeBSD console, xterm, konsole, and gnome-terminal, Shift-F1 to Shift-F4 will generate F13 to F16. On other terminals, such as the Linux console, rxvt, and Eterm, Shift-F3 to Shift-F6 will generate F13 to F16.</p></blockquote>
|
||||
<h3><a name="4.6"></a>4.6. nano crashes when I type <insert keystrokes here>!</h3>
|
||||
<blockquote><p>If you aren't trying some bizarre keystroke combination with some bizarre $TERM entry, chances are you have found a bug. You are welcome to submit it to the <a href="mailto:nano-devel@gnu.org">nano-devel</a> list or in the <a href="https://savannah.gnu.org/bugs/?group=nano">bug tracker</a> on Savannah.</p></blockquote>
|
||||
<h3><a name="4.7"></a>4.7. nano crashes when I resize my window. How can I fix that?</h3>
|
||||
<blockquote><p>Older versions of nano had this problem. Please upgrade to version 2.7.0 or newer.</p></blockquote>
|
||||
<h3><a name="4.8a"></a>4.8a. With what keystroke can I paste text from the clipboard into nano?</h3>
|
||||
<blockquote><p>You can use the <b>-K</b> or <b>--rawsequences</b> option on the command line, or add the line <b>set rawsequences</b> to your .nanorc. However, nano's mouse support will be disabled if you do any of these things.</p></blockquote>
|
||||
<h3><a name="4.4"></a>4.4. With what keystroke can I paste text from the clipboard into nano?</h3>
|
||||
<blockquote><p>In most desktop environments <b>Shift+Insert</b> will paste the contents of the clipboard.</p></blockquote>
|
||||
<h3><a name="4.8b"></a>4.8b. When I paste text into a document, each line gets indented further than the last. Why? And how can I stop this?</h3>
|
||||
<h3><a name="4.5"></a>4.5. How do I select text for or paste text from the clipboard when nano's mouse support is turned on?</h3>
|
||||
<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></blockquote>
|
||||
<h3><a name="4.8c"></a>4.8c. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?</h3>
|
||||
<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></blockquote>
|
||||
<h3><a name="4.9"></a>4.9. 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.9a">3.9a</a>.</p></blockquote>
|
||||
<h3><a name="4.10"></a>4.10. How do I make nano my default editor (in Pine, mutt, etc.)?</h3>
|
||||
<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>
|
||||
<blockquote><p>You need to make nano your $EDITOR. If you want this to be saved, you should put a line like this in your <b>.bashrc</b> if you use bash (or <b>.zshrc</b> if you believe in zsh):</p>
|
||||
<p><b>export EDITOR=/usr/local/bin/nano</b></p>
|
||||
<p>or, if you use tcsh, put this in your <b>.cshrc</b> file:</p>
|
||||
@@ -222,12 +205,6 @@
|
||||
<p>If you're a mutt user, you should see an effect immediately the next time you log in. No further configuration is needed. However, if you want to let people know you use nano to compose your email messages, you can put a line like this in your <b>.muttrc</b>:</p>
|
||||
<p><b>my_hdr X-Composer: nano x.y.z</b></p>
|
||||
<p>Again, replace x.y.z with the version of nano you use.</p></blockquote>
|
||||
<h3><a name="4.11"></a>4.11. How do I select text for or paste text from the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?</h3>
|
||||
<blockquote><p>Try holding down the Shift key and selecting or pasting the text as you normally would.</p></blockquote>
|
||||
<h3><a name="4.12"></a>4.12. On startup I get a message that says "Detected a legacy nano history file". Now older nano versions can't find my search history!</h3>
|
||||
<blockquote><p>In nano 2.3.0, cursor-position history was introduced, and both history files now reside in a .nano subdirectory in your home directory. A newer nano will move an existing search-history file to this new location so it can continue to be used. This means that if you then try and use an earlier version of nano, it will be unable to see your current search history. To fix this, run the following command:</p>
|
||||
<p><b>ln -sf ~/.nano/search_history ~/.nano_history</b></p>
|
||||
<p>The "migration service" (moving the search-history file to its new location) has been deleted from nano in late 2017, since version 2.9.0. The search-history and position-history files will now be looked for first in ~/.nano/ and, when not found there, then in ~/.local/share/nano/.</p></blockquote>
|
||||
<hr width="100%">
|
||||
|
||||
<h1><a name="5"></a>5. Internationalization</h1>
|
||||
@@ -243,10 +220,9 @@
|
||||
|
||||
<h1><a name="6"></a>6. Advocacy and Licensing</h1>
|
||||
<h3><a name="6.1"></a>6.1. Why should I use nano instead of Pico?</h3>
|
||||
<blockquote><p>There are many reasons to use nano instead of Pico. A more complete list can be found at the <a href="https://nano-editor.org/">nano homepage</a>.</p></blockquote>
|
||||
<blockquote><p>If you want features like undo/redo, syntax highlighting, line numbers, soft-wrapping, opening multiple files at once, an interface localized to your language, or search and replace with support for regular expressions, then you want nano.</p></blockquote>
|
||||
<h3><a name="6.2"></a>6.2. Why should I use Pico instead of nano?</h3>
|
||||
<blockquote><p>Again, check out the <a href="https://nano-editor.org/">nano homepage</a> for a good summary of reasons. It really is a matter of personal preference as to which editor you should use. If you're the type of person who likes using the original version of a program, then Pico is the editor for you. If you don't mind sacrificing mailer integration with Pine, and are looking for a few more features, as well as a 'better' license in terms of adding your own changes, nano is the way to go.</p>
|
||||
<p>Note that the last of these no longer applies to the new version of Pine, <a href="http://www.washington.edu/alpine/">Alpine</a>, which is under the Apache License, version 2.0.</p></blockquote>
|
||||
<blockquote><p>If you use your editor only to write emails or other texts and have no need for the above-mentioned features, then Pico will do fine for you.</p></blockquote>
|
||||
<h3><a name="6.3"></a>6.3. What is so bad about the older Pine license?</h3>
|
||||
<blockquote><p>The U of W license for older versions of Pine and Pico is not considered truly Free Software according to both the Free Software Foundation and the <a href="https://www.debian.org/social_contract#guidelines">Debian Free Software Guidelines</a>. The main problem regards the limitations on distributing derived works: according to UW, you can distribute their software, and you can modify it, but you can not do both, i.e. distribute modified binaries.</p></blockquote>
|
||||
<h3><a name="6.4"></a>6.4. Okay, well, what mail program should I use then?</h3>
|
||||
@@ -257,9 +233,9 @@
|
||||
<h1><a name="7"></a>7. Miscellaneous</h1>
|
||||
<h3><a name="7.1"></a>7.1. Where can I ask questions or send suggestions?</h3>
|
||||
<blockquote><p>There are three mailing lists for nano hosted at <a href="https://savannah.gnu.org/">Savannah</a>: info-nano, help-nano and nano-devel. info-nano is a very low traffic list where new versions of nano are announced (surprise!). help-nano is for getting help with the editor without needing to hear all of the development issues surrounding it. nano-devel is a normally low, sometimes high traffic list for discussing the present and future development of nano. Here are links to where you can sign up for a given list:</p>
|
||||
<p>info-nano - <a href="https://mail.gnu.org/mailman/listinfo/info-nano/">https://mail.gnu.org/mailman/listinfo/info-nano/</a><br>
|
||||
help-nano - <a href="https://mail.gnu.org/mailman/listinfo/help-nano/">https://mail.gnu.org/mailman/listinfo/help-nano/</a><br>
|
||||
nano-devel - <a href="https://mail.gnu.org/mailman/listinfo/nano-devel/">https://mail.gnu.org/mailman/listinfo/nano-devel/</a></p></blockquote>
|
||||
<p>info-nano - <a href="https://lists.gnu.org/mailman/listinfo/info-nano/">https://lists.gnu.org/mailman/listinfo/info-nano/</a><br>
|
||||
help-nano - <a href="https://lists.gnu.org/mailman/listinfo/help-nano/">https://lists.gnu.org/mailman/listinfo/help-nano/</a><br>
|
||||
nano-devel - <a href="https://lists.gnu.org/mailman/listinfo/nano-devel/">https://lists.gnu.org/mailman/listinfo/nano-devel/</a></p></blockquote>
|
||||
<h3><a name="7.2"></a>7.3. How do I submit a bug report or patch?</h3>
|
||||
<blockquote>
|
||||
<p>The best way to submit bugs is through the <a href="https://savannah.gnu.org/bugs/?group=nano">Savannah bug tracker</a>, as you can check whether the bug you are reporting has already been submitted, and it makes it easier for the maintainers to keep track of them.
|
||||
|
||||
99
doc/nano.1
99
doc/nano.1
@@ -1,4 +1,4 @@
|
||||
.\" Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc.
|
||||
.\" Copyright (C) 1999-2011, 2013-2019 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,15 +16,25 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANO 1 "version 3.2" "November 2018"
|
||||
.TH NANO 1 "version 4.0" "March 2019"
|
||||
|
||||
.SH NAME
|
||||
nano \- Nano's ANOther editor, an enhanced free Pico clone
|
||||
nano \- Nano's ANOther editor, inspired by Pico
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B nano
|
||||
.RI [ options "] [[+" line [, column "]]\ " file "]..."
|
||||
|
||||
.SH NOTE
|
||||
Starting with version 4.0, \fBnano\fR no longer hard-wraps an overlong
|
||||
line by default, and no longer automatically adds a newline at the end
|
||||
of the text if one is missing. Furthermore, it uses smooth scrolling
|
||||
by default and makes use of the line below the title bar.
|
||||
.sp
|
||||
If you want the old, Pico behavior back, you can use \fB\-\-breaklonglines\fR,
|
||||
\fB\-\-finalnewline\fR, \fB\-\-jumpyscrolling\fR, and \fB\-\-emptyline\fR
|
||||
(or \fB\-bfje\fR for short).
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fBnano\fP is a small and friendly editor. It copies the look and feel
|
||||
of Pico, but is free software, and implements several features that Pico
|
||||
@@ -101,13 +111,20 @@ executed commands, so they can be easily reused in later sessions.
|
||||
.BR \-I ", " \-\-ignorercfiles
|
||||
Don't look at the system's \fInanorc\fR nor at the user's \fInanorc\fR.
|
||||
.TP
|
||||
.BR \-K ", " \-\-rebindkeypad
|
||||
Interpret the numeric keypad keys so that they all work properly. You
|
||||
should only need to use this option if they don't, as mouse support
|
||||
won't work properly with this option enabled.
|
||||
.BR \-J\ \fInumber ", " \-\-guidestripe= \fInumber
|
||||
Draw a vertical stripe at the given column, to help judge the width of the
|
||||
text. (The color of the stripe can be changed with \fBset stripecolor\fR
|
||||
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.
|
||||
.TP
|
||||
.BR \-L ", " \-\-nonewlines
|
||||
Don't automatically add a newline when a file does not end with one.
|
||||
(This is the default.)
|
||||
.TP
|
||||
.BR \-M ", " \-\-trimblanks
|
||||
Snip trailing whitespace from the wrapped line when automatic
|
||||
@@ -117,7 +134,9 @@ hard-wrapping occurs or when text is justified.
|
||||
Disable automatic conversion of files from DOS/Mac format.
|
||||
.TP
|
||||
.BR \-O ", " \-\-morespace
|
||||
Use the blank line below the title bar as extra editing space.
|
||||
Obsolete and ignored option, since the line below the title bar is included
|
||||
into the editing space by default. If you prefer to keep this line blank,
|
||||
use \fB\-e\fR or \fB\-\-emptyline\fR.
|
||||
.TP
|
||||
.BR \-P ", " \-\-positionlog
|
||||
For the 200 most recent files, log the last position of the cursor,
|
||||
@@ -125,9 +144,10 @@ and place it at that position again upon reopening such a file.
|
||||
.TP
|
||||
.BR "\-Q ""\fIregex\fB""" ", " "\-\-quotestr=""" \fIregex """
|
||||
Set the regular expression for matching the quoting part of a line.
|
||||
This is used when justifying.
|
||||
The default value is \fB"^([\ \\t]*([#:>|}]|//))+"\fP.
|
||||
Note that \fB\\t\fP stands for an actual Tab.
|
||||
The default value is \fB"^([\ \\t]*([!#%:;>|}]|//|\-\-))+"\fP.
|
||||
(Note that \fB\\t\fP stands for an actual Tab.)
|
||||
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
|
||||
.BR \-R ", " \-\-restricted
|
||||
Restricted mode: don't read or write to any file not specified on the
|
||||
@@ -139,8 +159,9 @@ Restricted mode can also be activated by invoking \fBnano\fP
|
||||
with any name beginning with 'r' (e.g. "rnano").
|
||||
.TP
|
||||
.BR \-S ", " \-\-smooth
|
||||
Use smooth scrolling: text will scroll line-by-line, instead of the
|
||||
usual chunk-by-chunk behavior.
|
||||
Obsolete and ignored option, since smooth scrolling has become the default.
|
||||
If you prefer the chunk-by-chunk scrolling behavior,
|
||||
use \fB\-j\fR or \fB\-\-jumpyscrolling\fR.
|
||||
.TP
|
||||
.BR \-T\ \fInumber ", " \-\-tabsize= \fInumber
|
||||
Set the size (width) of a tab to \fInumber\fP columns. The value of
|
||||
@@ -175,14 +196,27 @@ Let an unmodified Backspace or Delete erase the marked region
|
||||
When doing soft line wrapping, wrap lines at whitespace
|
||||
instead of always at the edge of the screen.
|
||||
.TP
|
||||
.BR \-b ", " \-\-breaklonglines
|
||||
Automatically hard-wrap the current line when it becomes overlong.
|
||||
(This option is the opposite of \fB\-w\fR (\fB\-\-nowrap\fR) --
|
||||
the last one given takes effect.)
|
||||
.TP
|
||||
.BR \-c ", " \-\-constantshow
|
||||
Constantly show the cursor position on the status bar.
|
||||
Note that this overrides option \fB\-U\fR (\fB\-\-quickblank\fR).
|
||||
.TP
|
||||
.BR \-d ", " \-\-rebinddelete
|
||||
Interpret the Delete key differently so that both Backspace and Delete
|
||||
work properly. You should only need to use this option if Backspace
|
||||
acts like Delete on your system.
|
||||
Interpret the Delete and Backspace keys differently so that both Backspace
|
||||
and Delete work properly. You should only use this option when on your
|
||||
system either Backspace acts like Delete or Delete acts like Backspace.
|
||||
.TP
|
||||
.BR \-e ", " \-\-emptyline
|
||||
Do not use the line below the title bar, leaving it entirely blank.
|
||||
.TP
|
||||
.BR \-f ", " \-\-finalnewline
|
||||
If the buffer is not empty, ensure that it ends with a newline character.
|
||||
(This option is the opposite of \fB\-L\fR (\fB\-\-nonewlines\fR) --
|
||||
the last one given takes effect.)
|
||||
.TP
|
||||
.BR \-g ", " \-\-showcursor
|
||||
Make the cursor visible in the file browser (putting it on the
|
||||
@@ -197,6 +231,9 @@ Automatically indent a newly created line to the same number of tabs
|
||||
and/or spaces as the previous line (or as the next line if the previous
|
||||
line is the beginning of a paragraph).
|
||||
.TP
|
||||
.BR \-j ", " \-\-jumpyscrolling
|
||||
Scroll the buffer contents per half-screen instead of per line.
|
||||
.TP
|
||||
.BR \-k ", " \-\-cutfromcursor
|
||||
Make the 'Cut Text' command (normally \fB^K\fR) cut from the current cursor
|
||||
position to the end of the line, instead of cutting the entire line.
|
||||
@@ -226,15 +263,12 @@ similar to a chroot.
|
||||
Preserve the XON and XOFF sequences (^Q and ^S) so they will be caught
|
||||
by the terminal.
|
||||
.TP
|
||||
.BR \-q ", " \-\-quiet
|
||||
Obsolete option. Recognized but ignored.
|
||||
.TP
|
||||
.BR \-r\ \fInumber ", " \-\-fill= \fInumber
|
||||
Hard-wrap lines at column \fInumber\fP. If this value is 0 or less, wrapping
|
||||
will occur at the width of the screen less \fInumber\fP columns, allowing
|
||||
the wrap point to vary along with the width of the screen if the screen
|
||||
is resized. The default value is \-8. This option conflicts with
|
||||
\fB\-w\fR (\fB\-\-nowrap\fR) -- the last one given takes effect.
|
||||
Set the target width for justifying and automatic hard-wrapping at this
|
||||
\fInumber\fR of columns. If the value is 0 or less, wrapping will occur
|
||||
at the width of the screen minus \fInumber\fR columns, allowing the wrap
|
||||
point to vary along with the width of the screen if the screen is resized.
|
||||
The default value is \-8.
|
||||
.TP
|
||||
.BR \-s\ \fIprogram ", " \-\-speller= \fIprogram
|
||||
Use this alternative spell checker command.
|
||||
@@ -250,11 +284,11 @@ default behavior of saving a file in the format that it had.
|
||||
.BR \-v ", " \-\-view
|
||||
Just view the file and disallow editing: read-only mode.
|
||||
This mode allows the user to open also other files for viewing,
|
||||
unless \fB--restricted\fR is given too.
|
||||
unless \fB\-\-restricted\fR is given too.
|
||||
.TP
|
||||
.BR \-w ", " \-\-nowrap
|
||||
Disable the hard-wrapping of long lines. This option conflicts with
|
||||
\fB\-r\fR (\fB\-\-fill\fR) -- the last one given takes effect.
|
||||
Do not automatically hard-wrap the current line when it becomes overlong.
|
||||
(This is the default.)
|
||||
.TP
|
||||
.BR \-x ", " \-\-nohelp
|
||||
Don't show the two help lines at the bottom of the screen.
|
||||
@@ -272,9 +306,6 @@ continuing it over multiple screen lines. Since
|
||||
\&'$' normally refers to a variable in the Unix shell, you should specify
|
||||
this option last when using other options (e.g.\& 'nano \-wS$') or pass it
|
||||
separately (e.g.\& 'nano \-wS \-$').
|
||||
.TP
|
||||
.BR \-b ", " \-e ", " \-f ", " \-j
|
||||
Ignored, for compatibility with Pico.
|
||||
|
||||
.SH TOGGLES
|
||||
Several of the above options can be switched on and off also while
|
||||
@@ -308,12 +339,6 @@ it unique. In multibuffer mode, \fBnano\fP will write all the open
|
||||
buffers to their respective emergency files.
|
||||
|
||||
.SH BUGS
|
||||
Justifications (\fB^J\fR)
|
||||
are not yet covered by the general undo system. So after a justification
|
||||
that is not immediately undone, earlier edits
|
||||
cannot be undone any more. The workaround is, of course, to exit without
|
||||
saving.
|
||||
.sp
|
||||
The recording and playback of keyboard macros works correctly only on a
|
||||
terminal emulator, not on a Linux console (VT), because the latter does
|
||||
not by default distinguish modified from unmodified arrow keys.
|
||||
@@ -327,7 +352,7 @@ If you are able to reproduce the crash and you want to get a backtrace, define
|
||||
the environment variable \fBNANO_NOCATCH\fR.
|
||||
|
||||
.SH HOMEPAGE
|
||||
\fIhttps://nano-editor.org/\fR
|
||||
\fIhttps://nano\-editor.org/\fR
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR nanorc (5)
|
||||
|
||||
264
doc/nano.texi
264
doc/nano.texi
@@ -8,8 +8,8 @@
|
||||
|
||||
@smallbook
|
||||
@set EDITION 0.5
|
||||
@set VERSION 3.2
|
||||
@set UPDATED November 2018
|
||||
@set VERSION 4.0
|
||||
@set UPDATED March 2019
|
||||
|
||||
@dircategory Editors
|
||||
@direntry
|
||||
@@ -23,7 +23,7 @@
|
||||
@titlepage
|
||||
@title GNU @command{nano}
|
||||
@subtitle a small and friendly text editor
|
||||
@subtitle version 3.2
|
||||
@subtitle version 4.0
|
||||
|
||||
@author Chris Allegretta
|
||||
@page
|
||||
@@ -33,7 +33,7 @@ This manual documents the GNU @command{nano} editor.
|
||||
This manual is part of the GNU @command{nano} distribution.@*
|
||||
|
||||
@sp 4
|
||||
Copyright @copyright{} 1999-2009, 2014-2017 Free Software Foundation, Inc.
|
||||
Copyright @copyright{} 1999-2009, 2014-2019 Free Software Foundation, Inc.
|
||||
|
||||
@sp 1
|
||||
This document is dual-licensed. You may distribute and/or modify it
|
||||
@@ -63,7 +63,7 @@ e-mail: @email{chrisa@@asty.org}@*
|
||||
@node Top
|
||||
@top
|
||||
|
||||
This manual documents the GNU @command{nano} editor, version 3.2.
|
||||
This manual documents the GNU @command{nano} editor, version 4.0.
|
||||
|
||||
@menu
|
||||
* Introduction::
|
||||
@@ -84,18 +84,28 @@ This manual documents the GNU @command{nano} editor, version 3.2.
|
||||
@node Introduction
|
||||
@chapter Introduction
|
||||
|
||||
GNU @command{nano} is a small and friendly text editor. Besides basic text
|
||||
editing, @command{nano} offers many extra features, such as an interactive
|
||||
search-and-replace, undo/redo, syntax coloring, smooth scrolling,
|
||||
auto-indentation, go-to-line-and-column-number, feature toggles,
|
||||
file locking, backup files, and internationalization support.
|
||||
GNU @command{nano} is a small and friendly text editor. Besides
|
||||
basic text editing, @command{nano} offers features like undo/redo,
|
||||
syntax coloring, interactive search-and-replace, auto-indentation,
|
||||
line numbers, word completion, file locking, backup files, and
|
||||
internationalization support.
|
||||
|
||||
The original goal for @command{nano} was to be a complete bug-for-bug
|
||||
emulation of Pico. But currently the goal is to be as compatible
|
||||
as possible while offering a superset of Pico's functionality.
|
||||
as is reasonable while offering a superset of Pico's functionality.
|
||||
@xref{Pico Compatibility} for more details on how @command{nano} and
|
||||
Pico differ.
|
||||
|
||||
Starting with version 4.0, @command{nano} no longer hard-wraps an overlong
|
||||
line by default, and no longer automatically adds a newline at the end
|
||||
of the text if one is missing. Furthermore, it uses smooth scrolling
|
||||
by default and makes use of the line below the title bar.
|
||||
|
||||
If you want the old, Pico behavior back, you can use the
|
||||
following options: @option{--breaklonglines}, @option{--finalnewline},
|
||||
@option{--jumpyscrolling}, and @option{--emptyline}
|
||||
(or @option{-bfje} for short).
|
||||
|
||||
Please report bugs via @url{https://savannah.gnu.org/bugs/?group=nano}.
|
||||
|
||||
|
||||
@@ -190,15 +200,23 @@ executed commands, so they can be easily reused in later sessions.
|
||||
@itemx --ignorercfiles
|
||||
Don't look at the system's nanorc file nor at the user's nanorc.
|
||||
|
||||
@item -J
|
||||
@itemx --guidestripe
|
||||
Draw a vertical stripe at the given column, to help judge the width of the
|
||||
text. (The color of the stripe can be changed with @code{set stripecolor}
|
||||
in your nanorc file.)
|
||||
|
||||
@item -K
|
||||
@itemx --rebindkeypad
|
||||
Interpret the numeric keypad keys so that they all work properly. You
|
||||
should only need to use this option if they don't, as mouse support
|
||||
won't work properly with this option enabled.
|
||||
@itemx --rawsequences
|
||||
Interpret escape sequences directly (instead of asking @code{ncurses} to
|
||||
translate them). If you need this option to get your keyboard to work
|
||||
properly, please report a bug. Using this option disables @command{nano}'s
|
||||
mouse support.
|
||||
|
||||
@item -L
|
||||
@itemx --nonewlines
|
||||
Don't automatically add a newline when a file does not end with one.
|
||||
(This is the default.)
|
||||
|
||||
@item -M
|
||||
@itemx --trimblanks
|
||||
@@ -211,7 +229,9 @@ Disable automatic conversion of files from DOS/Mac format.
|
||||
|
||||
@item -O
|
||||
@itemx --morespace
|
||||
Use the blank line below the title bar as extra editing space.
|
||||
Obsolete and ignored option, since the line below the title bar is included
|
||||
into the editing space by default. If you prefer to keep this line blank,
|
||||
use @option{-e} or @option{--emptyline}.
|
||||
|
||||
@item -P
|
||||
@itemx --positionlog
|
||||
@@ -220,9 +240,11 @@ and place it at that position again upon reopening such a file.
|
||||
|
||||
@item -Q "@var{regex}"
|
||||
@itemx --quotestr="@var{regex}"
|
||||
Set the regular expression for matching the quoting part of a line, used
|
||||
when justifying. The default value is @t{"^([@w{ }\t]*([#:>|@}]|//))+"}.
|
||||
Note that @code{\t} stands for a literal Tab character.
|
||||
Set the regular expression for matching the quoting part of a line.
|
||||
The default value is @t{"^([@w{ }\t]*([!#%:;>|@}]|//|--))+"}.
|
||||
(Note that @code{\t} stands for a literal Tab character.)
|
||||
This makes it possible to rejustify blocks of quoted text when composing
|
||||
email, and to rewrap blocks of line comments when writing source code.
|
||||
|
||||
@item -R
|
||||
@itemx --restricted
|
||||
@@ -236,8 +258,9 @@ any name beginning with @code{r} (e.g.@: @command{rnano}).
|
||||
|
||||
@item -S
|
||||
@itemx --smooth
|
||||
Enable smooth scrolling. Text will scroll line-by-line, instead of the
|
||||
usual chunk-by-chunk behavior.
|
||||
Obsolete and ignored option, since smooth scrolling has become the default.
|
||||
If you prefer the chunk-by-chunk scrolling behavior,
|
||||
use @option{-j} or @option{--jumpyscrolling}.
|
||||
|
||||
@item -T @var{number}
|
||||
@itemx --tabsize=@var{number}
|
||||
@@ -280,6 +303,12 @@ Let an unmodified @key{Backspace} or @key{Delete} erase the marked region
|
||||
When doing soft line wrapping, wrap lines at whitespace
|
||||
instead of always at the edge of the screen.
|
||||
|
||||
@item -b
|
||||
@itemx --breaklonglines
|
||||
Automatically hard-wrap the current line when it becomes overlong.
|
||||
(This option is the opposite of @option{-w} (@option{--nowrap}) ---
|
||||
the last one given takes effect.)
|
||||
|
||||
@item -c
|
||||
@itemx --constantshow
|
||||
Constantly display the cursor position (line number, column number,
|
||||
@@ -288,9 +317,19 @@ Note that this overrides option @option{-U} (@option{--quickblank}).
|
||||
|
||||
@item -d
|
||||
@itemx --rebinddelete
|
||||
Interpret the Delete key differently so that both Backspace and Delete
|
||||
work properly. You should only need to use this option if Backspace
|
||||
acts like Delete on your system.
|
||||
Interpret the Delete and Backspace keys differently so that both Backspace
|
||||
and Delete work properly. You should only use this option when on your
|
||||
system either Backspace acts like Delete or Delete acts like Backspace.
|
||||
|
||||
@item -e
|
||||
@itemx --emptyline
|
||||
Do not use the line below the title bar, leaving it entirely blank.
|
||||
|
||||
@item -f
|
||||
@itemx --finalnewline
|
||||
If the buffer is not empty, ensure that it ends with a newline character.
|
||||
(This option is the opposite of @option{-L} (@option{--nonewlines}) ---
|
||||
the last one given takes effect.)
|
||||
|
||||
@item -g
|
||||
@itemx --showcursor
|
||||
@@ -308,6 +347,10 @@ Automatically indent a newly created line to the same number of tabs
|
||||
and/or spaces as the previous line (or as the next line if the previous
|
||||
line is the beginning of a paragraph).
|
||||
|
||||
@item -j
|
||||
@itemx --jumpyscrolling
|
||||
Scroll the buffer contents per half-screen instead of per line.
|
||||
|
||||
@item -k
|
||||
@itemx --cutfromcursor
|
||||
Make the 'Cut Text' command (normally @kbd{^K}) cut from the current cursor
|
||||
@@ -343,18 +386,13 @@ similar to a chroot.
|
||||
Preserve the @kbd{^Q} (XON) and @kbd{^S} (XOFF) sequences so data being
|
||||
sent to the editor can be stopped and started.
|
||||
|
||||
@item -q
|
||||
@itemx --quiet
|
||||
Obsolete option. Recognized but ignored.
|
||||
|
||||
@item -r @var{number}
|
||||
@itemx --fill=@var{number}
|
||||
Hard-wrap lines at column @var{number} (by inserting a newline character).
|
||||
If the given value is 0 or less, wrapping will occur at the width of
|
||||
the screen minus the given amount, allowing the wrapping width to
|
||||
vary along with the width of the screen if and when it is resized.
|
||||
The default value is @t{-8}. This option conflicts with @option{-w}
|
||||
(@option{--nowrap}); the last one given takes effect.
|
||||
Set the target width for justifying and automatic hard-wrapping at this
|
||||
@var{number} of columns. If the value is 0 or less, wrapping will occur
|
||||
at the width of the screen minus @var{number} columns, allowing the wrap
|
||||
point to vary along with the width of the screen if the screen is resized.
|
||||
The default value is @t{-8}.
|
||||
|
||||
@anchor{@option{--speller}}
|
||||
@item -s @var{program}
|
||||
@@ -387,8 +425,8 @@ file permissions to implement a read-only file.)
|
||||
|
||||
@item -w
|
||||
@itemx --nowrap
|
||||
Don't hard-wrap long lines at any length. This option conflicts with
|
||||
@option{-r} (@option{--fill}); the last one given takes effect.
|
||||
Do not automatically hard-wrap the current line when it becomes overlong.
|
||||
(This is the default.)
|
||||
|
||||
@anchor{Expert Mode}
|
||||
@item -x
|
||||
@@ -418,12 +456,6 @@ continuing it over multiple screen lines. Since
|
||||
this option last when using other options (e.g.@: @code{nano -wS$}) or pass it
|
||||
separately (e.g.@: @code{nano -wS -$}).
|
||||
|
||||
@item -b
|
||||
@itemx -e
|
||||
@itemx -f
|
||||
@itemx -j
|
||||
Ignored, for compatibility with Pico.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@@ -575,12 +607,6 @@ is running.
|
||||
@node Limitations
|
||||
@section Limitations
|
||||
|
||||
Justifications (@kbd{^J})
|
||||
are not yet covered by the general undo system. So after a justification
|
||||
that is not immediately undone, earlier edits
|
||||
cannot be undone any more. The workaround is, of course, to exit without
|
||||
saving.
|
||||
|
||||
The recording and playback of keyboard macros works correctly only on a
|
||||
terminal emulator, not on a Linux console (VT), because the latter does
|
||||
not by default distinguish modified from unmodified arrow keys.
|
||||
@@ -730,6 +756,9 @@ punctuation (see @code{set punct}), optionally followed by the specified
|
||||
closing brackets, can end sentences. The default value is
|
||||
@t{""')>]@}"}.
|
||||
|
||||
@item set breaklonglines
|
||||
Automatically hard-wrap the current line when it becomes overlong.
|
||||
|
||||
@item set casesensitive
|
||||
Do case-sensitive searches by default.
|
||||
|
||||
@@ -739,17 +768,23 @@ Note that this overrides @option{quickblank}.
|
||||
|
||||
@item set cutfromcursor
|
||||
Use cut-from-cursor-to-end-of-line by default, instead of cutting the whole line.
|
||||
(The old form of this option, @code{set cut}, is deprecated.)
|
||||
|
||||
@item set emptyline
|
||||
Do not use the line below the title bar, leaving it entirely blank.
|
||||
|
||||
@item set errorcolor @var{fgcolor},@var{bgcolor}
|
||||
Use this color combination for the status bar when an error message is displayed.
|
||||
@xref{@code{set functioncolor}} for valid color names.
|
||||
|
||||
@item set finalnewline
|
||||
If the buffer is not empty, ensure that it ends with a newline character.
|
||||
|
||||
@item set fill @var{number}
|
||||
Hard-wrap lines at column number @var{number}. If @var{number} is 0 or less,
|
||||
the maximum line length will be the screen width less @var{number} columns.
|
||||
The default value is @t{-8}. This option conflicts with
|
||||
@option{nowrap}; the last one given takes effect.
|
||||
Set the target width for justifying and automatic hard-wrapping at this
|
||||
@var{number} of columns. If the value is 0 or less, wrapping will occur
|
||||
at the width of the screen minus @var{number} columns, allowing the wrap
|
||||
point to vary along with the width of the screen if the screen is resized.
|
||||
The default value is @t{-8}.
|
||||
|
||||
@anchor{@code{set functioncolor}}
|
||||
@item set functioncolor @var{fgcolor},@var{bgcolor}
|
||||
@@ -766,6 +801,9 @@ And either @var{fgcolor} or ,@var{bgcolor} may be left out.
|
||||
Save the last hundred search strings and replacement strings and
|
||||
executed commands, so they can be easily reused in later sessions.
|
||||
|
||||
@item set jumpyscrolling
|
||||
Scroll the buffer contents per half-screen instead of per line.
|
||||
|
||||
@item set keycolor @var{fgcolor},@var{bgcolor}
|
||||
Use this color combination for the shortcut key combos
|
||||
in the two help lines at the bottom of the screen.
|
||||
@@ -777,6 +815,10 @@ Display line numbers to the left of the text area.
|
||||
@item set locking
|
||||
Enable vim-style lock-files for when editing files.
|
||||
|
||||
@item set guidestripe @var{number}
|
||||
Draw a vertical stripe at the given column, to help judge the width of the
|
||||
text. (The color of the stripe can be changed with @code{set stripecolor}.)
|
||||
|
||||
@item set matchbrackets "@var{string}"
|
||||
Set the opening and closing brackets that can be found by bracket
|
||||
searches. This may not include blank characters. The opening set must
|
||||
@@ -784,7 +826,8 @@ come before the closing set, and the two sets must be in the same order.
|
||||
The default value is @t{"(<[@{)>]@}"}.
|
||||
|
||||
@item set morespace
|
||||
Use the blank line below the title bar as extra editing space.
|
||||
Deprecated option since it has become the default setting.
|
||||
When needed, use @code{unset emptyline} instead.
|
||||
|
||||
@item set mouse
|
||||
Enable mouse support, so that mouse clicks can be used to place the
|
||||
@@ -800,15 +843,16 @@ Don't convert files from DOS/Mac format.
|
||||
Don't display the help lists at the bottom of the screen.
|
||||
|
||||
@item set nonewlines
|
||||
When a file does not end with a newline, don't automatically add one.
|
||||
Deprecated option since it has become the default setting.
|
||||
When needed, use @code{unset finalnewline} instead.
|
||||
|
||||
@item set nopauses
|
||||
Don't pause between warnings at startup. This means that only
|
||||
the last one will be visible (when there are multiple ones).
|
||||
|
||||
@item set nowrap
|
||||
Don't hard-wrap text at all. This option conflicts with
|
||||
@option{fill}; the last one given takes effect.
|
||||
Deprecated option since it has become the default setting.
|
||||
When needed, use @code{unset breaklonglines} instead.
|
||||
|
||||
@item set numbercolor @var{fgcolor},@var{bgcolor}
|
||||
Use this color combination for line numbers.
|
||||
@@ -838,24 +882,23 @@ The default value is @t{"!.?"}.
|
||||
Do quick status-bar blanking: status-bar messages will disappear after 1
|
||||
keystroke instead of 25. Note that @option{constantshow} overrides this.
|
||||
|
||||
@item set quiet
|
||||
Obsolete option. Recognized but ignored.
|
||||
|
||||
@item set quotestr "@var{regex}"
|
||||
The email-quote string, used to justify email-quoted paragraphs. This
|
||||
is an extended regular expression. The default value is
|
||||
@t{"^([@w{ }\t]*([#:>|@}]|//))+"}.
|
||||
Note that @code{\t} stands for a literal Tab character.
|
||||
Set the regular expression for matching the quoting part of a line.
|
||||
The default value is @t{"^([@w{ }\t]*([!#%:;>|@}]|//|--))+"}.
|
||||
(Note that @code{\t} stands for a literal Tab character.)
|
||||
This makes it possible to rejustify blocks of quoted text when composing
|
||||
email, and to rewrap blocks of line comments when writing source code.
|
||||
|
||||
@item set rawsequences
|
||||
Interpret escape sequences directly (instead of asking @code{ncurses} to
|
||||
translate them). If you need this option to get your keyboard to work
|
||||
properly, please report a bug. Using this option disables @command{nano}'s
|
||||
mouse support.
|
||||
|
||||
@item set rebinddelete
|
||||
Interpret the Delete key differently so that both Backspace and Delete
|
||||
work properly. You should only need to use this option if Backspace
|
||||
acts like Delete on your system.
|
||||
|
||||
@item set rebindkeypad
|
||||
Interpret the numeric keypad keys so that they all work properly. You
|
||||
should only need to use this option if they don't, as mouse support
|
||||
won't work properly with this option enabled.
|
||||
Interpret the Delete and Backspace keys differently so that both Backspace
|
||||
and Delete work properly. You should only use this option when on your
|
||||
system either Backspace acts like Delete or Delete acts like Backspace.
|
||||
|
||||
@item set regexp
|
||||
Do extended regular expression searches by default.
|
||||
@@ -877,7 +920,8 @@ already at that position, it will jump to the true beginning of the
|
||||
line.
|
||||
|
||||
@item set smooth
|
||||
Use smooth scrolling by default.
|
||||
Deprecated option since it has become the default setting.
|
||||
When needed, use @code{unset jumpyscrolling} instead.
|
||||
|
||||
@item set softwrap
|
||||
Enable soft line wrapping for easier viewing of very long lines.
|
||||
@@ -890,6 +934,10 @@ Use the given program to do spell checking and correcting.
|
||||
Use this color combination for the status bar.
|
||||
@xref{@code{set functioncolor}} for valid color names.
|
||||
|
||||
@item set stripecolor @var{fgcolor},@var{bgcolor}
|
||||
Use this color combination for the vertical guiding stripe.
|
||||
@xref{@code{set functioncolor}} for valid color names.
|
||||
|
||||
@item set suspend
|
||||
Allow @command{nano} to be suspended.
|
||||
|
||||
@@ -910,7 +958,6 @@ Use this color combination for the title bar.
|
||||
@item set trimblanks
|
||||
Remove trailing whitespace from wrapped lines when automatic
|
||||
hard-wrapping occurs or when text is justified.
|
||||
(The old form of this option, @code{set justifytrim}, is deprecated.)
|
||||
|
||||
@item set unix
|
||||
Save a file by default in Unix format. This overrides nano's
|
||||
@@ -990,7 +1037,6 @@ on the system and will be silently ignored otherwise.)
|
||||
|
||||
@item linter @var{program} [@var{arg} @dots{}]
|
||||
Use the given @var{program} to do a syntax check on the current buffer.
|
||||
(This overrides the speller function.)
|
||||
|
||||
@item comment "@var{string}"
|
||||
Use the given string for commenting and uncommenting lines.
|
||||
@@ -1152,25 +1198,23 @@ Cuts and stores the current line (or the marked region).
|
||||
|
||||
@item copy
|
||||
Copies the current line (or the marked region) without deleting it.
|
||||
(The old form 'copytext' is deprecated.)
|
||||
|
||||
@item paste
|
||||
Pastes the currently stored text into the current buffer at the
|
||||
current cursor position.
|
||||
(The old form 'uncut' is deprecated.)
|
||||
|
||||
@item zap
|
||||
Throw away the current line (or the marked region).
|
||||
Throws away the current line (or the marked region).
|
||||
(This function is bound by default to <Meta+Delete>.)
|
||||
|
||||
@item cutwordleft
|
||||
Cuts from the cursor position to the beginning of the preceding word.
|
||||
(This function is not bound by default. If your terminal produces
|
||||
@code{^H} for <Ctrl+Backspace>, you can make <Ctrl+Backspace> delete
|
||||
@item chopwordleft
|
||||
Deletes from the cursor position to the beginning of the preceding word.
|
||||
(This function is bound by default to <Shift+Ctrl+Delete>. If your terminal
|
||||
produces @code{^H} for <Ctrl+Backspace>, you can make <Ctrl+Backspace> delete
|
||||
the word to the left of the cursor by rebinding ^H to this function.)
|
||||
|
||||
@item cutwordright
|
||||
Cuts from the cursor position to the beginning of the next word.
|
||||
@item chopwordright
|
||||
Deletes from the cursor position to the beginning of the next word.
|
||||
(This function is bound by default to <Ctrl+Delete>.)
|
||||
|
||||
@item cutrestoffile
|
||||
@@ -1187,8 +1231,11 @@ Shows the current cursor position: the line, column, and character positions.
|
||||
Counts the number of words, lines and characters in the current buffer.
|
||||
|
||||
@item speller
|
||||
Invokes a spell-checking program (or linting program,
|
||||
if the active syntax defines such a thing).
|
||||
Invokes a spell-checking program, either the default one, or the one
|
||||
defined by @option{--speller} or @code{set speller}.
|
||||
|
||||
@item linter
|
||||
Invokes a syntax-checking program (if the active syntax defines one).
|
||||
|
||||
@item justify
|
||||
Justifies the current paragraph. A paragraph is a group of contiguous lines
|
||||
@@ -1340,7 +1387,6 @@ Toggles between searching for something and replacing something.
|
||||
|
||||
@item flipgoto
|
||||
Toggles between searching for text and targeting a line number.
|
||||
(The form @code{gototext} is deprecated.)
|
||||
|
||||
@item flipexecute
|
||||
Toggles between inserting a file and executing a command.
|
||||
@@ -1395,7 +1441,6 @@ Toggles the presence of the two-line list of key bindings at the bottom of the s
|
||||
|
||||
@item constantshow
|
||||
Toggles the constant display of the current line, column, and character positions.
|
||||
(The form @code{constupdate} is deprecated.)
|
||||
|
||||
@item smoothscroll
|
||||
Toggles smooth scrolling (when moving around with the arrow keys).
|
||||
@@ -1423,7 +1468,6 @@ is the beginning of a paragraph.
|
||||
@item cutfromcursor
|
||||
Toggles whether cutting text will cut the whole line or just from the current cursor
|
||||
position to the end of the line.
|
||||
(The form @code{cuttoend} is deprecated.)
|
||||
|
||||
@item nowrap
|
||||
Toggles whether long lines will be hard-wrapped to the next line.
|
||||
@@ -1519,11 +1563,40 @@ browser exits.
|
||||
@node Pico Compatibility
|
||||
@chapter Pico Compatibility
|
||||
|
||||
@command{nano} attempts to emulate Pico as closely as possible, but there
|
||||
are some differences between the editors:
|
||||
@command{nano} emulates Pico quite closely, but there
|
||||
are some differences between the two editors:
|
||||
|
||||
@table @code
|
||||
|
||||
@item Hard-Wrapping
|
||||
Unlike Pico, @command{nano} does not automatically hard-wrap the current
|
||||
line when it becomes overlong during typing. This hard-wrapping can be
|
||||
switched on with the @option{--breaklonglines} option. With that option,
|
||||
@command{nano} by default breaks lines at screen width minus eight columns,
|
||||
whereas Pico does it at screen width minus six columns. You can make
|
||||
@command{nano} do as Pico by using @option{--fill=-6}.
|
||||
|
||||
@item Magic Newline
|
||||
Pico ensures that any text always ends with a newline character.
|
||||
Nano does not do this by default: the user is left in full control
|
||||
of the formatting. You can get the automatic newline by using the
|
||||
@option{--finalnewline} option.
|
||||
|
||||
@item Scrolling
|
||||
By default, @command{nano} will scroll just one line (instead of half
|
||||
a screen) when the cursor is moved to a line that is just out of view.
|
||||
And when paging up or down, @command{nano} keeps the cursor in the same
|
||||
screen position as much as possible, instead always placing it on the
|
||||
first line of the viewport. The Pico-like behavior can be obtained
|
||||
with the @option{--jumpyscrolling} option.
|
||||
|
||||
@item Edit Area
|
||||
Pico never uses the line directly below the title bar, leaving it always
|
||||
blank. @command{nano} includes this line in the editing area, in order
|
||||
to not waste space, and because in this way it is slightly clearer where
|
||||
the text starts. If you are accustomed to this line being empty, you can
|
||||
get it back with the @option{--emptyline} option.
|
||||
|
||||
@item Interactive Replace
|
||||
Instead of allowing you to replace either just one occurrence of a search
|
||||
string or all of them, @command{nano}'s replace function is interactive: it
|
||||
@@ -1549,11 +1622,6 @@ The output of the "Display Cursor Position" command (@kbd{^C}) displays
|
||||
not only the current line and character position of the cursor,
|
||||
but also (between the two) the current column position.
|
||||
|
||||
@item Hard-Wrapping
|
||||
By default, @command{nano} hard-wraps lines at screen width minus eight
|
||||
columns, whereas Pico does it at screen width minus six columns. You can
|
||||
make @command{nano} do the same as Pico by using @option{--fill=-6}.
|
||||
|
||||
@item Spell Checking
|
||||
In the internal spell checker misspelled words are sorted alphabetically
|
||||
and trimmed for uniqueness, such that the words 'apple' and 'Apple' will
|
||||
@@ -1702,10 +1770,6 @@ chances are you only want this feature when you're working on the nano source.
|
||||
Disables Native Language support. This will disable the use of any
|
||||
available GNU @command{nano} translations.
|
||||
|
||||
@item --disable-wrapping-as-root
|
||||
Disable hard-wrapping of overlong lines by default when @command{nano}
|
||||
is run as root.
|
||||
|
||||
@item --enable-utf8
|
||||
Enable support for reading and writing Unicode files. This will require
|
||||
either a wide version of curses, or a UTF-8-enabled version of Slang.
|
||||
|
||||
124
doc/nanorc.5
124
doc/nanorc.5
@@ -1,4 +1,4 @@
|
||||
.\" Copyright (C) 2003-2011, 2013-2017 Free Software Foundation, Inc.
|
||||
.\" Copyright (C) 2003-2011, 2013-2019 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,11 +16,20 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANORC 5 "version 3.2" "November 2018"
|
||||
.TH NANORC 5 "version 4.0" "March 2019"
|
||||
|
||||
.SH NAME
|
||||
nanorc \- GNU nano's configuration file
|
||||
|
||||
.SH NOTE
|
||||
Starting with version 4.0, \fBnano\fR no longer hard-wraps an overlong
|
||||
line by default, and no longer automatically adds a newline at the end
|
||||
of the text if one is missing. Furthermore, it uses smooth scrolling
|
||||
by default and makes use of the line below the title bar.
|
||||
.sp
|
||||
If you want the old, Pico behavior back, you can use \fBset breaklonglines\fR,
|
||||
\fBset finalnewline\fR, \fBset jumpyscrolling\fR, and \fBset emptyline\fR.
|
||||
|
||||
.SH DESCRIPTION
|
||||
The \fInanorc\fP file contains the default settings for \fBnano\fP, a
|
||||
small and friendly editor. The file should be in Unix format, not in
|
||||
@@ -92,6 +101,9 @@ paragraphs. This may not include blank characters. Only closing
|
||||
punctuation (see \fBset punct\fP), optionally followed by the specified
|
||||
closing brackets, can end sentences. The default value is "\fB"')>]}\fP".
|
||||
.TP
|
||||
.B set breaklonglines
|
||||
Automatically hard-wrap the current line when it becomes overlong.
|
||||
.TP
|
||||
.B set casesensitive
|
||||
Do case-sensitive searches by default.
|
||||
.TP
|
||||
@@ -101,17 +113,23 @@ This overrides the option \fBquickblank\fR.
|
||||
.TP
|
||||
.B set cutfromcursor
|
||||
Use cut-from-cursor-to-end-of-line by default, instead of cutting the whole line.
|
||||
(The old form of this option, '\fBset cut\fR', is deprecated.)
|
||||
.TP
|
||||
.B set emptyline
|
||||
Do not use the line below the title bar, leaving it entirely blank.
|
||||
.TP
|
||||
.B set errorcolor \fIfgcolor\fR,\fIbgcolor\fR
|
||||
Use this color combination for the status bar when an error message is displayed.
|
||||
See \fBset titlecolor\fR for valid color names.
|
||||
.TP
|
||||
.B set finalnewline
|
||||
If the buffer is not empty, ensure that it ends with a newline character.
|
||||
.TP
|
||||
.B set fill \fInumber\fR
|
||||
Hard-wrap lines at column number \fInumber\fR. If \fInumber\fR is 0 or less,
|
||||
the maximum line length will be the screen width less \fInumber\fP columns.
|
||||
The default value is \fB\-8\fR. This option conflicts with
|
||||
\fBnowrap\fR -- the last one given takes effect.
|
||||
Set the target width for justifying and automatic hard-wrapping at this
|
||||
\fInumber\fR of columns. If the value is 0 or less, wrapping will occur
|
||||
at the width of the screen minus \fInumber\fR columns, allowing the wrap
|
||||
point to vary along with the width of the screen if the screen is resized.
|
||||
The default value is \-8.
|
||||
.TP
|
||||
.B set functioncolor \fIfgcolor\fR,\fIbgcolor\fR
|
||||
Specify the color combination to use for the function descriptions
|
||||
@@ -122,6 +140,9 @@ See \fBset titlecolor\fR for more details.
|
||||
Save the last hundred search strings and replacement strings and
|
||||
executed commands, so they can be easily reused in later sessions.
|
||||
.TP
|
||||
.B set jumpyscrolling
|
||||
Scroll the buffer contents per half-screen instead of per line.
|
||||
.TP
|
||||
.B set keycolor \fIfgcolor\fR,\fIbgcolor\fR
|
||||
Specify the color combination to use for the shortcut key combos
|
||||
in the two help lines at the bottom of the screen.
|
||||
@@ -133,6 +154,10 @@ Display line numbers to the left of the text area.
|
||||
.B set locking
|
||||
Enable vim-style lock-files for when editing files.
|
||||
.TP
|
||||
.B set guidestripe \fInumber
|
||||
Draw a vertical stripe at the given column, to help judge the width of the
|
||||
text. (The color of the stripe can be changed with \fBset stripecolor\fR.)
|
||||
.TP
|
||||
.B set matchbrackets "\fIstring\fP"
|
||||
Set the opening and closing brackets that can be found by bracket
|
||||
searches. This may not include blank characters. The opening set must
|
||||
@@ -140,7 +165,8 @@ come before the closing set, and the two sets must be in the same order.
|
||||
The default value is "\fB(<[{)>]}\fP".
|
||||
.TP
|
||||
.B set morespace
|
||||
Use the blank line below the title bar as extra editing space.
|
||||
Deprecated option since it has become the default setting.
|
||||
When needed, use \fBunset emptyline\fR instead.
|
||||
.TP
|
||||
.B set mouse
|
||||
Enable mouse support, if available for your system. When enabled, mouse
|
||||
@@ -159,15 +185,16 @@ Don't convert files from DOS/Mac format.
|
||||
Don't display the two help lines at the bottom of the screen.
|
||||
.TP
|
||||
.B set nonewlines
|
||||
When a file does not end with a newline, don't automatically add one.
|
||||
Deprecated option since it has become the default setting.
|
||||
When needed, use \fBunset finalnewline\fR instead.
|
||||
.TP
|
||||
.B set nopauses
|
||||
Don't pause between warnings at startup. This means that only
|
||||
the last one will be visible (when there are multiple ones).
|
||||
.TP
|
||||
.B set nowrap
|
||||
Don't hard-wrap text at all. This option conflicts with
|
||||
\fBfill\fR -- the last one given takes effect.
|
||||
Deprecated option since it has become the default setting.
|
||||
When needed, use \fBunset breaklonglines\fR instead.
|
||||
.TP
|
||||
.B set numbercolor \fIfgcolor\fR,\fIbgcolor\fR
|
||||
Specify the color combination to use for line numbers.
|
||||
@@ -196,24 +223,23 @@ specfified closing punctuation, optionally followed by closing brackets
|
||||
Do quick status-bar blanking: status-bar messages will disappear after 1
|
||||
keystroke instead of 25. The option \fBconstantshow\fR overrides this.
|
||||
.TP
|
||||
.B set quiet
|
||||
Obsolete option. Recognized but ignored.
|
||||
.TP
|
||||
.B set quotestr "\fIregex\fP"
|
||||
The email-quote string, used to justify email-quoted paragraphs. This
|
||||
is an extended regular expression. The default value is
|
||||
"\fB^([\ \\t]*([#:>|}]|//))+\fP". Note that \fB\\t\fR stands for an actual
|
||||
Tab character.
|
||||
Set the regular expression for matching the quoting part of a line.
|
||||
The default value is "\fB^([\ \\t]*([!#%:;>|}]|//|\-\-))+\fP".
|
||||
(Note that \fB\\t\fR stands for an actual Tab character.)
|
||||
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.
|
||||
.TP
|
||||
.B set rebinddelete
|
||||
Interpret the Delete key differently so that both Backspace and Delete
|
||||
work properly. You should only need to use this option if Backspace
|
||||
acts like Delete on your system.
|
||||
.TP
|
||||
.B set rebindkeypad
|
||||
Interpret the numeric keypad keys so that they all work properly. You
|
||||
should only need to use this option if they don't, as mouse support
|
||||
won't work properly with this option enabled.
|
||||
Interpret the Delete and Backspace keys differently so that both Backspace
|
||||
and Delete work properly. You should only use this option when on your
|
||||
system either Backspace acts like Delete or Delete acts like Backspace.
|
||||
.TP
|
||||
.B set regexp
|
||||
Do extended regular expression searches by default.
|
||||
@@ -234,7 +260,8 @@ already at that position, it will jump to the true beginning of the
|
||||
line.
|
||||
.TP
|
||||
.B set smooth
|
||||
Use smooth scrolling by default.
|
||||
Deprecated option since it has become the default setting.
|
||||
When needed, use \fBunset jumpyscrolling\fR instead.
|
||||
.TP
|
||||
.B set softwrap
|
||||
Enable soft line wrapping for easier viewing of very long lines.
|
||||
@@ -247,6 +274,10 @@ instead of the built-in corrector that calls \fBspell\fR.
|
||||
Specify the color combination to use for the status bar.
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
.B set stripecolor \fIfgcolor\fR,\fIbgcolor\fR
|
||||
Specify the color combination to use for the vertical guiding stripe.
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
.B set suspend
|
||||
Allow \fBnano\fP to be suspended.
|
||||
.TP
|
||||
@@ -272,7 +303,6 @@ And either "\fIfgcolor\fR" or ",\fIbgcolor\fR" may be left out.
|
||||
.B set trimblanks
|
||||
Remove trailing whitespace from wrapped lines when automatic
|
||||
hard-wrapping occurs or when text is justified.
|
||||
(The old form of this option, '\fBset justifytrim\fR', is deprecated.)
|
||||
.TP
|
||||
.B set unix
|
||||
Save a file by default in Unix format. This overrides nano's
|
||||
@@ -282,7 +312,7 @@ default behavior of saving a file in the format that it had.
|
||||
.B set view
|
||||
Disallow file modification: read-only mode.
|
||||
This mode allows the user to open also other files for viewing,
|
||||
unless \fB--restricted\fR is given on the command line.
|
||||
unless \fB\-\-restricted\fR is given on the command line.
|
||||
.TP
|
||||
.B set whitespace "\fIstring\fP"
|
||||
Set the two characters used to indicate the presence of tabs and
|
||||
@@ -322,7 +352,7 @@ command is encountered.
|
||||
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 by using the \fB\-Y\fR or \fB\-\-syntax\fR
|
||||
command-line option followed by the \fIname\fR.
|
||||
|
||||
The syntax \fBdefault\fP is special: it takes no \fIfileregex\fR,
|
||||
@@ -345,7 +375,6 @@ system and will be silently ignored otherwise.)
|
||||
.TP
|
||||
.BI linter " program " \fR[ "arg " \fR...]
|
||||
Use the given \fIprogram\fR to run a syntax check on the current buffer.
|
||||
(This overrides the speller function.)
|
||||
.TP
|
||||
.BI "comment """ string """
|
||||
Use the given \fIstring\fR for commenting and uncommenting lines.
|
||||
@@ -414,7 +443,7 @@ series of keystrokes to a single key in your nanorc:
|
||||
.RE
|
||||
.PP
|
||||
(Note that the \fB^R\fR, \fB^X\fR, and \fB^M\fR are each a single, literal
|
||||
control character. You can enter them by preceding each with \fBM-V\fR.)
|
||||
control character. You can enter them by preceding each with \fBM\-V\fR.)
|
||||
|
||||
.SH REBINDING KEYS
|
||||
Key bindings can be changed via the following three commands:
|
||||
@@ -430,7 +459,7 @@ 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.)
|
||||
with \fBM\-V\fR.)
|
||||
|
||||
.TP
|
||||
.BI unbind " key menu"
|
||||
@@ -447,9 +476,9 @@ followed by a Latin letter, by one of several ASCII characters
|
||||
(@, ], \\, ^, or _), or by the word "Space".
|
||||
Example: ^C.
|
||||
.TP
|
||||
.B M-
|
||||
.B M\-
|
||||
followed by any ASCII character except [, or by the word "Space".
|
||||
Example: M-C.
|
||||
Example: M\-C.
|
||||
.TP
|
||||
.B F
|
||||
followed by a numeric value from 1 to 16.
|
||||
@@ -503,25 +532,23 @@ Cuts and stores the current line (or the marked region).
|
||||
.TP
|
||||
.B copy
|
||||
Copies the current line (or the marked region) without deleting it.
|
||||
(The old form 'copytext' is deprecated.)
|
||||
.TP
|
||||
.B paste
|
||||
Pastes the currently stored text into the current buffer at the
|
||||
current cursor position.
|
||||
(The old form 'uncut' is deprecated.)
|
||||
.TP
|
||||
.B zap
|
||||
Throw away the current line (or the marked region).
|
||||
Throws away the current line (or the marked region).
|
||||
(This function is bound by default to <Meta+Delete>.)
|
||||
.TP
|
||||
.B cutwordleft
|
||||
Cuts from the cursor position to the beginning of the preceding word.
|
||||
(This function is not bound by default. If your terminal produces
|
||||
\fB^H\fR for <Ctrl+Backspace>, you can make <Ctrl+Backspace> delete
|
||||
.B chopwordleft
|
||||
Deletes from the cursor position to the beginning of the preceding word.
|
||||
(This function is bound by default to <Shift+Ctrl+Delete>. If your terminal
|
||||
produces \fB^H\fR for <Ctrl+Backspace>, you can make <Ctrl+Backspace> delete
|
||||
the word to the left of the cursor by rebinding ^H to this function.)
|
||||
.TP
|
||||
.B cutwordright
|
||||
Cuts from the cursor position to the beginning of the next word.
|
||||
.B chopwordright
|
||||
Deletes from the cursor position to the beginning of the next word.
|
||||
(This function is bound by default to <Ctrl+Delete>.)
|
||||
.TP
|
||||
.B cutrestoffile
|
||||
@@ -538,11 +565,11 @@ Shows the current cursor position: the line, column, and character positions.
|
||||
Counts the number of words, lines and characters in the current buffer.
|
||||
.TP
|
||||
.B speller
|
||||
Invokes a spell-checking program (or linting program,
|
||||
if the active syntax defines such a thing).
|
||||
Invokes a spell-checking program, either the default one, or the one
|
||||
defined by \fB\-\-speller\fR or \fBset speller\fR.
|
||||
.TP
|
||||
.B linter
|
||||
A synonym of \fBspeller\fR (for when the speller has not been configured).
|
||||
Invokes a syntax-checking program (if the active syntax defines one).
|
||||
.TP
|
||||
.B justify
|
||||
Justifies the current paragraph. A paragraph is a group of contiguous lines
|
||||
@@ -694,7 +721,6 @@ Toggles between searching for something and replacing something.
|
||||
.TP
|
||||
.B flipgoto
|
||||
Toggles between searching for text and targeting a line number.
|
||||
(The form 'gototext' is deprecated.)
|
||||
.TP
|
||||
.B flipexecute
|
||||
Toggles between inserting a file and executing a command.
|
||||
@@ -749,7 +775,6 @@ Toggles the presence of the two-line list of key bindings at the bottom of the s
|
||||
.TP
|
||||
.B constantshow
|
||||
Toggles the constant display of the current line, column, and character positions.
|
||||
(The form 'constupdate' is deprecated.)
|
||||
.TP
|
||||
.B smoothscroll
|
||||
Toggles smooth scrolling (when moving around with the arrow keys).
|
||||
@@ -777,7 +802,6 @@ is the beginning of a paragraph.
|
||||
.B cutfromcursor
|
||||
Toggles whether cutting text will cut the whole line or just from the current cursor
|
||||
position to the end of the line.
|
||||
(The form 'cuttoend' is deprecated.)
|
||||
.TP
|
||||
.B nowrap
|
||||
Toggles whether long lines will be hard-wrapped to the next line.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" Copyright (C) 2002, 2005, 2006, 2007, 2014 Free Software Foundation, Inc.
|
||||
.\" Copyright (C) 2002-2007, 2014-2019 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 3.2" "November 2018"
|
||||
.TH RNANO 1 "version 4.0" "March 2019"
|
||||
|
||||
.SH NAME
|
||||
rnano \- a restricted nano
|
||||
|
||||
@@ -40,6 +40,9 @@
|
||||
## optionally followed by these closing brackets, can end sentences.
|
||||
# set brackets ""')>]}"
|
||||
|
||||
## Automatically hard-wrap the current line when it becomes overlong.
|
||||
# set breaklonglines
|
||||
|
||||
## Do case-sensitive searches by default.
|
||||
# set casesensitive
|
||||
|
||||
@@ -49,16 +52,24 @@
|
||||
|
||||
## Use cut-from-cursor-to-end-of-line by default.
|
||||
# set cutfromcursor
|
||||
## (The old form, 'cut', is deprecated.)
|
||||
|
||||
## Do not use the line below the title bar, leaving it entirely blank.
|
||||
# set emptyline
|
||||
|
||||
## Enable hard-wrapping and set the target width, both for automatic
|
||||
## line wrapping and for justifying paragraphs. If the value is 0 or
|
||||
## less, the wrapping point will be the screen width minus this number.
|
||||
# set fill -8
|
||||
|
||||
## Ensure that a non-empty buffer ends with a newline character.
|
||||
# set finalnewline
|
||||
|
||||
## Remember the used search/replace strings for the next session.
|
||||
# set historylog
|
||||
|
||||
## Scroll the buffer contents per half-screen instead of per line.
|
||||
# set jumpyscrolling
|
||||
|
||||
## Display line numbers to the left of the text.
|
||||
# set linenumbers
|
||||
|
||||
@@ -72,9 +83,6 @@
|
||||
## come before the latter set, and both must be in the same order.
|
||||
# set matchbrackets "(<[{)>]}"
|
||||
|
||||
## Use the blank line below the title bar as extra editing space.
|
||||
# set morespace
|
||||
|
||||
## Enable mouse support, if available for your system. When enabled,
|
||||
## mouse clicks can be used to place the cursor, set the mark (with a
|
||||
## double click), and execute shortcuts. The mouse will work in the X
|
||||
@@ -91,16 +99,10 @@
|
||||
## Don't display the helpful shortcut lists at the bottom of the screen.
|
||||
# set nohelp
|
||||
|
||||
## Don't automatically add a newline when a file does not end with one.
|
||||
# set nonewlines
|
||||
|
||||
## Don't pause between warnings at startup. Which means that only the
|
||||
## last one will be readable (when there are multiple ones).
|
||||
# set nopauses
|
||||
|
||||
## Do not automatically hard-wrap text.
|
||||
# set nowrap
|
||||
|
||||
## Set operating directory. nano will not read or write files outside
|
||||
## this directory and its subdirectories. Also, the current directory
|
||||
## is changed to here, so any files are inserted from this dir. A blank
|
||||
@@ -123,16 +125,16 @@
|
||||
## 1 keystroke instead of 26. Note that "constantshow" overrides this.
|
||||
# set quickblank
|
||||
|
||||
## The email-quote string, used to justify email-quoted paragraphs.
|
||||
## This is an extended regular expression. The default is:
|
||||
# set quotestr "^([ ]*([#:>|}]|//))+"
|
||||
## The regular expression that matches quoting characters in email
|
||||
## or line-comment introducers in source code. The default is:
|
||||
# set quotestr "^([ ]*([!#%:;>|}]|//|--))+"
|
||||
|
||||
## Try to work around a mismatching terminfo terminal description.
|
||||
# set rawsequences
|
||||
|
||||
## Fix Backspace/Delete confusion problem.
|
||||
# set rebinddelete
|
||||
|
||||
## Fix numeric keypad key confusion problem.
|
||||
# set rebindkeypad
|
||||
|
||||
## Do extended regular expression searches by default.
|
||||
# set regexp
|
||||
|
||||
@@ -148,9 +150,6 @@
|
||||
## beginning of the line.
|
||||
# set smarthome
|
||||
|
||||
## Use line-by-line scrolling instead of chunk-by-chunk.
|
||||
# set smooth
|
||||
|
||||
## Enable soft line wrapping (AKA full-line display).
|
||||
# set softwrap
|
||||
|
||||
@@ -172,7 +171,6 @@
|
||||
|
||||
## Snip whitespace at the end of lines when justifying or hard-wrapping.
|
||||
# set trimblanks
|
||||
## (The old form, 'justifytrim', is deprecated.)
|
||||
|
||||
## Disallow file modification. Why would you want this in an rcfile? ;)
|
||||
# set view
|
||||
@@ -204,6 +202,7 @@
|
||||
# set statuscolor brightwhite,green
|
||||
# set errorcolor brightwhite,red
|
||||
# set selectedcolor brightwhite,magenta
|
||||
# set stripecolor ,yellow
|
||||
# set numbercolor cyan
|
||||
# set keycolor cyan
|
||||
# set functioncolor green
|
||||
@@ -212,6 +211,7 @@
|
||||
# set statuscolor brightwhite,magenta
|
||||
# set errorcolor brightwhite,red
|
||||
# set selectedcolor brightwhite,cyan
|
||||
# set stripecolor ,yellow
|
||||
# set numbercolor magenta
|
||||
# set keycolor brightmagenta
|
||||
# set functioncolor magenta
|
||||
@@ -272,7 +272,7 @@
|
||||
## keycode, which is hard-bound to the backspace function. So, if you
|
||||
## normally use <Backspace> for backspacing and not ^H, you can make
|
||||
## <Ctrl+Backspace> delete the word to the left of the cursor with:
|
||||
# bind ^H cutwordleft main
|
||||
# bind ^H chopwordleft 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,
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# List of available languages.
|
||||
bg ca cs da de eo es eu fi fr ga gl hr hu id it ja ms nb nl nn pl pt pt_BR ro ru sl sr sv tr uk vi zh_CN zh_TW
|
||||
bg ca cs da de eo es eu fi fr ga gl hr hu id it ja ko ms nb nl nn pl pt pt_BR ro ru sl sr sv tr uk vi zh_CN zh_TW
|
||||
|
||||
1023
po/nano.pot
1023
po/nano.pot
File diff suppressed because it is too large
Load Diff
1112
po/pt_BR.po
1112
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Let this be executed in the po/ subdir.
|
||||
cd "$(dirname "$0")" || exit
|
||||
cd "$(dirname "$0")" || exit 1
|
||||
|
||||
echo "Updating translations via TP"
|
||||
rsync -Lrtvz translationproject.org::tp/latest/nano/ .
|
||||
# First remove existing PO files, as wget will not overwrite them.
|
||||
rm *.po
|
||||
wget --recursive --level=1 --accept=po --no-directories --no-verbose \
|
||||
https://translationproject.org/latest/nano/ || exit 2
|
||||
|
||||
# Are there now PO files that are not in git yet?
|
||||
NEWSTUFF=$(git status --porcelain *.po | grep "^??")
|
||||
|
||||
1087
po/zh_CN.po
1087
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
1914
po/zh_TW.po
1914
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERSION="3.2"
|
||||
VERSION="4.0"
|
||||
|
||||
./configure -C --enable-tiny && make &&
|
||||
./configure -C --disable-wrapping-as-root &&
|
||||
./configure -C --enable-tiny && make && ./configure -C &&
|
||||
|
||||
echo "Running autogen..." && ./autogen.sh &&
|
||||
rm -v -f m4/*.m4~ *.asc *.sig *.gz *.xz &&
|
||||
@@ -13,6 +12,7 @@ po/update_linguas.sh &&
|
||||
|
||||
make distcheck && make dist-xz &&
|
||||
|
||||
git add po/*.po &&
|
||||
git commit -a -m "$(git log -1 --grep 'po: up' | grep o: | sed 's/^ //')" &&
|
||||
|
||||
gpg -a -b nano-$VERSION.tar.gz &&
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* browser.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2001-2011, 2013-2018 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2001-2011, 2013-2019 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2015-2016 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -462,7 +462,7 @@ functionptrtype parse_browser_input(int *kbinput)
|
||||
{
|
||||
if (!meta_key) {
|
||||
switch (*kbinput) {
|
||||
case DEL_CODE:
|
||||
case BS_CODE:
|
||||
case '-':
|
||||
return do_page_up;
|
||||
case ' ':
|
||||
@@ -529,7 +529,7 @@ void browser_refresh(void)
|
||||
/* 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);
|
||||
namelen + infomaxlen + 4 - longest : 0, longest, FALSE, FALSE);
|
||||
/* The filename (or a fragment of it) in displayable format.
|
||||
* When a fragment, account for dots plus one space padding. */
|
||||
|
||||
@@ -667,7 +667,7 @@ int filesearch_init(bool forwards)
|
||||
|
||||
/* If something was searched for before, show it between square brackets. */
|
||||
if (*last_search != '\0') {
|
||||
char *disp = display_string(last_search, 0, COLS / 3, FALSE);
|
||||
char *disp = display_string(last_search, 0, COLS / 3, FALSE, FALSE);
|
||||
|
||||
thedefault = charalloc(strlen(disp) + 7);
|
||||
/* We use (COLS / 3) here because we need to see more on the line. */
|
||||
|
||||
37
src/chars.c
37
src/chars.c
@@ -1,8 +1,8 @@
|
||||
/**************************************************************************
|
||||
* chars.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2001-2011, 2013-2018 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2016-2017 Benno Schulenberg *
|
||||
* Copyright (C) 2001-2011, 2013-2019 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2016-2018 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 *
|
||||
@@ -636,38 +636,21 @@ char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer)
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || defined(ENABLE_JUSTIFY))
|
||||
/* Return TRUE if the string s contains one or more blank characters,
|
||||
/* Return TRUE if the given string contains at least one blank character,
|
||||
* and FALSE otherwise. */
|
||||
bool has_blank_chars(const char *s)
|
||||
bool has_blank_char(const char *string)
|
||||
{
|
||||
for (; *s != '\0'; s++) {
|
||||
if (isblank((unsigned char)*s))
|
||||
char symbol[MAXCHARLEN];
|
||||
|
||||
while (*string != '\0') {
|
||||
string += parse_mbchar(string, symbol, NULL);
|
||||
|
||||
if (is_blank_mbchar(symbol))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Return TRUE if the multibyte string s contains one or more blank
|
||||
* multibyte characters, and FALSE otherwise. */
|
||||
bool has_blank_mbchars(const char *s)
|
||||
{
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
char symbol[MAXCHARLEN];
|
||||
|
||||
for (; *s != '\0'; s += move_mbright(s, 0)) {
|
||||
parse_mbchar(s, symbol, NULL);
|
||||
|
||||
if (is_blank_mbchar(symbol))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
} else
|
||||
#endif
|
||||
return has_blank_chars(s);
|
||||
}
|
||||
#endif /* ENABLE_NANORC && (!NANO_TINY || ENABLE_JUSTIFY) */
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
|
||||
20
src/color.c
20
src/color.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* color.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2001-2011, 2013-2018 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2001-2011, 2013-2019 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2017 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -70,6 +70,8 @@ void set_colorpairs(void)
|
||||
} else {
|
||||
if (i == FUNCTION_TAG)
|
||||
interface_color_pair[i] = A_NORMAL;
|
||||
else if (i == GUIDE_STRIPE)
|
||||
interface_color_pair[i] = A_REVERSE;
|
||||
else if (i == ERROR_MESSAGE) {
|
||||
init_pair(i + 1, COLOR_WHITE, COLOR_RED);
|
||||
interface_color_pair[i] = COLOR_PAIR(i + 1) | A_BOLD | A_BANDAID;
|
||||
@@ -144,7 +146,7 @@ bool found_in_list(regexlisttype *head, const char *shibboleth)
|
||||
regex_t rgx;
|
||||
|
||||
for (item = head; item != NULL; item = item->next) {
|
||||
regcomp(&rgx, fixbounds(item->full_regex), NANO_REG_EXTENDED);
|
||||
regcomp(&rgx, item->full_regex, NANO_REG_EXTENDED);
|
||||
|
||||
if (regexec(&rgx, shibboleth, 0, NULL, 0) == 0) {
|
||||
regfree(&rgx);
|
||||
@@ -215,7 +217,7 @@ void color_update(void)
|
||||
/* If the filename didn't match anything, try the first line. */
|
||||
if (sint == NULL && !inhelp) {
|
||||
for (sint = syntaxes; sint != NULL; sint = sint->next) {
|
||||
if (found_in_list(sint->headers, openfile->fileage->data))
|
||||
if (found_in_list(sint->headers, openfile->filetop->data))
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -273,19 +275,19 @@ void color_update(void)
|
||||
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
|
||||
if (ink->start == NULL) {
|
||||
ink->start = (regex_t *)nmalloc(sizeof(regex_t));
|
||||
regcomp(ink->start, fixbounds(ink->start_regex), ink->rex_flags);
|
||||
regcomp(ink->start, ink->start_regex, ink->rex_flags);
|
||||
}
|
||||
|
||||
if (ink->end_regex != NULL && ink->end == NULL) {
|
||||
ink->end = (regex_t *)nmalloc(sizeof(regex_t));
|
||||
regcomp(ink->end, fixbounds(ink->end_regex), ink->rex_flags);
|
||||
regcomp(ink->end, ink->end_regex, ink->rex_flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Determine whether the matches of multiline regexes are still the same,
|
||||
* and if not, schedule a screen refresh, so things will be repainted. */
|
||||
void check_the_multis(filestruct *line)
|
||||
void check_the_multis(linestruct *line)
|
||||
{
|
||||
const colortype *ink;
|
||||
bool astart, anend;
|
||||
@@ -330,7 +332,7 @@ void check_the_multis(filestruct *line)
|
||||
}
|
||||
|
||||
/* Allocate (for one line) the cache space for multiline color regexes. */
|
||||
void alloc_multidata_if_needed(filestruct *fileptr)
|
||||
void alloc_multidata_if_needed(linestruct *fileptr)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -348,7 +350,7 @@ void precalc_multicolorinfo(void)
|
||||
{
|
||||
const colortype *ink;
|
||||
regmatch_t startmatch, endmatch;
|
||||
filestruct *line, *tailline;
|
||||
linestruct *line, *tailline;
|
||||
|
||||
if (openfile->colorstrings == NULL || ISSET(NO_COLOR_SYNTAX))
|
||||
return;
|
||||
@@ -362,7 +364,7 @@ void precalc_multicolorinfo(void)
|
||||
if (ink->end == NULL)
|
||||
continue;
|
||||
|
||||
for (line = openfile->fileage; line != NULL; line = line->next) {
|
||||
for (line = openfile->filetop; line != NULL; line = line->next) {
|
||||
int index = 0;
|
||||
|
||||
alloc_multidata_if_needed(line);
|
||||
|
||||
310
src/cut.c
310
src/cut.c
@@ -1,9 +1,9 @@
|
||||
/**************************************************************************
|
||||
* cut.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2019 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014 Mark Majeres *
|
||||
* Copyright (C) 2016 Benno Schulenberg *
|
||||
* Copyright (C) 2016, 2018, 2019 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 *
|
||||
@@ -24,22 +24,196 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static bool keep_cutbuffer = FALSE;
|
||||
/* Should we keep the contents of the cutbuffer? */
|
||||
|
||||
/* Indicate that we should no longer keep the contents of the cutbuffer. */
|
||||
void cutbuffer_reset(void)
|
||||
/* Delete the character under the cursor. */
|
||||
void do_deletion(undo_type action)
|
||||
{
|
||||
keep_cutbuffer = FALSE;
|
||||
#ifndef NANO_TINY
|
||||
size_t old_amount = 0;
|
||||
#endif
|
||||
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
/* When in the middle of a line, delete the current character. */
|
||||
if (openfile->current->data[openfile->current_x] != '\0') {
|
||||
int char_len = parse_mbchar(openfile->current->data +
|
||||
openfile->current_x, NULL, NULL);
|
||||
size_t line_len = strlen(openfile->current->data +
|
||||
openfile->current_x);
|
||||
#ifndef NANO_TINY
|
||||
/* If the type of action changed or the cursor moved to a different
|
||||
* line, create a new undo item, otherwise update the existing item. */
|
||||
if (action != openfile->last_action ||
|
||||
openfile->current->lineno != openfile->current_undo->lineno)
|
||||
add_undo(action);
|
||||
else
|
||||
update_undo(action);
|
||||
|
||||
if (ISSET(SOFTWRAP))
|
||||
old_amount = number_of_chunks_in(openfile->current);
|
||||
#endif
|
||||
/* Move the remainder of the line "in", over the current character. */
|
||||
charmove(&openfile->current->data[openfile->current_x],
|
||||
&openfile->current->data[openfile->current_x + char_len],
|
||||
line_len - char_len + 1);
|
||||
#ifndef NANO_TINY
|
||||
/* Adjust the mark if it is after the cursor on the current line. */
|
||||
if (openfile->mark == openfile->current &&
|
||||
openfile->mark_x > openfile->current_x)
|
||||
openfile->mark_x -= char_len;
|
||||
#endif
|
||||
/* Otherwise, when not at end of buffer, join this line with the next. */
|
||||
} else if (openfile->current != openfile->filebot) {
|
||||
linestruct *joining = openfile->current->next;
|
||||
|
||||
/* If there is a magic line, and we're before it: don't eat it. */
|
||||
if (joining == openfile->filebot && openfile->current_x != 0 &&
|
||||
ISSET(FINAL_NEWLINE)) {
|
||||
#ifndef NANO_TINY
|
||||
if (action == BACK)
|
||||
add_undo(BACK);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(action);
|
||||
#endif
|
||||
/* Add the contents of the next line to those of the current one. */
|
||||
openfile->current->data = charealloc(openfile->current->data,
|
||||
strlen(openfile->current->data) + strlen(joining->data) + 1);
|
||||
strcat(openfile->current->data, joining->data);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Adjust the mark if it was on the line that was "eaten". */
|
||||
if (openfile->mark == joining) {
|
||||
openfile->mark = openfile->current;
|
||||
openfile->mark_x += openfile->current_x;
|
||||
}
|
||||
#endif
|
||||
unlink_node(joining);
|
||||
renumber(openfile->current);
|
||||
|
||||
/* Two lines were joined, so we need to refresh the screen. */
|
||||
refresh_needed = TRUE;
|
||||
} else
|
||||
/* We're at the end-of-file: nothing to do. */
|
||||
return;
|
||||
|
||||
/* Adjust the file size, and remember it for a possible redo. */
|
||||
openfile->totsize--;
|
||||
#ifndef NANO_TINY
|
||||
openfile->current_undo->newsize = openfile->totsize;
|
||||
|
||||
/* If the number of screen rows that a softwrapped line occupies
|
||||
* has changed, we need a full refresh. */
|
||||
if (ISSET(SOFTWRAP) && refresh_needed == FALSE &&
|
||||
number_of_chunks_in(openfile->current) != old_amount)
|
||||
refresh_needed = TRUE;
|
||||
#endif
|
||||
|
||||
set_modified();
|
||||
}
|
||||
|
||||
/* If we aren't on the last line of the file, move all the text of the
|
||||
* current line, plus the newline at the end, into the cutbuffer. If we
|
||||
* are, move all of the text of the current line into the cutbuffer. In
|
||||
* both cases, set the current place we want to the beginning of the
|
||||
* current line. */
|
||||
/* Delete the character under the cursor. */
|
||||
void do_delete(void)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->mark && ISSET(LET_THEM_ZAP))
|
||||
zap_text();
|
||||
else
|
||||
#endif
|
||||
do_deletion(DEL);
|
||||
}
|
||||
|
||||
/* Backspace over one character. That is, move the cursor left one
|
||||
* character, and then delete the character under the cursor. */
|
||||
void do_backspace(void)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->mark && ISSET(LET_THEM_ZAP))
|
||||
zap_text();
|
||||
else
|
||||
#endif
|
||||
if (openfile->current != openfile->filetop || openfile->current_x > 0) {
|
||||
do_left();
|
||||
do_deletion(BACK);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Delete text from the cursor until the first start of a word to
|
||||
* the left, or to the right when forward is TRUE. */
|
||||
void chop_word(bool forward)
|
||||
{
|
||||
/* Remember the current cursor position. */
|
||||
linestruct *is_current = openfile->current;
|
||||
size_t is_current_x = openfile->current_x;
|
||||
|
||||
/* Remember where the cutbuffer is and then make it seem blank. */
|
||||
linestruct *is_cutbuffer = cutbuffer;
|
||||
linestruct *is_cutbottom = cutbottom;
|
||||
cutbuffer = NULL;
|
||||
cutbottom = NULL;
|
||||
|
||||
/* Move the cursor to a word start, to the left or to the right.
|
||||
* If that word is on another line and the cursor was not already
|
||||
* 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));
|
||||
if (openfile->current != is_current) {
|
||||
if (is_current_x > 0) {
|
||||
openfile->current = is_current;
|
||||
openfile->current_x = 0;
|
||||
} else
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
}
|
||||
} else {
|
||||
do_next_word(FALSE, ISSET(WORD_BOUNDS));
|
||||
if (openfile->current != is_current &&
|
||||
is_current->data[is_current_x] != '\0') {
|
||||
openfile->current = is_current;
|
||||
openfile->current_x = strlen(is_current->data);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the mark at the start of that word. */
|
||||
openfile->mark = openfile->current;
|
||||
openfile->mark_x = openfile->current_x;
|
||||
|
||||
/* Put the cursor back where it was, so an undo will put it there too. */
|
||||
openfile->current = is_current;
|
||||
openfile->current_x = is_current_x;
|
||||
|
||||
/* Now kill the marked region and a word is gone. */
|
||||
do_cut_text_void();
|
||||
|
||||
/* Discard the cut word and restore the cutbuffer. */
|
||||
free_lines(cutbuffer);
|
||||
cutbuffer = is_cutbuffer;
|
||||
cutbottom = is_cutbottom;
|
||||
}
|
||||
|
||||
/* Delete a word leftward. */
|
||||
void chop_previous_word(void)
|
||||
{
|
||||
chop_word(BACKWARD);
|
||||
}
|
||||
|
||||
/* Delete a word rightward. */
|
||||
void chop_next_word(void)
|
||||
{
|
||||
if (is_cuttable(openfile->current_x > 0))
|
||||
chop_word(FORWARD);
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Move the whole current line from the current buffer to the cutbuffer. */
|
||||
void cut_line(void)
|
||||
{
|
||||
/* When not on the last line of the buffer, move the text from the
|
||||
* head of this line to the head of the next line into the cutbuffer;
|
||||
* otherwise, move all of the text of this line into the cutbuffer. */
|
||||
if (openfile->current != openfile->filebot)
|
||||
extract_buffer(&cutbuffer, &cutbottom, openfile->current, 0,
|
||||
openfile->current->next, 0);
|
||||
@@ -50,49 +224,40 @@ void cut_line(void)
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Move all currently marked text into the cutbuffer, and set the
|
||||
* current place we want to where the text used to start. */
|
||||
/* Move all marked text from the current buffer into the cutbuffer. */
|
||||
void cut_marked(bool *right_side_up)
|
||||
{
|
||||
filestruct *top, *bot;
|
||||
linestruct *top, *bot;
|
||||
size_t top_x, bot_x;
|
||||
|
||||
mark_order((const filestruct **)&top, &top_x,
|
||||
(const filestruct **)&bot, &bot_x, right_side_up);
|
||||
mark_order((const linestruct **)&top, &top_x,
|
||||
(const linestruct **)&bot, &bot_x, right_side_up);
|
||||
|
||||
extract_buffer(&cutbuffer, &cutbottom, top, top_x, bot, bot_x);
|
||||
openfile->placewewant = xplustabs();
|
||||
}
|
||||
|
||||
/* If we aren't at the end of the current line, move all the text from
|
||||
* the current cursor position to the end of the current line, not
|
||||
* counting the newline at the end, into the cutbuffer. If we are, and
|
||||
* we're not on the last line of the file, move the newline at the end
|
||||
* into the cutbuffer, and set the current place we want to where the
|
||||
* newline used to be. */
|
||||
/* Move all text from the cursor position until the end of this line into
|
||||
* the cutbuffer. But when already at the end of a line, then move this
|
||||
* "newline" to the cutbuffer. */
|
||||
void cut_to_eol(void)
|
||||
{
|
||||
size_t data_len = strlen(openfile->current->data);
|
||||
|
||||
/* 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 the line separation into the cutbuffer. */
|
||||
if (openfile->current_x < data_len)
|
||||
/* If we're not at the end of the line, move all the text from
|
||||
* the current position up to it, not counting the newline at
|
||||
* the end, into the cutbuffer. */
|
||||
extract_buffer(&cutbuffer, &cutbottom, openfile->current,
|
||||
openfile->current_x, openfile->current, data_len);
|
||||
else if (openfile->current != openfile->filebot) {
|
||||
/* If we're at the end of the line, and it isn't the last line
|
||||
* of the file, move all the text from the current position up
|
||||
* to the beginning of the next line, i.e. the newline at the
|
||||
* end, into the cutbuffer. */
|
||||
extract_buffer(&cutbuffer, &cutbottom, openfile->current,
|
||||
openfile->current_x, openfile->current->next, 0);
|
||||
openfile->placewewant = xplustabs();
|
||||
}
|
||||
}
|
||||
|
||||
/* Move all the text from the current cursor position to the end of the
|
||||
* file into the cutbuffer. */
|
||||
/* Move all text from the cursor position to end-of-file into the cutbuffer. */
|
||||
void cut_to_eof(void)
|
||||
{
|
||||
extract_buffer(&cutbuffer, &cutbottom,
|
||||
@@ -109,20 +274,20 @@ void cut_to_eof(void)
|
||||
void do_cut_text(bool copy_text, bool marked, bool cut_till_eof, bool append)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
filestruct *cb_save = NULL;
|
||||
linestruct *cb_save = NULL;
|
||||
/* The current end of the cutbuffer, before we add text to it. */
|
||||
size_t cb_save_len = 0;
|
||||
/* The length of the string at the current end of the cutbuffer,
|
||||
* before we add text to it. */
|
||||
bool old_no_newlines = ISSET(NO_NEWLINES);
|
||||
bool using_magicline = ISSET(FINAL_NEWLINE);
|
||||
/* Whether an automatic newline should be added at end-of-buffer. */
|
||||
bool right_side_up = TRUE;
|
||||
/* There *is* no region, *or* it is marked forward. */
|
||||
#endif
|
||||
size_t was_totsize = openfile->totsize;
|
||||
|
||||
/* If cuts were not continuous, or when cutting a region, clear the slate. */
|
||||
if (!append && (!keep_cutbuffer || marked || cut_till_eof)) {
|
||||
free_filestruct(cutbuffer);
|
||||
free_lines(cutbuffer);
|
||||
cutbuffer = NULL;
|
||||
/* After a line cut, future line cuts should add to the cutbuffer. */
|
||||
keep_cutbuffer = !marked && !cut_till_eof;
|
||||
@@ -135,8 +300,8 @@ void do_cut_text(bool copy_text, bool marked, bool cut_till_eof, bool append)
|
||||
cb_save = cutbottom;
|
||||
cb_save_len = strlen(cutbottom->data);
|
||||
}
|
||||
/* Don't add a magicline when moving text to the cutbuffer. */
|
||||
SET(NO_NEWLINES);
|
||||
/* Don't add a magic line when moving text to the cutbuffer. */
|
||||
UNSET(FINAL_NEWLINE);
|
||||
}
|
||||
|
||||
if (cut_till_eof) {
|
||||
@@ -172,32 +337,58 @@ void do_cut_text(bool copy_text, bool marked, bool cut_till_eof, bool append)
|
||||
if (right_side_up)
|
||||
openfile->placewewant = xplustabs();
|
||||
}
|
||||
/* Restore the magicline behavior now that we're done fiddling. */
|
||||
if (!old_no_newlines)
|
||||
UNSET(NO_NEWLINES);
|
||||
/* Restore the magic-line behavior now that we're done fiddling. */
|
||||
if (using_magicline)
|
||||
SET(FINAL_NEWLINE);
|
||||
} else
|
||||
#endif /* !NANO_TINY */
|
||||
/* Only set the modification flag if actually something was cut. */
|
||||
if (openfile->totsize != was_totsize)
|
||||
set_modified();
|
||||
|
||||
set_modified();
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
/* Return FALSE when a cut command would not actually cut anything: when
|
||||
* on an empty line at EOF, or when the mark covers zero characters, or
|
||||
* (when test_cliff is TRUE) when the magic line would be cut. */
|
||||
bool is_cuttable(bool test_cliff)
|
||||
{
|
||||
if ((openfile->current->next == NULL && openfile->current->data[0] == '\0'
|
||||
#ifndef NANO_TINY
|
||||
&& openfile->mark == NULL) ||
|
||||
(openfile->mark == openfile->current &&
|
||||
openfile->mark_x == openfile->current_x) ||
|
||||
(test_cliff && openfile->current->data[openfile->current_x] == '\0' &&
|
||||
((!ISSET(FINAL_NEWLINE) && openfile->current == openfile->filebot) ||
|
||||
(ISSET(FINAL_NEWLINE) && openfile->current == openfile->filebot->prev))
|
||||
#endif
|
||||
)) {
|
||||
#ifndef NANO_TINY
|
||||
openfile->mark = NULL;
|
||||
#endif
|
||||
statusbar(_("Nothing was cut"));
|
||||
return FALSE;
|
||||
} else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Move text from the current buffer into the cutbuffer. */
|
||||
void do_cut_text_void(void)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
if (!is_cuttable(ISSET(CUT_FROM_CURSOR) && openfile->mark == NULL))
|
||||
return;
|
||||
|
||||
/* Only add a new undo item when the current item is not a CUT or when
|
||||
* the current cut is not contiguous with the previous cutting. */
|
||||
if (openfile->last_action != CUT || openfile->current_undo == NULL ||
|
||||
openfile->current_undo->mark_begin_lineno != openfile->current->lineno ||
|
||||
!keep_cutbuffer)
|
||||
add_undo(CUT);
|
||||
do_cut_text(FALSE, openfile->mark, FALSE, FALSE);
|
||||
do_cut_text(FALSE, openfile->mark != NULL, FALSE, FALSE);
|
||||
update_undo(CUT);
|
||||
#else
|
||||
do_cut_text(FALSE, FALSE, FALSE, FALSE);
|
||||
if (is_cuttable(FALSE))
|
||||
do_cut_text(FALSE, FALSE, FALSE, FALSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -207,7 +398,7 @@ void do_cut_text_void(void)
|
||||
* was moved, blow away previous contents of the cutbuffer. */
|
||||
void do_copy_text(void)
|
||||
{
|
||||
static filestruct *next_contiguous_line = NULL;
|
||||
static linestruct *next_contiguous_line = NULL;
|
||||
bool mark_is_set = (openfile->mark != NULL);
|
||||
|
||||
/* Remember the current viewport and cursor position. */
|
||||
@@ -217,7 +408,7 @@ void do_copy_text(void)
|
||||
size_t is_current_x = openfile->current_x;
|
||||
|
||||
if (mark_is_set || openfile->current != next_contiguous_line)
|
||||
cutbuffer_reset();
|
||||
keep_cutbuffer = FALSE;
|
||||
|
||||
do_cut_text(TRUE, mark_is_set, FALSE, FALSE);
|
||||
|
||||
@@ -236,6 +427,13 @@ void do_copy_text(void)
|
||||
/* Cut from the current cursor position to the end of the file. */
|
||||
void do_cut_till_eof(void)
|
||||
{
|
||||
if ((openfile->current == openfile->filebot && openfile->current->data[0] == '\0') ||
|
||||
(ISSET(FINAL_NEWLINE) && openfile->current->next == openfile->filebot &&
|
||||
openfile->current->data[openfile->current_x] == '\0')) {
|
||||
statusbar(_("Nothing was cut"));
|
||||
return;
|
||||
}
|
||||
|
||||
add_undo(CUT_TO_EOF);
|
||||
do_cut_text(FALSE, FALSE, TRUE, FALSE);
|
||||
update_undo(CUT_TO_EOF);
|
||||
@@ -245,8 +443,11 @@ void do_cut_till_eof(void)
|
||||
void zap_text(void)
|
||||
{
|
||||
/* Remember the current cutbuffer so it can be restored after the zap. */
|
||||
filestruct *was_cutbuffer = cutbuffer;
|
||||
filestruct *was_cutbottom = cutbottom;
|
||||
linestruct *was_cutbuffer = cutbuffer;
|
||||
linestruct *was_cutbottom = cutbottom;
|
||||
|
||||
if (!is_cuttable(ISSET(CUT_FROM_CURSOR) && openfile->mark == NULL))
|
||||
return;
|
||||
|
||||
/* Add a new undo item only when the current item is not a ZAP or when
|
||||
* the current zap is not contiguous with the previous zapping. */
|
||||
@@ -259,7 +460,7 @@ void zap_text(void)
|
||||
cutbuffer = openfile->current_undo->cutbuffer;
|
||||
cutbottom = openfile->current_undo->cutbottom;
|
||||
|
||||
do_cut_text(FALSE, openfile->mark, FALSE, TRUE);
|
||||
do_cut_text(FALSE, openfile->mark != NULL, FALSE, TRUE);
|
||||
|
||||
update_undo(ZAP);
|
||||
|
||||
@@ -276,9 +477,10 @@ void do_uncut_text(void)
|
||||
size_t was_leftedge = 0;
|
||||
/* The leftedge where we started the paste. */
|
||||
|
||||
/* If the cutbuffer is empty, there is nothing to do. */
|
||||
if (cutbuffer == NULL)
|
||||
if (cutbuffer == NULL) {
|
||||
statusbar(_("The cutbuffer is empty"));
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(PASTE);
|
||||
|
||||
184
src/files.c
184
src/files.c
@@ -1,8 +1,8 @@
|
||||
/**************************************************************************
|
||||
* files.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2015-2018 Benno Schulenberg *
|
||||
* Copyright (C) 1999-2011, 2013-2019 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2015-2019 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 *
|
||||
@@ -117,12 +117,12 @@ void make_new_buffer(void)
|
||||
/* Initialize the text and pointers of the current openfile struct. */
|
||||
void initialize_buffer_text(void)
|
||||
{
|
||||
openfile->fileage = make_new_node(NULL);
|
||||
openfile->fileage->data = mallocstrcpy(NULL, "");
|
||||
openfile->filetop = make_new_node(NULL);
|
||||
openfile->filetop->data = mallocstrcpy(NULL, "");
|
||||
|
||||
openfile->filebot = openfile->fileage;
|
||||
openfile->edittop = openfile->fileage;
|
||||
openfile->current = openfile->fileage;
|
||||
openfile->filebot = openfile->filetop;
|
||||
openfile->edittop = openfile->filetop;
|
||||
openfile->current = openfile->filetop;
|
||||
|
||||
openfile->firstcolumn = 0;
|
||||
openfile->current_x = 0;
|
||||
@@ -316,7 +316,7 @@ int do_lockfile(const char *filename)
|
||||
size_t readtot = 0;
|
||||
size_t readamt = 0;
|
||||
char *lockbuf, *question, *pidstring, *postedname, *promptstr;
|
||||
int room, response;
|
||||
int room, choice;
|
||||
|
||||
if ((lockfd = open(lockfilename, O_RDONLY)) < 0) {
|
||||
statusline(MILD, _("Error opening lock file %s: %s"),
|
||||
@@ -359,13 +359,13 @@ int do_lockfile(const char *filename)
|
||||
postedname = mallocstrcpy(NULL, "_");
|
||||
else if (room < strlenpt(filename)) {
|
||||
char *fragment = display_string(filename,
|
||||
strlenpt(filename) - room + 3, room, FALSE);
|
||||
strlenpt(filename) - room + 3, room, FALSE, FALSE);
|
||||
postedname = charalloc(strlen(fragment) + 4);
|
||||
strcpy(postedname, "...");
|
||||
strcat(postedname, fragment);
|
||||
free(fragment);
|
||||
} else
|
||||
postedname = display_string(filename, 0, room, FALSE);
|
||||
postedname = display_string(filename, 0, room, FALSE, FALSE);
|
||||
|
||||
/* Allow extra space for username (14), program name (8), PID (8),
|
||||
* and terminating \0 (1), minus the %s (2) for the file name. */
|
||||
@@ -374,10 +374,10 @@ int do_lockfile(const char *filename)
|
||||
free(postedname);
|
||||
free(pidstring);
|
||||
|
||||
response = do_yesno_prompt(FALSE, promptstr);
|
||||
choice = do_yesno_prompt(FALSE, promptstr);
|
||||
free(promptstr);
|
||||
|
||||
if (response < 1) {
|
||||
if (choice < 1) {
|
||||
wipe_statusbar();
|
||||
goto free_the_name;
|
||||
}
|
||||
@@ -490,7 +490,7 @@ bool open_buffer(const char *filename, bool new_buffer)
|
||||
* the filename and put the cursor at the start of the buffer. */
|
||||
if (rc != -1 && new_buffer) {
|
||||
openfile->filename = mallocstrcpy(openfile->filename, realname);
|
||||
openfile->current = openfile->fileage;
|
||||
openfile->current = openfile->filetop;
|
||||
openfile->current_x = 0;
|
||||
openfile->placewewant = 0;
|
||||
}
|
||||
@@ -512,7 +512,7 @@ void replace_buffer(const char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
int descriptor;
|
||||
filestruct *was_cutbuffer = cutbuffer;
|
||||
linestruct *was_cutbuffer = cutbuffer;
|
||||
|
||||
/* Open the file quietly. */
|
||||
descriptor = open_file(filename, FALSE, TRUE, &f);
|
||||
@@ -528,7 +528,7 @@ void replace_buffer(const char *filename)
|
||||
|
||||
/* Throw away the text of the file. */
|
||||
cutbuffer = NULL;
|
||||
openfile->current = openfile->fileage;
|
||||
openfile->current = openfile->filetop;
|
||||
openfile->current_x = 0;
|
||||
#ifndef NANO_TINY
|
||||
add_undo(CUT_TO_EOF);
|
||||
@@ -537,7 +537,7 @@ void replace_buffer(const char *filename)
|
||||
#ifndef NANO_TINY
|
||||
update_undo(CUT_TO_EOF);
|
||||
#endif
|
||||
free_filestruct(cutbuffer);
|
||||
free_lines(cutbuffer);
|
||||
cutbuffer = was_cutbuffer;
|
||||
|
||||
/* Insert the processed file into its place. */
|
||||
@@ -557,16 +557,16 @@ void replace_marked_buffer(const char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
int descriptor;
|
||||
bool old_no_newlines = ISSET(NO_NEWLINES);
|
||||
filestruct *was_cutbuffer = cutbuffer;
|
||||
bool using_magicline = ISSET(FINAL_NEWLINE);
|
||||
linestruct *was_cutbuffer = cutbuffer;
|
||||
|
||||
descriptor = open_file(filename, FALSE, TRUE, &f);
|
||||
|
||||
if (descriptor < 0)
|
||||
return;
|
||||
|
||||
/* Don't add a magicline when replacing text in the buffer. */
|
||||
SET(NO_NEWLINES);
|
||||
/* Don't add a magic line when replacing text in the buffer. */
|
||||
UNSET(FINAL_NEWLINE);
|
||||
|
||||
add_undo(COUPLE_BEGIN);
|
||||
openfile->undotop->strdata = mallocstrcpy(NULL, _("spelling correction"));
|
||||
@@ -576,15 +576,15 @@ void replace_marked_buffer(const char *filename)
|
||||
add_undo(CUT);
|
||||
do_cut_text(FALSE, TRUE, FALSE, FALSE);
|
||||
update_undo(CUT);
|
||||
free_filestruct(cutbuffer);
|
||||
free_lines(cutbuffer);
|
||||
cutbuffer = was_cutbuffer;
|
||||
|
||||
/* Insert the processed file where the marked text was. */
|
||||
read_file(f, descriptor, filename, TRUE);
|
||||
|
||||
/* Restore the magicline behavior now that we're done fiddling. */
|
||||
if (!old_no_newlines)
|
||||
UNSET(NO_NEWLINES);
|
||||
/* Restore the magic-line behavior now that we're done fiddling. */
|
||||
if (using_magicline)
|
||||
SET(FINAL_NEWLINE);
|
||||
|
||||
add_undo(COUPLE_END);
|
||||
openfile->undotop->strdata = mallocstrcpy(NULL, _("spelling correction"));
|
||||
@@ -603,7 +603,7 @@ void prepare_for_display(void)
|
||||
/* If there are multiline coloring regexes, and there is no
|
||||
* multiline cache data yet, precalculate it now. */
|
||||
if (openfile->syntax && openfile->syntax->nmultis > 0 &&
|
||||
openfile->fileage->multidata == NULL)
|
||||
openfile->filetop->multidata == NULL)
|
||||
precalc_multicolorinfo();
|
||||
|
||||
have_palette = FALSE;
|
||||
@@ -661,6 +661,9 @@ void switch_to_adjacent_buffer(bool to_next)
|
||||
/* Ensure that the main loop will redraw the help lines. */
|
||||
currmenu = MMOST;
|
||||
|
||||
/* Prevent a possible Shift selection from getting cancelled. */
|
||||
shift_held = TRUE;
|
||||
|
||||
/* Indicate on the status bar where we switched to. */
|
||||
mention_name_and_linecount();
|
||||
}
|
||||
@@ -678,11 +681,9 @@ void switch_to_next_buffer(void)
|
||||
}
|
||||
|
||||
/* Delete an entry from the circular list of open files, and switch to the
|
||||
* one after it. Return TRUE on success, and FALSE if there are no other
|
||||
* open buffers. */
|
||||
* one after it. Return FALSE if just one buffer is open, otherwise TRUE. */
|
||||
bool close_buffer(void)
|
||||
{
|
||||
/* If only one file buffer is open, get out. */
|
||||
if (openfile == openfile->next)
|
||||
return FALSE;
|
||||
|
||||
@@ -692,8 +693,7 @@ bool close_buffer(void)
|
||||
openfile->current->lineno, xplustabs() + 1);
|
||||
#endif
|
||||
|
||||
/* Switch to the next file buffer. */
|
||||
switch_to_adjacent_buffer(TRUE);
|
||||
switch_to_next_buffer();
|
||||
|
||||
/* Delete the old file buffer, and adjust the count in the top bar. */
|
||||
unlink_opennode(openfile->prev);
|
||||
@@ -772,9 +772,9 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||
/* The buffer in which we assemble each line of the file. */
|
||||
size_t bufx = MAX_BUF_SIZE;
|
||||
/* The allocated size of the line buffer; increased as needed. */
|
||||
filestruct *topline;
|
||||
linestruct *topline;
|
||||
/* The top of the new buffer where we store the read file. */
|
||||
filestruct *bottomline;
|
||||
linestruct *bottomline;
|
||||
/* The bottom of the new buffer. */
|
||||
int input_int;
|
||||
/* The current value we read from the file, whether an input
|
||||
@@ -1201,7 +1201,7 @@ void do_insertfile(void)
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* If this is a new buffer, put the cursor at the top. */
|
||||
if (ISSET(MULTIBUFFER)) {
|
||||
openfile->current = openfile->fileage;
|
||||
openfile->current = openfile->filetop;
|
||||
openfile->current_x = 0;
|
||||
openfile->placewewant = 0;
|
||||
|
||||
@@ -1415,63 +1415,59 @@ char *check_writable_directory(const char *path)
|
||||
}
|
||||
|
||||
/* This function calls mkstemp(($TMPDIR|P_tmpdir|/tmp/)"nano.XXXXXX").
|
||||
* On success, it returns the malloc()ed filename and corresponding FILE
|
||||
* stream, opened in "r+b" mode. On error, it returns NULL for the
|
||||
* filename and leaves the FILE stream unchanged. */
|
||||
* On success, it returns the malloc()ed filename and corresponding
|
||||
* FILE stream, opened in "r+b" mode. On error, it returns NULL for
|
||||
* the filename and leaves the FILE stream unchanged. */
|
||||
char *safe_tempfile(FILE **f)
|
||||
{
|
||||
char *full_tempdir = NULL;
|
||||
const char *tmpdir_env;
|
||||
int fd;
|
||||
const char *tmpdir_env = getenv("TMPDIR");
|
||||
char *full_tempdir = NULL, *tempfile_name = NULL;
|
||||
mode_t original_umask = 0;
|
||||
int fd;
|
||||
|
||||
/* If $TMPDIR is set, set tempdir to it, run it through
|
||||
* get_full_path(), and save the result in full_tempdir. Otherwise,
|
||||
* leave full_tempdir set to NULL. */
|
||||
tmpdir_env = getenv("TMPDIR");
|
||||
/* Get the absolute path for the first directory among $TMPDIR
|
||||
* and P_tmpdir that is writable, otherwise use /tmp/. */
|
||||
if (tmpdir_env != NULL)
|
||||
full_tempdir = check_writable_directory(tmpdir_env);
|
||||
|
||||
/* If $TMPDIR is unset, empty, or not a writable directory, and
|
||||
* full_tempdir is NULL, try P_tmpdir instead. */
|
||||
if (full_tempdir == NULL)
|
||||
full_tempdir = check_writable_directory(P_tmpdir);
|
||||
|
||||
/* if P_tmpdir is NULL, use /tmp. */
|
||||
if (full_tempdir == NULL)
|
||||
full_tempdir = mallocstrcpy(NULL, "/tmp/");
|
||||
|
||||
full_tempdir = charealloc(full_tempdir, strlen(full_tempdir) + 12);
|
||||
strcat(full_tempdir, "nano.XXXXXX");
|
||||
tempfile_name = charealloc(full_tempdir, strlen(full_tempdir) + 12);
|
||||
strcat(tempfile_name, "nano.XXXXXX");
|
||||
|
||||
original_umask = umask(0);
|
||||
umask(S_IRWXG | S_IRWXO);
|
||||
|
||||
fd = mkstemp(full_tempdir);
|
||||
fd = mkstemp(tempfile_name);
|
||||
|
||||
if (fd != -1)
|
||||
*f = fdopen(fd, "r+b");
|
||||
else {
|
||||
free(full_tempdir);
|
||||
full_tempdir = NULL;
|
||||
free(tempfile_name);
|
||||
tempfile_name = NULL;
|
||||
}
|
||||
|
||||
umask(original_umask);
|
||||
|
||||
return full_tempdir;
|
||||
return tempfile_name;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_OPERATINGDIR
|
||||
/* Change to the specified operating directory, when it's valid. */
|
||||
void init_operating_dir(void)
|
||||
{
|
||||
operating_dir = free_and_assign(operating_dir, get_full_path(operating_dir));
|
||||
char *target = get_full_path(operating_dir);
|
||||
|
||||
/* If the operating directory is inaccessible, fail. */
|
||||
if (operating_dir == NULL || chdir(operating_dir) == -1)
|
||||
die(_("Invalid operating directory\n"));
|
||||
if (target == NULL || chdir(target) == -1)
|
||||
die(_("Invalid operating directory: %s\n"), operating_dir);
|
||||
|
||||
snuggly_fit(&operating_dir);
|
||||
free(operating_dir);
|
||||
operating_dir = charealloc(target, strlen(target) + 1);
|
||||
}
|
||||
|
||||
/* Check whether the given path is outside of the operating directory.
|
||||
@@ -1513,31 +1509,32 @@ bool outside_of_confinement(const char *currpath, bool allow_tabcomp)
|
||||
* messed up and I'm blanket allowing insecure file writing operations'. */
|
||||
int prompt_failed_backupwrite(const char *filename)
|
||||
{
|
||||
static int response;
|
||||
static int choice;
|
||||
static char *prevfile = NULL;
|
||||
/* The last file we were passed, so we don't keep asking this.
|
||||
* Though maybe we should? */
|
||||
/* The last filename we were passed, so we don't keep asking this. */
|
||||
|
||||
if (prevfile == NULL || strcmp(filename, prevfile)) {
|
||||
response = do_yesno_prompt(FALSE, _("Failed to write backup file; "
|
||||
choice = do_yesno_prompt(FALSE, _("Failed to write backup file; "
|
||||
"continue saving? (Say N if unsure.) "));
|
||||
prevfile = mallocstrcpy(prevfile, filename);
|
||||
}
|
||||
|
||||
return response;
|
||||
return choice;
|
||||
}
|
||||
|
||||
/* Transform the specified backup directory to an absolute path,
|
||||
* and verify that it is usable. */
|
||||
void init_backup_dir(void)
|
||||
{
|
||||
backup_dir = free_and_assign(backup_dir, get_full_path(backup_dir));
|
||||
char *target = get_full_path(backup_dir);
|
||||
|
||||
/* If we can't get an absolute path (which means it doesn't exist or
|
||||
* isn't accessible), or it's not a directory, fail. */
|
||||
if (backup_dir == NULL || backup_dir[strlen(backup_dir) - 1] != '/')
|
||||
die(_("Invalid backup directory\n"));
|
||||
if (target == NULL || target[strlen(target) - 1] != '/')
|
||||
die(_("Invalid backup directory: %s\n"), backup_dir);
|
||||
|
||||
snuggly_fit(&backup_dir);
|
||||
free(backup_dir);
|
||||
backup_dir = charealloc(target, strlen(target) + 1);
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
@@ -1596,7 +1593,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
||||
/* Instead of returning in this function, you should always
|
||||
* set retval and then goto cleanup_and_exit. */
|
||||
size_t lineswritten = 0;
|
||||
const filestruct *fileptr = openfile->fileage;
|
||||
const linestruct *fileptr = openfile->filetop;
|
||||
int fd;
|
||||
/* The file descriptor we use. */
|
||||
mode_t original_umask = 0;
|
||||
@@ -2002,7 +1999,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
||||
|
||||
/* If the syntax changed, discard and recompute the multidata. */
|
||||
if (strcmp(oldname, newname) != 0) {
|
||||
filestruct *line = openfile->fileage;
|
||||
linestruct *line = openfile->filetop;
|
||||
|
||||
while (line != NULL) {
|
||||
free(line->multidata);
|
||||
@@ -2047,30 +2044,28 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
|
||||
{
|
||||
bool retval;
|
||||
bool added_magicline = FALSE;
|
||||
/* Whether we added a magicline after filebot. */
|
||||
filestruct *top, *bot;
|
||||
linestruct *top, *bot;
|
||||
size_t top_x, bot_x;
|
||||
|
||||
/* Partition the buffer so that it contains only the marked text. */
|
||||
mark_order((const filestruct **)&top, &top_x,
|
||||
(const filestruct **)&bot, &bot_x, NULL);
|
||||
filepart = partition_filestruct(top, top_x, bot, bot_x);
|
||||
mark_order((const linestruct **)&top, &top_x,
|
||||
(const linestruct **)&bot, &bot_x, NULL);
|
||||
filepart = partition_buffer(top, top_x, bot, bot_x);
|
||||
|
||||
/* If we are doing magicline, and the last line of the partition
|
||||
/* If we are using a magic line, and the last line of the partition
|
||||
* isn't blank, then add a newline at the end of the buffer. */
|
||||
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0') {
|
||||
if (ISSET(FINAL_NEWLINE) && openfile->filebot->data[0] != '\0') {
|
||||
new_magicline();
|
||||
added_magicline = TRUE;
|
||||
}
|
||||
|
||||
retval = write_file(name, f_open, tmp, method, FALSE);
|
||||
|
||||
/* If we added a magicline, remove it now. */
|
||||
if (added_magicline)
|
||||
remove_magicline();
|
||||
|
||||
/* Unpartition the buffer so that it contains all the text again. */
|
||||
unpartition_filestruct(&filepart);
|
||||
unpartition_buffer(&filepart);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -2106,7 +2101,7 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
|
||||
while (TRUE) {
|
||||
const char *msg;
|
||||
int i = 0;
|
||||
int response, choice;
|
||||
functionptrtype func;
|
||||
#ifndef NANO_TINY
|
||||
const char *formatstr, *backupstr;
|
||||
@@ -2139,7 +2134,7 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
else {
|
||||
/* Ask for (confirmation of) the filename. Disable tab completion
|
||||
* when using restricted mode and the filename isn't blank. */
|
||||
i = do_prompt(!ISSET(RESTRICTED) || openfile->filename[0] == '\0',
|
||||
response = do_prompt(!ISSET(RESTRICTED) || openfile->filename[0] == '\0',
|
||||
TRUE, MWRITEFILE, given, NULL,
|
||||
edit_refresh, "%s%s%s", msg,
|
||||
#ifndef NANO_TINY
|
||||
@@ -2150,12 +2145,12 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
);
|
||||
}
|
||||
|
||||
if (i < 0) {
|
||||
if (response < 0) {
|
||||
statusbar(_("Cancelled"));
|
||||
break;
|
||||
}
|
||||
|
||||
func = func_from_key(&i);
|
||||
func = func_from_key(&response);
|
||||
|
||||
/* Upon request, abandon the buffer. */
|
||||
if (func == discard_buffer) {
|
||||
@@ -2261,18 +2256,18 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
if (name_exists) {
|
||||
char *question = _("File \"%s\" exists; OVERWRITE? ");
|
||||
char *name = display_string(answer, 0,
|
||||
COLS - strlenpt(question) + 1, FALSE);
|
||||
COLS - strlenpt(question) + 1, FALSE, FALSE);
|
||||
char *message = charalloc(strlen(question) +
|
||||
strlen(name) + 1);
|
||||
|
||||
sprintf(message, question, name);
|
||||
|
||||
i = do_yesno_prompt(FALSE, message);
|
||||
choice = do_yesno_prompt(FALSE, message);
|
||||
|
||||
free(message);
|
||||
free(name);
|
||||
|
||||
if (i < 1)
|
||||
if (choice < 1)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -2284,11 +2279,10 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
(openfile->current_stat->st_mtime < st.st_mtime ||
|
||||
openfile->current_stat->st_dev != st.st_dev ||
|
||||
openfile->current_stat->st_ino != st.st_ino)) {
|
||||
int response;
|
||||
|
||||
warn_and_shortly_pause(_("File on disk has changed"));
|
||||
|
||||
response = do_yesno_prompt(FALSE, _("File was modified "
|
||||
choice = do_yesno_prompt(FALSE, _("File was modified "
|
||||
"since you opened it; continue saving? "));
|
||||
wipe_statusbar();
|
||||
|
||||
@@ -2296,14 +2290,14 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
* overwrite the file right here when requested. */
|
||||
if (ISSET(TEMP_FILE) && withprompt) {
|
||||
free(given);
|
||||
if (response == 1)
|
||||
if (choice == 1)
|
||||
return write_file(openfile->filename, NULL,
|
||||
FALSE, OVERWRITE, TRUE);
|
||||
else if (response == 0)
|
||||
else if (choice == 0)
|
||||
return 2;
|
||||
else
|
||||
return 0;
|
||||
} else if (response != 1) {
|
||||
} else if (choice != 1) {
|
||||
free(given);
|
||||
return 1;
|
||||
}
|
||||
@@ -2417,18 +2411,16 @@ int diralphasort(const void *va, const void *vb)
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_TABCOMP
|
||||
/* Is the given path a directory? */
|
||||
bool is_dir(const char *buf)
|
||||
/* Return TRUE when the given path is a directory. */
|
||||
bool is_dir(const char *path)
|
||||
{
|
||||
char *dirptr;
|
||||
char *realpath = real_dir_from_tilde(path);
|
||||
struct stat fileinfo;
|
||||
bool retval;
|
||||
|
||||
dirptr = real_dir_from_tilde(buf);
|
||||
retval = (stat(realpath, &fileinfo) != -1 && S_ISDIR(fileinfo.st_mode));
|
||||
|
||||
retval = (stat(dirptr, &fileinfo) != -1 && S_ISDIR(fileinfo.st_mode));
|
||||
|
||||
free(dirptr);
|
||||
free(realpath);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -2712,7 +2704,7 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
|
||||
break;
|
||||
}
|
||||
|
||||
disp = display_string(matches[match], 0, longest_name, FALSE);
|
||||
disp = display_string(matches[match], 0, longest_name, FALSE, FALSE);
|
||||
waddstr(edit, disp);
|
||||
free(disp);
|
||||
|
||||
|
||||
231
src/global.c
231
src/global.c
@@ -1,8 +1,8 @@
|
||||
/**************************************************************************
|
||||
* global.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2018 Benno Schulenberg *
|
||||
* Copyright (C) 1999-2011, 2013-2019 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2019 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 *
|
||||
@@ -52,7 +52,7 @@ bool suppress_cursorpos = FALSE;
|
||||
message_type lastmessage = HUSH;
|
||||
/* Messages of type HUSH should not overwrite type MILD nor ALERT. */
|
||||
|
||||
filestruct *pletion_line = NULL;
|
||||
linestruct *pletion_line = NULL;
|
||||
/* The line where the last completion was found, if any. */
|
||||
|
||||
bool inhelp = FALSE;
|
||||
@@ -81,10 +81,10 @@ int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
ssize_t wrap_at = -COLUMNS_FROM_EOL;
|
||||
ssize_t fill = -COLUMNS_FROM_EOL;
|
||||
/* The relative column where we will wrap lines. */
|
||||
ssize_t fill = 0;
|
||||
/* The actual column where we will wrap lines, based on wrap_at. */
|
||||
ssize_t wrap_at = 0;
|
||||
/* The actual column where we will wrap lines, based on fill. */
|
||||
#endif
|
||||
|
||||
char *last_search = NULL;
|
||||
@@ -111,11 +111,18 @@ int editwincols = -1;
|
||||
/* The number of usable columns in the edit window: COLS - margin. */
|
||||
int margin = 0;
|
||||
/* The amount of space reserved at the left for line numbers. */
|
||||
#ifndef NANO_TINY
|
||||
ssize_t stripe_column = 0;
|
||||
/* The column at which a vertical bar will be drawn. */
|
||||
#endif
|
||||
|
||||
filestruct *cutbuffer = NULL;
|
||||
linestruct *cutbuffer = NULL;
|
||||
/* The buffer where we store cut text. */
|
||||
filestruct *cutbottom = NULL;
|
||||
linestruct *cutbottom = NULL;
|
||||
/* The last line in the cutbuffer. */
|
||||
bool keep_cutbuffer = FALSE;
|
||||
/* Whether to add to the cutbuffer instead of clearing it first. */
|
||||
|
||||
partition *filepart = NULL;
|
||||
/* The "partition" where we store a portion of the current file. */
|
||||
openfilestruct *openfile = NULL;
|
||||
@@ -128,7 +135,7 @@ char *matchbrackets = NULL;
|
||||
/* The opening and closing brackets that bracket searches can find. */
|
||||
char *whitespace = NULL;
|
||||
/* The characters used when visibly showing tabs and spaces. */
|
||||
int whitespace_len[2];
|
||||
int whitelen[2];
|
||||
/* The length in bytes of these characters. */
|
||||
#endif
|
||||
|
||||
@@ -142,10 +149,6 @@ char *quotestr = NULL;
|
||||
/* The quoting string. The default value is set in main(). */
|
||||
regex_t quotereg;
|
||||
/* The compiled regular expression from the quoting string. */
|
||||
int quoterc;
|
||||
/* Whether it was compiled successfully. */
|
||||
char *quoteerr = NULL;
|
||||
/* The error message, if it didn't. */
|
||||
#endif
|
||||
|
||||
char *word_chars = NULL;
|
||||
@@ -199,29 +202,24 @@ subnfunc *tailfunc;
|
||||
/* The last function in the list. */
|
||||
subnfunc *exitfunc;
|
||||
/* A pointer to the special Exit/Close item. */
|
||||
subnfunc *uncutfunc;
|
||||
/* A pointer to the special Uncut/Unjustify item. */
|
||||
|
||||
filestruct *search_history = NULL;
|
||||
linestruct *search_history = NULL;
|
||||
/* The current item in the list of strings that were searched for. */
|
||||
filestruct *execute_history = NULL;
|
||||
linestruct *execute_history = NULL;
|
||||
/* The current item in the list of commands that were run with ^R ^X. */
|
||||
filestruct *replace_history = NULL;
|
||||
linestruct *replace_history = NULL;
|
||||
/* The current item in the list of replace strings. */
|
||||
#ifdef ENABLE_HISTORIES
|
||||
filestruct *searchtop = NULL;
|
||||
linestruct *searchtop = NULL;
|
||||
/* The oldest item in the list of search strings. */
|
||||
filestruct *searchbot = NULL;
|
||||
linestruct *searchbot = NULL;
|
||||
/* The newest item in the list of search strings. */
|
||||
|
||||
filestruct *replacetop = NULL;
|
||||
filestruct *replacebot = NULL;
|
||||
linestruct *replacetop = NULL;
|
||||
linestruct *replacebot = NULL;
|
||||
|
||||
filestruct *executetop = NULL;
|
||||
filestruct *executebot = NULL;
|
||||
|
||||
poshiststruct *position_history = NULL;
|
||||
/* The list of filenames with their last cursor positions. */
|
||||
linestruct *executetop = NULL;
|
||||
linestruct *executebot = NULL;
|
||||
#endif
|
||||
|
||||
regex_t search_regexp;
|
||||
@@ -520,14 +518,10 @@ void print_sclist(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* These four tags are used elsewhere too, so they are global. */
|
||||
/* TRANSLATORS: Try to keep the next four strings at most 10 characters. */
|
||||
/* These two tags are used elsewhere too, so they are global. */
|
||||
/* TRANSLATORS: Try to keep the next two strings at most 10 characters. */
|
||||
const char *exit_tag = N_("Exit");
|
||||
const char *close_tag = N_("Close");
|
||||
const char *uncut_tag = N_("Uncut Text");
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
const char *unjust_tag = N_("Unjustify");
|
||||
#endif
|
||||
|
||||
/* Initialize the list of functions and the list of shortcuts. */
|
||||
void shortcut_init(void)
|
||||
@@ -563,7 +557,7 @@ void shortcut_init(void)
|
||||
const char *cut_gist =
|
||||
N_("Cut current line (or marked region) and store it in cutbuffer");
|
||||
const char *uncut_gist =
|
||||
N_("Uncut from the cutbuffer into the current line");
|
||||
N_("Paste the contents of cutbuffer at current cursor position");
|
||||
const char *cursorpos_gist = N_("Display the position of the cursor");
|
||||
#ifdef ENABLE_SPELLER
|
||||
const char *spell_gist = N_("Invoke the spell checker, if available");
|
||||
@@ -618,10 +612,10 @@ void shortcut_init(void)
|
||||
const char *backspace_gist =
|
||||
N_("Delete the character to the left of the cursor");
|
||||
#ifndef NANO_TINY
|
||||
const char *cutwordleft_gist =
|
||||
N_("Cut backward from cursor to word start");
|
||||
const char *cutwordright_gist =
|
||||
N_("Cut forward from cursor to next word start");
|
||||
const char *chopwordleft_gist =
|
||||
N_("Delete backward from cursor to word start");
|
||||
const char *chopwordright_gist =
|
||||
N_("Delete forward from cursor to next word start");
|
||||
const char *cuttilleof_gist =
|
||||
N_("Cut from the cursor position to the end of the file");
|
||||
#endif
|
||||
@@ -702,12 +696,12 @@ void shortcut_init(void)
|
||||
|
||||
/* Start populating the different menus with functions. */
|
||||
|
||||
add_to_funcs(do_help_void, MMOST & ~MFINDINHELP,
|
||||
add_to_funcs(do_help_void, (MMOST | MBROWSER) & ~MFINDINHELP,
|
||||
/* TRANSLATORS: Try to keep the next ninety strings or so at most 10
|
||||
* characters. Some strings may be longer -- run nano and see. */
|
||||
N_("Get Help"), WITHORSANS(help_gist), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(do_cancel, ((MMOST & ~MMAIN & ~MBROWSER) | MYESNO),
|
||||
add_to_funcs(do_cancel, ((MMOST & ~MMAIN) | MYESNO),
|
||||
N_("Cancel"), WITHORSANS(cancel_gist), BLANKAFTER, VIEW);
|
||||
|
||||
add_to_funcs(do_exit, MMAIN,
|
||||
@@ -717,7 +711,7 @@ void shortcut_init(void)
|
||||
|
||||
#ifdef ENABLE_BROWSER
|
||||
add_to_funcs(do_exit, MBROWSER,
|
||||
exit_tag, WITHORSANS(exitbrowser_gist), TOGETHER, VIEW);
|
||||
close_tag, WITHORSANS(exitbrowser_gist), TOGETHER, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(do_writeout_void, MMAIN,
|
||||
@@ -767,9 +761,7 @@ void shortcut_init(void)
|
||||
N_("Cut Text"), WITHORSANS(cut_gist), TOGETHER, NOVIEW);
|
||||
|
||||
add_to_funcs(do_uncut_text, MMAIN,
|
||||
uncut_tag, WITHORSANS(uncut_gist), BLANKAFTER, NOVIEW);
|
||||
/* Remember the entry for Uncut, to be able to replace it with Unjustify. */
|
||||
uncutfunc = tailfunc;
|
||||
N_("Paste Text"), WITHORSANS(uncut_gist), BLANKAFTER, NOVIEW);
|
||||
|
||||
if (!ISSET(RESTRICTED)) {
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
@@ -824,21 +816,18 @@ void shortcut_init(void)
|
||||
add_to_funcs(get_history_newer_void, MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE,
|
||||
N_("Newer"), WITHORSANS(newer_gist), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
add_to_funcs(do_full_justify, MWHEREIS,
|
||||
N_("FullJstify"), WITHORSANS(fulljustify_gist), TOGETHER, NOVIEW);
|
||||
|
||||
add_to_funcs(flip_goto, MWHEREIS,
|
||||
N_("Go To Line"), WITHORSANS(gotoline_gist), BLANKAFTER, VIEW);
|
||||
N_("Go To Line"), WITHORSANS(gotoline_gist), TOGETHER, VIEW);
|
||||
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
add_to_funcs(do_full_justify, MWHEREIS,
|
||||
N_("FullJstify"), WITHORSANS(fulljustify_gist), BLANKAFTER, NOVIEW);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(do_find_bracket, MMAIN,
|
||||
N_("To Bracket"), WITHORSANS(bracket_gist), BLANKAFTER, VIEW);
|
||||
#else
|
||||
/* Place this one here only in the tiny version; otherwise further down. */
|
||||
add_to_funcs(do_savefile, MMAIN,
|
||||
N_("Save"), WITHORSANS(savefile_gist), BLANKAFTER, NOVIEW);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_BROWSER
|
||||
@@ -847,14 +836,28 @@ void shortcut_init(void)
|
||||
add_to_funcs(do_search_backward, MBROWSER,
|
||||
N_("Where Was"), WITHORSANS(browserwherewas_gist), TOGETHER, VIEW);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(do_search_backward, MMAIN|MHELP,
|
||||
/* TRANSLATORS: This starts a backward search. */
|
||||
N_("Where Was"), WITHORSANS(wherewas_gist), TOGETHER, VIEW);
|
||||
#endif
|
||||
add_to_funcs(do_findprevious, MMAIN|MHELP|MBROWSER,
|
||||
/* TRANSLATORS: This refers to searching the preceding occurrence. */
|
||||
N_("Previous"), WITHORSANS(findprev_gist), TOGETHER, VIEW);
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(do_findnext, MMAIN|MHELP|MBROWSER,
|
||||
N_("Next"), WITHORSANS(findnext_gist), BLANKAFTER, VIEW);
|
||||
#else
|
||||
/* In the tiny version, arrange things a bit differently, so that
|
||||
* the useful M-W and M-Q are shown in the help lines. */
|
||||
add_to_funcs(do_findnext, MMAIN|MHELP|MBROWSER,
|
||||
N_("Next"), WITHORSANS(findnext_gist), TOGETHER, VIEW);
|
||||
add_to_funcs(do_search_backward, MMAIN|MHELP,
|
||||
N_("Where Was"), WITHORSANS(wherewas_gist), BLANKAFTER, VIEW);
|
||||
add_to_funcs(total_refresh, MMAIN,
|
||||
N_("Refresh"), WITHORSANS(refresh_gist), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(do_left, MMAIN,
|
||||
/* TRANSLATORS: This means move the cursor one character back. */
|
||||
@@ -894,9 +897,9 @@ void shortcut_init(void)
|
||||
add_to_funcs(do_next_block, MMAIN,
|
||||
N_("Next Block"), WITHORSANS(nextblock_gist), TOGETHER, VIEW);
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
add_to_funcs(do_para_begin_void, MMAIN|MWHEREIS,
|
||||
add_to_funcs(do_para_begin_void, MMAIN|MGOTOLINE,
|
||||
N_("Beg of Par"), WITHORSANS(parabegin_gist), TOGETHER, VIEW);
|
||||
add_to_funcs(do_para_end_void, MMAIN|MWHEREIS,
|
||||
add_to_funcs(do_para_end_void, MMAIN|MGOTOLINE,
|
||||
N_("End of Par"), WITHORSANS(paraend_gist), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
@@ -905,9 +908,9 @@ void shortcut_init(void)
|
||||
add_to_funcs(do_page_down, MMAIN|MHELP,
|
||||
N_("Next Page"), WITHORSANS(nextpage_gist), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(to_first_line, MMAIN|MHELP|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE,
|
||||
add_to_funcs(to_first_line, MMAIN|MHELP|MGOTOLINE,
|
||||
N_("First Line"), WITHORSANS(firstline_gist), TOGETHER, VIEW);
|
||||
add_to_funcs(to_last_line, MMAIN|MHELP|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE,
|
||||
add_to_funcs(to_last_line, MMAIN|MHELP|MGOTOLINE,
|
||||
N_("Last Line"), WITHORSANS(lastline_gist), BLANKAFTER, VIEW);
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
@@ -940,11 +943,11 @@ void shortcut_init(void)
|
||||
NOVIEW);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(do_cut_prev_word, MMAIN,
|
||||
/* TRANSLATORS: The next two strings refer to cutting words. */
|
||||
N_("Cut Left"), WITHORSANS(cutwordleft_gist), TOGETHER, NOVIEW);
|
||||
add_to_funcs(do_cut_next_word, MMAIN,
|
||||
N_("Cut Right"), WITHORSANS(cutwordright_gist), TOGETHER, NOVIEW);
|
||||
add_to_funcs(chop_previous_word, MMAIN,
|
||||
/* TRANSLATORS: The next two strings refer to deleting words. */
|
||||
N_("Chop Left"), WITHORSANS(chopwordleft_gist), TOGETHER, NOVIEW);
|
||||
add_to_funcs(chop_next_word, MMAIN,
|
||||
N_("Chop Right"), WITHORSANS(chopwordright_gist), TOGETHER, NOVIEW);
|
||||
add_to_funcs(do_cut_till_eof, MMAIN,
|
||||
N_("CutTillEnd"), WITHORSANS(cuttilleof_gist), BLANKAFTER, NOVIEW);
|
||||
#endif
|
||||
@@ -962,8 +965,10 @@ void shortcut_init(void)
|
||||
add_to_funcs(do_verbatim_input, MMAIN,
|
||||
N_("Verbatim"), WITHORSANS(verbatim_gist), BLANKAFTER, NOVIEW);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(total_refresh, MMAIN,
|
||||
N_("Refresh"), WITHORSANS(refresh_gist), TOGETHER, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(do_suspend_void, MMAIN,
|
||||
N_("Suspend"), WITHORSANS(suspend_gist), BLANKAFTER, VIEW);
|
||||
@@ -995,15 +1000,10 @@ void shortcut_init(void)
|
||||
if (!ISSET(RESTRICTED))
|
||||
add_to_funcs(do_linter, MMAIN,
|
||||
N_("To Linter"), WITHORSANS(lint_gist), BLANKAFTER, NOVIEW);
|
||||
#endif
|
||||
#endif
|
||||
add_to_funcs(do_savefile, MMAIN,
|
||||
N_("Save"), WITHORSANS(savefile_gist), BLANKAFTER, NOVIEW);
|
||||
#endif
|
||||
|
||||
#ifndef ENABLE_JUSTIFY
|
||||
add_to_funcs(flip_goto, MWHEREIS,
|
||||
N_("Go To Line"), WITHORSANS(gotoline_gist), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(flip_goto, MGOTOLINE,
|
||||
N_("Go To Text"), WITHORSANS(whereis_gist), BLANKAFTER, VIEW);
|
||||
@@ -1091,25 +1091,22 @@ void shortcut_init(void)
|
||||
/* Link key combos to functions in certain menus. */
|
||||
add_to_sclist(MMOST|MBROWSER, "^M", 0, do_enter, 0);
|
||||
add_to_sclist(MMOST|MBROWSER, "Enter", KEY_ENTER, do_enter, 0);
|
||||
add_to_sclist(MMOST, "^H", 0, do_backspace, 0);
|
||||
add_to_sclist(MMOST, "^H", BS_CODE, do_backspace, 0);
|
||||
add_to_sclist(MMOST, "Bsp", KEY_BACKSPACE, do_backspace, 0);
|
||||
add_to_sclist(MMOST, "Sh-Del", SHIFT_DELETE, do_backspace, 0);
|
||||
add_to_sclist(MMOST, "^D", 0, do_delete, 0);
|
||||
add_to_sclist(MMOST, "Del", 0, do_delete, 0);
|
||||
/* Make ASCII DEL do a delete when requested, otherwise a backspace. */
|
||||
if (ISSET(REBIND_DELETE))
|
||||
add_to_sclist(MMOST, "Del", DEL_CODE, do_delete, 0);
|
||||
else
|
||||
add_to_sclist(MMOST & ~MBROWSER, "Bsp", DEL_CODE, do_backspace, 0);
|
||||
add_to_sclist(MMOST, "^I", 0, do_tab, 0);
|
||||
add_to_sclist(MMOST, "Tab", TAB_CODE, do_tab, 0);
|
||||
add_to_sclist((MMOST|MBROWSER) & ~MFINDINHELP, "^G", 0, do_help_void, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "^X", 0, do_exit, 0);
|
||||
add_to_sclist(MMAIN, "^S", 0, do_savefile, 0);
|
||||
if (!ISSET(PRESERVE))
|
||||
add_to_sclist(MMAIN, "^S", 0, do_savefile, 0);
|
||||
add_to_sclist(MMAIN, "^O", 0, do_writeout_void, 0);
|
||||
add_to_sclist(MMAIN, "^R", 0, do_insertfile_void, 0);
|
||||
add_to_sclist(MMAIN, "Ins", 0, do_insertfile_void, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "^Q", 0, do_search_backward, 0);
|
||||
if (!ISSET(PRESERVE))
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "^Q", 0, do_search_backward, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "^W", 0, do_search_forward, 0);
|
||||
add_to_sclist(MMAIN, "^\\", 0, do_replace, 0);
|
||||
add_to_sclist(MMAIN, "M-R", 0, do_replace, 0);
|
||||
@@ -1155,8 +1152,8 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN, "M-;", 0, run_macro, 0);
|
||||
add_to_sclist(MMAIN, "M-U", 0, do_undo, 0);
|
||||
add_to_sclist(MMAIN, "M-E", 0, do_redo, 0);
|
||||
add_to_sclist(MMAIN, "Sh-^Del", CONTROL_SHIFT_DELETE, do_cut_prev_word, 0);
|
||||
add_to_sclist(MMAIN, "^Del", CONTROL_DELETE, do_cut_next_word, 0);
|
||||
add_to_sclist(MMAIN, "Sh-^Del", CONTROL_SHIFT_DELETE, chop_previous_word, 0);
|
||||
add_to_sclist(MMAIN, "^Del", CONTROL_DELETE, chop_next_word, 0);
|
||||
add_to_sclist(MMAIN, "M-Del", ALT_DELETE, zap_text, 0);
|
||||
#endif
|
||||
#ifdef ENABLE_WORDCOMPLETION
|
||||
@@ -1178,8 +1175,6 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN, "M-\xE2\x97\x80", ALT_LEFT, switch_to_prev_buffer, 0);
|
||||
add_to_sclist(MMAIN, "M-\xE2\x96\xb6", ALT_RIGHT, switch_to_next_buffer, 0);
|
||||
#endif
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "M-\xE2\x96\xb2", ALT_UP, do_findprevious, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "M-\xE2\x96\xbc", ALT_DOWN, do_findnext, 0);
|
||||
#endif
|
||||
} else
|
||||
#endif
|
||||
@@ -1189,6 +1184,12 @@ void shortcut_init(void)
|
||||
add_to_sclist(MSOME, "^Left", CONTROL_LEFT, do_prev_word_void, 0);
|
||||
add_to_sclist(MSOME, "^Right", CONTROL_RIGHT, do_next_word_void, 0);
|
||||
}
|
||||
#ifdef NANO_TINY
|
||||
add_to_sclist(MMAIN, "M-B", 0, do_prev_word_void, 0);
|
||||
add_to_sclist(MMAIN, "M-D", 0, do_prev_word_void, 0);
|
||||
add_to_sclist(MMAIN, "M-F", 0, do_next_word_void, 0);
|
||||
add_to_sclist(MMAIN, "M-N", 0, do_next_word_void, 0);
|
||||
#endif
|
||||
add_to_sclist(MMOST|MBROWSER, "M-Space", 0, do_prev_word_void, 0);
|
||||
add_to_sclist(MMOST|MBROWSER, "^Space", 0, do_next_word_void, 0);
|
||||
add_to_sclist(MMOST, "^A", 0, do_home, 0);
|
||||
@@ -1219,11 +1220,17 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN, "M-)", 0, do_para_end_void, 0);
|
||||
add_to_sclist(MMAIN, "M-0", 0, do_para_end_void, 0);
|
||||
#endif
|
||||
#if !defined(NANO_TINY) && defined(ENABLE_UTF8)
|
||||
if (using_utf8()) {
|
||||
add_to_sclist(MMAIN|MHELP, "M-\xE2\x96\xb2", ALT_UP, do_scroll_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-\xE2\x96\xbc", ALT_DOWN, do_scroll_down, 0);
|
||||
}
|
||||
#endif
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
|
||||
add_to_sclist(MMAIN, "M--", 0, do_scroll_up, 0);
|
||||
add_to_sclist(MMAIN, "M-_", 0, do_scroll_up, 0);
|
||||
add_to_sclist(MMAIN, "M-+", 0, do_scroll_down, 0);
|
||||
add_to_sclist(MMAIN, "M-=", 0, do_scroll_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M--", 0, do_scroll_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-_", 0, do_scroll_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-+", 0, do_scroll_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-=", 0, do_scroll_down, 0);
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
add_to_sclist(MMAIN, "M-<", 0, switch_to_prev_buffer, 0);
|
||||
@@ -1239,14 +1246,17 @@ void shortcut_init(void)
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
add_to_sclist(MMAIN|MWHEREIS, "M-J", 0, do_full_justify, 0);
|
||||
#endif
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "^L", 0, total_refresh, 0);
|
||||
if (!ISSET(PRESERVE))
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "^L", 0, total_refresh, 0);
|
||||
else
|
||||
add_to_sclist(MMAIN|MBROWSER, "^L", 0, total_refresh, 0);
|
||||
add_to_sclist(MMAIN, "^Z", 0, do_suspend_void, 0);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Group of "Appearance" toggles. */
|
||||
add_to_sclist(MMAIN, "M-X", 0, do_toggle_void, NO_HELP);
|
||||
add_to_sclist(MMAIN, "M-C", 0, do_toggle_void, CONSTANT_SHOW);
|
||||
add_to_sclist(MMAIN, "M-S", 0, do_toggle_void, SMOOTH_SCROLL);
|
||||
add_to_sclist(MMAIN, "M-S", 0, do_toggle_void, JUMPY_SCROLLING);
|
||||
add_to_sclist(MMAIN, "M-$", 0, do_toggle_void, SOFTWRAP);
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
add_to_sclist(MMAIN, "M-#", 0, do_toggle_void, LINE_NUMBERS);
|
||||
@@ -1261,7 +1271,7 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN, "M-I", 0, do_toggle_void, AUTOINDENT);
|
||||
add_to_sclist(MMAIN, "M-K", 0, do_toggle_void, CUT_FROM_CURSOR);
|
||||
#ifdef ENABLE_WRAPPING
|
||||
add_to_sclist(MMAIN, "M-L", 0, do_toggle_void, NO_WRAP);
|
||||
add_to_sclist(MMAIN, "M-L", 0, do_toggle_void, BREAK_LONG_LINES);
|
||||
#endif
|
||||
add_to_sclist(MMAIN, "M-O", 0, do_toggle_void, TABS_TO_SPACES);
|
||||
|
||||
@@ -1278,12 +1288,6 @@ void shortcut_init(void)
|
||||
add_to_sclist(MWHEREIS|MREPLACE, "M-R", 0, regexp_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE, "M-B", 0, backwards_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE, "^R", 0, flip_replace, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MFINDINHELP, "^Y", 0, to_first_line, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MFINDINHELP, "^V", 0, to_last_line, 0);
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH, "^W", 0, do_para_begin_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH, "^O", 0, do_para_end_void, 0);
|
||||
#endif
|
||||
add_to_sclist(MWHEREIS|MGOTOLINE, "^T", 0, flip_goto, 0);
|
||||
#ifdef ENABLE_HISTORIES
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "^P", 0, get_history_older_void, 0);
|
||||
@@ -1299,6 +1303,12 @@ void shortcut_init(void)
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "Down", KEY_DOWN, get_history_newer_void, 0);
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
add_to_sclist(MGOTOLINE, "^W", 0, do_para_begin_void, 0);
|
||||
add_to_sclist(MGOTOLINE, "^O", 0, do_para_end_void, 0);
|
||||
#endif
|
||||
add_to_sclist(MGOTOLINE, "^Y", 0, to_first_line, 0);
|
||||
add_to_sclist(MGOTOLINE, "^V", 0, to_last_line, 0);
|
||||
#ifdef ENABLE_BROWSER
|
||||
add_to_sclist(MWHEREISFILE, "^Y", 0, to_first_file, 0);
|
||||
add_to_sclist(MWHEREISFILE, "^V", 0, to_last_file, 0);
|
||||
@@ -1311,7 +1321,7 @@ void shortcut_init(void)
|
||||
add_to_sclist(MBROWSER, "^_", 0, goto_dir_void, 0);
|
||||
add_to_sclist(MBROWSER, "M-G", 0, goto_dir_void, 0);
|
||||
#endif
|
||||
if (ISSET(TEMP_FILE))
|
||||
if (ISSET(TEMP_FILE) && !ISSET(PRESERVE))
|
||||
add_to_sclist(MWRITEFILE, "^Q", 0, discard_buffer, 0);
|
||||
#ifndef NANO_TINY
|
||||
add_to_sclist(MWRITEFILE, "M-D", 0, dos_format_void, 0);
|
||||
@@ -1398,8 +1408,8 @@ const char *flagtostr(int flag)
|
||||
return N_("Help mode");
|
||||
case CONSTANT_SHOW:
|
||||
return N_("Constant cursor position display");
|
||||
case SMOOTH_SCROLL:
|
||||
return N_("Smooth scrolling");
|
||||
case JUMPY_SCROLLING:
|
||||
return N_("Jumpy scrolling (per half-screen)");
|
||||
case SOFTWRAP:
|
||||
return N_("Soft wrapping of overlong lines");
|
||||
case WHITESPACE_DISPLAY:
|
||||
@@ -1412,7 +1422,7 @@ const char *flagtostr(int flag)
|
||||
return N_("Auto indent");
|
||||
case CUT_FROM_CURSOR:
|
||||
return N_("Cut to end");
|
||||
case NO_WRAP:
|
||||
case BREAK_LONG_LINES:
|
||||
return N_("Hard wrapping of overlong lines");
|
||||
case TABS_TO_SPACES:
|
||||
return N_("Conversion of typed tabs to spaces");
|
||||
@@ -1468,14 +1478,12 @@ sc *strtosc(const char *input)
|
||||
s->func = do_replace;
|
||||
else if (!strcasecmp(input, "cut"))
|
||||
s->func = do_cut_text_void;
|
||||
else if (!strcasecmp(input, "paste") ||
|
||||
!strcasecmp(input, "uncut")) /* Deprecated. Remove end of 2018. */
|
||||
else if (!strcasecmp(input, "paste"))
|
||||
s->func = do_uncut_text;
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcasecmp(input, "cutrestoffile"))
|
||||
s->func = do_cut_till_eof;
|
||||
else if (!strcasecmp(input, "copy") ||
|
||||
!strcasecmp(input, "copytext")) /* Deprecated. Remove end of 2018. */
|
||||
else if (!strcasecmp(input, "copy"))
|
||||
s->func = do_copy_text;
|
||||
else if (!strcasecmp(input, "zap"))
|
||||
s->func = zap_text;
|
||||
@@ -1518,10 +1526,12 @@ sc *strtosc(const char *input)
|
||||
s->func = do_indent;
|
||||
else if (!strcasecmp(input, "unindent"))
|
||||
s->func = do_unindent;
|
||||
else if (!strcasecmp(input, "cutwordleft"))
|
||||
s->func = do_cut_prev_word;
|
||||
else if (!strcasecmp(input, "cutwordright"))
|
||||
s->func = do_cut_next_word;
|
||||
else if (!strcasecmp(input, "chopwordleft") ||
|
||||
!strcasecmp(input, "cutwordleft")) /* Deprecated; remove in 2021. */
|
||||
s->func = chop_previous_word;
|
||||
else if (!strcasecmp(input, "chopwordright") ||
|
||||
!strcasecmp(input, "cutwordright")) /* Deprecated; remove in 2021. */
|
||||
s->func = chop_next_word;
|
||||
else if (!strcasecmp(input, "findbracket"))
|
||||
s->func = do_find_bracket;
|
||||
else if (!strcasecmp(input, "wordcount"))
|
||||
@@ -1603,8 +1613,7 @@ sc *strtosc(const char *input)
|
||||
s->func = backwards_void;
|
||||
else if (!strcasecmp(input, "flipreplace"))
|
||||
s->func = flip_replace;
|
||||
else if (!strcasecmp(input, "flipgoto") ||
|
||||
!strcasecmp(input, "gototext")) /* Deprecated. Remove end of 2018. */
|
||||
else if (!strcasecmp(input, "flipgoto"))
|
||||
s->func = flip_goto;
|
||||
#ifdef ENABLE_HISTORIES
|
||||
else if (!strcasecmp(input, "older"))
|
||||
@@ -1650,11 +1659,10 @@ sc *strtosc(const char *input)
|
||||
s->func = do_toggle_void;
|
||||
if (!strcasecmp(input, "nohelp"))
|
||||
s->toggle = NO_HELP;
|
||||
else if (!strcasecmp(input, "constantshow") ||
|
||||
!strcasecmp(input, "constupdate")) /* Deprecated. Remove end of 2018. */
|
||||
else if (!strcasecmp(input, "constantshow"))
|
||||
s->toggle = CONSTANT_SHOW;
|
||||
else if (!strcasecmp(input, "smoothscroll"))
|
||||
s->toggle = SMOOTH_SCROLL;
|
||||
s->toggle = JUMPY_SCROLLING;
|
||||
else if (!strcasecmp(input, "softwrap"))
|
||||
s->toggle = SOFTWRAP;
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
@@ -1671,12 +1679,11 @@ sc *strtosc(const char *input)
|
||||
s->toggle = SMART_HOME;
|
||||
else if (!strcasecmp(input, "autoindent"))
|
||||
s->toggle = AUTOINDENT;
|
||||
else if (!strcasecmp(input, "cutfromcursor") ||
|
||||
!strcasecmp(input, "cuttoend")) /* Deprecated. Remove end of 2018. */
|
||||
else if (!strcasecmp(input, "cutfromcursor"))
|
||||
s->toggle = CUT_FROM_CURSOR;
|
||||
#ifdef ENABLE_WRAPPING
|
||||
else if (!strcasecmp(input, "nowrap"))
|
||||
s->toggle = NO_WRAP;
|
||||
s->toggle = BREAK_LONG_LINES;
|
||||
#endif
|
||||
else if (!strcasecmp(input, "tabstospaces"))
|
||||
s->toggle = TABS_TO_SPACES;
|
||||
|
||||
14
src/help.c
14
src/help.c
@@ -1,9 +1,9 @@
|
||||
/**************************************************************************
|
||||
* help.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2000-2011, 2013-2018 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2000-2011, 2013-2019 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2017 Rishabh Dave *
|
||||
* Copyright (C) 2014-2017 Benno Schulenberg *
|
||||
* Copyright (C) 2014-2018 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 *
|
||||
@@ -110,7 +110,7 @@ void do_help(void)
|
||||
/* The current answer when the user invokes help at the prompt. */
|
||||
unsigned stash[sizeof(flags) / sizeof(flags[0])];
|
||||
/* A storage place for the current flag settings. */
|
||||
filestruct *line;
|
||||
linestruct *line;
|
||||
int length;
|
||||
FILE *fp;
|
||||
|
||||
@@ -193,9 +193,9 @@ void do_help(void)
|
||||
} else if (ISSET(SHOW_CURSOR) && (func == do_left || func == do_right ||
|
||||
func == do_up || func == do_down)) {
|
||||
func();
|
||||
} else if (func == do_up) {
|
||||
} else if (func == do_up || func == do_scroll_up) {
|
||||
do_scroll_up();
|
||||
} else if (func == do_down) {
|
||||
} else if (func == do_down || func == do_scroll_down) {
|
||||
if (openfile->edittop->lineno + editwinrows - 1 <
|
||||
openfile->filebot->lineno)
|
||||
do_scroll_down();
|
||||
@@ -231,7 +231,7 @@ void do_help(void)
|
||||
edit_refresh();
|
||||
|
||||
location = 0;
|
||||
line = openfile->fileage;
|
||||
line = openfile->filetop;
|
||||
|
||||
/* Count how far (in bytes) edittop is into the file. */
|
||||
while (line != openfile->edittop) {
|
||||
@@ -567,7 +567,7 @@ functionptrtype parse_help_input(int *kbinput)
|
||||
{
|
||||
if (!meta_key) {
|
||||
switch (*kbinput) {
|
||||
case DEL_CODE:
|
||||
case BS_CODE:
|
||||
case '-':
|
||||
return do_page_up;
|
||||
case ' ':
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* history.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2003-2011, 2013-2018 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2003-2011, 2013-2019 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2016-2017 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -40,6 +40,8 @@ static struct stat stat_of_positions_file;
|
||||
/* The last-obtained stat information of the positions file. */
|
||||
static char *poshistname = NULL;
|
||||
/* The name of the positions-history file. */
|
||||
static poshiststruct *position_history = NULL;
|
||||
/* The list of filenames with their last cursor positions. */
|
||||
|
||||
/* Initialize the lists of historical search and replace strings
|
||||
* and the list of historical executed commands. */
|
||||
@@ -62,7 +64,7 @@ void history_init(void)
|
||||
}
|
||||
|
||||
/* Set the current position in the given history list to the bottom. */
|
||||
void history_reset(const filestruct *list)
|
||||
void history_reset(const linestruct *list)
|
||||
{
|
||||
if (list == search_history)
|
||||
search_history = searchbot;
|
||||
@@ -75,14 +77,14 @@ void history_reset(const filestruct *list)
|
||||
/* 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. */
|
||||
filestruct *find_history(const filestruct *start, const filestruct *end,
|
||||
linestruct *find_history(const linestruct *start, const linestruct *end,
|
||||
const char *text, size_t len)
|
||||
{
|
||||
const filestruct *item;
|
||||
const linestruct *item;
|
||||
|
||||
for (item = start; item != end->prev && item != NULL; item = item->prev) {
|
||||
if (strncmp(item->data, text, len) == 0)
|
||||
return (filestruct *)item;
|
||||
return (linestruct *)item;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -90,9 +92,9 @@ filestruct *find_history(const filestruct *start, const filestruct *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(filestruct **item, const char *text)
|
||||
void update_history(linestruct **item, const char *text)
|
||||
{
|
||||
filestruct **htop = NULL, **hbot = NULL, *thesame;
|
||||
linestruct **htop = NULL, **hbot = NULL, *thesame;
|
||||
|
||||
if (*item == search_history) {
|
||||
htop = &searchtop;
|
||||
@@ -110,7 +112,7 @@ void update_history(filestruct **item, const char *text)
|
||||
|
||||
/* If an identical string was found, delete that item. */
|
||||
if (thesame != NULL) {
|
||||
filestruct *after = thesame->next;
|
||||
linestruct *after = thesame->next;
|
||||
|
||||
/* If the string is at the head of the list, move the head. */
|
||||
if (thesame == *htop)
|
||||
@@ -123,7 +125,7 @@ void update_history(filestruct **item, const char *text)
|
||||
/* If the history is full, delete the oldest item (the one at the
|
||||
* head of the list), to make room for a new item at the end. */
|
||||
if ((*hbot)->lineno == MAX_SEARCH_HISTORY + 1) {
|
||||
filestruct *oldest = *htop;
|
||||
linestruct *oldest = *htop;
|
||||
|
||||
*htop = (*htop)->next;
|
||||
unlink_node(oldest);
|
||||
@@ -145,7 +147,7 @@ void update_history(filestruct **item, const char *text)
|
||||
|
||||
/* 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(filestruct **h)
|
||||
char *get_history_older(linestruct **h)
|
||||
{
|
||||
if ((*h)->prev == NULL)
|
||||
return NULL;
|
||||
@@ -157,7 +159,7 @@ char *get_history_older(filestruct **h)
|
||||
|
||||
/* 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(filestruct **h)
|
||||
char *get_history_newer(linestruct **h)
|
||||
{
|
||||
if ((*h)->next == NULL)
|
||||
return NULL;
|
||||
@@ -167,14 +169,12 @@ char *get_history_newer(filestruct **h)
|
||||
return (*h)->data;
|
||||
}
|
||||
|
||||
/* More placeholders. */
|
||||
void get_history_newer_void(void)
|
||||
{
|
||||
;
|
||||
}
|
||||
/* Two empty placeholder functions. */
|
||||
void get_history_older_void(void)
|
||||
{
|
||||
;
|
||||
}
|
||||
void get_history_newer_void(void)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef ENABLE_TABCOMP
|
||||
@@ -182,10 +182,10 @@ void get_history_older_void(void)
|
||||
* looking at only the first len characters of s, and return that
|
||||
* string. If there isn't one, or if len is 0, don't move h and return
|
||||
* s. */
|
||||
char *get_history_completion(filestruct **h, char *s, size_t len)
|
||||
char *get_history_completion(linestruct **h, char *s, size_t len)
|
||||
{
|
||||
if (len > 0) {
|
||||
filestruct *htop = NULL, *hbot = NULL, *p;
|
||||
linestruct *htop = NULL, *hbot = NULL, *p;
|
||||
|
||||
if (*h == search_history) {
|
||||
htop = searchtop;
|
||||
@@ -315,7 +315,7 @@ void load_history(void)
|
||||
/* Load the three history lists -- first search, then replace,
|
||||
* then execute -- from oldest entry to newest. Between two
|
||||
* lists there is an empty line. */
|
||||
filestruct **history = &search_history;
|
||||
linestruct **history = &search_history;
|
||||
char *line = NULL;
|
||||
size_t buf_len = 0;
|
||||
ssize_t read;
|
||||
@@ -344,9 +344,9 @@ void load_history(void)
|
||||
|
||||
/* Write the lines of a history list, starting at head, from oldest to newest,
|
||||
* to the given file. Return TRUE if writing succeeded, and FALSE otherwise. */
|
||||
bool write_list(const filestruct *head, FILE *hisfile)
|
||||
bool write_list(const linestruct *head, FILE *hisfile)
|
||||
{
|
||||
const filestruct *item;
|
||||
const linestruct *item;
|
||||
|
||||
for (item = head; item != NULL; item = item->next) {
|
||||
size_t length = strlen(item->data);
|
||||
@@ -593,7 +593,7 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
|
||||
* set line and column to the retrieved values. */
|
||||
bool has_old_position(const char *file, ssize_t *line, ssize_t *column)
|
||||
{
|
||||
poshiststruct *posptr = position_history;
|
||||
poshiststruct *posptr;
|
||||
char *fullpath = get_full_path(file);
|
||||
|
||||
if (fullpath == NULL)
|
||||
@@ -601,6 +601,7 @@ bool has_old_position(const char *file, ssize_t *line, ssize_t *column)
|
||||
|
||||
reload_positions_if_needed();
|
||||
|
||||
posptr = position_history;
|
||||
while (posptr != NULL && strcmp(posptr->filename, fullpath) != 0)
|
||||
posptr = posptr->next;
|
||||
|
||||
|
||||
97
src/move.c
97
src/move.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* move.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2019 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2018 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -26,7 +26,7 @@
|
||||
/* Move to the first line of the file. */
|
||||
void to_first_line(void)
|
||||
{
|
||||
openfile->current = openfile->fileage;
|
||||
openfile->current = openfile->filetop;
|
||||
openfile->current_x = 0;
|
||||
openfile->placewewant = 0;
|
||||
|
||||
@@ -68,7 +68,7 @@ void get_edge_and_target(size_t *leftedge, size_t *target_column)
|
||||
* chunk that starts at the given leftedge. If the target column has landed
|
||||
* on a tab, prevent the cursor from falling back a row when moving forward,
|
||||
* or from skipping a row when moving backward, by incrementing the index. */
|
||||
size_t proper_x(filestruct *line, size_t *leftedge, bool forward,
|
||||
size_t proper_x(linestruct *line, size_t *leftedge, bool forward,
|
||||
size_t column, bool *shifted)
|
||||
{
|
||||
size_t index = actual_x(line->data, column);
|
||||
@@ -117,7 +117,7 @@ void do_page_up(void)
|
||||
|
||||
/* If we're not in smooth scrolling mode, put the cursor at the
|
||||
* beginning of the top line of the edit window, as Pico does. */
|
||||
if (!ISSET(SMOOTH_SCROLL)) {
|
||||
if (ISSET(JUMPY_SCROLLING)) {
|
||||
openfile->current = openfile->edittop;
|
||||
leftedge = openfile->firstcolumn;
|
||||
openfile->current_y = 0;
|
||||
@@ -147,7 +147,7 @@ void do_page_down(void)
|
||||
|
||||
/* If we're not in smooth scrolling mode, put the cursor at the
|
||||
* beginning of the top line of the edit window, as Pico does. */
|
||||
if (!ISSET(SMOOTH_SCROLL)) {
|
||||
if (ISSET(JUMPY_SCROLLING)) {
|
||||
openfile->current = openfile->edittop;
|
||||
leftedge = openfile->firstcolumn;
|
||||
openfile->current_y = 0;
|
||||
@@ -170,59 +170,52 @@ void do_page_down(void)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
/* Move to the beginning of the first-found beginning-of-paragraph line
|
||||
* before the current line. */
|
||||
void do_para_begin(void)
|
||||
/* Move to the first beginning of a paragraph before the current line. */
|
||||
void do_para_begin(linestruct **line)
|
||||
{
|
||||
if (openfile->current != openfile->fileage)
|
||||
openfile->current = openfile->current->prev;
|
||||
if ((*line)->prev != NULL)
|
||||
*line = (*line)->prev;
|
||||
|
||||
while (!begpar(openfile->current, 0))
|
||||
openfile->current = openfile->current->prev;
|
||||
|
||||
openfile->current_x = 0;
|
||||
while (!begpar(*line, 0))
|
||||
*line = (*line)->prev;
|
||||
}
|
||||
|
||||
/* Move down to the beginning of the last line of the current paragraph.
|
||||
* Then move down one line farther if there is such a line, or to the
|
||||
* end of the current line if not. A line is the last line of a paragraph
|
||||
* if it is in a paragraph, and the next line either is the beginning line
|
||||
* of a paragraph or isn't in a paragraph. */
|
||||
void do_para_end(void)
|
||||
/* Move down to the last line of the first found paragraph. */
|
||||
void do_para_end(linestruct **line)
|
||||
{
|
||||
while (openfile->current != openfile->filebot &&
|
||||
!inpar(openfile->current))
|
||||
openfile->current = openfile->current->next;
|
||||
while ((*line)->next != NULL && !inpar(*line))
|
||||
*line = (*line)->next;
|
||||
|
||||
while (openfile->current != openfile->filebot &&
|
||||
inpar(openfile->current->next) &&
|
||||
!begpar(openfile->current->next, 0)) {
|
||||
openfile->current = openfile->current->next;
|
||||
}
|
||||
|
||||
if (openfile->current != openfile->filebot) {
|
||||
openfile->current = openfile->current->next;
|
||||
openfile->current_x = 0;
|
||||
} else
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
while ((*line)->next != NULL && inpar((*line)->next) &&
|
||||
!begpar((*line)->next, 0))
|
||||
*line = (*line)->next;
|
||||
}
|
||||
|
||||
/* Move up to first start of a paragraph before the current line. */
|
||||
void do_para_begin_void(void)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
linestruct *was_current = openfile->current;
|
||||
|
||||
do_para_begin();
|
||||
do_para_begin(&openfile->current);
|
||||
openfile->current_x = 0;
|
||||
|
||||
edit_redraw(was_current, CENTERING);
|
||||
}
|
||||
|
||||
/* Move down to just after the first end of a paragraph. */
|
||||
/* Move down to just after the first found end of a paragraph. */
|
||||
void do_para_end_void(void)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
linestruct *was_current = openfile->current;
|
||||
|
||||
do_para_end();
|
||||
do_para_end(&openfile->current);
|
||||
|
||||
/* Step beyond the last line of the paragraph, if possible;
|
||||
* otherwise, move to the end of the line. */
|
||||
if (openfile->current->next != NULL) {
|
||||
openfile->current = openfile->current->next;
|
||||
openfile->current_x = 0;
|
||||
} else
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
|
||||
edit_redraw(was_current, CENTERING);
|
||||
}
|
||||
@@ -231,7 +224,7 @@ void do_para_end_void(void)
|
||||
/* Move to the preceding block of text. */
|
||||
void do_prev_block(void)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
linestruct *was_current = openfile->current;
|
||||
bool is_text = FALSE, seen_text = FALSE;
|
||||
|
||||
/* Skip backward until first blank line after some nonblank line(s). */
|
||||
@@ -253,7 +246,7 @@ void do_prev_block(void)
|
||||
/* Move to the next block of text. */
|
||||
void do_next_block(void)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
linestruct *was_current = openfile->current;
|
||||
bool is_white = white_string(openfile->current->data);
|
||||
bool seen_white = is_white;
|
||||
|
||||
@@ -364,7 +357,7 @@ bool do_next_word(bool after_ends, bool allow_punct)
|
||||
* word if the WORD_BOUNDS flag is set, and update the screen afterwards. */
|
||||
void do_prev_word_void(void)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
linestruct *was_current = openfile->current;
|
||||
|
||||
do_prev_word(ISSET(WORD_BOUNDS));
|
||||
|
||||
@@ -376,7 +369,7 @@ void do_prev_word_void(void)
|
||||
* punctuation as part of a word. Update the screen afterwards. */
|
||||
void do_next_word_void(void)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
linestruct *was_current = openfile->current;
|
||||
|
||||
do_next_word(ISSET(AFTER_ENDS), ISSET(WORD_BOUNDS));
|
||||
|
||||
@@ -388,7 +381,7 @@ void do_next_word_void(void)
|
||||
* of the full line when already at the start of a chunk. */
|
||||
void do_home(void)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
linestruct *was_current = openfile->current;
|
||||
size_t was_column = xplustabs();
|
||||
bool moved_off_chunk = TRUE;
|
||||
#ifndef NANO_TINY
|
||||
@@ -448,7 +441,7 @@ void do_home(void)
|
||||
* end of the full line. */
|
||||
void do_end(void)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
linestruct *was_current = openfile->current;
|
||||
size_t was_column = xplustabs();
|
||||
size_t line_len = strlen(openfile->current->data);
|
||||
bool moved_off_chunk = TRUE;
|
||||
@@ -497,7 +490,7 @@ void do_end(void)
|
||||
/* Move the cursor to the preceding line or chunk. */
|
||||
void do_up(void)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
linestruct *was_current = openfile->current;
|
||||
size_t leftedge, target_column;
|
||||
|
||||
get_edge_and_target(&leftedge, &target_column);
|
||||
@@ -508,7 +501,7 @@ void do_up(void)
|
||||
|
||||
set_proper_index_and_pww(&leftedge, target_column, FALSE);
|
||||
|
||||
if (openfile->current_y == 0 && ISSET(SMOOTH_SCROLL))
|
||||
if (openfile->current_y == 0 && !ISSET(JUMPY_SCROLLING))
|
||||
edit_scroll(BACKWARD);
|
||||
else
|
||||
edit_redraw(was_current, FLOWING);
|
||||
@@ -520,7 +513,7 @@ void do_up(void)
|
||||
/* Move the cursor to next line or chunk. */
|
||||
void do_down(void)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
linestruct *was_current = openfile->current;
|
||||
size_t leftedge, target_column;
|
||||
|
||||
get_edge_and_target(&leftedge, &target_column);
|
||||
@@ -531,7 +524,7 @@ void do_down(void)
|
||||
|
||||
set_proper_index_and_pww(&leftedge, target_column, TRUE);
|
||||
|
||||
if (openfile->current_y == editwinrows - 1 && ISSET(SMOOTH_SCROLL))
|
||||
if (openfile->current_y == editwinrows - 1 && !ISSET(JUMPY_SCROLLING))
|
||||
edit_scroll(FORWARD);
|
||||
else
|
||||
edit_redraw(was_current, FLOWING);
|
||||
@@ -574,12 +567,12 @@ void do_scroll_down(void)
|
||||
/* Move left one character. */
|
||||
void do_left(void)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
linestruct *was_current = openfile->current;
|
||||
|
||||
if (openfile->current_x > 0)
|
||||
openfile->current_x = move_mbleft(openfile->current->data,
|
||||
openfile->current_x);
|
||||
else if (openfile->current != openfile->fileage) {
|
||||
else if (openfile->current != openfile->filetop) {
|
||||
openfile->current = openfile->current->prev;
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
}
|
||||
@@ -590,7 +583,7 @@ void do_left(void)
|
||||
/* Move right one character. */
|
||||
void do_right(void)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
linestruct *was_current = openfile->current;
|
||||
|
||||
if (openfile->current->data[openfile->current_x] != '\0')
|
||||
openfile->current_x = move_mbright(openfile->current->data,
|
||||
|
||||
446
src/nano.c
446
src/nano.c
File diff suppressed because it is too large
Load Diff
43
src/nano.h
43
src/nano.h
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* nano.h -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2019 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2017 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -270,32 +270,32 @@ typedef struct lintstruct {
|
||||
#endif /* ENABLE_COLOR */
|
||||
|
||||
/* More structure types. */
|
||||
typedef struct filestruct {
|
||||
typedef struct linestruct {
|
||||
char *data;
|
||||
/* The text of this line. */
|
||||
ssize_t lineno;
|
||||
/* The number of this line. */
|
||||
struct filestruct *next;
|
||||
struct linestruct *next;
|
||||
/* Next node. */
|
||||
struct filestruct *prev;
|
||||
struct linestruct *prev;
|
||||
/* Previous node. */
|
||||
#ifdef ENABLE_COLOR
|
||||
short *multidata;
|
||||
/* Array of which multi-line regexes apply to this line. */
|
||||
#endif
|
||||
} filestruct;
|
||||
} linestruct;
|
||||
|
||||
typedef struct partition {
|
||||
filestruct *fileage;
|
||||
linestruct *filetop;
|
||||
/* The top line of this portion of the file. */
|
||||
filestruct *top_prev;
|
||||
linestruct *top_prev;
|
||||
/* The line before the top line of this portion of the file. */
|
||||
char *top_data;
|
||||
/* The text before the beginning of the top line of this portion
|
||||
* of the file. */
|
||||
filestruct *filebot;
|
||||
linestruct *filebot;
|
||||
/* The bottom line of this portion of the file. */
|
||||
filestruct *bot_next;
|
||||
linestruct *bot_next;
|
||||
/* The line after the bottom line of this portion of the
|
||||
* file. */
|
||||
char *bot_data;
|
||||
@@ -332,9 +332,9 @@ typedef struct undo {
|
||||
/* Undo info specific to groups of lines. */
|
||||
|
||||
/* Cut-specific stuff we need. */
|
||||
filestruct *cutbuffer;
|
||||
linestruct *cutbuffer;
|
||||
/* Copy of the cutbuffer. */
|
||||
filestruct *cutbottom;
|
||||
linestruct *cutbottom;
|
||||
/* Copy of cutbottom. */
|
||||
ssize_t mark_begin_lineno;
|
||||
/* Mostly the line number of the current line; sometimes something else. */
|
||||
@@ -360,13 +360,13 @@ typedef struct poshiststruct {
|
||||
typedef struct openfilestruct {
|
||||
char *filename;
|
||||
/* The file's name. */
|
||||
filestruct *fileage;
|
||||
linestruct *filetop;
|
||||
/* The file's first line. */
|
||||
filestruct *filebot;
|
||||
linestruct *filebot;
|
||||
/* The file's last line. */
|
||||
filestruct *edittop;
|
||||
linestruct *edittop;
|
||||
/* The current top of the edit window for this file. */
|
||||
filestruct *current;
|
||||
linestruct *current;
|
||||
/* The current line for this file. */
|
||||
size_t totsize;
|
||||
/* The file's total number of characters. */
|
||||
@@ -384,7 +384,7 @@ typedef struct openfilestruct {
|
||||
struct stat *current_stat;
|
||||
/* The file's current stat information. */
|
||||
#ifndef NANO_TINY
|
||||
filestruct *mark;
|
||||
linestruct *mark;
|
||||
/* The line in the file where the mark is set; NULL if not set. */
|
||||
size_t mark_x;
|
||||
/* The mark's x position in the above line. */
|
||||
@@ -486,6 +486,7 @@ enum
|
||||
{
|
||||
TITLE_BAR = 0,
|
||||
LINE_NUMBER,
|
||||
GUIDE_STRIPE,
|
||||
SELECTED_TEXT,
|
||||
STATUS_BAR,
|
||||
ERROR_MESSAGE,
|
||||
@@ -513,7 +514,7 @@ enum
|
||||
MULTIBUFFER,
|
||||
SMOOTH_SCROLL,
|
||||
REBIND_DELETE,
|
||||
REBIND_KEYPAD,
|
||||
RAW_SEQUENCES,
|
||||
NO_CONVERT,
|
||||
BACKUP_FILE,
|
||||
INSECURE_BACKUP,
|
||||
@@ -529,7 +530,6 @@ enum
|
||||
WORD_BOUNDS,
|
||||
NO_NEWLINES,
|
||||
BOLD_TEXT,
|
||||
QUIET,
|
||||
SOFTWRAP,
|
||||
POSITIONLOG,
|
||||
LOCKING,
|
||||
@@ -541,7 +541,11 @@ enum
|
||||
NO_PAUSES,
|
||||
AT_BLANKS,
|
||||
AFTER_ENDS,
|
||||
LET_THEM_ZAP
|
||||
LET_THEM_ZAP,
|
||||
BREAK_LONG_LINES,
|
||||
FINAL_NEWLINE,
|
||||
JUMPY_SCROLLING,
|
||||
EMPTY_LINE
|
||||
};
|
||||
|
||||
/* Flags for the menus in which a given function should be present. */
|
||||
@@ -571,6 +575,7 @@ enum
|
||||
#endif
|
||||
|
||||
/* Basic control codes. */
|
||||
#define BS_CODE 0x08
|
||||
#define TAB_CODE 0x09
|
||||
#define ESC_CODE 0x1B
|
||||
#define DEL_CODE 0x7F
|
||||
|
||||
71
src/prompt.c
71
src/prompt.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* prompt.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2019 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2016, 2018 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -126,6 +126,11 @@ int do_statusbar_input(bool *finished)
|
||||
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)
|
||||
@@ -395,11 +400,12 @@ void draw_the_promptbar(void)
|
||||
waddch(bottomwin, ':');
|
||||
waddch(bottomwin, (the_page == 0) ? ' ' : '<');
|
||||
|
||||
expanded = display_string(answer, the_page, COLS - base - 1, FALSE);
|
||||
expanded = display_string(answer, the_page, COLS - base, FALSE, TRUE);
|
||||
waddstr(bottomwin, expanded);
|
||||
free(expanded);
|
||||
|
||||
waddch(bottomwin, (the_page >= end_page) ? ' ' : '>');
|
||||
if (base + strlenpt(answer) != COLS && the_page < end_page)
|
||||
mvwaddch(bottomwin, 0, COLS - 1, '>');
|
||||
|
||||
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
|
||||
@@ -432,7 +438,7 @@ void add_or_remove_pipe_symbol_from_answer(void)
|
||||
|
||||
/* Get a string of input at the statusbar prompt. */
|
||||
functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
bool allow_files, bool *listed, filestruct **history_list,
|
||||
bool allow_files, bool *listed, linestruct **history_list,
|
||||
void (*refresh_func)(void))
|
||||
{
|
||||
int kbinput = ERR;
|
||||
@@ -517,12 +523,6 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
answer = mallocstrcpy(answer, history);
|
||||
typing_x = strlen(answer);
|
||||
}
|
||||
|
||||
/* This key has a shortcut-list entry when it's used to
|
||||
* move to an older search, which means that finished has
|
||||
* been set to TRUE. Set it back to FALSE here, so that
|
||||
* we aren't kicked out of the statusbar prompt. */
|
||||
finished = FALSE;
|
||||
}
|
||||
} else if (func == get_history_newer_void) {
|
||||
if (history_list != NULL) {
|
||||
@@ -540,12 +540,6 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
answer = mallocstrcpy(answer, magichistory);
|
||||
typing_x = strlen(answer);
|
||||
}
|
||||
|
||||
/* This key has a shortcut-list entry when it's used to
|
||||
* move to a newer search, which means that finished has
|
||||
* been set to TRUE. Set it back to FALSE here, so that
|
||||
* we aren't kicked out of the statusbar prompt. */
|
||||
finished = FALSE;
|
||||
}
|
||||
} else
|
||||
#endif /* ENABLE_HISTORIES */
|
||||
@@ -581,19 +575,16 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
return func;
|
||||
}
|
||||
|
||||
/* Ask a question on the statusbar. The prompt will be stored in the
|
||||
* static prompt, which should be NULL initially, and the answer will be
|
||||
* stored in the answer global. Returns -1 on aborted enter, -2 on a
|
||||
* blank string, and 0 otherwise, the valid shortcut key caught.
|
||||
* curranswer is any editable text that we want to put up by default,
|
||||
* and refresh_func is the function we want to call to refresh the edit
|
||||
* window.
|
||||
/* Ask a question on the statusbar. Return 0 when text was entered,
|
||||
* -1 for a cancelled entry, -2 for a blank string, and the relevant
|
||||
* keycode when a valid shortcut key was pressed.
|
||||
*
|
||||
* The allow_tabs parameter indicates whether we should allow tabs to be
|
||||
* interpreted. The allow_files parameter indicates whether we should
|
||||
* allow all files (as opposed to just directories) to be tab completed. */
|
||||
* The allow_tabs parameter indicates whether tab completion is allowed,
|
||||
* and allow_files indicates whether all files (and not just directories)
|
||||
* can be tab completed. The curranswer parameter is the default answer
|
||||
* for when simply Enter is typed. */
|
||||
int do_prompt(bool allow_tabs, bool allow_files,
|
||||
int menu, const char *curranswer, filestruct **history_list,
|
||||
int menu, const char *curranswer, linestruct **history_list,
|
||||
void (*refresh_func)(void), const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
@@ -658,7 +649,7 @@ int do_prompt(bool allow_tabs, bool allow_files,
|
||||
* TRUE when passed in), and -1 for Cancel. */
|
||||
int do_yesno_prompt(bool all, const char *msg)
|
||||
{
|
||||
int response = -2, width = 16;
|
||||
int choice = -2, 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. */
|
||||
@@ -666,7 +657,7 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
const char *nostr = _("Nn");
|
||||
const char *allstr = _("Aa");
|
||||
|
||||
while (response == -2) {
|
||||
while (choice == -2) {
|
||||
#ifdef ENABLE_NLS
|
||||
char letter[MAXCHARLEN + 1];
|
||||
int index = 0;
|
||||
@@ -732,21 +723,21 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
|
||||
/* See if the typed letter is in the Yes, No, or All strings. */
|
||||
if (strstr(yesstr, letter) != NULL)
|
||||
response = 1;
|
||||
choice = 1;
|
||||
else if (strstr(nostr, letter) != NULL)
|
||||
response = 0;
|
||||
choice = 0;
|
||||
else if (all && strstr(allstr, letter) != NULL)
|
||||
response = 2;
|
||||
choice = 2;
|
||||
else
|
||||
#endif /* ENABLE_NLS */
|
||||
if (strchr("Yy", kbinput) != NULL)
|
||||
response = 1;
|
||||
choice = 1;
|
||||
else if (strchr("Nn", kbinput) != NULL)
|
||||
response = 0;
|
||||
choice = 0;
|
||||
else if (all && strchr("Aa", kbinput) != NULL)
|
||||
response = 2;
|
||||
choice = 2;
|
||||
else if (func_from_key(&kbinput) == do_cancel)
|
||||
response = -1;
|
||||
choice = -1;
|
||||
#ifdef ENABLE_MOUSE
|
||||
else if (kbinput == KEY_MOUSE) {
|
||||
int mouse_x, mouse_y;
|
||||
@@ -758,14 +749,14 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
int y = mouse_y - 1;
|
||||
|
||||
/* x == 0 means Yes or No, y == 0 means Yes or All. */
|
||||
response = -2 * x * y + x - y + 1;
|
||||
choice = -2 * x * y + x - y + 1;
|
||||
|
||||
if (response == 2 && !all)
|
||||
response = -2;
|
||||
if (choice == 2 && !all)
|
||||
choice = -2;
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_MOUSE */
|
||||
}
|
||||
|
||||
return response;
|
||||
return choice;
|
||||
}
|
||||
|
||||
150
src/proto.h
150
src/proto.h
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* proto.h -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2019 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 *
|
||||
@@ -44,7 +44,7 @@ extern bool suppress_cursorpos;
|
||||
|
||||
extern message_type lastmessage;
|
||||
|
||||
extern filestruct *pletion_line;
|
||||
extern linestruct *pletion_line;
|
||||
|
||||
extern bool inhelp;
|
||||
extern char *title;
|
||||
@@ -73,7 +73,7 @@ extern int shiftaltup, shiftaltdown;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
extern ssize_t wrap_at, fill;
|
||||
extern ssize_t fill, wrap_at;
|
||||
#endif
|
||||
|
||||
extern char *last_search;
|
||||
@@ -88,9 +88,14 @@ extern WINDOW *bottomwin;
|
||||
extern int editwinrows;
|
||||
extern int editwincols;
|
||||
extern int margin;
|
||||
#ifndef NANO_TINY
|
||||
extern ssize_t stripe_column;
|
||||
#endif
|
||||
|
||||
extern linestruct *cutbuffer;
|
||||
extern linestruct *cutbottom;
|
||||
extern bool keep_cutbuffer;
|
||||
|
||||
extern filestruct *cutbuffer;
|
||||
extern filestruct *cutbottom;
|
||||
extern partition *filepart;
|
||||
extern openfilestruct *openfile;
|
||||
extern openfilestruct *firstfile;
|
||||
@@ -98,20 +103,16 @@ extern openfilestruct *firstfile;
|
||||
#ifndef NANO_TINY
|
||||
extern char *matchbrackets;
|
||||
extern char *whitespace;
|
||||
extern int whitespace_len[2];
|
||||
extern int whitelen[2];
|
||||
#endif
|
||||
|
||||
extern const char *exit_tag;
|
||||
extern const char *close_tag;
|
||||
extern const char *uncut_tag;
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
extern const char *unjust_tag;
|
||||
extern char *punct;
|
||||
extern char *brackets;
|
||||
extern char *quotestr;
|
||||
extern regex_t quotereg;
|
||||
extern int quoterc;
|
||||
extern char *quoteerr;
|
||||
#endif
|
||||
|
||||
extern char *word_chars;
|
||||
@@ -145,19 +146,17 @@ extern int currmenu;
|
||||
extern sc *sclist;
|
||||
extern subnfunc *allfuncs;
|
||||
extern subnfunc *exitfunc;
|
||||
extern subnfunc *uncutfunc;
|
||||
|
||||
extern filestruct *search_history;
|
||||
extern filestruct *replace_history;
|
||||
extern filestruct *execute_history;
|
||||
extern linestruct *search_history;
|
||||
extern linestruct *replace_history;
|
||||
extern linestruct *execute_history;
|
||||
#ifdef ENABLE_HISTORIES
|
||||
extern filestruct *searchtop;
|
||||
extern filestruct *searchbot;
|
||||
extern filestruct *replacetop;
|
||||
extern filestruct *replacebot;
|
||||
extern filestruct *executetop;
|
||||
extern filestruct *executebot;
|
||||
extern poshiststruct *position_history;
|
||||
extern linestruct *searchtop;
|
||||
extern linestruct *searchbot;
|
||||
extern linestruct *replacetop;
|
||||
extern linestruct *replacebot;
|
||||
extern linestruct *executetop;
|
||||
extern linestruct *executebot;
|
||||
#endif
|
||||
|
||||
extern regex_t search_regexp;
|
||||
@@ -229,7 +228,7 @@ char *revstrpbrk(const char *head, const char *accept, const char *index);
|
||||
char *mbrevstrpbrk(const char *head, const char *accept, const char *index);
|
||||
#endif
|
||||
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || defined(ENABLE_JUSTIFY))
|
||||
bool has_blank_mbchars(const char *s);
|
||||
bool has_blank_char(const char *s);
|
||||
#endif
|
||||
#ifdef ENABLE_UTF8
|
||||
bool is_valid_unicode(wchar_t wc);
|
||||
@@ -240,17 +239,21 @@ bool is_valid_unicode(wchar_t wc);
|
||||
void set_colorpairs(void);
|
||||
void color_init(void);
|
||||
void color_update(void);
|
||||
void check_the_multis(filestruct *line);
|
||||
void alloc_multidata_if_needed(filestruct *fileptr);
|
||||
void check_the_multis(linestruct *line);
|
||||
void alloc_multidata_if_needed(linestruct *fileptr);
|
||||
void precalc_multicolorinfo(void);
|
||||
#endif
|
||||
|
||||
/* Most functions in cut.c. */
|
||||
void cutbuffer_reset(void);
|
||||
void do_delete(void);
|
||||
void do_backspace(void);
|
||||
#ifndef NANO_TINY
|
||||
void chop_previous_word(void);
|
||||
void chop_next_word(void);
|
||||
void cut_marked(bool *right_side_up);
|
||||
#endif
|
||||
void do_cut_text(bool copy_text, bool marked, bool cut_till_eof, bool append);
|
||||
bool is_cuttable(bool test_cliff);
|
||||
void do_cut_text_void(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_copy_text(void);
|
||||
@@ -340,14 +343,14 @@ void do_help_void(void);
|
||||
/* Most functions in history.c. */
|
||||
#ifdef ENABLE_HISTORIES
|
||||
void history_init(void);
|
||||
void history_reset(const filestruct *h);
|
||||
void update_history(filestruct **h, const char *s);
|
||||
char *get_history_older(filestruct **h);
|
||||
char *get_history_newer(filestruct **h);
|
||||
void history_reset(const linestruct *h);
|
||||
void update_history(linestruct **h, const char *s);
|
||||
char *get_history_older(linestruct **h);
|
||||
char *get_history_newer(linestruct **h);
|
||||
void get_history_older_void(void);
|
||||
void get_history_newer_void(void);
|
||||
#ifdef ENABLE_TABCOMP
|
||||
char *get_history_completion(filestruct **h, char *s, size_t len);
|
||||
char *get_history_completion(linestruct **h, char *s, size_t len);
|
||||
#endif
|
||||
bool have_statedir(void);
|
||||
void load_history(void);
|
||||
@@ -363,8 +366,8 @@ void to_last_line(void);
|
||||
void do_page_up(void);
|
||||
void do_page_down(void);
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
void do_para_begin(void);
|
||||
void do_para_end(void);
|
||||
void do_para_begin(linestruct **line);
|
||||
void do_para_end(linestruct **line);
|
||||
void do_para_begin_void(void);
|
||||
void do_para_end_void(void);
|
||||
#endif
|
||||
@@ -386,20 +389,20 @@ void do_left(void);
|
||||
void do_right(void);
|
||||
|
||||
/* Most functions in nano.c. */
|
||||
filestruct *make_new_node(filestruct *prevnode);
|
||||
void splice_node(filestruct *afterthis, filestruct *newnode);
|
||||
void unlink_node(filestruct *fileptr);
|
||||
void delete_node(filestruct *fileptr);
|
||||
filestruct *copy_filestruct(const filestruct *src);
|
||||
void free_filestruct(filestruct *src);
|
||||
void renumber(filestruct *line);
|
||||
partition *partition_filestruct(filestruct *top, size_t top_x,
|
||||
filestruct *bot, size_t bot_x);
|
||||
void unpartition_filestruct(partition **p);
|
||||
void extract_buffer(filestruct **file_top, filestruct **file_bot,
|
||||
filestruct *top, size_t top_x, filestruct *bot, size_t bot_x);
|
||||
void ingraft_buffer(filestruct *somebuffer);
|
||||
void copy_from_buffer(filestruct *somebuffer);
|
||||
linestruct *make_new_node(linestruct *prevnode);
|
||||
void splice_node(linestruct *afterthis, linestruct *newnode);
|
||||
void unlink_node(linestruct *fileptr);
|
||||
void delete_node(linestruct *fileptr);
|
||||
linestruct *copy_buffer(const linestruct *src);
|
||||
void free_lines(linestruct *src);
|
||||
void renumber(linestruct *line);
|
||||
partition *partition_buffer(linestruct *top, size_t top_x,
|
||||
linestruct *bot, size_t bot_x);
|
||||
void unpartition_buffer(partition **p);
|
||||
void extract_buffer(linestruct **file_top, linestruct **file_bot,
|
||||
linestruct *top, size_t top_x, linestruct *bot, size_t bot_x);
|
||||
void ingraft_buffer(linestruct *somebuffer);
|
||||
void copy_from_buffer(linestruct *somebuffer);
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
void unlink_opennode(openfilestruct *fileptr);
|
||||
void delete_opennode(openfilestruct *fileptr);
|
||||
@@ -435,7 +438,6 @@ void confirm_margin(void);
|
||||
#endif
|
||||
void unbound_key(int code);
|
||||
bool okay_for_view(const sc *shortcut);
|
||||
int do_input(bool allow_funcs);
|
||||
void do_output(char *output, size_t output_len, bool allow_cntrls);
|
||||
|
||||
/* Most functions in prompt.c. */
|
||||
@@ -457,7 +459,7 @@ size_t get_statusbar_page_start(size_t start_col, size_t column);
|
||||
void put_cursor_at_end_of_answer(void);
|
||||
void add_or_remove_pipe_symbol_from_answer(void);
|
||||
int do_prompt(bool allow_tabs, bool allow_files,
|
||||
int menu, const char *curranswer, filestruct **history_list,
|
||||
int menu, const char *curranswer, linestruct **history_list,
|
||||
void (*refresh_func)(void), const char *msg, ...);
|
||||
int do_yesno_prompt(bool all, const char *msg);
|
||||
|
||||
@@ -473,7 +475,7 @@ void do_rcfiles(void);
|
||||
/* Most functions in search.c. */
|
||||
void tidy_up_after_search(void);
|
||||
int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
size_t *match_len, bool skipone, const filestruct *begin, size_t begin_x);
|
||||
size_t *match_len, bool skipone, const linestruct *begin, size_t begin_x);
|
||||
void do_search(void);
|
||||
void do_search_forward(void);
|
||||
void do_search_backward(void);
|
||||
@@ -482,7 +484,7 @@ void do_findnext(void);
|
||||
void not_found_msg(const char *str);
|
||||
void go_looking(void);
|
||||
ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
const filestruct *real_current, size_t *real_current_x);
|
||||
const linestruct *real_current, size_t *real_current_x);
|
||||
void do_replace(void);
|
||||
void ask_for_replacement(void);
|
||||
void goto_line_posx(ssize_t line, size_t pos_x);
|
||||
@@ -497,12 +499,6 @@ void do_find_bracket(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_mark(void);
|
||||
#endif
|
||||
void do_delete(void);
|
||||
void do_backspace(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_cut_prev_word(void);
|
||||
void do_cut_next_word(void);
|
||||
#endif
|
||||
void do_tab(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_indent(void);
|
||||
@@ -525,7 +521,7 @@ void update_undo(undo_type action);
|
||||
#endif /* !NANO_TINY */
|
||||
#ifdef ENABLE_WRAPPING
|
||||
void wrap_reset(void);
|
||||
bool do_wrap(filestruct *line);
|
||||
bool do_wrap(linestruct *line);
|
||||
#endif
|
||||
#if defined(ENABLE_HELP) || defined(ENABLED_WRAPORJUSTIFY)
|
||||
ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl);
|
||||
@@ -534,9 +530,8 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl);
|
||||
size_t indent_length(const char *line);
|
||||
#endif
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
void justify_format(filestruct *paragraph, size_t skip);
|
||||
bool begpar(const filestruct *const foo, int depth);
|
||||
bool inpar(const filestruct *const foo);
|
||||
bool begpar(const linestruct *const foo, int depth);
|
||||
bool inpar(const linestruct *const foo);
|
||||
void do_justify(bool full_justify);
|
||||
void do_justify_void(void);
|
||||
void do_full_justify(void);
|
||||
@@ -562,14 +557,12 @@ int digits(ssize_t n);
|
||||
#endif
|
||||
bool parse_num(const char *str, ssize_t *val);
|
||||
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column);
|
||||
void snuggly_fit(char **str);
|
||||
void null_at(char **data, size_t index);
|
||||
void unsunder(char *str, size_t true_len);
|
||||
void sunder(char *str);
|
||||
#if !defined(ENABLE_TINY) || defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
|
||||
void free_chararray(char **array, size_t len);
|
||||
#endif
|
||||
const char *fixbounds(const char *r);
|
||||
#ifdef ENABLE_SPELLER
|
||||
bool is_separate_word(size_t position, size_t length, const char *buf);
|
||||
#endif
|
||||
@@ -591,13 +584,13 @@ void new_magicline(void);
|
||||
void remove_magicline(void);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
void mark_order(const filestruct **top, size_t *top_x,
|
||||
const filestruct **bot, size_t *bot_x, bool *right_side_up);
|
||||
void get_range(const filestruct **top, const filestruct **bot);
|
||||
void mark_order(const linestruct **top, size_t *top_x,
|
||||
const linestruct **bot, size_t *bot_x, bool *right_side_up);
|
||||
void get_range(const linestruct **top, const linestruct **bot);
|
||||
#endif
|
||||
size_t get_totsize(const filestruct *begin, const filestruct *end);
|
||||
size_t get_totsize(const linestruct *begin, const linestruct *end);
|
||||
#ifndef NANO_TINY
|
||||
filestruct *fsfromline(ssize_t lineno);
|
||||
linestruct *fsfromline(ssize_t lineno);
|
||||
#endif
|
||||
|
||||
/* Most functions in winio.c. */
|
||||
@@ -627,7 +620,8 @@ void blank_statusbar(void);
|
||||
void wipe_statusbar(void);
|
||||
void blank_bottombars(void);
|
||||
void check_statusblank(void);
|
||||
char *display_string(const char *buf, size_t column, size_t span, bool isdata);
|
||||
char *display_string(const char *buf, size_t column, size_t span,
|
||||
bool isdata, bool isprompt);
|
||||
void titlebar(const char *path);
|
||||
void statusbar(const char *msg);
|
||||
void warn_and_shortly_pause(const char *msg);
|
||||
@@ -635,28 +629,28 @@ void statusline(message_type importance, const char *msg, ...);
|
||||
void bottombars(int menu);
|
||||
void post_one_key(const char *keystroke, const char *tag, int width);
|
||||
void place_the_cursor(void);
|
||||
void edit_draw(filestruct *fileptr, const char *converted,
|
||||
void edit_draw(linestruct *fileptr, const char *converted,
|
||||
int line, size_t from_col);
|
||||
int update_line(filestruct *fileptr, size_t index);
|
||||
int update_line(linestruct *fileptr, size_t index);
|
||||
#ifndef NANO_TINY
|
||||
int update_softwrapped_line(filestruct *fileptr);
|
||||
int update_softwrapped_line(linestruct *fileptr);
|
||||
#endif
|
||||
bool line_needs_update(const size_t old_column, const size_t new_column);
|
||||
int go_back_chunks(int nrows, filestruct **line, size_t *leftedge);
|
||||
int go_forward_chunks(int nrows, filestruct **line, size_t *leftedge);
|
||||
int go_back_chunks(int nrows, linestruct **line, size_t *leftedge);
|
||||
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_chunk_and_edge(size_t column, filestruct *line, size_t *leftedge);
|
||||
size_t chunk_for(size_t column, filestruct *line);
|
||||
size_t leftedge_for(size_t column, filestruct *line);
|
||||
size_t number_of_chunks_in(filestruct *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);
|
||||
size_t number_of_chunks_in(linestruct *line);
|
||||
void ensure_firstcolumn_is_aligned(void);
|
||||
#endif
|
||||
size_t actual_last_column(size_t leftedge, size_t column);
|
||||
void edit_redraw(filestruct *old_current, update_type manner);
|
||||
void edit_redraw(linestruct *old_current, update_type manner);
|
||||
void edit_refresh(void);
|
||||
void adjust_viewport(update_type location);
|
||||
void total_redraw(void);
|
||||
|
||||
211
src/rcfile.c
211
src/rcfile.c
@@ -1,9 +1,9 @@
|
||||
/**************************************************************************
|
||||
* rcfile.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2001-2011, 2013-2018 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2001-2011, 2013-2019 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014 Mike Frysinger *
|
||||
* Copyright (C) 2014-2018 Benno Schulenberg *
|
||||
* Copyright (C) 2014-2019 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,18 +41,24 @@ static const rcoption rcopts[] = {
|
||||
{"boldtext", BOLD_TEXT},
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
{"brackets", 0},
|
||||
#endif
|
||||
#ifdef ENABLE_WRAPPING
|
||||
{"breaklonglines", BREAK_LONG_LINES},
|
||||
#endif
|
||||
{"constantshow", CONSTANT_SHOW},
|
||||
{"emptyline", EMPTY_LINE},
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
{"fill", 0},
|
||||
#endif
|
||||
{"finalnewline", FINAL_NEWLINE},
|
||||
#ifdef ENABLE_HISTORIES
|
||||
{"historylog", HISTORYLOG},
|
||||
#endif
|
||||
{"jumpyscrolling", JUMPY_SCROLLING},
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
{"linenumbers", LINE_NUMBERS},
|
||||
#endif
|
||||
{"morespace", MORE_SPACE},
|
||||
{"morespace", MORE_SPACE}, /* Deprecated; remove in 2021. */
|
||||
#ifdef ENABLE_MOUSE
|
||||
{"mouse", USE_MOUSE},
|
||||
#endif
|
||||
@@ -60,10 +66,10 @@ static const rcoption rcopts[] = {
|
||||
{"multibuffer", MULTIBUFFER},
|
||||
#endif
|
||||
{"nohelp", NO_HELP},
|
||||
{"nonewlines", NO_NEWLINES},
|
||||
{"nonewlines", NO_NEWLINES}, /* Deprecated; remove in 2021. */
|
||||
{"nopauses", NO_PAUSES},
|
||||
#ifdef ENABLE_WRAPPING
|
||||
{"nowrap", NO_WRAP},
|
||||
{"nowrap", NO_WRAP}, /* Deprecated; remove in 2021. */
|
||||
#endif
|
||||
#ifdef ENABLE_OPERATINGDIR
|
||||
{"operatingdir", 0},
|
||||
@@ -77,8 +83,8 @@ static const rcoption rcopts[] = {
|
||||
{"quotestr", 0},
|
||||
#endif
|
||||
{"quickblank", QUICK_BLANK},
|
||||
{"rawsequences", RAW_SEQUENCES},
|
||||
{"rebinddelete", REBIND_DELETE},
|
||||
{"rebindkeypad", REBIND_KEYPAD},
|
||||
{"regexp", USE_REGEXP},
|
||||
#ifdef ENABLE_SPELLER
|
||||
{"speller", 0},
|
||||
@@ -95,16 +101,14 @@ static const rcoption rcopts[] = {
|
||||
{"backup", BACKUP_FILE},
|
||||
{"backupdir", 0},
|
||||
{"casesensitive", CASE_SENSITIVE},
|
||||
{"cut", CUT_FROM_CURSOR}, /* deprecated form, remove end of 2018 */
|
||||
{"cutfromcursor", CUT_FROM_CURSOR},
|
||||
{"justifytrim", TRIM_BLANKS}, /* deprecated form, remove end of 2018 */
|
||||
{"guidestripe", 0},
|
||||
{"locking", LOCKING},
|
||||
{"matchbrackets", 0},
|
||||
{"noconvert", NO_CONVERT},
|
||||
{"quiet", QUIET},
|
||||
{"showcursor", SHOW_CURSOR},
|
||||
{"smarthome", SMART_HOME},
|
||||
{"smooth", SMOOTH_SCROLL},
|
||||
{"smooth", SMOOTH_SCROLL}, /* Deprecated; remove in 2021. */
|
||||
{"softwrap", SOFTWRAP},
|
||||
{"tabstospaces", TABS_TO_SPACES},
|
||||
{"trimblanks", TRIM_BLANKS},
|
||||
@@ -117,6 +121,7 @@ static const rcoption rcopts[] = {
|
||||
#ifdef ENABLE_COLOR
|
||||
{"titlecolor", 0},
|
||||
{"numbercolor", 0},
|
||||
{"stripecolor", 0},
|
||||
{"selectedcolor", 0},
|
||||
{"statuscolor", 0},
|
||||
{"errorcolor", 0},
|
||||
@@ -243,15 +248,14 @@ char *parse_next_regex(char *ptr)
|
||||
bool nregcomp(const char *regex, int compile_flags)
|
||||
{
|
||||
regex_t preg;
|
||||
const char *r = fixbounds(regex);
|
||||
int rc = regcomp(&preg, r, compile_flags);
|
||||
int rc = regcomp(&preg, regex, compile_flags);
|
||||
|
||||
if (rc != 0) {
|
||||
size_t len = regerror(rc, &preg, NULL, 0);
|
||||
char *str = charalloc(len);
|
||||
|
||||
regerror(rc, &preg, str, len);
|
||||
rcfile_error(N_("Bad regex \"%s\": %s"), r, str);
|
||||
rcfile_error(N_("Bad regex \"%s\": %s"), regex, str);
|
||||
free(str);
|
||||
}
|
||||
|
||||
@@ -344,7 +348,8 @@ void parse_binding(char *ptr, bool dobind)
|
||||
{
|
||||
char *keyptr = NULL, *keycopy = NULL, *funcptr = NULL, *menuptr = NULL;
|
||||
sc *s, *newsc = NULL;
|
||||
int menu;
|
||||
int menu, mask = 0;
|
||||
subnfunc *f;
|
||||
|
||||
if (*ptr == '\0') {
|
||||
rcfile_error(N_("Missing key name"));
|
||||
@@ -429,70 +434,65 @@ void parse_binding(char *ptr, bool dobind)
|
||||
goto free_things;
|
||||
}
|
||||
|
||||
if (dobind) {
|
||||
subnfunc *f;
|
||||
int mask = 0;
|
||||
/* Wipe the given shortcut from the given menu. */
|
||||
for (s = sclist; s != NULL; s = s->next)
|
||||
if ((s->menus & menu) && strcmp(s->keystr, keycopy) == 0)
|
||||
s->menus &= ~menu;
|
||||
|
||||
/* Tally up the menus where the function exists. */
|
||||
for (f = allfuncs; f != NULL; f = f->next)
|
||||
if (f->func == newsc->func)
|
||||
mask = mask | f->menus;
|
||||
/* When unbinding, we are done now. */
|
||||
if (!dobind)
|
||||
goto free_things;
|
||||
|
||||
/* Tally up the menus where the function exists. */
|
||||
for (f = allfuncs; f != NULL; f = f->next)
|
||||
if (f->func == newsc->func)
|
||||
mask = mask | f->menus;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Handle the special case of the toggles. */
|
||||
if (newsc->func == do_toggle_void)
|
||||
mask = MMAIN;
|
||||
/* Handle the special case of the toggles. */
|
||||
if (newsc->func == do_toggle_void)
|
||||
mask = MMAIN;
|
||||
#endif
|
||||
#ifdef ENABLE_NANORC
|
||||
/* Handle the special case of a key defined as a string. */
|
||||
if (newsc->func == (functionptrtype)implant)
|
||||
mask = MMOST | MHELP;
|
||||
/* Handle the special case of a key defined as a string. */
|
||||
if (newsc->func == (functionptrtype)implant)
|
||||
mask = MMOST | MHELP;
|
||||
#endif
|
||||
/* Now limit the given menu to those where the function exists. */
|
||||
menu = menu & (is_universal(newsc->func) ? MMOST : mask);
|
||||
/* Now limit the given menu to those where the function exists. */
|
||||
menu = menu & (is_universal(newsc->func) ? MMOST : mask);
|
||||
|
||||
if (!menu) {
|
||||
if (!ISSET(RESTRICTED))
|
||||
rcfile_error(N_("Function '%s' does not exist in menu '%s'"),
|
||||
funcptr, menuptr);
|
||||
goto free_things;
|
||||
}
|
||||
|
||||
newsc->menus = menu;
|
||||
assign_keyinfo(newsc, keycopy, 0);
|
||||
|
||||
/* Do not allow rebinding a frequent escape-sequence starter: Esc [. */
|
||||
if (newsc->meta && newsc->keycode == 91) {
|
||||
rcfile_error(N_("Sorry, keystroke \"%s\" may not be rebound"), newsc->keystr);
|
||||
goto free_things;
|
||||
}
|
||||
if (!menu) {
|
||||
if (!ISSET(RESTRICTED))
|
||||
rcfile_error(N_("Function '%s' does not exist in menu '%s'"),
|
||||
funcptr, menuptr);
|
||||
goto free_things;
|
||||
}
|
||||
|
||||
/* Now find and delete any existing same shortcut in the menu(s). */
|
||||
for (s = sclist; s != NULL; s = s->next) {
|
||||
if ((s->menus & menu) && !strcmp(s->keystr, keycopy))
|
||||
s->menus &= ~menu;
|
||||
}
|
||||
newsc->menus = menu;
|
||||
assign_keyinfo(newsc, keycopy, 0);
|
||||
|
||||
if (dobind) {
|
||||
#ifndef NANO_TINY
|
||||
/* If this is a toggle, copy its sequence number. */
|
||||
if (newsc->func == do_toggle_void) {
|
||||
for (s = sclist; s != NULL; s = s->next)
|
||||
if (s->func == do_toggle_void && s->toggle == newsc->toggle)
|
||||
newsc->ordinal = s->ordinal;
|
||||
} else
|
||||
newsc->ordinal = 0;
|
||||
#endif
|
||||
/* Add the new shortcut at the start of the list. */
|
||||
newsc->next = sclist;
|
||||
sclist = newsc;
|
||||
/* Disallow rebinding ^[ and frequent escape-sequence starter "Esc [". */
|
||||
if ((!newsc->meta && newsc->keycode == ESC_CODE) ||
|
||||
(newsc->meta && newsc->keycode == '[')) {
|
||||
rcfile_error(N_("Keystroke %s may not be rebound"), keycopy);
|
||||
free_things:
|
||||
free(keycopy);
|
||||
free(newsc);
|
||||
return;
|
||||
}
|
||||
|
||||
free_things:
|
||||
free(newsc);
|
||||
free(keycopy);
|
||||
#ifndef NANO_TINY
|
||||
/* If this is a toggle, find and copy its sequence number. */
|
||||
if (newsc->func == do_toggle_void) {
|
||||
for (s = sclist; s != NULL; s = s->next)
|
||||
if (s->func == do_toggle_void && s->toggle == newsc->toggle)
|
||||
newsc->ordinal = s->ordinal;
|
||||
} else
|
||||
newsc->ordinal = 0;
|
||||
#endif
|
||||
/* Add the new shortcut at the start of the list. */
|
||||
newsc->next = sclist;
|
||||
sclist = newsc;
|
||||
}
|
||||
|
||||
/* Verify that the given file exists, is not a folder nor a device. */
|
||||
@@ -543,31 +543,36 @@ static void parse_one_include(char *file)
|
||||
/* Expand globs in the passed name, and parse the resultant files. */
|
||||
void parse_includes(char *ptr)
|
||||
{
|
||||
char *option, *nanorc_save = nanorc, *expanded;
|
||||
size_t lineno_save = lineno, i;
|
||||
char *pattern, *expanded;
|
||||
char *was_nanorc = nanorc;
|
||||
size_t was_lineno = lineno;
|
||||
glob_t files;
|
||||
int result;
|
||||
|
||||
option = ptr;
|
||||
if (*option == '"')
|
||||
option++;
|
||||
pattern = ptr;
|
||||
if (*pattern == '"')
|
||||
pattern++;
|
||||
ptr = parse_argument(ptr);
|
||||
|
||||
/* Expand tildes first, then the globs. */
|
||||
expanded = real_dir_from_tilde(option);
|
||||
/* Expand a tilde first, then try to match the globbing pattern. */
|
||||
expanded = real_dir_from_tilde(pattern);
|
||||
result = glob(expanded, GLOB_ERR|GLOB_NOSORT, NULL, &files);
|
||||
|
||||
if (glob(expanded, GLOB_ERR|GLOB_NOSORT, NULL, &files) == 0) {
|
||||
for (i = 0; i < files.gl_pathc; ++i)
|
||||
/* If there are matches, process each of them. Otherwise, only
|
||||
* report an error if it's something other than zero matches. */
|
||||
if (result == 0) {
|
||||
for (size_t i = 0; i < files.gl_pathc; ++i)
|
||||
parse_one_include(files.gl_pathv[i]);
|
||||
} else
|
||||
rcfile_error(_("Error expanding %s: %s"), option, strerror(errno));
|
||||
} else if (result != GLOB_NOMATCH)
|
||||
rcfile_error(_("Error expanding %s: %s"), pattern, strerror(errno));
|
||||
|
||||
globfree(&files);
|
||||
free(expanded);
|
||||
|
||||
/* We're done with the included file(s). Restore the original
|
||||
* filename and line number position. */
|
||||
nanorc = nanorc_save;
|
||||
lineno = lineno_save;
|
||||
nanorc = was_nanorc;
|
||||
lineno = was_lineno;
|
||||
}
|
||||
|
||||
/* Return the short value corresponding to the color named in colorname,
|
||||
@@ -1085,6 +1090,8 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
|
||||
color_combo[TITLE_BAR] = parse_interface_color(option);
|
||||
else if (strcasecmp(rcopts[i].name, "numbercolor") == 0)
|
||||
color_combo[LINE_NUMBER] = parse_interface_color(option);
|
||||
else if (strcasecmp(rcopts[i].name, "stripecolor") == 0)
|
||||
color_combo[GUIDE_STRIPE] = parse_interface_color(option);
|
||||
else if (strcasecmp(rcopts[i].name, "selectedcolor") == 0)
|
||||
color_combo[SELECTED_TEXT] = parse_interface_color(option);
|
||||
else if (strcasecmp(rcopts[i].name, "statuscolor") == 0)
|
||||
@@ -1104,45 +1111,48 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
|
||||
#endif
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
if (strcasecmp(rcopts[i].name, "fill") == 0) {
|
||||
if (!parse_num(option, &wrap_at)) {
|
||||
if (!parse_num(option, &fill)) {
|
||||
rcfile_error(N_("Requested fill size \"%s\" is invalid"),
|
||||
option);
|
||||
wrap_at = -COLUMNS_FROM_EOL;
|
||||
} else
|
||||
UNSET(NO_WRAP);
|
||||
fill = -COLUMNS_FROM_EOL;
|
||||
}
|
||||
free(option);
|
||||
} else
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
if (strcasecmp(rcopts[i].name, "matchbrackets") == 0) {
|
||||
matchbrackets = option;
|
||||
if (has_blank_mbchars(matchbrackets)) {
|
||||
rcfile_error(N_("Non-blank characters required"));
|
||||
free(matchbrackets);
|
||||
matchbrackets = NULL;
|
||||
if (strcasecmp(rcopts[i].name, "guidestripe") == 0) {
|
||||
if (!parse_num(option, &stripe_column) || stripe_column <= 0) {
|
||||
rcfile_error(N_("Guide column \"%s\" is invalid"), option);
|
||||
stripe_column = 0;
|
||||
}
|
||||
free(option);
|
||||
}
|
||||
if (strcasecmp(rcopts[i].name, "matchbrackets") == 0) {
|
||||
if (has_blank_char(option)) {
|
||||
rcfile_error(N_("Non-blank characters required"));
|
||||
free(option);
|
||||
} else
|
||||
matchbrackets = option;
|
||||
} else if (strcasecmp(rcopts[i].name, "whitespace") == 0) {
|
||||
whitespace = option;
|
||||
if (mbstrlen(whitespace) != 2 || strlenpt(whitespace) != 2) {
|
||||
if (mbstrlen(option) != 2 || strlenpt(option) != 2) {
|
||||
rcfile_error(N_("Two single-column characters required"));
|
||||
free(whitespace);
|
||||
whitespace = NULL;
|
||||
free(option);
|
||||
} else {
|
||||
whitespace_len[0] = parse_mbchar(whitespace, NULL, NULL);
|
||||
whitespace_len[1] = parse_mbchar(whitespace +
|
||||
whitespace_len[0], NULL, NULL);
|
||||
whitespace = option;
|
||||
whitelen[0] = parse_mbchar(whitespace, NULL, NULL);
|
||||
whitelen[1] = parse_mbchar(whitespace + whitelen[0], NULL, NULL);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
if (strcasecmp(rcopts[i].name, "punct") == 0) {
|
||||
if (has_blank_mbchars(option)) {
|
||||
if (has_blank_char(option)) {
|
||||
rcfile_error(N_("Non-blank characters required"));
|
||||
free(option);
|
||||
} else
|
||||
punct = option;
|
||||
} else if (strcasecmp(rcopts[i].name, "brackets") == 0) {
|
||||
if (has_blank_mbchars(option)) {
|
||||
if (has_blank_char(option)) {
|
||||
rcfile_error(N_("Non-blank characters required"));
|
||||
free(option);
|
||||
} else
|
||||
@@ -1228,13 +1238,6 @@ void do_rcfiles(void)
|
||||
nanorc = mallocstrcpy(nanorc, SYSCONFDIR "/nanorc");
|
||||
parse_one_nanorc();
|
||||
|
||||
/* When configured with --disable-wrapping-as-root, turn wrapping off
|
||||
* for root, so that only root's .nanorc or --fill can turn it on. */
|
||||
#ifdef DISABLE_ROOTWRAPPING
|
||||
if (geteuid() == NANO_ROOT_UID)
|
||||
SET(NO_WRAP);
|
||||
#endif
|
||||
|
||||
get_homedir();
|
||||
xdgconfdir = getenv("XDG_CONFIG_HOME");
|
||||
|
||||
|
||||
56
src/search.c
56
src/search.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* search.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2019 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2015-2018 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -35,7 +35,7 @@ static bool have_compiled_regexp = FALSE;
|
||||
* Return TRUE if the expression is valid, and FALSE otherwise. */
|
||||
bool regexp_init(const char *regexp)
|
||||
{
|
||||
int value = regcomp(&search_regexp, fixbounds(regexp),
|
||||
int value = regcomp(&search_regexp, regexp,
|
||||
NANO_REG_EXTENDED | (ISSET(CASE_SENSITIVE) ? 0 : REG_ICASE));
|
||||
|
||||
/* If regex compilation failed, show the error message. */
|
||||
@@ -83,7 +83,7 @@ void search_init(bool replacing, bool keep_the_answer)
|
||||
|
||||
/* If something was searched for earlier, include it in the prompt. */
|
||||
if (*last_search != '\0') {
|
||||
char *disp = display_string(last_search, 0, COLS / 3, FALSE);
|
||||
char *disp = display_string(last_search, 0, COLS / 3, FALSE, FALSE);
|
||||
|
||||
thedefault = charalloc(strlen(disp) + 7);
|
||||
/* We use (COLS / 3) here because we need to see more on the line. */
|
||||
@@ -178,13 +178,13 @@ void search_init(bool replacing, bool keep_the_answer)
|
||||
* found something, 0 when nothing, and -2 on cancel. When match_len is
|
||||
* not NULL, set it to the length of the found string, if any. */
|
||||
int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
size_t *match_len, bool skipone, const filestruct *begin, size_t begin_x)
|
||||
size_t *match_len, bool skipone, const linestruct *begin, size_t begin_x)
|
||||
{
|
||||
size_t found_len = strlen(needle);
|
||||
/* The length of a match -- will be recomputed for a regex. */
|
||||
int feedback = 0;
|
||||
/* When bigger than zero, show and wipe the "Searching..." message. */
|
||||
filestruct *line = openfile->current;
|
||||
linestruct *line = openfile->current;
|
||||
/* The line that we will search through now. */
|
||||
const char *from = line->data + openfile->current_x;
|
||||
/* The point in the line from where we start searching. */
|
||||
@@ -279,7 +279,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
if (ISSET(BACKWARDS_SEARCH))
|
||||
line = openfile->filebot;
|
||||
else
|
||||
line = openfile->fileage;
|
||||
line = openfile->filetop;
|
||||
|
||||
if (modus == JUSTFIND) {
|
||||
statusbar(_("Search Wrapped"));
|
||||
@@ -388,7 +388,7 @@ void do_findnext(void)
|
||||
/* Report on the status bar that the given string was not found. */
|
||||
void not_found_msg(const char *str)
|
||||
{
|
||||
char *disp = display_string(str, 0, (COLS / 2) + 1, FALSE);
|
||||
char *disp = display_string(str, 0, (COLS / 2) + 1, FALSE, FALSE);
|
||||
size_t numchars = actual_x(disp, strnlenpt(disp, COLS / 2));
|
||||
|
||||
statusline(HUSH, _("\"%.*s%s\" not found"), numchars, disp,
|
||||
@@ -400,7 +400,7 @@ void not_found_msg(const char *str)
|
||||
* the string occurs only once. */
|
||||
void go_looking(void)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
linestruct *was_current = openfile->current;
|
||||
size_t was_current_x = openfile->current_x;
|
||||
#ifdef DEBUG
|
||||
clock_t start = clock();
|
||||
@@ -512,7 +512,7 @@ char *replace_line(const char *needle)
|
||||
* is replaced by a shorter word. Return -1 if needle isn't found, -2 if
|
||||
* the seeking is aborted, else the number of replacements performed. */
|
||||
ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
const filestruct *real_current, size_t *real_current_x)
|
||||
const linestruct *real_current, size_t *real_current_x)
|
||||
{
|
||||
ssize_t numreplaced = -1;
|
||||
size_t match_len;
|
||||
@@ -520,8 +520,8 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
bool skipone = ISSET(BACKWARDS_SEARCH);
|
||||
int modus = REPLACING;
|
||||
#ifndef NANO_TINY
|
||||
filestruct *was_mark = openfile->mark;
|
||||
filestruct *top, *bot;
|
||||
linestruct *was_mark = openfile->mark;
|
||||
linestruct *top, *bot;
|
||||
size_t top_x, bot_x;
|
||||
bool right_side_up = FALSE;
|
||||
/* TRUE if (mark_begin, mark_begin_x) is the top of the mark,
|
||||
@@ -529,8 +529,8 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
|
||||
/* If the mark is on, frame the region, and turn the mark off. */
|
||||
if (openfile->mark) {
|
||||
mark_order((const filestruct **)&top, &top_x,
|
||||
(const filestruct **)&bot, &bot_x, &right_side_up);
|
||||
mark_order((const linestruct **)&top, &top_x,
|
||||
(const linestruct **)&bot, &bot_x, &right_side_up);
|
||||
openfile->mark = NULL;
|
||||
modus = INREGION;
|
||||
|
||||
@@ -548,7 +548,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
came_full_circle = FALSE;
|
||||
|
||||
while (TRUE) {
|
||||
int i = 0;
|
||||
int choice = 0;
|
||||
int result = findnextstr(needle, whole_word_only, modus,
|
||||
&match_len, skipone, real_current, *real_current_x);
|
||||
|
||||
@@ -584,21 +584,21 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
edit_refresh();
|
||||
|
||||
/* TRANSLATORS: This is a prompt. */
|
||||
i = do_yesno_prompt(TRUE, _("Replace this instance?"));
|
||||
choice = do_yesno_prompt(TRUE, _("Replace this instance?"));
|
||||
|
||||
spotlighted = FALSE;
|
||||
|
||||
if (i == -1) /* The replacing was cancelled. */
|
||||
if (choice == -1) /* The replacing was cancelled. */
|
||||
break;
|
||||
else if (i == 2)
|
||||
else if (choice == 2)
|
||||
replaceall = TRUE;
|
||||
|
||||
/* When "No" or moving backwards, the search routine should
|
||||
* first move one character further before continuing. */
|
||||
skipone = (i == 0 || ISSET(BACKWARDS_SEARCH));
|
||||
skipone = (choice == 0 || ISSET(BACKWARDS_SEARCH));
|
||||
}
|
||||
|
||||
if (i == 1 || replaceall) { /* Yes, replace it. */
|
||||
if (choice == 1 || replaceall) { /* Yes, replace it. */
|
||||
char *copy;
|
||||
size_t length_change;
|
||||
|
||||
@@ -680,8 +680,8 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
#endif
|
||||
|
||||
/* If "automatic newline" is enabled, and text has been added to the
|
||||
* magicline, make a new magicline. */
|
||||
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
|
||||
* magic line, make a new magic line. */
|
||||
if (ISSET(FINAL_NEWLINE) && openfile->filebot->data[0] != '\0')
|
||||
new_magicline();
|
||||
|
||||
return numreplaced;
|
||||
@@ -701,7 +701,7 @@ void do_replace(void)
|
||||
/* Ask the user what the already given search string should be replaced with. */
|
||||
void ask_for_replacement(void)
|
||||
{
|
||||
filestruct *edittop_save, *begin;
|
||||
linestruct *edittop_save, *begin;
|
||||
size_t firstcolumn_save, begin_x;
|
||||
ssize_t numreplaced;
|
||||
int i = do_prompt(FALSE, FALSE, MREPLACEWITH, NULL, &replace_history,
|
||||
@@ -744,7 +744,7 @@ void ask_for_replacement(void)
|
||||
/* Go to the specified line and x position. */
|
||||
void goto_line_posx(ssize_t line, size_t pos_x)
|
||||
{
|
||||
for (openfile->current = openfile->fileage; line > 1 &&
|
||||
for (openfile->current = openfile->filetop; line > 1 &&
|
||||
openfile->current != openfile->filebot; line--)
|
||||
openfile->current = openfile->current->next;
|
||||
|
||||
@@ -804,7 +804,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
line = 1;
|
||||
|
||||
/* Iterate to the requested line. */
|
||||
for (openfile->current = openfile->fileage; line > 1 &&
|
||||
for (openfile->current = openfile->filetop; line > 1 &&
|
||||
openfile->current != openfile->filebot; line--)
|
||||
openfile->current = openfile->current->next;
|
||||
|
||||
@@ -833,7 +833,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
filestruct *currentline = openfile->current;
|
||||
linestruct *currentline = openfile->current;
|
||||
size_t leftedge = leftedge_for(xplustabs(), openfile->current);
|
||||
|
||||
rows_from_tail = (editwinrows / 2) - go_forward_chunks(
|
||||
@@ -846,7 +846,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
/* If the target line is close to the tail of the file, put the last
|
||||
* line or chunk on the bottom line of the screen; otherwise, just
|
||||
* center the target line. */
|
||||
if (rows_from_tail < editwinrows / 2 && ISSET(SMOOTH_SCROLL)) {
|
||||
if (rows_from_tail < editwinrows / 2 && !ISSET(JUMPY_SCROLLING)) {
|
||||
openfile->current_y = editwinrows - 1 - rows_from_tail;
|
||||
adjust_viewport(STATIONARY);
|
||||
} else
|
||||
@@ -868,7 +868,7 @@ void do_gotolinecolumn_void(void)
|
||||
* we found a match, and FALSE otherwise. */
|
||||
bool find_bracket_match(bool reverse, const char *bracket_set)
|
||||
{
|
||||
filestruct *fileptr = openfile->current;
|
||||
linestruct *fileptr = openfile->current;
|
||||
const char *rev_start = NULL, *found = NULL;
|
||||
|
||||
assert(mbstrlen(bracket_set) == 2);
|
||||
@@ -922,7 +922,7 @@ bool find_bracket_match(bool reverse, const char *bracket_set)
|
||||
* there is one. */
|
||||
void do_find_bracket(void)
|
||||
{
|
||||
filestruct *current_save;
|
||||
linestruct *current_save;
|
||||
size_t current_x_save;
|
||||
const char *ch;
|
||||
/* The location in matchbrackets of the bracket at the current
|
||||
|
||||
1344
src/text.c
1344
src/text.c
File diff suppressed because it is too large
Load Diff
65
src/utils.c
65
src/utils.c
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* utils.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999-2011, 2013-2019 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2016-2017 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
@@ -159,12 +159,6 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Reduce the memory allocation of a string to what is needed. */
|
||||
void snuggly_fit(char **string)
|
||||
{
|
||||
*string = charealloc(*string, strlen(*string) + 1);
|
||||
}
|
||||
|
||||
/* Null a string at a certain index and align it. */
|
||||
void null_at(char **data, size_t index)
|
||||
{
|
||||
@@ -206,37 +200,6 @@ void free_chararray(char **array, size_t len)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Fix the regex if we're on platforms which require an adjustment
|
||||
* from GNU-style to BSD-style word boundaries. */
|
||||
const char *fixbounds(const char *r)
|
||||
{
|
||||
#ifndef GNU_WORDBOUNDS
|
||||
int i, j = 0;
|
||||
char *r2 = charalloc(strlen(r) * 5);
|
||||
char *r3;
|
||||
|
||||
for (i = 0; i < strlen(r); i++) {
|
||||
if (r[i] != '\0' && r[i] == '\\' && (r[i + 1] == '>' || r[i + 1] == '<')) {
|
||||
strcpy(&r2[j], "[[:");
|
||||
r2[j + 3] = r[i + 1];
|
||||
strcpy(&r2[j + 4], ":]]");
|
||||
i++;
|
||||
j += 6;
|
||||
} else
|
||||
r2[j] = r[i];
|
||||
j++;
|
||||
}
|
||||
|
||||
r2[j] = '\0';
|
||||
r3 = mallocstrcpy(NULL, r2);
|
||||
free(r2);
|
||||
|
||||
return (const char *) r3;
|
||||
#endif /* !GNU_WORDBOUNDS */
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SPELLER
|
||||
/* Is the word starting at the given position in buf and of the given length
|
||||
* a separate word? That is: is it not part of a longer word?*/
|
||||
@@ -404,10 +367,10 @@ char *free_and_assign(char *dest, char *src)
|
||||
* get_page_start(column) < COLS). */
|
||||
size_t get_page_start(size_t column)
|
||||
{
|
||||
if (column < editwincols - 1 || ISSET(SOFTWRAP) || column == 0)
|
||||
if (column + 2 < editwincols || ISSET(SOFTWRAP) || column == 0)
|
||||
return 0;
|
||||
else if (editwincols > 8)
|
||||
return column - 7 - (column - 7) % (editwincols - 8);
|
||||
return column - 6 - (column - 6) % (editwincols - 8);
|
||||
else
|
||||
return column - (editwincols - 2);
|
||||
}
|
||||
@@ -474,7 +437,7 @@ size_t strlenpt(const char *text)
|
||||
return span;
|
||||
}
|
||||
|
||||
/* Append a new magicline to the end of the buffer. */
|
||||
/* Append a new magic line to the end of the buffer. */
|
||||
void new_magicline(void)
|
||||
{
|
||||
openfile->filebot->next = make_new_node(openfile->filebot);
|
||||
@@ -484,14 +447,14 @@ void new_magicline(void)
|
||||
}
|
||||
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
|
||||
/* Remove the magicline from the end of the buffer, if there is one and
|
||||
/* Remove the magic line from the end of the buffer, if there is one and
|
||||
* it isn't the only line in the file. */
|
||||
void remove_magicline(void)
|
||||
{
|
||||
if (openfile->filebot->data[0] == '\0' &&
|
||||
openfile->filebot != openfile->fileage) {
|
||||
openfile->filebot != openfile->filetop) {
|
||||
openfile->filebot = openfile->filebot->prev;
|
||||
free_filestruct(openfile->filebot->next);
|
||||
free_lines(openfile->filebot->next);
|
||||
openfile->filebot->next = NULL;
|
||||
openfile->totsize--;
|
||||
}
|
||||
@@ -502,8 +465,8 @@ void remove_magicline(void)
|
||||
/* Set (top, top_x) and (bot, bot_x) to the start and end "coordinates" of
|
||||
* the marked region. If right_side_up isn't NULL, set it to TRUE when the
|
||||
* mark is at the top of the marked region, and to FALSE otherwise. */
|
||||
void mark_order(const filestruct **top, size_t *top_x,
|
||||
const filestruct **bot, size_t *bot_x, bool *right_side_up)
|
||||
void mark_order(const linestruct **top, size_t *top_x,
|
||||
const linestruct **bot, size_t *bot_x, bool *right_side_up)
|
||||
{
|
||||
if ((openfile->current->lineno == openfile->mark->lineno &&
|
||||
openfile->current_x > openfile->mark_x) ||
|
||||
@@ -527,7 +490,7 @@ void mark_order(const filestruct **top, size_t *top_x,
|
||||
/* Get the set of lines to work on -- either just the current line, or the
|
||||
* first to last lines of the marked region. When the cursor (or mark) is
|
||||
* at the start of the last line of the region, exclude that line. */
|
||||
void get_range(const filestruct **top, const filestruct **bot)
|
||||
void get_range(const linestruct **top, const linestruct **bot)
|
||||
{
|
||||
if (!openfile->mark) {
|
||||
*top = openfile->current;
|
||||
@@ -545,9 +508,9 @@ void get_range(const filestruct **top, const filestruct **bot)
|
||||
}
|
||||
|
||||
/* Given a line number, return a pointer to the corresponding struct. */
|
||||
filestruct *fsfromline(ssize_t lineno)
|
||||
linestruct *fsfromline(ssize_t lineno)
|
||||
{
|
||||
filestruct *f = openfile->current;
|
||||
linestruct *f = openfile->current;
|
||||
|
||||
if (lineno <= openfile->current->lineno)
|
||||
while (f->lineno != lineno && f->prev != NULL)
|
||||
@@ -566,9 +529,9 @@ filestruct *fsfromline(ssize_t lineno)
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Count the number of characters from begin to end, and return it. */
|
||||
size_t get_totsize(const filestruct *begin, const filestruct *end)
|
||||
size_t get_totsize(const linestruct *begin, const linestruct *end)
|
||||
{
|
||||
const filestruct *line;
|
||||
const linestruct *line;
|
||||
size_t totsize = 0;
|
||||
|
||||
/* Sum the number of characters (plus a newline) in each line. */
|
||||
|
||||
333
src/winio.c
333
src/winio.c
@@ -1,8 +1,8 @@
|
||||
/**************************************************************************
|
||||
* winio.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2018 Benno Schulenberg *
|
||||
* Copyright (C) 1999-2011, 2013-2019 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2019 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 *
|
||||
@@ -122,14 +122,14 @@ void run_macro(void)
|
||||
* - Ctrl-M is Enter under ASCII, ANSI, VT100, VT220, and VT320.
|
||||
* - Ctrl-Q is XON under ASCII, ANSI, VT100, VT220, and VT320.
|
||||
* - Ctrl-S is XOFF under ASCII, ANSI, VT100, VT220, and VT320.
|
||||
* - Ctrl-8 (Ctrl-?) is Delete under ASCII, ANSI, VT100, and VT220,
|
||||
* - Ctrl-? is Delete under ASCII, ANSI, VT100, and VT220,
|
||||
* but is Backspace under VT320.
|
||||
*
|
||||
* Note: VT220 and VT320 also generate Esc [ 3 ~ for Delete. By default,
|
||||
* xterm assumes it's running on a VT320 and generates Ctrl-8 (Ctrl-?)
|
||||
* xterm assumes it's running on a VT320 and generates Ctrl-?
|
||||
* for Backspace and Esc [ 3 ~ for Delete. This causes problems for
|
||||
* VT100-derived terminals such as the FreeBSD console, which expect
|
||||
* Ctrl-H for Backspace and Ctrl-8 (Ctrl-?) for Delete, and on which the
|
||||
* Ctrl-H for Backspace and Ctrl-? for Delete, and on which the
|
||||
* VT320 sequences are translated by the keypad to KEY_DC and [nothing].
|
||||
* We work around this conflict via the REBIND_DELETE flag: if it's not set,
|
||||
* we assume VT320 compatibility, and if it is, we assume VT100 compatibility.
|
||||
@@ -475,7 +475,7 @@ int parse_kbinput(WINDOW *win)
|
||||
* or control character sequence mode. */
|
||||
if (!solitary) {
|
||||
meta_key = TRUE;
|
||||
retval = keycode;
|
||||
retval = tolower(keycode);
|
||||
} else
|
||||
retval = get_control_kbinput(keycode);
|
||||
else {
|
||||
@@ -502,11 +502,13 @@ int parse_kbinput(WINDOW *win)
|
||||
break;
|
||||
case 3:
|
||||
if (key_buffer_len == 0) {
|
||||
if (!solitary)
|
||||
if (!solitary) {
|
||||
meta_key = TRUE;
|
||||
/* Three escapes followed by a non-escape, and no
|
||||
* other codes are waiting: normal input mode. */
|
||||
retval = keycode;
|
||||
retval = tolower(keycode);
|
||||
} else
|
||||
/* Three escapes followed by a non-escape, and no
|
||||
* other codes are waiting: normal input mode. */
|
||||
retval = keycode;
|
||||
} else
|
||||
/* Three escapes followed by a non-escape, and more
|
||||
* codes are waiting: combined control character and
|
||||
@@ -724,6 +726,12 @@ int parse_kbinput(WINDOW *win)
|
||||
#endif
|
||||
case KEY_C3: /* PageDown (3) on keypad with NumLock off. */
|
||||
return KEY_NPAGE;
|
||||
/* When requested, swap meanings of keycodes for <Bsp> and <Del>. */
|
||||
case DEL_CODE:
|
||||
case KEY_BACKSPACE:
|
||||
return (ISSET(REBIND_DELETE) ? KEY_DC : KEY_BACKSPACE);
|
||||
case KEY_DC:
|
||||
return (ISSET(REBIND_DELETE) ? KEY_BACKSPACE : KEY_DC);
|
||||
#ifdef KEY_SDC /* Slang doesn't support KEY_SDC. */
|
||||
case KEY_SDC:
|
||||
return SHIFT_DELETE;
|
||||
@@ -1491,34 +1499,31 @@ long get_unicode_kbinput(WINDOW *win, int kbinput)
|
||||
}
|
||||
#endif /* ENABLE_UTF8 */
|
||||
|
||||
/* Translate a control character sequence: turn an ASCII non-control
|
||||
* character into its corresponding control character. */
|
||||
/* Translate a normal ASCII character into its corresponding control code.
|
||||
* The following groups of control keystrokes are equivalent:
|
||||
* Ctrl-2 == Ctrl-@ == Ctrl-` == Ctrl-Space
|
||||
* Ctrl-3 == Ctrl-[ == <Esc>
|
||||
* Ctrl-4 == Ctrl-\ == Ctrl-|
|
||||
* Ctrl-5 == Ctrl-]
|
||||
* Ctrl-6 == Ctrl-^ == Ctrl-~
|
||||
* Ctrl-7 == Ctrl-/ == Ctrl-_
|
||||
* Ctrl-8 == Ctrl-? */
|
||||
int get_control_kbinput(int kbinput)
|
||||
{
|
||||
int retval;
|
||||
|
||||
/* Ctrl-Space (Ctrl-2, Ctrl-@, Ctrl-`) */
|
||||
if ('@' <= kbinput && kbinput <= '_')
|
||||
return kbinput - '@';
|
||||
if ('`' <= kbinput && kbinput <= '~')
|
||||
return kbinput - '`';
|
||||
if ('3' <= kbinput && kbinput <= '7')
|
||||
return kbinput - 24;
|
||||
if (kbinput == '?' || kbinput == '8')
|
||||
return DEL_CODE;
|
||||
if (kbinput == ' ' || kbinput == '2')
|
||||
retval = 0;
|
||||
/* Ctrl-/ (Ctrl-7, Ctrl-_) */
|
||||
else if (kbinput == '/')
|
||||
retval = 31;
|
||||
/* Ctrl-3 (Ctrl-[, Esc) to Ctrl-7 (Ctrl-/, Ctrl-_) */
|
||||
else if ('3' <= kbinput && kbinput <= '7')
|
||||
retval = kbinput - 24;
|
||||
/* Ctrl-8 (Ctrl-?) */
|
||||
else if (kbinput == '8' || kbinput == '?')
|
||||
retval = DEL_CODE;
|
||||
/* Ctrl-@ (Ctrl-Space, Ctrl-2, Ctrl-`) to Ctrl-_ (Ctrl-/, Ctrl-7) */
|
||||
else if ('@' <= kbinput && kbinput <= '_')
|
||||
retval = kbinput - '@';
|
||||
/* Ctrl-` (Ctrl-2, Ctrl-Space, Ctrl-@) to Ctrl-~ (Ctrl-6, Ctrl-^) */
|
||||
else if ('`' <= kbinput && kbinput <= '~')
|
||||
retval = kbinput - '`';
|
||||
else
|
||||
retval = kbinput;
|
||||
return 0;
|
||||
if (kbinput == '/')
|
||||
return 31;
|
||||
|
||||
return retval;
|
||||
return kbinput;
|
||||
}
|
||||
|
||||
/* Read in a stream of characters verbatim, and return the length of the
|
||||
@@ -1532,7 +1537,7 @@ int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len)
|
||||
* don't get extended keypad values. */
|
||||
if (ISSET(PRESERVE))
|
||||
disable_flow_control();
|
||||
if (!ISSET(REBIND_KEYPAD))
|
||||
if (!ISSET(RAW_SEQUENCES))
|
||||
keypad(win, FALSE);
|
||||
|
||||
/* Read in one keycode, or one or two escapes. */
|
||||
@@ -1551,7 +1556,7 @@ int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len)
|
||||
enable_flow_control();
|
||||
/* Use the global window pointers, because a resize may have freed
|
||||
* the data that the win parameter points to. */
|
||||
if (!ISSET(REBIND_KEYPAD)) {
|
||||
if (!ISSET(RAW_SEQUENCES)) {
|
||||
keypad(edit, TRUE);
|
||||
keypad(bottomwin, TRUE);
|
||||
}
|
||||
@@ -1669,65 +1674,56 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
|
||||
* to figure out which shortcut was released on/clicked and put
|
||||
* back the equivalent keystroke(s) for it. */
|
||||
if (allow_shortcuts && !ISSET(NO_HELP) && in_bottomwin) {
|
||||
int i;
|
||||
/* The width of all the shortcuts, except for the last
|
||||
* two, in the shortcut list in bottomwin. */
|
||||
int j;
|
||||
/* The calculated index number of the clicked item. */
|
||||
int width;
|
||||
/* The width of each shortcut item, except the last two. */
|
||||
int index;
|
||||
/* The calculated index of the clicked item. */
|
||||
size_t number;
|
||||
/* The number of available shortcuts in the current menu. */
|
||||
/* The number of shortcut items that get displayed. */
|
||||
|
||||
/* Translate the mouse event coordinates so that they're
|
||||
* relative to bottomwin. */
|
||||
/* Translate the coordinates to become relative to bottomwin. */
|
||||
wmouse_trafo(bottomwin, mouse_y, mouse_x, FALSE);
|
||||
|
||||
/* Handle releases/clicks of the first mouse button on the
|
||||
* statusbar elsewhere. */
|
||||
/* Clicks on the status bar are handled elsewhere, so
|
||||
* restore the untranslated mouse-event coordinates. */
|
||||
if (*mouse_y == 0) {
|
||||
/* Restore the untranslated mouse event coordinates, so
|
||||
* that they're relative to the entire screen again. */
|
||||
*mouse_x = mevent.x - margin;
|
||||
*mouse_y = mevent.y;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Determine how many shortcuts are being shown. */
|
||||
/* Determine how many shortcuts will be shown. */
|
||||
number = length_of_list(currmenu);
|
||||
|
||||
if (number > MAIN_VISIBLE)
|
||||
number = MAIN_VISIBLE;
|
||||
|
||||
/* Calculate the width of all of the shortcuts in the list
|
||||
* except for the last two, which are longer by (COLS % i)
|
||||
* columns so as to not waste space. */
|
||||
/* Calculate the width of each non-rightmost shortcut item;
|
||||
* the rightmost ones will "absorb" any remaining slack. */
|
||||
if (number < 2)
|
||||
i = COLS / (MAIN_VISIBLE / 2);
|
||||
width = COLS / (MAIN_VISIBLE / 2);
|
||||
else
|
||||
i = COLS / ((number / 2) + (number % 2));
|
||||
width = COLS / ((number / 2) + (number % 2));
|
||||
|
||||
/* Calculate the one-based index in the shortcut list. */
|
||||
j = (*mouse_x / i) * 2 + *mouse_y;
|
||||
index = (*mouse_x / width) * 2 + *mouse_y;
|
||||
|
||||
/* Adjust the index if we hit the last two wider ones. */
|
||||
if ((j > number) && (*mouse_x % i < COLS % i))
|
||||
j -= 2;
|
||||
if ((index > number) && (*mouse_x % width < COLS % width))
|
||||
index -= 2;
|
||||
|
||||
/* Ignore releases/clicks of the first mouse button beyond
|
||||
* the last shortcut. */
|
||||
if (j > number)
|
||||
/* Ignore clicks beyond the last shortcut. */
|
||||
if (index > number)
|
||||
return 2;
|
||||
|
||||
/* Go through the list of functions to determine which
|
||||
* shortcut in the current menu we released/clicked on. */
|
||||
* shortcut in the current menu we clicked/released on. */
|
||||
for (f = allfuncs; f != NULL; f = f->next) {
|
||||
if ((f->menus & currmenu) == 0)
|
||||
continue;
|
||||
if (first_sc_for(currmenu, f->func) == NULL)
|
||||
continue;
|
||||
/* Tick off an actually shown shortcut. */
|
||||
j -= 1;
|
||||
if (j == 0)
|
||||
if (--index == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1738,8 +1734,7 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
|
||||
}
|
||||
return 1;
|
||||
} else
|
||||
/* Handle releases/clicks of the first mouse button that
|
||||
* aren't on the current shortcut list elsewhere. */
|
||||
/* Clicks outside of bottomwin are handled elsewhere. */
|
||||
return 0;
|
||||
}
|
||||
#if NCURSES_MOUSE_VERSION >= 2
|
||||
@@ -1750,27 +1745,21 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
|
||||
bool in_edit = wenclose(edit, *mouse_y, *mouse_x);
|
||||
|
||||
if (in_bottomwin)
|
||||
/* Translate the mouse event coordinates so that they're
|
||||
* relative to bottomwin. */
|
||||
/* Translate the coordinates to become relative to bottomwin. */
|
||||
wmouse_trafo(bottomwin, mouse_y, mouse_x, FALSE);
|
||||
|
||||
if (in_edit || (in_bottomwin && *mouse_y == 0)) {
|
||||
int i;
|
||||
|
||||
/* One roll of the mouse wheel should move three lines. */
|
||||
for (i = 0; i < 3; i++)
|
||||
for (int count = 1; count <= 3; count++)
|
||||
unget_kbinput((mevent.bstate & BUTTON4_PRESSED) ?
|
||||
KEY_UP : KEY_DOWN, FALSE);
|
||||
|
||||
return 1;
|
||||
} else
|
||||
/* Ignore presses of the fourth mouse button and presses of
|
||||
* the fifth mouse buttons that aren't on the edit window or
|
||||
* the statusbar. */
|
||||
/* Ignore presses of the fourth and fifth mouse buttons
|
||||
* that aren't on the edit window or the status bar. */
|
||||
return 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Ignore all other mouse events. */
|
||||
return 2;
|
||||
}
|
||||
@@ -1874,8 +1863,11 @@ void check_statusblank(void)
|
||||
* at most span columns. column is zero-based, and span is one-based, so
|
||||
* span == 0 means you get "" returned. The returned string is dynamically
|
||||
* allocated, and should be freed. If isdata is TRUE, the caller might put
|
||||
* "$" at the beginning or end of the line if it's too long. */
|
||||
char *display_string(const char *buf, size_t column, size_t span, bool isdata)
|
||||
* "<" at the beginning or ">" at the end of the line if it's too long. If
|
||||
* isprompt is TRUE, the caller might put ">" at the end of the line if it's
|
||||
* too long. */
|
||||
char *display_string(const char *buf, size_t column, size_t span,
|
||||
bool isdata, bool isprompt)
|
||||
{
|
||||
size_t start_index = actual_x(buf, column);
|
||||
/* The index of the first character that the caller wishes to show. */
|
||||
@@ -1897,7 +1889,7 @@ char *display_string(const char *buf, size_t column, size_t span, bool isdata)
|
||||
converted = charalloc(strlen(buf) * (MAXCHARLEN + tabsize) + 1);
|
||||
|
||||
/* If the first character starts before the left edge, or would be
|
||||
* overwritten by a "$" token, then show placeholders instead. */
|
||||
* overwritten by a "<" token, then show placeholders instead. */
|
||||
if (*buf != '\0' && *buf != '\t' && (start_col < column ||
|
||||
(start_col > 0 && isdata && !ISSET(SOFTWRAP)))) {
|
||||
if (is_cntrl_mbchar(buf)) {
|
||||
@@ -1914,8 +1906,8 @@ char *display_string(const char *buf, size_t column, size_t span, bool isdata)
|
||||
column++;
|
||||
}
|
||||
|
||||
/* Display the right half of a two-column character as '<'. */
|
||||
converted[index++] = '<';
|
||||
/* Display the right half of a two-column character as ']'. */
|
||||
converted[index++] = ']';
|
||||
column++;
|
||||
buf += parse_mbchar(buf, NULL, NULL);
|
||||
}
|
||||
@@ -1929,9 +1921,9 @@ char *display_string(const char *buf, size_t column, size_t span, bool isdata)
|
||||
/* Show a space as a visible character, or as a space. */
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(WHITESPACE_DISPLAY)) {
|
||||
int i = whitespace_len[0];
|
||||
int i = whitelen[0];
|
||||
|
||||
while (i < whitespace_len[0] + whitespace_len[1])
|
||||
while (i < whitelen[0] + whitelen[1])
|
||||
converted[index++] = whitespace[i++];
|
||||
} else
|
||||
#endif
|
||||
@@ -1947,7 +1939,7 @@ char *display_string(const char *buf, size_t column, size_t span, bool isdata)
|
||||
column == start_col)) {
|
||||
int i = 0;
|
||||
|
||||
while (i < whitespace_len[0])
|
||||
while (i < whitelen[0])
|
||||
converted[index++] = whitespace[i++];
|
||||
} else
|
||||
#endif
|
||||
@@ -1998,14 +1990,17 @@ char *display_string(const char *buf, size_t column, size_t span, bool isdata)
|
||||
buf += charlength + 7;
|
||||
}
|
||||
|
||||
/* If there is more text than can be shown, make room for the $ or >. */
|
||||
if (*buf != '\0' && (column > beyond || (isdata && !ISSET(SOFTWRAP)))) {
|
||||
index = move_mbleft(converted, index);
|
||||
/* If there is more text than can be shown, make room for the ">". */
|
||||
if (column > beyond || (*buf != '\0' && (isprompt ||
|
||||
(isdata && !ISSET(SOFTWRAP))))) {
|
||||
do {
|
||||
index = move_mbleft(converted, index);
|
||||
} while (mbwidth(converted + index) == 0);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
/* Display the left half of a two-column character as '>'. */
|
||||
/* Display the left half of a two-column character as '['. */
|
||||
if (mbwidth(converted + index) == 2)
|
||||
converted[index++] = '>';
|
||||
converted[index++] = '[';
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2070,7 +2065,7 @@ void titlebar(const char *path)
|
||||
/* Figure out the path, prefix and state strings. */
|
||||
#ifdef ENABLE_COLOR
|
||||
if (currmenu == MLINTER) {
|
||||
/* TRANSLATORS: The next four are "labels" in the title bar. */
|
||||
/* TRANSLATORS: The next five are "labels" in the title bar. */
|
||||
prefix = _("Linting --");
|
||||
path = openfile->filename;
|
||||
} else
|
||||
@@ -2101,6 +2096,8 @@ void titlebar(const char *path)
|
||||
state = _("Modified");
|
||||
else if (ISSET(VIEW_MODE))
|
||||
state = _("View");
|
||||
else if (ISSET(RESTRICTED))
|
||||
state = _("Restricted");
|
||||
|
||||
pluglen = strlenpt(_("Modified")) + 1;
|
||||
}
|
||||
@@ -2149,13 +2146,13 @@ void titlebar(const char *path)
|
||||
|
||||
/* Print the full path if there's room; otherwise, dottify it. */
|
||||
if (pathlen + pluglen + statelen <= COLS) {
|
||||
caption = display_string(path, 0, pathlen, FALSE);
|
||||
caption = display_string(path, 0, pathlen, FALSE, FALSE);
|
||||
waddstr(topwin, caption);
|
||||
free(caption);
|
||||
} else if (5 + statelen <= COLS) {
|
||||
waddstr(topwin, "...");
|
||||
caption = display_string(path, 3 + pathlen - COLS + statelen,
|
||||
COLS - statelen, FALSE);
|
||||
COLS - statelen, FALSE, FALSE);
|
||||
waddstr(topwin, caption);
|
||||
free(caption);
|
||||
}
|
||||
@@ -2246,7 +2243,7 @@ void statusline(message_type importance, const char *msg, ...)
|
||||
compound = charalloc(MAXCHARLEN * (COLS + 1));
|
||||
vsnprintf(compound, MAXCHARLEN * (COLS + 1), msg, ap);
|
||||
va_end(ap);
|
||||
message = display_string(compound, 0, COLS, FALSE);
|
||||
message = display_string(compound, 0, COLS, FALSE, FALSE);
|
||||
free(compound);
|
||||
|
||||
start_col = (COLS - strlenpt(message)) / 2;
|
||||
@@ -2363,7 +2360,7 @@ void place_the_cursor(void)
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
filestruct *line = openfile->edittop;
|
||||
linestruct *line = openfile->edittop;
|
||||
size_t leftedge;
|
||||
|
||||
row -= chunk_for(openfile->firstcolumn, openfile->edittop);
|
||||
@@ -2398,7 +2395,7 @@ void place_the_cursor(void)
|
||||
* character of this page. That is, the first character of converted
|
||||
* corresponds to character number actual_x(fileptr->data, from_col) of the
|
||||
* line. */
|
||||
void edit_draw(filestruct *fileptr, const char *converted,
|
||||
void edit_draw(linestruct *fileptr, const char *converted,
|
||||
int row, size_t from_col)
|
||||
{
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_COLOR)
|
||||
@@ -2459,9 +2456,9 @@ void edit_draw(filestruct *fileptr, const char *converted,
|
||||
/* The place in converted from where painting starts. */
|
||||
regmatch_t match;
|
||||
/* The match positions of a single-line regex. */
|
||||
const filestruct *start_line = fileptr->prev;
|
||||
const linestruct *start_line = fileptr->prev;
|
||||
/* The first line before fileptr that matches 'start'. */
|
||||
const filestruct *end_line = fileptr;
|
||||
const linestruct *end_line = fileptr;
|
||||
/* The line that matches 'end'. */
|
||||
regmatch_t startmatch, endmatch;
|
||||
/* The match positions of the start and end regexes. */
|
||||
@@ -2689,6 +2686,34 @@ void edit_draw(filestruct *fileptr, const char *converted,
|
||||
#endif /* ENABLE_COLOR */
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (stripe_column > from_col && !inhelp &&
|
||||
stripe_column <= from_col + editwincols) {
|
||||
ssize_t target_column = stripe_column - from_col - 1;
|
||||
size_t target_x = actual_x(converted, target_column);
|
||||
char striped_char[MAXCHARLEN];
|
||||
size_t charlen = 1;
|
||||
|
||||
if (*(converted + target_x) != '\0') {
|
||||
charlen = parse_mbchar(converted + target_x, striped_char, NULL);
|
||||
target_column = strnlenpt(converted, target_x);
|
||||
} else if (target_column + 1 == editwincols) {
|
||||
/* Defeat a VTE bug -- see https://sv.gnu.org/bugs/?55896. */
|
||||
#ifdef ENABLE_UTF8
|
||||
if (using_utf8()) {
|
||||
striped_char[0] = '\xC2';
|
||||
striped_char[1] = '\xA0';
|
||||
charlen = 2;
|
||||
} else
|
||||
#endif
|
||||
striped_char[0] = '.';
|
||||
} else
|
||||
striped_char[0] = ' ';
|
||||
|
||||
wattron(edit, interface_color_pair[GUIDE_STRIPE]);
|
||||
mvwaddnstr(edit, row, margin + target_column, striped_char, charlen);
|
||||
wattroff(edit, interface_color_pair[GUIDE_STRIPE]);
|
||||
}
|
||||
|
||||
/* If the mark is on, and fileptr is at least partially selected, we
|
||||
* need to paint it. */
|
||||
if (openfile->mark &&
|
||||
@@ -2696,7 +2721,7 @@ void edit_draw(filestruct *fileptr, const char *converted,
|
||||
fileptr->lineno <= openfile->current->lineno) &&
|
||||
(fileptr->lineno >= openfile->mark->lineno ||
|
||||
fileptr->lineno >= openfile->current->lineno)) {
|
||||
const filestruct *top, *bot;
|
||||
const linestruct *top, *bot;
|
||||
/* The lines where the marked region begins and ends. */
|
||||
size_t top_x, bot_x;
|
||||
/* The x positions where the marked region begins and ends. */
|
||||
@@ -2745,7 +2770,7 @@ void edit_draw(filestruct *fileptr, const char *converted,
|
||||
* line will be passed to update_softwrapped_line(). Likely values of
|
||||
* index are current_x or zero. Return the number of additional rows
|
||||
* consumed (when softwrapping). */
|
||||
int update_line(filestruct *fileptr, size_t index)
|
||||
int update_line(linestruct *fileptr, size_t index)
|
||||
{
|
||||
int row = 0;
|
||||
/* The row in the edit window we will be updating. */
|
||||
@@ -2778,16 +2803,22 @@ int update_line(filestruct *fileptr, size_t index)
|
||||
|
||||
/* Expand the line, replacing tabs with spaces, and control
|
||||
* characters with their displayed forms. */
|
||||
converted = display_string(fileptr->data, from_col, editwincols, TRUE);
|
||||
converted = display_string(fileptr->data, from_col, editwincols, TRUE, FALSE);
|
||||
|
||||
/* Draw the line. */
|
||||
edit_draw(fileptr, converted, row, from_col);
|
||||
free(converted);
|
||||
|
||||
if (from_col > 0)
|
||||
mvwaddch(edit, row, margin, '$');
|
||||
if (strlenpt(fileptr->data) > from_col + editwincols)
|
||||
mvwaddch(edit, row, COLS - 1, '$');
|
||||
if (from_col > 0) {
|
||||
wattron(edit, hilite_attribute);
|
||||
mvwaddch(edit, row, margin, '<');
|
||||
wattroff(edit, hilite_attribute);
|
||||
}
|
||||
if (strlenpt(fileptr->data) > from_col + editwincols) {
|
||||
wattron(edit, hilite_attribute);
|
||||
mvwaddch(edit, row, COLS - 1, '>');
|
||||
wattroff(edit, hilite_attribute);
|
||||
}
|
||||
|
||||
if (spotlighted && !inhelp)
|
||||
spotlight(light_from_col, light_to_col);
|
||||
@@ -2799,11 +2830,11 @@ int update_line(filestruct *fileptr, size_t index)
|
||||
/* Redraw all the chunks of the given line (as far as they fit onscreen),
|
||||
* unless it's edittop, which will be displayed from column firstcolumn.
|
||||
* Return the number of additional rows consumed. */
|
||||
int update_softwrapped_line(filestruct *fileptr)
|
||||
int update_softwrapped_line(linestruct *fileptr)
|
||||
{
|
||||
int row = 0;
|
||||
/* The row in the edit window we will write to. */
|
||||
filestruct *line = openfile->edittop;
|
||||
linestruct *line = openfile->edittop;
|
||||
/* An iterator needed to find the relevant row. */
|
||||
int starting_row;
|
||||
/* The first row in the edit window that gets updated. */
|
||||
@@ -2842,18 +2873,18 @@ int update_softwrapped_line(filestruct *fileptr)
|
||||
blank_row(edit, row, 0, COLS);
|
||||
|
||||
/* Convert the chunk to its displayable form and draw it. */
|
||||
converted = display_string(fileptr->data, from_col, to_col - from_col, TRUE);
|
||||
converted = display_string(fileptr->data, from_col, to_col - from_col,
|
||||
TRUE, FALSE);
|
||||
edit_draw(fileptr, converted, row++, from_col);
|
||||
free(converted);
|
||||
|
||||
if (end_of_line)
|
||||
break;
|
||||
|
||||
/* If the line is softwrapped before its last column, add a ">" just
|
||||
* after its softwrap breakpoint, unless we're softwrapping at blanks
|
||||
* and not in the middle of a word. */
|
||||
/* If the line is softwrapped early (because of a two-column character),
|
||||
* show a "[" placeholder, unless we're softwrapping at blanks. */
|
||||
if (!ISSET(AT_BLANKS) && to_col - from_col < editwincols)
|
||||
mvwaddch(edit, row - 1, to_col - from_col, '>');
|
||||
mvwaddch(edit, row - 1, to_col - from_col, '[');
|
||||
|
||||
from_col = to_col;
|
||||
}
|
||||
@@ -2882,7 +2913,7 @@ bool line_needs_update(const size_t old_column, const size_t new_column)
|
||||
* given column (leftedge). After moving, leftedge will be set to the
|
||||
* starting column of the current chunk. Return the number of chunks we
|
||||
* couldn't move up, which will be zero if we completely succeeded. */
|
||||
int go_back_chunks(int nrows, filestruct **line, size_t *leftedge)
|
||||
int go_back_chunks(int nrows, linestruct **line, size_t *leftedge)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -2897,7 +2928,7 @@ int go_back_chunks(int nrows, filestruct **line, size_t *leftedge)
|
||||
if (chunk >= i)
|
||||
return go_forward_chunks(chunk - i, line, leftedge);
|
||||
|
||||
if (*line == openfile->fileage)
|
||||
if (*line == openfile->filetop)
|
||||
break;
|
||||
|
||||
i -= chunk;
|
||||
@@ -2919,7 +2950,7 @@ int go_back_chunks(int nrows, filestruct **line, size_t *leftedge)
|
||||
* given column (leftedge). After moving, leftedge will be set to the
|
||||
* starting column of the current chunk. Return the number of chunks we
|
||||
* couldn't move down, which will be zero if we completely succeeded. */
|
||||
int go_forward_chunks(int nrows, filestruct **line, size_t *leftedge)
|
||||
int go_forward_chunks(int nrows, linestruct **line, size_t *leftedge)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -2962,7 +2993,7 @@ bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
filestruct *line = openfile->current;
|
||||
linestruct *line = openfile->current;
|
||||
size_t leftedge = leftedge_for(xplustabs(), openfile->current);
|
||||
int rows_left = go_back_chunks(editwinrows - 1, &line, &leftedge);
|
||||
|
||||
@@ -2977,7 +3008,7 @@ bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge)
|
||||
* draw the relevant content on the resultant blank row. */
|
||||
void edit_scroll(bool direction)
|
||||
{
|
||||
filestruct *line;
|
||||
linestruct *line;
|
||||
size_t leftedge;
|
||||
int remainder = 0, nrows = 1;
|
||||
|
||||
@@ -3094,7 +3125,7 @@ size_t get_softwrap_breakpoint(const char *text, size_t leftedge,
|
||||
/* Get the row of the softwrapped chunk of the given line that column is on,
|
||||
* relative to the first row (zero-based), and return it. If leftedge isn't
|
||||
* NULL, return the leftmost column of the chunk in it. */
|
||||
size_t get_chunk_and_edge(size_t column, filestruct *line, size_t *leftedge)
|
||||
size_t get_chunk_and_edge(size_t column, linestruct *line, size_t *leftedge)
|
||||
{
|
||||
size_t current_chunk = 0, start_col = 0, end_col;
|
||||
bool end_of_line = FALSE;
|
||||
@@ -3116,7 +3147,7 @@ size_t get_chunk_and_edge(size_t column, filestruct *line, size_t *leftedge)
|
||||
|
||||
/* Return the row of the softwrapped chunk of the given line that column is on,
|
||||
* relative to the first row (zero-based). */
|
||||
size_t chunk_for(size_t column, filestruct *line)
|
||||
size_t chunk_for(size_t column, linestruct *line)
|
||||
{
|
||||
if (ISSET(SOFTWRAP))
|
||||
return get_chunk_and_edge(column, line, NULL);
|
||||
@@ -3126,7 +3157,7 @@ size_t chunk_for(size_t column, filestruct *line)
|
||||
|
||||
/* Return the leftmost column of the softwrapped chunk of the given line that
|
||||
* column is on. */
|
||||
size_t leftedge_for(size_t column, filestruct *line)
|
||||
size_t leftedge_for(size_t column, linestruct *line)
|
||||
{
|
||||
size_t leftedge;
|
||||
|
||||
@@ -3140,7 +3171,7 @@ size_t leftedge_for(size_t column, filestruct *line)
|
||||
|
||||
/* Return the row of the last softwrapped chunk of the given line, relative to
|
||||
* the first row (zero-based). */
|
||||
size_t number_of_chunks_in(filestruct *line)
|
||||
size_t number_of_chunks_in(linestruct *line)
|
||||
{
|
||||
return chunk_for((size_t)-1, line);
|
||||
}
|
||||
@@ -3206,7 +3237,7 @@ bool current_is_below_screen(void)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
filestruct *line = openfile->edittop;
|
||||
linestruct *line = openfile->edittop;
|
||||
size_t leftedge = openfile->firstcolumn;
|
||||
|
||||
/* If current[current_x] is more than a screen's worth of lines after
|
||||
@@ -3231,7 +3262,7 @@ bool current_is_offscreen(void)
|
||||
|
||||
/* Update any lines between old_current and current that need to be
|
||||
* updated. Use this if we've moved without changing any text. */
|
||||
void edit_redraw(filestruct *old_current, update_type manner)
|
||||
void edit_redraw(linestruct *old_current, update_type manner)
|
||||
{
|
||||
size_t was_pww = openfile->placewewant;
|
||||
|
||||
@@ -3239,7 +3270,7 @@ void edit_redraw(filestruct *old_current, update_type manner)
|
||||
|
||||
/* If the current line is offscreen, scroll until it's onscreen. */
|
||||
if (current_is_offscreen()) {
|
||||
adjust_viewport(ISSET(SMOOTH_SCROLL) ? manner : CENTERING);
|
||||
adjust_viewport(ISSET(JUMPY_SCROLLING) ? CENTERING : manner);
|
||||
refresh_needed = TRUE;
|
||||
return;
|
||||
}
|
||||
@@ -3247,7 +3278,7 @@ void edit_redraw(filestruct *old_current, update_type manner)
|
||||
#ifndef NANO_TINY
|
||||
/* If the mark is on, update all lines between old_current and current. */
|
||||
if (openfile->mark) {
|
||||
filestruct *line = old_current;
|
||||
linestruct *line = old_current;
|
||||
|
||||
while (line != openfile->current) {
|
||||
update_line(line, 0);
|
||||
@@ -3274,7 +3305,7 @@ void edit_redraw(filestruct *old_current, update_type manner)
|
||||
* if we've moved and changed text. */
|
||||
void edit_refresh(void)
|
||||
{
|
||||
filestruct *line;
|
||||
linestruct *line;
|
||||
int row = 0;
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
@@ -3285,7 +3316,7 @@ void edit_refresh(void)
|
||||
|
||||
/* If the current line is out of view, get it back on screen. */
|
||||
if (current_is_offscreen())
|
||||
adjust_viewport((focusing || !ISSET(SMOOTH_SCROLL)) ? CENTERING : FLOWING);
|
||||
adjust_viewport((focusing || ISSET(JUMPY_SCROLLING)) ? CENTERING : FLOWING);
|
||||
|
||||
line = openfile->edittop;
|
||||
|
||||
@@ -3383,7 +3414,7 @@ void do_cursorpos(bool force)
|
||||
saved_byte = openfile->current->data[openfile->current_x];
|
||||
openfile->current->data[openfile->current_x] = '\0';
|
||||
|
||||
sum = get_totsize(openfile->fileage, openfile->current);
|
||||
sum = get_totsize(openfile->filetop, openfile->current);
|
||||
|
||||
openfile->current->data[openfile->current_x] = saved_byte;
|
||||
|
||||
@@ -3426,8 +3457,9 @@ void enable_waiting(void)
|
||||
/* Highlight the text between from_col and to_col. */
|
||||
void spotlight(size_t from_col, size_t to_col)
|
||||
{
|
||||
size_t right_edge;
|
||||
bool overshoots = FALSE;
|
||||
char *word;
|
||||
size_t word_span, room;
|
||||
|
||||
place_the_cursor();
|
||||
|
||||
@@ -3438,29 +3470,28 @@ void spotlight(size_t from_col, size_t to_col)
|
||||
}
|
||||
#endif
|
||||
|
||||
right_edge = get_page_start(from_col) + editwincols;
|
||||
|
||||
/* Limit the end column to the edge of the screen. */
|
||||
if (to_col > right_edge) {
|
||||
to_col = right_edge;
|
||||
overshoots = TRUE;
|
||||
}
|
||||
|
||||
/* This is so we can show zero-length matches. */
|
||||
if (to_col == from_col) {
|
||||
word = mallocstrcpy(NULL, " ");
|
||||
to_col++;
|
||||
} else
|
||||
word = display_string(openfile->current->data, from_col,
|
||||
to_col - from_col, FALSE);
|
||||
|
||||
word_span = strlenpt(word);
|
||||
|
||||
/* Compute the number of columns that are available for the word. */
|
||||
room = editwincols + get_page_start(from_col) - from_col;
|
||||
|
||||
/* If the word is partially offscreen, reserve space for the "$". */
|
||||
if (word_span > room)
|
||||
room--;
|
||||
to_col - from_col, FALSE, overshoots);
|
||||
|
||||
wattron(edit, interface_color_pair[SELECTED_TEXT]);
|
||||
|
||||
waddnstr(edit, word, actual_x(word, room));
|
||||
waddnstr(edit, word, actual_x(word, to_col));
|
||||
|
||||
if (word_span > room)
|
||||
waddch(edit, '$');
|
||||
if (overshoots)
|
||||
mvwaddch(edit, openfile->current_y, COLS - 1, '>');
|
||||
|
||||
wattroff(edit, interface_color_pair[SELECTED_TEXT]);
|
||||
|
||||
@@ -3497,7 +3528,7 @@ void spotlight_softwrapped(size_t from_col, size_t to_col)
|
||||
break_col++;
|
||||
} else
|
||||
word = display_string(openfile->current->data, from_col,
|
||||
break_col - from_col, FALSE);
|
||||
break_col - from_col, FALSE, FALSE);
|
||||
|
||||
wattron(edit, interface_color_pair[SELECTED_TEXT]);
|
||||
|
||||
@@ -3528,8 +3559,8 @@ void spotlight_softwrapped(size_t from_col, size_t to_col)
|
||||
* are FALSE. */
|
||||
void do_credits(void)
|
||||
{
|
||||
bool old_more_space = ISSET(MORE_SPACE);
|
||||
bool old_no_help = ISSET(NO_HELP);
|
||||
bool with_empty_line = ISSET(EMPTY_LINE);
|
||||
bool with_help = !ISSET(NO_HELP);
|
||||
int kbinput = ERR, crpos = 0, xlpos = 0;
|
||||
const char *credits[CREDIT_LEN] = {
|
||||
NULL, /* "The nano text editor" */
|
||||
@@ -3579,7 +3610,7 @@ void do_credits(void)
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"(C) 2018",
|
||||
"(C) 2019",
|
||||
"Free Software Foundation, Inc.",
|
||||
"",
|
||||
"",
|
||||
@@ -3600,8 +3631,8 @@ void do_credits(void)
|
||||
N_("Thank you for using nano!")
|
||||
};
|
||||
|
||||
if (!old_more_space || !old_no_help) {
|
||||
SET(MORE_SPACE);
|
||||
if (with_empty_line || with_help) {
|
||||
UNSET(EMPTY_LINE);
|
||||
SET(NO_HELP);
|
||||
window_init();
|
||||
}
|
||||
@@ -3659,9 +3690,9 @@ void do_credits(void)
|
||||
if (kbinput != ERR)
|
||||
ungetch(kbinput);
|
||||
|
||||
if (!old_more_space)
|
||||
UNSET(MORE_SPACE);
|
||||
if (!old_no_help)
|
||||
if (with_empty_line)
|
||||
SET(EMPTY_LINE);
|
||||
if (with_help)
|
||||
UNSET(NO_HELP);
|
||||
window_init();
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ color red "\"[^"]*\"" "\'[^']*\'"
|
||||
color green "`[^`]*`"
|
||||
|
||||
# Error lines:
|
||||
color brightred "^\*\*\*.*"
|
||||
color brightred "^[[:space:]]*\*\*\*.*"
|
||||
|
||||
# Brackets:
|
||||
color magenta "\[|\]|\(|\)"
|
||||
|
||||
@@ -7,9 +7,10 @@ comment "#"
|
||||
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|i?color|extendsyntax).*"
|
||||
|
||||
# Keywords
|
||||
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cutfromcursor|fill[[:space:]]+-?[[:digit:]]+|historylog|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize[[:space:]]+[1-9][0-9]*|tabstospaces|tempfile|trimblanks|unix|view|wordbounds|zap)\>"
|
||||
icolor yellow "^[[:space:]]*set[[:space:]]+((error|function|key|number|selected|status|title)color)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>"
|
||||
icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|selectedcolor|speller|statuscolor|titlecolor|whitespace|wordchars)[[:space:]]+"
|
||||
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|finalnewline|historylog|jumpyscrolling|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabstospaces|tempfile|trimblanks|unix|view|wordbounds|zap)\>"
|
||||
icolor yellow "^[[:space:]]*set[[:space:]]+((error|function|key|number|selected|status|stripe|title)color)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>"
|
||||
icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|selectedcolor|speller|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:space:]]+"
|
||||
icolor brightgreen "^[[:space:]]*set[[:space:]]+(fill[[:space:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:space:]]+[1-9][0-9]*)\>"
|
||||
icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^([[:alpha:]]|[]@\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+([[:alpha:]]+|".*")[[:space:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
|
||||
icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([[:alpha:]]|[]@\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
|
||||
icolor brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|comment|linter)[[:space:]]+.*"
|
||||
|
||||
@@ -7,14 +7,16 @@ comment "#"
|
||||
# Standard Tcl [info commands]:
|
||||
color green "\<(after|append|array|auto_execok|auto_import|auto_load|auto_load_index|auto_qualify|binary|break|case|catch|cd|clock|close|concat|continue|encoding|eof|error|eval|exec|exit|expr|fblocked|fconfigure|fcopy|file|fileevent|flush|for|foreach|format|gets|glob|global|history|if|incr|info|interp|join|lappend|lindex|linsert|list|llength|load|lrange|lreplace|lsearch|lset|lsort|namespace|open|package|pid|puts|pwd|read|regexp|regsub|rename|return|scan|seek|set|socket|source|split|string|subst|switch|tclLog|tell|time|trace|unknown|unset|update|uplevel|upvar|variable|vwait|while)\>"
|
||||
# Basic Tcl subcommands:
|
||||
color green "\<(array anymore|array donesearch|array exists|array get|array names|array nextelement|array set|array size|array startsearch|array statistics|array unset)\>"
|
||||
color green "\<(string bytelength|string compare|string equal|string first|string index|string is|string last|string length|string map|string match|string range|string repeat|string replace|string to|string tolower|string totitle|string toupper|string trim|string trimleft|string trimright|string will|string wordend|string wordstart)\>"
|
||||
color green "\<array (anymore|donesearch|exists|get|names|nextelement|set|size|startsearch|statistics|unset)\>"
|
||||
color green "\<string (bytelength|compare|equal|first|index|is|last|length|map|match|range|repeat|replace|to|tolower|totitle|toupper|trim|trimleft|trimright|will|wordend|wordstart)\>"
|
||||
# Extended TclX [info commands]:
|
||||
color green "\<(alarm|auto_load_pkg|bsearch|catclose|catgets|catopen|ccollate|cconcat|cequal|chgrp|chmod|chown|chroot|cindex|clength|cmdtrace|commandloop|crange|csubstr|ctoken|ctype|dup|echo|execl|fcntl|flock|fork|fstat|ftruncate|funlock|host_info|id|infox|keyldel|keylget|keylkeys|keylset|kill|lassign|lcontain|lempty|lgets|link|lmatch|loadlibindex|loop|lvarcat|lvarpop|lvarpush|max|min|nice|pipe|profile|random|readdir|replicate|scancontext|scanfile|scanmatch|select|server_accept|server_create|signal|sleep|sync|system|tclx_findinit|tclx_fork|tclx_load_tndxs|tclx_sleep|tclx_system|tclx_wait|times|translit|try_eval|umask|wait)\>"
|
||||
# Syntax:
|
||||
color brightblue "proc[[:space:]]" "(\{|\})"
|
||||
color green "(\(|\)|\;|`|\\|\$|<|>|!|=|&|\|)"
|
||||
color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"
|
||||
icolor brightred "\$\{?[0-9A-Z_!@#$*?-]+\}?"
|
||||
color brightred "\$\{?[0-9A-Za-z_!@#$*?-]+\}?"
|
||||
# Trailing whitespace:
|
||||
color ,green "[[:space:]]+$"
|
||||
color ,magenta "^[[:space:]]*#.*"
|
||||
# Comments:
|
||||
color cyan "^[[:space:]]*#.*"
|
||||
|
||||
Reference in New Issue
Block a user