Compare commits
241 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d54231967 | ||
|
|
8f2ac1b7f6 | ||
|
|
ee8681d7cc | ||
|
|
a1fba43452 | ||
|
|
0e4cbd4bfd | ||
|
|
ce68f81b2b | ||
|
|
255f5478e4 | ||
|
|
2a7c9b7f62 | ||
|
|
1146381765 | ||
|
|
8b1f283a73 | ||
|
|
43a5c87682 | ||
|
|
e4a69f8b94 | ||
|
|
8b3213cadb | ||
|
|
14c5f03e38 | ||
|
|
1e2d9a697a | ||
|
|
63c428ad08 | ||
|
|
f55b65bd99 | ||
|
|
f4c3670f64 | ||
|
|
6d121cc81f | ||
|
|
e57b755665 | ||
|
|
fb5478338f | ||
|
|
961294f533 | ||
|
|
46cec27b26 | ||
|
|
baa73d69e3 | ||
|
|
6855b79267 | ||
|
|
934a2192dc | ||
|
|
5df47bfef6 | ||
|
|
fb51d617fd | ||
|
|
7e9799d42b | ||
|
|
d02c1993d8 | ||
|
|
42f5a84c6f | ||
|
|
109ad0915d | ||
|
|
ee52f45b01 | ||
|
|
2367f3d8e6 | ||
|
|
684fc8f84a | ||
|
|
092174dad5 | ||
|
|
78bc8b698c | ||
|
|
d58ef8d579 | ||
|
|
4f3249de56 | ||
|
|
ecc7c26641 | ||
|
|
fbbf501f8f | ||
|
|
ac7a071893 | ||
|
|
09723b07a8 | ||
|
|
dd667ce92c | ||
|
|
482fb352b8 | ||
|
|
8766e7bdcb | ||
|
|
bb4d0d548a | ||
|
|
aa04ad4f83 | ||
|
|
a4c2eaa2e6 | ||
|
|
4d7735c8f9 | ||
|
|
8490f4acab | ||
|
|
e375995d98 | ||
|
|
35f6a1767a | ||
|
|
5bc4abeefe | ||
|
|
ac726f08fa | ||
|
|
30986db708 | ||
|
|
1439016c20 | ||
|
|
79971a309f | ||
|
|
a7901dd1e0 | ||
|
|
1695463347 | ||
|
|
f46544f67b | ||
|
|
9462ba8217 | ||
|
|
23f5515fbb | ||
|
|
747310562c | ||
|
|
1ae97076cd | ||
|
|
09f516a58b | ||
|
|
025232b25b | ||
|
|
7c41c8641f | ||
|
|
6295cca03b | ||
|
|
1c05090a4a | ||
|
|
14bd52ced8 | ||
|
|
7d46eff738 | ||
|
|
84b6525914 | ||
|
|
2abe7c03fe | ||
|
|
bf72cdd814 | ||
|
|
8e3f40155c | ||
|
|
4239e5fe1a | ||
|
|
d1ee41f319 | ||
|
|
b93767b54f | ||
|
|
8fbf10428c | ||
|
|
3719d8e208 | ||
|
|
50cbde8b23 | ||
|
|
9ffd3c0222 | ||
|
|
2704b3874b | ||
|
|
139f9c2fe5 | ||
|
|
580fa53aba | ||
|
|
2380ee20c5 | ||
|
|
c0a52372f1 | ||
|
|
fd8ce7af8e | ||
|
|
c5a0c9b6b2 | ||
|
|
6520aa0079 | ||
|
|
3d8b9895b8 | ||
|
|
9026e04c73 | ||
|
|
92befae93d | ||
|
|
dbbc14e0ac | ||
|
|
8b80ec3e1a | ||
|
|
a71a2f9a0c | ||
|
|
56ce5f2ba8 | ||
|
|
5ebdd3fe6e | ||
|
|
426e6d37c5 | ||
|
|
4dd9aadf8a | ||
|
|
5ecd81bd19 | ||
|
|
b4a955512e | ||
|
|
33c7a4ca95 | ||
|
|
40d34862fd | ||
|
|
bee670424e | ||
|
|
8dffb00fd9 | ||
|
|
403e87c0a0 | ||
|
|
942bb39547 | ||
|
|
52b7a41ea4 | ||
|
|
6807e06a74 | ||
|
|
84cd0abd6f | ||
|
|
6a70d2b6e2 | ||
|
|
16482f99b8 | ||
|
|
621eb904b3 | ||
|
|
84ff9ebb91 | ||
|
|
a2038a9b2b | ||
|
|
a969adf804 | ||
|
|
59b0f81bfa | ||
|
|
6ad3d3d6c0 | ||
|
|
ca70885564 | ||
|
|
cfa20c3f42 | ||
|
|
4781d4d351 | ||
|
|
ef1a3b08ae | ||
|
|
4063fce6a0 | ||
|
|
3db2beefd3 | ||
|
|
5907f8801b | ||
|
|
c68398f18f | ||
|
|
d653aeab93 | ||
|
|
491e02f532 | ||
|
|
f1a47a2aae | ||
|
|
7b23878b42 | ||
|
|
5cdadc3eb1 | ||
|
|
8f89e23adb | ||
|
|
8302ff700b | ||
|
|
a32d21c759 | ||
|
|
f8214440c2 | ||
|
|
c1b08302df | ||
|
|
afd8a4e804 | ||
|
|
88b740179a | ||
|
|
9ce41543ed | ||
|
|
e4775c2060 | ||
|
|
cd7c3483b4 | ||
|
|
8075e454a9 | ||
|
|
93b1c1bea6 | ||
|
|
aa14526cb3 | ||
|
|
d29d49aece | ||
|
|
e8f90789e9 | ||
|
|
c830b8f51c | ||
|
|
28beb3f9c5 | ||
|
|
08fd5b349b | ||
|
|
6971db773b | ||
|
|
c620fc6aa9 | ||
|
|
7e09f2c64a | ||
|
|
968c07fc81 | ||
|
|
858e75e4cf | ||
|
|
a05180ed2d | ||
|
|
00533854c0 | ||
|
|
dc3610fc8e | ||
|
|
a33a4f00e5 | ||
|
|
509b091c47 | ||
|
|
9ea5eef200 | ||
|
|
e701bb01aa | ||
|
|
a3102cd4cf | ||
|
|
da67883508 | ||
|
|
03c3e2b7c0 | ||
|
|
4953dcec20 | ||
|
|
f5155786e1 | ||
|
|
a9abc3d95f | ||
|
|
09cabcad5d | ||
|
|
f162a6a2ab | ||
|
|
5a3de7f117 | ||
|
|
7b5cc1dcda | ||
|
|
2b38547875 | ||
|
|
492166a3f7 | ||
|
|
e1e15fd0f4 | ||
|
|
9c2bc68847 | ||
|
|
3d1ef8e07f | ||
|
|
5033cfd81a | ||
|
|
9c3a149b14 | ||
|
|
a9c4682c25 | ||
|
|
6566177743 | ||
|
|
443e1484e5 | ||
|
|
ac9550d4c2 | ||
|
|
1423e57199 | ||
|
|
c095ece497 | ||
|
|
9366131c51 | ||
|
|
009cd30695 | ||
|
|
c42d6d378a | ||
|
|
1a79b3d514 | ||
|
|
7d3d3dec9a | ||
|
|
6240805c41 | ||
|
|
17cf7d1c62 | ||
|
|
3275c4e514 | ||
|
|
395c8e9e25 | ||
|
|
a8a60b29e6 | ||
|
|
c1ebfa04ae | ||
|
|
6967fae35d | ||
|
|
a37435141a | ||
|
|
329021e24a | ||
|
|
b06407fbd7 | ||
|
|
8edaa38a1e | ||
|
|
1f55c8819b | ||
|
|
03ecbf3d55 | ||
|
|
81aebeb2a9 | ||
|
|
7b442ea4cb | ||
|
|
a846a2c19f | ||
|
|
a832fffb1f | ||
|
|
99fa20645c | ||
|
|
26fe2118c4 | ||
|
|
46430999d5 | ||
|
|
9cff7a1689 | ||
|
|
ae15fc9bb2 | ||
|
|
b3b3dd5792 | ||
|
|
7e1648fdb0 | ||
|
|
e05dfda2be | ||
|
|
fe012dad91 | ||
|
|
3787494c15 | ||
|
|
8de4b7aaeb | ||
|
|
9de0f158e2 | ||
|
|
3d62d32cbe | ||
|
|
f9fea02fc5 | ||
|
|
90bd25c1bb | ||
|
|
ca6d7b6a46 | ||
|
|
d6313c2f8c | ||
|
|
861d81edba | ||
|
|
ac1444578c | ||
|
|
9a4c384afa | ||
|
|
040bd93cc4 | ||
|
|
e935fd4f88 | ||
|
|
a43eee6aec | ||
|
|
1fbe7596f8 | ||
|
|
3c875f9b59 | ||
|
|
700c5c9399 | ||
|
|
74f128859b | ||
|
|
953fbf8efe | ||
|
|
3dc6ccbe86 | ||
|
|
b98545f455 | ||
|
|
5a741a0205 | ||
|
|
6723ac6fcc | ||
|
|
bbc718633e |
10
AUTHORS
10
AUTHORS
@@ -8,8 +8,8 @@ Chris Allegretta <chrisa@asty.org>
|
||||
David Lawrence Ramsey <pooka109@gmail.com>
|
||||
* Former stable series maintainer. Multiple buffer support,
|
||||
operating dir (-o) option, bug fixes for display routines,
|
||||
wrapping code, spelling fixes, const mode, parts of the
|
||||
UTF-8 support, and various other fixes.
|
||||
wrapping code, spelling fixes, constantshow mode, parts of
|
||||
UTF-8 support, softwrap overhaul, and various other fixes.
|
||||
|
||||
Jordi Mallach <jordi@gnu.org>
|
||||
* Debian package maintainer, fellow bug squasher.
|
||||
@@ -39,7 +39,8 @@ Mike Frysinger <vapier@gentoo.org>
|
||||
* Gentoo package maintainer. Whitespace display mode,
|
||||
--enable-utf8/--disable-utf8 configure options for ncurses,
|
||||
many new color regexes and improvements to existing color
|
||||
regexes in syntax/*.nanorc, and miscellaneous bug fixes.
|
||||
regexes in syntax/*.nanorc, the move from svn to git, the
|
||||
conversion to gnulib, and miscellaneous bug fixes.
|
||||
|
||||
Mark Majeres <mark@engine12.com>
|
||||
* A functional undo/redo system, and coloring nano's interface.
|
||||
@@ -56,6 +57,9 @@ Faissal Bensefia <faissaloo@gmail.com>
|
||||
Sumedh Pendurkar <sumedh.pendurkar@gmail.com>
|
||||
* The word-completion feature.
|
||||
|
||||
Rishabh Dave <rishabhddave@gmail.com>
|
||||
* Searchable help.
|
||||
|
||||
Benno Schulenberg <bensberg@justemail.net>
|
||||
* An array of small bug fixes, the cut-word and block-jump
|
||||
routines, text selection by holding Shift, and some extra
|
||||
|
||||
273
ChangeLog
273
ChangeLog
@@ -1,3 +1,276 @@
|
||||
Changes between v2.8.5 and v2.8.6:
|
||||
----------------------------------
|
||||
|
||||
Benno Schulenberg (58):
|
||||
build: for Solaris, tell the linker to use a threading lib
|
||||
bump version numbers and add a news item for the 2.8.6 release
|
||||
display: avoid a jumpy cursor by redrawing bottom bars only when needed
|
||||
display: when back in the main loop, always redraw the help lines
|
||||
display: wipe stale messages from the status bar straightaway
|
||||
docs: add some more mark-up to the Info document
|
||||
docs: be more precise about when a dash is given instead of a filename
|
||||
docs: drop the cluttering Info-style links from the HTML manual
|
||||
docs: improve cross references and mark-up in the Info document
|
||||
docs: improve some spacing, especially of the synopsis in the PDF
|
||||
docs: make the guillemot and the middle dot appear correctly in HTML
|
||||
docs: move the descriptions of 'header' and 'magic' next to 'syntax'
|
||||
docs: remove the mention of backslashes for the argument of 'comment'
|
||||
docs: reword the explanation of the 'syntax' command
|
||||
docs: use real cross references in the Info document
|
||||
docs: use the @command and @option mark-up more consistently
|
||||
files: don't bother counting rows when opening a fresh buffer
|
||||
files: warn more conspicuously when the file on disk has changed
|
||||
gnulib: update to its current state
|
||||
input: recognize the Ctrl+Arrow key sequences from Haiku's Terminal
|
||||
options: recognize -a and --atblanks on the command line
|
||||
options: rename --cut to --cutfromcursor, to be clearer
|
||||
pasting: restore the cap on the number of chunks to move backward
|
||||
rcfile: don't require backslashing in the argument of 'comment'
|
||||
screen: defeat a VTE/Konsole bug also for the case of --constantshow
|
||||
screen: retain the same help-line tags when the window is resized
|
||||
softwrap: when possible, go back a whole bunch of chunks at a time
|
||||
startup: don't try parsing color names that were not specified
|
||||
startup: in default mode, display the tail of the file as Pico does
|
||||
suspension: prevent entering an invalid byte upon resume (with S-Lang)
|
||||
syntax: gentoo: make it clearer that the file contains two syntaxes
|
||||
syntax: man, groff: fix the string that introduces a comment
|
||||
syntax: nanorc: don't color numeric arguments specially
|
||||
syntax: nanorc: don't color the argument of 'linter' as if invalid
|
||||
syntax: texinfo: cover also some special cases like @U, @OE and @TeX
|
||||
tweaks: adjust an error message so it fits all possible cases
|
||||
tweaks: avoid a clang warning about an expression being treated as NULL
|
||||
tweaks: avoid a failure with black diamonds in a PDF
|
||||
tweaks: avoid an unused-variable warning for the tiny version
|
||||
tweaks: chuck some debugging stuff
|
||||
tweaks: chuck two useless asserts, and elide a call to strncasecmp()
|
||||
tweaks: correct two conditions for conditional compilation
|
||||
tweaks: drop a bunch of useless asserts
|
||||
tweaks: elide unneeded calls of get_last_chunk_leftedge()
|
||||
tweaks: fix compilation with --enable-tiny
|
||||
tweaks: move an include to the file that actually makes use of it
|
||||
tweaks: put declarations always first, so it will compile on Haiku
|
||||
tweaks: recognize the empty string as comment inhibitor, instead of NULL
|
||||
tweaks: remove two superfluous includes
|
||||
tweaks: rename a constant, to match the corresponding option
|
||||
tweaks: rename another constant, to be more precise
|
||||
tweaks: rename a variable, to have more contrast
|
||||
tweaks: rename four functions, to be more distinct
|
||||
tweaks: rename two variables, to make a little sense
|
||||
tweaks: reshuffle some things to condense the code
|
||||
tweaks: simplify the parsing of color combinations
|
||||
tweaks: spell an option correctly in NEWS
|
||||
tweaks: swap ^X and ^L in the help lines of the help viewer
|
||||
|
||||
David Lawrence Ramsey (29):
|
||||
display: when converting tabs, don't go beyond the screen width
|
||||
docs: consistently describe the -U/-c and -r/-w overrides
|
||||
docs: mention that boldtext can be overridden also for function tags
|
||||
docs: mention the default values for comment and whitespace directives
|
||||
moving: fix the cursor jumping back and forth with non-smooth paging
|
||||
moving: make vertical movement account for varying chunk width
|
||||
new feature: allow lines to be softwrapped at whitespace
|
||||
replacing: make spotlight() account for varying chunk width
|
||||
softwrap: add new functions for chunks of varying width
|
||||
softwrap: don't flag EOL too early, nor break continuous text too early
|
||||
softwrap: in do_mouse(), keep the cursor before a softwrap breakpoint
|
||||
softwrap: make the changes to actually allow the chunk width to vary
|
||||
softwrap: prepare for allowing the chunk width to vary
|
||||
softwrap: remove unneeded caps on the number of chunks to move
|
||||
syntax: nanorc: properly color a "fill" option with a negative value
|
||||
text: adjust the comments in do_indent() and do_unindent()
|
||||
text: make do_unindent() an exact copy of do_indent()
|
||||
text: make sure commenting is disabled when comment "" was specified
|
||||
text: normalize the indentation in do_indent() and do_unindent()
|
||||
text: remove indent-related code from do_unindent()
|
||||
text: remove the last usage of cols in do_indent() and do_unindent()
|
||||
text: remove unindent-related code from do_indent()
|
||||
text: remove unneeded references to cols from the indentation routines
|
||||
text: update placewewant properly when indenting/unindenting
|
||||
tweaks: correct a parameter type, and correct two empty initializations
|
||||
tweaks: fix a typo in NEWS
|
||||
tweaks: only compensate for a partially-offscreen line in softwrap mode
|
||||
tweaks: remove unneeded braces, and mark empty parameter list as void
|
||||
usage: a dash doesn't have to come first among the filenames
|
||||
|
||||
|
||||
Changes between v2.8.4 and v2.8.5:
|
||||
----------------------------------
|
||||
|
||||
Benno Schulenberg (35):
|
||||
bindings: in the tiny version exclude word jumping from the prompts
|
||||
bump version numbers and add a news item for the 2.8.5 release
|
||||
display: don't let a SIGCONT write anything to the screen
|
||||
display: don't show the cursor while we are busy calculating its position
|
||||
display: redraw title bar and edit window only when needed
|
||||
display: show the cursor position also when searching took a while
|
||||
docs: avoid a double "see" for cross references in the HTML manual
|
||||
docs: spell "title bar" and "status bar" correctly
|
||||
gnulib: update to its current state
|
||||
input: give an appropriate message when there are too many errors
|
||||
startup: allow negative line and column numbers on the command line
|
||||
startup: allow positioning the cursor also when reading standard input
|
||||
startup: always open with the file that was mentioned first
|
||||
startup: don't crash when opening standard input would fail
|
||||
startup: don't mark the buffer as modified when in view mode
|
||||
startup: don't mark the buffer as modified when nothing was read
|
||||
startup: don't try placing the cursor when reading standard input failed
|
||||
startup: don't use position history when reading from standard input
|
||||
suspension: fake a SIGWINCH when coming back out of the background
|
||||
suspension: remove a duplicate setting of the HUP and TERM handler
|
||||
syntax: default: allow leading whitespace before a hash comment
|
||||
tweaks: adjust indentation after preceding changes
|
||||
tweaks: avoid compiler warning about implicit type
|
||||
tweaks: be consistent in the spelling of title bar and status bar
|
||||
tweaks: don't bother calculating the position when we won't show it
|
||||
tweaks: elide a function that should not be a separate one
|
||||
tweaks: elide a variable
|
||||
tweaks: frob a few comments, and elide and #ifndef
|
||||
tweaks: reduce the scope of three variables, and rename them besides
|
||||
tweaks: reduce the scope of two variables, and rename them too
|
||||
tweaks: rename a function and a variable, to better match what they do
|
||||
tweaks: rename a variable, and frob a couple of comments
|
||||
tweaks: rename two functions and a variable, and invert its logic
|
||||
tweaks: reshuffle some stuff, to put related things closer together
|
||||
tweaks: unglobalize the nodelay_mode variable
|
||||
|
||||
|
||||
Changes between v2.8.3 and v2.8.4:
|
||||
----------------------------------
|
||||
|
||||
Benno Schulenberg (11):
|
||||
build: correct the inverted logic for the nanorc man page
|
||||
bump version numbers and add a news item for the 2.8.4 release
|
||||
gnulib: update to its current state
|
||||
syntax: default: color also hash comments and email addresses
|
||||
syntax: php: color "static" again as "function", like it used to be
|
||||
tweaks: adjust the indentation after the preceding change
|
||||
tweaks: avoid an unused-variable warning when using --disable-comment
|
||||
tweaks: do actual screen refreshes in a single call, when possible
|
||||
tweaks: remove the no-op x$disable tests
|
||||
tweaks: reorder three items in the Info document
|
||||
tweaks: reshuffle a few things to reduce duplication
|
||||
|
||||
|
||||
Changes between v2.8.2 and v2.8.3:
|
||||
----------------------------------
|
||||
|
||||
Benno Schulenberg (34):
|
||||
bindings: allow toggling a new buffer when multiple buffers are enabled
|
||||
build: don't use a dummy dependency, as it breaks non-GNU makes
|
||||
build: for Solaris, tell the linker where to find clock_gettime()
|
||||
build: use backticks to avoid a warning during autoreconf
|
||||
build: use the "force" mechanism to always run the revision rule
|
||||
bump version numbers and add a news item for the 2.8.3 release
|
||||
chars: optimize moving a character left in the non-UTF-8 case
|
||||
chars: probe for a valid UTF-8 starter byte, instead of overstepping
|
||||
chars: valid UTF-8 codes are at most 4 bytes long, so look only that far
|
||||
display: keep the cursor put, also when toggling nohelp or morespace
|
||||
files: don't ask "save anyway" when user orders to discard the buffer
|
||||
history: don't save the cursor position for temporary help files
|
||||
moving: limit the target column when it is beyond the last chunk
|
||||
replacing: don't let placewewant influence the placement of the cursor
|
||||
startup: don't call delwin() with NULL, to avoid crashing on Solaris
|
||||
syntax: makefile: color comments only at start of line or after whitespace
|
||||
syntax: nanohelp: color also ^6 as a shortcut keystroke
|
||||
syntax: php: color also variable names, and color more reserved words
|
||||
syntax: php: recognize also the .phtml and .php7 extensions
|
||||
syntax: xml: recognize an XML file also by its first line
|
||||
tweaks: add another warning for an impossible condition
|
||||
tweaks: adjust whitespace and comments after the preceding change
|
||||
tweaks: avoid an empty function call in tiny version with line numbers
|
||||
tweaks: exclude from the tiny version five error-betraying messages
|
||||
tweaks: exclude from the tiny version two messages that will never occur
|
||||
tweaks: fix compilation with --enable-tiny ...-help and ...-multibuffer
|
||||
tweaks: remove an old fault-catching message
|
||||
tweaks: remove five dummy function definitions from the tiny version
|
||||
tweaks: rename three empty functions, and reshuffle some others
|
||||
tweaks: rewrap a couple of old items in NEWS, and fix an article
|
||||
tweaks: swap a comparison, to be clearer
|
||||
tweaks: transform the token DISABLE_BROWSER to ENABLE_BROWSER
|
||||
tweaks: transform the token DISABLE_NANORC to ENABLE_NANORC
|
||||
tweaks: transform the token DISABLE_TABCOMP to ENABLE_TABCOMP
|
||||
|
||||
David Lawrence Ramsey (2):
|
||||
display: ensure smooth scrolling when the edit window is resized
|
||||
tweaks: fix several whitespace irregularities
|
||||
|
||||
|
||||
Changes between v2.8.1 and v2.8.2:
|
||||
----------------------------------
|
||||
|
||||
Benno Schulenberg (64):
|
||||
bindings: allow using <Backspace> to scroll back up in the help viewer
|
||||
bindings: allow using '/' to start a search in the help viewer
|
||||
bindings: show Home and End in browser help text, instead of M-| and M-?
|
||||
browser: make ^End work properly by fixing a paste error
|
||||
build: make --enable-help properly depend on --enable-multibuffer
|
||||
bump version numbers and add a news item for the 2.8.2 release
|
||||
display: initialize the colors only when starting to draw the content
|
||||
display: push the titlebar to the screen as soon as it has been drawn
|
||||
docs: add an item to the FAQ, about pasting from Windows to a remote nano
|
||||
docs: harmonize the nanorc man page and Info document a bit
|
||||
docs: in the FAQ, extend the answer to the pasting problem
|
||||
docs: reword the main paragraph of the man page
|
||||
docs: update the list of who authored what
|
||||
gnulib: update to its current state in git
|
||||
help: after a search, show the cursor only when something was found
|
||||
help: allocate enough space for the descriptions, so we don't crash
|
||||
help: don't crash when nano was started with --noread
|
||||
help: don't cycle forward in the buffers when exiting from help
|
||||
help: keep the same position also after M-\ or M-/ has been used
|
||||
help: keep the text at the same position when the screen is resized
|
||||
help: remove the final blank line, so <End> does the same as all <Down>
|
||||
help: set tabsize to the default width while showing a help text
|
||||
help: suppress nano's name and number to make it clearer this is help
|
||||
help: use a dedicated syntax to color shortcuts in a help text
|
||||
help: when searching, do it forward, without case, and without regexes
|
||||
input: avoid crashing when resizing the window during verbatim input
|
||||
options: allow -U (--quickblank) to be used in the tiny version
|
||||
scrolling: don't bother to limit the number of lines to step back
|
||||
startup: warn about a strange character size only in the UTF-8 case
|
||||
syntax: nanohelp: change the hue of the keystrokes to match sample.nanorc
|
||||
tweaks: add a warning for a condition that should never occur
|
||||
tweaks: add three warnings for conditions that should never occur
|
||||
tweaks: avoid an unused-variable warning
|
||||
tweaks: be more precise about what --disable-extra does
|
||||
tweaks: check for an empty needle in a central place
|
||||
tweaks: complete the exclusion of backups and such from the tiny version
|
||||
tweaks: condense two bits of code, and drop two asserts
|
||||
tweaks: distinguish (in the comments) between buffers and linestructs
|
||||
tweaks: drop a bunch of asserts
|
||||
tweaks: elide a function that is used just once
|
||||
tweaks: fix compilation with --enable-tiny --enable-color --enable-speller
|
||||
tweaks: fix two typos
|
||||
tweaks: remove a superfluous check
|
||||
tweaks: remove a superfluous strlen() call from the reverse searches
|
||||
tweaks: remove some superfluous placements of the cursor
|
||||
tweaks: remove two superfluous calls of wnoutrefresh()
|
||||
tweaks: rename a constant, to match the corresponding option
|
||||
tweaks: rename a function, to be more accurate
|
||||
tweaks: rename a function, to better suit what it does
|
||||
tweaks: rename another function, to better describe what it does
|
||||
tweaks: rename a parameter, to be more imperative
|
||||
tweaks: rename a variable, use a faster comparison, and reshuffle a bit
|
||||
tweaks: rename one variable again
|
||||
tweaks: rename some more of these 'rev_start' variables
|
||||
tweaks: rename three variables, elide another, and reshuffle some stuff
|
||||
tweaks: rename two variables, because this 'rev_start' is irksome
|
||||
tweaks: reshuffle a couple of lines to avoid a duplicate call
|
||||
tweaks: reshuffle help-text initialization, to elide a save-and-restore
|
||||
tweaks: reshuffle some more stuff, and rename two more variables
|
||||
tweaks: swap the names of two variables, to make more sense
|
||||
tweaks: transform the token DISABLE_MOUSE to ENABLE_MOUSE
|
||||
tweaks: transform the token DISABLE_MULTIBUFFER to ENABLE_MULTIBUFFER
|
||||
tweaks: use the logic from revstrstr() also in mbrevstrcasestr()
|
||||
tweaks: use the logic from revstrstr() also in revstrcasestr()
|
||||
|
||||
David Lawrence Ramsey (1):
|
||||
docs: mention that also numbercolor overrides boldtext
|
||||
|
||||
Rishabh Dave (1):
|
||||
new feature: add a search facility to the help viewer
|
||||
|
||||
|
||||
Changes between v2.8.0 and v2.8.1:
|
||||
----------------------------------
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@ Improvements in GNU nano
|
||||
========================
|
||||
|
||||
Since 2.8.0:
|
||||
- Softwrapping can be done at whitespace (with --soft --atblanks).
|
||||
- The ^G help texts have become searchable (with ^W and M-W).
|
||||
- Ctrl+Home and Ctrl+End jump to start and end of file.
|
||||
- In softwrap mode the cursor now moves per visual row instead of per
|
||||
logical line, and the screen will scroll per row.
|
||||
- In softwrap mode the cursor now moves per visual row instead of
|
||||
per logical line, and the screen will scroll per row.
|
||||
|
||||
Since 2.7.0:
|
||||
- The keystroke ^] to complete a fragment to an existing full word.
|
||||
|
||||
97
NEWS
97
NEWS
@@ -1,3 +1,40 @@
|
||||
2017.07.21 - GNU nano 2.8.6 "Kekulé" offers a new feature: the ability
|
||||
to do softwrapping between words -- at whitespace --
|
||||
instead of always at the edge of the screen. This can
|
||||
be activated with -a or --atblanks or 'set atblanks'
|
||||
together with the softwrap option. This release further
|
||||
fixes a handful of rare display glitches, fixes a build
|
||||
failure on AIX, harmonizes the quoting rules in the rc
|
||||
files, and renames the option 'cut' to 'cutfromcursor'
|
||||
(please update your nanorc files before 2020).
|
||||
|
||||
2017.06.25 - GNU nano 2.8.5 "Farouche" avoids a crash when waking from
|
||||
a suspension that was induced from the outside, allows
|
||||
negative line and column numbers on the command line,
|
||||
avoids some flickering when resizing the screen while
|
||||
in the file browser, opens files in the order they were
|
||||
mentioned on the command line, and does not pretend to
|
||||
have woken from suspension when receiving a SIGCONT.
|
||||
|
||||
2017.05.21 - GNU nano 2.8.4 "Our Version of Events" includes the nanorc
|
||||
man page again.
|
||||
|
||||
2017.05.18 - GNU nano 2.8.3 "Hirsch" fixes a misplacement of the spotlight
|
||||
during interactive replacing, avoids build failures on AIX
|
||||
and Solaris, fixes a crash on Solaris, speeds up backwards
|
||||
searching, improves PHP syntax highlighting, and no longer
|
||||
asks “save anyway?” when the user ^Q discards the buffer.
|
||||
|
||||
2017.05.04 - GNU nano 2.8.2 "Krats" adds another new feature: it makes
|
||||
the ^G help texts searchable with ^W. Apart from that,
|
||||
it fixes a crash when resizing the window in the middle
|
||||
of verbatim input, avoids an unlikely crash when used
|
||||
without UTF-8 support in some locales, avoids redrawing
|
||||
the screen twice when switching between buffers while
|
||||
line numbers are active, and works around a coloring
|
||||
bug on musl. Plus tweaks to the documentation; plus
|
||||
translation updates for fifteen languages.
|
||||
|
||||
2017.04.12 - GNU nano 2.8.1 "Ellert" fixes build failures on MacOS and
|
||||
on musl, fixes scrolling problems in softwrap mode when
|
||||
double-width characters on row boundaries are involved,
|
||||
@@ -107,7 +144,7 @@
|
||||
input (M-V followed by a six-digit hexadecimal number which
|
||||
must start with 0 or 10), avoids a crash when resizing the
|
||||
window during Verbatim input, doesn't drop a keystroke after
|
||||
having been suspended, and replaces the beginning-of-line
|
||||
having been suspended, and replaces the beginning-of-line
|
||||
anchor (^) just once per line. There are also several tiny
|
||||
improvements in screen rendering and key handling. Come get
|
||||
your hair tousled!
|
||||
@@ -256,13 +293,12 @@
|
||||
handling of --tempfile mode, and better handling of
|
||||
command line arguments when also attempting to specify
|
||||
+<line number>. As always, please file any bugs you
|
||||
find at the Savannah page for nano, at
|
||||
https://savannah.gnu.org/bugs/index.php?42639 and
|
||||
thanks for using nano.
|
||||
find via https://savannah.gnu.org/bugs/?group=nano
|
||||
and thanks for using nano.
|
||||
|
||||
2014.06.02 - GNU nano 2.3.4 won't leave you high, won't leave you dry. This
|
||||
release contains only a small number of fixes, but in
|
||||
particular allows nano to compile on non-UTF-8 curses
|
||||
2014.06.02 - GNU nano 2.3.4 won't leave you high, won't leave you dry.
|
||||
This release contains only a small number of fixes, but
|
||||
in particular allows nano to compile on non-UTF-8 curses
|
||||
implementations (i.e. libncursesw). Other small fixes to
|
||||
the undo implementation and the default syntax config are
|
||||
also included. As always, Share and Enjoy!
|
||||
@@ -522,16 +558,16 @@
|
||||
an internal error occurs in the undo code, and fixes for
|
||||
various combinations of configure-time options and
|
||||
compiler flags. Also included is new support for
|
||||
changing the rc file name at configure time, and
|
||||
using GNU-style regexes for word-boundaries on systems
|
||||
which do not support them natively, as well as the ever
|
||||
popular translation updates. Rock the tarball.
|
||||
changing the rc file name at configure time, and using
|
||||
GNU-style regexes for word-boundaries on systems which
|
||||
do not support them natively, as well as the ever popular
|
||||
translation updates. Rock the tarball.
|
||||
|
||||
2008.08.09 - GNU nano 2.1.4 "I told you so!" is released. This release
|
||||
includes fixes for several severe issues with the new
|
||||
undo/redo code. Also the behavior of writing
|
||||
files when using backup mode has changed as well: if writing
|
||||
the backup file fails, nano will not attempt to write the
|
||||
undo/redo code. Also the behavior of writing files when
|
||||
using backup mode has changed as well: if writing the
|
||||
backup file fails, nano will not attempt to write the
|
||||
current file. This should help folks who enjoy "extreme
|
||||
text editing", i.e. editing files on file systems which
|
||||
are likely to run out of space; see Savannah bug #24000.
|
||||
@@ -555,7 +591,7 @@
|
||||
compiling on AIX, and a segfault when making the terminal
|
||||
window too small. Rest in Peace Tim and George!
|
||||
|
||||
2008.04.01 - GNU nano 2.1.1 wont get fooled again. This release contains
|
||||
2008.04.01 - GNU nano 2.1.1 won't get fooled again. This release contains
|
||||
fixes for the new user-rebindable keys (in particular
|
||||
bracket match which was mis-bound), and various
|
||||
problems with translations and configure-related
|
||||
@@ -720,7 +756,7 @@
|
||||
focuses mostly on bugfixes, which include better
|
||||
handling of the cursor at the statusbar prompt, support
|
||||
for certain combinations of Shift and keypad keys in
|
||||
both normal and --rebind-keypad mode, a fix for a minor
|
||||
both normal and --rebindkeypad mode, a fix for a minor
|
||||
display problem after some searches, a real fix for a
|
||||
long-standing segfault when displaying overly long
|
||||
lines, and a real fix for nano's not hanging up properly
|
||||
@@ -1237,28 +1273,27 @@
|
||||
Have fun with it.
|
||||
|
||||
2001.03.22 - GNU Nano 1.0 is released! The autoindent wrapping bug
|
||||
has been fixed, as well as strange bug when using Pico
|
||||
has been fixed, as well as a strange bug when using Pico
|
||||
mode and regex search. There have also been some minor
|
||||
spelling and documentation updates. As stated on the
|
||||
website, there are currently no known bugs with nano,
|
||||
but some will pop up eventually and they will be
|
||||
addressed in subsequent releases. We hope you enjoy
|
||||
this first stable release of nano, and as always,
|
||||
feedback is welcome! nano@nano-editor.org.
|
||||
feedback is welcome! <nano@nano-editor.org>
|
||||
|
||||
|
||||
2001.02.19 - Nano 0.9.99pre3 brings a lot of changes! The most
|
||||
important being that nano is now officially a GNU
|
||||
program. Some changes have been made for GNU
|
||||
compatibility (like the default list of shortcuts, "^G
|
||||
Get Help" is now listed and "^_ Goto Line" is not). The
|
||||
Yes/No/All keys have finally been internationalized
|
||||
also. All in all, quite a few changes, considering nano
|
||||
is supposed to be in a code freeze. But there are the
|
||||
usual helping of bugfixes, a nasty bug when cutting text
|
||||
in -k mode and some compatibility issues with older
|
||||
ncurses libraries have also been fixed. All in all, a
|
||||
lot to see.
|
||||
2001.02.19 - Nano 0.9.99pre3 brings a lot of changes! The most important
|
||||
being that nano is now officially a GNU program. Some
|
||||
changes have been made for GNU compatibility (like in the
|
||||
default list of shortcuts: "^G Get Help" is now listed
|
||||
and "^_ Goto Line" is not). The Yes/No/All keys have
|
||||
finally been internationalized also. All in all, quite
|
||||
a few changes, considering nano is supposed to be in
|
||||
a code freeze. But there are the usual helping of
|
||||
bugfixes, a nasty bug when cutting text in -k mode and
|
||||
some compatibility issues with older ncurses libraries
|
||||
have also been fixed. All in all, a lot to see.
|
||||
|
||||
2001.01.31 - Nano 0.9.99pre2 is released. Not surprisingly, all that is
|
||||
new is bugfixes, bugfixes, bugfixes. There were a few
|
||||
@@ -1267,7 +1302,7 @@
|
||||
is now a preliminary (read: needs testing) fix for
|
||||
resizing the editor in any mode other than normal edit
|
||||
mode. Other fixes include some more tab completion
|
||||
segfaults, and an silly segfault that occurred when
|
||||
segfaults, and a silly segfault that occurred when
|
||||
successfully writing a file on the 2nd try (i.e. after
|
||||
an initial write error). Slowly but surely, on toward
|
||||
1.0 we travel.
|
||||
|
||||
5
TODO
5
TODO
@@ -3,8 +3,6 @@ A list of desired features
|
||||
|
||||
Somewhat urgent:
|
||||
- Make undo/redo work also for justifying and indenting.
|
||||
- Allow text searches in the help viewer.
|
||||
See https://savannah.gnu.org/bugs/?28994.
|
||||
- Detect when text is being pasted, so that we can handle it faster.
|
||||
See https://savannah.gnu.org/bugs/?40060.
|
||||
- Allow to define and execute a macro: a stored sequence of keystrokes.
|
||||
@@ -27,6 +25,9 @@ Vague musings:
|
||||
- Allow indentation to add just enough columns to reach the nearest
|
||||
multiple of tabsize, rather than always adding tabsize columns?
|
||||
|
||||
For version 2.8:
|
||||
- Allow text searches in the help viewer. [DONE]
|
||||
|
||||
For version 2.4:
|
||||
- Handle window resizes better. After we've resized, we should stay
|
||||
wherever we were before we resized, as Pico does. [DONE]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Generate configure & friends for GIT users.
|
||||
|
||||
gnulib_url="git://git.sv.gnu.org/gnulib.git"
|
||||
gnulib_hash="06d9e7302a736d7fa3db9cf1eb9850b60aee612f"
|
||||
gnulib_hash="c7711db84f251d9e580d9fa53a070fa97ae89095"
|
||||
|
||||
modules="
|
||||
futimens
|
||||
|
||||
151
configure.ac
151
configure.ac
@@ -16,7 +16,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
AC_INIT([GNU nano], [2.8.1], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [2.8.6], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AC_CANONICAL_HOST
|
||||
AM_INIT_AUTOMAKE([1.14])
|
||||
@@ -63,9 +63,14 @@ AC_CHECK_HEADERS(libintl.h limits.h pwd.h termios.h sys/param.h)
|
||||
dnl Checks for options.
|
||||
|
||||
AC_ARG_ENABLE(browser,
|
||||
AS_HELP_STRING([--disable-browser], [Disable built-in file browser]))
|
||||
if test "x$enable_browser" = xno; then
|
||||
AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in file browser.])
|
||||
AS_HELP_STRING([--disable-browser], [Disable the built-in file browser]))
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
if test "x$enable_browser" != xyes; then
|
||||
enable_browser=no
|
||||
fi
|
||||
fi
|
||||
if test "x$enable_browser" != xno; then
|
||||
AC_DEFINE(ENABLE_BROWSER, 1, [Define this to enable the built-in file browser.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(color,
|
||||
@@ -85,7 +90,7 @@ else
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(comment,
|
||||
AS_HELP_STRING([--disable-comment], [Disable comment/uncomment functions]))
|
||||
AS_HELP_STRING([--disable-comment], [Disable the comment/uncomment function]))
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
if test "x$enable_comment" = xyes; then
|
||||
AC_MSG_ERROR([--enable-comment cannot work with --enable-tiny])
|
||||
@@ -93,22 +98,37 @@ if test "x$enable_tiny" = xyes; then
|
||||
enable_comment=no
|
||||
fi
|
||||
fi
|
||||
if test "x$disable_comment" != xyes; then
|
||||
if test "x$enable_comment" != xno; then
|
||||
AC_DEFINE(ENABLE_COMMENT, 1, [Define this to enable the comment/uncomment function.])
|
||||
fi
|
||||
if test "x$enable_comment" != xno; then
|
||||
AC_DEFINE(ENABLE_COMMENT, 1, [Define this to enable the comment/uncomment function.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(extra,
|
||||
AS_HELP_STRING([--disable-extra], [Disable extra features, currently only easter eggs]))
|
||||
AS_HELP_STRING([--disable-extra], [Disable the Easter egg]))
|
||||
if test "x$enable_extra" = xno; then
|
||||
AC_DEFINE(DISABLE_EXTRA, 1, [Define this to disable extra stuff.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(help,
|
||||
AS_HELP_STRING([--disable-help], [Disable help functions]))
|
||||
if test "x$enable_help" = xno; then
|
||||
AC_DEFINE(DISABLE_HELP, 1, [Define this to disable the help text display.])
|
||||
AS_HELP_STRING([--disable-help], [Disable the built-in help texts]))
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
if test "x$enable_help" = xyes; then
|
||||
if test "x$enable_multibuffer" != xyes; then
|
||||
AC_MSG_ERROR([--enable-help needs --enable-multibuffer to work])
|
||||
fi
|
||||
else
|
||||
enable_help=no
|
||||
fi
|
||||
fi
|
||||
if test "x$enable_multibuffer" = xno; then
|
||||
if test "x$enable_help" = xyes; then
|
||||
AC_MSG_ERROR([--enable-help cannot work with --disable-multibuffer])
|
||||
else
|
||||
# Disabling multibuffer silently disables the help texts.
|
||||
enable_help=no
|
||||
fi
|
||||
fi
|
||||
if test "x$enable_help" != xno; then
|
||||
AC_DEFINE(ENABLE_HELP, 1, [Define this to enable the Ctrl+G help texts.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(histories,
|
||||
@@ -118,7 +138,7 @@ if test "x$enable_histories" = xno; then
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(justify,
|
||||
AS_HELP_STRING([--disable-justify], [Disable justify/unjustify functions]))
|
||||
AS_HELP_STRING([--disable-justify], [Disable the justify/unjustify functions]))
|
||||
if test "x$enable_justify" = xno; then
|
||||
AC_DEFINE(DISABLE_JUSTIFY, 1, [Define this to disable the justify routines.])
|
||||
fi
|
||||
@@ -133,52 +153,69 @@ if test "x$enable_tiny" = xyes; then
|
||||
enable_linenumbers=no
|
||||
fi
|
||||
fi
|
||||
if test "x$disable_linenumbers" != xyes; then
|
||||
if test "x$enable_linenumbers" != xno; then
|
||||
AC_DEFINE(ENABLE_LINENUMBERS, 1, [Define this to enable line numbering.])
|
||||
fi
|
||||
if test "x$enable_linenumbers" != xno; then
|
||||
AC_DEFINE(ENABLE_LINENUMBERS, 1, [Define this to enable line numbering.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(mouse,
|
||||
AS_HELP_STRING([--disable-mouse], [Disable mouse support (and -m flag)]))
|
||||
if test "x$enable_mouse" = xno; then
|
||||
AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable the mouse support.])
|
||||
AS_HELP_STRING([--disable-mouse], [Disable mouse support]))
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
if test "x$enable_mouse" != xyes; then
|
||||
enable_mouse=no
|
||||
fi
|
||||
fi
|
||||
if test "x$enable_mouse" != xno; then
|
||||
AC_DEFINE(ENABLE_MOUSE, 1, [Define this to enable mouse support.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(multibuffer,
|
||||
AS_HELP_STRING([--disable-multibuffer], [Disable multiple file buffers]))
|
||||
if test "x$enable_multibuffer" = xno; then
|
||||
AC_DEFINE(DISABLE_MULTIBUFFER, 1, [Define this to disable multiple file buffers.])
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
if test "x$enable_multibuffer" != xyes; then
|
||||
enable_multibuffer=no
|
||||
fi
|
||||
fi
|
||||
if test "x$enable_multibuffer" != xno; then
|
||||
AC_DEFINE(ENABLE_MULTIBUFFER, 1, [Define this to enable multiple file buffers.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(nanorc,
|
||||
AS_HELP_STRING([--disable-nanorc], [Disable use of .nanorc files]))
|
||||
if test "x$enable_nanorc" = xno; then
|
||||
AC_DEFINE(DISABLE_NANORC, 1, [Define this to disable the use of .nanorc files.])
|
||||
else
|
||||
AS_HELP_STRING([--disable-nanorc], [Disable the use of .nanorc files]))
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
if test "x$enable_nanorc" != xyes; then
|
||||
enable_nanorc=no
|
||||
fi
|
||||
fi
|
||||
if test "x$enable_nanorc" != xno; then
|
||||
AC_DEFINE(ENABLE_NANORC, 1, [Define this to enable the use of .nanorc files.])
|
||||
nanorc_support=yes
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(operatingdir,
|
||||
AS_HELP_STRING([--disable-operatingdir], [Disable setting of operating directory (chroot of sorts)]))
|
||||
AS_HELP_STRING([--disable-operatingdir], [Disable the setting of an operating directory]))
|
||||
if test "x$enable_operatingdir" = xno; then
|
||||
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of the operating directory (chroot of sorts).])
|
||||
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of an operating directory (a chroot of sorts).])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(speller,
|
||||
AS_HELP_STRING([--disable-speller], [Disable spell checker functions]))
|
||||
AS_HELP_STRING([--disable-speller], [Disable the spell-checker functions]))
|
||||
if test "x$enable_speller" = xno; then
|
||||
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell checker functions.])
|
||||
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell-checker functions.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(tabcomp,
|
||||
AS_HELP_STRING([--disable-tabcomp], [Disable tab completion functions]))
|
||||
if test "x$enable_tabcomp" = xno; then
|
||||
AC_DEFINE(DISABLE_TABCOMP, 1, [Define this to disable the tab completion functions for filenames and search strings.])
|
||||
AS_HELP_STRING([--disable-tabcomp], [Disable the tab-completion functions]))
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
if test "x$enable_tabcomp" != xyes; then
|
||||
enable_tabcomp=no
|
||||
fi
|
||||
fi
|
||||
if test "x$enable_tabcomp" != xno; then
|
||||
AC_DEFINE(ENABLE_TABCOMP, 1, [Define this to have tab completion for filenames and search strings.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(wordcomp,
|
||||
AS_HELP_STRING([--disable-wordcomp], [Disable the word completion function]))
|
||||
AS_HELP_STRING([--disable-wordcomp], [Disable the word-completion function]))
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
if test "x$enable_wordcomp" = xyes; then
|
||||
AC_MSG_ERROR([--enable-wordcomp cannot work with --enable-tiny])
|
||||
@@ -186,16 +223,14 @@ if test "x$enable_tiny" = xyes; then
|
||||
enable_wordcomp=no
|
||||
fi
|
||||
fi
|
||||
if test "x$disable_wordcomp" != xyes; then
|
||||
if test "x$enable_wordcomp" != xno; then
|
||||
AC_DEFINE(ENABLE_WORDCOMPLETION, 1, [Define this to enable the word completion function.])
|
||||
fi
|
||||
if test "x$enable_wordcomp" != xno; then
|
||||
AC_DEFINE(ENABLE_WORDCOMPLETION, 1, [Define this to enable the word-completion function.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(wrapping,
|
||||
AS_HELP_STRING([--disable-wrapping], [Disable all wrapping of text (and -w flag)]))
|
||||
AS_HELP_STRING([--disable-wrapping], [Disable all hard-wrapping of text]))
|
||||
if test "x$enable_wrapping" = xno; then
|
||||
AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable all text wrapping.])
|
||||
AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable all hard text wrapping.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(wrapping-as-root,
|
||||
@@ -207,7 +242,7 @@ fi
|
||||
AC_ARG_ENABLE(debug,
|
||||
AS_HELP_STRING([--enable-debug], [Enable debugging (disabled by default)]))
|
||||
if test "x$enable_debug" = xyes; then
|
||||
AC_DEFINE(DEBUG, 1, [Define this to enable debug messages and assert warnings.])
|
||||
AC_DEFINE(DEBUG, 1, [Define this to enable debug messages and abortion on failing asserts.])
|
||||
else
|
||||
AC_DEFINE(NDEBUG, 1, [Shut up assert warnings :-)])
|
||||
fi
|
||||
@@ -216,23 +251,17 @@ AC_ARG_ENABLE(tiny,
|
||||
AS_HELP_STRING([--enable-tiny], [Disable features for the sake of size]))
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
AC_DEFINE(NANO_TINY, 1, [Define this to make the nano executable as small as possible.])
|
||||
if test "x$enable_browser" != xyes; then
|
||||
AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in file browser.])
|
||||
fi
|
||||
if test "x$enable_color" != xyes; then
|
||||
AC_DEFINE(DISABLE_COLOR, 1, [Define this to disable syntax highlighting.])
|
||||
color_support=no
|
||||
else
|
||||
if test "x$enable_nanorc" != xyes; then
|
||||
AC_MSG_ERROR([--enable-color with --enable-tiny cannot work without --enable-nanorc])
|
||||
AC_MSG_ERROR([--enable-color needs --enable-nanorc to work])
|
||||
fi
|
||||
fi
|
||||
if test "x$enable_extra" != xyes; then
|
||||
AC_DEFINE(DISABLE_EXTRA, 1, [Define this to disable extra stuff.])
|
||||
fi
|
||||
if test "x$enable_help" != xyes; then
|
||||
AC_DEFINE(DISABLE_HELP, 1, [Define this to disable the help text display.])
|
||||
fi
|
||||
if test "x$enable_histories" != xyes; then
|
||||
AC_DEFINE(DISABLE_HISTORIES, 1, [Define this to disable search and position histories.])
|
||||
fi
|
||||
@@ -242,23 +271,11 @@ if test "x$enable_tiny" = xyes; then
|
||||
if test "x$enable_libmagic" != xyes; then
|
||||
enable_libmagic=no
|
||||
fi
|
||||
if test "x$enable_mouse" != xyes; then
|
||||
AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable the mouse support.])
|
||||
fi
|
||||
if test "x$enable_multibuffer" != xyes; then
|
||||
AC_DEFINE(DISABLE_MULTIBUFFER, 1, [Define this to disable multiple file buffers.])
|
||||
fi
|
||||
if test "x$enable_nanorc" != xyes; then
|
||||
AC_DEFINE(DISABLE_NANORC, 1, [Define this to disable the use of .nanorc files.])
|
||||
fi
|
||||
if test "x$enable_operatingdir" != xyes; then
|
||||
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of the operating directory (chroot of sorts).])
|
||||
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of an operating directory (a chroot of sorts).])
|
||||
fi
|
||||
if test "x$enable_speller" != xyes; then
|
||||
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell checker functions.])
|
||||
fi
|
||||
if test "x$enable_tabcomp" != xyes; then
|
||||
AC_DEFINE(DISABLE_TABCOMP, 1, [Define this to disable the tab completion functions for files and search strings.])
|
||||
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell-checker functions.])
|
||||
fi
|
||||
if test "x$enable_wrapping" != xyes; then
|
||||
AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable all text wrapping.])
|
||||
@@ -545,13 +562,13 @@ else
|
||||
fi
|
||||
|
||||
AC_CHECK_LIB([$CURSES_LIB_NAME], [use_default_colors],
|
||||
[AC_DEFINE(HAVE_USE_DEFAULT_COLORS, 1, [Define this if your curses library has the use_default_colors() command.])],
|
||||
[AC_DEFINE(HAVE_USE_DEFAULT_COLORS, 1, [Define this if your curses library has the use_default_colors() function.])],
|
||||
[], [$CURSES_LIB])
|
||||
AC_CHECK_LIB([$CURSES_LIB_NAME], [set_escdelay],
|
||||
[AC_DEFINE(HAVE_SET_ESCDELAY, 1, [Define this if your curses library has the set_escdelay() function.])],
|
||||
[], [$CURSES_LIB])
|
||||
AC_CHECK_LIB([$CURSES_LIB_NAME], [key_defined],
|
||||
[AC_DEFINE(HAVE_KEY_DEFINED, 1, [Define this if your curses library has the key_defined() command.])],
|
||||
[AC_DEFINE(HAVE_KEY_DEFINED, 1, [Define this if your curses library has the key_defined() function.])],
|
||||
[], [$CURSES_LIB])
|
||||
|
||||
dnl Parse any configure options.
|
||||
@@ -678,7 +695,7 @@ int main(void)
|
||||
int testcolor = COLOR_WHITE;
|
||||
return 0;
|
||||
}],
|
||||
AC_DEFINE(NEED_XOPEN_SOURCE_EXTENDED, 1, [Define this if you need the _XOPEN_SOURCE_EXTENDED macro for color support])
|
||||
AC_DEFINE(NEED_XOPEN_SOURCE_EXTENDED, 1, [Define this if you need the _XOPEN_SOURCE_EXTENDED macro for color support.])
|
||||
AC_MSG_RESULT(yes),
|
||||
AC_MSG_RESULT(not sure)
|
||||
AC_MSG_WARN([*** Couldn't successfully compile basic color test with or without _XOPEN_SOURCE_EXTENDED])
|
||||
@@ -696,7 +713,7 @@ int main(void)
|
||||
COLS = 25;
|
||||
return 0;
|
||||
}],
|
||||
AC_DEFINE(REDEFINING_MACROS_OK, 1, [Define this if you know your curses library allows LINES and COLS to be redefined to deal with a resizing bug])
|
||||
AC_DEFINE(REDEFINING_MACROS_OK, 1, [Define this if you know your curses library allows LINES and COLS to be redefined to deal with a resizing bug.])
|
||||
AC_MSG_RESULT(yes),
|
||||
AC_MSG_RESULT(no),
|
||||
AC_MSG_WARN([*** Can't check for macro redefinability when cross-compiling]))
|
||||
|
||||
@@ -28,6 +28,6 @@ info_TEXINFOS = nano.texi
|
||||
BUILT_SOURCES += nano.html
|
||||
dist_html_DATA += nano.html
|
||||
|
||||
AM_MAKEINFOHTMLFLAGS = --no-split
|
||||
AM_MAKEINFOHTMLFLAGS = --no-split -c HEADERS=0
|
||||
|
||||
EXTRA_DIST = $(BUILT_SOURCES) $(info_TEXINFOS)
|
||||
|
||||
35
doc/faq.html
35
doc/faq.html
@@ -38,10 +38,11 @@
|
||||
<a href="#4.2">4.2. Ack! My Backspace/Delete/Enter/Meta/double bucky key doesn't seem to work! What can I do?</a><br>
|
||||
<a href="#4.3">4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</a><br>
|
||||
<a href="#4.4">4.4. Ack! When I hold down a Meta key combination for a while, the character of the held key gets inserted now and then. What gives?</a><br>
|
||||
<a href="#4.5">4.5. How do I type the F13-F16 keys shown in the help browser? My keyboard only has F1-F12!</a><br>
|
||||
<a href="#4.5">4.5. How do I type the F13-F16 keys listed in the help viewer? My keyboard only has F1-F12!</a><br>
|
||||
<a href="#4.6">4.6. nano crashes when I type <insert keystroke here>!</a><br>
|
||||
<a href="#4.7">4.7. nano crashes when I resize my window. How can I fix that?</a><br>
|
||||
<a href="#4.8">4.8. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</a><br>
|
||||
<a href="#4.8a">4.8a. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</a><br>
|
||||
<a href="#4.8b">4.8b. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?<a><br>
|
||||
<a href="#4.9">4.9. I've compiled nano with color support, but I don't see any color when I run it!</a><br>
|
||||
<a href="#4.10">4.10. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
|
||||
<a href="#4.11">4.11. How do I select text for or paste text from the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?</a><br>
|
||||
@@ -82,7 +83,7 @@
|
||||
<h2><a name="1.3"></a>1.3. Why the name change from TIP?</h2>
|
||||
<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>
|
||||
<h2><a name="1.4"></a>1.4. What is the current version of nano?</h2>
|
||||
<blockquote><p>The current version of nano <i>should</i> be <b>2.8.1</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>2.8.6</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
|
||||
<h2><a name="1.5"></a>1.5. I want to read the man page without having to download the program!</h2>
|
||||
<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%">
|
||||
@@ -138,27 +139,29 @@
|
||||
<pre>
|
||||
<b>--disable-browser</b> Disable the built-in file browser
|
||||
<b>--disable-color</b> Disable color and syntax highlighting
|
||||
<b>--disable-extra</b> Disable extra features (currently only an easter egg)
|
||||
<b>--disable-help</b> Disable help functions
|
||||
<b>--disable-comment</b> Disable the comment/uncomment function
|
||||
<b>--disable-extra</b> Disable the easter egg
|
||||
<b>--disable-help</b> Disable the built-in help texts
|
||||
<b>--disable-histories</b> Disable the saving of search strings and cursor positions
|
||||
<b>--disable-justify</b> Disable justify/unjustify functions
|
||||
<b>--disable-justify</b> Disable the justify/unjustify functions
|
||||
<b>--disable-libmagic</b> Disable the use of libmagic for determining a file's syntax
|
||||
<b>--disable-linenumbers</b> Disable line numbering
|
||||
<b>--disable-mouse</b> Disable mouse support
|
||||
<b>--disable-multibuffer</b> Disable having multiple file buffers open
|
||||
<b>--disable-multibuffer</b> Disable the opening of multiple file buffers
|
||||
<b>--disable-nanorc</b> Disable the use of .nanorc files
|
||||
<b>--disable-operatingdir</b> Disable the setting of an operating directory
|
||||
<b>--disable-speller</b> Disable spell checker functions
|
||||
<b>--disable-tabcomp</b> Disable tab completion functions
|
||||
<b>--disable-wordcomp</b> Disable the word completion function
|
||||
<b>--disable-speller</b> Disable the spell-checker functions
|
||||
<b>--disable-tabcomp</b> Disable the tab-completion functions
|
||||
<b>--disable-wordcomp</b> Disable the word-completion function
|
||||
<b>--disable-wrapping</b> Disable all hard-wrapping of text</pre>
|
||||
<p>There's also the <b>--enable-tiny</b> option which disables everything above, as well as some larger chunks of the program (like the marker code that you use with Control-^ to select text). Also, if you know you aren't going to be using other languages, you can use <b>--disable-nls</b> to disable internationalization and save a few K to a few dozen K depending on whether you have locale support on your system. And finally, there's always good old <b>strip</b> to strip all debugging code and code that exists in libraries on your system.</p>
|
||||
<p>With <b>--disable-wrapping-as-root</b> you can disable any hard-wrapping by default when the user is root, useful to prevent accidentally changing long lines in system configuration files.</p>
|
||||
</blockquote>
|
||||
<h2><a name="3.7"></a>3.7. Tell me more about this multibuffer stuff!</h2>
|
||||
<blockquote><p>To use multiple file buffers, you must not have configured nano with <b>--disable-multibuffer</b> nor with <b>--enable-tiny</b> (use <b>nano -V</b> to check the compilation options). Then when you want to insert a file into its own buffer instead of into the current file, just hit <b>Meta-F</b>, then insert the file as normal with <b>^R</b>. If you always want files to be loaded into their own buffers, use the <b>--multibuffer</b> or <b>-F</b> flag when you invoke nano.</p>
|
||||
<blockquote><p>To use multiple file buffers, you must not have configured nano with <b>--disable-multibuffer</b> nor with <b>--enable-tiny</b> (use <b>nano -V</b> to check the compilation options). Then when you want to insert a file into its own buffer instead of into the current file, just hit <b>Meta-F</b> after typing <b>^R</b>. If you always want files to be loaded into their own buffers, use the <b>--multibuffer</b> or <b>-F</b> flag when you invoke nano.</p>
|
||||
<p>You can move between the buffers you have open with the <b>Meta-<</b> and <b>Meta-></b> keys, or more easily without holding Shift: <b>Meta-,</b> and <b>Meta-.</b> (clear as mud, right? =-). When you have more than one file buffer open, the ^X shortcut will say "Close", instead of the normal "Exit" when only one buffer is open.</p></blockquote>
|
||||
<h2><a name="3.8"></a>3.8. Tell me more about this verbatim input stuff!</h2>
|
||||
<blockquote><p>When you want to insert a literal character into the file you're editing, such as a control character that nano usually treats as a command, first press <b>Meta-V</b> (if you're not at a prompt, you'll get the message "Verbatim Input" on the statusbar), then press the key(s) that generate the character you want.</p>
|
||||
<blockquote><p>When you want to insert a literal character into the file you're editing, such as a control character that nano usually treats as a command, first press <b>Meta-V</b> (if you're not at a prompt, you'll get the message "Verbatim Input" on the status bar), then press the key(s) that generate the character you want.</p>
|
||||
<p>Alternatively, if you've enabled Unicode support (see section <a href="#5.3">5.3</a>), you can press <b>Meta-V</b> and then type a six-digit hexadecimal code (from 000000 to 10FFFF, case-insensitive), and the character with the corresponding value will be inserted. The statubar will change to "Unicode Input: ......" when you do this.</p></blockquote>
|
||||
<h2><a name="3.9a"></a>3.9a. How do I make a .nanorc file that will be read when I start nano?</h2>
|
||||
<blockquote><p>It's not hard at all! But, your nano must <b>not</b> have been compiled with <b>--disable-nanorc</b>. Then simply copy the <b>sample.nanorc</b> that came with the nano source or your nano package (most likely in /usr/doc/nano) to .nanorc in your home directory. If you didn't get one, the syntax of the file is simple. Flags are turned on and off by using the words <b>set</b> and <b>unset</b> plus the long option name for the feature. For example, "set nowrap" or "set smarthome".</p></blockquote>
|
||||
@@ -184,16 +187,18 @@
|
||||
<blockquote><p>You can use the <b>-K</b> or <b>--rebindkeypad</b> option on the command line, or add the line <b>set rebindkeypad</b> to your .nanorc. However, nano's mouse support won't work properly if you do any of these things.</p></blockquote>
|
||||
<h2><a name="4.4"></a>4.4. Ack! When I hold down a Meta key combination for a while, the character of the held key gets inserted now and then. What gives?</h2>
|
||||
<blockquote><p>This was a bug in how nano handled consecutive escape sequences. It should be fixed since version 2.6.0.</p></blockquote>
|
||||
<h2><a name="4.5"></a>4.5. How do I type the F13-F16 keys shown in the help browser? My keyboard only has F1-F12!</h2>
|
||||
<h2><a name="4.5"></a>4.5. How do I type the F13-F16 keys listed in the help viewer? My keyboard only has F1-F12!</h2>
|
||||
<blockquote><p>It depends on the terminal type you're using. On some terminals, such as the FreeBSD console, xterm, konsole, and gnome-terminal, Shift-F1 to Shift-F4 will generate F13 to F16. On other terminals, such as the Linux console, rxvt, and Eterm, Shift-F3 to Shift-F6 will generate F13 to F16.</p></blockquote>
|
||||
<h2><a name="4.6"></a>4.6. nano crashes when I type <insert keystroke here>!</h2>
|
||||
<blockquote><p>If you aren't trying some bizarre keystroke combination with some bizarre $TERM entry, chances are you have found a bug. You are welcome to submit it to the <a href="mailto:nano-devel@gnu.org">nano-devel</a> list or in the <a href="https://savannah.gnu.org/bugs/?group=nano">bug tracker</a> on Savannah.</p></blockquote>
|
||||
<h2><a name="4.7"></a>4.7. nano crashes when I resize my window. How can I fix that?</h2>
|
||||
<blockquote><p>Older versions of nano had this problem. Please upgrade to version 2.7.0 or newer.</p></blockquote>
|
||||
<h2><a name="4.8"></a>4.8. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</h2>
|
||||
<h2><a name="4.8a"></a>4.8a. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</h2>
|
||||
<blockquote><p>You have the autoindent feature turned on. Hit Meta-I to turn it off, paste your text, and then hit Meta-I again to turn it back on.</p></blockquote>
|
||||
<h2><a name="4.8b"></a>4.8b. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?</h2>
|
||||
<blockquote><p>When pasting from Windows, in some situations linefeeds are sent instead of carriage returns (Enters). And linefeeds are <b>^J</b>s, which make nano justify (rewrap) the current paragraph. To prevent these linefeeds from causing these unwanted justifications, add this line to your .nanorc on the remote Linux box: <b>unbind ^J main</b> or <b>bind ^J enter main</b>, depending on whether the paste contains CR + LF or only LF.</p></blockquote>
|
||||
<h2><a name="4.9"></a>4.9. I've compiled nano with color support, but I don't see any color when I run it!</h2>
|
||||
<blockquote><p>If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Several example configurations are in the <b>doc/syntax</b> subdirectory of the nano source, which are normally installed to <b>/usr/local/share/nano</b>. To enable all of them, uncomment the line <b># include "/usr/local/share/nano/*.nanorc"</b> in your nanorc. See also section <a href="#3.9a">3.9a</a>.</p></blockquote>
|
||||
<blockquote><p>If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Several example configurations are in the <b>syntax/</b> subdirectory of the nano source, which are normally installed to <b>/usr/local/share/nano/</b>. To enable all of them, uncomment the line <b># include "/usr/local/share/nano/*.nanorc"</b> in your nanorc. See also section <a href="#3.9a">3.9a</a>.</p></blockquote>
|
||||
<h2><a name="4.10"></a>4.10. How do I make nano my default editor (in Pine, mutt, etc.)?</h2>
|
||||
<blockquote><p>You need to make nano your $EDITOR. If you want this to be saved, you should put a line like this in your <b>.bashrc</b> if you use bash (or <b>.zshrc</b> if you believe in zsh):</p>
|
||||
<p><b>export EDITOR=/usr/local/bin/nano</b></p>
|
||||
|
||||
55
doc/nano.1
55
doc/nano.1
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANO 1 "version 2.8.1" "April 2017"
|
||||
.TH NANO 1 "version 2.8.6" "July 2017"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
|
||||
.SH NAME
|
||||
@@ -27,18 +27,17 @@ nano \- Nano's ANOther editor, an enhanced free Pico clone
|
||||
.RI [ options "] [[+" line [, column "]]\ " file "]..."
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fBnano\fP is a small, free and friendly editor which aims to replace
|
||||
Pico, the default editor included in the non-free Pine package. On
|
||||
top of copying Pico's look and feel, \fBnano\fP also implements some
|
||||
missing (or disabled by default) features in Pico, such as "search and
|
||||
replace" and "go to line and column number".
|
||||
\fBnano\fP is a small and friendly editor. It copies the look and feel
|
||||
of Pico, but is free software, and implements several features that Pico
|
||||
lacks, such as: opening multiple files, scrolling per line, undo/redo,
|
||||
syntax coloring, line numbering, and soft-wrapping overlong lines.
|
||||
|
||||
When opening a file, 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.
|
||||
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.
|
||||
|
||||
If the first file specified is a dash (\fB\-\fR), \fBnano\fR will read
|
||||
data from standard input.
|
||||
As a special case: if instead of a filename a dash (\fB\-\fR) is given,
|
||||
\fBnano\fR will read data from standard input.
|
||||
|
||||
.SH EDITING
|
||||
Entering text and moving around in a file is straightforward: typing the
|
||||
@@ -60,7 +59,7 @@ Since nano-2.7.0, text can also be selected by holding Shift and moving the
|
||||
cursor with the arrow keys. Holding down the Alt key too will increase the
|
||||
stride.
|
||||
.PP
|
||||
The two lines at the bottom of the screen show the most important commands;
|
||||
The two lines at the bottom of the screen show some important commands;
|
||||
the built-in help (\fB^G\fR) lists all the available ones.
|
||||
The default key bindings can be changed via the .nanorc file -- see
|
||||
.BR nanorc (5).
|
||||
@@ -80,7 +79,7 @@ filename suffixed with a tilde (\fB~\fP).
|
||||
.TP
|
||||
.BR \-C\ \fIdirectory\fR ", " \-\-backupdir= \fIdirectory
|
||||
Make and keep not just one backup file, but make and keep a uniquely
|
||||
numbered one every time a file is saved -- when backups are enabled.
|
||||
numbered one every time a file is saved -- when backups are enabled (\fB\-B\fR).
|
||||
The uniquely numbered files are stored in the specified \fIdirectory\fR.
|
||||
.TP
|
||||
.BR \-D ", " \-\-boldtext
|
||||
@@ -90,10 +89,10 @@ Use bold text instead of reverse video text.
|
||||
Convert typed tabs to spaces.
|
||||
.TP
|
||||
.BR \-F ", " \-\-multibuffer
|
||||
Enable multiple file buffers (if support for them has been compiled in).
|
||||
Read a file into a new buffer by default.
|
||||
.TP
|
||||
.BR \-G ", " \-\-locking
|
||||
Enable vim-style file locking when editing files.
|
||||
Use vim-style file locking when editing files.
|
||||
.TP
|
||||
.BR \-H ", " \-\-historylog
|
||||
Log search and replace strings to \fI~/.nano/search_history\fP, so they can be
|
||||
@@ -114,7 +113,7 @@ Don't add newlines to the ends of files.
|
||||
Disable automatic conversion of files from DOS/Mac format.
|
||||
.TP
|
||||
.BR \-O ", " \-\-morespace
|
||||
Use the blank line below the titlebar as extra editing space.
|
||||
Use the blank line below the title bar as extra editing space.
|
||||
.TP
|
||||
.BR \-P ", " \-\-positionlog
|
||||
For the 200 most recent files, log the last position of the cursor,
|
||||
@@ -137,7 +136,7 @@ This restricted mode is also accessible by invoking \fBnano\fP
|
||||
with any name beginning with 'r' (e.g. "rnano").
|
||||
.TP
|
||||
.BR \-S ", " \-\-smooth
|
||||
Enable smooth scrolling. Text will scroll line-by-line, instead of the
|
||||
Use smooth scrolling: text will scroll line-by-line, instead of the
|
||||
usual chunk-by-chunk behavior.
|
||||
.TP
|
||||
.BR \-T\ \fInumber\fR ", " \-\-tabsize= \fInumber
|
||||
@@ -145,8 +144,9 @@ Set the size (width) of a tab to \fInumber\fP columns. The value of
|
||||
\fInumber\fP must be greater than 0. The default value is 8.
|
||||
.TP
|
||||
.BR \-U ", " \-\-quickblank
|
||||
Do quick statusbar blanking. Statusbar messages will disappear after 1
|
||||
keystroke instead of 25. Note that \fB\-c\fP overrides this.
|
||||
Do quick status-bar blanking: status-bar messages will disappear after 1
|
||||
keystroke instead of 25. Note that option \fB\-c\fR (\fB\-\-constantshow\fR)
|
||||
overrides this.
|
||||
.TP
|
||||
.BR \-V ", " \-\-version
|
||||
Show the current version number and exit.
|
||||
@@ -164,8 +164,13 @@ should be considered as part of a word. This overrides option
|
||||
Specify the name of the syntax highlighting to use from among the ones
|
||||
defined in the \fInanorc\fP files.
|
||||
.TP
|
||||
.BR \-a ", " \-\-atblanks
|
||||
When doing soft line wrapping, wrap lines at whitespace
|
||||
instead of always at the edge of the screen.
|
||||
.TP
|
||||
.BR \-c ", " \-\-constantshow
|
||||
Constantly show the cursor position. Note that this overrides \fB\-U\fP.
|
||||
Constantly show the cursor position on the status bar.
|
||||
Note that this overrides option \fB\-U\fR (\fB\-\-quickblank\fR).
|
||||
.TP
|
||||
.BR \-d ", " \-\-rebinddelete
|
||||
Interpret the Delete key differently so that both Backspace and Delete
|
||||
@@ -183,7 +188,7 @@ Show a summary of the available command-line options and exit.
|
||||
Indent new lines to the previous line's indentation. Useful when
|
||||
editing source code.
|
||||
.TP
|
||||
.BR \-k ", " \-\-cut
|
||||
.BR \-k ", " \-\-cutfromcursor
|
||||
Make the 'Cut Text' command (normally \fB^K\fR) cut from the current cursor
|
||||
position to the end of the line, instead of cutting the entire line.
|
||||
.TP
|
||||
@@ -221,7 +226,7 @@ Hard-wrap lines at column \fInumber\fP. If this value is 0 or less, wrapping
|
||||
will occur at the width of the screen less \fInumber\fP columns, allowing
|
||||
the wrap point to vary along with the width of the screen if the screen
|
||||
is resized. The default value is \-8. This option conflicts with
|
||||
\fB\-w\fR -- the last one given takes effect.
|
||||
\fB\-w\fR (\fB\-\-nowrap\fR) -- the last one given takes effect.
|
||||
.TP
|
||||
.BR \-s\ \fIprogram\fR ", " \-\-speller= \fIprogram
|
||||
Use this alternative spell checker command.
|
||||
@@ -239,7 +244,7 @@ Just view the file and disallow editing: read-only mode.
|
||||
.TP
|
||||
.BR \-w ", " \-\-nowrap
|
||||
Disable the hard-wrapping of long lines. This option conflicts with
|
||||
\fB\-r\fR -- the last one given takes effect.
|
||||
\fB\-r\fR (\fB\-\-fill\fR) -- the last one given takes effect.
|
||||
.TP
|
||||
.BR \-x ", " \-\-nohelp
|
||||
Don't show the two help lines at the bottom of the screen.
|
||||
@@ -255,7 +260,7 @@ continuing it over multiple screen lines. Since
|
||||
this option last when using other options (e.g.\& 'nano \-wS$') or pass it
|
||||
separately (e.g.\& 'nano \-wS \-$').
|
||||
.TP
|
||||
.BR \-a ", " \-b ", " \-e ", " \-f ", " \-j
|
||||
.BR \-b ", " \-e ", " \-f ", " \-j
|
||||
Ignored, for compatibility with Pico.
|
||||
|
||||
.SH TOGGLES
|
||||
@@ -300,7 +305,7 @@ Please report any other bugs that you encounter via:
|
||||
\fIhttps://savannah.gnu.org/bugs/?group=nano\fR.
|
||||
|
||||
.SH HOMEPAGE
|
||||
https://nano-editor.org/
|
||||
\fIhttps://nano-editor.org/\fR
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR nanorc (5)
|
||||
|
||||
661
doc/nano.texi
661
doc/nano.texi
File diff suppressed because it is too large
Load Diff
148
doc/nanorc.5
148
doc/nanorc.5
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANORC 5 "version 2.8.1" "April 2017"
|
||||
.TH NANORC 5 "version 2.8.6" "July 2017"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
|
||||
.SH NAME
|
||||
@@ -57,6 +57,10 @@ When backing up files, allow the backup to succeed even if its permissions
|
||||
can't be (re)set due to special OS considerations. You should
|
||||
NOT enable this option unless you are sure you need it.
|
||||
.TP
|
||||
.B set atblanks
|
||||
When soft line wrapping is enabled, make it wrap lines at blank characters
|
||||
(tabs and spaces) instead of always at the edge of the screen.
|
||||
.TP
|
||||
.B set autoindent
|
||||
Use auto-indentation.
|
||||
.TP
|
||||
@@ -66,7 +70,7 @@ the file's name.
|
||||
.TP
|
||||
.B set backupdir "\fIdirectory\fP"
|
||||
Make and keep not just one backup file, but make and keep a uniquely
|
||||
numbered one every time a file is saved --- when backups are enabled
|
||||
numbered one every time a file is saved -- when backups are enabled
|
||||
with \fBset backup\fR or \fB\-\-backup\fR or \fB\-B\fR.
|
||||
The uniquely numbered files are stored in the specified \fIdirectory\fR.
|
||||
.TP
|
||||
@@ -74,9 +78,10 @@ The uniquely numbered files are stored in the specified \fIdirectory\fR.
|
||||
Do backwards searches by default.
|
||||
.TP
|
||||
.B set boldtext
|
||||
Use bold instead of reverse video for the titlebar, statusbar, key combos,
|
||||
and selected text. This can be overridden for the first three by setting
|
||||
the options \fBtitlecolor\fP, \fBstatuscolor\fP, and \fBkeycolor\fP.
|
||||
Use bold instead of reverse video for the title bar, status bar, key combos,
|
||||
function tags, line numbers, and selected text. This can be overridden for
|
||||
the first five by setting the options \fBtitlecolor\fP, \fBstatuscolor\fP,
|
||||
\fBkeycolor\fP, \fBfunctioncolor\fP, and \fBnumbercolor\fP.
|
||||
.TP
|
||||
.B set brackets "\fIstring\fP"
|
||||
Set the characters treated as closing brackets when justifying
|
||||
@@ -90,14 +95,17 @@ Do case-sensitive searches by default.
|
||||
.B set constantshow
|
||||
Constantly display the cursor position in the status bar.
|
||||
(The old form of this option, '\fBset const\fR', is deprecated.)
|
||||
This overrides the option \fBquickblank\fR.
|
||||
.TP
|
||||
.B set cut
|
||||
Use cut-to-end-of-line by default, instead of cutting the whole line.
|
||||
.B set cutfromcursor
|
||||
Use cut-from-cursor-to-end-of-line by default, instead of cutting the whole line.
|
||||
(The old form of this option, '\fBset cut\fR', is deprecated.)
|
||||
.TP
|
||||
.B set fill \fInumber\fR
|
||||
Hard-wrap lines at column number \fInumber\fR. If \fInumber\fR is 0 or less,
|
||||
the maximum line length will be the screen width less \fInumber\fP columns.
|
||||
The default value is \fB\-8\fR.
|
||||
The default value is \fB\-8\fR. This option conflicts with
|
||||
\fBnowrap\fR -- the last one given takes effect.
|
||||
.TP
|
||||
.B set functioncolor \fIfgcolor\fR,\fIbgcolor\fR
|
||||
Specify the color combination to use for the function descriptions
|
||||
@@ -129,7 +137,7 @@ come before the closing set, and the two sets must be in the same order.
|
||||
The default value is "\fB(<[{)>]}\fP".
|
||||
.TP
|
||||
.B set morespace
|
||||
Use the blank line below the titlebar as extra editing space.
|
||||
Use the blank line below the title bar as extra editing space.
|
||||
.TP
|
||||
.B set mouse
|
||||
Enable mouse support, if available for your system. When enabled, mouse
|
||||
@@ -155,7 +163,8 @@ Don't pause between warnings at startup. This means that only
|
||||
the last one will be visible (when there are multiple ones).
|
||||
.TP
|
||||
.B set nowrap
|
||||
Don't hard-wrap text at all.
|
||||
Don't hard-wrap text at all. This option conflicts with
|
||||
\fBfill\fR -- the last one given takes effect.
|
||||
.TP
|
||||
.B set numbercolor \fIfgcolor\fR,\fIbgcolor\fR
|
||||
Specify the color combination to use for line numbers.
|
||||
@@ -182,8 +191,8 @@ specfified closing punctuation, optionally followed by closing brackets
|
||||
(see \fBbrackets\fP), can end sentences. The default value is "\fB!.?\fP".
|
||||
.TP
|
||||
.B set quickblank
|
||||
Do quick statusbar blanking. Statusbar messages will disappear after 1
|
||||
keystroke instead of 25.
|
||||
Do quick status-bar blanking: status-bar messages will disappear after 1
|
||||
keystroke instead of 25. The option \fBconstantshow\fR overrides this.
|
||||
.TP
|
||||
.B set quiet
|
||||
\fBnano\fP will not report errors in the \fInanorc\fP file nor ask them
|
||||
@@ -233,7 +242,7 @@ Use spelling checker \fIspellprog\fP instead of the built-in one, which
|
||||
calls \fIspell\fP.
|
||||
.TP
|
||||
.B set statuscolor \fIfgcolor\fR,\fIbgcolor\fR
|
||||
Specify the color combination to use for the statusbar.
|
||||
Specify the color combination to use for the status bar.
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
.B set suspend
|
||||
@@ -250,7 +259,7 @@ Convert typed tabs to spaces.
|
||||
Save automatically on exit, don't prompt.
|
||||
.TP
|
||||
.B set titlecolor \fIfgcolor\fR,\fIbgcolor\fR
|
||||
Specify the color combination to use for the titlebar.
|
||||
Specify the color combination to use for the title bar.
|
||||
Valid names for the foreground and background colors are:
|
||||
.BR white ", " black ", " blue ", " green ", " red ", " cyan ", " yellow ", and " magenta .
|
||||
The name of the foreground color may be prefixed with \fBbright\fR.
|
||||
@@ -266,7 +275,8 @@ Disallow file modification.
|
||||
.TP
|
||||
.B set whitespace "\fIstring\fP"
|
||||
Set the two characters used to indicate the presence of tabs and
|
||||
spaces. They must be single-column characters.
|
||||
spaces. They must be single-column characters. The default pair
|
||||
for a UTF-8 locale is "\fB\[Fc]\[md]\fR", and for other locales "\fB>.\fR".
|
||||
.TP
|
||||
.B set wordbounds
|
||||
Detect word boundaries differently by treating punctuation
|
||||
@@ -285,53 +295,58 @@ 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
|
||||
A separate syntax can be defined for each kind of file
|
||||
For each kind of file a separate syntax can be defined
|
||||
via the following commands:
|
||||
.TP
|
||||
.BR syntax " ""\fIstr\fR"" [""\fIfileregex\fR"" ...]"
|
||||
Defines a syntax named \fIstr\fP which can be activated via the
|
||||
.BR \-Y / \-\-syntax
|
||||
command-line option, or will be automatically activated if
|
||||
the current filename matches the extended regular expression
|
||||
\fIfileregex\fP. All subsequent \fBcolor\fR, \fBicolor\fR,
|
||||
\fBheader\fR and other such statements will apply to this
|
||||
\fIstr\fP syntax until a new \fBsyntax\fR command is encountered.
|
||||
.BR syntax " ""\fIname\fR"" [""\fIfileregex\fR"" ...]"
|
||||
Start the definition of a syntax with this \fIname\fR.
|
||||
All subsequent \fBcolor\fR and other such commands
|
||||
will be added to this syntax, until a new \fBsyntax\fR
|
||||
command is encountered.
|
||||
|
||||
The \fBnone\fP syntax is reserved; specifying it on the command line is
|
||||
the same as not having a syntax at all. The \fBdefault\fP syntax is
|
||||
special: it takes no \fIfileregex\fP, and applies to files that don't
|
||||
match any syntax's \fIfileregex\fP.
|
||||
When \fBnano\fR is run, this syntax will be automatically
|
||||
activated if the current filename matches the extended regular
|
||||
expression \fIfileregex\fR. Or the syntax can be explicitly
|
||||
activated by using the \fB-Y\fR or \fB\-\-syntax\fR
|
||||
command-line option followed by the \fIname\fR.
|
||||
|
||||
The syntax "\fBdefault\fP" is special: it takes no \fIfileregex\fR,
|
||||
and applies to files that don't match any syntax's regexes.
|
||||
The syntax "\fBnone\fP" is reserved; specifying it on the command line
|
||||
is the same as not having a syntax at all.
|
||||
.TP
|
||||
.BR header " ""\fIregex\fR"" " ...
|
||||
If from all defined syntaxes no \fIfileregex\fR matched, then compare
|
||||
this \fIregex\fR (or regexes) against the first line of the current file,
|
||||
to determine whether this syntax should be used for it.
|
||||
.TP
|
||||
.BR magic " ""\fIregex\fR"" " ...
|
||||
If no \fIfileregex\fR matched and no \fBheader\fR regex matched
|
||||
either, then compare this \fIregex\fR (or regexes) against the
|
||||
result of querying the \fBmagic\fP database about the current
|
||||
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 linter " program " \fR[ "arg " \fR...]
|
||||
Use the given \fIprogram\fR to run a syntax check on the current file
|
||||
(this overrides the speller function when defined).
|
||||
Use the given \fIprogram\fR to run a syntax check on the current file.
|
||||
(This overrides the speller function.)
|
||||
.TP
|
||||
.BI formatter " program " \fR[ "arg " \fR...]
|
||||
Use the given \fIprogram\fR to automatically reformat text.
|
||||
Useful in certain programming languages (e.g. Go).
|
||||
Use the given \fIprogram\fR to automatically reformat text --
|
||||
useful in a programming language like Go.
|
||||
(This overrides the speller and linter functions.)
|
||||
.TP
|
||||
.BR header " \fIregex\fR " ...
|
||||
Add one or more regexes which will
|
||||
be compared against the very first line of the file to be edited,
|
||||
to determine whether this syntax should be used for that file.
|
||||
.TP
|
||||
.BR magic " \fIregex\fR " ...
|
||||
Add one or more regexes which
|
||||
will be compared against the result of querying the \fBmagic\fP
|
||||
database about the file to be edited, to determine whether this
|
||||
syntax should be used for that file. This
|
||||
functionality only works when \fBlibmagic\fP is installed on the
|
||||
system and will be silently ignored otherwise.
|
||||
.TP
|
||||
.BI comment " string"
|
||||
Use the given string for commenting and uncommenting lines. A vertical bar or
|
||||
pipe character (|) designates bracket-style comments; for example, "/*|*/" for
|
||||
.BR comment " ""\fIstring\fR"""
|
||||
Use the given string for commenting and uncommenting lines.
|
||||
If the string contains a vertical bar or pipe character (\fB|\fR),
|
||||
this designates bracket-style comments; for example, "\fB/*|*/\fR" for
|
||||
CSS files. The characters before the pipe are prepended to the line and the
|
||||
characters after the pipe are appended at the end of the line. If no pipe
|
||||
character is present, the entire string is prepended; for example, "#" for
|
||||
Python files. If empty double quotes are specified, the comment/uncomment
|
||||
function is disabled; for example, "" for JSON. Double quotes or backslashes
|
||||
may be escaped with a backslash; for example, ".\\"" for man page source.
|
||||
character is present, the full string is prepended; for example, "\fB#\fR"
|
||||
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
|
||||
.B color \fIfgcolor\fR,\fIbgcolor\fR """\fIregex\fR""" ...
|
||||
Display all pieces of text that match
|
||||
@@ -345,32 +360,33 @@ foreground. If your terminal supports transparency, not specifying a
|
||||
background.
|
||||
.TP
|
||||
.B icolor \fIfgcolor\fR,\fIbgcolor\fR """\fIregex\fR""" ...
|
||||
Same as above, except that the text matching is case insensitive.
|
||||
Same as above, except that the matching is case insensitive.
|
||||
.TP
|
||||
.BR color " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIsr\fR"" " end= """\fIer\fR""
|
||||
.BR color " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIfromrx\fR"" " end= """\fItorx\fR""
|
||||
Display all pieces of text whose start matches extended regular expression
|
||||
\fIsr\fP and whose end matches extended regular expression \fIer\fP with
|
||||
\fIfromrx\fP and whose end matches extended regular expression \fItorx\fP with
|
||||
foreground color \fIfgcolor\fP and background color \fIbgcolor\fP,
|
||||
at least one of which must be specified. This means that, after an
|
||||
initial instance of \fIsr\fP, all text will be highlighted until the
|
||||
first instance of \fIer\fP. This allows syntax highlighting to span
|
||||
initial instance of \fIfromrx\fP, all text until the first instance of
|
||||
\fItorx\fP will be colored. This allows syntax highlighting to span
|
||||
multiple lines.
|
||||
.TP
|
||||
.BR icolor " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIsr\fR"" " end= """\fIer\fR""
|
||||
Same as above, except that the text matching is case insensitive.
|
||||
.BR icolor " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIfromrx\fR"" " end= """\fItorx\fR""
|
||||
Same as above, except that the matching is case insensitive.
|
||||
.TP
|
||||
.BR include " ""\fIsyntaxfile\fR"""
|
||||
Read in self-contained color syntaxes from \fIsyntaxfile\fP. Note that
|
||||
\fIsyntaxfile\fP may contain only the above commands, from \fBsyntax\fP
|
||||
to \fBicolor\fP.
|
||||
.TP
|
||||
.BI extendsyntax " str directive " \fR[ "arg " \fR...]
|
||||
Extend the syntax previously defined as \fIstr\fP to include
|
||||
new information. This allows you to add a new \fBcolor\fP, \fBicolor\fP,
|
||||
\fBheader\fP, \fBmagic\fP, \fBcomment\fP, \fBlinter\fP, or \fBformatter\fP directive
|
||||
to an already defined syntax -- useful when you want to
|
||||
.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, \fBlinter\fP, or \fBformatter\fP
|
||||
command to an already defined syntax -- useful when you want to
|
||||
slightly improve a syntax defined in one of the system-installed
|
||||
files (which are normally not writable)
|
||||
files (which normally are not writable).
|
||||
|
||||
.SH REBINDING KEYS
|
||||
Key bindings can be changed via the following two commands:
|
||||
.TP
|
||||
@@ -664,7 +680,7 @@ Toggles the presence of the two-line list of key bindings at the bottom of the s
|
||||
Toggles the constant display of the current line, column, and character positions.
|
||||
.TP
|
||||
.B morespace
|
||||
Toggles the presence of the blank line which 'separates' the titlebar from the file text.
|
||||
Toggles the presence of the blank line that 'separates' the title bar from the file text.
|
||||
.TP
|
||||
.B smoothscroll
|
||||
Toggles smooth scrolling (when moving around with the arrow keys).
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH RNANO 1 "version 2.8.1" "April 2017"
|
||||
.TH RNANO 1 "version 2.8.6" "July 2017"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
|
||||
.SH NAME
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
## versions of nano installed (e.g. your home directory is on NFS).
|
||||
# set quiet
|
||||
|
||||
## When soft line wrapping is enabled, make it wrap lines at blanks
|
||||
## (tabs and spaces) instead of always at the edge of the screen.
|
||||
# set atblanks
|
||||
|
||||
## Use auto-indentation.
|
||||
# set autoindent
|
||||
|
||||
@@ -44,13 +48,14 @@
|
||||
## Do case-sensitive searches by default.
|
||||
# set casesensitive
|
||||
|
||||
## Constantly display the cursor position in the statusbar. Note that
|
||||
## Constantly display the cursor position in the status bar. Note that
|
||||
## this overrides "quickblank".
|
||||
# set constantshow
|
||||
## (The old form, 'const', is deprecated.)
|
||||
|
||||
## Use cut-to-end-of-line by default.
|
||||
# set cut
|
||||
## Use cut-from-cursor-to-end-of-line by default.
|
||||
# set cutfromcursor
|
||||
## (The old form, 'cut', is deprecated.)
|
||||
|
||||
## Set the line length for wrapping text and justifying paragraphs.
|
||||
## If the value is 0 or less, the wrapping point will be the screen
|
||||
@@ -76,7 +81,7 @@
|
||||
## come before the latter set, and both must be in the same order.
|
||||
# set matchbrackets "(<[{)>]}"
|
||||
|
||||
## Use the blank line below the titlebar as extra editing space.
|
||||
## Use the blank line below the title bar as extra editing space.
|
||||
# set morespace
|
||||
|
||||
## Enable mouse support, if available for your system. When enabled,
|
||||
@@ -124,8 +129,8 @@
|
||||
## sentences.
|
||||
# set punct "!.?"
|
||||
|
||||
## Do quick statusbar blanking. Statusbar messages will disappear after
|
||||
## 1 keystroke instead of 26. Note that "const" overrides this.
|
||||
## Do quick status-bar blanking. Status-bar messages will disappear after
|
||||
## 1 keystroke instead of 26. Note that "constantshow" overrides this.
|
||||
# set quickblank
|
||||
|
||||
## The email-quote string, used to justify email-quoted paragraphs.
|
||||
|
||||
1122
po/nano.pot
1122
po/nano.pot
File diff suppressed because it is too large
Load Diff
1075
po/pt_BR.po
1075
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
1053
po/zh_CN.po
1053
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
1049
po/zh_TW.po
1049
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@ AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -DSYSCONFDIR=\"$(sysconfdir)\" \
|
||||
CLEANFILES = revision.h
|
||||
|
||||
if BUILDING_FROM_GIT
|
||||
SOMETHING = "REVISION \"$(shell git describe --tags 2>/dev/null)\""
|
||||
SOMETHING = "REVISION \"`git describe --tags 2>/dev/null`\""
|
||||
else
|
||||
SOMETHING = "NOTHING \"from tarball\""
|
||||
endif
|
||||
@@ -12,12 +12,13 @@ endif
|
||||
nano.o: revision.h
|
||||
winio.o: revision.h
|
||||
|
||||
revision.h: update_revision
|
||||
# Always run the commands in this rule. But update the target
|
||||
# only when the revision actually changed.
|
||||
revision.h: FORCE
|
||||
@[ -f $@ ] || touch $@
|
||||
@echo "#define $(SOMETHING)" | cmp -s $@ - || \
|
||||
echo "#define $(SOMETHING)" > $@
|
||||
|
||||
.PHONY: update_revision
|
||||
echo "#define $(SOMETHING)" > $@
|
||||
FORCE:
|
||||
|
||||
bin_PROGRAMS = nano
|
||||
nano_SOURCES = browser.c \
|
||||
@@ -36,9 +37,10 @@ nano_SOURCES = browser.c \
|
||||
search.c \
|
||||
text.c \
|
||||
utils.c \
|
||||
winio.c
|
||||
winio.c
|
||||
|
||||
nano_LDADD = @LIBINTL@ $(top_builddir)/lib/libgnu.a
|
||||
nano_LDADD = @LIBINTL@ $(top_builddir)/lib/libgnu.a \
|
||||
$(LIB_CLOCK_GETTIME) $(LIBTHREAD)
|
||||
|
||||
install-exec-hook:
|
||||
cd $(DESTDIR)$(bindir) && rm -f rnano && $(LN_S) nano rnano
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
#ifdef ENABLE_BROWSER
|
||||
|
||||
static char **filelist = NULL;
|
||||
/* The list of files to display in the file browser. */
|
||||
@@ -122,7 +122,7 @@ char *do_browser(char *path)
|
||||
|
||||
kbinput = get_kbinput(edit);
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef ENABLE_MOUSE
|
||||
if (kbinput == KEY_MOUSE) {
|
||||
int mouse_x, mouse_y;
|
||||
|
||||
@@ -151,7 +151,7 @@ char *do_browser(char *path)
|
||||
|
||||
continue;
|
||||
}
|
||||
#endif /* !DISABLE_MOUSE */
|
||||
#endif /* ENABLE_MOUSE */
|
||||
|
||||
func = parse_browser_input(&kbinput);
|
||||
|
||||
@@ -162,7 +162,7 @@ char *do_browser(char *path)
|
||||
kbinput = KEY_WINCH;
|
||||
#endif
|
||||
} else if (func == do_help_void) {
|
||||
#ifndef DISABLE_HELP
|
||||
#ifdef ENABLE_HELP
|
||||
do_help_void();
|
||||
#ifndef NANO_TINY
|
||||
/* The window dimensions might have changed, so act as if. */
|
||||
@@ -183,14 +183,12 @@ char *do_browser(char *path)
|
||||
} else if (func == do_right) {
|
||||
if (selected < filelist_len - 1)
|
||||
selected++;
|
||||
#ifndef NANO_TINY
|
||||
} else if (func == do_prev_word_void) {
|
||||
selected -= (selected % width);
|
||||
} else if (func == do_next_word_void) {
|
||||
selected += width - 1 - (selected % width);
|
||||
if (selected >= filelist_len)
|
||||
selected = filelist_len - 1;
|
||||
#endif
|
||||
} else if (func == do_up_void) {
|
||||
if (selected >= width)
|
||||
selected -= width;
|
||||
@@ -490,7 +488,11 @@ functionptrtype parse_browser_input(int *kbinput)
|
||||
return do_enter;
|
||||
case 'W':
|
||||
case 'w':
|
||||
case '/':
|
||||
return do_search;
|
||||
case 'N':
|
||||
case 'n':
|
||||
return do_research;
|
||||
}
|
||||
}
|
||||
return func_from_key(kbinput);
|
||||
@@ -808,4 +810,4 @@ char *strip_last_component(const char *path)
|
||||
return copy;
|
||||
}
|
||||
|
||||
#endif /* !DISABLE_BROWSER */
|
||||
#endif /* ENABLE_BROWSER */
|
||||
|
||||
202
src/chars.c
202
src/chars.c
@@ -70,8 +70,6 @@ void mbtowc_reset(void)
|
||||
/* This function is equivalent to isalpha() for multibyte characters. */
|
||||
bool is_alpha_mbchar(const char *c)
|
||||
{
|
||||
assert(c != NULL);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
wchar_t wc;
|
||||
@@ -90,8 +88,6 @@ bool is_alpha_mbchar(const char *c)
|
||||
/* This function is equivalent to isalnum() for multibyte characters. */
|
||||
bool is_alnum_mbchar(const char *c)
|
||||
{
|
||||
assert(c != NULL);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
wchar_t wc;
|
||||
@@ -110,8 +106,6 @@ bool is_alnum_mbchar(const char *c)
|
||||
/* This function is equivalent to isblank() for multibyte characters. */
|
||||
bool is_blank_mbchar(const char *c)
|
||||
{
|
||||
assert(c != NULL);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
wchar_t wc;
|
||||
@@ -158,8 +152,6 @@ bool is_cntrl_mbchar(const char *c)
|
||||
/* This function is equivalent to ispunct() for multibyte characters. */
|
||||
bool is_punct_mbchar(const char *c)
|
||||
{
|
||||
assert(c != NULL);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
wchar_t wc;
|
||||
@@ -234,8 +226,6 @@ char control_mbrep(const char *c, bool isdata)
|
||||
* return the number of columns that the character occupies. */
|
||||
int length_of_char(const char *c, int *width)
|
||||
{
|
||||
assert(c != NULL);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
wchar_t wc;
|
||||
@@ -265,8 +255,6 @@ int length_of_char(const char *c, int *width)
|
||||
/* This function is equivalent to wcwidth() for multibyte characters. */
|
||||
int mbwidth(const char *c)
|
||||
{
|
||||
assert(c != NULL);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
wchar_t wc;
|
||||
@@ -321,14 +309,10 @@ char *make_mbchar(long chr, int *chr_mb_len)
|
||||
* col isn't NULL, add the character's width (in columns) to it. */
|
||||
int parse_mbchar(const char *buf, char *chr, size_t *col)
|
||||
{
|
||||
int length;
|
||||
|
||||
assert(buf != NULL);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
/* Get the number of bytes in the multibyte character. */
|
||||
length = mblen(buf, MAXCHARLEN);
|
||||
int length = mblen(buf, MAXCHARLEN);
|
||||
|
||||
/* When the multibyte sequence is invalid, only take the first byte. */
|
||||
if (length <= 0) {
|
||||
@@ -358,12 +342,11 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
|
||||
} else
|
||||
*col += mbwidth(buf);
|
||||
}
|
||||
|
||||
return length;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/* A byte character is one byte long. */
|
||||
length = 1;
|
||||
|
||||
/* When requested, store the byte character in chr. */
|
||||
if (chr != NULL)
|
||||
*chr = *buf;
|
||||
@@ -382,33 +365,48 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
|
||||
else
|
||||
(*col)++;
|
||||
}
|
||||
}
|
||||
|
||||
return length;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return the index in buf of the beginning of the multibyte character
|
||||
* before the one at pos. */
|
||||
size_t move_mbleft(const char *buf, size_t pos)
|
||||
{
|
||||
size_t before, char_len = 0;
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
size_t before, char_len = 0;
|
||||
|
||||
assert(buf != NULL && pos <= strlen(buf));
|
||||
if (pos < 4)
|
||||
before = 0;
|
||||
else {
|
||||
const char *ptr = buf + pos;
|
||||
|
||||
/* There is no library function to move backward one multibyte
|
||||
* character. So we just start groping for one at the farthest
|
||||
* possible point. */
|
||||
if (pos < MAXCHARLEN)
|
||||
before = 0;
|
||||
else
|
||||
before = pos - MAXCHARLEN;
|
||||
/* Probe for a valid starter byte in the preceding four bytes. */
|
||||
if ((signed char)*(--ptr) > -65)
|
||||
before = pos - 1;
|
||||
else if ((signed char)*(--ptr) > -65)
|
||||
before = pos - 2;
|
||||
else if ((signed char)*(--ptr) > -65)
|
||||
before = pos - 3;
|
||||
else if ((signed char)*(--ptr) > -65)
|
||||
before = pos - 4;
|
||||
else
|
||||
before = pos - 1;
|
||||
}
|
||||
|
||||
while (before < pos) {
|
||||
char_len = parse_mbchar(buf + before, NULL, NULL);
|
||||
before += char_len;
|
||||
}
|
||||
/* Move forward again until we reach the original character,
|
||||
* so we know the length of its preceding the character. */
|
||||
while (before < pos) {
|
||||
char_len = parse_mbchar(buf + before, NULL, NULL);
|
||||
before += char_len;
|
||||
}
|
||||
|
||||
return before - char_len;
|
||||
return before - char_len;
|
||||
} else
|
||||
#endif
|
||||
return (pos == 0 ? 0 : pos - 1);
|
||||
}
|
||||
|
||||
/* Return the index in buf of the beginning of the multibyte character
|
||||
@@ -473,12 +471,7 @@ char *mbstrcasestr(const char *haystack, const char *needle)
|
||||
{
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
size_t needle_len;
|
||||
|
||||
if (*needle == '\0')
|
||||
return (char *)haystack;
|
||||
|
||||
needle_len = mbstrlen(needle);
|
||||
size_t needle_len = mbstrlen(needle);
|
||||
|
||||
while (*haystack != '\0') {
|
||||
if (mbstrncasecmp(haystack, needle, needle_len) == 0)
|
||||
@@ -494,19 +487,13 @@ char *mbstrcasestr(const char *haystack, const char *needle)
|
||||
}
|
||||
|
||||
/* This function is equivalent to strstr(), except in that it scans the
|
||||
* string in reverse, starting at rev_start. */
|
||||
* string in reverse, starting at pointer. */
|
||||
char *revstrstr(const char *haystack, const char *needle,
|
||||
const char *pointer)
|
||||
{
|
||||
size_t needle_len = strlen(needle);
|
||||
size_t tail_len = strlen(pointer);
|
||||
|
||||
if (needle_len == 0)
|
||||
return (char *)pointer;
|
||||
|
||||
if (strlen(haystack) < needle_len)
|
||||
return NULL;
|
||||
|
||||
if (tail_len < needle_len)
|
||||
pointer += tail_len - needle_len;
|
||||
|
||||
@@ -520,65 +507,53 @@ char *revstrstr(const char *haystack, const char *needle,
|
||||
}
|
||||
|
||||
/* This function is equivalent to strcasestr(), except in that it scans
|
||||
* the string in reverse, starting at rev_start. */
|
||||
char *revstrcasestr(const char *haystack, const char *needle, const char
|
||||
*rev_start)
|
||||
* the string in reverse, starting at pointer. */
|
||||
char *revstrcasestr(const char *haystack, const char *needle,
|
||||
const char *pointer)
|
||||
{
|
||||
size_t rev_start_len, needle_len;
|
||||
size_t needle_len = strlen(needle);
|
||||
size_t tail_len = strlen(pointer);
|
||||
|
||||
if (*needle == '\0')
|
||||
return (char *)rev_start;
|
||||
if (tail_len < needle_len)
|
||||
pointer += tail_len - needle_len;
|
||||
|
||||
needle_len = strlen(needle);
|
||||
|
||||
if (strlen(haystack) < needle_len)
|
||||
return NULL;
|
||||
|
||||
rev_start_len = strlen(rev_start);
|
||||
|
||||
for (; rev_start >= haystack; rev_start--, rev_start_len++) {
|
||||
if (rev_start_len >= needle_len && strncasecmp(rev_start,
|
||||
needle, needle_len) == 0)
|
||||
return (char *)rev_start;
|
||||
while (pointer >= haystack) {
|
||||
if (strncasecmp(pointer, needle, needle_len) == 0)
|
||||
return (char *)pointer;
|
||||
pointer--;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This function is equivalent to strcasestr() for multibyte strings,
|
||||
* except in that it scans the string in reverse, starting at rev_start. */
|
||||
char *mbrevstrcasestr(const char *haystack, const char *needle, const
|
||||
char *rev_start)
|
||||
* except in that it scans the string in reverse, starting at pointer. */
|
||||
char *mbrevstrcasestr(const char *haystack, const char *needle,
|
||||
const char *pointer)
|
||||
{
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
size_t rev_start_len, needle_len;
|
||||
size_t needle_len = mbstrlen(needle);
|
||||
size_t tail_len = mbstrlen(pointer);
|
||||
|
||||
if (*needle == '\0')
|
||||
return (char *)rev_start;
|
||||
if (tail_len < needle_len)
|
||||
pointer += tail_len - needle_len;
|
||||
|
||||
needle_len = mbstrlen(needle);
|
||||
|
||||
if (mbstrlen(haystack) < needle_len)
|
||||
if (pointer < haystack)
|
||||
return NULL;
|
||||
|
||||
rev_start_len = mbstrlen(rev_start);
|
||||
|
||||
while (TRUE) {
|
||||
if (rev_start_len >= needle_len &&
|
||||
mbstrncasecmp(rev_start, needle, needle_len) == 0)
|
||||
return (char *)rev_start;
|
||||
if (mbstrncasecmp(pointer, needle, needle_len) == 0)
|
||||
return (char *)pointer;
|
||||
|
||||
/* If we've reached the head of the haystack, we found nothing. */
|
||||
if (rev_start == haystack)
|
||||
if (pointer == haystack)
|
||||
return NULL;
|
||||
|
||||
rev_start = haystack + move_mbleft(haystack, rev_start - haystack);
|
||||
rev_start_len++;
|
||||
pointer = haystack + move_mbleft(haystack, pointer - haystack);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
return revstrcasestr(haystack, needle, rev_start);
|
||||
return revstrcasestr(haystack, needle, pointer);
|
||||
}
|
||||
|
||||
/* This function is equivalent to strlen() for multibyte strings. */
|
||||
@@ -608,8 +583,6 @@ size_t mbstrnlen(const char *s, size_t maxlen)
|
||||
/* This function is equivalent to strchr() for multibyte strings. */
|
||||
char *mbstrchr(const char *s, const char *c)
|
||||
{
|
||||
assert(s != NULL && c != NULL);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
bool bad_s_mb = FALSE, bad_c_mb = FALSE;
|
||||
@@ -666,59 +639,54 @@ char *mbstrpbrk(const char *s, const char *accept)
|
||||
return (char *) strpbrk(s, accept);
|
||||
}
|
||||
|
||||
/* This function is equivalent to strpbrk(), except in that it scans the
|
||||
* string in reverse, starting at rev_start. */
|
||||
char *revstrpbrk(const char *s, const char *accept, const char
|
||||
*rev_start)
|
||||
/* Locate, in the string that starts at head, the first occurrence of any of
|
||||
* the characters in the string accept, starting from pointer and searching
|
||||
* backwards. */
|
||||
char *revstrpbrk(const char *head, const char *accept, const char *pointer)
|
||||
{
|
||||
assert(s != NULL && accept != NULL && rev_start != NULL);
|
||||
|
||||
if (*rev_start == '\0') {
|
||||
if (rev_start == s)
|
||||
if (*pointer == '\0') {
|
||||
if (pointer == head)
|
||||
return NULL;
|
||||
rev_start--;
|
||||
pointer--;
|
||||
}
|
||||
|
||||
for (; rev_start >= s; rev_start--) {
|
||||
if (strchr(accept, *rev_start) != NULL)
|
||||
return (char *)rev_start;
|
||||
while (pointer >= head) {
|
||||
if (strchr(accept, *pointer) != NULL)
|
||||
return (char *)pointer;
|
||||
pointer--;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This function is equivalent to strpbrk() for multibyte strings,
|
||||
* except in that it scans the string in reverse, starting at rev_start. */
|
||||
char *mbrevstrpbrk(const char *s, const char *accept, const char
|
||||
*rev_start)
|
||||
/* The same as the preceding function but then for multibyte strings. */
|
||||
char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer)
|
||||
{
|
||||
assert(s != NULL && accept != NULL && rev_start != NULL);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
if (*rev_start == '\0') {
|
||||
if (rev_start == s)
|
||||
if (*pointer == '\0') {
|
||||
if (pointer == head)
|
||||
return NULL;
|
||||
rev_start = s + move_mbleft(s, rev_start - s);
|
||||
pointer = head + move_mbleft(head, pointer - head);
|
||||
}
|
||||
|
||||
while (TRUE) {
|
||||
if (mbstrchr(accept, rev_start) != NULL)
|
||||
return (char *)rev_start;
|
||||
if (mbstrchr(accept, pointer) != NULL)
|
||||
return (char *)pointer;
|
||||
|
||||
/* If we've reached the head of the string, we found nothing. */
|
||||
if (rev_start == s)
|
||||
if (pointer == head)
|
||||
return NULL;
|
||||
|
||||
rev_start = s + move_mbleft(s, rev_start - s);
|
||||
pointer = head + move_mbleft(head, pointer - head);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
return revstrpbrk(s, accept, rev_start);
|
||||
return revstrpbrk(head, accept, pointer);
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
#if !defined(DISABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
|
||||
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
|
||||
/* Return TRUE if the string s contains one or more blank characters,
|
||||
* and FALSE otherwise. */
|
||||
bool has_blank_chars(const char *s)
|
||||
@@ -751,7 +719,7 @@ bool has_blank_mbchars(const char *s)
|
||||
#endif
|
||||
return has_blank_chars(s);
|
||||
}
|
||||
#endif /* !DISABLE_NANORC && (!NANO_TINY || !DISABLE_JUSTIFY) */
|
||||
#endif /* ENABLE_NANORC && (!NANO_TINY || !DISABLE_JUSTIFY) */
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
/* Return TRUE if wc is valid Unicode, and FALSE otherwise. */
|
||||
@@ -764,7 +732,7 @@ bool is_valid_unicode(wchar_t wc)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_NANORC
|
||||
#ifdef ENABLE_NANORC
|
||||
/* Check if the string s is a valid multibyte string. Return TRUE if it
|
||||
* is, and FALSE otherwise. */
|
||||
bool is_valid_mbstring(const char *s)
|
||||
@@ -776,4 +744,4 @@ bool is_valid_mbstring(const char *s)
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* !DISABLE_NANORC */
|
||||
#endif /* ENABLE_NANORC */
|
||||
|
||||
11
src/color.c
11
src/color.c
@@ -24,7 +24,6 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_MAGIC_H
|
||||
@@ -54,8 +53,9 @@ void set_colorpairs(void)
|
||||
for (i = 0; i < NUMBER_OF_ELEMENTS; i++) {
|
||||
bool bright = FALSE;
|
||||
|
||||
if (parse_color_names(specified_color_combo[i],
|
||||
&foreground, &background, &bright)) {
|
||||
if (specified_color_combo[i] != NULL &&
|
||||
parse_color_names(specified_color_combo[i],
|
||||
&foreground, &background, &bright)) {
|
||||
if (foreground == -1 && !using_defaults)
|
||||
foreground = COLOR_WHITE;
|
||||
if (background == -1 && !using_defaults)
|
||||
@@ -63,8 +63,7 @@ void set_colorpairs(void)
|
||||
init_pair(i + 1, foreground, background);
|
||||
interface_color_pair[i] =
|
||||
COLOR_PAIR(i + 1) | (bright ? A_BOLD : A_NORMAL);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (i != FUNCTION_TAG)
|
||||
interface_color_pair[i] = hilite_attribute;
|
||||
else
|
||||
@@ -132,6 +131,8 @@ void color_init(void)
|
||||
fprintf(stderr, "init_pair(): fg = %hd, bg = %hd\n", foreground, background);
|
||||
#endif
|
||||
}
|
||||
|
||||
have_palette = TRUE;
|
||||
}
|
||||
|
||||
/* Try to match the given shibboleth string with one of the regexes in
|
||||
|
||||
26
src/cut.c
26
src/cut.c
@@ -108,8 +108,8 @@ void cut_to_eof(void)
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Move text from the current filestruct into the cutbuffer. If
|
||||
* copy_text is TRUE, copy the text back into the filestruct afterward.
|
||||
/* Move text from the current buffer into the cutbuffer. If
|
||||
* copy_text is TRUE, copy the text back into the buffer afterward.
|
||||
* If cut_till_eof is TRUE, move all text from the current cursor
|
||||
* position to the end of the file into the cutbuffer. */
|
||||
void do_cut_text(bool copy_text, bool cut_till_eof)
|
||||
@@ -155,7 +155,7 @@ void do_cut_text(bool copy_text, bool cut_till_eof)
|
||||
/* Move the marked text to the cutbuffer, and turn the mark off. */
|
||||
cut_marked(&right_side_up);
|
||||
openfile->mark_set = FALSE;
|
||||
} else if (ISSET(CUT_TO_END))
|
||||
} else if (ISSET(CUT_FROM_CURSOR))
|
||||
/* Move all text up to the end of the line into the cutbuffer. */
|
||||
cut_to_eol();
|
||||
else
|
||||
@@ -201,7 +201,7 @@ void do_cut_text(bool copy_text, bool cut_till_eof)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Move text from the current filestruct into the cutbuffer. */
|
||||
/* Move text from the current buffer into the cutbuffer. */
|
||||
void do_cut_text_void(void)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
@@ -214,8 +214,8 @@ void do_cut_text_void(void)
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Move text from the current filestruct into the cutbuffer, and copy it
|
||||
* back into the filestruct afterward. If the mark is set or the cursor
|
||||
/* Move text from the current buffer into the cutbuffer, and copy it
|
||||
* back into the buffer afterward. If the mark is set or the cursor
|
||||
* was moved, blow away previous contents of the cutbuffer. */
|
||||
void do_copy_text(void)
|
||||
{
|
||||
@@ -248,13 +248,13 @@ void do_copy_text(void)
|
||||
/* Cut from the current cursor position to the end of the file. */
|
||||
void do_cut_till_eof(void)
|
||||
{
|
||||
add_undo(CUT_EOF);
|
||||
add_undo(CUT_TO_EOF);
|
||||
do_cut_text(FALSE, TRUE);
|
||||
update_undo(CUT_EOF);
|
||||
update_undo(CUT_TO_EOF);
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Copy text from the cutbuffer into the current filestruct. */
|
||||
/* Copy text from the cutbuffer into the current buffer. */
|
||||
void do_uncut_text(void)
|
||||
{
|
||||
ssize_t was_lineno = openfile->current->lineno;
|
||||
@@ -270,10 +270,10 @@ void do_uncut_text(void)
|
||||
add_undo(PASTE);
|
||||
|
||||
if (ISSET(SOFTWRAP))
|
||||
was_leftedge = (xplustabs() / editwincols) * editwincols;
|
||||
was_leftedge = leftedge_for(xplustabs(), openfile->current);
|
||||
#endif
|
||||
|
||||
/* Add a copy of the text in the cutbuffer to the current filestruct
|
||||
/* Add a copy of the text in the cutbuffer to the current buffer
|
||||
* at the current cursor position. */
|
||||
copy_from_buffer(cutbuffer);
|
||||
|
||||
@@ -291,8 +291,8 @@ void do_uncut_text(void)
|
||||
/* Mark the file as modified. */
|
||||
set_modified();
|
||||
|
||||
/* Update the cursor position to account for the inserted lines. */
|
||||
reset_cursor();
|
||||
/* Update current_y to account for the inserted lines. */
|
||||
place_the_cursor(TRUE);
|
||||
|
||||
refresh_needed = TRUE;
|
||||
|
||||
|
||||
196
src/files.c
196
src/files.c
@@ -21,10 +21,10 @@
|
||||
|
||||
#include "proto.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <utime.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
@@ -62,32 +62,29 @@ bool has_valid_path(const char *filename)
|
||||
return validity;
|
||||
}
|
||||
|
||||
/* Add an entry to the circular list of openfile structs. */
|
||||
/* Add an item to the circular list of openfile structs. */
|
||||
void make_new_buffer(void)
|
||||
{
|
||||
openfilestruct *newnode = make_new_opennode();
|
||||
|
||||
if (openfile == NULL) {
|
||||
openfile = make_new_opennode();
|
||||
|
||||
/* Make the first open file the only element in the list. */
|
||||
openfile->prev = openfile;
|
||||
openfile->next = openfile;
|
||||
newnode->prev = newnode;
|
||||
newnode->next = newnode;
|
||||
} else {
|
||||
openfilestruct *newnode = make_new_opennode();
|
||||
|
||||
/* Add the new open file after the current one in the list. */
|
||||
newnode->prev = openfile;
|
||||
newnode->next = openfile->next;
|
||||
openfile->next->prev = newnode;
|
||||
openfile->next = newnode;
|
||||
|
||||
/* Make the new file the current one. */
|
||||
openfile = newnode;
|
||||
|
||||
/* There is more than one file open: show Close in help lines. */
|
||||
/* There is more than one file open: show "Close" in help lines. */
|
||||
exitfunc->desc = close_tag;
|
||||
}
|
||||
|
||||
/* Start initializing the new buffer. */
|
||||
/* Make the new buffer the current one, and start initializing it. */
|
||||
openfile = newnode;
|
||||
|
||||
openfile->filename = mallocstrcpy(NULL, "");
|
||||
|
||||
initialize_buffer_text();
|
||||
@@ -117,11 +114,9 @@ void make_new_buffer(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Initialize the text of the current openfile struct. */
|
||||
/* Initialize the text and pointers of the current openfile struct. */
|
||||
void initialize_buffer_text(void)
|
||||
{
|
||||
assert(openfile != NULL);
|
||||
|
||||
openfile->fileage = make_new_node(NULL);
|
||||
openfile->fileage->data = mallocstrcpy(NULL, "");
|
||||
|
||||
@@ -435,8 +430,6 @@ bool open_buffer(const char *filename, bool undoable)
|
||||
/* rc == -2 means that we have a new file. -1 means that the
|
||||
* open() failed. 0 means that the open() succeeded. */
|
||||
|
||||
assert(filename != NULL);
|
||||
|
||||
/* Display newlines in filenames as ^J. */
|
||||
as_an_at = FALSE;
|
||||
|
||||
@@ -470,12 +463,12 @@ bool open_buffer(const char *filename, bool undoable)
|
||||
if (new_buffer) {
|
||||
make_new_buffer();
|
||||
|
||||
if (has_valid_path(realname)) {
|
||||
if (!inhelp && has_valid_path(realname)) {
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(LOCKING) && filename[0] != '\0') {
|
||||
/* When not overriding an existing lock, discard the buffer. */
|
||||
if (do_lockfile(realname) < 0) {
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
close_buffer();
|
||||
#endif
|
||||
free(realname);
|
||||
@@ -489,7 +482,7 @@ bool open_buffer(const char *filename, bool undoable)
|
||||
/* If the filename isn't blank, and we are not in NOREAD_MODE,
|
||||
* open the file. Otherwise, treat it as a new file. */
|
||||
rc = (filename[0] != '\0' && !ISSET(NOREAD_MODE)) ?
|
||||
open_file(realname, new_buffer, FALSE, &f) : -2;
|
||||
open_file(realname, new_buffer, inhelp, &f) : -2;
|
||||
|
||||
/* If we have a file, and we're loading into a new buffer, update
|
||||
* the filename. */
|
||||
@@ -532,8 +525,6 @@ void replace_buffer(const char *filename)
|
||||
FILE *f;
|
||||
int descriptor;
|
||||
|
||||
assert(filename != NULL && filename[0] != '\0');
|
||||
|
||||
/* Open the file quietly. */
|
||||
descriptor = open_file(filename, FALSE, TRUE, &f);
|
||||
|
||||
@@ -583,39 +574,35 @@ void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
|
||||
if (!old_no_newlines)
|
||||
UNSET(NO_NEWLINES);
|
||||
}
|
||||
#endif /* !ENABLE_TINY */
|
||||
#endif /* !NANO_TINY */
|
||||
#endif /* !DISABLE_SPELLER */
|
||||
|
||||
/* Update the screen to account for the current buffer. */
|
||||
void display_buffer(void)
|
||||
/* Update the titlebar and the multiline cache to match the current buffer. */
|
||||
void prepare_for_display(void)
|
||||
{
|
||||
/* Update the titlebar, since the filename may have changed. */
|
||||
titlebar(NULL);
|
||||
if (!inhelp)
|
||||
titlebar(NULL);
|
||||
|
||||
#ifndef DISABLE_COLOR
|
||||
/* Make sure we're using the buffer's associated colors. */
|
||||
color_init();
|
||||
|
||||
/* If there are multiline coloring regexes, and there is no
|
||||
* multiline cache data yet, precalculate it now. */
|
||||
if (openfile->syntax && openfile->syntax->nmultis > 0 &&
|
||||
openfile->fileage->multidata == NULL)
|
||||
precalc_multicolorinfo();
|
||||
#endif
|
||||
|
||||
/* Update the content of the edit window straightaway. */
|
||||
edit_refresh();
|
||||
have_palette = FALSE;
|
||||
#endif
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* Switch to a neighbouring file buffer; to the next if to_next is TRUE;
|
||||
* otherwise, to the previous one. */
|
||||
void switch_to_prevnext_buffer(bool to_next)
|
||||
{
|
||||
assert(openfile != NULL);
|
||||
|
||||
/* If only one file buffer is open, say so and get out. */
|
||||
if (openfile == openfile->next) {
|
||||
if (openfile == openfile->next && !inhelp) {
|
||||
statusbar(_("No more open file buffers"));
|
||||
return;
|
||||
}
|
||||
@@ -635,13 +622,19 @@ void switch_to_prevnext_buffer(bool to_next)
|
||||
openfile->firstcolumn = 0;
|
||||
#endif
|
||||
|
||||
/* Update the screen to account for the current buffer. */
|
||||
display_buffer();
|
||||
/* Update titlebar and multiline info to match the current buffer. */
|
||||
prepare_for_display();
|
||||
|
||||
if (inhelp)
|
||||
return;
|
||||
|
||||
/* Ensure that the main loop will redraw the help lines. */
|
||||
currmenu = MMOST;
|
||||
|
||||
/* Indicate the switch on the statusbar. */
|
||||
statusline(HUSH, _("Switched to %s"),
|
||||
((openfile->filename[0] == '\0') ?
|
||||
_("New Buffer") : openfile->filename));
|
||||
((openfile->filename[0] == '\0') ?
|
||||
_("New Buffer") : openfile->filename));
|
||||
|
||||
#ifdef DEBUG
|
||||
dump_filestruct(openfile->current);
|
||||
@@ -665,8 +658,6 @@ void switch_to_next_buffer_void(void)
|
||||
* open buffers. */
|
||||
bool close_buffer(void)
|
||||
{
|
||||
assert(openfile != NULL);
|
||||
|
||||
/* If only one file buffer is open, get out. */
|
||||
if (openfile == openfile->next)
|
||||
return FALSE;
|
||||
@@ -683,13 +674,13 @@ bool close_buffer(void)
|
||||
/* Close the file buffer we had open before. */
|
||||
unlink_opennode(openfile->prev);
|
||||
|
||||
/* If only one buffer is open now, show Exit in the help lines. */
|
||||
/* If now just one buffer remains open, show "Exit" in the help lines. */
|
||||
if (openfile == openfile->next)
|
||||
exitfunc->desc = exit_tag;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* !DISABLE_MULTIBUFFER */
|
||||
#endif /* ENABLE_MULTIBUFFER */
|
||||
|
||||
/* Do a quick permissions check by verifying whether the file is appendable.
|
||||
* Err on the side of permissiveness (reporting TRUE when it might be wrong)
|
||||
@@ -706,8 +697,6 @@ int is_file_writable(const char *filename)
|
||||
if (ISSET(VIEW_MODE))
|
||||
return TRUE;
|
||||
|
||||
assert(filename != NULL);
|
||||
|
||||
/* Get the specified file's full path. */
|
||||
full_filename = get_full_path(filename);
|
||||
|
||||
@@ -783,7 +772,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
|
||||
add_undo(INSERT);
|
||||
|
||||
if (ISSET(SOFTWRAP))
|
||||
was_leftedge = (xplustabs() / editwincols) * editwincols;
|
||||
was_leftedge = leftedge_for(xplustabs(), openfile->current);
|
||||
#endif
|
||||
|
||||
/* Create an empty buffer. */
|
||||
@@ -908,6 +897,10 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
|
||||
/* Set the desired x position at the end of what was inserted. */
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
/* If we've read a help file, don't give any feedback. */
|
||||
if (inhelp)
|
||||
return;
|
||||
|
||||
if (!writable)
|
||||
statusline(ALERT, _("File '%s' is unwritable"), filename);
|
||||
#ifndef NANO_TINY
|
||||
@@ -933,7 +926,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
|
||||
(unsigned long)num_lines), (unsigned long)num_lines);
|
||||
|
||||
/* If we inserted less than a screenful, don't center the cursor. */
|
||||
if (less_than_a_screenful(was_lineno, was_leftedge))
|
||||
if (undoable && less_than_a_screenful(was_lineno, was_leftedge))
|
||||
focusing = FALSE;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -955,8 +948,6 @@ int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
|
||||
int fd;
|
||||
char *full_filename;
|
||||
|
||||
assert(filename != NULL && f != NULL);
|
||||
|
||||
/* Get the specified file's full path. */
|
||||
full_filename = get_full_path(filename);
|
||||
|
||||
@@ -1001,7 +992,7 @@ int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
|
||||
if (*f == NULL) {
|
||||
statusline(ALERT, _("Error reading %s: %s"), filename, strerror(errno));
|
||||
close(fd);
|
||||
} else
|
||||
} else if (!inhelp)
|
||||
statusbar(_("Reading File"));
|
||||
}
|
||||
|
||||
@@ -1020,8 +1011,6 @@ char *get_next_filename(const char *name, const char *suffix)
|
||||
char *buf;
|
||||
size_t wholenamelen;
|
||||
|
||||
assert(name != NULL && suffix != NULL);
|
||||
|
||||
wholenamelen = strlen(name) + strlen(suffix);
|
||||
|
||||
/* Reserve space for: the name plus the suffix plus a dot plus
|
||||
@@ -1066,7 +1055,7 @@ void do_insertfile(void)
|
||||
while (TRUE) {
|
||||
#ifndef NANO_TINY
|
||||
if (execute) {
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (ISSET(MULTIBUFFER))
|
||||
/* TRANSLATORS: The next four messages are prompts. */
|
||||
msg = _("Command to execute in new buffer");
|
||||
@@ -1076,7 +1065,7 @@ void do_insertfile(void)
|
||||
} else
|
||||
#endif /* NANO_TINY */
|
||||
{
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (ISSET(MULTIBUFFER))
|
||||
msg = _("File to insert into new buffer [from %s]");
|
||||
else
|
||||
@@ -1108,14 +1097,13 @@ void do_insertfile(void)
|
||||
} else {
|
||||
ssize_t was_current_lineno = openfile->current->lineno;
|
||||
size_t was_current_x = openfile->current_x;
|
||||
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_BROWSER) || defined(ENABLE_MULTIBUFFER)
|
||||
functionptrtype func = func_from_key(&i);
|
||||
#endif
|
||||
given = mallocstrcpy(given, answer);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
if (func == new_buffer_void) {
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (func == flip_newbuffer) {
|
||||
/* Don't allow toggling when in view mode. */
|
||||
if (!ISSET(VIEW_MODE))
|
||||
TOGGLE(MULTIBUFFER);
|
||||
@@ -1124,13 +1112,13 @@ void do_insertfile(void)
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (func == flip_execute_void) {
|
||||
#ifndef NANO_TINY
|
||||
if (func == flip_execute) {
|
||||
execute = !execute;
|
||||
continue;
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
#endif
|
||||
#ifdef ENABLE_BROWSER
|
||||
if (func == to_files_void) {
|
||||
char *chosen = do_browse_from(answer);
|
||||
|
||||
@@ -1149,7 +1137,7 @@ void do_insertfile(void)
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (execute) {
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* When in multibuffer mode, first open a blank buffer. */
|
||||
if (ISSET(MULTIBUFFER))
|
||||
open_buffer("", FALSE);
|
||||
@@ -1157,7 +1145,7 @@ void do_insertfile(void)
|
||||
/* Save the command's output in the current buffer. */
|
||||
execute_command(answer);
|
||||
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* If this is a new buffer, put the cursor at the top. */
|
||||
if (ISSET(MULTIBUFFER)) {
|
||||
openfile->current = openfile->fileage;
|
||||
@@ -1178,7 +1166,7 @@ void do_insertfile(void)
|
||||
open_buffer(answer, TRUE);
|
||||
}
|
||||
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (ISSET(MULTIBUFFER)) {
|
||||
#ifndef DISABLE_HISTORIES
|
||||
if (ISSET(POS_HISTORY)) {
|
||||
@@ -1191,17 +1179,17 @@ void do_insertfile(void)
|
||||
}
|
||||
#endif /* !DISABLE_HISTORIES */
|
||||
/* Update stuff to account for the current buffer. */
|
||||
display_buffer();
|
||||
prepare_for_display();
|
||||
} else
|
||||
#endif /* !DISABLE_MULTIBUFFER */
|
||||
#endif /* ENABLE_MULTIBUFFER */
|
||||
{
|
||||
/* Mark the file as modified if it changed. */
|
||||
if (openfile->current->lineno != was_current_lineno ||
|
||||
openfile->current_x != was_current_x)
|
||||
set_modified();
|
||||
|
||||
/* Update the cursor position to account for inserted lines. */
|
||||
reset_cursor();
|
||||
/* Update current_y to account for inserted lines. */
|
||||
place_the_cursor(TRUE);
|
||||
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
@@ -1218,7 +1206,7 @@ void do_insertfile_void(void)
|
||||
{
|
||||
if (ISSET(RESTRICTED))
|
||||
show_restricted_warning();
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
else if (ISSET(VIEW_MODE) && !ISSET(MULTIBUFFER))
|
||||
statusbar(_("Key invalid in non-multibuffer mode"));
|
||||
#endif
|
||||
@@ -1389,8 +1377,6 @@ char *safe_tempfile(FILE **f)
|
||||
int fd;
|
||||
mode_t original_umask = 0;
|
||||
|
||||
assert(f != NULL);
|
||||
|
||||
/* If $TMPDIR is set, set tempdir to it, run it through
|
||||
* get_full_path(), and save the result in full_tempdir. Otherwise,
|
||||
* leave full_tempdir set to NULL. */
|
||||
@@ -1431,8 +1417,6 @@ char *safe_tempfile(FILE **f)
|
||||
/* Initialize full_operating_dir based on operating_dir. */
|
||||
void init_operating_dir(void)
|
||||
{
|
||||
assert(full_operating_dir == NULL);
|
||||
|
||||
if (operating_dir == NULL)
|
||||
return;
|
||||
|
||||
@@ -1464,8 +1448,6 @@ bool check_operating_dir(const char *currpath, bool allow_tabcomp)
|
||||
if (operating_dir == NULL)
|
||||
return FALSE;
|
||||
|
||||
assert(full_operating_dir != NULL);
|
||||
|
||||
fullpath = get_full_path(currpath);
|
||||
|
||||
/* If fullpath is NULL, it means some directory in the path doesn't
|
||||
@@ -1990,6 +1972,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
||||
/* If we must set the filename, and it changed, adjust things. */
|
||||
if (!nonamechange && strcmp(openfile->filename, realname) != 0) {
|
||||
#ifndef DISABLE_COLOR
|
||||
char *newname;
|
||||
char *oldname = openfile->syntax ? openfile->syntax->name : "";
|
||||
filestruct *line = openfile->fileage;
|
||||
#endif
|
||||
@@ -2000,7 +1983,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
||||
color_update();
|
||||
color_init();
|
||||
|
||||
char *newname = openfile->syntax ? openfile->syntax->name : "";
|
||||
newname = openfile->syntax ? openfile->syntax->name : "";
|
||||
|
||||
/* If the syntax changed, discard and recompute the multidata. */
|
||||
if (strcmp(oldname, newname) != 0) {
|
||||
@@ -2049,7 +2032,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
|
||||
filestruct *top, *bot;
|
||||
size_t top_x, bot_x;
|
||||
|
||||
/* Partition the filestruct so that it contains only the marked text. */
|
||||
/* Partition the buffer so that it contains only the marked text. */
|
||||
mark_order((const filestruct **)&top, &top_x,
|
||||
(const filestruct **)&bot, &bot_x, NULL);
|
||||
filepart = partition_filestruct(top, top_x, bot, bot_x);
|
||||
@@ -2067,7 +2050,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
|
||||
if (added_magicline)
|
||||
remove_magicline();
|
||||
|
||||
/* Unpartition the filestruct so that it contains all the text again. */
|
||||
/* Unpartition the buffer so that it contains all the text again. */
|
||||
unpartition_filestruct(&filepart);
|
||||
|
||||
if (old_modified)
|
||||
@@ -2130,11 +2113,12 @@ int do_writeout(bool exiting)
|
||||
msg = (method == PREPEND) ? _("Prepend Selection to File") :
|
||||
(method == APPEND) ? _("Append Selection to File") :
|
||||
_("Write Selection to File");
|
||||
else if (method != OVERWRITE)
|
||||
msg = (method == PREPEND) ? _("File Name to Prepend to") :
|
||||
_("File Name to Append to");
|
||||
else
|
||||
#endif /* !NANO_TINY */
|
||||
msg = (method == PREPEND) ? _("File Name to Prepend to") :
|
||||
(method == APPEND) ? _("File Name to Append to") :
|
||||
_("File Name to Write");
|
||||
msg = _("File Name to Write");
|
||||
|
||||
present_path = mallocstrcpy(present_path, "./");
|
||||
|
||||
@@ -2159,24 +2143,15 @@ int do_writeout(bool exiting)
|
||||
} else {
|
||||
functionptrtype func = func_from_key(&i);
|
||||
|
||||
/* Upon request, abandon the buffer, if user is sure. */
|
||||
/* Upon request, abandon the buffer. */
|
||||
if (func == discard_buffer) {
|
||||
if (openfile->modified)
|
||||
i = do_yesno_prompt(FALSE,
|
||||
_("Save modified buffer anyway? "));
|
||||
else
|
||||
i = 0;
|
||||
|
||||
if (i == 0) {
|
||||
free(given);
|
||||
return 2; /* Yes, discard the buffer. */
|
||||
} else
|
||||
continue; /* Go back to the filename prompt. */
|
||||
free(given);
|
||||
return 2;
|
||||
}
|
||||
|
||||
given = mallocstrcpy(given, answer);
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
#ifdef ENABLE_BROWSER
|
||||
if (func == to_files_void) {
|
||||
char *chosen = do_browse_from(answer);
|
||||
|
||||
@@ -2187,7 +2162,7 @@ int do_writeout(bool exiting)
|
||||
free(answer);
|
||||
answer = chosen;
|
||||
} else
|
||||
#endif /* !DISABLE_BROWSER */
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
if (func == dos_format_void) {
|
||||
openfile->fmt = (openfile->fmt == DOS_FILE) ? NIX_FILE :
|
||||
@@ -2200,15 +2175,15 @@ int do_writeout(bool exiting)
|
||||
} else if (func == backup_file_void) {
|
||||
TOGGLE(BACKUP_FILE);
|
||||
continue;
|
||||
} else
|
||||
#endif /* !NANO_TINY */
|
||||
if (func == prepend_void) {
|
||||
} else if (func == prepend_void) {
|
||||
method = (method == PREPEND) ? OVERWRITE : PREPEND;
|
||||
continue;
|
||||
} else if (func == append_void) {
|
||||
method = (method == APPEND) ? OVERWRITE : APPEND;
|
||||
continue;
|
||||
} else if (func == do_help_void) {
|
||||
} else
|
||||
#endif /* !NANO_TINY */
|
||||
if (func == do_help_void) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2295,6 +2270,8 @@ int do_writeout(bool exiting)
|
||||
openfile->current_stat->st_dev != st.st_dev ||
|
||||
openfile->current_stat->st_ino != st.st_ino)) {
|
||||
|
||||
warn_and_shortly_pause(_("File on disk has changed"));
|
||||
|
||||
if (do_yesno_prompt(FALSE, _("File was modified since "
|
||||
"you opened it; continue saving? ")) < 1)
|
||||
continue;
|
||||
@@ -2388,7 +2365,7 @@ char *real_dir_from_tilde(const char *buf)
|
||||
return retval;
|
||||
}
|
||||
|
||||
#if !defined(DISABLE_TABCOMP) || !defined(DISABLE_BROWSER)
|
||||
#if defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
|
||||
/* Our sort routine for file listings. Sort alphabetically and
|
||||
* case-insensitively, and sort directories before filenames. */
|
||||
int diralphasort(const void *va, const void *vb)
|
||||
@@ -2425,7 +2402,7 @@ void free_chararray(char **array, size_t len)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_TABCOMP
|
||||
#ifdef ENABLE_TABCOMP
|
||||
/* Is the given path a directory? */
|
||||
bool is_dir(const char *buf)
|
||||
{
|
||||
@@ -2466,14 +2443,15 @@ char **username_tab_completion(const char *buf, size_t *num_matches,
|
||||
size_t buf_len)
|
||||
{
|
||||
char **matches = NULL;
|
||||
#ifdef HAVE_PWD_H
|
||||
const struct passwd *userdata;
|
||||
#endif
|
||||
|
||||
assert(buf != NULL && num_matches != NULL && buf_len > 0);
|
||||
|
||||
*num_matches = 0;
|
||||
|
||||
#ifdef HAVE_PWD_H
|
||||
const struct passwd *userdata;
|
||||
|
||||
while ((userdata = getpwent()) != NULL) {
|
||||
if (strncmp(userdata->pw_name, buf + 1, buf_len - 1) == 0) {
|
||||
/* Cool, found a match. Add it to the list. This makes a
|
||||
@@ -2749,7 +2727,7 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
|
||||
|
||||
return buf;
|
||||
}
|
||||
#endif /* !DISABLE_TABCOMP */
|
||||
#endif /* ENABLE_TABCOMP */
|
||||
|
||||
/* Return the filename part of the given path. */
|
||||
const char *tail(const char *path)
|
||||
@@ -3005,7 +2983,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 || fullpath[strlen(fullpath) - 1] == '/' || inhelp) {
|
||||
free(fullpath);
|
||||
return;
|
||||
}
|
||||
@@ -3077,7 +3055,7 @@ bool has_old_position(const char *file, ssize_t *line, ssize_t *column)
|
||||
free(fullpath);
|
||||
|
||||
if (posptr == NULL)
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
|
||||
*line = posptr->lineno;
|
||||
*column = posptr->xno;
|
||||
|
||||
266
src/global.c
266
src/global.c
@@ -52,12 +52,28 @@ int margin = 0;
|
||||
int editwincols = -1;
|
||||
/* The number of usable columns in the edit window: COLS - margin. */
|
||||
|
||||
#ifndef DISABLE_COLOR
|
||||
bool have_palette = FALSE;
|
||||
/* Whether the colors for the current syntax have been initialized. */
|
||||
#endif
|
||||
|
||||
bool suppress_cursorpos = FALSE;
|
||||
/* Should we skip constant position display for current keystroke? */
|
||||
|
||||
message_type lastmessage = HUSH;
|
||||
/* Messages of type HUSH should not overwrite type MILD nor ALERT. */
|
||||
|
||||
filestruct *pletion_line = NULL;
|
||||
/* The line where the last completion was found, if any. */
|
||||
|
||||
bool inhelp = FALSE;
|
||||
/* Whether we are in the help viewer. */
|
||||
char *title = NULL;
|
||||
/* When not NULL: the title of the current help text. */
|
||||
|
||||
int didfind = 0;
|
||||
/* Whether the last search found something. */
|
||||
|
||||
int controlleft, controlright, controlup, controldown, controlhome, controlend;
|
||||
#ifndef NANO_TINY
|
||||
int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown;
|
||||
@@ -82,14 +98,14 @@ char *present_path = NULL;
|
||||
|
||||
unsigned flags[4] = {0, 0, 0, 0};
|
||||
/* Our flag containing the states of all global options. */
|
||||
WINDOW *topwin;
|
||||
WINDOW *topwin = NULL;
|
||||
/* The top portion of the window, where we display the version
|
||||
* number of nano, the name of the current file, and whether the
|
||||
* current file has been modified. */
|
||||
WINDOW *edit;
|
||||
WINDOW *edit = NULL;
|
||||
/* The middle portion of the window, i.e. the edit window, where
|
||||
* we display the current file we're editing. */
|
||||
WINDOW *bottomwin;
|
||||
WINDOW *bottomwin = NULL;
|
||||
/* The bottom portion of the window, where we display statusbar
|
||||
* messages, the statusbar prompt, and a list of shortcuts. */
|
||||
int editwinrows = 0;
|
||||
@@ -133,9 +149,6 @@ char *quoteerr = NULL;
|
||||
char *word_chars = NULL;
|
||||
/* Nonalphanumeric characters that also form words. */
|
||||
|
||||
bool nodelay_mode = FALSE;
|
||||
/* Are we checking for a cancel wile doing something? */
|
||||
|
||||
char *answer = NULL;
|
||||
/* The answer string used by the statusbar prompt. */
|
||||
|
||||
@@ -214,10 +227,10 @@ regmatch_t regmatches[10];
|
||||
int hilite_attribute = A_REVERSE;
|
||||
/* The curses attribute we use to highlight something. */
|
||||
#ifndef DISABLE_COLOR
|
||||
char* specified_color_combo[] = {};
|
||||
char* specified_color_combo[] = {NULL};
|
||||
/* The color combinations as specified in the rcfile. */
|
||||
#endif
|
||||
int interface_color_pair[] = {};
|
||||
int interface_color_pair[] = {0};
|
||||
/* The processed color pairs for the interface elements. */
|
||||
|
||||
char *homedir = NULL;
|
||||
@@ -253,10 +266,13 @@ void regexp_void(void)
|
||||
void backwards_void(void)
|
||||
{
|
||||
}
|
||||
void flip_replace(void)
|
||||
{
|
||||
}
|
||||
void gototext_void(void)
|
||||
{
|
||||
}
|
||||
#ifndef DISABLE_BROWSER
|
||||
#ifdef ENABLE_BROWSER
|
||||
void to_files_void(void)
|
||||
{
|
||||
}
|
||||
@@ -264,6 +280,7 @@ void goto_dir_void(void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
void dos_format_void(void)
|
||||
{
|
||||
}
|
||||
@@ -279,18 +296,18 @@ void prepend_void(void)
|
||||
void backup_file_void(void)
|
||||
{
|
||||
}
|
||||
void flip_execute(void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
void flip_newbuffer(void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
void discard_buffer(void)
|
||||
{
|
||||
}
|
||||
void new_buffer_void(void)
|
||||
{
|
||||
}
|
||||
void flip_replace_void(void)
|
||||
{
|
||||
}
|
||||
void flip_execute_void(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* Add a function to the function list. */
|
||||
void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *help,
|
||||
@@ -309,7 +326,7 @@ void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *h
|
||||
f->menus = menus;
|
||||
f->desc = desc;
|
||||
f->viewok = viewok;
|
||||
#ifndef DISABLE_HELP
|
||||
#ifdef ENABLE_HELP
|
||||
f->help = help;
|
||||
f->blank_after = blank_after;
|
||||
#endif
|
||||
@@ -475,16 +492,13 @@ void shortcut_init(void)
|
||||
/* TRANSLATORS: Try to keep this string at most 12 characters. */
|
||||
const char *whereis_next_tag = N_("WhereIs Next");
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
#ifdef ENABLE_HELP
|
||||
/* TRANSLATORS: The next long series of strings are shortcut descriptions;
|
||||
* they are best kept shorter than 56 characters, but may be longer. */
|
||||
const char *nano_justify_msg = N_("Justify the current paragraph");
|
||||
#endif
|
||||
const char *nano_cancel_msg = N_("Cancel the current function");
|
||||
const char *nano_help_msg = N_("Display this help text");
|
||||
const char *nano_exit_msg =
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
N_("Close the current file buffer / Exit from nano")
|
||||
#else
|
||||
N_("Exit from nano")
|
||||
@@ -496,7 +510,7 @@ void shortcut_init(void)
|
||||
N_("Insert another file into the current one");
|
||||
const char *nano_whereis_msg =
|
||||
N_("Search for a string or a regular expression");
|
||||
#ifndef DISABLE_BROWSER
|
||||
#ifdef ENABLE_BROWSER
|
||||
const char *nano_browser_whereis_msg = N_("Search for a string");
|
||||
const char *nano_browser_refresh_msg = N_("Refresh the file list");
|
||||
#ifndef NANO_TINY
|
||||
@@ -553,7 +567,7 @@ void shortcut_init(void)
|
||||
const char *nano_scrolldown_msg =
|
||||
N_("Scroll down one line without scrolling the cursor");
|
||||
#endif
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
const char *nano_prevfile_msg = N_("Switch to the previous file buffer");
|
||||
const char *nano_nextfile_msg = N_("Switch to the next file buffer");
|
||||
#endif
|
||||
@@ -572,6 +586,7 @@ void shortcut_init(void)
|
||||
N_("Cut from the cursor position to the end of the file");
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
const char *nano_justify_msg = N_("Justify the current paragraph");
|
||||
const char *nano_fulljustify_msg = N_("Justify the entire file");
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
@@ -606,9 +621,6 @@ void shortcut_init(void)
|
||||
const char *nano_next_history_msg =
|
||||
N_("Recall the next search/replace string");
|
||||
#endif
|
||||
#ifndef DISABLE_BROWSER
|
||||
const char *nano_tofiles_msg = N_("Go to file browser");
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
const char *nano_dos_msg = N_("Toggle the use of DOS format");
|
||||
const char *nano_mac_msg = N_("Toggle the use of Mac format");
|
||||
@@ -617,11 +629,12 @@ void shortcut_init(void)
|
||||
const char *nano_backup_msg = N_("Toggle backing up of the original file");
|
||||
const char *nano_execute_msg = N_("Execute external command");
|
||||
#endif
|
||||
const char *nano_discard_buffer_msg = N_("Close buffer without saving it");
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
const char *nano_multibuffer_msg = N_("Toggle the use of a new buffer");
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
const char *nano_newbuffer_msg = N_("Toggle the use of a new buffer");
|
||||
#endif
|
||||
#ifndef DISABLE_BROWSER
|
||||
const char *nano_discard_buffer_msg = N_("Close buffer without saving it");
|
||||
#ifdef ENABLE_BROWSER
|
||||
const char *nano_tofiles_msg = N_("Go to file browser");
|
||||
const char *nano_exitbrowser_msg = N_("Exit from the file browser");
|
||||
const char *nano_firstfile_msg = N_("Go to the first file in the list");
|
||||
const char *nano_lastfile_msg = N_("Go to the last file in the list");
|
||||
@@ -637,9 +650,9 @@ void shortcut_init(void)
|
||||
const char *nano_formatter_msg = N_("Invoke formatter, if available");
|
||||
#endif
|
||||
#endif
|
||||
#endif /* !DISABLE_HELP */
|
||||
#endif /* ENABLE_HELP */
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
#ifdef ENABLE_HELP
|
||||
#define IFSCHELP(help) help
|
||||
#else
|
||||
#define IFSCHELP(help) ""
|
||||
@@ -659,7 +672,7 @@ void shortcut_init(void)
|
||||
/* Remember the entry for Exit, to be able to replace it with Close. */
|
||||
exitfunc = tailfunc;
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
#ifdef ENABLE_BROWSER
|
||||
add_to_funcs(do_exit, MBROWSER,
|
||||
exit_tag, IFSCHELP(nano_exitbrowser_msg), TOGETHER, VIEW);
|
||||
#endif
|
||||
@@ -678,7 +691,7 @@ void shortcut_init(void)
|
||||
read_file_tag, IFSCHELP(nano_insert_msg), BLANKAFTER,
|
||||
/* We allow inserting files in view mode if multibuffer mode
|
||||
* is switched on, so that we can view multiple files. */
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
VIEW);
|
||||
#else
|
||||
NOVIEW);
|
||||
@@ -696,7 +709,7 @@ void shortcut_init(void)
|
||||
add_to_funcs(do_replace, MMAIN,
|
||||
replace_tag, IFSCHELP(nano_replace_msg), TOGETHER, NOVIEW);
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
#ifdef ENABLE_BROWSER
|
||||
add_to_funcs(do_search, MBROWSER,
|
||||
whereis_tag, IFSCHELP(nano_browser_whereis_msg), TOGETHER, VIEW);
|
||||
|
||||
@@ -704,15 +717,14 @@ void shortcut_init(void)
|
||||
N_("Go To Dir"), IFSCHELP(nano_gotodir_msg), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
#ifdef ENABLE_HELP
|
||||
/* The description ("x") and blank_after (0) are irrelevant,
|
||||
* because the help viewer does not have a help text. */
|
||||
add_to_funcs(do_exit, MHELP, exit_tag, "x", 0, VIEW);
|
||||
|
||||
add_to_funcs(total_refresh, MHELP, refresh_tag, "x", 0, VIEW);
|
||||
add_to_funcs(do_exit, MHELP, close_tag, "x", 0, VIEW);
|
||||
|
||||
add_to_funcs(do_up_void, MHELP, prev_line_tag, "x", 0, VIEW);
|
||||
add_to_funcs(do_down_void, MHELP, next_line_tag, "x" , 0, VIEW);
|
||||
add_to_funcs(do_search, MHELP, whereis_tag, "x", 0, VIEW);
|
||||
add_to_funcs(do_research, MHELP, whereis_next_tag, "x", 0, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(do_cut_text_void, MMAIN,
|
||||
@@ -773,10 +785,10 @@ void shortcut_init(void)
|
||||
add_to_funcs(backwards_void, MWHEREIS|MREPLACE,
|
||||
N_("Backwards"), IFSCHELP(nano_reverse_msg), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(flip_replace_void, MWHEREIS,
|
||||
add_to_funcs(flip_replace, MWHEREIS,
|
||||
replace_tag, IFSCHELP(nano_replace_msg), BLANKAFTER, VIEW);
|
||||
|
||||
add_to_funcs(flip_replace_void, MREPLACE,
|
||||
add_to_funcs(flip_replace, MREPLACE,
|
||||
N_("No Replace"), IFSCHELP(nano_whereis_msg), BLANKAFTER, VIEW);
|
||||
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
@@ -804,7 +816,7 @@ void shortcut_init(void)
|
||||
N_("Back"), IFSCHELP(nano_back_msg), TOGETHER, VIEW);
|
||||
add_to_funcs(do_right, MMAIN,
|
||||
N_("Forward"), IFSCHELP(nano_forward_msg), TOGETHER, VIEW);
|
||||
#ifndef DISABLE_BROWSER
|
||||
#ifdef ENABLE_BROWSER
|
||||
add_to_funcs(do_left, MBROWSER,
|
||||
N_("Back"), IFSCHELP(nano_backfile_msg), TOGETHER, VIEW);
|
||||
add_to_funcs(do_right, MBROWSER,
|
||||
@@ -821,9 +833,9 @@ void shortcut_init(void)
|
||||
add_to_funcs(do_end_void, MMAIN,
|
||||
N_("End"), IFSCHELP(nano_end_msg), BLANKAFTER, VIEW);
|
||||
|
||||
add_to_funcs(do_up_void, MMAIN|MBROWSER,
|
||||
add_to_funcs(do_up_void, MMAIN|MHELP|MBROWSER,
|
||||
prev_line_tag, IFSCHELP(nano_prevline_msg), TOGETHER, VIEW);
|
||||
add_to_funcs(do_down_void, MMAIN|MBROWSER,
|
||||
add_to_funcs(do_down_void, MMAIN|MHELP|MBROWSER,
|
||||
next_line_tag, IFSCHELP(nano_nextline_msg), TOGETHER, VIEW);
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(do_scroll_up, MMAIN,
|
||||
@@ -853,7 +865,7 @@ void shortcut_init(void)
|
||||
add_to_funcs(do_last_line, MMAIN|MHELP|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE,
|
||||
N_("Last Line"), IFSCHELP(nano_lastline_msg), BLANKAFTER, VIEW);
|
||||
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
add_to_funcs(switch_to_prev_buffer_void, MMAIN,
|
||||
N_("Prev File"), IFSCHELP(nano_prevfile_msg), TOGETHER, VIEW);
|
||||
add_to_funcs(switch_to_next_buffer_void, MMAIN,
|
||||
@@ -918,7 +930,7 @@ void shortcut_init(void)
|
||||
N_("Suspend"), IFSCHELP(nano_suspend_msg), BLANKAFTER, VIEW);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(do_indent_void, MMAIN,
|
||||
add_to_funcs(do_indent, MMAIN,
|
||||
N_("Indent Text"), IFSCHELP(nano_indent_msg), TOGETHER, NOVIEW);
|
||||
add_to_funcs(do_unindent, MMAIN,
|
||||
N_("Unindent Text"), IFSCHELP(nano_unindent_msg), BLANKAFTER, NOVIEW);
|
||||
@@ -976,20 +988,20 @@ void shortcut_init(void)
|
||||
/* If we're using restricted mode, file insertion is disabled, and
|
||||
* thus command execution and the multibuffer toggle have no place. */
|
||||
if (!ISSET(RESTRICTED)) {
|
||||
add_to_funcs(flip_execute_void, MINSERTFILE,
|
||||
add_to_funcs(flip_execute, MINSERTFILE,
|
||||
N_("Execute Command"), IFSCHELP(nano_execute_msg), TOGETHER, NOVIEW);
|
||||
|
||||
add_to_funcs(flip_execute_void, MEXTCMD,
|
||||
add_to_funcs(flip_execute, MEXTCMD,
|
||||
read_file_tag, IFSCHELP(nano_insert_msg), TOGETHER, NOVIEW);
|
||||
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
add_to_funcs(new_buffer_void, MINSERTFILE|MEXTCMD,
|
||||
N_("New Buffer"), IFSCHELP(nano_multibuffer_msg), TOGETHER, NOVIEW);
|
||||
#endif
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (!ISSET(RESTRICTED))
|
||||
add_to_funcs(flip_newbuffer, MINSERTFILE|MEXTCMD,
|
||||
N_("New Buffer"), IFSCHELP(nano_newbuffer_msg), TOGETHER, NOVIEW);
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
#ifdef ENABLE_BROWSER
|
||||
if (!ISSET(RESTRICTED))
|
||||
add_to_funcs(to_files_void, MWRITEFILE|MINSERTFILE,
|
||||
N_("To Files"), IFSCHELP(nano_tofiles_msg), TOGETHER, VIEW);
|
||||
@@ -1008,7 +1020,7 @@ void shortcut_init(void)
|
||||
add_to_funcs(discard_buffer, MWRITEFILE,
|
||||
N_("Discard buffer"), IFSCHELP(nano_discard_buffer_msg), BLANKAFTER, NOVIEW);
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
#ifdef ENABLE_BROWSER
|
||||
add_to_funcs(do_research, MBROWSER,
|
||||
whereis_next_tag, IFSCHELP(nano_whereis_next_msg), TOGETHER, VIEW);
|
||||
add_to_funcs(total_refresh, MBROWSER,
|
||||
@@ -1035,8 +1047,8 @@ void shortcut_init(void)
|
||||
|
||||
/* Start associating key combos with functions in specific menus. */
|
||||
|
||||
add_to_sclist(MMOST, "^G", 0, do_help_void, 0);
|
||||
add_to_sclist(MMOST, "F1", 0, do_help_void, 0);
|
||||
add_to_sclist(MMOST & ~MFINDINHELP, "^G", 0, do_help_void, 0);
|
||||
add_to_sclist(MMOST & ~MFINDINHELP, "F1", 0, do_help_void, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "^X", 0, do_exit, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", 0, do_exit, 0);
|
||||
add_to_sclist(MMAIN, "^O", 0, do_writeout_void, 0);
|
||||
@@ -1044,8 +1056,8 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN, "^R", 0, do_insertfile_void, 0);
|
||||
add_to_sclist(MMAIN, "F5", 0, do_insertfile_void, 0);
|
||||
add_to_sclist(MMAIN, "Ins", 0, do_insertfile_void, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER, "^W", 0, do_search, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER, "F6", 0, do_search, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "^W", 0, do_search, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "F6", 0, do_search, 0);
|
||||
add_to_sclist(MMAIN, "^\\", 0, do_replace, 0);
|
||||
add_to_sclist(MMAIN, "M-R", 0, do_replace, 0);
|
||||
add_to_sclist(MMAIN, "F14", 0, do_replace, 0);
|
||||
@@ -1074,6 +1086,7 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^Y", 0, do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F7", 0, do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgUp", KEY_PPAGE, do_page_up, 0);
|
||||
add_to_sclist(MHELP|MBROWSER, "Bsp", KEY_BACKSPACE, do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^V", 0, do_page_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F8", 0, do_page_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgDn", KEY_NPAGE, do_page_down, 0);
|
||||
@@ -1083,8 +1096,8 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN|MHELP, "M-/", 0, do_last_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "^End", CONTROL_END, do_last_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-?", 0, do_last_line, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER, "M-W", 0, do_research, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER, "F16", 0, do_research, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "M-W", 0, do_research, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "F16", 0, do_research, 0);
|
||||
#ifndef NANO_TINY
|
||||
add_to_sclist(MMAIN, "M-]", 0, do_find_bracket, 0);
|
||||
add_to_sclist(MMAIN, "M-A", 0, do_mark, 0);
|
||||
@@ -1093,7 +1106,7 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN, "F15", 0, do_mark, 0);
|
||||
add_to_sclist(MMAIN, "M-6", 0, do_copy_text, 0);
|
||||
add_to_sclist(MMAIN, "M-^", 0, do_copy_text, 0);
|
||||
add_to_sclist(MMAIN, "M-}", 0, do_indent_void, 0);
|
||||
add_to_sclist(MMAIN, "M-}", 0, do_indent, 0);
|
||||
add_to_sclist(MMAIN, "M-{", 0, do_unindent, 0);
|
||||
add_to_sclist(MMAIN, "M-U", 0, do_undo, 0);
|
||||
add_to_sclist(MMAIN, "M-E", 0, do_redo, 0);
|
||||
@@ -1110,15 +1123,15 @@ void shortcut_init(void)
|
||||
if (using_utf8()) {
|
||||
add_to_sclist(MMOST, "\xE2\x86\x90", KEY_LEFT, do_left, 0);
|
||||
add_to_sclist(MMOST, "\xE2\x86\x92", KEY_RIGHT, do_right, 0);
|
||||
add_to_sclist(MMOST, "^\xE2\x86\x90", CONTROL_LEFT, do_prev_word_void, 0);
|
||||
add_to_sclist(MMOST, "^\xE2\x86\x92", CONTROL_RIGHT, do_next_word_void, 0);
|
||||
add_to_sclist(MSOME, "^\xE2\x86\x90", CONTROL_LEFT, do_prev_word_void, 0);
|
||||
add_to_sclist(MSOME, "^\xE2\x86\x92", CONTROL_RIGHT, do_next_word_void, 0);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
add_to_sclist(MMOST, "Left", KEY_LEFT, do_left, 0);
|
||||
add_to_sclist(MMOST, "Right", KEY_RIGHT, do_right, 0);
|
||||
add_to_sclist(MMOST, "^Left", CONTROL_LEFT, do_prev_word_void, 0);
|
||||
add_to_sclist(MMOST, "^Right", CONTROL_RIGHT, do_next_word_void, 0);
|
||||
add_to_sclist(MSOME, "^Left", CONTROL_LEFT, do_prev_word_void, 0);
|
||||
add_to_sclist(MSOME, "^Right", CONTROL_RIGHT, 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);
|
||||
@@ -1156,7 +1169,7 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN, "M-+", 0, do_scroll_down, 0);
|
||||
add_to_sclist(MMAIN, "M-=", 0, do_scroll_down, 0);
|
||||
#endif
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
add_to_sclist(MMAIN, "M-<", 0, switch_to_prev_buffer_void, 0);
|
||||
add_to_sclist(MMAIN, "M-,", 0, switch_to_prev_buffer_void, 0);
|
||||
add_to_sclist(MMAIN, "M->", 0, switch_to_next_buffer_void, 0);
|
||||
@@ -1176,7 +1189,7 @@ void shortcut_init(void)
|
||||
#ifndef NANO_TINY
|
||||
/* Group of "Appearance" toggles. */
|
||||
add_to_sclist(MMAIN, "M-X", 0, do_toggle_void, NO_HELP);
|
||||
add_to_sclist(MMAIN, "M-C", 0, do_toggle_void, CONST_UPDATE);
|
||||
add_to_sclist(MMAIN, "M-C", 0, do_toggle_void, CONSTANT_SHOW);
|
||||
add_to_sclist(MMAIN, "M-O", 0, do_toggle_void, MORE_SPACE);
|
||||
add_to_sclist(MMAIN, "M-S", 0, do_toggle_void, SMOOTH_SCROLL);
|
||||
add_to_sclist(MMAIN, "M-$", 0, do_toggle_void, SOFTWRAP);
|
||||
@@ -1191,7 +1204,7 @@ void shortcut_init(void)
|
||||
/* Group of "Editing-behavior" toggles. */
|
||||
add_to_sclist(MMAIN, "M-H", 0, do_toggle_void, SMART_HOME);
|
||||
add_to_sclist(MMAIN, "M-I", 0, do_toggle_void, AUTOINDENT);
|
||||
add_to_sclist(MMAIN, "M-K", 0, do_toggle_void, CUT_TO_END);
|
||||
add_to_sclist(MMAIN, "M-K", 0, do_toggle_void, CUT_FROM_CURSOR);
|
||||
#ifndef DISABLE_WRAPPING
|
||||
add_to_sclist(MMAIN, "M-L", 0, do_toggle_void, NO_WRAP);
|
||||
#endif
|
||||
@@ -1199,10 +1212,10 @@ void shortcut_init(void)
|
||||
|
||||
/* Group of "Peripheral-feature" toggles. */
|
||||
add_to_sclist(MMAIN, "M-B", 0, do_toggle_void, BACKUP_FILE);
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
add_to_sclist(MMAIN, "M-F", 0, do_toggle_void, MULTIBUFFER);
|
||||
#endif
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef ENABLE_MOUSE
|
||||
add_to_sclist(MMAIN, "M-M", 0, do_toggle_void, USE_MOUSE);
|
||||
#endif
|
||||
add_to_sclist(MMAIN, "M-N", 0, do_toggle_void, NO_CONVERT);
|
||||
@@ -1217,7 +1230,7 @@ void shortcut_init(void)
|
||||
add_to_sclist(MWHEREIS|MREPLACE, "M-C", 0, case_sens_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE, "M-R", 0, regexp_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE, "M-B", 0, backwards_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE, "^R", 0, flip_replace_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE, "^R", 0, flip_replace, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^Y", 0, do_first_line, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^V", 0, do_last_line, 0);
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
@@ -1227,30 +1240,30 @@ void shortcut_init(void)
|
||||
add_to_sclist(MWHEREIS, "^T", 0, do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MGOTOLINE, "^T", 0, gototext_void, 0);
|
||||
#ifndef DISABLE_HISTORIES
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^P", 0, get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^N", 0, get_history_newer_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "^P", 0, get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "^N", 0, get_history_newer_void, 0);
|
||||
#ifdef ENABLE_UTF8
|
||||
if (using_utf8()) {
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "\xE2\x86\x91", KEY_UP, get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "\xE2\x86\x93", KEY_DOWN, get_history_newer_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "\xE2\x86\x91", KEY_UP, get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "\xE2\x86\x93", KEY_DOWN, get_history_newer_void, 0);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Up", KEY_UP, get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Down", KEY_DOWN, get_history_newer_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "Up", KEY_UP, get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "Down", KEY_DOWN, get_history_newer_void, 0);
|
||||
}
|
||||
#endif
|
||||
#ifndef DISABLE_BROWSER
|
||||
#ifdef ENABLE_BROWSER
|
||||
add_to_sclist(MWHEREISFILE, "^Y", 0, do_first_file, 0);
|
||||
add_to_sclist(MWHEREISFILE, "^V", 0, do_last_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-\\", 0, do_first_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", 0, do_first_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-/", 0, do_last_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", 0, do_last_file, 0);
|
||||
add_to_sclist(MBROWSER, "Home", KEY_HOME, do_first_file, 0);
|
||||
add_to_sclist(MBROWSER, "End", KEY_END, do_last_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", 0, do_first_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", 0, do_last_file, 0);
|
||||
add_to_sclist(MBROWSER, "^Home", CONTROL_HOME, do_first_file, 0);
|
||||
add_to_sclist(MBROWSER, "^End", CONTROL_HOME, do_last_file, 0);
|
||||
add_to_sclist(MBROWSER, "^End", CONTROL_END, do_last_file, 0);
|
||||
add_to_sclist(MBROWSER, "^_", 0, goto_dir_void, 0);
|
||||
add_to_sclist(MBROWSER, "M-G", 0, goto_dir_void, 0);
|
||||
add_to_sclist(MBROWSER, "F13", 0, goto_dir_void, 0);
|
||||
@@ -1258,26 +1271,34 @@ void shortcut_init(void)
|
||||
#endif
|
||||
if (ISSET(TEMP_FILE))
|
||||
add_to_sclist(MWRITEFILE, "^Q", 0, discard_buffer, 0);
|
||||
#ifndef NANO_TINY
|
||||
add_to_sclist(MWRITEFILE, "M-D", 0, dos_format_void, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-M", 0, mac_format_void, 0);
|
||||
/* In restricted mode, don't allow Appending, Prepending, nor making
|
||||
* backups, nor executing a command, nor opening a new buffer. */
|
||||
if (!ISSET(RESTRICTED)) {
|
||||
/* Don't allow Appending, Prepending, nor Backups in restricted mode. */
|
||||
add_to_sclist(MWRITEFILE, "M-A", 0, append_void, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-P", 0, prepend_void, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-B", 0, backup_file_void, 0);
|
||||
#ifndef DISABLE_BROWSER
|
||||
add_to_sclist(MINSERTFILE|MEXTCMD, "^X", 0, flip_execute, 0);
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (!ISSET(RESTRICTED))
|
||||
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, flip_newbuffer, 0);
|
||||
#endif
|
||||
#ifdef ENABLE_BROWSER
|
||||
/* In restricted mode, don't allow entering the file browser. */
|
||||
if (!ISSET(RESTRICTED))
|
||||
add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", 0, to_files_void, 0);
|
||||
#endif
|
||||
add_to_sclist(MINSERTFILE|MEXTCMD, "^X", 0, flip_execute_void, 0);
|
||||
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, new_buffer_void, 0);
|
||||
}
|
||||
add_to_sclist(MHELP|MBROWSER, "^C", 0, do_exit, 0);
|
||||
/* Allow exiting from the file browser and the help viewer with
|
||||
* the same key as they were entered. */
|
||||
#ifndef DISABLE_BROWSER
|
||||
#ifdef ENABLE_BROWSER
|
||||
add_to_sclist(MBROWSER, "^T", 0, do_exit, 0);
|
||||
#endif
|
||||
#ifndef DISABLE_HELP
|
||||
#ifdef ENABLE_HELP
|
||||
add_to_sclist(MHELP, "^G", 0, do_exit, 0);
|
||||
add_to_sclist(MHELP, "Home", KEY_HOME, do_first_line, 0);
|
||||
add_to_sclist(MHELP, "End", KEY_END, do_last_line, 0);
|
||||
@@ -1339,7 +1360,7 @@ const char *flagtostr(int flag)
|
||||
/* TRANSLATORS: The next seventeen strings are toggle descriptions;
|
||||
* they are best kept shorter than 40 characters, but may be longer. */
|
||||
return N_("Help mode");
|
||||
case CONST_UPDATE:
|
||||
case CONSTANT_SHOW:
|
||||
return N_("Constant cursor position display");
|
||||
case MORE_SPACE:
|
||||
return N_("Use of one more line for editing");
|
||||
@@ -1355,7 +1376,7 @@ const char *flagtostr(int flag)
|
||||
return N_("Smart home key");
|
||||
case AUTOINDENT:
|
||||
return N_("Auto indent");
|
||||
case CUT_TO_END:
|
||||
case CUT_FROM_CURSOR:
|
||||
return N_("Cut to end");
|
||||
case NO_WRAP:
|
||||
return N_("Hard wrapping of overlong lines");
|
||||
@@ -1379,7 +1400,7 @@ const char *flagtostr(int flag)
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
#ifndef DISABLE_NANORC
|
||||
#ifdef ENABLE_NANORC
|
||||
/* Interpret a function string given in the rc file, and return a
|
||||
* shortcut struct with the corresponding function filled in. */
|
||||
sc *strtosc(const char *input)
|
||||
@@ -1390,7 +1411,7 @@ sc *strtosc(const char *input)
|
||||
s->toggle = 0;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
#ifdef ENABLE_HELP
|
||||
if (!strcasecmp(input, "help"))
|
||||
s->scfunc = do_help_void;
|
||||
else
|
||||
@@ -1468,25 +1489,17 @@ sc *strtosc(const char *input)
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcasecmp(input, "indent"))
|
||||
s->scfunc = do_indent_void;
|
||||
s->scfunc = do_indent;
|
||||
else if (!strcasecmp(input, "unindent"))
|
||||
s->scfunc = do_unindent;
|
||||
else if (!strcasecmp(input, "scrollup"))
|
||||
s->scfunc = do_scroll_up;
|
||||
else if (!strcasecmp(input, "scrolldown"))
|
||||
s->scfunc = do_scroll_down;
|
||||
else if (!strcasecmp(input, "prevword"))
|
||||
s->scfunc = do_prev_word_void;
|
||||
else if (!strcasecmp(input, "nextword"))
|
||||
s->scfunc = do_next_word_void;
|
||||
else if (!strcasecmp(input, "cutwordleft"))
|
||||
s->scfunc = do_cut_prev_word;
|
||||
else if (!strcasecmp(input, "cutwordright"))
|
||||
s->scfunc = do_cut_next_word;
|
||||
else if (!strcasecmp(input, "prevblock"))
|
||||
s->scfunc = do_prev_block;
|
||||
else if (!strcasecmp(input, "nextblock"))
|
||||
s->scfunc = do_next_block;
|
||||
else if (!strcasecmp(input, "findbracket"))
|
||||
s->scfunc = do_find_bracket;
|
||||
else if (!strcasecmp(input, "wordcount"))
|
||||
@@ -1508,10 +1521,18 @@ sc *strtosc(const char *input)
|
||||
else if (!strcasecmp(input, "down") ||
|
||||
!strcasecmp(input, "nextline"))
|
||||
s->scfunc = do_down_void;
|
||||
else if (!strcasecmp(input, "prevword"))
|
||||
s->scfunc = do_prev_word_void;
|
||||
else if (!strcasecmp(input, "nextword"))
|
||||
s->scfunc = do_next_word_void;
|
||||
else if (!strcasecmp(input, "home"))
|
||||
s->scfunc = do_home_void;
|
||||
else if (!strcasecmp(input, "end"))
|
||||
s->scfunc = do_end_void;
|
||||
else if (!strcasecmp(input, "prevblock"))
|
||||
s->scfunc = do_prev_block;
|
||||
else if (!strcasecmp(input, "nextblock"))
|
||||
s->scfunc = do_next_block;
|
||||
else if (!strcasecmp(input, "pageup") ||
|
||||
!strcasecmp(input, "prevpage"))
|
||||
s->scfunc = do_page_up;
|
||||
@@ -1522,7 +1543,7 @@ sc *strtosc(const char *input)
|
||||
s->scfunc = do_first_line;
|
||||
else if (!strcasecmp(input, "lastline"))
|
||||
s->scfunc = do_last_line;
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
else if (!strcasecmp(input, "prevbuf"))
|
||||
s->scfunc = switch_to_prev_buffer_void;
|
||||
else if (!strcasecmp(input, "nextbuf"))
|
||||
@@ -1551,7 +1572,7 @@ sc *strtosc(const char *input)
|
||||
s->scfunc = backwards_void;
|
||||
else if (!strcasecmp(input, "flipreplace") ||
|
||||
!strcasecmp(input, "dontreplace")) /* Deprecated. Remove in 2018. */
|
||||
s->scfunc = flip_replace_void;
|
||||
s->scfunc = flip_replace;
|
||||
else if (!strcasecmp(input, "gototext"))
|
||||
s->scfunc = gototext_void;
|
||||
#ifndef DISABLE_HISTORIES
|
||||
@@ -1560,6 +1581,7 @@ sc *strtosc(const char *input)
|
||||
else if (!strcasecmp(input, "nexthistory"))
|
||||
s->scfunc = get_history_newer_void;
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcasecmp(input, "dosformat"))
|
||||
s->scfunc = dos_format_void;
|
||||
else if (!strcasecmp(input, "macformat"))
|
||||
@@ -1570,16 +1592,15 @@ sc *strtosc(const char *input)
|
||||
s->scfunc = prepend_void;
|
||||
else if (!strcasecmp(input, "backup"))
|
||||
s->scfunc = backup_file_void;
|
||||
#ifndef ENABLE_TINY
|
||||
else if (!strcasecmp(input, "flipexecute"))
|
||||
s->scfunc = flip_execute_void;
|
||||
s->scfunc = flip_execute;
|
||||
#endif
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
else if (!strcasecmp(input, "flipnewbuffer") ||
|
||||
!strcasecmp(input, "newbuffer")) /* Deprecated. Remove in 2018. */
|
||||
s->scfunc = new_buffer_void;
|
||||
s->scfunc = flip_newbuffer;
|
||||
#endif
|
||||
#ifndef DISABLE_BROWSER
|
||||
#ifdef ENABLE_BROWSER
|
||||
else if (!strcasecmp(input, "tofiles") ||
|
||||
!strcasecmp(input, "browser"))
|
||||
s->scfunc = to_files_void;
|
||||
@@ -1596,7 +1617,7 @@ sc *strtosc(const char *input)
|
||||
if (!strcasecmp(input, "nohelp"))
|
||||
s->toggle = NO_HELP;
|
||||
else if (!strcasecmp(input, "constupdate"))
|
||||
s->toggle = CONST_UPDATE;
|
||||
s->toggle = CONSTANT_SHOW;
|
||||
else if (!strcasecmp(input, "morespace"))
|
||||
s->toggle = MORE_SPACE;
|
||||
else if (!strcasecmp(input, "smoothscroll"))
|
||||
@@ -1614,7 +1635,7 @@ sc *strtosc(const char *input)
|
||||
else if (!strcasecmp(input, "autoindent"))
|
||||
s->toggle = AUTOINDENT;
|
||||
else if (!strcasecmp(input, "cuttoend"))
|
||||
s->toggle = CUT_TO_END;
|
||||
s->toggle = CUT_FROM_CURSOR;
|
||||
#ifndef DISABLE_WRAPPING
|
||||
else if (!strcasecmp(input, "nowrap"))
|
||||
s->toggle = NO_WRAP;
|
||||
@@ -1623,11 +1644,11 @@ sc *strtosc(const char *input)
|
||||
s->toggle = TABS_TO_SPACES;
|
||||
else if (!strcasecmp(input, "backupfile"))
|
||||
s->toggle = BACKUP_FILE;
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
else if (!strcasecmp(input, "multibuffer"))
|
||||
s->toggle = MULTIBUFFER;
|
||||
#endif
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef ENABLE_MOUSE
|
||||
else if (!strcasecmp(input, "mouse"))
|
||||
s->toggle = USE_MOUSE;
|
||||
#endif
|
||||
@@ -1668,7 +1689,7 @@ int strtomenu(const char *input)
|
||||
else if (!strcasecmp(input, "externalcmd") ||
|
||||
!strcasecmp(input, "extcmd"))
|
||||
return MEXTCMD;
|
||||
#ifndef DISABLE_HELP
|
||||
#ifdef ENABLE_HELP
|
||||
else if (!strcasecmp(input, "help"))
|
||||
return MHELP;
|
||||
#endif
|
||||
@@ -1678,7 +1699,7 @@ int strtomenu(const char *input)
|
||||
#endif
|
||||
else if (!strcasecmp(input, "linter"))
|
||||
return MLINTER;
|
||||
#ifndef DISABLE_BROWSER
|
||||
#ifdef ENABLE_BROWSER
|
||||
else if (!strcasecmp(input, "browser"))
|
||||
return MBROWSER;
|
||||
else if (!strcasecmp(input, "whereisfile"))
|
||||
@@ -1688,7 +1709,7 @@ int strtomenu(const char *input)
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
#endif /* !DISABLE_NANORC */
|
||||
#endif /* ENABLE_NANORC */
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -1699,7 +1720,8 @@ int strtomenu(const char *input)
|
||||
* function unless debugging is turned on. */
|
||||
void thanks_for_all_the_fish(void)
|
||||
{
|
||||
delwin(topwin);
|
||||
if (topwin != NULL)
|
||||
delwin(topwin);
|
||||
delwin(edit);
|
||||
delwin(bottomwin);
|
||||
|
||||
@@ -1794,7 +1816,7 @@ void thanks_for_all_the_fish(void)
|
||||
sclist = sclist->next;
|
||||
free(s);
|
||||
}
|
||||
#ifndef DISABLE_NANORC
|
||||
#ifdef ENABLE_NANORC
|
||||
free(homedir);
|
||||
#endif
|
||||
}
|
||||
|
||||
337
src/help.c
337
src/help.c
@@ -2,7 +2,8 @@
|
||||
* help.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2000-2011, 2013-2017 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014, 2015, 2016 Benno Schulenberg *
|
||||
* Copyright (C) 2017 Rishabh Dave *
|
||||
* Copyright (C) 2014-2017 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published *
|
||||
@@ -24,165 +25,265 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
#ifdef ENABLE_HELP
|
||||
|
||||
static char *help_text = NULL;
|
||||
/* The text displayed in the help window. */
|
||||
|
||||
static const char *start_of_body = NULL;
|
||||
/* The point in the help text just after the title. */
|
||||
|
||||
static char *end_of_intro = NULL;
|
||||
/* The point in the help text where the introductory paragraphs end
|
||||
* and the shortcut descriptions begin. */
|
||||
/* The point in the help text where the shortcut descriptions begin. */
|
||||
|
||||
static size_t location;
|
||||
/* The offset (in bytes) of the topleft of the shown help text. */
|
||||
|
||||
char *tempfilename = NULL;
|
||||
/* Name of the temporary file used for wrapping the help text. */
|
||||
|
||||
/* Hard-wrap the help text, write it to the existing temporary file, and
|
||||
* read that file into a new buffer. */
|
||||
void wrap_the_help_text(bool redisplaying)
|
||||
{
|
||||
int sum = 0;
|
||||
const char *ptr = start_of_body;
|
||||
FILE *tempfile = fopen(tempfilename, "w+b");
|
||||
|
||||
/* If re-opening the temporary file failed, give up. */
|
||||
if (tempfile == NULL) {
|
||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
/* Write the body of the help_text into the temporary file. */
|
||||
while (*ptr != '\0') {
|
||||
int length = help_line_len(ptr);
|
||||
|
||||
fwrite(ptr, sizeof(char), length, tempfile);
|
||||
ptr += length;
|
||||
|
||||
/* Hard-wrap the lines in the help text. */
|
||||
if (*ptr != '\n')
|
||||
fwrite("\n", sizeof(char), 1, tempfile);
|
||||
else while (*ptr == '\n')
|
||||
fwrite(ptr++, sizeof(char), 1, tempfile);
|
||||
}
|
||||
|
||||
fclose(tempfile);
|
||||
|
||||
if (redisplaying)
|
||||
close_buffer();
|
||||
|
||||
open_buffer(tempfilename, FALSE);
|
||||
remove_magicline();
|
||||
|
||||
prepare_for_display();
|
||||
|
||||
/* Move to the position in the file where we were before. */
|
||||
while (TRUE) {
|
||||
sum += strlen(openfile->current->data);
|
||||
if (sum > location)
|
||||
break;
|
||||
openfile->current = openfile->current->next;
|
||||
}
|
||||
|
||||
openfile->edittop = openfile->current;
|
||||
}
|
||||
|
||||
/* Our main help-viewer function. */
|
||||
void do_help(void)
|
||||
{
|
||||
int kbinput = ERR;
|
||||
bool old_no_help = ISSET(NO_HELP);
|
||||
size_t line = 0;
|
||||
/* The line number in help_text of the first displayed help
|
||||
* line. This variable is zero-based. */
|
||||
size_t last_line = 0;
|
||||
/* The line number in help_text of the last help line. This
|
||||
* variable is zero-based. */
|
||||
int oldmenu = currmenu;
|
||||
/* The menu we were called from. */
|
||||
const char *ptr;
|
||||
/* The current line of the help text. */
|
||||
size_t old_line = (size_t)-1;
|
||||
/* The line we were on before the current line. */
|
||||
functionptrtype func;
|
||||
/* The function of the key the user typed in. */
|
||||
int oldmenu = currmenu;
|
||||
/* The menu we were called from. */
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
int was_margin = margin;
|
||||
#endif
|
||||
ssize_t was_tabsize = tabsize;
|
||||
#ifndef DISABLE_COLOR
|
||||
char *was_syntax = syntaxstr;
|
||||
#endif
|
||||
char *saved_answer = (answer != NULL) ? strdup(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. */
|
||||
filestruct *line;
|
||||
int length;
|
||||
FILE *fp;
|
||||
|
||||
/* Don't show a cursor in the help screen. */
|
||||
curs_set(0);
|
||||
blank_edit();
|
||||
blank_statusbar();
|
||||
|
||||
/* Set help_text as the string to display. */
|
||||
help_init();
|
||||
/* Get a temporary file for the help text. If it fails, give up. */
|
||||
tempfilename = safe_tempfile(&fp);
|
||||
if (tempfilename == NULL) {
|
||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||
free(saved_answer);
|
||||
return;
|
||||
}
|
||||
|
||||
assert(help_text != NULL);
|
||||
fclose(fp);
|
||||
|
||||
if (ISSET(NO_HELP)) {
|
||||
/* Make sure that the help screen's shortcut list will actually
|
||||
* be displayed. */
|
||||
/* Save the settings of all flags. */
|
||||
memcpy(stash, flags, sizeof(flags));
|
||||
|
||||
/* Ensure that the help screen's shortcut list can be displayed. */
|
||||
if (ISSET(NO_HELP) && LINES > 4) {
|
||||
UNSET(NO_HELP);
|
||||
window_init();
|
||||
}
|
||||
|
||||
/* When searching, do it forward, case insensitive, and without regexes. */
|
||||
UNSET(BACKWARDS_SEARCH);
|
||||
UNSET(CASE_SENSITIVE);
|
||||
UNSET(USE_REGEXP);
|
||||
|
||||
UNSET(WHITESPACE_DISPLAY);
|
||||
UNSET(NOREAD_MODE);
|
||||
SET(MULTIBUFFER);
|
||||
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
UNSET(LINE_NUMBERS);
|
||||
margin = 0;
|
||||
#endif
|
||||
tabsize = 8;
|
||||
#ifndef DISABLE_COLOR
|
||||
syntaxstr = "nanohelp";
|
||||
#endif
|
||||
curs_set(0);
|
||||
|
||||
/* Compose the help text from all the pieces. */
|
||||
help_init();
|
||||
inhelp = TRUE;
|
||||
location = 0;
|
||||
|
||||
bottombars(MHELP);
|
||||
wnoutrefresh(bottomwin);
|
||||
|
||||
/* 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[length] = '\0';
|
||||
|
||||
titlebar(title);
|
||||
|
||||
/* Skip over the title to point at the start of the body text. */
|
||||
start_of_body = help_text + length;
|
||||
while (*start_of_body == '\n')
|
||||
start_of_body++;
|
||||
|
||||
wrap_the_help_text(FALSE);
|
||||
edit_refresh();
|
||||
|
||||
while (TRUE) {
|
||||
size_t i;
|
||||
|
||||
ptr = help_text;
|
||||
|
||||
/* Find the line number of the last line of the help text. */
|
||||
for (last_line = 0; *ptr != '\0'; last_line++) {
|
||||
ptr += help_line_len(ptr);
|
||||
if (*ptr == '\n')
|
||||
ptr++;
|
||||
}
|
||||
|
||||
if (last_line > 0)
|
||||
last_line--;
|
||||
|
||||
/* Redisplay if the text was scrolled or an invalid key was pressed. */
|
||||
if (line != old_line || kbinput == ERR) {
|
||||
blank_edit();
|
||||
|
||||
ptr = help_text;
|
||||
|
||||
/* Advance in the text to the first line to be displayed. */
|
||||
for (i = 0; i < line; i++) {
|
||||
ptr += help_line_len(ptr);
|
||||
if (*ptr == '\n')
|
||||
ptr++;
|
||||
}
|
||||
|
||||
/* Now display as many lines as the window will hold. */
|
||||
for (i = 0; i < editwinrows && *ptr != '\0'; i++) {
|
||||
size_t j = help_line_len(ptr);
|
||||
|
||||
mvwaddnstr(edit, i, 0, ptr, j);
|
||||
ptr += j;
|
||||
if (*ptr == '\n')
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
wnoutrefresh(edit);
|
||||
|
||||
old_line = line;
|
||||
|
||||
lastmessage = HUSH;
|
||||
focusing = TRUE;
|
||||
didfind = 0;
|
||||
|
||||
kbinput = get_kbinput(edit);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (kbinput == KEY_WINCH) {
|
||||
kbinput = ERR;
|
||||
continue; /* Redraw the screen. */
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
if (kbinput == KEY_MOUSE) {
|
||||
int mouse_x, mouse_y;
|
||||
get_mouseinput(&mouse_x, &mouse_y, TRUE);
|
||||
continue; /* Redraw the screen. */
|
||||
}
|
||||
#endif
|
||||
|
||||
func = parse_help_input(&kbinput);
|
||||
|
||||
if (func == total_refresh) {
|
||||
total_redraw();
|
||||
} else if (func == do_up_void) {
|
||||
if (line > 0)
|
||||
line--;
|
||||
do_up(TRUE);
|
||||
} else if (func == do_down_void) {
|
||||
if (line + (editwinrows - 1) < last_line)
|
||||
line++;
|
||||
if (openfile->edittop->lineno + editwinrows - 1 <
|
||||
openfile->filebot->lineno)
|
||||
do_down(TRUE);
|
||||
} else if (func == do_page_up) {
|
||||
if (line > editwinrows - 2)
|
||||
line -= editwinrows - 2;
|
||||
else
|
||||
line = 0;
|
||||
do_page_up();
|
||||
} else if (func == do_page_down) {
|
||||
if (line + (editwinrows - 1) < last_line)
|
||||
line += editwinrows - 2;
|
||||
do_page_down();
|
||||
} else if (func == do_first_line) {
|
||||
line = 0;
|
||||
do_first_line();
|
||||
} else if (func == do_last_line) {
|
||||
if (line + (editwinrows - 1) < last_line)
|
||||
line = last_line - (editwinrows - 1);
|
||||
do_last_line();
|
||||
} else if (func == do_search) {
|
||||
do_search();
|
||||
bottombars(MHELP);
|
||||
} else if (func == do_research) {
|
||||
do_research();
|
||||
currmenu = MHELP;
|
||||
#ifndef NANO_TINY
|
||||
} else if (kbinput == KEY_WINCH) {
|
||||
; /* Nothing to do. */
|
||||
#endif
|
||||
#ifdef ENABLE_MOUSE
|
||||
} else if (kbinput == KEY_MOUSE) {
|
||||
int dummy_x, dummy_y;
|
||||
get_mouseinput(&dummy_x, &dummy_y, TRUE);
|
||||
#endif
|
||||
} else if (func == do_exit) {
|
||||
/* Exit from the help viewer. */
|
||||
close_buffer();
|
||||
break;
|
||||
} else
|
||||
unbound_key(kbinput);
|
||||
|
||||
/* If we searched and found something, let the cursor show it. */
|
||||
if (didfind == 1)
|
||||
curs_set(1);
|
||||
else
|
||||
curs_set(0);
|
||||
|
||||
edit_refresh();
|
||||
|
||||
location = 0;
|
||||
line = openfile->fileage;
|
||||
|
||||
/* Count how far (in bytes) edittop is into the file. */
|
||||
while (line != openfile->edittop) {
|
||||
location += strlen(line->data);
|
||||
line = line->next;
|
||||
}
|
||||
}
|
||||
|
||||
if (old_no_help) {
|
||||
/* Restore the settings of all flags. */
|
||||
memcpy(flags, stash, sizeof(flags));
|
||||
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
margin = was_margin;
|
||||
#endif
|
||||
tabsize = was_tabsize;
|
||||
#ifndef DISABLE_COLOR
|
||||
syntaxstr = was_syntax;
|
||||
#endif
|
||||
|
||||
/* Switch back to the buffer we were invoked from. */
|
||||
switch_to_prev_buffer_void();
|
||||
|
||||
if (ISSET(NO_HELP)) {
|
||||
blank_bottombars();
|
||||
wnoutrefresh(bottomwin);
|
||||
currmenu = oldmenu;
|
||||
SET(NO_HELP);
|
||||
window_init();
|
||||
} else
|
||||
bottombars(oldmenu);
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
free(title);
|
||||
title = NULL;
|
||||
inhelp = FALSE;
|
||||
|
||||
#ifdef ENABLE_BROWSER
|
||||
if (oldmenu == MBROWSER || oldmenu == MWHEREISFILE || oldmenu == MGOTODIR)
|
||||
browser_refresh();
|
||||
else
|
||||
#endif
|
||||
edit_refresh();
|
||||
total_refresh();
|
||||
|
||||
free(answer);
|
||||
answer = saved_answer;
|
||||
|
||||
remove(tempfilename);
|
||||
free(tempfilename);
|
||||
|
||||
/* We're exiting from the help screen. */
|
||||
free(help_text);
|
||||
}
|
||||
|
||||
@@ -199,12 +300,6 @@ void help_init(void)
|
||||
const subnfunc *f;
|
||||
const sc *s;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
bool old_whitespace = ISSET(WHITESPACE_DISPLAY);
|
||||
|
||||
UNSET(WHITESPACE_DISPLAY);
|
||||
#endif
|
||||
|
||||
/* First, set up the initial help text for the current function. */
|
||||
if (currmenu == MWHEREIS || currmenu == MREPLACE || currmenu == MREPLACEWITH) {
|
||||
htx[0] = N_("Search Command Help Text\n\n "
|
||||
@@ -258,7 +353,7 @@ void help_init(void)
|
||||
htx[1] = NULL;
|
||||
htx[2] = NULL;
|
||||
}
|
||||
#ifndef DISABLE_BROWSER
|
||||
#ifdef ENABLE_BROWSER
|
||||
else if (currmenu == MBROWSER) {
|
||||
htx[0] = N_("File Browser Help Text\n\n "
|
||||
"The file browser is used to visually browse the "
|
||||
@@ -296,7 +391,7 @@ void help_init(void)
|
||||
htx[1] = NULL;
|
||||
htx[2] = NULL;
|
||||
}
|
||||
#endif /* !DISABLE_BROWSER */
|
||||
#endif /* ENABLE_BROWSER */
|
||||
#ifndef DISABLE_SPELLER
|
||||
else if (currmenu == MSPELL) {
|
||||
htx[0] = N_("Spell Check Help Text\n\n "
|
||||
@@ -369,7 +464,7 @@ void help_init(void)
|
||||
* plus one or two \n's. */
|
||||
for (f = allfuncs; f != NULL; f = f->next)
|
||||
if (f->menus & currmenu)
|
||||
allocsize += (16 * MAXCHARLEN) + strlen(f->help) + 2;
|
||||
allocsize += (16 * MAXCHARLEN) + strlen(_(f->help)) + 2;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If we're on the main list, we also count the toggle help text.
|
||||
@@ -384,7 +479,7 @@ void help_init(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Allocate space for the help text. */
|
||||
/* Allocate memory for the help text. */
|
||||
help_text = charalloc(allocsize + 1);
|
||||
|
||||
/* Now add the text we want. */
|
||||
@@ -464,13 +559,10 @@ void help_init(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (old_whitespace)
|
||||
SET(WHITESPACE_DISPLAY);
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* If all went well, we didn't overwrite the allocated space. */
|
||||
assert(strlen(help_text) <= allocsize + 1);
|
||||
if (strlen(help_text) > allocsize)
|
||||
statusline(ALERT, "Help text spilled over -- please report a bug");
|
||||
}
|
||||
|
||||
/* Return the function that is bound to the given key, accepting certain
|
||||
@@ -483,6 +575,13 @@ functionptrtype parse_help_input(int *kbinput)
|
||||
return do_page_down;
|
||||
case '-':
|
||||
return do_page_up;
|
||||
case 'W':
|
||||
case 'w':
|
||||
case '/':
|
||||
return do_search;
|
||||
case 'N':
|
||||
case 'n':
|
||||
return do_research;
|
||||
case 'E':
|
||||
case 'e':
|
||||
case 'Q':
|
||||
@@ -524,17 +623,17 @@ size_t help_line_len(const char *ptr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* !DISABLE_HELP */
|
||||
#endif /* ENABLE_HELP */
|
||||
|
||||
/* Start the help viewer. */
|
||||
void do_help_void(void)
|
||||
{
|
||||
#ifndef DISABLE_HELP
|
||||
#ifdef ENABLE_HELP
|
||||
do_help();
|
||||
#else
|
||||
if (currmenu == MMAIN)
|
||||
say_there_is_no_help();
|
||||
else
|
||||
beep();
|
||||
#endif /* !DISABLE_HELP */
|
||||
#endif
|
||||
}
|
||||
|
||||
98
src/move.c
98
src/move.c
@@ -53,13 +53,8 @@ void get_edge_and_target(size_t *leftedge, size_t *target_column)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
size_t realspan = strlenpt(openfile->current->data);
|
||||
|
||||
if (openfile->placewewant < realspan)
|
||||
realspan = openfile->placewewant;
|
||||
|
||||
*leftedge = (realspan / editwincols) * editwincols;
|
||||
*target_column = openfile->placewewant % editwincols;
|
||||
*leftedge = leftedge_for(xplustabs(), openfile->current);
|
||||
*target_column = openfile->placewewant - *leftedge;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
@@ -79,6 +74,8 @@ void do_page_up(void)
|
||||
if (!ISSET(SMOOTH_SCROLL)) {
|
||||
openfile->current = openfile->edittop;
|
||||
openfile->placewewant = openfile->firstcolumn;
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
openfile->firstcolumn);
|
||||
openfile->current_y = 0;
|
||||
}
|
||||
|
||||
@@ -93,7 +90,7 @@ void do_page_up(void)
|
||||
|
||||
openfile->placewewant = leftedge + target_column;
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
openfile->placewewant);
|
||||
actual_last_column(leftedge, target_column));
|
||||
|
||||
/* Move the viewport so that the cursor stays immobile, if possible. */
|
||||
adjust_viewport(STATIONARY);
|
||||
@@ -111,6 +108,8 @@ void do_page_down(void)
|
||||
if (!ISSET(SMOOTH_SCROLL)) {
|
||||
openfile->current = openfile->edittop;
|
||||
openfile->placewewant = openfile->firstcolumn;
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
openfile->firstcolumn);
|
||||
openfile->current_y = 0;
|
||||
}
|
||||
|
||||
@@ -125,7 +124,7 @@ void do_page_down(void)
|
||||
|
||||
openfile->placewewant = leftedge + target_column;
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
openfile->placewewant);
|
||||
actual_last_column(leftedge, target_column));
|
||||
|
||||
/* Move the viewport so that the cursor stays immobile, if possible. */
|
||||
adjust_viewport(STATIONARY);
|
||||
@@ -133,10 +132,9 @@ void do_page_down(void)
|
||||
}
|
||||
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
/* Move up to the beginning of the last beginning-of-paragraph line
|
||||
* before the current line. If allow_update is TRUE, update the screen
|
||||
* afterwards. */
|
||||
void do_para_begin(bool allow_update)
|
||||
/* Move to the beginning of the last beginning-of-paragraph line before the
|
||||
* current line. If update_screen is TRUE, update the screen afterwards. */
|
||||
void do_para_begin(bool update_screen)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
|
||||
@@ -148,7 +146,7 @@ void do_para_begin(bool allow_update)
|
||||
|
||||
openfile->current_x = 0;
|
||||
|
||||
if (allow_update)
|
||||
if (update_screen)
|
||||
edit_redraw(was_current);
|
||||
}
|
||||
|
||||
@@ -160,11 +158,11 @@ void do_para_begin_void(void)
|
||||
|
||||
/* Move down to the beginning of the last line of the current paragraph.
|
||||
* Then move down one line farther if there is such a line, or to the
|
||||
* end of the current line if not. If allow_update is TRUE, update the
|
||||
* end of the current line if not. If update_screen is TRUE, update the
|
||||
* screen afterwards. A line is the last line of a paragraph if it is
|
||||
* in a paragraph, and the next line either is the beginning line of a
|
||||
* paragraph or isn't in a paragraph. */
|
||||
void do_para_end(bool allow_update)
|
||||
void do_para_end(bool update_screen)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
|
||||
@@ -184,7 +182,7 @@ void do_para_end(bool allow_update)
|
||||
} else
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
|
||||
if (allow_update)
|
||||
if (update_screen)
|
||||
edit_redraw(was_current);
|
||||
}
|
||||
|
||||
@@ -236,9 +234,9 @@ void do_next_block(void)
|
||||
}
|
||||
|
||||
/* Move to the previous word in the file. If allow_punct is TRUE, treat
|
||||
* punctuation as part of a word. If allow_update is TRUE, update the
|
||||
* punctuation as part of a word. If update_screen is TRUE, update the
|
||||
* screen afterwards. */
|
||||
void do_prev_word(bool allow_punct, bool allow_update)
|
||||
void do_prev_word(bool allow_punct, bool update_screen)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
bool seen_a_word = FALSE, step_forward = FALSE;
|
||||
@@ -275,8 +273,7 @@ void do_prev_word(bool allow_punct, bool allow_update)
|
||||
openfile->current_x = move_mbright(openfile->current->data,
|
||||
openfile->current_x);
|
||||
|
||||
/* If allow_update is TRUE, update the screen. */
|
||||
if (allow_update) {
|
||||
if (update_screen) {
|
||||
focusing = FALSE;
|
||||
edit_redraw(was_current);
|
||||
}
|
||||
@@ -290,10 +287,10 @@ void do_prev_word_void(void)
|
||||
}
|
||||
|
||||
/* Move to the next word in the file. If allow_punct is TRUE, treat
|
||||
* punctuation as part of a word. If allow_update is TRUE, update the
|
||||
* punctuation as part of a word. If update_screen is TRUE, update the
|
||||
* screen afterwards. Return TRUE if we started on a word, and FALSE
|
||||
* otherwise. */
|
||||
bool do_next_word(bool allow_punct, bool allow_update)
|
||||
bool do_next_word(bool allow_punct, bool update_screen)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
bool started_on_word = is_word_mbchar(openfile->current->data +
|
||||
@@ -325,8 +322,7 @@ bool do_next_word(bool allow_punct, bool allow_update)
|
||||
break;
|
||||
}
|
||||
|
||||
/* If allow_update is TRUE, update the screen. */
|
||||
if (allow_update) {
|
||||
if (update_screen) {
|
||||
focusing = FALSE;
|
||||
edit_redraw(was_current);
|
||||
}
|
||||
@@ -349,15 +345,16 @@ void do_next_word_void(void)
|
||||
void do_home(bool be_clever)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
size_t was_column = openfile->placewewant;
|
||||
size_t was_column = xplustabs();
|
||||
bool moved_off_chunk = TRUE;
|
||||
#ifndef NANO_TINY
|
||||
bool moved = FALSE;
|
||||
size_t leftedge_x = 0;
|
||||
size_t leftedge = 0, leftedge_x = 0;
|
||||
|
||||
if (ISSET(SOFTWRAP))
|
||||
leftedge_x = actual_x(openfile->current->data,
|
||||
(was_column / editwincols) * editwincols);
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
leftedge = leftedge_for(was_column, openfile->current);
|
||||
leftedge_x = actual_x(openfile->current->data, leftedge);
|
||||
}
|
||||
|
||||
if (ISSET(SMART_HOME) && be_clever) {
|
||||
size_t indent_x = indent_length(openfile->current->data);
|
||||
@@ -379,11 +376,11 @@ void do_home(bool be_clever)
|
||||
if (!moved && ISSET(SOFTWRAP)) {
|
||||
/* If already at the left edge of the screen, move fully home.
|
||||
* Otherwise, move to the left edge. */
|
||||
if (was_column % editwincols == 0 && be_clever)
|
||||
if (openfile->current_x == leftedge_x && be_clever)
|
||||
openfile->current_x = 0;
|
||||
else {
|
||||
openfile->current_x = leftedge_x;
|
||||
openfile->placewewant = (was_column / editwincols) * editwincols;
|
||||
openfile->placewewant = leftedge;
|
||||
moved_off_chunk = FALSE;
|
||||
}
|
||||
} else if (!moved)
|
||||
@@ -414,15 +411,26 @@ void do_home_void(void)
|
||||
void do_end(bool be_clever)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
size_t was_column = openfile->placewewant;
|
||||
size_t was_column = xplustabs();
|
||||
size_t line_len = strlen(openfile->current->data);
|
||||
bool moved_off_chunk = TRUE;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
size_t rightedge_x = actual_x(openfile->current->data,
|
||||
((was_column / editwincols) * editwincols) +
|
||||
(editwincols - 1));
|
||||
bool last_chunk = FALSE;
|
||||
size_t leftedge = leftedge_for(was_column, openfile->current);
|
||||
size_t rightedge = get_softwrap_breakpoint(openfile->current->data,
|
||||
leftedge, &last_chunk);
|
||||
size_t rightedge_x;
|
||||
|
||||
/* If we're on the last chunk, we're already at the end of the line.
|
||||
* Otherwise, we're one column past the end of the line. Shifting
|
||||
* backwards one column might put us in the middle of a multi-column
|
||||
* character, but actual_x() will fix that. */
|
||||
if (!last_chunk)
|
||||
rightedge--;
|
||||
|
||||
rightedge_x = actual_x(openfile->current->data, rightedge);
|
||||
|
||||
/* If already at the right edge of the screen, move fully to
|
||||
* the end of the line. Otherwise, move to the right edge. */
|
||||
@@ -430,13 +438,15 @@ void do_end(bool be_clever)
|
||||
openfile->current_x = line_len;
|
||||
else {
|
||||
openfile->current_x = rightedge_x;
|
||||
openfile->placewewant = rightedge;
|
||||
moved_off_chunk = FALSE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
openfile->current_x = line_len;
|
||||
|
||||
openfile->placewewant = xplustabs();
|
||||
if (moved_off_chunk)
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
/* If we changed chunk, we might be offscreen. Otherwise,
|
||||
* update current if the mark is on or we changed "page". */
|
||||
@@ -474,7 +484,7 @@ void do_up(bool scroll_only)
|
||||
|
||||
openfile->placewewant = leftedge + target_column;
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
openfile->placewewant);
|
||||
actual_last_column(leftedge, target_column));
|
||||
|
||||
/* When the cursor was on the first line of the edit window (or when just
|
||||
* scrolling without moving the cursor), scroll the edit window up -- one
|
||||
@@ -518,7 +528,7 @@ void do_down(bool scroll_only)
|
||||
|
||||
openfile->placewewant = leftedge + target_column;
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
openfile->placewewant);
|
||||
actual_last_column(leftedge, target_column));
|
||||
|
||||
/* When the cursor was on the last line of the edit window (or when just
|
||||
* scrolling without moving the cursor), scroll the edit window down -- one
|
||||
@@ -565,8 +575,8 @@ void do_left(void)
|
||||
{
|
||||
size_t was_column = xplustabs();
|
||||
#ifndef NANO_TINY
|
||||
size_t was_chunk = (was_column / editwincols);
|
||||
filestruct *was_current = openfile->current;
|
||||
size_t was_chunk = chunk_for(was_column, was_current);
|
||||
#endif
|
||||
|
||||
if (openfile->current_x > 0)
|
||||
@@ -585,7 +595,8 @@ void do_left(void)
|
||||
* we're now above the first line of the edit window, so scroll up. */
|
||||
if (ISSET(SOFTWRAP) && openfile->current_y == 0 &&
|
||||
openfile->current == was_current &&
|
||||
openfile->placewewant / editwincols != was_chunk) {
|
||||
chunk_for(openfile->placewewant,
|
||||
openfile->current) != was_chunk) {
|
||||
edit_scroll(UPWARD, ISSET(SMOOTH_SCROLL) ? 1 : editwinrows / 2 + 1);
|
||||
return;
|
||||
}
|
||||
@@ -601,8 +612,8 @@ void do_right(void)
|
||||
{
|
||||
size_t was_column = xplustabs();
|
||||
#ifndef NANO_TINY
|
||||
size_t was_chunk = (was_column / editwincols);
|
||||
filestruct *was_current = openfile->current;
|
||||
size_t was_chunk = chunk_for(was_column, was_current);
|
||||
#endif
|
||||
|
||||
if (openfile->current->data[openfile->current_x] != '\0')
|
||||
@@ -621,7 +632,8 @@ void do_right(void)
|
||||
* we're now below the first line of the edit window, so scroll down. */
|
||||
if (ISSET(SOFTWRAP) && openfile->current_y == editwinrows - 1 &&
|
||||
openfile->current == was_current &&
|
||||
openfile->placewewant / editwincols != was_chunk) {
|
||||
chunk_for(openfile->placewewant,
|
||||
openfile->current) != was_chunk) {
|
||||
edit_scroll(DOWNWARD, ISSET(SMOOTH_SCROLL) ? 1 : editwinrows / 2 + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
541
src/nano.c
541
src/nano.c
File diff suppressed because it is too large
Load Diff
45
src/nano.h
45
src/nano.h
@@ -48,8 +48,6 @@
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
/* Suppress warnings for __attribute__((warn_unused_result)). */
|
||||
#define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0)
|
||||
|
||||
@@ -124,10 +122,10 @@
|
||||
#include <signal.h>
|
||||
#include <assert.h>
|
||||
|
||||
/* If we aren't using ncurses with mouse support, turn the mouse support
|
||||
* off, as it's useless then. */
|
||||
/* If we aren't using an ncurses with mouse support, exclude any
|
||||
* mouse routines, as they are useless then. */
|
||||
#ifndef NCURSES_MOUSE_VERSION
|
||||
#define DISABLE_MOUSE 1
|
||||
#undef ENABLE_MOUSE
|
||||
#endif
|
||||
|
||||
#if defined(DISABLE_WRAPPING) && defined(DISABLE_JUSTIFY)
|
||||
@@ -160,11 +158,11 @@ typedef enum {
|
||||
} update_type;
|
||||
|
||||
typedef enum {
|
||||
ADD, DEL, BACK, CUT, CUT_EOF, REPLACE,
|
||||
ADD, DEL, BACK, CUT, CUT_TO_EOF, REPLACE,
|
||||
#ifndef DISABLE_WRAPPING
|
||||
SPLIT_BEGIN, SPLIT_END,
|
||||
#endif
|
||||
#ifndef DISABLE_COMMENT
|
||||
#ifdef ENABLE_COMMENT
|
||||
COMMENT, UNCOMMENT, PREFLIGHT,
|
||||
#endif
|
||||
JOIN, PASTE, INSERT, ENTER, OTHER
|
||||
@@ -220,8 +218,10 @@ typedef struct syntaxtype {
|
||||
/* The command with which to lint this type of file. */
|
||||
char *formatter;
|
||||
/* The formatting command (for programming languages mainly). */
|
||||
#ifdef ENABLE_COMMENT
|
||||
char *comment;
|
||||
/* The line comment prefix (and postfix) for this type of file. */
|
||||
#endif
|
||||
colortype *color;
|
||||
/* The colors and their regexes used in this syntax. */
|
||||
int nmultis;
|
||||
@@ -404,7 +404,7 @@ typedef struct openfilestruct {
|
||||
/* The preceding open file, if any. */
|
||||
} openfilestruct;
|
||||
|
||||
#ifndef DISABLE_NANORC
|
||||
#ifdef ENABLE_NANORC
|
||||
typedef struct rcoption {
|
||||
const char *name;
|
||||
/* The name of the rcfile option. */
|
||||
@@ -442,7 +442,7 @@ typedef struct subnfunc {
|
||||
/* In what menus this function applies. */
|
||||
const char *desc;
|
||||
/* The function's short description, for example "Where Is". */
|
||||
#ifndef DISABLE_HELP
|
||||
#ifdef ENABLE_HELP
|
||||
const char *help;
|
||||
/* The help-screen text for this function. */
|
||||
bool blank_after;
|
||||
@@ -480,7 +480,7 @@ enum
|
||||
{
|
||||
DONTUSE,
|
||||
CASE_SENSITIVE,
|
||||
CONST_UPDATE,
|
||||
CONSTANT_SHOW,
|
||||
NO_HELP,
|
||||
SUSPEND,
|
||||
NO_WRAP,
|
||||
@@ -489,7 +489,7 @@ enum
|
||||
USE_MOUSE,
|
||||
USE_REGEXP,
|
||||
TEMP_FILE,
|
||||
CUT_TO_END,
|
||||
CUT_FROM_CURSOR,
|
||||
BACKWARDS_SEARCH,
|
||||
MULTIBUFFER,
|
||||
SMOOTH_SCROLL,
|
||||
@@ -519,7 +519,8 @@ enum
|
||||
JUSTIFY_TRIM,
|
||||
SHOW_CURSOR,
|
||||
LINE_NUMBERS,
|
||||
NO_PAUSES
|
||||
NO_PAUSES,
|
||||
AT_BLANKS
|
||||
};
|
||||
|
||||
/* Flags for the menus in which a given function should be present. */
|
||||
@@ -538,9 +539,15 @@ enum
|
||||
#define MGOTODIR (1<<12)
|
||||
#define MYESNO (1<<13)
|
||||
#define MLINTER (1<<14)
|
||||
#define MFINDINHELP (1<<15)
|
||||
/* This is an abbreviation for all menus except Help and YesNo. */
|
||||
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\
|
||||
MEXTCMD|MBROWSER|MWHEREISFILE|MGOTODIR|MSPELL|MLINTER)
|
||||
MEXTCMD|MBROWSER|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER)
|
||||
#ifndef NANO_TINY
|
||||
#define MSOME MMOST
|
||||
#else
|
||||
#define MSOME MMAIN|MBROWSER
|
||||
#endif
|
||||
|
||||
/* Basic control codes. */
|
||||
#define TAB_CODE 0x09
|
||||
@@ -569,6 +576,15 @@ enum
|
||||
#define SHIFT_HOME 0x40f
|
||||
#define SHIFT_END 0x410
|
||||
|
||||
#ifdef USE_SLANG
|
||||
#ifdef ENABLE_UTF8
|
||||
#define KEY_BAD 0xFF /* Clipped error code. */
|
||||
#endif
|
||||
#define KEY_FLUSH 0x91 /* User-definable control code. */
|
||||
#else
|
||||
#define KEY_FLUSH KEY_F0 /* Nonexistent function key. */
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* An imaginary key for when we get a SIGWINCH (window resize). */
|
||||
#define KEY_WINCH -2
|
||||
@@ -591,6 +607,9 @@ enum
|
||||
/* The default width of a tab in spaces. */
|
||||
#define WIDTH_OF_TAB 8
|
||||
|
||||
/* The default comment character when a syntax does not specify any. */
|
||||
#define GENERAL_COMMENT_CHARACTER "#"
|
||||
|
||||
/* The maximum number of search/replace history strings saved, not
|
||||
* counting the blank lines at their ends. */
|
||||
#define MAX_SEARCH_HISTORY 100
|
||||
|
||||
71
src/prompt.c
71
src/prompt.c
@@ -57,7 +57,7 @@ int do_statusbar_input(bool *ran_func, bool *finished)
|
||||
return KEY_WINCH;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef ENABLE_MOUSE
|
||||
/* If we got a mouse click and it was on a shortcut, read in the
|
||||
* shortcut character. */
|
||||
if (input == KEY_MOUSE) {
|
||||
@@ -95,7 +95,7 @@ int do_statusbar_input(bool *ran_func, bool *finished)
|
||||
kbinput = (int *)nrealloc(kbinput, kbinput_len * sizeof(int));
|
||||
kbinput[kbinput_len - 1] = input;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If we got a shortcut, or if there aren't any other keystrokes waiting
|
||||
* after the one we read in, we need to insert all the characters in the
|
||||
@@ -137,9 +137,9 @@ int do_statusbar_input(bool *ran_func, bool *finished)
|
||||
s->scfunc == do_delete ||
|
||||
s->scfunc == do_backspace))
|
||||
;
|
||||
else if (s->scfunc == do_verbatim_input) {
|
||||
else if (s->scfunc == do_verbatim_input)
|
||||
do_statusbar_verbatim_input();
|
||||
} else if (s->scfunc == do_cut_text_void)
|
||||
else if (s->scfunc == do_cut_text_void)
|
||||
do_statusbar_cut_text();
|
||||
else if (s->scfunc == do_delete)
|
||||
do_statusbar_delete();
|
||||
@@ -164,7 +164,7 @@ int do_statusbar_input(bool *ran_func, bool *finished)
|
||||
return input;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef ENABLE_MOUSE
|
||||
/* Handle a mouse click on the statusbar prompt or the shortcut list. */
|
||||
int do_statusbar_mouse(void)
|
||||
{
|
||||
@@ -291,7 +291,7 @@ void do_statusbar_delete(void)
|
||||
/* Zap some or all text from the answer. */
|
||||
void do_statusbar_cut_text(void)
|
||||
{
|
||||
if (!ISSET(CUT_TO_END))
|
||||
if (!ISSET(CUT_FROM_CURSOR))
|
||||
statusbar_x = 0;
|
||||
|
||||
answer[statusbar_x] = '\0';
|
||||
@@ -383,35 +383,18 @@ void reinit_statusbar_x(void)
|
||||
statusbar_x = HIGHEST_POSITIVE;
|
||||
}
|
||||
|
||||
/* Put the cursor in the answer at statusbar_x. */
|
||||
void reset_statusbar_cursor(void)
|
||||
{
|
||||
size_t start_col = strlenpt(prompt) + 2;
|
||||
size_t xpt = statusbar_xplustabs();
|
||||
|
||||
/* Work around a cursor-misplacement bug in VTEs. */
|
||||
wmove(bottomwin, 0, 0);
|
||||
wnoutrefresh(bottomwin);
|
||||
doupdate();
|
||||
|
||||
wmove(bottomwin, 0, start_col + xpt -
|
||||
get_statusbar_page_start(start_col, start_col + xpt));
|
||||
|
||||
wnoutrefresh(bottomwin);
|
||||
}
|
||||
|
||||
/* Repaint the statusbar. */
|
||||
/* Redraw the promptbar and place the cursor at the right spot. */
|
||||
void update_the_statusbar(void)
|
||||
{
|
||||
size_t base, the_page, end_page;
|
||||
size_t base = strlenpt(prompt) + 2;
|
||||
size_t the_page, end_page, column;
|
||||
char *expanded;
|
||||
|
||||
base = strlenpt(prompt) + 2;
|
||||
the_page = get_statusbar_page_start(base, base + strnlenpt(answer, statusbar_x));
|
||||
end_page = get_statusbar_page_start(base, base + strlenpt(answer) - 1);
|
||||
|
||||
/* Color the promptbar over its full width. */
|
||||
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
|
||||
blank_statusbar();
|
||||
|
||||
mvwaddstr(bottomwin, 0, 0, prompt);
|
||||
@@ -426,7 +409,14 @@ void update_the_statusbar(void)
|
||||
|
||||
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
|
||||
reset_statusbar_cursor();
|
||||
/* Work around a cursor-misplacement bug in VTEs. */
|
||||
wmove(bottomwin, 0, 0);
|
||||
wrefresh(bottomwin);
|
||||
|
||||
/* Place the cursor at statusbar_x in the answer. */
|
||||
column = base + statusbar_xplustabs();
|
||||
wmove(bottomwin, 0, column - get_statusbar_page_start(base, column));
|
||||
wnoutrefresh(bottomwin);
|
||||
}
|
||||
|
||||
/* Get a string of input at the statusbar prompt. */
|
||||
@@ -440,7 +430,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
int kbinput = ERR;
|
||||
bool ran_func, finished;
|
||||
functionptrtype func;
|
||||
#ifndef DISABLE_TABCOMP
|
||||
#ifdef ENABLE_TABCOMP
|
||||
bool tabbed = FALSE;
|
||||
/* Whether we've pressed Tab. */
|
||||
#endif
|
||||
@@ -450,7 +440,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
char *magichistory = NULL;
|
||||
/* The temporary string typed at the bottom of the history, if
|
||||
* any. */
|
||||
#ifndef DISABLE_TABCOMP
|
||||
#ifdef ENABLE_TABCOMP
|
||||
int last_kbinput = ERR;
|
||||
/* The key we pressed before the current key. */
|
||||
size_t complete_len = 0;
|
||||
@@ -468,10 +458,6 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
|
||||
update_the_statusbar();
|
||||
|
||||
/* Refresh edit window and statusbar before getting input. */
|
||||
wnoutrefresh(edit);
|
||||
wnoutrefresh(bottomwin);
|
||||
|
||||
while (TRUE) {
|
||||
/* Ensure the cursor is shown when waiting for input. */
|
||||
curs_set(1);
|
||||
@@ -495,7 +481,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
if (func == do_cancel || func == do_enter)
|
||||
break;
|
||||
|
||||
#ifndef DISABLE_TABCOMP
|
||||
#ifdef ENABLE_TABCOMP
|
||||
if (func != do_tab)
|
||||
tabbed = FALSE;
|
||||
|
||||
@@ -516,7 +502,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
answer = input_tab(answer, allow_files, &statusbar_x,
|
||||
&tabbed, refresh_func, listed);
|
||||
} else
|
||||
#endif /* !DISABLE_TABCOMP */
|
||||
#endif /* ENABLE_TABCOMP */
|
||||
#ifndef DISABLE_HISTORIES
|
||||
if (func == get_history_older_void) {
|
||||
if (history_list != NULL) {
|
||||
@@ -580,7 +566,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
|
||||
update_the_statusbar();
|
||||
|
||||
#if !defined(DISABLE_HISTORIES) && !defined(DISABLE_TABCOMP)
|
||||
#if !defined(DISABLE_HISTORIES) && defined(ENABLE_TABCOMP)
|
||||
last_kbinput = kbinput;
|
||||
#endif
|
||||
}
|
||||
@@ -620,8 +606,9 @@ int do_prompt(bool allow_tabs, bool allow_files,
|
||||
int retval;
|
||||
functionptrtype func = NULL;
|
||||
bool listed = FALSE;
|
||||
/* Save a possible current statusbar x position. */
|
||||
/* Save a possible current statusbar x position and prompt. */
|
||||
size_t was_statusbar_x = statusbar_x;
|
||||
char *saved_prompt = prompt;
|
||||
|
||||
bottombars(menu);
|
||||
|
||||
@@ -644,7 +631,7 @@ int do_prompt(bool allow_tabs, bool allow_files,
|
||||
refresh_func);
|
||||
|
||||
free(prompt);
|
||||
prompt = NULL;
|
||||
prompt = saved_prompt;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (retval == KEY_WINCH)
|
||||
@@ -670,7 +657,7 @@ int do_prompt(bool allow_tabs, bool allow_files,
|
||||
fprintf(stderr, "answer = \"%s\"\n", answer);
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_TABCOMP
|
||||
#ifdef ENABLE_TABCOMP
|
||||
/* If we've done tab completion, there might still be a list of
|
||||
* filename matches on the edit window. Clear them off. */
|
||||
if (listed)
|
||||
@@ -751,7 +738,7 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
|
||||
if (func == do_cancel)
|
||||
response = -1;
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef ENABLE_MOUSE
|
||||
else if (kbinput == KEY_MOUSE) {
|
||||
int mouse_x, mouse_y;
|
||||
/* We can click on the Yes/No/All shortcuts to select an answer. */
|
||||
@@ -773,7 +760,7 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
response = -2;
|
||||
}
|
||||
}
|
||||
#endif /* !DISABLE_MOUSE */
|
||||
#endif /* ENABLE_MOUSE */
|
||||
else {
|
||||
/* Look for the kbinput in the Yes, No (and All) strings. */
|
||||
if (strchr(yesstr, kbinput) != NULL)
|
||||
|
||||
117
src/proto.h
117
src/proto.h
@@ -24,6 +24,7 @@
|
||||
#include "nano.h"
|
||||
|
||||
/* All external variables. See global.c for their descriptions. */
|
||||
|
||||
#ifndef NANO_TINY
|
||||
extern volatile sig_atomic_t the_window_resized;
|
||||
#endif
|
||||
@@ -42,10 +43,21 @@ extern bool as_an_at;
|
||||
extern int margin;
|
||||
extern int editwincols;
|
||||
|
||||
#ifndef DISABLE_COLOR
|
||||
extern bool have_palette;
|
||||
#endif
|
||||
|
||||
extern bool suppress_cursorpos;
|
||||
|
||||
extern message_type lastmessage;
|
||||
|
||||
extern filestruct *pletion_line;
|
||||
|
||||
extern bool inhelp;
|
||||
extern char *title;
|
||||
|
||||
extern int didfind;
|
||||
|
||||
extern int controlleft;
|
||||
extern int controlright;
|
||||
extern int controlup;
|
||||
@@ -109,8 +121,6 @@ extern char *quoteerr;
|
||||
|
||||
extern char *word_chars;
|
||||
|
||||
extern bool nodelay_mode;
|
||||
|
||||
extern char *answer;
|
||||
|
||||
extern ssize_t tabsize;
|
||||
@@ -166,7 +176,7 @@ extern char *homedir;
|
||||
typedef void (*functionptrtype)(void);
|
||||
|
||||
/* Most functions in browser.c. */
|
||||
#ifndef DISABLE_BROWSER
|
||||
#ifdef ENABLE_BROWSER
|
||||
char *do_browse_from(const char *inpath);
|
||||
void read_the_list(const char *path, DIR *dir);
|
||||
functionptrtype parse_browser_input(int *kbinput);
|
||||
@@ -202,9 +212,9 @@ int mbstrcasecmp(const char *s1, const char *s2);
|
||||
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 *pointer);
|
||||
char *mbrevstrcasestr(const char *haystack, const char *needle, const
|
||||
char *rev_start);
|
||||
const char *index);
|
||||
char *mbrevstrcasestr(const char *haystack, const char *needle,
|
||||
const char *index);
|
||||
size_t mbstrlen(const char *s);
|
||||
size_t mbstrnlen(const char *s, size_t maxlen);
|
||||
#if !defined(NANO_TINY) || !defined(DISABLE_JUSTIFY)
|
||||
@@ -212,18 +222,16 @@ char *mbstrchr(const char *s, const char *c);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
char *mbstrpbrk(const char *s, const char *accept);
|
||||
char *revstrpbrk(const char *s, const char *accept, const char
|
||||
*rev_start);
|
||||
char *mbrevstrpbrk(const char *s, const char *accept, const char
|
||||
*rev_start);
|
||||
char *revstrpbrk(const char *head, const char *accept, const char *index);
|
||||
char *mbrevstrpbrk(const char *head, const char *accept, const char *index);
|
||||
#endif
|
||||
#if !defined(DISABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
|
||||
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
|
||||
bool has_blank_mbchars(const char *s);
|
||||
#endif
|
||||
#ifdef ENABLE_UTF8
|
||||
bool is_valid_unicode(wchar_t wc);
|
||||
#endif
|
||||
#ifndef DISABLE_NANORC
|
||||
#ifdef ENABLE_NANORC
|
||||
bool is_valid_mbstring(const char *s);
|
||||
#endif
|
||||
|
||||
@@ -261,8 +269,8 @@ void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
|
||||
filestruct *bot, size_t bot_x);
|
||||
#endif
|
||||
#endif
|
||||
void display_buffer(void);
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
void prepare_for_display(void);
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
void switch_to_prev_buffer_void(void);
|
||||
void switch_to_next_buffer_void(void);
|
||||
bool close_buffer(void);
|
||||
@@ -296,11 +304,11 @@ void do_writeout_void(void);
|
||||
void do_savefile(void);
|
||||
#endif
|
||||
char *real_dir_from_tilde(const char *buf);
|
||||
#if !defined(DISABLE_TABCOMP) || !defined(DISABLE_BROWSER)
|
||||
#if defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
|
||||
int diralphasort(const void *va, const void *vb);
|
||||
void free_chararray(char **array, size_t len);
|
||||
#endif
|
||||
#ifndef DISABLE_TABCOMP
|
||||
#ifdef ENABLE_TABCOMP
|
||||
char *input_tab(char *buf, bool allow_files, size_t *place,
|
||||
bool *lastwastab, void (*refresh_func)(void), bool *listed);
|
||||
#endif
|
||||
@@ -336,7 +344,8 @@ void thanks_for_all_the_fish(void);
|
||||
#endif
|
||||
|
||||
/* All functions in help.c. */
|
||||
#ifndef DISABLE_HELP
|
||||
#ifdef ENABLE_HELP
|
||||
void wrap_the_help_text(bool redisplaying);
|
||||
void do_help(void);
|
||||
void help_init(void);
|
||||
functionptrtype parse_help_input(int *kbinput);
|
||||
@@ -350,16 +359,16 @@ void do_last_line(void);
|
||||
void do_page_up(void);
|
||||
void do_page_down(void);
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
void do_para_begin(bool allow_update);
|
||||
void do_para_begin(bool update_screen);
|
||||
void do_para_begin_void(void);
|
||||
void do_para_end(bool allow_update);
|
||||
void do_para_end(bool update_screen);
|
||||
void do_para_end_void(void);
|
||||
#endif
|
||||
void do_prev_block(void);
|
||||
void do_next_block(void);
|
||||
void do_prev_word(bool allow_punct, bool allow_update);
|
||||
void do_prev_word(bool allow_punct, bool update_screen);
|
||||
void do_prev_word_void(void);
|
||||
bool do_next_word(bool allow_punct, bool allow_update);
|
||||
bool do_next_word(bool allow_punct, bool update_screen);
|
||||
void do_next_word_void(void);
|
||||
void do_home(bool be_clever);
|
||||
void do_home_void(void);
|
||||
@@ -396,7 +405,7 @@ void unlink_opennode(openfilestruct *fileptr);
|
||||
void delete_opennode(openfilestruct *fileptr);
|
||||
void print_view_warning(void);
|
||||
void show_restricted_warning(void);
|
||||
#ifdef DISABLE_HELP
|
||||
#ifndef ENABLE_HELP
|
||||
void say_there_is_no_help(void);
|
||||
#endif
|
||||
void finish(void);
|
||||
@@ -421,13 +430,13 @@ void enable_flow_control(void);
|
||||
void terminal_init(void);
|
||||
void unbound_key(int code);
|
||||
int do_input(bool allow_funcs);
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef ENABLE_MOUSE
|
||||
int do_mouse(void);
|
||||
#endif
|
||||
void do_output(char *output, size_t output_len, bool allow_cntrls);
|
||||
|
||||
/* Most functions in prompt.c. */
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef ENABLE_MOUSE
|
||||
int do_statusbar_mouse(void);
|
||||
#endif
|
||||
void do_statusbar_output(int *the_input, size_t input_len,
|
||||
@@ -457,14 +466,14 @@ int do_prompt(bool allow_tabs, bool allow_files,
|
||||
int do_yesno_prompt(bool all, const char *msg);
|
||||
|
||||
/* Most functions in rcfile.c. */
|
||||
#ifndef DISABLE_NANORC
|
||||
#ifdef ENABLE_NANORC
|
||||
#ifndef DISABLE_COLOR
|
||||
bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright);
|
||||
void grab_and_store(const char *kind, char *ptr, regexlisttype **storage);
|
||||
#endif
|
||||
void parse_rcfile(FILE *rcstream, bool syntax_only);
|
||||
void do_rcfiles(void);
|
||||
#endif /* !DISABLE_NANORC */
|
||||
#endif /* ENABLE_NANORC */
|
||||
|
||||
/* Most functions in search.c. */
|
||||
void not_found_msg(const char *str);
|
||||
@@ -487,7 +496,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
void do_gotolinecolumn_void(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_find_bracket(void);
|
||||
#ifndef DISABLE_TABCOMP
|
||||
#ifdef ENABLE_TABCOMP
|
||||
char *get_history_completion(filestruct **h, char *s, size_t len);
|
||||
#endif
|
||||
#endif
|
||||
@@ -514,8 +523,7 @@ void do_cut_next_word(void);
|
||||
#endif
|
||||
void do_tab(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_indent(ssize_t cols);
|
||||
void do_indent_void(void);
|
||||
void do_indent(void);
|
||||
void do_unindent(void);
|
||||
#endif
|
||||
bool white_string(const char *s);
|
||||
@@ -531,7 +539,7 @@ RETSIGTYPE cancel_command(int signal);
|
||||
bool execute_command(const char *command);
|
||||
void discard_until(const undo *thisitem, openfilestruct *thefile);
|
||||
void add_undo(undo_type action);
|
||||
#ifndef DISABLE_COMMENT
|
||||
#ifdef ENABLE_COMMENT
|
||||
void update_comment_undo(ssize_t lineno);
|
||||
#endif
|
||||
void update_undo(undo_type action);
|
||||
@@ -540,7 +548,7 @@ void update_undo(undo_type action);
|
||||
void wrap_reset(void);
|
||||
bool do_wrap(filestruct *line);
|
||||
#endif
|
||||
#if !defined(DISABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
|
||||
#if defined(ENABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
|
||||
ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl);
|
||||
#endif
|
||||
#if !defined(NANO_TINY) || !defined(DISABLE_JUSTIFY)
|
||||
@@ -596,8 +604,10 @@ size_t actual_x(const char *s, size_t column);
|
||||
size_t strnlenpt(const char *s, size_t maxlen);
|
||||
size_t strlenpt(const char *s);
|
||||
void new_magicline(void);
|
||||
#ifndef NANO_TINY
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
|
||||
void remove_magicline(void);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
void mark_order(const filestruct **top, size_t *top_x, const filestruct
|
||||
**bot, size_t *bot_x, bool *right_side_up);
|
||||
#endif
|
||||
@@ -622,7 +632,7 @@ int get_byte_kbinput(int kbinput);
|
||||
int get_control_kbinput(int kbinput);
|
||||
int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len);
|
||||
int *parse_verbatim_kbinput(WINDOW *win, size_t *count);
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef ENABLE_MOUSE
|
||||
int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts);
|
||||
#endif
|
||||
const sc *get_shortcut(int *kbinput);
|
||||
@@ -631,8 +641,7 @@ void blank_edit(void);
|
||||
void blank_statusbar(void);
|
||||
void blank_bottombars(void);
|
||||
void check_statusblank(void);
|
||||
char *display_string(const char *buf, size_t start_col, size_t span,
|
||||
bool dollars);
|
||||
char *display_string(const char *buf, size_t column, size_t span, bool isdata);
|
||||
void titlebar(const char *path);
|
||||
extern void set_modified(void);
|
||||
void statusbar(const char *msg);
|
||||
@@ -640,7 +649,7 @@ void warn_and_shortly_pause(const char *msg);
|
||||
void statusline(message_type importance, const char *msg, ...);
|
||||
void bottombars(int menu);
|
||||
void onekey(const char *keystroke, const char *desc, int length);
|
||||
void reset_cursor(void);
|
||||
void place_the_cursor(bool forreal);
|
||||
void edit_draw(filestruct *fileptr, const char *converted,
|
||||
int line, size_t from_col);
|
||||
int update_line(filestruct *fileptr, size_t index);
|
||||
@@ -652,7 +661,16 @@ int go_back_chunks(int nrows, filestruct **line, size_t *leftedge);
|
||||
int go_forward_chunks(int nrows, filestruct **line, size_t *leftedge);
|
||||
bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge);
|
||||
void edit_scroll(scroll_dir direction, int nrows);
|
||||
#ifndef NANO_TINY
|
||||
size_t get_softwrap_breakpoint(const char *text, size_t leftedge,
|
||||
bool *end_of_line);
|
||||
size_t get_chunk_and_edge(size_t column, filestruct *line, size_t *leftedge);
|
||||
size_t chunk_for(size_t column, filestruct *line);
|
||||
size_t leftedge_for(size_t column, filestruct *line);
|
||||
size_t number_of_chunks_in(filestruct *line);
|
||||
void ensure_firstcolumn_is_aligned(void);
|
||||
#endif
|
||||
size_t actual_last_column(size_t leftedge, size_t column);
|
||||
void edit_redraw(filestruct *old_current);
|
||||
void edit_refresh(void);
|
||||
void adjust_viewport(update_type location);
|
||||
@@ -661,32 +679,41 @@ void total_refresh(void);
|
||||
void display_main_list(void);
|
||||
void do_cursorpos(bool force);
|
||||
void do_cursorpos_void(void);
|
||||
void spotlight(bool active, const char *word);
|
||||
void spotlight(bool active, size_t from_col, size_t to_col);
|
||||
#ifndef NANO_TINY
|
||||
void spotlight_softwrapped(bool active, size_t from_col, size_t to_col);
|
||||
#endif
|
||||
void xon_complaint(void);
|
||||
void xoff_complaint(void);
|
||||
void do_suspend_void(void);
|
||||
void enable_nodelay(void);
|
||||
void disable_nodelay(void);
|
||||
void disable_waiting(void);
|
||||
void enable_waiting(void);
|
||||
#ifndef DISABLE_EXTRA
|
||||
void do_credits(void);
|
||||
#endif
|
||||
|
||||
/* May as well throw these here, since they are just placeholders. */
|
||||
/* These are just name definitions. */
|
||||
void do_cancel(void);
|
||||
void case_sens_void(void);
|
||||
void regexp_void(void);
|
||||
void backwards_void(void);
|
||||
void flip_replace(void);
|
||||
void gototext_void(void);
|
||||
#ifdef ENABLE_BROWSER
|
||||
void to_files_void(void);
|
||||
void goto_dir_void(void);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
void dos_format_void(void);
|
||||
void mac_format_void(void);
|
||||
void append_void(void);
|
||||
void prepend_void(void);
|
||||
void backup_file_void(void);
|
||||
void flip_execute(void);
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
void flip_newbuffer(void);
|
||||
#endif
|
||||
void discard_buffer(void);
|
||||
void new_buffer_void(void);
|
||||
void backwards_void(void);
|
||||
void goto_dir_void(void);
|
||||
void flip_replace_void(void);
|
||||
void flip_execute_void(void);
|
||||
|
||||
#endif /* !PROTO_H */
|
||||
|
||||
102
src/rcfile.c
102
src/rcfile.c
@@ -30,7 +30,7 @@
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef DISABLE_NANORC
|
||||
#ifdef ENABLE_NANORC
|
||||
|
||||
#ifndef RCFILE_NAME
|
||||
#define RCFILE_NAME ".nanorc"
|
||||
@@ -44,8 +44,8 @@ static const rcoption rcopts[] = {
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
{"brackets", 0},
|
||||
#endif
|
||||
{"const", CONST_UPDATE}, /* deprecated form, remove in 2018 */
|
||||
{"constantshow", CONST_UPDATE},
|
||||
{"const", CONSTANT_SHOW}, /* deprecated form, remove in 2018 */
|
||||
{"constantshow", CONSTANT_SHOW},
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
{"fill", 0},
|
||||
#endif
|
||||
@@ -53,10 +53,10 @@ static const rcoption rcopts[] = {
|
||||
{"historylog", HISTORYLOG},
|
||||
#endif
|
||||
{"morespace", MORE_SPACE},
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef ENABLE_MOUSE
|
||||
{"mouse", USE_MOUSE},
|
||||
#endif
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
{"multibuffer", MULTIBUFFER},
|
||||
#endif
|
||||
{"nohelp", NO_HELP},
|
||||
@@ -77,6 +77,7 @@ static const rcoption rcopts[] = {
|
||||
{"punct", 0},
|
||||
{"quotestr", 0},
|
||||
#endif
|
||||
{"quickblank", QUICK_BLANK},
|
||||
{"rebinddelete", REBIND_DELETE},
|
||||
{"rebindkeypad", REBIND_KEYPAD},
|
||||
{"regexp", USE_REGEXP},
|
||||
@@ -89,17 +90,18 @@ static const rcoption rcopts[] = {
|
||||
{"view", VIEW_MODE},
|
||||
#ifndef NANO_TINY
|
||||
{"allow_insecure_backup", INSECURE_BACKUP},
|
||||
{"atblanks", AT_BLANKS},
|
||||
{"autoindent", AUTOINDENT},
|
||||
{"backup", BACKUP_FILE},
|
||||
{"backupdir", 0},
|
||||
{"backwards", BACKWARDS_SEARCH},
|
||||
{"casesensitive", CASE_SENSITIVE},
|
||||
{"cut", CUT_TO_END},
|
||||
{"cut", CUT_FROM_CURSOR}, /* deprecated form, remove in 2020 */
|
||||
{"cutfromcursor", CUT_FROM_CURSOR},
|
||||
{"justifytrim", JUSTIFY_TRIM},
|
||||
{"locking", LOCKING},
|
||||
{"matchbrackets", 0},
|
||||
{"noconvert", NO_CONVERT},
|
||||
{"quickblank", QUICK_BLANK},
|
||||
{"quiet", QUIET},
|
||||
{"showcursor", SHOW_CURSOR},
|
||||
{"smarthome", SMART_HOME},
|
||||
@@ -159,9 +161,9 @@ void rcfile_error(const char *msg, ...)
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
#endif /* !DISABLE_NANORC */
|
||||
#endif /* ENABLE_NANORC */
|
||||
|
||||
#if !defined(DISABLE_NANORC) || !defined(DISABLE_HISTORIES)
|
||||
#if defined(ENABLE_NANORC) || !defined(DISABLE_HISTORIES)
|
||||
/* Parse the next word from the string, null-terminate it, and return
|
||||
* a pointer to the first character after the null terminator. The
|
||||
* returned pointer will point to '\0' if we hit the end of the line. */
|
||||
@@ -181,9 +183,9 @@ char *parse_next_word(char *ptr)
|
||||
|
||||
return ptr;
|
||||
}
|
||||
#endif /* !DISABLE_NANORC || !DISABLE_HISTORIES */
|
||||
#endif /* ENABLE_NANORC || !DISABLE_HISTORIES */
|
||||
|
||||
#ifndef DISABLE_NANORC
|
||||
#ifdef ENABLE_NANORC
|
||||
/* Parse an argument, with optional quotes, after a keyword that takes
|
||||
* one. If the next word starts with a ", we say that it ends with the
|
||||
* last " of the line. Otherwise, we interpret it as usual, so that the
|
||||
@@ -315,7 +317,9 @@ void parse_syntax(char *ptr)
|
||||
live_syntax->magics = NULL;
|
||||
live_syntax->linter = NULL;
|
||||
live_syntax->formatter = NULL;
|
||||
live_syntax->comment = NULL;
|
||||
#ifdef ENABLE_COMMENT
|
||||
live_syntax->comment = mallocstrcpy(NULL, GENERAL_COMMENT_CHARACTER);
|
||||
#endif
|
||||
live_syntax->color = NULL;
|
||||
lastcolor = NULL;
|
||||
live_syntax->nmultis = 0;
|
||||
@@ -346,11 +350,13 @@ void parse_syntax(char *ptr)
|
||||
/* Check whether the given executable function is "universal" (meaning
|
||||
* any horizontal movement or deletion) and thus is present in almost
|
||||
* all menus. */
|
||||
bool is_universal(void (*func))
|
||||
bool is_universal(void (*func)(void))
|
||||
{
|
||||
if (func == do_left || func == do_right ||
|
||||
func == do_home_void || func == do_end_void ||
|
||||
#ifndef NANO_TINY
|
||||
func == do_prev_word_void || func == do_next_word_void ||
|
||||
#endif
|
||||
func == do_verbatim_input || func == do_cut_text_void ||
|
||||
func == do_delete || func == do_backspace ||
|
||||
func == do_tab || func == do_enter)
|
||||
@@ -607,8 +613,6 @@ void parse_includes(char *ptr)
|
||||
* and set bright to TRUE if that color is bright. */
|
||||
short color_to_short(const char *colorname, bool *bright)
|
||||
{
|
||||
assert(colorname != NULL && bright != NULL);
|
||||
|
||||
if (strncasecmp(colorname, "bright", 6) == 0) {
|
||||
*bright = TRUE;
|
||||
colorname += 6;
|
||||
@@ -648,8 +652,6 @@ void parse_colors(char *ptr, int rex_flags)
|
||||
bool bright = FALSE;
|
||||
char *item;
|
||||
|
||||
assert(ptr != NULL);
|
||||
|
||||
if (!opensyntax) {
|
||||
rcfile_error(
|
||||
N_("A '%s' command requires a preceding 'syntax' command"),
|
||||
@@ -723,9 +725,6 @@ void parse_colors(char *ptr, int rex_flags)
|
||||
|
||||
newcolor->next = NULL;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Adding an entry for fg %hd, bg %hd\n", fg, bg);
|
||||
#endif
|
||||
if (lastcolor == NULL)
|
||||
live_syntax->color = newcolor;
|
||||
else
|
||||
@@ -776,33 +775,22 @@ void parse_colors(char *ptr, int rex_flags)
|
||||
/* Parse the color name, or pair of color names, in combostr. */
|
||||
bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright)
|
||||
{
|
||||
bool no_fgcolor = FALSE;
|
||||
char *comma = strchr(combostr, ',');
|
||||
|
||||
if (combostr == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (strchr(combostr, ',') != NULL) {
|
||||
char *bgcolorname;
|
||||
strtok(combostr, ",");
|
||||
bgcolorname = strtok(NULL, ",");
|
||||
if (bgcolorname == NULL) {
|
||||
/* If we have a background color without a foreground color,
|
||||
* parse it properly. */
|
||||
bgcolorname = combostr + 1;
|
||||
no_fgcolor = TRUE;
|
||||
}
|
||||
if (strncasecmp(bgcolorname, "bright", 6) == 0) {
|
||||
rcfile_error(N_("Background color \"%s\" cannot be bright"), bgcolorname);
|
||||
if (comma != NULL) {
|
||||
*bg = color_to_short(comma + 1, bright);
|
||||
if (*bright) {
|
||||
rcfile_error(N_("A background color cannot be bright"));
|
||||
return FALSE;
|
||||
}
|
||||
*bg = color_to_short(bgcolorname, bright);
|
||||
*comma = '\0';
|
||||
} else
|
||||
*bg = -1;
|
||||
|
||||
if (!no_fgcolor) {
|
||||
if (comma != combostr) {
|
||||
*fg = color_to_short(combostr, bright);
|
||||
|
||||
/* Don't try to parse screwed-up foreground colors. */
|
||||
/* If the specified foreground color is bad, ignore the regexes. */
|
||||
if (*fg == -1)
|
||||
return FALSE;
|
||||
} else
|
||||
@@ -875,7 +863,7 @@ void grab_and_store(const char *kind, char *ptr, regexlisttype **storage)
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse and store the name given after a linter/formatter command. */
|
||||
/* Gather and store the string after a comment/linter/formatter command. */
|
||||
void pick_up_name(const char *kind, char *ptr, char **storage)
|
||||
{
|
||||
assert(ptr != NULL);
|
||||
@@ -887,35 +875,27 @@ void pick_up_name(const char *kind, char *ptr, char **storage)
|
||||
}
|
||||
|
||||
if (*ptr == '\0') {
|
||||
rcfile_error(N_("Missing command after '%s'"), kind);
|
||||
rcfile_error(N_("Missing argument after '%s'"), kind);
|
||||
return;
|
||||
}
|
||||
|
||||
free(*storage);
|
||||
/* If the argument starts with a quote, find the terminating quote. */
|
||||
if (*ptr == '"') {
|
||||
char *look = ++ptr;
|
||||
|
||||
/* Allow unsetting the command by using an empty string. */
|
||||
if (!strcmp(ptr, "\"\""))
|
||||
*storage = NULL;
|
||||
else if (*ptr == '"') {
|
||||
*storage = mallocstrcpy(NULL, ++ptr);
|
||||
char* q = *storage;
|
||||
char* p = *storage;
|
||||
/* Snip out the backslashes of escaped characters. */
|
||||
while (*p != '"') {
|
||||
if (*p == '\0') {
|
||||
look += strlen(ptr);
|
||||
|
||||
while (*look != '"') {
|
||||
if (--look < ptr) {
|
||||
rcfile_error(N_("Argument of '%s' lacks closing \""), kind);
|
||||
free(*storage);
|
||||
*storage = NULL;
|
||||
return;
|
||||
} else if (*p == '\\' && *(p + 1) != '\0') {
|
||||
p++;
|
||||
}
|
||||
*q++ = *p++;
|
||||
}
|
||||
*q = '\0';
|
||||
*look = '\0';
|
||||
}
|
||||
else
|
||||
*storage = mallocstrcpy(NULL, ptr);
|
||||
|
||||
*storage = mallocstrcpy(*storage, ptr);
|
||||
|
||||
}
|
||||
#endif /* !DISABLE_COLOR */
|
||||
|
||||
@@ -1300,4 +1280,4 @@ void do_rcfiles(void)
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* !DISABLE_NANORC */
|
||||
#endif /* ENABLE_NANORC */
|
||||
|
||||
57
src/search.c
57
src/search.c
@@ -143,7 +143,8 @@ int search_init(bool replacing, bool use_answer)
|
||||
|
||||
/* This is now one simple call. It just does a lot. */
|
||||
i = do_prompt(FALSE, FALSE,
|
||||
replacing ? MREPLACE : MWHEREIS, backupstring,
|
||||
inhelp ? MFINDINHELP : (replacing ? MREPLACE : MWHEREIS),
|
||||
backupstring,
|
||||
#ifndef DISABLE_HISTORIES
|
||||
&search_history,
|
||||
#endif
|
||||
@@ -201,7 +202,7 @@ int search_init(bool replacing, bool use_answer)
|
||||
TOGGLE(USE_REGEXP);
|
||||
backupstring = mallocstrcpy(backupstring, answer);
|
||||
return 1;
|
||||
} else if (func == do_replace || func == flip_replace_void) {
|
||||
} else if (func == flip_replace) {
|
||||
backupstring = mallocstrcpy(backupstring, answer);
|
||||
return -2; /* Call the opposite search function. */
|
||||
} else if (func == do_gotolinecolumn_void) {
|
||||
@@ -233,8 +234,10 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region,
|
||||
size_t found_x;
|
||||
/* The x coordinate of a found occurrence. */
|
||||
time_t lastkbcheck = time(NULL);
|
||||
/* The time we last looked at the keyboard. */
|
||||
|
||||
enable_nodelay();
|
||||
/* Set non-blocking input so that we can just peek for a Cancel. */
|
||||
disable_waiting();
|
||||
|
||||
if (begin == NULL)
|
||||
came_full_circle = FALSE;
|
||||
@@ -251,7 +254,7 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region,
|
||||
while (input) {
|
||||
if (func_from_key(&input) == do_cancel) {
|
||||
statusbar(_("Cancelled"));
|
||||
disable_nodelay();
|
||||
enable_waiting();
|
||||
return -2;
|
||||
}
|
||||
input = parse_kbinput(NULL);
|
||||
@@ -302,7 +305,7 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region,
|
||||
/* If we're back at the beginning, then there is no needle. */
|
||||
if (came_full_circle) {
|
||||
not_found_msg(needle);
|
||||
disable_nodelay();
|
||||
enable_waiting();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -316,7 +319,7 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region,
|
||||
* but stop when spell-checking or replacing in a region. */
|
||||
if (line == NULL) {
|
||||
if (whole_word_only || have_region) {
|
||||
disable_nodelay();
|
||||
enable_waiting();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -342,16 +345,15 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region,
|
||||
|
||||
found_x = found - line->data;
|
||||
|
||||
enable_waiting();
|
||||
|
||||
/* Ensure that the found occurrence is not beyond the starting x. */
|
||||
if (came_full_circle && ((!ISSET(BACKWARDS_SEARCH) && found_x > begin_x) ||
|
||||
(ISSET(BACKWARDS_SEARCH) && found_x < begin_x))) {
|
||||
not_found_msg(needle);
|
||||
disable_nodelay();
|
||||
return 0;
|
||||
}
|
||||
|
||||
disable_nodelay();
|
||||
|
||||
/* Set the current position to point at what we found. */
|
||||
openfile->current = line;
|
||||
openfile->current_x = found_x;
|
||||
@@ -360,8 +362,11 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region,
|
||||
if (match_len != NULL)
|
||||
*match_len = found_len;
|
||||
|
||||
if (feedback > 0)
|
||||
/* Wipe the "Searching..." message and unset the suppression flag. */
|
||||
if (feedback > 0) {
|
||||
blank_statusbar();
|
||||
suppress_cursorpos = FALSE;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -437,7 +442,6 @@ void go_looking(void)
|
||||
{
|
||||
filestruct *was_current = openfile->current;
|
||||
size_t was_current_x = openfile->current_x;
|
||||
int didfind;
|
||||
#ifdef DEBUG
|
||||
clock_t start = clock();
|
||||
#endif
|
||||
@@ -610,10 +614,9 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
numreplaced = 0;
|
||||
|
||||
if (!replaceall) {
|
||||
size_t xpt = xplustabs();
|
||||
char *exp_word = display_string(openfile->current->data,
|
||||
xpt, strnlenpt(openfile->current->data,
|
||||
openfile->current_x + match_len) - xpt, FALSE);
|
||||
size_t from_col = xplustabs();
|
||||
size_t to_col = strnlenpt(openfile->current->data,
|
||||
openfile->current_x + match_len);
|
||||
|
||||
/* Refresh the edit window, scrolling it if necessary. */
|
||||
edit_refresh();
|
||||
@@ -621,14 +624,12 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
/* Don't show cursor, to not distract from highlighted match. */
|
||||
curs_set(0);
|
||||
|
||||
spotlight(TRUE, exp_word);
|
||||
spotlight(TRUE, from_col, to_col);
|
||||
|
||||
/* TRANSLATORS: This is a prompt. */
|
||||
i = do_yesno_prompt(TRUE, _("Replace this instance?"));
|
||||
|
||||
spotlight(FALSE, exp_word);
|
||||
|
||||
free(exp_word);
|
||||
spotlight(FALSE, from_col, to_col);
|
||||
|
||||
if (i == -1) /* The replacing was cancelled. */
|
||||
break;
|
||||
@@ -855,10 +856,10 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (line < 1)
|
||||
if (line == 0)
|
||||
line = openfile->current->lineno;
|
||||
|
||||
if (column < 1)
|
||||
if (column == 0)
|
||||
column = openfile->placewewant + 1;
|
||||
}
|
||||
|
||||
@@ -883,6 +884,12 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
openfile->current_x = actual_x(openfile->current->data, column - 1);
|
||||
openfile->placewewant = column - 1;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP) && openfile->placewewant / editwincols >
|
||||
strlenpt(openfile->current->data) / editwincols)
|
||||
openfile->placewewant = strlenpt(openfile->current->data);
|
||||
#endif
|
||||
|
||||
/* When the position was manually given, center the target line. */
|
||||
if (interactive) {
|
||||
adjust_viewport(CENTERING);
|
||||
@@ -893,7 +900,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
filestruct *line = openfile->current;
|
||||
size_t leftedge = (xplustabs() / editwincols) * editwincols;
|
||||
size_t leftedge = leftedge_for(xplustabs(), openfile->current);
|
||||
|
||||
rows_from_tail = (editwinrows / 2) -
|
||||
go_forward_chunks(editwinrows / 2, &line, &leftedge);
|
||||
@@ -905,7 +912,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
/* If the target line is close to the tail of the file, put the last
|
||||
* line or chunk on the bottom line of the screen; otherwise, just
|
||||
* center the target line. */
|
||||
if (rows_from_tail < editwinrows / 2) {
|
||||
if (rows_from_tail < editwinrows / 2 && ISSET(SMOOTH_SCROLL)) {
|
||||
openfile->current_y = editwinrows - 1 - rows_from_tail;
|
||||
adjust_viewport(STATIONARY);
|
||||
} else
|
||||
@@ -1224,7 +1231,7 @@ void get_history_older_void(void)
|
||||
;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_TABCOMP
|
||||
#ifdef ENABLE_TABCOMP
|
||||
/* Move h to the next string that's a tab completion of the string s,
|
||||
* looking at only the first len characters of s, and return that
|
||||
* string. If there isn't one, or if len is 0, don't move h and return
|
||||
@@ -1277,5 +1284,5 @@ char *get_history_completion(filestruct **h, char *s, size_t len)
|
||||
* match, or len is 0. Return s. */
|
||||
return (char *)s;
|
||||
}
|
||||
#endif /* !DISABLE_TABCOMP */
|
||||
#endif /* ENSABLE_TABCOMP */
|
||||
#endif /* !DISABLE_HISTORIES */
|
||||
|
||||
350
src/text.c
350
src/text.c
@@ -91,7 +91,7 @@ char *invocation_error(const char *name)
|
||||
void do_deletion(undo_type action)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
size_t orig_rows = 0;
|
||||
size_t old_amount = 0;
|
||||
#endif
|
||||
|
||||
assert(openfile->current != NULL && openfile->current->data != NULL &&
|
||||
@@ -112,7 +112,7 @@ void do_deletion(undo_type action)
|
||||
update_undo(action);
|
||||
|
||||
if (ISSET(SOFTWRAP))
|
||||
orig_rows = strlenpt(openfile->current->data) / editwincols;
|
||||
old_amount = number_of_chunks_in(openfile->current);
|
||||
#endif
|
||||
|
||||
/* Move the remainder of the line "in", over the current character. */
|
||||
@@ -181,7 +181,7 @@ void do_deletion(undo_type action)
|
||||
/* If the number of screen rows that a softwrapped line occupies
|
||||
* has changed, we need a full refresh. */
|
||||
if (ISSET(SOFTWRAP) && refresh_needed == FALSE &&
|
||||
strlenpt(openfile->current->data) / editwincols != orig_rows)
|
||||
number_of_chunks_in(openfile->current) != old_amount)
|
||||
refresh_needed = TRUE;
|
||||
#endif
|
||||
|
||||
@@ -277,17 +277,11 @@ void do_tab(void)
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Indent or unindent the current line (or, if the mark is on, all lines
|
||||
* covered by the mark) len columns, depending on whether len is
|
||||
* positive or negative. If the TABS_TO_SPACES flag is set, indent or
|
||||
* unindent by len spaces. Otherwise, indent or unindent by (len /
|
||||
* tabsize) tabs and (len % tabsize) spaces. */
|
||||
void do_indent(ssize_t cols)
|
||||
/* Indent the current line (or the marked lines) by tabsize columns.
|
||||
* This inserts either a tab character or a tab's worth of spaces,
|
||||
* depending on whether --tabstospaces is in effect. */
|
||||
void do_indent(void)
|
||||
{
|
||||
bool indent_changed = FALSE;
|
||||
/* Whether any indenting or unindenting was done. */
|
||||
bool unindent = FALSE;
|
||||
/* Whether we're unindenting text. */
|
||||
char *line_indent = NULL;
|
||||
/* The text added to each line in order to indent it. */
|
||||
size_t line_indent_len = 0;
|
||||
@@ -298,19 +292,6 @@ void do_indent(ssize_t cols)
|
||||
|
||||
assert(openfile->current != NULL && openfile->current->data != NULL);
|
||||
|
||||
/* If cols is zero, get out. */
|
||||
if (cols == 0)
|
||||
return;
|
||||
|
||||
/* If cols is negative, make it positive and set unindent to TRUE. */
|
||||
if (cols < 0) {
|
||||
cols = -cols;
|
||||
unindent = TRUE;
|
||||
/* Otherwise, we're indenting, in which case the file will always be
|
||||
* modified, so set indent_changed to TRUE. */
|
||||
} else
|
||||
indent_changed = TRUE;
|
||||
|
||||
/* If the mark is on, use all lines covered by the mark. */
|
||||
if (openfile->mark_set)
|
||||
mark_order((const filestruct **)&top, &top_x,
|
||||
@@ -321,105 +302,134 @@ void do_indent(ssize_t cols)
|
||||
bot = top;
|
||||
}
|
||||
|
||||
if (!unindent) {
|
||||
/* Set up the text we'll be using as indentation. */
|
||||
line_indent = charalloc(cols + 1);
|
||||
/* Set up the text we'll be using as indentation. */
|
||||
line_indent = charalloc(tabsize + 1);
|
||||
|
||||
if (ISSET(TABS_TO_SPACES)) {
|
||||
/* Set the indentation to cols spaces. */
|
||||
charset(line_indent, ' ', cols);
|
||||
line_indent_len = cols;
|
||||
} else {
|
||||
/* Set the indentation to (cols / tabsize) tabs and (cols %
|
||||
* tabsize) spaces. */
|
||||
size_t num_tabs = cols / tabsize;
|
||||
size_t num_spaces = cols % tabsize;
|
||||
|
||||
charset(line_indent, '\t', num_tabs);
|
||||
charset(line_indent + num_tabs, ' ', num_spaces);
|
||||
|
||||
line_indent_len = num_tabs + num_spaces;
|
||||
}
|
||||
|
||||
line_indent[line_indent_len] = '\0';
|
||||
if (ISSET(TABS_TO_SPACES)) {
|
||||
/* Set the indentation to tabsize spaces. */
|
||||
charset(line_indent, ' ', tabsize);
|
||||
line_indent_len = tabsize;
|
||||
} else {
|
||||
/* Set the indentation to a tab. */
|
||||
line_indent[0] = '\t';
|
||||
line_indent_len = 1;
|
||||
}
|
||||
|
||||
line_indent[line_indent_len] = '\0';
|
||||
|
||||
/* Go through each line of the text. */
|
||||
for (f = top; f != bot->next; f = f->next) {
|
||||
size_t line_len = strlen(f->data);
|
||||
size_t indent_len = indent_length(f->data);
|
||||
|
||||
if (!unindent) {
|
||||
/* If we're indenting, add the characters in line_indent to
|
||||
* the beginning of the non-whitespace text of this line. */
|
||||
f->data = charealloc(f->data, line_len + line_indent_len + 1);
|
||||
charmove(&f->data[indent_len + line_indent_len],
|
||||
/* Add the characters in line_indent to
|
||||
* the beginning of the non-whitespace text of this line. */
|
||||
f->data = charealloc(f->data, line_len + line_indent_len + 1);
|
||||
charmove(&f->data[indent_len + line_indent_len],
|
||||
&f->data[indent_len], line_len - indent_len + 1);
|
||||
strncpy(f->data + indent_len, line_indent, line_indent_len);
|
||||
openfile->totsize += line_indent_len;
|
||||
strncpy(f->data + indent_len, line_indent, line_indent_len);
|
||||
openfile->totsize += line_indent_len;
|
||||
|
||||
/* Keep track of the change in the current line. */
|
||||
if (openfile->mark_set && f == openfile->mark_begin &&
|
||||
openfile->mark_begin_x >= indent_len)
|
||||
openfile->mark_begin_x += line_indent_len;
|
||||
|
||||
if (f == openfile->current && openfile->current_x >= indent_len) {
|
||||
openfile->current_x += line_indent_len;
|
||||
openfile->placewewant = xplustabs();
|
||||
}
|
||||
|
||||
/* If the NO_NEWLINES flag isn't set, and this is the
|
||||
* magicline, add a new magicline. */
|
||||
if (!ISSET(NO_NEWLINES) && f == openfile->filebot)
|
||||
new_magicline();
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
free(line_indent);
|
||||
|
||||
/* Throw away the undo stack, to prevent making mistakes when
|
||||
* the user tries to undo something in the indented text. */
|
||||
discard_until(NULL, openfile);
|
||||
|
||||
/* Mark the file as modified. */
|
||||
set_modified();
|
||||
|
||||
/* Update the screen. */
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
/* Unindent the current line (or the marked lines) by tabsize columns.
|
||||
* The removed indent can be a mixture of spaces plus at most one tab. */
|
||||
void do_unindent(void)
|
||||
{
|
||||
bool indent_changed = FALSE;
|
||||
/* Whether any unindenting was done. */
|
||||
filestruct *top, *bot, *f;
|
||||
size_t top_x, bot_x;
|
||||
|
||||
assert(openfile->current != NULL && openfile->current->data != NULL);
|
||||
|
||||
/* If the mark is on, use all lines covered by the mark. */
|
||||
if (openfile->mark_set)
|
||||
mark_order((const filestruct **)&top, &top_x,
|
||||
(const filestruct **)&bot, &bot_x, NULL);
|
||||
/* Otherwise, use the current line. */
|
||||
else {
|
||||
top = openfile->current;
|
||||
bot = top;
|
||||
}
|
||||
|
||||
/* Go through each line of the text. */
|
||||
for (f = top; f != bot->next; f = f->next) {
|
||||
size_t line_len = strlen(f->data);
|
||||
size_t indent_len = indent_length(f->data);
|
||||
size_t indent_col = strnlenpt(f->data, indent_len);
|
||||
/* The length in columns of the indentation on this line. */
|
||||
|
||||
if (tabsize <= indent_col) {
|
||||
size_t indent_new = actual_x(f->data, indent_col - tabsize);
|
||||
/* The length of the indentation remaining on
|
||||
* this line after we unindent. */
|
||||
size_t indent_shift = indent_len - indent_new;
|
||||
/* The change in the indentation on this line
|
||||
* after we unindent. */
|
||||
|
||||
/* If there's at least tabsize
|
||||
* columns' worth of indentation at the beginning of the
|
||||
* non-whitespace text of this line, remove it. */
|
||||
charmove(&f->data[indent_new], &f->data[indent_len],
|
||||
line_len - indent_shift - indent_new + 1);
|
||||
null_at(&f->data, line_len - indent_shift + 1);
|
||||
openfile->totsize -= indent_shift;
|
||||
|
||||
/* Keep track of the change in the current line. */
|
||||
if (openfile->mark_set && f == openfile->mark_begin &&
|
||||
openfile->mark_begin_x >= indent_len)
|
||||
openfile->mark_begin_x += line_indent_len;
|
||||
|
||||
if (f == openfile->current && openfile->current_x >= indent_len)
|
||||
openfile->current_x += line_indent_len;
|
||||
|
||||
/* If the NO_NEWLINES flag isn't set, and this is the
|
||||
* magicline, add a new magicline. */
|
||||
if (!ISSET(NO_NEWLINES) && f == openfile->filebot)
|
||||
new_magicline();
|
||||
} else {
|
||||
size_t indent_col = strnlenpt(f->data, indent_len);
|
||||
/* The length in columns of the indentation on this line. */
|
||||
|
||||
if (cols <= indent_col) {
|
||||
size_t indent_new = actual_x(f->data, indent_col - cols);
|
||||
/* The length of the indentation remaining on
|
||||
* this line after we unindent. */
|
||||
size_t indent_shift = indent_len - indent_new;
|
||||
/* The change in the indentation on this line
|
||||
* after we unindent. */
|
||||
|
||||
/* If we're unindenting, and there's at least cols
|
||||
* columns' worth of indentation at the beginning of the
|
||||
* non-whitespace text of this line, remove it. */
|
||||
charmove(&f->data[indent_new], &f->data[indent_len],
|
||||
line_len - indent_shift - indent_new + 1);
|
||||
null_at(&f->data, line_len - indent_shift + 1);
|
||||
openfile->totsize -= indent_shift;
|
||||
|
||||
/* Keep track of the change in the current line. */
|
||||
if (openfile->mark_set && f == openfile->mark_begin &&
|
||||
openfile->mark_begin_x > indent_new) {
|
||||
if (openfile->mark_begin_x <= indent_len)
|
||||
openfile->mark_begin_x = indent_new;
|
||||
else
|
||||
openfile->mark_begin_x -= indent_shift;
|
||||
}
|
||||
|
||||
if (f == openfile->current &&
|
||||
openfile->current_x > indent_new) {
|
||||
if (openfile->current_x <= indent_len)
|
||||
openfile->current_x = indent_new;
|
||||
else
|
||||
openfile->current_x -= indent_shift;
|
||||
}
|
||||
|
||||
/* We've unindented, so the indentation changed. */
|
||||
indent_changed = TRUE;
|
||||
if (openfile->mark_begin_x <= indent_len)
|
||||
openfile->mark_begin_x = indent_new;
|
||||
else
|
||||
openfile->mark_begin_x -= indent_shift;
|
||||
}
|
||||
|
||||
if (f == openfile->current &&
|
||||
openfile->current_x > indent_new) {
|
||||
if (openfile->current_x <= indent_len)
|
||||
openfile->current_x = indent_new;
|
||||
else
|
||||
openfile->current_x -= indent_shift;
|
||||
openfile->placewewant = xplustabs();
|
||||
}
|
||||
|
||||
/* We've unindented, so the indentation changed. */
|
||||
indent_changed = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!unindent)
|
||||
/* Clean up. */
|
||||
free(line_indent);
|
||||
|
||||
if (indent_changed) {
|
||||
/* Throw away the undo stack, to prevent making mistakes when
|
||||
* the user tries to undo something in the reindented text. */
|
||||
* the user tries to undo something in the unindented text. */
|
||||
discard_until(NULL, openfile);
|
||||
|
||||
/* Mark the file as modified. */
|
||||
@@ -429,20 +439,6 @@ void do_indent(ssize_t cols)
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Indent the current line, or all lines covered by the mark if the mark
|
||||
* is on, tabsize columns. */
|
||||
void do_indent_void(void)
|
||||
{
|
||||
do_indent(tabsize);
|
||||
}
|
||||
|
||||
/* Unindent the current line, or all lines covered by the mark if the
|
||||
* mark is on, tabsize columns. */
|
||||
void do_unindent(void)
|
||||
{
|
||||
do_indent(-tabsize);
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Test whether the string is empty or consists of only blanks. */
|
||||
@@ -456,9 +452,9 @@ bool white_string(const char *s)
|
||||
|
||||
#ifdef ENABLE_COMMENT
|
||||
/* Comment or uncomment the current line or the marked lines. */
|
||||
void do_comment()
|
||||
void do_comment(void)
|
||||
{
|
||||
const char *comment_seq = "#";
|
||||
const char *comment_seq = GENERAL_COMMENT_CHARACTER;
|
||||
undo_type action = UNCOMMENT;
|
||||
filestruct *top, *bot, *f;
|
||||
size_t top_x, bot_x;
|
||||
@@ -467,11 +463,10 @@ void do_comment()
|
||||
assert(openfile->current != NULL && openfile->current->data != NULL);
|
||||
|
||||
#ifndef DISABLE_COLOR
|
||||
if (openfile->syntax && openfile->syntax->comment)
|
||||
if (openfile->syntax)
|
||||
comment_seq = openfile->syntax->comment;
|
||||
|
||||
/* Does the syntax not allow comments? */
|
||||
if (strlen(comment_seq) == 0) {
|
||||
if (*comment_seq == '\0') {
|
||||
statusbar(_("Commenting is not supported for this file type"));
|
||||
return;
|
||||
}
|
||||
@@ -653,12 +648,14 @@ void undo_cut(undo *u)
|
||||
/* Redo a cut, or undo an uncut. */
|
||||
void redo_cut(undo *u)
|
||||
{
|
||||
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
|
||||
|
||||
/* If we cut the magicline, we may as well not crash. :/ */
|
||||
if (!u->cutbuffer)
|
||||
return;
|
||||
|
||||
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
|
||||
cutbuffer = cutbottom = NULL;
|
||||
cutbuffer = NULL;
|
||||
cutbottom = NULL;
|
||||
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
|
||||
@@ -678,7 +675,9 @@ void do_undo(void)
|
||||
{
|
||||
undo *u = openfile->current_undo;
|
||||
filestruct *f, *t = NULL;
|
||||
filestruct *oldcutbuffer, *oldcutbottom;
|
||||
char *data, *undidmsg = NULL;
|
||||
size_t from_x, to_x;
|
||||
|
||||
if (!u) {
|
||||
statusbar(_("Nothing in undo buffer!"));
|
||||
@@ -749,7 +748,7 @@ void do_undo(void)
|
||||
splice_node(f, t);
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
break;
|
||||
case CUT_EOF:
|
||||
case CUT_TO_EOF:
|
||||
case CUT:
|
||||
undidmsg = _("text cut");
|
||||
undo_cut(u);
|
||||
@@ -767,8 +766,8 @@ void do_undo(void)
|
||||
break;
|
||||
}
|
||||
undidmsg = _("line break");
|
||||
size_t from_x = (u->begin == 0) ? 0 : u->mark_begin_x;
|
||||
size_t to_x = (u->begin == 0) ? u->mark_begin_x : u->begin;
|
||||
from_x = (u->begin == 0) ? 0 : u->mark_begin_x;
|
||||
to_x = (u->begin == 0) ? u->mark_begin_x : u->begin;
|
||||
f->data = charealloc(f->data, strlen(f->data) +
|
||||
strlen(&u->strdata[from_x]) + 1);
|
||||
strcat(f->data, &u->strdata[from_x]);
|
||||
@@ -787,7 +786,8 @@ void do_undo(void)
|
||||
#endif
|
||||
case INSERT:
|
||||
undidmsg = _("text insert");
|
||||
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
|
||||
oldcutbuffer = cutbuffer;
|
||||
oldcutbottom = cutbottom;
|
||||
cutbuffer = NULL;
|
||||
cutbottom = NULL;
|
||||
openfile->mark_begin = fsfromline(u->mark_begin_lineno);
|
||||
@@ -832,7 +832,7 @@ void do_undo(void)
|
||||
/* Redo the last thing(s) we undid. */
|
||||
void do_redo(void)
|
||||
{
|
||||
filestruct *f;
|
||||
filestruct *f, *shoveline;
|
||||
char *data, *redidmsg = NULL;
|
||||
undo *u = openfile->undotop;
|
||||
|
||||
@@ -883,7 +883,7 @@ void do_redo(void)
|
||||
break;
|
||||
case ENTER:
|
||||
redidmsg = _("line break");
|
||||
filestruct *shoveline = make_new_node(f);
|
||||
shoveline = make_new_node(f);
|
||||
shoveline->data = mallocstrcpy(NULL, u->strdata);
|
||||
data = mallocstrncpy(NULL, f->data, u->begin + 1);
|
||||
data[u->begin] = '\0';
|
||||
@@ -926,7 +926,7 @@ void do_redo(void)
|
||||
renumber(f);
|
||||
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
|
||||
break;
|
||||
case CUT_EOF:
|
||||
case CUT_TO_EOF:
|
||||
case CUT:
|
||||
redidmsg = _("text cut");
|
||||
redo_cut(u);
|
||||
@@ -983,11 +983,9 @@ void do_enter(void)
|
||||
{
|
||||
filestruct *newnode = make_new_node(openfile->current);
|
||||
size_t extra = 0;
|
||||
#ifndef NANO_TINY
|
||||
bool allblanks = FALSE;
|
||||
|
||||
assert(openfile->current != NULL && openfile->current->data != NULL);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(AUTOINDENT)) {
|
||||
extra = indent_length(openfile->current->data);
|
||||
|
||||
@@ -1142,7 +1140,9 @@ bool execute_command(const char *command)
|
||||
void discard_until(const undo *thisitem, openfilestruct *thefile)
|
||||
{
|
||||
undo *dropit = thefile->undotop;
|
||||
#ifdef ENABLE_COMMENT
|
||||
undo_group *group;
|
||||
#endif
|
||||
|
||||
while (dropit != NULL && dropit != thisitem) {
|
||||
thefile->undotop = dropit->next;
|
||||
@@ -1261,7 +1261,7 @@ void add_undo(undo_type action)
|
||||
case REPLACE:
|
||||
u->strdata = mallocstrcpy(NULL, openfile->current->data);
|
||||
break;
|
||||
case CUT_EOF:
|
||||
case CUT_TO_EOF:
|
||||
cutbuffer_reset();
|
||||
break;
|
||||
case CUT:
|
||||
@@ -1270,7 +1270,7 @@ void add_undo(undo_type action)
|
||||
u->mark_begin_lineno = openfile->mark_begin->lineno;
|
||||
u->mark_begin_x = openfile->mark_begin_x;
|
||||
u->xflags = MARK_WAS_SET;
|
||||
} else if (!ISSET(CUT_TO_END)) {
|
||||
} else if (!ISSET(CUT_FROM_CURSOR)) {
|
||||
/* The entire line is being cut regardless of the cursor position. */
|
||||
u->begin = 0;
|
||||
u->xflags = WAS_WHOLE_LINE;
|
||||
@@ -1395,7 +1395,7 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case CUT_EOF:
|
||||
case CUT_TO_EOF:
|
||||
case CUT:
|
||||
if (!cutbuffer)
|
||||
break;
|
||||
@@ -1406,11 +1406,12 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
|
||||
* bottom-->top, then swap the mark points. */
|
||||
if ((u->lineno == u->mark_begin_lineno && u->begin < u->mark_begin_x)
|
||||
|| u->lineno < u->mark_begin_lineno) {
|
||||
ssize_t line = u->lineno;
|
||||
size_t x_loc = u->begin;
|
||||
|
||||
u->begin = u->mark_begin_x;
|
||||
u->mark_begin_x = x_loc;
|
||||
|
||||
ssize_t line = u->lineno;
|
||||
u->lineno = u->mark_begin_lineno;
|
||||
u->mark_begin_lineno = line;
|
||||
} else
|
||||
@@ -1422,7 +1423,7 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
|
||||
u->cutbottom = u->cutbottom->next;
|
||||
u->lineno = u->mark_begin_lineno + u->cutbottom->lineno -
|
||||
u->cutbuffer->lineno;
|
||||
if (ISSET(CUT_TO_END) || u->type == CUT_EOF) {
|
||||
if (ISSET(CUT_FROM_CURSOR) || u->type == CUT_TO_EOF) {
|
||||
u->begin = strlen(u->cutbottom->data);
|
||||
if (u->lineno == u->mark_begin_lineno)
|
||||
u->begin += u->mark_begin_x;
|
||||
@@ -1487,6 +1488,9 @@ bool do_wrap(filestruct *line)
|
||||
size_t next_line_len = 0;
|
||||
/* The length of next_line. */
|
||||
|
||||
size_t old_x = openfile->current_x;
|
||||
filestruct * old_line = openfile->current;
|
||||
|
||||
/* There are three steps. First, we decide where to wrap. Then, we
|
||||
* create the new wrap line. Finally, we clean up. */
|
||||
|
||||
@@ -1529,8 +1533,6 @@ bool do_wrap(filestruct *line)
|
||||
add_undo(SPLIT_BEGIN);
|
||||
#endif
|
||||
|
||||
size_t old_x = openfile->current_x;
|
||||
filestruct * oldLine = openfile->current;
|
||||
openfile->current = line;
|
||||
|
||||
/* Step 2, making the new wrap line. It will consist of indentation
|
||||
@@ -1593,7 +1595,7 @@ bool do_wrap(filestruct *line)
|
||||
|
||||
if (old_x < wrap_loc) {
|
||||
openfile->current_x = old_x;
|
||||
openfile->current = oldLine;
|
||||
openfile->current = old_line;
|
||||
prepend_wrap = TRUE;
|
||||
} else {
|
||||
openfile->current_x += (old_x - wrap_loc);
|
||||
@@ -1610,7 +1612,7 @@ bool do_wrap(filestruct *line)
|
||||
}
|
||||
#endif /* !DISABLE_WRAPPING */
|
||||
|
||||
#if !defined(DISABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
|
||||
#if defined(ENABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
|
||||
/* We are trying to break a chunk off line. We find the last blank such
|
||||
* that the display length to there is at most (goal + 1). If there is
|
||||
* no such blank, then we find the first blank. We then take the last
|
||||
@@ -1645,7 +1647,7 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
|
||||
if (column <= goal)
|
||||
return index;
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
#ifdef ENABLE_HELP
|
||||
/* If we're wrapping a help text and no blank was found, or was
|
||||
* found only as the first character, force a line break. */
|
||||
if (snap_at_nl && lastblank < 1)
|
||||
@@ -1682,7 +1684,7 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
|
||||
|
||||
return lastblank;
|
||||
}
|
||||
#endif /* !DISABLE_HELP || !DISABLE_WRAPJUSTIFY */
|
||||
#endif /* ENABLE_HELP || !DISABLE_WRAPJUSTIFY */
|
||||
|
||||
#if !defined(NANO_TINY) || !defined(DISABLE_JUSTIFY)
|
||||
/* The "indentation" of a line is the whitespace between the quote part
|
||||
@@ -2011,13 +2013,11 @@ void backup_lines(filestruct *first_line, size_t par_len)
|
||||
for (i = par_len; i > 0 && bot != openfile->filebot; i--)
|
||||
bot = bot->next;
|
||||
|
||||
/* Move the paragraph from the current buffer's filestruct to the
|
||||
* justify buffer. */
|
||||
/* Move the paragraph from the current buffer to the justify buffer. */
|
||||
extract_buffer(&jusbuffer, &jusbottom, top, 0, bot,
|
||||
(i == 1 && bot == openfile->filebot) ? strlen(bot->data) : 0);
|
||||
|
||||
/* Copy the paragraph back to the current buffer's filestruct from
|
||||
* the justify buffer. */
|
||||
/* Copy the paragraph back to the current buffer. */
|
||||
copy_from_buffer(jusbuffer);
|
||||
|
||||
/* Move upward from the last line of the paragraph to the first
|
||||
@@ -2433,7 +2433,7 @@ void do_justify(bool full_justify)
|
||||
|
||||
edit_refresh();
|
||||
|
||||
/* Display the shortcut list with UnJustify. */
|
||||
/* Show "Unjustify" in the help lines. */
|
||||
uncutfunc->desc = unjust_tag;
|
||||
display_main_list();
|
||||
|
||||
@@ -2443,17 +2443,15 @@ void do_justify(bool full_justify)
|
||||
do {
|
||||
#endif
|
||||
statusbar(_("Can now UnJustify!"));
|
||||
reset_cursor();
|
||||
place_the_cursor(TRUE);
|
||||
curs_set(1);
|
||||
kbinput = do_input(FALSE);
|
||||
#ifndef NANO_TINY
|
||||
} while (kbinput == KEY_WINCH);
|
||||
#endif
|
||||
|
||||
/* If needed, unset the cursor-position suppression flag, so the cursor
|
||||
* position /will/ be displayed upon a return to the main loop. */
|
||||
if (ISSET(CONST_UPDATE))
|
||||
do_cursorpos(FALSE);
|
||||
/* Unset the suppression flag after showing the Unjustify message. */
|
||||
suppress_cursorpos = FALSE;
|
||||
|
||||
func = func_from_key(&kbinput);
|
||||
|
||||
@@ -2511,10 +2509,11 @@ void do_justify(bool full_justify)
|
||||
jusbuffer = NULL;
|
||||
|
||||
blank_statusbar();
|
||||
wnoutrefresh(bottomwin);
|
||||
|
||||
/* Display the shortcut list with UnCut. */
|
||||
/* Show "Uncut" again in the help lines, and force their redrawing. */
|
||||
uncutfunc->desc = uncut_tag;
|
||||
display_main_list();
|
||||
currmenu = MMOST;
|
||||
}
|
||||
|
||||
/* Justify the current paragraph. */
|
||||
@@ -2535,7 +2534,7 @@ void do_full_justify(void)
|
||||
* return FALSE if the user cancels. */
|
||||
bool do_int_spell_fix(const char *word)
|
||||
{
|
||||
char *save_search, *exp_word;
|
||||
char *save_search;
|
||||
size_t firstcolumn_save = openfile->firstcolumn;
|
||||
size_t current_x_save = openfile->current_x;
|
||||
filestruct *edittop_save = openfile->edittop;
|
||||
@@ -2600,11 +2599,12 @@ bool do_int_spell_fix(const char *word)
|
||||
proceed = TRUE;
|
||||
napms(2800);
|
||||
} else if (result == 1) {
|
||||
exp_word = display_string(openfile->current->data, xplustabs(),
|
||||
strlenpt(word), FALSE);
|
||||
size_t from_col = xplustabs();
|
||||
size_t to_col = from_col + strlenpt(word);
|
||||
|
||||
edit_refresh();
|
||||
|
||||
spotlight(TRUE, exp_word);
|
||||
spotlight(TRUE, from_col, to_col);
|
||||
|
||||
/* Let the user supply a correctly spelled alternative. */
|
||||
proceed = (do_prompt(FALSE, FALSE, MSPELL, word,
|
||||
@@ -2613,9 +2613,7 @@ bool do_int_spell_fix(const char *word)
|
||||
#endif
|
||||
edit_refresh, _("Edit a replacement")) != -1);
|
||||
|
||||
spotlight(FALSE, exp_word);
|
||||
|
||||
free(exp_word);
|
||||
spotlight(FALSE, from_col, to_col);
|
||||
|
||||
/* If a replacement was given, go through all occurrences. */
|
||||
if (proceed && strcmp(word, answer) != 0) {
|
||||
@@ -3315,7 +3313,7 @@ void do_linter(void)
|
||||
}
|
||||
|
||||
/* Place and show the cursor to indicate the affected line. */
|
||||
reset_cursor();
|
||||
place_the_cursor(TRUE);
|
||||
wnoutrefresh(edit);
|
||||
curs_set(1);
|
||||
|
||||
@@ -3347,6 +3345,7 @@ void do_linter(void)
|
||||
}
|
||||
|
||||
blank_statusbar();
|
||||
wnoutrefresh(bottomwin);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
free_lints_and_return:
|
||||
@@ -3390,8 +3389,10 @@ void do_formatter(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* We're not supporting partial formatting, oi vey. */
|
||||
openfile->mark_set = FALSE;
|
||||
#endif
|
||||
status = write_file(temp, temp_file, TRUE, OVERWRITE, FALSE);
|
||||
|
||||
if (!status) {
|
||||
@@ -3457,10 +3458,11 @@ void do_formatter(void)
|
||||
|
||||
set_modified();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Flush the undo stack, to avoid a mess or crash when
|
||||
* the user tries to undo things in reformatted lines. */
|
||||
discard_until(NULL, openfile);
|
||||
|
||||
#endif
|
||||
finalstatus = _("Finished formatting");
|
||||
}
|
||||
|
||||
@@ -3498,7 +3500,7 @@ void do_wordlinechar_count(void)
|
||||
filestruct *top, *bot;
|
||||
size_t top_x, bot_x;
|
||||
|
||||
/* If the mark is on, partition the filestruct so that it
|
||||
/* If the mark is on, partition the buffer so that it
|
||||
* contains only the marked text, and turn the mark off. */
|
||||
if (old_mark_set) {
|
||||
mark_order((const filestruct **)&top, &top_x,
|
||||
@@ -3528,7 +3530,7 @@ void do_wordlinechar_count(void)
|
||||
nlines = openfile->filebot->lineno - openfile->fileage->lineno + 1;
|
||||
chars = get_totsize(openfile->fileage, openfile->filebot);
|
||||
|
||||
/* Unpartition the filestruct so that it contains all the text
|
||||
/* Unpartition the buffer so that it contains all the text
|
||||
* again, and turn the mark back on. */
|
||||
unpartition_filestruct(&filepart);
|
||||
openfile->mark_set = TRUE;
|
||||
@@ -3559,15 +3561,15 @@ void do_verbatim_input(void)
|
||||
/* TRANSLATORS: This is displayed when the next keystroke will be
|
||||
* inserted verbatim. */
|
||||
statusbar(_("Verbatim Input"));
|
||||
reset_cursor();
|
||||
place_the_cursor(TRUE);
|
||||
curs_set(1);
|
||||
|
||||
/* Read in all the verbatim characters. */
|
||||
kbinput = get_verbatim_kbinput(edit, &kbinput_len);
|
||||
|
||||
/* Unsuppress cursor-position display or blank the statusbar. */
|
||||
if (ISSET(CONST_UPDATE))
|
||||
do_cursorpos(FALSE);
|
||||
if (ISSET(CONSTANT_SHOW))
|
||||
suppress_cursorpos = FALSE;
|
||||
else {
|
||||
blank_statusbar();
|
||||
wnoutrefresh(bottomwin);
|
||||
|
||||
64
src/utils.c
64
src/utils.c
@@ -60,30 +60,29 @@ void get_homedir(void)
|
||||
int digits(ssize_t n)
|
||||
{
|
||||
if (n < 100000) {
|
||||
if (n < 1000) {
|
||||
if (n < 100)
|
||||
return 2;
|
||||
else
|
||||
return 3;
|
||||
} else {
|
||||
if (n < 10000)
|
||||
return 4;
|
||||
else
|
||||
return 5;
|
||||
}
|
||||
if (n < 1000) {
|
||||
if (n < 100)
|
||||
return 2;
|
||||
else
|
||||
return 3;
|
||||
} else {
|
||||
if (n < 10000)
|
||||
return 4;
|
||||
else
|
||||
return 5;
|
||||
}
|
||||
} else {
|
||||
if (n < 10000000) {
|
||||
if (n < 1000000)
|
||||
return 6;
|
||||
else
|
||||
return 7;
|
||||
}
|
||||
else {
|
||||
if (n < 100000000)
|
||||
return 8;
|
||||
else
|
||||
return 9;
|
||||
}
|
||||
if (n < 10000000) {
|
||||
if (n < 1000000)
|
||||
return 6;
|
||||
else
|
||||
return 7;
|
||||
} else {
|
||||
if (n < 100000000)
|
||||
return 8;
|
||||
else
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -117,7 +116,7 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
|
||||
const char *comma;
|
||||
|
||||
while (*str == ' ')
|
||||
str++;
|
||||
str++;
|
||||
|
||||
comma = strpbrk(str, "m,. /;");
|
||||
|
||||
@@ -237,6 +236,13 @@ bool is_separate_word(size_t position, size_t length, const char *buf)
|
||||
const char *strstrwrapper(const char *haystack, const char *needle,
|
||||
const char *start)
|
||||
{
|
||||
if (*needle == '\0') {
|
||||
#ifndef NANO_TINY
|
||||
statusline(ALERT, "Searching for nothing -- please report a bug");
|
||||
#endif
|
||||
return (char *)start;
|
||||
}
|
||||
|
||||
if (ISSET(USE_REGEXP)) {
|
||||
if (ISSET(BACKWARDS_SEARCH)) {
|
||||
size_t last_find, ceiling, far_end;
|
||||
@@ -275,7 +281,7 @@ const char *strstrwrapper(const char *haystack, const char *needle,
|
||||
regmatches[0].rm_eo = far_end;
|
||||
if (regexec(&search_regexp, haystack, 10, regmatches,
|
||||
REG_STARTEND) != 0)
|
||||
statusline(ALERT, "BAD: failed to refind the match!");
|
||||
return NULL;
|
||||
|
||||
return haystack + regmatches[0].rm_so;
|
||||
}
|
||||
@@ -452,7 +458,7 @@ void new_magicline(void)
|
||||
openfile->totsize++;
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
|
||||
/* Remove the magicline from filebot, if there is one and it isn't the
|
||||
* only line in the file. Assume that edittop and current are not at
|
||||
* filebot. */
|
||||
@@ -466,7 +472,9 @@ void remove_magicline(void)
|
||||
openfile->totsize--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Set top_x and bot_x to the top and bottom x-coordinates of the mark,
|
||||
* respectively, based on the locations of top and bot. If
|
||||
* right_side_up isn't NULL, set it to TRUE if the mark begins with
|
||||
@@ -535,7 +543,7 @@ size_t get_totsize(const filestruct *begin, const filestruct *end)
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/* Dump the filestruct inptr to stderr. */
|
||||
/* Dump the given buffer to stderr. */
|
||||
void dump_filestruct(const filestruct *inptr)
|
||||
{
|
||||
if (inptr == openfile->fileage)
|
||||
@@ -551,7 +559,7 @@ void dump_filestruct(const filestruct *inptr)
|
||||
}
|
||||
}
|
||||
|
||||
/* Dump the current buffer's filestruct to stderr in reverse. */
|
||||
/* Dump the current buffer to stderr in reverse. */
|
||||
void dump_filestruct_reverse(void)
|
||||
{
|
||||
const filestruct *fileptr = openfile->filebot;
|
||||
|
||||
655
src/winio.c
655
src/winio.c
File diff suppressed because it is too large
Load Diff
@@ -22,6 +22,7 @@ pkgdata_DATA = asm.nanorc \
|
||||
man.nanorc \
|
||||
mgp.nanorc \
|
||||
mutt.nanorc \
|
||||
nanohelp.nanorc \
|
||||
nanorc.nanorc \
|
||||
nftables.nanorc \
|
||||
objc.nanorc \
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
## A default syntax, which is used
|
||||
## for files that do not match any other syntax.
|
||||
## An example of a default syntax. The default syntax is used for
|
||||
## files that do not match any other syntax.
|
||||
|
||||
syntax "default"
|
||||
comment "#"
|
||||
|
||||
# Comments.
|
||||
color cyan "^[[:space:]]*#.*"
|
||||
|
||||
# Spaces in front of tabs.
|
||||
color ,red " + +"
|
||||
|
||||
# Nano's name, including version.
|
||||
color brightred "(GNU )?nano [1-9]\.[0-9]\.[^[:space:][:punct:]]+"
|
||||
|
||||
# Email addresses.
|
||||
color yellow "<[[:alnum:].%_+-]+@[[:alnum:].-]+\.[[:alpha:]]{2,}>"
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
## Here is an example for Gentoo ebuilds/eclasses.
|
||||
## Here is an example for Gentoo ebuilds/eclasses,
|
||||
## and (further down) one for Portage control files.
|
||||
|
||||
syntax "ebuild" "\.e(build|class|blit)$"
|
||||
comment "#"
|
||||
|
||||
## All the standard portage functions
|
||||
## All the standard portage functions:
|
||||
color brightgreen "(^|\<default_)src_(unpack|prepare|configure|compile|install|test)\>"
|
||||
color brightgreen "^pkg_(config|nofetch|info|pretend|setup|(pre|post)(inst|rm))\>"
|
||||
color brightgreen "\<default(_pkg_nofetch|_src_(unpack|prepare|configure|compile|test))?\>"
|
||||
## Highlight bash related syntax
|
||||
## Bash-related syntax:
|
||||
color green "\<(break|case|continue|do|done|elif|else|esac|exit|fi|for|function|if|in|read|return|select|shift|then|time|until|while)\>"
|
||||
color green "\<(declare|eval|exec|export|let|local)\>"
|
||||
color green "[{}():;|`$<>!=&\\]" "(\]|\[)"
|
||||
color green "-[defhnrsuwxzL]\>"
|
||||
color green "-(eq|ne|gt|lt|ge|le)\>"
|
||||
## Highlight variables ... official portage ones in red, all others in bright red
|
||||
## 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)\>"
|
||||
@@ -22,7 +23,7 @@ color red "\<(AS|C(PP|XX)?|LD)FLAGS\>" "\<C(HOST|TARGET|BUILD)\>" "\<(MERGE_TYPE
|
||||
color red "\<EBUILD_PHASE(_FUNC)?\>"
|
||||
color red "\<QA_((TEXTRELS|EXECSTACK|WX_LOAD)(_[a-zA-Z_0-9]+)?|DT_HASH|PRESTRIPPED)\>"
|
||||
color red "\<(PATCHES|(HTML_)?DOCS)\>" "\<WANT_(AUTO(CONF|MAKE)|LIBTOOL)\>" "\<AT_M4DIR\>"
|
||||
## Highlight portage commands
|
||||
## Portage commands:
|
||||
color magenta "\<(use(_(with|enable|if_iuse)|x)?|in_iuse)\> [!a-zA-Z0-9_+ -]*" "inherit.*"
|
||||
color brightblue "\<e(begin|end|conf|install|make|qmake4|ant|(qa)?warn|infon?|error|log|patch(_user)?|new(group|user))\>"
|
||||
color brightblue "\<e(pause|beep|mktemp|(cvs|svn)_clean|punt_cxx)\>" "\<e(aclocal|auto(reconf|header|conf|make)|libtoolize)\>"
|
||||
@@ -35,20 +36,21 @@ color brightblue "\<prepall(docs|info|man|strip)?\>" "\<prep(info|lib|lib\.(so|a
|
||||
color brightblue "\<(doc|ins|exe)?into\>" "\<(f|games)(owners|perms)\>" "\<(exe|ins|dir)opts\>"
|
||||
color brightblue "\<tc-get(BUILD_)?(AR|AS|CC|CPP|CXX|LD|NM|OBJCOPY|PKG_CONFIG|RANLIB)\>"
|
||||
color brightblue "\<tc-(arch(-kernel)?|export|has-(tls|openmp))\>"
|
||||
## Highlight common commands used in ebuilds
|
||||
## Common commands used in ebuilds:
|
||||
color blue "\<(awk|cat|cd|chmod|chown|cp|echo|env|find|e?grep|ln|make|mkdir|mv|popd|printf|pushd|rm|rmdir|sed|set|tar|touch|unset|xargs)\>"
|
||||
## Highlight comments (doesnt work that well)
|
||||
## Comments (doesn't work that well):
|
||||
color yellow "(^|[[:space:]])#.*$"
|
||||
## Highlight strings (doesnt work that well)
|
||||
## Strings (doesn't work that well):
|
||||
color brightyellow ""(\\.|[^\"])*"" "'(\\.|[^'])*'"
|
||||
## Trailing space is bad!
|
||||
color ,green "[[:space:]]+$"
|
||||
## Mixed whitespace is also bad.
|
||||
color ,green " "
|
||||
|
||||
## Here is an example for Portage control files.
|
||||
##
|
||||
|
||||
syntax "/etc/portage" "\.(accept_keywords|env|keywords|mask|unmask|use)(/.+)?$"
|
||||
comment "#"
|
||||
|
||||
## Base text:
|
||||
color green "^.+$"
|
||||
## Likely version and slot numbers:
|
||||
|
||||
@@ -7,7 +7,7 @@ color red "[:=]"
|
||||
color magenta "\<(if|ifeq|else|endif)\>"
|
||||
color blue "\$+[{(][a-zA-Z0-9_-]+[})]"
|
||||
color brightblue "^[^ ]+:"
|
||||
color green "#.*$"
|
||||
color green "(^|[[:space:]]+)#.*"
|
||||
|
||||
## Trailing whitespace.
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
12
syntax/nanohelp.nanorc
Normal file
12
syntax/nanohelp.nanorc
Normal file
@@ -0,0 +1,12 @@
|
||||
## This is meant for highlighting key combos in a nano help text.
|
||||
|
||||
# It should not apply to any normal file, so no fileregex.
|
||||
syntax "nanohelp"
|
||||
|
||||
# Key combos:
|
||||
color cyan "\^([]4-8A-Z^\_←→↑↓]|Home|End)" "[←→↑↓]"
|
||||
color cyan "\<(Tab|Enter|Home|End|Ins|Del|Bsp|PgUp|PgDn)\>"
|
||||
color cyan "\<M-." "\<F1?[0-9]" "(\^|M-)Space"
|
||||
|
||||
# Quoted indicators:
|
||||
color brightred "'(\^|M-)'"
|
||||
@@ -4,15 +4,16 @@ syntax "nanorc" "\.?nanorc$"
|
||||
comment "#"
|
||||
|
||||
# Possible errors and parameters
|
||||
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|comment|magic|linter|i?color|extendsyntax).*$"
|
||||
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|formatter|i?color|extendsyntax).*$"
|
||||
|
||||
# Keywords
|
||||
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cut|fill[[:space:]]+[[:digit:]]+|historylog|justifytrim|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize[[:space:]]+[[:digit:]]+|tabstospaces|tempfile|unix|view|wordbounds)\>"
|
||||
icolor yellow "^[[:space:]]*set[[:space:]]+((function|key|number|status|title)color)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>" "[[:space:]]+[[:digit:]]+$"
|
||||
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cutfromcursor|fill[[:space:]]+-?[[:digit:]]+|historylog|justifytrim|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize[[:space:]]+[1-9][0-9]*|tabstospaces|tempfile|unix|view|wordbounds)\>"
|
||||
icolor yellow "^[[:space:]]*set[[:space:]]+((function|key|number|status|title)color)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
|
||||
icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|speller|statuscolor|titlecolor|whitespace|wordchars)[[:space:]]+"
|
||||
icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^([[:alpha:]]|[]0-9\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]+(all|main|search|replace(with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
|
||||
icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([[:alpha:]]|[]0-9\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+(all|main|search|replace(with)?|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|formatter)[[:space:]]+.*$"
|
||||
icolor brightgreen "^[[:space:]]*(linter|formatter)[[:space:]]+[[:alpha:]]+"
|
||||
icolor green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|formatter|extendsyntax)\>"
|
||||
|
||||
# Colors
|
||||
|
||||
@@ -1,32 +1,35 @@
|
||||
## Here is an example for PHP.
|
||||
|
||||
syntax "php" "\.php[2345s~]?$"
|
||||
syntax "php" "\.ph(p[23457s~]?|tml)$"
|
||||
magic "PHP script text"
|
||||
comment "//"
|
||||
|
||||
# PHP markings.
|
||||
color brightgreen "(<\?(php)?|\?>)"
|
||||
|
||||
# Functions.
|
||||
# Function names.
|
||||
color white "\<[a-z_]*\("
|
||||
# Variable names.
|
||||
color cyan "\$[a-z_]+"
|
||||
|
||||
# Types.
|
||||
color green "\<(var|float|global|double|bool|char|int|enum|const)\>"
|
||||
color green "\<(array|bool|callable|const|float|global|int|object|string|var)\>"
|
||||
|
||||
# Structure.
|
||||
color brightyellow "\<(class|new|private|public|function|for|foreach|if|while|do|else|elseif|case|default|switch)\>"
|
||||
# Directives and structure.
|
||||
color brightyellow "\<(abstract|as|class|clone|(end)?declare|extends|function|implements|include(_once)?|inst(ance|ead)of|interface|namespace|new|private|protected|public|require(_once)?|static|trait|use|yield)\>"
|
||||
color brightyellow "\<(case|catch|default|do|echo|else(if)?|end(for(each)?|if|switch|while)|final(ly)?|for(each)?|if|print|switch|throw|try|while)\>"
|
||||
# Operators.
|
||||
color brightyellow "\<(and|or|xor)\>"
|
||||
|
||||
# Control flow.
|
||||
color magenta "\<(goto|continue|break|return)\>"
|
||||
color magenta "\<(break|continue|goto|return)\>"
|
||||
|
||||
# Strings.
|
||||
color brightyellow "<[^= ]*>" ""(\.|[^"])*""
|
||||
color brightyellow ""(\.|[^"])*"" "'(\.|[^'])*'"
|
||||
|
||||
# Comments.
|
||||
color brightblue "//.*"
|
||||
color brightblue "(^|[[:space:]]+)//.*"
|
||||
color brightblue start="/\*" end="\*/"
|
||||
##color blue start="<" end=">"
|
||||
##color red "&[^;[:space:]]*;"
|
||||
|
||||
# Trailing whitespace.
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
@@ -7,9 +7,9 @@ comment "@c "
|
||||
|
||||
# Command arguments, trailing and enclosed.
|
||||
color cyan "^@[a-z]+[[:space:]]+.*$"
|
||||
color brightmagenta "@[a-z]+\{[^}]*\}"
|
||||
color brightmagenta "@[a-zA-Z]+\{[^}]*\}"
|
||||
# Commands themselves.
|
||||
color yellow "@[a-z]+\{?" "\}"
|
||||
color yellow "@[a-zA-Z]+\{?" "\}"
|
||||
|
||||
# Menu items.
|
||||
color brightred "^\*[[:space:]]+.*::.*$"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
## Here is an example for XML files.
|
||||
|
||||
syntax "xml" "\.([jrsx]html?|jnlp|mml|pom|rng|sgml?|svg|w[as]dl|wsdd|xjb|xml|xs(d|lt?)|xul)$"
|
||||
header "<\?xml.*version=.*\?>"
|
||||
magic "(XML|SGML) (sub)?document text"
|
||||
comment "<!--|-->"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user