Compare commits

..

183 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
66 changed files with 21195 additions and 18324 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.

523
ChangeLog
View File

@@ -1,4 +1,480 @@
GNU nano 2.5.0 - 2015.12.05
2015-12-05 Chris Allegretta <chrisa@asty.org>
* src/nano.c (main) : key_defined() is an ncurses-ism. Add
better checks for this.
2015-12-05 Benno Schulenberg <bensberg@justemail.net>
* src/text.c: Fix compilation with --enable-tiny --enable-justify.
* doc/man/{nano.1,rnano.1,nanorc.5}, doc/texinfo/nano.texi:
Update date and version number to match the upcoming release.
* src/files.c, src/winio.c: Avoid two compilation warnings.
2015-12-04 Benno Schulenberg <bensberg@justemail.net>
* src/proto.h: Avoid a compilation warning.
* src/color.c (reset_multis_for_id, reset_multis_before/after):
Fuse these three functions into a single one.
* src/*.c: Rewrap some lines and tweak some comments.
2015-12-03 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (discard_until): Move the trimming of the undo stack
into a separate function, so it can be used elsewhere.
* src/text.c (do_justify): Discard 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.
* src/text.c (do_indent): Also here discard 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.
* doc/man/nano.1, doc/texinfo/nano.texi: Add a note about undo not
working after a justification or reindentation.
2015-12-02 Benno Schulenberg <bensberg@justemail.net>
* doc/syntax/python.nanorc: Don't colour triple quotes by themselves.
* doc/syntax/python.nanorc: Treat backslashed quotes properly, and
don't colour triple-quoted strings in two manners.
* src/text.c (do_justify): Accept not just the Uncut keystroke but
also the Undo keystroke for undoing a justification.
2015-12-02 Arturo Borrero González <arturo.borrero.glez@gmail.com>
* doc/syntax/nftables.nanorc: New file; syntax colouring for nftables.
This addresses Debian bug #805288.
2015-12-01 Benno Schulenberg <bensberg@justemail.net>
* src/files.c (do_insertfile): Mark the buffer as mofified only when
actually something was inserted. This fixes Savannah bug #45409.
* src/files.c (do_insertfile): Rename two variables for clarity.
* src/text.c (redo_cut): Delete two redundant assignments.
* src/winio.c (edit_draw): Move a check to a better place.
* src/winio.c (edit_draw): Rename a label and elide an 'else'.
* src/winio.c (edit_draw): Unindent after previous change.
* src/color.c (reset_multis_before, reset_multis_after): Delete four
superfluous checks.
2015-11-30 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (redo_cut, update_undo): When cutting reaches the EOF,
and NONEWLINES is set, there is no next line at which to put the
cutting point for a redo. So put it at the very end of the cut.
This fixes Savannah bug #46541.
* src/text.c (add_undo, update_undo, do_undo, do_redo), src/nano.h:
Store and retrieve the correct file size before and after an action.
This fixes Savannah bug #45523.
* src/files.c (free_chararray): Allow the parameter to be NULL.
This fixes Savannah bug #46420.
2015-11-29 Benno Schulenberg <bensberg@justemail.net>
* src/color.c (reset_multis): Evaluate correctly whether to reset
the multidata cache. This fixes Savannah bug #46543.
* src/color.c (reset_multis): Reset the multidata a bit less often.
* src/color.c (reset_multis): Adjust whitespace and comments.
* src/winio.c (edit_draw): When an end is found but nothing is painted
(because the coloured part is horizontally scrolled off), nevertheless
set the multidata to CBEGINBEFORE. This fixes Savannah bug #46545.
* src/winio.c (edit_draw): Use the main cache-allocation routine.
* src/winio.c (edit_draw): Delete two redundant conditions, and move
the least frequent case to the end.
* src/winio.c (edit_draw): Elide a variable, tweak some comments.
2015-11-28 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (main): Allow the user full control over the values of
MALLOC_CHECK_ and MALLOC_PERTURB_; nano shouldn't override these.
This reverts r5344 from August 6.
* src/nano.c (alloc_multidata_if_needed): When allocating a new
multidata array, initialize the array. Problem was betrayed by
using MALLOC_PERTURB_, and was located with valgrind.
2015-11-26 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (do_redo): Not just the undoing, also the redoing of a
Backspace at EOF is a special case. This fixes Savannah bug #46532.
* src/text.c (do_redo): Warn about an impossible condition, instead
of blithely continuing. And elide an unneeded variable.
2015-11-25 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (do_output): Refreshing the whole edit window (instead
of just the current line) is not needed for any kind of syntax, but
only when there are multiline regexes. And check for this not on
every keystroke in a burst, but just once.
* src/text.c (do_undo): Warn about a condition that should never
occur, instead of silently continuing.
* src/text.c (do_undo): Elide an unneeded variable, and don't skip
the end of this function when things went wrong.
* src/text.c (do_undo, do_redo, add_undo, update_undo): Handle more
possible internal errors, and do it correctly.
* AUTHORS: Add Mark and myself.
2015-11-24 Benno Schulenberg <bensberg@justemail.net>
* doc/syntax/makefile.nanorc: Also recognize the extensions .make and
.mk as Makefiles. Suggested by Emmanuel Bourg in Debian bug #804845.
* src/color.c (color_update): Tell the user when a syntax name given
on the command line does not exist. This fixes Savannah bug #46503.
* src/nano.c (splice_node): Inserting a new node into a linked list
requires just two parameters: the insertion point and the new node.
* src/nano.c (splice_node): Rename a variable for clarity.
2015-11-23 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (main), src/winio.c (parse_kbinput): Make Ctrl+Left and
Ctrl+Right work on more terminals by asking ncurses for the keycodes.
This addresses Debian bug #800681 reported by Arturo Borrero González.
2015-11-22 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (add_undo): Delete a condition that will never occur --
this function is only ever called with PASTE when cutbuffer != NULL.
* src/text.c: Rewrap, rewrite, rename, and reorder some things.
* src/text.c (do_undo, do_redo): Elide an unneeded variable.
* src/nano.c (unlink_node): After unlinking, also delete the node.
2015-11-21 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (main): Let the value of a --fill option on the
command line override the value of a "set fill" in an rcfile.
This fixes Savannah bug #46492.
* ChangeLog, NEWS: Add the release marker and copy the news item.
2015-11-21 David Lawrence Ramsey <pooka109@gmail.com>
* ChangeLog, NEWS: Fix a typo and adjust some spacing.
GNU nano 2.4.3 - 2015.11.18
2015-11-12 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (do_undo, update_undo): Store the correct end position of
an inserted file, and use it when undoing. Fixes Savannah bug #46414.
* src/text.c (add_undo, update_undo): Delete an unneeded alias -- it
wasn't being used consistently anyway.
2015-11-11 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (do_redo, update_undo): Redo an Enter from the stored
undo data, instead of running do_enter() again, because the latter
will behave differently depending on the setting of autoindent.
This addresses Debian bug #793053 reported by Clancy.
* src/text.c (do_enter): Chop the now unused parameter 'undoing'.
* src/text.c (do_enter_void): Discard this now useless function.
2015-11-10 Benno Schulenberg <bensberg@justemail.net>
* src/winio.c (edit_draw): Skip a zero-length match only when there
/is/ a match. Found with valgrind. This fixes Savannah bug #41908.
* src/files.c (do_lockfile, update_poshistory): Plug memory leaks.
2015-11-08 Benno Schulenberg <bensberg@justemail.net>
* src/global.c (shortcut_init): Allow exiting from the file browser
with the same key (^T) as it was entered (as ^G for the help viewer).
* doc/syntax/changelog.nanorc: Accept longer bug and patch numbers.
2015-11-07 Benno Schulenberg <bensberg@justemail.net>
* src/search.c (do_replace_loop): Correct the logic for adjusting the
x position of the mark -- it happened to work because 'mark_begin' is
NULL when 'old_mark_set' is FALSE. Also improve the comments.
2015-11-06 Benno Schulenberg <bensberg@justemail.net>
* src/files.c (write_lockfile): Don't bail out when the hostname is
overlong, but instead truncate it properly and continue. This fixes
Ubuntu bug #1509081 reported by Sam Reed.
* src/global.c (length_of_list), src/winio.c(get_mouseinput): Don't
check whether a function has a help line, since all of them have.
(And even if some didn't, they would still be valid functions.)
* src/cut.c (cut_line): There is no need to set 'openfile->mark_begin'
just like that; it will be set when 'openfile->mark_set' becomes TRUE.
* src/text.c (do_redo): Delete a redundant assignment.
2015-11-02 Benno Schulenberg <bensberg@justemail.net>
* src/nano.h: Delete an unused type definition.
* src/nano.h: Improve several comments.
* src/text.c (do_wrap): Elide two variables.
* src/cut.c (do_cut_text): Chop the 'undoing' parameter, so that the
calls of this function become more symmetrical.
2015-10-31 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (copy_from_filestruct): When pasting while the mark is
on, the mark's pointer needs to be refreshed only when it is on the
same line as the cursor, and the mark's x coordinate only when the
mark is located after the cursor. This fixes Savannah bug #46347.
* src/nano.c (copy_from_filestruct): Improve comments and combine
two conditions.
* ChangeLog: Correct the description of an old change.
2015-10-29 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (add_undo): Only skip adding an undo when the current
action equals the last action. This condition is needed for when
typing text is broken by an undo+redo. Fixes Savannah bug #46323.
* src/text.c (do_redo): Check for "nothing to redo" earlier, so we
can restore the possible warning about an internal error.
* src/text.c (add_undo): Remove an 'if' that will never be true,
and remove some assignments that have already been done.
2015-10-29 David Lawrence Ramsey <pooka109@gmail.com>
* src/files.c (do_writeout), src/nano.c (no_current_file_name_warning,
do_exit): When option -t is given, make ^O work the same way as under
Pico, writing out the file without prompting. And make it work even
better than Pico when the current file doesn't have a name yet. This
fixes Savannah bug #45415.
2015-10-28 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (do_redo): For an INSERT, 'u->mark_begin_lineno' is not
an actual line number, so spoof it. It can be spoofed, because 'f'
is not used for the INSERT case. This fixes Savannah bug #45524.
* src/text.c (do_redo): Remove a condition that can never occur.
Also rewrite a loop to become somewhat clearer.
2015-10-27 Benno Schulenberg <bensberg@justemail.net>
* src/move.c (do_next_word): Rewrite this function to use the same
logic as do_prev_word(), reducing its number of lines to half.
* src/move.c (do_down): Don't calculate the line length twice. And
in the bargain avoid a warning about comparison of signed/unsigned.
2015-09-05 Benno Schulenberg <bensberg@justemail.net>
* src/winio.c (display_string, edit_draw): Force a redraw of a line
only when it contains a multicolumn character, to spare all regular
text this significant slowdown. This fixes Savannah bug #45684
reported by Wyatt Ward.
* src/move.c (do_prev_word): Drop a return value that is never used.
* src/move.c (do_prev_word): When in the middle of a word, jump to
its beginning instead of to the beginning of the preceding word.
Nano now matches the behaviour of Pico and of most other editors.
This fixes Savannah bug #45413.
2015-09-04 Benno Schulenberg <bensberg@justemail.net>
* src/chars.c: Reverting r5354 from August 12. This fixes Savannah
bug #45874. Apparently there is /some/ state somewhere after all.
2015-08-29 Benno Schulenberg <bensberg@justemail.net>
* doc/syntax/autoconf.nanorc: New file; syntax colouring for Autoconf.
* src/files.c: Rewrap some lines and tweak two comments.
2015-08-16 Benno Schulenberg <bensberg@justemail.net>
* src/help.c (help_init, help_line_len): Avoid wide paragraphs of text
in the help screens: wrap them at 74 columns if the screen is wider.
* src/help.c (help_init): Reduce the scope of a variable.
* src/help.c: Adjust some comments and whitespace.
* src/help.c (do_help, do_help_void): Don't bother passing a function
when it's used only once.
* src/help.c (help_line_len): The wrap location can be beyond the EOL,
so for determining the length of the current line, don't start at that
location but at the beginning. This fixes Savannah bug #45770.
* src/help.c (help_line_len): Rename and reorder most of it.
* src/nano.c (make_new_opennode), src/files.c (initialize_buffer):
Remove some duplication in the initialization of a new openfile node.
* src/nano.c (make_new_opennode): Don't bother setting things to NULL
when they will be initialized right away.
* src/files.c (make_new_buffer): Don't bother with a separate function
when it's used only once, right there.
* src/help.c (help_init): Since the new SIGWINCH handling, a resizing
of the window will no longer break out of the help viewer, so there is
no need any more for an extra freeing of the help text.
2015-08-13 Benno Schulenberg <bensberg@justemail.net>
* src/search.c (do_find_bracket): Remove mistaken comparison between
pointer and literal character. Found with cppcheck.
* src/browser.c (browser_init): Speed up the finding of the longest
filename: don't limit the value to that of COLS all the time, as this
is done later anyway, and don't bother skipping the dot entry.
* src/global.c (shortcut_init): In restricted mode, allow changing
the file format, but actually disable Appending, Prepending, making
Backups, and opening the File Browser.
2015-08-12 Benno Schulenberg <bensberg@justemail.net>
* src/chars.c: UTF-8 is a stateless encoding, so there is no need to
reset any state. [Reverted in r5369 on September 4.]
2015-08-11 Benno Schulenberg <bensberg@justemail.net>
* src/files.c (write_file): Avoid calling copy_file() with a null
pointer. Found with cppcheck.
* src/files.c (write_file): A failure to delete the temporary file
does not mean that it wasn't copied properly.
2015-08-09 Benno Schulenberg <bensberg@justemail.net>
* src/global.c, src/help.c (help_init), src/nano.c (do_toggle, main),
src/winio.c (display_string, statusbar): Allow toggling the display
of whitespace also when support for nanorc files was not built in,
because the default values are quite usable.
* src/files.c (read_file), src/rcfile.c, src/nano.c (main, usage):
Fix compilation with --enable-tiny; file formats are not available
then, so option --unix has no place; also add its description.
* src/nano.c (finish): Remove an unneeded and mistaken condition.
* src/nano.c (say_there_is_no_help): Make it sound more definitive.
2015-08-08 Benno Schulenberg <bensberg@justemail.net>
* src/winio.c (display_string): For some reason the reallocation done
by null_at() messes things up. So put in the null byte "manually".
This is a fix -- or workaround -- for Savannah bug #45718.
2015-08-06 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (main): For --enable-debug builds, let malloc() help
to find initialization failures and uses-after-free. Suggested by
Mike Frysinger. [Reverted in r5446 on November 28.]
* doc/texinfo/nano.texi: Improve the formatting, using @t to mark
double-quoted literal strings, @: to mark periods that do not end
sentences, and @. to mark a finishing period after a capital.
2015-08-04 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (main), src/files.c (read_file), src/rcfile.c,
doc/man/nano.1, doc/man/nanorc.5, doc/texinfo/nano.texi: Add
the option --unix, to save a file by default in Unix format.
* doc/nanorc.sample.in: Advertise the five new bindable functions.
* doc/man/nano.1, doc/man/nanorc.5, doc/texinfo/nano.texi: Tweaks.
2015-08-03 Benno Schulenberg <bensberg@justemail.net>
* src/rcfile.c (parse_binding): Check the value of shortcut->toggle
only if it actually is a toggle. Found with valgrind.
* src/files.c (write_lockfile): Plug a leak. Found with valgrind.
* src/rcfile.c (parse_binding): Plug a tiny leak.
2015-08-02 Benno Schulenberg <bensberg@justemail.net>
* src/files.c (initialize_buffer): Initialize also openfile->syntax.
This addresses Debian bug #787914 reported by Paul Wise.
2015-08-01 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (precalc_multicolorinfo): Set each multiline-color
value instead of OR-ing it. This fixes Savannah bug #45640.
* src/help.c (help_init): Show also the dedicated keys in the
^G help text. This helps to clarify some keys, and helps to
see which ones could easily be rebound.
* src/nano.c (usage): Add "and exit" to the description of --help,
to match --version, and to distinguish it more from ^G.
2015-07-31 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (do_cutword, do_cut_prev_word, do_cut_next_word),
src/global.c (shortcut_init, strtosc), doc/texinfo/nano.texi,
doc/man/nanorc.5: Add two new bindable functions, 'cutwordleft'
and 'cutwordright', which delete all characters from the cursor
to the preceding or succeeding word start. Fixes bug #32803.
2015-07-30 Benno Schulenberg <bensberg@justemail.net>
* src/global.c (shortcut_init): Don't show ^R and ^T in the help
lines in restricted mode (if possible), to give visual feedback.
* src/*.c: Normalize the whitespace after the preceding changes.
* src/nano.c (show_restricted_warning, say_there_is_no_help):
Differentiate between something being disabled/restricted (because
of the way of invocation) and help texts being unavailable (which
is a compile-time decision).
* src/global.c (shortcut_init): Change "Justify" to a tag and regroup.
* src/nano.c (do_suspend_void, do_suspend): Provide feedback when
suspension is not enabled; and it cannot be enabled in restricted
mode any longer, so there is no need to check for that any more.
2015-07-29 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (do_linter): When the linter is called in restricted mode
(possible when nano was built with --disable-speller), it is better to
say that this function is disabled than that no linter was defined.
* src/nano.c (usage): When asking for --help in restricted mode, don't
show options that don't have any effect.
* src/nano.c (do_toggle): Make the four toggles that don't have any
effect in restricted mode say that they're disabled.
2015-07-28 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (do_formatter), src/nano.c (allow_pending_sigwinch):
Reenable SIGWINCH-es also when invoking the formatter fails, and
correct some comments.
* src/text.c (do_linter, do_formatter): In restricted mode, no nanorc
files are read, so no linter or formatter will be defined, so these
routines will never be called. Also, the formatter will only ever
be called when a syntax applies to the current file and this syntax
defines a formatter, so there is no need to check this again.
2015-07-26 Benno Schulenberg <bensberg@justemail.net>
* src/search.c (do_replace_loop): When doing regex replacements, find
each zero-length match only once. This fixes Savannah bug #45626.
* src/global.c (shortcut_init, strtosc), src/search.c (do_findnext,
do_findprevious), doc/man/nanorc.5, doc/texinfo/nano.texi: Add two
new bindable functions, 'findnext' and 'findprevious', which repeat
the last search command in a fixed direction without prompting.
* src/global.c (shortcut_init): Tweak a string.
* src/search.c, src/move.c: Improve a few of the comments.
* src/search.c (replace_regexp, replace_line): Rename two variables,
and make the calculation of the new line size more symmetrical.
2015-07-25 Benno Schulenberg <bensberg@justemail.net>
* src/global.c (shortcut_init, strtosc), src/files.c (savefile),
doc/man/nanorc.5, doc/texinfo/nano.texi: Add a new bindable function,
'savefile', which writes a file to disk without first asking for its
name. This implements Savannah patch #8208 submitted by Seiya Nuta.
2015-07-23 Benno Schulenberg <bensberg@justemail.net>
* doc/man/{nano.1,nanorc.5}, doc/texinfo/nano.texi: Add deprecation
notices for the options 'set const', 'set poslog' and '--poslog'.
Suggested by Eitan Adler.
* doc/faq.html: Mention --disable-histories and --disable-libmagic.
* src/chars.c (mbstrcasestr, mbrevstrcasestr): When searching, find
only valid UTF-8 byte sequences. This fixes Savannah bug #45579,
first reported in 2009 by Mike Frysinger.
2015-07-22 Mike Frysinger <vapier@gentoo.org>
* src/files.c (check_dotnano), src/global.c (thanks_for_all_the_fish),
src/rcfile.c (parse_binding): Plug a few memory leaks.
2015-07-19 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (main): Accept again a +LINE argument for each file
given on the command line. This fixes Savannah bug #45576.
* src/nano.c (main): Adjust some comments and rewrap some lines.
2015-07-18 Benno Schulenberg <bensberg@justemail.net>
* src/winio.c (edit_draw): When looking for multiline-regex matches,
look for a new start only after an end, instead of right after the
last start. This fixes bug #45525 and bug #41313 on Savannah.
* src/nano.c, src/text.c, src/winio.c: Adjust some comments.
* doc/faq.html: Fix a few typos and make some updates for 2.4.*.
* ChangeLog: Make the release markers stand out more.
2015-07-17 Benno Schulenberg <bensberg@justemail.net>
* src/files.c (open_buffer): Verify that a named and existing file
is a normal file, to avoid opening an empty buffer when the name of
a directory is specified. This fixes Savannah bug #45383 reported
by Mike Frysinger, and also Savannah bug #27839 (which is an echo
from Debian bug #551717 reported by Paul Wise).
* src/files.c (load_history): Remove an earlier attempt to make M-W
work at startup. It no longer worked because the assigned value gets
overwritten by a later initialization of 'last_search' to the empty
string. Found through the use of valgrind.
* src/text.c (do_alt_speller): Avoid an unfounded warning about a
possibly uninitialized variable.
2015-07-17 Mike Frysinger <vapier@gentoo.org>
* src/browser.c (browser_refresh): Use the proper type (off_t) for
the size of a file, and avoid warnings about too large bit shifts.
2015-07-15 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c, src/rcfile.c, doc/nanorc.sample.in, doc/man/nano.1,
doc/man/nanorc.5, doc/texinfo/nano.texi, doc/syntax/nanorc.nanorc:
Unabbreviate the long option --const to --constantshow, and --poslog
to --positionlog, to be more understandable.
* src/nano.h, src/global.c (add_to_sclist), src/help.c (help_init),
src/rcfile.c (parse_binding), src/winio.c (get_shortcut): Rename
the 'menu' item in the sc (shortcut) struct to 'menus', as it can
refer to more than one menu.
2015-07-13 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (do_int_spell_fix, do_alt_speller): Remove an unneeded
condition; 'added_magicline' can only be true when NO_NEWLINES isn't.
* src/files.c (replace_buffer): Prevent a segfault when spellchecking
a marked region and nonewlines isn't set.
2015-07-12 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (do_alt_speller): Rename the variable 'totsize_save'
to 'size_of_surrounding', to better describe what it contains.
* src/files.c (read_file): Remove a stray space from a message.
2015-07-10 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (delete_opennode): Plug a small memory leak.
* src/files.c (do_lockfile): Rename a variable; it does not contain
the size of the file but the size of the name.
* src/nano.c (do_toggle): Elide an unneeded variable.
* src/files.c: Unwrap some lines and rewrap some others in a more
congenial manner; tweak some comments and whitespace and braces.
* src/files.c (read_line): Remove two lines of dead code.
* src/files.c (read_line): Rearrange a few lines and some whitespace.
2015-07-06 Benno Schulenberg <bensberg@justemail.net>
* src/global.c (add_to_sclist), src/help.c (help_init), src/nano.h,
src/rcfile.c (parse_binding): When defining the toggles, give each
of them a sequence number, so that, when they are rebound, they can
still be listed in the original order in the help text. This fixes
Savannah bug #45417.
* src/text.c (do_undo): Make it clearer what WAS_FINAL_BACKSPACE does.
* src/text.c (add_undo, do_deletion): Move the check for a Delete at
the end-of-file to a less frequently travelled path.
* src/text.c (do_deletion): If a Backspace happens at the end-of-file,
don't remove and then re-add the magic line; just add an undo item.
* src/help.c (help_init), src/text.c (do_undo): Adjust whitespace and
bracing after the previous changes.
GNU nano 2.4.2 - 2015.07.05
2015-06-28 Benno Schulenberg <bensberg@justemail.net>
* src/browser.c (browser_refresh): Limit the selected file to the
available ones in the list -- after a refresh the number may have
@@ -217,6 +693,7 @@ GNU nano 2.4.2 - 2015.07.05
Browser in the order of ascending stride, as in the Help Viewer.
GNU nano 2.4.1 - 2015.04.14
2015-04-13 Benno Schulenberg <bensberg@justemail.net>
* src/search.c (do_replace_loop): Fix compilation with --enable-tiny.
* README: Mention also the Savannah page for reporting bugs.
@@ -334,6 +811,7 @@ GNU nano 2.4.1 - 2015.04.14
Fixes compilation on win32 and macOS.
GNU nano 2.4.0 - 2015.03.22
2015-03-22 Benno Schulenberg <bensberg@justemail.net>
* src/chars.c (move_mbleft): Start looking for a multibyte char
not at the start of the string, but only as far back as such a
@@ -397,6 +875,7 @@ GNU nano 2.4.0 - 2015.03.22
texinfo document, and slightly improve its punctuation.
GNU nano 2.3.99pre3 - 2015.02.27
2015-02-25 Chris Allegretta <chrisa@asty.org>
* src/rcfile.c (parse_binding): Add an exception for do_toggle() as
rebinding toggles broke with r5022. (Fixed in r5134.)
@@ -421,6 +900,7 @@ GNU nano 2.3.99pre3 - 2015.02.27
RPM file creation.
GNU nano 2.3.99pre2 - 2015.02.06
2015-02-03 Alex Henrie <alexhenrie24@gmail.com>
* src/cut.c (do_cut_text): Make sure to set modified even when
using --enable-tiny.
@@ -447,6 +927,7 @@ GNU nano 2.3.99pre2 - 2015.02.06
open_file(). Fixes Savannah bug #42373 reported by Benno Schulenberg.
GNU nano 2.3.99pre1 - 2015.01.06
2015-01-03 Chris Allegretta <chrisa@asty.org>
* New formatter code to support syntaxes like
go which have tools to automatically lint and reformat the text for
@@ -522,6 +1003,7 @@ GNU nano 2.3.99pre1 - 2015.01.06
* doc/nanorc.sample.in: Remove undo section which is now obsolete.
GNU nano 2.3.6 - 2014.07.17
2014-07-16 Jordi Mallach <jordi@gnu.org>
* doc/man/rnano.1: Additional printing formatting improvement from
Bjarni Ingi Gislason.
@@ -568,6 +1050,7 @@ GNU nano 2.3.6 - 2014.07.17
* src/files.c (write_lockfile): Refix typo in error message.
GNU nano 2.3.5 - 2014.07.11
2014-07-11 Chris Allegretta <chrisa@asty.org>
* src/files.c (do_lockfile, open_file): If locking fails,
allow the lock failure message to be preserved AND
@@ -898,6 +1381,7 @@ GNU nano 2.3.5 - 2014.07.11
necessary.
GNU nano 2.3.4 - 2014.06.02
2014-06-02 Chris Allegretta <chrisa@asty.org>
* doc/syntax/default.nanorc: Can't do trailing spaces in the
default syntax or it will hilight the spaces as you type them
@@ -913,6 +1397,7 @@ GNU nano 2.3.4 - 2014.06.02
* nano-regress: Added --disable-utf8 to regression check.
GNU nano 2.3.3 - 2014.05.29
2014-05-28 Chris Allegretta <chrisa@asty.org>
* doc/syntax/mutt.nanorc: Include Benno's awesome signature
matcher, modified slightly to also work for quoted sigs.
@@ -1731,8 +2216,10 @@ GNU nano 2.3.3 - 2014.05.29
* src/winio.c (set_modified): Check for a filename before trying to lock.
2014-01-24 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (copy_from_filestruct): Check explicitly for mark being set when
trying to partition, as we shouldn't be messing with the x address, etc.
* src/nano.c (copy_from_filestruct): Refresh the mark's pointer when
stuff was pasted into the line where the mark is. This applies
Savannah patch #8180 and fixes the segfault reported on the list:
https://lists.gnu.org/archive/html/nano-devel/2012-07/msg00000.html.
2014-01-01 Chris Allegretta <chrisa@asty.org>
* doc/texinfo/nano.texi: Change '@sp4' since makeinfo 5.1 hates the
@@ -1766,6 +2253,7 @@ GNU nano 2.3.3 - 2014.05.29
Partly fixes an issue reported by Benno Schulenberg.
GNU nano 2.3.2 - 2013.03.23
2013-03-17 Chris Allegretta <chrisa@asty.org>
* Revert r4547 as we should have a new release and the overlap code is not yet
ready for public consumption.
@@ -1822,6 +2310,7 @@ GNU nano 2.3.2 - 2013.03.23
be, and maybe we'll even start checking for it in autoconf!
GNU nano 2.3.1 - 2011.05.10
2011-05-10 Chris Allegretta <chrisa@asty.org>
* text.c (do_enter): Only increment totsize by the auto-indented amount, since the previous
line's size was already counted. Fixes bug reported by Robert Spanjaard.
@@ -1849,6 +2338,7 @@ GNU nano 2.3.1 - 2011.05.10
Fixed extra messages going to stderr, reported by Mike Frysinger.
GNU nano 2.3.0 - 2011.02.26
2011-02-26 Chris Allegretta <chrisa@asty.org>
* Change RAW in function_type enum to RAWINPUT, to fix compilation on AIX,
reported by Richard G Daniel <skunk@iskunk.org>.
@@ -1890,6 +2380,7 @@ GNU nano 2.3.0 - 2011.02.26
* winio.c (edit_redraw): Removed unused variable.
GNU nano 2.2.6 - 2010.11.22
2010-11-15 Chris Allegretta <chrisa@asty.org>
* Add a section to the FAQ about using nanorc on Win32 systems.
@@ -1899,6 +2390,7 @@ GNU nano 2.2.6 - 2010.11.22
mode. Fixes Savannah bug #31625 reported by Charlie Somerville.
GNU nano 2.2.5 - 2010.08.05
2010-08-04 Lauri Kasanen <curaga@operamail.comcuraga@operamail.com>
* doc/syntax/mgp.nanorc: New Magicpoint syntax highlighting definition.
@@ -1917,6 +2409,7 @@ GNU nano 2.2.5 - 2010.08.05
#29514: [nano 2.2.2] backup should ignore chown errors.
GNU nano 2.2.4 - 2010.04.15
2010-04-07 Chris Allegretta <chrisa@asty.org>
* doc/man/nano.1,nanorc.5: Remove the backup file warnings now
that a sufficient security fix exists for the backup file code.
@@ -1975,11 +2468,13 @@ GNU nano 2.2.4 - 2010.04.15
bug #28984.
GNU nano 2.2.3 - 2010.02.11
2010-01-28 Chris Allegretta <chrisa@asty.org>
* move.c (do_page_up, do_page_down): Fix for smooth mode not preserving cursor
position. Part one of fix for Savannah bug #21178 by Mike Frysinger.
GNU nano 2.2.2 - 2010.01.17
2010-01-17 Chris Allegretta <chrisa@asty.org>
* nano.c (main), prompt.c (do_statusbar_input): Handle problems with an unmapped
function due to key rebinding, fixes crashes on FreeBSD reported by Eitan
@@ -2030,6 +2525,7 @@ GNU nano 2.2.2 - 2010.01.17
Savannah bug #28299 reported by Mike Frysinger.
GNU nano 2.2.1 - 2009.12.12
2009-12-12 Chris Allegretta <chrisa@asty.org>
* text.c (do_delete), nano.c (do_output): Add check for length of current line
before and after adding/deleting text, and do full refresh if it is now
@@ -2082,6 +2578,7 @@ GNU nano 2.2.1 - 2009.12.12
file, man pages, UPGRADE file, and update copyright notice for the current year.
GNU nano 2.2.0 - 2009.11.30
2009-11-29 Chris Allegretta <chrisa@asty.org>
* prompt.c (get_prompt_string): Universally handle help key when it is disabled.
Fixes Savannah bug #28117 by David Lawrence Ramsey <pooka109@gmail.com>.
@@ -2126,13 +2623,14 @@ GNU nano 2.2.0 - 2009.11.30
* doc/syntax/gentoo.nanorc: Tweak comment highlighting.
GNU nano 2.1.99pre2 - 2009.11.21
2009-11-21 Chris Allegretta <chrisa@asty.org>
* rcfile.c: Add unbinding keyword, fixes Savannah bug #22852 reported by frankd.
* prompt.c (update_statusbar_line): Set statusbar_pww when updating the line.
Fixes Savannah bug #24957 reported by Mike Frysinger.
2009-11-19 Chris Allegretta <chrisa@asty.org>
* nano.c (die_save_file) Try and match the permissions of the file we were
* nano.c (die_save_file): Try and match the permissions of the file we were
editing but only make a minimal effort to do so. Fixes Savannah bug #27273
reported by Mike Frysinger.
@@ -2145,6 +2643,7 @@ GNU nano 2.1.99pre2 - 2009.11.21
is enabled. Fixes Savannah bug #28024 by Mike Frysinger.
GNU nano 2.1.99pre1 - 2009.11.15
2009-11-14 Chris Allegretta <chrisa@asty.org>
* move.c (do_first_line, do_last_line): Just set edit_refresh_needed
rather than get messy.
@@ -2190,6 +2689,7 @@ GNU nano 2.1.99pre1 - 2009.11.15
* winio.c: Clean up some unused variables from the soft wrapping code.
GNU nano 2.1.11 - 2009.09.14
2009-09-12 Chris Allegretta <chrisa@asty.org>
* winio.c (edit_update): properly update edittop when using soft wrapping.
Fixes lack of centering for searching for off-screen answers, found by
@@ -2204,7 +2704,7 @@ GNU nano 2.1.11 - 2009.09.14
2009-09-02 Chris Allegretta <chrisa@asty.org>
* Attempt to check file writability and emit a warning on the status bar
if nano doesn't think the file can be written to. Feature originally
requested by Damien Jolders <madamien@skullsquad.com> et al.
requested by Damien Joldersma <damien@skullsquad.com> et al.
2009-08-29 Chris Allegretta <chrisa@asty.org>
* Fix more soft wrapping issues, particularly with scrolling,
@@ -2228,6 +2728,7 @@ GNU nano 2.1.11 - 2009.09.14
previous undo flag to be implemented consistent with other flags.
GNU nano 2.1.10 - 2009.07.28
2009-07-27 Chris Allegretta <chrisa@asty.org>
* text.c (undo_cut, redo_cut): Don't actually try and undo/redo an empty cut, i.e. the magicline.
Fixes crash on cutting last line discovered by Eitan Adler <eitanadlerlist@gmail.com>.
@@ -2256,6 +2757,7 @@ GNU nano 2.1.10 - 2009.07.28
* doc/man/fr/Makefile.am: Add groff check fix to fr files.
GNU nano 2.1.9 - 2009.02.16
2009-02-16 Chris Allegretta <chrisa@asty.org>
* Add new argument to reset_multis for force redraws without attempting to
guess whether we need to, for functions that we don't have good info about
@@ -2294,6 +2796,7 @@ GNU nano 2.1.9 - 2009.02.16
with syntax highlighting in new buffers, initially reported by Mike Frysinger.
GNU nano 2.1.8 - 2009.02.07
2009-02-06 Chris Allegretta <chrisa@asty.org>
* rcfile.c (parse_include): Abort on being unable to open an included rcfile.
Fixes Savannah bug #25490, nanorc: "include"ing a file which doesn't exist
@@ -2339,6 +2842,7 @@ GNU nano 2.1.8 - 2009.02.07
reported by Eitan Adler <eitanadlerlist@gmail.com>.
GNU nano 2.1.7 - 2008.11.10
2008-10-20 Chris Allegretta <chrisa@asty.org>
* files.c (do_writeout): Add check for file modification when saving
the file so the user can at least know they may be blowing away changes.
@@ -2358,6 +2862,7 @@ GNU nano 2.1.7 - 2008.11.10
next uncut, fixes Savannah bug #24183.
GNU nano 2.1.6 - 2008.10.03
2008-10-03 Pascal Gentil <pascal.gentil@univ-rennes1.fr>
* fortran.nanorc: Sample Fortran syntax highlighting file.
@@ -2389,6 +2894,7 @@ GNU nano 2.1.6 - 2008.10.03
we can't generate ^C without it.
GNU nano 2.1.5 - 2008.08.30
2008-08-29 Chris Allegretta <chrisa@asty.org>
* configure.ac, color.c, rcfile.c, utils.c: 1st attempt at supporting systems
which don't support GNU-style word boundaries. New function fixbounds() to
@@ -2420,6 +2926,7 @@ GNU nano 2.1.5 - 2008.08.30
space on partition - nano claims successful write - file is empty.
GNU nano 2.1.4 - 2008.08.09
2008-08-08 Chris Allegretta <chrisa@asty.org>
* files.c (write_file): Do not go on and attempt to write the main file if writing
the backup file failed, related to Savannah bug #24000.
@@ -2433,11 +2940,12 @@ GNU nano 2.1.4 - 2008.08.09
a struct which may be NULL.
GNU nano 2.1.3 - 2008.08.04
2008-07-23 Chris Allegretta <chrisa@asty.org>
* configure.ac: Add ncursesw dir to include path if lib is detected.
2008-07-11 Mike Frysinger <vapier@gentoo.org>
* doc/nanorc.sample.in: Include the updates files in the default sample nanorc.
* doc/nanorc.sample.in: Include the updated files in the default sample nanorc.
2008-07-11 Fabian Groffen <grobian@gentoo.org>
* nano.c: Don't include langinfo.h if not using ENABLE_UTF8
@@ -2455,8 +2963,8 @@ GNU nano 2.1.3 - 2008.08.04
* global.c: Fix for not having a search history when --disable-justify is used
(Savannah bug #23733).
GNU nano 2.1.2 - 2008.06.24
2008-06-24 Chris Allegretta <chrisa@asty.org>
* rcfile.c: Added function check_bad_binding() to look for sequences which
shouldn't be bound, per Savannah bug #22674.
@@ -2482,6 +2990,7 @@ GNU nano 2.1.2 - 2008.06.24
by Andreas Amann <andreas.amann@tyndall.ie>.
GNU nano 2.1.1 - 2008.04.01
2008-05-31 Chris Allegretta <chrisa@asty.org>
* Added the following contributed files, by owner:
Donnie Berkholz <dberkholz@gentoo.org>
@@ -2489,7 +2998,7 @@ GNU nano 2.1.1 - 2008.04.01
Simon Rupf <simon.rupf@int-ag.ch>
* Sample css.nanorc
Josef 'Jupp' Schugt <jupp@rubyforge.org>
* sample ruby.nanorc
* Sample ruby.nanorc
2008-03-31 Chris Allegretta <chrisa@asty.org>
* global.c: Fix for issues compiling with --enable-tiny and

39
NEWS
View File

@@ -1,4 +1,25 @@
2015.07.05 - GNU nano 2.4.1 "Portorož" is released. This release
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
@@ -11,7 +32,7 @@
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
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!
@@ -76,12 +97,12 @@
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
@@ -92,7 +113,7 @@
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
@@ -127,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
@@ -173,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.
@@ -214,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.
@@ -253,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

View File

@@ -20,7 +20,7 @@
#
# $Id$
AC_INIT([GNU nano], [2.4.2], [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.2" "June 2015"
.TH NANO 1 "version 2.5.0" "December 2015"
.\" Please adjust this date whenever revising the manpage.
.\"
@@ -115,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
@@ -157,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
@@ -222,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
@@ -270,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.2" "June 2015"
.TH NANORC 5 "version 2.5.0" "December 2015"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH NAME
@@ -90,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.
@@ -158,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).
@@ -240,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
@@ -336,7 +343,7 @@ 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
@@ -365,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
@@ -378,7 +385,10 @@ 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 (at the current cursor position),
@@ -389,7 +399,13 @@ 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.
@@ -407,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
@@ -453,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

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

@@ -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

@@ -12,7 +12,7 @@ color yellow "<[^>]*@[^>]*>"
# Command-line options.
color cyan "[[:space:]]-[a-zA-Z\$]" "--[8a-z-]+"
# Bug and patch numbers.
color cyan "bug #[0-9]{5,6}" "patch #[0-9]{4,5}"
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.

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,7 +6,7 @@ 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:]]+(all|main|search|replace(2|with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)+[[:space:]]*$"

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

@@ -10,14 +10,14 @@ 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}"
# Single-quoted strings.
color brightgreen "'([^'\]|\\.)+'"
color brightgreen ""([^"\]|\\.)+""
# Comments.
color brightred "(^|[[:blank:]])#.*$"
# Multiline strings.
color brightgreen start="\"\"\"[^"),]" end="(^|[^(])\"\"\""
color brightgreen start="'''[^'),]" end="(^|[^(])'''"
# Triple-quoted strings.
color brightgreen start="'''[^'),]" end="(^|[^(\])'''"
color brightgreen start="\"\"\"[^"),]" end="(^|[^(\])\"\"\""
# Reminders.
color ,yellow "(FIXME|TODO|XXX)"

View File

@@ -6,8 +6,8 @@
@smallbook
@set EDITION 0.3
@set VERSION 2.4.2
@set UPDATED June 2015
@set VERSION 2.5.0
@set UPDATED December 2015
@dircategory Editors
@direntry
@@ -21,7 +21,7 @@
@titlepage
@title GNU @code{nano}
@subtitle a small and friendly text editor.
@subtitle version 2.4.2
@subtitle version 2.5.0
@author Chris Allegretta
@page
@@ -109,9 +109,9 @@ adding it with a comma. So the complete command synopsis is:
@end quotation
But normallly you would set your preferred options in your
@file{.nanorc} file. And when the @code{poslog} option is set
(making @code{nano} remember the cursor position), you will rarely
need to specify a line number.
@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
@chapter Command-line Options
@@ -135,7 +135,7 @@ line.
@item -B
@itemx --backup
When saving a file, back up the previous version of it, using the current
filename suffixed with a tilde (@samp{~}).
filename suffixed with a tilde (@code{~}).
@item -C @var{directory}
@itemx --backupdir=@var{directory}
@@ -187,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
@@ -210,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
@@ -220,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
@@ -242,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
@@ -308,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}
@@ -324,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
@@ -333,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
@@ -355,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
@@ -382,6 +386,7 @@ Ignored, for compatibility with Pico.
* The Statusbar::
* Shortcut Lists::
* Using the Mouse::
* Limitation::
@end menu
@node Entering Text
@@ -486,11 +491,20 @@ 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
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.
@node Built-in Help
@chapter Built-in Help
The built-in help system in @code{nano} is available by pressing ^G.
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.
@@ -507,57 +521,57 @@ 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 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,7 +583,7 @@ 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
@@ -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
@@ -626,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.
@@ -650,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
@@ -673,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.
@@ -710,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).
@@ -720,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
@@ -735,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
@@ -782,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.
@@ -796,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.
@@ -803,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
@@ -845,7 +856,7 @@ Use the given program to do a syntax check on the current file
@item formatter program [arg @dots{}]
Use the given program to automatically reformat text.
Useful in certain programming languages (e.g. Go).
Useful in certain programming languages (e.g.@: Go).
@item header "regex" @dots{}
Add one or more regexes which will
@@ -900,7 +911,7 @@ in one of the system-installed files (which are normally not writable).
@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
@@ -947,7 +958,10 @@ 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 (at the current cursor position),
@@ -958,7 +972,13 @@ 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.
@@ -976,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.
@@ -1019,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.
@@ -1103,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.

1063
po/bg.po

File diff suppressed because it is too large Load Diff

1101
po/ca.po

File diff suppressed because it is too large Load Diff

1081
po/cs.po

File diff suppressed because it is too large Load Diff

1096
po/da.po

File diff suppressed because it is too large Load Diff

1093
po/de.po

File diff suppressed because it is too large Load Diff

1112
po/eo.po

File diff suppressed because it is too large Load Diff

1124
po/es.po

File diff suppressed because it is too large Load Diff

1074
po/eu.po

File diff suppressed because it is too large Load Diff

1049
po/fi.po

File diff suppressed because it is too large Load Diff

1119
po/fr.po

File diff suppressed because it is too large Load Diff

1029
po/ga.po

File diff suppressed because it is too large Load Diff

1078
po/gl.po

File diff suppressed because it is too large Load Diff

1070
po/hu.po

File diff suppressed because it is too large Load Diff

1036
po/id.po

File diff suppressed because it is too large Load Diff

1095
po/it.po

File diff suppressed because it is too large Load Diff

1068
po/ja.po

File diff suppressed because it is too large Load Diff

1079
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1092
po/nb.po

File diff suppressed because it is too large Load Diff

1102
po/nl.po

File diff suppressed because it is too large Load Diff

1027
po/nn.po

File diff suppressed because it is too large Load Diff

1075
po/pl.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1252
po/ro.po

File diff suppressed because it is too large Load Diff

1075
po/ru.po

File diff suppressed because it is too large Load Diff

1070
po/sl.po

File diff suppressed because it is too large Load Diff

1084
po/sr.po

File diff suppressed because it is too large Load Diff

1121
po/sv.po

File diff suppressed because it is too large Load Diff

1033
po/tr.po

File diff suppressed because it is too large Load Diff

1089
po/uk.po

File diff suppressed because it is too large Load Diff

1097
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

@@ -24,6 +24,7 @@
#include "proto.h"
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
@@ -157,7 +158,7 @@ char *do_browser(char *path, DIR *dir)
/* 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 */
@@ -173,7 +174,7 @@ char *do_browser(char *path, DIR *dir)
browser_refresh();
curs_set(0);
#else
nano_disabled_msg();
say_there_is_no_help();
#endif
} else if (func == do_search) {
/* Search for a filename. */
@@ -284,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"));
@@ -435,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;
@@ -485,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;
@@ -542,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;
@@ -637,7 +632,7 @@ void browser_refresh(void)
} else
foo = mallocstrcpy(NULL, _("(dir)"));
} else {
unsigned long result = st.st_size;
off_t result = st.st_size;
char modifier;
foo = charalloc(foomaxlen + 1);
@@ -655,10 +650,10 @@ void browser_refresh(void)
modifier = 'G'; /* gigabytes */
}
/* If less than a terabyte, or if numbers can't even go
* that high, show the size, otherwise show "(huge)". */
if (st.st_size < (1 << 40) || (1 << 40) == 0)
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. */

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

