Compare commits

..

308 Commits

Author SHA1 Message Date
Chris Allegretta
fa695744fd GNU nano 2.5.0 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5483 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-06 05:24:07 +00:00
Chris Allegretta
c4a6725ad6 2015-12-05 Chris Allegretta <chrisa@asty.org>
* src/nano.c (main) : key_defined() is an ncurses-ism.  Add
	better checks for this.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5482 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-06 05:21:43 +00:00
Benno Schulenberg
bb31118fcb Avoiding two compilation warnings.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5481 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-05 11:38:26 +00:00
Benno Schulenberg
26151189ba Updating date and version number for the upcoming release.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5480 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-05 11:04:24 +00:00
Benno Schulenberg
40e1fd37d7 Fixing compilation with --enable-tiny --enable-justify.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5479 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-05 10:16:26 +00:00
Benno Schulenberg
f2da466388 Rewrapping some lines and tweaking some comments.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5478 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-04 21:11:10 +00:00
Benno Schulenberg
ba8f806705 Fusing three functions into a single one.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5477 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-04 20:54:34 +00:00
Benno Schulenberg
c12d1b87d4 Avoiding a compilation warning.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5476 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-04 11:01:48 +00:00
Benno Schulenberg
ccc9b24f16 Adding a note to the documentation about undo not working after
a justification or reindentation.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5475 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-03 09:34:10 +00:00
Benno Schulenberg
4bc8ff1e6d Discarding the entire undo stack, to prevent nano from making mistakes
when trying to undo edits after an indentation change.
This works around Savannah bug #46591.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5474 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-03 09:17:06 +00:00
Benno Schulenberg
8651fefc68 Discarding the entire undo stack, to prevent nano from dying (or
making mistakes) when trying to undo edits after a justification.
This works around Savannah bug #45531.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5473 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-03 09:03:45 +00:00
Benno Schulenberg
ee5cdcbce5 Moving the trimming of the undo stack into a separate function.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5472 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-03 08:50:34 +00:00
Benno Schulenberg
a41968eeef A typo fix by David Lawrence Ramsey,
and an accent fix by myself.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5471 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-03 08:35:40 +00:00
Benno Schulenberg
e76bbc8832 Oh darn... doing too many things at once.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5470 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-02 19:13:06 +00:00
Benno Schulenberg
6fa1e98c8d Ehm... that was a silly, superfluous condition.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5469 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-02 19:11:03 +00:00
Benno Schulenberg
1fbcf0b23d Accepting not just 'Uncut' but also 'Undo' for undoing a justification.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5468 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-02 19:03:34 +00:00
Benno Schulenberg
1ea76eb51b Treating backslashed quotes properly, and
not colouring triple-quoted strings twice.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5467 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-02 10:29:18 +00:00
Benno Schulenberg
5634d7d717 Not colouring triple quotes by themselves (in Python).
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5466 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-02 09:19:04 +00:00
Benno Schulenberg
ad1f1bce7f Adding syntax colouring for nftables.
Original file by Arturo Borrero Gonzalez.
This addresses Debian bug #805288.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5465 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-02 09:14:45 +00:00
Benno Schulenberg
c9e91df4e4 Deleting four superfluous checks.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5464 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-01 13:44:52 +00:00
Benno Schulenberg
07e806e7f2 Unindenting the part that was the 'else'.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5463 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-01 13:33:45 +00:00
Benno Schulenberg
eee07d5755 Renaming a label and eliding an 'else'.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5462 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-01 12:49:17 +00:00
Benno Schulenberg
3d6378b153 Moving a check to a better place.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5461 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-01 12:35:48 +00:00
Benno Schulenberg
ae22fe03eb Deleting two redundant assignments.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5460 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-01 11:51:10 +00:00
Benno Schulenberg
4ea55c3bf7 Renaming two variables for clarity.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5459 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-01 11:43:13 +00:00
Benno Schulenberg
6a88d8a737 Marking the current buffer as mofified only when actually something
was inserted.  This fixes Savannah bug #45409.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5458 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-01 11:39:04 +00:00
Benno Schulenberg
42ac5368e1 Allowing an array parameter to be NULL.
This fixes Savannah bug #46420.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5457 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-30 16:44:44 +00:00
Benno Schulenberg
66e21416af Storing and retrieving the correct file size before and after an action.
This fixes Savannah bug #45523.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5456 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-30 16:21:51 +00:00
Benno Schulenberg
6b1566023a Redoing cuts at EOF properly.
This fixes Savannah bug #46541.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5455 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-30 15:49:37 +00:00
Benno Schulenberg
0129299dc9 Eliding a variable, and tweaking some comments.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5454 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-29 14:15:16 +00:00
Benno Schulenberg
98f2f852dd Deleting two redundant conditions, and moving the least frequent case
to the end.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5453 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-29 13:52:48 +00:00
Benno Schulenberg
ee33503402 Using the main multidata-cache-allocation routine.
(Note that there can only be colorstrings when there /is/ a syntax,
so there is no need to check for the latter here.)


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5452 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-29 13:20:08 +00:00
Benno Schulenberg
e19a16f0e6 Always setting the multidata to CBEGINBEFORE when an end is found,
also when the coloured part is horizontally scrolled off.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5451 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-29 12:31:49 +00:00
Benno Schulenberg
9e22e8b1b5 Adjusting whitespace and comments.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5450 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-29 10:43:10 +00:00
Benno Schulenberg
6135e28878 Resetting the multidata a bit less often.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5449 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-29 10:14:25 +00:00
Benno Schulenberg
f9a6eb8bec Evaluating correctly whether to reset the multidata cache.
This fixes Savannah bug #46543.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5448 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-29 10:07:49 +00:00
Benno Schulenberg
b1d6d7f95c Initializing a newly allocated multidata array.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5447 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-28 19:03:33 +00:00
Benno Schulenberg
be01647a18 Allowing the user full control over the values of MALLOC_CHECK_ and
MALLOC_PERTURB_; nano shouldn't override them.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5446 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-28 17:29:39 +00:00
Benno Schulenberg
4a59b12ed4 Warning about an impossible condition, instead of blithely continuing.
And eliding an unneeded variable.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5445 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-26 09:31:33 +00:00
Benno Schulenberg
793d8490de Also the /redoing/ of a Backspace at EOF is a special case.
This fixes Savannah bug #46532.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5444 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-26 08:45:22 +00:00
Benno Schulenberg
cf0c9403e1 Adding Mark Majeres and myself to the AUTHORS file.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5443 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-25 10:23:05 +00:00
Benno Schulenberg
530c7862c9 Handling more internal errors, and doing it correctly: showing it
directly on the statusbar instead of as an undid or redid message.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5442 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-25 10:11:54 +00:00
Benno Schulenberg
b255b01b50 Eliding an unneeded variable, and not skipping the end of the function
when things went wrong.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5441 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-25 09:49:27 +00:00
Benno Schulenberg
1b69dd629a Warning about a condition that should never occur,
instead of silently continuing.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5440 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-25 09:27:25 +00:00
Benno Schulenberg
438cb110ff Refreshing the whole edit window only when there are multiline regexes,
and checking for this just once for every burst of keystrokes.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5439 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-25 09:10:02 +00:00
Benno Schulenberg
e0d0ca4b97 Renaming a variable for clarity.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5438 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-24 13:28:32 +00:00
Benno Schulenberg
fbe4376822 Inserting a new node into a linked list by using just two parameters:
the insertion point and the new node.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5437 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-24 13:24:01 +00:00
Benno Schulenberg
9c821dfe2e Telling the user on the statusbar when a syntax name given on the
command line does not exist.  This fixes Savannah bug #46503.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5436 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-24 11:42:19 +00:00
Benno Schulenberg
9dc47fdfe5 Recognizing also files with the extensions .make and .mk as Makefiles.
This addresses Debian bug #804845.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5435 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-24 11:09:06 +00:00
Benno Schulenberg
f08d79d204 Making Ctrl+Left and Ctrl+Right work on more terminals by asking
ncurses for the keycodes.  This addresses Debian bug #800681.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5434 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-23 08:52:23 +00:00
Benno Schulenberg
72caa54020 Deleting a node right after unlinking it.
This now mirrors unlink_opennode() and delete_opennode().


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5433 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-22 16:14:42 +00:00
Benno Schulenberg
81f3177a33 Eliding an unneeded variable.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5432 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-22 16:09:15 +00:00
Benno Schulenberg
6007d6227b Rewrapping, rewriting, renaming, and reordering some things.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5431 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-22 16:08:28 +00:00
Benno Schulenberg
d6bd276c8c Deleting a condition that will never occur.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5430 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-22 16:07:23 +00:00
Benno Schulenberg
c706b79b63 Adding the release marker, and copying the news item from the 2.4 branch.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5429 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-21 19:55:09 +00:00
Benno Schulenberg
1f027a838e Letting the value of a --fill option on the command line
override the value of a "set fill" option in an rcfile.
This fixes Savannah bug #46492.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5428 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-21 19:44:27 +00:00
Benno Schulenberg
c9e8370cec Fixing a typo and adjusting some spacing.
Patch by David Lawrence Ramsey.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5427 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-21 19:05:10 +00:00
Benno Schulenberg
f9274a5a29 Deleting an unneeded variable alias.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5405 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-12 19:50:33 +00:00
Benno Schulenberg
ec26fd5e7c Storing the correct end position of an inserted file,
and using it for an undo and redo.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5404 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-12 19:01:57 +00:00
Benno Schulenberg
bde996db67 Discarding a now useless function.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5403 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-11 19:56:35 +00:00
Benno Schulenberg
7be493047c Oops! Blackout!
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5402 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-11 19:15:36 +00:00
Benno Schulenberg
54c2f6b5ae Chopping the now unused parameter 'undoing'.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5401 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-11 19:04:31 +00:00
Benno Schulenberg
f1d9fcc77b Redoing an Enter from stored undo data, instead of running do_enter() again,
because the latter behaves differently depending on the setting of autoindent.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5400 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-11 18:51:39 +00:00
Benno Schulenberg
619f28077c Plugging four memory leaks.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5399 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-10 15:09:36 +00:00
Benno Schulenberg
02a3a25aa0 Skipping a zero-length match only when there /is/ a match.
(Finally I understood what valgrind was complaining about.)


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5398 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-10 10:39:12 +00:00
Benno Schulenberg
c43c048783 Accepting longer bug and patch numbers.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5397 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-08 19:44:57 +00:00
Benno Schulenberg
4a23a171b8 Allowing to exit the file browser with the same key as it was entered: ^T.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5396 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-08 19:40:13 +00:00
Benno Schulenberg
a1c03ed5c1 Correcting the logic for adjusting the x position of the mark,
and improving the comments.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5395 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-07 09:49:34 +00:00
Benno Schulenberg
b66e4bfa5b Deleting a redundant assignment.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5394 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-06 21:02:50 +00:00
Benno Schulenberg
a3c9dfa391 Not setting 'openfile->mark_begin' for no reason.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5393 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-06 20:55:46 +00:00
Benno Schulenberg
53fbcf77f2 Not checking whether a function has a help line; it's irrelevant.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5392 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-06 20:25:05 +00:00
Benno Schulenberg
4ede3b494f Truncating an overlong hostname properly instead of bailing out
when writing a lock file.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5391 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-06 20:14:37 +00:00
Benno Schulenberg
452066bc88 Chopping the 'undoing' parameter, so that the calls of do_cut_text() become
more symmetrical: wrapped in add_undo() + update_undo() where needed.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5390 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-02 13:46:40 +00:00
Benno Schulenberg
d0e8887e3b Eliding two variables.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5389 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-02 11:24:22 +00:00
Benno Schulenberg
bf84e5972d Improving several comments.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5388 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-02 10:40:06 +00:00
Benno Schulenberg
5cbb5115c6 Deleting an unused type definition.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5387 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-02 10:27:02 +00:00
Benno Schulenberg
2418b9486b Correcting the changelog description of an old change.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5386 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-10-31 20:32:11 +00:00
Benno Schulenberg
df80bfd2fc Improving comments and combining two conditions.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5385 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-10-31 20:17:09 +00:00
Benno Schulenberg
4a1835fd93 Refreshing the mark's pointer only when it is on the same line as the cursor,
and recalculating the mark's x coordinate only when the mark comes after it.
Also correcting the recalculation in one case.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5384 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-10-31 19:03:53 +00:00
Benno Schulenberg
c67ab656dc Adding a forgotton bug number to the Changelog.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5383 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-10-29 21:10:26 +00:00
Benno Schulenberg
3c40b35055 Tweaking the Changelog.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5382 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-10-29 17:31:34 +00:00
Benno Schulenberg
499c2af385 Removing an 'if' that will never be true, and removing some
assignments that have already been done.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5381 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-10-29 17:27:33 +00:00
Benno Schulenberg
bf64514283 Checking for "nothing to redo" earlier, in order to restore the
possible warning about an internal error.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5380 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-10-29 17:02:13 +00:00
Benno Schulenberg
b0a2f9853b Skipping the addition of an undo only when the current action equals the
last action.  Necessary for when typing text is broken by an undo+redo.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5379 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-10-29 16:52:42 +00:00
Benno Schulenberg
0d9397e5b0 Making ^O work the same way as under Pico when option -t is given:
writing out the file immediately, without prompting.
Patch by David Lawrence Ramsey.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5378 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-10-29 10:36:07 +00:00
Benno Schulenberg
d0b72552bf Oops! You can't swap those two conditions.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5377 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-10-29 09:04:30 +00:00
Benno Schulenberg
26eed9d406 Removing a condition that can never occur.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5376 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-10-28 20:49:16 +00:00
Benno Schulenberg
3059e16c25 Spoofing a line number for the redoing of an INSERT, because
'u->mark_begin_lineno' is being used as the length of the insertion.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5375 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-10-28 20:24:15 +00:00
Benno Schulenberg
08e5eea5b6 Not calculating the line length twice.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5374 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-10-27 16:57:32 +00:00
Benno Schulenberg
17b46f04da Rewriting do_next_word() to use the same, simpler logic as do_prev_word().
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5373 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-10-27 16:48:24 +00:00
Benno Schulenberg
b4103321e6 Jumping to the beginning of the current word when in its middle
instead of to the beginning of the preceding word, to match the
behaviour of Pico and of most other editors.  It also rewrites
the entire routine.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5372 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-09-05 09:40:09 +00:00
Benno Schulenberg
6620de0091 Dropping a return value that is never used.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5371 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-09-05 09:22:50 +00:00
Benno Schulenberg
954d04bc59 Forcing a redraw of a line only when it contains a multicolumn character,
as that is the only known situation where things go wrong.  This spares
all regular text a significant slowdown.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5370 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-09-05 09:14:24 +00:00
Benno Schulenberg
9205c28865 Reverting my own patch that claimed that UTF8 is a stateless encoding.
Apparently there is /some/ state somewhere after all.  Don't have time
now to figure out where exactly.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5369 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-09-04 19:34:55 +00:00
Benno Schulenberg
459d9f8ba8 Rewrapping some lines and tweaking two comments.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5368 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-29 20:14:57 +00:00
Benno Schulenberg
213294e69c Adding a file: syntax colouring for Autoconf files.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5367 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-29 19:52:03 +00:00
Benno Schulenberg
86bbe50a3b Discarding an unneeded extra freeing of the help text.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5366 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-16 17:53:28 +00:00
Benno Schulenberg
8925eabd5e Not bothering to set things to NULL when they will be initialized right away,
nor bothering with a separate initialization function when it's used only once.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5365 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-16 15:21:32 +00:00
Benno Schulenberg
149b1fe439 Removing some duplication in the initialization of a new openfile node.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5364 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-16 13:05:35 +00:00
Benno Schulenberg
a5b29539b1 Renaming and reordering most of 'help_line_len()'.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5363 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-16 12:20:24 +00:00
Benno Schulenberg
9e438cdce1 Determining the length of the current line by starting at the very
beginning of it instead of at the wrap location.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5362 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-16 12:15:11 +00:00
Benno Schulenberg
7a1959fb11 Not bothering to pass around a function when it's used only once.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5361 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-16 09:28:33 +00:00
Benno Schulenberg
427eff6780 Adjusting some comments and whitespace.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5360 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-16 09:14:42 +00:00
Benno Schulenberg
5440796f31 Reducing the scope of a variable.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5359 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-16 08:49:29 +00:00
Benno Schulenberg
a9aa0ef997 Avoiding wide paragraphs of running text in the help screens,
wrapping them at 74 columns if the screen is wider.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5358 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-16 08:43:56 +00:00
Benno Schulenberg
f811846dc5 Allowing to change the file format in restricted mode, but actually disabling
Appending, Prepending, making Backups, and opening the File Browser.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5357 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-13 19:29:55 +00:00
Benno Schulenberg
8a058d1f9a Speeding up the finding of the longest filename in the current folder.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5356 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-13 18:22:29 +00:00
Benno Schulenberg
677e9474f7 Removing the mistaken comparison between a pointer and a literal character.
(It will always be false, so it is apparently unneeded.)


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5355 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-13 17:46:19 +00:00
Benno Schulenberg
58a0ddebac Not bothering to reset any state, because UTF-8 is a stateless encoding.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5354 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-12 19:27:13 +00:00
Benno Schulenberg
07fdf46154 Avoiding a possibly erroneous message, because failing to delete
the temporary file does not mean that copying failed.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5353 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-11 17:43:08 +00:00
Benno Schulenberg
c9337dd4ed Avoiding a call of copy_file() with a null pointer.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5352 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-11 17:27:30 +00:00
Benno Schulenberg
f5234e583f Making a message sound more definitive instead of temporary.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5351 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-09 18:12:32 +00:00
Benno Schulenberg
ea2b51a41d Removing an unneeded and mistaken condition:
if something should be blanked, then both.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5350 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-09 18:10:13 +00:00
Benno Schulenberg
eac0446c86 Fixing compilation with --enable-tiny: file formats don't exist then.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5349 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-09 16:31:01 +00:00
Benno Schulenberg
90798fbfba Allowing to toggle whitespace display also when support for nanorc files
has not been built in, since the default values are quite usable.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5348 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-09 16:05:50 +00:00
Benno Schulenberg
2a5bd555e7 Putting in the null byte "manually", and only when using UTF-8.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5347 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-08 08:10:57 +00:00
Benno Schulenberg
7e1bc82d98 Improving the formatting of the texi file, to get better HTML
without adding confusing single quotes to the Info document.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5346 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-06 19:42:08 +00:00
Benno Schulenberg
30daf4d43f Letting malloc() help to find initialization failures and uses-after-free.
Change was suggested by Mike Frysinger.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5345 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-06 09:01:33 +00:00
Benno Schulenberg
24d6b7fcf7 Tweaking the documentation. Mainly putting prevword and nextword in
the standard order, and giving the Savannah URL for bug reporting.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5344 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-04 19:51:02 +00:00
Benno Schulenberg
052ad10d11 Advertising the five new bindable functions.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5343 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-04 19:20:51 +00:00
Benno Schulenberg
70cbbda87c Adding the option --unix (and 'set unix'),
to save a file by default in Unix format.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5342 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-04 18:49:57 +00:00
Benno Schulenberg
95e1f55574 Plugging a tiny leak.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5341 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-03 19:52:48 +00:00
Benno Schulenberg
455fb4f063 Plugging a memory leak.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5340 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-03 08:32:52 +00:00
Benno Schulenberg
3d2784e113 Checking the value of shortcut->toggle only if it actually is a toggle.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5339 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-03 08:03:22 +00:00
Benno Schulenberg
8a06dfa4d7 Initializing also openfile->syntax.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5338 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-02 20:27:45 +00:00
Benno Schulenberg
ace151778b Adding "and exit" to the description of --help, for veracity, to match
--version, and to distinguish it more from the description of ^G.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5337 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-01 08:47:38 +00:00
Benno Schulenberg
45f873a6a7 Showing also the dedicated keys in the ^G help text,
to clarify some keys and to see which ones can be rebound.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5336 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-01 08:41:36 +00:00
Benno Schulenberg
e919c22793 Setting each multiline-color value instead of OR-ing it.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5335 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-01 08:35:14 +00:00
Benno Schulenberg
b3e4051ded Adding two new bindable functions which delete all characters
from the cursor to the preceding or succeeding word start.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5334 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-31 11:52:26 +00:00
Benno Schulenberg
20ba559b9f Providing feedback for ^Z when suspension is not enabled.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5333 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-30 20:15:01 +00:00
Benno Schulenberg
b7f7df93df Changing "Justify" to a tag and regrouping a couple.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5332 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-30 19:51:08 +00:00
Benno Schulenberg
6847616aee Differentiating between something being disabled/restricted and
help texts being unavailable.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5331 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-30 18:10:16 +00:00
Benno Schulenberg
104ea6b0c3 Normalizing whitespace after the preceding changes.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5330 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-30 11:29:45 +00:00
Benno Schulenberg
2ee18d635f Not showing ^R and ^T in the help lines in restricted mode (if possible),
to give visual feedback.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5329 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-30 10:37:28 +00:00
Benno Schulenberg
efbf7b6ef3 Making the four toggles that don't have any effect in restricted mode
say that they're disabled.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5328 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-29 20:21:45 +00:00
Benno Schulenberg
5885e34b23 Not showing options that don't have any effect when asking for --help in
restricted mode.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5327 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-29 19:31:50 +00:00
Benno Schulenberg
e4294a211e It is better to say that this function is disabled
than that no linter has been defined.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5326 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-29 17:36:39 +00:00
Benno Schulenberg
0b15c42a5c Dropping two superfluous checks for restricted mode, and
two superfluous checks for the definition of a formatter.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5325 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-28 20:04:18 +00:00
Benno Schulenberg
bff6a905af Reenabling SIGWINCH-es also when invocation of the formatter fails,
and correcting some comments.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5324 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-28 19:39:34 +00:00
Benno Schulenberg
c7f5691637 Making the calculation of the new line size more efficient and symmetrical,
and renaming two variables in the process.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5323 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-26 17:29:34 +00:00
Benno Schulenberg
17ab9a2dba Improving a few comments.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5322 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-26 17:04:29 +00:00
Benno Schulenberg
f7e8861770 Tweaking a string, to match the --help text.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5321 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-26 09:29:42 +00:00
Benno Schulenberg
4990f74f83 Adding two new bindable functions that repeat the last search command
in a fixed direction without prompting.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5320 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-26 09:23:24 +00:00
Benno Schulenberg
8ffc33cd89 Finding each zero-length match only once, when doing regex replacements.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5319 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-26 08:20:28 +00:00
Benno Schulenberg
ee7b095678 Adding a new bindable function that writes a file to disk without
first asking for its name.  Patch was suggested by Seiya Nuta.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5318 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-25 19:25:50 +00:00
Benno Schulenberg
25c775af21 Mentioning the configure options --disable-histories and --disable-libmagic.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5317 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-23 19:31:36 +00:00
Benno Schulenberg
b967368d41 Finding only valid UTF-8 byte sequences when searching.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5316 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-23 19:18:25 +00:00
Benno Schulenberg
f47813eefa Adding deprecation notices for the options 'const' and 'poslog'.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5315 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-23 17:56:54 +00:00
Benno Schulenberg
474b390816 Plugging a few memory leaks.
Patch by Mike Frysinger.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5314 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-22 18:02:36 +00:00
Benno Schulenberg
b58676f3c9 Correcting a name in the Changelog; otherwise googling for it is difficult.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5313 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-19 16:01:15 +00:00
Benno Schulenberg
d52f108526 Adjusting some comments for clarity and accuracy, and rewrapping some lines.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5312 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-19 09:25:25 +00:00
Benno Schulenberg
9dc544acbd Accepting again a +LINE argument for each file given on the command line,
instead of only for the first.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5311 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-19 09:01:59 +00:00
Benno Schulenberg
59fdd4db7a Making the release markers stand out more,
plus a few small other fixes.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5310 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-18 19:06:42 +00:00
Benno Schulenberg
f1bd958851 Fixing a few typos and making some updates for 2.4.* in the FAQ.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5309 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-18 12:00:34 +00:00
Benno Schulenberg
74e7521478 Adjusting some comments.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5308 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-18 10:32:01 +00:00
Benno Schulenberg
3f1878d9a9 Looking for a new start only after an end,
instead of right after the last start.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5307 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-18 07:34:27 +00:00
Benno Schulenberg
6039cd7f6e Avoiding an unfounded warning about a possibly uninitialized variable.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5306 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-17 21:11:32 +00:00
Benno Schulenberg
1dc298d28b Removing an earlier attempt at making M-W work at startup.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5305 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-17 21:06:46 +00:00
Benno Schulenberg
98ffb642f3 Verifying that a named and existing file is a normal file, to avoid
opening an empty buffer when the name of a directory is specified. 


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5304 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-17 20:40:44 +00:00
Benno Schulenberg
8cde95e170 Using the proper type (off_t) for the size of a file,
and avoiding warnings about too large bit shifts.
Patch by Mike Frysinger.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5303 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-17 19:38:22 +00:00
Benno Schulenberg
aa0fd889af Fixing a quote. (Found this with my default syntax colouring.)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5302 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-15 20:21:15 +00:00
Benno Schulenberg
1f866c29db Renaming the 'menu' item to 'menus' in the shortcut struct.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5301 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-15 20:13:05 +00:00
Benno Schulenberg
cadb4f3689 Unabbreviating the long option --poslog to --positionlog.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5300 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-15 19:50:55 +00:00
Benno Schulenberg
79526151d5 Unabbreviating the long option --const to --constantshow.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5299 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-15 19:40:37 +00:00
Benno Schulenberg
5e53c6ee9e Preventing a segfault when spellchecking a marked region
and nonewlines isn't set.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5298 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-13 18:04:05 +00:00
Benno Schulenberg
42f307ef75 (Putting in the original patch, from before I got overzealous.)
Removing an unneeded condition -- 'added_magicline' can only be
true when NO_NEWLINES isn't.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5297 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-13 17:57:58 +00:00
Benno Schulenberg
674ab835e8 Arh! I tested that without actually making any spell correction.
That wasn't very clever.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5296 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-13 05:32:17 +00:00
Benno Schulenberg
badbc676fb Removing a stray space from a statusbar message.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5295 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-12 19:31:08 +00:00
Benno Schulenberg
aee86996de Renaming the variable 'totsize_save' to 'size_of_surrounding',
to better describe what it contains.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5294 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-12 19:27:26 +00:00
Benno Schulenberg
3d01486409 Removing the variable 'added_magicline', as it will always be FALSE
and thus will never cause anything to be done.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5293 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-12 19:20:46 +00:00
Benno Schulenberg
5bb096d32f Rearranging a few lines plus some whitespace.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5292 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-10 17:49:30 +00:00
Benno Schulenberg
aff252aed6 Removing two lines of dead code.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5291 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-10 17:42:32 +00:00
Benno Schulenberg
08d9f572a4 Unwrapping some lines and rewrapping some others in a more congenial manner;
tweaking some comments and whitespace and braces.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5290 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-10 17:25:51 +00:00
Benno Schulenberg
ea4b775a3e Eliding an unneeded variable.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5289 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-10 16:00:12 +00:00
Benno Schulenberg
93e391eba3 Renaming a variable.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5288 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-10 15:57:49 +00:00
Benno Schulenberg
9fcde23009 Plugging a small memory leak.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5287 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-10 15:54:06 +00:00
Benno Schulenberg
6095ff3d39 Adjusting whitespace and bracings after the previous changes.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5286 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-06 19:17:27 +00:00
Benno Schulenberg
fc7825d00d Not removing and then re-adding the magic line when a Backspace happens
at the end-of-file; just adding a token undo item to be able to put the
cursor back at the very tail of the file.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5285 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-06 19:08:13 +00:00
Benno Schulenberg
8f5fa24e51 Moving the check for a Delete at the end-of-file to a less frequently
travelled code path.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5284 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-06 18:48:15 +00:00
Benno Schulenberg
619666460e Making it more transparent what WAS_FINAL_BACKSPACE does.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5283 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-06 18:03:14 +00:00
Benno Schulenberg
5ac6a87522 Giving each toggle a sequence number, to be able to show them in a fixed order.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5282 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-06 17:51:17 +00:00
Chris Allegretta
05fb283034 move trunk to 2.5 branch
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5281 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-05 08:06:40 +00:00
Chris Allegretta
6edb7a43f2 Type in NEWS
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5280 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-05 08:04:53 +00:00
Chris Allegretta
5190ab9c9b GNU nano 2.4.2 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5277 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-05 07:51:55 +00:00
Benno Schulenberg
b60f555843 Recognizing several more kinds of XML files.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5276 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-28 18:15:41 +00:00
Benno Schulenberg
953ccc990f Unwrapping some lines, rewrapping some others more logically,
plus several other esthetic tweaks.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5275 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-28 14:12:25 +00:00
Benno Schulenberg
296ff1ed2a Not checking again for a condition that was checked before.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5274 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-28 14:04:03 +00:00
Benno Schulenberg
6062a040e1 Limiting the selected file to the available ones in the list.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5273 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-28 06:32:56 +00:00
Benno Schulenberg
954f98c448 Removing a duplicate binding of ^T, to prevent it being shown twice.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5272 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-27 15:58:20 +00:00
Benno Schulenberg
076fcbf631 Removing the obsolete execute flag from the shortcut struct.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5271 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-27 15:47:39 +00:00
Benno Schulenberg
38e8ed14ca Normalizing the whitespace and some comments in src/files.c.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5270 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-27 15:10:58 +00:00
Benno Schulenberg
ecffb85656 Forgetting the case of an empty filename for replace_buffer(),
and not bothering to put the pointer at the top.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5269 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-27 15:03:45 +00:00
Benno Schulenberg
f0bb50306c Renaming three flags for clarity.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5268 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-27 09:27:19 +00:00
Benno Schulenberg
412b9fc0a2 Skipping the undo of a backspace *only* when it really
tried to delete the final, magic newline.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5267 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-27 09:17:36 +00:00
Benno Schulenberg
75ac24b25e Verifying that there exists multidata for the found starting line
before trying to use this multidata -- when a file is inserted, all
its lines will not have any multidata associated with them.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5266 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-23 18:06:30 +00:00
Benno Schulenberg
4499520c03 Removing the obsolete long option --undo, and sorting some things.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5265 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-20 18:48:43 +00:00
Benno Schulenberg
7f0003a54b Adding a bug reference.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5264 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-20 12:53:27 +00:00
Benno Schulenberg
57f52a8a20 Reverting the last commit, as it is making things worse:
backspacing at the tail of the file no longer has any efffect.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5263 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-20 09:42:26 +00:00
Benno Schulenberg
e219bb9dba Not deleting the magic line, instead of removing and then re-adding it.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5262 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-20 09:00:22 +00:00
Benno Schulenberg
4310139117 Stopping the changed-files colour from spilling beyond an empty line.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5261 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-20 08:44:31 +00:00
Benno Schulenberg
11fa458677 Colouring key-binding lines in a nanorc file affirmatively
only when the specified menu name is an existing one.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5260 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-20 08:31:27 +00:00
Benno Schulenberg
e06472a249 Keeping homedir NULL when no home directory could be determined,
so that nano will show a message about it.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5259 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-20 08:21:35 +00:00
Benno Schulenberg
a267699440 Making M-W work also right after startup.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5258 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-20 08:10:25 +00:00
Benno Schulenberg
025553769e Deleting two unused things, and adding two comments.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5257 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-18 19:07:56 +00:00
Benno Schulenberg
7c2f53b2a9 Allowing a tiny nano to enable search and position histories.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5256 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-18 18:51:27 +00:00
Benno Schulenberg
3021a04c1c Improving the visibility of the undo-related debugging messages.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5255 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-17 15:17:09 +00:00
Benno Schulenberg
86cbd959f6 Renaming the parameter 'current_action' to 'action',
in order to match the other functions.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5254 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-17 11:18:20 +00:00
Benno Schulenberg
ef2593695d Oops! Misplaced a closing parenthesis.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5253 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-17 11:12:42 +00:00
Benno Schulenberg
6404101407 Eliding an unneeded variable and correcting two comments.
And putting the more frequent condition first.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5252 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-17 10:59:16 +00:00
Benno Schulenberg
67667af233 Adjusting whitespace after the previous change.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5251 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-17 10:47:00 +00:00
Benno Schulenberg
82373d85f9 Preventing the addition of an extra newline when undoing a Backspace or Delete
at the tail of the file while nonewlines is not set.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5250 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-17 10:41:57 +00:00
Benno Schulenberg
c32a58a826 Not checking for non-NULL before freeing a variable, as it's unnecessary.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5249 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-14 19:14:41 +00:00
Benno Schulenberg
26ae9dbd12 Not bothering to look for any starting matches on the current line
when the whole line has already been coloured.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5248 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-14 18:06:36 +00:00
Benno Schulenberg
d49c267f91 Skipping to the next step when a found start has been qualified as
an end earlier.  This helps with Python's triple-quoted strings.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5247 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-14 17:56:44 +00:00
Benno Schulenberg
2e121fa08c Adding some debugging code to track which multidata codes get assigned.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5246 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-14 15:58:57 +00:00
Benno Schulenberg
e00b3e8587 Making it easy to see what codes a key stroke produces when debugging.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5245 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-11 19:01:28 +00:00
Benno Schulenberg
87e963a2c7 Adding a section to the man page on the non-obvious functioning of
the cutbuffer and the mark.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5244 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-07 20:14:41 +00:00
Benno Schulenberg
74ac8ce407 Clarifying the meaning of the --backupdir option.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5243 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-07 18:45:34 +00:00
Benno Schulenberg
f87de12b96 Improving some formatting, hyphenation, wording and dashes.
And removing some confusing, historical text.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5242 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-07 16:45:09 +00:00
Benno Schulenberg
1a3fa549a9 Showing the node with the command-line options in the main menu.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5241 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-07 10:02:31 +00:00
Benno Schulenberg
0424243e3c Adding the post-install and pre-uninstall rules for the Info document,
plus some tweaks.  (Patch was tested by Kamil Dudka.)


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5240 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-04 18:05:27 +00:00
Benno Schulenberg
a1c4da8b04 Fixing compilation with --enable-tiny.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5239 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-04 17:59:50 +00:00
Benno Schulenberg
7b2ea40575 Requiring again that the triple quote that starts a docstring
is followed by some character.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5238 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-02 14:53:48 +00:00
Benno Schulenberg
1f3148db4b Colouring also an optional option in apt's sources.list on Debian.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5237 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-02 14:35:21 +00:00
Benno Schulenberg
24f39d3ad1 Tweaking some wordings, adding some missing formatting to the Info document,
and fixing an mdash.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5236 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-02 14:24:19 +00:00
Benno Schulenberg
40bfc729ca Preventing a floating-point exception when the available length
for an answer becomes zero.  The answer will instead wrap to the
next line, which does not look nice but is better than crashing.
Patch by Mahyar Abbaspour.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5235 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-05-31 08:45:17 +00:00
Benno Schulenberg
01e39f4ff9 Ah, fixing name.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5234 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-05-28 18:59:41 +00:00
Benno Schulenberg
d297784b87 Allowing a CD name to contain any character.
Changes were suggested by Dani Moller.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5233 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-05-28 18:56:31 +00:00
Benno Schulenberg
72b437bbd2 Marking window resizes and better file-type detection as done.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5232 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-05-28 14:56:38 +00:00
Benno Schulenberg
3e8dadfb1b Back to SVN.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5231 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-05-28 13:51:32 +00:00
Benno Schulenberg
2661d6d397 Using 'width' instead of hardcoded 16. And doing things in the same order
for all three cases: setting the string and then positioning the cursor.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5230 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-05-28 13:51:03 +00:00
Benno Schulenberg
59187b8051 Normalizing the whitespace after the recent changes in logic.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5229 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-05-28 13:28:37 +00:00
Benno Schulenberg
75d64e677e Handling a SIGWINCH (which signals a change in window size) not when it
happens but only when checking for keyboard input.  It now reports the
SIGWINCH via a special key value to the calling routine, to allow not
only the main editor but also the help viewer and the file browser to
adapt their display to the new size.
Patch by Mahyar Abbaspour, somewhat edited by Benno.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5228 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-05-28 13:02:29 +00:00
Benno Schulenberg
c5710d0ef8 Bleh. Adding postgresql to the Makefile.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5227 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-05-21 07:46:01 +00:00
Benno Schulenberg
de6da120a0 Adding one file: syntax highlighting for PostgreSQL.
Original file by Devrim Gündüz.  (Tweaked by Benno.)


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5226 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-05-20 18:57:18 +00:00
Benno Schulenberg
f111c0d6ab Limiting the number of backup files to one hundred thousand, well
before finding a unused filename takes an annoying amount of time.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5225 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-05-08 21:11:30 +00:00
Benno Schulenberg
55d1e1a9b8 Taking the distant possibility of terabyte files into account,
and in the bargain getting rid of the need to calculate the
number of digits in UINT_MAX.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5224 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-05-08 19:35:47 +00:00
Benno Schulenberg
2da9cbf1a1 Using character classes correctly.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5223 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-05-03 15:47:05 +00:00
Benno Schulenberg
a338798559 Adjusting a few comments and line wrappings.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5222 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-05-03 13:56:51 +00:00
Benno Schulenberg
46464105f2 Displaying an ellipsis only when the filename is longer than
the available space, not when it still fits.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5221 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-05-03 13:25:24 +00:00
Benno Schulenberg
7f3bd26593 Unwrapping a bunch of comments.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5220 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-28 20:09:40 +00:00
Benno Schulenberg
9233c98a7e Improving the colouring of message tags in PO files.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5219 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-28 19:22:11 +00:00
Benno Schulenberg
ec8d51bee3 Matching the file regex of a syntax against the absolute,
canonical path instead of against the path the user gave.
This fixes Savannah bug #44288, reported by Mike Frysinger.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5218 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-28 19:18:38 +00:00
Benno Schulenberg
3739016e45 Adding a cross reference.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5217 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-25 15:47:08 +00:00
Benno Schulenberg
df7524d7e8 Renaming the parameter 'whole_word' to 'whole_word_only',
because the first sounds too much like "found_whole" to me.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5216 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-25 15:26:09 +00:00
Benno Schulenberg
b454d9c89b Deleting an always-FALSE parameter.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5215 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-25 15:17:22 +00:00
Benno Schulenberg
af708843f6 Removing the unintended special case for replacing
multiple occurrences of a literal ^ or $.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5214 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-25 14:52:58 +00:00
Benno Schulenberg
ca1983adb4 Eliding another tiny function.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5213 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-21 18:47:58 +00:00
Benno Schulenberg
1cf22d4d4f Initializing the search and replace strings in a central place.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5212 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-21 18:42:11 +00:00
Benno Schulenberg
583a30e971 Saving and restoring the global flags the short and quick way.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5211 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-21 17:37:59 +00:00
Benno Schulenberg
6bdcc8faa9 Saving the settings of the global case-sens, direction, and regexp flags,
and restoring them on exit.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5210 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-21 17:27:33 +00:00
Benno Schulenberg
e68759bf12 Deleting redundant reprises of a bol/eol regular-expression search.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5209 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-20 18:01:06 +00:00
Benno Schulenberg
ec0e0235fa Renaming a function to the simpler 'need_statusbar_update()'
as there is no vertical counterpart.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5208 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-20 08:35:41 +00:00
Benno Schulenberg
7edd350593 Fusing two identical functions into one: need_screen_update().
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5207 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-20 08:16:41 +00:00
Benno Schulenberg
455a918071 Making sure an invalid starting byte of a multibyte sequence is properly
terminated, to prevent the displaying of ghost characters.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5206 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-18 20:07:31 +00:00
Benno Schulenberg
296152ec67 Making the descriptions of the multibuffer feature more accurate.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5205 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-18 16:07:53 +00:00
Benno Schulenberg
6ff772b8d9 Adding two files: syntax highlighting for Emacs Lisp and Guile Scheme.
Patch by Mark Oteiza.  (Tweaked by Benno.)


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5204 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-18 13:04:57 +00:00
Benno Schulenberg
3de2c704ef Adding a linter definition to four of the syntax files.
Patch by Mark Oteiza.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5203 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-18 11:35:23 +00:00
Benno Schulenberg
cc65a42035 Arranging the movement keys in the File Browser in the order of
ascending stride, as in the Help Viewer.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5202 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-17 10:06:03 +00:00
Benno Schulenberg
5b83d7df51 Binding the unbound Home and End keys to goto_top and goto_bottom in the
Help Viewer and the File Browswer, to mimic the behaviour of these keys
in file viewers and web browsers.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5201 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-17 09:42:04 +00:00
Benno Schulenberg
45772652ff Adding the 2.4.1 release marker to the Changelog.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5200 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-17 09:28:18 +00:00
Benno Schulenberg
f225991b05 Distinguishing a failure to launch the linter from receiving 0 parsable lines.
Adding a new function to glue together the invocation-error string.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5199 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-17 09:24:17 +00:00
Chris Allegretta
4d2b198403 GNU nano 2.4.1 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5197 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-14 18:03:44 +00:00
Chris Allegretta
5ea46cacb6 Go even farther on the bug report front in README and only mention
about the Savannah page, based on Benno's excellent suggestion.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5196 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-14 16:07:23 +00:00
Benno Schulenberg
fd759d5ca3 Fixing compilation with --enable-tiny (oops), and mentioning
also the Savannah page as a place for reporting bugs.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5195 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-13 10:59:12 +00:00
Benno Schulenberg
f34c8fdc6b Oops. Correcting an oversight in the Changelog:
the original recent undo fix was by Mark Majeres.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5194 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-12 11:29:35 +00:00
Benno Schulenberg
1cf9deb603 Using mallocstrcpy() in a correct manner and
not letting it free an unrelated string.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5193 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-12 11:15:57 +00:00
Benno Schulenberg
4e5ea18394 Removing an unused variable, and adjusting the introductory comment
for the recently tweaked logic.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5192 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-12 09:04:30 +00:00
Benno Schulenberg
4e9b3687ba Rebinding ^Y and ^V in the WhereisFile menu
to the effective and consistent first_file() and last_file().


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5191 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-12 08:44:37 +00:00
Benno Schulenberg
99d2358510 Stopping M-\ and M-/ in the WhereisFile menu from doing also an
unrequested search after having performed their function.
Fixes Savannah bug #44790.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5190 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-12 08:31:53 +00:00
Benno Schulenberg
08a52c1dab Not splitting off the marked region into a separate partition, but
doing the replacings in situ in the current one, to fix an undo bug.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5189 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-11 15:21:08 +00:00
Benno Schulenberg
ce48ca2223 Correcting and adjusting some comments.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5188 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-08 19:57:31 +00:00
Benno Schulenberg
2dc9cbefd3 Renaming some things, for more contrast or to be more fitting.
And condensing the renamed function, and making it void because
the result isn't used anyway.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5187 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-08 18:40:40 +00:00
Benno Schulenberg
0f7b99b433 Giving the file a neater layout, plus two table headers.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5186 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-07 15:37:07 +00:00
Benno Schulenberg
057348e1da Adding the names of recent translators, and sorting them.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5185 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-07 15:23:12 +00:00
Benno Schulenberg
ab21161a69 Eliding another miniscule function.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5184 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-07 14:24:18 +00:00
Benno Schulenberg
d8b6dbfffe Letting bottombars() set the global variable 'currmenu'.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5183 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-07 14:16:07 +00:00
Benno Schulenberg
d5177059e8 Greatly simplifying the searching for the next matching filename.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5182 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-07 13:34:12 +00:00
Benno Schulenberg
a9647b0508 Avoiding to set 'focusing' when searching for filenames;
it should be set only when searching/replacing text.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5181 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-07 11:04:32 +00:00
Benno Schulenberg
37fd348a1d Eliding a miniscule function, and renaming a variable for clarity.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5180 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-07 10:41:00 +00:00
Benno Schulenberg
2aac470cb9 Consistently using the appropriate variable in the appropriate function.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5179 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-07 08:44:24 +00:00
Benno Schulenberg
25ce5f6759 Removing an unfitting comment and tweaking some others.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5178 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-07 08:23:52 +00:00
Benno Schulenberg
5d0b267aaa Not searching for the empty string when nothing was sought yet
in the file browser (when historylig is set).


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5177 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-07 08:19:04 +00:00
Benno Schulenberg
c2ed8277c2 Expanding on nano's features, and condensing the synopsis,
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5176 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-05 09:14:13 +00:00
Benno Schulenberg
d7ade1f346 Ignoring magic without libmagic, and ignoring formatter without spell checking.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5175 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-03 17:28:30 +00:00
Benno Schulenberg
de53c53c6e Removing two superfluous #ifndefs.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5174 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-03 15:57:22 +00:00
Benno Schulenberg
5ac108188d Updating the README text to the fifth milestone: 2.4.x.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5173 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-03 15:48:57 +00:00
Benno Schulenberg
e683e32c74 Also colouring a series of changed files that spans more than one line.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5172 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-28 19:56:41 +00:00
Benno Schulenberg
7fe830fd20 Only scrolling the required number of lines
when pasting lines onto the bottom line.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5171 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-28 17:11:28 +00:00
Benno Schulenberg
07e199ff0e When searching, put a found off-screen string on the center line
instead of at the bottom or top, to show it in context.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5170 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-28 17:01:46 +00:00
Benno Schulenberg
6f2da6b9b2 Adjusting the end point of the marked region to compensate
for any change in length of the region's last line.
Patch by Mark Majeres.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5169 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-27 20:16:36 +00:00
Benno Schulenberg
14a9c8aa0b Treating the formatter like a speller,
to fix compilation with --disable-speller.
This fixes Savannah bug #44607.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5168 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-27 16:55:49 +00:00
Benno Schulenberg
52d7d5f55a The linter is only available when colour is.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5167 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-27 15:34:41 +00:00
Benno Schulenberg
0b6d6f45d2 Normalizing some whitespace.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5166 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-27 13:46:50 +00:00
Benno Schulenberg
0a79c78e05 Removing two unneeded calls to edit_refresh(), to greatly speed up nano
when doing a Replace All with *lots* of occurrences.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5165 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-27 11:29:23 +00:00
Benno Schulenberg
ad827a6aef Adjusting some whitespace and wrapping.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5164 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-27 10:49:19 +00:00
Benno Schulenberg
41580848e3 Recognizing also Debian package diffs.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5163 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-27 09:14:21 +00:00
Benno Schulenberg
b455fa3a16 Allowing to rebind the linter when nano was configured with --disable-speller.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5162 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-25 19:33:00 +00:00
Benno Schulenberg
ff4a457d82 Removing unneeded statement -- nothing has changed the value of 'currmenu'.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5161 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-25 16:23:45 +00:00
Benno Schulenberg
eae9f282de Removing a mistaken menu name -- as the formatter allows no interaction
it needs no associated menu.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5160 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-25 16:20:45 +00:00
Benno Schulenberg
e39cf37026 Not letting hashes inside triple-quoted strings cause comment colouring.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5159 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-25 13:50:12 +00:00
Benno Schulenberg
6440aa9e47 Slightly widening and relaxing the header regex.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5158 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-25 13:42:40 +00:00
Benno Schulenberg
745fab8293 Correcting the description of option --noread,
allowing writing to named pipes.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5157 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-23 18:16:37 +00:00
Benno Schulenberg
a37ebcf2f8 Not unsetting the mark before the possible bailout for zero size.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5156 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-23 17:12:49 +00:00
Benno Schulenberg
92142bed34 Avoiding a spell-check error when the marked region is zero bytes long.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5155 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-23 17:01:25 +00:00
Benno Schulenberg
83ec9e7d50 Three tiny Changelog fixes.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5154 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-23 13:06:07 +00:00
Chris Allegretta
a0a0556993 2015-02-25 Chris Allegretta <chrisa@asty.org>
* src/text.c (do_alt_speller): timestamp can just be a __time_t.
        Fixes compilation on win32.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5153 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-23 04:32:45 +00:00
