Compare commits
292 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
075b7e75bc | ||
|
|
c00431134f | ||
|
|
51065ff24b | ||
|
|
4314feae11 | ||
|
|
410280b089 | ||
|
|
178dd9181f | ||
|
|
d30ca576b7 | ||
|
|
ed520c89bc | ||
|
|
cb44a2bd2c | ||
|
|
a0055f3640 | ||
|
|
b00c1d6110 | ||
|
|
594ef2225f | ||
|
|
9631e858f2 | ||
|
|
26d88ccbb1 | ||
|
|
413b9cb774 | ||
|
|
d3a8d81afb | ||
|
|
e16026eacd | ||
|
|
90f18af8bd | ||
|
|
011e8de480 | ||
|
|
4e8afb2877 | ||
|
|
c7ad5c8d86 | ||
|
|
0b1a766964 | ||
|
|
a7e11495bd | ||
|
|
b56db25a35 | ||
|
|
e3957ee5ee | ||
|
|
2a73b4a050 | ||
|
|
ef7c78910c | ||
|
|
772f1029e5 | ||
|
|
3251a216cd | ||
|
|
00b0316ab8 | ||
|
|
76d90617cc | ||
|
|
f516cddce7 | ||
|
|
60b826e5ee | ||
|
|
fc0fcdea10 | ||
|
|
1dd7b216a0 | ||
|
|
87bf46ffb6 | ||
|
|
a921bdadbf | ||
|
|
0271e4a187 | ||
|
|
076eb6f6af | ||
|
|
e484918ef2 | ||
|
|
fdf095c32f | ||
|
|
81402101d9 | ||
|
|
154742c5e3 | ||
|
|
ec569b4bd0 | ||
|
|
38743b0016 | ||
|
|
68c3aaf2df | ||
|
|
2a97cb9f41 | ||
|
|
af8ffa8c94 | ||
|
|
3ffefbfddc | ||
|
|
8637acb106 | ||
|
|
51a3f78d69 | ||
|
|
4d77e0adbb | ||
|
|
2b8a73348c | ||
|
|
576502a5c5 | ||
|
|
ec9a11c761 | ||
|
|
1c63bf0e38 | ||
|
|
4aa1678f3b | ||
|
|
c60d3bbb97 | ||
|
|
90d4b51837 | ||
|
|
302ea79d1c | ||
|
|
ebeed9c013 | ||
|
|
75dd9bee38 | ||
|
|
9151abcd45 | ||
|
|
3258bb0ff4 | ||
|
|
3f3698640b | ||
|
|
432388b23e | ||
|
|
bad618e537 | ||
|
|
7ae305fdc0 | ||
|
|
7d4f279c04 | ||
|
|
f230c46e5e | ||
|
|
bc5a225678 | ||
|
|
493b334ebb | ||
|
|
7d54207627 | ||
|
|
458933f09e | ||
|
|
2b49a19793 | ||
|
|
fc716156a4 | ||
|
|
2b9f06194f | ||
|
|
631defb8b2 | ||
|
|
a6dae403e6 | ||
|
|
b4dbbe3799 | ||
|
|
4281b6becb | ||
|
|
34b1824822 | ||
|
|
b025f67805 | ||
|
|
40f8ca0d07 | ||
|
|
aae752912e | ||
|
|
3c695664ec | ||
|
|
8a7634f070 | ||
|
|
fa88fcc8f2 | ||
|
|
c2d8641f01 | ||
|
|
3d5e51bcd0 | ||
|
|
95ae124891 | ||
|
|
1a8646393a | ||
|
|
054559dc93 | ||
|
|
fdeab9b4c9 | ||
|
|
f26c121ca9 | ||
|
|
17c16a4bf5 | ||
|
|
46566572d6 | ||
|
|
b4a5fac744 | ||
|
|
f816da413a | ||
|
|
3a0ac428ba | ||
|
|
97ab28a164 | ||
|
|
ccb739dd7d | ||
|
|
1082f2adec | ||
|
|
042b8394a0 | ||
|
|
f2d6e6fa5e | ||
|
|
5390f96900 | ||
|
|
50ed18be17 | ||
|
|
a6365707c0 | ||
|
|
6fad6a17da | ||
|
|
eb757e7c5b | ||
|
|
b554606047 | ||
|
|
e915fb1650 | ||
|
|
4e40ec057e | ||
|
|
bd0026be86 | ||
|
|
a1bef0e953 | ||
|
|
f5693d4151 | ||
|
|
e3807f00a2 | ||
|
|
022cc084a7 | ||
|
|
0f98466e2f | ||
|
|
40c067133a | ||
|
|
36270748dc | ||
|
|
1894c81412 | ||
|
|
e917ef0105 | ||
|
|
3347682fd0 | ||
|
|
7c5b104859 | ||
|
|
3b9a24a7ca | ||
|
|
7d3290fb91 | ||
|
|
df0ae2ace5 | ||
|
|
bc91af2e3c | ||
|
|
48b94d71c7 | ||
|
|
f14be47878 | ||
|
|
c51f5f4bff | ||
|
|
7f8851caa8 | ||
|
|
bfdc31fbb4 | ||
|
|
69d2045c9f | ||
|
|
c63f4c1f58 | ||
|
|
b8dc8d4a37 | ||
|
|
8749ccb469 | ||
|
|
b5c5cde0d4 | ||
|
|
d8c03cd4cd | ||
|
|
1536a76ced | ||
|
|
d2fb371fe2 | ||
|
|
34170611d3 | ||
|
|
23c36ba667 | ||
|
|
31d5cb1118 | ||
|
|
f551c07e7a | ||
|
|
2656f543f4 | ||
|
|
ba79602281 | ||
|
|
094758be15 | ||
|
|
06bbc70d4a | ||
|
|
d256d0cbc0 | ||
|
|
ab6635c3a6 | ||
|
|
416ad4c5fd | ||
|
|
0374708597 | ||
|
|
101987f5c6 | ||
|
|
ad451933c6 | ||
|
|
222e67300e | ||
|
|
d12191db5a | ||
|
|
785efc2087 | ||
|
|
557ad827f9 | ||
|
|
600f81cf98 | ||
|
|
56d98052d1 | ||
|
|
265d3245af | ||
|
|
53d4224be9 | ||
|
|
f813fd0f4d | ||
|
|
e90b40e651 | ||
|
|
07c1e72216 | ||
|
|
7338b45d36 | ||
|
|
c95e5362e6 | ||
|
|
2698a2ba68 | ||
|
|
ff0e01a69e | ||
|
|
72b13adeff | ||
|
|
481178428b | ||
|
|
9a2ef3a542 | ||
|
|
b480e7fc9c | ||
|
|
3e33d1eba6 | ||
|
|
cdb9b04980 | ||
|
|
31ff7ead73 | ||
|
|
5398d986ef | ||
|
|
b02dccc51f | ||
|
|
3158133edd | ||
|
|
acf50ae26d | ||
|
|
01b840890d | ||
|
|
9bd60e7d5d | ||
|
|
c5e46101b1 | ||
|
|
53b77cb4c6 | ||
|
|
cc4ce8d83b | ||
|
|
23c8ef70aa | ||
|
|
2a4d338d97 | ||
|
|
9c202198a3 | ||
|
|
c8dc67717b | ||
|
|
4df2f81295 | ||
|
|
78def852d1 | ||
|
|
a4933873c9 | ||
|
|
1861052234 | ||
|
|
2307b31887 | ||
|
|
108a3b0b41 | ||
|
|
e0d9b7a8af | ||
|
|
b3ace4d8f6 | ||
|
|
e9d6ceab0b | ||
|
|
5103bfe6b8 | ||
|
|
cfd17f5722 | ||
|
|
43235c2f16 | ||
|
|
b14ad451a9 | ||
|
|
cd00d0975e | ||
|
|
40f6dbc34e | ||
|
|
a9fb56a8c9 | ||
|
|
07c0d29276 | ||
|
|
310c971d50 | ||
|
|
3644d51b97 | ||
|
|
591d3170aa | ||
|
|
752dde1130 | ||
|
|
b5eda7f812 | ||
|
|
4d44b03fc8 | ||
|
|
2d16c27820 | ||
|
|
ad65b79ac7 | ||
|
|
fe5bd8cdef | ||
|
|
c848ec3d53 | ||
|
|
ab6390cad0 | ||
|
|
48124fdba4 | ||
|
|
ebd9eb346d | ||
|
|
413116e1b5 | ||
|
|
69a3d39bc4 | ||
|
|
f081fa3047 | ||
|
|
4383b01b9b | ||
|
|
b901a20a06 | ||
|
|
d6e05d8376 | ||
|
|
21e307e820 | ||
|
|
dbcf4f0cbe | ||
|
|
7b88557ef5 | ||
|
|
75a6abe6d2 | ||
|
|
ba5b85baf0 | ||
|
|
9f95fa9ce5 | ||
|
|
8853bc448d | ||
|
|
15148a5e6d | ||
|
|
7d9ad31cd9 | ||
|
|
aecbc6faa9 | ||
|
|
a06b921f12 | ||
|
|
bdf1a9d4e7 | ||
|
|
5c399dfc6e | ||
|
|
ed4b6486a1 | ||
|
|
2326bf695e | ||
|
|
a9dd73fb16 | ||
|
|
073bd3ad6e | ||
|
|
4bcc224560 | ||
|
|
f2f367ba9c | ||
|
|
48bff32ee3 | ||
|
|
304f07258b | ||
|
|
e1c2573c7a | ||
|
|
07ec7de8eb | ||
|
|
82f5fed45a | ||
|
|
a2f7e31ba2 | ||
|
|
55983ee9d1 | ||
|
|
cd274a7830 | ||
|
|
f773fa3968 | ||
|
|
288355686b | ||
|
|
f7d5a82a5d | ||
|
|
63e04ac31e | ||
|
|
0c63b50fdc | ||
|
|
94c9defde1 | ||
|
|
ee91c51e09 | ||
|
|
1e3f3a7511 | ||
|
|
8fce33afe0 | ||
|
|
4314b8ded3 | ||
|
|
52e39ae5f7 | ||
|
|
5e7ba03ad1 | ||
|
|
97fec5603f | ||
|
|
3b8847f319 | ||
|
|
a578d2706c | ||
|
|
44d38815cc | ||
|
|
b23a5d5b29 | ||
|
|
b96cc8c212 | ||
|
|
09ad0eb5f7 | ||
|
|
62ca113ed3 | ||
|
|
5cfb74650d | ||
|
|
8cd6aa0a32 | ||
|
|
fcbe41942f | ||
|
|
39e5b52734 | ||
|
|
70b347183b | ||
|
|
699cacf7a4 | ||
|
|
23cb26c58f | ||
|
|
3422ec3419 | ||
|
|
5f1d9af375 | ||
|
|
f3a441043d | ||
|
|
e6c629951f | ||
|
|
c06d5452f5 | ||
|
|
1fcb9b99cf | ||
|
|
d8c840692e | ||
|
|
8c7b6bd21a | ||
|
|
21d0755de5 | ||
|
|
bbab9e2e62 | ||
|
|
9ea1cd947c |
318
ChangeLog
318
ChangeLog
@@ -1,3 +1,321 @@
|
||||
Changes between v4.6 and v4.7:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (39):
|
||||
build: add the uploading of PDF and cheatsheet to the release script
|
||||
build: avoid three compiler warnings when using gcc-9.2 or newer
|
||||
build: fix compilation for --enable-tiny --enable-wrapping
|
||||
build: fix compilation on macOS, where 'st_mtim' is unknown
|
||||
build: fix compilation when configured with --disable-justify
|
||||
bump version numbers and add a news item for the 4.7 release
|
||||
display: don't color the space that separates line numbers from text
|
||||
docs: add or improve the 'description' meta tag in the two HTML pages
|
||||
docs: add the 'lang' attribute in the right place to the two HTML pages
|
||||
docs: mention that all keywords in a nanorc file should be in lowercase
|
||||
docs: mention that a negative number after "+" counts from the end
|
||||
gnulib: update to its current upstream state
|
||||
input: make <Tab> indent only when mark and cursor are on different lines
|
||||
justify: distinguish between tabs and spaces when comparing indentation
|
||||
justify: treat consecutive indentations that look the same as the same
|
||||
linter: beep when trying to go beyond first or last message
|
||||
rcfile: accept also function names and menu names only in lowercase
|
||||
rcfile: accept only keywords in all lowercase, for speed of comparison
|
||||
rcfile: demand that function 'exit' is bound in the file browser
|
||||
syntax: nanohelp: colorize also ^/ as a possible keystroke
|
||||
syntax: sh: recognize shell rc files also in dedicated directories
|
||||
tweaks: avoid using strlen() where it is not needed
|
||||
tweaks: drop M-Space and ^Space from the browser's key list
|
||||
tweaks: improve two comments and the ordering of some operands
|
||||
tweaks: move three functions to the file where they are used
|
||||
tweaks: optimize the trimming of trailing whitespace
|
||||
tweaks: remove a stray space
|
||||
tweaks: rename a function, to get out of the way for another rename
|
||||
tweaks: rename a function, to get rid of a useless suffix
|
||||
tweaks: reshuffle a few lines, for brevity or speed or consistency
|
||||
tweaks: reshuffle a few lines, for symmetry with the preceding function
|
||||
tweaks: reshuffle a fragment of code, for efficiency
|
||||
tweaks: reshuffle and rename a few things, to elide duplication
|
||||
tweaks: reshuffle an item, to avoid a lone 'else'
|
||||
tweaks: reshuffle two declarations, for compactness
|
||||
tweaks: slightly streamline the search for a possible wrapping point
|
||||
tweaks: trim or adjust some whitespace in HTML, and add two keywords
|
||||
tweaks: unwrap a few lines, and move some strings to among their peers
|
||||
wrapping: never break in the quoting part nor in the indentation part
|
||||
|
||||
|
||||
Changes between v4.5 and v4.6:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (128):
|
||||
bindings: allow to rebind ^/, even though it is synonymous with ^_
|
||||
bindings: don't hard-bind ^H in the help viewer or the file browser
|
||||
bindings: the 'all' keyword should encompass the browser menu too
|
||||
bindings: the 'all' keyword should include the browser menu always
|
||||
build: fix compilation for --enable-tiny --enable-histories
|
||||
build: fix compilation when configured with --disable-color
|
||||
build: slightly speed up the compilation of the tiny version
|
||||
bump version numbers and add a news item for the 4.6 release
|
||||
chars: add a faster version of the character-parsing function
|
||||
commands: rename 'fixer' to 'formatter', to be less misleading
|
||||
cutting: do nothing when trying to chop a word leftward at start of file
|
||||
display: do refresh the edit window when exiting from the help viewer
|
||||
docs: add a note saying that rebinding ^M or ^I is not advisable
|
||||
docs: add the M-F and M-N keystrokes to the cheatsheet
|
||||
docs: adjust the compilation instructions to two-digit version numbers
|
||||
docs: correct the description of the 'spell' menu
|
||||
docs: document the 'fixer' command, a per-syntax content arranger
|
||||
docs: mention that color rules are applied in the order they are listed
|
||||
docs: mention that 'hunspell' is now the first default spelling program
|
||||
docs: mention that the 'nopauses' option is obsolete
|
||||
docs: remove some excessive detail from the sample nanorc file
|
||||
docs: remove the note about the formatter having been removed
|
||||
feedback: say it when spell check or manipulation did not change anything
|
||||
files: distinguish between read error and write error when prepending
|
||||
files: don't mention the name of the temp file when reading goes wrong
|
||||
files: when opening a file for copying, it should NOT be created
|
||||
formatter: accept the formatted result also upon a nonzero exit status
|
||||
formatter: don't let output from the program pollute the screen
|
||||
gnulib: update to its current upstream state
|
||||
history: don't wait when there is something wrong with the history files
|
||||
linter: report it as an error when running the linting program fails
|
||||
rcfile: allow binding also F17...F24
|
||||
rcfile: process extensions to file-matching commands straightaway
|
||||
restored feature: a per-syntax 'fixer' command that processes the buffer
|
||||
softwrap: when switching to another buffer, re-align the starting column
|
||||
speller: prefer 'hunspell' over 'spell', because it can handle UTF-8
|
||||
speller: when 'spell' is not found, try running 'hunspell -l' instead
|
||||
statusbar: show only the first error message, with dots to indicate more
|
||||
syntax: c: recognize some C++ header files by their Emacs modeline
|
||||
syntax: default: don't colorize stuff between two pairs of brackets
|
||||
syntax: html: add a formatter command, making use of 'tidy'
|
||||
syntax: html: colorize only full attributes, and colorize strings later
|
||||
syntax: javascript: colorize also special values 'null' and 'undefined'
|
||||
syntax: javascript: colorize the boolean values 'true' and 'false' too
|
||||
syntax: nanorc: colorize all arguments of 'fixer' and 'linter' as valid
|
||||
syntax: nanorc: colorize in bright red everything that is invalid
|
||||
syntax: nanorc: colorize only lowercase keywords as valid
|
||||
syntax: nanorc: colorize the 'fixer' command as valid
|
||||
syntax: ruby: colorize also lowercase global/instance variables
|
||||
syntaxes: put the 'linter' and 'formatter' commands on a separate line
|
||||
tweaks: add a helper function without the ubiquitous NULL argument
|
||||
tweaks: add a local variable, for clarity, to not preuse another one
|
||||
tweaks: add some "fall-through" comments, and reshuffle some breaks
|
||||
tweaks: add two translator hints
|
||||
tweaks: adjust the indentation after the previous change
|
||||
tweaks: adjust the indentation after the previous change
|
||||
tweaks: adjust the indentation after the previous change, and another
|
||||
tweaks: adjust two comments, to better fit the actual functions
|
||||
tweaks: avoid setting and resetting a variable when there is no need
|
||||
tweaks: avoid three unneeded calls of umask() in the normal case
|
||||
tweaks: be explicit about which program complained
|
||||
tweaks: check the return value of copy_file() also after its other uses
|
||||
tweaks: close the unused reading ends of two more output pipes
|
||||
tweaks: condense a fragment of code by making use of a helper function
|
||||
tweaks: condense or improve some comments
|
||||
tweaks: condense two comments, and rename two parameters
|
||||
tweaks: condense two comments, and rewrap a line
|
||||
tweaks: correct a comment, and retype a variable
|
||||
tweaks: die on an impossible condition -- to be removed later
|
||||
tweaks: don't do in the parent something that only the child needs
|
||||
tweaks: don't wrap calls of statusline() that slightly overshoot 80 cols
|
||||
tweaks: drop the unneeded closing of descriptors when exiting anyway
|
||||
tweaks: elide a duplicate opening of the existing file when prepending
|
||||
tweaks: elide a function call for the plain ASCII case
|
||||
tweaks: elide another two calls of umask(), and rename two variables
|
||||
tweaks: elide an unneeded and leaky function
|
||||
tweaks: elide an unneeded check when making a backup
|
||||
tweaks: elide a variable, and add a condition to elide an assignment
|
||||
tweaks: elide a variable that is the same as another
|
||||
tweaks: exclude two fragments of code from the tiny version
|
||||
tweaks: fuse two regexes into one
|
||||
tweaks: group the closing of descriptors together, for compactness
|
||||
tweaks: group the closing of two descriptors, and reword two comments
|
||||
tweaks: harmonize a message with another
|
||||
tweaks: improve some comments, and trim some repetitive ones
|
||||
tweaks: make a function do a check so its calls don't need to
|
||||
tweaks: mark two strings for translation
|
||||
tweaks: move a call of umask() closer to where it is relevant
|
||||
tweaks: move two functions to after the one that they make use of
|
||||
tweaks: normalize the indentation after the previous change
|
||||
tweaks: order two functions more sensibly
|
||||
tweaks: pass an empty string as an answer instead of a NULL pointer
|
||||
tweaks: pass an empty string for copying instead of a non-existent one
|
||||
tweaks: pass any special undo/redo messages to the add_undo() function
|
||||
tweaks: remove a pointless updating of the title bar
|
||||
tweaks: remove a redundant check for an existing emergency file
|
||||
tweaks: remove the superfluous closing of a file descriptor
|
||||
tweaks: remove two pointless re-inclusion guards
|
||||
tweaks: remove two superfluous conditions when prepending
|
||||
tweaks: rename a function and add a parameter, so it becomes more general
|
||||
tweaks: rename a function, and elide a parameter that is always NULL
|
||||
tweaks: rename a function and elide its first parameter
|
||||
tweaks: rename a local variable, to not shadow another
|
||||
tweaks: rename a variable, to be a bit more fitting
|
||||
tweaks: rename a variable, to be distinct and visible
|
||||
tweaks: rename three variables, and reshuffle some lines
|
||||
tweaks: rename three variables, to be consistent with other linestructs
|
||||
tweaks: rename three variables, to be more descriptive
|
||||
tweaks: rename three variables, to match others elsewhere
|
||||
tweaks: rename two parameters, for contrast and to match others
|
||||
tweaks: rename two parameters plus a variable, to match others
|
||||
tweaks: rename two variables, and add a third, for more contrast
|
||||
tweaks: reshuffle a few declarations, and reduce the scope of one
|
||||
tweaks: reshuffle a fragment of code into two alternatives
|
||||
tweaks: reshuffle an 'if' to avoid a negation, and improve a comment
|
||||
tweaks: reshuffle some declarations, and rename a variable
|
||||
tweaks: reword an undo/redo string that was overlooked during the rename
|
||||
tweaks: silence a warning when configured with --enable-tiny
|
||||
tweaks: simplify the opening of files when prepending
|
||||
tweaks: slightly reword some fragments in the manual's rebinding section
|
||||
tweaks: use a better variable name for the argument of an option
|
||||
tweaks: use a literal NULL instead of a variable that is NULL
|
||||
tweaks: use a simpler positive/negative check for after copy_file()
|
||||
tweaks: use a string-copy function that checks for out-of-memory
|
||||
tweaks: use the given string instead of the found match, for clarity
|
||||
undo: don't try to copy a string that doesn't exist
|
||||
undo: put the cursor back on the original row for a full-buffer operation
|
||||
utils: don't accept NULL for the string to be copied
|
||||
|
||||
Jeroen Roovers (1):
|
||||
syntax: gentoo: highlight the BDEPEND variable as well
|
||||
|
||||
|
||||
Changes between v4.4 and v4.5:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (60):
|
||||
bindings: add a dedicated keycode for <Tab> for when a region is marked
|
||||
bump version numbers and add a news item for the 4.5 release
|
||||
color: don't concatenate an absolute path with the working directory
|
||||
docs: add two examples of the 'tabgives' command to the sample nanorc
|
||||
docs: describe the new syntax-specific 'tabgives' command
|
||||
docs: mark the undoing of justifications as done in the TODO list
|
||||
docs: mention that gcc must be at least version 5.0
|
||||
gnulib: update to its current upstream state
|
||||
mouse: make the clickable width of menu items more consistent
|
||||
new feature: a 'tabgives' command to define what the Tab key produces
|
||||
search: after search-at-startup, store the column (for vertical movement)
|
||||
tweaks: add a translator hint, and correct two others
|
||||
tweaks: add some translator hints, be more precise on permissible length
|
||||
tweaks: add two hints for translators, to try and help avoid mistakes
|
||||
tweaks: adjust indentation after previous change, reshuffle declarations
|
||||
tweaks: avoid a comparison between signed and unsigned [coverity]
|
||||
tweaks: avoid leaking memory when finding an invalid string [coverity]
|
||||
tweaks: avoid recomputing a maximum value every time round the loop
|
||||
tweaks: don't burden all menus with something meant for the WriteOut menu
|
||||
tweaks: elide a function from a non-UTF8 build
|
||||
tweaks: elide two multiplications with something that is always 1
|
||||
tweaks: frob a few comments
|
||||
tweaks: improve a bunch of comments, and reshuffle some declarations
|
||||
tweaks: improve a handful of comments, and reduce the needed padding
|
||||
tweaks: mark as 'const' a parameter that takes fixed strings [coverity]
|
||||
tweaks: meld two calls of free() into a single one, to elide an 'else'
|
||||
tweaks: move a fragment of common code into the appropriate function
|
||||
tweaks: move a function to a better file, to be amongst its kind
|
||||
tweaks: move a function to before its callers and next to its kind
|
||||
tweaks: move two functions to after the ones that they call
|
||||
tweaks: remove some timing code that has served its purpose
|
||||
tweaks: remove two superfluous macros, as sizeof(char) is always 1
|
||||
tweaks: rename a function, to be a bit more fitting
|
||||
tweaks: rename another type, again to better fit the general pattern
|
||||
tweaks: rename another type, to also better fit the general pattern
|
||||
tweaks: rename another variable, for a better fit
|
||||
tweaks: rename a type, to better fit the general pattern
|
||||
tweaks: rename a variable, normalize a comment, and reshuffle a free()
|
||||
tweaks: rename a variable, to be more compact
|
||||
tweaks: rename three variables, for contrast and more sense
|
||||
tweaks: rename three variables, for more contrast
|
||||
tweaks: rename three variables, to better indicate what they hold
|
||||
tweaks: rename two variables, away from single letters
|
||||
tweaks: rename two variables, to better describe what they contain
|
||||
tweaks: reshuffle a fragment, to group some toggles together
|
||||
tweaks: reshuffle a line, to group things better
|
||||
tweaks: reshuffle some lines, to elide an unneeded assignment
|
||||
tweaks: reshuffle some lines, to have the same order as elsewhere
|
||||
tweaks: reshuffle two fragments, to group things better
|
||||
tweaks: rewrap a line, reshuffle a declaration, and improve some comments
|
||||
tweaks: simplify a calculation, as done elsewhere
|
||||
tweaks: simplify the determination of a canonical path
|
||||
tweaks: sort two keywords strictly alphabetically
|
||||
tweaks: speed up determining the width of plain ASCII characters
|
||||
tweaks: speed up the counting of the menu entries to be shown
|
||||
tweaks: use a more effecient way to skip storing an empty file name
|
||||
tweaks: use an early return when there is no tilde
|
||||
tweaks: use 'void' in prototypes of parameterless functions [coverity]
|
||||
usage: mark the -J/--guidestripe option plus argument as translatable
|
||||
usage: properly align --help output also when it has accented characters
|
||||
|
||||
Brand Huntsman (1):
|
||||
search: accept a match at start of file when searching from command line
|
||||
|
||||
Dirkjan Ochtman (1):
|
||||
syntax: rust: add the words reserved in 2018, and remove unreserved ones
|
||||
|
||||
|
||||
Changes between v4.3 and v4.4:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (53):
|
||||
browser: draw a bar of spaces only where needed -- for the selected item
|
||||
build: exclude the search-at-startup feature from the tiny version
|
||||
bump version numbers and add a news item for the 4.4 release
|
||||
copying: do not prevent M-6 from copying emptiness into the cutbuffer
|
||||
display: blank the status bar on a successful cut or paste
|
||||
display: clear the remainder of a row only when there actually is some
|
||||
display: don't clear a row beforehand -- just clear the remainder
|
||||
display: use a somewhat faster method to clear a row
|
||||
display: when linenumbering, correctly spotlight text that spans two rows
|
||||
display: where needed, use slow blanking, but elsewhere do it much faster
|
||||
docs: change a few URLs over to https, and rewrap a couple of NEWS items
|
||||
docs: document the search-at-startup feature (+/string or +?string)
|
||||
docs: make the synopsis of --speller and 'set speller' more accurate
|
||||
docs: mention the M-N toggle instead of the obsolete M-# one
|
||||
docs: slightly reword some of the descriptions around syntax highlighting
|
||||
docs: slightly reword the descriptions of most configure options
|
||||
docs: stop mentioning the 'unjustify' function, as it no longer exists
|
||||
gnulib: update to its current upstream state
|
||||
new document: a condensed overview of nano's shortcut keystrokes
|
||||
new feature: allow specifying a search string to "jump to" at startup
|
||||
rcfile: properly handle an empty syntax before an 'include' statement
|
||||
scrolling: don't overscroll when the edit window has just one row
|
||||
search: don't wipe the status bar at startup when there was an error
|
||||
search: wipe the status bar before searching again (M-W / M-Q)
|
||||
syntax: c: allow an underscore in lowercase type names
|
||||
syntax: default: colorize bracketed section headers in some config files
|
||||
syntaxes: change some unneeded 'icolor' commands to 'color' commands
|
||||
syntaxes: recognize .ctp extension as a PHP file, and .cu as a C/C++ file
|
||||
syntax: perl: avoid recognizing embedded hash signs as a comment starter
|
||||
syntax: perl: avoid upsetting older glibcs with crafty range expression
|
||||
syntax: perl: don't color the character after a variable name
|
||||
syntax: po: colorize numbers only when they form a self-contained word
|
||||
text: copy leading quote characters when automatic hard-wrapping occurs
|
||||
tweaks: add a translator hint, to clarify four short words
|
||||
tweaks: call the correct lighting function directly when softwrapping
|
||||
tweaks: condense some comments, and drop two unneeded initializations
|
||||
tweaks: drop two parameters that are no longer needed
|
||||
tweaks: improve a comment, and drop a superfluous one
|
||||
tweaks: improve a handful of comments
|
||||
tweaks: make a function name unique, to not overlap with others
|
||||
tweaks: move a call from two different places to a single place
|
||||
tweaks: move a function to before the first one that calls it
|
||||
tweaks: move a general function to a better place
|
||||
tweaks: remove a saving and restoring that has become superfluous
|
||||
tweaks: rename a function, to suit better, and reshuffle its parameters
|
||||
tweaks: rename a parameter in three functions, to say what it points to
|
||||
tweaks: reshuffle an assignment, and trim some excessive blank lines
|
||||
tweaks: reshuffle an 'if' out of a function, and rename the function
|
||||
tweaks: reword and condense two comments, and correct another
|
||||
tweaks: rewrap two lines, and reshuffle some logic to make more sense
|
||||
tweaks: shorten two messages that translators tend to make too long
|
||||
tweaks: try the allocation of a multidata cache just once per line
|
||||
tweaks: when precalculating, allocate all the cache space upfront
|
||||
|
||||
Brand Huntsman (3):
|
||||
rcfile: for an empty syntax, show the line number of the 'syntax' command
|
||||
rcfile: report the correct command location for an invalid 'include'
|
||||
search: accept toggles for case and regex when searching at startup
|
||||
|
||||
|
||||
Changes between v4.2 and v4.3:
|
||||
------------------------------
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@ Improvements in GNU nano
|
||||
========================
|
||||
|
||||
Since 4.0:
|
||||
- What the <Tab> key produces can be specified per syntax with 'tabgives'.
|
||||
- The ability to perform a search at startup with +/string or +?string.
|
||||
- Comment characters are copied when automatic hard-wrapping occurs.
|
||||
- The ability to both read from and write to a FIFO.
|
||||
- Automatic hard-wrapping is no longer the default.
|
||||
- Addition of --guidestripe to draw a helpful vertical bar.
|
||||
|
||||
111
NEWS
111
NEWS
@@ -1,3 +1,34 @@
|
||||
2019.12.23 - GNU nano 4.7 "Havikskruid"
|
||||
• A <Tab> will indent a marked region only when mark and cursor are
|
||||
on different lines.
|
||||
• Two indentations (any mix of tabs and spaces) are considered the
|
||||
same when they look the same (that is: indent to the same level).
|
||||
• When using --breaklonglines or ^J, a line will never be broken in
|
||||
its leading whitespace or quoting.
|
||||
• The keywords in nanorc files must be in lowercase.
|
||||
|
||||
2019.11.29 - GNU nano 4.6 "And don't you eat that yellow snow"
|
||||
• The 'formatter' command has returned, bound by default to M-F.
|
||||
It allows running a syntax-specific command on the contents of
|
||||
the buffer.
|
||||
• ^T will try to run 'hunspell' before 'spell', because it checks
|
||||
spellling for the locale's language and understands UTF-8.
|
||||
• Multiple errors or warnings on startup will no longer slow nano
|
||||
down but will be indicated on the status bar with trailing dots.
|
||||
|
||||
2019.10.04 - GNU nano 4.5 "Košice"
|
||||
• The new 'tabgives' command allows you to specify per syntax what
|
||||
the <Tab> key should produce: some spaces, a hard TAB, ...
|
||||
• The output of --help is properly aligned again for all languages.
|
||||
• <Tab> will indent a marked region also when M-} has been rebound.
|
||||
|
||||
2019.08.25 - GNU nano 4.4 "Hagelslag"
|
||||
• At startup, the cursor can be put on the first or last occurrence
|
||||
of a string by preceding the filename with +/string or +?string.
|
||||
• When automatic hard-wrapping occurs (--breaklonglines), any leading
|
||||
quoting characters will be automatically copied to the new line.
|
||||
• M-6 works again also when the cursor is at end of buffer.
|
||||
|
||||
2019.06.18 - GNU nano 4.3 "Musa Kart"
|
||||
• The ability to read from and write to a FIFO has been regained.
|
||||
• Startup time is reduced by fully parsing a syntax only when needed.
|
||||
@@ -615,7 +646,7 @@
|
||||
like this what could POSSIBLY go WRONG? Hahaha.
|
||||
Enjoy and if you find new bugs, as always please
|
||||
use Savannah's bug tracker.
|
||||
http://savannah.gnu.org/bugs/?func=additem&group=nano
|
||||
https://savannah.gnu.org/bugs/?func=additem&group=nano
|
||||
|
||||
2010.01.17 - GNU nano 2.2.2 is released for you, you, you. This
|
||||
release includes fixes for: crashes when writing
|
||||
@@ -700,7 +731,7 @@
|
||||
editor, via the -$ or --softwrap command-line flags,
|
||||
or via "set softwrap" in your .nanorc. As always,
|
||||
please report any bugs to the nano Savannah project page
|
||||
(http://savannah.gnu.org/bugs/?func=additem&group=nano)
|
||||
(https://savannah.gnu.org/bugs/?func=additem&group=nano)
|
||||
Remember: data loss happens, back up your files.
|
||||
|
||||
2009.07.28 - GNU nano 2.1.10 "Ellie" is released. This version includes
|
||||
@@ -728,45 +759,41 @@
|
||||
birthday lenny!
|
||||
|
||||
2009.02.07 - GNU nano 2.1.8 "unsafe at any speed" is released. This
|
||||
release include some long overdue performance
|
||||
improvements in syntax color highlighting, the ability
|
||||
to abort running searches (useful mainly when
|
||||
editing very large files) and the ability to use nano
|
||||
like a pager for viewing standard input (i.e. "nano -").
|
||||
Additionally, there are gentoo syntax highlighting
|
||||
updates and fixes for issues with reading files
|
||||
in a directory with strange parent directory permissions.
|
||||
The key bindings code was also substantially changed
|
||||
in order to be more ISO-C compatible. Be sure to use
|
||||
the Savannah page not only for bug reports but for any
|
||||
release includes some long overdue performance improvements
|
||||
in syntax color highlighting, the ability to abort running
|
||||
searches (useful mainly when editing very large files) and
|
||||
the ability to use nano like a pager for viewing standard
|
||||
input (i.e. "nano -"). Additionally, there are gentoo
|
||||
syntax highlighting updates and fixes for issues with
|
||||
reading files in a directory with strange parent directory
|
||||
permissions. The key-bindings code was also substantially
|
||||
changed in order to be more ISO-C compatible. Be sure to
|
||||
use the Savannah page not only for bug reports but for any
|
||||
features you would like to see before the next stable
|
||||
series is released. Have fun with it!
|
||||
|
||||
2008.11.10 - GNU nano 2.1.7 "Effingham" is ready to make good on those
|
||||
campaign promises of lower bug rates and 50% more pie.
|
||||
This release includes a new check for external
|
||||
modifications when saving a file, some code and
|
||||
documentation cleanups, and more bug fixes for
|
||||
the new undo code (but we continue to welcome
|
||||
your bug reports via the Savannah bug page at
|
||||
http://savannah.gnu.org/bugs/?func=additem&group=nano).
|
||||
This release includes a new check for external modifications
|
||||
when saving a file, some code and documentation cleanups,
|
||||
and more bug fixes for the new undo code (but we continue
|
||||
to welcome your bug reports via the Savannah bug page at
|
||||
https://savannah.gnu.org/bugs/?func=additem&group=nano).
|
||||
Come get some.
|
||||
|
||||
2008.10.03 - GNU nano 2.1.6 was for new features before it was against
|
||||
them. This release includes more undo capability,
|
||||
several new syntax highlighting configurations including
|
||||
Objective C, OCaml, and Fortran, and a new capability
|
||||
to activate highlighting based on the 1st line of the
|
||||
file being edited. Also, the new default configure
|
||||
options now include color syntax highlighting, .nanorc
|
||||
support, multibuffer and extras. These items can still
|
||||
be disabled and are not enabled with --enable-tiny. Bug
|
||||
fixes include better signal handling under Cygwin, and
|
||||
that's about it. Again please remember to
|
||||
submit bug reports via Savannah at
|
||||
http://savannah.gnu.org/bugs/?func=additem&group=nano
|
||||
as undo functions certainly need more testing.
|
||||
Bon appetit.
|
||||
them. This release includes more undo capability, several
|
||||
new syntax highlighting configurations including Objective
|
||||
C, OCaml, and Fortran, and a new capability to activate
|
||||
highlighting based on the 1st line of the file being
|
||||
edited. Also, the new default configure options now
|
||||
include color syntax highlighting, .nanorc support,
|
||||
multibuffer and extras. These items can still be disabled
|
||||
and are not enabled with --enable-tiny. Bug fixes include
|
||||
better signal handling under Cygwin, and that's about it.
|
||||
Again please remember to submit bug reports via Savannah at
|
||||
https://savannah.gnu.org/bugs/?func=additem&group=nano as
|
||||
undo functions certainly need more testing. Bon appetit.
|
||||
|
||||
2008.08.30 - GNU nano 2.1.5 is ready to lead on day one. This release
|
||||
contains a better fix for incorrectly reported successful
|
||||
@@ -789,15 +816,15 @@
|
||||
are likely to run out of space; see Savannah bug #24000.
|
||||
Have fun with it!
|
||||
|
||||
2008.08.04 - GNU nano 2.1.3 "least stable version ever" is released. This
|
||||
release includes new (and experimental) undo and redo
|
||||
functionality for most text operations. The default
|
||||
key bindings are Meta-U for undo and Meta-E for redo, but
|
||||
these can be remapped using the new 2.1 keybinding code.
|
||||
Also included are some fixes for configuring using wide
|
||||
curses, crashing when invoking the help menu with
|
||||
certain locales, and not saving the search history when
|
||||
compiled with configure options.
|
||||
2008.08.04 - GNU nano 2.1.3 "least stable version ever" is released.
|
||||
This release includes new (and experimental) undo and redo
|
||||
functionality for most text operations. The default key
|
||||
bindings are Meta-U for undo and Meta-E for redo, but these
|
||||
can be remapped using the new 2.1 keybinding code. Also
|
||||
included are some fixes for configuring using wide curses,
|
||||
crashing when invoking the help menu with certain locales,
|
||||
and not saving the search history when compiled with
|
||||
configure options.
|
||||
|
||||
2008.04.24 - GNU nano 2.1.2 "New York City" is released. This release
|
||||
contains fixes for binding bad keys, some
|
||||
|
||||
6
README
6
README
@@ -25,10 +25,10 @@ Overview
|
||||
|
||||
How to compile and install nano
|
||||
|
||||
Download the nano source code, then:
|
||||
Download the latest nano source tarball, then:
|
||||
|
||||
tar xvzf nano-x.y.z.tar.gz
|
||||
cd nano-x.y.z
|
||||
tar -xvf nano-x.y.tar.gz
|
||||
cd nano-x.y
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
|
||||
@@ -14,13 +14,13 @@ packages:
|
||||
- autoconf (version >= 2.69)
|
||||
- automake (version >= 1.14)
|
||||
- autopoint (version >= 0.18.3)
|
||||
- gcc (version >= 5.0)
|
||||
- gettext (version >= 0.18.3)
|
||||
- git (version >= 2.7.4)
|
||||
- groff (version >= 1.12)
|
||||
- make (any version)
|
||||
- pkg-config (version >= 0.22)
|
||||
- texinfo (version >= 4.0)
|
||||
- gcc (any version)
|
||||
- make (any version)
|
||||
|
||||
If you want UTF-8 support, you will also need libncursesw5-dev installed
|
||||
(version >= 5.7), or libslang2-dev (version >= 2.0) if you use --with-slang.
|
||||
|
||||
4
TODO
4
TODO
@@ -2,7 +2,6 @@ A list of desired features
|
||||
--------------------------
|
||||
|
||||
Somewhat urgent:
|
||||
- Make undo/redo work also for justifying.
|
||||
- Detect when text is being pasted, so that we can handle it faster.
|
||||
See https://savannah.gnu.org/bugs/?40060.
|
||||
- Allow color syntaxes to apply to more than just color, so that we can
|
||||
@@ -17,6 +16,9 @@ Vague musings:
|
||||
- Make matching bracket searches sophisticated enough to skip over
|
||||
brackets inside comments?
|
||||
|
||||
For version 4.0:
|
||||
- Make undo/redo work also for justifying. [DONE]
|
||||
|
||||
For version 2.9:
|
||||
- Allow piping (marked) text to an external command and replacing it with
|
||||
the command's output. That is: implement filtering. [DONE]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Generate configure & friends for GIT users.
|
||||
|
||||
gnulib_url="git://git.sv.gnu.org/gnulib.git"
|
||||
gnulib_hash="a1beabcb14cde661c36f7a3c7c17b5871704003e"
|
||||
gnulib_hash="129087dbb4f8721d750d2ec58261c56b2bda2536"
|
||||
|
||||
modules="
|
||||
futimens
|
||||
|
||||
@@ -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], [4.3], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [4.7], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AC_CANONICAL_HOST
|
||||
AM_INIT_AUTOMAKE([1.14])
|
||||
|
||||
134
doc/cheatsheet.html
Normal file
134
doc/cheatsheet.html
Normal file
@@ -0,0 +1,134 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>Cheatsheet for nano</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="description" content="A concise overview of the command shortcuts of the GNU nano editor, grouped by category.">
|
||||
<meta name="keywords" content="cheatsheet, nano, editor, shortcuts, keystrokes, functions, operations, commands">
|
||||
<meta name="author" content="Benno Schulenberg">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<br>
|
||||
<h1 align="center">Overview of nano's shortcuts </h1>
|
||||
<h3 align="center">The editor's keystrokes and their functions </h3>
|
||||
<br>
|
||||
|
||||
<table align="center"><tbody>
|
||||
<tr><td>
|
||||
|
||||
<b>File handling</b>
|
||||
<table><tbody>
|
||||
<tr><td>Ctrl+S </td><td>Save current file</td></tr>
|
||||
<tr><td>Ctrl+O</td><td>Offer to write file ("Save as")</td></tr>
|
||||
<tr><td>Ctrl+R</td><td>Insert a file into current one</td></tr>
|
||||
<tr><td>Ctrl+X</td><td>Close buffer, exit from nano</td></tr>
|
||||
</tbody></table>
|
||||
<br>
|
||||
|
||||
<b>Editing</b>
|
||||
<table><tbody>
|
||||
<tr><td>Ctrl+K </td><td>Cut current line into cutbuffer</td></tr>
|
||||
<tr><td>Alt+6</td><td>Copy current line into cutbuffer</td></tr>
|
||||
<tr><td>Ctrl+U</td><td>Paste contents of cutbuffer</td></tr>
|
||||
<tr><td>Alt+T</td><td>Cut until end of buffer</td></tr>
|
||||
<tr><td>Ctrl+]</td><td>Complete current word</td></tr>
|
||||
<tr><td>Alt+3</td><td>Comment/uncomment line/region</td></tr>
|
||||
<tr><td>Alt+U</td><td>Undo last action</td></tr>
|
||||
<tr><td>Alt+E</td><td>Redo last undone action</td></tr>
|
||||
</tbody></table>
|
||||
<br>
|
||||
|
||||
<b>Search and replace</b>
|
||||
<table><tbody>
|
||||
<tr><td>Ctrl+Q </td><td>Start backward search</td></tr>
|
||||
<tr><td>Ctrl+W</td><td>Start forward search</td></tr>
|
||||
<tr><td>Alt+Q</td><td>Find next occurrence backward</td></tr>
|
||||
<tr><td>Alt+W</td><td>Find next occurrence forward</td></tr>
|
||||
<tr><td>Alt+R</td><td>Start a replacing session</td></tr>
|
||||
</tbody></table>
|
||||
<br>
|
||||
|
||||
<b>Deletion</b>
|
||||
<table><tbody>
|
||||
<tr><td>Ctrl+H</td><td>Delete character before cursor </td></tr>
|
||||
<tr><td>Ctrl+D</td><td>Delete character under cursor</td></tr>
|
||||
<tr><td>Ctrl+Shift+Del </td><td>Delete word to the left</td></tr>
|
||||
<tr><td>Ctrl+Del</td><td>Delete word to the right</td></tr>
|
||||
<tr><td>Alt+Del</td><td>Delete current line</td></tr>
|
||||
</tbody></table>
|
||||
<br>
|
||||
|
||||
<b>Operations</b>
|
||||
<table><tbody>
|
||||
<tr><td>Ctrl+T </td><td>Run a spell check</td></tr>
|
||||
<tr><td>Ctrl+J</td><td>Justify paragraph or region</td></tr>
|
||||
<tr><td>Alt+J</td><td>Justify entire buffer</td></tr>
|
||||
<tr><td>Alt+B</td><td>Run a syntax check</td></tr>
|
||||
<tr><td>Alt+F</td><td>Run a formatter/fixer/arranger</td></tr>
|
||||
<tr><td>Alt+:</td><td>Start/stop recording of macro</td></tr>
|
||||
<tr><td>Alt+;</td><td>Replay macro</td></tr>
|
||||
</tbody></table>
|
||||
<br>
|
||||
|
||||
</td><td>
|
||||
|
||||
<b>Moving around</b>
|
||||
<table><tbody>
|
||||
<tr><td>Ctrl+B </td><td>One character backward</td></tr>
|
||||
<tr><td>Ctrl+F</td><td>One character forward</td></tr>
|
||||
<tr><td>Ctrl+⯇</td><td>One word backward</td></tr>
|
||||
<tr><td>Ctrl+⯈</td><td>One word forward</td></tr>
|
||||
<tr><td>Ctrl+A</td><td>To start of line</td></tr>
|
||||
<tr><td>Ctrl+E</td><td>To end of line</td></tr>
|
||||
<tr><td>Ctrl+P</td><td>One line up</td></tr>
|
||||
<tr><td>Ctrl+N</td><td>One line down</td></tr>
|
||||
<tr><td>Ctrl+⯅</td><td>To previous block</td></tr>
|
||||
<tr><td>Ctrl+⯆</td><td>To next block</td></tr>
|
||||
<tr><td>Ctrl+Y</td><td>One page up</td></tr>
|
||||
<tr><td>Ctrl+V</td><td>One page down</td></tr>
|
||||
<tr><td>Alt+\</td><td>To top of buffer</td></tr>
|
||||
<tr><td>Alt+/</td><td>To end of buffer</td></tr>
|
||||
</tbody></table>
|
||||
<br>
|
||||
|
||||
<b>Special movement</b>
|
||||
<table><tbody>
|
||||
<tr><td>Alt+G </td><td>Go to specified line</td></tr>
|
||||
<tr><td>Alt+]</td><td>Go to complementary bracket</td></tr>
|
||||
<tr><td>Alt+⯅</td><td>Scroll viewport up</td></tr>
|
||||
<tr><td>Alt+⯆</td><td>Scroll viewport down</td></tr>
|
||||
<tr><td>Alt+<</td><td>Switch to preceding buffer</td></tr>
|
||||
<tr><td>Alt+></td><td>Switch to succeeding buffer</td></tr>
|
||||
</tbody></table>
|
||||
<br>
|
||||
|
||||
<b>Information</b>
|
||||
<table><tbody>
|
||||
<tr><td>Ctrl+C </td><td>Report cursor position</td></tr>
|
||||
<tr><td>Alt+D</td><td>Report word/line/char count</td></tr>
|
||||
<tr><td>Ctrl+G</td><td>Display help text</td></tr>
|
||||
</tbody></table>
|
||||
<br>
|
||||
|
||||
<b>Various</b>
|
||||
<table><tbody>
|
||||
<tr><td>Alt+A</td><td>Turn the mark on/off</td></tr>
|
||||
<tr><td>Tab</td><td>Indent marked region</td></tr>
|
||||
<tr><td>Shift+Tab </td><td>Unindent marked region</td></tr>
|
||||
<tr><td>Alt+N</td><td>Turn line numbers on/off</td></tr>
|
||||
<tr><td>Alt+P</td><td>Turn visible whitespace on/off</td></tr>
|
||||
<tr><td>Alt+V</td><td>Enter next keystroke verbatim</td></tr>
|
||||
<tr><td>Ctrl+L</td><td>Refresh the screen</td></tr>
|
||||
<tr><td>Ctrl+Z</td><td>Suspend nano</td></tr>
|
||||
</tbody></table>
|
||||
<br>
|
||||
|
||||
</td></tr>
|
||||
</tbody></table>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
23
doc/faq.html
23
doc/faq.html
@@ -1,9 +1,12 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>The GNU nano editor FAQ</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="description" content="The genesis story of the nano editor, plus the solution to some common problems.">
|
||||
</head>
|
||||
|
||||
<body text="#330000" bgcolor="#ffffff" link="#0000ef" vlink="#51188e" alink="#ff0000">
|
||||
|
||||
<h1>The GNU nano editor FAQ</h1>
|
||||
@@ -85,7 +88,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>4.3</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
|
||||
<blockquote><p>The current version of nano <i>should</i> be <b>4.7</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%">
|
||||
@@ -112,7 +115,7 @@
|
||||
<li><a href="https://packages.debian.org/testing/editors/nano">testing</a></li>
|
||||
<li><a href="https://packages.debian.org/unstable/editors/nano">unstable</a></li>
|
||||
</ul>
|
||||
<p>You can also have a look at the <a href="ftp://ftp.debian.org/debian/pool/main/n/nano/">Package Pool</a> to see all the available binary and source packages.</p>
|
||||
<p>You can also have a look at the <a href="http://ftp.debian.org/debian/pool/main/n/nano/">Package Pool</a> to see all the available binary and source packages.</p>
|
||||
</blockquote>
|
||||
<h3><a name="2.4"></a>2.4. By GIT (for the brave).</h3>
|
||||
<blockquote><p>For the 'bleeding edge' current version of nano, you can use GIT to download the current source code. <b>Note:</b> believe it or not, by downloading code that has not yet stabilized into an official release, there could quite possibly be bugs, in fact the code may not even compile! Anyway, see <a href="http://git.savannah.gnu.org/cgit/nano.git/tree/README.GIT">the nano GIT document</a> for info on anonymous GIT access to the nano source.</p></blockquote>
|
||||
@@ -120,13 +123,13 @@
|
||||
|
||||
<h1><a name="3"></a>3. Installation and Configuration</h1>
|
||||
<h3><a name="3.1"></a>3.1. How do I install the RPM or DEB package?</h3>
|
||||
<blockquote><p>It's simple really! As root, type <b>rpm -Uvh nano-x.y.z-1.i386.rpm</b> if you have a RedHat-ish system or <b>dpkg -i nano_x.y.z-1.deb</b> if you have a Debian-ish system, where <b>x.y.z</b> is the release of nano. There are other programs to install packages, and if you wish to use those, knock yourself out.</p></blockquote>
|
||||
<blockquote><p>It's simple really! As root, type <b>rpm -Uvh nano-x.y-1*.rpm</b> if you have a RedHat-ish system or <b>dpkg -i nano_x.y-1*.deb</b> if you have a Debian-ish system, where <b>x.y</b> is the version number of nano. There are other programs to install packages, and if you wish to use those, knock yourself out.</p></blockquote>
|
||||
<h3><a name="3.2"></a>3.2. Compiling from source: WHAT THE HECK DO I DO NOW?</h3>
|
||||
<blockquote><p>Okay, take a deep breath, this really isn't hard. Unpack the nano source with a command like:</p>
|
||||
<p><b>tar -xvf nano-x.y.z.tar.gz</b></p>
|
||||
<p><b>tar -xvf nano-x.y.tar.gz</b></p>
|
||||
<p>Then you need to run <b>configure</b> with any options you might want (if any).</p>
|
||||
<p>The average case is this:</p>
|
||||
<p><b>cd nano-x.y.z/</b><br>
|
||||
<p><b>cd nano-x.y/</b><br>
|
||||
<b>./configure</b><br>
|
||||
<b>make</b><br>
|
||||
<b>make install</b> (as root, of course)</p></blockquote>
|
||||
@@ -203,8 +206,8 @@
|
||||
<b>[ ] enable-alternate-editor-implicitly</b></p>
|
||||
<p>Then exit (<b>E</b>) and select Yes (<b>Y</b>).</p>
|
||||
<p>If you're a mutt user, you should see an effect immediately the next time you log in. No further configuration is needed. However, if you want to let people know you use nano to compose your email messages, you can put a line like this in your <b>.muttrc</b>:</p>
|
||||
<p><b>my_hdr X-Composer: nano x.y.z</b></p>
|
||||
<p>Again, replace x.y.z with the version of nano you use.</p></blockquote>
|
||||
<p><b>my_hdr X-Composer: nano-x.y</b></p>
|
||||
<p>Again, replace x.y with the version of nano you use.</p></blockquote>
|
||||
<hr width="100%">
|
||||
|
||||
<h1><a name="5"></a>5. Internationalization</h1>
|
||||
|
||||
28
doc/nano.1
28
doc/nano.1
@@ -16,14 +16,16 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANO 1 "version 4.3" "June 2019"
|
||||
.TH NANO 1 "version 4.7" "December 2019"
|
||||
|
||||
.SH NAME
|
||||
nano \- Nano's ANOther editor, inspired by Pico
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B nano
|
||||
.RI [ options "] [[+" line [, column "]]\ " file "]..."
|
||||
.RI [ options "] [[\fB+" line [\fB, column "]] " file ]...
|
||||
.sp
|
||||
.BR nano " [" \fIoptions "] [[" + [ crCR ]( / | ? ) \fIstring "] " \fIfile ]...
|
||||
|
||||
.SH NOTICE
|
||||
Starting with version 4.0, \fBnano\fR no longer hard-wraps an overlong
|
||||
@@ -38,11 +40,24 @@ If you want the old, Pico behavior back, you can use \fB\-\-breaklonglines\fR,
|
||||
of Pico, but is free software, and implements several features that Pico
|
||||
lacks, such as: opening multiple files, scrolling per line, undo/redo,
|
||||
syntax coloring, line numbering, and soft-wrapping overlong lines.
|
||||
|
||||
.sp
|
||||
When giving a filename on the command line, the cursor can be put on a
|
||||
specific line by adding the line number with a plus sign (\fB+\fR) before
|
||||
the filename, and even in a specific column by adding it with a comma.
|
||||
|
||||
(Negative numbers count from the end of the file or line.)
|
||||
The cursor can be put on the first or last occurrence of a specific string
|
||||
by specifying that string after \fB+/\fR or \fB+?\fR before the filename.
|
||||
The string can be made case sensitive and/or caused to be interpreted as a
|
||||
regular expression by inserting \fBc\fR and/or \fBr\fR after the \fB+\fR sign.
|
||||
These search modes can be explicitly disabled by using the uppercase variant
|
||||
of those letters: \fBC\fR and/or \fBR\fR. When the string contains spaces,
|
||||
it needs to be enclosed in quotes. To give an example: to open a file at
|
||||
the first occurrence of the word "Foo", one would do:
|
||||
.sp
|
||||
.RS 4
|
||||
.BI "nano +c/Foo " file
|
||||
.RE
|
||||
.sp
|
||||
As a special case: if instead of a filename a dash (\fB\-\fR) is given,
|
||||
\fBnano\fR will read data from standard input.
|
||||
|
||||
@@ -263,8 +278,9 @@ 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.
|
||||
.B "\-s ""\fIprogram\fR [\fIarg\fR...]\fB""\fR, \fB\-\-speller=""\fIprogram\fR [\fIarg\fR...]\fB"""
|
||||
Use this command to perform spell checking and correcting, instead of
|
||||
using the built-in corrector that calls \fBhunspell\fR or GNU \fBspell\fR.
|
||||
.TP
|
||||
.BR \-t ", " \-\-tempfile
|
||||
Save a changed buffer without prompting (when exiting with \fB^X\fR).
|
||||
|
||||
181
doc/nano.texi
181
doc/nano.texi
@@ -8,8 +8,8 @@
|
||||
|
||||
@smallbook
|
||||
@set EDITION 0.5
|
||||
@set VERSION 4.3
|
||||
@set UPDATED June 2019
|
||||
@set VERSION 4.7
|
||||
@set UPDATED December 2019
|
||||
|
||||
@dircategory Editors
|
||||
@direntry
|
||||
@@ -23,7 +23,7 @@
|
||||
@titlepage
|
||||
@title GNU @command{nano}
|
||||
@subtitle a small and friendly text editor
|
||||
@subtitle version 4.3
|
||||
@subtitle version 4.7
|
||||
|
||||
@author Chris Allegretta
|
||||
@page
|
||||
@@ -57,13 +57,13 @@ You may contact the author by
|
||||
e-mail: @email{chrisa@@asty.org}@*
|
||||
@end titlepage
|
||||
|
||||
|
||||
@ifnottex
|
||||
|
||||
|
||||
@node Top
|
||||
@top
|
||||
|
||||
This manual documents the GNU @command{nano} editor, version 4.3.
|
||||
This manual documents the GNU @command{nano} editor, version 4.7.
|
||||
|
||||
@menu
|
||||
* Introduction::
|
||||
@@ -127,13 +127,22 @@ But it is also possible to specify one or more options (see the next
|
||||
section), and to edit several files in a row. Additionally, the cursor
|
||||
can be put on a specific line of a file by adding the line number
|
||||
with a plus sign before the filename, and even in a specific column by
|
||||
adding it with a comma. So a more complete command synopsis is:
|
||||
adding it with a comma.
|
||||
(Negative numbers count from the end of the file or line.)
|
||||
The cursor can also be put on the first or last occurrence of a specific string
|
||||
by specifying that string after @code{+/} or @code{+?} before the filename.
|
||||
The string can be made case sensitive and/or caused to be interpreted as a
|
||||
regular expression by inserting a @code{c} and/or @code{r} after the plus sign.
|
||||
These search modes can be explicitly disabled by using the uppercase variant
|
||||
of those letters: @code{C} and/or @code{R}. When the string contains spaces,
|
||||
it needs to be enclosed in quotes.
|
||||
A more complete command synopsis thus is:
|
||||
|
||||
@iftex
|
||||
@sp 1
|
||||
@end iftex
|
||||
@example
|
||||
@code{nano [OPTION]@dots{} [[+LINE[,COLUMN]|+,COLUMN] FILE]@dots{}}
|
||||
@code{nano [OPTION]@dots{} [[+LINE[,COLUMN]|+[crCR](/|?)STRING] FILE]@dots{}}
|
||||
@end example
|
||||
@iftex
|
||||
@sp 1
|
||||
@@ -148,6 +157,7 @@ As a special case: when instead of a filename a dash is given, @command{nano}
|
||||
will read data from standard input. This means you can pipe the output of
|
||||
a command straight into a buffer, and then edit it.
|
||||
|
||||
|
||||
@node Command-line Options
|
||||
@chapter Command-line Options
|
||||
|
||||
@@ -388,13 +398,14 @@ 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}
|
||||
@itemx --speller=@var{program}
|
||||
@item -s "@var{program} [@var{arg} @dots{}]"
|
||||
@itemx --speller="@var{program} [@var{arg} @dots{}]"
|
||||
Use the given program to do spell checking and correcting. By default,
|
||||
@command{nano} uses the command specified in the @env{SPELL} environment
|
||||
variable. If @env{SPELL} is not set, and @option{--speller} is
|
||||
not specified either, then @command{nano} uses its own interactive spell
|
||||
corrector, which requires the GNU @command{spell} program to be installed.
|
||||
corrector, which requires either @command{hunspell} or GNU @command{spell}
|
||||
to be installed.
|
||||
|
||||
@item -t
|
||||
@itemx --tempfile
|
||||
@@ -606,6 +617,7 @@ 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.
|
||||
|
||||
|
||||
@node Built-in Help
|
||||
@chapter Built-in Help
|
||||
|
||||
@@ -683,6 +695,7 @@ be used to configure @command{nano} on startup without using command-line
|
||||
options. Additionally, there are some commands to define syntax highlighting
|
||||
and to rebind keys --- @pxref{Syntax Highlighting} and @ref{Rebinding Keys}.
|
||||
@command{nano} will read one command per line.
|
||||
All commands and keywords should be written in lowercase.
|
||||
|
||||
Options in nanorc files take precedence over @command{nano}'s defaults, and
|
||||
command-line options override nanorc settings. Also, options that do not
|
||||
@@ -835,8 +848,7 @@ Don't automatically add a newline when a text does not end with one.
|
||||
(This can cause you to save non-POSIX text files.)
|
||||
|
||||
@item set nopauses
|
||||
Don't pause between warnings at startup. This means that only
|
||||
the last one will be visible (when there are multiple ones).
|
||||
Obsolete option. Ignored.
|
||||
|
||||
@item set nowrap
|
||||
Deprecated option since it has become the default setting.
|
||||
@@ -915,7 +927,7 @@ When needed, use @code{unset jumpyscrolling} instead.
|
||||
@item set softwrap
|
||||
Enable soft line wrapping for easier viewing of very long lines.
|
||||
|
||||
@item set speller "@var{program}"
|
||||
@item set speller "@var{program} [@var{arg} @dots{}]"
|
||||
Use the given program to do spell checking and correcting.
|
||||
@xref{@option{--speller}} for details.
|
||||
|
||||
@@ -989,7 +1001,7 @@ powerful enough to fully parse a file. Nevertheless, regular
|
||||
expressions can do a lot and are easy to make, so they are a
|
||||
good fit for a small editor like @command{nano}.
|
||||
|
||||
All regular expressions in @command{nano} are extended regular expressions
|
||||
All regular expressions in @command{nano} are POSIX extended regular expressions
|
||||
(ERE). This means that @code{.}, @code{?}, @code{*}, @code{+}, @code{^},
|
||||
@code{$}, and several other characters are special.
|
||||
The period @code{.} matches any single character,
|
||||
@@ -1021,7 +1033,7 @@ activated by using the @option{-Y} or @option{--syntax}
|
||||
command-line option followed by the @var{name}.
|
||||
|
||||
The @code{default} syntax is special: it takes no @var{fileregex},
|
||||
and applies to files that don't match any syntax's @var{fileregex}.
|
||||
and applies to files that don't match any syntax's regexes.
|
||||
The @code{none} syntax is reserved; specifying it on the
|
||||
command line is the same as not having a syntax at all.
|
||||
|
||||
@@ -1038,6 +1050,12 @@ file, to determine whether this syntax should be used for it.
|
||||
(This functionality only works when @code{libmagic} is installed
|
||||
on the system and will be silently ignored otherwise.)
|
||||
|
||||
@item formatter @var{program} [@var{arg} @dots{}]
|
||||
Run the given @var{program} on the full contents of the current buffer.
|
||||
(The current buffer is written out to a temporary file, the program is
|
||||
run on it, and then the temporary file is read back in, replacing the
|
||||
contents of the buffer.)
|
||||
|
||||
@item linter @var{program} [@var{arg} @dots{}]
|
||||
Use the given @var{program} to do a syntax check on the current buffer.
|
||||
|
||||
@@ -1052,26 +1070,33 @@ Python files. If empty double quotes are specified, the comment/uncomment
|
||||
functions are disabled; for example, @t{""} for JSON.
|
||||
The default value is @t{"#"}.
|
||||
|
||||
@item tabgives "@var{string}"
|
||||
Make the <Tab> key produce the given @var{string}. Useful for languages like
|
||||
Python that want to see only spaces for indentation.
|
||||
This overrides the setting of the @code{tabstospaces} option.
|
||||
|
||||
@item color @var{fgcolor},@var{bgcolor} "@var{regex}" @dots{}
|
||||
Display all pieces of text that match the
|
||||
extended regular expression "regex" with foreground color "fgcolor" and
|
||||
background color "bgcolor", at least one of which must be specified.
|
||||
Valid names for foreground and background color are:
|
||||
Paint all pieces of text that match the extended regular expression "regex"
|
||||
with the given foreground and background colors, at least one of which must
|
||||
be specified. Valid color names are:
|
||||
@code{white}, @code{black}, @code{blue}, @code{green},
|
||||
@code{red}, @code{cyan}, @code{yellow}, @code{magenta}, and @code{normal}
|
||||
--- where @code{normal} means the default foreground or background color.
|
||||
You may use the prefix @code{bright}
|
||||
to get a stronger color highlight for the foreground. If your
|
||||
terminal supports transparency, not specifying a "bgcolor" tells @command{nano}
|
||||
to attempt to use a transparent background.
|
||||
You may use the prefix @code{bright} for the foreground color to get a
|
||||
stronger highlight.
|
||||
If your terminal supports transparency, not specifying a "bgcolor"
|
||||
tells @command{nano} to attempt to use a transparent background.
|
||||
|
||||
All coloring commands are applied in the order in which they are specified,
|
||||
which means that later commands can recolor stuff that was colored earlier.
|
||||
|
||||
@item icolor @var{fgcolor},@var{bgcolor} "@var{regex}" @dots{}
|
||||
Same as above, except that the matching is case insensitive.
|
||||
|
||||
@item color @var{fgcolor},@var{bgcolor} start="@var{fromrx}" end="@var{torx}"
|
||||
Display all pieces of text whose start matches extended regular expression
|
||||
Paint all pieces of text whose start matches extended regular expression
|
||||
"fromrx" and whose end matches extended regular expression "torx" with
|
||||
foreground color "fgcolor" and background color "bgcolor", at least one of
|
||||
the given foreground and background colors, at least one of
|
||||
which must be specified. This means that, after an initial instance of
|
||||
"fromrx", all text until the first instance of "torx" will be colored.
|
||||
This allows syntax highlighting to span multiple lines.
|
||||
@@ -1087,28 +1112,12 @@ to @code{icolor}.
|
||||
@item extendsyntax @var{name} @var{command} [@var{arg} @dots{}]
|
||||
Extend the syntax previously defined as "@var{name}" with another @var{command}.
|
||||
This allows you to add a new @code{color}, @code{icolor}, @code{header},
|
||||
@code{magic}, @code{comment}, or @code{linter} command to an already
|
||||
@code{magic}, @code{comment}, @code{linter}, or @code{formatter} command to an already
|
||||
defined syntax --- useful when you want to slightly improve a syntax defined
|
||||
in one of the system-installed files (which normally are not writable).
|
||||
|
||||
@end table
|
||||
|
||||
Note: the @code{formatter} command has been removed. It was superseded by
|
||||
a more general mechanism: the filtering of buffer or marked text through
|
||||
an external command. Such filtering is done by typing @code{^R^X} and then
|
||||
preceding your formatter command with the pipe symbol (@code{|}). It has
|
||||
the added advantage that the operation can be undone.
|
||||
|
||||
If you use such a formatting command regularly, you could assign the relevant
|
||||
series of keystrokes to a single key in your nanorc:
|
||||
|
||||
@example
|
||||
bind M-F "^R^X|yourformatcommand^M" main
|
||||
@end example
|
||||
|
||||
(Note that the @key{^R}, @key{^X}, and @key{^M} are each a single, literal
|
||||
control character. You can enter them by preceding each with @key{M-V}.)
|
||||
|
||||
@node Rebinding Keys
|
||||
@section Rebinding Keys
|
||||
|
||||
@@ -1119,7 +1128,7 @@ nanorc file:
|
||||
|
||||
@item bind key function menu
|
||||
Rebinds @code{key} to @code{function} in the context of @code{menu}
|
||||
(or in all menus where the function exists by using @code{all}).
|
||||
(or in all menus where the function exists when @code{all} is used).
|
||||
|
||||
@item bind key "string" menu
|
||||
Makes @code{key} produce @code{string} in the context of @code{menu}
|
||||
@@ -1130,7 +1139,7 @@ with @kbd{M-V}.)
|
||||
|
||||
@item unbind key menu
|
||||
Unbinds @code{key} from @code{menu}
|
||||
(or from all menus where it exists by using @code{all}).
|
||||
(or from all menus where the key exists when @code{all} is used).
|
||||
|
||||
@end table
|
||||
|
||||
@@ -1139,22 +1148,29 @@ The format of @code{key} should be one of:
|
||||
|
||||
@itemize @w{}
|
||||
@item
|
||||
@code{^}@ followed by a Latin letter, by one of several ASCII characters
|
||||
(@@, ], \, ^, or _), or by the word "Space".
|
||||
@code{^@var{X}} ------ where @var{X} is a Latin letter, or one of several
|
||||
ASCII characters (@@, ], \, ^, _), or the word "Space".
|
||||
Example: @code{^C}.
|
||||
|
||||
@item
|
||||
@code{M-}@ followed by any ASCII character except [, or by the word "Space".
|
||||
@code{M-@var{X}} ------ where @var{X} is any ASCII character except [,
|
||||
or the word "Space".
|
||||
Example: @code{M-C}.
|
||||
|
||||
@item
|
||||
@code{F}@ followed by a numeric value from 1 to 16.
|
||||
@code{F@var{n}} ------ where @var{n} is a numeric value from 1 to 24.
|
||||
Example: @code{F10}.
|
||||
(Often, @code{F13} to @code{F24} can be typed as @code{F1} to @code{F12}
|
||||
with Shift.)
|
||||
|
||||
@item
|
||||
the word "Ins" or the word "Del".
|
||||
@code{Ins} or @code{Del}.
|
||||
@end itemize
|
||||
|
||||
Rebinding @code{^M} (Enter) or @code{^I} (Tab) is probably not a good idea.
|
||||
On some terminals it's not possible to rebind @code{^H} (unless @code{--raw}
|
||||
is used) because its keycode is identical to that of the Backspace key.
|
||||
|
||||
@sp 1
|
||||
Valid names for the @code{function} to be bound are:
|
||||
|
||||
@@ -1234,8 +1250,12 @@ 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, either the default one, or the one
|
||||
defined by @option{--speller} or @code{set speller}.
|
||||
Invokes a spell-checking program, either the default @command{hunspell}
|
||||
or GNU @command{spell}, or the one defined by @option{--speller} or
|
||||
@code{set speller}.
|
||||
|
||||
@item formatter
|
||||
Invokes a full-buffer-processing program (if the active syntax defines one).
|
||||
|
||||
@item linter
|
||||
Invokes a syntax-checking program (if the active syntax defines one).
|
||||
@@ -1519,7 +1539,7 @@ The menu for inserting output from an external command, reached from the insert
|
||||
The help-viewer menu.
|
||||
|
||||
@item spell
|
||||
The interactive spell checker Yes/no menu.
|
||||
The menu of the integrated spell checker where the user can edit a misspelled word.
|
||||
|
||||
@item linter
|
||||
The linter menu.
|
||||
@@ -1677,54 +1697,54 @@ The possible options to @code{./configure} are:
|
||||
@table @code
|
||||
|
||||
@item --disable-browser
|
||||
Disable the mini file browser that can be called with @kbd{^T} when reading
|
||||
or writing files.
|
||||
Exclude the mini file browser that can be called with @kbd{^T} when
|
||||
wanting to read or write a file.
|
||||
|
||||
@item --disable-color
|
||||
Disable support for the syntax coloring of files. This also eliminates
|
||||
the @option{-Y} command-line option, which chooses a specific syntax.
|
||||
Exclude support for syntax coloring. This also eliminates the @option{-Y}
|
||||
command-line option, which allows choosing a specific syntax.
|
||||
|
||||
@item --disable-comment
|
||||
Disable the single-keystroke comment/uncomment function (@kbd{M-3}).
|
||||
Exclude the single-keystroke comment/uncomment function (@kbd{M-3}).
|
||||
|
||||
@item --disable-extra
|
||||
Disable the Easter egg: a crawl of major contributors.
|
||||
Exclude the Easter egg: a crawl of major contributors.
|
||||
|
||||
@item --disable-help
|
||||
Disable the help function. Doing this makes the binary much smaller,
|
||||
but makes it difficult for new users to learn more than very basic
|
||||
Exclude the help texts (@kbd{^G}). This makes the binary much smaller,
|
||||
but also makes it difficult for new users to learn more than very basic
|
||||
things about using the editor.
|
||||
|
||||
@item --disable-histories
|
||||
Disable the code for the handling of the history files: the search and
|
||||
Exclude the code for handling the history files: the search and
|
||||
replace strings that were used, and the cursor position at which each
|
||||
file was closed. This also eliminates the @option{-H} and @option{-P}
|
||||
command-line options, which switch on the logging of search/replace
|
||||
strings and cursor positions.
|
||||
|
||||
@item --disable-justify
|
||||
Disable the justify and unjustify functions.
|
||||
Exclude the justify functions (@kbd{^J} and @kbd{M-J}).
|
||||
|
||||
@item --disable-libmagic
|
||||
Disable the use of the library of magic-number tests (for determining
|
||||
the file type and thus which syntax to use for colouring --- often the
|
||||
tests on filename extension and header line will be enough).
|
||||
Exclude the code for using the library of magic-number tests (for determining
|
||||
the file type and thus which syntax to use for coloring --- often the regexes
|
||||
for filename and header line will be enough).
|
||||
|
||||
@item --disable-linenumbers
|
||||
Disable the line-numbering function (@kbd{M-#}). This also eliminates the
|
||||
Exclude the line-numbering function (@kbd{M-N}). This also eliminates the
|
||||
@option{-l} command-line option, which turns line numbering on.
|
||||
|
||||
@item --disable-mouse
|
||||
Disable all mouse functionality. This also eliminates the @option{-m}
|
||||
Exclude all mouse functionality. This also eliminates the @option{-m}
|
||||
command-line option, which enables the mouse functionality.
|
||||
|
||||
@item --disable-multibuffer
|
||||
Disable support for opening multiple files at a time and switching
|
||||
Exclude support for opening multiple files at a time and switching
|
||||
between them on the fly. This also eliminates the @option{-F} command-line
|
||||
option, which causes a file to be read into a separate buffer by default.
|
||||
|
||||
@item --disable-nanorc
|
||||
Disable support for reading the nanorc files at startup. With such
|
||||
Exclude support for reading the nanorc files at startup. With such
|
||||
support, you can store custom settings in a system-wide and a per-user
|
||||
nanorc file rather than having to pass command-line options to get
|
||||
the desired behavior. @xref{Nanorc Files} for more info.
|
||||
@@ -1732,22 +1752,23 @@ Disabling this also eliminates the @option{-I} command-line option,
|
||||
which inhibits the reading of nanorc files.
|
||||
|
||||
@item --disable-operatingdir
|
||||
Disable setting the operating directory. This also eliminates the @option{-o}
|
||||
command-line option, which sets the operating directory.
|
||||
Exclude the code for setting the operating directory. This also eliminates
|
||||
the @option{-o} command-line option, which sets the operating directory.
|
||||
|
||||
@item --disable-speller
|
||||
Disable use of the spell checker. This also eliminates the @option{-s}
|
||||
Exclude the code for spell checking. This also eliminates the @option{-s}
|
||||
command-line option, which allows specifying an alternate spell checker.
|
||||
|
||||
@item --disable-tabcomp
|
||||
Disable tab completion (when nano asks for a filename or a search string).
|
||||
Exclude tab completion (when nano asks for a filename or a search string).
|
||||
|
||||
@item --disable-wordcomp
|
||||
Disable word completion (@kbd{^]}).
|
||||
Exclude word completion (@kbd{^]}).
|
||||
|
||||
@item --disable-wrapping
|
||||
Disable all hard-wrapping of overlong lines. This also eliminates the
|
||||
@option{-w} command-line option, which switches long-line wrapping off.
|
||||
Exclude all hard-wrapping of overlong lines. This also eliminates the
|
||||
@option{-b} and @option{-w} command-line options, which switch automatic
|
||||
long-line wrapping on and off, respectively.
|
||||
|
||||
@item --enable-tiny
|
||||
This option implies all of the above. It also disables some other
|
||||
@@ -1757,19 +1778,19 @@ counterpart of the above options together with @option{--enable-tiny},
|
||||
specific features can be switched back on --- but a few cannot.
|
||||
|
||||
@item --enable-debug
|
||||
Enable support for runtime debug output. This can get pretty messy, so
|
||||
Include some code for runtime debugging output. This can get pretty messy, so
|
||||
chances are you only want this feature when you're working on the nano source.
|
||||
|
||||
@item --disable-nls
|
||||
Disables Native Language support. This will disable the use of any
|
||||
Exclude Native Language support. This will disable the use of any
|
||||
available GNU @command{nano} translations.
|
||||
|
||||
@item --enable-utf8
|
||||
Enable support for reading and writing Unicode files. This will require
|
||||
Include support for reading and writing Unicode files. This will require
|
||||
either a wide version of curses, or a UTF-8-enabled version of Slang.
|
||||
|
||||
@item --disable-utf8
|
||||
Disable support for reading and writing Unicode files. Normally the
|
||||
Exclude support for reading and writing Unicode files. Normally the
|
||||
configure script auto-detects whether to enable UTF-8 support or not.
|
||||
You can use this or the previous option to override that detection.
|
||||
|
||||
|
||||
110
doc/nanorc.5
110
doc/nanorc.5
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANORC 5 "version 4.3" "June 2019"
|
||||
.TH NANORC 5 "version 4.7" "December 2019"
|
||||
|
||||
.SH NAME
|
||||
nanorc \- GNU nano's configuration file
|
||||
@@ -44,6 +44,7 @@ commands, which can be used to configure nano on startup without using
|
||||
command-line options. Additionally, there are some commands to define
|
||||
syntax highlighting and to rebind keys -- see the two separate sections
|
||||
on those. \fBnano\fP reads one command per line.
|
||||
All commands and keywords should be written in lowercase.
|
||||
.sp
|
||||
Options in \fInanorc\fP files take precedence over nano's defaults, and
|
||||
command-line options override \fInanorc\fP settings. Also, options that
|
||||
@@ -183,8 +184,7 @@ Don't automatically add a newline when a text does not end with one.
|
||||
(This can cause you to save non-POSIX text files.)
|
||||
.TP
|
||||
.B set nopauses
|
||||
Don't pause between warnings at startup. This means that only
|
||||
the last one will be visible (when there are multiple ones).
|
||||
Obsolete option. Ignored.
|
||||
.TP
|
||||
.B set nowrap
|
||||
Deprecated option since it has become the default setting.
|
||||
@@ -261,9 +261,9 @@ When needed, use \fBunset jumpyscrolling\fR instead.
|
||||
.B set softwrap
|
||||
Enable soft line wrapping for easier viewing of very long lines.
|
||||
.TP
|
||||
.B set speller "\fIprogram\fP"
|
||||
Use the given \fIprogram\fR to do spell checking and correcting,
|
||||
instead of the built-in corrector that calls \fBspell\fR.
|
||||
.B set speller """\fIprogram\fR [\fIarg\fR...]\fB"""
|
||||
Use the given \fIprogram\fR to do spell checking and correcting, instead of
|
||||
using the built-in corrector that calls \fBhunspell\fR or GNU \fBspell\fR.
|
||||
.TP
|
||||
.B set statuscolor \fIfgcolor\fR,\fIbgcolor\fR
|
||||
Specify the color combination to use for the status bar.
|
||||
@@ -335,7 +335,7 @@ powerful enough to fully parse a file. Nevertheless, regular
|
||||
expressions can do a lot and are easy to make, so they are a
|
||||
good fit for a small editor like \fBnano\fR.
|
||||
.sp
|
||||
All regular expressions in \fBnano\fR are extended regular expressions (ERE).
|
||||
All regular expressions in \fBnano\fR are POSIX extended regular expressions.
|
||||
This means that \fB.\fR, \fB?\fR, \fB*\fR, \fB+\fR, \fB^\fR, \fB$\fR, and
|
||||
several other characters are special.
|
||||
The period \fB.\fR matches any single character,
|
||||
@@ -382,6 +382,12 @@ file, to determine whether this syntax should be used for it.
|
||||
(This functionality only works when \fBlibmagic\fP is installed on the
|
||||
system and will be silently ignored otherwise.)
|
||||
.TP
|
||||
.BI formatter " program " \fR[ "arg " \fR...]
|
||||
Run the given \fIprogram\fR on the full contents of the current buffer.
|
||||
(The current buffer is written out to a temporary file, the program is
|
||||
run on it, and then the temporary file is read back in, replacing the
|
||||
contents of the buffer.)
|
||||
.TP
|
||||
.BI linter " program " \fR[ "arg " \fR...]
|
||||
Use the given \fIprogram\fR to run a syntax check on the current buffer.
|
||||
.TP
|
||||
@@ -396,26 +402,32 @@ for Python files. If empty double quotes are specified, the comment/uncomment
|
||||
function is disabled; for example, "" for JSON.
|
||||
The default value is "\fB#\fP".
|
||||
.TP
|
||||
.BI "tabgives """ string """
|
||||
Make the <Tab> key produce the given \fIstring\fR. Useful for languages like
|
||||
Python that want to see only spaces for indentation.
|
||||
This overrides the setting of the \fBtabstospaces\fR option.
|
||||
.TP
|
||||
.BI "color " fgcolor , bgcolor " """ regex """ " \fR...
|
||||
Display all pieces of text that match
|
||||
the extended regular expression \fIregex\fP with foreground color
|
||||
\fIfgcolor\fP and background color \fIbgcolor\fP, at least one of which
|
||||
must be specified. Valid names for foreground and background colors are:
|
||||
Paint all pieces of text that match the extended regular expression
|
||||
\fIregex\fP with the given foreground and background colors, at least
|
||||
one of which must be specified. Valid color names are:
|
||||
.BR white ", " black ", " blue ", " green ", " red ", "
|
||||
.BR cyan ", " yellow ", " magenta ", and " normal
|
||||
-- where \fBnormal\fR means the default foreground or background color.
|
||||
You may use the prefix \fBbright\fR to get a stronger color highlight for the
|
||||
foreground. If your terminal supports transparency, not specifying a
|
||||
\fIbgcolor\fP tells \fBnano\fP to attempt to use a transparent
|
||||
background.
|
||||
You may use the prefix \fBbright\fR for the foreground color to get a
|
||||
stronger highlight. If your terminal supports transparency, not specifying
|
||||
a \fIbgcolor\fP tells \fBnano\fP to attempt to use a transparent background.
|
||||
.sp
|
||||
All coloring commands are applied in the order in which they are specified,
|
||||
which means that later commands can recolor stuff that was colored earlier.
|
||||
.TP
|
||||
.BI "icolor " fgcolor , bgcolor " """ regex """ " \fR...
|
||||
Same as above, except that the matching is case insensitive.
|
||||
.TP
|
||||
.BI "color " fgcolor , bgcolor " start=""" fromrx """ end=""" torx """
|
||||
Display all pieces of text whose start matches extended regular expression
|
||||
\fIfromrx\fP and whose end matches extended regular expression \fItorx\fP with
|
||||
foreground color \fIfgcolor\fP and background color \fIbgcolor\fP,
|
||||
Paint all pieces of text whose start matches extended regular expression
|
||||
\fIfromrx\fP and whose end matches extended regular expression \fItorx\fP
|
||||
with the given foreground and background colors,
|
||||
at least one of which must be specified. This means that, after an
|
||||
initial instance of \fIfromrx\fP, all text until the first instance of
|
||||
\fItorx\fP will be colored. This allows syntax highlighting to span
|
||||
@@ -432,36 +444,18 @@ to \fBicolor\fP.
|
||||
.BI extendsyntax " name command " \fR[ "arg " \fR...]
|
||||
Extend the syntax previously defined as \fIname\fR with another
|
||||
\fIcommand\fR. This allows adding a new \fBcolor\fP, \fBicolor\fP,
|
||||
\fBheader\fP, \fBmagic\fP, \fBcomment\fP, or \fBlinter\fP
|
||||
\fBheader\fP, \fBmagic\fP, \fBcomment\fP, \fBlinter\fP, or \fBformatter\fR
|
||||
command to an already defined syntax -- useful when you want to
|
||||
slightly improve a syntax defined in one of the system-installed
|
||||
files (which normally are not writable).
|
||||
|
||||
.P
|
||||
Note: the \fBformatter\fR command has been removed. It was superseded by
|
||||
a more general mechanism: the filtering of buffer or marked text through
|
||||
an external command. Such filtering is done by typing \fB^R^X\fR and then
|
||||
preceding your formatter command with the pipe symbol (\fB|\fR). It has
|
||||
the added advantage that the operation can be undone.
|
||||
.sp
|
||||
If you use such a formatting command regularly, you could assign the relevant
|
||||
series of keystrokes to a single key in your nanorc:
|
||||
.sp
|
||||
.RS
|
||||
.B "bind M\-F \(dq^R^X|yourformatcommand^M\(dq main"
|
||||
.RE
|
||||
.sp
|
||||
(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.)
|
||||
|
||||
.SH REBINDING KEYS
|
||||
Key bindings can be changed via the following three commands:
|
||||
.RS 3
|
||||
.TP
|
||||
.BI bind " key function menu"
|
||||
Rebinds the key \fIkey\fP to a new function named \fIfunction\fP in the
|
||||
context of menu \fImenu\fP (or in all menus where the function exists
|
||||
by using \fBall\fP).
|
||||
Rebinds the given \fIkey\fP to the given \fIfunction\fP in the given \fImenu\fP
|
||||
(or in all menus where the function exists when \fBall\fP is used).
|
||||
.TP
|
||||
.BI bind " key " """" string """" " menu"
|
||||
Makes the given \fIkey\fR produce the given \fIstring\fR in the given
|
||||
@@ -469,33 +463,38 @@ Makes the given \fIkey\fR produce the given \fIstring\fR in the given
|
||||
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.)
|
||||
|
||||
.TP
|
||||
.BI unbind " key menu"
|
||||
Unbinds the key \fIkey\fP from the menu named \fImenu\fP (or from all
|
||||
menus where it exists by using \fBall\fP).
|
||||
Unbinds the given \fIkey\fP from the given \fImenu\fP (or from all
|
||||
menus where the key exists when \fBall\fP is used).
|
||||
.RE
|
||||
|
||||
.TP
|
||||
The format of \fIkey\fP should be one of:
|
||||
.RS 3
|
||||
.TP 3
|
||||
.B ^
|
||||
followed by a Latin letter, by one of several ASCII characters
|
||||
(@, ], \\, ^, or _), or by the word "Space".
|
||||
.TP 5
|
||||
.BI ^ X
|
||||
where \fIX\fR is a Latin letter, or one of several ASCII characters
|
||||
(@, ], \\, ^, _), or the word "Space".
|
||||
Example: ^C.
|
||||
.TP
|
||||
.B M\-
|
||||
followed by any ASCII character except [, or by the word "Space".
|
||||
.BI M\- X
|
||||
where \fIX\fR is any ASCII character except [, or the word "Space".
|
||||
Example: M\-C.
|
||||
.TP
|
||||
.B F
|
||||
followed by a numeric value from 1 to 16.
|
||||
.BI F N
|
||||
where \fIN\fR is a numeric value from 1 to 24.
|
||||
Example: F10.
|
||||
(Often, \fBF13\fR to \fBF24\fR can be typed as \fBF1\fR to \fBF12\fR with Shift.)
|
||||
|
||||
.TP
|
||||
the word "Ins" or the word "Del".
|
||||
.BR Ins " or " Del .
|
||||
.RE
|
||||
|
||||
Rebinding \fB^M\fR (Enter) or \fB^I\fR (Tab) is probably not a good idea.
|
||||
On some terminals it's not possible to rebind \fB^H\fR (unless \fB\-\-raw\fR
|
||||
is used) because its keycode is identical to that of the Backspace key.
|
||||
|
||||
.TP
|
||||
Valid \fIfunction\fP names to be bound are:
|
||||
.RS 3
|
||||
@@ -574,8 +573,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, either the default one, or the one
|
||||
defined by \fB\-\-speller\fR or \fBset speller\fR.
|
||||
Invokes a spell-checking program, either the default \fBhunspell\fR or GNU
|
||||
\fBspell\fR, or the one defined by \fB\-\-speller\fR or \fBset speller\fR.
|
||||
.TP
|
||||
.B formatter
|
||||
Invokes a full-buffer-processing program (if the active syntax defines one).
|
||||
.TP
|
||||
.B linter
|
||||
Invokes a syntax-checking program (if the active syntax defines one).
|
||||
@@ -857,7 +859,7 @@ The menu for inserting output from an external command, reached from the insert
|
||||
The help-viewer menu.
|
||||
.TP
|
||||
.B spell
|
||||
The interactive spell checker Yes/no menu.
|
||||
The menu of the integrated spell checker where the user can edit a misspelled word.
|
||||
.TP
|
||||
.B linter
|
||||
The linter menu.
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH RNANO 1 "version 4.3" "June 2019"
|
||||
.TH RNANO 1 "version 4.7" "December 2019"
|
||||
|
||||
.SH NAME
|
||||
rnano \- a restricted nano
|
||||
|
||||
@@ -97,10 +97,6 @@
|
||||
## 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
|
||||
|
||||
## 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
|
||||
@@ -218,49 +214,44 @@
|
||||
|
||||
## Setup of syntax coloring.
|
||||
##
|
||||
## Format:
|
||||
## syntax "name" ["filename regex" ...]
|
||||
##
|
||||
## syntax "short description" ["filename regex" ...]
|
||||
## color|icolor foreground,background "regex" ["regex"...]
|
||||
## [...]
|
||||
##
|
||||
## The "none" syntax is reserved; specifying it on the command line is
|
||||
## the same as not having a syntax at all. The "default" syntax is
|
||||
## special: it takes no filename regexes, and applies to files that
|
||||
## don't match any other syntax's filename regexes.
|
||||
##
|
||||
## color foreground,background "regex" ["regex"...]
|
||||
## or
|
||||
## icolor foreground,background "regex" ["regex"...]
|
||||
##
|
||||
## "color" will do case-sensitive matches, while "icolor" will do
|
||||
## 'color' will do case-sensitive matches, while 'icolor' will do
|
||||
## case-insensitive matches.
|
||||
##
|
||||
## Valid color names ares: white, black, normal, red, blue, green,
|
||||
## yellow, magenta, cyan. For foreground colors, you may use the
|
||||
## prefix "bright" to get a stronger highlight.
|
||||
## All color commands are applied in the order in which they are specified,
|
||||
## meaning that later commands can recolor stuff that was colored earlier.
|
||||
##
|
||||
## Valid color names for foreground and background are: white, black, normal,
|
||||
## red, blue, green, yellow, magenta, cyan. For foreground colors, you may
|
||||
## use the prefix "bright" to get a stronger highlight.
|
||||
##
|
||||
## All regexes (regular expressions) are of the extended type (ERE).
|
||||
##
|
||||
## To use multi-line regexes, use the start="regex" end="regex"
|
||||
## [start="regex" end="regex"...] format.
|
||||
## If the coloring rule should span multiple lines, use the following format:
|
||||
##
|
||||
## If your system supports transparency, not specifying a background
|
||||
## color will use a transparent color. If you don't want this, be sure
|
||||
## to set the background color to black or white.
|
||||
## color fg,bg start="regex" end="regex"
|
||||
##
|
||||
## If you wish, you may put your syntax definitions in separate files.
|
||||
## You can make use of such files as follows:
|
||||
##
|
||||
## include "/path/to/syntax_file.nanorc"
|
||||
##
|
||||
## Unless otherwise noted, the name of the syntax file (without the
|
||||
## ".nanorc" extension) should be the same as the "short description"
|
||||
## name inside that file. These names are kept fairly short to make
|
||||
## them easier to remember and faster to type using nano's -Y option.
|
||||
## include "/path/to/syntax_file.nanorc"
|
||||
|
||||
## To include all existing syntax definitions, you can do:
|
||||
# include "@PKGDATADIR@/*.nanorc"
|
||||
|
||||
|
||||
## If <Tab> should always produce four spaces when editing a Python file,
|
||||
## independent of the settings of 'tabsize' and 'tabstospaces':
|
||||
# extendsyntax python tabgives " "
|
||||
|
||||
## If <Tab> should always produce an actual TAB when editing a Makefile:
|
||||
# extendsyntax makefile tabgives " "
|
||||
|
||||
|
||||
## Key bindings.
|
||||
## See nanorc(5) (section REBINDING KEYS) for more details on this.
|
||||
|
||||
|
||||
1400
po/nano.pot
1400
po/nano.pot
File diff suppressed because it is too large
Load Diff
1266
po/pt_BR.po
1266
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
1268
po/zh_CN.po
1268
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
1268
po/zh_TW.po
1268
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERSION="4.3"
|
||||
VERSION="4.7"
|
||||
|
||||
./configure -C --enable-tiny && make && ./configure -C &&
|
||||
|
||||
@@ -22,6 +22,10 @@ gpg --verify nano-$VERSION.tar.xz.asc &&
|
||||
|
||||
git tag -u A0ACE884 -a v$VERSION -m "the nano $VERSION release" &&
|
||||
|
||||
make pdf && rm -rf doc/nano.t2p &&
|
||||
scp doc/nano.pdf bens@wh0rd.org:nano.pdf &&
|
||||
scp doc/cheatsheet.html bens@wh0rd.org:cheatsheet.html &&
|
||||
|
||||
for file in nano-$VERSION.tar.*z*; do scp $file bens@wh0rd.org:$file; done &&
|
||||
|
||||
gnupload --to ftp.gnu.org:nano nano-$VERSION.tar.*z &&
|
||||
|
||||
@@ -21,13 +21,13 @@
|
||||
|
||||
#include "proto.h"
|
||||
|
||||
#ifdef ENABLE_BROWSER
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef ENABLE_BROWSER
|
||||
|
||||
static char **filelist = NULL;
|
||||
/* The list of files to display in the file browser. */
|
||||
static size_t filelist_len = 0;
|
||||
@@ -153,9 +153,9 @@ char *do_browser(char *path)
|
||||
/* Simulate a window resize to force a directory reread. */
|
||||
kbinput = KEY_WINCH;
|
||||
#endif
|
||||
} else if (func == do_help_void) {
|
||||
} else if (func == do_help) {
|
||||
#ifdef ENABLE_HELP
|
||||
do_help_void();
|
||||
do_help();
|
||||
#ifndef NANO_TINY
|
||||
/* The window dimensions might have changed, so act as if. */
|
||||
kbinput = KEY_WINCH;
|
||||
@@ -221,7 +221,7 @@ char *do_browser(char *path)
|
||||
selected = filelist_len - 1;
|
||||
} else if (func == goto_dir_void) {
|
||||
/* Ask for the directory to go to. */
|
||||
if (do_prompt(TRUE, FALSE, MGOTODIR, NULL, NULL,
|
||||
if (do_prompt(TRUE, FALSE, MGOTODIR, "", NULL,
|
||||
/* TRANSLATORS: This is a prompt. */
|
||||
browser_refresh, _("Go To Directory")) < 0) {
|
||||
statusbar(_("Cancelled"));
|
||||
@@ -285,7 +285,7 @@ char *do_browser(char *path)
|
||||
|
||||
/* If it isn't a directory, a file was selected -- we're done. */
|
||||
if (!S_ISDIR(st.st_mode)) {
|
||||
retval = mallocstrcpy(NULL, filelist[selected]);
|
||||
retval = copy_of(filelist[selected]);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ char *do_browser(char *path)
|
||||
/* If the window resized, refresh the file list. */
|
||||
if (kbinput == KEY_WINCH) {
|
||||
/* Remember the selected file, to be able to reselect it. */
|
||||
present_name = mallocstrcpy(NULL, filelist[selected]);
|
||||
present_name = copy_of(filelist[selected]);
|
||||
/* Reread the contents of the current directory. */
|
||||
goto read_directory_contents;
|
||||
}
|
||||
@@ -453,26 +453,10 @@ functionptrtype parse_browser_input(int *kbinput)
|
||||
{
|
||||
if (!meta_key) {
|
||||
switch (*kbinput) {
|
||||
case BS_CODE:
|
||||
case '-':
|
||||
return do_page_up;
|
||||
case ' ':
|
||||
return do_page_down;
|
||||
case '?':
|
||||
return do_help_void;
|
||||
case 'E':
|
||||
case 'e':
|
||||
case 'Q':
|
||||
case 'q':
|
||||
case 'X':
|
||||
case 'x':
|
||||
return do_exit;
|
||||
case 'G':
|
||||
case 'g':
|
||||
return goto_dir_void;
|
||||
case 'S':
|
||||
case 's':
|
||||
return do_enter;
|
||||
case 'W':
|
||||
case 'w':
|
||||
case '/':
|
||||
@@ -481,6 +465,21 @@ functionptrtype parse_browser_input(int *kbinput)
|
||||
return do_findprevious;
|
||||
case 'n':
|
||||
return do_findnext;
|
||||
case 'G':
|
||||
case 'g':
|
||||
return goto_dir_void;
|
||||
case '?':
|
||||
return do_help;
|
||||
case 'S':
|
||||
case 's':
|
||||
return do_enter;
|
||||
case 'E':
|
||||
case 'e':
|
||||
case 'Q':
|
||||
case 'q':
|
||||
case 'X':
|
||||
case 'x':
|
||||
return do_exit;
|
||||
}
|
||||
}
|
||||
return func_from_key(kbinput);
|
||||
@@ -524,16 +523,15 @@ void browser_refresh(void)
|
||||
/* The filename (or a fragment of it) in displayable format.
|
||||
* When a fragment, account for dots plus one space padding. */
|
||||
|
||||
/* If this is the selected item, start its highlighting, and
|
||||
/* If this is the selected item, draw its highlighted bar upfront, and
|
||||
* remember its location to be able to place the cursor on it. */
|
||||
if (i == selected) {
|
||||
wattron(edit, interface_color_pair[SELECTED_TEXT]);
|
||||
mvwprintw(edit, row, col, "%*s", longest, " ");
|
||||
the_row = row;
|
||||
the_column = col;
|
||||
}
|
||||
|
||||
blank_row(edit, row, col, longest);
|
||||
|
||||
/* If the name is too long, we display something like "...ename". */
|
||||
if (dots)
|
||||
mvwaddstr(edit, row, col, "...");
|
||||
@@ -548,17 +546,17 @@ void browser_refresh(void)
|
||||
* "(dir)" for directories, and the file size for normal files. */
|
||||
if (lstat(filelist[i], &st) == -1 || S_ISLNK(st.st_mode)) {
|
||||
if (stat(filelist[i], &st) == -1 || !S_ISDIR(st.st_mode))
|
||||
info = mallocstrcpy(NULL, "--");
|
||||
info = copy_of("--");
|
||||
else
|
||||
/* TRANSLATORS: Try to keep this at most 7 characters. */
|
||||
info = mallocstrcpy(NULL, _("(dir)"));
|
||||
info = copy_of(_("(dir)"));
|
||||
} else if (S_ISDIR(st.st_mode)) {
|
||||
if (strcmp(thename, "..") == 0) {
|
||||
/* TRANSLATORS: Try to keep this at most 12 characters. */
|
||||
info = mallocstrcpy(NULL, _("(parent dir)"));
|
||||
info = copy_of(_("(parent dir)"));
|
||||
infomaxlen = 12;
|
||||
} else
|
||||
info = mallocstrcpy(NULL, _("(dir)"));
|
||||
info = copy_of(_("(dir)"));
|
||||
} else {
|
||||
off_t result = st.st_size;
|
||||
char modifier;
|
||||
@@ -666,11 +664,12 @@ int filesearch_init(bool forwards)
|
||||
(breadth(last_search) > COLS / 3) ? "..." : "");
|
||||
free(disp);
|
||||
} else
|
||||
thedefault = mallocstrcpy(NULL, "");
|
||||
thedefault = copy_of("");
|
||||
|
||||
/* Now ask what to search for. */
|
||||
response = do_prompt(FALSE, FALSE, MWHEREISFILE, NULL, &search_history,
|
||||
response = do_prompt(FALSE, FALSE, MWHEREISFILE, "", &search_history,
|
||||
browser_refresh, "%s%s%s", _("Search"),
|
||||
/* TRANSLATORS: A modifier of the Search prompt. */
|
||||
!forwards ? _(" [Backwards]") : "", thedefault);
|
||||
free(thedefault);
|
||||
|
||||
@@ -793,7 +792,7 @@ void to_last_file(void)
|
||||
* The returned string is dynamically allocated, and should be freed. */
|
||||
char *strip_last_component(const char *path)
|
||||
{
|
||||
char *copy = mallocstrcpy(NULL, path);
|
||||
char *copy = copy_of(path);
|
||||
char *last_slash = strrchr(copy, '/');
|
||||
|
||||
if (last_slash != NULL)
|
||||
|
||||
169
src/chars.c
169
src/chars.c
@@ -160,7 +160,7 @@ bool is_word_mbchar(const char *c, bool allow_punct)
|
||||
|
||||
if (word_chars != NULL && *word_chars != '\0') {
|
||||
char symbol[MAXCHARLEN + 1];
|
||||
int symlen = parse_mbchar(c, symbol, NULL);
|
||||
int symlen = collect_char(c, symbol);
|
||||
|
||||
symbol[symlen] = '\0';
|
||||
return (strstr(word_chars, symbol) != NULL);
|
||||
@@ -200,11 +200,12 @@ char control_mbrep(const char *c, bool isdata)
|
||||
return control_rep(*c);
|
||||
}
|
||||
|
||||
/* This function is equivalent to wcwidth() for multibyte characters. */
|
||||
#ifdef ENABLE_UTF8
|
||||
/* Return the width in columns of the given (multibyte) character. */
|
||||
int mbwidth(const char *c)
|
||||
{
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
/* Ask for the width only when the character isn't plain ASCII. */
|
||||
if ((signed char)*c <= 0) {
|
||||
wchar_t wc;
|
||||
int width;
|
||||
|
||||
@@ -213,41 +214,41 @@ int mbwidth(const char *c)
|
||||
|
||||
width = wcwidth(wc);
|
||||
|
||||
if (width == -1)
|
||||
if (width < 0)
|
||||
return 1;
|
||||
|
||||
return width;
|
||||
} else
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Convert the Unicode value in chr to a multibyte character, if possible.
|
||||
/* Convert the Unicode value in code to a multibyte character, if possible.
|
||||
* If the conversion succeeds, return the (dynamically allocated) multibyte
|
||||
* character and its length. Otherwise, return an undefined (dynamically
|
||||
* allocated) multibyte character and a length of zero. */
|
||||
char *make_mbchar(long chr, int *chr_mb_len)
|
||||
char *make_mbchar(long code, int *length)
|
||||
{
|
||||
char *chr_mb;
|
||||
char *mb_char;
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
chr_mb = charalloc(MAXCHARLEN);
|
||||
*chr_mb_len = wctomb(chr_mb, (wchar_t)chr);
|
||||
mb_char = charalloc(MAXCHARLEN);
|
||||
*length = wctomb(mb_char, (wchar_t)code);
|
||||
|
||||
/* Reject invalid Unicode characters. */
|
||||
if (*chr_mb_len < 0 || !is_valid_unicode((wchar_t)chr)) {
|
||||
if (*length < 0 || !is_valid_unicode((wchar_t)code)) {
|
||||
IGNORE_CALL_RESULT(wctomb(NULL, 0));
|
||||
*chr_mb_len = 0;
|
||||
*length = 0;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
*chr_mb_len = 1;
|
||||
chr_mb = mallocstrncpy(NULL, (char *)&chr, 1);
|
||||
mb_char = measured_copy((char *)&code, 1);
|
||||
*length = 1;
|
||||
}
|
||||
|
||||
return chr_mb;
|
||||
return mb_char;
|
||||
}
|
||||
|
||||
/* Return the length (in bytes) of the character located at *pointer. */
|
||||
@@ -264,50 +265,88 @@ int char_length(const char *pointer)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Parse a multibyte character from buf. Return the number of bytes
|
||||
* used. If chr isn't NULL, store the multibyte character in it. If
|
||||
* col isn't NULL, add the character's width (in columns) to it. */
|
||||
int parse_mbchar(const char *buf, char *chr, size_t *col)
|
||||
/* Return the number of (multibyte) characters in the given string. */
|
||||
size_t mbstrlen(const char *pointer)
|
||||
{
|
||||
int length;
|
||||
size_t count = 0;
|
||||
|
||||
while (*pointer != '\0') {
|
||||
#ifdef ENABLE_UTF8
|
||||
if ((signed char)*pointer < 0) {
|
||||
int length = mblen(pointer, MAXCHARLEN);
|
||||
|
||||
pointer += (length < 0 ? 1 : length);
|
||||
} else
|
||||
#endif
|
||||
pointer++;
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Return the length (in bytes) of the character at the start of the
|
||||
* given string, and return a copy of this character in *thechar. */
|
||||
int collect_char(const char *string, char *thechar)
|
||||
{
|
||||
int charlen;
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
/* If this is a UTF-8 starter byte, get the number of bytes of the character. */
|
||||
if ((signed char)*buf < 0) {
|
||||
length = mblen(buf, MAXCHARLEN);
|
||||
if ((signed char)*string < 0) {
|
||||
charlen = mblen(string, MAXCHARLEN);
|
||||
|
||||
/* When the multibyte sequence is invalid, only take the first byte. */
|
||||
if (length <= 0)
|
||||
length = 1;
|
||||
if (charlen <= 0)
|
||||
charlen = 1;
|
||||
} else
|
||||
#endif
|
||||
length = 1;
|
||||
charlen = 1;
|
||||
|
||||
/* When requested, store the multibyte character in chr. */
|
||||
if (chr != NULL)
|
||||
for (int i = 0; i < length; i++)
|
||||
chr[i] = buf[i];
|
||||
for (int i = 0; i < charlen; i++)
|
||||
thechar[i] = string[i];
|
||||
|
||||
/* When requested, add the width of the character to col. */
|
||||
if (col != NULL) {
|
||||
/* If we have a tab, compute its width in columns based on the
|
||||
* current value of col. */
|
||||
if (*buf == '\t')
|
||||
*col += tabsize - *col % tabsize;
|
||||
/* If we have a control character, it's two columns wide: one
|
||||
* column for the "^", and one for the visible character. */
|
||||
else if (is_cntrl_mbchar(buf))
|
||||
*col += 2;
|
||||
/* If we have a normal character, get its width normally. */
|
||||
else if (length == 1)
|
||||
*col += 1;
|
||||
return charlen;
|
||||
}
|
||||
|
||||
/* Return the length (in bytes) of the character at the start of
|
||||
* the given string, and add this character's width to *column. */
|
||||
int advance_over(const char *string, size_t *column)
|
||||
{
|
||||
#ifdef ENABLE_UTF8
|
||||
else
|
||||
*col += mbwidth(buf);
|
||||
#endif
|
||||
}
|
||||
if ((signed char)*string < 0) {
|
||||
int charlen = mblen(string, MAXCHARLEN);
|
||||
|
||||
return length;
|
||||
if (charlen > 0) {
|
||||
if (is_cntrl_mbchar(string))
|
||||
*column += 2;
|
||||
else
|
||||
*column += mbwidth(string);
|
||||
} else {
|
||||
charlen = 1;
|
||||
*column += 1;
|
||||
}
|
||||
|
||||
return charlen;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((unsigned char)*string < 0x20) {
|
||||
if (*string == '\t')
|
||||
*column += tabsize - *column % tabsize;
|
||||
else
|
||||
*column += 2;
|
||||
} else if (*string == 0x7F)
|
||||
*column += 2;
|
||||
#ifndef ENABLE_UTF8
|
||||
else if (0x7F < (unsigned char)*string && (unsigned char)*string < 0xA0)
|
||||
*column += 2;
|
||||
#endif
|
||||
else
|
||||
*column += 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Return the index in buf of the beginning of the multibyte character
|
||||
@@ -346,7 +385,7 @@ size_t step_left(const char *buf, size_t pos)
|
||||
return before - charlen;
|
||||
} else
|
||||
#endif
|
||||
return (pos == 0 ? 0 : pos - 1);
|
||||
return (pos == 0 ? 0 : pos - 1);
|
||||
}
|
||||
|
||||
/* Return the index in buf of the beginning of the multibyte character
|
||||
@@ -487,27 +526,6 @@ char *mbrevstrcasestr(const char *haystack, const char *needle,
|
||||
return revstrcasestr(haystack, needle, pointer);
|
||||
}
|
||||
|
||||
/* Count the number of (multibyte) characters in the given string. */
|
||||
size_t mbstrlen(const char *pointer)
|
||||
{
|
||||
size_t count = 0;
|
||||
|
||||
while (*pointer != '\0') {
|
||||
#ifdef ENABLE_UTF8
|
||||
if ((signed char)*pointer < 0) {
|
||||
int length = mblen(pointer, MAXCHARLEN);
|
||||
|
||||
pointer += (length < 0 ? 1 : length);
|
||||
} else
|
||||
#endif
|
||||
pointer++;
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_JUSTIFY)
|
||||
/* This function is equivalent to strchr() for multibyte strings. */
|
||||
char *mbstrchr(const char *string, const char *chr)
|
||||
@@ -592,7 +610,7 @@ bool has_blank_char(const char *string)
|
||||
char symbol[MAXCHARLEN];
|
||||
|
||||
while (*string != '\0') {
|
||||
string += parse_mbchar(string, symbol, NULL);
|
||||
string += collect_char(string, symbol);
|
||||
|
||||
if (is_blank_mbchar(symbol))
|
||||
return TRUE;
|
||||
@@ -602,6 +620,15 @@ bool has_blank_char(const char *string)
|
||||
}
|
||||
#endif /* ENABLE_NANORC && (!NANO_TINY || ENABLE_JUSTIFY) */
|
||||
|
||||
/* Return TRUE when the given string is empty or consists of only blanks. */
|
||||
bool white_string(const char *string)
|
||||
{
|
||||
while (*string != '\0' && (is_blank_mbchar(string) || *string == '\r'))
|
||||
string += char_length(string);
|
||||
|
||||
return !*string;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
/* Return TRUE if wc is valid Unicode, and FALSE otherwise. */
|
||||
bool is_valid_unicode(wchar_t wc)
|
||||
|
||||
56
src/color.c
56
src/color.c
@@ -21,14 +21,13 @@
|
||||
|
||||
#include "proto.h"
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_MAGIC_H
|
||||
#include <magic.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
|
||||
/* For early versions of ncurses-6.0, use an additional A_PROTECT attribute
|
||||
* for all colors, in order to work around an ncurses miscoloring bug. */
|
||||
@@ -192,20 +191,7 @@ void color_update(void)
|
||||
/* If no syntax-override string was specified, or it didn't match,
|
||||
* try finding a syntax based on the filename (extension). */
|
||||
if (sint == NULL && !inhelp) {
|
||||
char *reserved = charalloc(PATH_MAX + 1);
|
||||
char *currentdir = getcwd(reserved, PATH_MAX + 1);
|
||||
char *joinednames = charalloc(PATH_MAX + 1);
|
||||
char *fullname = NULL;
|
||||
|
||||
if (currentdir == NULL)
|
||||
free(reserved);
|
||||
else {
|
||||
/* Concatenate the current working directory with the
|
||||
* specified filename, and canonicalize the result. */
|
||||
sprintf(joinednames, "%s/%s", currentdir, openfile->filename);
|
||||
fullname = get_full_path(joinednames);
|
||||
free(currentdir);
|
||||
}
|
||||
char *fullname = get_full_path(openfile->filename);
|
||||
|
||||
if (fullname == NULL)
|
||||
fullname = mallocstrcpy(fullname, openfile->filename);
|
||||
@@ -215,7 +201,6 @@ void color_update(void)
|
||||
break;
|
||||
}
|
||||
|
||||
free(joinednames);
|
||||
free(fullname);
|
||||
}
|
||||
|
||||
@@ -282,6 +267,15 @@ void color_update(void)
|
||||
openfile->colorstrings = (sint == NULL ? NULL : sint->color);
|
||||
}
|
||||
|
||||
/* Allocate and initialize (for the given line) the cache for multiline info. */
|
||||
void set_up_multicache(linestruct *line)
|
||||
{
|
||||
line->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
|
||||
for (int index = 0; index < openfile->syntax->nmultis; index++)
|
||||
line->multidata[index] = -1;
|
||||
}
|
||||
|
||||
/* Determine whether the matches of multiline regexes are still the same,
|
||||
* and if not, schedule a screen refresh, so things will be repainted. */
|
||||
void check_the_multis(linestruct *line)
|
||||
@@ -295,13 +289,14 @@ void check_the_multis(linestruct *line)
|
||||
if (openfile->syntax == NULL || openfile->syntax->nmultis == 0)
|
||||
return;
|
||||
|
||||
if (line->multidata == NULL)
|
||||
set_up_multicache(line);
|
||||
|
||||
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
|
||||
/* If it's not a multiline regex, skip. */
|
||||
if (ink->end == NULL)
|
||||
continue;
|
||||
|
||||
alloc_multidata_if_needed(line);
|
||||
|
||||
astart = (regexec(ink->start, line->data, 1, &startmatch, 0) == 0);
|
||||
afterstart = line->data + (astart ? startmatch.rm_eo : 0);
|
||||
anend = (regexec(ink->end, afterstart, 1, &endmatch, 0) == 0);
|
||||
@@ -328,17 +323,6 @@ void check_the_multis(linestruct *line)
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate (for one line) the cache space for multiline color regexes. */
|
||||
void alloc_multidata_if_needed(linestruct *fileptr)
|
||||
{
|
||||
if (fileptr->multidata == NULL) {
|
||||
fileptr->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
|
||||
for (int i = 0; i < openfile->syntax->nmultis; i++)
|
||||
fileptr->multidata[i] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Precalculate the multi-line start and end regex info so we can
|
||||
* speed up rendering (with any hope at all...). */
|
||||
void precalc_multicolorinfo(void)
|
||||
@@ -350,6 +334,10 @@ void precalc_multicolorinfo(void)
|
||||
if (openfile->colorstrings == NULL || ISSET(NO_COLOR_SYNTAX))
|
||||
return;
|
||||
|
||||
/* For each line, allocate cache space for the multiline-regex info. */
|
||||
for (line = openfile->filetop; line != NULL; line = line->next)
|
||||
set_up_multicache(line);
|
||||
|
||||
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
|
||||
/* If this is not a multi-line regex, skip it. */
|
||||
if (ink->end == NULL)
|
||||
@@ -358,7 +346,6 @@ void precalc_multicolorinfo(void)
|
||||
for (line = openfile->filetop; line != NULL; line = line->next) {
|
||||
int index = 0;
|
||||
|
||||
alloc_multidata_if_needed(line);
|
||||
/* Assume nothing applies until proven otherwise below. */
|
||||
line->multidata[ink->id] = CNONE;
|
||||
|
||||
@@ -410,12 +397,9 @@ void precalc_multicolorinfo(void)
|
||||
* the lines in between and the end properly. */
|
||||
line->multidata[ink->id] = CENDAFTER;
|
||||
|
||||
for (line = line->next; line != tailline; line = line->next) {
|
||||
alloc_multidata_if_needed(line);
|
||||
for (line = line->next; line != tailline; line = line->next)
|
||||
line->multidata[ink->id] = CWHOLELINE;
|
||||
}
|
||||
|
||||
alloc_multidata_if_needed(tailline);
|
||||
tailline->multidata[ink->id] = CBEGINBEFORE;
|
||||
|
||||
/* Begin looking for a new start after the end match. */
|
||||
|
||||
45
src/cut.c
45
src/cut.c
@@ -42,7 +42,7 @@ void do_deletion(undo_type action)
|
||||
* 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);
|
||||
add_undo(action, NULL);
|
||||
else
|
||||
update_undo(action);
|
||||
|
||||
@@ -50,7 +50,7 @@ void do_deletion(undo_type action)
|
||||
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],
|
||||
memmove(&openfile->current->data[openfile->current_x],
|
||||
&openfile->current->data[openfile->current_x + charlen],
|
||||
line_len - charlen + 1);
|
||||
#ifndef NANO_TINY
|
||||
@@ -68,13 +68,13 @@ void do_deletion(undo_type action)
|
||||
!ISSET(NO_NEWLINES)) {
|
||||
#ifndef NANO_TINY
|
||||
if (action == BACK)
|
||||
add_undo(BACK);
|
||||
add_undo(BACK, NULL);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(action);
|
||||
add_undo(action, NULL);
|
||||
#endif
|
||||
/* Add the contents of the next line to those of the current one. */
|
||||
openfile->current->data = charealloc(openfile->current->data,
|
||||
@@ -182,7 +182,9 @@ void chop_word(bool forward)
|
||||
openfile->current_x = is_current_x;
|
||||
|
||||
/* Now kill the marked region and a word is gone. */
|
||||
cut_text();
|
||||
add_undo(CUT, NULL);
|
||||
do_snip(FALSE, TRUE, FALSE, FALSE);
|
||||
update_undo(CUT);
|
||||
|
||||
/* Discard the cut word and restore the cutbuffer. */
|
||||
free_lines(cutbuffer);
|
||||
@@ -192,7 +194,10 @@ void chop_word(bool forward)
|
||||
/* Delete a word leftward. */
|
||||
void chop_previous_word(void)
|
||||
{
|
||||
chop_word(BACKWARD);
|
||||
if (openfile->current->prev == NULL && openfile->current_x == 0)
|
||||
statusbar(_("Nothing was cut"));
|
||||
else
|
||||
chop_word(BACKWARD);
|
||||
}
|
||||
|
||||
/* Delete a word rightward. */
|
||||
@@ -268,7 +273,7 @@ void cut_to_eof(void)
|
||||
* If until_eof is TRUE, move all text from the current cursor
|
||||
* position to the end of the file into the cutbuffer. If append
|
||||
* is TRUE (when zapping), always append the cut to the cutbuffer. */
|
||||
void do_cut_text(bool copying, bool marked, bool until_eof, bool append)
|
||||
void do_snip(bool copying, bool marked, bool until_eof, bool append)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
linestruct *was_bottom = NULL;
|
||||
@@ -380,16 +385,17 @@ void cut_text(void)
|
||||
* the current cut is not contiguous with the previous cutting. */
|
||||
if (openfile->last_action != CUT || !keep_cutbuffer) {
|
||||
keep_cutbuffer = FALSE;
|
||||
add_undo(CUT);
|
||||
add_undo(CUT, NULL);
|
||||
}
|
||||
|
||||
do_cut_text(FALSE, openfile->mark != NULL, FALSE, FALSE);
|
||||
do_snip(FALSE, openfile->mark != NULL, FALSE, FALSE);
|
||||
|
||||
update_undo(CUT);
|
||||
#else
|
||||
if (is_cuttable(FALSE))
|
||||
do_cut_text(FALSE, FALSE, FALSE, FALSE);
|
||||
do_snip(FALSE, FALSE, FALSE, FALSE);
|
||||
#endif
|
||||
wipe_statusbar();
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -406,11 +412,7 @@ void copy_text(void)
|
||||
ssize_t is_current_lineno = openfile->current->lineno;
|
||||
size_t is_current_x = openfile->current_x;
|
||||
|
||||
/* If there is nothing to copy, don't even try. */
|
||||
if (openfile->current->next == NULL && openfile->current->data[0] == '\0')
|
||||
return;
|
||||
|
||||
do_cut_text(TRUE, mark_is_set, FALSE, FALSE);
|
||||
do_snip(TRUE, mark_is_set, FALSE, FALSE);
|
||||
|
||||
/* If the mark was set, restore the viewport and cursor position. */
|
||||
if (mark_is_set) {
|
||||
@@ -434,9 +436,10 @@ void cut_till_eof(void)
|
||||
return;
|
||||
}
|
||||
|
||||
add_undo(CUT_TO_EOF);
|
||||
do_cut_text(FALSE, FALSE, TRUE, FALSE);
|
||||
add_undo(CUT_TO_EOF, NULL);
|
||||
do_snip(FALSE, FALSE, TRUE, FALSE);
|
||||
update_undo(CUT_TO_EOF);
|
||||
wipe_statusbar();
|
||||
}
|
||||
|
||||
/* Erase text (current line or marked region), sending it into oblivion. */
|
||||
@@ -451,14 +454,15 @@ void zap_text(void)
|
||||
/* 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. */
|
||||
if (openfile->last_action != ZAP || !keep_cutbuffer)
|
||||
add_undo(ZAP);
|
||||
add_undo(ZAP, NULL);
|
||||
|
||||
/* Use the cutbuffer from the ZAP undo item, so the cut can be undone. */
|
||||
cutbuffer = openfile->current_undo->cutbuffer;
|
||||
|
||||
do_cut_text(FALSE, openfile->mark != NULL, FALSE, TRUE);
|
||||
do_snip(FALSE, openfile->mark != NULL, FALSE, TRUE);
|
||||
|
||||
update_undo(ZAP);
|
||||
wipe_statusbar();
|
||||
|
||||
cutbuffer = was_cutbuffer;
|
||||
}
|
||||
@@ -478,7 +482,7 @@ void paste_text(void)
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(PASTE);
|
||||
add_undo(PASTE, NULL);
|
||||
|
||||
if (ISSET(SOFTWRAP))
|
||||
was_leftedge = leftedge_for(xplustabs(), openfile->current);
|
||||
@@ -500,5 +504,6 @@ void paste_text(void)
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
set_modified();
|
||||
wipe_statusbar();
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
664
src/files.c
664
src/files.c
File diff suppressed because it is too large
Load Diff
516
src/global.c
516
src/global.c
@@ -68,6 +68,9 @@ bool more_than_one = FALSE;
|
||||
bool also_the_last = FALSE;
|
||||
/* Whether indenting/commenting should include the last line of
|
||||
* the marked region. */
|
||||
bool is_shorter;
|
||||
/* Whether a row's text is narrower than the screen's width. */
|
||||
|
||||
int didfind = 0;
|
||||
/* Whether the last search found something. */
|
||||
|
||||
@@ -86,7 +89,7 @@ int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown;
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
ssize_t fill = -COLUMNS_FROM_EOL;
|
||||
/* The relative column where we will wrap lines. */
|
||||
ssize_t wrap_at = 0;
|
||||
size_t wrap_at = 0;
|
||||
/* The actual column where we will wrap lines, based on fill. */
|
||||
#endif
|
||||
|
||||
@@ -245,21 +248,9 @@ char *homedir = NULL;
|
||||
char *statedir = NULL;
|
||||
/* The directory for nano's history files. */
|
||||
|
||||
#ifdef ENABLE_NANORC
|
||||
#define NUMBER_OF_MENUS 16
|
||||
char *menunames[NUMBER_OF_MENUS] = { "main", "search", "replace", "replacewith",
|
||||
"yesno", "gotoline", "writeout", "insert",
|
||||
"extcmd", "help", "spell", "linter",
|
||||
"browser", "whereisfile", "gotodir",
|
||||
"all" };
|
||||
int menusymbols[NUMBER_OF_MENUS] = { MMAIN, MWHEREIS, MREPLACE, MREPLACEWITH,
|
||||
MYESNO, MGOTOLINE, MWRITEFILE, MINSERTFILE,
|
||||
MEXTCMD, MHELP, MSPELL, MLINTER,
|
||||
MBROWSER, MWHEREISFILE, MGOTODIR,
|
||||
MMOST|MHELP|MYESNO };
|
||||
|
||||
char *rcfile_with_errors = NULL;
|
||||
/* The first nanorc file, if any, that produced warnings. */
|
||||
#if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES)
|
||||
char *startup_problem = NULL;
|
||||
/* An error message (if any) about nanorc files or history files. */
|
||||
#endif
|
||||
|
||||
bool spotlighted = FALSE;
|
||||
@@ -269,19 +260,6 @@ size_t light_from_col = 0;
|
||||
size_t light_to_col = 0;
|
||||
/* Where the spotlighted text ends. */
|
||||
|
||||
/* Return the number of entries in the shortcut list for a given menu. */
|
||||
size_t length_of_list(int menu)
|
||||
{
|
||||
funcstruct *f;
|
||||
size_t i = 0;
|
||||
|
||||
for (f = allfuncs; f != NULL; f = f->next)
|
||||
if ((f->menus & menu) && first_sc_for(menu, f->func) != NULL)
|
||||
i++;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* To make the functions and shortcuts lists clearer. */
|
||||
#define VIEW TRUE /* Is allowed in view mode. */
|
||||
#define NOVIEW FALSE
|
||||
@@ -358,9 +336,9 @@ void do_cancel(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* Add a function to the function list. */
|
||||
void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *help,
|
||||
bool blank_after, bool viewok)
|
||||
/* Add a function to the linked list of functions. */
|
||||
void add_to_funcs(void (*func)(void), int menus, const char *desc,
|
||||
const char *help, bool blank_after, bool viewok)
|
||||
{
|
||||
funcstruct *f = nmalloc(sizeof(funcstruct));
|
||||
|
||||
@@ -381,7 +359,7 @@ void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *h
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Add a key combo to the shortcut list. */
|
||||
/* Add a key combo to the linked list of shortcuts. */
|
||||
void add_to_sclist(int menus, const char *scstring, const int keycode,
|
||||
void (*func)(void), int toggle)
|
||||
{
|
||||
@@ -438,6 +416,46 @@ int the_code_for(void (*func)(void), int defaultval)
|
||||
return s->keycode;
|
||||
}
|
||||
|
||||
/* Return the number of entries that can be shown in the given menu. */
|
||||
size_t shown_entries_for(int menu)
|
||||
{
|
||||
funcstruct *item = allfuncs;
|
||||
size_t maximum = ((COLS + 40) / 20) * 2;
|
||||
size_t count = 0;
|
||||
|
||||
while (count < maximum && item != NULL) {
|
||||
if (item->menus & menu)
|
||||
count++;
|
||||
item = item->next;
|
||||
}
|
||||
|
||||
/* When --tempfile is not used, widen the grid of the WriteOut menu. */
|
||||
if (menu == MWRITEFILE && first_sc_for(menu, discard_buffer) == NULL)
|
||||
count--;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Return the shortcut that corresponds to the values of kbinput (the
|
||||
* key itself) and meta_key (whether the key is a meta sequence). The
|
||||
* returned shortcut will be the first in the list that corresponds to
|
||||
* the given sequence. */
|
||||
const keystruct *get_shortcut(int *kbinput)
|
||||
{
|
||||
/* Plain characters cannot be shortcuts, so just skip those. */
|
||||
if (!meta_key && ((*kbinput >= 0x20 && *kbinput < 0x7F) ||
|
||||
(*kbinput >= 0xA0 && *kbinput <= 0xFF)))
|
||||
return NULL;
|
||||
|
||||
for (keystruct *s = sclist; s != NULL; s = s->next) {
|
||||
if ((s->menus & currmenu) && *kbinput == s->keycode &&
|
||||
meta_key == s->meta)
|
||||
return s;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Return a pointer to the function that is bound to the given key. */
|
||||
functionptrtype func_from_key(int *kbinput)
|
||||
{
|
||||
@@ -449,53 +467,54 @@ functionptrtype func_from_key(int *kbinput)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Set the string and its corresponding keycode for the given shortcut s. */
|
||||
void assign_keyinfo(keystruct *s, const char *keystring, const int keycode)
|
||||
{
|
||||
s->keystr = keystring;
|
||||
s->meta = (keystring[0] == 'M' && keycode == 0);
|
||||
|
||||
if (keycode)
|
||||
s->keycode = keycode;
|
||||
else
|
||||
s->keycode = keycode_from_string(keystring);
|
||||
}
|
||||
|
||||
/* Parse the given keystring and return the corresponding keycode,
|
||||
* or return -1 when the string is invalid. */
|
||||
int keycode_from_string(const char *keystring)
|
||||
{
|
||||
if (keystring[0] == '^') {
|
||||
if (strcasecmp(keystring, "^Space") == 0)
|
||||
return 0;
|
||||
if (keystring[2] == '\0') {
|
||||
if (keystring[1] == '/')
|
||||
return 31;
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
|
||||
if (strcasecmp(keystring, "^H") == 0)
|
||||
return KEY_BACKSPACE;
|
||||
if (keystring[1] == 'H')
|
||||
return KEY_BACKSPACE;
|
||||
#endif
|
||||
if (keystring[1] <= '_' && strlen(keystring) == 2)
|
||||
return keystring[1] - 64;
|
||||
if (keystring[1] <= '_')
|
||||
return keystring[1] - 64;
|
||||
else
|
||||
return -1;
|
||||
} else if (strcasecmp(keystring, "^Space") == 0)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
} else if (keystring[0] == 'M') {
|
||||
if (keystring[1] == '-' && keystring[3] == '\0')
|
||||
return tolower((unsigned char)keystring[2]);
|
||||
if (strcasecmp(keystring, "M-Space") == 0)
|
||||
return (int)' ';
|
||||
if (keystring[1] == '-' && strlen(keystring) == 3)
|
||||
return tolower((unsigned char)keystring[2]);
|
||||
else
|
||||
return -1;
|
||||
} else if (keystring[0] == 'F') {
|
||||
int fn = atoi(&keystring[1]);
|
||||
if (fn < 1 || fn > 16)
|
||||
if (fn < 1 || fn > 24)
|
||||
return -1;
|
||||
return KEY_F0 + fn;
|
||||
} else if (!strcasecmp(keystring, "Ins"))
|
||||
} else if (strcasecmp(keystring, "Ins") == 0)
|
||||
return KEY_IC;
|
||||
else if (!strcasecmp(keystring, "Del"))
|
||||
else if (strcasecmp(keystring, "Del") == 0)
|
||||
return KEY_DC;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Set the string and its corresponding keycode for the given shortcut s. */
|
||||
void assign_keyinfo(keystruct *s, const char *keystring, const int keycode)
|
||||
{
|
||||
s->keystr = keystring;
|
||||
s->meta = (keystring[0] == 'M' && keycode == 0);
|
||||
s->keycode = (keycode ? keycode : keycode_from_string(keystring));
|
||||
}
|
||||
|
||||
/* 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");
|
||||
@@ -509,8 +528,7 @@ void shortcut_init(void)
|
||||
* they are best kept shorter than 56 characters, but may be longer. */
|
||||
const char *cancel_gist = N_("Cancel the current function");
|
||||
const char *help_gist = N_("Display this help text");
|
||||
const char *exit_gist =
|
||||
N_("Close the current buffer / Exit from nano");
|
||||
const char *exit_gist = N_("Close the current buffer / Exit from nano");
|
||||
const char *writeout_gist =
|
||||
N_("Write the current buffer (or the marked region) to disk");
|
||||
const char *readfile_gist =
|
||||
@@ -519,19 +537,6 @@ void shortcut_init(void)
|
||||
N_("Search forward for a string or a regular expression");
|
||||
const char *wherewas_gist =
|
||||
N_("Search backward for a string or a regular expression");
|
||||
#ifdef ENABLE_BROWSER
|
||||
const char *browserwhereis_gist = N_("Search forward for a string");
|
||||
const char *browserwherewas_gist = N_("Search backward for a string");
|
||||
const char *browserrefresh_gist = N_("Refresh the file list");
|
||||
#ifndef NANO_TINY
|
||||
const char *browserlefthand_gist = N_("Go to lefthand column");
|
||||
const char *browserrighthand_gist = N_("Go to righthand column");
|
||||
const char *browsertoprow_gist = N_("Go to first row in this column");
|
||||
const char *browserbottomrow_gist = N_("Go to last row in this column");
|
||||
#endif
|
||||
#endif
|
||||
const char *prevpage_gist = N_("Go one screenful up");
|
||||
const char *nextpage_gist = N_("Go one screenful down");
|
||||
const char *cut_gist =
|
||||
N_("Cut current line (or marked region) and store it in cutbuffer");
|
||||
const char *uncut_gist =
|
||||
@@ -568,6 +573,8 @@ void shortcut_init(void)
|
||||
const char *paraend_gist =
|
||||
N_("Go just beyond end of paragraph; then of next paragraph");
|
||||
#endif
|
||||
const char *prevpage_gist = N_("Go one screenful up");
|
||||
const char *nextpage_gist = N_("Go one screenful down");
|
||||
const char *firstline_gist = N_("Go to the first line of the file");
|
||||
const char *lastline_gist = N_("Go to the last line of the file");
|
||||
#ifndef NANO_TINY
|
||||
@@ -623,12 +630,9 @@ void shortcut_init(void)
|
||||
const char *recordmacro_gist = N_("Start/stop recording a macro");
|
||||
const char *runmacro_gist = N_("Run the last recorded macro");
|
||||
#endif
|
||||
const char *case_gist =
|
||||
N_("Toggle the case sensitivity of the search");
|
||||
const char *reverse_gist =
|
||||
N_("Reverse the direction of the search");
|
||||
const char *regexp_gist =
|
||||
N_("Toggle the use of regular expressions");
|
||||
const char *case_gist = N_("Toggle the case sensitivity of the search");
|
||||
const char *reverse_gist = N_("Reverse the direction of the search");
|
||||
const char *regexp_gist = N_("Toggle the use of regular expressions");
|
||||
#ifdef ENABLE_HISTORIES
|
||||
const char *older_gist =
|
||||
N_("Recall the previous search/replace string");
|
||||
@@ -657,12 +661,25 @@ void shortcut_init(void)
|
||||
const char *lastfile_gist = N_("Go to the last file in the list");
|
||||
const char *backfile_gist = N_("Go to the previous file in the list");
|
||||
const char *forwardfile_gist = N_("Go to the next file in the list");
|
||||
#ifndef NANO_TINY
|
||||
const char *browserlefthand_gist = N_("Go to lefthand column");
|
||||
const char *browserrighthand_gist = N_("Go to righthand column");
|
||||
const char *browsertoprow_gist = N_("Go to first row in this column");
|
||||
const char *browserbottomrow_gist = N_("Go to last row in this column");
|
||||
#endif
|
||||
const char *browserwhereis_gist = N_("Search forward for a string");
|
||||
const char *browserwherewas_gist = N_("Search backward for a string");
|
||||
const char *browserrefresh_gist = N_("Refresh the file list");
|
||||
const char *gotodir_gist = N_("Go to directory");
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
const char *lint_gist = N_("Invoke the linter, if available");
|
||||
const char *prevlint_gist = N_("Go to previous linter msg");
|
||||
const char *nextlint_gist = N_("Go to next linter msg");
|
||||
#ifdef ENABLE_SPELLER
|
||||
const char *formatter_gist =
|
||||
N_("Invoke a program to format/arrange/manipulate the buffer");
|
||||
#endif
|
||||
#endif
|
||||
#endif /* ENABLE_HELP */
|
||||
|
||||
@@ -674,9 +691,8 @@ void shortcut_init(void)
|
||||
|
||||
/* Start populating the different menus with functions. */
|
||||
|
||||
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. */
|
||||
add_to_funcs(do_help, (MMOST | MBROWSER) & ~MFINDINHELP,
|
||||
/* TRANSLATORS: Try to keep the next eleven strings at most 10 characters. */
|
||||
N_("Get Help"), WITHORSANS(help_gist), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(do_cancel, ((MMOST & ~MMAIN) | MYESNO),
|
||||
@@ -724,14 +740,6 @@ void shortcut_init(void)
|
||||
add_to_funcs(do_replace, MMAIN,
|
||||
N_("Replace"), WITHORSANS(replace_gist), TOGETHER, NOVIEW);
|
||||
|
||||
#ifdef ENABLE_BROWSER
|
||||
add_to_funcs(goto_dir_void, MBROWSER,
|
||||
N_("Go To Dir"), WITHORSANS(gotodir_gist), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(total_refresh, MBROWSER,
|
||||
N_("Refresh"), WITHORSANS(browserrefresh_gist), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(cut_text, MMAIN,
|
||||
N_("Cut Text"), WITHORSANS(cut_gist), TOGETHER, NOVIEW);
|
||||
|
||||
@@ -750,6 +758,7 @@ void shortcut_init(void)
|
||||
}
|
||||
|
||||
add_to_funcs(do_cursorpos_void, MMAIN,
|
||||
/* TRANSLATORS: Try to keep the next thirteen strings at most 12 characters. */
|
||||
N_("Cur Pos"), WITHORSANS(cursorpos_gist), TOGETHER, VIEW);
|
||||
|
||||
#if (defined(ENABLE_JUSTIFY) && (defined(ENABLE_SPELLER) || defined(ENABLE_COLOR)) || \
|
||||
@@ -800,12 +809,14 @@ void shortcut_init(void)
|
||||
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);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_BROWSER
|
||||
add_to_funcs(goto_dir_void, MBROWSER,
|
||||
/* TRANSLATORS: Try to keep the next seven strings at most 10 characters. */
|
||||
N_("Go To Dir"), WITHORSANS(gotodir_gist), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(total_refresh, MBROWSER,
|
||||
N_("Refresh"), WITHORSANS(browserrefresh_gist), BLANKAFTER, VIEW);
|
||||
|
||||
add_to_funcs(do_search_forward, MBROWSER,
|
||||
N_("Where Is"), WITHORSANS(browserwhereis_gist), TOGETHER, VIEW);
|
||||
add_to_funcs(do_search_backward, MBROWSER,
|
||||
@@ -813,6 +824,9 @@ void shortcut_init(void)
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(do_find_bracket, MMAIN,
|
||||
N_("To Bracket"), WITHORSANS(bracket_gist), BLANKAFTER, VIEW);
|
||||
|
||||
add_to_funcs(do_search_backward, MMAIN|MHELP,
|
||||
/* TRANSLATORS: This starts a backward search. */
|
||||
N_("Where Was"), WITHORSANS(wherewas_gist), TOGETHER, VIEW);
|
||||
@@ -847,6 +861,7 @@ void shortcut_init(void)
|
||||
#endif
|
||||
|
||||
add_to_funcs(do_prev_word_void, MMAIN,
|
||||
/* TRANSLATORS: Try to keep the next eighteen strings at most 12 characters. */
|
||||
N_("Prev Word"), WITHORSANS(prevword_gist), TOGETHER, VIEW);
|
||||
add_to_funcs(do_next_word_void, MMAIN,
|
||||
N_("Next Word"), WITHORSANS(nextword_gist), TOGETHER, VIEW);
|
||||
@@ -902,6 +917,7 @@ void shortcut_init(void)
|
||||
#endif
|
||||
|
||||
add_to_funcs(do_tab, MMAIN,
|
||||
/* TRANSLATORS: The next four strings are names of keyboard keys. */
|
||||
N_("Tab"), WITHORSANS(tab_gist), TOGETHER, NOVIEW);
|
||||
add_to_funcs(do_enter, MMAIN,
|
||||
N_("Enter"), WITHORSANS(enter_gist), BLANKAFTER, NOVIEW);
|
||||
@@ -972,9 +988,14 @@ void shortcut_init(void)
|
||||
N_("Zap Text"), WITHORSANS(zap_gist), BLANKAFTER, NOVIEW);
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
if (!ISSET(RESTRICTED))
|
||||
if (!ISSET(RESTRICTED)) {
|
||||
add_to_funcs(do_linter, MMAIN,
|
||||
N_("To Linter"), WITHORSANS(lint_gist), BLANKAFTER, NOVIEW);
|
||||
N_("To Linter"), WITHORSANS(lint_gist), TOGETHER, NOVIEW);
|
||||
#ifdef ENABLE_SPELLER
|
||||
add_to_funcs(do_formatter, MMAIN,
|
||||
N_("Formatter"), WITHORSANS(formatter_gist), BLANKAFTER, NOVIEW);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
add_to_funcs(do_savefile, MMAIN,
|
||||
@@ -1057,7 +1078,7 @@ void shortcut_init(void)
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
add_to_funcs(do_page_up, MLINTER,
|
||||
/* TRANSLATORS: Try to keep the next two strings at most 20 characters. */
|
||||
/* TRANSLATORS: The next two strings may be up to 37 characters each. */
|
||||
N_("Prev Lint Msg"), WITHORSANS(prevlint_gist), TOGETHER, VIEW);
|
||||
add_to_funcs(do_page_down, MLINTER,
|
||||
N_("Next Lint Msg"), WITHORSANS(nextlint_gist), TOGETHER, VIEW);
|
||||
@@ -1073,7 +1094,7 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMOST, "Del", 0, do_delete, 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((MMOST|MBROWSER) & ~MFINDINHELP, "^G", 0, do_help, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "^X", 0, do_exit, 0);
|
||||
if (!ISSET(PRESERVE))
|
||||
add_to_sclist(MMAIN, "^S", 0, do_savefile, 0);
|
||||
@@ -1095,6 +1116,9 @@ void shortcut_init(void)
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
add_to_sclist(MMAIN, "M-B", 0, do_linter, 0);
|
||||
#ifdef ENABLE_SPELLER
|
||||
add_to_sclist(MMAIN, "M-F", 0, do_formatter, 0);
|
||||
#endif
|
||||
#endif
|
||||
add_to_sclist(MMAIN, "^C", 0, do_cursorpos_void, 0);
|
||||
add_to_sclist(MMAIN, "^_", 0, do_gotolinecolumn_void, 0);
|
||||
@@ -1120,7 +1144,7 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN, "M-6", 0, copy_text, 0);
|
||||
add_to_sclist(MMAIN, "M-^", 0, copy_text, 0);
|
||||
add_to_sclist(MMAIN, "M-}", 0, do_indent, 0);
|
||||
add_to_sclist(MMAIN, "Tab", TAB_CODE, do_indent, 0);
|
||||
add_to_sclist(MMAIN, "Tab", INDENT_KEY, do_indent, 0);
|
||||
add_to_sclist(MMAIN, "M-{", 0, do_unindent, 0);
|
||||
add_to_sclist(MMAIN, "Sh-Tab", SHIFT_TAB, do_unindent, 0);
|
||||
add_to_sclist(MMAIN, "M-:", 0, record_macro, 0);
|
||||
@@ -1171,8 +1195,8 @@ void shortcut_init(void)
|
||||
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, "M-Space", 0, do_prev_word_void, 0);
|
||||
add_to_sclist(MMOST, "^Space", 0, do_next_word_void, 0);
|
||||
add_to_sclist(MMOST, "^A", 0, do_home, 0);
|
||||
add_to_sclist(MMOST, "Home", KEY_HOME, do_home, 0);
|
||||
add_to_sclist(MMOST, "^E", 0, do_end, 0);
|
||||
@@ -1356,7 +1380,7 @@ void shortcut_init(void)
|
||||
#ifdef ENABLE_COLOR
|
||||
add_to_sclist(MLINTER, "^X", 0, do_cancel, 0);
|
||||
#endif
|
||||
add_to_sclist(MMOST & ~MFINDINHELP, "F1", 0, do_help_void, 0);
|
||||
add_to_sclist(MMOST & ~MFINDINHELP, "F1", 0, do_help, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", 0, do_exit, 0);
|
||||
add_to_sclist(MMAIN, "F3", 0, do_writeout_void, 0);
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
@@ -1380,7 +1404,7 @@ const char *flagtostr(int flag)
|
||||
{
|
||||
switch (flag) {
|
||||
case NO_HELP:
|
||||
/* TRANSLATORS: The next fourteen strings are toggle descriptions;
|
||||
/* TRANSLATORS: The next thirteen strings are toggle descriptions;
|
||||
* they are best kept shorter than 40 characters, but may be longer. */
|
||||
return N_("Help mode");
|
||||
case CONSTANT_SHOW:
|
||||
@@ -1412,291 +1436,3 @@ const char *flagtostr(int flag)
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
#ifdef ENABLE_NANORC
|
||||
/* Interpret a function string given in the rc file, and return a
|
||||
* shortcut record with the corresponding function filled in. */
|
||||
keystruct *strtosc(const char *input)
|
||||
{
|
||||
keystruct *s = nmalloc(sizeof(keystruct));
|
||||
|
||||
#ifndef NANO_TINY
|
||||
s->toggle = 0;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_HELP
|
||||
if (!strcasecmp(input, "help"))
|
||||
s->func = do_help_void;
|
||||
else
|
||||
#endif
|
||||
if (!strcasecmp(input, "cancel"))
|
||||
s->func = do_cancel;
|
||||
else if (!strcasecmp(input, "exit"))
|
||||
s->func = do_exit;
|
||||
else if (!strcasecmp(input, "discardbuffer"))
|
||||
s->func = discard_buffer;
|
||||
else if (!strcasecmp(input, "writeout"))
|
||||
s->func = do_writeout_void;
|
||||
else if (!strcasecmp(input, "savefile"))
|
||||
s->func = do_savefile;
|
||||
else if (!strcasecmp(input, "insert"))
|
||||
s->func = do_insertfile_void;
|
||||
else if (!strcasecmp(input, "whereis"))
|
||||
s->func = do_search_forward;
|
||||
else if (!strcasecmp(input, "wherewas"))
|
||||
s->func = do_search_backward;
|
||||
else if (!strcasecmp(input, "findprevious"))
|
||||
s->func = do_findprevious;
|
||||
else if (!strcasecmp(input, "findnext"))
|
||||
s->func = do_findnext;
|
||||
else if (!strcasecmp(input, "replace"))
|
||||
s->func = do_replace;
|
||||
else if (!strcasecmp(input, "cut"))
|
||||
s->func = cut_text;
|
||||
else if (!strcasecmp(input, "paste"))
|
||||
s->func = paste_text;
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcasecmp(input, "cutrestoffile"))
|
||||
s->func = cut_till_eof;
|
||||
else if (!strcasecmp(input, "copy"))
|
||||
s->func = copy_text;
|
||||
else if (!strcasecmp(input, "zap"))
|
||||
s->func = zap_text;
|
||||
else if (!strcasecmp(input, "mark"))
|
||||
s->func = do_mark;
|
||||
#endif
|
||||
#ifdef ENABLE_SPELLER
|
||||
else if (!strcasecmp(input, "tospell") ||
|
||||
!strcasecmp(input, "speller"))
|
||||
s->func = do_spell;
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
else if (!strcasecmp(input, "linter"))
|
||||
s->func = do_linter;
|
||||
#endif
|
||||
else if (!strcasecmp(input, "curpos"))
|
||||
s->func = do_cursorpos_void;
|
||||
else if (!strcasecmp(input, "gotoline"))
|
||||
s->func = do_gotolinecolumn_void;
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
else if (!strcasecmp(input, "justify"))
|
||||
s->func = do_justify_void;
|
||||
else if (!strcasecmp(input, "fulljustify"))
|
||||
s->func = do_full_justify;
|
||||
else if (!strcasecmp(input, "beginpara"))
|
||||
s->func = do_para_begin_void;
|
||||
else if (!strcasecmp(input, "endpara"))
|
||||
s->func = do_para_end_void;
|
||||
#endif
|
||||
#ifdef ENABLE_COMMENT
|
||||
else if (!strcasecmp(input, "comment"))
|
||||
s->func = do_comment;
|
||||
#endif
|
||||
#ifdef ENABLE_WORDCOMPLETION
|
||||
else if (!strcasecmp(input, "complete"))
|
||||
s->func = complete_a_word;
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcasecmp(input, "indent"))
|
||||
s->func = do_indent;
|
||||
else if (!strcasecmp(input, "unindent"))
|
||||
s->func = do_unindent;
|
||||
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"))
|
||||
s->func = do_wordlinechar_count;
|
||||
else if (!strcasecmp(input, "recordmacro"))
|
||||
s->func = record_macro;
|
||||
else if (!strcasecmp(input, "runmacro"))
|
||||
s->func = run_macro;
|
||||
else if (!strcasecmp(input, "undo"))
|
||||
s->func = do_undo;
|
||||
else if (!strcasecmp(input, "redo"))
|
||||
s->func = do_redo;
|
||||
#endif
|
||||
else if (!strcasecmp(input, "left") ||
|
||||
!strcasecmp(input, "back"))
|
||||
s->func = do_left;
|
||||
else if (!strcasecmp(input, "right") ||
|
||||
!strcasecmp(input, "forward"))
|
||||
s->func = do_right;
|
||||
else if (!strcasecmp(input, "up") ||
|
||||
!strcasecmp(input, "prevline"))
|
||||
s->func = do_up;
|
||||
else if (!strcasecmp(input, "down") ||
|
||||
!strcasecmp(input, "nextline"))
|
||||
s->func = do_down;
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
|
||||
else if (!strcasecmp(input, "scrollup"))
|
||||
s->func = do_scroll_up;
|
||||
else if (!strcasecmp(input, "scrolldown"))
|
||||
s->func = do_scroll_down;
|
||||
#endif
|
||||
else if (!strcasecmp(input, "prevword"))
|
||||
s->func = do_prev_word_void;
|
||||
else if (!strcasecmp(input, "nextword"))
|
||||
s->func = do_next_word_void;
|
||||
else if (!strcasecmp(input, "home"))
|
||||
s->func = do_home;
|
||||
else if (!strcasecmp(input, "end"))
|
||||
s->func = do_end;
|
||||
else if (!strcasecmp(input, "prevblock"))
|
||||
s->func = do_prev_block;
|
||||
else if (!strcasecmp(input, "nextblock"))
|
||||
s->func = do_next_block;
|
||||
else if (!strcasecmp(input, "pageup") ||
|
||||
!strcasecmp(input, "prevpage"))
|
||||
s->func = do_page_up;
|
||||
else if (!strcasecmp(input, "pagedown") ||
|
||||
!strcasecmp(input, "nextpage"))
|
||||
s->func = do_page_down;
|
||||
else if (!strcasecmp(input, "firstline"))
|
||||
s->func = to_first_line;
|
||||
else if (!strcasecmp(input, "lastline"))
|
||||
s->func = to_last_line;
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
else if (!strcasecmp(input, "prevbuf"))
|
||||
s->func = switch_to_prev_buffer;
|
||||
else if (!strcasecmp(input, "nextbuf"))
|
||||
s->func = switch_to_next_buffer;
|
||||
#endif
|
||||
else if (!strcasecmp(input, "verbatim"))
|
||||
s->func = do_verbatim_input;
|
||||
else if (!strcasecmp(input, "tab"))
|
||||
s->func = do_tab;
|
||||
else if (!strcasecmp(input, "enter"))
|
||||
s->func = do_enter;
|
||||
else if (!strcasecmp(input, "delete"))
|
||||
s->func = do_delete;
|
||||
else if (!strcasecmp(input, "backspace"))
|
||||
s->func = do_backspace;
|
||||
else if (!strcasecmp(input, "refresh"))
|
||||
s->func = total_refresh;
|
||||
else if (!strcasecmp(input, "suspend"))
|
||||
s->func = do_suspend_void;
|
||||
else if (!strcasecmp(input, "casesens"))
|
||||
s->func = case_sens_void;
|
||||
else if (!strcasecmp(input, "regexp"))
|
||||
s->func = regexp_void;
|
||||
else if (!strcasecmp(input, "backwards"))
|
||||
s->func = backwards_void;
|
||||
else if (!strcasecmp(input, "flipreplace"))
|
||||
s->func = flip_replace;
|
||||
else if (!strcasecmp(input, "flipgoto"))
|
||||
s->func = flip_goto;
|
||||
#ifdef ENABLE_HISTORIES
|
||||
else if (!strcasecmp(input, "older"))
|
||||
s->func = get_history_older_void;
|
||||
else if (!strcasecmp(input, "newer"))
|
||||
s->func = get_history_newer_void;
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcasecmp(input, "dosformat"))
|
||||
s->func = dos_format_void;
|
||||
else if (!strcasecmp(input, "macformat"))
|
||||
s->func = mac_format_void;
|
||||
else if (!strcasecmp(input, "append"))
|
||||
s->func = append_void;
|
||||
else if (!strcasecmp(input, "prepend"))
|
||||
s->func = prepend_void;
|
||||
else if (!strcasecmp(input, "backup"))
|
||||
s->func = backup_file_void;
|
||||
else if (!strcasecmp(input, "flipexecute"))
|
||||
s->func = flip_execute;
|
||||
else if (!strcasecmp(input, "flippipe"))
|
||||
s->func = flip_pipe;
|
||||
else if (!strcasecmp(input, "flipconvert"))
|
||||
s->func = flip_convert;
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
else if (!strcasecmp(input, "flipnewbuffer"))
|
||||
s->func = flip_newbuffer;
|
||||
#endif
|
||||
#ifdef ENABLE_BROWSER
|
||||
else if (!strcasecmp(input, "tofiles") ||
|
||||
!strcasecmp(input, "browser"))
|
||||
s->func = to_files_void;
|
||||
else if (!strcasecmp(input, "gotodir"))
|
||||
s->func = goto_dir_void;
|
||||
else if (!strcasecmp(input, "firstfile"))
|
||||
s->func = to_first_file;
|
||||
else if (!strcasecmp(input, "lastfile"))
|
||||
s->func = to_last_file;
|
||||
#endif
|
||||
else {
|
||||
#ifndef NANO_TINY
|
||||
s->func = do_toggle_void;
|
||||
if (!strcasecmp(input, "nohelp"))
|
||||
s->toggle = NO_HELP;
|
||||
else if (!strcasecmp(input, "constantshow"))
|
||||
s->toggle = CONSTANT_SHOW;
|
||||
else if (!strcasecmp(input, "softwrap"))
|
||||
s->toggle = SOFTWRAP;
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
else if (!strcasecmp(input, "linenumbers"))
|
||||
s->toggle = LINE_NUMBERS;
|
||||
#endif
|
||||
else if (!strcasecmp(input, "whitespacedisplay"))
|
||||
s->toggle = WHITESPACE_DISPLAY;
|
||||
#ifdef ENABLE_COLOR
|
||||
else if (!strcasecmp(input, "nosyntax"))
|
||||
s->toggle = NO_COLOR_SYNTAX;
|
||||
#endif
|
||||
else if (!strcasecmp(input, "smarthome"))
|
||||
s->toggle = SMART_HOME;
|
||||
else if (!strcasecmp(input, "autoindent"))
|
||||
s->toggle = AUTOINDENT;
|
||||
else if (!strcasecmp(input, "cutfromcursor"))
|
||||
s->toggle = CUT_FROM_CURSOR;
|
||||
#ifdef ENABLE_WRAPPING
|
||||
else if (!strcasecmp(input, "nowrap"))
|
||||
s->toggle = BREAK_LONG_LINES;
|
||||
#endif
|
||||
else if (!strcasecmp(input, "tabstospaces"))
|
||||
s->toggle = TABS_TO_SPACES;
|
||||
#ifdef ENABLE_MOUSE
|
||||
else if (!strcasecmp(input, "mouse"))
|
||||
s->toggle = USE_MOUSE;
|
||||
#endif
|
||||
else if (!strcasecmp(input, "suspendenable"))
|
||||
s->toggle = SUSPEND;
|
||||
else
|
||||
#endif /* !NANO_TINY */
|
||||
{
|
||||
free(s);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/* Return the symbol that corresponds to the given menu name. */
|
||||
int name_to_menu(const char *name)
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
while (++index < NUMBER_OF_MENUS)
|
||||
if (strcasecmp(name, menunames[index]) == 0)
|
||||
return menusymbols[index];
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Return the name that corresponds to the given menu symbol. */
|
||||
char *menu_to_name(int menu)
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
while (++index < NUMBER_OF_MENUS)
|
||||
if (menusymbols[index] == menu)
|
||||
return menunames[index];
|
||||
|
||||
return "boooo";
|
||||
}
|
||||
#endif /* ENABLE_NANORC */
|
||||
|
||||
32
src/help.c
32
src/help.c
@@ -22,11 +22,11 @@
|
||||
|
||||
#include "proto.h"
|
||||
|
||||
#ifdef ENABLE_HELP
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef ENABLE_HELP
|
||||
|
||||
static char *help_text = NULL;
|
||||
/* The text displayed in the help window. */
|
||||
|
||||
@@ -40,7 +40,7 @@ static size_t location;
|
||||
/* The offset (in bytes) of the topleft of the shown help text. */
|
||||
|
||||
/* Hard-wrap the concatenated help text, and write it into a new buffer. */
|
||||
void wrap_help_text_into_buffer()
|
||||
void wrap_help_text_into_buffer(void)
|
||||
{
|
||||
size_t sum = 0;
|
||||
const char *ptr = start_of_body;
|
||||
@@ -64,7 +64,7 @@ void wrap_help_text_into_buffer()
|
||||
do {
|
||||
openfile->current->next = make_new_node(openfile->current);
|
||||
openfile->current = openfile->current->next;
|
||||
openfile->current->data = mallocstrcpy(NULL, "");
|
||||
openfile->current->data = copy_of("");
|
||||
} while (*(++ptr) == '\n');
|
||||
}
|
||||
|
||||
@@ -88,8 +88,8 @@ void wrap_help_text_into_buffer()
|
||||
openfile->edittop = openfile->current;
|
||||
}
|
||||
|
||||
/* Our main help-viewer function. */
|
||||
void do_help(void)
|
||||
/* Assemble a help text, display it, and allow scrolling through it. */
|
||||
void show_help(void)
|
||||
{
|
||||
int kbinput = ERR;
|
||||
functionptrtype func;
|
||||
@@ -103,7 +103,7 @@ void do_help(void)
|
||||
#ifdef ENABLE_COLOR
|
||||
char *was_syntax = syntaxstr;
|
||||
#endif
|
||||
char *saved_answer = (answer != NULL) ? strdup(answer) : NULL;
|
||||
char *saved_answer = (answer != NULL) ? copy_of(answer) : NULL;
|
||||
/* 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. */
|
||||
@@ -140,8 +140,9 @@ void do_help(void)
|
||||
#endif
|
||||
curs_set(0);
|
||||
|
||||
/* Compose the help text from all the pieces. */
|
||||
/* Compose the help text from all the relevant pieces. */
|
||||
help_init();
|
||||
|
||||
inhelp = TRUE;
|
||||
location = 0;
|
||||
didfind = 0;
|
||||
@@ -150,8 +151,7 @@ void do_help(void)
|
||||
|
||||
/* Extract the title from the head of the help text. */
|
||||
length = break_line(help_text, MAX_BUF_SIZE, TRUE);
|
||||
title = charalloc(length * sizeof(char) + 1);
|
||||
strncpy(title, help_text, length);
|
||||
title = measured_copy(help_text, length + 1);
|
||||
title[length] = '\0';
|
||||
|
||||
titlebar(title);
|
||||
@@ -247,7 +247,6 @@ void do_help(void)
|
||||
inhelp = FALSE;
|
||||
|
||||
curs_set(0);
|
||||
refresh_needed = TRUE;
|
||||
|
||||
if (ISSET(NO_HELP)) {
|
||||
currmenu = oldmenu;
|
||||
@@ -262,7 +261,10 @@ void do_help(void)
|
||||
browser_refresh();
|
||||
else
|
||||
#endif
|
||||
{
|
||||
titlebar(NULL);
|
||||
edit_refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate space for the help text for the current menu, and concatenate
|
||||
@@ -547,7 +549,6 @@ functionptrtype parse_help_input(int *kbinput)
|
||||
{
|
||||
if (!meta_key) {
|
||||
switch (*kbinput) {
|
||||
case BS_CODE:
|
||||
case '-':
|
||||
return do_page_up;
|
||||
case ' ':
|
||||
@@ -600,14 +601,13 @@ size_t help_line_len(const char *ptr)
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* ENABLE_HELP */
|
||||
|
||||
/* Start the help viewer. */
|
||||
void do_help_void(void)
|
||||
/* Start the help viewer, or indicate that there is no help. */
|
||||
void do_help(void)
|
||||
{
|
||||
#ifdef ENABLE_HELP
|
||||
do_help();
|
||||
show_help();
|
||||
#else
|
||||
if (currmenu == MMAIN)
|
||||
say_there_is_no_help();
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
|
||||
#include "proto.h"
|
||||
|
||||
#ifdef ENABLE_HISTORIES
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef ENABLE_HISTORIES
|
||||
|
||||
#ifndef SEARCH_HISTORY
|
||||
#define SEARCH_HISTORY "search_history"
|
||||
#endif
|
||||
@@ -48,17 +48,17 @@ static poshiststruct *position_history = NULL;
|
||||
void history_init(void)
|
||||
{
|
||||
search_history = make_new_node(NULL);
|
||||
search_history->data = mallocstrcpy(NULL, "");
|
||||
search_history->data = copy_of("");
|
||||
searchtop = search_history;
|
||||
searchbot = search_history;
|
||||
|
||||
replace_history = make_new_node(NULL);
|
||||
replace_history->data = mallocstrcpy(NULL, "");
|
||||
replace_history->data = copy_of("");
|
||||
replacetop = replace_history;
|
||||
replacebot = replace_history;
|
||||
|
||||
execute_history = make_new_node(NULL);
|
||||
execute_history->data = mallocstrcpy(NULL, "");
|
||||
execute_history->data = copy_of("");
|
||||
executetop = execute_history;
|
||||
executebot = execute_history;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ void update_history(linestruct **item, const char *text)
|
||||
(*hbot)->data = mallocstrcpy((*hbot)->data, text);
|
||||
splice_node(*hbot, make_new_node(*hbot));
|
||||
*hbot = (*hbot)->next;
|
||||
(*hbot)->data = mallocstrcpy(NULL, "");
|
||||
(*hbot)->data = copy_of("");
|
||||
|
||||
/* Indicate that the history needs to be saved on exit. */
|
||||
history_changed = TRUE;
|
||||
@@ -229,19 +229,6 @@ char *get_history_completion(linestruct **h, char *s, size_t len)
|
||||
}
|
||||
#endif /* ENABLE_TABCOMP */
|
||||
|
||||
void history_error(const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, msg);
|
||||
vfprintf(stderr, _(msg), ap);
|
||||
va_end(ap);
|
||||
|
||||
fprintf(stderr, _("\nPress Enter to continue\n"));
|
||||
while (getchar() != '\n')
|
||||
;
|
||||
}
|
||||
|
||||
/* Check whether we have or could make a directory for history files. */
|
||||
bool have_statedir(void)
|
||||
{
|
||||
@@ -280,14 +267,14 @@ bool have_statedir(void)
|
||||
free(statepath);
|
||||
}
|
||||
if (mkdir(statedir, S_IRWXU) == -1) {
|
||||
history_error(N_("Unable to create directory %s: %s\n"
|
||||
jot_error(N_("Unable to create directory %s: %s\n"
|
||||
"It is required for saving/loading "
|
||||
"search history or cursor positions.\n"),
|
||||
statedir, strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
} else if (!S_ISDIR(dirstat.st_mode)) {
|
||||
history_error(N_("Path %s is not a directory and needs to be.\n"
|
||||
jot_error(N_("Path %s is not a directory and needs to be.\n"
|
||||
"Nano will be unable to load or save "
|
||||
"search history or cursor positions.\n"),
|
||||
statedir);
|
||||
@@ -308,7 +295,7 @@ void load_history(void)
|
||||
if (errno != ENOENT) {
|
||||
/* When reading failed, don't save history when we quit. */
|
||||
UNSET(HISTORYLOG);
|
||||
history_error(N_("Error reading %s: %s"), histname,
|
||||
jot_error(N_("Error reading %s: %s"), histname,
|
||||
strerror(errno));
|
||||
}
|
||||
} else {
|
||||
@@ -404,7 +391,7 @@ void load_poshistory(void)
|
||||
if (errno != ENOENT) {
|
||||
/* When reading failed, don't save history when we quit. */
|
||||
UNSET(POSITIONLOG);
|
||||
history_error(N_("Error reading %s: %s"), poshistname, strerror(errno));
|
||||
jot_error(N_("Error reading %s: %s"), poshistname, strerror(errno));
|
||||
}
|
||||
} else {
|
||||
char *line = NULL, *lineptr, *xptr;
|
||||
@@ -414,7 +401,7 @@ void load_poshistory(void)
|
||||
|
||||
/* Read and parse each line, and store the extracted data. */
|
||||
while ((read = getline(&line, &buf_len, hisfile)) > 5) {
|
||||
/* Decode nulls as embedded newlines. */
|
||||
/* Decode NULs as embedded newlines. */
|
||||
unsunder(line, read);
|
||||
|
||||
/* Find where the x index and line number are in the line. */
|
||||
@@ -431,7 +418,7 @@ void load_poshistory(void)
|
||||
|
||||
/* Create a new position record. */
|
||||
newrecord = (poshiststruct *)nmalloc(sizeof(poshiststruct));
|
||||
newrecord->filename = mallocstrcpy(NULL, line);
|
||||
newrecord->filename = copy_of(line);
|
||||
newrecord->lineno = atoi(lineptr);
|
||||
newrecord->xno = atoi(xptr);
|
||||
newrecord->next = NULL;
|
||||
@@ -484,7 +471,7 @@ void save_poshistory(void)
|
||||
posptr->filename, posptr->lineno, posptr->xno);
|
||||
length = strlen(path_and_place);
|
||||
|
||||
/* Encode newlines in filenames as nulls. */
|
||||
/* Encode newlines in filenames as NULs. */
|
||||
sunder(path_and_place);
|
||||
/* Restore the terminating newline. */
|
||||
path_and_place[length - 1] = '\n';
|
||||
@@ -528,7 +515,7 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
|
||||
poshiststruct *posptr, *theone, *posprev = NULL;
|
||||
char *fullpath = get_full_path(filename);
|
||||
|
||||
if (fullpath == NULL || fullpath[strlen(fullpath) - 1] == '/') {
|
||||
if (fullpath == NULL || *filename == '\0') {
|
||||
free(fullpath);
|
||||
return;
|
||||
}
|
||||
@@ -563,7 +550,7 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
|
||||
* not at the end, move the matching one to the end. */
|
||||
if (theone == NULL) {
|
||||
theone = (poshiststruct *)nmalloc(sizeof(poshiststruct));
|
||||
theone->filename = mallocstrcpy(NULL, fullpath);
|
||||
theone->filename = copy_of(fullpath);
|
||||
if (position_history == NULL)
|
||||
position_history = theone;
|
||||
else
|
||||
|
||||
12
src/move.c
12
src/move.c
@@ -109,7 +109,7 @@ void set_proper_index_and_pww(size_t *leftedge, size_t target, bool forward)
|
||||
openfile->placewewant = *leftedge + target;
|
||||
}
|
||||
|
||||
/* Move up nearly one screenful. */
|
||||
/* Move up almost one screenful. */
|
||||
void do_page_up(void)
|
||||
{
|
||||
int mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
|
||||
@@ -139,7 +139,7 @@ void do_page_up(void)
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
/* Move down nearly one screenful. */
|
||||
/* Move down almost one screenful. */
|
||||
void do_page_down(void)
|
||||
{
|
||||
int mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
|
||||
@@ -534,7 +534,7 @@ void do_down(void)
|
||||
}
|
||||
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
|
||||
/* Scroll up one line or chunk without scrolling the cursor. */
|
||||
/* Scroll up one line or chunk without moving the cursor textwise. */
|
||||
void do_scroll_up(void)
|
||||
{
|
||||
/* When the top of the file is onscreen, we can't scroll. */
|
||||
@@ -548,18 +548,18 @@ void do_scroll_up(void)
|
||||
edit_scroll(BACKWARD);
|
||||
}
|
||||
|
||||
/* Scroll down one line or chunk without scrolling the cursor. */
|
||||
/* Scroll down one line or chunk without moving the cursor textwise. */
|
||||
void do_scroll_down(void)
|
||||
{
|
||||
if (openfile->current_y == 0)
|
||||
do_down();
|
||||
|
||||
if (openfile->edittop->next != NULL
|
||||
if (editwinrows > 1 && (openfile->edittop->next != NULL
|
||||
#ifndef NANO_TINY
|
||||
|| chunk_for(openfile->firstcolumn, openfile->edittop) <
|
||||
number_of_chunks_in(openfile->edittop)
|
||||
#endif
|
||||
)
|
||||
))
|
||||
edit_scroll(FORWARD);
|
||||
}
|
||||
#endif
|
||||
|
||||
254
src/nano.c
254
src/nano.c
@@ -53,8 +53,8 @@ static int oldinterval = -1;
|
||||
/* Used to store the user's original mouse click interval. */
|
||||
#endif
|
||||
#ifdef HAVE_TERMIOS_H
|
||||
static struct termios oldterm;
|
||||
/* The user's original terminal settings. */
|
||||
static struct termios original_state;
|
||||
/* The original settings of the user's terminal. */
|
||||
#else
|
||||
# define tcsetattr(...)
|
||||
# define tcgetattr(...)
|
||||
@@ -100,7 +100,7 @@ linestruct *copy_node(const linestruct *src)
|
||||
{
|
||||
linestruct *dst = nmalloc(sizeof(linestruct));
|
||||
|
||||
dst->data = mallocstrcpy(NULL, src->data);
|
||||
dst->data = copy_of(src->data);
|
||||
dst->next = src->next;
|
||||
dst->prev = src->prev;
|
||||
dst->lineno = src->lineno;
|
||||
@@ -127,33 +127,33 @@ void splice_node(linestruct *afterthis, linestruct *newnode)
|
||||
}
|
||||
|
||||
/* Disconnect a node from a linked list of linestructs and delete it. */
|
||||
void unlink_node(linestruct *fileptr)
|
||||
void unlink_node(linestruct *line)
|
||||
{
|
||||
if (fileptr->prev != NULL)
|
||||
fileptr->prev->next = fileptr->next;
|
||||
if (fileptr->next != NULL)
|
||||
fileptr->next->prev = fileptr->prev;
|
||||
if (line->prev != NULL)
|
||||
line->prev->next = line->next;
|
||||
if (line->next != NULL)
|
||||
line->next->prev = line->prev;
|
||||
|
||||
/* Update filebot when removing a node at the end of file. */
|
||||
if (openfile && openfile->filebot == fileptr)
|
||||
openfile->filebot = fileptr->prev;
|
||||
if (openfile && openfile->filebot == line)
|
||||
openfile->filebot = line->prev;
|
||||
|
||||
delete_node(fileptr);
|
||||
delete_node(line);
|
||||
}
|
||||
|
||||
/* Free the data structures in the given node. */
|
||||
void delete_node(linestruct *fileptr)
|
||||
void delete_node(linestruct *line)
|
||||
{
|
||||
#ifdef ENABLE_WRAPPING
|
||||
/* If the spill-over line for hard-wrapping is deleted... */
|
||||
if (fileptr == openfile->spillage_line)
|
||||
if (line == openfile->spillage_line)
|
||||
openfile->spillage_line = NULL;
|
||||
#endif
|
||||
free(fileptr->data);
|
||||
free(line->data);
|
||||
#ifdef ENABLE_COLOR
|
||||
free(fileptr->multidata);
|
||||
free(line->multidata);
|
||||
#endif
|
||||
free(fileptr);
|
||||
free(line);
|
||||
}
|
||||
|
||||
/* Duplicate an entire linked list of linestructs. */
|
||||
@@ -226,24 +226,24 @@ void partition_buffer(linestruct *top, size_t top_x,
|
||||
* top of the partition from it, and save the text before top_x. */
|
||||
foreline = top->prev;
|
||||
top->prev = NULL;
|
||||
antedata = mallocstrncpy(NULL, top->data, top_x + 1);
|
||||
antedata = measured_copy(top->data, top_x + 1);
|
||||
antedata[top_x] = '\0';
|
||||
|
||||
/* Remember which line is below the bottom of the partition, detach the
|
||||
* bottom of the partition from it, and save the text after bot_x. */
|
||||
hindline = bot->next;
|
||||
bot->next = NULL;
|
||||
postdata = mallocstrcpy(NULL, bot->data + bot_x);
|
||||
postdata = copy_of(bot->data + bot_x);
|
||||
|
||||
/* At the end of the partition, remove all text after bot_x. */
|
||||
bot->data[bot_x] = '\0';
|
||||
|
||||
/* At the beginning of the partition, remove all text before top_x. */
|
||||
charmove(top->data, top->data + top_x, strlen(top->data) - top_x + 1);
|
||||
memmove(top->data, top->data + top_x, strlen(top->data) - top_x + 1);
|
||||
}
|
||||
|
||||
/* Unpartition the current buffer so that it is complete again. */
|
||||
void unpartition_buffer()
|
||||
void unpartition_buffer(void)
|
||||
{
|
||||
/* Reattach the line that was above the top of the partition. */
|
||||
openfile->filetop->prev = foreline;
|
||||
@@ -253,9 +253,9 @@ void unpartition_buffer()
|
||||
/* Restore the text that was on the first partition line before its start. */
|
||||
openfile->filetop->data = charealloc(openfile->filetop->data,
|
||||
strlen(antedata) + strlen(openfile->filetop->data) + 1);
|
||||
charmove(openfile->filetop->data + strlen(antedata),
|
||||
memmove(openfile->filetop->data + strlen(antedata),
|
||||
openfile->filetop->data, strlen(openfile->filetop->data) + 1);
|
||||
strncpy(openfile->filetop->data, antedata, strlen(antedata));
|
||||
memcpy(openfile->filetop->data, antedata, strlen(antedata));
|
||||
free(antedata);
|
||||
antedata = NULL;
|
||||
|
||||
@@ -288,10 +288,8 @@ void extract(linestruct *top, size_t top_x, linestruct *bot, size_t bot_x)
|
||||
bool mark_inside = FALSE;
|
||||
bool same_line = FALSE;
|
||||
|
||||
if (top == bot && top_x == bot_x) {
|
||||
statusline(ALERT, "Extracting nothing -- please report a bug");
|
||||
if (top == bot && top_x == bot_x)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Partition the buffer so that it contains only the text from
|
||||
@@ -344,7 +342,7 @@ void extract(linestruct *top, size_t top_x, linestruct *bot, size_t bot_x)
|
||||
|
||||
/* Since the text has now been saved, remove it from the file buffer. */
|
||||
openfile->filetop = make_new_node(NULL);
|
||||
openfile->filetop->data = mallocstrcpy(NULL, "");
|
||||
openfile->filetop->data = copy_of("");
|
||||
openfile->filebot = openfile->filetop;
|
||||
|
||||
/* Restore the current line and cursor position. If the mark begins
|
||||
@@ -465,11 +463,15 @@ void print_view_warning(void)
|
||||
statusbar(_("Key is invalid in view mode"));
|
||||
}
|
||||
|
||||
/* Indicate that something is disabled in restricted mode. */
|
||||
void show_restricted_warning(void)
|
||||
/* When in restricted mode, show a warning and return TRUE. */
|
||||
bool in_restricted_mode(void)
|
||||
{
|
||||
statusbar(_("This function is disabled in restricted mode"));
|
||||
beep();
|
||||
if (ISSET(RESTRICTED)) {
|
||||
statusbar(_("This function is disabled in restricted mode"));
|
||||
beep();
|
||||
return TRUE;
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifndef ENABLE_HELP
|
||||
@@ -500,9 +502,9 @@ void finish(void)
|
||||
endwin();
|
||||
|
||||
/* Restore the old terminal settings. */
|
||||
tcsetattr(0, TCSANOW, &oldterm);
|
||||
tcsetattr(0, TCSANOW, &original_state);
|
||||
|
||||
#ifdef ENABLE_NANORC
|
||||
#if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES)
|
||||
display_rcfile_errors();
|
||||
#endif
|
||||
|
||||
@@ -531,7 +533,7 @@ void die(const char *msg, ...)
|
||||
endwin();
|
||||
|
||||
/* Restore the old terminal settings. */
|
||||
tcsetattr(0, TCSANOW, &oldterm);
|
||||
tcsetattr(0, TCSANOW, &original_state);
|
||||
|
||||
#ifdef ENABLE_NANORC
|
||||
display_rcfile_errors();
|
||||
@@ -651,11 +653,12 @@ void window_init(void)
|
||||
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
/* Set up the wrapping point, accounting for screen width when negative. */
|
||||
wrap_at = fill;
|
||||
if (wrap_at <= 0)
|
||||
wrap_at += COLS;
|
||||
if (wrap_at < 0)
|
||||
if (COLS + fill < 0)
|
||||
wrap_at = 0;
|
||||
else if (fill <= 0)
|
||||
wrap_at = COLS + fill;
|
||||
else
|
||||
wrap_at = fill;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -685,7 +688,18 @@ void mouse_init(void)
|
||||
/* Print the usage line for the given option to the screen. */
|
||||
void print_opt(const char *shortflag, const char *longflag, const char *desc)
|
||||
{
|
||||
printf(" %-14s %-23s %s\n", shortflag, longflag, _(desc));
|
||||
int firstwidth = breadth(shortflag);
|
||||
int secondwidth = breadth(longflag);
|
||||
|
||||
printf(" %s", shortflag);
|
||||
if (firstwidth < 14)
|
||||
printf("%*s", 14 - firstwidth, " ");
|
||||
|
||||
printf(" %s", longflag);
|
||||
if (secondwidth < 24)
|
||||
printf("%*s", 24 - secondwidth, " ");
|
||||
|
||||
printf("%s\n", _(desc));
|
||||
}
|
||||
|
||||
/* Explain how to properly use nano and its command-line options. */
|
||||
@@ -698,7 +712,7 @@ void usage(void)
|
||||
"a '+' before the filename. The column number can be added after a comma.\n"));
|
||||
printf(_("When a filename is '-', nano reads data from standard input.\n\n"));
|
||||
/* TRANSLATORS: The next three are column headers of the --help output. */
|
||||
printf("%-16s%-26s%s\n", _("Option"), _("Long option"), _("Meaning"));
|
||||
print_opt(_("Option"), _("Long option"), N_("Meaning"));
|
||||
#ifndef NANO_TINY
|
||||
/* TRANSLATORS: The next forty or so strings are option descriptions
|
||||
* for the --help output. Try to keep them at most 40 characters. */
|
||||
@@ -730,7 +744,7 @@ void usage(void)
|
||||
print_opt("-I", "--ignorercfiles", N_("Don't look at nanorc files"));
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-J <number>", "--guidestripe=<number>",
|
||||
print_opt(_("-J <number>"), _("--guidestripe=<number>"),
|
||||
N_("Show a guiding bar at this column"));
|
||||
#endif
|
||||
print_opt("-K", "--rawsequences",
|
||||
@@ -754,7 +768,9 @@ void usage(void)
|
||||
#endif
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
print_opt(_("-Q <regex>"), _("--quotestr=<regex>"),
|
||||
N_("Regular expression to match quoting"));
|
||||
/* TRANSLATORS: This refers to email quoting,
|
||||
* like the > in: > quoted text. */
|
||||
N_("Regular expression to match quoting"));
|
||||
#endif
|
||||
if (!ISSET(RESTRICTED))
|
||||
print_opt("-R", "--restricted", N_("Restricted mode"));
|
||||
@@ -1070,7 +1086,7 @@ void reconnect_and_store_state(void)
|
||||
|
||||
/* If input was not cut short, store the current state of the terminal. */
|
||||
if (!control_C_was_pressed)
|
||||
tcgetattr(0, &oldterm);
|
||||
tcgetattr(0, &original_state);
|
||||
}
|
||||
|
||||
/* Read whatever comes from standard input into a new buffer. */
|
||||
@@ -1080,7 +1096,7 @@ bool scoop_stdin(void)
|
||||
|
||||
/* Exit from curses mode and put the terminal into its original state. */
|
||||
endwin();
|
||||
tcsetattr(0, TCSANOW, &oldterm);
|
||||
tcsetattr(0, TCSANOW, &original_state);
|
||||
|
||||
/* When input comes from a terminal, show a helpful message. */
|
||||
if (isatty(STANDARD_INPUT))
|
||||
@@ -1205,7 +1221,7 @@ RETSIGTYPE do_suspend(int signal)
|
||||
fflush(stdout);
|
||||
|
||||
/* Restore the old terminal settings. */
|
||||
tcsetattr(0, TCSANOW, &oldterm);
|
||||
tcsetattr(0, TCSANOW, &original_state);
|
||||
|
||||
/* The suspend keystroke must not elicit cursor-position display. */
|
||||
suppress_cursorpos=TRUE;
|
||||
@@ -1328,10 +1344,8 @@ void do_toggle(int flag)
|
||||
{
|
||||
bool enabled;
|
||||
|
||||
if (flag == SUSPEND && ISSET(RESTRICTED)) {
|
||||
show_restricted_warning();
|
||||
if (flag == SUSPEND && in_restricted_mode())
|
||||
return;
|
||||
}
|
||||
|
||||
TOGGLE(flag);
|
||||
focusing = FALSE;
|
||||
@@ -1380,12 +1394,12 @@ void do_toggle(int flag)
|
||||
void disable_extended_io(void)
|
||||
{
|
||||
#ifdef HAVE_TERMIOS_H
|
||||
struct termios term = {0};
|
||||
struct termios settings = {0};
|
||||
|
||||
tcgetattr(0, &term);
|
||||
term.c_lflag &= ~IEXTEN;
|
||||
term.c_oflag &= ~OPOST;
|
||||
tcsetattr(0, TCSANOW, &term);
|
||||
tcgetattr(0, &settings);
|
||||
settings.c_lflag &= ~IEXTEN;
|
||||
settings.c_oflag &= ~OPOST;
|
||||
tcsetattr(0, TCSANOW, &settings);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1393,11 +1407,11 @@ void disable_extended_io(void)
|
||||
void disable_kb_interrupt(void)
|
||||
{
|
||||
#ifdef HAVE_TERMIOS_H
|
||||
struct termios term = {0};
|
||||
struct termios settings = {0};
|
||||
|
||||
tcgetattr(0, &term);
|
||||
term.c_lflag &= ~ISIG;
|
||||
tcsetattr(0, TCSANOW, &term);
|
||||
tcgetattr(0, &settings);
|
||||
settings.c_lflag &= ~ISIG;
|
||||
tcsetattr(0, TCSANOW, &settings);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1405,11 +1419,11 @@ void disable_kb_interrupt(void)
|
||||
void enable_kb_interrupt(void)
|
||||
{
|
||||
#ifdef HAVE_TERMIOS_H
|
||||
struct termios term = {0};
|
||||
struct termios settings = {0};
|
||||
|
||||
tcgetattr(0, &term);
|
||||
term.c_lflag |= ISIG;
|
||||
tcsetattr(0, TCSANOW, &term);
|
||||
tcgetattr(0, &settings);
|
||||
settings.c_lflag |= ISIG;
|
||||
tcsetattr(0, TCSANOW, &settings);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1417,11 +1431,11 @@ void enable_kb_interrupt(void)
|
||||
void disable_flow_control(void)
|
||||
{
|
||||
#ifdef HAVE_TERMIOS_H
|
||||
struct termios term;
|
||||
struct termios settings;
|
||||
|
||||
tcgetattr(0, &term);
|
||||
term.c_iflag &= ~IXON;
|
||||
tcsetattr(0, TCSANOW, &term);
|
||||
tcgetattr(0, &settings);
|
||||
settings.c_iflag &= ~IXON;
|
||||
tcsetattr(0, TCSANOW, &settings);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1429,11 +1443,11 @@ void disable_flow_control(void)
|
||||
void enable_flow_control(void)
|
||||
{
|
||||
#ifdef HAVE_TERMIOS_H
|
||||
struct termios term;
|
||||
struct termios settings;
|
||||
|
||||
tcgetattr(0, &term);
|
||||
term.c_iflag |= IXON;
|
||||
tcsetattr(0, TCSANOW, &term);
|
||||
tcgetattr(0, &settings);
|
||||
settings.c_iflag |= IXON;
|
||||
tcsetattr(0, TCSANOW, &settings);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1454,27 +1468,27 @@ void terminal_init(void)
|
||||
* disable the special control keys and interpretation of the flow
|
||||
* control characters using termios, save the terminal state after
|
||||
* the first call, and restore it on subsequent calls. */
|
||||
static struct termios newterm;
|
||||
static bool newterm_set = FALSE;
|
||||
static struct termios desired_state;
|
||||
static bool have_new_state = FALSE;
|
||||
|
||||
if (!newterm_set) {
|
||||
if (!have_new_state) {
|
||||
#endif
|
||||
raw();
|
||||
nonl();
|
||||
noecho();
|
||||
disable_extended_io();
|
||||
disable_kb_interrupt();
|
||||
|
||||
if (ISSET(PRESERVE))
|
||||
enable_flow_control();
|
||||
|
||||
disable_kb_interrupt();
|
||||
#ifdef USE_SLANG
|
||||
if (!ISSET(PRESERVE))
|
||||
else
|
||||
disable_flow_control();
|
||||
|
||||
tcgetattr(0, &newterm);
|
||||
newterm_set = TRUE;
|
||||
tcgetattr(0, &desired_state);
|
||||
have_new_state = TRUE;
|
||||
} else
|
||||
tcsetattr(0, TCSANOW, &newterm);
|
||||
tcsetattr(0, TCSANOW, &desired_state);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1799,7 +1813,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
output[i] = '\n';
|
||||
|
||||
/* Get the next multibyte character. */
|
||||
charlen = parse_mbchar(output + i, onechar, NULL);
|
||||
charlen = collect_char(output + i, onechar);
|
||||
|
||||
i += charlen;
|
||||
|
||||
@@ -1810,7 +1824,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
/* Make room for the new character and copy it into the line. */
|
||||
openfile->current->data = charealloc(openfile->current->data,
|
||||
current_len + charlen + 1);
|
||||
charmove(openfile->current->data + openfile->current_x + charlen,
|
||||
memmove(openfile->current->data + openfile->current_x + charlen,
|
||||
openfile->current->data + openfile->current_x,
|
||||
current_len - openfile->current_x + 1);
|
||||
strncpy(openfile->current->data + openfile->current_x, onechar,
|
||||
@@ -1825,7 +1839,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
if (openfile->last_action != ADD ||
|
||||
openfile->current_undo->mark_begin_lineno != openfile->current->lineno ||
|
||||
openfile->current_undo->mark_begin_x != openfile->current_x)
|
||||
add_undo(ADD);
|
||||
add_undo(ADD, NULL);
|
||||
|
||||
/* Note that current_x has not yet been incremented. */
|
||||
if (openfile->current == openfile->mark &&
|
||||
@@ -1993,7 +2007,7 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
/* Back up the terminal settings so that they can be restored. */
|
||||
tcgetattr(0, &oldterm);
|
||||
tcgetattr(0, &original_state);
|
||||
|
||||
/* Get the state of standard input and ensure it uses blocking mode. */
|
||||
stdin_flags = fcntl(0, F_GETFL, 0);
|
||||
@@ -2317,18 +2331,8 @@ int main(int argc, char **argv)
|
||||
#ifdef ENABLE_SPELLER
|
||||
alt_speller = NULL;
|
||||
#endif
|
||||
|
||||
//#define TIMEIT 12
|
||||
#ifdef TIMEIT
|
||||
#include <time.h>
|
||||
clock_t start = clock();
|
||||
#endif
|
||||
/* Now process the system's and the user's nanorc file, if any. */
|
||||
do_rcfiles();
|
||||
#ifdef TIMEIT
|
||||
fprintf(stderr, "Took: %.3f\n",
|
||||
(double)(clock() - start) / CLOCKS_PER_SEC);
|
||||
#endif
|
||||
|
||||
/* If the backed-up command-line options have a value, restore them. */
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
@@ -2440,11 +2444,11 @@ int main(int argc, char **argv)
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
/* Set the default value for things that weren't specified. */
|
||||
if (punct == NULL)
|
||||
punct = mallocstrcpy(NULL, "!.?");
|
||||
punct = copy_of("!.?");
|
||||
if (brackets == NULL)
|
||||
brackets = mallocstrcpy(NULL, "\"')>]}");
|
||||
brackets = copy_of("\"')>]}");
|
||||
if (quotestr == NULL)
|
||||
quotestr = mallocstrcpy(NULL, "^([ \t]*([!#%:;>|}]|/{2}))+");
|
||||
quotestr = copy_of("^([ \t]*([!#%:;>|}]|/{2}))+");
|
||||
|
||||
/* Compile the quoting regex, and exit when it's invalid. */
|
||||
quoterc = regcomp("ereg, quotestr, NANO_REG_EXTENDED);
|
||||
@@ -2468,14 +2472,14 @@ int main(int argc, char **argv)
|
||||
const char *spellenv = getenv("SPELL");
|
||||
|
||||
if (spellenv != NULL)
|
||||
alt_speller = mallocstrcpy(NULL, spellenv);
|
||||
alt_speller = copy_of(spellenv);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If matchbrackets wasn't specified, set its default value. */
|
||||
if (matchbrackets == NULL)
|
||||
matchbrackets = mallocstrcpy(NULL, "(<[{)>]}");
|
||||
matchbrackets = copy_of("(<[{)>]}");
|
||||
|
||||
/* If the whitespace option wasn't specified, set its default value. */
|
||||
if (whitespace == NULL) {
|
||||
@@ -2483,13 +2487,13 @@ int main(int argc, char **argv)
|
||||
if (using_utf8()) {
|
||||
/* A tab is shown as a Right-Pointing Double Angle Quotation Mark
|
||||
* (U+00BB), and a space as a Middle Dot (U+00B7). */
|
||||
whitespace = mallocstrcpy(NULL, "\xC2\xBB\xC2\xB7");
|
||||
whitespace = copy_of("\xC2\xBB\xC2\xB7");
|
||||
whitelen[0] = 2;
|
||||
whitelen[1] = 2;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
whitespace = mallocstrcpy(NULL, ">.");
|
||||
whitespace = copy_of(">.");
|
||||
whitelen[0] = 1;
|
||||
whitelen[1] = 1;
|
||||
}
|
||||
@@ -2497,7 +2501,7 @@ int main(int argc, char **argv)
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Initialize the search string. */
|
||||
last_search = mallocstrcpy(NULL, "");
|
||||
last_search = copy_of("");
|
||||
UNSET(BACKWARDS_SEARCH);
|
||||
|
||||
/* If tabsize wasn't specified, set its default value. */
|
||||
@@ -2583,10 +2587,37 @@ int main(int argc, char **argv)
|
||||
/* Read the files mentioned on the command line into new buffers. */
|
||||
while (optind < argc && (!openfile || read_them_all)) {
|
||||
ssize_t givenline = 0, givencol = 0;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
char *searchstring = NULL;
|
||||
#endif
|
||||
/* If there's a +LINE[,COLUMN] argument here, eat it up. */
|
||||
if (optind < argc - 1 && argv[optind][0] == '+') {
|
||||
if (!parse_line_column(&argv[optind++][1], &givenline, &givencol))
|
||||
int n = 1;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
while (isalpha(argv[optind][n])) {
|
||||
switch (argv[optind][n++]) {
|
||||
case 'c': SET(CASE_SENSITIVE); break;
|
||||
case 'C': UNSET(CASE_SENSITIVE); break;
|
||||
case 'r': SET(USE_REGEXP); break;
|
||||
case 'R': UNSET(USE_REGEXP); break;
|
||||
default:
|
||||
statusline(ALERT, _("Invalid search modifier '%c'"),
|
||||
argv[optind][n - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
if (argv[optind][n] == '/' || argv[optind][n] == '?') {
|
||||
if (argv[optind][n + 1]) {
|
||||
searchstring = copy_of(&argv[optind][n + 1]);
|
||||
if (argv[optind][n] == '?')
|
||||
SET(BACKWARDS_SEARCH);
|
||||
} else if (n == 1)
|
||||
statusline(ALERT, _("Empty search string"));
|
||||
optind++;
|
||||
} else
|
||||
#endif
|
||||
if (!parse_line_column(&argv[optind++][n], &givenline, &givencol))
|
||||
statusline(ALERT, _("Invalid line or column number"));
|
||||
}
|
||||
|
||||
@@ -2602,6 +2633,23 @@ int main(int argc, char **argv)
|
||||
/* If a position was given on the command line, go there. */
|
||||
if (givenline != 0 || givencol != 0)
|
||||
do_gotolinecolumn(givenline, givencol, FALSE, FALSE);
|
||||
#ifndef NANO_TINY
|
||||
else if (searchstring != NULL) {
|
||||
if (ISSET(USE_REGEXP))
|
||||
regexp_init(searchstring);
|
||||
if (!findnextstr(searchstring, FALSE, JUSTFIND, NULL,
|
||||
ISSET(BACKWARDS_SEARCH), openfile->filetop, 0))
|
||||
not_found_msg(searchstring);
|
||||
else if (lastmessage == HUSH)
|
||||
wipe_statusbar();
|
||||
openfile->placewewant = xplustabs();
|
||||
if (ISSET(USE_REGEXP))
|
||||
tidy_up_after_search();
|
||||
free(last_search);
|
||||
last_search = searchstring;
|
||||
searchstring = NULL;
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_HISTORIES
|
||||
else if (ISSET(POSITIONLOG) && openfile->filename[0] != '\0') {
|
||||
ssize_t savedline, savedcol;
|
||||
@@ -2637,8 +2685,8 @@ int main(int argc, char **argv)
|
||||
prepare_for_display();
|
||||
|
||||
#ifdef ENABLE_NANORC
|
||||
if (rcfile_with_errors != NULL)
|
||||
statusline(ALERT, _("Mistakes in '%s'"), rcfile_with_errors);
|
||||
if (startup_problem != NULL)
|
||||
statusline(ALERT, startup_problem);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_HELP
|
||||
|
||||
74
src/nano.h
74
src/nano.h
@@ -19,9 +19,6 @@
|
||||
* *
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef NANO_H
|
||||
#define NANO_H 1
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
@@ -59,11 +56,9 @@
|
||||
#define ISSET(flag) ((FLAGS(flag) & FLAGMASK(flag)) != 0)
|
||||
#define TOGGLE(flag) FLAGS(flag) ^= FLAGMASK(flag)
|
||||
|
||||
/* Macros for character allocation and more. */
|
||||
#define charalloc(howmuch) (char *)nmalloc((howmuch) * sizeof(char))
|
||||
#define charealloc(ptr, howmuch) (char *)nrealloc(ptr, (howmuch) * sizeof(char))
|
||||
#define charmove(dest, src, n) memmove(dest, src, (n) * sizeof(char))
|
||||
#define charset(dest, src, n) memset(dest, src, (n) * sizeof(char))
|
||||
/* Macros for allocation of character strings. */
|
||||
#define charalloc(howmuch) (char *)nmalloc(howmuch)
|
||||
#define charealloc(ptr, howmuch) (char *)nrealloc(ptr, howmuch)
|
||||
|
||||
/* In UTF-8 a character is at most six bytes long. */
|
||||
#ifdef ENABLE_UTF8
|
||||
@@ -149,7 +144,7 @@
|
||||
/* Enumeration types. */
|
||||
typedef enum {
|
||||
NIX_FILE, DOS_FILE, MAC_FILE
|
||||
} file_format;
|
||||
} format_type;
|
||||
|
||||
typedef enum {
|
||||
HUSH, NOTICE, MILD, ALERT
|
||||
@@ -236,6 +231,10 @@ typedef struct syntaxtype {
|
||||
/* The list of libmagic results that this syntax applies to. */
|
||||
char *linter;
|
||||
/* The command with which to lint this type of file. */
|
||||
char *formatter;
|
||||
/* The command with which to format/modify/arrange this type of file. */
|
||||
char *tab;
|
||||
/* What the Tab key should produce; NULL for default behavior. */
|
||||
#ifdef ENABLE_COMMENT
|
||||
char *comment;
|
||||
/* The line comment prefix (and postfix) for this type of file. */
|
||||
@@ -295,41 +294,43 @@ typedef struct linestruct {
|
||||
} linestruct;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
typedef struct undo_group {
|
||||
typedef struct groupstruct {
|
||||
ssize_t top_line;
|
||||
/* First line of group. */
|
||||
ssize_t bottom_line;
|
||||
/* Last line of group. */
|
||||
char **indentations;
|
||||
/* String data used to restore the affected lines; one per line. */
|
||||
struct undo_group *next;
|
||||
} undo_group;
|
||||
struct groupstruct *next;
|
||||
/* The next group, if any. */
|
||||
} groupstruct;
|
||||
|
||||
typedef struct undo {
|
||||
ssize_t lineno;
|
||||
typedef struct undostruct {
|
||||
undo_type type;
|
||||
/* What type of undo this was. */
|
||||
/* The operation type that this undo item is for. */
|
||||
int xflags;
|
||||
/* Some flag data to mark certain corner cases. */
|
||||
ssize_t lineno;
|
||||
/* The line number where the operation began or ended. */
|
||||
size_t begin;
|
||||
/* Where did this action begin or end. */
|
||||
/* The x position where the operation began or ended. */
|
||||
char *strdata;
|
||||
/* String type data we will use for copying the affected line back. */
|
||||
/* String data to help restore the affected line. */
|
||||
size_t wassize;
|
||||
/* The file size before the action. */
|
||||
size_t newsize;
|
||||
/* The file size after the action. */
|
||||
int xflags;
|
||||
/* Some flag data we need. */
|
||||
undo_group *grouping;
|
||||
groupstruct *grouping;
|
||||
/* Undo info specific to groups of lines. */
|
||||
linestruct *cutbuffer;
|
||||
/* Copy of the cutbuffer. */
|
||||
/* A copy of the cutbuffer. */
|
||||
ssize_t mark_begin_lineno;
|
||||
/* Mostly the line number of the current line; sometimes something else. */
|
||||
size_t mark_begin_x;
|
||||
/* The x position corresponding to the above line number. */
|
||||
struct undo *next;
|
||||
struct undostruct *next;
|
||||
/* A pointer to the undo item of the preceding action. */
|
||||
} undo;
|
||||
} undostruct;
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
#ifdef ENABLE_HISTORIES
|
||||
@@ -339,8 +340,9 @@ typedef struct poshiststruct {
|
||||
ssize_t lineno;
|
||||
/* Line number we left off on. */
|
||||
ssize_t xno;
|
||||
/* x position in the file we left off on. */
|
||||
/* The x position in the file we left off on. */
|
||||
struct poshiststruct *next;
|
||||
/* The next item of position history. */
|
||||
} poshiststruct;
|
||||
#endif
|
||||
|
||||
@@ -366,8 +368,6 @@ typedef struct openfilestruct {
|
||||
/* The file's x position we would like. */
|
||||
ssize_t current_y;
|
||||
/* The file's y-coordinate position. */
|
||||
bool modified;
|
||||
/* Whether the file has been modified. */
|
||||
struct stat *current_stat;
|
||||
/* The file's current stat information. */
|
||||
#ifdef ENABLE_WRAPPING
|
||||
@@ -381,19 +381,21 @@ typedef struct openfilestruct {
|
||||
/* The mark's x position in the above line. */
|
||||
mark_type kind_of_mark;
|
||||
/* Whether it is a soft (with Shift) or a hard mark. */
|
||||
file_format fmt;
|
||||
format_type fmt;
|
||||
/* The file's format -- Unix or DOS or Mac or mixed. */
|
||||
undo *undotop;
|
||||
char *lock_filename;
|
||||
/* The path of the lockfile, if we created one. */
|
||||
undostruct *undotop;
|
||||
/* The top of the undo list. */
|
||||
undo *current_undo;
|
||||
undostruct *current_undo;
|
||||
/* The current (i.e. next) level of undo. */
|
||||
undo *last_saved;
|
||||
undostruct *last_saved;
|
||||
/* The undo item at which the file was last saved. */
|
||||
undo_type last_action;
|
||||
/* The type of the last action the user performed. */
|
||||
char *lock_filename;
|
||||
/* The path of the lockfile, if we created one. */
|
||||
#endif
|
||||
bool modified;
|
||||
/* Whether the file has been modified. */
|
||||
#ifdef ENABLE_COLOR
|
||||
syntaxtype *syntax;
|
||||
/* The syntax struct for this file, if any. */
|
||||
@@ -605,6 +607,9 @@ enum
|
||||
#define SHIFT_DELETE 0x45D
|
||||
#define SHIFT_TAB 0x45F
|
||||
|
||||
/* A special keycode for when <Tab> is pressed while the mark is on. */
|
||||
#define INDENT_KEY 0x4F1
|
||||
|
||||
#ifdef USE_SLANG
|
||||
#ifdef ENABLE_UTF8
|
||||
#define KEY_BAD 0xFF /* Clipped error code. */
|
||||
@@ -626,9 +631,6 @@ enum
|
||||
#define WAS_MARKED_FORWARD (1<<5)
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* The maximum number of entries displayed in the main shortcut list. */
|
||||
#define MAIN_VISIBLE (((COLS + 40) / 20) * 2)
|
||||
|
||||
/* The default number of columns from end of line where wrapping occurs. */
|
||||
#define COLUMNS_FROM_EOL 8
|
||||
|
||||
@@ -647,5 +649,3 @@ enum
|
||||
|
||||
/* The largest size_t number that doesn't have the high bit set. */
|
||||
#define HIGHEST_POSITIVE ((~(size_t)0) >> 1)
|
||||
|
||||
#endif /* !NANO_H */
|
||||
|
||||
28
src/prompt.c
28
src/prompt.c
@@ -203,7 +203,7 @@ void do_statusbar_output(int *the_input, size_t input_len,
|
||||
output[j] = '\n';
|
||||
|
||||
/* Interpret the next multibyte character. */
|
||||
charlen = parse_mbchar(output + j, onechar, NULL);
|
||||
charlen = collect_char(output + j, onechar);
|
||||
|
||||
j += charlen;
|
||||
|
||||
@@ -213,7 +213,7 @@ void do_statusbar_output(int *the_input, size_t input_len,
|
||||
|
||||
/* Insert the typed character into the existing answer string. */
|
||||
answer = charealloc(answer, strlen(answer) + charlen + 1);
|
||||
charmove(answer + typing_x + charlen, answer + typing_x,
|
||||
memmove(answer + typing_x + charlen, answer + typing_x,
|
||||
strlen(answer) - typing_x + 1);
|
||||
strncpy(answer + typing_x, onechar, charlen);
|
||||
|
||||
@@ -255,7 +255,7 @@ void do_statusbar_delete(void)
|
||||
if (answer[typing_x] != '\0') {
|
||||
int charlen = char_length(answer + typing_x);
|
||||
|
||||
charmove(answer + typing_x, answer + typing_x + charlen,
|
||||
memmove(answer + typing_x, answer + typing_x + charlen,
|
||||
strlen(answer) - typing_x - charlen + 1);
|
||||
}
|
||||
}
|
||||
@@ -394,7 +394,7 @@ void draw_the_promptbar(void)
|
||||
|
||||
/* Color the promptbar over its full width. */
|
||||
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
blank_statusbar();
|
||||
mvwprintw(bottomwin, 0, 0, "%*s", COLS, " ");
|
||||
|
||||
mvwaddstr(bottomwin, 0, 0, prompt);
|
||||
waddch(bottomwin, ':');
|
||||
@@ -424,12 +424,12 @@ void draw_the_promptbar(void)
|
||||
void add_or_remove_pipe_symbol_from_answer(void)
|
||||
{
|
||||
if (answer[0] == '|') {
|
||||
charmove(answer, answer + 1, strlen(answer) + 1);
|
||||
memmove(answer, answer + 1, strlen(answer) + 1);
|
||||
if (typing_x > 0)
|
||||
typing_x--;
|
||||
} else {
|
||||
answer = charealloc(answer, strlen(answer) + 2);
|
||||
charmove(answer + 1, answer, strlen(answer) + 1);
|
||||
memmove(answer + 1, answer, strlen(answer) + 1);
|
||||
answer[0] = '|';
|
||||
typing_x++;
|
||||
}
|
||||
@@ -543,9 +543,9 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
}
|
||||
} else
|
||||
#endif /* ENABLE_HISTORIES */
|
||||
if (func == do_help_void) {
|
||||
if (func == do_help) {
|
||||
/* This key has a shortcut-list entry when it's used to go to
|
||||
* the help browser or display a message indicating that help
|
||||
* the help viewer or display a message indicating that help
|
||||
* is disabled, 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. */
|
||||
@@ -581,10 +581,10 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
*
|
||||
* 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
|
||||
* can be tab completed. The 'provided' 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, linestruct **history_list,
|
||||
int menu, const char *provided, linestruct **history_list,
|
||||
void (*refresh_func)(void), const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
@@ -597,8 +597,8 @@ int do_prompt(bool allow_tabs, bool allow_files,
|
||||
|
||||
bottombars(menu);
|
||||
|
||||
if (answer != curranswer || answer == NULL)
|
||||
answer = mallocstrcpy(answer, curranswer);
|
||||
if (answer != provided)
|
||||
answer = mallocstrcpy(answer, provided);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
redo_theprompt:
|
||||
@@ -695,9 +695,9 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
post_one_key(cancelshortcut->keystr, _("Cancel"), width);
|
||||
}
|
||||
|
||||
/* Color the statusbar over its full width and display the question. */
|
||||
/* Color the promptbar over its full width and display the question. */
|
||||
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
blank_statusbar();
|
||||
mvwprintw(bottomwin, 0, 0, "%*s", COLS, " ");
|
||||
mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));
|
||||
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
wnoutrefresh(bottomwin);
|
||||
|
||||
75
src/proto.h
75
src/proto.h
@@ -18,9 +18,6 @@
|
||||
* *
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef PROTO_H
|
||||
#define PROTO_H 1
|
||||
|
||||
#include "nano.h"
|
||||
|
||||
/* All external variables. See global.c for their descriptions. */
|
||||
@@ -55,6 +52,8 @@ extern bool more_than_one;
|
||||
|
||||
extern bool also_the_last;
|
||||
|
||||
extern bool is_shorter;
|
||||
|
||||
extern int didfind;
|
||||
|
||||
extern int controlleft, controlright;
|
||||
@@ -75,7 +74,8 @@ extern int shiftaltup, shiftaltdown;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
extern ssize_t fill, wrap_at;
|
||||
extern ssize_t fill;
|
||||
extern size_t wrap_at;
|
||||
#endif
|
||||
|
||||
extern char *last_search;
|
||||
@@ -173,8 +173,8 @@ extern int interface_color_pair[NUMBER_OF_ELEMENTS];
|
||||
|
||||
extern char *homedir;
|
||||
extern char *statedir;
|
||||
#ifdef ENABLE_NANORC
|
||||
extern char *rcfile_with_errors;
|
||||
#if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES)
|
||||
extern char *startup_problem;
|
||||
#endif
|
||||
|
||||
extern bool spotlighted;
|
||||
@@ -210,10 +210,14 @@ bool is_ascii_cntrl_char(int c);
|
||||
bool is_cntrl_mbchar(const char *c);
|
||||
bool is_word_mbchar(const char *c, bool allow_punct);
|
||||
char control_mbrep(const char *c, bool isdata);
|
||||
#ifdef ENABLE_UTF8
|
||||
int mbwidth(const char *c);
|
||||
#endif
|
||||
char *make_mbchar(long chr, int *chr_mb_len);
|
||||
int char_length(const char *pointer);
|
||||
int parse_mbchar(const char *buf, char *chr, size_t *col);
|
||||
size_t mbstrlen(const char *s);
|
||||
int collect_char(const char *buf, char *chr);
|
||||
int advance_over(const char *string, size_t *column);
|
||||
size_t step_left(const char *buf, size_t pos);
|
||||
size_t step_right(const char *buf, size_t pos);
|
||||
int mbstrcasecmp(const char *s1, const char *s2);
|
||||
@@ -221,7 +225,6 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n);
|
||||
char *mbstrcasestr(const char *haystack, const char *needle);
|
||||
char *revstrstr(const char *haystack, const char *needle, const char *index);
|
||||
char *mbrevstrcasestr(const char *haystack, const char *needle, const char *index);
|
||||
size_t mbstrlen(const char *s);
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_JUSTIFY)
|
||||
char *mbstrchr(const char *s, const char *c);
|
||||
#endif
|
||||
@@ -233,6 +236,7 @@ char *mbrevstrpbrk(const char *head, const char *accept, const char *index);
|
||||
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || defined(ENABLE_JUSTIFY))
|
||||
bool has_blank_char(const char *s);
|
||||
#endif
|
||||
bool white_string(const char *s);
|
||||
#ifdef ENABLE_UTF8
|
||||
bool is_valid_unicode(wchar_t wc);
|
||||
#endif
|
||||
@@ -242,8 +246,8 @@ bool is_valid_unicode(wchar_t wc);
|
||||
void set_colorpairs(void);
|
||||
void color_init(void);
|
||||
void color_update(void);
|
||||
void set_up_multicache(linestruct *line);
|
||||
void check_the_multis(linestruct *line);
|
||||
void alloc_multidata_if_needed(linestruct *fileptr);
|
||||
void precalc_multicolorinfo(void);
|
||||
#endif
|
||||
|
||||
@@ -255,7 +259,7 @@ void chop_previous_word(void);
|
||||
void chop_next_word(void);
|
||||
void cut_marked(bool *right_side_up);
|
||||
#endif
|
||||
void do_cut_text(bool copying, bool marked, bool until_eof, bool append);
|
||||
void do_snip(bool copying, bool marked, bool until_eof, bool append);
|
||||
bool is_cuttable(bool test_cliff);
|
||||
void cut_text(void);
|
||||
#ifndef NANO_TINY
|
||||
@@ -270,7 +274,8 @@ void make_new_buffer(void);
|
||||
void set_modified(void);
|
||||
bool open_buffer(const char *filename, bool new_buffer);
|
||||
#ifdef ENABLE_SPELLER
|
||||
bool replace_buffer(const char *filename, undo_type action, bool marked);
|
||||
bool replace_buffer(const char *filename, undo_type action, bool marked,
|
||||
const char *operation);
|
||||
#endif
|
||||
void prepare_for_display(void);
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
@@ -314,29 +319,24 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
|
||||
#endif
|
||||
|
||||
/* Some functions in global.c. */
|
||||
size_t length_of_list(int menu);
|
||||
const keystruct *first_sc_for(int menu, void (*func)(void));
|
||||
int the_code_for(void (*func)(void), int defaultval);
|
||||
size_t shown_entries_for(int menu);
|
||||
const keystruct *get_shortcut(int *kbinput);
|
||||
functionptrtype func_from_key(int *kbinput);
|
||||
int keycode_from_string(const char *keystring);
|
||||
void assign_keyinfo(keystruct *s, const char *keystring, const int keycode);
|
||||
void shortcut_init(void);
|
||||
const char *flagtostr(int flag);
|
||||
#ifdef ENABLE_NANORC
|
||||
keystruct *strtosc(const char *input);
|
||||
int name_to_menu(const char *name);
|
||||
char *menu_to_name(int menu);
|
||||
#endif
|
||||
|
||||
/* All functions in help.c. */
|
||||
#ifdef ENABLE_HELP
|
||||
void wrap_help_text_into_buffer();
|
||||
void do_help(void);
|
||||
void wrap_help_text_into_buffer(void);
|
||||
void help_init(void);
|
||||
functionptrtype parse_help_input(int *kbinput);
|
||||
size_t help_line_len(const char *ptr);
|
||||
#endif
|
||||
void do_help_void(void);
|
||||
void do_help(void);
|
||||
|
||||
/* Most functions in history.c. */
|
||||
#ifdef ENABLE_HISTORIES
|
||||
@@ -396,12 +396,12 @@ void free_lines(linestruct *src);
|
||||
void renumber_from(linestruct *line);
|
||||
void partition_buffer(linestruct *top, size_t top_x,
|
||||
linestruct *bot, size_t bot_x);
|
||||
void unpartition_buffer();
|
||||
void unpartition_buffer(void);
|
||||
void extract(linestruct *top, size_t top_x, linestruct *bot, size_t bot_x);
|
||||
void ingraft_buffer(linestruct *somebuffer);
|
||||
void copy_from_buffer(linestruct *somebuffer);
|
||||
void print_view_warning(void);
|
||||
void show_restricted_warning(void);
|
||||
bool in_restricted_mode(void);
|
||||
#ifndef ENABLE_HELP
|
||||
void say_there_is_no_help(void);
|
||||
#endif
|
||||
@@ -464,8 +464,11 @@ int do_prompt(bool allow_tabs, bool allow_files,
|
||||
int do_yesno_prompt(bool all, const char *msg);
|
||||
|
||||
/* Most functions in rcfile.c. */
|
||||
#if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES)
|
||||
void display_rcfile_errors(void);
|
||||
void jot_error(const char *msg, ...);
|
||||
#endif
|
||||
#ifdef ENABLE_NANORC
|
||||
void display_rcfile_errors();
|
||||
#ifdef ENABLE_COLOR
|
||||
void parse_one_include(char *file, syntaxtype *syntax);
|
||||
void grab_and_store(const char *kind, char *ptr, regexlisttype **storage);
|
||||
@@ -476,6 +479,8 @@ void do_rcfiles(void);
|
||||
#endif /* ENABLE_NANORC */
|
||||
|
||||
/* Most functions in search.c. */
|
||||
bool regexp_init(const char *regexp);
|
||||
void tidy_up_after_search(void);
|
||||
int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
size_t *match_len, bool skipone, const linestruct *begin, size_t begin_x);
|
||||
void do_search(void);
|
||||
@@ -506,7 +511,6 @@ void do_tab(void);
|
||||
void do_indent(void);
|
||||
void do_unindent(void);
|
||||
#endif
|
||||
bool white_string(const char *s);
|
||||
#ifdef ENABLE_COMMENT
|
||||
void do_comment(void);
|
||||
#endif
|
||||
@@ -516,8 +520,8 @@ void do_enter(void);
|
||||
#ifndef NANO_TINY
|
||||
RETSIGTYPE cancel_command(int signal);
|
||||
bool execute_command(const char *command);
|
||||
void discard_until(const undo *thisitem, openfilestruct *thefile, bool keep);
|
||||
void add_undo(undo_type action);
|
||||
void discard_until(const undostruct *thisitem, openfilestruct *thefile, bool keep);
|
||||
void add_undo(undo_type action, const char *message);
|
||||
void update_multiline_undo(ssize_t lineno, char *indentation);
|
||||
void update_undo(undo_type action);
|
||||
#endif /* !NANO_TINY */
|
||||
@@ -527,10 +531,11 @@ bool do_wrap(void);
|
||||
#if defined(ENABLE_HELP) || defined(ENABLED_WRAPORJUSTIFY)
|
||||
ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl);
|
||||
#endif
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_JUSTIFY)
|
||||
#if !defined(NANO_TINY) || defined(ENABLED_WRAPORJUSTIFY)
|
||||
size_t indent_length(const char *line);
|
||||
#endif
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
size_t quote_length(const char *line);
|
||||
bool begpar(const linestruct *const foo, int depth);
|
||||
bool inpar(const linestruct *const foo);
|
||||
void do_justify(bool full_justify);
|
||||
@@ -542,6 +547,7 @@ void do_spell(void);
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
void do_linter(void);
|
||||
void do_formatter(void);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
void do_wordlinechar_count(void);
|
||||
@@ -558,8 +564,8 @@ 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 unsunder(char *str, size_t true_len);
|
||||
void sunder(char *str);
|
||||
void unsunder(char *string, size_t length);
|
||||
void sunder(char *string);
|
||||
#if !defined(ENABLE_TINY) || defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
|
||||
void free_chararray(char **array, size_t len);
|
||||
#endif
|
||||
@@ -570,8 +576,9 @@ const char *strstrwrapper(const char *haystack, const char *needle,
|
||||
const char *start);
|
||||
void *nmalloc(size_t howmuch);
|
||||
void *nrealloc(void *ptr, size_t howmuch);
|
||||
char *mallocstrncpy(char *dest, const char *src, size_t n);
|
||||
char *measured_copy(const char *src, size_t n);
|
||||
char *mallocstrcpy(char *dest, const char *src);
|
||||
char *copy_of(const char *string);
|
||||
char *free_and_assign(char *dest, char *src);
|
||||
size_t get_page_start(size_t column);
|
||||
size_t xplustabs(void);
|
||||
@@ -612,8 +619,6 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count);
|
||||
#ifdef ENABLE_MOUSE
|
||||
int get_mouseinput(int *mouse_row, int *mouse_col, bool allow_shortcuts);
|
||||
#endif
|
||||
const keystruct *get_shortcut(int *kbinput);
|
||||
void blank_row(WINDOW *win, int y, int x, int n);
|
||||
void blank_edit(void);
|
||||
void blank_statusbar(void);
|
||||
void wipe_statusbar(void);
|
||||
@@ -622,14 +627,12 @@ void check_statusblank(void);
|
||||
char *display_string(const char *buf, size_t column, size_t span,
|
||||
bool isdata, bool isprompt);
|
||||
void titlebar(const char *path);
|
||||
void statusline(message_type importance, const char *msg, ...);
|
||||
void statusbar(const char *msg);
|
||||
void warn_and_shortly_pause(const char *msg);
|
||||
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(linestruct *fileptr, const char *converted,
|
||||
int line, size_t from_col);
|
||||
int update_line(linestruct *fileptr, size_t index);
|
||||
#ifndef NANO_TINY
|
||||
int update_softwrapped_line(linestruct *fileptr);
|
||||
@@ -693,5 +696,3 @@ void flip_newbuffer(void);
|
||||
#endif
|
||||
void discard_buffer(void);
|
||||
void do_cancel(void);
|
||||
|
||||
#endif /* !PROTO_H */
|
||||
|
||||
651
src/rcfile.c
651
src/rcfile.c
@@ -23,14 +23,14 @@
|
||||
|
||||
#include "proto.h"
|
||||
|
||||
#ifdef ENABLE_NANORC
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <glob.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef ENABLE_NANORC
|
||||
|
||||
#ifndef RCFILE_NAME
|
||||
#define HOME_RC_NAME ".nanorc"
|
||||
#define RCFILE_NAME "nanorc"
|
||||
@@ -67,7 +67,7 @@ static const rcoption rcopts[] = {
|
||||
#endif
|
||||
{"nohelp", NO_HELP},
|
||||
{"nonewlines", NO_NEWLINES},
|
||||
{"nopauses", NO_PAUSES},
|
||||
{"nopauses", NO_PAUSES}, /* Obsolete; remove in 2021. */
|
||||
#ifdef ENABLE_WRAPPING
|
||||
{"nowrap", NO_WRAP}, /* Deprecated; remove in 2021. */
|
||||
#endif
|
||||
@@ -147,12 +147,26 @@ static colortype *lastcolor = NULL;
|
||||
/* The end of the color list for the current syntax. */
|
||||
#endif
|
||||
|
||||
#define NUMBER_OF_MENUS 16
|
||||
char *menunames[NUMBER_OF_MENUS] = { "main", "search", "replace", "replacewith",
|
||||
"yesno", "gotoline", "writeout", "insert",
|
||||
"extcmd", "help", "spell", "linter",
|
||||
"browser", "whereisfile", "gotodir",
|
||||
"all" };
|
||||
int menusymbols[NUMBER_OF_MENUS] = { MMAIN, MWHEREIS, MREPLACE, MREPLACEWITH,
|
||||
MYESNO, MGOTOLINE, MWRITEFILE, MINSERTFILE,
|
||||
MEXTCMD, MHELP, MSPELL, MLINTER,
|
||||
MBROWSER, MWHEREISFILE, MGOTODIR,
|
||||
MMOST|MBROWSER|MHELP|MYESNO };
|
||||
#endif /* ENABLE_NANORC */
|
||||
|
||||
#if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES)
|
||||
static linestruct *errors_head = NULL;
|
||||
static linestruct *errors_tail = NULL;
|
||||
/* Beginning and end of a list of errors in rcfiles, if any. */
|
||||
|
||||
/* Send the gathered error messages (if any) to the terminal. */
|
||||
void display_rcfile_errors()
|
||||
void display_rcfile_errors(void)
|
||||
{
|
||||
for (linestruct *error = errors_head; error != NULL; error = error->next)
|
||||
fprintf(stderr, "%s\n", error->data);
|
||||
@@ -174,13 +188,20 @@ void jot_error(const char *msg, ...)
|
||||
errors_tail->next = error;
|
||||
errors_tail = error;
|
||||
|
||||
if (rcfile_with_errors == NULL)
|
||||
rcfile_with_errors = strdup(nanorc);
|
||||
|
||||
if (startup_problem == NULL) {
|
||||
#ifdef ENABLE_NANORC
|
||||
if (nanorc != NULL) {
|
||||
snprintf(textbuf, MAXSIZE, _("Mistakes in '%s'"), nanorc);
|
||||
startup_problem = copy_of(textbuf);
|
||||
} else
|
||||
#endif
|
||||
startup_problem = copy_of(_("Problems with history file"));
|
||||
}
|
||||
#ifdef ENABLE_NANORC
|
||||
if (lineno > 0)
|
||||
length = snprintf(textbuf, MAXSIZE, _("Error in %s on line %zu: "),
|
||||
nanorc, lineno);
|
||||
|
||||
#endif
|
||||
va_start(ap, msg);
|
||||
length += vsnprintf(textbuf + length, MAXSIZE - length, _(msg), ap);
|
||||
va_end(ap);
|
||||
@@ -188,6 +209,297 @@ void jot_error(const char *msg, ...)
|
||||
error->data = nmalloc(length + 1);
|
||||
sprintf(error->data, "%s", textbuf);
|
||||
}
|
||||
#endif /* ENABLE_NANORC || ENABLE_HISTORIES */
|
||||
|
||||
#ifdef ENABLE_NANORC
|
||||
/* Interpret a function string given in the rc file, and return a
|
||||
* shortcut record with the corresponding function filled in. */
|
||||
keystruct *strtosc(const char *input)
|
||||
{
|
||||
keystruct *s = nmalloc(sizeof(keystruct));
|
||||
|
||||
#ifndef NANO_TINY
|
||||
s->toggle = 0;
|
||||
#endif
|
||||
|
||||
if (!strcmp(input, "cancel"))
|
||||
s->func = do_cancel;
|
||||
#ifdef ENABLE_HELP
|
||||
else if (!strcmp(input, "help"))
|
||||
s->func = do_help;
|
||||
#endif
|
||||
else if (!strcmp(input, "exit"))
|
||||
s->func = do_exit;
|
||||
else if (!strcmp(input, "discardbuffer"))
|
||||
s->func = discard_buffer;
|
||||
else if (!strcmp(input, "writeout"))
|
||||
s->func = do_writeout_void;
|
||||
else if (!strcmp(input, "savefile"))
|
||||
s->func = do_savefile;
|
||||
else if (!strcmp(input, "insert"))
|
||||
s->func = do_insertfile_void;
|
||||
else if (!strcmp(input, "whereis"))
|
||||
s->func = do_search_forward;
|
||||
else if (!strcmp(input, "wherewas"))
|
||||
s->func = do_search_backward;
|
||||
else if (!strcmp(input, "findprevious"))
|
||||
s->func = do_findprevious;
|
||||
else if (!strcmp(input, "findnext"))
|
||||
s->func = do_findnext;
|
||||
else if (!strcmp(input, "replace"))
|
||||
s->func = do_replace;
|
||||
else if (!strcmp(input, "cut"))
|
||||
s->func = cut_text;
|
||||
else if (!strcmp(input, "paste"))
|
||||
s->func = paste_text;
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcmp(input, "cutrestoffile"))
|
||||
s->func = cut_till_eof;
|
||||
else if (!strcmp(input, "copy"))
|
||||
s->func = copy_text;
|
||||
else if (!strcmp(input, "zap"))
|
||||
s->func = zap_text;
|
||||
else if (!strcmp(input, "mark"))
|
||||
s->func = do_mark;
|
||||
#endif
|
||||
#ifdef ENABLE_SPELLER
|
||||
else if (!strcmp(input, "tospell") ||
|
||||
!strcmp(input, "speller"))
|
||||
s->func = do_spell;
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
else if (!strcmp(input, "linter"))
|
||||
s->func = do_linter;
|
||||
#ifdef ENABLE_SPELLER
|
||||
else if (!strcmp(input, "formatter"))
|
||||
s->func = do_formatter;
|
||||
#endif
|
||||
#endif
|
||||
else if (!strcmp(input, "curpos"))
|
||||
s->func = do_cursorpos_void;
|
||||
else if (!strcmp(input, "gotoline"))
|
||||
s->func = do_gotolinecolumn_void;
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
else if (!strcmp(input, "justify"))
|
||||
s->func = do_justify_void;
|
||||
else if (!strcmp(input, "fulljustify"))
|
||||
s->func = do_full_justify;
|
||||
else if (!strcmp(input, "beginpara"))
|
||||
s->func = do_para_begin_void;
|
||||
else if (!strcmp(input, "endpara"))
|
||||
s->func = do_para_end_void;
|
||||
#endif
|
||||
#ifdef ENABLE_COMMENT
|
||||
else if (!strcmp(input, "comment"))
|
||||
s->func = do_comment;
|
||||
#endif
|
||||
#ifdef ENABLE_WORDCOMPLETION
|
||||
else if (!strcmp(input, "complete"))
|
||||
s->func = complete_a_word;
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcmp(input, "indent"))
|
||||
s->func = do_indent;
|
||||
else if (!strcmp(input, "unindent"))
|
||||
s->func = do_unindent;
|
||||
else if (!strcmp(input, "chopwordleft") ||
|
||||
!strcmp(input, "cutwordleft")) /* Deprecated; remove in 2021. */
|
||||
s->func = chop_previous_word;
|
||||
else if (!strcmp(input, "chopwordright") ||
|
||||
!strcmp(input, "cutwordright")) /* Deprecated; remove in 2021. */
|
||||
s->func = chop_next_word;
|
||||
else if (!strcmp(input, "findbracket"))
|
||||
s->func = do_find_bracket;
|
||||
else if (!strcmp(input, "wordcount"))
|
||||
s->func = do_wordlinechar_count;
|
||||
else if (!strcmp(input, "recordmacro"))
|
||||
s->func = record_macro;
|
||||
else if (!strcmp(input, "runmacro"))
|
||||
s->func = run_macro;
|
||||
else if (!strcmp(input, "undo"))
|
||||
s->func = do_undo;
|
||||
else if (!strcmp(input, "redo"))
|
||||
s->func = do_redo;
|
||||
#endif
|
||||
else if (!strcmp(input, "left") ||
|
||||
!strcmp(input, "back"))
|
||||
s->func = do_left;
|
||||
else if (!strcmp(input, "right") ||
|
||||
!strcmp(input, "forward"))
|
||||
s->func = do_right;
|
||||
else if (!strcmp(input, "up") ||
|
||||
!strcmp(input, "prevline"))
|
||||
s->func = do_up;
|
||||
else if (!strcmp(input, "down") ||
|
||||
!strcmp(input, "nextline"))
|
||||
s->func = do_down;
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
|
||||
else if (!strcmp(input, "scrollup"))
|
||||
s->func = do_scroll_up;
|
||||
else if (!strcmp(input, "scrolldown"))
|
||||
s->func = do_scroll_down;
|
||||
#endif
|
||||
else if (!strcmp(input, "prevword"))
|
||||
s->func = do_prev_word_void;
|
||||
else if (!strcmp(input, "nextword"))
|
||||
s->func = do_next_word_void;
|
||||
else if (!strcmp(input, "home"))
|
||||
s->func = do_home;
|
||||
else if (!strcmp(input, "end"))
|
||||
s->func = do_end;
|
||||
else if (!strcmp(input, "prevblock"))
|
||||
s->func = do_prev_block;
|
||||
else if (!strcmp(input, "nextblock"))
|
||||
s->func = do_next_block;
|
||||
else if (!strcmp(input, "pageup") ||
|
||||
!strcmp(input, "prevpage"))
|
||||
s->func = do_page_up;
|
||||
else if (!strcmp(input, "pagedown") ||
|
||||
!strcmp(input, "nextpage"))
|
||||
s->func = do_page_down;
|
||||
else if (!strcmp(input, "firstline"))
|
||||
s->func = to_first_line;
|
||||
else if (!strcmp(input, "lastline"))
|
||||
s->func = to_last_line;
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
else if (!strcmp(input, "prevbuf"))
|
||||
s->func = switch_to_prev_buffer;
|
||||
else if (!strcmp(input, "nextbuf"))
|
||||
s->func = switch_to_next_buffer;
|
||||
#endif
|
||||
else if (!strcmp(input, "verbatim"))
|
||||
s->func = do_verbatim_input;
|
||||
else if (!strcmp(input, "tab"))
|
||||
s->func = do_tab;
|
||||
else if (!strcmp(input, "enter"))
|
||||
s->func = do_enter;
|
||||
else if (!strcmp(input, "delete"))
|
||||
s->func = do_delete;
|
||||
else if (!strcmp(input, "backspace"))
|
||||
s->func = do_backspace;
|
||||
else if (!strcmp(input, "refresh"))
|
||||
s->func = total_refresh;
|
||||
else if (!strcmp(input, "suspend"))
|
||||
s->func = do_suspend_void;
|
||||
else if (!strcmp(input, "casesens"))
|
||||
s->func = case_sens_void;
|
||||
else if (!strcmp(input, "regexp"))
|
||||
s->func = regexp_void;
|
||||
else if (!strcmp(input, "backwards"))
|
||||
s->func = backwards_void;
|
||||
else if (!strcmp(input, "flipreplace"))
|
||||
s->func = flip_replace;
|
||||
else if (!strcmp(input, "flipgoto"))
|
||||
s->func = flip_goto;
|
||||
#ifdef ENABLE_HISTORIES
|
||||
else if (!strcmp(input, "older"))
|
||||
s->func = get_history_older_void;
|
||||
else if (!strcmp(input, "newer"))
|
||||
s->func = get_history_newer_void;
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcmp(input, "dosformat"))
|
||||
s->func = dos_format_void;
|
||||
else if (!strcmp(input, "macformat"))
|
||||
s->func = mac_format_void;
|
||||
else if (!strcmp(input, "append"))
|
||||
s->func = append_void;
|
||||
else if (!strcmp(input, "prepend"))
|
||||
s->func = prepend_void;
|
||||
else if (!strcmp(input, "backup"))
|
||||
s->func = backup_file_void;
|
||||
else if (!strcmp(input, "flipexecute"))
|
||||
s->func = flip_execute;
|
||||
else if (!strcmp(input, "flippipe"))
|
||||
s->func = flip_pipe;
|
||||
else if (!strcmp(input, "flipconvert"))
|
||||
s->func = flip_convert;
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
else if (!strcmp(input, "flipnewbuffer"))
|
||||
s->func = flip_newbuffer;
|
||||
#endif
|
||||
#ifdef ENABLE_BROWSER
|
||||
else if (!strcmp(input, "tofiles") ||
|
||||
!strcmp(input, "browser"))
|
||||
s->func = to_files_void;
|
||||
else if (!strcmp(input, "gotodir"))
|
||||
s->func = goto_dir_void;
|
||||
else if (!strcmp(input, "firstfile"))
|
||||
s->func = to_first_file;
|
||||
else if (!strcmp(input, "lastfile"))
|
||||
s->func = to_last_file;
|
||||
#endif
|
||||
else {
|
||||
#ifndef NANO_TINY
|
||||
s->func = do_toggle_void;
|
||||
if (!strcmp(input, "nohelp"))
|
||||
s->toggle = NO_HELP;
|
||||
else if (!strcmp(input, "constantshow"))
|
||||
s->toggle = CONSTANT_SHOW;
|
||||
else if (!strcmp(input, "softwrap"))
|
||||
s->toggle = SOFTWRAP;
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
else if (!strcmp(input, "linenumbers"))
|
||||
s->toggle = LINE_NUMBERS;
|
||||
#endif
|
||||
else if (!strcmp(input, "whitespacedisplay"))
|
||||
s->toggle = WHITESPACE_DISPLAY;
|
||||
#ifdef ENABLE_COLOR
|
||||
else if (!strcmp(input, "nosyntax"))
|
||||
s->toggle = NO_COLOR_SYNTAX;
|
||||
#endif
|
||||
else if (!strcmp(input, "smarthome"))
|
||||
s->toggle = SMART_HOME;
|
||||
else if (!strcmp(input, "autoindent"))
|
||||
s->toggle = AUTOINDENT;
|
||||
else if (!strcmp(input, "cutfromcursor"))
|
||||
s->toggle = CUT_FROM_CURSOR;
|
||||
#ifdef ENABLE_WRAPPING
|
||||
else if (!strcmp(input, "nowrap"))
|
||||
s->toggle = BREAK_LONG_LINES;
|
||||
#endif
|
||||
else if (!strcmp(input, "tabstospaces"))
|
||||
s->toggle = TABS_TO_SPACES;
|
||||
#ifdef ENABLE_MOUSE
|
||||
else if (!strcmp(input, "mouse"))
|
||||
s->toggle = USE_MOUSE;
|
||||
#endif
|
||||
else if (!strcmp(input, "suspendenable"))
|
||||
s->toggle = SUSPEND;
|
||||
else
|
||||
#endif /* !NANO_TINY */
|
||||
{
|
||||
free(s);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/* Return the symbol that corresponds to the given menu name. */
|
||||
int name_to_menu(const char *name)
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
while (++index < NUMBER_OF_MENUS)
|
||||
if (strcmp(name, menunames[index]) == 0)
|
||||
return menusymbols[index];
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Return the name that corresponds to the given menu symbol. */
|
||||
char *menu_to_name(int menu)
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
while (++index < NUMBER_OF_MENUS)
|
||||
if (menusymbols[index] == menu)
|
||||
return menunames[index];
|
||||
|
||||
return "boooo";
|
||||
}
|
||||
|
||||
/* Parse the next word from the string, null-terminate it, and return
|
||||
* a pointer to the first character after the null terminator. The
|
||||
@@ -325,16 +637,18 @@ void begin_new_syntax(char *ptr)
|
||||
|
||||
/* Initialize a new syntax struct. */
|
||||
live_syntax = (syntaxtype *)nmalloc(sizeof(syntaxtype));
|
||||
live_syntax->name = mallocstrcpy(NULL, nameptr);
|
||||
live_syntax->filename = strdup(nanorc);
|
||||
live_syntax->name = copy_of(nameptr);
|
||||
live_syntax->filename = copy_of(nanorc);
|
||||
live_syntax->lineno = lineno;
|
||||
live_syntax->augmentations = NULL;
|
||||
live_syntax->extensions = NULL;
|
||||
live_syntax->headers = NULL;
|
||||
live_syntax->magics = NULL;
|
||||
live_syntax->linter = NULL;
|
||||
live_syntax->formatter = NULL;
|
||||
live_syntax->tab = NULL;
|
||||
#ifdef ENABLE_COMMENT
|
||||
live_syntax->comment = mallocstrcpy(NULL, GENERAL_COMMENT_CHARACTER);
|
||||
live_syntax->comment = copy_of(GENERAL_COMMENT_CHARACTER);
|
||||
#endif
|
||||
live_syntax->color = NULL;
|
||||
live_syntax->nmultis = 0;
|
||||
@@ -362,8 +676,13 @@ void begin_new_syntax(char *ptr)
|
||||
void check_for_nonempty_syntax(void)
|
||||
{
|
||||
#ifdef ENABLE_COLOR
|
||||
if (opensyntax && !seen_color_command)
|
||||
if (opensyntax && !seen_color_command) {
|
||||
size_t current_lineno = lineno;
|
||||
|
||||
lineno = live_syntax->lineno;
|
||||
jot_error(N_("Syntax \"%s\" has no color commands"), live_syntax->name);
|
||||
lineno = current_lineno;
|
||||
}
|
||||
|
||||
opensyntax = FALSE;
|
||||
#endif
|
||||
@@ -399,9 +718,9 @@ void parse_binding(char *ptr, bool dobind)
|
||||
|
||||
keyptr = ptr;
|
||||
ptr = parse_next_word(ptr);
|
||||
keycopy = mallocstrcpy(NULL, keyptr);
|
||||
keycopy = copy_of(keyptr);
|
||||
|
||||
if (strlen(keycopy) < 2) {
|
||||
if (keycopy[1] == '\0') {
|
||||
jot_error(N_("Key name is too short"));
|
||||
goto free_things;
|
||||
}
|
||||
@@ -410,12 +729,11 @@ void parse_binding(char *ptr, bool dobind)
|
||||
keycopy[0] = toupper((unsigned char)keycopy[0]);
|
||||
keycopy[1] = toupper((unsigned char)keycopy[1]);
|
||||
if (keycopy[0] == 'M' && keycopy[1] == '-') {
|
||||
if (strlen(keycopy) > 2)
|
||||
keycopy[2] = toupper((unsigned char)keycopy[2]);
|
||||
else {
|
||||
if (keycopy[2] == '\0') {
|
||||
jot_error(N_("Key name is too short"));
|
||||
goto free_things;
|
||||
}
|
||||
} else
|
||||
keycopy[2] = toupper((unsigned char)keycopy[2]);
|
||||
}
|
||||
|
||||
/* Allow the codes for Insert and Delete to be rebound, but apart
|
||||
@@ -457,7 +775,7 @@ void parse_binding(char *ptr, bool dobind)
|
||||
if (*funcptr == '"') {
|
||||
newsc = nmalloc(sizeof(keystruct));
|
||||
newsc->func = (functionptrtype)implant;
|
||||
newsc->expansion = mallocstrcpy(NULL, funcptr + 1);
|
||||
newsc->expansion = copy_of(funcptr + 1);
|
||||
#ifndef NANO_TINY
|
||||
newsc->toggle = 0;
|
||||
#endif
|
||||
@@ -495,13 +813,12 @@ void parse_binding(char *ptr, bool dobind)
|
||||
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;
|
||||
#endif
|
||||
mask = MMOST|MBROWSER|MHELP;
|
||||
|
||||
/* Now limit the given menu to those where the function exists. */
|
||||
menu = menu & (is_universal(newsc->func) ? MMOST : mask);
|
||||
menu = menu & (is_universal(newsc->func) ? (MMOST|MBROWSER) : mask);
|
||||
|
||||
if (!menu) {
|
||||
if (!ISSET(RESTRICTED) && !ISSET(VIEW_MODE))
|
||||
@@ -557,9 +874,12 @@ bool is_good_file(char *file)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
/* Read and parse one included syntax file. */
|
||||
/* Partially parse the syntaxes in the given file, or (when syntax
|
||||
* is not NULL) fully parse one specific syntax from the file . */
|
||||
void parse_one_include(char *file, syntaxtype *syntax)
|
||||
{
|
||||
char *was_nanorc = nanorc;
|
||||
size_t was_lineno = lineno;
|
||||
augmentstruct *extra;
|
||||
FILE *rcstream;
|
||||
|
||||
@@ -567,7 +887,6 @@ void parse_one_include(char *file, syntaxtype *syntax)
|
||||
if (!is_good_file(file))
|
||||
return;
|
||||
|
||||
/* Open the included syntax file. */
|
||||
rcstream = fopen(file, "rb");
|
||||
|
||||
if (rcstream == NULL) {
|
||||
@@ -583,6 +902,8 @@ void parse_one_include(char *file, syntaxtype *syntax)
|
||||
/* If this is the first pass, parse only the prologue. */
|
||||
if (syntax == NULL) {
|
||||
parse_rcfile(rcstream, TRUE, TRUE);
|
||||
nanorc = was_nanorc;
|
||||
lineno = was_lineno;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -610,17 +931,20 @@ void parse_one_include(char *file, syntaxtype *syntax)
|
||||
|
||||
free(syntax->filename);
|
||||
syntax->filename = NULL;
|
||||
|
||||
nanorc = was_nanorc;
|
||||
lineno = was_lineno;
|
||||
}
|
||||
|
||||
/* Expand globs in the passed name, and parse the resultant files. */
|
||||
void parse_includes(char *ptr)
|
||||
{
|
||||
char *pattern, *expanded;
|
||||
char *was_nanorc = nanorc;
|
||||
size_t was_lineno = lineno;
|
||||
glob_t files;
|
||||
int result;
|
||||
|
||||
check_for_nonempty_syntax();
|
||||
|
||||
pattern = ptr;
|
||||
if (*pattern == '"')
|
||||
pattern++;
|
||||
@@ -640,11 +964,6 @@ void parse_includes(char *ptr)
|
||||
|
||||
globfree(&files);
|
||||
free(expanded);
|
||||
|
||||
/* We're done with the included file(s). Restore the original
|
||||
* filename and line number position. */
|
||||
nanorc = was_nanorc;
|
||||
lineno = was_lineno;
|
||||
}
|
||||
|
||||
/* Return the short value corresponding to the color named in colorname,
|
||||
@@ -657,23 +976,23 @@ short color_to_short(const char *colorname, bool *bright)
|
||||
} else
|
||||
*bright = FALSE;
|
||||
|
||||
if (strcasecmp(colorname, "green") == 0)
|
||||
if (strcmp(colorname, "green") == 0)
|
||||
return COLOR_GREEN;
|
||||
else if (strcasecmp(colorname, "red") == 0)
|
||||
else if (strcmp(colorname, "red") == 0)
|
||||
return COLOR_RED;
|
||||
else if (strcasecmp(colorname, "blue") == 0)
|
||||
else if (strcmp(colorname, "blue") == 0)
|
||||
return COLOR_BLUE;
|
||||
else if (strcasecmp(colorname, "white") == 0)
|
||||
else if (strcmp(colorname, "white") == 0)
|
||||
return COLOR_WHITE;
|
||||
else if (strcasecmp(colorname, "yellow") == 0)
|
||||
else if (strcmp(colorname, "yellow") == 0)
|
||||
return COLOR_YELLOW;
|
||||
else if (strcasecmp(colorname, "cyan") == 0)
|
||||
else if (strcmp(colorname, "cyan") == 0)
|
||||
return COLOR_CYAN;
|
||||
else if (strcasecmp(colorname, "magenta") == 0)
|
||||
else if (strcmp(colorname, "magenta") == 0)
|
||||
return COLOR_MAGENTA;
|
||||
else if (strcasecmp(colorname, "black") == 0)
|
||||
else if (strcmp(colorname, "black") == 0)
|
||||
return COLOR_BLACK;
|
||||
else if (strcasecmp(colorname, "normal") == 0)
|
||||
else if (strcmp(colorname, "normal") == 0)
|
||||
return USE_THE_DEFAULT;
|
||||
|
||||
jot_error(N_("Color \"%s\" not understood"), colorname);
|
||||
@@ -892,7 +1211,7 @@ void grab_and_store(const char *kind, char *ptr, regexlisttype **storage)
|
||||
|
||||
/* Copy the regex into a struct, and hook this in at the end. */
|
||||
newthing = (regexlisttype *)nmalloc(sizeof(regexlisttype));
|
||||
newthing->full_regex = mallocstrcpy(NULL, regexstring);
|
||||
newthing->full_regex = copy_of(regexstring);
|
||||
newthing->next = NULL;
|
||||
|
||||
if (lastthing == NULL)
|
||||
@@ -933,16 +1252,22 @@ void pick_up_name(const char *kind, char *ptr, char **storage)
|
||||
/* Handle the four syntax-only commands. */
|
||||
bool parse_syntax_commands(char *keyword, char *ptr)
|
||||
{
|
||||
if (strcasecmp(keyword, "color") == 0)
|
||||
if (strcmp(keyword, "color") == 0)
|
||||
parse_colors(ptr, NANO_REG_EXTENDED);
|
||||
else if (strcasecmp(keyword, "icolor") == 0)
|
||||
else if (strcmp(keyword, "icolor") == 0)
|
||||
parse_colors(ptr, NANO_REG_EXTENDED | REG_ICASE);
|
||||
else if (strcasecmp(keyword, "comment") == 0) {
|
||||
else if (strcmp(keyword, "comment") == 0) {
|
||||
#ifdef ENABLE_COMMENT
|
||||
pick_up_name("comment", ptr, &live_syntax->comment);
|
||||
#endif
|
||||
} else if (strcasecmp(keyword, "linter") == 0)
|
||||
} else if (strcmp(keyword, "tabgives") == 0) {
|
||||
#ifdef ENABLE_COLOR
|
||||
pick_up_name("tabgives", ptr, &live_syntax->tab);
|
||||
#endif
|
||||
} else if (strcmp(keyword, "linter") == 0)
|
||||
pick_up_name("linter", ptr, &live_syntax->linter);
|
||||
else if (strcmp(keyword, "formatter") == 0)
|
||||
pick_up_name("formatter", ptr, &live_syntax->formatter);
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
@@ -954,14 +1279,12 @@ bool parse_syntax_commands(char *keyword, char *ptr)
|
||||
* function that we consider 'vital' (such as "Exit"). */
|
||||
static void check_vitals_mapped(void)
|
||||
{
|
||||
funcstruct *f;
|
||||
int v;
|
||||
#define VITALS 3
|
||||
void (*vitals[VITALS])(void) = { do_exit, do_exit, do_cancel };
|
||||
int inmenus[VITALS] = { MMAIN, MHELP, MYESNO };
|
||||
#define VITALS 4
|
||||
void (*vitals[VITALS])(void) = { do_exit, do_exit, do_exit, do_cancel };
|
||||
int inmenus[VITALS] = { MMAIN, MBROWSER, MHELP, MYESNO };
|
||||
|
||||
for (v = 0; v < VITALS; v++) {
|
||||
for (f = allfuncs; f != NULL; f = f->next) {
|
||||
for (int v = 0; v < VITALS; v++) {
|
||||
for (funcstruct *f = allfuncs; f != NULL; f = f->next) {
|
||||
if (f->func == vitals[v] && f->menus & inmenus[v]) {
|
||||
const keystruct *s = first_sc_for(inmenus[v], f->func);
|
||||
if (!s) {
|
||||
@@ -988,7 +1311,10 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
|
||||
size_t size = 0;
|
||||
|
||||
while ((len = getline(&buffer, &size, rcstream)) > 0) {
|
||||
char *ptr, *keyword, *option;
|
||||
char *ptr, *keyword, *option, *argument;
|
||||
#ifdef ENABLE_COLOR
|
||||
bool drop_open = FALSE;
|
||||
#endif
|
||||
int set = 0;
|
||||
size_t i;
|
||||
|
||||
@@ -1017,7 +1343,7 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
/* Handle extending first... */
|
||||
if (!just_syntax && strcasecmp(keyword, "extendsyntax") == 0) {
|
||||
if (!just_syntax && strcmp(keyword, "extendsyntax") == 0) {
|
||||
augmentstruct *newitem, *extra;
|
||||
char *syntaxname = ptr;
|
||||
syntaxtype *sint;
|
||||
@@ -1035,55 +1361,69 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
|
||||
continue;
|
||||
}
|
||||
|
||||
newitem = nmalloc(sizeof(augmentstruct));;
|
||||
keyword = ptr;
|
||||
argument = copy_of(ptr);
|
||||
ptr = parse_next_word(ptr);
|
||||
|
||||
/* Store the content of an 'extendsyntax', for later parsing. */
|
||||
newitem->filename = strdup(nanorc);
|
||||
newitem->lineno = lineno;
|
||||
newitem->data = strdup(ptr);
|
||||
newitem->next = NULL;
|
||||
/* File-matching commands need to be processed immediately;
|
||||
* other commands are stored for possible later processing. */
|
||||
if (strcmp(keyword, "header") == 0 || strcmp(keyword, "magic") == 0) {
|
||||
free(argument);
|
||||
live_syntax = sint;
|
||||
opensyntax = TRUE;
|
||||
drop_open = TRUE;
|
||||
} else {
|
||||
newitem = nmalloc(sizeof(augmentstruct));;
|
||||
|
||||
if (sint->augmentations != NULL) {
|
||||
extra = sint->augmentations;
|
||||
while (extra->next != NULL)
|
||||
extra = extra->next;
|
||||
extra->next = newitem;
|
||||
} else
|
||||
sint->augmentations = newitem;
|
||||
newitem->filename = copy_of(nanorc);
|
||||
newitem->lineno = lineno;
|
||||
newitem->data = argument;
|
||||
newitem->next = NULL;
|
||||
|
||||
continue;
|
||||
if (sint->augmentations != NULL) {
|
||||
extra = sint->augmentations;
|
||||
while (extra->next != NULL)
|
||||
extra = extra->next;
|
||||
extra->next = newitem;
|
||||
} else
|
||||
sint->augmentations = newitem;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* Try to parse the keyword. */
|
||||
if (strcasecmp(keyword, "syntax") == 0) {
|
||||
if (strcmp(keyword, "syntax") == 0) {
|
||||
if (intros_only) {
|
||||
check_for_nonempty_syntax();
|
||||
begin_new_syntax(ptr);
|
||||
} else
|
||||
break;
|
||||
} else if (strcasecmp(keyword, "header") == 0) {
|
||||
} else if (strcmp(keyword, "header") == 0) {
|
||||
if (intros_only)
|
||||
grab_and_store("header", ptr, &live_syntax->headers);
|
||||
} else if (strcasecmp(keyword, "magic") == 0) {
|
||||
} else if (strcmp(keyword, "magic") == 0) {
|
||||
#ifdef HAVE_LIBMAGIC
|
||||
if (intros_only)
|
||||
grab_and_store("magic", ptr, &live_syntax->magics);
|
||||
#endif
|
||||
} else if (just_syntax && (strcasecmp(keyword, "set") == 0 ||
|
||||
strcasecmp(keyword, "unset") == 0 ||
|
||||
strcasecmp(keyword, "bind") == 0 ||
|
||||
strcasecmp(keyword, "unbind") == 0 ||
|
||||
strcasecmp(keyword, "include") == 0 ||
|
||||
strcasecmp(keyword, "extendsyntax") == 0)) {
|
||||
} else if (just_syntax && (strcmp(keyword, "set") == 0 ||
|
||||
strcmp(keyword, "unset") == 0 ||
|
||||
strcmp(keyword, "bind") == 0 ||
|
||||
strcmp(keyword, "unbind") == 0 ||
|
||||
strcmp(keyword, "include") == 0 ||
|
||||
strcmp(keyword, "extendsyntax") == 0)) {
|
||||
if (intros_only)
|
||||
jot_error(N_("Command \"%s\" not allowed in included file"),
|
||||
keyword);
|
||||
else
|
||||
break;
|
||||
} else if (intros_only && (strcasecmp(keyword, "color") == 0 ||
|
||||
strcasecmp(keyword, "icolor") == 0 ||
|
||||
strcasecmp(keyword, "comment") == 0 ||
|
||||
strcasecmp(keyword, "linter") == 0)) {
|
||||
} else if (intros_only && (strcmp(keyword, "color") == 0 ||
|
||||
strcmp(keyword, "icolor") == 0 ||
|
||||
strcmp(keyword, "comment") == 0 ||
|
||||
strcmp(keyword, "tabgives") == 0 ||
|
||||
strcmp(keyword, "linter") == 0 ||
|
||||
strcmp(keyword, "formatter") == 0)) {
|
||||
if (!opensyntax)
|
||||
jot_error(N_("A '%s' command requires a preceding "
|
||||
"'syntax' command"), keyword);
|
||||
@@ -1092,21 +1432,25 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
|
||||
continue;
|
||||
} else if (parse_syntax_commands(keyword, ptr))
|
||||
;
|
||||
else if (strcasecmp(keyword, "include") == 0)
|
||||
else if (strcmp(keyword, "include") == 0)
|
||||
parse_includes(ptr);
|
||||
else
|
||||
#endif /* ENABLE_COLOR */
|
||||
if (strcasecmp(keyword, "set") == 0)
|
||||
if (strcmp(keyword, "set") == 0)
|
||||
set = 1;
|
||||
else if (strcasecmp(keyword, "unset") == 0)
|
||||
else if (strcmp(keyword, "unset") == 0)
|
||||
set = -1;
|
||||
else if (strcasecmp(keyword, "bind") == 0)
|
||||
else if (strcmp(keyword, "bind") == 0)
|
||||
parse_binding(ptr, TRUE);
|
||||
else if (strcasecmp(keyword, "unbind") == 0)
|
||||
else if (strcmp(keyword, "unbind") == 0)
|
||||
parse_binding(ptr, FALSE);
|
||||
else if (intros_only)
|
||||
jot_error(N_("Command \"%s\" not understood"), keyword);
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
if (drop_open)
|
||||
opensyntax = FALSE;
|
||||
#endif
|
||||
if (set == 0)
|
||||
continue;
|
||||
|
||||
@@ -1122,7 +1466,7 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
|
||||
|
||||
/* Find the just parsed option name among the existing names. */
|
||||
for (i = 0; rcopts[i].name != NULL; i++) {
|
||||
if (strcasecmp(option, rcopts[i].name) == 0)
|
||||
if (strcmp(option, rcopts[i].name) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1142,125 +1486,125 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
|
||||
|
||||
/* An option that takes an argument cannot be unset. */
|
||||
if (set == -1) {
|
||||
jot_error(N_("Cannot unset option \"%s\""), rcopts[i].name);
|
||||
jot_error(N_("Cannot unset option \"%s\""), option);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (*ptr == '\0') {
|
||||
jot_error(N_("Option \"%s\" requires an argument"), rcopts[i].name);
|
||||
jot_error(N_("Option \"%s\" requires an argument"), option);
|
||||
continue;
|
||||
}
|
||||
|
||||
option = ptr;
|
||||
if (*option == '"')
|
||||
option++;
|
||||
argument = ptr;
|
||||
if (*argument == '"')
|
||||
argument++;
|
||||
ptr = parse_argument(ptr);
|
||||
|
||||
option = mallocstrcpy(NULL, option);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
/* When in a UTF-8 locale, ignore arguments with invalid sequences. */
|
||||
if (using_utf8() && mbstowcs(NULL, option, 0) == (size_t)-1) {
|
||||
if (using_utf8() && mbstowcs(NULL, argument, 0) == (size_t)-1) {
|
||||
jot_error(N_("Argument is not a valid multibyte string"));
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
argument = copy_of(argument);
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
if (strcasecmp(rcopts[i].name, "titlecolor") == 0)
|
||||
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)
|
||||
color_combo[STATUS_BAR] = parse_interface_color(option);
|
||||
else if (strcasecmp(rcopts[i].name, "errorcolor") == 0)
|
||||
color_combo[ERROR_MESSAGE] = parse_interface_color(option);
|
||||
else if (strcasecmp(rcopts[i].name, "keycolor") == 0)
|
||||
color_combo[KEY_COMBO] = parse_interface_color(option);
|
||||
else if (strcasecmp(rcopts[i].name, "functioncolor") == 0)
|
||||
color_combo[FUNCTION_TAG] = parse_interface_color(option);
|
||||
if (strcmp(option, "titlecolor") == 0)
|
||||
color_combo[TITLE_BAR] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "numbercolor") == 0)
|
||||
color_combo[LINE_NUMBER] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "stripecolor") == 0)
|
||||
color_combo[GUIDE_STRIPE] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "selectedcolor") == 0)
|
||||
color_combo[SELECTED_TEXT] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "statuscolor") == 0)
|
||||
color_combo[STATUS_BAR] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "errorcolor") == 0)
|
||||
color_combo[ERROR_MESSAGE] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "keycolor") == 0)
|
||||
color_combo[KEY_COMBO] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "functioncolor") == 0)
|
||||
color_combo[FUNCTION_TAG] = parse_interface_color(argument);
|
||||
else
|
||||
#endif
|
||||
#ifdef ENABLE_OPERATINGDIR
|
||||
if (strcasecmp(rcopts[i].name, "operatingdir") == 0)
|
||||
operating_dir = option;
|
||||
if (strcmp(option, "operatingdir") == 0)
|
||||
operating_dir = argument;
|
||||
else
|
||||
#endif
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
if (strcasecmp(rcopts[i].name, "fill") == 0) {
|
||||
if (!parse_num(option, &fill)) {
|
||||
jot_error(N_("Requested fill size \"%s\" is invalid"), option);
|
||||
if (strcmp(option, "fill") == 0) {
|
||||
if (!parse_num(argument, &fill)) {
|
||||
jot_error(N_("Requested fill size \"%s\" is invalid"), argument);
|
||||
fill = -COLUMNS_FROM_EOL;
|
||||
}
|
||||
free(option);
|
||||
free(argument);
|
||||
} else
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
if (strcasecmp(rcopts[i].name, "guidestripe") == 0) {
|
||||
if (!parse_num(option, &stripe_column) || stripe_column <= 0) {
|
||||
jot_error(N_("Guide column \"%s\" is invalid"), option);
|
||||
if (strcmp(option, "guidestripe") == 0) {
|
||||
if (!parse_num(argument, &stripe_column) || stripe_column <= 0) {
|
||||
jot_error(N_("Guide column \"%s\" is invalid"), argument);
|
||||
stripe_column = 0;
|
||||
}
|
||||
free(option);
|
||||
} else if (strcasecmp(rcopts[i].name, "matchbrackets") == 0) {
|
||||
if (has_blank_char(option)) {
|
||||
free(argument);
|
||||
} else if (strcmp(option, "matchbrackets") == 0) {
|
||||
if (has_blank_char(argument)) {
|
||||
jot_error(N_("Non-blank characters required"));
|
||||
free(option);
|
||||
} else if (mbstrlen(option) % 2 != 0) {
|
||||
free(argument);
|
||||
} else if (mbstrlen(argument) % 2 != 0) {
|
||||
jot_error(N_("Even number of characters required"));
|
||||
free(option);
|
||||
free(argument);
|
||||
} else
|
||||
matchbrackets = option;
|
||||
} else if (strcasecmp(rcopts[i].name, "whitespace") == 0) {
|
||||
if (mbstrlen(option) != 2 || breadth(option) != 2) {
|
||||
matchbrackets = argument;
|
||||
} else if (strcmp(option, "whitespace") == 0) {
|
||||
if (mbstrlen(argument) != 2 || breadth(argument) != 2) {
|
||||
jot_error(N_("Two single-column characters required"));
|
||||
free(option);
|
||||
free(argument);
|
||||
} else {
|
||||
whitespace = option;
|
||||
whitespace = argument;
|
||||
whitelen[0] = char_length(whitespace);
|
||||
whitelen[1] = char_length(whitespace + whitelen[0]);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
if (strcasecmp(rcopts[i].name, "punct") == 0) {
|
||||
if (has_blank_char(option)) {
|
||||
if (strcmp(option, "punct") == 0) {
|
||||
if (has_blank_char(argument)) {
|
||||
jot_error(N_("Non-blank characters required"));
|
||||
free(option);
|
||||
free(argument);
|
||||
} else
|
||||
punct = option;
|
||||
} else if (strcasecmp(rcopts[i].name, "brackets") == 0) {
|
||||
if (has_blank_char(option)) {
|
||||
punct = argument;
|
||||
} else if (strcmp(option, "brackets") == 0) {
|
||||
if (has_blank_char(argument)) {
|
||||
jot_error(N_("Non-blank characters required"));
|
||||
free(option);
|
||||
free(argument);
|
||||
} else
|
||||
brackets = option;
|
||||
} else if (strcasecmp(rcopts[i].name, "quotestr") == 0)
|
||||
quotestr = option;
|
||||
brackets = argument;
|
||||
} else if (strcmp(option, "quotestr") == 0)
|
||||
quotestr = argument;
|
||||
else
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
if (strcasecmp(rcopts[i].name, "backupdir") == 0)
|
||||
backup_dir = option;
|
||||
if (strcmp(option, "backupdir") == 0)
|
||||
backup_dir = argument;
|
||||
else
|
||||
if (strcasecmp(rcopts[i].name, "wordchars") == 0)
|
||||
word_chars = option;
|
||||
if (strcmp(option, "wordchars") == 0)
|
||||
word_chars = argument;
|
||||
else
|
||||
#endif
|
||||
#ifdef ENABLE_SPELLER
|
||||
if (strcasecmp(rcopts[i].name, "speller") == 0)
|
||||
alt_speller = option;
|
||||
if (strcmp(option, "speller") == 0)
|
||||
alt_speller = argument;
|
||||
else
|
||||
#endif
|
||||
if (strcasecmp(rcopts[i].name, "tabsize") == 0) {
|
||||
if (!parse_num(option, &tabsize) || tabsize <= 0) {
|
||||
jot_error(N_("Requested tab size \"%s\" is invalid"), option);
|
||||
if (strcmp(option, "tabsize") == 0) {
|
||||
if (!parse_num(argument, &tabsize) || tabsize <= 0) {
|
||||
jot_error(N_("Requested tab size \"%s\" is invalid"), argument);
|
||||
tabsize = -1;
|
||||
}
|
||||
free(option);
|
||||
free(argument);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1287,7 +1631,7 @@ void parse_one_nanorc(void)
|
||||
jot_error(N_("Error reading %s: %s"), nanorc, strerror(errno));
|
||||
}
|
||||
|
||||
bool have_nanorc(const char *path, char *name)
|
||||
bool have_nanorc(const char *path, const char *name)
|
||||
{
|
||||
if (path == NULL)
|
||||
return FALSE;
|
||||
@@ -1323,6 +1667,7 @@ void do_rcfiles(void)
|
||||
check_vitals_mapped();
|
||||
|
||||
free(nanorc);
|
||||
nanorc = NULL;
|
||||
}
|
||||
|
||||
#endif /* ENABLE_NANORC */
|
||||
|
||||
14
src/search.c
14
src/search.c
@@ -76,7 +76,7 @@ void search_init(bool replacing, bool keep_the_answer)
|
||||
|
||||
/* When starting a new search, clear the current answer. */
|
||||
if (!keep_the_answer)
|
||||
answer = mallocstrcpy(answer, NULL);
|
||||
answer = mallocstrcpy(answer, "");
|
||||
|
||||
/* If something was searched for earlier, include it in the prompt. */
|
||||
if (*last_search != '\0') {
|
||||
@@ -88,7 +88,7 @@ void search_init(bool replacing, bool keep_the_answer)
|
||||
(breadth(last_search) > COLS / 3) ? "..." : "");
|
||||
free(disp);
|
||||
} else
|
||||
thedefault = mallocstrcpy(NULL, "");
|
||||
thedefault = copy_of("");
|
||||
|
||||
while (TRUE) {
|
||||
functionptrtype func;
|
||||
@@ -98,7 +98,7 @@ void search_init(bool replacing, bool keep_the_answer)
|
||||
answer, &search_history, edit_refresh,
|
||||
/* TRANSLATORS: This is the main search prompt. */
|
||||
"%s%s%s%s%s%s", _("Search"),
|
||||
/* TRANSLATORS: The next five modify the search prompt. */
|
||||
/* TRANSLATORS: The next four modify the search prompt. */
|
||||
ISSET(CASE_SENSITIVE) ? _(" [Case Sensitive]") : "",
|
||||
ISSET(USE_REGEXP) ? _(" [Regexp]") : "",
|
||||
ISSET(BACKWARDS_SEARCH) ? _(" [Backwards]") : "",
|
||||
@@ -359,6 +359,8 @@ void do_research(void)
|
||||
/* Use the search-menu key bindings, to allow cancelling. */
|
||||
currmenu = MWHEREIS;
|
||||
|
||||
wipe_statusbar();
|
||||
|
||||
go_looking();
|
||||
|
||||
tidy_up_after_search();
|
||||
@@ -596,7 +598,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
size_t length_change;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(REPLACE);
|
||||
add_undo(REPLACE, NULL);
|
||||
#endif
|
||||
copy = replace_line(needle);
|
||||
|
||||
@@ -697,7 +699,7 @@ void ask_for_replacement(void)
|
||||
linestruct *edittop_save, *begin;
|
||||
size_t firstcolumn_save, begin_x;
|
||||
ssize_t numreplaced;
|
||||
int response = do_prompt(FALSE, FALSE, MREPLACEWITH, NULL,
|
||||
int response = do_prompt(FALSE, FALSE, MREPLACEWITH, "",
|
||||
/* TRANSLATORS: This is a prompt. */
|
||||
&replace_history, edit_refresh, _("Replace with"));
|
||||
|
||||
@@ -756,7 +758,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
if (interactive) {
|
||||
/* Ask for the line and column. */
|
||||
int response = do_prompt(FALSE, FALSE, MGOTOLINE,
|
||||
use_answer ? answer : NULL, NULL, edit_refresh,
|
||||
use_answer ? answer : "", NULL, edit_refresh,
|
||||
/* TRANSLATORS: This is a prompt. */
|
||||
_("Enter line number, column number"));
|
||||
|
||||
|
||||
700
src/text.c
700
src/text.c
File diff suppressed because it is too large
Load Diff
71
src/utils.c
71
src/utils.c
@@ -49,7 +49,7 @@ void get_homedir(void)
|
||||
/* Only set homedir if some home directory could be determined,
|
||||
* otherwise keep homedir NULL. */
|
||||
if (homenv != NULL && *homenv != '\0')
|
||||
homedir = mallocstrcpy(NULL, homenv);
|
||||
homedir = copy_of(homenv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
|
||||
if (comma == str)
|
||||
return retval;
|
||||
|
||||
firstpart = mallocstrcpy(NULL, str);
|
||||
firstpart = copy_of(str);
|
||||
firstpart[comma - str] = '\0';
|
||||
|
||||
retval = parse_num(firstpart, line) && retval;
|
||||
@@ -159,23 +159,24 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* For non-null-terminated lines. A line, by definition, shouldn't
|
||||
* normally have newlines in it, so encode its nulls as newlines. */
|
||||
void unsunder(char *str, size_t true_len)
|
||||
/* In the given string, recode each embedded NUL as a newline. */
|
||||
void unsunder(char *string, size_t length)
|
||||
{
|
||||
for (; true_len > 0; true_len--, str++) {
|
||||
if (*str == '\0')
|
||||
*str = '\n';
|
||||
while (length > 0) {
|
||||
if (*string == '\0')
|
||||
*string = '\n';
|
||||
length--;
|
||||
string++;
|
||||
}
|
||||
}
|
||||
|
||||
/* For non-null-terminated lines. A line, by definition, shouldn't
|
||||
* normally have newlines in it, so decode its newlines as nulls. */
|
||||
void sunder(char *str)
|
||||
/* In the given string, recode each embedded newline as a NUL. */
|
||||
void sunder(char *string)
|
||||
{
|
||||
for (; *str != '\0'; str++) {
|
||||
if (*str == '\n')
|
||||
*str = '\0';
|
||||
while (*string != '\0') {
|
||||
if (*string == '\n')
|
||||
*string = '\0';
|
||||
string++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,8 +203,8 @@ bool is_separate_word(size_t position, size_t length, const char *buf)
|
||||
size_t word_end = position + length;
|
||||
|
||||
/* Get the characters before and after the word, if any. */
|
||||
parse_mbchar(buf + step_left(buf, position), before, NULL);
|
||||
parse_mbchar(buf + word_end, after, NULL);
|
||||
collect_char(buf + step_left(buf, position), before);
|
||||
collect_char(buf + word_end, after);
|
||||
|
||||
/* If the word starts at the beginning of the line OR the character before
|
||||
* the word isn't a letter, and if the word ends at the end of the line OR
|
||||
@@ -311,24 +312,32 @@ void *nrealloc(void *ptr, size_t howmuch)
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Allocate and copy the first n characters of the given src string, after
|
||||
* freeing the destination. Usage: "dest = mallocstrncpy(dest, src, n);". */
|
||||
char *mallocstrncpy(char *dest, const char *src, size_t n)
|
||||
/* Return an appropriately reallocated dest string holding a copy of src.
|
||||
* Usage: "dest = mallocstrcpy(dest, src);". */
|
||||
char *mallocstrcpy(char *dest, const char *src)
|
||||
{
|
||||
if (src == NULL)
|
||||
src = "";
|
||||
size_t count = strlen(src) + 1;
|
||||
|
||||
dest = charealloc(dest, n);
|
||||
strncpy(dest, src, n);
|
||||
dest = charealloc(dest, count);
|
||||
strncpy(dest, src, count);
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* Free the dest string and return a malloc'ed copy of src. Should be used as:
|
||||
* "dest = mallocstrcpy(dest, src);". */
|
||||
char *mallocstrcpy(char *dest, const char *src)
|
||||
/* Return an allocated copy of the first count characters of the given string. */
|
||||
char *measured_copy(const char *string, size_t count)
|
||||
{
|
||||
return mallocstrncpy(dest, src, (src == NULL) ? 1 : strlen(src) + 1);
|
||||
char *thecopy = charalloc(count);
|
||||
|
||||
strncpy(thecopy, string, count);
|
||||
|
||||
return thecopy;
|
||||
}
|
||||
|
||||
/* Return an allocated copy of the given string. */
|
||||
char *copy_of(const char *string)
|
||||
{
|
||||
return measured_copy(string, strlen(string) + 1);
|
||||
}
|
||||
|
||||
/* Free the string at dest and return the string at src. */
|
||||
@@ -370,7 +379,7 @@ size_t actual_x(const char *text, size_t column)
|
||||
/* The current accumulated span, in columns. */
|
||||
|
||||
while (*text != '\0') {
|
||||
int charlen = parse_mbchar(text, NULL, &width);
|
||||
int charlen = advance_over(text, &width);
|
||||
|
||||
if (width > column)
|
||||
break;
|
||||
@@ -391,7 +400,7 @@ size_t wideness(const char *text, size_t maxlen)
|
||||
return 0;
|
||||
|
||||
while (*text != '\0') {
|
||||
size_t charlen = parse_mbchar(text, NULL, &width);
|
||||
size_t charlen = advance_over(text, &width);
|
||||
|
||||
if (maxlen <= charlen)
|
||||
break;
|
||||
@@ -409,7 +418,7 @@ size_t breadth(const char *text)
|
||||
size_t span = 0;
|
||||
|
||||
while (*text != '\0')
|
||||
text += parse_mbchar(text, NULL, &span);
|
||||
text += advance_over(text, &span);
|
||||
|
||||
return span;
|
||||
}
|
||||
@@ -418,7 +427,7 @@ size_t breadth(const char *text)
|
||||
void new_magicline(void)
|
||||
{
|
||||
openfile->filebot->next = make_new_node(openfile->filebot);
|
||||
openfile->filebot->next->data = mallocstrcpy(NULL, "");
|
||||
openfile->filebot->next->data = copy_of("");
|
||||
openfile->filebot = openfile->filebot->next;
|
||||
openfile->totsize++;
|
||||
}
|
||||
|
||||
381
src/winio.c
381
src/winio.c
@@ -658,12 +658,9 @@ int parse_kbinput(WINDOW *win)
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* When <Tab> is pressed while the mark is on, do an indent. */
|
||||
if (retval == TAB_CODE && openfile->mark && currmenu == MMAIN) {
|
||||
const keystruct *command = first_sc_for(MMAIN, do_indent);
|
||||
|
||||
meta_key = command->meta;
|
||||
return command->keycode;
|
||||
}
|
||||
if (retval == TAB_CODE && openfile->mark && currmenu == MMAIN &&
|
||||
openfile->mark != openfile->current)
|
||||
return INDENT_KEY;
|
||||
#endif
|
||||
|
||||
switch (retval) {
|
||||
@@ -1695,17 +1692,14 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Determine how many shortcuts will be shown. */
|
||||
number = length_of_list(currmenu);
|
||||
if (number > MAIN_VISIBLE)
|
||||
number = MAIN_VISIBLE;
|
||||
/* Determine how many shortcuts are being shown. */
|
||||
number = shown_entries_for(currmenu);
|
||||
|
||||
/* Calculate the width of each non-rightmost shortcut item;
|
||||
* the rightmost ones will "absorb" any remaining slack. */
|
||||
if (number < 2)
|
||||
width = COLS / (MAIN_VISIBLE / 2);
|
||||
/* Calculate the clickable width of each menu item. */
|
||||
if (number < 5)
|
||||
width = COLS / 2;
|
||||
else
|
||||
width = COLS / ((number / 2) + (number % 2));
|
||||
width = COLS / ((number + 1) / 2);
|
||||
|
||||
/* Calculate the one-based index in the shortcut list. */
|
||||
index = (*mouse_x / width) * 2 + *mouse_y;
|
||||
@@ -1768,74 +1762,45 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
|
||||
}
|
||||
#endif /* ENABLE_MOUSE */
|
||||
|
||||
/* Return the shortcut that corresponds to the values of kbinput (the
|
||||
* key itself) and meta_key (whether the key is a meta sequence). The
|
||||
* returned shortcut will be the first in the list that corresponds to
|
||||
* the given sequence. */
|
||||
const keystruct *get_shortcut(int *kbinput)
|
||||
/* Move (in the given window) to the given row and wipe it clean. */
|
||||
void blank_row(WINDOW *window, int row)
|
||||
{
|
||||
keystruct *s;
|
||||
|
||||
/* Plain characters cannot be shortcuts, so just skip those. */
|
||||
if (!meta_key && ((*kbinput >= 0x20 && *kbinput < 0x7F) ||
|
||||
(*kbinput >= 0xA0 && *kbinput <= 0xFF)))
|
||||
return NULL;
|
||||
|
||||
for (s = sclist; s != NULL; s = s->next) {
|
||||
if ((s->menus & currmenu) && *kbinput == s->keycode &&
|
||||
meta_key == s->meta)
|
||||
return s;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
wmove(window, row, 0);
|
||||
wclrtoeol(window);
|
||||
}
|
||||
|
||||
/* Move to (x, y) in win, and display a line of n spaces with the
|
||||
* current attributes. */
|
||||
void blank_row(WINDOW *win, int y, int x, int n)
|
||||
{
|
||||
wmove(win, y, x);
|
||||
|
||||
for (; n > 0; n--)
|
||||
waddch(win, ' ');
|
||||
}
|
||||
|
||||
/* Blank the first line of the top portion of the window. */
|
||||
/* Blank the first line of the top portion of the screen. */
|
||||
void blank_titlebar(void)
|
||||
{
|
||||
blank_row(topwin, 0, 0, COLS);
|
||||
mvwprintw(topwin, 0, 0, "%*s", COLS, " ");
|
||||
}
|
||||
|
||||
/* Blank all the lines of the middle portion of the window, i.e. the
|
||||
* edit window. */
|
||||
/* Blank all lines of the middle portion of the screen (the edit window). */
|
||||
void blank_edit(void)
|
||||
{
|
||||
int row;
|
||||
|
||||
for (row = 0; row < editwinrows; row++)
|
||||
blank_row(edit, row, 0, COLS);
|
||||
for (int row = 0; row < editwinrows; row++)
|
||||
blank_row(edit, row);
|
||||
}
|
||||
|
||||
/* Blank the first line of the bottom portion of the window. */
|
||||
/* Blank the first line of the bottom portion of the screen. */
|
||||
void blank_statusbar(void)
|
||||
{
|
||||
blank_row(bottomwin, 0, 0, COLS);
|
||||
blank_row(bottomwin, 0);
|
||||
}
|
||||
|
||||
/* Wipe the status bar clean and include this in the next screen update. */
|
||||
void wipe_statusbar(void)
|
||||
{
|
||||
blank_row(bottomwin, 0, 0, COLS);
|
||||
blank_row(bottomwin, 0);
|
||||
wnoutrefresh(bottomwin);
|
||||
}
|
||||
|
||||
/* If the NO_HELP flag isn't set, blank the last two lines of the bottom
|
||||
* portion of the window. */
|
||||
/* Blank out the two help lines (when they are present). */
|
||||
void blank_bottombars(void)
|
||||
{
|
||||
if (!ISSET(NO_HELP) && LINES > 4) {
|
||||
blank_row(bottomwin, 1, 0, COLS);
|
||||
blank_row(bottomwin, 2, 0, COLS);
|
||||
blank_row(bottomwin, 1);
|
||||
blank_row(bottomwin, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1926,11 +1891,13 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
#define ISO8859_CHAR FALSE
|
||||
#define ZEROWIDTH_CHAR (mbwidth(buf) == 0)
|
||||
#else
|
||||
#define ISO8859_CHAR ((unsigned char)*buf > 0x9F)
|
||||
#define ZEROWIDTH_CHAR FALSE
|
||||
#endif
|
||||
|
||||
while (*buf != '\0' && (column < beyond || mbwidth(buf) == 0)) {
|
||||
while (*buf != '\0' && (column < beyond || ZEROWIDTH_CHAR)) {
|
||||
/* A plain printable ASCII character is one byte, one column. */
|
||||
if (((signed char)*buf > 0x20 && *buf != DEL_CODE) || ISO8859_CHAR) {
|
||||
converted[index++] = *(buf++);
|
||||
@@ -2018,18 +1985,22 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||
|
||||
/* If there is more text than can be shown, make room for the ">". */
|
||||
if (column > beyond || (*buf != '\0' && (isprompt ||
|
||||
(isdata && !ISSET(SOFTWRAP))))) {
|
||||
(isdata && !ISSET(SOFTWRAP))))) {
|
||||
#ifdef ENABLE_UTF8
|
||||
do {
|
||||
index = step_left(converted, index);
|
||||
} while (mbwidth(converted + index) == 0);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
/* Display the left half of a two-column character as '['. */
|
||||
if (mbwidth(converted + index) == 2)
|
||||
converted[index++] = '[';
|
||||
#else
|
||||
index--;
|
||||
#endif
|
||||
}
|
||||
|
||||
is_shorter = (column < beyond);
|
||||
|
||||
/* Null-terminate the converted string. */
|
||||
converted[index] = '\0';
|
||||
|
||||
@@ -2124,8 +2095,8 @@ void titlebar(const char *path)
|
||||
state = _("View");
|
||||
else if (ISSET(RESTRICTED))
|
||||
state = _("Restricted");
|
||||
|
||||
pluglen = breadth(_("Modified")) + 1;
|
||||
else
|
||||
pluglen = breadth(_("Modified")) + 1;
|
||||
}
|
||||
|
||||
/* Determine the widths of the four elements, including their padding. */
|
||||
@@ -2135,10 +2106,8 @@ void titlebar(const char *path)
|
||||
prefixlen++;
|
||||
pathlen = breadth(path);
|
||||
statelen = breadth(state) + 2;
|
||||
if (statelen > 2) {
|
||||
if (statelen > 2)
|
||||
pathlen++;
|
||||
pluglen = 0;
|
||||
}
|
||||
|
||||
/* Only print the version message when there is room for it. */
|
||||
if (verlen + prefixlen + pathlen + pluglen + statelen <= COLS)
|
||||
@@ -2194,30 +2163,15 @@ void titlebar(const char *path)
|
||||
wrefresh(topwin);
|
||||
}
|
||||
|
||||
/* Display a normal message on the statusbar, quietly. */
|
||||
void statusbar(const char *msg)
|
||||
{
|
||||
statusline(HUSH, msg);
|
||||
}
|
||||
|
||||
/* Warn the user on the statusbar and pause for a moment, so that the
|
||||
* message can be noticed and read. */
|
||||
void warn_and_shortly_pause(const char *msg)
|
||||
{
|
||||
statusline(ALERT, msg);
|
||||
napms(1800);
|
||||
}
|
||||
|
||||
/* Display a message on the statusbar, and set suppress_cursorpos to
|
||||
* TRUE, so that the message won't be immediately overwritten if
|
||||
* constant cursor position display is on. */
|
||||
void statusline(message_type importance, const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
static int alerts = 0;
|
||||
int colorpair;
|
||||
char *compound, *message;
|
||||
size_t start_col;
|
||||
static size_t start_col = 0;
|
||||
bool bracketed;
|
||||
#ifndef NANO_TINY
|
||||
bool old_whitespace = ISSET(WHITESPACE_DISPLAY);
|
||||
@@ -2240,20 +2194,23 @@ void statusline(message_type importance, const char *msg, ...)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If the ALERT status has been reset, reset the counter. */
|
||||
if (lastmessage == HUSH)
|
||||
alerts = 0;
|
||||
|
||||
/* Shortly pause after each of the first three alert messages,
|
||||
* to give the user time to read them. */
|
||||
if (lastmessage == ALERT && alerts < 4 && !ISSET(NO_PAUSES))
|
||||
napms(1200);
|
||||
/* If there are multiple alert messages, add trailing dots to the first. */
|
||||
if (lastmessage == ALERT) {
|
||||
if (start_col > 4) {
|
||||
wmove(bottomwin, 0, COLS + 2 - start_col);
|
||||
wattron(bottomwin, interface_color_pair[ERROR_MESSAGE]);
|
||||
waddstr(bottomwin, "...");
|
||||
wattroff(bottomwin, interface_color_pair[ERROR_MESSAGE]);
|
||||
wnoutrefresh(bottomwin);
|
||||
start_col = 0;
|
||||
napms(100);
|
||||
beep();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (importance == ALERT) {
|
||||
if (++alerts > 3 && !ISSET(NO_PAUSES))
|
||||
msg = _("Further warnings were suppressed");
|
||||
else if (alerts < 4)
|
||||
beep();
|
||||
beep();
|
||||
colorpair = interface_color_pair[ERROR_MESSAGE];
|
||||
} else if (importance == NOTICE)
|
||||
colorpair = interface_color_pair[SELECTED_TEXT];
|
||||
@@ -2307,6 +2264,20 @@ void statusline(message_type importance, const char *msg, ...)
|
||||
statusblank = 26;
|
||||
}
|
||||
|
||||
/* Display a normal message on the statusbar, quietly. */
|
||||
void statusbar(const char *msg)
|
||||
{
|
||||
statusline(HUSH, msg);
|
||||
}
|
||||
|
||||
/* Warn the user on the statusbar and pause for a moment, so that the
|
||||
* message can be noticed and read. */
|
||||
void warn_and_shortly_pause(const char *msg)
|
||||
{
|
||||
statusline(ALERT, msg);
|
||||
napms(1800);
|
||||
}
|
||||
|
||||
/* Display the shortcut list corresponding to menu on the last two rows
|
||||
* of the bottom portion of the window. */
|
||||
void bottombars(int menu)
|
||||
@@ -2321,14 +2292,11 @@ void bottombars(int menu)
|
||||
if (ISSET(NO_HELP) || LINES < 5)
|
||||
return;
|
||||
|
||||
/* Determine how many shortcuts there are to show. */
|
||||
number = length_of_list(menu);
|
||||
|
||||
if (number > MAIN_VISIBLE)
|
||||
number = MAIN_VISIBLE;
|
||||
/* Determine how many shortcuts must be shown. */
|
||||
number = shown_entries_for(menu);
|
||||
|
||||
/* Compute the width of each keyname-plus-explanation pair. */
|
||||
itemwidth = COLS / ((number / 2) + (number % 2));
|
||||
itemwidth = COLS / ((number + 1) / 2);
|
||||
|
||||
/* If there is no room, don't print anything. */
|
||||
if (itemwidth == 0)
|
||||
@@ -2413,24 +2381,19 @@ void place_the_cursor(void)
|
||||
openfile->current_y = row;
|
||||
}
|
||||
|
||||
/* edit_draw() takes care of the job of actually painting a line into
|
||||
* the edit window. fileptr is the line to be painted, at row row of
|
||||
* the window. converted is the actual string to be written to the
|
||||
* window, with tabs and control characters replaced by strings of
|
||||
* regular characters. from_col is the column number of the first
|
||||
* 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(linestruct *fileptr, const char *converted,
|
||||
int row, size_t from_col)
|
||||
/* Draw the given text on the given row of the edit window. line is the
|
||||
* line to be drawn, and converted is the actual string to be written with
|
||||
* tabs and control characters replaced by strings of regular characters.
|
||||
* from_col is the column number of the first character of this "page". */
|
||||
void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||
{
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_COLOR)
|
||||
size_t from_x = actual_x(fileptr->data, from_col);
|
||||
/* The position in fileptr->data of the leftmost character
|
||||
size_t from_x = actual_x(line->data, from_col);
|
||||
/* The position in the line's data of the leftmost character
|
||||
* that displays at least partially on the window. */
|
||||
size_t till_x = actual_x(fileptr->data, from_col + editwincols - 1) + 1;
|
||||
/* The position in fileptr->data of the first character that is
|
||||
* completely off the window to the right. Note that till_x
|
||||
size_t till_x = actual_x(line->data, from_col + editwincols - 1) + 1;
|
||||
/* The position in the line's data of the first character that
|
||||
* is completely off the window to the right. Note that till_x
|
||||
* might be beyond the null terminator of the string. */
|
||||
#endif
|
||||
|
||||
@@ -2444,8 +2407,9 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
||||
mvwprintw(edit, row, 0, "%*s", margin - 1, " ");
|
||||
else
|
||||
#endif
|
||||
mvwprintw(edit, row, 0, "%*zd", margin - 1, fileptr->lineno);
|
||||
mvwprintw(edit, row, 0, "%*zd", margin - 1, line->lineno);
|
||||
wattroff(edit, interface_color_pair[LINE_NUMBER]);
|
||||
wprintw(edit, " ");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2453,6 +2417,10 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
||||
* and the marking highlight on just the pieces that need it. */
|
||||
mvwaddstr(edit, row, margin, converted);
|
||||
|
||||
/* When needed, clear the remainder of the row. */
|
||||
if (is_shorter || ISSET(SOFTWRAP))
|
||||
wclrtoeol(edit);
|
||||
|
||||
#ifdef USING_OLD_NCURSES
|
||||
/* Tell ncurses to really redraw the line without trying to optimize
|
||||
* for what it thinks is already there, because it gets it wrong in
|
||||
@@ -2467,8 +2435,8 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
||||
const colortype *varnish = openfile->colorstrings;
|
||||
|
||||
/* If there are multiline regexes, make sure there is a cache. */
|
||||
if (openfile->syntax->nmultis > 0)
|
||||
alloc_multidata_if_needed(fileptr);
|
||||
if (openfile->syntax->nmultis > 0 && line->multidata == NULL)
|
||||
set_up_multicache(line);
|
||||
|
||||
/* Iterate through all the coloring regexes. */
|
||||
for (; varnish != NULL; varnish = varnish->next) {
|
||||
@@ -2482,9 +2450,9 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
||||
/* The place in converted from where painting starts. */
|
||||
regmatch_t match;
|
||||
/* The match positions of a single-line regex. */
|
||||
const linestruct *start_line = fileptr->prev;
|
||||
/* The first line before fileptr that matches 'start'. */
|
||||
const linestruct *end_line = fileptr;
|
||||
const linestruct *start_line = line->prev;
|
||||
/* The first line before line that matches 'start'. */
|
||||
const linestruct *end_line = line;
|
||||
/* The line that matches 'end'. */
|
||||
regmatch_t startmatch, endmatch;
|
||||
/* The match positions of the start and end regexes. */
|
||||
@@ -2507,13 +2475,13 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
||||
* unless index is zero. If regexec() returns
|
||||
* REG_NOMATCH, there are no more matches in the
|
||||
* line. */
|
||||
if (regexec(varnish->start, &fileptr->data[index], 1,
|
||||
if (regexec(varnish->start, &line->data[index], 1,
|
||||
&match, (index == 0) ? 0 : REG_NOTBOL) != 0)
|
||||
break;
|
||||
|
||||
/* If the match is of length zero, skip it. */
|
||||
if (match.rm_so == match.rm_eo) {
|
||||
index = step_right(fileptr->data, index + match.rm_eo);
|
||||
index = step_right(line->data, index + match.rm_eo);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2527,12 +2495,12 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
||||
continue;
|
||||
|
||||
start_col = (match.rm_so <= from_x) ?
|
||||
0 : wideness(fileptr->data,
|
||||
0 : wideness(line->data,
|
||||
match.rm_so) - from_col;
|
||||
|
||||
thetext = converted + actual_x(converted, start_col);
|
||||
|
||||
paintlen = actual_x(thetext, wideness(fileptr->data,
|
||||
paintlen = actual_x(thetext, wideness(line->data,
|
||||
match.rm_eo) - from_col - start_col);
|
||||
|
||||
mvwaddnstr(edit, row, margin + start_col, thetext, paintlen);
|
||||
@@ -2543,7 +2511,7 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
||||
/* Second case: varnish is a multiline expression. */
|
||||
|
||||
/* Assume nothing gets painted until proven otherwise below. */
|
||||
fileptr->multidata[varnish->id] = CNONE;
|
||||
line->multidata[varnish->id] = CNONE;
|
||||
|
||||
/* First check the multidata of the preceding line -- it tells
|
||||
* us about the situation so far, and thus what to do here. */
|
||||
@@ -2617,31 +2585,31 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
||||
|
||||
/* If there is no end, there is nothing to paint. */
|
||||
if (end_line == NULL) {
|
||||
fileptr->multidata[varnish->id] = CWOULDBE;
|
||||
line->multidata[varnish->id] = CWOULDBE;
|
||||
goto tail_of_loop;
|
||||
}
|
||||
|
||||
/* If the end is on a later line, paint whole line, and be done. */
|
||||
if (end_line != fileptr) {
|
||||
if (end_line != line) {
|
||||
mvwaddnstr(edit, row, margin, converted, -1);
|
||||
fileptr->multidata[varnish->id] = CWHOLELINE;
|
||||
line->multidata[varnish->id] = CWHOLELINE;
|
||||
goto tail_of_loop;
|
||||
}
|
||||
|
||||
/* Only if it is visible, paint the part to be coloured. */
|
||||
if (endmatch.rm_eo > from_x) {
|
||||
paintlen = actual_x(converted, wideness(fileptr->data,
|
||||
paintlen = actual_x(converted, wideness(line->data,
|
||||
endmatch.rm_eo) - from_col);
|
||||
mvwaddnstr(edit, row, margin, converted, paintlen);
|
||||
}
|
||||
fileptr->multidata[varnish->id] = CBEGINBEFORE;
|
||||
line->multidata[varnish->id] = CBEGINBEFORE;
|
||||
|
||||
step_two:
|
||||
/* Second step: look for starts on this line, but begin
|
||||
* looking only after an end match, if there is one. */
|
||||
index = (paintlen == 0) ? 0 : endmatch.rm_eo;
|
||||
|
||||
while (regexec(varnish->start, fileptr->data + index,
|
||||
while (regexec(varnish->start, line->data + index,
|
||||
1, &startmatch, (index == 0) ?
|
||||
0 : REG_NOTBOL) == 0) {
|
||||
/* Translate the match to be relative to the
|
||||
@@ -2650,12 +2618,12 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
||||
startmatch.rm_eo += index;
|
||||
|
||||
start_col = (startmatch.rm_so <= from_x) ?
|
||||
0 : wideness(fileptr->data,
|
||||
0 : wideness(line->data,
|
||||
startmatch.rm_so) - from_col;
|
||||
|
||||
thetext = converted + actual_x(converted, start_col);
|
||||
|
||||
if (regexec(varnish->end, fileptr->data + startmatch.rm_eo,
|
||||
if (regexec(varnish->end, line->data + startmatch.rm_eo,
|
||||
1, &endmatch, (startmatch.rm_eo == 0) ?
|
||||
0 : REG_NOTBOL) == 0) {
|
||||
/* Translate the end match to be relative to
|
||||
@@ -2666,27 +2634,27 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
||||
* it is more than zero characters long. */
|
||||
if (endmatch.rm_eo > from_x &&
|
||||
endmatch.rm_eo > startmatch.rm_so) {
|
||||
paintlen = actual_x(thetext, wideness(fileptr->data,
|
||||
paintlen = actual_x(thetext, wideness(line->data,
|
||||
endmatch.rm_eo) - from_col - start_col);
|
||||
|
||||
mvwaddnstr(edit, row, margin + start_col,
|
||||
thetext, paintlen);
|
||||
|
||||
fileptr->multidata[varnish->id] = CSTARTENDHERE;
|
||||
line->multidata[varnish->id] = CSTARTENDHERE;
|
||||
}
|
||||
index = endmatch.rm_eo;
|
||||
/* If both start and end match are anchors, advance. */
|
||||
if (startmatch.rm_so == startmatch.rm_eo &&
|
||||
endmatch.rm_so == endmatch.rm_eo) {
|
||||
if (fileptr->data[index] == '\0')
|
||||
if (line->data[index] == '\0')
|
||||
break;
|
||||
index = step_right(fileptr->data, index);
|
||||
index = step_right(line->data, index);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/* There is no end on this line. But maybe on later lines? */
|
||||
end_line = fileptr->next;
|
||||
end_line = line->next;
|
||||
|
||||
while (end_line != NULL && regexec(varnish->end, end_line->data,
|
||||
0, NULL, 0) == REG_NOMATCH)
|
||||
@@ -2694,13 +2662,13 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
||||
|
||||
/* If there is no end, we're done with this regex. */
|
||||
if (end_line == NULL) {
|
||||
fileptr->multidata[varnish->id] = CWOULDBE;
|
||||
line->multidata[varnish->id] = CWOULDBE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Paint the rest of the line, and we're done. */
|
||||
mvwaddnstr(edit, row, margin + start_col, thetext, -1);
|
||||
fileptr->multidata[varnish->id] = CENDAFTER;
|
||||
line->multidata[varnish->id] = CENDAFTER;
|
||||
break;
|
||||
}
|
||||
tail_of_loop:
|
||||
@@ -2718,7 +2686,7 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
||||
size_t charlen = 1;
|
||||
|
||||
if (*(converted + target_x) != '\0') {
|
||||
charlen = parse_mbchar(converted + target_x, striped_char, NULL);
|
||||
charlen = collect_char(converted + target_x, striped_char);
|
||||
target_column = wideness(converted, target_x);
|
||||
} else if (target_column + 1 == editwincols) {
|
||||
/* Defeat a VTE bug -- see https://sv.gnu.org/bugs/?55896. */
|
||||
@@ -2738,13 +2706,11 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
||||
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 &&
|
||||
(fileptr->lineno <= openfile->mark->lineno ||
|
||||
fileptr->lineno <= openfile->current->lineno) &&
|
||||
(fileptr->lineno >= openfile->mark->lineno ||
|
||||
fileptr->lineno >= openfile->current->lineno)) {
|
||||
/* If the line is at least partially selected, paint the marked part. */
|
||||
if (openfile->mark && ((line->lineno >= openfile->mark->lineno &&
|
||||
line->lineno <= openfile->current->lineno) ||
|
||||
(line->lineno <= openfile->mark->lineno &&
|
||||
line->lineno >= openfile->current->lineno))) {
|
||||
const linestruct *top, *bot;
|
||||
/* The lines where the marked region begins and ends. */
|
||||
size_t top_x, bot_x;
|
||||
@@ -2758,15 +2724,15 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
||||
|
||||
get_region(&top, &top_x, &bot, &bot_x, NULL);
|
||||
|
||||
if (top->lineno < fileptr->lineno || top_x < from_x)
|
||||
if (top->lineno < line->lineno || top_x < from_x)
|
||||
top_x = from_x;
|
||||
if (bot->lineno > fileptr->lineno || bot_x > till_x)
|
||||
if (bot->lineno > line->lineno || bot_x > till_x)
|
||||
bot_x = till_x;
|
||||
|
||||
/* Only paint if the marked part of the line is on this page. */
|
||||
if (top_x < till_x && bot_x > from_x) {
|
||||
/* Compute on which screen column to start painting. */
|
||||
start_col = wideness(fileptr->data, top_x) - from_col;
|
||||
start_col = wideness(line->data, top_x) - from_col;
|
||||
|
||||
if (start_col < 0)
|
||||
start_col = 0;
|
||||
@@ -2776,7 +2742,7 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
||||
/* If the end of the mark is onscreen, compute how many
|
||||
* characters to paint. Otherwise, just paint all. */
|
||||
if (bot_x < till_x) {
|
||||
size_t end_col = wideness(fileptr->data, bot_x) - from_col;
|
||||
size_t end_col = wideness(line->data, bot_x) - from_col;
|
||||
paintlen = actual_x(thetext, end_col - start_col);
|
||||
}
|
||||
|
||||
@@ -2788,40 +2754,29 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
||||
#endif /* !NANO_TINY */
|
||||
}
|
||||
|
||||
/* Redraw the line at fileptr. The line will be displayed so that the
|
||||
* character with the given index is visible -- if necessary, the line
|
||||
* will be horizontally scrolled. In softwrap mode, however, the entire
|
||||
* 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(linestruct *fileptr, size_t index)
|
||||
/* Redraw the given line so that the character at the given index is visible
|
||||
* -- if necessary, scroll the line horizontally (when not softwrapping).
|
||||
* Return the number of rows "consumed" (relevant when softwrapping). */
|
||||
int update_line(linestruct *line, size_t index)
|
||||
{
|
||||
int row = 0;
|
||||
int row;
|
||||
/* The row in the edit window we will be updating. */
|
||||
char *converted;
|
||||
/* The data of the line with tabs and control characters expanded. */
|
||||
size_t from_col = 0;
|
||||
size_t from_col;
|
||||
/* From which column a horizontally scrolled line is displayed. */
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP))
|
||||
return update_softwrapped_line(fileptr);
|
||||
return update_softwrapped_line(line);
|
||||
#endif
|
||||
|
||||
row = fileptr->lineno - openfile->edittop->lineno;
|
||||
row = line->lineno - openfile->edittop->lineno;
|
||||
from_col = get_page_start(wideness(line->data, index));
|
||||
|
||||
/* First, blank out the row. */
|
||||
blank_row(edit, row, 0, COLS);
|
||||
|
||||
/* Next, find out from which column to start displaying the line. */
|
||||
from_col = get_page_start(wideness(fileptr->data, index));
|
||||
|
||||
/* Expand the line, replacing tabs with spaces, and control
|
||||
* characters with their displayed forms. */
|
||||
converted = display_string(fileptr->data, from_col, editwincols, TRUE, FALSE);
|
||||
|
||||
/* Draw the line. */
|
||||
edit_draw(fileptr, converted, row, from_col);
|
||||
/* Expand the piece to be drawn to its representable form, and draw it. */
|
||||
converted = display_string(line->data, from_col, editwincols, TRUE, FALSE);
|
||||
draw_row(row, converted, line, from_col);
|
||||
free(converted);
|
||||
|
||||
if (from_col > 0) {
|
||||
@@ -2829,7 +2784,7 @@ int update_line(linestruct *fileptr, size_t index)
|
||||
mvwaddch(edit, row, margin, '<');
|
||||
wattroff(edit, hilite_attribute);
|
||||
}
|
||||
if (breadth(fileptr->data) > from_col + editwincols) {
|
||||
if (breadth(line->data) > from_col + editwincols) {
|
||||
wattron(edit, hilite_attribute);
|
||||
mvwaddch(edit, row, COLS - 1, '>');
|
||||
wattroff(edit, hilite_attribute);
|
||||
@@ -2844,31 +2799,31 @@ int update_line(linestruct *fileptr, size_t index)
|
||||
#ifndef NANO_TINY
|
||||
/* 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(linestruct *fileptr)
|
||||
* Return the number of rows that were "consumed". */
|
||||
int update_softwrapped_line(linestruct *line)
|
||||
{
|
||||
int row = 0;
|
||||
/* The row in the edit window we will write to. */
|
||||
linestruct *line = openfile->edittop;
|
||||
linestruct *someline = openfile->edittop;
|
||||
/* An iterator needed to find the relevant row. */
|
||||
int starting_row;
|
||||
/* The first row in the edit window that gets updated. */
|
||||
size_t from_col = 0;
|
||||
/* The starting column of the current chunk. */
|
||||
size_t to_col = 0;
|
||||
/* To which column a line is displayed. */
|
||||
/* The end column of the current chunk. */
|
||||
char *converted;
|
||||
/* The data of the chunk with tabs and control characters expanded. */
|
||||
|
||||
if (fileptr == openfile->edittop)
|
||||
if (line == openfile->edittop)
|
||||
from_col = openfile->firstcolumn;
|
||||
else
|
||||
row -= chunk_for(openfile->firstcolumn, openfile->edittop);
|
||||
|
||||
/* Find out on which screen row the target line should be shown. */
|
||||
while (line != fileptr && line != NULL) {
|
||||
row += number_of_chunks_in(line) + 1;
|
||||
line = line->next;
|
||||
while (someline != line && someline != NULL) {
|
||||
row += number_of_chunks_in(someline) + 1;
|
||||
someline = someline->next;
|
||||
}
|
||||
|
||||
/* If the first chunk is offscreen, don't even try to display it. */
|
||||
@@ -2883,14 +2838,12 @@ int update_softwrapped_line(linestruct *fileptr)
|
||||
while (row < editwinrows) {
|
||||
bool end_of_line = FALSE;
|
||||
|
||||
to_col = get_softwrap_breakpoint(fileptr->data, from_col, &end_of_line);
|
||||
|
||||
blank_row(edit, row, 0, COLS);
|
||||
to_col = get_softwrap_breakpoint(line->data, from_col, &end_of_line);
|
||||
|
||||
/* Convert the chunk to its displayable form and draw it. */
|
||||
converted = display_string(fileptr->data, from_col, to_col - from_col,
|
||||
converted = display_string(line->data, from_col, to_col - from_col,
|
||||
TRUE, FALSE);
|
||||
edit_draw(fileptr, converted, row++, from_col);
|
||||
draw_row(row++, converted, line, from_col);
|
||||
free(converted);
|
||||
|
||||
if (end_of_line)
|
||||
@@ -2905,7 +2858,7 @@ int update_softwrapped_line(linestruct *fileptr)
|
||||
}
|
||||
|
||||
if (spotlighted && !inhelp)
|
||||
spotlight(light_from_col, light_to_col);
|
||||
spotlight_softwrapped(light_from_col, light_to_col);
|
||||
|
||||
return (row - starting_row);
|
||||
}
|
||||
@@ -3092,7 +3045,7 @@ size_t get_softwrap_breakpoint(const char *text, size_t leftedge,
|
||||
|
||||
/* First find the place in text where the current chunk starts. */
|
||||
while (*text != '\0' && column < leftedge)
|
||||
text += parse_mbchar(text, NULL, &column);
|
||||
text += advance_over(text, &column);
|
||||
|
||||
/* Now find the place in text where this chunk should end. */
|
||||
while (*text != '\0' && column <= goal_column) {
|
||||
@@ -3103,7 +3056,7 @@ size_t get_softwrap_breakpoint(const char *text, size_t leftedge,
|
||||
}
|
||||
|
||||
breaking_col = (*text == '\t' ? goal_column : column);
|
||||
text += parse_mbchar(text, NULL, &column);
|
||||
text += advance_over(text, &column);
|
||||
}
|
||||
|
||||
/* If we didn't overshoot the limit, we've found a breaking point;
|
||||
@@ -3116,7 +3069,7 @@ size_t get_softwrap_breakpoint(const char *text, size_t leftedge,
|
||||
/* If we're softwrapping at blanks and we found at least one blank, break
|
||||
* after that blank -- if it doesn't overshoot the screen's edge. */
|
||||
if (farthest_blank != NULL) {
|
||||
parse_mbchar(farthest_blank, NULL, &last_blank_col);
|
||||
advance_over(farthest_blank, &last_blank_col);
|
||||
|
||||
if (last_blank_col <= goal_column)
|
||||
return last_blank_col;
|
||||
@@ -3167,14 +3120,14 @@ size_t chunk_for(size_t column, linestruct *line)
|
||||
* column is on. */
|
||||
size_t leftedge_for(size_t column, linestruct *line)
|
||||
{
|
||||
size_t leftedge;
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
size_t leftedge;
|
||||
|
||||
if (!ISSET(SOFTWRAP))
|
||||
get_chunk_and_edge(column, line, &leftedge);
|
||||
|
||||
return leftedge;
|
||||
} else
|
||||
return 0;
|
||||
|
||||
get_chunk_and_edge(column, line, &leftedge);
|
||||
|
||||
return leftedge;
|
||||
}
|
||||
|
||||
/* Return the row of the last softwrapped chunk of the given line, relative to
|
||||
@@ -3337,7 +3290,7 @@ void edit_refresh(void)
|
||||
}
|
||||
|
||||
while (row < editwinrows)
|
||||
blank_row(edit, row++, 0, COLS);
|
||||
blank_row(edit, row++);
|
||||
|
||||
place_the_cursor();
|
||||
wnoutrefresh(edit);
|
||||
@@ -3466,21 +3419,12 @@ 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;
|
||||
size_t right_edge = get_page_start(from_col) + editwincols;
|
||||
bool overshoots = FALSE;
|
||||
char *word;
|
||||
|
||||
place_the_cursor();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
spotlight_softwrapped(from_col, to_col);
|
||||
return;
|
||||
}
|
||||
#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;
|
||||
@@ -3489,19 +3433,16 @@ void spotlight(size_t from_col, size_t to_col)
|
||||
|
||||
/* This is so we can show zero-length matches. */
|
||||
if (to_col == from_col) {
|
||||
word = mallocstrcpy(NULL, " ");
|
||||
word = copy_of(" ");
|
||||
to_col++;
|
||||
} else
|
||||
word = display_string(openfile->current->data, from_col,
|
||||
to_col - from_col, FALSE, overshoots);
|
||||
|
||||
wattron(edit, interface_color_pair[SELECTED_TEXT]);
|
||||
|
||||
waddnstr(edit, word, actual_x(word, to_col));
|
||||
|
||||
if (overshoots)
|
||||
mvwaddch(edit, openfile->current_y, COLS - 1, '>');
|
||||
|
||||
wattroff(edit, interface_color_pair[SELECTED_TEXT]);
|
||||
|
||||
free(word);
|
||||
@@ -3520,6 +3461,8 @@ void spotlight_softwrapped(size_t from_col, size_t to_col)
|
||||
bool end_of_line = FALSE;
|
||||
char *word;
|
||||
|
||||
place_the_cursor();
|
||||
|
||||
while (row < editwinrows) {
|
||||
break_col = get_softwrap_breakpoint(openfile->current->data,
|
||||
leftedge, &end_of_line);
|
||||
@@ -3533,16 +3476,14 @@ void spotlight_softwrapped(size_t from_col, size_t to_col)
|
||||
|
||||
/* This is so we can show zero-length matches. */
|
||||
if (break_col == from_col) {
|
||||
word = mallocstrcpy(NULL, " ");
|
||||
word = copy_of(" ");
|
||||
break_col++;
|
||||
} else
|
||||
word = display_string(openfile->current->data, from_col,
|
||||
break_col - from_col, FALSE, FALSE);
|
||||
|
||||
wattron(edit, interface_color_pair[SELECTED_TEXT]);
|
||||
|
||||
waddnstr(edit, word, actual_x(word, break_col));
|
||||
|
||||
wattroff(edit, interface_color_pair[SELECTED_TEXT]);
|
||||
|
||||
free(word);
|
||||
@@ -3550,7 +3491,7 @@ void spotlight_softwrapped(size_t from_col, size_t to_col)
|
||||
if (end_of_line)
|
||||
break;
|
||||
|
||||
wmove(edit, ++row, 0);
|
||||
wmove(edit, ++row, margin);
|
||||
|
||||
leftedge = break_col;
|
||||
from_col = break_col;
|
||||
|
||||
@@ -8,7 +8,7 @@ color red "\<[A-Z_]{2,}\>"
|
||||
color brightgreen "\.(data|subsection|text)"
|
||||
color green "\.(align|file|globl|global|hidden|section|size|type|weak)"
|
||||
color brightyellow "\.(ascii|asciz|byte|double|float|hword|int|long|short|single|struct|word)"
|
||||
icolor brightred "^[[:space:]]*[.0-9A-Z_]*:"
|
||||
color brightred "^[[:space:]]*[.0-9A-Za-z_]*:"
|
||||
color brightcyan "^[[:space:]]*#[[:space:]]*(define|undef|include|ifn?def|endif|elif|else|if|warning|error)"
|
||||
|
||||
# Strings.
|
||||
|
||||
@@ -6,7 +6,7 @@ magic "awk script"
|
||||
comment "#"
|
||||
|
||||
# Records.
|
||||
icolor brightred "\$[0-9A-Z_!@#$*?-]+"
|
||||
color brightred "\$[0-9A-Za-z_!@#$*?-]+"
|
||||
# Awk-set variables.
|
||||
color red "\<(ARGC|ARGIND|ARGV|BINMODE|CONVFMT|ENVIRON|ERRNO|FIELDWIDTHS)\>"
|
||||
color red "\<(FILENAME|FNR|FS|IGNORECASE|LINT|NF|NR|OFMT|OFS|ORS)\>"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
## Here is an example for C/C++.
|
||||
|
||||
syntax c "\.([ch](pp|xx)?|C|cc|c\+\+|H|hh|ii?)$"
|
||||
syntax c "\.([ch](pp|xx)?|C|cc|c\+\+|cu|H|hh|ii?)$"
|
||||
header "-\*-.*\<C(\+\+)?((;|\s).*)?-\*-"
|
||||
magic "^(C|C\+\+) (source|program)"
|
||||
comment "//"
|
||||
|
||||
@@ -10,7 +11,7 @@ color brightred "\<[A-Z_][0-9A-Z_]+\>"
|
||||
color brightmagenta "^[[:space:]]*[A-Z_a-z]+:[[:space:]]*$"
|
||||
|
||||
color green "\<(float|double|bool|char|int|short|long|sizeof|enum|void|auto|static|const|struct|union|typedef|extern|(un)?signed|inline)\>"
|
||||
color green "\<([[:lower:]]+|(u_?)?int(8|16|32|64|ptr))_t\>"
|
||||
color green "\<([[:lower:]][[:lower:]_]*|(u_?)?int(8|16|32|64))_t\>"
|
||||
color green "\<(class|namespace|template|public|protected|private|typename|this|friend|virtual|override|using|mutable|volatile|register|explicit)\>"
|
||||
color brightyellow "\<(for|if|while|do|else|case|default|switch)\>"
|
||||
color brightyellow "\<(try|throw|catch|operator|new|delete)\>"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
syntax cmake "(CMakeLists\.txt|\.cmake)$"
|
||||
comment "#"
|
||||
|
||||
icolor green "^[[:space:]]*[A-Z0-9_]+"
|
||||
color green "^[[:space:]]*[0-9A-Za-z_]+"
|
||||
icolor brightyellow "^[[:space:]]*(include|include_directories|include_external_msproject)\>"
|
||||
|
||||
icolor brightgreen "^[[:space:]]*((else|end)?if|else|(end)?while|(end)?foreach|break)\>"
|
||||
@@ -12,7 +12,7 @@ color brightgreen "[[:space:]](OR|AND|IS_NEWER_THAN|MATCHES|(STR|VERSION_)?(LESS
|
||||
|
||||
icolor brightred "^[[:space:]]*((end)?(function|macro)|return)"
|
||||
|
||||
icolor cyan start="\$(\{|ENV\{)" end="\}"
|
||||
icolor cyan start="\$(ENV)?\{" end="\}"
|
||||
color magenta "\<(APPLE|UNIX|WIN32|CYGWIN|BORLAND|MINGW|MSVC(_IDE|60|71|80|90)?)\>"
|
||||
|
||||
color brightblue "(^|[[:space:]])#.*"
|
||||
|
||||
@@ -15,3 +15,6 @@ color brightred "(GNU )?[Nn]ano [1-4]\.[0-9][-.[:alnum:]]*\>"
|
||||
|
||||
# Email addresses.
|
||||
color magenta "<[[:alnum:].%_+-]+@[[:alnum:].-]+\.[[:alpha:]]{2,}>"
|
||||
|
||||
# Bracketed captions in certain config files.
|
||||
color brightgreen "^\[[^][]+\]$"
|
||||
|
||||
@@ -34,7 +34,7 @@ icolor yellow "\<(.or.|repeat|select case|then|where|while)\>"
|
||||
icolor magenta "\<(continue|cycle|exit|go?to|result|return)\>"
|
||||
|
||||
# Strings.
|
||||
icolor yellow "<[^= ]*>" ""(\\.|[^"])*""
|
||||
color yellow "<[^= ]*>" ""(\\.|[^"])*""
|
||||
|
||||
# Comments.
|
||||
icolor blue "!.*"
|
||||
color blue "!.*"
|
||||
|
||||
@@ -17,7 +17,7 @@ color green "-(eq|ne|gt|lt|ge|le)\>"
|
||||
## Variables... official portage ones in red, all others in bright red:
|
||||
color brightred "\$[-0-9@*#?$!]" "\$[[:alpha:]_][[:alnum:]_]*"
|
||||
color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:digit:]]|@)+\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
|
||||
color red "\<(EAPI|ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|[HPR]?DEPEND|PROVIDE|PROPERTIES|REQUIRED_USE|RESTRICT|USERLAND)\>"
|
||||
color red "\<(EAPI|ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|[BHPR]?DEPEND|PROVIDE|PROPERTIES|REQUIRED_USE|RESTRICT|USERLAND)\>"
|
||||
color red "\<(S|E?D|T|PV|PF|P|PN|PR|PVR|A|CATEGORY|DISTDIR|FILESDIR|EPREFIX|E?ROOT|WORKDIR)\>"
|
||||
color red "\<(AS|C(PP|XX)?|LD)FLAGS\>" "\<C(HOST|TARGET|BUILD)\>" "\<(MERGE_TYPE|REPLACING_VERSIONS|REPLACED_BY_VERSION)\>"
|
||||
color red "\<EBUILD_PHASE(_FUNC)?\>"
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
syntax go "\.go$"
|
||||
comment "//"
|
||||
|
||||
formatter gofmt -w
|
||||
|
||||
# Types.
|
||||
color green "\<(bool|u?int(8|16|32|64)?|float(32|64)|complex(64|128)|byte|rune|uintptr|string|error)\>"
|
||||
color green "\<((<-[[:space:]]*)chan|chan[[:space:]]*<-|const|func|interface|map|struct|type|var)\>"
|
||||
|
||||
@@ -4,6 +4,8 @@ syntax html "\.html?$"
|
||||
magic "HTML document"
|
||||
comment "<!--|-->"
|
||||
|
||||
formatter tidy -m -q
|
||||
|
||||
# Tags:
|
||||
color cyan "<[[:alpha:]/!?][^>]*>"
|
||||
# Bold, italic, and underlined:
|
||||
@@ -11,18 +13,19 @@ color brightmagenta "</?[biu]>"
|
||||
|
||||
# Named character references:
|
||||
color red "&[^;[:space:]]*;"
|
||||
|
||||
# Attributes:
|
||||
color red "\<(abbr|accept(-charset)?|accesskey|action|alink|align|alt|archive|axis|background|bgcolor|border)="
|
||||
color red "\<(cell(padding|spacing)|char(off|set)?|checked|cite|class(id)?|compact|code(base|tag)?|cols(pan)?)="
|
||||
color red "\<(content(editable)?|contextmenu|coords|data|datetime|declare|defer|dir|disabled|enctype)="
|
||||
color red "\<(for|frame(border)?|headers|height|hidden|href(lang)?|hspace|http-equiv|id|ismap)="
|
||||
color red "\<(label|lang|link|longdesc|margin(height|width)|maxlength|media|method|multiple)="
|
||||
color red "\<(name|nohref|noresize|noshade|object|onclick|onfocus|onload|onmouseover|profile|readonly|rel|rev)="
|
||||
color red "\<(rows(pan)?|rules|scheme|scope|scrolling|selected|shape|size|span|src|standby|start|style|summary)="
|
||||
color red "\<(tabindex|target|text|title|type|usemap|valign|value(type)?|vlink|vspace|width|xmlns|xml:space)="
|
||||
|
||||
# Strings:
|
||||
color green ""(\\.|[^"])*""
|
||||
|
||||
# Attributes:
|
||||
color red "(abbr|accept(-charset)?|accesskey|action|alink|align|alt|archive|axis|background|bgcolor|border)="
|
||||
color red "(cell(padding|spacing)|char(off|set)?|checked|cite|class(id)?|compact|code(base|tag)?|cols(pan)?)="
|
||||
color red "(content(editable)?|contextmenu|coords|data|datetime|declare|defer|dir|disabled|enctype)="
|
||||
color red "(for|frame(border)?|headers|height|hidden|href(lang)?|hspace|http-equiv|id|ismap)="
|
||||
color red "(label|lang|link|longdesc|margin(height|width)|maxlength|media|method|multiple)="
|
||||
color red "(name|nohref|noresize|noshade|object|onclick|onfocus|onload|onmouseover|profile|readonly|rel|rev)="
|
||||
color red "(rows(pan)?|rules|scheme|scope|scrolling|selected|shape|size|span|src|standby|start|style|summary)="
|
||||
color red "(tabindex|target|text|title|type|usemap|valign|value(type)?|vlink|vspace|width|xmlns|xml:space)="
|
||||
|
||||
# Comments:
|
||||
color yellow start="<!--" end="-->"
|
||||
|
||||
@@ -12,7 +12,9 @@ color brightyellow "\<(await|export|import|throw|try|catch|finally|new|delete)\>
|
||||
color magenta "\<(break|continue|return|yield)\>"
|
||||
|
||||
# Octal/decimal and hexadecimal numbers.
|
||||
color cyan "\<[0-9]+\>" "\<0x[0-9A-Fa-f]+\>"
|
||||
color cyan "\<([0-9]+|0x[0-9A-Fa-f]+)\>"
|
||||
# Special values.
|
||||
color cyan "\<(true|false|null|undefined)\>"
|
||||
|
||||
# Strings.
|
||||
color brightmagenta ""(\\.|[^"])*"" "'(\\.|[^'])*'" "`(\\.|[^`])*`"
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
|
||||
syntax lua "\.lua$"
|
||||
magic "Lua script"
|
||||
linter "luacheck --no-color"
|
||||
comment "--"
|
||||
|
||||
linter luacheck --no-color
|
||||
|
||||
color brightwhite "\[\[.*\]\]"
|
||||
|
||||
# Operators
|
||||
@@ -44,7 +45,7 @@ color brightmagenta "\<(false|nil|true)\>"
|
||||
|
||||
# Decimal and hexadecimal numbers
|
||||
color red "\<[0-9]+(\.[0-9]*)?([Ee][+-]?[0-9]+)?\>"
|
||||
icolor red "\<0x[0-9a-f]+(\.[0-9a-f]*)?(p[+-]?[0-9]+)?\>"
|
||||
color red "\<0x[0-9A-Fa-f]+(\.[0-9A-Fa-f]*)?([Pp][+-]?[0-9]+)?\>"
|
||||
|
||||
# Brackets
|
||||
color brightmagenta "\(|\)|\[|\]|\{|\}"
|
||||
|
||||
@@ -4,6 +4,6 @@ syntax mgp "\.mgp$"
|
||||
header "^%include.*"
|
||||
comment "#"
|
||||
|
||||
icolor green "^%[a-z].*"
|
||||
color green "^%[A-Za-z].*"
|
||||
color cyan "(^|[[:space:]])(#|%%).*"
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
syntax nanohelp
|
||||
|
||||
# Key combos:
|
||||
color cyan "\^[]4-8A-Z^\_◀▶▲▼]" "[◀▶▲▼]" "\<M-." "\<F1?[0-9]"
|
||||
color cyan "\^[]/4-8A-Z\^_◀▶▲▼]" "[◀▶▲▼]" "\<M-." "\<F([1-9]|1[0-9]|2[0-4])"
|
||||
color cyan "\<((Sh-)?Tab|Enter|Ins|(Sh-\^?)?Del|Space|Bsp|Up|Down|Left|Right|Home|End|PgUp|PgDn)\>"
|
||||
|
||||
# Quoted indicators:
|
||||
|
||||
@@ -3,26 +3,26 @@
|
||||
syntax nanorc "\.?nanorc$"
|
||||
comment "#"
|
||||
|
||||
# Possible errors and parameters
|
||||
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|i?color|extendsyntax).*"
|
||||
# Everything that does not get recolored is invalid
|
||||
color brightred ".*"
|
||||
|
||||
# Keywords
|
||||
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:]]+.*"
|
||||
icolor brightgreen "^[[:space:]]*(syntax|linter)[[:space:]]+[^[:blank:]]+"
|
||||
icolor green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|extendsyntax)\>"
|
||||
color 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)\>"
|
||||
color 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))?\>"
|
||||
color brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|selectedcolor|speller|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:space:]]+"
|
||||
color brightgreen "^[[:space:]]*set[[:space:]]+(fill[[:space:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:space:]]+[1-9][0-9]*)\>"
|
||||
color brightgreen "^[[:space:]]*bind[[:space:]]+((\^([[:alpha:]]|[]/@\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|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:]]*$)"
|
||||
color brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([[:alpha:]]|[]/@\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:space:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
|
||||
color brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|comment|formatter|linter|tabgives)[[:space:]]+.*"
|
||||
color brightgreen "^[[:space:]]*(syntax[[:space:]]+[^[:blank:]]+|(formatter|linter)[[:space:]]+.+)"
|
||||
color green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|formatter|linter|tabgives|extendsyntax)\>"
|
||||
|
||||
# Strings
|
||||
color brightmagenta "([[:space:]]|(start|end)=)".+"([[:space:]]|$)"
|
||||
|
||||
# Colors
|
||||
icolor yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>"
|
||||
icolor magenta "^[[:space:]]*i?color\>" "\<(start|end)="
|
||||
color yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>"
|
||||
color magenta "^[[:space:]]*i?color\>" "\<(start|end)="
|
||||
|
||||
# Comments
|
||||
color brightblue "(^|[[:space:]]+)#.*"
|
||||
|
||||
@@ -7,9 +7,18 @@ comment "#"
|
||||
|
||||
color red "\<(accept|alarm|atan2|bin(d|mode)|c(aller|h(dir|mod|op|own|root)|lose(dir)?|onnect|os|rypt)|d(bm(close|open)|efined|elete|ie|o|ump)|e(ach|of|val|x(ec|ists|it|p))|f(cntl|ileno|lock|ork))\>" "\<(get(c|login|peername|pgrp|ppid|priority|pwnam|(host|net|proto|serv)byname|pwuid|grgid|(host|net)byaddr|protobynumber|servbyport)|([gs]et|end)(pw|gr|host|net|proto|serv)ent|getsock(name|opt)|gmtime|goto|grep|hex|index|int|ioctl|join)\>" "\<(keys|kill|last|length|link|listen|local(time)?|log|lstat|m|mkdir|msg(ctl|get|snd|rcv)|next|oct|open(dir)?|ord|pack|pipe|pop|printf?|push|q|qq|qx|rand|re(ad(dir|link)?|cv|do|name|quire|set|turn|verse|winddir)|rindex|rmdir|s|scalar|seek(dir)?)\>" "\<(se(lect|mctl|mget|mop|nd|tpgrp|tpriority|tsockopt)|shift|shm(ctl|get|read|write)|shutdown|sin|sleep|socket(pair)?|sort|spli(ce|t)|sprintf|sqrt|srand|stat|study|substr|symlink|sys(call|read|tem|write)|tell(dir)?|time|tr(y)?|truncate|umask)\>" "\<(un(def|link|pack|shift)|utime|values|vec|wait(pid)?|wantarray|warn|write)\>"
|
||||
color magenta "\<(continue|else|elsif|do|for|foreach|if|unless|until|while|eq|ne|lt|gt|le|ge|cmp|x|my|sub|use|package|can|isa)\>"
|
||||
icolor cyan start="[$@%]" end="( |[^0-9A-Z_]|-)"
|
||||
|
||||
# Variable names.
|
||||
color cyan "[$%&@]([A-Za-z_][0-9A-Za-z_]*|\^[][A-Z?\^_]|[0-9]+)\>"
|
||||
color cyan "[$%&@]\{(\^?[A-Za-z_][0-9A-Za-z_]*|\^[][?\^][0-9]+)\}"
|
||||
color cyan "[$%&@]([][!"#'()*+,.:;<=>?`|~-]|\{[][!-/:-@\`|~]\})|\$[$%&@]"
|
||||
color cyan "(^|[[:space:]])[$%@][/\]"
|
||||
|
||||
color yellow "".*"|qq\|.*\|"
|
||||
color white "[sm]/.*/"
|
||||
color white start="(^use| = new)" end=";"
|
||||
color green "#.*"
|
||||
|
||||
# Comments.
|
||||
color green "(^|[[:space:]])#.*"
|
||||
|
||||
color yellow start="<< 'STOP'" end="STOP"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## Here is an example for PHP.
|
||||
|
||||
syntax php "\.ph(p[23457s~]?|tml)$"
|
||||
syntax php "\.(php[23457s~]?|phtml|ctp)$"
|
||||
magic "PHP script"
|
||||
comment "//"
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ color brightmagenta "\<(Project\-Id\-Version|Report\-Msgid\-Bugs\-To|Last\-Trans
|
||||
color cyan "\<(POT\-Creation\-Date|PO\-Revision\-Date|MIME\-Version|Content\-Type|Content\-Transfer\-Encoding)\>"
|
||||
# Encodings and numbers.
|
||||
color yellow "\<(UTF|ISO|Windows|Mac|IBM)-[0-9]+"
|
||||
color yellow "[0-9]|pre[0-9]|[0-9]bit"
|
||||
color yellow "\<((pre|rc)?[0-9]+|[0-9]bit)\>"
|
||||
# Msgids.
|
||||
color brightblue "^(msgid|msgid_plural|msgstr)\>"
|
||||
# Tags.
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
syntax python "\.py$"
|
||||
header "^#!.*python"
|
||||
magic "Python script"
|
||||
linter pyflakes
|
||||
comment "#"
|
||||
|
||||
linter pyflakes
|
||||
|
||||
# Function definitions.
|
||||
icolor brightblue "def [0-9A-Z_]+"
|
||||
color brightblue "def [0-9A-Za-z_]+"
|
||||
# Keywords.
|
||||
color brightcyan "\<(and|as|assert|async|await|break|class|continue)\>"
|
||||
color brightcyan "\<(def|del|elif|else|except|finally|for|from)\>"
|
||||
|
||||
@@ -6,13 +6,13 @@ magic "Ruby script"
|
||||
linter ruby -w -c
|
||||
comment "#"
|
||||
|
||||
# Constants.
|
||||
color brightblue "\<[A-Z]+[0-9A-Z_a-z]*|(\$|@|@@)[0-9A-Z_a-z]+"
|
||||
# Reserved words.
|
||||
color yellow "\<(BEGIN|END|alias|and|begin|break|case|class|def|defined\?|do|else|elsif|end|ensure|false|for|if|in|module)\>"
|
||||
color yellow "\<(next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\>"
|
||||
# Constants.
|
||||
color brightblue "(\$|@|@@)?\<[A-Z]+[0-9A-Z_a-z]*"
|
||||
# Ruby "symbols".
|
||||
icolor magenta "([ ]|^):[0-9A-Z_]+\>"
|
||||
color magenta "([ ]|^):[0-9A-Za-z_]+\>"
|
||||
# Some unique things we want to stand out.
|
||||
color brightyellow "\<(__FILE__|__LINE__)\>"
|
||||
# Regular expressions.
|
||||
|
||||
@@ -11,7 +11,7 @@ comment "//"
|
||||
color magenta "fn [a-z_0-9]+"
|
||||
|
||||
# Reserved words
|
||||
color yellow "\<(abstract|alignof|as|become|box|break|const|continue|crate|do|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|offsetof|override|priv|pub|pure|ref|return|sizeof|static|self|struct|super|true|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\>"
|
||||
color yellow "\<(abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|true|try|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\>"
|
||||
|
||||
# Macros
|
||||
color red "[a-z_]+!"
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
## Here is an example for Bourne shell scripts.
|
||||
|
||||
syntax sh "(\.sh|\.(a|ba|c|da|k|mk|pdk|tc|z)(sh|shrc|sh_profile)|/(etc/|\.)profile)$"
|
||||
syntax sh "(\.sh|(\.|/)(a|ba|c|da|k|mk|pdk|tc|z)sh(rc|_profile)?|/(etc/|\.)profile)$"
|
||||
header "^#!.*/(((a|ba|c|da|k|mk|pdk|tc|z)?sh)|(busybox|env) +sh|openrc-run|runscript)"
|
||||
magic "(POSIX|Bourne-Again) shell script.*text"
|
||||
linter dash -n
|
||||
comment "#"
|
||||
|
||||
linter dash -n
|
||||
|
||||
# Function declarations.
|
||||
color brightgreen "^[A-Za-z0-9_-]+\(\)"
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
syntax tex "\.tex$"
|
||||
magic "(La)?TeX document"
|
||||
linter chktex -v0 -q -I
|
||||
comment "%"
|
||||
|
||||
icolor green "\\.|\\[A-Z]*"
|
||||
linter chktex -v0 -q -I
|
||||
|
||||
color green "\\.|\\[A-Za-z]*"
|
||||
color magenta "[{}]"
|
||||
color blue "(^|[^\])%.*"
|
||||
|
||||
Reference in New Issue
Block a user