@@ -180,6 +180,9 @@ 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
@@ -362,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;
@@ -433,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 */

View File

@@ -51,15 +51,7 @@ void make_new_buffer(void)
exitfunc->desc = close_tag;
}
/* Initialize the new buffer. */
initialize_buffer();
}
/* Initialize the current entry of the openfile openfilestruct. */
void initialize_buffer(void)
{
assert(openfile != NULL);
/* Start initializing the new buffer. */
openfile->filename = mallocstrcpy(NULL, "");
initialize_buffer_text();
@@ -71,18 +63,20 @@ void initialize_buffer(void)
openfile->modified = FALSE;
#ifndef NANO_TINY
openfile->mark_set = FALSE;
openfile->mark_begin = NULL;
openfile->mark_begin_x = 0;
openfile->fmt = NIX_FILE;
openfile->current_stat = NULL;
openfile->undotop = NULL;
openfile->current_undo = NULL;
openfile->last_action = OTHER;
openfile->current_stat = NULL;
openfile->lock_filename = NULL;
#endif
#ifndef DISABLE_COLOR
openfile->syntax = NULL;
openfile->colorstrings = NULL;
#endif
}
@@ -137,19 +131,23 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
myuid = geteuid();
if ((mypwuid = getpwuid(myuid)) == NULL) {
statusbar(_("Couldn't determine my identity for lock file (getpwuid() failed)"));
return -1;
goto free_and_fail;
}
mypid = getpid();
if (gethostname(myhostname, 31) < 0) {
statusbar(_("Couldn't determine hostname for lock file: %s"), strerror(errno));
return -1;
if (errno == ENAMETOOLONG)
myhostname[31] = '\0';
else {
statusbar(_("Couldn't determine hostname for lock file: %s"), strerror(errno));
goto free_and_fail;
}
}
/* Check if the lock exists before we try to delete it...*/
if (stat(lockfilename, &fileinfo) != -1)
if (delete_lockfile(lockfilename) < 0)
return -1;
goto free_and_fail;
if (ISSET(INSECURE_BACKUP))
cflags = O_WRONLY | O_CREAT | O_APPEND;
@@ -164,6 +162,7 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
if (fd < 0) {
statusbar(_("Error writing lock file %s: %s"), lockfilename,
strerror(errno));
free(lockdata);
return 0;
}
@@ -174,7 +173,7 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
if (fd < 0 || filestream == NULL) {
statusbar(_("Error writing lock file %s: %s"), lockfilename,
strerror(errno));
return -1;
goto free_and_fail;
}
/* Okay, so at the moment we're following this state for how to
@@ -211,7 +210,7 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
if (wroteamt < lockdatalen) {
statusbar(_("Error writing lock file %s: %s"),
lockfilename, ferror(filestream));
return -1;
goto free_and_fail;
}
#ifdef DEBUG
@@ -221,12 +220,17 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
if (fclose(filestream) == EOF) {
statusbar(_("Error writing lock file %s: %s"),
lockfilename, strerror(errno));
return -1;
goto free_and_fail;
}
openfile->lock_filename = lockfilename;
openfile->lock_filename = (char *) lockfilename;
free(lockdata);
return 1;
free_and_fail:
free(lockdata);
return -1;
}
/* Less exciting, delete the lockfile. Return -1 if unsuccessful and
@@ -247,18 +251,20 @@ int delete_lockfile(const char *lockfilename)
* complain to the user. */
int do_lockfile(const char *filename)
{
char *lockdir = dirname((char *) mallocstrcpy(NULL, filename));
char *lockbase = basename((char *) mallocstrcpy(NULL, filename));
size_t lockfilesize = strlen(filename) + strlen(locking_prefix)
char *namecopy1 = (char *) mallocstrcpy(NULL, filename);
char *namecopy2 = (char *) mallocstrcpy(NULL, filename);
size_t locknamesize = strlen(filename) + strlen(locking_prefix)
+ strlen(locking_suffix) + 3;
char *lockfilename = charalloc(lockfilesize);
char *lockfilename = charalloc(locknamesize);
char *lockfiledir = NULL;
static char lockprog[11], lockuser[17];
struct stat fileinfo;
int lockfd, lockpid;
snprintf(lockfilename, lockfilesize, "%s/%s%s%s", lockdir,
locking_prefix, lockbase, locking_suffix);
snprintf(lockfilename, locknamesize, "%s/%s%s%s", dirname(namecopy1),
locking_prefix, basename(namecopy2), locking_suffix);
free(namecopy1);
free(namecopy2);
#ifdef DEBUG
fprintf(stderr, "lock file name is %s\n", lockfilename);
#endif
@@ -305,8 +311,10 @@ int do_lockfile(const char *filename)
if (stat(lockfiledir, &fileinfo) == -1) {
statusbar(_("Error writing lock file: Directory \'%s\' doesn't exist"),
lockfiledir);
free(lockfiledir);
return 0;
}
free(lockfiledir);
}
return write_lockfile(lockfilename, filename, FALSE);
@@ -339,8 +347,23 @@ void open_buffer(const char *filename, bool undoable)
}
#endif
/* If we're loading into a new buffer, add a new entry to
* openfile. */
/* When the specified filename is not empty, and the thing exists,
* verify that it is a normal file. */
if (strcmp(filename, "") != 0) {
struct stat fileinfo;
if (stat(filename, &fileinfo) == 0 && !S_ISREG(fileinfo.st_mode)) {
if (S_ISDIR(fileinfo.st_mode))
statusbar(_("\"%s\" is a directory"), filename);
else
statusbar(_("\"%s\" is not a normal file"), filename);
beep();
return;
}
}
/* If we're going to load into a new buffer, first create the new
* buffer and lock the corresponding file. */
if (new_buffer) {
make_new_buffer();
@@ -420,6 +443,9 @@ void replace_buffer(const char *filename)
/* If opening the file succeeded, read it in. */
if (descriptor > 0)
read_file(f, descriptor, filename, FALSE, TRUE);
/* Put current at a place that is certain to exist. */
openfile->current = openfile->fileage;
}
#endif /* !DISABLE_SPELLER */
@@ -541,8 +567,8 @@ int is_file_writable(const char *filename)
/* Get the specified file's full path. */
full_filename = get_full_path(filename);
/* Okay, if we can't stat the path due to a component's
*permissions, just try the relative one. */
/* Okay, if we can't stat the absolute path due to some component's
* permissions, just try the relative one. */
if (full_filename == NULL ||
(stat(full_filename, &fileinfo) == -1 && stat(filename, &fileinfo2) != -1))
full_filename = mallocstrcpy(NULL, filename);
@@ -568,8 +594,7 @@ filestruct *read_line(char *buf, filestruct *prevnode, bool
{
filestruct *fileptr = (filestruct *)nmalloc(sizeof(filestruct));
/* Convert nulls to newlines. buf_len is the string's real
* length. */
/* Convert nulls to newlines. buf_len is the string's real length. */
unsunder(buf, buf_len);
assert(openfile->fileage != NULL && strlen(buf) == buf_len);
@@ -584,31 +609,25 @@ filestruct *read_line(char *buf, filestruct *prevnode, bool
#endif
#ifndef DISABLE_COLOR
fileptr->multidata = NULL;
fileptr->multidata = NULL;
#endif
if (*first_line_ins) {
/* Special case: We're inserting with the cursor on the first
* line. */
/* Special case: we're inserting into the first line. */
fileptr->prev = NULL;
fileptr->next = openfile->fileage;
fileptr->lineno = 1;
if (*first_line_ins) {
*first_line_ins = FALSE;
/* If we're inserting into the first line of the file, then
* we want to make sure that our edit buffer stays on the
* first line and that fileage stays up to date. */
openfile->edittop = fileptr;
} else
openfile->filebot = fileptr;
openfile->fileage = fileptr;
fileptr->lineno = 1;
/* Make sure that our edit window stays on the first line. */
openfile->edittop = fileptr;
*first_line_ins = FALSE;
} else {
assert(prevnode != NULL);
prevnode->next = fileptr;
fileptr->prev = prevnode;
fileptr->next = NULL;
fileptr->lineno = prevnode->lineno + 1;
prevnode->next = fileptr;
}
return fileptr;
@@ -675,7 +694,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
* line otherwise), and file conversion isn't disabled,
* handle it! */
if (!ISSET(NO_CONVERT) && (num_lines == 0 || format != 0) &&
i > 0 && buf[i - 1] == '\r') {
i > 0 && buf[i - 1] == '\r') {
if (format == 0 || format == 2)
format++;
}
@@ -684,8 +703,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
/* Read in the line properly. */
fileptr = read_line(buf, fileptr, &first_line_ins, len);
/* Reset the line length in preparation for the next
* line. */
/* Reset the line length in preparation for the next line. */
len = 0;
num_lines++;
@@ -798,11 +816,10 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
/* Tack the text at fileptr onto the beginning of the text
* at current. */
openfile->current->data =
charealloc(openfile->current->data, len +
current_len + 1);
charmove(openfile->current->data + len,
openfile->current->data, current_len + 1);
openfile->current->data = charealloc(openfile->current->data,
len + current_len + 1);
charmove(openfile->current->data + len, openfile->current->data,
current_len + 1);
strncpy(openfile->current->data, fileptr->data, len);
/* Don't destroy fileage, edittop, or filebot! */
@@ -826,13 +843,11 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
openfile->current->prev = fileptr;
}
/* Renumber starting with the last line of the file we
* inserted. */
/* Renumber, starting with the last line of the file we inserted. */
renumber(openfile->current);
}
openfile->totsize += get_totsize(openfile->fileage,
openfile->filebot);
openfile->totsize += get_totsize(openfile->fileage, openfile->filebot);
/* If the NO_NEWLINES flag isn't set, and text has been added to
* the magicline (i.e. a file that doesn't end in a newline has been
@@ -889,9 +904,14 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
statusbar(P_("Read %lu line", "Read %lu lines",
(unsigned long)num_lines), (unsigned long)num_lines);
else
statusbar(P_("Read %lu line ( Warning: No write permission)",
statusbar(P_("Read %lu line (Warning: No write permission)",
"Read %lu lines (Warning: No write permission)",
(unsigned long)num_lines), (unsigned long)num_lines);
#ifndef NANO_TINY
if (ISSET(MAKE_IT_UNIX))
openfile->fmt = NIX_FILE;
#endif
}
/* Open the file (and decide if it exists). If newfie is TRUE, display
@@ -914,11 +934,10 @@ int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
/* Okay, if we can't stat the path due to a component's
* permissions, just try the relative one. */
if (full_filename == NULL
|| (stat(full_filename, &fileinfo) == -1 && stat(filename, &fileinfo2) != -1))
if (full_filename == NULL || (stat(full_filename, &fileinfo) == -1 &&
stat(filename, &fileinfo2) != -1))
full_filename = mallocstrcpy(NULL, filename);
if (stat(full_filename, &fileinfo) == -1) {
/* Well, maybe we can open the file even if the OS says it's
* not there. */
@@ -938,7 +957,7 @@ int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
beep();
return -1;
} else if (S_ISDIR(fileinfo.st_mode) || S_ISCHR(fileinfo.st_mode) ||
S_ISBLK(fileinfo.st_mode)) {
S_ISBLK(fileinfo.st_mode)) {
/* Don't open directories, character files, or block files.
* Sorry, /dev/sndstat! */
statusbar(S_ISDIR(fileinfo.st_mode) ?
@@ -947,8 +966,7 @@ int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
beep();
return -1;
} else if ((fd = open(full_filename, O_RDONLY)) == -1) {
statusbar(_("Error reading %s: %s"), filename,
strerror(errno));
statusbar(_("Error reading %s: %s"), filename, strerror(errno));
beep();
return -1;
} else {
@@ -956,8 +974,7 @@ int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
*f = fdopen(fd, "rb");
if (*f == NULL) {
statusbar(_("Error reading %s: %s"), filename,
strerror(errno));
statusbar(_("Error reading %s: %s"), filename, strerror(errno));
beep();
close(fd);
} else
@@ -1024,8 +1041,9 @@ void do_insertfile(
char *ans = mallocstrcpy(NULL, "");
/* The last answer the user typed at the statusbar prompt. */
filestruct *edittop_save = openfile->edittop;
size_t current_x_save = openfile->current_x;
ssize_t current_y_save = openfile->current_y;
ssize_t was_current_lineno = openfile->current->lineno;
size_t was_current_x = openfile->current_x;
ssize_t was_current_y = openfile->current_y;
bool edittop_inside = FALSE;
#ifndef NANO_TINY
bool right_side_up = FALSE, single_line = FALSE;
@@ -1082,8 +1100,9 @@ void do_insertfile(
break;
} else {
size_t pww_save = openfile->placewewant;
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
functionptrtype func = func_from_key(&i);
#endif
ans = mallocstrcpy(ans, answer);
#ifndef NANO_TINY
@@ -1118,8 +1137,7 @@ void do_insertfile(
}
#endif
/* If we don't have a file yet, go back to the statusbar
* prompt. */
/* If we don't have a file yet, go back to the statusbar prompt. */
if (i != 0
#ifndef DISABLE_MULTIBUFFER
&& (i != -2 || !ISSET(MULTIBUFFER))
@@ -1148,19 +1166,16 @@ void do_insertfile(
/* If we're not inserting into a new buffer, partition
* the filestruct so that it contains no text and hence
* looks like a new buffer, and keep track of whether
* the top of the edit window is inside the
* partition. */
* the top of the edit window is inside the partition. */
filepart = partition_filestruct(openfile->current,
openfile->current_x, openfile->current,
openfile->current_x);
edittop_inside =
(openfile->edittop == openfile->fileage);
edittop_inside = (openfile->edittop == openfile->fileage);
#ifndef DISABLE_MULTIBUFFER
}
#endif
/* Convert newlines to nulls, just before we insert the file
* or execute the command. */
/* Convert newlines to nulls in the given filename. */
sunder(answer);
align(&answer);
@@ -1184,24 +1199,20 @@ void do_insertfile(
openfile->placewewant = 0;
}
#endif
} else {
} else
#endif /* !NANO_TINY */
{
/* Make sure the path to the file specified in answer is
* tilde-expanded. */
answer = mallocstrassn(answer,
real_dir_from_tilde(answer));
answer = mallocstrassn(answer, real_dir_from_tilde(answer));
/* Save the file specified in answer in the current
* buffer. */
/* Save the file specified in answer in the current buffer. */
open_buffer(answer, TRUE);
#ifndef NANO_TINY
}
#endif
#if !defined(DISABLE_MULTIBUFFER) && !defined(DISABLE_HISTORIES)
if (ISSET(MULTIBUFFER)) {
/* Update the screen to account for the current
* buffer. */
/* Update the screen to account for the current buffer. */
display_buffer();
ssize_t savedposline, savedposcol;
@@ -1212,7 +1223,7 @@ void do_insertfile(
check_poshistory(answer, &savedposline, &savedposcol))
do_gotolinecolumn(savedposline, savedposcol, FALSE, FALSE, FALSE, FALSE);
} else
#endif
#endif /* !DISABLE_MULTIBUFFER && !DISABLE_HISTORIES */
{
filestruct *top_save = openfile->fileage;
@@ -1224,37 +1235,35 @@ void do_insertfile(
/* Update the current x-coordinate to account for the
* number of characters inserted on the current line.
* If the mark begins inside the partition, adjust the
* mark coordinates to compensate for the change in the
* current line. */
* If the mark was positioned after the cursor and on the
* same line, adjust the mark's coordinates to compensate
* for the change in this line. */
openfile->current_x = strlen(openfile->filebot->data);
if (openfile->fileage == openfile->filebot) {
#ifndef NANO_TINY
if (openfile->mark_set) {
openfile->mark_begin = openfile->current;
if (!right_side_up)
openfile->mark_begin_x +=
openfile->current_x;
openfile->mark_begin_x += openfile->current_x;
}
#endif
openfile->current_x += current_x_save;
openfile->current_x += was_current_x;
}
#ifndef NANO_TINY
else if (openfile->mark_set) {
if (!right_side_up) {
if (single_line) {
openfile->mark_begin = openfile->current;
openfile->mark_begin_x -= current_x_save;
openfile->mark_begin_x -= was_current_x;
} else
openfile->mark_begin_x -=
openfile->current_x;
openfile->mark_begin_x -= openfile->current_x;
}
}
#endif
/* Update the current y-coordinate to account for the
* number of lines inserted. */
openfile->current_y += current_y_save;
openfile->current_y += was_current_y;
/* Unpartition the filestruct so that it contains all
* the text again. Note that we've replaced the
@@ -1272,8 +1281,10 @@ void do_insertfile(
/* Restore the old place we want. */
openfile->placewewant = pww_save;
/* Mark the file as modified. */
set_modified();
/* Mark the file as modified if it changed. */
if (openfile->current->lineno != was_current_lineno ||
openfile->current_x != was_current_x)
set_modified();
/* Update the screen. */
edit_refresh();
@@ -1291,7 +1302,7 @@ void do_insertfile(
void do_insertfile_void(void)
{
if (ISSET(RESTRICTED)) {
nano_disabled_msg();
show_restricted_warning();
return;
}
@@ -1357,8 +1368,7 @@ char *get_full_path(const char *origpath)
/* If stat()ing d_there fails, assume that d_there refers to a new
* file that hasn't been saved to disk yet. Set path_only to TRUE
* if d_there refers to a directory, and FALSE otherwise. */
path_only = (stat(d_there, &fileinfo) != -1 &&
S_ISDIR(fileinfo.st_mode));
path_only = (stat(d_there, &fileinfo) != -1 && S_ISDIR(fileinfo.st_mode));
/* If path_only is TRUE, make sure d_there ends in a slash. */
if (path_only) {
@@ -1444,7 +1454,7 @@ char *get_full_path(const char *origpath)
}
/* Return the full version of path, as returned by get_full_path(). On
* error, if path doesn't reference a directory, or if the directory
* error, or if path doesn't reference a directory, or if the directory
* isn't writable, return NULL. */
char *check_writable_directory(const char *path)
{
@@ -1454,10 +1464,9 @@ char *check_writable_directory(const char *path)
if (full_path == NULL)
return NULL;
/* If we can't write to path or path isn't a directory, return
* NULL. */
/* If we can't write to path or path isn't a directory, return NULL. */
if (access(full_path, W_OK) != 0 ||
full_path[strlen(full_path) - 1] != '/') {
full_path[strlen(full_path) - 1] != '/') {
free(full_path);
return NULL;
}
@@ -1703,7 +1712,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
FILE *f = NULL;
/* The actual file, realname, we are writing to. */
char *tempname = NULL;
/* The temp file name we write to on prepend. */
/* The name of the temporary file we write to on prepend. */
assert(name != NULL);
@@ -1759,9 +1768,9 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
* aren't appending, prepending, or writing a selection, we backup
* only if the file has not been modified by someone else since nano
* opened it. */
if (ISSET(BACKUP_FILE) && !tmp && realexists && ((append !=
OVERWRITE || openfile->mark_set) || (openfile->current_stat &&
openfile->current_stat->st_mtime == st.st_mtime))) {
if (ISSET(BACKUP_FILE) && !tmp && realexists && ((append != OVERWRITE ||
openfile->mark_set) || (openfile->current_stat &&
openfile->current_stat->st_mtime == st.st_mtime))) {
int backup_fd;
FILE *backup_file;
char *backupname;
@@ -1892,7 +1901,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
fclose(backup_file);
/* If we can't write to the backup, DONT go on, since
* whatever caused the backup file to fail (e.g. disk
* full may well cause the real file write to fail, which
* full) may well cause the real file write to fail, which
* means we could lose both the backup and the original! */
goto cleanup_and_exit;
}
@@ -1934,7 +1943,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
* doing prepend or append. So we delete the link first, and just
* overwrite. */
if (ISSET(NOFOLLOW_SYMLINKS) && anyexists && S_ISLNK(lst.st_mode) &&
unlink(realname) == -1) {
unlink(realname) == -1) {
statusbar(_("Error writing %s: %s"), realname, strerror(errno));
goto cleanup_and_exit;
}
@@ -1991,7 +2000,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
}
}
if (copy_file(f_source, f) != 0) {
if (f_source == NULL || copy_file(f_source, f) != 0) {
statusbar(_("Error writing %s: %s"), tempname,
strerror(errno));
unlink(tempname);
@@ -2062,8 +2071,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
lineswritten--;
} else {
#ifndef NANO_TINY
if (openfile->fmt == DOS_FILE || openfile->fmt ==
MAC_FILE) {
if (openfile->fmt == DOS_FILE || openfile->fmt == MAC_FILE) {
if (putc('\r', f) == EOF) {
statusbar(_("Error writing %s: %s"), realname,
strerror(errno));
@@ -2072,7 +2080,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
}
}
if (openfile->fmt != MAC_FILE) {
if (openfile->fmt != MAC_FILE)
#endif
if (putc('\n', f) == EOF) {
statusbar(_("Error writing %s: %s"), realname,
@@ -2080,9 +2088,6 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
fclose(f);
goto cleanup_and_exit;
}
#ifndef NANO_TINY
}
#endif
}
fileptr = fileptr->next;
@@ -2110,11 +2115,13 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
goto cleanup_and_exit;
}
if (copy_file(f_source, f) == -1 || unlink(tempname) == -1) {
if (copy_file(f_source, f) == -1) {
statusbar(_("Error writing %s: %s"), realname,
strerror(errno));
goto cleanup_and_exit;
}
unlink(tempname);
} else if (fclose(f) != 0) {
statusbar(_("Error writing %s: %s"), realname,
strerror(errno));
@@ -2134,8 +2141,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
/* If color syntaxes are available and turned on, we need to
* call edit_refresh(). */
if (openfile->colorstrings != NULL &&
!ISSET(NO_COLOR_SYNTAX))
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX))
edit_refresh();
#endif
}
@@ -2192,7 +2198,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
* end of the file. Otherwise, add a magicline and treat it as the
* end of the file. */
if (!ISSET(NO_NEWLINES) &&
(added_magicline = (openfile->filebot->data[0] != '\0')))
(added_magicline = (openfile->filebot->data[0] != '\0')))
new_magicline();
retval = write_file(name, f_open, tmp, append, TRUE);
@@ -2230,7 +2236,7 @@ bool do_writeout(bool exiting)
#endif
bool retval = FALSE;
if (exiting && openfile->filename[0] != '\0' && ISSET(TEMP_FILE)) {
if (openfile->filename[0] != '\0' && ISSET(TEMP_FILE)) {
retval = write_file(openfile->filename, NULL, FALSE, OVERWRITE,
FALSE);
@@ -2250,9 +2256,8 @@ bool do_writeout(bool exiting)
#ifndef NANO_TINY
const char *formatstr, *backupstr;
formatstr = (openfile->fmt == DOS_FILE) ?
_(" [DOS Format]") : (openfile->fmt == MAC_FILE) ?
_(" [Mac Format]") : "";
formatstr = (openfile->fmt == DOS_FILE) ? _(" [DOS Format]") :
(openfile->fmt == MAC_FILE) ? _(" [Mac Format]") : "";
backupstr = ISSET(BACKUP_FILE) ? _(" [Backup]") : "";
@@ -2261,15 +2266,22 @@ bool do_writeout(bool exiting)
* it allows reading from or writing to files not specified on
* the command line. */
if (!ISSET(RESTRICTED) && !exiting && openfile->mark_set)
msg = (append == PREPEND) ?
_("Prepend Selection to File") : (append == APPEND) ?
_("Append Selection to File") :
_("Write Selection to File");
msg = (append == PREPEND) ? _("Prepend Selection to File") :
(append == APPEND) ? _("Append Selection to File") :
_("Write Selection to File");
else
#endif /* !NANO_TINY */
msg = (append == PREPEND) ? _("File Name to Prepend to") :
(append == APPEND) ? _("File Name to Append to") :
_("File Name to Write");
(append == APPEND) ? _("File Name to Append to") :
_("File Name to Write");
/* If we're not exiting, and the TEMP_FILE flag is set, and
* the current file doesn't have a name, warn the user before
* prompting for a name. If we are exiting, we've already
* warned the user just before the "Save modified buffer"
* prompt, so we don't need to do it again. */
if (!exiting && openfile->filename[0] == '\0' && ISSET(TEMP_FILE))
no_current_file_name_warning();
/* If we're using restricted mode, the filename isn't blank,
* and we're at the "Write File" prompt, disable tab
@@ -2350,7 +2362,7 @@ bool do_writeout(bool exiting)
* this is the first time we've done this, show an Easter
* egg. Display the credits. */
if (!did_credits && exiting && !ISSET(TEMP_FILE) &&
strcasecmp(answer, "zzy") == 0) {
strcasecmp(answer, "zzy") == 0) {
do_credits();
did_credits = TRUE;
retval = FALSE;
@@ -2429,8 +2441,7 @@ bool do_writeout(bool exiting)
}
/* Convert newlines to nulls, just before we save the
* file. */
/* Convert newlines to nulls, just before we save the file. */
sunder(answer);
align(&answer);
@@ -2462,6 +2473,17 @@ void do_writeout_void(void)
display_main_list();
}
#ifndef NANO_TINY
/* If it has a name, write the current file to disk without prompting. */
void do_savefile(void)
{
if (openfile->filename[0] != '\0')
write_file(openfile->filename, NULL, FALSE, OVERWRITE, FALSE);
else
do_writeout_void();
}
#endif
/* Return a malloc()ed string containing the actual directory, used to
* convert ~user/ and ~/ notation. */
char *real_dir_from_tilde(const char *buf)
@@ -2534,7 +2556,8 @@ int diralphasort(const void *va, const void *vb)
* elements. */
void free_chararray(char **array, size_t len)
{
assert(array != NULL);
if (array == NULL)
return;
for (; len > 0; len--)
free(array[len - 1]);
@@ -2554,8 +2577,7 @@ bool is_dir(const char *buf)
dirptr = real_dir_from_tilde(buf);
retval = (stat(dirptr, &fileinfo) != -1 &&
S_ISDIR(fileinfo.st_mode));
retval = (stat(dirptr, &fileinfo) != -1 && S_ISDIR(fileinfo.st_mode));
free(dirptr);
@@ -2671,8 +2693,8 @@ char **cwd_tab_completion(const char *buf, bool allow_files, size_t
#endif
/* See if this matches. */
if (strncmp(nextdir->d_name, filename, filenamelen) == 0 &&
(*filename == '.' || (strcmp(nextdir->d_name, ".") !=
0 && strcmp(nextdir->d_name, "..") != 0))) {
(*filename == '.' || (strcmp(nextdir->d_name, ".") != 0 &&
strcmp(nextdir->d_name, "..") != 0))) {
/* Cool, found a match. Add it to the list. This makes a
* lot more sense to me (Chris) this way... */
@@ -2720,7 +2742,8 @@ char *input_tab(char *buf, bool allow_files, size_t *place, bool
size_t num_matches = 0, buf_len;
char **matches = NULL;
assert(buf != NULL && place != NULL && *place <= strlen(buf) && lastwastab != NULL && refresh_func != NULL && list != NULL);
assert(buf != NULL && place != NULL && *place <= strlen(buf) &&
lastwastab != NULL && refresh_func != NULL && list != NULL);
*list = FALSE;
@@ -2736,8 +2759,7 @@ char *input_tab(char *buf, bool allow_files, size_t *place, bool
/* Match against files relative to the current working directory. */
if (matches == NULL)
matches = cwd_tab_completion(buf, allow_files, &num_matches,
*place);
matches = cwd_tab_completion(buf, allow_files, &num_matches, *place);
buf_len = strlen(buf);
@@ -2955,6 +2977,7 @@ void history_error(const char *msg, ...)
* successfully created, and return 0 otherwise. */
int check_dotnano(void)
{
int ret = 1;
struct stat dirstat;
char *nanodir = construct_filename("/.nano");
@@ -2963,15 +2986,17 @@ int check_dotnano(void)
history_error(N_("Unable to create directory %s: %s\n"
"It is required for saving/loading search history or cursor positions.\n"),
nanodir, strerror(errno));
return 0;
ret = 0;
}
} else if (!S_ISDIR(dirstat.st_mode)) {
history_error(N_("Path %s is not a directory and needs to be.\n"
"Nano will be unable to load or save search history or cursor positions.\n"),
nanodir);
return 0;
ret = 0;
}
return 1;
free(nanodir);
return ret;
}
/* Load the search and replace histories from ~/.nano/search_history. */
@@ -3026,8 +3051,6 @@ void load_history(void)
fclose(hist);
free(line);
if (search_history->prev != NULL)
last_search = mallocstrcpy(NULL, search_history->prev->data);
}
free(nanohist);
free(legacyhist);
@@ -3063,7 +3086,7 @@ void save_history(void)
/* Don't save unchanged or empty histories. */
if (!history_has_changed() || (searchbot->lineno == 1 &&
replacebot->lineno == 1))
replacebot->lineno == 1))
return;
nanohist = histfilename();
@@ -3079,8 +3102,7 @@ void save_history(void)
* history file. */
chmod(nanohist, S_IRUSR | S_IWUSR);
if (!writehist(hist, searchage) || !writehist(hist,
replaceage))
if (!writehist(hist, searchage) || !writehist(hist, replaceage))
history_error(N_("Error writing %s: %s"), nanohist,
strerror(errno));
@@ -3140,6 +3162,7 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
if (!strcmp(posptr->filename, fullpath)) {
posptr->lineno = lineno;
posptr->xno = xpos;
free(fullpath);
return;
}
posprev = posptr;

View File

@@ -41,6 +41,11 @@ bool func_key;
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;
/* The column where we will wrap lines. */
@@ -89,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
@@ -221,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;
@@ -311,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. */
@@ -325,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
}
@@ -354,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
@@ -471,22 +471,19 @@ 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 ten 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");
@@ -494,11 +491,15 @@ void shortcut_init(void)
const char *next_line_tag = N_("Next Line");
const char *prev_page_tag = N_("Prev Page");
const char *next_page_tag = N_("Next Page");
const char *read_file_tag = N_("Read File");
#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 =
@@ -679,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);
@@ -725,24 +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_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);
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,
@@ -874,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,
@@ -888,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
@@ -908,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),
@@ -921,19 +955,16 @@ 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(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,
@@ -1168,23 +1199,31 @@ void shortcut_init(void)
#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);
@@ -1296,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"))
@@ -1304,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;
@@ -1356,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"))
@@ -1402,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"))
@@ -1610,6 +1661,8 @@ void thanks_for_all_the_fish(void)
syntaxtype *bill = syntaxes;
free(syntaxes->desc);
free(syntaxes->linter);
free(syntaxes->formatter);
while (syntaxes->extensions != NULL) {
regexlisttype *bob = syntaxes->extensions;
syntaxes->extensions = bob->next;

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);
@@ -75,9 +78,9 @@ void do_help(void (*refresh_func)(void))
while (TRUE) {
size_t i;
/* Get the last line of the help text. */
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')
@@ -87,21 +90,20 @@ void do_help(void (*refresh_func)(void))
if (last_line > 0)
last_line--;
/* Display the help text if we don't have a key, or if the help
* text has moved. */
if (kbinput == ERR || line != old_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);
@@ -122,7 +124,7 @@ void do_help(void (*refresh_func)(void))
if (kbinput == KEY_WINCH) {
kbinput = ERR;
curs_set(0);
continue;
continue; /* Redraw the screen. */
}
#endif
@@ -158,7 +160,7 @@ 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;
}
}
@@ -173,35 +175,35 @@ void do_help(void (*refresh_func)(void))
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. */
@@ -368,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.
@@ -385,10 +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. */
free(help_text);
/* Allocate space for the help text. */
help_text = charalloc(allocsize + 1);
@@ -401,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) {
@@ -444,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);
}
@@ -482,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
@@ -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;
}
}