Chris Allegretta
33ac317132 Back to SVN
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5152 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-23 04:23:32 +00:00
83 changed files with 26548 additions and 23120 deletions

15
AUTHORS
View File

@@ -9,8 +9,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, const mode, parts of the
UTF-8 support, and various other fixes.
Jordi Mallach <jordi@gnu.org>
* Debian package maintainer, fellow bug squasher.
@@ -23,8 +23,8 @@ Adam Rogoyski <rogoyski@cs.utexas.edu>
Robert Siemborski <rjs3@andrew.cmu.edu>
* Miscellaneous cut, display, replace, and other bug fixes,
original and new "magic line" code, read_line() function, new
edit display routines.
original and new "magic line" code, read_line() function,
new edit display routines.
Rocco Corsi <rocco.corsi@sympatico.ca>
* Internal spelling code, many optimizations and bug fixes for
@@ -41,3 +41,10 @@ Mike Frysinger <vapier@gentoo.org>
--enable-utf8/--disable-utf8 configure options for ncurses,
many new color regexes and improvements to existing color
regexes for nanorc.sample, and miscellaneous bug fixes.
Mark Majeres <mark@engine12.com>
* A functional undo/redo system, and coloring nano's interface.
Benno Schulenberg <bensberg@justemail.net>
* A bunch of small bug fixes, the cutword routines, some extra
key bindings. Current maintainer.

866
ChangeLog

File diff suppressed because it is too large Load Diff

61
NEWS
View File

@@ -1,6 +1,45 @@
2015.12.05 - GNU nano 2.5.0 "Karma", the the first release of the 2.5
series, is now available. Please note that as of this release,
there will no longer be separate stable and unstable
branches. The development team will prioritize bug fixes as
needed, and make new releases in proportion to the
severity of the bugs which are fixed.
This release includes many of the fixes now in
2.4.3, as well as color synax highlighting improvements,
undo fixes, and many more improvements! Thank you for
using nano!
2015.11.18 - GNU nano 2.4.3 "Apocalypse" is now available for your
downloading pleasure. This release includes a myriad
of fixes including several memory leaks, issues with
color syntax highlighting, search/replace, file
insertion and help menu bugs. Many thanks to
Benno Schulenberg for tireless efforts on the vast
majority of fixes for some time now. As always please
report bugs via the Savannah page, and remember to
Share and Enjoy.
2015.07.05 - GNU nano 2.4.2 "Portorož" is released. This release
includes several fixes, including the ability to resize
when in modes other than the main editing window,
proper displaying of invalid UTF-8 bytes, new syntax
definitions for Elisp, Guile, and PostgreSQL, and
better display of shortcuts in the help menu and file
browser. Thanks for your patience and using nano!
2015.04.14 - GNU nano 2.4.1 "Glitch Gremlin" is released. This release
includes several fixes for issues with the file browser
menu, linter and formatter functions, spell checker,
undo/redo with some specific marked-cutting situations,
and some small improvements to the color syntax
highlighting definitions. There are also various
documentation and code comment updates included, and
finally, fixes for compilation on non-GNU/Linux systems
and certain configure combinations. Toasters!
2015.03.22 - GNU nano 2.4.0 "lizf" is released. This is the first
stable release in many years, and brinds together many
new features from the 2.3 series: including:
stable release in many years, and brings together many
new features from the 2.3 series, including:
a fully functional undo system (now enabled by default),
vim-compatible file locking, linter support, formatter
support, syntax highlighting flexibility, and many fixes
@@ -30,7 +69,7 @@
2015.01.06 - GNU nano 2.3.99pre1 "Junior" is released. As the first
2.4 release candidate there will be fewer new features
but many bugfixes going forward. This release contains
new support for language reformatters like go's gofmt
new support for language reformatters like Go's gofmt
command which takes the place of the spelling checker.
Fixes in this release include many syntax highlighting
fixes and improvements, and documentation formatting updates.
@@ -58,23 +97,23 @@
https://savannah.gnu.org/bugs/index.php?42639 and
thanks for using nano.
2014.06.02 - GNU nano 2.3.4 won't leave you high, won't leave you dry. This
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-UTF8 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!
also included. As always, Share and Enjoy!
2014.05.28 - GNU nano 2.3.3 is in its right place. This release contains
many many improvements to the core system, including
substantial improvements to the undo/redo code, UTF-8
handling, the configure script, and display of shortcuts
on very wide terminals, New features include the
ability to read named pipes (--noread), as well as
ability to write to named pipes (--noread), as well as
linter support (see the nanorc man page for details). Also
included are much improved syntax highlighting code, and
configurations for JSON, texinfo, Go, and a default syntax
for catch all highlighting. Finally, nano now has the
for catch all highlighting. Finally, nano now has the
ability to set the color of the title bar, status bar, and
shortcut keys (e.g. "^X") and their descriptions. Again
see the nanorc page for details. There's much more, too
@@ -109,7 +148,7 @@
in your .nanorc. Also included are some fixes for
compilation with g++, and better handling of issues
writing the backup file, which should reduce the need
for the 'set allow_insecure_backup" nanorc option.
for the "set allow_insecure_backup" nanorc option.
Don't stop, get it get it, don't stop, get it get it.
2010.11.22 - GNU nano 2.2.6 "Pimp my BBS" wants you to go to
@@ -155,7 +194,7 @@
This release contains a fix for only one bug, but a
rather irritating one: when paging up/down with smooth
scrolling, the cursor position was not being preserved
due to a bug in 2.2.2. With such a targeted fix
due to a bug in 2.2.2. With such a targeted fix
like this what could POSSIBLY go WRONG? Hahaha.
Enjoy and if you find new bugs, as always please
use Savannah's bug tracker.
@@ -196,7 +235,7 @@
the help keys and replace menu text), more 'final'
fixes for soft wrapping, and several typo and documentation
updates including nanorc tweaks and a new syntax
highlighting file for makefiles. Also included is a long
highlighting file for makefiles. Also included is a long
standing fix for random crashing when using nanorc on
FreeBSD, and nano will no longer clear the screen on
suspend to maintain compatibility with other *nix editors.
@@ -235,7 +274,7 @@
2009.09.14 - GNU nano 2.1.11 is on very thin ice, very thin ice, very thin
ice. This release includes two new features: first, nano
will check whether the current file is writable when it
is opened, and warn if it is not on the status bar. Secondly,
is opened, and warn if it is not on the status bar. Secondly,
a new soft-wrapping (AKA full line display) option is
available, which will attempt to fully display the contents
of lines longer than the width of the screen without the

31
README
View File

@@ -6,20 +6,19 @@ Overview
The nano project was started because of a few "problems" with the
wonderfully easy-to-use and friendly Pico text editor.
First and foremost is its license: the Pine suite does not use the
GPL or a GPL-friendly license, and has unclear restrictions on
First and foremost was its license: the Pine suite does not use
the GPL or a GPL-friendly license, and has unclear restrictions on
redistribution. Because of this, Pine and Pico are not included
with many GNU/Linux distributions. Also, other features (like go
to line number or search and replace) were unavailable until
recently or require a command line flag. Yuck.
with many GNU/Linux distributions. Also, other features (like
go-to-line-number or search-and-replace) were unavailable until
recently or require a command-line flag. Yuck.
nano aims to solve these problems by emulating the functionality of
Pico as closely as possible while addressing the problems above and
perhaps providing other extra functionality.
providing other extra functionality.
The nano editor is now an official GNU package. For more
information on GNU and the Free Software Foundation, please see
http://www.gnu.org/.
The nano editor is an official GNU package. For more information on
GNU and the Free Software Foundation, please see http://www.gnu.org/.
How to compile and install nano
@@ -60,11 +59,15 @@ Mailing Lists and Bug Reports
subject of "subscribe", where <name> is the list you want to
subscribe to.
For general bug reports, send a description of the problem to
nano@nano-editor.org or directly to the development list.
For general bug reports, please file a description of the problem
on the Savannah bug tracker page for nano
(https://savannah.gnu.org/bugs/?group=nano). The issue may have
already been reported, and we are better able to track the state
of the issue and whom to notify when fixed, the more the bug
tracker is used.
Current Status
GNU nano has reached its fourth stable milestone, 2.2.x.
Development of new features continues in the 2.3.x branch, while
2.2.x versions are dedicated to bug-fixing and polishing.
GNU nano has reached its fifth stable milestone, 2.4.x.
Development of new features will continue in the 2.5.x branch,
while 2.4.x versions are dedicated to bug-fixing and polishing.

142
THANKS
View File

@@ -2,82 +2,87 @@ The following people have helped GNU nano in some way or another.
If we missed you here, let us know!
Sharuzzaman Ahmat Raslan <sharuzzaman@excite.com>
Malay translator
Laurentiu Buzdugan <buzdugan@voyager.net> Romanian translator
CHAO Wei-Lun <chaoweilun@pcmail.com.tw> Chinese (traditional) translator
Ricardo Cárdenes Medina <ricardo@conisys.com> Spanish translator
Marco Colombo <magicdice@inwind.it> Italian translator
Yavor Doganov <yavor@doganov.org> Bulgarian translator
Karl Eichwalder <keichwa@gmx.net> German translator
Doruk Fisek <dfisek@fisek.com.tr> Turkish translator
Jean-Philippe Guérard <jean-philippe.guerard@laposte.net>
French translator
Geir Helland <pjallabais@users.sourceforge.net> Norwegian Bokmål translator
Tedi Heriyanto <tedi_h@gmx.net> Indonesian translator
Václav Haisman <V.Haisman@sh.cvut.cz> Czech translator
Szabolcs Horvath <horvaths@janus.gimsz.sulinet.hu>
Hungarian translator
Kalle Kivimaa <kalle.kivimaa@iki.fi> Finnish translator
Eivind Kjørstad <ekj@vestdata.no> Norwegian Nynorsk translator
Florian König <floki@bigfoot.com> German translator
Wojciech Kotwica <wkotwica@post.pl> Polish translator
Clement Laforet <clem_laf@wanadoo.fr> French translator
Daniele Medri <madrid@linux.it> Italian translator
Gergely Nagy <algernon@debian.org> Hungarian translator
Kalle Olavi Niemitalo <kon@iki.fi> Finnish translator
A. Murat EREN <meren@comu.edu.tr> Turkish translator
Claudio Neves <cneves@nextis.com> Brazilian Portuguese translator
Daniel Nylander <po@danielnylander.se> Swedish translator
Michael Piefel <piefel@informatik.hu-berlin.de> German translator
Sergey A. Ribalchenko <fisher@obu.ck.ua> Ukrainian and Russian translator
Michel Robitaille <robitail@IRO.UMontreal.CA> French translator
Christian Rose <menthos@menthos.com> Swedish translator
Stig E Sandø <stig@ii.uib.no> Norwegian Bokmål translator
Benno Schulenberg <benno@vertaalt.nl> Dutch and Esperanto translator
Danilo Segan <dsegan@gmx.net> Serbian translator
Keld Simonsen <keld@dkuug.dk> Danish translator
Guus Sliepen <guus@nl.linux.org> Dutch translator
Cezary Sliwa <sliwa@cft.edu.pl> Polish translator
Pierre Tane <tanep@bigfoot.com> French translator
Jacobo Tarrío <jtarrio@trasno.net> Galician translator
Kjetil Torgrim Homme <kjetilho@linpro.no> Norwegian Nynorsk translator
Miquel Vidal <miquel@sindominio.net> Catalan translator
Phan Vinh Thinh <teppi82@gmail.com> Vietnamese translator
Pauli Virtanen <pauli.virtanen@saunalahti.fi> Finnish translator
Peio Ziarsolo <peio@sindominio.net> Basque translator
Anton Zinoviev <zinoviev@debian.org> Bulgarian translator
João Victor Duarte Martins <jvdm@sdf.lonestar.org>
Brazilian Portuguese translator
Kevin Patrick Scannell <kscanne@gmail.com> Irish translator
Gabor Kelemen <kelemeng@gnome.hu> Hungarian translator
Francisco Javier Tsao Santín <tsao@members.fsf.org>
Galician translator
Dimitriy Ryazantcev <DJm00n@mail.ru> Russian translator
Clytie Siddall <clytie@riverland.net.au> Vietnamese translator
LI Daobing <lidaobing@gmail.com> Chinese (simplified) translator
Jorma Karvonen <karvonen.jorma@gmail.com> Finnish translator
Aron Xu <happyaron.xu@gmail.com> Chinese (simplified) translator
Pavel Fric <pavelfric@seznam.cz> Czech translator
Pavel Maryanov <acid@jack.kiev.ua> Russian translator
Sergey Poznyakoff <gray@gnu.org> Polish translator
Ask Hjorth Larsen <asklarsen@gmail.com> Danish translator
Trần Ngọc Quân <vnwildman@gmail.com> Vietnamese translator
Klemen Košir <klemen913@gmail.com> Slovenian translator
Yasuaki Taniguchi <yasuakit@gmail.com> Japanese translator
Jorge González <aloriel@gmail.com> Spanish translator
Johnny A. Solbu <johnny@solbu.net> Norwegian Bokmål translator
Мирослав Николић <miroslavnikolic@rocketmail.com>
Serbian translator
Translations:
============
Sharuzzaman Ahmat Raslan <sharuzzaman@excite.com> Malay
Josef Andersson <josef.andersson@fripost.org> Swedish
Laurentiu Buzdugan <buzdugan@voyager.net> Romanian
Mario Blättermann <mario.blaettermann@gmail.com> German
Wei-Lun CHAO <chaoweilun@pcmail.com.tw> Chinese (traditional)
Ricardo Cárdenes Medina <ricardo@conisys.com> Spanish
Yuri Chornoivan <yurchor@ukr.net> Ukrainian
Mihai Cristescu <mihai.cristescu@archlinux.info> Romanian
Marco Colombo <magicdice@inwind.it> Italian
Yavor Doganov <yavor@doganov.org> Bulgarian
Karl Eichwalder <keichwa@gmx.net> German
A. Murat EREN <meren@comu.edu.tr> Turkish
Rafael Ferreira <rafael.f.f1@gmail.com> Brazilian Portuguese
Doruk Fisek <dfisek@fisek.com.tr> Turkish
Pavel Fric <pavelfric@seznam.cz> Czech
Jorge González <aloriel@gmail.com> Spanish
Jean-Philippe Guérard <jean-philippe.guerard@laposte.net> French
Geir Helland <pjallabais@users.sourceforge.net> Norwegian Bokmål
Tedi Heriyanto <tedi_h@gmx.net> Indonesian
Václav Haisman <V.Haisman@sh.cvut.cz> Czech
Kjetil Torgrim Homme <kjetilho@linpro.no> Norwegian Nynorsk
Szabolcs Horvath <horvaths@janus.gimsz.sulinet.hu> Hungarian
Jorma Karvonen <karvonen.jorma@gmail.com> Finnish
Gabor Kelemen <kelemeng@gnome.hu> Hungarian
Kalle Kivimaa <kalle.kivimaa@iki.fi> Finnish
Eivind Kjørstad <ekj@vestdata.no> Norwegian Nynorsk
Florian König <floki@bigfoot.com> German
Klemen Košir <klemen913@gmail.com> Slovenian
Wojciech Kotwica <wkotwica@post.pl> Polish
Ask Hjorth Larsen <asklarsen@gmail.com> Danish
Clement Laforet <clem_laf@wanadoo.fr> French
LI Daobing <lidaobing@gmail.com> Chinese (simplified)
João Victor Duarte Martins <jvdm@sdf.lonestar.org> Brazilian Portuguese
Pavel Maryanov <acid@jack.kiev.ua> Russian
Daniele Medri <madrid@linux.it> Italian
Gergely Nagy <algernon@debian.org> Hungarian
Kalle Olavi Niemitalo <kon@iki.fi> Finnish
Мирослав Николић <miroslavnikolic@rocketmail.com> Serbian
Claudio Neves <cneves@nextis.com> Brazilian Portuguese
Daniel Nylander <po@danielnylander.se> Swedish
Mikel Olasagasti <hey_neken@mundurat.net> Basque
Michael Piefel <piefel@informatik.hu-berlin.de> German
Sergey Poznyakoff <gray@gnu.org> Polish
Trần Ngọc Quân <vnwildman@gmail.com> Vietnamese
Sergey A. Ribalchenko <fisher@obu.ck.ua> Ukrainian and Russian
Michel Robitaille <robitail@IRO.UMontreal.CA> French
Christian Rose <menthos@menthos.com> Swedish
Dimitriy Ryazantcev <DJm00n@mail.ru> Russian
Stig E Sandø <stig@ii.uib.no> Norwegian Bokmål
Kevin Patrick Scannell <kscanne@gmail.com> Irish
Benno Schulenberg <benno@vertaalt.nl> Dutch and Esperanto
Danilo Segan <dsegan@gmx.net> Serbian
Clytie Siddall <clytie@riverland.net.au> Vietnamese
Keld Simonsen <keld@dkuug.dk> Danish
Guus Sliepen <guus@nl.linux.org> Dutch
Cezary Sliwa <sliwa@cft.edu.pl> Polish
Johnny A. Solbu <johnny@solbu.net> Norwegian Bokmål
Pierre Tane <tanep@bigfoot.com> French
Yasuaki Taniguchi <yasuakit@gmail.com> Japanese
Jacobo Tarrío <jtarrio@trasno.net> Galician
Francisco Javier Tsao Santín <tsao@members.fsf.org> Galician
Miquel Vidal <miquel@sindominio.net> Catalan
Phan Vinh Thinh <teppi82@gmail.com> Vietnamese
Pauli Virtanen <pauli.virtanen@saunalahti.fi> Finnish
Aron Xu <happyaron.xu@gmail.com> Chinese (simplified)
Peio Ziarsolo <peio@sindominio.net> Basque
Anton Zinoviev <zinoviev@debian.org> Bulgarian
Other stuff:
===========
Ben Armstrong <synrg@sanctuary.nslug.ns.ca> Negative -r value idea, code
Thomas Dickey <dickey@herndon4.his.com> Curses help and advice
Sven Guckes <guckes@math.fu-berlin.de> Advice and Advocacy
Sven Guckes <guckes@math.fu-berlin.de> Advice and advocacy
Thijs Kinkhorst <thijs@kinkhorst.com> rnano.1 manpage
Jim Knoble <jmknoble@pobox.com> Pico compat for browser
Ryan Krebs <fluffy@highwire.stanford.edu> Many bug fixes and testing
Roy Lanek <lanek@ranahminang.net> Advice and advocacy
Mark Majeres <mark@engine12.com> Working undo/redo code
Chuck Mead <csm@MoonGroup.com> Feedback and RPM stuff
Mike Melanson <melanson@pcisys.net> Bugs
Neil Parks <nparks@acsmail.com> Bug reports and fixes
@@ -85,4 +90,5 @@ Jeremy Robichaud <robicj@yahoo.com> Beta tester
Bill Soudan <wes0472@rit.edu> Regex code, etc
Ken Tyler <kent@werple.net.au> Search fixes and more
$Id$

20
TODO
View File

@@ -17,30 +17,32 @@ For the future (no targeted version, catch-all)
- Allow color syntaxes to apply to more than just color, so that we can
e.g. specify a different alternate spell checker depending on which
file type we have open.
- Allow even better file type detection than we have currently, e.g.
through libmagic?
- Allow setting marks (saved positions, not to be confused with the mark
set via Ctrl-^) at various lines and/or columns in the buffer, and
allow movement between them with a single keystroke? (we're running
out of keystrokes)
allow movement between them with a single keystroke? (We're running
out of keystrokes, though.)
- Allow searching for and replacing newlines.
- Fix handling of bad/incomplete UTF-8 sequences to display one Unicode
FFFD (Replacement Character) per sequence instead of one per byte.
For version 2.4:
For version 2.6:
- New regression framework built on expect.
- Allow text searches in the help browser.
- Handle window resizes better. After we resize, we should stay
wherever we were before we resized, as Pico does.
- Allow text searches in the help viewer.
- Add the ability to move to different lines of the screen with a single
keystroke, e.g. M-` (M-~) to go to the top line, M-& (M-7) to go to
the center line, and M-' (M-") to go to the last line.
- Detect when we're pasting text, so that we can handle it differently
(i.e. faster than currently with screen redraws)
(i.e. faster than currently with screen redraws).
- Allow piping marked text to an external command and replacing it with
the command's output (as the internal spell checker already does with
the "spell" command)?
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]
- Allow even better file-type detection than we have currently, e.g.
through libmagic. [DONE]
For version 2.2:
- Rebindable keys? [DONE]
- Undo/Redo keys (M-U and M-E)? [DONE]

View File

@@ -20,7 +20,7 @@
#
# $Id$
AC_INIT([GNU nano], [2.4.0], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [2.5.0], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE
@@ -527,6 +527,7 @@ 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_CHECK_LIB([$CURSES_LIB_NAME], key_defined, AC_DEFINE(HAVE_KEY_DEFINED, 1, [Define this if your curses library has the key_defined() command.]))
dnl Parse any configure options.

View File

@@ -28,8 +28,8 @@
<a href="#3.6">3.6. How can I make the executable smaller? This is too bloated!</a><br>
<a href="#3.7">3.7. Tell me more about this multibuffer stuff!</a><br>
<a href="#3.8">3.8. Tell me more about this verbatim input stuff!</a><br>
<a href="#3.9">3.9. How do I make a .nanorc file that nano will read when I start it?</a></br>
<a href="#3.9.1">3.9.1. How about in Win32?</a></p></blockquote>
<a href="#3.9a">3.9a. How do I make a .nanorc file that nano will read when I start it?</a><br>
<a href="#3.9b">3.9b. How about in Win32?</a></p></blockquote>
<h2><a href="#4">4. Running</a></h2>
<blockquote><p><a href="#4.1">4.1. How do I open a file with a name beginning with '+' from the command line?</a><br>
<a href="#4.2">4.2. Ack! My Backspace/Delete/Enter/Meta/double bucky key doesn't seem to work! What can I do?</a><br>
@@ -84,9 +84,9 @@
<h2><a name="1.5"></a>1.5. 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 &quot;establishes a full duplex terminal connection to a remote host&quot;, 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.6"></a>1.6. What is the current version of nano?</h2>
<blockquote><p>The current stable version of nano *should* be 2.2.6. Of course, you should always check the nano homepage to see what the latest and greatest version is.</p></blockquote>
<blockquote><p>The current stable version of nano *should* be 2.4.2. Of course, you should always check the <a href="http://www.nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<h2><a name="1.7"></a>1.7. 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="http://www.nano-editor.org/dist/v2.2/nano.1.html">here</a>.</p></blockquote>
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="http://www.nano-editor.org/dist/v2.4/nano.1.html">here</a>.</p></blockquote>
<hr width="100%">
<h1><a name="2"></a>2. Where to get GNU nano.</h1>
<h2><a name="2.1"></a>2.1. FTP and WWW sites that carry nano.</h2>
@@ -135,18 +135,20 @@
<h2><a name="3.6"></a>3.6. How can I make the executable smaller? This is too bloated!</h2>
<blockquote><p>Actually, there are several parts of the editor that can be disabled. You can pass arguments to the <b>configure</b> script that disable certain features. Here's a brief list:</p>
<pre>
<b>--disable-browser</b> Disable built-in file browser
<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-extra</b> Disable extra features (currently only an easter egg)
<b>--disable-help</b> Disable help functions
<b>--disable-histories</b> Disable the saving of search strings and cursor positions
<b>--disable-justify</b> Disable justify/unjustify functions
<b>--disable-mouse</b> Disable mouse support (and -m flag)
<b>--disable-libmagic</b> Disable the use of libmagic for determining a file's syntax
<b>--disable-mouse</b> Disable mouse support
<b>--disable-multibuffer</b> Disable having multiple file buffers open
<b>--disable-nanorc</b> Disable the use of .nanorc files
<b>--disable-operatingdir</b> Disable setting of operating directory
<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-wrapping</b> Disable all wrapping of text (and -w flag)</pre>
<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 if 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>
@@ -156,12 +158,12 @@
<h2><a name="3.8"></a>3.8. Tell me more about this verbatim input stuff!</h2>
<blockquote><p>To use verbatim input, you must be using nano 1.3.1 or newer. 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 &quot;Verbatim Input&quot;), 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 instead. The prompt will change to &quot;Unicode Input&quot; when you do this.</p></blockquote>
<h2><a name="3.9"></a>3.9. How do I make a .nanorc file that nano will read when I start it?</h2>
<blockquote><p>It's not hard at all! But, your version of nano must not have been compiled with <b>--disable-nanorc</b>, and must be version 1.1.12 or newer (use nano -V to check your version and compiled features). Then simply copy the <b>nanorc.sample</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 is simple. Flags are turned on and off by using the word <b>set</b> and the getopt_long flag for the feature, for example &quot;set nowrap&quot; or &quot;set suspend&quot;.</p></blockquote>
<h2><a name="3.9.1"></a>3.9. How about in Win32?</h2>
<blockquote><p>If you're using the official nano .zip file and have extracted all the files, you should take the file nano.rc and place it somewhere on your Win32 system (for example if you have write permission to do so, at the top of C:\). Then you must create an Environment variable called HOME which points to the directory where you put nano.rc. In Windows XP, you can get to Environment variables by right-clicking "My Computer" either on the desktop or in the Start Menu, and selecting Properties. This should bring up the System Properties panel. Then click the Advanced Tab, and there should be a button called Environment Variables. Click that to bring up the Environment Variables section. Now, under User Variables you should be able to click the New button, and make a new Variables Name called HOME, with the Variable Value of whatever path you copied nano.rc into (just the directory name; don't add nano.rc onto the end).</p>
<p>We're still working on documentation for enabling synax highlighting on Win32; please bear with us.</p>
<p>Note that the nano.rc file must remain Unix-formated in order for nano to understand it. In other words, you should probably use only nano to edit its config file. Other programs like Wordpad and Notepad will convert the file to DOS format when saving, and the latter does not even properly read Unix-formatted files to begin with.</p></blockquote>
<h2><a name="3.9a"></a>3.9a. How do I make a .nanorc file that nano will read when I start it?</h2>
<blockquote><p>It's not hard at all! But, your version of nano must <b>not</b> have been compiled with <b>--disable-nanorc</b>, and must be version 1.1.12 or newer (use nano -V to check your version and compiled features). Then simply copy the <b>nanorc.sample</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 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, &quot;set nowrap&quot; or &quot;set smarthome&quot;.</p></blockquote>
<h2><a name="3.9b"></a>3.9b. How about in Win32?</h2>
<blockquote><p>If you're using the official nano .zip file and have extracted all the files, you should take the file nano.rc and place it somewhere on your Win32 system (for example, if you have write permission to do so, at the top of C:\). Then you must create an Environment variable called HOME which points to the directory where you put nano.rc. In Windows XP, you can get to Environment variables by right-clicking "My Computer" either on the desktop or in the Start Menu, and selecting Properties. This should bring up the System Properties panel. Then click the Advanced Tab, and there should be a button called Environment Variables. Click that to bring up the Environment Variables section. Now, under User Variables you should be able to click the New button, and make a new Variables Name called HOME, with the Variable Value of whatever path you copied nano.rc into (just the directory name; don't add nano.rc onto the end).</p>
<p>We're still working on documentation for enabling syntax highlighting on Win32; please bear with us.</p>
<p>Note that the nano.rc file must remain Unix-formatted in order for nano to understand it. In other words, you should probably use only nano to edit its config file. Other programs like Wordpad and Notepad will convert the file to DOS format when saving, and the latter does not even properly read Unix-formatted files to begin with.</p></blockquote>
<hr width="100%">
<h1><a name="4"></a>4. Running</h1>
<h2><a name="4.1"></a>4.1. How do I open a file with a name beginning with '+' from the command line?</h2>
@@ -182,9 +184,9 @@
<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>
<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 &lt;insert keystroke here&gt;!</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 database</a> on Savannah.</p></blockquote>
<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 a newer version (at least 0.9.9, but 2.2.6 is recommended).</p></blockquote>
<blockquote><p>Older versions of nano had this problem, please upgrade to a newer version (at least 0.9.9, but 2.4.2 is recommended).</p></blockquote>
<h2><a name="4.8"></a>4.8. [version 1.3.12 and later] I'm using glibc 2.2.3, and nano crashes when I use color support or do regular expression searches. How can I fix that?</h2>
<blockquote><p>It's a bug in glibc 2.2.3. You should upgrade to at least glibc 2.2.4.</p></blockquote>
<h2><a name="4.9"></a>4.9. [version 1.1.12 and earlier] Why does nano show ^\ in the shortcut list instead of ^J?</h2>
@@ -207,15 +209,15 @@
<p><b>my_hdr X-Composer: nano x.y.z</b></p>
<p>Again, replace x.y.z with the version of nano you use.</p></blockquote>
<h2><a name="4.12"></a>4.12. 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.9">3.9</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>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>
<h2><a name="4.13"></a>4.13. 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?</h2>
<blockquote><p>Try holding down the Shift key and selecting or pasting the text as you normally would.</p></blockquote>
<h2><a name="4.14"></a>4.14. 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.15"></a>4.15. On startup I get a message that says "Detected a legacy nano history file". Now older nano versions can't find my search history!</h2>
<blockquote><p>In nano 2.3.0, cursor-position history was introduced, and both history files now reside under a .nano directory in your home. nano was trying to move this file into the new location so it could continue to use it. This means that if you try and use an earlier version of nano, it will be unable to see your current search history. To fix this, run the following commands:<br>
mv ~/.nano/search_history ~/.nano_history<br>
ln -sf ~/.nano_history ~/.nano/search_history<br>
<p><b>mv ~/.nano/search_history ~/.nano_history</b><br>
<b>ln -sf ~/.nano_history ~/.nano/search_history</b></p>
</p></blockquote>
<hr width="100%">
<h1><a name="5"></a>5. Internationalization</h1>
@@ -256,7 +258,9 @@ Of course, due to the license change you can now use the <A HREF="http://www.was
<h2><a name="7.5"></a>7.5. Can I have write access to the subversion tree?</h2>
<blockquote><p>Re-read Section <a href="#7.4">7.4</a> and you should know the answer.</p></blockquote>
<h2><a name="8"></a>8. ChangeLog</h2>
<blockquote><p>2014/04/24 - A bunch of small fixes and updates. (Benno)<br>
<blockquote><p>
2015/07/18 - More small fixes and updates. (Benno)<br>
2014/04/24 - A bunch of small fixes and updates. (Benno)<br>
2009/11/30 - Update various bits for nano 2.2.x. (DLR)<br>
2009/11/18 - Typo fix. (j.mader@gmail.com)<br>
2008/03/16 - Update docs to refer to subversion instead of CVS, add more words about Alpine, and refer to Savannah for bugs and patches. (chrisa)<br>

View File

@@ -20,7 +20,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 2.4.0" "March 2015"
.TH NANO 1 "version 2.5.0" "December 2015"
.\" Please adjust this date whenever revising the manpage.
.\"
@@ -38,6 +38,27 @@ 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".
.SH EDITING
Entering text and moving around in a file is straightforward: typing the
letters and using the normal cursor movement keys. Commands are entered
by using the Control (^) and the Alt or Meta (M-) keys.
Typing \fB^K\fR deletes the current line and puts it in the cutbuffer.
Consecutive \fB^K\fRs will put all deleted lines together in the cutbuffer.
Any cursor movement or executing any other command will cause the next
\fB^K\fR to overwrite the cutbuffer. A \fB^U\fR will paste the current
contents of the cutbuffer at the current cursor position.
.PP
When a more precise piece of text needs to be cut or copied, one can mark
its start with \fB^6\fR, move the cursor to its end (the marked text will be
highlighted), and then use \fB^K\fR to cut it, or \fBM-6\fR to copy it to the
cutbuffer. One can also save the marked text to a file with \fB^O\fR, or
spell check it with \fB^T\fR.
.PP
The two lines at the bottom of the screen show the most 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).
.SH OPTIONS
.TP
.B +\fIline\fP,\fIcolumn\fP
@@ -53,12 +74,13 @@ already at that position, it will jump to the true beginning of the
line.
.TP
.BR \-B ", " \-\-backup
When saving a file, back up the previous version of it to the current
When saving a file, back up the previous version of it, using the current
filename suffixed with a tilde (\fB~\fP).
.TP
.BR \-C\ \fIdirectory\fR ", " \-\-backupdir= \fIdirectory
Set the directory where \fBnano\fP puts unique backup files, if file
backups are enabled.
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.
The uniquely numbered files are stored in the specified \fIdirectory\fR.
.TP
.BR \-D ", " \-\-boldtext
Use bold text instead of reverse video text.
@@ -93,9 +115,9 @@ Disable automatic conversion of files from DOS/Mac format.
.BR \-O ", " \-\-morespace
Use the blank line below the titlebar as extra editing space.
.TP
.BR \-P ", " \-\-poslog
.BR \-P ", " \-\-positionlog
Log and later read back the location of the cursor and place it there
again.
again. (The old form of this option, \fB\-\-poslog\fR, is deprecated.)
.TP
.BR "\-Q ""\fIcharacters\fB""" ", " "\-\-quotestr=""" \fIcharacters\fR """
Set the quoting string for justifying. The default is
@@ -135,7 +157,7 @@ characters as part of a word.
Specify the name of the syntax highlighting to use from among the ones
defined in the \fInanorc\fP files.
.TP
.BR \-c ", " \-\-const
.BR \-c ", " \-\-constantshow
Constantly show the cursor position. Note that this overrides \fB\-U\fP.
.TP
.BR \-d ", " \-\-rebinddelete
@@ -200,6 +222,11 @@ Use this alternative spell checker command.
Always save a changed buffer without prompting. Same as Pico's \fB\-t\fP
option.
.TP
.BR \-u ", " \-\-unix
Save a file by default in Unix format. This overrides nano's
default behavior of saving a file in the format that it had.
(This option has no effect when you also use \fB\-\-noconvert\fR.)
.TP
.BR \-v ", " \-\-view
View-file (read-only) mode.
.TP
@@ -248,12 +275,14 @@ it unique. In multibuffer mode, \fBnano\fP will write all the open
buffers to their respective emergency files.
.SH BUGS
Please send any comments or bug reports to \fBnano@nano-editor.org\fP.
The \fBnano\fP mailing list is available from \fBnano-devel@gnu.org\fP.
To subscribe, email to \fBnano-devel-request@gnu.org\fP with a subject
of "subscribe".
Justifications (\fB^J\fR) and reindentations (\fBM-{\fR and \fBM-}\fR)
are not yet covered by the general undo system. So after a justification
that is not immediately undone, or after any reindentation, earlier edits
cannot be undone any more. The workaround is, of course, to exit without
saving.
.sp
Please report any other bugs that you encounter via
https://savannah.gnu.org/bugs/?group=nano.
.SH HOMEPAGE
http://www.nano-editor.org/

View File

@@ -20,7 +20,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 2.4.0" "March 2015"
.TH NANORC 5 "version 2.5.0" "December 2015"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH NAME
@@ -64,11 +64,14 @@ NOT enable this option unless you are sure you need it.
Use auto-indentation.
.TP
.B set backup
Create backup files by adding a tilde (\fB~\fP) to each file's name.
When saving a file, create a backup file by adding a tilde (\fB~\fP) to
the file's name.
.TP
.B set backupdir "\fIdirectory\fP"
Set the directory where \fBnano\fP puts unique backup files, if file
backups are enabled.
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
with \fBset backup\fR or \fB\-\-backup\fR or \fB\-B\fR.
The uniquely numbered files are stored in the specified \fIdirectory\fR.
.TP
.B set backwards
Do backwards searches by default.
@@ -87,8 +90,9 @@ closing brackets, can end sentences. The default value is "\fB"')>]}\fP".
.B set casesensitive
Do case-sensitive searches by default.
.TP
.B set const
.B set constantshow
Constantly display the cursor position in the status bar.
(The old form of this option, '\fBset const\fR', is deprecated.)
.TP
.B set cut
Use cut-to-end-of-line by default, instead of cutting the whole line.
@@ -132,7 +136,7 @@ System, and on the console when gpm is running. Text can still be
selected through dragging by holding down the Shift key.
.TP
.B set multibuffer
Allow inserting files into their own buffers.
When reading in a file with ^R, insert it into a new buffer by default.
.TP
.B set noconvert
Don't convert files from DOS/Mac format.
@@ -155,8 +159,9 @@ subdirectories. Also, the current directory is changed to here, so
files are inserted from this directory. By default, the operating
directory feature is turned off.
.TP
.B set poslog
.B set positionlog
Save the cursor position of files between editing sessions.
(The old form of this option, '\fBset poslog\fR', is deprecated.)
.TP
.B set preserve
Preserve the XON and XOFF keys (^Q and ^S).
@@ -237,6 +242,11 @@ Valid color names for foreground and background are:
.BR white , \ black , \ red , \ blue , \ green , \ yellow , \ magenta ", and " cyan .
And either "\fIfgcolor\fR" or ",\fIbgcolor\fR" may be left out.
.TP
.B set unix
Save a file by default in Unix format. This overrides nano's
default behavior of saving a file in the format that it had.
(This option has no effect when you also use \fBset noconvert\fR.)
.TP
.B set view
Disallow file modification.
.TP
@@ -264,31 +274,30 @@ 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 following \fBcolor\fP and \fBicolor\fP statements
will apply to this \fIstr\fP syntax until a new syntax is defined.
\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.
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 other syntax's \fIfileregex\fP.
match any syntax's \fIfileregex\fP.
.TP
.BI linter " program " \fR[ "arg " \fR...]
For the currently defined syntax, use the given \fIprogram\fR
to invoke the linter (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 when defined).
.TP
.BI formatter " program " \fR[ "arg " \fR...]
For the currently defined syntax, 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 certain programming languages (e.g. Go).
.TP
.BR header " \fIregex\fR " ...
For the currently defined syntax, add one or more regexes which will
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 " ...
For the currently defined syntax, add one or more regexes which
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
@@ -296,7 +305,7 @@ functionality only works when \fBlibmagic\fP is installed on the
system and will be silently ignored otherwise.
.TP
.B color \fIfgcolor\fR,\fIbgcolor\fR """\fIregex\fR""" ...
For the currently defined syntax, display all expressions matching
Display all pieces of text that match
the extended regular expression \fIregex\fP with foreground color
\fIfgcolor\fP and background color \fIbgcolor\fP, at least one of which
must be specified. Valid colors for foreground and background
@@ -307,34 +316,34 @@ 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 expression matching is case insensitive.
Same as above, except that the text matching is case insensitive.
.TP
.BR color " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIsr\fR"" " end= """\fIer\fR""
Display expressions which start with the extended regular expression
\fIsr\fP and end with the extended regular expression \fIer\fP with
Display all pieces of text whose start matches extended regular expression
\fIsr\fP and whose end matches extended regular expression \fIer\fP with
foreground color \fIfgcolor\fP and background color \fIbgcolor\fP,
at least one of which must be specified. This allows syntax
highlighting to span multiple lines. Note that all subsequent instances
of \fIsr\fP after an initial \fIsr\fP is found will be highlighted until
the first instance of \fIer\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
multiple lines.
.TP
.BR icolor " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIsr\fR"" " end= """\fIer\fR""
Same as above, except that the expression matching is case insensitive.
Same as above, except that the text matching is case insensitive.
.TP
.BR include " ""\fIsyntaxfile\fR"""
Read in self-contained color syntaxes from \fIsyntaxfile\fP. Note that
\fIsyntaxfile\fP can only contain the above commands, from \fBsyntax\fP
\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 \fIcolor\fP, \fIicolor\fP,
\fImagic\fP, \fIheader\fP, or \fIlinter\fP directive to an already
defined syntax -- useful when you want to add to definitions from the
system-installed syntax definitions (which are normally not writable).
new information. This allows you to add a new \fBcolor\fP, \fBicolor\fP,
\fBheader\fP, \fBmagic\fP, \fBlinter\fP, or \fBformatter\fP directive
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)
.SH REBINDING KEYS
Key bindings may be reassigned via the following commands:
Key bindings can be changed via the following two commands:
.TP
.BI bind " key function menu"
Rebinds the key \fIkey\fP to a new function named \fIfunction\fP in the
@@ -363,7 +372,7 @@ Example: F10
.RE
.TP
Valid \fIfunction\fP names to be bound include:
Valid \fIfunction\fP names to be bound are:
.RS 3
.TP 2
.B help
@@ -376,18 +385,27 @@ Cancels the current command.
Exits from the program (or from the help viewer or the file browser).
.TP
.B writeout
Writes the current buffer to disk.
Writes the current buffer to disk, asking for a name.
.TP
.B savefile
Writes the current file to disk without prompting or warning.
.TP
.B insert
Inserts a file into the current buffer (or into a new buffer when multibuffer
is enabled).
Inserts a file into the current buffer (at the current cursor position),
or into a new buffer when option \fBmultibuffer\fR is set.
.TP
.B whereis
Searches for text in the current buffer -- or for filenames matching
a string in the current list in the file browser.
.TP
.B searchagain
Repeats the last search command.
Repeats the last search command without prompting.
.TP
.B findprevious
As \fBsearchagain\fR, but always in the backward direction.
.TP
.B findnext
As \fBsearchagain\fR, but always in the forward direction.
.TP
.B replace
Interactively replaces text within the current buffer.
@@ -405,6 +423,12 @@ current cursor position.
.B mark
Sets the mark at the current position, to start selecting text.
.TP
.B cutwordleft
Cuts from the cursor position to the beginning of the preceding word.
.TP
.B cutwordright
Cuts from the cursor position to the beginning of the next word.
.TP
.B cutrestoffile
Cuts all text from the cursor position till the end of the buffer.
.TP
@@ -418,6 +442,9 @@ Counts the number of words, lines and characters in the current buffer.
Invokes a spell-checking program (or a linting program, if the current
syntax highlighting defines one).
.TP
.B linter
A synonym of \fBspeller\fR (for when the speller has not been configured).
.TP
.B justify
Justifies the current paragraph.
.TP
@@ -448,12 +475,12 @@ Scrolls up one line of text from the current position.
.B scrolldown
Scrolls down one line of text from the current position.
.TP
.B nextword
Moves the cursor to the beginning of the next word.
.TP
.B prevword
Moves the cursor to the beginning of the previous word.
.TP
.B nextword
Moves the cursor to the beginning of the next word.
.TP
.B home
Moves the cursor to the beginning of the current line.
.TP
@@ -489,10 +516,10 @@ Moves the cursor to the bracket (brace, parenthesis, etc.) that matches
(pairs) with the one under the cursor.
.TP
.B prevbuf
Switches to editing/viewing the previous buffer when using multibuffer mode.
Switches to editing/viewing the previous buffer when multiple buffers are open.
.TP
.B nextbuf
Switches to editing/viewing the next buffer when using multibuffer mode.
Switches to editing/viewing the next buffer when multiple buffers are open.
.TP
.B verbatim
Inserts the next character verbatim into the file.
@@ -613,10 +640,11 @@ Toggles whether long lines will be hard-wrapped to the next line.
Toggles whether typed tabs will be converted to spaces.
.TP
.B backupfile
Toggles whether a backup will be made of the file to be edited.
Toggles whether a backup will be made of the file being edited.
.TP
.B multibuffer
Toggles the use of multiple file buffers (if support for them has been compiled in).
Toggles whether a file is inserted into the current buffer
or read into a new buffer.
.TP
.B mouse
Toggles mouse support.

View File

@@ -19,7 +19,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH RNANO 1 "version 2.4.0" "March 2015"
.TH RNANO 1 "version 2.5.0" "December 2015"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH NAME

View File

@@ -46,7 +46,8 @@
## Constantly display the cursor position in the statusbar. Note that
## this overrides "quickblank".
# set const
# set constantshow
## (The old form, 'const', is deprecated.)
## Use cut-to-end-of-line by default.
# set cut
@@ -104,7 +105,8 @@
# set operatingdir ""
## Remember the cursor position in each file for the next editing session.
# set poslog
# set positionlog
## (The old form, 'poslog', is deprecated.)
## Preserve the XON and XOFF keys (^Q and ^S).
# set preserve
@@ -235,13 +237,15 @@
## Key bindings.
## See nanorc(5) for more details on this.
## See nanorc(5) (section REBINDING KEYS) for more details on this.
##
## Here are a few samples to get you going.
##
# bind M-W nowrap main
# bind M-A casesens search
# bind ^S research main
## The following five functions are not bound to any key by default.
## You may wish to choose different keys than the ones suggested here.
# bind ^S savefile main
# bind M-Q findprevious main
# bind M-W findnext main
# bind M-B cutwordleft main
# bind M-N cutwordright main
## Set this if your backspace key sends Del most of the time.
## Set this if your Backspace key sends Del most of the time.
# bind Del backspace all

View File

@@ -6,10 +6,12 @@ pkgdata_DATA = asm.nanorc \
css.nanorc \
debian.nanorc \
default.nanorc \
elisp.nanorc \
fortran.nanorc \
gentoo.nanorc \
go.nanorc \
groff.nanorc \
guile.nanorc \
html.nanorc \
java.nanorc \
javascript.nanorc \
@@ -26,6 +28,7 @@ pkgdata_DATA = asm.nanorc \
perl.nanorc \
php.nanorc \
po.nanorc \
postgresql.nanorc \
pov.nanorc \
python.nanorc \
ruby.nanorc \

View File

@@ -0,0 +1,28 @@
## Here is an example for Autoconf.
syntax "autoconf" "\.ac$"
# Keywords:
color yellow "\<(if|test|then|else|fi|for|in|do|done)\>"
color yellow "(=|!=|&&|\|\|)"
# Macros:
color cyan "\<[[:upper:]_[:digit:]]+\>"
# Version numbers:
color red "\<[-_.0-9]+\>"
# Strings:
color red "\"[^"]*\"" "\'[^']*\'"
# Backticks:
color green "`[^`]*`"
# Error lines:
color black "^\*\*\*.*"
# Brackets:
color magenta "\[|\]|\(|\)"
# Comments:
color blue "^[[:blank:]]*#.*" "^dnl.*"

View File

@@ -9,17 +9,20 @@ color red "^(19|20)[0-9-]{8}"
# Email addresses.
color yellow "<[^>]*@[^>]*>"
# Changed files.
color magenta "[[:space:]]\*[[:space:]].*:"
# Command-line options.
color cyan "[[:space:]]-[a-zA-Z\$]" "--[8a-z-]+"
# Bug numbers.
color cyan "bug #[0-9]{5}"
# Probable variables, for variety.
# Bug and patch numbers.
color cyan "bug #[0-9]{5,9}" "patch #[0-9]{4,9}"
# Probable constants, for variety.
color brightred "\<[A-Z_][0-9A-Z_]+\>"
# Key sequences.
color brightblue "\^[A-Z]" "\<M-." "\<F1?[0-9]" "(\^|M-)Space"
# Changed files.
color magenta start="^( | {8})\* " end="(:( |$)|^$)"
# Release markers.
color brightblue "^(GNU )?nano[- ][0-9]\.[0-9]\.[^ ]+"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -1,19 +1,20 @@
## Here is an example for apt's sources.list.
syntax "apt/sources.list" "sources\.list(\.old|~)?$" "apt/sources\.list\.d/.*\.list$"
syntax "sources.list" "sources\.list(~|\.old|\.save)?$" "sources\.list\.d/.*\.list(~|\.old|\.save)?$"
# Coloring the deb lines, working from tail to head. First the
# components -- well, everything, and thus also the components.
color brightmagenta "^deb.*"
# Distribution -- well, everything, except the components.
color brightred "^deb(-src)? ((http(s)?|ftp|rsh|ssh|file|copy|tor|spacewalk):/[^ ]+|cdrom:\[[-a-zA-Z0-9\._\(\) ]+\]/) [^ ]+"
color brightred "^deb(-src)?\s+.*((ftp|https?|rsh|ssh|copy|file|spacewalk|tor):/\S+|cdrom:\[.+\]/)\s+\S+"
# URIs.
color brightgreen "(http(s)?|ftp|rsh|ssh|file|copy|tor|spacewalk):/[^ ]+"
color brightgreen "^deb(-src)?\s+.*(ftp|https?|rsh|ssh|copy|file|spacewalk|tor):/\S+"
# CDroms.
color brightgreen "cdrom:\[[-a-zA-Z0-9\._\(\) ]+\]/"
color brightgreen "^deb(-src)?\s+.*cdrom:\[.+\]/"
# Options.
color brightcyan "^deb(-src)?\s+\[.+\]\s+"
# And finally the initial deb tag.
color yellow "^deb(-src)?"
# Comments.
color brightblue "#.*"

31
doc/syntax/elisp.nanorc Normal file
View File

@@ -0,0 +1,31 @@
## Here is an example for Emacs Lisp.
syntax "elisp" "\.el$"
# Basic functions/macros
color brightcyan "\<(if|when|unless|cond|and|or|lambda|let|progn|while|dolist|dotimes)\>"
color brightcyan "\<save-((window-)?excursion|restriction)\>"
color brightcyan "\<eval-(and|when)-compile\>"
# Defining functions
color brightcyan "\<def(un|macro|subst|generic|alias)\>"
color brightcyan "\<cl-def(un|macro|subst|generic|struct|type)\>"
color brightcyan "\<define-(derived|minor|generic)-mode\>"
# Defining variables
color brightcyan "\<def(class|const|var(-local|alias)?)\>"
# Customization functions
color brightcyan "\<def(custom|face|group|theme)\>"
# Setting values
color brightcyan "\<(setq(-default|-local)?|setf|push|pop|declare(-function)?)\>"
# Feature functions
color brightcyan "\<(require|provide)\>"
# Quoted symbols
color brightyellow "#?'\<(\w|-)+\>"
# Booleans
color brightred "\<(t|nil)\>"
# Keywords
color blue ":(\w|[?-])+"
# Strings
color yellow start="^[[:blank:]]+\"" end="[^\]\""
color yellow ""(\\.|[^"])*""
# Comments
color cyan "(^|[[:space:]]);.*$"

View File

@@ -3,7 +3,7 @@
syntax "groff" "\.m[ems]$" "\.rof" "\.tmac$" "^tmac."
# The argument of .ds or .nr
color cyan "^\.(ds|nr) [^[[:space:]]]*"
color cyan "^\.(ds|nr) [^[:space:]]*"
# Single-character escapes
color brightmagenta "\\."
# The argument of \f or \s in the same color
@@ -12,7 +12,7 @@ color brightmagenta "\\f." "\\f\(.." "\\s(\+|\-)?[0-9]"
color cyan "(\\|\\\\)n(.|\(..)"
color cyan start="(\\|\\\\)n\[" end="]"
# Requests
color brightgreen "^\.[[:space:]]*[^[[:space:]]]*"
color brightgreen "^\.[[:space:]]*[^[:space:]]*"
# Comments
color yellow "^\.\\".*$"
# Strings

24
doc/syntax/guile.nanorc Normal file
View File

@@ -0,0 +1,24 @@
## Here is an example for Guile Scheme.
syntax "guile" "\.scm$"
header "^#!.*guile"
magic "guile"
# Basic scheme functions
color green "\<(do|if|lambda|let(rec)?|map|unless|when)\>"
# Defining things
color brightcyan "\<define(-macro|-module|-public|-syntax)?\>"
# Quoted symbols
color brightyellow "'\<(\w|-)+\>"
# Chars
color brightmagenta "#\\."
color brightmagenta "#\\\w+\>"
# Booleans
color brightred "(#t|#f)\>"
# Keywords
color blue "#?:(\w|[?-])+"
# Strings
color yellow start="^[[:blank:]]+\"" end="[^\]\""
color yellow ""(\\.|[^"])*""
# Comments
color cyan "(^|[[:space:]]);.*$"

View File

@@ -1,6 +1,6 @@
## Here is an example for Makefiles.
syntax "makefile" "Makefile[^/]*$"
syntax "makefile" "Makefile[^/]*$" "\.(make|mk)$"
color red "[:=]"
color magenta "\<(if|ifeq|else|endif)\>"

View File

@@ -6,13 +6,13 @@ syntax "nanorc" "\.?nanorc$"
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|linter|i?color|extendsyntax).*$"
# Keywords
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|const|cut|fill|historylog|locking|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|poslog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|suspend|tabsize|tabstospaces|tempfile|view|wordbounds)\>"
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|const(antshow)?|cut|fill|historylog|locking|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|pos(ition)?log|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|suspend|tabsize|tabstospaces|tempfile|unix|view|wordbounds)\>"
icolor yellow "^[[:space:]]*set[[:space:]]+(functioncolor|keycolor|statuscolor|titlecolor)[[: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|operatingdir|punct|quotestr|speller|statuscolor|titlecolor|whitespace)[[:space:]]+"
icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^|M-)([[:alpha:]]|space|[]]|[0-9_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]+[[:alpha:]]+[[:space:]]*$"
icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^|M-)([[:alpha:]]|space|[]]|[0-9_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]*$"
icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^|M-)([[:alpha:]]|space|[]]|[0-9_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]+(all|main|search|replace(2|with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)+[[:space:]]*$"
icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^|M-)([[:alpha:]]|space|[]]|[0-9_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+(all|main|search|replace(2|with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)+[[:space:]]*$"
icolor brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|linter|formatter)[[:space:]]+.*$"
icolor green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|linter|extendsyntax)\>"
icolor green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|linter|formatter|extendsyntax)\>"
# Colors
icolor yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"

View File

@@ -0,0 +1,29 @@
## Here is an example for nftables.
syntax "nftables" "\.(nft|nftables)$"
header "^#!.*(nft|nftables)"
# Objects and operations
color green "\<(chain|hook|policy|priority|ruleset|set|table|type|v?map)\>"
color green "\<(define|include)\>"
color red "\<(add|delete|flush|insert|remove|replace)\>"
# Families
color yellow "\<(arp|bridge|inet|ip6?)\>"
# Terminal statements
color red "\<(drop|reject)\>"
color brightblue "\<(accept|continue|(d|s)nat|goto|jump|masquerade|return)\>"
# Comments
color cyan "(^|[[:space:]])#.*$"
# Trailing whitespace
color ,green "[[:space:]]+$"
# Strings and others
color yellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"
color green "[{}():;|`$<>!=&\\]" "(\]|\[)"
# Basic variable names
color brightred "\$[[:alpha:]_][[:alnum:]_.]*"

View File

@@ -1,6 +1,6 @@
## Here is an example for patch files.
syntax "patch" "\.(patch|diff)$"
syntax "patch" "\.(patch|diff|debdiff)$"
magic "diff output text"
# Added lines.

View File

@@ -25,7 +25,7 @@ color brightyellow "<[^= ]*>" ""(\.|[^"])*""
color brightblue "//.*"
color brightblue start="/\*" end="\*/"
##color blue start="<" end=">"
##color red "&[^;[[:space:]]]*;"
##color red "&[^;[:space:]]*;"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -6,16 +6,16 @@ syntax "po" "\.pot?$"
color green "^#.*$"
color yellow "Copyright|\(C\)"
# Header fields.
color brightmagenta "\<(Project\-Id\-Version|Report\-Msgid\-Bugs\-To|Last\-Translator|Language\-Team|Language|X\-Generator|Plural\-Forms)\>"
color brightmagenta "\<(Project\-Id\-Version|Report\-Msgid\-Bugs\-To|Last\-Translator|Language(\-Team)?|X\-Generator|Plural\-Forms)\>"
color cyan "\<(POT\-Creation\-Date|PO\-Revision\-Date|MIME\-Version|Content\-Type|Content\-Transfer\-Encoding)\>"
# Encodings and numbers.
color yellow "\<(UTF|ISO|Windows|Mac|IBM)\>\-[0-9]"
color yellow "[0-9]|pre[0-9]|[0-9]bit"
# Msgids.
color brightblue "\<(msgid|msgid_plural|msgstr)\>"
color brightblue "^(msgid|msgid_plural|msgstr)\>"
# Tags.
color red "\<fuzzy\>"
color yellow "\<c-format\>"
color red " fuzzy(,|$)"
color yellow " (no-)?[-[:alpha:]]+-format(,|$)"
# Format specifiers.
color brightmagenta "%([1-9]\$)?[a-z]*"
# Quotes and newlines.

View File

@@ -0,0 +1,75 @@
## Here is an example for PostgreSQL.
syntax "sql" "\.sql[2345s~]?$"
magic "PostgreSQL script text"
# Functions.
color white "\<[a-z_]*\("
# Types.
color green "\<(int2|smallint|int4|int|integer|int8|bigint|decimal|numeric|real|double precision|(small|big)?serial)\>"
color green "\<(bit( varying)?|boolean|bytea|enum|money|tsvector|uuid)\>"
color green "\<(char|varchar|character( varying)?|text)\>"
color green "\<(date|interval|time(stamp)?( with time zone| without time zone)?)\>"
color green "\<(point|line|lseg|path|box|polygon|circle)\>"
color green "\<(cidr|inet|macaddr)\>"
color green "\<(daterange|int4range|int8range|numrange|tsrange|tstzrange)\>"
# Structure.
color brightyellow "\<(CASE|CLASS|DEFAULT|DO|ELSE|ELSEIF|FOR|FOREACH|FUNCTION|IF|IS NULL)\>"
color brightyellow "\<(NEW|PRIVATE|PUBLIC|RETURN|RETURNS|SETOF|SWITCH|THEN|WHEN|WHILE)>"
# Control flow.
color magenta "\<(EXCEPTION|NOTICE|RAISE|RETURN)\>"
# SQL keywords.
color blue "\<(ABORT|AGGREGATE|ALTER|ANALYZE|AND|AS|AUTHORIZATION|BEGIN|CAST|CHECKPOINT|CLASS|CLOSE)\>"
color blue "\<(CLUSTER|COLLATION|COMMENT|COMMIT|CONFIGURATION|CONSTRAINTS|CONVERSION|COPY|CREATE)\>"
color blue "\<(DATA|DATABASE|DEALLOCATE|DECLARE|DEFAULT|DELETE|DICTIONARY|DISCARD|DO|DOMAIN|DROP)\>"
color blue "\<(END|EVENT|EXECUTE|EXPLAIN|EXTENSION|FAMILY|FETCH|FOREIGN|FROM|FUNCTION)\>"
color blue "\<(GRANT|GROUP|IF NOT EXISTS|IMMUTABLE|INDEX|INSERT|INTO|LABEL|LANGUAGE|LARGE|LOAD|LOCK)\>"
color blue "\<(MAPPING FOR|MATERIALIZED|MOVE|NOTIFY|OBJECT|OPERATOR|OPTIONS|OWNED|OWNER)\>"
color blue "\<(PARSER|PREPARED?|PRIVILEGES|REASSIGN|REFRESH|RELEASE|RESET|REVOKE|ROLE|ROLLBACK|RULE)\>"
color blue "\<(SAVEPOINT|SCHEMA|SEARCH|SECURITY|SELECT|SEQUENCE|SERVER|SESSION|SET|SHOW|SPACE|START|SYSTEM)\>"
color blue "\<(TABLE|TEXT|TO|TRANSACTION|TYPE|UPDATE|USER|VACUUM|VALUES|VIEW|WHERE|WITH|WRAPPER)\>"
# Strings.
color brightyellow "<[^= ]*>" ""(\.|[^"])*""
# Trailing whitespace.
color ,green "[[:space:]]+$"
# Regular expressions.
color brightmagenta "/([^/]|(\\/))*/[iomx]*" "%r\{([^}]|(\\}))*\}[iomx]*"
# Shell command expansion is in `backticks` or like %x{this}. These are
# "double-quotish" (to use a perlism).
color brightblue "`[^`]*`" "%x\{[^}]*\}"
# Strings, double-quoted.
color green ""([^"]|(\\"))*"" "%[QW]?\{[^}]*\}" "%[QW]?\([^)]*\)" "%[QW]?<[^>]*>"
color green "%[QW]?\[[^]]*\]" "%[QW]?\$[^$]*\$" "%[QW]?\^[^^]*\^" "%[QW]?![^!]*!"
# Expression substitution. These go inside double-quoted strings,
# "like #{this}".
color brightgreen "#\{[^}]*\}"
# Strings, single-quoted.
color green "'([^']|(\\'))*'" "%[qw]\{[^}]*\}" "%[qw]\([^)]*\)" "%[qw]<[^>]*>"
color green "%[qw]\[[^]]*\]" "%[qw]\$[^$]*\$" "%[qw]\^[^^]*\^" "%[qw]![^!]*!"
# Comments.
color red "#[^{].*$" "#$"
color red "--[^{].*$" "#$"
color red "##[^{].*$" "##$"
color brightblue "//.*"
color brightblue start="/\*" end="\*/"
# PostgreSQL markings.
color red "(--)"
# PostgreSQL default schemas.
color brightred "(pg_catalog|public)"
# PostgreSQL PLs.
color brightblue "(pljava|plperlu?|plpgsql|plpy|plpythonu?|plr|plruby|plsh|pltcl|plscheme)"

View File

@@ -2,6 +2,7 @@
syntax "python" "\.py$"
header "^#!.*python[-0-9._]*"
linter pyflakes
# Function definitions.
icolor brightblue "def [0-9A-Z_]+"
@@ -9,15 +10,15 @@ icolor brightblue "def [0-9A-Z_]+"
color brightcyan "\<(and|as|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from)\>"
color brightcyan "\<(global|if|import|in|is|lambda|not|or|pass|print|raise|return|try|while|with|yield)\>"
# Strings.
color brightgreen "['][^']*[^\\][']" "[']{3}.*[^\\][']{3}"
color brightgreen "["][^"]*[^\\]["]" "["]{3}.*[^\\]["]{3}"
# Multiline strings.
color brightgreen start="\"\"\"([^"),]|$)" end="(^|[^(])\"\"\""
color brightgreen start="'''([^'),]|$)" end="(^|[^(])'''"
# Single-quoted strings.
color brightgreen "'([^'\]|\\.)+'"
color brightgreen ""([^"\]|\\.)+""
# Comments.
color brightred "(^|[[:blank:]])#.*$"
# Triple-quoted strings.
color brightgreen start="'''[^'),]" end="(^|[^(\])'''"
color brightgreen start="\"\"\"[^"),]" end="(^|[^(\])\"\"\""
# Reminders.
color ,yellow "(FIXME|TODO|XXX)"

View File

@@ -2,6 +2,7 @@
syntax "ruby" "\.rb$"
header "^#!.*ruby[-0-9._]*"
linter ruby -w -c
# Reserved words.
color yellow "\<(BEGIN|END|alias|and|begin|break|case|class|def|defined\?|do|else|elsif|end|ensure|false|for|if|in|module)\>"

View File

@@ -3,6 +3,7 @@
syntax "sh" "\.sh$"
header "^#!.*((ba|da|k|pdk)?sh[-0-9_]*|openrc-run|runscript)"
magic "(POSIX|Bourne.*) shell script text"
linter dash -n
icolor brightgreen "^[0-9A-Z_]+\(\)"
color green "\<(break|case|continue|do|done|elif|else|esac|exit|fi|for|function|if|in|read|return|select|shift|then|time|until|while)\>"

View File

@@ -1,6 +1,7 @@
## Here is a short example for TeX files.
syntax "tex" "\.tex$"
linter chktex -v0 -q -I
icolor green "\\.|\\[A-Z]*"
color magenta "[{}]"

View File

@@ -1,11 +1,20 @@
## Here is an example for XML files.
syntax "xml" "\.([jrs]html?|sgml?|xml|xslt?)$"
syntax "xml" "\.([jrsx]html?|jnlp|mml|pom|rng|sgml?|svg|w[as]dl|wsdd|xjb|xml|xs(d|lt?)|xul)$"
magic "(XML|SGML) (sub)?document text"
# The entire content of the tag:
color green start="<" end=">"
color cyan "<[^> ]+"
color cyan ">"
# The start and the end of the tag:
color cyan "<[^> ]+" ">"
# The strings inside the tag:
color magenta "\"[^"]*\""
# Comments:
color yellow start="<!DOCTYPE" end="[/]?>"
color yellow start="<!--" end="-->"
# Escapes:
color red "&[^;]*;"

View File

@@ -1,15 +1,13 @@
\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename nano.info
@settitle nano Command Manual
@settitle nano
@c %**end of header
@c This file has the new style title page commands.
@c Run 'makeinfo' rather than 'texinfo-format-buffer'.
@smallbook
@set EDITION 0.3
@set VERSION 2.4.0
@set UPDATED March 2015
@set VERSION 2.5.0
@set UPDATED December 2015
@dircategory Editors
@direntry
@@ -23,7 +21,7 @@
@titlepage
@title GNU @code{nano}
@subtitle a small and friendly text editor.
@subtitle version 2.4.0
@subtitle version 2.5.0
@author Chris Allegretta
@page
@@ -63,8 +61,10 @@ editor.
@menu
* Introduction::
* Invoking::
* Command-line Options::
* Editor Basics::
* Online Help::
* Built-in Help::
* Feature Toggles::
* Nanorc Files::
* The File Browser::
@@ -77,51 +77,49 @@ editor.
@chapter Introduction
GNU @code{nano} is a small and friendly text editor. Besides basic text
editing, @code{nano} offers many extra features, like an interactive
search-and-replace, go-to-line-and-column-number, auto-indentation,
feature toggles, internationalization support, and filename tab
completion.
editing, @code{nano} offers many extra features, such as an interactive
search-and-replace, undo/redo, syntax coloring, smooth scrolling,
auto-indentation, go-to-line-and-column-number, feature toggles,
file locking, backup files, and internationalization support.
@menu
* Overview::
* Command Line Options::
@end menu
@node Overview
@section Overview
The original goal for @code{nano} was a complete bug-for-bug compatible
emulation of Pico, but @code{nano}'s current goal is to be as compatible
The original goal for @code{nano} was to be a complete bug-for-bug
emulation of Pico. But currently the goal is to be as compatible
as possible while offering a superset of Pico's functionality. See
@xref{Pico Compatibility}, for more info.
Please report bugs via @url{https://savannah.gnu.org/bugs/?group=nano}.
@node Invoking
@chapter Invoking
The usual way to invoke @code{nano} is:
@quotation
@code{nano [OPTION]@dots{} [FILE]}
@code{nano [FILE]}
@end quotation
But it is also possible to edit several files in a row. Additionally,
the cursor can be put on a desired line number by adding this number
with a plus sign before any filename, and even in a desired column by
adding it with a comma. So the complete synopsis is:
But it is also possible to specify one or more options, and to edit
several files in a row. Additionally, the cursor can be put on a
specific line of a file by adding the line number
with a plus sign before the filename, and even in a specific column by
adding it with a comma. So the complete command synopsis is:
@quotation
@code{nano [OPTION]@dots{} [[+LINE] FILE]@dots{}}
@code{nano [OPTION]@dots{} [[+,COLUMN] FILE]@dots{}}
@code{nano [OPTION]@dots{} [[+LINE,COLUMN] FILE]@dots{}}
@code{nano [OPTION]@dots{} [[+LINE[,COLUMN]|+,COLUMN] FILE]@dots{}}
@end quotation
Email bug reports to @email{nano@@nano-editor.org}.
But normallly you would set your preferred options in your
@file{.nanorc} file. And when the @code{positionlog} option is set
(making @code{nano} remember the cursor position when you close a file),
you will rarely need to specify a line number.
@node Command Line Options
@section Command Line Options
@node Command-line Options
@chapter Command-line Options
@command{nano} takes the following options from the command line:
@table @option
@item +@var{line},@var{column}
Start at line number @var{line} and column number @var{column} (at least one of
which must be specified) instead of the default of line 1, column 1.
@@ -136,13 +134,14 @@ line.
@item -B
@itemx --backup
When saving a file, back up the previous version of it to the current
filename suffixed with a @samp{~}.
When saving a file, back up the previous version of it, using the current
filename suffixed with a tilde (@code{~}).
@item -C @var{directory}
@itemx --backupdir=@var{directory}
Set the directory where @command{nano} puts unique backup files if file
backups are enabled.
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.
The uniquely numbered files are stored in the specified directory.
@item -D
@itemx --boldtext
@@ -154,7 +153,7 @@ Convert typed tabs to spaces.
@item -F
@itemx --multibuffer
Enable multiple file buffers (if support for them has been compiled in).
Read a file into a new buffer by default.
@item -G
@itemx --locking
@@ -188,20 +187,17 @@ Disable automatic conversion of files from DOS/Mac format.
Use the blank line below the titlebar as extra editing space.
@item -P
@itemx --poslog
@itemx --positionlog
Log for each file the last location of the cursor, and read it
back upon reopening the file and place it there again.
(The old form of this option, @code{--poslog}, is deprecated.)
@item -Q "@var{characters}"
@itemx --quotestr="@var{characters}"
Set the quoting string for justifying. The default value is
@quotation
"^([ \t]*[|>:@}#])+"
@end quotation
if extended regular expression support is available, or @code{> } otherwise.
Note that @code{\t} above stands for a literal Tab character.
@t{"^([ \t]*[|>:@}#])+"} if extended regular expression support
is available, and @t{"> "} otherwise.
Note that @code{\t} stands for a literal Tab character.
@item -R
@itemx --restricted
@@ -211,7 +207,7 @@ suspending nor spell checking; don't
allow a file to be appended to, prepended to, or saved under a different
name if it already has one; and don't use backup files.
This restricted mode is also accessible by invoking @command{nano} with
any name beginning with @samp{r} (e.g. @command{rnano}).
any name beginning with @code{r} (e.g.@: @command{rnano}).
@item -S
@itemx --smooth
@@ -221,12 +217,13 @@ usual chunk-by-chunk behavior.
@item -T @var{number}
@itemx --tabsize=@var{number}
Set the displayed tab length to @var{number} columns. The value of
@var{number} must be greater than 0. The default value is @samp{8}.
@var{number} must be greater than 0. The default value is @t{8}.
@item -U
@itemx --quickblank
Do quick statusbar blanking. Statusbar messages will disappear after 1
keystroke instead of 25. Note that @option{-c} overrides this.
keystroke instead of 25. Note that option @option{-c}
(@option{--constantshow}) overrides this.
@item -V
@itemx --version
@@ -243,9 +240,9 @@ Specify a specific syntax from the nanorc files to use for highlighting.
See @xref{Syntax Highlighting}, for more info.
@item -c
@itemx --const
@itemx --constantshow
Constantly display the cursor position and line number on the statusbar.
Note that this overrides @option{-U}.
Note that this overrides option @option{-U} (@option{--quickblank}).
@item -d
@itemx --rebinddelete
@@ -309,8 +306,8 @@ Hard-wrap lines at column @var{number} (by inserting a newline character).
If the given value is 0 or less, wrapping will occur at the width of
the screen minus the given amount, allowing the wrapping width to
vary along with the width of the screen if and when it is resized.
The default value is @samp{-8}. This option conflicts with @option{-w}
-- the last one given takes effect.
The default value is @t{-8}. This option conflicts with @option{-w}
(@option{--nowrap}); the last one given takes effect.
@item -s @var{program}
@itemx --speller=@var{program}
@@ -325,6 +322,12 @@ Don't ask whether or not to save the current contents of the file when
exiting, assume yes. This is most useful when using @command{nano} as the
composer of a mailer program.
@item -u
@item --unix
Save a file by default in Unix format. This overrides nano's
default behavior of saving a file in the format that it had.
(This option has no effect when you also use @code{--noconvert}.)
@item -v
@itemx --view
Don't allow the contents of the file to be altered. Note that this
@@ -334,7 +337,7 @@ implement a read-only file.
@item -w
@itemx --nowrap
Don't hard-wrap long lines at any length. This option conflicts with
@option{-r} -- the last one given takes effect.
@option{-r} (@option{--fill}); the last one given takes effect.
@anchor{Expert Mode}
@item -x
@@ -356,9 +359,9 @@ keystroke (usually ^Z).
Enable 'soft wrapping'. This will make @command{nano} attempt to display the
entire contents of any line, even if it is longer than the screen width, by
continuing it over multiple screen lines. Since
@samp{$} normally refers to a variable in the Unix shell, you should specify
this option last when using other options (e.g. @code{nano -wS$}) or pass it
separately (e.g. @code{nano -wS -$}).
@code{$} normally refers to a variable in the Unix shell, you should specify
this option last when using other options (e.g.@: @code{nano -wS$}) or pass it
separately (e.g.@: @code{nano -wS -$}).
@item -a
@itemx -b
@@ -367,6 +370,7 @@ separately (e.g. @code{nano -wS -$}).
@itemx -g
@itemx -j
Ignored, for compatibility with Pico.
@end table
@@ -382,6 +386,7 @@ Ignored, for compatibility with Pico.
* The Statusbar::
* Shortcut Lists::
* Using the Mouse::
* Limitation::
@end menu
@node Entering Text
@@ -486,78 +491,87 @@ Shift key during those actions.
The mouse will work in the X Window System, and on the console when gpm
is running.
@node Limitation
@section Limitation
@node Online Help
@chapter Online Help
Justifications (@code{^J}) and reindentations (@code{M-@{} and @code{M-@}})
are not yet covered by the general undo system. So after a justification
that is not immediately undone, or after any reindentation, earlier edits
cannot be undone any more. The workaround is, of course, to exit without
saving.
The online help system in @code{nano} is available by pressing ^G.
It is fairly self-explanatory, documenting the various parts of the
editor and available keystrokes. Navigation is via the ^Y (Page Up)
@node Built-in Help
@chapter Built-in Help
The built-in help system in @code{nano} is available by pressing ^G@.
It is fairly self-explanatory. It documents the various parts of the
editor and the available keystrokes. Navigation is via the ^Y (Page Up)
and ^V (Page Down) keys. ^X exits the help system.
@node Feature Toggles
@chapter Feature Toggles
Toggles allow you to change certain aspects of the editor that would
normally be done via command-line options. They are invoked via Meta
key sequences. See @xref{Special Functions}, for more info. The
following global toggles are available:
Toggles allow you to change on-the-fly certain aspects of the editor
which would normally be specified via command-line options. They are
invoked via Meta-key sequences. See @xref{Special Functions}, for more info.
The following global toggles are available:
@table @code
@item Backup Files Toggle (Meta-B)
toggles the -B (@code{--backup}) command line option.
toggles the @code{-B} (@code{--backup}) command-line option.
@item Constant Cursor Position Display Toggle (Meta-C)
toggles the -c (@code{--const}) command line option.
toggles the @code{-c} (@code{--constantshow}) command-line option.
@item Multiple File Buffers Toggle (Meta-F)
toggles the -F (@code{--multibuffer}) command line option.
toggles the @code{-F} (@code{--multibuffer}) command-line option.
@item Smart Home Key Toggle (Meta-H)
toggles the -A (@code{--smarthome}) command line option.
toggles the @code{-A} (@code{--smarthome}) command-line option.
@item Auto Indent Toggle (Meta-I)
toggles the -i (@code{--autoindent}) command line option.
toggles the @code{-i} (@code{--autoindent}) command-line option.
@item Cut To End Toggle (Meta-K)
toggles the -k (@code{--cut}) command line option.
toggles the @code{-k} (@code{--cut}) command-line option.
@item Long Line Wrapping Toggle (Meta-L)
toggles the -w (@code{--nowrap}) command line option.
toggles the @code{-w} (@code{--nowrap}) command-line option.
@item Mouse Support Toggle (Meta-M)
toggles the -m (@code{--mouse}) command line option.
toggles the @code{-m} (@code{--mouse}) command-line option.
@item No Conversion From DOS/Mac Format Toggle (Meta-N)
toggles the -N (@code{--noconvert}) command line option.
toggles the @code{-N} (@code{--noconvert}) command-line option.
@item More Space For Editing Toggle (Meta-O)
toggles the -O (@code{--morespace}) command line option.
toggles the @code{-O} (@code{--morespace}) command-line option.
@item Whitespace Display Toggle (Meta-P)
toggles whitespace-display mode.
toggles the whitespace-display mode.
See @xref{Whitespace}, for more info.
@item Tabs to Spaces Toggle (Meta-Q)
toggles the -E (@code{--tabstospaces}) command line option.
toggles the @code{-E} (@code{--tabstospaces}) command-line option.
@item Smooth Scrolling Toggle (Meta-S)
toggles the -S (@code{--smooth}) command line option.
toggles the @code{-S} (@code{--smooth}) command-line option.
@item Expert/No Help Toggle (Meta-X)
toggles the -x (@code{--nohelp}) command line option.
toggles the @code{-x} (@code{--nohelp}) command-line option.
@item Color Syntax Highlighting Toggle (Meta-Y)
toggles color syntax highlighting if you have color syntaxes in your
nanorc. See @xref{Syntax Highlighting}, for more info.
@item Suspend Toggle (Meta-Z)
toggles the -z (@code{--suspend}) command line option.
@item Suspension Toggle (Meta-Z)
toggles the @code{-z} (@code{--suspend}) command-line option.
@item Soft Wrapping Toggle (Meta-$)
toggles the -$ (@code{--softwrap}) command line option.
toggles the @code{-$} (@code{--softwrap}) command-line option.
@end table
@@ -569,12 +583,12 @@ The nanorc files contain the default settings for @code{nano}. They
should be in Unix format, not in DOS or Mac format. During startup,
@code{nano} will first read the system-wide settings, from /etc/nanorc
(the exact path might be different), and then the user-specific settings,
from ~/.nanorc.
from @file{~/.nanorc}.
A nanorc file accepts a series of "set" and "unset" commands, which can
be used to configure @code{nano} on startup without using command-line
options. Additionally, there are some commands to define syntax highlighting
and to rebind keys -- @xref{Syntax Highlighting}, and @xref{Rebinding Keys}.
and to rebind keys --- @xref{Syntax Highlighting}, and @xref{Rebinding Keys}.
@code{nano} will read one command per line.
Options in nanorc files take precedence over @code{nano}'s defaults, and
@@ -586,7 +600,7 @@ be unset.
Quotes inside string parameters don't have to be escaped with
backslashes. The last double quote in the string will be treated as its
end. For example, for the "brackets" option, @code{""')>]@}"} will match
end. For example, for the @code{brackets} option, @t{""')>]@}"} will match
@code{"}, @code{'}, @code{)}, @code{>}, @code{]}, and @code{@}}.
@menu
@@ -611,12 +625,14 @@ You should NOT enable this option unless you are sure you need it.
Use auto-indentation.
@item set backup
When saving a file, back up the previous version of it to the current
When saving a file, back up the previous version of it, using the current
filename suffixed with a tilde (@code{~}).
@item set backupdir "directory"
Set the directory where @code{nano} puts unique backup files, if file
backups are enabled.
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
with @code{set backup} or @code{--backup} or @code{-B}.
The uniquely numbered files are stored in the specified directory.
@item set backwards
Do backwards searches by default.
@@ -624,23 +640,21 @@ Do backwards searches by default.
@item 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 "titlecolor", "statuscolor", and "keycolor".
the options @code{titlecolor}, @code{statuscolor}, and @code{keycolor}.
@item set brackets "@var{string}"
Set the characters treated as closing brackets when justifying
paragraphs. This may not include blank characters. Only closing
punctuation (see "punct"), optionally followed by the specified
punctuation (see @code{set punct}), optionally followed by the specified
closing brackets, can end sentences. The default value is
@quotation
""')>]@}"
@end quotation
@t{"')>]@}"}.
@item set casesensitive
Do case-sensitive searches by default.
@item set const
@item set constantshow
Constantly display the cursor position in the status bar.
(The old form of this option, @code{set const}, is deprecated.)
@item set cut
Use cut-to-end-of-line by default, instead of cutting the whole line.
@@ -648,7 +662,7 @@ Use cut-to-end-of-line by default, instead of cutting the whole line.
@item set fill @var{number}
Hard-wrap lines at column number @var{number}. If @var{number} is 0 or less,
the maximum line length will be the screen width less @var{number} columns.
The default value is -8.
The default value is @t{-8}.
@item set functioncolor @var{fgcolor},@var{bgcolor}
Specify the color combination to use for the function descriptions
@@ -671,11 +685,7 @@ Enable vim-style lock-files for when editing files.
Set the opening and closing brackets that can be found by bracket
searches. This may not include blank characters. The opening set must
come before the closing set, and the two sets must be in the same order.
The default value is
@quotation
"(<[@{)>]@}"
@end quotation
The default value is @t{"(<[@{)>]@}"}.
@item set morespace
Use the blank line below the titlebar as extra editing space.
@@ -685,7 +695,7 @@ Enable mouse support, so that mouse clicks can be used to place the
cursor, set the mark (with a double click), or execute shortcuts.
@item set multibuffer
Allow inserting files into their own buffers.
When reading in a file with ^R, insert it into a new buffer by default.
@item set noconvert
Don't convert files from DOS/Mac format.
@@ -708,8 +718,9 @@ subdirectories. Also, the current directory is changed to here, so
files are inserted from this directory. By default, the operating
directory feature is turned off.
@item set poslog
@item set positionlog
Save the cursor position of files between editing sessions.
(The old form of this option, @code{set poslog}, is deprecated.)
@item set preserve
Preserve the XON and XOFF keys (^Q and ^S).
@@ -718,7 +729,8 @@ Preserve the XON and XOFF keys (^Q and ^S).
Set the characters treated as closing punctuation when justifying
paragraphs. This may not include blank characters. Only the
specified closing punctuation, optionally followed by closing brackets
(see "brackets"), can end sentences. The default value is "!.?".
(see @code{set brackets}), can end sentences.
The default value is @t{"!.?"}.
@item set quickblank
Do quick statusbar blanking. Statusbar messages will disappear after 1
@@ -733,13 +745,9 @@ should be placed at the top of the file to be fully effective.
The email-quote string, used to justify email-quoted paragraphs. This
is an extended regular expression if your system supports them,
otherwise a literal string. The default value is
@quotation
"^([ \\t]*[#:>\\|@}])+"
@end quotation
if you have extended regular expression support, and "> " otherwise.
Note that '\\t' stands for a literal Tab character.
@t{"^([ \\t]*[#:>\\|@}])+"} if you have extended regular expression
support, and @t{"> "} otherwise.
Note that @code{\t} stands for a literal Tab character.
@item set rebinddelete
Interpret the Delete key differently so that both Backspace and Delete
@@ -780,7 +788,7 @@ Allow @code{nano} to be suspended.
@item set tabsize @var{number}
Use a tab size of @var{number} columns. The value of @var{number} must be
greater than 0. The default value is 8.
greater than 0. The default value is @t{8}.
@item set tabstospaces
Convert typed tabs to spaces.
@@ -794,6 +802,11 @@ Valid color names for foreground and background are:
white, black, red, blue, green, yellow, magenta, and cyan.
And either @var{fgcolor} or @var{,bgcolor} may be left out.
@item set unix
Save a file by default in Unix format. This overrides nano's
default behavior of saving a file in the format that it had.
(This option has no effect when you also use @code{set noconvert}.)
@item set view
Disallow file modification.
@@ -801,7 +814,7 @@ Disallow file modification.
@item set whitespace "@var{string}"
Set the two characters used to indicate the presence of tabs and
spaces. They must be single-column characters. The default pair
for a UTF-8 locale is "»·", and for other locales ">.".
for a UTF-8 locale is @t{"»·"}, and for other locales @t{">."}.
@item set wordbounds
Detect word boundaries more accurately by treating punctuation
@@ -825,39 +838,40 @@ via the following commands in a nanorc file:
@table @code
@item syntax "str" ["fileregex" @dots{}]
Defines a syntax named "str" which can be activated via the -Y/--syntax
Defines a syntax named "str" which can be activated via the @code{-Y/--syntax}
command-line option, or will be automatically activated if the current
filename matches the extended regular expression "fileregex". All
following "color" and "icolor" statements will apply to this "str"
syntax until a new syntax is defined.
subsequent @code{color}, @code{icolor}, @code{header} and other such
statements will apply to this "str" syntax until a new @code{syntax}
command is encountered.
The "none" syntax is reserved; specifying it on the command line is the
same as not having a syntax at all. The "default" syntax is special: it
takes no "fileregex", and applies to files that don't match any other
takes no "fileregex", and applies to files that don't match any
syntax's "fileregex".
@item linter program [arg @dots{}]
For the currently defined syntax, use the given program to invoke the
linter (this overrides the speller function when defined).
Use the given program to do a syntax check on the current file
(this overrides the speller function when defined).
@item formatter program [arg @dots{}]
For the currently defined syntax, use the given program to automatically
reformat text. Useful in certain programming languages (e.g. go).
Use the given program to automatically reformat text.
Useful in certain programming languages (e.g.@: Go).
@item header "regex" @dots{}
For the currently defined syntax, add one or more regexes which will
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.
@item magic "regex" @dots{}
For the currently defined syntax, add one or more regexes which will be
Add one or more regexes which will be
compared against the result of querying the magic database about the file
to be edited, to determine whether this syntax should be used for that
file. This functionality only works when libmagic is installed on the
system and will be silently ignored otherwise.
@item color fgcolor,bgcolor "regex" @dots{}
For the currently defined syntax, display all expressions matching the
Display all pieces of text that match the
extended regular expression "regex" with foreground color "fgcolor" and
background color "bgcolor", at least one of which must be specified.
Valid colors for foreground and background are: white, black, red,
@@ -867,36 +881,37 @@ terminal supports transparency, not specifying a "bgcolor" tells @code{nano}
to attempt to use a transparent background.
@item icolor fgcolor,bgcolor "regex" @dots{}
Same as above, except that the expression matching is case insensitive.
Same as above, except that the text matching is case insensitive.
@item color fgcolor,bgcolor start="sr" end="er"
Display expressions which start with the extended regular expression
"sr" and end with the extended regular expression "er" with foreground
Display all pieces of text whose start matches extended regular expression
"sr" and whose end matches extended regular expression "er" with foreground
color "fgcolor" and background color "bgcolor", at least one of which
must be specified. This allows syntax highlighting to span multiple
lines. Note that all subsequent instances of "sr" after an initial "sr"
is found will be highlighted until the first instance of "er".
must be specified. This means that, after an initial instance of "sr",
all text will be highlighted until the first instance of "er".
This allows syntax highlighting to span multiple lines.
@item icolor fgcolor,bgcolor start="sr" end="er"
Same as above, except that the expression matching is case insensitive.
Same as above, except that the text matching is case insensitive.
@item include "syntaxfile"
Read in self-contained color syntaxes from "syntaxfile". Note that
"syntaxfile" can only contain the above commands, from "syntax" to
"icolor".
"syntaxfile" may contain only the above commands, from @code{syntax}
to @code{icolor}.
@item extendsyntax str directive [arg @dots{}]
Extend the syntax previously defined as str to include new information.
Allows you to add a new color, icolor, magic, header, or linter directive
to an already defined syntax. Useful when you want to add to definitions
from the system-installed syntax definitions (which are normally not writable).
This allows you to add a new @code{color}, @code{icolor}, @code{header},
@code{magic}, @code{linter}, or @code{formatter} directive 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).
@end table
@node Rebinding Keys
@section Rebinding Keys
Key bindings may be reassigned via the following two commands in a
Key bindings can be changed via the following two commands in a
nanorc file:
@table @code
@@ -943,18 +958,27 @@ Cancels the current command.
Exits from the program (or from the help viewer or the file browser).
@item writeout
Writes the current buffer to disk.
Writes the current buffer to disk, asking for a name.
@item savefile
Writes the current file to disk without prompting or warning.
@item insert
Inserts a file into the current buffer (or into a new buffer when multibuffer
is enabled).
Inserts a file into the current buffer (at the current cursor position),
or into a new buffer when option @code{multibuffer} is set.
@item whereis
Searches for text in the current buffer -- or for filenames matching
Searches for text in the current buffer --- or for filenames matching
a string in the current list in the file browser
@item searchagain
Repeats the last search command.
Repeats the last search command without prompting.
@item findprevious
As @code{searchagain}, but always in the backward direction.
@item findnext
As @code{searchagain}, but always in the forward direction.
@item replace
Interactively replaces text within the current buffer.
@@ -972,6 +996,12 @@ current cursor position.
@item mark
Sets the mark at the current position, to start selecting text.
@item cutwordleft
Cuts from the cursor position to the beginning of the preceding word.
@item cutwordright
Cuts from the cursor position to the beginning of the next word.
@item cutrestoffile
Cuts all text from the cursor position till the end of the buffer.
@@ -1015,12 +1045,12 @@ Scrolls up one line of text from the current position.
@item scrolldown
Scrolls down one line of text from the current position.
@item nextword
Moves the cursor to the beginning of the next word.
@item prevword
Moves the cursor to the beginning of the previous word.
@item nextword
Moves the cursor to the beginning of the next word.
@item home
Moves the cursor to the beginning of the current line.
@@ -1056,10 +1086,10 @@ Moves the cursor to the bracket (brace, parenthesis, etc.) that matches
(pairs) with the one under the cursor.
@item prevbuf
Switches to editing/viewing the previous buffer when using multibuffer mode.
Switches to editing/viewing the previous buffer when multiple buffers are open.
@item nextbuf
Switches to editing/viewing the next buffer when using multibuffer mode.
Switches to editing/viewing the next buffer when multiple buffers are open.
@item verbatim
Inserts the next character verbatim into the file.
@@ -1099,10 +1129,10 @@ Toggles whether searching/replacing is based on literal strings or regular expre
Toggles whether searching/replacing goes forward or backward.
@item prevhistory
Shows the previous history entry in the prompt menus (e.g. search).
Shows the previous history entry in the prompt menus (e.g.@: search).
@item nexthistory
Shows the next history entry in the prompt menus (e.g. search).
Shows the next history entry in the prompt menus (e.g.@: search).
@item flipreplace
Toggles between searching for something and replacing something.
@@ -1183,7 +1213,8 @@ Toggles whether typed tabs will be converted to spaces.
Toggles whether a backup will be made of the file to be edited.
@item multibuffer
Toggles the use of multiple file buffers (if available).
Toggles whether a file is inserted into the current buffer
or read into a new buffer.
@item mouse
Toggles mouse support.
@@ -1246,6 +1277,7 @@ The 'go to directory' menu in the file browser.
A special name that encompasses all menus. For @code{bind} it means
all menus where the specified @code{function} exists; for @code{unbind}
it means all menus where the specified @code{key} exists.
@end table
@@ -1273,20 +1305,19 @@ browser exits.
are certain differences between the editors:
@table @code
@item Search and Replace History
As of version 1.1.99pre1 of @code{nano}, text entered as search or
replace strings will be stored and can be accessed with the up/down
arrow keys. Previously, @code{nano} offered a more consistent, but
incompatible with Pico, method for entering search and replace strings.
In the old method, previous entries would be displayed by default as
editable text in front of the cursor, as opposed to being bracketed and
uneditable as it is in Pico. The old behavior could be made compatible
with Pico via the @code{-p} option, but recent versions of Pico use the
@code{-p} option to preserve the XON and XOFF sequences within the
editor. Since, with the new method, search and replace strings can
still be edited by simply hitting the up arrow key once, the old method
was removed completely.
@item Interactive Replace
Instead of allowing you to replace either just one occurrence of a search
string or all of them, @code{nano}'s replace function is interactive: it
will pause at each found search string and query whether to replace this
instance. You can then choose Yes, or No (skip this one), or All (don't
ask any more), or Cancel (stop with replacing).
@item Search and Replace History
When the option @code{-H} or @code{--historylog} is given (or set in
the .nanorc file), text entered as search or replace strings is stored.
These strings can be accessed with the up/down arrow keys. A retrieved
string can subsequently be edited.
@item Writing, Appending, or Prepending Selected Text to Files
Text selected using the marking key (^^) can be written out, appended,
@@ -1295,26 +1326,20 @@ or prepended to a new or existing file using the WriteOut key (^O).
@item Toggles
Many options which alter the functionality of the program can be
"toggled" on or off using Meta key sequences, meaning the program does
not have to be restarted to turn a particular feature of the editor on
or off. Please see the internal help function (^G) for a list of what
functions can be toggled for a particular version of @code{nano}. See
@xref{Feature Toggles}, for more info.
not have to be restarted to turn a particular feature on or off.
See the internal help function (^G) for a list of features that
can be toggled. Or see @xref{Feature Toggles} instead.
@item Cursor Position Display
The output of the "Display Cursor Position" in @code{nano} displays
the current line position of the cursor, as well as the column and
total character position.
@item Current Cursor Position
The output of the "Display Cursor Position" command (^C) displays
not only the current line and character position of the cursor,
but also (between the two) the current column position.
@item Interactive Replace and Spell Checker
It is worth noting that @code{nano}'s replace function is interactive,
i.e. it does not stop after one search string was found and automatically
replaced. The @code{nano} implementation will pause at each found
search string and query whether to replace this instance or not. The
internal spell checker operates similarly. Note that there is no way to
force these functions to behave in the Pico fashion. As of version
1.1.99pre1, misspelled words are sorted and trimmed for uniqueness in
the internal spell checker such that the words 'apple' and 'Apple' will
@item Spell Checking
In the internal spell checker misspelled words are sorted alphabetically
and trimmed for uniqueness, such that the words 'apple' and 'Apple' will
be prompted for correction separately.
@end table
@@ -1342,7 +1367,7 @@ Disable the mini file browser when reading or writing files.
@item --disable-color
Disable support for the syntax coloring of files. This also eliminates
the -Y command-line option, which chooses a specific syntax.
the @code{-Y} command-line option, which chooses a specific syntax.
@item --disable-extra
Disable extra features. At the moment, this is just easter-egg-type
@@ -1356,57 +1381,57 @@ things about using the editor.
@item --disable-histories
Disable the code for the handling of the history files: the search and
replace strings that were used, and the cursor position at which each
file was closed. This also eliminates the -H and -P command-line
options, which switch on the logging of search/replace strings and
cursor positions.
file was closed. This also eliminates the @code{-H} and @code{-P}
command-line options, which switch on the logging of search/replace
strings and cursor positions.
@item --disable-justify
Disable the justify and unjustify functions.
@item --disable-libmagic
Disable the use of the library of magic-number tests (for determining
the file type and thus which syntax to use for colouring -- often the
the file type and thus which syntax to use for colouring --- often the
tests on filename extension and header line will be enough).
@item --disable-mouse
Disable all mouse functionality. This also eliminates the -m
Disable all mouse functionality. This also eliminates the @code{-m}
command-line option, which enables the mouse functionality.
@item --disable-multibuffer
Disable support for opening multiple files at a time and switching
between them on the fly. This also eliminates the -F command-line
option, which switches the use of multiple file buffers on.
between them on the fly. This also eliminates the @code{-F} command-line
option, which causes a file to be read into a separate buffer by default.
@item --disable-nanorc
Disable support for reading the nanorc files at startup. With such
support, you can store custom settings in a system-wide and a per-user
nanorc file rather than having to pass command-line options to get
the desired behavior. See @xref{Nanorc Files}, for more info.
Disabling this also eliminates the -I and -q command-line options;
the first inhibits the reading of nanorcfiles, and the second
Disabling this also eliminates the @code{-I} and @code{-q} command-line
options; the first inhibits the reading of nanorcfiles, and the second
suppresses warnings about errors in those files.
@item --disable-operatingdir
Disable setting the operating directory. This also eliminates the -o
Disable setting the operating directory. This also eliminates the @code{-o}
command-line option, which sets the operating directory.
@item --disable-speller
Disable use of the spell checker. This also eliminates the -s
Disable use of the spell checker. This also eliminates the @code{-s}
command-line option, which allows specifying an alternate spell checker.
@item --disable-tabcomp
Disable the tab completion code when reading or writing files.
@item --disable-wrapping
Disable hard-wrapping of overlong lines. This also eliminates the -w
Disable hard-wrapping of overlong lines. This also eliminates the @code{-w}
command-line option, which enables long-line wrapping.
@item --enable-tiny
This option disables all the above. It also disables some of the larger
internals of the editor, like the marking code and the cut-to-end-of-line
code. It also disables the function toggles. By using the enabling
counterpart of the above options together with --enable-tiny, specific
features can be switched back on.
counterpart of the above options together with @code{--enable-tiny},
specific features can be switched back on.
@item --enable-debug
Enable support for runtime debug output. This can get pretty messy, so

View File

@@ -2,20 +2,24 @@
%define version @VERSION@
%define release 1
Summary : Pico editor clone with enhancements
Name : %{name}
Version : %{version}
Release : %{release}
Summary : a user-friendly editor, a Pico clone with enhancements
License : GPLv3+
Group : Applications/Editors
URL : http://www.nano-editor.org/
Source : http://www.nano-editor.org/dist/v2.3/%{name}-%{version}.tar.gz
Source : http://www.nano-editor.org/dist/v2.4/%{name}-%{version}.tar.gz
BuildRoot : %{_tmppath}/%{name}-%{version}-root
BuildRequires : autoconf, automake, gettext-devel, ncurses-devel, texinfo
Requires(post) : info
Requires(preun) : info
%description
GNU nano is a small and friendly text editor. It aims to emulate the
Pico text editor while also offering a few enhancements.
Pico text editor while also offering several enhancements.
%prep
%setup -q
@@ -26,8 +30,16 @@ make
%install
make DESTDIR="%{buildroot}" install
#ln -s nano %{buildroot}%{_bindir}/pico
rm -f %{buildroot}%{_infodir}/dir
#ln -s nano %{buildroot}/%{_bindir}/pico
rm -f %{buildroot}/%{_infodir}/dir
%post
/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir || :
%preun
if [ $1 = 0 ] ; then
/sbin/install-info --delete %{_infodir}/%{name}.info %{_infodir}/dir || :
fi
%files
%defattr(-,root,root)

1286
po/bg.po

File diff suppressed because it is too large Load Diff

1162
po/ca.po

File diff suppressed because it is too large Load Diff

1148
po/cs.po

File diff suppressed because it is too large Load Diff

2067
po/da.po

File diff suppressed because it is too large Load Diff

1154
po/de.po

File diff suppressed because it is too large Load Diff

1323
po/eo.po

File diff suppressed because it is too large Load Diff

1582
po/es.po

File diff suppressed because it is too large Load Diff

1297
po/eu.po

File diff suppressed because it is too large Load Diff

1307
po/fi.po

File diff suppressed because it is too large Load Diff

1242
po/fr.po

File diff suppressed because it is too large Load Diff

1140
po/ga.po

File diff suppressed because it is too large Load Diff

1145
po/gl.po

File diff suppressed because it is too large Load Diff

1137
po/hu.po

File diff suppressed because it is too large Load Diff

1271
po/id.po

File diff suppressed because it is too large Load Diff

1148
po/it.po

File diff suppressed because it is too large Load Diff

1287
po/ja.po

File diff suppressed because it is too large Load Diff

1282
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1846
po/nb.po

File diff suppressed because it is too large Load Diff

1315
po/nl.po

File diff suppressed because it is too large Load Diff

1267
po/nn.po

File diff suppressed because it is too large Load Diff

1142
po/pl.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1301
po/ro.po

File diff suppressed because it is too large Load Diff

1142
po/ru.po

File diff suppressed because it is too large Load Diff

1137
po/sl.po

File diff suppressed because it is too large Load Diff

1696
po/sr.po

File diff suppressed because it is too large Load Diff

1332
po/sv.po

File diff suppressed because it is too large Load Diff

1268
po/tr.po

File diff suppressed because it is too large Load Diff

1152
po/uk.po

File diff suppressed because it is too large Load Diff

1310
po/vi.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,8 @@
* browser.c *
* *
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, *
* 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* 2010, 2011, 2013, 2014, 2015 Free Software Foundation, Inc. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3, or (at your option) *
@@ -23,6 +24,7 @@
#include "proto.h"
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
@@ -39,10 +41,9 @@ static int width = 0;
static int longest = 0;
/* The number of columns in the longest filename in the list. */
static size_t selected = 0;
/* The currently selected filename in the list. This variable
* is zero-based. */
static bool search_last_file = FALSE;
/* Have we gone past the last file while searching? */
/* The currently selected filename in the list; zero-based. */
static char *path_save = NULL;
/* A copy of the current path. */
/* Our main file browser function. path is the tilde-expanded path we
* start browsing from. */
@@ -52,8 +53,7 @@ char *do_browser(char *path, DIR *dir)
int kbinput;
bool old_const_update = ISSET(CONST_UPDATE);
char *prev_dir = NULL;
/* The directory we were in, if any, before backing up via
* browsing to "..". */
/* The directory we were in before backing up to "..". */
char *ans = NULL;
/* The last answer the user typed at the statusbar prompt. */
size_t old_selected;
@@ -63,7 +63,6 @@ char *do_browser(char *path, DIR *dir)
curs_set(0);
blank_statusbar();
currmenu = MBROWSER;
bottombars(MBROWSER);
wnoutrefresh(bottomwin);
@@ -79,6 +78,9 @@ char *do_browser(char *path, DIR *dir)
path = mallocstrassn(path, get_full_path(path));
/* Save the current path in order to be used later. */
path_save = path;
assert(path != NULL && path[strlen(path) - 1] == '/');
/* Get the file list, and set longest and width in the process. */
@@ -92,7 +94,7 @@ char *do_browser(char *path, DIR *dir)
/* If prev_dir isn't NULL, select the directory saved in it, and
* then blow it away. */
if (prev_dir != NULL) {
browser_select_filename(prev_dir);
browser_select_dirname(prev_dir);
free(prev_dir);
prev_dir = NULL;
@@ -122,6 +124,14 @@ char *do_browser(char *path, DIR *dir)
kbinput = get_kbinput(edit);
#ifndef NANO_TINY
if (kbinput == KEY_WINCH) {
kbinput = ERR;
curs_set(0);
continue;
}
#endif
#ifndef DISABLE_MOUSE
if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y;
@@ -137,21 +147,18 @@ char *do_browser(char *path, DIR *dir)
width) + (mouse_x / (longest + 2));
/* If they clicked beyond the end of a row,
* select the filename at the end of that
* row. */
* select the last filename in that row. */
if (mouse_x > width * (longest + 2))
selected--;
/* If we're off the screen, select the last
* filename. */
/* If we're off the screen, select the last filename. */
if (selected > filelist_len - 1)
selected = filelist_len - 1;
/* If we selected the same filename as last
* time, put back the Enter key so that it's
* read in. */
/* If we selected the same filename as last time,
* put back the Enter key so that it's read in. */
if (old_selected == selected)
unget_kbinput(sc_seq_or(do_enter_void, 0), FALSE, FALSE);
unget_kbinput(sc_seq_or(do_enter, 0), FALSE, FALSE);
}
}
#endif /* !DISABLE_MOUSE */
@@ -163,9 +170,11 @@ char *do_browser(char *path, DIR *dir)
} else if (func == do_help_void) {
#ifndef DISABLE_HELP
do_help_void();
/* Perhaps the window dimensions have changed. */
browser_refresh();
curs_set(0);
#else
nano_disabled_msg();
say_there_is_no_help();
#endif
} else if (func == do_search) {
/* Search for a filename. */
@@ -203,7 +212,6 @@ char *do_browser(char *path, DIR *dir)
browser_refresh, _("Go To Directory"));
curs_set(0);
currmenu = MBROWSER;
bottombars(MBROWSER);
/* If the directory begins with a newline (i.e. an
@@ -277,7 +285,7 @@ char *do_browser(char *path, DIR *dir)
} else if (func == do_right) {
if (selected < filelist_len - 1)
selected++;
} else if (func == do_enter_void) {
} else if (func == do_enter) {
/* We can't move up from "/". */
if (strcmp(filelist[selected], "/..") == 0) {
statusbar(_("Can't move up a directory"));
@@ -398,8 +406,7 @@ char *do_browse_from(const char *inpath)
/* If we can't open the path, get out. */
if (dir == NULL) {
if (path != NULL)
free(path);
free(path);
beep();
return NULL;
}
@@ -429,31 +436,31 @@ void browser_init(const char *path, DIR *dir)
assert(path != NULL && path[strlen(path) - 1] == '/' && dir != NULL);
/* Set longest to zero, just before we initialize it. */
longest = 0;
/* Find the length of the longest filename in the current folder. */
while ((nextdir = readdir(dir)) != NULL) {
size_t d_len;
size_t name_len = strlenpt(nextdir->d_name);
/* Don't show the "." entry. */
if (strcmp(nextdir->d_name, ".") == 0)
continue;
d_len = strlenpt(nextdir->d_name);
if (d_len > longest)
longest = (d_len > COLS) ? COLS : d_len;
if (name_len > longest)
longest = name_len;
i++;
}
rewinddir(dir);
/* Put 10 columns' worth of blank space between columns of filenames
/* Put 10 characters' worth of blank space between columns of filenames
* in the list whenever possible, as Pico does. */
longest += 10;
if (filelist != NULL)
free_chararray(filelist, filelist_len);
/* Make sure longest is between 15 and COLS. */
if (longest < 15)
longest = 15;
if (longest > COLS)
longest = COLS;
rewinddir(dir);
free_chararray(filelist, filelist_len);
filelist_len = i;
@@ -479,12 +486,6 @@ void browser_init(const char *path, DIR *dir)
closedir(dir);
/* Make sure longest is between 15 and COLS. */
if (longest < 15)
longest = 15;
if (longest > COLS)
longest = COLS;
/* Set width to zero, just before we initialize it. */
width = 0;
@@ -536,7 +537,7 @@ functionptrtype parse_browser_input(int *kbinput)
return goto_dir_void;
case 'S':
case 's':
return do_enter_void;
return do_enter;
case 'W':
case 'w':
return do_search;
@@ -549,20 +550,21 @@ functionptrtype parse_browser_input(int *kbinput)
* necessary, and display the list of files. */
void browser_refresh(void)
{
static int uimax_digits = -1;
size_t i;
int col = 0;
/* The maximum number of columns that the filenames will take
* up. */
int line = 0;
/* The maximum number of lines that the filenames will take
* up. */
int line = 0, col = 0;
/* The current line and column while the list is getting displayed. */
char *foo;
/* The file information that we'll display. */
/* The additional information that we'll display about a file. */
if (uimax_digits == -1)
uimax_digits = digits(UINT_MAX);
/* Perhaps window dimensions have changed; reinitialize the browser. */
browser_init(path_save, opendir(path_save));
qsort(filelist, filelist_len, sizeof(char *), diralphasort);
/* Make sure the selected file is within range. */
if (selected >= filelist_len)
selected = filelist_len - 1;
titlebar(path_save);
blank_edit();
wmove(edit, 0, 0);
@@ -581,7 +583,7 @@ void browser_refresh(void)
/* The maximum length of the file information in
* columns: seven for "--", "(dir)", or the file size,
* and 12 for "(parent dir)". */
bool dots = (COLS >= 15 && filetaillen >= longest - foomaxlen - 1);
bool dots = (COLS >= 15 && filetaillen >= longest - foomaxlen);
/* Do we put an ellipsis before the filename? Don't set
* this to TRUE if we have fewer than 15 columns (i.e.
* one column for padding, plus seven columns for a
@@ -593,15 +595,13 @@ void browser_refresh(void)
* "(dir)", or the file size, plus three columns for the
* ellipsis. */
/* Start highlighting the currently selected file or
* directory. */
/* Start highlighting the currently selected file or directory. */
if (i == selected)
wattron(edit, hilite_attribute);
blank_line(edit, line, col, longest);
/* If dots is TRUE, we will display something like
* "...ename". */
/* If dots is TRUE, we will display something like "...ename". */
if (dots)
mvwaddstr(edit, line, col, "...");
mvwaddstr(edit, line, dots ? col + 3 : col, disp);
@@ -621,42 +621,43 @@ void browser_refresh(void)
/* If the file is a symlink that points to a directory,
* display it as a directory. */
else
/* TRANSLATORS: Try to keep this at most 7
* characters. */
/* TRANSLATORS: Try to keep this at most 7 characters. */
foo = mallocstrcpy(NULL, _("(dir)"));
} else if (S_ISDIR(st.st_mode)) {
/* If the file is a directory, display it as such. */
if (strcmp(filetail, "..") == 0) {
/* TRANSLATORS: Try to keep this at most 12
* characters. */
/* TRANSLATORS: Try to keep this at most 12 characters. */
foo = mallocstrcpy(NULL, _("(parent dir)"));
foomaxlen = 12;
} else
foo = mallocstrcpy(NULL, _("(dir)"));
} else {
unsigned long result = st.st_size;
off_t result = st.st_size;
char modifier;
foo = charalloc(uimax_digits + 4);
foo = charalloc(foomaxlen + 1);
/* Bytes. */
if (st.st_size < (1 << 10))
modifier = ' ';
/* Kilobytes. */
modifier = ' '; /* bytes */
else if (st.st_size < (1 << 20)) {
result >>= 10;
modifier = 'K';
/* Megabytes. */
modifier = 'K'; /* kilobytes */
} else if (st.st_size < (1 << 30)) {
result >>= 20;
modifier = 'M';
/* Gigabytes. */
modifier = 'M'; /* megabytes */
} else {
result >>= 30;
modifier = 'G';
modifier = 'G'; /* gigabytes */
}
sprintf(foo, "%4lu %cB", result, modifier);
/* Show the size if less than a terabyte,
* otherwise show "(huge)". */
if (result < (1 << 10))
sprintf(foo, "%4ju %cB", (intmax_t)result, modifier);
else
/* TRANSLATORS: Try to keep this at most 7 characters.
* If necessary, you can leave out the parentheses. */
foo = mallocstrcpy(foo, _("(huge)"));
}
/* Make sure foo takes up no more than foomaxlen columns. */
@@ -668,8 +669,7 @@ void browser_refresh(void)
mvwaddstr(edit, line, col - foolen, foo);
/* Finish highlighting the currently selected file or
* directory. */
/* Finish highlighting the currently selected file or directory. */
if (i == selected)
wattroff(edit, hilite_attribute);
@@ -691,56 +691,34 @@ void browser_refresh(void)
wnoutrefresh(edit);
}
/* Look for needle. If we find it, set selected to its location. Note
* that needle must be an exact match for a file in the list. The
* return value specifies whether we found anything. */
bool browser_select_filename(const char *needle)
/* Look for needle. If we find it, set selected to its location.
* Note that needle must be an exact match for a file in the list. */
void browser_select_dirname(const char *needle)
{
size_t currselected;
bool found = FALSE;
size_t looking_at = 0;
for (currselected = 0; currselected < filelist_len;
currselected++) {
if (strcmp(filelist[currselected], needle) == 0) {
found = TRUE;
for (; looking_at < filelist_len; looking_at++) {
if (strcmp(filelist[looking_at], needle) == 0) {
selected = looking_at;
break;
}
}
if (found)
selected = currselected;
return found;
}
/* Set up the system variables for a filename search. Return -1 if the
* search should be canceled (due to Cancel, a blank search string, or a
* failed regcomp()), return 0 on success, and return 1 on rerun calling
* program. */
/* Set up the system variables for a filename search. Return -1 or -2 if
* the search should be canceled (due to Cancel or a blank search string),
* return 0 when we have a string, and return a positive value when some
* function was run. */
int filesearch_init(void)
{
int i = 0;
int input;
char *buf;
static char *backupstring = NULL;
/* The search string we'll be using. */
/* If backupstring doesn't exist, initialize it to "". */
if (backupstring == NULL)
backupstring = mallocstrcpy(NULL, "");
/* We display the search prompt below. If the user types a partial
* search string and then Replace or a toggle, we will return to
* do_search() or do_replace() and be called again. In that case,
* we should put the same search string back up. */
search_init_globals();
if (last_search[0] != '\0') {
char *disp = display_string(last_search, 0, COLS / 3, FALSE);
buf = charalloc(strlen(disp) + 7);
/* We use (COLS / 3) here because we need to see more on the
* line. */
/* We use (COLS / 3) here because we need to see more on the line. */
sprintf(buf, " [%s%s]", disp,
(strlenpt(last_search) > COLS / 3) ? "..." : "");
free(disp);
@@ -748,11 +726,11 @@ int filesearch_init(void)
buf = mallocstrcpy(NULL, "");
/* This is now one simple call. It just does a lot. */
i = do_prompt(FALSE,
input = do_prompt(FALSE,
#ifndef DISABLE_TABCOMP
TRUE,
#endif
MWHEREISFILE, backupstring,
MWHEREISFILE, NULL,
#ifndef DISABLE_HISTORIES
&search_history,
#endif
@@ -761,100 +739,92 @@ int filesearch_init(void)
/* Release buf now that we don't need it anymore. */
free(buf);
free(backupstring);
backupstring = NULL;
/* If only Enter was pressed but we have a previous string, it's okay. */
if (input == -2 && *last_search != '\0')
return 0;
/* Cancel any search, or just return with no previous search. */
if (i == -1 || (i < 0 && *last_search == '\0') || (i == 0 &&
*answer == '\0')) {
/* Otherwise negative inputs are a bailout. */
if (input < 0)
statusbar(_("Cancelled"));
return -1;
}
return 0;
return input;
}
/* Look for needle. If no_sameline is TRUE, skip over selected when
* looking for needle. begin is the location of the filename where we
* first started searching. The return value specifies whether we found
* anything. */
bool findnextfile(bool no_sameline, size_t begin, const char *needle)
/* Look for the given needle in the list of files. */
void findnextfile(const char *needle)
{
size_t currselected = selected;
/* The location in the current file list of the match we
* find. */
const char *filetail = tail(filelist[currselected]);
size_t looking_at = selected;
/* The location in the file list of the filename we're looking at. */
bool came_full_circle = FALSE;
/* Have we reached the starting file again? */
const char *filetail = tail(filelist[looking_at]);
/* The filename we display, minus the path. */
const char *rev_start = filetail, *found = NULL;
unsigned stash[sizeof(flags) / sizeof(flags[0])];
/* A storage place for the current flag settings. */
/* Look for needle in the current filename we're searching. */
/* Save the settings of all flags. */
memcpy(stash, flags, sizeof(flags));
/* Search forward, case insensitive and without regexes. */
UNSET(BACKWARDS_SEARCH);
UNSET(CASE_SENSITIVE);
UNSET(USE_REGEXP);
/* Step through each filename in the list until a match is found or
* we've come back to the point where we started. */
while (TRUE) {
found = strstrwrapper(filetail, needle, rev_start);
/* We've found a potential match. If we're not allowed to find
* a match on the same filename we started on and this potential
* match is on that line, continue searching. */
if (found != NULL && (!no_sameline || currselected != begin))
/* If we've found a match and it's not the same filename where
* we started, then we're done. */
if (found != NULL && looking_at != selected)
break;
/* We've finished processing the filenames, so get out. */
if (search_last_file) {
/* If we've found a match and we're back at the beginning, then
* it's the only occurrence. */
if (found != NULL && came_full_circle) {
statusbar(_("This is the only occurrence"));
break;
}
if (came_full_circle) {
/* We're back at the beginning and didn't find anything. */
not_found_msg(needle);
return FALSE;
return;
}
/* Move to the next filename in the list. If we've reached the
* end of the list, wrap around. */
if (currselected < filelist_len - 1)
currselected++;
if (looking_at < filelist_len - 1)
looking_at++;
else {
currselected = 0;
looking_at = 0;
statusbar(_("Search Wrapped"));
}
/* We've reached the original starting file. */
if (currselected == begin)
search_last_file = TRUE;
if (looking_at == selected)
/* We've reached the original starting file. */
came_full_circle = TRUE;
filetail = tail(filelist[currselected]);
filetail = tail(filelist[looking_at]);
rev_start = filetail;
}
/* We've definitely found something. */
selected = currselected;
/* Restore the settings of all flags. */
memcpy(flags, stash, sizeof(flags));
return TRUE;
}
/* Clear the flag indicating that a search reached the last file in the
* list. We need to do this just before a new search. */
void findnextfile_wrap_reset(void)
{
search_last_file = FALSE;
}
/* Abort the current filename search. Clean up by setting the current
* shortcut list to the browser shortcut list, and displaying it. */
void filesearch_abort(void)
{
currmenu = MBROWSER;
bottombars(MBROWSER);
/* Select the one we've found. */
selected = looking_at;
}
/* Search for a filename. */
void do_filesearch(void)
{
size_t begin = selected;
bool didfind;
UNSET(CASE_SENSITIVE);
UNSET(USE_REGEXP);
UNSET(BACKWARDS_SEARCH);
if (filesearch_init() != 0) {
/* Cancelled or a blank search string. */
filesearch_abort();
/* Cancelled, or a blank search string, or done something. */
bottombars(MBROWSER);
return;
}
@@ -871,50 +841,18 @@ void do_filesearch(void)
update_history(&search_history, answer);
#endif
findnextfile_wrap_reset();
didfind = findnextfile(FALSE, begin, answer);
findnextfile(answer);
/* Check to see if there's only one occurrence of the string and
* we're on it now. */
if (selected == begin && didfind) {
/* Do the search again, skipping over the current line. We
* should only end up back at the same position if the string
* isn't found again, in which case it's the only occurrence. */
didfind = findnextfile(TRUE, begin, answer);
if (selected == begin && !didfind)
statusbar(_("This is the only occurrence"));
}
filesearch_abort();
bottombars(MBROWSER);
}
/* Search for the last filename without prompting. */
/* Search for the last given filename again without prompting. */
void do_fileresearch(void)
{
size_t begin = selected;
bool didfind;
search_init_globals();
if (last_search[0] != '\0') {
findnextfile_wrap_reset();
didfind = findnextfile(FALSE, begin, answer);
/* Check to see if there's only one occurrence of the string and
* we're on it now. */
if (selected == begin && didfind) {
/* Do the search again, skipping over the current line. We
* should only end up back at the same position if the
* string isn't found again, in which case it's the only
* occurrence. */
didfind = findnextfile(TRUE, begin, answer);
if (selected == begin && !didfind)
statusbar(_("This is the only occurrence"));
}
} else
statusbar(_("No current search pattern"));
filesearch_abort();
if (last_search[0] == '\0')
statusbar(_("No current search pattern"));
else
findnextfile(last_search);
}
/* Select the first file in the list. */

View File

@@ -636,7 +636,8 @@ char *mbstrcasestr(const char *haystack, const char *needle)
for (; *haystack != '\0' && haystack_len >= needle_len;
haystack += move_mbright(haystack, 0), haystack_len--) {
if (mbstrncasecmp(haystack, needle, needle_len) == 0)
if (mbstrncasecmp(haystack, needle, needle_len) == 0 &&
mblen(haystack, MB_CUR_MAX) > 0)
return (char *)haystack;
}
@@ -729,8 +730,9 @@ char *mbrevstrcasestr(const char *haystack, const char *needle, const
rev_start_len = mbstrlen(rev_start);
while (!begin_line) {
if (rev_start_len >= needle_len && mbstrncasecmp(rev_start,
needle, needle_len) == 0)
if (rev_start_len >= needle_len &&
mbstrncasecmp(rev_start, needle, needle_len) == 0 &&
mblen(rev_start, MB_CUR_MAX) > 0)
return (char *)rev_start;
if (rev_start == haystack)

View File

@@ -3,7 +3,7 @@
* color.c *
* *
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, *
* 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* 2010, 2011, 2013, 2014, 2015 Free Software Foundation, Inc. *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3, or (at your option) *
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#ifdef HAVE_MAGIC_H
#include <magic.h>
@@ -69,10 +70,8 @@ void set_colorpairs(void)
interface_color_pair[i].pairnum = A_NORMAL;
}
if (specified_color_combo[i] != NULL) {
free(specified_color_combo[i]);
specified_color_combo[i] = NULL;
}
free(specified_color_combo[i]);
specified_color_combo[i] = NULL;
}
for (; this_syntax != NULL; this_syntax = this_syntax->next) {
@@ -181,12 +180,30 @@ void color_update(void)
if (openfile->colorstrings != NULL)
break;
}
if (openfile->colorstrings == NULL)
statusbar(_("Unknown syntax name: %s"), syntaxstr);
}
/* If we didn't specify a syntax override string, or if we did and
* there was no syntax by that name, get the syntax based on the
* file extension, then try the headerline, and then try magic. */
if (openfile->colorstrings == NULL) {
char *currentdir = getcwd(NULL, PATH_MAX + 1);
char *joinednames = charalloc(PATH_MAX + 1);
char *fullname = NULL;
if (currentdir != NULL) {
/* Concatenate the current working directory with the
* specified filename, and canonicalize the result. */
sprintf(joinednames, "%s/%s", currentdir, openfile->filename);
fullname = realpath(joinednames, NULL);
free(currentdir);
}
if (fullname == NULL)
fullname = mallocstrcpy(fullname, openfile->filename);
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
tmpsyntax = tmpsyntax->next) {
@@ -211,7 +228,7 @@ void color_update(void)
}
/* Set colorstrings if we match the extension regex. */
if (regexec(e->ext, openfile->filename, 0, NULL, 0) == 0) {
if (regexec(e->ext, fullname, 0, NULL, 0) == 0) {
openfile->syntax = tmpsyntax;
openfile->colorstrings = tmpsyntax->color;
break;
@@ -224,6 +241,9 @@ void color_update(void)
}
}
free(joinednames);
free(fullname);
/* Check the headerline if the extension didn't match anything. */
if (openfile->colorstrings == NULL) {
#ifdef DEBUG
@@ -269,9 +289,9 @@ void color_update(void)
/* Open the magic database and get a diagnosis of the file. */
cookie = magic_open(MAGIC_SYMLINK |
#ifdef DEBUG
MAGIC_DEBUG | MAGIC_CHECK |
MAGIC_DEBUG | MAGIC_CHECK |
#endif
MAGIC_ERROR);
MAGIC_ERROR);
if (cookie == NULL || magic_load(cookie, NULL) < 0)
statusbar(_("magic_load() failed: %s"), strerror(errno));
else {
@@ -345,67 +365,49 @@ void color_update(void)
}
}
/* Reset the multicolor info cache for records for any lines which need
* to be recalculated. */
void reset_multis_after(filestruct *fileptr, int mindex)
/* Reset the multiline coloring cache for one specific regex (given by
* index) for lines that need reevaluation. */
void reset_multis_for_id(filestruct *fileptr, int index)
{
filestruct *oof;
for (oof = fileptr->next; oof != NULL; oof = oof->next) {
alloc_multidata_if_needed(oof);
if (oof->multidata == NULL)
continue;
if (oof->multidata[mindex] != CNONE)
oof->multidata[mindex] = -1;
else
filestruct *row;
/* Reset the cache of earlier lines, as far back as needed. */
for (row = fileptr->prev; row != NULL; row = row->prev) {
alloc_multidata_if_needed(row);
if (row->multidata[index] == CNONE)
break;
row->multidata[index] = -1;
}
for (; oof != NULL; oof = oof->next) {
alloc_multidata_if_needed(oof);
if (oof->multidata == NULL)
continue;
if (oof->multidata[mindex] == CNONE)
oof->multidata[mindex] = -1;
else
for (; row != NULL; row = row->prev) {
alloc_multidata_if_needed(row);
if (row->multidata[index] != CNONE)
break;
row->multidata[index] = -1;
}
/* Reset the cache of the current line. */
fileptr->multidata[index] = -1;
/* Reset the cache of later lines, as far ahead as needed. */
for (row = fileptr->next; row != NULL; row = row->next) {
alloc_multidata_if_needed(row);
if (row->multidata[index] == CNONE)
break;
row->multidata[index] = -1;
}
for (; row != NULL; row = row->next) {
alloc_multidata_if_needed(row);
if (row->multidata[index] != CNONE)
break;
row->multidata[index] = -1;
}
edit_refresh_needed = TRUE;
}
void reset_multis_before(filestruct *fileptr, int mindex)
{
filestruct *oof;
for (oof = fileptr->prev; oof != NULL; oof = oof->prev) {
alloc_multidata_if_needed(oof);
if (oof->multidata == NULL)
continue;
if (oof->multidata[mindex] != CNONE)
oof->multidata[mindex] = -1;
else
break;
}
for (; oof != NULL; oof = oof->prev) {
alloc_multidata_if_needed(oof);
if (oof->multidata == NULL)
continue;
if (oof->multidata[mindex] == CNONE)
oof->multidata[mindex] = -1;
else
break;
}
edit_refresh_needed = TRUE;
}
/* Reset one multiline regex info. */
void reset_multis_for_id(filestruct *fileptr, int num)
{
reset_multis_before(fileptr, num);
reset_multis_after(fileptr, num);
fileptr->multidata[num] = -1;
}
/* Reset multi-line strings around a filestruct ptr, trying to be smart
* about stopping. Bool force means: reset everything regardless, useful
* when we don't know how much screen state has changed. */
/* Reset multi-line strings around the filestruct fileptr, trying to be
* smart about stopping. Bool force means: reset everything regardless,
* useful when we don't know how much screen state has changed. */
void reset_multis(filestruct *fileptr, bool force)
{
int nobegin, noend;
@@ -416,34 +418,32 @@ void reset_multis(filestruct *fileptr, bool force)
return;
for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) {
/* If it's not a multi-line regex, amscray. */
if (tmpcolor->end == NULL)
continue;
alloc_multidata_if_needed(fileptr);
if (force == TRUE) {
reset_multis_for_id(fileptr, tmpcolor->id);
continue;
if (force == FALSE) {
/* Check whether the multidata still matches the current situation. */
nobegin = regexec(tmpcolor->start, fileptr->data, 1, &startmatch, 0);
noend = regexec(tmpcolor->end, fileptr->data, 1, &endmatch, 0);
if ((fileptr->multidata[tmpcolor->id] == CWHOLELINE ||
fileptr->multidata[tmpcolor->id] == CNONE) &&
nobegin && noend)
continue;
else if (fileptr->multidata[tmpcolor->id] == CSTARTENDHERE &&
!nobegin && !noend && startmatch.rm_so < endmatch.rm_so)
continue;
else if (fileptr->multidata[tmpcolor->id] == CBEGINBEFORE &&
nobegin && !noend)
continue;
else if (fileptr->multidata[tmpcolor->id] == CENDAFTER &&
!nobegin && noend)
continue;
}
/* Figure out where the first begin and end are to determine if
* things changed drastically for the precalculated multi values. */
nobegin = regexec(tmpcolor->start, fileptr->data, 1, &startmatch, 0);
noend = regexec(tmpcolor->end, fileptr->data, 1, &endmatch, 0);
if (fileptr->multidata[tmpcolor->id] == CWHOLELINE) {
if (nobegin && noend)
continue;
} else if (fileptr->multidata[tmpcolor->id] == CNONE) {
if (nobegin && noend)
continue;
} else if (fileptr->multidata[tmpcolor->id] & CBEGINBEFORE && !noend
&& (nobegin || endmatch.rm_eo > startmatch.rm_eo)) {
reset_multis_after(fileptr, tmpcolor->id);
continue;
}
/* If we got here, assume the worst. */
/* If we got here, things have changed. */
reset_multis_for_id(fileptr, tmpcolor->id);
}
}

View File

@@ -50,11 +50,6 @@ inline bool keeping_cutbuffer(void)
* current line. */
void cut_line(void)
{
#ifndef NANO_TINY
if (!openfile->mark_begin)
openfile->mark_begin = openfile->current;
#endif
if (openfile->current != openfile->filebot)
move_to_filestruct(&cutbuffer, &cutbottom, openfile->current, 0,
openfile->current->next, 0);
@@ -124,7 +119,7 @@ void cut_to_eof(void)
* position to the end of the file into the cutbuffer. */
void do_cut_text(
#ifndef NANO_TINY
bool copy_text, bool cut_till_eof, bool undoing
bool copy_text, bool cut_till_eof
#else
void
#endif
@@ -214,8 +209,7 @@ void do_cut_text(
* disturbing the text. */
if (!old_no_newlines)
UNSET(NO_NEWLINES);
} else if (!undoing)
update_undo(cut_till_eof ? CUT_EOF : CUT);
}
/* Leave the text in the cutbuffer, and mark the file as
* modified. */
@@ -240,12 +234,11 @@ void do_cut_text_void(void)
{
#ifndef NANO_TINY
add_undo(CUT);
do_cut_text(FALSE, FALSE);
update_undo(CUT);
#else
do_cut_text();
#endif
do_cut_text(
#ifndef NANO_TINY
FALSE, FALSE, FALSE
#endif
);
}
#ifndef NANO_TINY
@@ -260,7 +253,7 @@ void do_copy_text(void)
if (mark_set || openfile->current != next_contiguous_line)
cutbuffer_reset();
do_cut_text(TRUE, FALSE, FALSE);
do_cut_text(TRUE, FALSE);
/* If the mark was set, blow away the cutbuffer on the next copy. */
next_contiguous_line = (mark_set ? NULL : openfile->current);
@@ -270,7 +263,8 @@ void do_copy_text(void)
void do_cut_till_eof(void)
{
add_undo(CUT_EOF);
do_cut_text(FALSE, TRUE, FALSE);
do_cut_text(FALSE, TRUE);
update_undo(CUT_EOF);
}
#endif /* !NANO_TINY */

File diff suppressed because it is too large Load Diff

View File

@@ -30,18 +30,21 @@
/* Global variables. */
#ifndef NANO_TINY
sigjmp_buf jump_buf;
/* Used to return to either main() or the unjustify routine in
* do_justify() after a SIGWINCH. */
bool jump_buf_main = FALSE;
/* Have we set jump_buf so that we return to main() after a
* SIGWINCH? */
volatile sig_atomic_t sigwinch_counter = 0;
/* Is incremented by the handler whenever a SIGWINCH occurs. */
#endif
bool meta_key;
/* Whether the current keystroke is a Meta key. */
bool func_key;
/* Whether the current keystroke is an extended keypad value. */
bool focusing = FALSE;
/* Whether an update of the edit window should center the cursor. */
#ifndef NANO_TINY
int controlleft = CONTROL_LEFT;
int controlright = CONTROL_RIGHT;
#endif
#ifndef DISABLE_WRAPJUSTIFY
ssize_t fill = 0;
@@ -91,14 +94,10 @@ openfilestruct *openfile = NULL;
char *matchbrackets = NULL;
/* The opening and closing brackets that can be found by bracket
* searches. */
#endif
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
char *whitespace = NULL;
/* The characters used when displaying the first characters of
* tabs and spaces. */
/* The characters used when visibly showing tabs and spaces. */
int whitespace_len[2];
/* The length of these characters. */
/* The length in bytes of these characters. */
#endif
#ifndef DISABLE_JUSTIFY
@@ -137,9 +136,9 @@ char *backup_dir = NULL;
/* The directory where we store backup files. */
const char *locking_prefix = ".";
/* Prefix of how to store the vim-style lock file. */
/* Prefix of how to store the vim-style lock file. */
const char *locking_suffix = ".swp";
/* Suffix of the vim-style lock file. */
/* Suffix of the vim-style lock file. */
#endif
#ifndef DISABLE_OPERATINGDIR
char *operating_dir = NULL;
@@ -223,11 +222,7 @@ size_t length_of_list(int menu)
size_t i = 0;
for (f = allfuncs; f != NULL; f = f->next)
if ((f->menus & menu) != 0
#ifndef DISABLE_HELP
&& strlen(f->help) > 0
#endif
) {
if ((f->menus & menu) != 0) {
i++;
}
return i;
@@ -313,9 +308,10 @@ void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *h
}
/* Add a key combo to the shortcut list. */
void add_to_sclist(int menu, const char *scstring, void (*func)(void), int toggle)
void add_to_sclist(int menus, const char *scstring, void (*func)(void), int toggle)
{
static sc *tailsc;
static int counter = 0;
sc *s = (sc *)nmalloc(sizeof(sc));
/* Start the list, or tack on the next item. */
@@ -327,15 +323,17 @@ void add_to_sclist(int menu, const char *scstring, void (*func)(void), int toggl
s->next = NULL;
/* Fill in the data. */
s->menu = menu;
s->menus = menus;
s->scfunc = func;
s->toggle = toggle;
if (toggle)
s->ordinal = ++counter;
s->keystr = (char *) scstring;
s->type = strtokeytype(scstring);
assign_keyinfo(s);
#ifdef DEBUG
fprintf(stderr, "Setting sequence to %d for shortcut \"%s\" in menu %x\n", s->seq, scstring, (int)s->menu);
fprintf(stderr, "Setting sequence to %d for shortcut \"%s\" in menus %x\n", s->seq, scstring, s->menus);
#endif
}
@@ -356,7 +354,7 @@ const sc *first_sc_for(int menu, void (*func)(void))
const sc *s;
for (s = sclist; s != NULL; s = s->next)
if ((s->menu & menu) && s->scfunc == func)
if ((s->menus & menu) && s->scfunc == func)
return s;
#ifdef DEBUG
@@ -374,7 +372,7 @@ int sc_seq_or(void (*func)(void), int defaultval)
if (s) {
meta_key = (s->type == META);
return s->seq;
return s->seq;
}
/* else */
return defaultval;
@@ -409,16 +407,16 @@ key_type strtokeytype(const char *str)
void assign_keyinfo(sc *s)
{
if (s->type == CONTROL) {
assert(strlen(s->keystr) > 1);
s->seq = s->keystr[1] - 64;
assert(strlen(s->keystr) > 1);
s->seq = s->keystr[1] - 64;
} else if (s->type == META) {
assert(strlen(s->keystr) > 2);
s->seq = tolower((int) s->keystr[2]);
assert(strlen(s->keystr) > 2);
s->seq = tolower((int) s->keystr[2]);
} else if (s->type == FKEY) {
assert(strlen(s->keystr) > 1);
s->seq = KEY_F0 + atoi(&s->keystr[1]);
assert(strlen(s->keystr) > 1);
s->seq = KEY_F0 + atoi(&s->keystr[1]);
} else /* RAWINPUT */
s->seq = (int) s->keystr[0];
s->seq = (int) s->keystr[0];
/* Override some keys which don't bind as easily as we'd like. */
if (s->type == CONTROL && (!strcasecmp(&s->keystr[1], "space")))
@@ -473,32 +471,35 @@ void print_sclist(void)
}
#endif
/* TRANSLATORS: Try to keep the next four strings at most 10 characters. */
/* These four tags are used elsewhere too, so they are global. */
/* TRANSLATORS: Try to keep the next fifteen strings at most 10 characters. */
const char *exit_tag = N_("Exit");
const char *close_tag = N_("Close");
const char *uncut_tag = N_("Uncut Text");
#ifndef DISABLE_JUSITIFY
const char *unjust_tag = N_("Unjustify");
#endif
#ifndef NANO_TINY
/* TRANSLATORS: Try to keep this at most 12 characters. */
const char *whereis_next_tag = N_("WhereIs Next");
#endif
/* Initialize the list of functions and the list of shortcuts. */
void shortcut_init(void)
{
/* TRANSLATORS: Try to keep the next eight strings at most 10 characters. */
const char *read_file_tag = N_("Read File");
const char *whereis_tag = N_("Where Is");
const char *replace_tag = N_("Replace");
const char *gotoline_tag = N_("Go To Line");
const char *prev_line_tag = N_("Prev Line");
const char *next_line_tag = N_("Next Line");
const char *read_file_tag = N_("Read File");
const char *prev_page_tag = N_("Prev Page");
const char *next_page_tag = N_("Next Page");
#ifndef DISABLE_JUSTIFY
const char *justify_tag = N_("Justify");
const char *fulljustify_tag = N_("FullJstify");
#endif
const char *refresh_tag = N_("Refresh");
#ifndef NANO_TINY
/* TRANSLATORS: Try to keep this string at most 12 characters. */
const char *whereis_next_tag = N_("WhereIs Next");
#endif
#ifndef DISABLE_HELP
#ifndef DISABLE_JUSTIFY
@@ -583,6 +584,10 @@ void shortcut_init(void)
const char *nano_backspace_msg =
N_("Delete the character to the left of the cursor");
#ifndef NANO_TINY
const char *nano_cut_word_left_msg =
N_("Cut backward from cursor to word start");
const char *nano_cut_word_right_msg =
N_("Cut forward from cursor to next word start");
const char *nano_cut_till_eof_msg =
N_("Cut from the cursor position to the end of the file");
#endif
@@ -596,8 +601,11 @@ void shortcut_init(void)
const char *nano_refresh_msg =
N_("Refresh (redraw) the current screen");
const char *nano_suspend_msg =
N_("Suspend the editor (if suspend is enabled)");
N_("Suspend the editor (if suspension is enabled)");
#ifndef NANO_TINY
const char *nano_savefile_msg = N_("Save file without prompting");
const char *nano_findprev_msg = N_("Search next occurrence backward");
const char *nano_findnext_msg = N_("Search next occurrence forward");
const char *nano_case_msg =
N_("Toggle the case sensitivity of the search");
const char *nano_reverse_msg =
@@ -639,8 +647,10 @@ void shortcut_init(void)
const char *nano_lint_msg = N_("Invoke the linter, if available");
const char *nano_prevlint_msg = N_("Go to previous linter msg");
const char *nano_nextlint_msg = N_("Go to next linter msg");
#ifndef DISABLE_SPELLER
const char *nano_formatter_msg = N_("Invoke formatter, if available");
#endif
#endif
#endif /* !DISABLE_HELP */
#ifndef DISABLE_HELP
@@ -650,9 +660,9 @@ void shortcut_init(void)
#endif
while (allfuncs != NULL) {
subnfunc *f = allfuncs;
allfuncs = allfuncs->next;
free(f);
subnfunc *f = allfuncs;
allfuncs = allfuncs->next;
free(f);
}
/* Start populating the different menus with functions. */
@@ -677,18 +687,28 @@ void shortcut_init(void)
add_to_funcs(do_writeout_void, MMAIN,
N_("Write Out"), IFSCHELP(nano_writeout_msg), TOGETHER, NOVIEW);
/* We allow inserting files in view mode if multibuffers are
* available, so that we can view multiple files. If we're using
* restricted mode, inserting files is disabled, since it allows
* reading from or writing to files not specified on the command
* line. */
add_to_funcs(do_insertfile_void, MMAIN,
read_file_tag, IFSCHELP(nano_insert_msg), BLANKAFTER,
#ifndef DISABLE_MULTIBUFFER
VIEW);
#ifndef DISABLE_JUSTIFY
if (!ISSET(RESTRICTED)) {
#else
NOVIEW);
/* If we can't replace Insert with Justify, show Insert anyway, to
* keep the help items nicely paired also in restricted mode. */
if (TRUE) {
#endif
add_to_funcs(do_insertfile_void, MMAIN,
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
VIEW);
#else
NOVIEW);
#endif
} else {
#ifndef DISABLE_JUSTIFY
add_to_funcs(do_justify_void, MMAIN,
justify_tag, IFSCHELP(nano_justify_msg), BLANKAFTER, NOVIEW);
#endif
}
add_to_funcs(do_search, MMAIN,
whereis_tag, IFSCHELP(nano_whereis_msg), TOGETHER, VIEW);
@@ -723,22 +743,25 @@ void shortcut_init(void)
/* Remember the entry for Uncut, to be able to replace it with Unjustify. */
uncutfunc = tailfunc;
if (!ISSET(RESTRICTED)) {
#ifndef DISABLE_JUSTIFY
add_to_funcs(do_justify_void, MMAIN,
N_("Justify"), IFSCHELP(nano_justify_msg), TOGETHER, NOVIEW);
add_to_funcs(do_justify_void, MMAIN,
justify_tag, IFSCHELP(nano_justify_msg), TOGETHER, NOVIEW);
#endif
#ifndef DISABLE_SPELLER
add_to_funcs(do_spell, MMAIN,
N_("To Spell"), IFSCHELP(nano_spell_msg), TOGETHER, NOVIEW);
add_to_funcs(do_spell, MMAIN,
N_("To Spell"), IFSCHELP(nano_spell_msg), TOGETHER, NOVIEW);
#endif
#ifndef DISABLE_COLOR
add_to_funcs(do_linter, MMAIN,
N_("To Linter"), IFSCHELP(nano_lint_msg), TOGETHER, NOVIEW);
add_to_funcs(do_formatter, MMAIN,
N_("Formatter"), IFSCHELP(nano_formatter_msg), BLANKAFTER, NOVIEW);
add_to_funcs(do_linter, MMAIN,
N_("To Linter"), IFSCHELP(nano_lint_msg), TOGETHER, NOVIEW);
#ifndef DISABLE_SPELLER
add_to_funcs(do_formatter, MMAIN,
N_("Formatter"), IFSCHELP(nano_formatter_msg), BLANKAFTER, NOVIEW);
#endif
#endif
}
#ifndef NANO_TINY
add_to_funcs(case_sens_void, MWHEREIS|MREPLACE,
@@ -776,10 +799,10 @@ void shortcut_init(void)
gotoline_tag, IFSCHELP(nano_gotoline_msg), BLANKAFTER, VIEW);
#endif
add_to_funcs(do_page_up, MMAIN|MHELP|MBROWSER,
N_("Prev Page"), IFSCHELP(nano_prevpage_msg), TOGETHER, VIEW);
add_to_funcs(do_page_down, MMAIN|MHELP|MBROWSER,
N_("Next Page"), IFSCHELP(nano_nextpage_msg), TOGETHER, VIEW);
add_to_funcs(do_page_up, MMAIN|MHELP,
prev_page_tag, IFSCHELP(nano_prevpage_msg), TOGETHER, VIEW);
add_to_funcs(do_page_down, MMAIN|MHELP,
next_page_tag, IFSCHELP(nano_nextpage_msg), TOGETHER, VIEW);
add_to_funcs(do_first_line, MMAIN|MHELP|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE,
N_("First Line"), IFSCHELP(nano_firstline_msg), TOGETHER, VIEW);
@@ -870,8 +893,9 @@ void shortcut_init(void)
add_to_funcs(do_tab, MMAIN,
N_("Tab"), IFSCHELP(nano_tab_msg), TOGETHER, NOVIEW);
add_to_funcs(do_enter_void, MMAIN,
N_("Enter"), IFSCHELP(nano_enter_msg), TOGETHER, NOVIEW);
add_to_funcs(do_enter, MMAIN,
N_("Enter"), IFSCHELP(nano_enter_msg), BLANKAFTER, NOVIEW);
add_to_funcs(do_delete, MMAIN,
N_("Delete"), IFSCHELP(nano_delete_msg), TOGETHER, NOVIEW);
add_to_funcs(do_backspace, MMAIN,
@@ -884,6 +908,10 @@ void shortcut_init(void)
NOVIEW);
#ifndef NANO_TINY
add_to_funcs(do_cut_prev_word, MMAIN,
N_("Cut Left"), IFSCHELP(nano_cut_word_left_msg), TOGETHER, NOVIEW);
add_to_funcs(do_cut_next_word, MMAIN,
N_("Cut Right"), IFSCHELP(nano_cut_word_right_msg), TOGETHER, NOVIEW);
add_to_funcs(do_cut_till_eof, MMAIN,
N_("CutTillEnd"), IFSCHELP(nano_cut_till_eof_msg), BLANKAFTER, NOVIEW);
#endif
@@ -904,6 +932,16 @@ void shortcut_init(void)
add_to_funcs(do_suspend_void, MMAIN,
N_("Suspend"), IFSCHELP(nano_suspend_msg), BLANKAFTER, VIEW);
#ifndef NANO_TINY
add_to_funcs(do_savefile, MMAIN,
N_("Save"), IFSCHELP(nano_savefile_msg), BLANKAFTER, NOVIEW);
add_to_funcs(do_findprevious, MMAIN,
N_("Previous"), IFSCHELP(nano_findprev_msg), TOGETHER, VIEW);
add_to_funcs(do_findnext, MMAIN,
N_("Next"), IFSCHELP(nano_findnext_msg), BLANKAFTER, VIEW);
#endif
#ifndef DISABLE_HISTORIES
add_to_funcs(get_history_older_void,
(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE),
@@ -917,35 +955,32 @@ void shortcut_init(void)
N_("Go To Text"), IFSCHELP(nano_whereis_msg), BLANKAFTER, VIEW);
#ifndef NANO_TINY
/* If we're using restricted mode, the DOS format, Mac format,
* append, prepend, and backup toggles are disabled. The first and
* second are useless since inserting files is disabled, the third
* and fourth are disabled because they allow writing to files not
* specified on the command line, and the fifth is useless since
* backups are disabled. */
add_to_funcs(dos_format_void, MWRITEFILE,
N_("DOS Format"), IFSCHELP(nano_dos_msg), TOGETHER, NOVIEW);
add_to_funcs(mac_format_void, MWRITEFILE,
N_("Mac Format"), IFSCHELP(nano_mac_msg), TOGETHER, NOVIEW);
/* If we're using restricted mode, the Append, Prepend, and Backup toggles
* are disabled. The first and second are not useful as they only allow
* reduplicating the current file, and the third is not allowed as it
* would write to a file not specified on the command line. */
if (!ISSET(RESTRICTED)) {
add_to_funcs(dos_format_void, MWRITEFILE,
N_("DOS Format"), IFSCHELP(nano_dos_msg), TOGETHER, NOVIEW);
add_to_funcs(append_void, MWRITEFILE,
N_("Append"), IFSCHELP(nano_append_msg), TOGETHER, NOVIEW);
add_to_funcs(prepend_void, MWRITEFILE,
N_("Prepend"), IFSCHELP(nano_prepend_msg), TOGETHER, NOVIEW);
add_to_funcs(mac_format_void, MWRITEFILE,
N_("Mac Format"), IFSCHELP(nano_mac_msg), TOGETHER, NOVIEW);
add_to_funcs(append_void, MWRITEFILE,
N_("Append"), IFSCHELP(nano_append_msg), TOGETHER, NOVIEW);
add_to_funcs(prepend_void, MWRITEFILE,
N_("Prepend"), IFSCHELP(nano_prepend_msg), TOGETHER, NOVIEW);
add_to_funcs(backup_file_void, MWRITEFILE,
N_("Backup File"), IFSCHELP(nano_backup_msg), TOGETHER, NOVIEW);
add_to_funcs(backup_file_void, MWRITEFILE,
N_("Backup File"), IFSCHELP(nano_backup_msg), TOGETHER, NOVIEW);
}
/* 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_void, MINSERTFILE,
N_("Execute Command"), IFSCHELP(nano_execute_msg), TOGETHER, NOVIEW);
add_to_funcs(flip_execute_void, MEXTCMD,
add_to_funcs(flip_execute_void, MEXTCMD,
read_file_tag, IFSCHELP(nano_insert_msg), TOGETHER, NOVIEW);
#ifndef DISABLE_MULTIBUFFER
@@ -960,10 +995,15 @@ void shortcut_init(void)
add_to_funcs(to_files_void, MWRITEFILE|MINSERTFILE,
N_("To Files"), IFSCHELP(nano_tofiles_msg), TOGETHER, VIEW);
add_to_funcs(do_page_up, MBROWSER,
prev_page_tag, IFSCHELP(nano_prevpage_msg), TOGETHER, VIEW);
add_to_funcs(do_page_down, MBROWSER,
next_page_tag, IFSCHELP(nano_nextpage_msg), TOGETHER, VIEW);
add_to_funcs(do_first_file, (MBROWSER|MWHEREISFILE),
N_("First File"), IFSCHELP(nano_firstfile_msg), TOGETHER, VIEW);
add_to_funcs(do_last_file, (MBROWSER|MWHEREISFILE),
N_("Last File"), IFSCHELP(nano_lastfile_msg), TOGETHER, VIEW);
N_("Last File"), IFSCHELP(nano_lastfile_msg), BLANKAFTER, VIEW);
#endif
#if !defined(NANO_TINY) && !defined(DISABLE_BROWSER)
@@ -1010,8 +1050,6 @@ void shortcut_init(void)
#ifndef DISABLE_COLOR
add_to_sclist(MMAIN, "^T", do_linter, 0);
add_to_sclist(MMAIN, "F12", do_linter, 0);
add_to_sclist(MMAIN, "^T", do_formatter, 0);
add_to_sclist(MMAIN, "F12", do_formatter, 0);
#endif
#endif
add_to_sclist(MMAIN, "^C", do_cursorpos_void, 0);
@@ -1019,12 +1057,12 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "^_", do_gotolinecolumn_void, 0);
add_to_sclist(MMAIN, "M-G", do_gotolinecolumn_void, 0);
add_to_sclist(MMAIN, "F13", do_gotolinecolumn_void, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE|MLINTER, "^Y", do_page_up, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE|MLINTER, "F7", do_page_up, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE|MLINTER, "PgUp", do_page_up, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE|MLINTER, "^V", do_page_down, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE|MLINTER, "F8", do_page_down, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE|MLINTER, "PgDn", do_page_down, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^Y", do_page_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F7", do_page_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgUp", do_page_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^V", do_page_down, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F8", do_page_down, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgDn", do_page_down, 0);
add_to_sclist(MMAIN|MHELP, "M-\\", do_first_line, 0);
add_to_sclist(MMAIN|MHELP, "M-|", do_first_line, 0);
add_to_sclist(MMAIN|MHELP, "M-/", do_last_line, 0);
@@ -1051,10 +1089,10 @@ void shortcut_init(void)
add_to_sclist(MMOST, "M-Space", do_prev_word_void, 0);
add_to_sclist(MMOST, "^Space", do_next_word_void, 0);
#endif
add_to_sclist(MMOST, "^A", do_home, 0);
add_to_sclist(MMOST, "Home", do_home, 0);
add_to_sclist(MMOST, "^E", do_end, 0);
add_to_sclist(MMOST, "End", do_end, 0);
add_to_sclist((MMOST & ~MBROWSER), "^A", do_home, 0);
add_to_sclist((MMOST & ~MBROWSER), "Home", do_home, 0);
add_to_sclist((MMOST & ~MBROWSER), "^E", do_end, 0);
add_to_sclist((MMOST & ~MBROWSER), "End", do_end, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^P", do_up_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "Up", do_up_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^N", do_down_void, 0);
@@ -1147,31 +1185,45 @@ void shortcut_init(void)
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Down", get_history_newer_void, 0);
#endif
#ifndef DISABLE_BROWSER
add_to_sclist(MWHEREISFILE, "^Y", do_first_file, 0);
add_to_sclist(MWHEREISFILE, "^V", do_last_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-\\", do_first_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", do_first_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-/", do_last_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", do_last_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "^_", goto_dir_void, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-G", goto_dir_void, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "F13", goto_dir_void, 0);
add_to_sclist(MBROWSER, "Home", do_first_file, 0);
add_to_sclist(MBROWSER, "End", do_last_file, 0);
add_to_sclist(MBROWSER, "^_", goto_dir_void, 0);
add_to_sclist(MBROWSER, "M-G", goto_dir_void, 0);
add_to_sclist(MBROWSER, "F13", goto_dir_void, 0);
#endif
add_to_sclist(MWRITEFILE, "M-D", dos_format_void, 0);
add_to_sclist(MWRITEFILE, "M-M", mac_format_void, 0);
add_to_sclist(MWRITEFILE, "M-A", append_void, 0);
add_to_sclist(MWRITEFILE, "M-P", prepend_void, 0);
add_to_sclist(MWRITEFILE, "M-B", backup_file_void, 0);
if (!ISSET(RESTRICTED)) {
/* Don't allow Appending, Prepending, nor Backups in restricted mode. */
add_to_sclist(MWRITEFILE, "M-A", append_void, 0);
add_to_sclist(MWRITEFILE, "M-P", prepend_void, 0);
add_to_sclist(MWRITEFILE, "M-B", backup_file_void, 0);
#ifndef DISABLE_BROWSER
add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", to_files_void, 0);
add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", to_files_void, 0);
#endif
add_to_sclist(MINSERTFILE|MEXTCMD, "^X", flip_execute_void, 0);
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", new_buffer_void, 0);
add_to_sclist(MINSERTFILE|MEXTCMD, "^X", flip_execute_void, 0);
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", new_buffer_void, 0);
}
add_to_sclist(MHELP|MBROWSER, "^C", do_exit, 0);
/* Allow exiting from the file browser and the help viewer with
* the same key as they were entered. */
#ifndef DISABLE_BROWSER
add_to_sclist(MBROWSER, "^T", do_exit, 0);
#endif
#ifndef DISABLE_HELP
add_to_sclist(MHELP, "^G", do_exit, 0);
add_to_sclist(MHELP, "Home", do_first_line, 0);
add_to_sclist(MHELP, "End", do_last_line, 0);
#endif
add_to_sclist(MMOST, "^I", do_tab, 0);
add_to_sclist(MMOST, "^M", do_enter_void, 0);
add_to_sclist(MMOST, "Enter", do_enter_void, 0);
add_to_sclist(MMOST, "^M", do_enter, 0);
add_to_sclist(MMOST, "Enter", do_enter, 0);
add_to_sclist(MMOST, "^D", do_delete, 0);
add_to_sclist(MMOST, "Del", do_delete, 0);
add_to_sclist(MMOST, "^H", do_backspace, 0);
@@ -1221,44 +1273,44 @@ const subnfunc *sctofunc(sc *s)
const char *flagtostr(int flag)
{
switch (flag) {
case NO_HELP:
/* 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:
return N_("Constant cursor position display");
case MORE_SPACE:
return N_("Use of one more line for editing");
case SMOOTH_SCROLL:
return N_("Smooth scrolling");
case SOFTWRAP:
return N_("Soft wrapping of overlong lines");
case WHITESPACE_DISPLAY:
return N_("Whitespace display");
case NO_COLOR_SYNTAX:
return N_("Color syntax highlighting");
case SMART_HOME:
return N_("Smart home key");
case AUTOINDENT:
return N_("Auto indent");
case CUT_TO_END:
return N_("Cut to end");
case NO_WRAP:
return N_("Hard wrapping of overlong lines");
case TABS_TO_SPACES:
return N_("Conversion of typed tabs to spaces");
case BACKUP_FILE:
return N_("Backup files");
case MULTIBUFFER:
return N_("Multiple file buffers");
case USE_MOUSE:
return N_("Mouse support");
case NO_CONVERT:
return N_("No conversion from DOS/Mac format");
case SUSPEND:
return N_("Suspension");
default:
return "?????";
case NO_HELP:
/* 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:
return N_("Constant cursor position display");
case MORE_SPACE:
return N_("Use of one more line for editing");
case SMOOTH_SCROLL:
return N_("Smooth scrolling");
case SOFTWRAP:
return N_("Soft wrapping of overlong lines");
case WHITESPACE_DISPLAY:
return N_("Whitespace display");
case NO_COLOR_SYNTAX:
return N_("Color syntax highlighting");
case SMART_HOME:
return N_("Smart home key");
case AUTOINDENT:
return N_("Auto indent");
case CUT_TO_END:
return N_("Cut to end");
case NO_WRAP:
return N_("Hard wrapping of overlong lines");
case TABS_TO_SPACES:
return N_("Conversion of typed tabs to spaces");
case BACKUP_FILE:
return N_("Backup files");
case MULTIBUFFER:
return N_("Reading file into separate buffer");
case USE_MOUSE:
return N_("Mouse support");
case NO_CONVERT:
return N_("No conversion from DOS/Mac format");
case SUSPEND:
return N_("Suspension");
default:
return "?????";
}
}
#endif /* !NANO_TINY */
@@ -1283,6 +1335,10 @@ sc *strtosc(char *input)
s->scfunc = do_exit;
else if (!strcasecmp(input, "writeout"))
s->scfunc = do_writeout_void;
#ifndef NANO_TINY
else if (!strcasecmp(input, "savefile"))
s->scfunc = do_savefile;
#endif
else if (!strcasecmp(input, "insert"))
s->scfunc = do_insertfile_void;
else if (!strcasecmp(input, "whereis"))
@@ -1291,6 +1347,10 @@ sc *strtosc(char *input)
else if (!strcasecmp(input, "searchagain") ||
!strcasecmp(input, "research"))
s->scfunc = do_research;
else if (!strcasecmp(input, "findprevious"))
s->scfunc = do_findprevious;
else if (!strcasecmp(input, "findnext"))
s->scfunc = do_findnext;
#endif
else if (!strcasecmp(input, "replace"))
s->scfunc = do_replace;
@@ -1310,6 +1370,10 @@ sc *strtosc(char *input)
else if (!strcasecmp(input, "tospell") ||
!strcasecmp(input, "speller"))
s->scfunc = do_spell;
#endif
#ifndef DISABLE_COLOR
else if (!strcasecmp(input, "linter"))
s->scfunc = do_linter;
#endif
else if (!strcasecmp(input, "curpos") ||
!strcasecmp(input, "cursorpos"))
@@ -1339,6 +1403,10 @@ sc *strtosc(char *input)
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, "findbracket"))
s->scfunc = do_find_bracket;
else if (!strcasecmp(input, "wordcount"))
@@ -1385,7 +1453,7 @@ sc *strtosc(char *input)
else if (!strcasecmp(input, "tab"))
s->scfunc = do_tab;
else if (!strcasecmp(input, "enter"))
s->scfunc = do_enter_void;
s->scfunc = do_enter;
else if (!strcasecmp(input, "delete"))
s->scfunc = do_delete;
else if (!strcasecmp(input, "backspace"))
@@ -1528,7 +1596,7 @@ int strtomenu(char *input)
return MHELP;
#endif
#ifndef DISABLE_SPELLER
else if (!strcasecmp(input, "spell") || !strcasecmp(input, "formatter"))
else if (!strcasecmp(input, "spell"))
return MSPELL;
#endif
else if (!strcasecmp(input, "linter"))
@@ -1559,34 +1627,25 @@ void thanks_for_all_the_fish(void)
delwin(bottomwin);
#ifndef DISABLE_JUSTIFY
if (quotestr != NULL)
free(quotestr);
free(quotestr);
#ifdef HAVE_REGEX_H
regfree(&quotereg);
if (quoteerr != NULL)
free(quoteerr);
free(quoteerr);
#endif
#endif
#ifndef NANO_TINY
if (backup_dir != NULL)
free(backup_dir);
free(backup_dir);
#endif
#ifndef DISABLE_OPERATINGDIR
if (operating_dir != NULL)
free(operating_dir);
if (full_operating_dir != NULL)
free(full_operating_dir);
free(operating_dir);
free(full_operating_dir);
#endif
if (last_search != NULL)
free(last_search);
if (last_replace != NULL)
free(last_replace);
free(answer);
free(last_search);
free(last_replace);
#ifndef DISABLE_SPELLER
if (alt_speller != NULL)
free(alt_speller);
free(alt_speller);
#endif
if (answer != NULL)
free(answer);
if (cutbuffer != NULL)
free_filestruct(cutbuffer);
#ifndef DISABLE_JUSTIFY
@@ -1597,12 +1656,13 @@ void thanks_for_all_the_fish(void)
if (openfile != NULL)
free_openfilestruct(openfile);
#ifndef DISABLE_COLOR
if (syntaxstr != NULL)
free(syntaxstr);
free(syntaxstr);
while (syntaxes != NULL) {
syntaxtype *bill = syntaxes;
free(syntaxes->desc);
free(syntaxes->linter);
free(syntaxes->formatter);
while (syntaxes->extensions != NULL) {
regexlisttype *bob = syntaxes->extensions;
syntaxes->extensions = bob->next;
@@ -1663,18 +1723,17 @@ void thanks_for_all_the_fish(void)
#endif
/* Free the functions and shortcuts lists. */
while (allfuncs != NULL) {
subnfunc *f = allfuncs;
allfuncs = allfuncs->next;
free(f);
subnfunc *f = allfuncs;
allfuncs = allfuncs->next;
free(f);
}
while (sclist != NULL) {
sc *s = sclist;
sclist = sclist->next;
free(s);
sc *s = sclist;
sclist = sclist->next;
free(s);
}
#ifndef DISABLE_NANORC
if (homedir != NULL)
free(homedir);
free(homedir);
#endif
}

View File

@@ -32,9 +32,12 @@
static char *help_text = NULL;
/* The text displayed in the help window. */
/* Our main help browser function. refresh_func is the function we will
* call to refresh the edit window. */
void do_help(void (*refresh_func)(void))
static char *end_of_intro = NULL;
/* The point in the help text where the introductory paragraphs end
* and the shortcut descriptions begin. */
/* Our main help-viewer function. */
void do_help(void)
{
int kbinput = ERR;
bool old_no_help = ISSET(NO_HELP);
@@ -62,10 +65,6 @@ void do_help(void (*refresh_func)(void))
assert(help_text != NULL);
/* Set currmenu to allow clicking on the help screen's shortcut
* list, after help_init() is called. */
currmenu = MHELP;
if (ISSET(NO_HELP)) {
/* Make sure that the help screen's shortcut list will actually
* be displayed. */
@@ -76,35 +75,35 @@ void do_help(void (*refresh_func)(void))
bottombars(MHELP);
wnoutrefresh(bottomwin);
/* Get the last line of the help text. */
ptr = help_text;
for (; *ptr != '\0'; last_line++) {
ptr += help_line_len(ptr);
if (*ptr == '\n')
ptr++;
}
if (last_line > 0)
last_line--;
while (TRUE) {
size_t i;
/* Display the help text if we don't have a key, or if the help
* text has moved. */
if (kbinput == ERR || line != old_line) {
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;
/* Calculate where in the text we should be, based on the
* page. */
/* 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);
@@ -121,6 +120,14 @@ void do_help(void (*refresh_func)(void))
kbinput = get_kbinput(edit);
#ifndef NANO_TINY
if (kbinput == KEY_WINCH) {
kbinput = ERR;
curs_set(0);
continue; /* Redraw the screen. */
}
#endif
#ifndef DISABLE_MOUSE
if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y;
@@ -153,51 +160,50 @@ void do_help(void (*refresh_func)(void))
if (line + (editwinrows - 1) < last_line)
line = last_line - (editwinrows - 1);
} else if (func == do_exit) {
/* Exit from the help browser. */
/* Exit from the help viewer. */
break;
}
}
currmenu = oldmenu;
if (old_no_help) {
blank_bottombars();
wnoutrefresh(bottomwin);
currmenu = oldmenu;
SET(NO_HELP);
window_init();
} else
bottombars(currmenu);
bottombars(oldmenu);
curs_set(1);
refresh_func();
/* The help_init() at the beginning allocated help_text. Since
* help_text has now been written to the screen, we don't need it
* anymore. */
#ifndef DISABLE_BROWSER
if (oldmenu == MBROWSER || oldmenu == MWHEREISFILE || oldmenu == MGOTODIR)
browser_refresh();
else
#endif
edit_refresh();
/* We're exiting from the help screen. */
free(help_text);
help_text = NULL;
}
/* This function allocates help_text, and stores the help string in it.
* help_text should be NULL initially. */
/* Allocate space for the help text for the current menu, and concatenate
* the different pieces of text into it. */
void help_init(void)
{
size_t allocsize = 0; /* Space needed for help_text. */
const char *htx[3]; /* Untranslated help message. We break
* it up into three chunks in case the
* full string is too long for the
* compiler to handle. */
size_t allocsize = 0;
/* Space needed for help_text. */
const char *htx[3];
/* Untranslated help introduction. We break it up into three chunks
* in case the full string is too long for the compiler to handle. */
char *ptr;
const subnfunc *f;
const sc *s;
int scsfound = 0;
#ifndef NANO_TINY
#ifndef DISABLE_NANORC
bool old_whitespace = ISSET(WHITESPACE_DISPLAY);
UNSET(WHITESPACE_DISPLAY);
#endif
#endif
/* First, set up the initial help text for the current function. */
@@ -364,9 +370,9 @@ void help_init(void)
/* Calculate the length of the shortcut help text. Each entry has
* one or two keys, which fill 16 columns, plus translated text,
* plus one or two \n's. */
for (f = allfuncs; f != NULL; f = f->next)
if (f->menus & currmenu)
allocsize += (16 * mb_cur_max()) + strlen(f->help) + 2;
for (f = allfuncs; f != NULL; f = f->next)
if (f->menus & currmenu)
allocsize += (16 * mb_cur_max()) + strlen(f->help) + 2;
#ifndef NANO_TINY
/* If we're on the main list, we also count the toggle help text.
@@ -381,11 +387,6 @@ void help_init(void)
}
#endif
/* help_text has been freed and set to NULL unless the user resized
* while in the help screen. */
if (help_text != NULL)
free(help_text);
/* Allocate space for the help text. */
help_text = charalloc(allocsize + 1);
@@ -398,19 +399,20 @@ void help_init(void)
ptr = help_text + strlen(help_text);
/* Remember this end-of-introduction, start-of-shortcuts. */
end_of_intro = ptr;
/* Now add our shortcut info. */
for (f = allfuncs; f != NULL; f = f->next) {
int scsfound = 0;
if ((f->menus & currmenu) == 0)
continue;
/* Let's simply show the first two shortcuts from the list. */
for (s = sclist, scsfound = 0; s != NULL; s = s->next) {
for (s = sclist; s != NULL; s = s->next) {
if (s->type == RAWINPUT)
continue;
if ((s->menu & currmenu) == 0)
if ((s->menus & currmenu) == 0)
continue;
if (s->scfunc == f->scfunc) {
@@ -441,23 +443,32 @@ void help_init(void)
#ifndef NANO_TINY
/* And the toggles... */
if (currmenu == MMAIN)
for (s = sclist; s != NULL; s = s->next) {
if (s->scfunc == do_toggle_void)
ptr += sprintf(ptr, "%s\t\t%s %s\n", (s->menu == MMAIN ? s->keystr : ""),
_(flagtostr(s->toggle)), _("enable/disable"));
if (s->toggle == NO_COLOR_SYNTAX || s->toggle == TABS_TO_SPACES)
ptr += sprintf(ptr, "\n");
}
if (currmenu == MMAIN) {
int maximum = 0, counter = 0;
/* First see how many toggles there are. */
for (s = sclist; s != NULL; s = s->next)
maximum = (s->toggle && s->ordinal > maximum) ? s->ordinal : maximum;
/* Now show them in the original order. */
while (counter < maximum) {
counter++;
for (s = sclist; s != NULL; s = s->next)
if (s->toggle && s->ordinal == counter) {
ptr += sprintf(ptr, "%s\t\t%s %s\n", (s->menus == MMAIN ? s->keystr : ""),
_(flagtostr(s->toggle)), _("enable/disable"));
if (s->toggle == NO_COLOR_SYNTAX || s->toggle == TABS_TO_SPACES)
ptr += sprintf(ptr, "\n");
break;
}
}
}
#ifndef DISABLE_NANORC
if (old_whitespace)
SET(WHITESPACE_DISPLAY);
#endif
#endif /* !NANO_TINY */
/* If all went well, we didn't overwrite the allocated space for
* help_text. */
/* If all went well, we didn't overwrite the allocated space. */
assert(strlen(help_text) <= allocsize + 1);
}
@@ -479,46 +490,45 @@ functionptrtype parse_help_input(int *kbinput)
return func_from_key(kbinput);
}
/* Calculate the next line of help_text, starting at ptr. */
/* Calculate the displayable length of the help-text line starting at ptr. */
size_t help_line_len(const char *ptr)
{
int help_cols = (COLS > 24) ? COLS - 1 : 24;
size_t wrapping_point = (COLS > 24) ? COLS - 1 : 24;
/* The target width for wrapping long lines. */
ssize_t wrap_location;
/* Actual position where the line can be wrapped. */
size_t length = 0;
/* Full length of the line, until the first newline. */
/* Try to break the line at (COLS - 1) columns if we have more than
* 24 columns, and at 24 columns otherwise. */
ssize_t wrap_loc = break_line(ptr, help_cols, TRUE);
size_t retval = (wrap_loc < 0) ? 0 : wrap_loc;
size_t retval_save = retval;
/* Avoid overwide paragraphs in the introductory text. */
if (ptr < end_of_intro && COLS > 74)
wrapping_point = 74;
wrap_location = break_line(ptr, wrapping_point, TRUE);
/* Get the length of the entire line up to a null or a newline. */
while (*(ptr + retval) != '\0' && *(ptr + retval) != '\n')
retval += move_mbright(ptr + retval, 0);
while (*(ptr + length) != '\0' && *(ptr + length) != '\n')
length = move_mbright(ptr, length);
/* If the entire line doesn't go more than one column beyond where
* we tried to break it, we should display it as-is. Otherwise, we
* should display it only up to the break. */
if (strnlenpt(ptr, retval) > help_cols + 1)
retval = retval_save;
return retval;
/* If the entire line will just fit the screen, don't wrap it. */
if (strnlenpt(ptr, length) <= wrapping_point + 1)
return length;
else if (wrap_location > 0)
return wrap_location;
else
return 0;
}
#endif /* !DISABLE_HELP */
/* Start the help browser. */
/* Start the help viewer. */
void do_help_void(void)
{
#ifndef DISABLE_HELP
/* Start the help browser, with the correct refresher for afterwards. */
#ifndef DISABLE_BROWSER
if (currmenu == MBROWSER || currmenu == MWHEREISFILE || currmenu == MGOTODIR)
do_help(&browser_refresh);
else
#endif
do_help(&edit_refresh);
do_help();
#else
if (currmenu == MMAIN)
nano_disabled_msg();
say_there_is_no_help();
else
beep();
#endif /* !DISABLE_HELP */

View File

@@ -52,9 +52,8 @@ void do_page_up(void)
{
int i, skipped = 0;
/* If there's less than a page of text left on the screen, put the
* cursor at the beginning of the first line of the file, and then
* update the edit window. */
/* If the cursor is less than a page away from the top of the file,
* put it at the beginning of the first line. */
if (openfile->current->lineno == 1 || (
#ifndef NANO_TINY
!ISSET(SOFTWRAP) &&
@@ -106,9 +105,8 @@ void do_page_down(void)
{
int i;
/* If there's less than a page of text left on the screen, put the
* cursor at the beginning of the last line of the file, and then
* update the edit window. */
/* If the cursor is less than a page away from the bottom of the file,
* put it at the end of the last line. */
if (openfile->current->lineno + maxrows - 2 >=
openfile->filebot->lineno) {
do_last_line();
@@ -225,75 +223,37 @@ bool do_next_word(bool allow_punct, bool allow_update)
{
size_t pww_save = openfile->placewewant;
filestruct *current_save = openfile->current;
char *char_mb;
int char_mb_len;
bool end_line = FALSE, started_on_word = FALSE;
bool started_on_word = is_word_mbchar(openfile->current->data +
openfile->current_x, allow_punct);
bool seen_space = !started_on_word;
assert(openfile->current != NULL && openfile->current->data != NULL);
char_mb = charalloc(mb_cur_max());
/* Move forward until we find the character after the last letter of
* the current word. */
while (!end_line) {
char_mb_len = parse_mbchar(openfile->current->data +
openfile->current_x, char_mb, NULL);
/* If we've found it, stop moving forward through the current
* line. */
if (!is_word_mbchar(char_mb, allow_punct))
break;
/* If we haven't found it, then we've started on a word, so set
* started_on_word to TRUE. */
started_on_word = TRUE;
if (openfile->current->data[openfile->current_x] == '\0')
end_line = TRUE;
else
openfile->current_x += char_mb_len;
}
/* Move forward until we find the first letter of the next word. */
if (openfile->current->data[openfile->current_x] == '\0')
end_line = TRUE;
else
openfile->current_x += char_mb_len;
for (; openfile->current != NULL;
openfile->current = openfile->current->next) {
while (!end_line) {
char_mb_len = parse_mbchar(openfile->current->data +
openfile->current_x, char_mb, NULL);
/* If we've found it, stop moving forward through the
* current line. */
if (is_word_mbchar(char_mb, allow_punct))
/* Move forward until we reach the start of a word. */
while (TRUE) {
/* If at the end of a line, move to the beginning of the next one. */
if (openfile->current->data[openfile->current_x] == '\0') {
/* If at the end of the file, stop. */
if (openfile->current->next == NULL)
break;
if (openfile->current->data[openfile->current_x] == '\0')
end_line = TRUE;
else
openfile->current_x += char_mb_len;
}
/* If we've found it, stop moving forward to the beginnings of
* subsequent lines. */
if (!end_line)
break;
if (openfile->current != openfile->filebot) {
end_line = FALSE;
openfile->current = openfile->current->next;
openfile->current_x = 0;
seen_space = TRUE;
} else {
/* Step forward one character. */
openfile->current_x = move_mbright(openfile->current->data,
openfile->current_x);
}
/* If this is not a word character, then it's a separator; else
* if we've already seen a separator, then it's a word start. */
if (!is_word_mbchar(openfile->current->data + openfile->current_x,
allow_punct))
seen_space = TRUE;
else if (seen_space)
break;
}
free(char_mb);
/* If we haven't found it, move to the end of the file. */
if (openfile->current == NULL)
openfile->current = openfile->filebot;
openfile->placewewant = xplustabs();
/* If allow_update is TRUE, update the screen. */
@@ -314,125 +274,51 @@ void do_next_word_void(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
* screen afterwards. Return TRUE if we started on a word, and FALSE
* otherwise. */
bool do_prev_word(bool allow_punct, bool allow_update)
* screen afterwards. */
void do_prev_word(bool allow_punct, bool allow_update)
{
size_t pww_save = openfile->placewewant;
filestruct *current_save = openfile->current;
char *char_mb;
int char_mb_len;
bool begin_line = FALSE, started_on_word = FALSE;
bool seen_a_word = FALSE, step_forward = FALSE;
assert(openfile->current != NULL && openfile->current->data != NULL);
char_mb = charalloc(mb_cur_max());
/* Move backward until we pass over the start of a word. */
while (TRUE) {
/* If at the head of a line, move to the end of the preceding one. */
if (openfile->current_x == 0) {
if (openfile->current->prev == NULL)
break;
openfile->current = openfile->current->prev;
openfile->current_x = strlen(openfile->current->data);
}
/* Move backward until we find the character before the first letter
* of the current word. */
while (!begin_line) {
char_mb_len = parse_mbchar(openfile->current->data +
openfile->current_x, char_mb, NULL);
/* If we've found it, stop moving backward through the current
* line. */
if (!is_word_mbchar(char_mb, allow_punct))
break;
/* If we haven't found it, then we've started on a word, so set
* started_on_word to TRUE. */
started_on_word = TRUE;
if (openfile->current_x == 0)
begin_line = TRUE;
else
openfile->current_x = move_mbleft(openfile->current->data,
openfile->current_x);
}
/* Move backward until we find the last letter of the previous
* word. */
if (openfile->current_x == 0)
begin_line = TRUE;
else
/* Step back one character. */
openfile->current_x = move_mbleft(openfile->current->data,
openfile->current_x);
for (; openfile->current != NULL;
openfile->current = openfile->current->prev) {
while (!begin_line) {
char_mb_len = parse_mbchar(openfile->current->data +
openfile->current_x, char_mb, NULL);
/* If we've found it, stop moving backward through the
* current line. */
if (is_word_mbchar(char_mb, allow_punct))
break;
openfile->current_x);
if (is_word_mbchar(openfile->current->data + openfile->current_x,
allow_punct)) {
seen_a_word = TRUE;
/* If at the head of a line now, this surely is a word start. */
if (openfile->current_x == 0)
begin_line = TRUE;
else
openfile->current_x =
move_mbleft(openfile->current->data,
openfile->current_x);
}
/* If we've found it, stop moving backward to the ends of
* previous lines. */
if (!begin_line)
break;
} else if (seen_a_word) {
/* This is space now: we've overshot the start of the word. */
step_forward = TRUE;
break;
if (openfile->current != openfile->fileage) {
begin_line = FALSE;
openfile->current_x = strlen(openfile->current->prev->data);
}
}
/* If we haven't found it, move to the beginning of the file. */
if (openfile->current == NULL)
openfile->current = openfile->fileage;
/* If we've found it, move backward until we find the character
* before the first letter of the previous word. */
else if (!begin_line) {
if (openfile->current_x == 0)
begin_line = TRUE;
else
openfile->current_x = move_mbleft(openfile->current->data,
openfile->current_x);
while (!begin_line) {
char_mb_len = parse_mbchar(openfile->current->data +
openfile->current_x, char_mb, NULL);
/* If we've found it, stop moving backward through the
* current line. */
if (!is_word_mbchar(char_mb, allow_punct))
break;
if (openfile->current_x == 0)
begin_line = TRUE;
else
openfile->current_x =
move_mbleft(openfile->current->data,
openfile->current_x);
}
/* If we've found it, move forward to the first letter of the
* previous word. */
if (!begin_line)
openfile->current_x += char_mb_len;
}
free(char_mb);
if (step_forward)
/* Move one character forward again to sit on the start of the word. */
openfile->current_x = move_mbright(openfile->current->data,
openfile->current_x);
openfile->placewewant = xplustabs();
/* If allow_update is TRUE, update the screen. */
if (allow_update)
edit_redraw(current_save, pww_save);
/* Return whether we started on a word. */
return started_on_word;
}
/* Move to the previous word in the file, treating punctuation as part
@@ -471,7 +357,7 @@ void do_home(void)
}
#endif
if (need_horizontal_update(pww_save))
if (need_screen_update(pww_save))
update_line(openfile->current, openfile->current_x);
}
@@ -483,7 +369,7 @@ void do_end(void)
openfile->current_x = strlen(openfile->current->data);
openfile->placewewant = xplustabs();
if (need_horizontal_update(pww_save))
if (need_screen_update(pww_save))
update_line(openfile->current, openfile->current_x);
}
@@ -534,7 +420,7 @@ void do_up(
* needs to be redrawn if we're not on the first page, and the
* latter needs to be drawn unconditionally. */
if (openfile->current_y > 0) {
if (need_vertical_update(0))
if (need_screen_update(0))
update_line(openfile->current->next, 0);
update_line(openfile->current, openfile->current_x);
}
@@ -592,11 +478,11 @@ void do_down(
topline = openfile->edittop;
/* Reduce the amount when there are overlong lines at the top. */
for (enough = 1; enough < amount; enough++) {
if (amount <= strlenpt(topline->data) / COLS) {
amount -= strlenpt(topline->data) / COLS;
if (amount <= 0) {
amount = enough;
break;
}
amount -= strlenpt(topline->data) / COLS;
topline = topline->next;
}
}
@@ -632,7 +518,7 @@ void do_down(
|| ISSET(SOFTWRAP)
#endif
) {
if (need_vertical_update(0))
if (need_screen_update(0))
update_line(openfile->current->prev, 0);
update_line(openfile->current, openfile->current_x);
}
@@ -671,7 +557,7 @@ void do_left(void)
openfile->placewewant = xplustabs();
if (need_horizontal_update(pww_save))
if (need_screen_update(pww_save))
update_line(openfile->current, openfile->current_x);
}
@@ -692,6 +578,6 @@ void do_right(void)
openfile->placewewant = xplustabs();
if (need_horizontal_update(pww_save))
if (need_screen_update(pww_save))
update_line(openfile->current, openfile->current_x);
}

View File

@@ -25,7 +25,6 @@
#include <stdio.h>
#include <stdarg.h>
#include <signal.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
@@ -95,21 +94,20 @@ filestruct *copy_node(const filestruct *src)
return dst;
}
/* Splice a node into an existing filestruct. */
void splice_node(filestruct *begin, filestruct *newnode, filestruct
*end)
/* Splice a new node into an existing linked list of filestructs. */
void splice_node(filestruct *afterthis, filestruct *newnode)
{
assert(newnode != NULL && begin != NULL);
assert(afterthis != NULL && newnode != NULL);
newnode->next = end;
newnode->prev = begin;
begin->next = newnode;
if (end != NULL)
end->prev = newnode;
newnode->next = afterthis->next;
newnode->prev = afterthis;
if (afterthis->next != NULL)
afterthis->next->prev = newnode;
afterthis->next = newnode;
}
/* Unlink a node from the rest of the filestruct. */
void unlink_node(const filestruct *fileptr)
/* Unlink a node from the rest of the filestruct and delete it. */
void unlink_node(filestruct *fileptr)
{
assert(fileptr != NULL);
@@ -117,6 +115,8 @@ void unlink_node(const filestruct *fileptr)
fileptr->prev->next = fileptr->next;
if (fileptr->next != NULL)
fileptr->next->prev = fileptr->prev;
delete_node(fileptr);
}
/* Delete a node from the filestruct. */
@@ -124,14 +124,10 @@ void delete_node(filestruct *fileptr)
{
assert(fileptr != NULL && fileptr->data != NULL);
if (fileptr->data != NULL)
free(fileptr->data);
free(fileptr->data);
#ifndef DISABLE_COLOR
if (fileptr->multidata)
free(fileptr->multidata);
free(fileptr->multidata);
#endif
free(fileptr);
}
@@ -389,7 +385,7 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
openfile->mark_begin = openfile->current;
openfile->mark_begin_x = openfile->current_x;
} else if (same_line)
/* Update the content of this partially cut line. */
/* Update the pointer to this partially cut line. */
openfile->mark_begin = openfile->current;
#endif
@@ -456,34 +452,31 @@ void copy_from_filestruct(filestruct *somebuffer)
while (openfile->filebot->next != NULL)
openfile->filebot = openfile->filebot->next;
/* Restore the current line and cursor position. If the mark begins
* inside the partition, adjust the mark coordinates to compensate
* for the change in the current line. */
/* Put the cursor at the end of the pasted text. */
openfile->current = openfile->filebot;
openfile->current_x = strlen(openfile->filebot->data);
/* Refresh the mark's pointer, and compensate the mark's
* x coordinate for the change in the current line. */
if (openfile->fileage == openfile->filebot) {
#ifndef NANO_TINY
if (openfile->mark_set) {
if (openfile->mark_set && single_line) {
openfile->mark_begin = openfile->current;
if (!right_side_up)
openfile->mark_begin_x += openfile->current_x;
}
#endif
/* When the pasted stuff contains no newline, adjust the cursor's
* x coordinate for the text that is before the pasted stuff. */
openfile->current_x += current_x_save;
}
#ifndef NANO_TINY
else if (openfile->mark_set) {
if (right_side_up) {
if (single_line)
/* Get the new data, stuff was inserted on the mark line. */
openfile->mark_begin = openfile->fileage;
/* The x is okay, it did not move. */
} else {
if (single_line) {
openfile->mark_begin = openfile->current;
openfile->mark_begin_x -= current_x_save;
} else
openfile->mark_begin_x -= openfile->current_x;
else if (openfile->mark_set && single_line) {
if (right_side_up)
openfile->mark_begin = openfile->fileage;
else {
openfile->mark_begin = openfile->current;
openfile->mark_begin_x += openfile->current_x - current_x_save;
}
}
#endif
@@ -522,21 +515,7 @@ void copy_from_filestruct(filestruct *somebuffer)
/* Create a new openfilestruct node. */
openfilestruct *make_new_opennode(void)
{
openfilestruct *newnode =
(openfilestruct *)nmalloc(sizeof(openfilestruct));
newnode->filename = NULL;
newnode->fileage = NULL;
newnode->filebot = NULL;
newnode->edittop = NULL;
newnode->current = NULL;
#ifndef NANO_TINY
newnode->current_stat = NULL;
newnode->last_action = OTHER;
newnode->lock_filename = NULL;
#endif
return newnode;
return (openfilestruct *)nmalloc(sizeof(openfilestruct));
}
/* Splice a node into an existing openfilestruct. */
@@ -556,7 +535,8 @@ void splice_opennode(openfilestruct *begin, openfilestruct *newnode,
/* Unlink a node from the rest of the openfilestruct, and delete it. */
void unlink_opennode(openfilestruct *fileptr)
{
assert(fileptr != NULL && fileptr->prev != NULL && fileptr->next != NULL && fileptr != fileptr->prev && fileptr != fileptr->next);
assert(fileptr != NULL && fileptr->prev != NULL && fileptr->next != NULL &&
fileptr != fileptr->prev && fileptr != fileptr->next);
fileptr->prev->next = fileptr->next;
fileptr->next->prev = fileptr->prev;
@@ -572,10 +552,9 @@ void delete_opennode(openfilestruct *fileptr)
free(fileptr->filename);
free_filestruct(fileptr->fileage);
#ifndef NANO_TINY
if (fileptr->current_stat != NULL)
free(fileptr->current_stat);
free(fileptr->current_stat);
free(fileptr->lock_filename);
#endif
free(fileptr);
}
@@ -598,18 +577,31 @@ void free_openfilestruct(openfilestruct *src)
/* Display a warning about a key disabled in view mode. */
void print_view_warning(void)
{
statusbar(_("Key invalid in view mode"));
statusbar(_("Key is invalid in view mode"));
}
/* Indicate that something is disabled in restricted mode. */
void show_restricted_warning(void)
{
statusbar(_("This function is disabled in restricted mode"));
beep();
}
#ifdef DISABLE_HELP
/* Indicate that help texts are unavailable. */
void say_there_is_no_help(void)
{
statusbar(_("Help is not available"));
}
#endif
/* Make nano exit gracefully. */
void finish(void)
{
/* Blank the statusbar (and shortcut list, if applicable), and move
* the cursor to the last line of the screen. */
if (!ISSET(NO_HELP))
blank_bottombars();
else
blank_statusbar();
/* Blank the statusbar and (if applicable) the shortcut list,
* and move the cursor to the last line of the screen. */
blank_statusbar();
blank_bottombars();
wrefresh(bottomwin);
endwin();
@@ -719,9 +711,9 @@ void die_save_file(const char *die_filename
_("Too many backup files?"));
#ifndef NANO_TINY
/* Try and chmod/chown the save file to the values of the original file, but
dont worry if it fails because we're supposed to be bailing as fast
as possible. */
/* Try and chmod/chown the save file to the values of the original file,
* but don't worry if it fails because we're supposed to be bailing as
* fast as possible. */
if (die_stat) {
int shush;
shush = chmod(retval, die_stat->st_mode);
@@ -847,30 +839,32 @@ void usage(void)
N_("Start at line LINE, column COLUMN"));
#ifndef NANO_TINY
print_opt("-A", "--smarthome", N_("Enable smart home key"));
print_opt("-B", "--backup", N_("Save backups of existing files"));
print_opt(_("-C <dir>"), _("--backupdir=<dir>"),
N_("Directory for saving unique backup files"));
if (!ISSET(RESTRICTED)) {
print_opt("-B", "--backup", N_("Save backups of existing files"));
print_opt(_("-C <dir>"), _("--backupdir=<dir>"),
N_("Directory for saving unique backup files"));
}
#endif
print_opt("-D", "--boldtext",
N_("Use bold instead of reverse video text"));
print_opt("-D", "--boldtext", N_("Use bold instead of reverse video text"));
#ifndef NANO_TINY
print_opt("-E", "--tabstospaces",
N_("Convert typed tabs to spaces"));
print_opt("-E", "--tabstospaces", N_("Convert typed tabs to spaces"));
#endif
#ifndef DISABLE_MULTIBUFFER
print_opt("-F", "--multibuffer", N_("Enable multiple file buffers"));
if (!ISSET(RESTRICTED))
print_opt("-F", "--multibuffer",
N_("Read a file into a new buffer by default"));
#endif
#ifndef NANO_TINY
print_opt("-G", "--locking",
N_("Use (vim-style) lock files"));
print_opt("-G", "--locking", N_("Use (vim-style) lock files"));
#endif
#ifndef DISABLE_HISTORIES
print_opt("-H", "--historylog",
N_("Log & read search/replace string history"));
if (!ISSET(RESTRICTED))
print_opt("-H", "--historylog",
N_("Log & read search/replace string history"));
#endif
#ifndef DISABLE_NANORC
print_opt("-I", "--ignorercfiles",
N_("Don't look at nanorc files"));
if (!ISSET(RESTRICTED))
print_opt("-I", "--ignorercfiles", N_("Don't look at nanorc files"));
#endif
print_opt("-K", "--rebindkeypad",
N_("Fix numeric keypad key confusion problem"));
@@ -882,44 +876,42 @@ void usage(void)
#endif
print_opt("-O", "--morespace", N_("Use one more line for editing"));
#ifndef DISABLE_HISTORIES
print_opt("-P", "--poslog",
N_("Log & read location of cursor position"));
if (!ISSET(RESTRICTED))
print_opt("-P", "--positionlog",
N_("Log & read location of cursor position"));
#endif
#ifndef DISABLE_JUSTIFY
print_opt(_("-Q <str>"), _("--quotestr=<str>"),
N_("Quoting string"));
print_opt(_("-Q <str>"), _("--quotestr=<str>"), N_("Quoting string"));
#endif
print_opt("-R", "--restricted", N_("Restricted mode"));
if (!ISSET(RESTRICTED))
print_opt("-R", "--restricted", N_("Restricted mode"));
#ifndef NANO_TINY
print_opt("-S", "--smooth",
N_("Scroll by line instead of half-screen"));
print_opt("-S", "--smooth", N_("Scroll by line instead of half-screen"));
#endif
print_opt(_("-T <#cols>"), _("--tabsize=<#cols>"),
N_("Set width of a tab to #cols columns"));
#ifndef NANO_TINY
print_opt("-U", "--quickblank", N_("Do quick statusbar blanking"));
#endif
print_opt("-V", "--version",
N_("Print version information and exit"));
print_opt("-V", "--version", N_("Print version information and exit"));
#ifndef NANO_TINY
print_opt("-W", "--wordbounds",
N_("Detect word boundaries more accurately"));
#endif
#ifndef DISABLE_COLOR
print_opt(_("-Y <str>"), _("--syntax=<str>"),
N_("Syntax definition to use for coloring"));
if (!ISSET(RESTRICTED))
print_opt(_("-Y <str>"), _("--syntax=<str>"),
N_("Syntax definition to use for coloring"));
#endif
print_opt("-c", "--const", N_("Constantly show cursor position"));
print_opt("-c", "--constantshow", N_("Constantly show cursor position"));
print_opt("-d", "--rebinddelete",
N_("Fix Backspace/Delete confusion problem"));
print_opt("-h", "--help", N_("Show this help text"));
print_opt("-h", "--help", N_("Show this help text and exit"));
#ifndef NANO_TINY
print_opt("-i", "--autoindent",
N_("Automatically indent new lines"));
print_opt("-i", "--autoindent", N_("Automatically indent new lines"));
print_opt("-k", "--cut", N_("Cut from cursor to end of line"));
#endif
print_opt("-l", "--nofollow",
N_("Don't follow symbolic links, overwrite"));
print_opt("-l", "--nofollow", N_("Don't follow symbolic links, overwrite"));
#ifndef DISABLE_MOUSE
print_opt("-m", "--mouse", N_("Enable the use of the mouse"));
#endif
@@ -928,28 +920,32 @@ void usage(void)
print_opt(_("-o <dir>"), _("--operatingdir=<dir>"),
N_("Set operating directory"));
#endif
print_opt("-p", "--preserve",
N_("Preserve XON (^Q) and XOFF (^S) keys"));
print_opt("-p", "--preserve", N_("Preserve XON (^Q) and XOFF (^S) keys"));
#ifndef DISABLE_NANORC
print_opt("-q", "--quiet",
N_("Silently ignore startup issues like rc file errors"));
if (!ISSET(RESTRICTED))
print_opt("-q", "--quiet",
N_("Silently ignore startup issues like rc file errors"));
#endif
#ifndef DISABLE_WRAPJUSTIFY
print_opt(_("-r <#cols>"), _("--fill=<#cols>"),
N_("Set hard-wrapping point at column #cols"));
#endif
#ifndef DISABLE_SPELLER
print_opt(_("-s <prog>"), _("--speller=<prog>"),
N_("Enable alternate speller"));
if (!ISSET(RESTRICTED))
print_opt(_("-s <prog>"), _("--speller=<prog>"),
N_("Enable alternate speller"));
#endif
print_opt("-t", "--tempfile", N_("Auto save on exit, don't prompt"));
#ifndef NANO_TINY
print_opt("-u", "--unix", N_("Save a file by default in Unix format"));
#endif
print_opt("-t", "--tempfile",
N_("Auto save on exit, don't prompt"));
print_opt("-v", "--view", N_("View mode (read-only)"));
#ifndef DISABLE_WRAPPING
print_opt("-w", "--nowrap", N_("Don't hard-wrap long lines"));
#endif
print_opt("-x", "--nohelp", N_("Don't show the two help lines"));
print_opt("-z", "--suspend", N_("Enable suspension"));
if (!ISSET(RESTRICTED))
print_opt("-z", "--suspend", N_("Enable suspension"));
#ifndef NANO_TINY
print_opt("-$", "--softwrap", N_("Enable soft line wrapping"));
#endif
@@ -1090,10 +1086,22 @@ int no_help(void)
return ISSET(NO_HELP) ? 2 : 0;
}
/* Indicate a disabled function on the statusbar. */
void nano_disabled_msg(void)
/* Indicate that the current file has no name, in a way that gets the
* user's attention. This is used when trying to save a file with no
* name with the TEMP_FILE flag set, just before the filename prompt. */
void no_current_file_name_warning(void)
{
statusbar(_("Sorry, support for this function has been disabled"));
curs_set(0);
/* Warn that the current file has no name. */
statusbar(_("No file name"));
beep();
/* Ensure that we see the warning. */
doupdate();
napms(1800);
curs_set(1);
}
/* If the current file buffer has been modified, and the TEMP_FILE flag
@@ -1117,20 +1125,9 @@ void do_exit(void)
/* Otherwise, ask the user whether or not to save. */
else {
/* If the TEMP_FILE flag is set, and the current file doesn't
* have a name, handle it the same way Pico does. */
if (ISSET(TEMP_FILE)) {
curs_set(0);
/* Warn that the current file has no name. */
statusbar(_("No file name"));
beep();
/* Ensure that we see the warning. */
doupdate();
napms(2000);
curs_set(1);
}
* have a name, warn the user before prompting for a name. */
if (ISSET(TEMP_FILE))
no_current_file_name_warning();
i = do_yesno_prompt(FALSE,
_("Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? "));
@@ -1145,8 +1142,8 @@ void do_exit(void)
if (i == 0 || (i == 1 && do_writeout(TRUE))) {
#ifndef NANO_TINY
if (ISSET(LOCKING) && openfile->lock_filename)
delete_lockfile(openfile->lock_filename);
if (ISSET(LOCKING) && openfile->lock_filename)
delete_lockfile(openfile->lock_filename);
#endif
#ifndef DISABLE_MULTIBUFFER
@@ -1167,9 +1164,12 @@ void do_cancel(void)
;
}
static struct sigaction pager_oldaction, pager_newaction; /* Original and temporary handlers for SIGINT. */
static bool pager_sig_failed = FALSE; /* Did sigaction() fail without changing the signal handlers? */
static bool pager_input_aborted = FALSE; /* Did someone invoke the pager and abort it via ^C? */
static struct sigaction pager_oldaction, pager_newaction;
/* Original and temporary handlers for SIGINT. */
static bool pager_sig_failed = FALSE;
/* Did sigaction() fail without changing the signal handlers? */
static bool pager_input_aborted = FALSE;
/* Did someone invoke the pager and abort it via ^C? */
/* Things which need to be run regardless of whether
* we finished the stdin pipe correctly or not. */
@@ -1237,8 +1237,7 @@ void stdin_pager(void)
/* Initialize the signal handlers. */
void signal_init(void)
{
/* Trap SIGINT and SIGQUIT because we want them to do useful
* things. */
/* Trap SIGINT and SIGQUIT because we want them to do useful things. */
memset(&act, 0, sizeof(struct sigaction));
act.sa_handler = SIG_IGN;
sigaction(SIGINT, &act, NULL);
@@ -1253,7 +1252,6 @@ void signal_init(void)
/* Trap SIGWINCH because we want to handle window resizes. */
act.sa_handler = handle_sigwinch;
sigaction(SIGWINCH, &act, NULL);
allow_pending_sigwinch(FALSE);
#endif
/* Trap normal suspend (^Z) so we can handle it ourselves. */
@@ -1282,12 +1280,6 @@ RETSIGTYPE handle_hupterm(int signal)
/* Handler for SIGTSTP (suspend). */
RETSIGTYPE do_suspend(int signal)
{
if (ISSET(RESTRICTED)) {
nano_disabled_msg();
return;
}
#ifndef DISABLE_MOUSE
/* Turn mouse support off. */
disable_mouse_support();
@@ -1314,11 +1306,15 @@ RETSIGTYPE do_suspend(int signal)
kill(0, SIGSTOP);
}
/* the subnfunc version */
/* The version of above function that is bound to a key. */
void do_suspend_void(void)
{
if (ISSET(SUSPEND))
do_suspend(0);
else {
statusbar(_("Suspension is not enabled"));
beep();
}
}
/* Handler for SIGCONT (continue after suspend). */
@@ -1352,6 +1348,13 @@ RETSIGTYPE do_continue(int signal)
#ifndef NANO_TINY
/* Handler for SIGWINCH (window size change). */
RETSIGTYPE handle_sigwinch(int signal)
{
/* Let the input routine know that a SIGWINCH has occurred. */
sigwinch_counter++;
}
/* Reinitialize and redraw the screen completely. */
void regenerate_screen(void)
{
const char *tty = ttyname(0);
int fd, result = 0;
@@ -1376,10 +1379,6 @@ RETSIGTYPE handle_sigwinch(int signal)
LINES = win.ws_row;
#endif
/* If we've partitioned the filestruct, unpartition it now. */
if (filepart != NULL)
unpartition_filestruct(&filepart);
#ifdef USE_SLANG
/* Slang curses emulation brain damage, part 1: If we just do what
* curses does here, it'll only work properly if the resize made the
@@ -1406,22 +1405,16 @@ RETSIGTYPE handle_sigwinch(int signal)
window_init();
/* Redraw the contents of the windows that need it. */
blank_statusbar();
wnoutrefresh(bottomwin);
currmenu = MMAIN;
total_refresh();
/* Jump back to either main() or the unjustify routine in
* do_justify(). */
siglongjmp(jump_buf, 1);
}
/* If allow is TRUE, block any SIGWINCH signals that we get, so that we
* can deal with them later. If allow is FALSE, unblock any SIGWINCH
/* If allow is FALSE, block any SIGWINCH signals that we get, so that
* we can deal with them later. If allow is TRUE, unblock any SIGWINCH
* signals that we have, so that we can deal with them now. */
void allow_pending_sigwinch(bool allow)
{
sigset_t winch;
sigemptyset(&winch);
sigaddset(&winch, SIGWINCH);
sigprocmask(allow ? SIG_UNBLOCK : SIG_BLOCK, &winch, NULL);
@@ -1433,7 +1426,12 @@ void allow_pending_sigwinch(bool allow)
void do_toggle(int flag)
{
bool enabled;
const char *desc;
if (ISSET(RESTRICTED) && (flag == SUSPEND || flag == MULTIBUFFER ||
flag == BACKUP_FILE || flag == NO_COLOR_SYNTAX)) {
show_restricted_warning();
return;
}
TOGGLE(flag);
@@ -1451,12 +1449,10 @@ void do_toggle(int flag)
case SUSPEND:
signal_init();
break;
#ifndef DISABLE_NANORC
case WHITESPACE_DISPLAY:
titlebar(NULL);
edit_refresh();
break;
#endif
#ifndef DISABLE_COLOR
case NO_COLOR_SYNTAX:
#endif
@@ -1477,8 +1473,7 @@ void do_toggle(int flag)
)
enabled = !enabled;
desc = (char *) _(flagtostr(flag));
statusbar("%s %s", desc, enabled ? _("enabled") : _("disabled"));
statusbar("%s %s", _(flagtostr(flag)), enabled ? _("enabled") : _("disabled"));
}
#endif /* !NANO_TINY */
@@ -1608,6 +1603,11 @@ int do_input(bool allow_funcs)
/* Read in a character. */
input = get_kbinput(edit);
#ifndef NANO_TINY
if (input == KEY_WINCH)
return KEY_WINCH;
#endif
#ifndef DISABLE_MOUSE
if (func_key && input == KEY_MOUSE) {
/* We received a mouse click. */
@@ -1804,7 +1804,7 @@ int do_mouse(void)
mouse_x, (unsigned long)openfile->current_x);
#endif
} else {
openfile->current_x = actual_x(openfile->current->data, mouse_x);
openfile->current_x = actual_x(openfile->current->data, mouse_x);
#ifdef DEBUG
fprintf(stderr, "do_mouse(): i <= mouse_y, mouse_x = %d, setting current_x to = %lu\n",
mouse_x, (unsigned long)openfile->current_x);
@@ -1849,8 +1849,14 @@ int do_mouse(void)
#ifndef DISABLE_COLOR
void alloc_multidata_if_needed(filestruct *fileptr)
{
if (!fileptr->multidata)
int i;
if (fileptr->multidata == NULL) {
fileptr->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short));
for (i = 0; i < openfile->syntax->nmultis; i++)
fileptr->multidata[i] = -1;
}
}
/* Precalculate the multi-line start and end regex info so we can
@@ -1909,7 +1915,7 @@ void precalc_multicolorinfo(void)
if (regexec(tmpcolor->end, &fileptr->data[startx], 1, &endmatch,
(startx == 0) ? 0 : REG_NOTBOL) == 0) {
startx += endmatch.rm_eo;
fileptr->multidata[tmpcolor->id] |= CSTARTENDHERE;
fileptr->multidata[tmpcolor->id] = CSTARTENDHERE;
#ifdef DEBUG
fprintf(stderr, "end found on this line\n");
#endif
@@ -1943,7 +1949,7 @@ void precalc_multicolorinfo(void)
#endif
/* We found it, we found it, la la la la la. Mark all
* the lines in between and the end properly. */
fileptr->multidata[tmpcolor->id] |= CENDAFTER;
fileptr->multidata[tmpcolor->id] = CENDAFTER;
#ifdef DEBUG
fprintf(stderr, "marking line %ld as CENDAFTER\n", (long)fileptr->lineno);
#endif
@@ -1955,7 +1961,7 @@ void precalc_multicolorinfo(void)
#endif
}
alloc_multidata_if_needed(endptr);
fileptr->multidata[tmpcolor->id] |= CBEGINBEFORE;
fileptr->multidata[tmpcolor->id] = CBEGINBEFORE;
#ifdef DEBUG
fprintf(stderr, "marking line %ld as CBEGINBEFORE\n", (long)fileptr->lineno);
#endif
@@ -2003,15 +2009,14 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
#endif
while (i < output_len) {
/* If allow_cntrls is TRUE, convert nulls and newlines
* properly. */
/* If allow_cntrls is TRUE, convert nulls and newlines properly. */
if (allow_cntrls) {
/* Null to newline, if needed. */
if (output[i] == '\0')
output[i] = '\n';
/* Newline to Enter, if needed. */
else if (output[i] == '\n') {
do_enter(FALSE);
do_enter();
i++;
continue;
}
@@ -2022,28 +2027,24 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
i += char_buf_len;
/* If allow_cntrls is FALSE, filter out an ASCII control
* character. */
if (!allow_cntrls && is_ascii_cntrl_char(*(output + i -
char_buf_len)))
/* If allow_cntrls is FALSE, filter out an ASCII control character. */
if (!allow_cntrls && is_ascii_cntrl_char(*(output + i - char_buf_len)))
continue;
/* If the NO_NEWLINES flag isn't set, when a character is
* added to the magicline, it means we need a new magicline. */
if (!ISSET(NO_NEWLINES) && openfile->filebot ==
openfile->current)
if (!ISSET(NO_NEWLINES) && openfile->filebot == openfile->current)
new_magicline();
/* More dangerousness fun =) */
openfile->current->data = charealloc(openfile->current->data,
current_len + (char_buf_len * 2));
current_len + (char_buf_len * 2));
assert(openfile->current_x <= current_len);
charmove(openfile->current->data + openfile->current_x +
char_buf_len, openfile->current->data +
openfile->current_x, current_len - openfile->current_x +
char_buf_len);
charmove(openfile->current->data + openfile->current_x + char_buf_len,
openfile->current->data + openfile->current_x,
current_len - openfile->current_x + char_buf_len);
strncpy(openfile->current->data + openfile->current_x, char_buf,
char_buf_len);
current_len += char_buf_len;
@@ -2054,9 +2055,8 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
add_undo(ADD);
/* Note that current_x has not yet been incremented. */
if (openfile->mark_set && openfile->current ==
openfile->mark_begin && openfile->current_x <
openfile->mark_begin_x)
if (openfile->mark_set && openfile->current == openfile->mark_begin &&
openfile->current_x < openfile->mark_begin_x)
openfile->mark_begin_x += char_buf_len;
#endif
@@ -2072,14 +2072,15 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
if (do_wrap(openfile->current))
edit_refresh_needed = TRUE;
#endif
}
#ifndef DISABLE_COLOR
/* If color syntaxes are available and turned on, we need to
* call edit_refresh(). */
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX))
edit_refresh_needed = TRUE;
/* If syntax highlighting is turned on and there are multiline regexes,
* the edit window will need to be refreshed. */
if (!ISSET(NO_COLOR_SYNTAX) && openfile->syntax &&
openfile->syntax->nmultis > 0)
edit_refresh_needed = TRUE;
#endif
}
#ifndef NANO_TINY
/* Well, we might also need a full refresh if we've changed the
@@ -2110,7 +2111,9 @@ int main(int argc, char **argv)
/* Target line and column when specified on the command line. */
#ifndef DISABLE_WRAPJUSTIFY
bool fill_used = FALSE;
/* Was the fill option used? */
/* Was the fill option used on the command line? */
bool forced_wrapping = FALSE;
/* Should long lines be automatically hard wrapped? */
#endif
#ifndef DISABLE_MULTIBUFFER
bool old_multibuffer;
@@ -2119,7 +2122,6 @@ int main(int argc, char **argv)
#endif
#ifdef HAVE_GETOPT_LONG
const struct option long_options[] = {
{"help", 0, NULL, 'h'},
{"boldtext", 0, NULL, 'D'},
#ifndef DISABLE_MULTIBUFFER
{"multibuffer", 0, NULL, 'F'},
@@ -2139,8 +2141,9 @@ int main(int argc, char **argv)
#ifndef DISABLE_COLOR
{"syntax", 1, NULL, 'Y'},
#endif
{"const", 0, NULL, 'c'},
{"constantshow", 0, NULL, 'c'},
{"rebinddelete", 0, NULL, 'd'},
{"help", 0, NULL, 'h'},
{"nofollow", 0, NULL, 'l'},
#ifndef DISABLE_MOUSE
{"mouse", 0, NULL, 'm'},
@@ -2172,13 +2175,14 @@ int main(int argc, char **argv)
{"locking", 0, NULL, 'G'},
{"historylog", 0, NULL, 'H'},
{"noconvert", 0, NULL, 'N'},
{"poslog", 0, NULL, 'P'},
{"poslog", 0, NULL, 'P'}, /* deprecated form, remove in 2018 */
{"positionlog", 0, NULL, 'P'},
{"smooth", 0, NULL, 'S'},
{"quickblank", 0, NULL, 'U'},
{"undo", 0, NULL, 'u'},
{"wordbounds", 0, NULL, 'W'},
{"autoindent", 0, NULL, 'i'},
{"cut", 0, NULL, 'k'},
{"unix", 0, NULL, 'u'},
{"softwrap", 0, NULL, '$'},
#endif
{NULL, 0, NULL, 0}
@@ -2218,11 +2222,11 @@ int main(int argc, char **argv)
while ((optchr =
#ifdef HAVE_GETOPT_LONG
getopt_long(argc, argv,
"ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tvwxz$",
"ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tuvwxz$",
long_options, NULL)
#else
getopt(argc, argv,
"ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tvwxz$")
"ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tuvwxz$")
#endif
) != -1) {
switch (optchr) {
@@ -2376,6 +2380,7 @@ int main(int argc, char **argv)
exit(1);
}
fill_used = TRUE;
forced_wrapping = TRUE;
break;
#endif
#ifndef DISABLE_SPELLER
@@ -2386,6 +2391,11 @@ int main(int argc, char **argv)
case 't':
SET(TEMP_FILE);
break;
#ifndef NANO_TINY
case 'u':
SET(MAKE_IT_UNIX);
break;
#endif
case 'v':
SET(VIEW_MODE);
break;
@@ -2394,7 +2404,7 @@ int main(int argc, char **argv)
SET(NO_WRAP);
/* If both --fill and --nowrap are given on the
* command line, the last given option wins. */
fill_used = FALSE;
forced_wrapping = FALSE;
break;
#endif
case 'x':
@@ -2481,8 +2491,8 @@ int main(int argc, char **argv)
do_rcfile();
#ifdef DEBUG
fprintf(stderr, "After rebinding keys...\n");
print_sclist();
fprintf(stderr, "After rebinding keys...\n");
print_sclist();
#endif
#ifndef DISABLE_OPERATINGDIR
@@ -2528,9 +2538,9 @@ int main(int argc, char **argv)
#endif /* !DISABLE_NANORC */
#ifndef DISABLE_WRAPPING
/* Overwrite an rcfile "set nowrap" or --disable-wrapping-as-root
* if a --fill option was given on the command line. */
if (fill_used)
/* Override a "set nowrap" in an rcfile (or a --disable-wrapping-as-root)
* if --fill was given on the command line and not undone by --nowrap. */
if (forced_wrapping)
UNSET(NO_WRAP);
#endif
@@ -2626,7 +2636,6 @@ int main(int argc, char **argv)
if (matchbrackets == NULL)
matchbrackets = mallocstrcpy(NULL, "(<[{)>]}");
#ifndef DISABLE_NANORC
/* If whitespace wasn't specified, set its default value. If we're
* using UTF-8, it's Unicode 00BB (Right-Pointing Double Angle
* Quotation Mark) and Unicode 00B7 (Middle Dot). Otherwise, it's
@@ -2645,9 +2654,12 @@ int main(int argc, char **argv)
whitespace_len[1] = 1;
}
}
#endif /* !DISABLE_NANORC */
#endif /* !NANO_TINY */
/* Initialize the search and replace strings. */
last_search = mallocstrcpy(NULL, "");
last_replace = mallocstrcpy(NULL, "");
/* If tabsize wasn't specified, set its default value. */
if (tabsize == -1)
tabsize = WIDTH_OF_TAB;
@@ -2694,6 +2706,14 @@ int main(int argc, char **argv)
interface_color_pair[FUNCTION_TAG].bright = FALSE;
#endif
#if !defined(NANO_TINY) && defined(HAVE_KEY_DEFINED)
/* Ask ncurses for the key codes for Control+Left and Control+Right. */
if ((int)tigetstr("kLFT5") > 0)
controlleft = key_defined(tigetstr("kLFT5"));
if ((int)tigetstr("kRIT5") > 0)
controlright = key_defined(tigetstr("kRIT5"));
#endif
#ifdef DEBUG
fprintf(stderr, "Main: open file\n");
#endif
@@ -2723,28 +2743,26 @@ int main(int argc, char **argv)
ssize_t iline = 0, icol = 0;
for (; i < argc; i++) {
/* If there's a +LINE or +LINE,COLUMN flag here, it is
* followed by at least one other argument, the filename it
* applies to. */
if (i < argc - 1 && argv[i][0] == '+' && iline == 1 &&
icol == 1)
/* If there's a +LINE or +LINE,COLUMN flag here, it is followed
* by at least one other argument: the filename it applies to. */
if (i < argc - 1 && argv[i][0] == '+')
parse_line_column(&argv[i][1], &iline, &icol);
else {
open_buffer(argv[i], FALSE);
/* If a position was given on the command line, go there. */
if (iline > 0 || icol > 0) {
do_gotolinecolumn(iline, icol, FALSE, FALSE, FALSE,
FALSE);
iline = 1;
icol = 1;
do_gotolinecolumn(iline, icol, FALSE, FALSE, FALSE, FALSE);
iline = 0;
icol = 0;
}
#ifndef DISABLE_HISTORIES
else {
/* See if we have a POS history to use if we haven't overridden it. */
else {
ssize_t savedposline, savedposcol;
/* If edited before, restore the last cursor position. */
if (check_poshistory(argv[i], &savedposline, &savedposcol))
do_gotolinecolumn(savedposline, savedposcol, FALSE, FALSE, FALSE,
FALSE);
do_gotolinecolumn(savedposline, savedposcol, FALSE,
FALSE, FALSE, FALSE);
}
#endif
}
@@ -2752,16 +2770,13 @@ int main(int argc, char **argv)
}
#endif /* !DISABLE_MULTIBUFFER */
/* Read the first file on the command line into either the current
* buffer or a new buffer, depending on whether multibuffer mode is
* enabled. */
/* Now read the first file on the command line into a new buffer. */
if (optind < argc)
open_buffer(argv[optind], FALSE);
/* We didn't open any files if all the command line arguments were
* invalid files like directories or if there were no command line
* arguments given. In this case, we have to load a blank buffer.
* Also, we unset view mode to allow editing. */
/* If all the command-line arguments were invalid files like directories,
* or if there were no filenames given, we didn't open any file. In this
* case, load a blank buffer. Also, unset view mode to allow editing. */
if (openfile == NULL) {
open_buffer("", FALSE);
UNSET(VIEW_MODE);
@@ -2782,13 +2797,13 @@ int main(int argc, char **argv)
precalc_multicolorinfo();
#endif
/* If a starting position was given on the command line, go there. */
if (startline > 0 || startcol > 0)
do_gotolinecolumn(startline, startcol, FALSE, FALSE, FALSE,
FALSE);
do_gotolinecolumn(startline, startcol, FALSE, FALSE, FALSE, FALSE);
#ifndef DISABLE_HISTORIES
else {
/* See if we have a POS history to use if we haven't overridden it. */
ssize_t savedposline, savedposcol;
/* If the file was edited before, restore the last cursor position. */
if (check_poshistory(argv[optind], &savedposline, &savedposcol))
do_gotolinecolumn(savedposline, savedposcol, FALSE, FALSE, FALSE, FALSE);
}
@@ -2803,17 +2818,6 @@ int main(int argc, char **argv)
reset_cursor();
wnoutrefresh(edit);
#ifndef NANO_TINY
if (!jump_buf_main) {
/* If we haven't already, we're going to set jump_buf so
* that we return here after a SIGWINCH. Indicate this. */
jump_buf_main = TRUE;
/* Return here after a SIGWINCH. */
sigsetjmp(jump_buf, 1);
}
#endif
/* Just in case we were at the statusbar prompt, make sure the
* statusbar cursor position is reset. */
do_prompt_abort();
@@ -2824,7 +2828,7 @@ int main(int argc, char **argv)
if (ISSET(CONST_UPDATE) && get_key_buffer_len() == 0)
do_cursorpos(TRUE);
currmenu = MMAIN;
currmenu = MMAIN;
/* Read in and interpret characters. */
do_input(TRUE);

View File

@@ -116,9 +116,7 @@
#ifdef HAVE_REGEX_H
#include <regex.h>
#endif
#ifndef NANO_TINY
#include <setjmp.h>
#endif
#include <signal.h>
#include <assert.h>
/* If no vsnprintf(), use the version from glib 2.x. */
@@ -194,6 +192,7 @@ typedef enum {
JOIN, PASTE, INSERT, ENTER, OTHER
} undo_type;
/* Structure types. */
typedef struct color_pair {
int pairnum;
/* The color pair number used for this foreground color and
@@ -274,7 +273,7 @@ typedef struct lintstruct {
/* Previous error. */
} lintstruct;
/* Flags that indicate how a multiline regex applies to a line. */
#define CNONE (1<<1)
/* Yay, regex doesn't apply to this line at all! */
#define CBEGINBEFORE (1<<2)
@@ -285,13 +284,9 @@ typedef struct lintstruct {
/* Whole line engulfed by the regex, start < me, end > me. */
#define CSTARTENDHERE (1<<5)
/* Regex starts and ends within this line. */
#define CWTF (1<<6)
/* Something else. */
#endif /* !DISABLE_COLOR */
/* Structure types. */
/* More structure types. */
typedef struct filestruct {
char *data;
/* The text of this line. */
@@ -334,6 +329,10 @@ typedef struct undo {
/* Where did this action begin or end. */
char *strdata;
/* String type data we will use for copying the affected line back. */
size_t wassize;
/* The file size before the action. */
size_t newsize;
/* The file size after the action. */
int xflags;
/* Some flag data we need. */
@@ -366,75 +365,57 @@ typedef struct poshiststruct {
typedef struct openfilestruct {
char *filename;
/* The current file's name. */
/* The file's name. */
filestruct *fileage;
/* The current file's first line. */
/* The file's first line. */
filestruct *filebot;
/* The current file's last line. */
/* The file's last line. */
filestruct *edittop;
/* The current top of the edit window. */
/* The current top of the edit window for this file. */
filestruct *current;
/* The current file's current line. */
/* The current line for this file. */
size_t totsize;
/* The current file's total number of characters. */
/* The file's total number of characters. */
size_t current_x;
/* The current file's x-coordinate position. */
/* The file's x-coordinate position. */
size_t placewewant;
/* The current file's x position we would like. */
/* The file's x position we would like. */
ssize_t current_y;
/* The current file's y-coordinate position. */
/* The file's y-coordinate position. */
bool modified;
/* Whether the current file has been modified. */
/* Whether the file has been modified. */
#ifndef NANO_TINY
bool mark_set;
/* Whether the mark is on in the current file. */
/* Whether the mark is on in this file. */
filestruct *mark_begin;
/* The current file's beginning marked line, if any. */
/* The file's line where the mark is, if any. */
size_t mark_begin_x;
/* The current file's beginning marked line's x-coordinate
* position, if any. */
/* The file's mark's x-coordinate position, if any. */
file_format fmt;
/* The current file's format. */
/* The file's format. */
struct stat *current_stat;
/* The current file's stat. */
/* The file's current stat information. */
undo *undotop;
/* Top of the undo list. */
/* The top of the undo list. */
undo *current_undo;
/* The current (i.e. next) level of undo. */
undo_type last_action;
const char *lock_filename;
/* The type of the last action the user performed. */
char *lock_filename;
/* The path of the lockfile, if we created one. */
#endif
#ifndef DISABLE_COLOR
syntaxtype *syntax;
/* The syntax struct for this file, if any. */
colortype *colorstrings;
/* The current file's associated colors. */
/* The file's associated colors. */
#endif
struct openfilestruct *next;
/* Next node. */
/* The next open file, if any. */
struct openfilestruct *prev;
/* Previous node. */
/* The preceding open file, if any. */
} openfilestruct;
typedef struct shortcut {
const char *desc;
/* The function's description, e.g. "Page Up". */
#ifndef DISABLE_HELP
const char *help;
/* The help file entry text for this function. */
bool blank_after;
/* Whether there should be a blank line after the help entry
* text for this function. */
#endif
bool viewok;
/* Is this function allowed when in view mode? */
void (*func)(void);
/* The function to call when we get this key. */
struct shortcut *next;
/* Next shortcut. */
} shortcut;
#ifndef DISABLE_NANORC
typedef struct rcoption {
const char *name;
@@ -450,38 +431,38 @@ typedef struct sc {
key_type type;
/* What kind of command key it is, for convenience later. */
int seq;
/* The actual sequence to check on the type is determined. */
int menu;
/* What list this applies to. */
/* The actual sequence to check once the type is determined. */
int menus;
/* Which menus this applies to. */
void (*scfunc)(void);
/* The function we're going to run. */
int toggle;
/* If a toggle, what we're toggling. */
bool execute;
/* Whether to execute the function in question or just return
* so the sequence can be caught by the calling code. */
int ordinal;
/* The how-manieth toggle this is, in order to be able to
* keep them in sequence. */
struct sc *next;
/* Next in the list. */
} sc;
typedef struct subnfunc {
void (*scfunc)(void);
/* What function this is. */
/* The actual function to call. */
int menus;
/* In what menus this function applies. */
const char *desc;
/* The function's description, e.g. "Page Up". */
/* The function's short description, for example "Where Is". */
#ifndef DISABLE_HELP
const char *help;
/* The help file entry text for this function. */
/* The help-screen text for this function. */
bool blank_after;
/* Whether there should be a blank line after the help entry
* text for this function. */
/* Whether there should be a blank line after the help text
* for this function. */
#endif
bool viewok;
/* Is this function allowed when in view mode? */
long toggle;
/* If this is a toggle, if nonzero what toggle to set. */
/* If this is a toggle, which toggle to affect. */
struct subnfunc *next;
/* Next item in the list. */
} subnfunc;
@@ -536,7 +517,8 @@ enum
SOFTWRAP,
POS_HISTORY,
LOCKING,
NOREAD_MODE
NOREAD_MODE,
MAKE_IT_UNIX
};
/* Flags for the menus in which a given function should be present. */
@@ -556,7 +538,8 @@ enum
#define MYESNO (1<<13)
#define MLINTER (1<<14)
/* 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)
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\
MEXTCMD|MBROWSER|MWHEREISFILE|MGOTODIR|MSPELL|MLINTER)
/* Control key sequences. Changing these would be very, very bad. */
#define NANO_CONTROL_SPACE 0
@@ -565,17 +548,18 @@ enum
#define NANO_CONTROL_7 31
#define NANO_CONTROL_8 127
/* Codes for "modified" Arrow keys. Chosen like this because some
* terminals produce them, and they are beyond KEY_MAX of ncurses. */
#define CONTROL_LEFT 539
#define CONTROL_RIGHT 554
/* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */
#define CONTROL_LEFT 0x401
#define CONTROL_RIGHT 0x402
#ifndef NANO_TINY
/* Extra bits for the undo function. */
#define UNdel_del (1<<0)
#define UNdel_backspace (1<<1)
#define UNcut_marked_forward (1<<2)
#define UNcut_cutline (1<<3)
/* An imaginary key for when we get a SIGWINCH (window resize). */
#define KEY_WINCH -2
/* Some extra flags for the undo function. */
#define WAS_FINAL_BACKSPACE (1<<1)
#define WAS_MARKED_FORWARD (1<<2)
#define WAS_WHOLE_LINE (1<<3)
#endif /* !NANO_TINY */
/* The maximum number of entries displayed in the main shortcut list. */

View File

@@ -66,6 +66,11 @@ int do_statusbar_input(bool *ran_func, bool *finished,
/* Read in a character. */
input = get_kbinput(bottomwin);
#ifndef NANO_TINY
if (input == KEY_WINCH)
return KEY_WINCH;
#endif
#ifndef DISABLE_MOUSE
/* If we got a mouse click and it was on a shortcut, read in the
* shortcut character. */
@@ -140,7 +145,7 @@ int do_statusbar_input(bool *ran_func, bool *finished,
}
if (have_shortcut) {
if (s->scfunc == do_tab || s->scfunc == do_enter_void)
if (s->scfunc == do_tab || s->scfunc == do_enter)
;
else if (s->scfunc == total_refresh)
total_statusbar_refresh(refresh_func);
@@ -181,7 +186,7 @@ int do_statusbar_input(bool *ran_func, bool *finished,
* set finished to TRUE to indicate that we're done. */
if (got_enter) {
get_input(NULL, 1);
input = sc_seq_or(do_enter_void, 0);
input = sc_seq_or(do_enter, 0);
*finished = TRUE;
}
}
@@ -245,7 +250,7 @@ int do_statusbar_mouse(void)
statusbar_xplustabs()) + mouse_x - start_col);
statusbar_pww = statusbar_xplustabs();
if (need_statusbar_horizontal_update(pww_save))
if (need_statusbar_update(pww_save))
update_statusbar_line(answer, statusbar_x);
}
}
@@ -347,7 +352,7 @@ void do_statusbar_home(void)
statusbar_pww = statusbar_xplustabs();
}
if (need_statusbar_horizontal_update(pww_save))
if (need_statusbar_update(pww_save))
update_statusbar_line(answer, statusbar_x);
}
@@ -359,7 +364,7 @@ void do_statusbar_end(void)
statusbar_x = strlen(answer);
statusbar_pww = statusbar_xplustabs();
if (need_statusbar_horizontal_update(pww_save))
if (need_statusbar_update(pww_save))
update_statusbar_line(answer, statusbar_x);
}
@@ -372,7 +377,7 @@ void do_statusbar_left(void)
statusbar_x = move_mbleft(answer, statusbar_x);
statusbar_pww = statusbar_xplustabs();
if (need_statusbar_horizontal_update(pww_save))
if (need_statusbar_update(pww_save))
update_statusbar_line(answer, statusbar_x);
}
}
@@ -386,7 +391,7 @@ void do_statusbar_right(void)
statusbar_x = move_mbright(answer, statusbar_x);
statusbar_pww = statusbar_xplustabs();
if (need_statusbar_horizontal_update(pww_save))
if (need_statusbar_update(pww_save))
update_statusbar_line(answer, statusbar_x);
}
}
@@ -500,7 +505,7 @@ bool do_statusbar_next_word(bool allow_punct)
statusbar_pww = statusbar_xplustabs();
if (need_statusbar_horizontal_update(pww_save))
if (need_statusbar_update(pww_save))
update_statusbar_line(answer, statusbar_x);
/* Return whether we started on a word. */
@@ -595,7 +600,7 @@ bool do_statusbar_prev_word(bool allow_punct)
statusbar_pww = statusbar_xplustabs();
if (need_statusbar_horizontal_update(pww_save))
if (need_statusbar_update(pww_save))
update_statusbar_line(answer, statusbar_x);
/* Return whether we started on a word. */
@@ -645,7 +650,7 @@ size_t statusbar_xplustabs(void)
* get_statusbar_page_start(column) < COLS). */
size_t get_statusbar_page_start(size_t start_col, size_t column)
{
if (column == start_col || column < COLS - 1)
if (column == start_col || column < COLS - 1 || COLS == start_col + 1)
return 0;
else
return column - start_col - (column - start_col) % (COLS -
@@ -698,10 +703,10 @@ void update_statusbar_line(const char *curranswer, size_t index)
wnoutrefresh(bottomwin);
}
/* Return TRUE if we need an update after moving horizontally, and FALSE
* otherwise. We need one if pww_save and statusbar_pww are on
/* Return TRUE if we need an update after moving the cursor, and FALSE
* otherwise. We need an update if pww_save and statusbar_pww are on
* different pages. */
bool need_statusbar_horizontal_update(size_t pww_save)
bool need_statusbar_update(size_t pww_save)
{
size_t start_col = strlenpt(prompt) + 2;
@@ -794,9 +799,17 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs,
kbinput = do_statusbar_input(&ran_func, &finished, refresh_func);
assert(statusbar_x <= strlen(answer));
#ifndef NANO_TINY
if (kbinput == KEY_WINCH) {
refresh_func();
update_statusbar_line(answer, statusbar_x);
continue;
}
#endif
func = func_from_key(&kbinput);
if (func == do_cancel || func == do_enter_void)
if (func == do_cancel || func == do_enter)
break;
#ifndef DISABLE_TABCOMP
@@ -905,8 +918,7 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs,
if (history_list != NULL) {
history_reset(*history_list);
if (magichistory != NULL)
free(magichistory);
free(magichistory);
}
#endif
@@ -915,7 +927,7 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs,
* we've finished putting in an answer, reset the statusbar cursor
* position too. */
if (func) {
if (func == do_cancel || func == do_enter_void || ran_func) {
if (func == do_cancel || func == do_enter || ran_func) {
statusbar_x = old_statusbar_x;
statusbar_pww = old_pww;
@@ -964,12 +976,10 @@ int do_prompt(bool allow_tabs,
/* prompt has been freed and set to NULL unless the user resized
* while at the statusbar prompt. */
if (prompt != NULL)
free(prompt);
free(prompt);
prompt = charalloc(((COLS - 4) * mb_cur_max()) + 1);
currmenu = menu;
bottombars(menu);
va_start(ap, msg);
@@ -1000,7 +1010,7 @@ int do_prompt(bool allow_tabs,
* properly. */
if (func == do_cancel)
retval = -1;
else if (func == do_enter_void)
else if (func == do_enter)
retval = (*answer == '\0') ? -2 : 0;
blank_statusbar();
@@ -1056,49 +1066,6 @@ int do_yesno_prompt(bool all, const char *msg)
nostr = _("Nn");
allstr = _("Aa");
if (!ISSET(NO_HELP)) {
char shortstr[3];
/* Temp string for Yes, No, All. */
if (COLS < 32)
width = COLS / 2;
/* Clear the shortcut list from the bottom of the screen. */
blank_bottombars();
sprintf(shortstr, " %c", yesstr[0]);
wmove(bottomwin, 1, 0);
onekey(shortstr, _("Yes"), width);
if (all) {
wmove(bottomwin, 1, width);
shortstr[1] = allstr[0];
onekey(shortstr, _("All"), width);
}
wmove(bottomwin, 2, 0);
shortstr[1] = nostr[0];
onekey(shortstr, _("No"), width);
wmove(bottomwin, 2, 16);
onekey("^C", _("Cancel"), width);
}
if (interface_color_pair[TITLE_BAR].bright)
wattron(bottomwin, A_BOLD);
wattron(bottomwin, interface_color_pair[TITLE_BAR].pairnum);
blank_statusbar();
mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));
wattroff(bottomwin, A_BOLD);
wattroff(bottomwin, interface_color_pair[TITLE_BAR].pairnum);
/* Refresh the edit window and the statusbar before getting
* input. */
wnoutrefresh(edit);
wnoutrefresh(bottomwin);
do {
int kbinput;
functionptrtype func;
@@ -1106,8 +1073,57 @@ int do_yesno_prompt(bool all, const char *msg)
int mouse_x, mouse_y;
#endif
if (!ISSET(NO_HELP)) {
char shortstr[3];
/* Temporary string for (translated) " Y", " N" and " A". */
if (COLS < 32)
width = COLS / 2;
/* Clear the shortcut list from the bottom of the screen. */
blank_bottombars();
/* Now show the ones for "Yes", "No", "Cancel" and maybe "All". */
sprintf(shortstr, " %c", yesstr[0]);
wmove(bottomwin, 1, 0);
onekey(shortstr, _("Yes"), width);
if (all) {
shortstr[1] = allstr[0];
wmove(bottomwin, 1, width);
onekey(shortstr, _("All"), width);
}
shortstr[1] = nostr[0];
wmove(bottomwin, 2, 0);
onekey(shortstr, _("No"), width);
wmove(bottomwin, 2, width);
onekey("^C", _("Cancel"), width);
}
if (interface_color_pair[TITLE_BAR].bright)
wattron(bottomwin, A_BOLD);
wattron(bottomwin, interface_color_pair[TITLE_BAR].pairnum);
blank_statusbar();
mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));
wattroff(bottomwin, A_BOLD);
wattroff(bottomwin, interface_color_pair[TITLE_BAR].pairnum);
/* Refresh edit window and statusbar before getting input. */
wnoutrefresh(edit);
wnoutrefresh(bottomwin);
currmenu = MYESNO;
kbinput = get_kbinput(bottomwin);
#ifndef NANO_TINY
if (kbinput == KEY_WINCH)
continue;
#endif
func = func_from_key(&kbinput);
if (func == do_cancel)

View File

@@ -28,12 +28,17 @@
/* All external variables. See global.c for their descriptions. */
#ifndef NANO_TINY
extern sigjmp_buf jump_buf;
extern bool jump_buf_main;
extern volatile sig_atomic_t sigwinch_counter;
#endif
extern bool meta_key;
extern bool func_key;
extern bool focusing;
#ifndef NANO_TINY
extern int controlleft;
extern int controlright;
#endif
#ifndef DISABLE_WRAPJUSTIFY
extern ssize_t fill;
@@ -62,7 +67,7 @@ extern openfilestruct *openfile;
extern char *matchbrackets;
#endif
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
#ifndef NANO_TINY
extern char *whitespace;
extern int whitespace_len[2];
#endif
@@ -148,10 +153,9 @@ char *do_browse_from(const char *inpath);
void browser_init(const char *path, DIR *dir);
functionptrtype parse_browser_input(int *kbinput);
void browser_refresh(void);
bool browser_select_filename(const char *needle);
void browser_select_dirname(const char *needle);
int filesearch_init(void);
bool findnextfile(bool no_sameline, size_t begin, const char *needle);
void findnextfile_wrap_reset(void);
void findnextfile(const char *needle);
void filesearch_abort(void);
void do_filesearch(void);
void do_fileresearch(void);
@@ -261,7 +265,7 @@ void cut_to_eof(void);
#endif
void do_cut_text(
#ifndef NANO_TINY
bool copy_text, bool cut_till_eof, bool undoing
bool copy_text, bool cut_till_eof
#else
void
#endif
@@ -275,7 +279,6 @@ void do_uncut_text(void);
/* All functions in files.c. */
void make_new_buffer(void);
void initialize_buffer(void);
void initialize_buffer_text(void);
void open_buffer(const char *filename, bool undoable);
#ifndef DISABLE_SPELLER
@@ -322,6 +325,9 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
#endif
bool do_writeout(bool exiting);
void do_writeout_void(void);
#ifndef NANO_TINY
void do_savefile(void);
#endif
char *real_dir_from_tilde(const char *buf);
#if !defined(DISABLE_TABCOMP) || !defined(DISABLE_BROWSER)
int diralphasort(const void *va, const void *vb);
@@ -372,7 +378,7 @@ void thanks_for_all_the_fish(void);
/* All functions in help.c. */
#ifndef DISABLE_HELP
void do_help(void (*refresh_func)(void));
void do_help(void);
void help_init(void);
functionptrtype parse_help_input(int *kbinput);
size_t help_line_len(const char *ptr);
@@ -393,7 +399,7 @@ void do_para_end_void(void);
#ifndef NANO_TINY
bool do_next_word(bool allow_punct, bool allow_update);
void do_next_word_void(void);
bool do_prev_word(bool allow_punct, bool allow_update);
void do_prev_word(bool allow_punct, bool allow_update);
void do_prev_word_void(void);
#endif
void do_home(void);
@@ -426,9 +432,8 @@ void do_right(void);
/* All functions in nano.c. */
filestruct *make_new_node(filestruct *prevnode);
filestruct *copy_node(const filestruct *src);
void splice_node(filestruct *begin, filestruct *newnode, filestruct
*end);
void unlink_node(const filestruct *fileptr);
void splice_node(filestruct *afterthis, filestruct *newnode);
void unlink_node(filestruct *fileptr);
void delete_node(filestruct *fileptr);
filestruct *copy_filestruct(const filestruct *src);
void free_filestruct(filestruct *src);
@@ -448,6 +453,10 @@ void delete_opennode(openfilestruct *fileptr);
void free_openfilestruct(openfilestruct *src);
#endif
void print_view_warning(void);
void show_restricted_warning(void);
#ifdef DISABLE_HELP
void say_there_is_no_help(void);
#endif
void finish(void);
void die(const char *msg, ...);
void die_save_file(const char *die_filename
@@ -470,7 +479,7 @@ void usage(void);
void version(void);
int more_space(void);
int no_help(void);
void nano_disabled_msg(void);
void no_current_file_name_warning(void);
void do_exit(void);
void signal_init(void);
RETSIGTYPE handle_hupterm(int signal);
@@ -478,6 +487,7 @@ RETSIGTYPE do_suspend(int signal);
RETSIGTYPE do_continue(int signal);
#ifndef NANO_TINY
RETSIGTYPE handle_sigwinch(int signal);
void regenerate_screen(void);
void allow_pending_sigwinch(bool allow);
void do_toggle(int flag);
#endif
@@ -522,7 +532,7 @@ size_t statusbar_xplustabs(void);
size_t get_statusbar_page_start(size_t start_col, size_t column);
void reset_statusbar_cursor(void);
void update_statusbar_line(const char *curranswer, size_t index);
bool need_statusbar_horizontal_update(size_t pww_save);
bool need_statusbar_update(size_t pww_save);
void total_statusbar_refresh(void (*refresh_func)(void));
functionptrtype get_prompt_string(int *value, bool allow_tabs,
#ifndef DISABLE_TABCOMP
@@ -579,16 +589,19 @@ void regexp_cleanup(void);
#endif
void not_found_msg(const char *str);
void search_replace_abort(void);
void search_init_globals(void);
int search_init(bool replacing, bool use_answer);
bool findnextstr(
#ifndef DISABLE_SPELLER
bool whole_word,
bool whole_word_only,
#endif
bool no_sameline, const filestruct *begin, size_t begin_x, const
char *needle, size_t *needle_len);
const filestruct *begin, size_t begin_x,
const char *needle, size_t *needle_len);
void findnextstr_wrap_reset(void);
void do_search(void);
#ifndef NANO_TINY
void do_findprevious(void);
void do_findnext(void);
#endif
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
void do_research(void);
#endif
@@ -598,7 +611,7 @@ int replace_regexp(char *string, bool create);
char *replace_line(const char *needle);
ssize_t do_replace_loop(
#ifndef DISABLE_SPELLER
bool whole_word,
bool whole_word_only,
#endif
bool *canceled, const filestruct *real_current, size_t
*real_current_x, const char *needle);
@@ -637,6 +650,10 @@ void do_mark(void);
#endif
void do_delete(void);
void do_backspace(void);
#ifndef NANO_TINY
void do_cut_prev_word(void);
void do_cut_next_word(void);
#endif
void do_tab(void);
#ifndef NANO_TINY
void do_indent(ssize_t cols);
@@ -645,8 +662,7 @@ void do_unindent(void);
void do_undo(void);
void do_redo(void);
#endif
void do_enter(bool undoing);
void do_enter_void(void);
void do_enter(void);
#ifndef NANO_TINY
RETSIGTYPE cancel_command(int signal);
bool execute_command(const char *command);
@@ -696,7 +712,6 @@ void do_wordlinechar_count(void);
void do_verbatim_input(void);
/* All functions in utils.c. */
int digits(size_t n);
void get_homedir(void);
bool parse_num(const char *str, ssize_t *val);
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column);
@@ -713,7 +728,6 @@ ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream);
#endif
#endif
#ifdef HAVE_REGEX_H
bool regexp_bol_or_eol(const regex_t *preg, const char *string);
const char *fixbounds(const char *r);
#endif
#ifndef DISABLE_SPELLER
@@ -737,7 +751,8 @@ void new_magicline(void);
void remove_magicline(void);
void mark_order(const filestruct **top, size_t *top_x, const filestruct
**bot, size_t *bot_x, bool *right_side_up);
void add_undo(undo_type current_action);
void discard_until(undo *thisone);
void add_undo(undo_type action);
void update_undo(undo_type action);
#endif
size_t get_totsize(const filestruct *begin, const filestruct *end);
@@ -789,8 +804,7 @@ void reset_cursor(void);
void edit_draw(filestruct *fileptr, const char *converted, int
line, size_t start);
int update_line(filestruct *fileptr, size_t index);
bool need_horizontal_update(size_t pww_save);
bool need_vertical_update(size_t pww_save);
bool need_screen_update(size_t pww_save);
void edit_scroll(scroll_dir direction, ssize_t nlines);
void edit_redraw(filestruct *old_current, size_t pww_save);
void edit_refresh(void);

View File

@@ -38,20 +38,21 @@ static const rcoption rcopts[] = {
#ifndef DISABLE_JUSTIFY
{"brackets", 0},
#endif
{"const", CONST_UPDATE},
{"const", CONST_UPDATE}, /* deprecated form, remove in 2018 */
{"constantshow", CONST_UPDATE},
#ifndef DISABLE_WRAPJUSTIFY
{"fill", 0},
#endif
#ifndef NANO_TINY
{"locking", LOCKING},
#ifndef DISABLE_HISTORIES
{"historylog", HISTORYLOG},
#endif
{"morespace", MORE_SPACE},
#ifndef DISABLE_MOUSE
{"mouse", USE_MOUSE},
#endif
#ifndef DISABLE_MULTIBUFFER
{"multibuffer", MULTIBUFFER},
#endif
{"morespace", MORE_SPACE},
{"nofollow", NOFOLLOW_SYMLINKS},
{"nohelp", NO_HELP},
{"nonewlines", NO_NEWLINES},
@@ -60,6 +61,10 @@ static const rcoption rcopts[] = {
#endif
#ifndef DISABLE_OPERATINGDIR
{"operatingdir", 0},
#endif
#ifndef DISABLE_HISTORIES
{"poslog", POS_HISTORY}, /* deprecated form, remove in 2018 */
{"positionlog", POS_HISTORY},
#endif
{"preserve", PRESERVE},
#ifndef DISABLE_JUSTIFY
@@ -79,25 +84,25 @@ static const rcoption rcopts[] = {
{"tempfile", TEMP_FILE},
{"view", VIEW_MODE},
#ifndef NANO_TINY
{"allow_insecure_backup", INSECURE_BACKUP},
{"autoindent", AUTOINDENT},
{"backup", BACKUP_FILE},
{"allow_insecure_backup", INSECURE_BACKUP},
{"backupdir", 0},
{"backwards", BACKWARDS_SEARCH},
{"casesensitive", CASE_SENSITIVE},
{"cut", CUT_TO_END},
{"historylog", HISTORYLOG},
{"locking", LOCKING},
{"matchbrackets", 0},
{"noconvert", NO_CONVERT},
{"poslog", POS_HISTORY},
{"quiet", QUIET},
{"quickblank", QUICK_BLANK},
{"quiet", QUIET},
{"smarthome", SMART_HOME},
{"smooth", SMOOTH_SCROLL},
{"softwrap", SOFTWRAP},
{"tabstospaces", TABS_TO_SPACES},
{"unix", MAKE_IT_UNIX},
{"whitespace", 0},
{"wordbounds", WORD_BOUNDS},
{"softwrap", SOFTWRAP},
#endif
#ifndef DISABLE_COLOR
{"titlecolor", 0},
@@ -440,7 +445,7 @@ void parse_binding(char *ptr, bool dobind)
if (strlen(keycopy) < 2) {
rcfile_error(N_("Key name is too short"));
return;
goto free_copy;
}
/* Uppercase only the first two or three characters of the key name. */
@@ -451,7 +456,7 @@ void parse_binding(char *ptr, bool dobind)
keycopy[2] = toupper(keycopy[2]);
else {
rcfile_error(N_("Key name is too short"));
return;
goto free_copy;
}
}
@@ -461,7 +466,7 @@ void parse_binding(char *ptr, bool dobind)
keycopy[1] = tolower(keycopy[1]);
else if (keycopy[0] != '^' && keycopy[0] != 'M' && keycopy[0] != 'F') {
rcfile_error(N_("Key name must begin with \"^\", \"M\", or \"F\""));
return;
goto free_copy;
}
if (dobind) {
@@ -470,7 +475,7 @@ void parse_binding(char *ptr, bool dobind)
if (funcptr[0] == '\0') {
rcfile_error(N_("Must specify a function to bind the key to"));
return;
goto free_copy;
}
}
@@ -480,21 +485,21 @@ void parse_binding(char *ptr, bool dobind)
if (menuptr[0] == '\0') {
/* TRANSLATORS: Do not translate the word "all". */
rcfile_error(N_("Must specify a menu (or \"all\") in which to bind/unbind the key"));
return;
goto free_copy;
}
if (dobind) {
newsc = strtosc(funcptr);
if (newsc == NULL) {
rcfile_error(N_("Cannot map name \"%s\" to a function"), funcptr);
return;
goto free_copy;
}
}
menu = strtomenu(menuptr);
if (menu < 1) {
rcfile_error(N_("Cannot map name \"%s\" to a menu"), menuptr);
return;
goto free_copy;
}
#ifdef DEBUG
@@ -527,11 +532,11 @@ void parse_binding(char *ptr, bool dobind)
if (!menu) {
rcfile_error(N_("Function '%s' does not exist in menu '%s'"), funcptr, menuptr);
free(newsc);
return;
goto free_copy;
}
newsc->keystr = keycopy;
newsc->menu = menu;
newsc->menus = menu;
newsc->type = strtokeytype(newsc->keystr);
assign_keyinfo(newsc);
#ifdef DEBUG
@@ -542,25 +547,36 @@ void parse_binding(char *ptr, bool dobind)
if (check_bad_binding(newsc)) {
rcfile_error(N_("Sorry, keystroke \"%s\" may not be rebound"), newsc->keystr);
free(newsc);
return;
goto free_copy;
}
}
/* Now find and delete any existing same shortcut in the menu(s). */
for (s = sclist; s != NULL; s = s->next) {
if (((s->menu & menu)) && !strcmp(s->keystr, keycopy)) {
if ((s->menus & menu) && !strcmp(s->keystr, keycopy)) {
#ifdef DEBUG
fprintf(stderr, "deleting entry from menu %x\n", s->menu);
fprintf(stderr, "deleting entry from among menus %x\n", s->menus);
#endif
s->menu &= ~menu;
s->menus &= ~menu;
}
}
if (dobind) {
/* If this is a toggle, copy its sequence number. */
if (newsc->scfunc == do_toggle_void) {
for (s = sclist; s != NULL; s = s->next)
if (s->scfunc == do_toggle_void && s->toggle == newsc->toggle)
newsc->ordinal = s->ordinal;
} else
newsc->ordinal = 0;
/* Add the new shortcut at the start of the list. */
newsc->next = sclist;
sclist = newsc;
return;
}
free_copy:
free(keycopy);
}
@@ -601,11 +617,7 @@ static void _parse_include(char *file)
fprintf(stderr, "Parsing file \"%s\"\n", file);
#endif
parse_rcfile(rcstream
#ifndef DISABLE_COLOR
, TRUE
#endif
);
parse_rcfile(rcstream, TRUE);
}
void parse_include(char *ptr)
@@ -907,11 +919,10 @@ void parse_header_exp(char *ptr)
}
}
#ifndef DISABLE_COLOR
#ifdef HAVE_LIBMAGIC
/* Parse the magic regexes that may influence the choice of syntax. */
void parse_magic_exp(char *ptr)
{
#ifdef HAVE_LIBMAGIC
regexlisttype *endmagic = NULL;
assert(ptr != NULL);
@@ -971,11 +982,10 @@ void parse_magic_exp(char *ptr)
} else
free(newmagic);
}
#endif /* HAVE_LIBMAGIC */
}
#endif /* !DISABLE_COLOR */
#endif /* HAVE_LIBMAGIC */
/* Parse the linter requested for this syntax. Simple? */
/* Parse the linter requested for this syntax. */
void parse_linter(char *ptr)
{
assert(ptr != NULL);
@@ -991,16 +1001,17 @@ void parse_linter(char *ptr)
return;
}
if (endsyntax->linter != NULL)
free(endsyntax->linter);
free(endsyntax->linter);
/* Let them unset the linter by using "". */
if (!strcmp(ptr, "\"\""))
endsyntax->linter = NULL;
else
endsyntax->linter = mallocstrcpy(syntaxes->linter, ptr);
endsyntax->linter = mallocstrcpy(NULL, ptr);
}
#ifndef DISABLE_SPELLER
/* Parse the formatter requested for this syntax. */
void parse_formatter(char *ptr)
{
assert(ptr != NULL);
@@ -1016,15 +1027,15 @@ void parse_formatter(char *ptr)
return;
}
if (endsyntax->formatter != NULL)
free(endsyntax->formatter);
free(endsyntax->formatter);
/* Let them unset the formatter by using "". */
if (!strcmp(ptr, "\"\""))
endsyntax->formatter = NULL;
else
endsyntax->formatter = mallocstrcpy(syntaxes->formatter, ptr);
endsyntax->formatter = mallocstrcpy(NULL, ptr);
}
#endif /* !DISABLE_SPELLER */
#endif /* !DISABLE_COLOR */
/* Check whether the user has unmapped every shortcut for a
@@ -1151,7 +1162,11 @@ void parse_rcfile(FILE *rcstream
parse_syntax(ptr);
}
else if (strcasecmp(keyword, "magic") == 0)
#ifdef HAVE_LIBMAGIC
parse_magic_exp(ptr);
#else
;
#endif
else if (strcasecmp(keyword, "header") == 0)
parse_header_exp(ptr);
else if (strcasecmp(keyword, "color") == 0)
@@ -1161,7 +1176,11 @@ void parse_rcfile(FILE *rcstream
else if (strcasecmp(keyword, "linter") == 0)
parse_linter(ptr);
else if (strcasecmp(keyword, "formatter") == 0)
#ifndef DISABLE_SPELLER
parse_formatter(ptr);
#else
;
#endif
#endif /* !DISABLE_COLOR */
else if (strcasecmp(keyword, "bind") == 0)
parse_binding(ptr, TRUE);

View File

@@ -106,6 +106,7 @@ void not_found_msg(const char *str)
void search_replace_abort(void)
{
display_main_list();
focusing = FALSE;
#ifndef NANO_TINY
if (openfile->mark_set)
edit_refresh();
@@ -115,15 +116,6 @@ void search_replace_abort(void)
#endif
}
/* Initialize the global search and replace strings. */
void search_init_globals(void)
{
if (last_search == NULL)
last_search = mallocstrcpy(NULL, "");
if (last_replace == NULL)
last_replace = mallocstrcpy(NULL, "");
}
/* Set up the system variables for a search or replace. If use_answer
* is TRUE, only set backupstring to answer. Return -2 to run the
* opposite program (search -> replace, replace -> search), return -1 if
@@ -155,7 +147,7 @@ int search_init(bool replacing, bool use_answer)
* do_search() or do_replace() and be called again. In that case,
* we should put the same search string back up. */
search_init_globals();
focusing = TRUE;
if (last_search[0] != '\0') {
char *disp = display_string(last_search, 0, COLS / 3, FALSE);
@@ -257,17 +249,16 @@ int search_init(bool replacing, bool use_answer)
return 0;
}
/* Look for needle, starting at (current, current_x). If no_sameline is
* TRUE, skip over begin when looking for needle. begin is the line
/* Look for needle, starting at (current, current_x). begin is the line
* where we first started searching, at column begin_x. The return
* value specifies whether we found anything. If we did, set needle_len
* to the length of the string we found if it isn't NULL. */
bool findnextstr(
#ifndef DISABLE_SPELLER
bool whole_word,
bool whole_word_only,
#endif
bool no_sameline, const filestruct *begin, size_t begin_x, const
char *needle, size_t *needle_len)
const filestruct *begin, size_t begin_x,
const char *needle, size_t *needle_len)
{
size_t found_len;
/* The length of the match we find. */
@@ -324,7 +315,7 @@ bool findnextstr(
#ifndef DISABLE_SPELLER
/* If we're searching for whole words, see if this potential
* match is a whole word. */
if (whole_word) {
if (whole_word_only) {
char *word = mallocstrncpy(NULL, found, found_len + 1);
word[found_len] = '\0';
@@ -332,17 +323,11 @@ bool findnextstr(
fileptr->data, word);
free(word);
}
#endif
/* If we're searching for whole words and this potential
* match isn't a whole word, or if we're not allowed to find
* a match on the same line we started on and this potential
* match is on that line, continue searching. */
if (
#ifndef DISABLE_SPELLER
(!whole_word || found_whole) &&
* match isn't a whole word, continue searching. */
if (!whole_word_only || found_whole)
#endif
(!no_sameline || fileptr != openfile->current))
break;
}
@@ -475,35 +460,13 @@ void do_search(void)
#ifndef DISABLE_SPELLER
FALSE,
#endif
FALSE, openfile->current, openfile->current_x, answer, NULL);
openfile->current, openfile->current_x, answer, NULL);
/* Check to see if there's only one occurrence of the string and
* we're on it now. */
/* If we found something, and we're back at the exact same spot where
* we started searching, then this is the only occurrence. */
if (fileptr == openfile->current && fileptr_x ==
openfile->current_x && didfind) {
#ifdef HAVE_REGEX_H
/* Do the search again, skipping over the current line, if we're
* doing a bol and/or eol regex search ("^", "$", or "^$"), so
* that we find one only once per line. We should only end up
* back at the same position if the string isn't found again, in
* which case it's the only occurrence. */
if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp,
last_search)) {
didfind = findnextstr(
#ifndef DISABLE_SPELLER
FALSE,
#endif
TRUE, openfile->current,
openfile->current_x, answer, NULL);
if (fileptr == openfile->current && fileptr_x ==
openfile->current_x && !didfind)
statusbar(_("This is the only occurrence"));
} else {
#endif
statusbar(_("This is the only occurrence"));
#ifdef HAVE_REGEX_H
}
#endif
}
openfile->placewewant = xplustabs();
@@ -511,6 +474,31 @@ void do_search(void)
search_replace_abort();
}
#ifndef NANO_TINY
/* Search in the backward direction for the next occurrence. */
void do_findprevious(void)
{
if ISSET(BACKWARDS_SEARCH)
do_research();
else {
SET(BACKWARDS_SEARCH);
do_research();
UNSET(BACKWARDS_SEARCH);
}
}
/* Search in the forward direction for the next occurrence. */
void do_findnext(void)
{
if ISSET(BACKWARDS_SEARCH) {
UNSET(BACKWARDS_SEARCH);
do_research();
SET(BACKWARDS_SEARCH);
} else
do_research();
}
#endif
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
/* Search for the last string without prompting. */
void do_research(void)
@@ -520,7 +508,14 @@ void do_research(void)
size_t pww_save = openfile->placewewant;
bool didfind;
search_init_globals();
focusing = TRUE;
#ifndef DISABLE_HISTORIES
/* If nothing was searched for yet during this run of nano, but
* there is a search history, take the most recent item. */
if (last_search[0] == '\0' && searchbot->prev != NULL)
last_search = mallocstrcpy(last_search, searchbot->prev->data);
#endif
if (last_search[0] != '\0') {
#ifdef HAVE_REGEX_H
@@ -534,36 +529,13 @@ void do_research(void)
#ifndef DISABLE_SPELLER
FALSE,
#endif
FALSE, openfile->current, openfile->current_x,
last_search, NULL);
openfile->current, openfile->current_x, last_search, NULL);
/* Check to see if there's only one occurrence of the string and
* we're on it now. */
/* If we found something, and we're back at the exact same spot
* where we started searching, then this is the only occurrence. */
if (fileptr == openfile->current && fileptr_x ==
openfile->current_x && didfind) {
#ifdef HAVE_REGEX_H
/* Do the search again, skipping over the current line, if
* we're doing a bol and/or eol regex search ("^", "$", or
* "^$"), so that we find one only once per line. We should
* only end up back at the same position if the string isn't
* found again, in which case it's the only occurrence. */
if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp,
last_search)) {
didfind = findnextstr(
#ifndef DISABLE_SPELLER
FALSE,
#endif
TRUE, openfile->current, openfile->current_x,
answer, NULL);
if (fileptr == openfile->current && fileptr_x ==
openfile->current_x && !didfind)
statusbar(_("This is the only occurrence"));
} else {
#endif /* HAVE_REGEX_H */
statusbar(_("This is the only occurrence"));
#ifdef HAVE_REGEX_H
}
#endif
}
} else
statusbar(_("No current search pattern"));
@@ -575,17 +547,13 @@ void do_research(void)
#endif /* !NANO_TINY */
#ifdef HAVE_REGEX_H
/* Calculate the size of the replacement text, taking possible
* subexpressions \1 to \9 into account. Return the replacement
* text in the passed string only when create is TRUE. */
int replace_regexp(char *string, bool create)
{
/* We have a split personality here. If create is FALSE, just
* calculate the size of the replacement line (necessary because of
* subexpressions \1 to \9 in the replaced text). */
const char *c = last_replace;
size_t search_match_count = regmatches[0].rm_eo -
regmatches[0].rm_so;
size_t new_line_size = strlen(openfile->current->data) + 1 -
search_match_count;
size_t replacement_size = 0;
/* Iterate through the replacement text to handle subexpression
* replacement using \1, \2, \3, etc. */
@@ -597,7 +565,7 @@ int replace_regexp(char *string, bool create)
if (create)
*string++ = *c;
c++;
new_line_size++;
replacement_size++;
} else {
size_t i = regmatches[num].rm_eo - regmatches[num].rm_so;
@@ -605,7 +573,7 @@ int replace_regexp(char *string, bool create)
c += 2;
/* But add the length of the subexpression to new_size. */
new_line_size += i;
replacement_size += i;
/* And if create is TRUE, append the result of the
* subexpression match to the new line. */
@@ -620,25 +588,26 @@ int replace_regexp(char *string, bool create)
if (create)
*string = '\0';
return new_line_size;
return replacement_size;
}
#endif /* HAVE_REGEX_H */
/* Return a copy of the current line with one needle replaced. */
char *replace_line(const char *needle)
{
char *copy;
size_t new_line_size, search_match_count;
size_t match_len;
size_t new_line_size = strlen(openfile->current->data) + 1;
/* Calculate the size of the new line. */
/* First adjust the size of the new line for the change. */
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP)) {
search_match_count = regmatches[0].rm_eo - regmatches[0].rm_so;
new_line_size = replace_regexp(NULL, FALSE);
match_len = regmatches[0].rm_eo - regmatches[0].rm_so;
new_line_size += replace_regexp(NULL, FALSE) - match_len;
} else {
#endif
search_match_count = strlen(needle);
new_line_size = strlen(openfile->current->data) -
search_match_count + strlen(answer) + 1;
match_len = strlen(needle);
new_line_size += strlen(answer) - match_len;
#ifdef HAVE_REGEX_H
}
#endif
@@ -646,10 +615,10 @@ char *replace_line(const char *needle)
/* Create the buffer. */
copy = charalloc(new_line_size);
/* The head of the original line. */
/* Copy the head of the original line. */
strncpy(copy, openfile->current->data, openfile->current_x);
/* The replacement text. */
/* Add the replacement text. */
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP))
replace_regexp(copy + openfile->current_x, TRUE);
@@ -657,11 +626,10 @@ char *replace_line(const char *needle)
#endif
strcpy(copy + openfile->current_x, answer);
/* The tail of the original line. */
assert(openfile->current_x + search_match_count <= strlen(openfile->current->data));
assert(openfile->current_x + match_len <= strlen(openfile->current->data));
strcat(copy, openfile->current->data + openfile->current_x +
search_match_count);
/* Copy the tail of the original line. */
strcat(copy, openfile->current->data + openfile->current_x + match_len);
return copy;
}
@@ -676,7 +644,7 @@ char *replace_line(const char *needle)
* canceled isn't NULL, set it to TRUE if we canceled. */
ssize_t do_replace_loop(
#ifndef DISABLE_SPELLER
bool whole_word,
bool whole_word_only,
#endif
bool *canceled, const filestruct *real_current, size_t
*real_current_x, const char *needle)
@@ -684,31 +652,28 @@ ssize_t do_replace_loop(
ssize_t numreplaced = -1;
size_t match_len;
bool replaceall = FALSE;
#ifdef HAVE_REGEX_H
/* The starting-line match and bol/eol regex flags. */
bool begin_line = FALSE, bol_or_eol = FALSE;
#endif
#ifndef NANO_TINY
bool old_mark_set = openfile->mark_set;
filestruct *edittop_save = openfile->edittop, *top, *bot;
filestruct *top, *bot;
size_t top_x, bot_x;
bool right_side_up = FALSE;
/* TRUE if (mark_begin, mark_begin_x) is the top of the mark,
* FALSE if (current, current_x) is. */
if (old_mark_set) {
/* If the mark is on, partition the filestruct so that it
* contains only the marked text, set edittop to the top of the
* partition, turn the mark off, and refresh the screen. */
/* If the mark is on, frame the region, and turn the mark off. */
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, &right_side_up);
filepart = partition_filestruct(top, top_x, bot, bot_x);
openfile->edittop = openfile->fileage;
openfile->mark_set = FALSE;
#ifndef DISABLE_COLOR
reset_multis(openfile->current, TRUE);
#endif
edit_refresh();
/* Start either at the top or the bottom of the marked region. */
if (!ISSET(BACKWARDS_SEARCH)) {
openfile->current = top;
openfile->current_x = (top_x == 0 ? 0 : top_x - 1);
} else {
openfile->current = bot;
openfile->current_x = bot_x;
}
}
#endif /* !NANO_TINY */
@@ -718,39 +683,23 @@ ssize_t do_replace_loop(
findnextstr_wrap_reset();
while (findnextstr(
#ifndef DISABLE_SPELLER
whole_word,
whole_word_only,
#endif
#ifdef HAVE_REGEX_H
/* We should find a bol and/or eol regex only once per line. If
* the bol_or_eol flag is set, it means that the last search
* found one on the beginning line, so we should skip over the
* beginning line when doing this search. */
bol_or_eol
#else
FALSE
#endif
, real_current, *real_current_x, needle, &match_len)) {
real_current, *real_current_x, needle, &match_len)) {
int i = 0;
#ifdef HAVE_REGEX_H
/* If the bol_or_eol flag is set, we've found a match on the
* beginning line already, and we're still on the beginning line
* after the search, it means that we've wrapped around, so
* we're done. */
if (bol_or_eol && begin_line && openfile->current == real_current)
break;
/* Otherwise, set the begin_line flag if we've found a match on
* the beginning line, reset the bol_or_eol flag, and continue. */
else {
if (openfile->current == real_current)
begin_line = TRUE;
bol_or_eol = FALSE;
#ifndef NANO_TINY
if (old_mark_set) {
/* When we've found an occurrence outside of the marked region,
* stop the fanfare. */
if (openfile->current->lineno > bot->lineno ||
openfile->current->lineno < top->lineno ||
(openfile->current == bot && openfile->current_x > bot_x) ||
(openfile->current == top && openfile->current_x < top_x))
break;
}
#endif
if (!replaceall)
edit_refresh();
/* Indicate that we found the search string. */
if (numreplaced == -1)
numreplaced = 0;
@@ -761,6 +710,8 @@ ssize_t do_replace_loop(
xpt, strnlenpt(openfile->current->data,
openfile->current_x + match_len) - xpt, FALSE);
edit_refresh();
curs_set(0);
do_replace_highlight(TRUE, exp_word);
@@ -781,59 +732,53 @@ ssize_t do_replace_loop(
}
}
#ifdef HAVE_REGEX_H
/* Set the bol_or_eol flag if we're doing a bol and/or eol regex
* replace ("^", "$", or "^$"). */
if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp,
needle))
bol_or_eol = TRUE;
#endif
if (i > 0 || replaceall) { /* Yes, replace it!!!! */
char *copy;
size_t length_change;
#ifndef NANO_TINY
update_undo(REPLACE);
add_undo(REPLACE);
#endif
if (i == 2)
replaceall = TRUE;
copy = replace_line(needle);
length_change = strlen(copy) -
strlen(openfile->current->data);
length_change = strlen(copy) - strlen(openfile->current->data);
#ifndef NANO_TINY
/* If the mark was on and (mark_begin, mark_begin_x) was the
* top of it, don't change mark_begin_x. */
if (!old_mark_set || !right_side_up) {
/* Keep mark_begin_x in sync with the text changes. */
/* If the mark was on and it was located after the cursor,
* then adjust its x position for any text length changes. */
if (old_mark_set && !right_side_up) {
if (openfile->current == openfile->mark_begin &&
openfile->mark_begin_x > openfile->current_x) {
if (openfile->mark_begin_x < openfile->current_x +
match_len)
if (openfile->mark_begin_x < openfile->current_x + match_len)
openfile->mark_begin_x = openfile->current_x;
else
openfile->mark_begin_x += length_change;
bot_x = openfile->mark_begin_x;
}
}
/* If the mark was on and (current, current_x) was the top
* of it, don't change real_current_x. */
/* If the mark was not on or it was before the cursor, then
* adjust the cursor's x position for any text length changes. */
if (!old_mark_set || right_side_up) {
#endif
/* Keep real_current_x in sync with the text changes. */
if (openfile->current == real_current &&
openfile->current_x <= *real_current_x) {
if (*real_current_x <
openfile->current_x + match_len)
*real_current_x = openfile->current_x +
match_len;
if (*real_current_x < openfile->current_x + match_len)
*real_current_x = openfile->current_x + match_len;
*real_current_x += length_change;
}
#ifndef NANO_TINY
bot_x = *real_current_x;
}
#endif
}
#ifdef HAVE_REGEX_H
/* Don't find the same zero-length match again. */
if (match_len == 0)
match_len++;
#endif
/* Set the cursor at the last character of the replacement
@@ -845,16 +790,18 @@ ssize_t do_replace_loop(
#endif
openfile->current_x += match_len + length_change - 1;
/* Clean up. */
openfile->totsize += mbstrlen(copy) -
mbstrlen(openfile->current->data);
/* Update the file size, and put the changed line into place. */
openfile->totsize += mbstrlen(copy) - mbstrlen(openfile->current->data);
free(openfile->current->data);
openfile->current->data = copy;
#ifndef DISABLE_COLOR
reset_multis(openfile->current, TRUE);
/* Reset the precalculated multiline-regex hints only when
* the first replacement has been made. */
if (numreplaced == 0)
reset_multis(openfile->current, TRUE);
#endif
edit_refresh();
if (!replaceall) {
#ifndef DISABLE_COLOR
/* If color syntaxes are available and turned on, we
@@ -872,16 +819,12 @@ ssize_t do_replace_loop(
}
}
if (numreplaced == -1)
not_found_msg(needle);
#ifndef NANO_TINY
if (old_mark_set) {
/* If the mark was on, unpartition the filestruct so that it
* contains all the text again, set edittop back to what it was
* before, turn the mark back on, and refresh the screen. */
unpartition_filestruct(&filepart);
openfile->edittop = edittop_save;
if (old_mark_set)
openfile->mark_set = TRUE;
edit_refresh();
}
#endif
/* If the NO_NEWLINES flag isn't set, and text has been added to the
@@ -1203,7 +1146,7 @@ void do_find_bracket(void)
ch = openfile->current->data + openfile->current_x;
if (ch == '\0' || (ch = mbstrchr(matchbrackets, ch)) == NULL) {
if ((ch = mbstrchr(matchbrackets, ch)) == NULL) {
statusbar(_("Not a bracket"));
return;
}
@@ -1364,7 +1307,6 @@ void update_history(filestruct **h, const char *s)
foo = p;
bar = p->next;
unlink_node(foo);
delete_node(foo);
renumber(bar);
}
@@ -1376,13 +1318,12 @@ void update_history(filestruct **h, const char *s)
*hage = (*hage)->next;
unlink_node(foo);
delete_node(foo);
renumber(*hage);
}
/* Add the new entry to the end. */
(*hbot)->data = mallocstrcpy((*hbot)->data, s);
splice_node(*hbot, make_new_node(*hbot), (*hbot)->next);
splice_node(*hbot, make_new_node(*hbot));
*hbot = (*hbot)->next;
(*hbot)->data = mallocstrcpy(NULL, "");

File diff suppressed because it is too large Load Diff

View File

@@ -30,21 +30,6 @@
#include <ctype.h>
#include <errno.h>
/* Return the number of decimal digits in n. */
int digits(size_t n)
{
int i;
if (n == 0)
i = 1;
else {
for (i = 0; n != 0; n /= 10, i++)
;
}
return i;
}
/* Return the user's home directory. We use $HOME, and if that fails,
* we fall back on the home directory of the effective user ID. */
void get_homedir(void)
@@ -58,7 +43,11 @@ void get_homedir(void)
if (userage != NULL)
homenv = userage->pw_dir;
}
homedir = mallocstrcpy(NULL, homenv);
/* Only set homedir if some home directory could be determined,
* otherwise keep homedir NULL. */
if (homenv != NULL && strcmp(homenv, "") != 0)
homedir = mallocstrcpy(NULL, homenv);
}
}
@@ -250,15 +239,6 @@ ssize_t ngetline(char **lineptr, size_t *n, FILE *stream)
#endif /* !DISABLE_NANORC */
#ifdef HAVE_REGEX_H
/* Do the compiled regex in preg and the regex in string match the
* beginning or end of a line? */
bool regexp_bol_or_eol(const regex_t *preg, const char *string)
{
return (regexec(preg, string, 0, NULL, 0) == 0 &&
regexec(preg, string, 0, NULL, REG_NOTBOL | REG_NOTEOL) ==
REG_NOMATCH);
}
/* Fix the regex if we're on platforms which require an adjustment
* from GNU-style to BSD-style word boundaries. */
const char *fixbounds(const char *r)
@@ -290,12 +270,11 @@ const char *fixbounds(const char *r)
fprintf(stderr, "fixbounds(): Ending string = \"%s\"\n", r3);
#endif
return (const char *) r3;
#endif
#endif /* !GNU_WORDBOUNDS */
return r;
}
#endif
#endif /* HAVE_REGEX_H */
#ifndef DISABLE_SPELLER
/* Is the word starting at position pos in buf a whole word? */
@@ -425,8 +404,7 @@ void *nrealloc(void *ptr, size_t howmuch)
}
/* Copy the first n characters of one malloc()ed string to another
* pointer. Should be used as: "dest = mallocstrncpy(dest, src,
* n);". */
* pointer. Should be used as: "dest = mallocstrncpy(dest, src, n);". */
char *mallocstrncpy(char *dest, const char *src, size_t n)
{
if (src == NULL)
@@ -445,8 +423,7 @@ char *mallocstrncpy(char *dest, const char *src, size_t n)
* "dest = mallocstrcpy(dest, src);". */
char *mallocstrcpy(char *dest, const char *src)
{
return mallocstrncpy(dest, src, (src == NULL) ? 1 :
strlen(src) + 1);
return mallocstrncpy(dest, src, (src == NULL) ? 1 : strlen(src) + 1);
}
/* Free the malloc()ed string at dest and return the malloc()ed string
@@ -643,7 +620,7 @@ filestruct *fsfromline(ssize_t lineno)
for (; f->lineno != lineno && f != openfile->fileage; f = f->prev)
;
else
for (; f->lineno != lineno && f->next != NULL; f = f->next)
for (; f->lineno != lineno && f->next != NULL; f = f->next)
;
if (f->lineno != lineno)

File diff suppressed because it is too large Load Diff