View File

@@ -94,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);
@@ -116,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. */
@@ -384,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
@@ -451,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
@@ -517,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. */
@@ -569,6 +553,7 @@ void delete_opennode(openfilestruct *fileptr)
free_filestruct(fileptr->fileage);
#ifndef NANO_TINY
free(fileptr->current_stat);
free(fileptr->lock_filename);
#endif
free(fileptr);
}
@@ -592,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();
@@ -841,27 +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"));
#ifndef NANO_TINY
print_opt("-E", "--tabstospaces", N_("Convert typed tabs to spaces"));
#endif
#ifndef DISABLE_MULTIBUFFER
print_opt("-F", "--multibuffer",
N_("Read a file into a new buffer by default"));
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"));
#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"));
@@ -873,12 +876,15 @@ 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"));
#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"));
#endif
@@ -893,13 +899,14 @@ void usage(void)
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("-k", "--cut", N_("Cut from cursor to end of line"));
@@ -915,24 +922,30 @@ void usage(void)
#endif
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("-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
@@ -1073,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
@@ -1100,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) ? "));
@@ -1266,11 +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();
@@ -1302,6 +1311,10 @@ void do_suspend_void(void)
{
if (ISSET(SUSPEND))
do_suspend(0);
else {
statusbar(_("Suspension is not enabled"));
beep();
}
}
/* Handler for SIGCONT (continue after suspend). */
@@ -1395,12 +1408,13 @@ void regenerate_screen(void)
total_refresh();
}
/* 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);
@@ -1412,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);
@@ -1430,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
@@ -1456,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 */
@@ -1833,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
@@ -1893,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
@@ -1927,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
@@ -1939,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
@@ -1987,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;
}
@@ -2006,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;
@@ -2038,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
@@ -2056,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
@@ -2094,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;
@@ -2122,7 +2141,7 @@ 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'},
@@ -2156,12 +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'},
{"wordbounds", 0, NULL, 'W'},
{"autoindent", 0, NULL, 'i'},
{"cut", 0, NULL, 'k'},
{"unix", 0, NULL, 'u'},
{"softwrap", 0, NULL, '$'},
#endif
{NULL, 0, NULL, 0}
@@ -2201,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) {
@@ -2359,6 +2380,7 @@ int main(int argc, char **argv)
exit(1);
}
fill_used = TRUE;
forced_wrapping = TRUE;
break;
#endif
#ifndef DISABLE_SPELLER
@@ -2369,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;
@@ -2377,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':
@@ -2511,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
@@ -2609,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
@@ -2628,7 +2654,6 @@ int main(int argc, char **argv)
whitespace_len[1] = 1;
}
}
#endif /* !DISABLE_NANORC */
#endif /* !NANO_TINY */
/* Initialize the search and replace strings. */
@@ -2681,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
@@ -2710,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. */
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
}
@@ -2739,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);
@@ -2769,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);
}

View File

@@ -329,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. */
@@ -361,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;
@@ -445,35 +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. */
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;
@@ -528,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. */
@@ -548,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
@@ -557,10 +548,9 @@ 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
/* An imaginary key for when we get a SIGWINCH (window resize). */

View File

@@ -145,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);
@@ -186,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;
}
}
@@ -809,7 +809,7 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs,
func = func_from_key(&kbinput);
if (func == do_cancel || func == do_enter_void)
if (func == do_cancel || func == do_enter)
break;
#ifndef DISABLE_TABCOMP
@@ -927,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;
@@ -1010,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();

View File

@@ -35,6 +35,11 @@ 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;
extern ssize_t wrap_at;
@@ -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
@@ -260,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
@@ -274,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
@@ -321,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);
@@ -371,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);
@@ -392,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);
@@ -425,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);
@@ -447,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
@@ -469,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);
@@ -588,6 +598,10 @@ bool findnextstr(
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
@@ -636,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);
@@ -644,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);
@@ -734,6 +751,7 @@ 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 discard_until(undo *thisone);
void add_undo(undo_type action);
void update_undo(undo_type action);
#endif

View File

@@ -38,7 +38,8 @@ 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
@@ -62,7 +63,8 @@ static const rcoption rcopts[] = {
{"operatingdir", 0},
#endif
#ifndef DISABLE_HISTORIES
{"poslog", POS_HISTORY},
{"poslog", POS_HISTORY}, /* deprecated form, remove in 2018 */
{"positionlog", POS_HISTORY},
#endif
{"preserve", PRESERVE},
#ifndef DISABLE_JUSTIFY
@@ -98,6 +100,7 @@ static const rcoption rcopts[] = {
{"smooth", SMOOTH_SCROLL},
{"softwrap", SOFTWRAP},
{"tabstospaces", TABS_TO_SPACES},
{"unix", MAKE_IT_UNIX},
{"whitespace", 0},
{"wordbounds", WORD_BOUNDS},
#endif
@@ -442,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. */
@@ -453,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;
}
}
@@ -463,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) {
@@ -472,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;
}
}
@@ -482,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
@@ -529,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
@@ -544,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);
}

View File

@@ -474,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)
@@ -522,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. */
@@ -544,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;
@@ -552,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. */
@@ -567,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
@@ -593,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);
@@ -604,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;
}
@@ -726,14 +747,12 @@ ssize_t do_replace_loop(
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;
@@ -741,11 +760,10 @@ ssize_t do_replace_loop(
}
}
/* 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)
@@ -757,6 +775,12 @@ ssize_t do_replace_loop(
#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
* text, so searching will resume after the replacement
* text. Note that current_x might be set to (size_t)-1
@@ -766,9 +790,8 @@ 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;
@@ -1123,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;
}
@@ -1284,7 +1307,6 @@ void update_history(filestruct **h, const char *s)
foo = p;
bar = p->next;
unlink_node(foo);
delete_node(foo);
renumber(bar);
}
@@ -1296,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

@@ -404,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)
@@ -424,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

View File

@@ -40,8 +40,12 @@ static int statusblank = 0;
static bool disable_cursorpos = FALSE;
/* Should we temporarily disable constant cursor position
* display? */
static bool seen_wide = FALSE;
/* Whether we've seen a multicolumn character in the current line. */
#ifndef NANO_TINY
static sig_atomic_t sigwinch_counter_save = 0;
#endif
/* Control character compatibility:
*
@@ -563,7 +567,7 @@ int parse_kbinput(WINDOW *win)
retval = sc_seq_or(do_page_up, *kbinput);
break;
case KEY_ENTER:
retval = sc_seq_or(do_enter_void, *kbinput);
retval = sc_seq_or(do_enter, *kbinput);
break;
case KEY_B2: /* Center (5) on numeric keypad with
* NumLock off. */
@@ -632,16 +636,6 @@ int parse_kbinput(WINDOW *win)
retval = ERR;
break;
#endif
case CONTROL_LEFT:
#ifndef NANO_TINY
retval = sc_seq_or(do_prev_word_void, 0);
#endif
break;
case CONTROL_RIGHT:
#ifndef NANO_TINY
retval = sc_seq_or(do_next_word_void, 0);
#endif
break;
#ifndef NANO_TINY
case KEY_WINCH:
retval = KEY_WINCH;
@@ -649,6 +643,13 @@ int parse_kbinput(WINDOW *win)
#endif
}
#ifndef NANO_TINY
if (retval == controlleft)
retval = sc_seq_or(do_prev_word_void, 0);
else if (retval == controlright)
retval = sc_seq_or(do_next_word_void, 0);
#endif
/* If our result is an extended keypad value (i.e. a value
* outside of byte range), set func_key to TRUE. */
if (retval != ERR)
@@ -1682,10 +1683,6 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
for (f = allfuncs; f != NULL; f = f->next) {
if ((f->menus & currmenu) == 0)
continue;
#ifndef DISABLE_HELP
if (!f->help || strlen(f->help) == 0)
continue;
#endif
if (first_sc_for(currmenu, f->scfunc) == NULL)
continue;
/* Tick off an actually shown shortcut. */
@@ -1758,11 +1755,11 @@ const sc *get_shortcut(int *kbinput)
#endif
for (s = sclist; s != NULL; s = s->next) {
if ((currmenu & s->menu) && *kbinput == s->seq
if ((s->menus & currmenu) && *kbinput == s->seq
&& meta_key == (s->type == META)) {
#ifdef DEBUG
fprintf (stderr, "matched seq \"%s\", and btw meta was %d (menu is %x from %x)\n",
s->keystr, meta_key, currmenu, s->menu);
s->keystr, meta_key, currmenu, s->menus);
#endif
return s;
}
@@ -1896,6 +1893,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
converted = charalloc(alloc_len);
index = 0;
seen_wide = FALSE;
if (buf[start_index] != '\0' && buf[start_index] != '\t' &&
(column < start_col || (dollars && column > 0))) {
@@ -1939,6 +1937,9 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
while (buf[start_index] != '\0') {
buf_mb_len = parse_mbchar(buf + start_index, buf_mb, NULL);
if (mbwidth(buf + start_index) > 1)
seen_wide = TRUE;
/* Make sure there's enough room for the next character, whether
* it's a multibyte control character, a non-control multibyte
* character, a tab character, or a null terminator. */
@@ -1949,7 +1950,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
/* If buf contains a tab character, interpret it. */
if (*buf_mb == '\t') {
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
#ifndef NANO_TINY
if (ISSET(WHITESPACE_DISPLAY)) {
int i;
@@ -1982,7 +1983,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
free(ctrl_buf_mb);
/* If buf contains a space character, interpret it. */
} else if (*buf_mb == ' ') {
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
#ifndef NANO_TINY
if (ISSET(WHITESPACE_DISPLAY)) {
int i;
@@ -1999,10 +2000,13 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
char *nctrl_buf_mb = charalloc(mb_cur_max());
int nctrl_buf_mb_len, i;
#ifdef ENABLE_UTF8
/* Make sure an invalid sequence-starter byte is properly
* terminated, so that it doesn't pick up lingering bytes
* of any previous content. */
null_at(&buf_mb, buf_mb_len);
if (using_utf8() && buf_mb_len == 1)
buf_mb[1] = '\0';
#endif
nctrl_buf_mb = mbrep(buf_mb, nctrl_buf_mb,
&nctrl_buf_mb_len);
@@ -2237,8 +2241,10 @@ void statusbar(const char *msg, ...)
va_list ap;
char *bar, *foo;
size_t start_x;
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
bool old_whitespace;
#ifndef NANO_TINY
bool old_whitespace = ISSET(WHITESPACE_DISPLAY);
UNSET(WHITESPACE_DISPLAY);
#endif
va_start(ap, msg);
@@ -2253,16 +2259,13 @@ void statusbar(const char *msg, ...)
blank_statusbar();
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
old_whitespace = ISSET(WHITESPACE_DISPLAY);
UNSET(WHITESPACE_DISPLAY);
#endif
bar = charalloc(mb_cur_max() * (COLS - 3));
vsnprintf(bar, mb_cur_max() * (COLS - 3), msg, ap);
va_end(ap);
foo = display_string(bar, 0, COLS - 4, FALSE);
free(bar);
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
#ifndef NANO_TINY
if (old_whitespace)
SET(WHITESPACE_DISPLAY);
#endif
@@ -2297,8 +2300,8 @@ void statusbar(const char *msg, ...)
26;
}
/* Display the shortcut list in s on the last two rows of the bottom
* portion of the window. */
/* Display the shortcut list corresponding to menu on the last two rows
* of the bottom portion of the window. */
void bottombars(int menu)
{
size_t i, colwidth, slen;
@@ -2470,7 +2473,8 @@ void edit_draw(filestruct *fileptr, const char *converted, int
/* Tell ncurses to really redraw the line without trying to optimize
* for what it thinks is already there, because it gets it wrong in
* the case of a wide character in column zero. See bug #31743. */
wredrawln(edit, line, 1);
if (seen_wide)
wredrawln(edit, line, 1);
#endif
#ifndef DISABLE_COLOR
@@ -2479,16 +2483,10 @@ void edit_draw(filestruct *fileptr, const char *converted, int
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX)) {
const colortype *tmpcolor = openfile->colorstrings;
/* Set up multi-line color data for this line if it's not yet
* calculated. */
if (fileptr->multidata == NULL && openfile->syntax
&& openfile->syntax->nmultis > 0) {
int i;
fileptr->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short));
for (i = 0; i < openfile->syntax->nmultis; i++)
/* Assume this applies until we know otherwise. */
fileptr->multidata[i] = -1;
}
/* If there are multiline regexes, make sure there is a cache. */
if (openfile->syntax->nmultis > 0)
alloc_multidata_if_needed(fileptr);
for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) {
int x_start;
/* Starting column for mvwaddnstr. Zero-based. */
@@ -2554,211 +2552,210 @@ void edit_draw(filestruct *fileptr, const char *converted, int
}
k = startmatch.rm_eo;
}
} else if (fileptr->multidata != NULL && fileptr->multidata[tmpcolor->id] != CNONE) {
/* This is a multi-line regex. There are two steps.
* First, we have to see if the beginning of the line is
* colored by a start on an earlier line, and an end on
* this line or later.
*
* We find the first line before fileptr matching the
* start. If every match on that line is followed by an
* end, then go to step two. Otherwise, find the next
* line after start_line matching the end. If that line
* is not before fileptr, then paint the beginning of
* this line. */
} else { /* This is a multiline expression. */
const filestruct *start_line = fileptr->prev;
/* The first line before fileptr matching start. */
/* The first line before fileptr that matches 'start'. */
regoff_t start_col;
/* Where it starts in that line. */
/* Where the match starts in that line. */
const filestruct *end_line;
short md = fileptr->multidata[tmpcolor->id];
/* The line that matches 'end'. */
if (md == -1)
/* Assume this until we know otherwise. */
fileptr->multidata[tmpcolor->id] = CNONE;
else if (md == CNONE)
goto end_of_loop;
else if (md == CWHOLELINE) {
/* First see if the multidata was maybe already calculated. */
if (fileptr->multidata[tmpcolor->id] == CNONE)
goto tail_of_loop;
else if (fileptr->multidata[tmpcolor->id] == CWHOLELINE) {
mvwaddnstr(edit, line, 0, converted, -1);
goto end_of_loop;
} else if (md == CBEGINBEFORE) {
goto tail_of_loop;
} else if (fileptr->multidata[tmpcolor->id] == CBEGINBEFORE) {
regexec(tmpcolor->end, fileptr->data, 1, &endmatch, 0);
/* If the coloured part is scrolled off, skip it. */
if (endmatch.rm_eo <= startpos)
goto tail_of_loop;
paintlen = actual_x(converted, strnlenpt(fileptr->data,
endmatch.rm_eo) - start);
mvwaddnstr(edit, line, 0, converted, paintlen);
goto end_of_loop;
}
goto tail_of_loop;
} if (fileptr->multidata[tmpcolor->id] == -1)
/* Assume this until proven otherwise below. */
fileptr->multidata[tmpcolor->id] = CNONE;
/* There is no precalculated multidata, so find it out now.
* First check if the beginning of the line is colored by a
* start on an earlier line, and an end on this line or later.
*
* So: find the first line before fileptr matching the start.
* If every match on that line is followed by an end, then go
* to step two. Otherwise, find a line after start_line that
* matches the end. If that line is not before fileptr, then
* paint the beginning of this line. */
while (start_line != NULL && regexec(tmpcolor->start,
start_line->data, 1, &startmatch, 0) ==
REG_NOMATCH) {
/* If there is an end on this line, there is no need
* to look for starts on earlier lines. */
if (regexec(tmpcolor->end, start_line->data, 0,
NULL, 0) == 0)
start_line->data, 1, &startmatch, 0) == REG_NOMATCH) {
/* There is no start; but if there is an end on this line,
* there is no need to look for starts on earlier lines. */
if (regexec(tmpcolor->end, start_line->data, 0, NULL, 0) == 0)
goto step_two;
start_line = start_line->prev;
}
/* If the found start has been qualified as an end earlier,
/* If no start was found, skip to the next step. */
if (start_line == NULL)
goto step_two;
/* If a found start has been qualified as an end earlier,
* believe it and skip to the next step. */
if (start_line != NULL && start_line->multidata != NULL &&
start_line->multidata[tmpcolor->id] == CBEGINBEFORE)
if (start_line->multidata != NULL &&
(start_line->multidata[tmpcolor->id] == CBEGINBEFORE ||
start_line->multidata[tmpcolor->id] == CSTARTENDHERE))
goto step_two;
/* Skip over a zero-length regex match. */
if (startmatch.rm_so == startmatch.rm_eo)
startmatch.rm_eo++;
else {
/* No start found, so skip to the next step. */
if (start_line == NULL)
goto step_two;
/* Now start_line is the first line before fileptr
* containing a start match. Is there a start on
* this line not followed by an end on this line? */
start_col = 0;
while (TRUE) {
start_col += startmatch.rm_so;
startmatch.rm_eo -= startmatch.rm_so;
if (regexec(tmpcolor->end, start_line->data +
goto tail_of_loop;
/* Now start_line is the first line before fileptr containing
* a start match. Is there a start on that line not followed
* by an end on that line? */
start_col = 0;
while (TRUE) {
start_col += startmatch.rm_so;
startmatch.rm_eo -= startmatch.rm_so;
if (regexec(tmpcolor->end, start_line->data +
start_col + startmatch.rm_eo, 0, NULL,
(start_col + startmatch.rm_eo == 0) ?
0 : REG_NOTBOL) == REG_NOMATCH)
/* No end found after this start. */
break;
start_col++;
if (regexec(tmpcolor->start, start_line->data +
/* No end found after this start. */
break;
start_col++;
if (regexec(tmpcolor->start, start_line->data +
start_col, 1, &startmatch,
REG_NOTBOL) == REG_NOMATCH)
/* No later start on this line. */
goto step_two;
}
/* Indeed, there is a start not followed on this
* line by an end. */
/* We have already checked that there is no end
* before fileptr and after the start. Is there an
* end after the start at all? We don't paint
* unterminated starts. */
end_line = fileptr;
while (end_line != NULL && regexec(tmpcolor->end,
end_line->data, 1, &endmatch, 0) == REG_NOMATCH)
end_line = end_line->next;
/* No end found, or it is too early. */
if (end_line == NULL || (end_line == fileptr &&
endmatch.rm_eo <= startpos))
/* No later start on this line. */
goto step_two;
}
/* Indeed, there is a start without an end on that line. */
/* Now paint the start of fileptr. If the start of
* fileptr is on a different line from the end,
* paintlen is -1, meaning that everything on the
* line gets painted. Otherwise, paintlen is the
* expanded location of the end of the match minus
* the expanded location of the beginning of the
* page. */
if (end_line != fileptr) {
paintlen = -1;
fileptr->multidata[tmpcolor->id] = CWHOLELINE;
/* We've already checked that there is no end before fileptr
* and after the start. But is there an end after the start
* at all? We don't paint unterminated starts. */
end_line = fileptr;
while (end_line != NULL && regexec(tmpcolor->end,
end_line->data, 1, &endmatch, 0) == REG_NOMATCH)
end_line = end_line->next;
/* If no end was found, or it is too early, next step. */
if (end_line == NULL)
goto step_two;
if (end_line == fileptr && endmatch.rm_eo <= startpos) {
fileptr->multidata[tmpcolor->id] = CBEGINBEFORE;
goto step_two;
}
/* Now paint the start of fileptr. If the start of fileptr
* is on a different line from the end, paintlen is -1, which
* means that everything on the line gets painted. Otherwise,
* paintlen is the expanded location of the end of the match
* minus the expanded location of the beginning of the page. */
if (end_line != fileptr) {
paintlen = -1;
fileptr->multidata[tmpcolor->id] = CWHOLELINE;
#ifdef DEBUG
fprintf(stderr, " Marking for id %i line %i as CWHOLELINE\n", tmpcolor->id, line);
#endif
} else {
paintlen = actual_x(converted,
strnlenpt(fileptr->data,
endmatch.rm_eo) - start);
fileptr->multidata[tmpcolor->id] = CBEGINBEFORE;
} else {
paintlen = actual_x(converted, strnlenpt(fileptr->data,
endmatch.rm_eo) - start);
fileptr->multidata[tmpcolor->id] = CBEGINBEFORE;
#ifdef DEBUG
fprintf(stderr, " Marking for id %i line %i as CBEGINBEFORE\n", tmpcolor->id, line);
#endif
}
mvwaddnstr(edit, line, 0, converted, paintlen);
/* If the whole line has been painted, don't bother
* looking for any more starts. */
if (paintlen < 0)
goto end_of_loop;
}
mvwaddnstr(edit, line, 0, converted, paintlen);
/* If the whole line has been painted, don't bother looking
* for any more starts. */
if (paintlen < 0)
goto tail_of_loop;
step_two:
/* Second step, we look for starts on this line. */
start_col = 0;
/* Second step: look for starts on this line, but start
* looking only after an end match, if there is one. */
start_col = (paintlen == 0) ? 0 : endmatch.rm_eo;
while (start_col < endpos) {
if (regexec(tmpcolor->start, fileptr->data +
start_col, 1, &startmatch, (start_col ==
0) ? 0 : REG_NOTBOL) == REG_NOMATCH ||
while (start_col < endpos) {
if (regexec(tmpcolor->start, fileptr->data + start_col,
1, &startmatch, (start_col == 0) ?
0 : REG_NOTBOL) == REG_NOMATCH ||
start_col + startmatch.rm_so >= endpos)
/* No more starts on this line. */
break;
/* Translate the match to be relative to the
* beginning of the line. */
startmatch.rm_so += start_col;
startmatch.rm_eo += start_col;
/* No more starts on this line. */
break;
x_start = (startmatch.rm_so <= startpos) ? 0 :
strnlenpt(fileptr->data,
/* Translate the match to be relative to the
* beginning of the line. */
startmatch.rm_so += start_col;
startmatch.rm_eo += start_col;
x_start = (startmatch.rm_so <= startpos) ?
0 : strnlenpt(fileptr->data,
startmatch.rm_so) - start;
index = actual_x(converted, x_start);
index = actual_x(converted, x_start);
if (regexec(tmpcolor->end, fileptr->data +
if (regexec(tmpcolor->end, fileptr->data +
startmatch.rm_eo, 1, &endmatch,
(startmatch.rm_eo == 0) ? 0 :
REG_NOTBOL) == 0) {
/* Translate the end match to be relative to
* the beginning of the line. */
endmatch.rm_so += startmatch.rm_eo;
endmatch.rm_eo += startmatch.rm_eo;
/* There is an end on this line. But does
* it appear on this page, and is the match
* more than zero characters long? */
if (endmatch.rm_eo > startpos &&
(startmatch.rm_eo == 0) ?
0 : REG_NOTBOL) == 0) {
/* Translate the end match to be relative to
* the beginning of the line. */
endmatch.rm_so += startmatch.rm_eo;
endmatch.rm_eo += startmatch.rm_eo;
/* There is an end on this line. But does
* it appear on this page, and is the match
* more than zero characters long? */
if (endmatch.rm_eo > startpos &&
endmatch.rm_eo > startmatch.rm_so) {
paintlen = actual_x(converted + index,
paintlen = actual_x(converted + index,
strnlenpt(fileptr->data,
endmatch.rm_eo) - start -
x_start);
endmatch.rm_eo) - start - x_start);
assert(0 <= x_start && x_start < COLS);
assert(0 <= x_start && x_start < COLS);
mvwaddnstr(edit, line, x_start,
mvwaddnstr(edit, line, x_start,
converted + index, paintlen);
if (paintlen > 0) {
fileptr->multidata[tmpcolor->id] = CSTARTENDHERE;
if (paintlen > 0) {
fileptr->multidata[tmpcolor->id] = CSTARTENDHERE;
#ifdef DEBUG
fprintf(stderr, " Marking for id %i line %i as CSTARTENDHERE\n", tmpcolor->id, line);
#endif
}
}
} else {
/* There is no end on this line. But we
* haven't yet looked for one on later
* lines. */
end_line = fileptr->next;
}
start_col = endmatch.rm_eo;
} else {
/* There is no end on this line. But we haven't yet
* looked for one on later lines. */
end_line = fileptr->next;
while (end_line != NULL &&
while (end_line != NULL &&
regexec(tmpcolor->end, end_line->data,
0, NULL, 0) == REG_NOMATCH)
end_line = end_line->next;
end_line = end_line->next;
if (end_line != NULL) {
assert(0 <= x_start && x_start < COLS);
if (end_line != NULL) {
assert(0 <= x_start && x_start < COLS);
mvwaddnstr(edit, line, x_start,
mvwaddnstr(edit, line, x_start,
converted + index, -1);
/* We painted to the end of the line, so
* don't bother checking any more
* starts. */
fileptr->multidata[tmpcolor->id] = CENDAFTER;
#ifdef DEBUG
fprintf(stderr, " Marking for id %i line %i as CENDAFTER\n", tmpcolor->id, line);
#endif
fileptr->multidata[tmpcolor->id] = CENDAFTER;
break;
}
/* We painted to the end of the line, so
* don't bother checking any more starts. */
break;
}
start_col = startmatch.rm_so + 1;
}
}
}
end_of_loop:
tail_of_loop:
wattroff(edit, A_BOLD);
wattroff(edit, COLOR_PAIR(tmpcolor->pairnum));
}
@@ -3333,11 +3330,9 @@ void do_cursorpos(bool constant)
/* Display the current cursor position on the statusbar, and set
* disable_cursorpos to FALSE. */
linepct = 100 * openfile->current->lineno /
openfile->filebot->lineno;
linepct = 100 * openfile->current->lineno / openfile->filebot->lineno;
colpct = 100 * cur_xpt / cur_lenpt;
charpct = (openfile->totsize == 0) ? 0 : 100 * i /
openfile->totsize;
charpct = (openfile->totsize == 0) ? 0 : 100 * i / openfile->totsize;
statusbar(
_("line %ld/%ld (%d%%), col %lu/%lu (%d%%), char %lu/%lu (%d%%)"),