Compare commits

...

109 Commits

Author SHA1 Message Date
Benno Schulenberg
492166a3f7 po: update translations and regenerate POT file and PO files 2017-05-04 11:19:50 +02:00
Benno Schulenberg
e1e15fd0f4 bump version numbers and add a news item for the 2.8.2 release 2017-05-04 10:24:54 +02:00
Benno Schulenberg
9c2bc68847 help: after a search, show the cursor only when something was found
And hide the cursor again as soon as the user scrolls.
Achieve this through making the 'didfind' variable global.

Also, remove a superfluous call of wnoutrefresh(), as bottombars()
already does that.

This fixes https://savannah.gnu.org/bugs/?50918.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-05-03 17:02:49 +02:00
Benno Schulenberg
3d1ef8e07f bindings: show Home and End in browser help text, instead of M-| and M-? 2017-05-02 17:56:08 +02:00
Benno Schulenberg
5033cfd81a tweaks: transform the token DISABLE_MOUSE to ENABLE_MOUSE
Also, trim some comments and avoid an unused-variable warning.
2017-05-01 20:53:07 +02:00
Benno Schulenberg
9c3a149b14 tweaks: transform the token DISABLE_MULTIBUFFER to ENABLE_MULTIBUFFER 2017-05-01 20:20:34 +02:00
Benno Schulenberg
a9c4682c25 tweaks: rename another function, to better describe what it does
Also, reshuffle two initializations to go sit with the other ones.
2017-05-01 17:54:48 +02:00
Benno Schulenberg
6566177743 tweaks: add a warning for a condition that should never occur 2017-05-01 17:42:55 +02:00
Benno Schulenberg
443e1484e5 tweaks: reshuffle help-text initialization, to elide a save-and-restore 2017-05-01 17:32:50 +02:00
Benno Schulenberg
ac9550d4c2 tweaks: remove two superfluous calls of wnoutrefresh()
The bottomwin has just been refreshed by update_the_statusbar(),
and it should not be the responsibility of the prompt routines
to keep the edit window up to date, as they don't write anything
there.
2017-05-01 17:14:20 +02:00
Benno Schulenberg
1423e57199 tweaks: rename a function, to better suit what it does
Things have morphed over time and display_buffer() no longer actually
displays the buffer -- it just displays the title bar, precalculates
the multiline color info, and schedules a refresh of the edit window.
2017-05-01 16:53:13 +02:00
Benno Schulenberg
c095ece497 gnulib: update to its current state in git 2017-05-01 15:07:33 +02:00
Benno Schulenberg
9366131c51 tweaks: reshuffle some more stuff, and rename two more variables 2017-05-01 13:22:37 +02:00
Benno Schulenberg
009cd30695 tweaks: rename three variables, elide another, and reshuffle some stuff
Also, avoid an unused-variable warning when configured with
--enable-tiny --enable-help --enable-multibuffer.
2017-05-01 12:10:17 +02:00
Benno Schulenberg
c42d6d378a tweaks: check for an empty needle in a central place
Searching for an empty string should be impossible, it should never
happen, but it is bit too hard to verify this at the moment.
2017-04-30 20:32:01 +02:00
Benno Schulenberg
1a79b3d514 tweaks: remove a superfluous strlen() call from the reverse searches
If the length of the haystack is smaller than the length of the needle,
this means that also the length of the tail will be smaller -- because
pointer will be bigger than or equal to haystack -- so the pointer gets
readjusted to be a needle length before the end of the haystack, which
means that it ends up /before/ the haystack: thus the while loop will
never run.

On average, this saves some 200 nanoseconds per line.
2017-04-30 19:51:36 +02:00
Benno Schulenberg
7d3d3dec9a tweaks: use the logic from revstrstr() also in mbrevstrcasestr()
Because it is slightly faster.
2017-04-30 19:51:14 +02:00
Benno Schulenberg
6240805c41 tweaks: rename one variable again
It is not an index, it is not an offset from anything,
it is a direct pointer.
2017-04-30 17:50:12 +02:00
Benno Schulenberg
17cf7d1c62 syntax: nanohelp: change the hue of the keystrokes to match sample.nanorc
And because I think it looks slightly better.
2017-04-30 17:37:07 +02:00
Benno Schulenberg
3275c4e514 display: initialize the colors only when starting to draw the content
This avoids https://savannah.gnu.org/bugs/?49912 while at the same time
avoiding to draw the edit window twice in a row -- the first drawing
would use a wrong margin, which results in a visible and irritating
shift left or right of the content upon the second drawing.

This fixes https://savannah.gnu.org/bugs/?50877.
2017-04-30 17:29:17 +02:00
Benno Schulenberg
395c8e9e25 help: allocate enough space for the descriptions, so we don't crash
We should measure the length of each /translated/ shortcut description,
not of the original English one.

This fixes https://savannah.gnu.org/bugs/?50899.
2017-04-30 13:00:02 +02:00
Benno Schulenberg
a8a60b29e6 startup: warn about a strange character size only in the UTF-8 case
This addresses https://savannah.gnu.org/bugs/?50897.
Reported-by: Hannu Nyman <hannu.nyman@iki.fi>
2017-04-30 11:15:03 +02:00
Benno Schulenberg
c1ebfa04ae docs: in the FAQ, extend the answer to the pasting problem 2017-04-28 22:13:02 +02:00
Benno Schulenberg
6967fae35d tweaks: use the logic from revstrstr() also in revstrcasestr()
This elides a counter and a comparison from the central loop,
and thus makes the search a tiny bit faster.
2017-04-28 22:12:53 +02:00
Benno Schulenberg
a37435141a tweaks: rename some more of these 'rev_start' variables 2017-04-28 22:09:38 +02:00
Benno Schulenberg
329021e24a tweaks: rename two variables, because this 'rev_start' is irksome
And one-letter variables I cannot "see" -- they are too small.
2017-04-28 21:02:24 +02:00
Benno Schulenberg
b06407fbd7 tweaks: drop a bunch of asserts 2017-04-28 16:07:27 +02:00
Benno Schulenberg
8edaa38a1e tweaks: condense two bits of code, and drop two asserts 2017-04-28 15:57:51 +02:00
Benno Schulenberg
1f55c8819b tweaks: swap the names of two variables, to make more sense
An iterator should not be called "start_col", because it is only the
starting column at the very beginning.

Also, start_col (after the rename) can never be /larger/ than column.
2017-04-28 15:48:50 +02:00
Benno Schulenberg
03ecbf3d55 tweaks: remove a superfluous check
The mbwidth() function itself checks whether UTF-8 is being used
and does the right thing.
2017-04-28 15:47:53 +02:00
Benno Schulenberg
81aebeb2a9 bindings: allow using <Backspace> to scroll back up in the help viewer
Backspace is a more logical counterpart of Space than minus.
2017-04-26 15:14:28 +02:00
Benno Schulenberg
7b442ea4cb tweaks: be more precise about what --disable-extra does
Also, harmonize some configure-option descriptions,
add a slash after a subdir, and fix a typo.
2017-04-26 13:54:48 +02:00
Benno Schulenberg
a846a2c19f docs: add an item to the FAQ, about pasting from Windows to a remote nano
Also, add two missing configure options, and frob some other things.
2017-04-26 12:49:10 +02:00
Benno Schulenberg
a832fffb1f browser: make ^End work properly by fixing a paste error
It complained of "Unbound key" until now.
2017-04-26 10:05:18 +02:00
Benno Schulenberg
99fa20645c tweaks: avoid an unused-variable warning
That is: nest the conditions consistently.
And in the bargain rename the variable.
2017-04-25 20:57:22 +02:00
Benno Schulenberg
26fe2118c4 docs: update the list of who authored what
Also, mention that help texts can now be searched through, update
a copyright notice, and update and simplify a copyright year.
2017-04-25 20:32:05 +02:00
Benno Schulenberg
46430999d5 build: make --enable-help properly depend on --enable-multibuffer
And in the process transform the token DISABLE_HELP to ENABLE_HELP.
2017-04-25 18:27:55 +02:00
Benno Schulenberg
9cff7a1689 help: use a dedicated syntax to color shortcuts in a help text
This avoids applying the default syntax, or the syntax specified
with --syntax, to a ^G help text.
2017-04-25 17:21:46 +02:00
Benno Schulenberg
ae15fc9bb2 bindings: allow using '/' to start a search in the help viewer
And allow 'N' for searching the next occurrence.  Add the
same keystrokes to the file browser too, for consistency.
2017-04-25 17:21:38 +02:00
Benno Schulenberg
b3b3dd5792 help: remove the final blank line, so <End> does the same as all <Down>
Since the help text is searchable, an <End> would go to the end of the
text but would leave a blank line above the statusbar -- a blank line
that wasn't there before, and that is not reached when simply holding
down <Down> all the way from the top.
2017-04-25 17:21:33 +02:00
Benno Schulenberg
7e1648fdb0 help: set tabsize to the default width while showing a help text
So that the shortcut explanations get properly aligned.
2017-04-25 17:21:28 +02:00
Benno Schulenberg
e05dfda2be help: don't cycle forward in the buffers when exiting from help
When nano has multiple files open, closing a help buffer should
not switch to the next buffer in the ring but to the preceding one,
because it was from there that the help screen was invoked.
2017-04-25 17:21:25 +02:00
Benno Schulenberg
fe012dad91 help: when searching, do it forward, without case, and without regexes
Also, save and restore all the flags in a single swoop.
2017-04-25 17:21:21 +02:00
Benno Schulenberg
3787494c15 help: don't crash when nano was started with --noread
There is no need to restore NOREAD_MODE after unsetting it, because
any files mentioned on the command line have already been /not/ read.
2017-04-25 17:21:16 +02:00
Benno Schulenberg
8de4b7aaeb tweaks: rename a variable, use a faster comparison, and reshuffle a bit 2017-04-25 17:21:13 +02:00
Benno Schulenberg
9de0f158e2 help: keep the same position also after M-\ or M-/ has been used 2017-04-25 17:21:09 +02:00
Benno Schulenberg
3d62d32cbe help: keep the text at the same position when the screen is resized
However, prefer moving the starting point of the text backwards over
moving it forward, so that of the same paragraph more text is shown
instead of less.  But scroll an empty line out of view -- no text is
"lost" then.
2017-04-25 17:21:06 +02:00
Benno Schulenberg
f9fea02fc5 help: suppress nano's name and number to make it clearer this is help
The top-left corner changing is far more conspicuous than the top right.
2017-04-25 17:21:02 +02:00
Rishabh Dave
90bd25c1bb new feature: add a search facility to the help viewer
Allow the user to search in a help text with ^W and M-W.

Achieve this by not writing the help text directly to the screen
but first writing it to a temporary file and then opening this file
in a new buffer, and treating it specially: the normal file-reading
feedback is suppressed, the titlebar shows the headline of the text,
the cursor is hidden, and the menu is limited to just the up and down
movements and searching.

This fulfills https://savannah.gnu.org/bugs/?28994.

Signed-off-by: Rishabh Dave <rishabhddave@gmail.com>
2017-04-25 17:20:34 +02:00
Benno Schulenberg
ca6d7b6a46 input: avoid crashing when resizing the window during verbatim input
This fixes https://savannah.gnu.org/bugs/?50872.
2017-04-25 13:01:21 +02:00
Benno Schulenberg
d6313c2f8c tweaks: fix two typos 2017-04-24 20:29:41 +02:00
Benno Schulenberg
861d81edba scrolling: don't bother to limit the number of lines to step back
The go_back_chunks() function will do this clipping.

This fixes https://savannah.gnu.org/bugs/?50866.
2017-04-24 19:48:55 +02:00
Benno Schulenberg
ac1444578c docs: harmonize the nanorc man page and Info document a bit
And make the strings after "start=" and  "end=" more readable.
2017-04-21 11:29:19 +02:00
Benno Schulenberg
9a4c384afa docs: reword the main paragraph of the man page
Mention some things that really set nano apart from Pico.
Plus some other small tweaks here and there.
2017-04-19 20:31:04 +02:00
Benno Schulenberg
040bd93cc4 tweaks: distinguish (in the comments) between buffers and linestructs
Call something a buffer when it refers to a linked list of linestructs,
and call something a linestruct when it is a struct that describes a
single line.
2017-04-19 17:48:52 +02:00
Benno Schulenberg
e935fd4f88 tweaks: reshuffle a couple of lines to avoid a duplicate call
Trim a superfluous assert too.
2017-04-19 16:32:16 +02:00
Benno Schulenberg
a43eee6aec tweaks: fix compilation with --enable-tiny --enable-color --enable-speller
Also avoid an unused-variable warning, and trim a useless assert.
2017-04-19 14:30:36 +02:00
Benno Schulenberg
1fbe7596f8 options: allow -U (--quickblank) to be used in the tiny version
It takes almost no code and is a useful little improvement over Pico.
2017-04-19 13:47:40 +02:00
Benno Schulenberg
3c875f9b59 tweaks: complete the exclusion of backups and such from the tiny version
File formats, appending and prepending, and backups are not available
when --enable-tiny is used, so prevent all relevant pieces of code from
getting compiled.  And correct two misspelled ENABLE_TINY to NANO_TINY.
2017-04-19 13:30:43 +02:00
Benno Schulenberg
700c5c9399 tweaks: rename a parameter, to be more imperative 2017-04-17 12:01:03 +02:00
Benno Schulenberg
74f128859b tweaks: rename a constant, to match the corresponding option 2017-04-17 11:51:48 +02:00
Benno Schulenberg
953fbf8efe tweaks: elide a function that is used just once
And in the bargain avoid a duplicate call of strlenpt(prompt).
2017-04-17 11:44:04 +02:00
Benno Schulenberg
3dc6ccbe86 tweaks: rename a function, to be more accurate
Because nothing gets reset to zero or to some initial value.
2017-04-17 11:29:29 +02:00
Benno Schulenberg
b98545f455 display: push the titlebar to the screen as soon as it has been drawn
To avoid an ncurses hiccup (miscoloring) when running on musl.

This fixes https://savannah.gnu.org/bugs/?50787.
Reported-by: Avi Halachmi <avihpit@yahoo.com>
2017-04-17 10:53:38 +02:00
Benno Schulenberg
5a741a0205 tweaks: remove some superfluous placements of the cursor
The cursor needs to be placed in its proper spot in the edit window
/only/ when nano is about to accept input from the user and needs to
show where this input will go.

(This might cause a scrolling issue to appear, because reset_cursor()
does not just place the cursor, it also recomputes current_y, which
is used in several places to determine whether and how much to scroll.
If it so happens, we'll deal with that fallout later.)
2017-04-17 10:35:05 +02:00
Benno Schulenberg
6723ac6fcc tweaks: add three warnings for conditions that should never occur 2017-04-17 10:17:47 +02:00
David Lawrence Ramsey
bbc718633e docs: mention that also numbercolor overrides boldtext 2017-04-16 19:30:40 +02:00
Benno Schulenberg
b7166d5c06 po: update translations and regenerate POT file and PO files 2017-04-12 10:19:50 +02:00
Benno Schulenberg
1e8f6fd7a9 bump version numbers and add a news item for the 2.8.1 release 2017-04-12 10:11:45 +02:00
Benno Schulenberg
0b93fff802 docs: correct an answer to a question in the FAQ 2017-04-11 21:10:07 +02:00
Benno Schulenberg
1c74517629 docs: remove the self-referencing stuff and the changelog from the FAQ
Furthermore, change an item header into a question, swap two items,
and tweak the formatting a bit.
2017-04-11 20:41:17 +02:00
Benno Schulenberg
9f696ef9af copyright: update the year in --version, and use the standard hyphen 2017-04-11 13:57:29 +02:00
Benno Schulenberg
5aa12a2b3d tweaks: group ^D and ^H together in the help lines
This also groups ^I and ^M together, and cutwordleft and cutwordright
(when they are bound).  It furthermore makes that less pairs are now
mixed and instead consist of either two Ctrl or two Meta combos.  In
short: it looks better in the default config.  The only sacrifice is
that Verbatim is now split off from the other "inserting" keys.
2017-04-11 13:23:43 +02:00
Benno Schulenberg
2439e1e451 linting: treat a tab as one "column", not eight
This fixes https://savannah.gnu.org/bugs/?47131.
2017-04-10 20:32:36 +02:00
Benno Schulenberg
dab70d06ed linting: when no is said to a file, remove all corresponding entries
When the user chooses not to open a file that some message refers to,
remove all messages for that file from the linting results, so the user
does not get asked about that same file again.

This fixes https://savannah.gnu.org/bugs/?47130.
2017-04-10 19:55:46 +02:00
Benno Schulenberg
8993c36366 tweaks: reduce the number of additions that actual_x() performs
Replace them by a single subtraction.
2017-04-10 19:25:40 +02:00
David Lawrence Ramsey
5c51d4ea46 tweaks: avoid a compilation warning 2017-04-10 16:26:52 +02:00
David Lawrence Ramsey
02376103eb bindings: use arrows instead of words for search history too
When UTF-8 is available, use actual arrows instead of untranslated words
to indicate the cursor keys in the search history, as is done elsewhere.
2017-04-10 16:19:37 +02:00
Benno Schulenberg
999d99c6e4 tweaks: delete a function that hasn't been used since 2005 2017-04-09 13:33:25 +02:00
Benno Schulenberg
6e73805a0d tweaks: delete unnecessary function prototypes
These functions are used only in the file in which they are declared,
and they are declared before they are used.
2017-04-09 13:28:27 +02:00
Benno Schulenberg
754c62c5cc copyright: update the years, use ranges, and explain this usage
The interval 2013-2017 for the Free Software Foundation is valid
because in those years there were releases with changes by either
Chris or David, and the GNU maintainers guide advises to mention
a new year in all files of a package, not just in the ones that
actually changed, and be done with it for the rest of the year.
2017-04-09 12:09:23 +02:00
Benno Schulenberg
9f2c80db24 moving: when determining where we are on the screen, use placewewant
To make dynamic Home and End work properly when double-width characters
straddle a chunk boundary, use the spot where the cursor is really shown
instead of the "actual x" position of the current character, because the
latter might be on the preceding row.

This fixes https://savannah.gnu.org/bugs/?50737.
2017-04-09 11:36:39 +02:00
Benno Schulenberg
4c987bc3e0 tweaks: adjust a couple of comments 2017-04-07 21:40:33 +02:00
Benno Schulenberg
e75c933cb0 tweaks: fix two typos in the NEWS file
Also, use single quotes for rcfile options more consistently.
2017-04-07 21:23:00 +02:00
Benno Schulenberg
28767d8fec tweaks: fix some inconsistencies in an old Changelog 2017-04-07 21:22:55 +02:00
Benno Schulenberg
bf00e3f606 tweaks: put M-A before ^6, to look better above M-6 in the help lines
Also, M-A is far more mnemonic for setting the mark than ^6 or ^^,
so it's better to try and teach the user that.
2017-04-07 20:07:37 +02:00
David Lawrence Ramsey
23ae7bfbbf input: support escape sequences for ^Home and ^End
Make nano recognize the escape sequences for Ctrl-Home, Ctrl-End,
Shift-Ctrl-Home, and Shift-Ctrl-End on xterm, rxvt, and Eterm.
2017-04-06 21:25:41 +02:00
Benno Schulenberg
cb0806b2a0 bindings: make ^Home and ^End go to top and tail of buffer
On some terminal emulators, Ctrl+Home and Ctrl+End produce special
keycodes, distinct from plain Home and End.  Make the users of those
emulators (and of the Linux console) glad by making ^Home and ^End
do the obvious thing, and the combinations with Shift too.
2017-04-06 21:19:00 +02:00
Benno Schulenberg
005ee8eda6 editing: avoid creating blank lines when using autoindent
When Enter is pressed while the cursor is exactly on the current
indent width, remove the blank characters on that line to avoid
creating a line that consists only of trailing whitespace.

(When Enter is pressed somewhere in the middle of the blanks,
however, the whitespace is preserved.)

Suggested-by: Florian Zeitz <florob@babelmonkeys.de>
2017-04-06 20:34:04 +02:00
Benno Schulenberg
f3e2ad945d display: with softwrap, show the cursor where the eye expects it
When a multi-column character straddles a chunk boundary, and the
preferred column (placewewant) for the cursor is zero, cheat: show
the cursor not where the character starts but on the beginning of
the next row.  This makes the cursor move smoothly in the leftmost
column of the screen when using <Up> and <Down> and such, instead
of jumping around.

In this way the scrolling logic won't get confused and the screen
will scroll properly when stepping beyond the top or bottom row.

This fixes https://savannah.gnu.org/bugs/?50687.
2017-04-06 19:51:07 +02:00
Benno Schulenberg
6ec65d5500 display: check the correct character for being double-width
This fixes https://savannah.gnu.org/bugs/?50741.
2017-04-06 17:39:58 +02:00
Benno Schulenberg
de0adb8e3e tweaks: keep the help text aligned, also with the narrow arrows 2017-04-05 18:02:03 +02:00
Mike Frysinger
cc91ee603c configure: ignore the REG_ENHANCED test when we use gnulib
If we're using the bundled gnulib regex module, then assume REG_ENHANCED
is not supported (since gnulib doesn't support it).

This fixes https://savannah.gnu.org/bugs/?50714.
2017-04-04 21:21:37 +02:00
Benno Schulenberg
c84324bc7a gnulib: update to current state 2017-04-04 21:11:31 +02:00
Benno Schulenberg
8fc72eb32b bindings: use arrows instead of words to designate the cursor keys
When UTF-8 is available, use actual arrows instead of untranslated words
to indicate the cursor keys.  This was already done for the combinations
with Ctrl but not yet for the plain cursor keys.
2017-04-04 20:53:08 +02:00
Benno Schulenberg
6b5aff4878 tweaks: put unshifted shortcuts ^6 and M-6 first, instead of ^^ and M-^
The unshifted shortcuts are easier to type, and also less confusing in
my eyes.  Putting them first means they get shown in the help lines,
and get listed first in the ^G help text.

(I would also like to put ^- first instead of ^_ (because the latter
is hard to see when using the default inverse video for shortcuts),
but on several terminal emulators Ctrl+- reduces the font size.)
2017-04-04 20:41:09 +02:00
Benno Schulenberg
fb534bada6 bindings: make ^Up/^Down go to first/last row in the file browser
Making ^Up and ^Down go to top and bottom row in the file browser
complements and completes the behavior of ^Left and ^Right.
2017-04-04 20:26:21 +02:00
Benno Schulenberg
b5bc1b5094 tweaks: again use memory on the stack instead of malloc() and free()
Also, don't bother copying the found bracket -- just compare it in situ
and thus elide a variable.
2017-04-04 19:20:33 +02:00
Benno Schulenberg
aedc3ddd49 tweaks: replace a function call or a macro with a hard number
Verify at startup that the number is not too small.
2017-04-04 19:17:02 +02:00
Benno Schulenberg
754aa8ba79 tweaks: elide a variable and a pair of braces 2017-04-04 19:15:15 +02:00
Benno Schulenberg
53cea142e0 tweaks: use memory on the stack instead of calling malloc() and free()
Rename some variables in the process, and remove two cluttering asserts.
2017-04-04 19:14:14 +02:00
Benno Schulenberg
7e18100197 tweaks: close the backup file also when we skip making a backup
(We still leak the backupname in that case, but I can't be bothered
with that now.)

Also elide a variable, trim some comments, and rewrap some lines.
2017-04-04 12:50:49 +02:00
Benno Schulenberg
0abf225129 files: check also for write errors when prepending, not just read errors 2017-04-04 12:21:43 +02:00
Kamil Dudka
70bcf752dc backup: prevent a symlink attack by operating on the file descriptor
Use futimens() instead of utime() to change the timestamps on a backup
file.  Otherwise, a non-privileged user could create an arbitrary symlink
with the name of the backup file and in this way fool a privileged user
to call utime() on the attacker-chosen file.

Import the relevant gnulib module to make sure futimens() is available.
2017-04-04 11:28:01 +02:00
Mike Frysinger
8f2b5bbf3d configure: fix up word boundary regex logic now that we have gnulib
If we're using the bundled gnulib regex module, then assume word boundary
support is available to avoid issues with the regcomp test.  This also
unifies the different code paths a bit.

This fixes https://savannah.gnu.org/bugs/?50705.
2017-04-04 11:08:58 +02:00
David Lawrence Ramsey
f9a8d6ff4e scrolling: properly compensate for the onscreen chunks
If edittop is partially offscreen before we scroll, and it gets
scrolled more offscreen, we do need to compensate for the chunks
between firstcolumn and leftedge -- that is: the chunks between
the top row and the cursor row.

This fixes https://savannah.gnu.org/bugs/?50691.
2017-04-04 10:55:24 +02:00
David Lawrence Ramsey
c3830517cc display: show '<' and '>' placeholders for characters that get split
When a two-column character cannot be shown because it straddles the
boundary between two chunks of a line, show the '>' placeholder for
its left "half", and '<' for its right "half".

This mitigates https://savannah.gnu.org/bugs/?49440.
2017-04-03 21:51:46 +02:00
Benno Schulenberg
6d70ab11d6 docs: mention another difference with Pico in the Info document 2017-04-02 13:26:53 +02:00
Benno Schulenberg
5f359179b2 docs: trim the TODO file a bit, and put the more important items first
Remove some things we're never going to do: allowing to replace
newlines, a regression framework, characterset conversions, or
jumping to various screen lines.
2017-04-02 13:09:52 +02:00
67 changed files with 21106 additions and 20750 deletions

10
AUTHORS
View File

@@ -8,8 +8,8 @@ Chris Allegretta <chrisa@asty.org>
David Lawrence Ramsey <pooka109@gmail.com>
* Former stable series maintainer. Multiple buffer support,
operating dir (-o) option, bug fixes for display routines,
wrapping code, spelling fixes, const mode, parts of the
UTF-8 support, and various other fixes.
wrapping code, spelling fixes, constantshow mode, parts of
UTF-8 support, softwrap overhaul, and various other fixes.
Jordi Mallach <jordi@gnu.org>
* Debian package maintainer, fellow bug squasher.
@@ -39,7 +39,8 @@ Mike Frysinger <vapier@gentoo.org>
* Gentoo package maintainer. Whitespace display mode,
--enable-utf8/--disable-utf8 configure options for ncurses,
many new color regexes and improvements to existing color
regexes in syntax/*.nanorc, and miscellaneous bug fixes.
regexes in syntax/*.nanorc, the move from svn to git, the
conversion to gnulib, and miscellaneous bug fixes.
Mark Majeres <mark@engine12.com>
* A functional undo/redo system, and coloring nano's interface.
@@ -56,6 +57,9 @@ Faissal Bensefia <faissaloo@gmail.com>
Sumedh Pendurkar <sumedh.pendurkar@gmail.com>
* The word-completion feature.
Rishabh Dave <rishabhddave@gmail.com>
* Searchable help.
Benno Schulenberg <bensberg@justemail.net>
* An array of small bug fixes, the cut-word and block-jump
routines, text selection by holding Shift, and some extra

129
ChangeLog
View File

@@ -1,3 +1,132 @@
Changes between v2.8.1 and v2.8.2:
----------------------------------
Benno Schulenberg (64):
bindings: allow using <Backspace> to scroll back up in the help viewer
bindings: allow using '/' to start a search in the help viewer
bindings: show Home and End in browser help text, instead of M-| and M-?
browser: make ^End work properly by fixing a paste error
build: make --enable-help properly depend on --enable-multibuffer
bump version numbers and add a news item for the 2.8.2 release
display: initialize the colors only when starting to draw the content
display: push the titlebar to the screen as soon as it has been drawn
docs: add an item to the FAQ, about pasting from Windows to a remote nano
docs: harmonize the nanorc man page and Info document a bit
docs: in the FAQ, extend the answer to the pasting problem
docs: reword the main paragraph of the man page
docs: update the list of who authored what
gnulib: update to its current state in git
help: after a search, show the cursor only when something was found
help: allocate enough space for the descriptions, so we don't crash
help: don't crash when nano was started with --noread
help: don't cycle forward in the buffers when exiting from help
help: keep the same position also after M-\ or M-/ has been used
help: keep the text at the same position when the screen is resized
help: remove the final blank line, so <End> does the same as all <Down>
help: set tabsize to the default width while showing a help text
help: suppress nano's name and number to make it clearer this is help
help: use a dedicated syntax to color shortcuts in a help text
help: when searching, do it forward, without case, and without regexes
input: avoid crashing when resizing the window during verbatim input
options: allow -U (--quickblank) to be used in the tiny version
scrolling: don't bother to limit the number of lines to step back
startup: warn about a strange character size only in the UTF-8 case
syntax: nanohelp: change the hue of the keystrokes to match sample.nanorc
tweaks: add a warning for a condition that should never occur
tweaks: add three warnings for conditions that should never occur
tweaks: avoid an unused-variable warning
tweaks: be more precise about what --disable-extra does
tweaks: check for an empty needle in a central place
tweaks: complete the exclusion of backups and such from the tiny version
tweaks: condense two bits of code, and drop two asserts
tweaks: distinguish (in the comments) between buffers and linestructs
tweaks: drop a bunch of asserts
tweaks: elide a function that is used just once
tweaks: fix compilation with --enable-tiny --enable-color --enable-speller
tweaks: fix two typos
tweaks: remove a superfluous check
tweaks: remove a superfluous strlen() call from the reverse searches
tweaks: remove some superfluous placements of the cursor
tweaks: remove two superfluous calls of wnoutrefresh()
tweaks: rename a constant, to match the corresponding option
tweaks: rename a function, to be more accurate
tweaks: rename a function, to better suit what it does
tweaks: rename another function, to better describe what it does
tweaks: rename a parameter, to be more imperative
tweaks: rename a variable, use a faster comparison, and reshuffle a bit
tweaks: rename one variable again
tweaks: rename some more of these 'rev_start' variables
tweaks: rename three variables, elide another, and reshuffle some stuff
tweaks: rename two variables, because this 'rev_start' is irksome
tweaks: reshuffle a couple of lines to avoid a duplicate call
tweaks: reshuffle help-text initialization, to elide a save-and-restore
tweaks: reshuffle some more stuff, and rename two more variables
tweaks: swap the names of two variables, to make more sense
tweaks: transform the token DISABLE_MOUSE to ENABLE_MOUSE
tweaks: transform the token DISABLE_MULTIBUFFER to ENABLE_MULTIBUFFER
tweaks: use the logic from revstrstr() also in mbrevstrcasestr()
tweaks: use the logic from revstrstr() also in revstrcasestr()
David Lawrence Ramsey (1):
docs: mention that also numbercolor overrides boldtext
Rishabh Dave (1):
new feature: add a search facility to the help viewer
Changes between v2.8.0 and v2.8.1:
----------------------------------
Benno Schulenberg (33):
bindings: make ^Home and ^End go to top and tail of buffer
bindings: make ^Up/^Down go to first/last row in the file browser
bindings: use arrows instead of words to designate the cursor keys
bump version numbers and add a news item for the 2.8.1 release
copyright: update the year in --version, and use the standard hyphen
copyright: update the years, use ranges, and explain this usage
display: check the correct character for being double-width
display: with softwrap, show the cursor where the eye expects it
docs: correct an answer to a question in the FAQ
docs: mention another difference with Pico in the Info document
docs: remove the self-referencing stuff and the changelog from the FAQ
docs: trim the TODO file a bit, and put the more important items first
editing: avoid creating blank lines when using autoindent
files: check also for write errors when prepending, not just read errors
gnulib: update to current state
linting: treat a tab as one "column", not eight
linting: when no is said to a file, remove all corresponding entries
moving: when determining where we are on the screen, use placewewant
tweaks: adjust a couple of comments
tweaks: again use memory on the stack instead of malloc() and free()
tweaks: close the backup file also when we skip making a backup
tweaks: delete a function that hasn't been used since 2005
tweaks: delete unnecessary function prototypes
tweaks: elide a variable and a pair of braces
tweaks: fix some inconsistencies in an old Changelog
tweaks: fix two typos in the NEWS file
tweaks: group ^D and ^H together in the help lines
tweaks: keep the help text aligned, also with the narrow arrows
tweaks: put M-A before ^6, to look better above M-6 in the help lines
tweaks: put unshifted shortcuts ^6 and M-6 first, instead of ^^ and M-^
tweaks: reduce the number of additions that actual_x() performs
tweaks: replace a function call or a macro with a hard number
tweaks: use memory on the stack instead of calling malloc() and free()
David Lawrence Ramsey (5):
bindings: use arrows instead of words for search history too
display: show '<' and '>' placeholders for characters that get split
input: support escape sequences for ^Home and ^End
scrolling: properly compensate for the onscreen chunks
tweaks: avoid a compilation warning
Kamil Dudka (1):
backup: prevent a symlink attack by operating on the file descriptor
Mike Frysinger (2):
configure: fix up word boundary regex logic now that we have gnulib
configure: ignore the REG_ENHANCED test when we use gnulib
Changes between v2.7.5 and v2.8.0:
----------------------------------

View File

@@ -5975,7 +5975,7 @@ GNU nano 1.1.8 - 2002.03.30
do_insertfile()
- Handle cancel from ExtCmd properly. (David Benbennick)
read_file()
- Abort if we read a file of 0 lines (num_lines == 0), fixes BUG #70.
- Abort if we read a file of 0 lines (num_lines == 0). Fixes bug #70.
- Reverse tests to stop segfault on editing a new file of 0 lines.
(David Benbennick)
- Change input var to one char instead of array. (David Benbennick)
@@ -6108,8 +6108,8 @@ GNU nano 1.1.7 - 2002.03.05
- Added Noconvert option to man page. (DLR)
- nano.c:
justify_format(), do_justify()
- Various fixes for starting blank spaces, spaces after
punctuation, & segfault with quoting strings. (David Benbennick)
- Various fixes for starting blank spaces, spaces after
punctuation, & segfault with quoting strings. (David Benbennick)
do_justify()
- Don't continue to justify string if it's indented more
(quoting wise) than the beginning of the justification.
@@ -6139,8 +6139,8 @@ GNU nano 1.1.7 - 2002.03.05
- NANO_SMALL test was backwards. (Ken Tyler)
- winio.c:
strlenpt()
- Changed main function to strnlenpt() for new justify changes,
original function now just a stub.
- Changed main function to strnlenpt() for new justify changes,
original function now just a stub.
- nanorc.sample
- Mention unset in the sample nanorc.
- po/ca.po, po/es.po:
@@ -6208,7 +6208,7 @@ nano-1.1.6 - 2002.01.25
- Temporarily unset REVERSE_SEARCH if it's set. (Rocco Corsi)
do_suspend()
- Call tcsetattr() to restore the old terminal settings, so
tcsh can use ^C after suspend for example (fixes BUG #68).
tcsh can use ^C after suspend for example. Fixes bug #68.
do_wrap()
- Move "right" increment to part where new line is created,
should change (fix?) some wrapping problems with autoindent.
@@ -6368,10 +6368,10 @@ nano-1.1.4 - 2001.12.11
- nano.c:
main()
- Add Esc-[-[IGL] keys for FreeBSD Console (PgUp,PgDn,Insert).
- Added better Hurd support for function keys (Alt-V,U,9,@,F).
- Added better Hurd support for function keys (Alt-V,U,9,@,F).
signal_init()
- do SIG_IGN for the SIGTSTP sigaction regardless of whether
we have _POSIX_VDISABLE or not (more Hurd fixes)
- do SIG_IGN for the SIGTSTP sigaction regardless of whether
we have _POSIX_VDISABLE or not (more Hurd fixes)
help_init()
- Typo fixes and additions to the new help texts.
do_curpos()
@@ -6487,10 +6487,10 @@ nano-1.1.2 - 2001.10.03
- Take control-space out of -tiny build, unneeded.
- cut.c:
cut_marked_segment()
- Add magic line when cutting a selection including filebot
(discovered by DLR, fixed by DLR & Chris, fixes BUG #66).
- Add magic line when cutting a selection including filebot.
Fixes bug #66. (discovered by DLR, fixed by DLR & Chris)
do_cut_text()
- Don't recenter the line when cutting one line (DLR) (Bug #65).
- Don't recenter the line when cutting one line. Fixes bug #65. (DLR)
- faq.html:
- Notes about the Free Translation Project.
- Debian additions.
@@ -6681,14 +6681,14 @@ nano-1.1.0 - 2001.07.15
add_to_cutbuffer()
- Remove useless statements. (Rocco)
cut_marked_segment()
- Add bizarre copy of bot node, else *BSD goes ballistic (fixes
BUG #60).
- Add bizarre copy of bot node, else *BSD goes ballistic. Fixes
bug #60.
- Added 'destructive' argument. Allows the selected text to be
added to the cutbuffer without changing the contents of the
file. This allows writing selection to separate files.
do_cut_text()
- If the line is empty when using -k and wasn't already added,
create a dummy line and add it to the cutbuffer (fixes bug #61)
create a dummy line and add it to the cutbuffer. Fixes bug #61.
- Reset marked_cut if we blow away the cutbuffer.
- Moved the case of current == mark_beginbuf into cut_marked
segment, so do_writeout could call it when writing selection to
@@ -6719,7 +6719,7 @@ nano-1.1.0 - 2001.07.15
- move.c:
page_up()
- Rewritten with a loop to make screen updates work when
mark is set (fixes bug #59).
mark is set. Fixes bug #59.
do_home(), do_end()
- Don't keep cutbuffer.
- nano.1:
@@ -6756,7 +6756,7 @@ nano-1.1.0 - 2001.07.15
- Optimizations, remove "$" goes-to-last-line, less messages. (Rocco)
do_replace()
- If we manage to make it in somehow with VIEW_MODE on, abort
nicely (fixes BUG #59).
nicely. Fixes bug #59.
- utils.c
strcasestr()
- Replaced by mutt's mutt_stristr function, because the thought
@@ -6844,13 +6844,13 @@ nano-1.0.0 - 2001.03.22
- move.c:
page_down()
- Check for totlines < editwinrows in check for superfluous
edit update (fixed BUG #57).
edit update. Fixes bug #57.
- search.c:
print_replaced()
- s/occurence/occurrence typos. (Jordi)
search_init()
- If using Pico mode and regex and same answer is entered, use
last_search string instead of answer (fixes BUG #56).
last_search string instead of answer. Fixes bug #56.
- nano.texi:
- Meta-Z correction and grammar in --enable-tiny desc. (Neil Parks)
@@ -6868,7 +6868,7 @@ nano-0.9.99pre3 - 2001.02.19
- ALL_LINGUAS: added hu and ca.
- cut.c:
do_cut_text()
- marked text cut fixes (Rocco) (Fixes bug #54).
- Marked text cut fixes. Fixes bug #54. (Rocco)
- nano.c:
do_delete()
- Added check for current->next == fileptr, as we have a magic
@@ -7016,7 +7016,7 @@ General -
for now.
- Moved keypad() calls for PDCurses from main() to window_init()
so the keypad continues to work after a Meta-X, for example.
Fixed bug #51.
Fixes bug #51.
- faq.html:
- Fix typos and small mistakes. (Jordi)
- files.c:
@@ -7038,7 +7038,7 @@ General -
- move.c:
page_down()
- Don't do an edit_update when there is only one page of text
(fileage == edittop && filebot == editbot). Fixes Bug #50.
(fileage == edittop && filebot == editbot). Fixes bug #50.
- nano.c:
main()
- Reorder the getopt options to be more or less alphabetical
@@ -7080,7 +7080,7 @@ General
uncutting marked text at filebot. (Ryan Krebs)
- files.c:
read_file()
- If we encounter an error and insert is not set, run new_file().
- If we encounter an error and insert is not set, run new_file()
(bug discovered by Ben Roberts).
write_file()
- Change open call flags, basically copy joe's way of doing it so
@@ -7097,8 +7097,8 @@ General
modify_control_key. Removed #ifdef _POSIX_VDISABLE check
around Control-S,Q,Z handlers because we need it now for
the Alt-Alt-x code.
- Added --view option to getopt_long() call. Bug discovered
by Rocco Corsi.
- Added --view option to getopt_long() call (bug discovered by
Rocco Corsi).
help_init()
- Fix off by one error that was making ^G help in normal mode and
^_ in Pico mode not be displayed in the help (bug discovered by
@@ -7292,7 +7292,7 @@ nano 0.9.20 - 2000.11.18
- nano.c:
keypad_on()
- New function, toggles turning the keypad on and off in edit and
bottomwin(). Added call to this in finish(), fixes bug #45.
bottomwin(). Added call to this in finish(). Fixes bug #45.
- search.c
findnextstr()
- New arg for begin_x variable, basically a rewrite that
@@ -7359,7 +7359,7 @@ nano 0.9.18 - 2000.09.18
- cut.c:
do_cut_text()
- Don't immediately abort if we're on filebot and the marker is
set (fixes bug #42).
set. Fixes bug #42.
- files.c:
open_file()
- Fix for bug #44. (Rocco Corsi)
@@ -7372,9 +7372,9 @@ nano 0.9.18 - 2000.09.18
available, allows nano to work with cygwin.
- Added gettext calls to enable/disable strings. (Jordi)
- Revamped a great deal of the F-key and keypad key handling,
because we not longer use keypad() (see below).
because we no longer use keypad() (see below).
- Removed keypad() call because nano was not working with the
keypad in many terms, which is very bad.
keypad on many terminals, which is very bad.
- Made insert key call do_insertfile().
do_toggle()
- Rewrote function to allow NOHELP toggle to work on systems
@@ -7450,7 +7450,7 @@ nano-0.9.17 - 2000.09.04
findnextstr():
- Added reset for placewewant. (Ben Roberts)
- Fixed check for string that only occurs on the same line failing
(discovered by Ken Tyler).
(bug discovered by Ken Tyler).
nano-0.9.16 - 2000.08.09
- cut.c:
@@ -7481,7 +7481,7 @@ nano-0.9.15 - 2000.08.03
with --with-slang or --without-slang
- nano.c:
splice_node()
- New function, abstracts linking in nodes. Fixes bug #36.
- New function, abstracts linking in nodes. Fixes bug #36.
null_at()
- New function, nulls a string at a given index and realigns it.
delete_buffer()
@@ -7555,7 +7555,7 @@ nano-0.9.13 - 2000.07.23
- More intelligent emergency-save filename selection. (Rob)
do_spell():
- Changed exit semantics a bit so that aspell wouldn't get
all screwy (bug discovered by Joshua Jensen.
all screwy (bug discovered by Joshua Jensen).
- files.c:
read_file():
- Added init of buf variable, hopefully this will stop the
@@ -7606,8 +7606,8 @@ nano-0.9.12 - 2000.07.07
- Magic Line code in read_file (Rob)
- nano.c:
- Removed dual alt_speller variables, oops! (Rocco Corsi)
- Removed unnecessary do_oldspell function. (Rocco Corsi). Added
SMALL_NANO #ifdef around actual spell function.
- Removed unnecessary do_oldspell function. (Rocco Corsi)
- Added SMALL_NANO #ifdef around actual spell function.
- Moved page_up() to move.c where is belongs.
- Corrected FIXME in do_enter with explanation. (Rob)
- Fixed FIXME in do_justify, resulted in creation of

View File

@@ -1,6 +1,12 @@
Improvements in GNU nano
========================
Since 2.8.0:
- The ^G help texts have become searchable (with ^W and M-W).
- Ctrl+Home and Ctrl+End jump to start and end of file.
- In softwrap mode the cursor now moves per visual row instead of per
logical line, and the screen will scroll per row.
Since 2.7.0:
- The keystroke ^] to complete a fragment to an existing full word.
- The ability to display line numbers in front of the text (M-#).

40
NEWS
View File

@@ -1,3 +1,27 @@
2017.05.04 - GNU nano 2.8.2 "Krats" adds another new feature: it makes
the ^G help texts searchable with ^W. Apart from that,
it fixes a crash when resizing the window in the middle
of verbatim input, avoids an unlikely crash when used
without UTF-8 support in some locales, avoids redrawing
the screen twice when switching between buffers while
line numbers are active, and works around a coloring
bug on musl. Plus tweaks to the documentation; plus
translation updates for fifteen languages.
2017.04.12 - GNU nano 2.8.1 "Ellert" fixes build failures on MacOS and
on musl, fixes scrolling problems in softwrap mode when
double-width characters on row boundaries are involved,
shows double-width characters as ">" and "<" when split
across two rows, moves the cursor more predictably (at
the cost of sometimes putting it on the second "half"
of a character), avoids creating lines that consist of
only blanks when using autoindent, makes ^Home and ^End
go to the start and end of the file (on terminals that
support those keystrokes), places the cursor better when
linting, lets the linter ask only once whether to open
an included file, and adds bindings for ^Up and ^Down
in the file browser. Don't sit on your hands.
2017.03.31 - GNU nano 2.8.0 "Axat" makes it easier to move around in
softwrapped lines: the Up and Down keys now step from
visual row to visual row instead of jumping between
@@ -8,7 +32,7 @@
of always per logical line. On an entirely different
front: nano now makes use of gnulib, to make it build
on more platforms. In short: there were many internal
changes, not many user-visible ones (apart form the
changes, not many user-visible ones (apart from the
new softwrap navigation). The conversion to gnulib
was done by Mike Frysinger, the softwrap overhaul by
David Ramsey.
@@ -51,8 +75,8 @@
related to using line numbers in softwrap mode, allows to
use the PageUp and PageDown keys together with Shift on
VTE-based terminals, stops the help lines from flickering
during interactive replacing, makes a "set fill" override
an earlier "set nowrap", properly restores the selected
during interactive replacing, makes a 'set fill' override
an earlier 'set nowrap', properly restores the selected
region after an external spell check, and improves a few
other tidbits. If you should find any more bugs, please
run 'man nano | grep bugs' and report them there.
@@ -293,11 +317,11 @@
has been added on top of the existing file extension
and header support already available. Secondly, cursor
position can be saved between editing sessions with
the -P or --poslog command-line flag, or via "set poslog"
the -P or --poslog command-line flag, or via 'set poslog'
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.
@@ -317,7 +341,7 @@
being used out of crontab). For very strange situations
(such as where you cannot change the permissions on the
file you're writing), there is a new rc file option
"allow_insecure_backup" to be even more permissive and
'allow_insecure_backup' to be even more permissive and
allow the write to proceed. Also included are some
syntax highlighting updates, and that is about it.
Keep fighting the good fight children.
@@ -1237,7 +1261,7 @@
important being that nano is now officially a GNU
program. Some changes have been made for GNU
compatibility (like the default list of shortcuts, "^G
Get Help" is now Listed and "^_ Goto Line" is not). The
Get Help" is now listed and "^_ Goto Line" is not). The
Yes/No/All keys have finally been internationalized
also. All in all, quite a few changes, considering nano
is supposed to be in a code freeze. But there are the
@@ -1253,7 +1277,7 @@
is now a preliminary (read: needs testing) fix for
resizing the editor in any mode other than normal edit
mode. Other fixes include some more tab completion
segfaults, and an silly segfault that occurred when
segfaults, and a silly segfault that occurred when
successfully writing a file on the 2nd try (i.e. after
an initial write error). Slowly but surely, on toward
1.0 we travel.

11
README
View File

@@ -65,5 +65,12 @@ Bug Reports
Current Status
GNU nano has reached its seventh milestone, 2.6.x. Since 2.5.0, it
is a "rolling" release: bug fixing and development go hand in hand.
Since version 2.5.0, GNU nano has abandoned the distinction between
a stable and a development branch: it is now on a "rolling" release
-- fixing bugs and adding new features go hand in hand.
Copyright Years
When in any file of this package a copyright notice mentions a
year range (such as 1999-2011), it is a shorthand for a list of
all the years in that interval.

45
TODO
View File

@@ -1,29 +1,12 @@
A list of desired features
--------------------------
Vague musings:
- FriBidi support?
- Make matching bracket searches sophisticated enough to skip over
brackets inside comments?
- Allow indentation of marked text by spaces as well as tabs?
- Allow indentation to add just enough columns to reach the nearest
multiple of tabsize, rather than always adding tabsize columns?
- Allow conversion between different character sets.
- Allow setting marks (saved positions, not to be confused with the mark
set via Ctrl-^) at various lines and/or columns in the buffer, and
allow movement between them with a single keystroke?
- Allow searching for and replacing newlines?
See also https://savannah.gnu.org/bugs/?47053.
- New regression framework built on expect?
- Add the ability to move to different lines of the screen with a single
keystroke, e.g. M-` (M-~) to go to the top line, M-& (M-7) to go to
the center line, and M-' (M-") to go to the last line?
Somewhat urgent:
- Allow text searches in the help viewer.
See https://savannah.gnu.org/bugs/?28994.
- Make undo/redo work also for justifying and indenting.
- Detect when text is being pasted, so that we can handle it faster.
See https://savannah.gnu.org/bugs/?40060.
- Allow to define and execute a macro: a stored sequence of keystrokes.
See https://savannah.gnu.org/bugs/?50314.
- Allow color syntaxes to apply to more than just color, so that we can
e.g. specify a different alternate spell checker depending on which
file type we have open.
@@ -31,6 +14,20 @@ Somewhat urgent:
the command's output -- that is: generalize the spell-check flow.
See also https://savannah.gnu.org/bugs/?28993.
Vague musings:
- FriBidi support?
- Allow setting marks (saved positions, not to be confused with the
mark set via Ctrl-^) at various lines and/or columns in the buffer,
and allow movement between them with a single keystroke?
- Make matching bracket searches sophisticated enough to skip over
brackets inside comments?
- Allow indentation of marked text by spaces as well as tabs?
- Allow indentation to add just enough columns to reach the nearest
multiple of tabsize, rather than always adding tabsize columns?
For version 2.8:
- Allow text searches in the help viewer. [DONE]
For version 2.4:
- Handle window resizes better. After we've resized, we should stay
wherever we were before we resized, as Pico does. [DONE]
@@ -63,14 +60,13 @@ For version 2.0:
For version 1.2:
- Single-line scroll up/down? [DONE]
- Color syntax highlighting? (Certainly seems like there's a demand for
it.) [DONE]
- .nanorc [DONE]
- Color syntax highlighting? (There seems to be a demand for it.) [DONE]
- Support for a .nanorc file. [DONE]
- Backup making (filename~)? [DONE]
- Search/replace string history. [DONE]
- Implement Pico's -j and -g flags, as they are pretty easy to do. [DONE]
- Make mouse support work with clicking on the shortcuts (-m). [DONE]
- Implement -o (chroot of sorts). [DONE]
- Implement -o (--operatingdir, a chroot of sorts). [DONE]
- Allow -r to take a negative argument, meaning right margin instead of
left (allows resizing that way), formerly -W arg. [DONE]
@@ -81,7 +77,6 @@ For version 1.0:
- Allow nano to be resized in X. [DONE]
- On PageUp/Down, put the cursor on the first line (like Pico), not the
center line. [DONE]
- Rewrite edit_refresh, if at all possible. [DONE]
- Implement justify function. [DONE]
- Cut to end of line. [DONE]
- Built-in speller command. [DONE]

View File

@@ -2,9 +2,10 @@
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="4084b3a1094372b960ce4a97634e08f4538c8bdd"
gnulib_hash="3eee3a1e3c5b8883e0d4934bfc1326ee605cb7c1"
modules="
futimens
getdelim
getline
getopt-gnu

View File

@@ -1,7 +1,7 @@
# Configuration for GNU nano - a small and user-friendly text editor
#
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
# 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc.
# Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc.
# Copyright (C) 2014, 2017 Mike Frysinger
#
# GNU nano is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
AC_INIT([GNU nano], [2.8.0], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [2.8.2], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.14])
@@ -63,7 +63,7 @@ AC_CHECK_HEADERS(libintl.h limits.h pwd.h termios.h sys/param.h)
dnl Checks for options.
AC_ARG_ENABLE(browser,
AS_HELP_STRING([--disable-browser], [Disable built-in file browser]))
AS_HELP_STRING([--disable-browser], [Disable the built-in file browser]))
if test "x$enable_browser" = xno; then
AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in file browser.])
fi
@@ -85,7 +85,7 @@ else
fi
AC_ARG_ENABLE(comment,
AS_HELP_STRING([--disable-comment], [Disable comment/uncomment functions]))
AS_HELP_STRING([--disable-comment], [Disable the comment/uncomment function]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_comment" = xyes; then
AC_MSG_ERROR([--enable-comment cannot work with --enable-tiny])
@@ -100,15 +100,34 @@ if test "x$disable_comment" != xyes; then
fi
AC_ARG_ENABLE(extra,
AS_HELP_STRING([--disable-extra], [Disable extra features, currently only easter eggs]))
AS_HELP_STRING([--disable-extra], [Disable the Easter egg]))
if test "x$enable_extra" = xno; then
AC_DEFINE(DISABLE_EXTRA, 1, [Define this to disable extra stuff.])
fi
AC_ARG_ENABLE(help,
AS_HELP_STRING([--disable-help], [Disable help functions]))
if test "x$enable_help" = xno; then
AC_DEFINE(DISABLE_HELP, 1, [Define this to disable the help text display.])
AS_HELP_STRING([--disable-help], [Disable the built-in help texts]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_help" = xyes; then
if test "x$enable_multibuffer" != xyes; then
AC_MSG_ERROR([--enable-help cannot work without --enable-multibuffer])
fi
else
enable_help=no
fi
fi
if test "x$enable_multibuffer" = xno; then
if test "x$enable_help" = xyes; then
AC_MSG_ERROR([--enable-help cannot work with --disable-multibuffer])
else
# Disabling multibuffer silently disables the help texts.
enable_help=no
fi
fi
if test "x$disable_help" != xyes; then
if test "x$enable_help" != xno; then
AC_DEFINE(ENABLE_HELP, 1, [Define this to enable the Ctrl+G help texts.])
fi
fi
AC_ARG_ENABLE(histories,
@@ -118,7 +137,7 @@ if test "x$enable_histories" = xno; then
fi
AC_ARG_ENABLE(justify,
AS_HELP_STRING([--disable-justify], [Disable justify/unjustify functions]))
AS_HELP_STRING([--disable-justify], [Disable the justify/unjustify functions]))
if test "x$enable_justify" = xno; then
AC_DEFINE(DISABLE_JUSTIFY, 1, [Define this to disable the justify routines.])
fi
@@ -140,19 +159,33 @@ if test "x$disable_linenumbers" != xyes; then
fi
AC_ARG_ENABLE(mouse,
AS_HELP_STRING([--disable-mouse], [Disable mouse support (and -m flag)]))
if test "x$enable_mouse" = xno; then
AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable the mouse support.])
AS_HELP_STRING([--disable-mouse], [Disable mouse support]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_mouse" != xyes; then
enable_mouse=no
fi
fi
if test "x$disable_mouse" != xyes; then
if test "x$enable_mouse" != xno; then
AC_DEFINE(ENABLE_MOUSE, 1, [Define this to enable mouse support.])
fi
fi
AC_ARG_ENABLE(multibuffer,
AS_HELP_STRING([--disable-multibuffer], [Disable multiple file buffers]))
if test "x$enable_multibuffer" = xno; then
AC_DEFINE(DISABLE_MULTIBUFFER, 1, [Define this to disable multiple file buffers.])
if test "x$enable_tiny" = xyes; then
if test "x$enable_multibuffer" != xyes; then
enable_multibuffer=no
fi
fi
if test "x$disable_multibuffer" != xyes; then
if test "x$enable_multibuffer" != xno; then
AC_DEFINE(ENABLE_MULTIBUFFER, 1, [Define this to enable multiple file buffers.])
fi
fi
AC_ARG_ENABLE(nanorc,
AS_HELP_STRING([--disable-nanorc], [Disable use of .nanorc files]))
AS_HELP_STRING([--disable-nanorc], [Disable the use of .nanorc files]))
if test "x$enable_nanorc" = xno; then
AC_DEFINE(DISABLE_NANORC, 1, [Define this to disable the use of .nanorc files.])
else
@@ -160,25 +193,25 @@ else
fi
AC_ARG_ENABLE(operatingdir,
AS_HELP_STRING([--disable-operatingdir], [Disable setting of operating directory (chroot of sorts)]))
AS_HELP_STRING([--disable-operatingdir], [Disable the setting of an operating directory]))
if test "x$enable_operatingdir" = xno; then
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of the operating directory (chroot of sorts).])
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of an operating directory (a chroot of sorts).])
fi
AC_ARG_ENABLE(speller,
AS_HELP_STRING([--disable-speller], [Disable spell checker functions]))
AS_HELP_STRING([--disable-speller], [Disable the spell-checker functions]))
if test "x$enable_speller" = xno; then
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell checker functions.])
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell-checker functions.])
fi
AC_ARG_ENABLE(tabcomp,
AS_HELP_STRING([--disable-tabcomp], [Disable tab completion functions]))
AS_HELP_STRING([--disable-tabcomp], [Disable the tab-completion functions]))
if test "x$enable_tabcomp" = xno; then
AC_DEFINE(DISABLE_TABCOMP, 1, [Define this to disable the tab completion functions for filenames and search strings.])
AC_DEFINE(DISABLE_TABCOMP, 1, [Define this to disable the tab-completion functions for filenames and search strings.])
fi
AC_ARG_ENABLE(wordcomp,
AS_HELP_STRING([--disable-wordcomp], [Disable the word completion function]))
AS_HELP_STRING([--disable-wordcomp], [Disable the word-completion function]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_wordcomp" = xyes; then
AC_MSG_ERROR([--enable-wordcomp cannot work with --enable-tiny])
@@ -188,14 +221,14 @@ if test "x$enable_tiny" = xyes; then
fi
if test "x$disable_wordcomp" != xyes; then
if test "x$enable_wordcomp" != xno; then
AC_DEFINE(ENABLE_WORDCOMPLETION, 1, [Define this to enable the word completion function.])
AC_DEFINE(ENABLE_WORDCOMPLETION, 1, [Define this to enable the word-completion function.])
fi
fi
AC_ARG_ENABLE(wrapping,
AS_HELP_STRING([--disable-wrapping], [Disable all wrapping of text (and -w flag)]))
AS_HELP_STRING([--disable-wrapping], [Disable all hard-wrapping of text]))
if test "x$enable_wrapping" = xno; then
AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable all text wrapping.])
AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable all hard text wrapping.])
fi
AC_ARG_ENABLE(wrapping-as-root,
@@ -207,7 +240,7 @@ fi
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug], [Enable debugging (disabled by default)]))
if test "x$enable_debug" = xyes; then
AC_DEFINE(DEBUG, 1, [Define this to enable debug messages and assert warnings.])
AC_DEFINE(DEBUG, 1, [Define this to enable debug messages and abortion on failing asserts.])
else
AC_DEFINE(NDEBUG, 1, [Shut up assert warnings :-)])
fi
@@ -230,9 +263,6 @@ if test "x$enable_tiny" = xyes; then
if test "x$enable_extra" != xyes; then
AC_DEFINE(DISABLE_EXTRA, 1, [Define this to disable extra stuff.])
fi
if test "x$enable_help" != xyes; then
AC_DEFINE(DISABLE_HELP, 1, [Define this to disable the help text display.])
fi
if test "x$enable_histories" != xyes; then
AC_DEFINE(DISABLE_HISTORIES, 1, [Define this to disable search and position histories.])
fi
@@ -242,23 +272,17 @@ if test "x$enable_tiny" = xyes; then
if test "x$enable_libmagic" != xyes; then
enable_libmagic=no
fi
if test "x$enable_mouse" != xyes; then
AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable the mouse support.])
fi
if test "x$enable_multibuffer" != xyes; then
AC_DEFINE(DISABLE_MULTIBUFFER, 1, [Define this to disable multiple file buffers.])
fi
if test "x$enable_nanorc" != xyes; then
AC_DEFINE(DISABLE_NANORC, 1, [Define this to disable the use of .nanorc files.])
fi
if test "x$enable_operatingdir" != xyes; then
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of the operating directory (chroot of sorts).])
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of an operating directory (a chroot of sorts).])
fi
if test "x$enable_speller" != xyes; then
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell checker functions.])
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell-checker functions.])
fi
if test "x$enable_tabcomp" != xyes; then
AC_DEFINE(DISABLE_TABCOMP, 1, [Define this to disable the tab completion functions for files and search strings.])
AC_DEFINE(DISABLE_TABCOMP, 1, [Define this to disable the tab-completion functions for files and search strings.])
fi
if test "x$enable_wrapping" != xyes; then
AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable all text wrapping.])
@@ -545,13 +569,13 @@ else
fi
AC_CHECK_LIB([$CURSES_LIB_NAME], [use_default_colors],
[AC_DEFINE(HAVE_USE_DEFAULT_COLORS, 1, [Define this if your curses library has the use_default_colors() command.])],
[AC_DEFINE(HAVE_USE_DEFAULT_COLORS, 1, [Define this if your curses library has the use_default_colors() function.])],
[], [$CURSES_LIB])
AC_CHECK_LIB([$CURSES_LIB_NAME], [set_escdelay],
[AC_DEFINE(HAVE_SET_ESCDELAY, 1, [Define this if your curses library has the set_escdelay() function.])],
[], [$CURSES_LIB])
AC_CHECK_LIB([$CURSES_LIB_NAME], [key_defined],
[AC_DEFINE(HAVE_KEY_DEFINED, 1, [Define this if your curses library has the key_defined() command.])],
[AC_DEFINE(HAVE_KEY_DEFINED, 1, [Define this if your curses library has the key_defined() function.])],
[], [$CURSES_LIB])
dnl Parse any configure options.
@@ -587,36 +611,43 @@ else
fi
fi
AC_CACHE_CHECK([for enhanced regular expression flag], nano_cv_flag_reg_extended,
AC_CACHE_CHECK([for enhanced regular expression flag], nano_cv_flag_reg_enhanced,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <regex.h>]],
[[
#ifndef REG_ENHANCED
error: No REG_ENHANCED support!
#endif
]])],
[nano_cv_flag_reg_extended="REG_EXTENDED | REG_ENHANCED"],
[nano_cv_flag_reg_extended="REG_EXTENDED"])])
[nano_cv_flag_reg_enhanced=yes],
[nano_cv_flag_reg_enhanced=no])])
dnl The bundled gnulib regex module doesn't support REG_ENHANCED.
if test "$ac_use_included_regex" = "yes"; then
nano_cv_flag_reg_enhanced="no"
fi
if test "$nano_cv_flag_reg_enhanced" = "yes"; then
nano_reg_extended="REG_EXTENDED | REG_ENHANCED"
else
nano_reg_extended="REG_EXTENDED"
fi
AC_DEFINE_UNQUOTED(NANO_REG_EXTENDED, $nano_cv_flag_reg_extended,
AC_DEFINE_UNQUOTED(NANO_REG_EXTENDED, $nano_reg_extended,
[Flag(s) to use to get the full range of extended regular expressions])
# Check for word-boundary support (/< and />).
AC_MSG_CHECKING([for GNU-style word boundary regex support])
AC_ARG_WITH(wordbounds,
AS_HELP_STRING([--with-wordbounds], [Use GNU-style word boundary delimiters]),
[ case "$with_wordbounds" in
no)
AC_MSG_RESULT(no)
;;
*)
AC_MSG_RESULT(yes)
# We explicitly don't check if the user forced the option, because
# this is needed for cross compilers and we can't test the target.
AC_DEFINE(GNU_WORDBOUNDS, 1, [Define this if the system supports GNU-style word boundaries in regexes.]) gnu_wordbounds=yes,
;;
esac
], [
AC_TRY_RUN([
[with_wordbounds=$withval], [with_wordbounds=auto])
if test "$with_wordbounds" != "no"; then
dnl If we're using the bundled gnulib regex module, we know it's supported.
if test "$ac_use_included_regex" = "yes"; then
with_wordbounds="yes"
fi
dnl We explicitly don't check if the user forced the option, because
dnl this is needed for cross compilers and we can't test the target.
if test "$with_wordbounds" != "yes"; then
AC_TRY_RUN([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@@ -627,18 +658,29 @@ int main(void)
size_t nmatch;
regmatch_t pmatch;
if (regcomp(&r, "\\\\>", $nano_cv_flag_reg_extended|REG_NOSUB))
if (regcomp(&r, "\\\\>", $nano_reg_extended|REG_NOSUB))
return 1;
if (regexec(&r, "word boundary", nmatch, &pmatch, 0))
return 1;
return 0;
}],
AC_MSG_RESULT(yes)
AC_DEFINE(GNU_WORDBOUNDS, 1, [Define this if the system supports GNU-style word boundaries in regexes.]) gnu_wordbounds=yes,
AC_MSG_RESULT(no),
AC_MSG_WARN([*** Can't check for GNU-style word boundary support when cross-compiling])
)
])
with_wordbounds="yes",
with_wordbounds="no",
with_wordbounds="cross")
fi
fi
case $with_wordbounds in
yes)
AC_MSG_RESULT(yes)
AC_DEFINE(GNU_WORDBOUNDS, 1, [Define this if the system supports GNU-style word boundaries in regexes.])
;;
no)
AC_MSG_RESULT(no)
;;
cross)
AC_MSG_WARN([*** Can't check for GNU-style word boundary support when cross-compiling])
;;
esac
if test x$color_support = xyes; then
# if test x$CURSES_LIB_NAME = xcurses; then
@@ -660,7 +702,7 @@ int main(void)
int testcolor = COLOR_WHITE;
return 0;
}],
AC_DEFINE(NEED_XOPEN_SOURCE_EXTENDED, 1, [Define this if you need the _XOPEN_SOURCE_EXTENDED macro for color support])
AC_DEFINE(NEED_XOPEN_SOURCE_EXTENDED, 1, [Define this if you need the _XOPEN_SOURCE_EXTENDED macro for color support.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(not sure)
AC_MSG_WARN([*** Couldn't successfully compile basic color test with or without _XOPEN_SOURCE_EXTENDED])
@@ -678,7 +720,7 @@ int main(void)
COLS = 25;
return 0;
}],
AC_DEFINE(REDEFINING_MACROS_OK, 1, [Define this if you know your curses library allows LINES and COLS to be redefined to deal with a resizing bug])
AC_DEFINE(REDEFINING_MACROS_OK, 1, [Define this if you know your curses library allows LINES and COLS to be redefined to deal with a resizing bug.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no),
AC_MSG_WARN([*** Can't check for macro redefinability when cross-compiling]))

View File

@@ -9,20 +9,21 @@
<h1>The GNU nano editor FAQ</h1>
<h2>Table of Contents</h2>
<h2><a href="#1">1. General</a></h2>
<blockquote><p><a href="#1.1">1.1 About this FAQ</a><br>
<a href="#1.2">1.2. How do I contribute to it?</a><br>
<a href="#1.3">1.3. What is GNU nano?</a><br>
<a href="#1.4">1.4. What is the history behind nano?</a><br>
<a href="#1.5">1.5. Why the name change from TIP?</a><br>
<a href="#1.6">1.6. What is the current version of nano?</a><br>
<a href="#1.7">1.7. I want to read the manpage without having to download the program!</a></p></blockquote>
<blockquote><p>
<a href="#1.1">1.1. What is GNU nano?</a><br>
<a href="#1.2">1.2. What is the history behind nano?</a><br>
<a href="#1.3">1.3. Why the name change from TIP?</a><br>
<a href="#1.4">1.4. What is the current version of nano?</a><br>
<a href="#1.5">1.5. I want to read the manpage without having to download the program!</a></p></blockquote>
<h2><a href="#2">2. Where to get GNU nano.</a></h2>
<blockquote><p><a href="#2.1">2.1. FTP and WWW sites that carry nano.</a><br>
<blockquote><p>
<a href="#2.1">2.1. FTP and WWW sites that carry nano.</a><br>
<a href="#2.2">2.2. RedHat and derivatives (.rpm) packages.</a><br>
<a href="#2.3">2.3. Debian (.deb) packages.</a><br>
<a href="#2.4">2.4. By GIT (for the brave).</a></p></blockquote>
<h2><a href="#3">3. Installation and Configuration</a></h2>
<blockquote><p><a href="#3.1">3.1. How do I install the RPM or DEB package?</a><br>
<blockquote><p>
<a href="#3.1">3.1. How do I install the RPM or DEB package?</a><br>
<a href="#3.2">3.2. Compiling from source: WHAT THE HECK DO I DO NOW?</a><br>
<a href="#3.3">3.3. Why does everything go into /usr/local?</a><br>
<a href="#3.5">3.5. nano should automatically run strip on the binary when installing it!</a><br>
@@ -32,44 +33,44 @@
<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>
<blockquote><p>
<a href="#4.1">4.1. How do I open a file with a name beginning with '+' from the command line?</a><br>
<a href="#4.2">4.2. Ack! My Backspace/Delete/Enter/Meta/double bucky key doesn't seem to work! What can I do?</a><br>
<a href="#4.3">4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</a><br>
<a href="#4.4">4.4. Ack! When I hold down a Meta key combination for a while, the character of the held key gets inserted now and then. What gives?</a><br>
<a href="#4.5">4.5. How do I type the F13-F16 keys shown in the help browser? My keyboard only has F1-F12!</a><br>
<a href="#4.5">4.5. How do I type the F13-F16 keys listed in the help viewer? My keyboard only has F1-F12!</a><br>
<a href="#4.6">4.6. nano crashes when I type &lt;insert keystroke here&gt;!</a><br>
<a href="#4.7">4.7. nano crashes when I resize my window. How can I fix that?</a><br>
<a href="#4.8">4.8. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</a><br>
<a href="#4.8a">4.8a. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</a><br>
<a href="#4.8b">4.8b. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?<a><br>
<a href="#4.9">4.9. I've compiled nano with color support, but I don't see any color when I run it!</a><br>
<a href="#4.10">4.10. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
<a href="#4.11">4.11. How do I select text for or paste text from the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?</a><br>
<a href="#4.12">4.12. On startup I get a message that says "Detected a legacy nano history file". Now older nano versions can't find my search history!</a></p></blockquote>
<h2><a href="#5">5. Internationalization</a></h2>
<blockquote><p><a href="#5.1">5.1. There's no translation for my language!</a><br>
<blockquote><p>
<a href="#5.1">5.1. There's no translation for my language!</a><br>
<a href="#5.2">5.2. I don't like the translation for &lt;x&gt; in my language. How can I fix it?</a><br>
<a href="#5.3">5.3. What is the status of Unicode support?</a></p></blockquote>
<h2><a href="#6">6. Advocacy and Licensing</a></h2>
<blockquote><p><a href="#6.1">6.1. Why should I use nano instead of Pico?</a><br>
<blockquote><p>
<a href="#6.1">6.1. Why should I use nano instead of Pico?</a><br>
<a href="#6.2">6.2. Why should I use Pico instead of nano?</a><br>
<a href="#6.3">6.3. What is so bad about the older Pine license?</a><br>
<a href="#6.4">6.4. Okay, well, what mail program should I use then?</a></p></blockquote>
<h2><a href="#7">7. Miscellaneous</a></h2>
<blockquote><p><a href="#7.1">7.1. nano-related mailing lists.</a><br>
<a href="#7.2">7.2. I want to send the development team a big load of cash (or just a thank you).</a><br>
<a href="#7.3">7.3. How do I submit a bug report or patch?</a><br>
<blockquote><p>
<a href="#7.1">7.1. Where can I ask questions or send suggestions?</a><br>
<a href="#7.2">7.2. How do I submit a bug report or patch?</a><br>
<a href="#7.3">7.3. I want to send the development team a big load of cash (or just a thank you).</a><br>
<a href="#7.4">7.4. How do I join the development team?</a><br>
<a href="#7.5">7.5. Can I have write access to the GIT tree?</a></p></blockquote>
<h2><a href="#8">8. ChangeLog</a></h2>
<hr width="100%">
<h1><a name="1"></a>1. General</h1>
<h2><a name="1.1"></a>1.1 About this FAQ</h2>
<blockquote><p>This FAQ was originally written and maintained by Chris Allegretta &lt;<a href="mailto:chrisa@asty.org">chrisa@asty.org</a>&gt;, who also happens to be the creator of nano. It was then maintained by David Lawrence Ramsey &lt;<a href="mailto:pooka109@gmail.com">pooka109@gmail.com</a>&gt;. Maybe someone else will volunteer to maintain this FAQ someday, who knows...</p></blockquote>
<h2><a name="1.2"></a>1.2. How do I contribute to it?</h2>
<blockquote><p>Your best bet is to send it to the nano email address, <a href="mailto:nano@nano-editor.org">nano@nano-editor.org</a> and if it is useful enough it will be included in future versions.</p></blockquote>
<h2><a name="1.3"></a>1.3. What is GNU nano?</h2>
<h2><a name="1.1"></a>1.1. What is GNU nano?</h2>
<blockquote><p>GNU nano is designed to be a free replacement for the Pico text editor, part of the Pine email suite from <a href="http://www.washington.edu/pine/">The University of Washington</a>. It aims to &quot;emulate Pico as closely as possible and then include extra functionality&quot;.</p></blockquote>
<h2><a name="1.4"></a>1.4. What is the history behind nano?</h2>
<h2><a name="1.2"></a>1.2. What is the history behind nano?</h2>
<blockquote><p>Funny you should ask!</p>
<p><b>In the beginning...</b></p>
<p>For years Pine was THE program used to read email on a Unix system. The Pico text editor is the portion of the program one would use to compose his or her mail messages. Many beginners to Unix flocked to Pico and Pine because of their well organized, easy to use interfaces. With the proliferation of GNU/Linux in the mid to late 90's, many University students became intimately familiar with the strengths (and weaknesses) of Pine and Pico.</p>
@@ -79,11 +80,11 @@
<p>It was in late 1999 when Chris Allegretta (our hero) was yet again complaining to himself about the less-than-perfect license Pico was distributed under, the 1000 makefiles that came with it and how just a few small improvements could make it the Best Editor in the World (TM). Having been a convert from Slackware to Debian, he missed having a simple binary package that included Pine and Pico, and had grown tired of downloading them himself.</p>
<p>Finally something snapped inside and Chris coded and hacked like a madman for many hours straight one weekend to make a (barely usable) Pico clone, at the time called TIP (Tip Isn't Pico). The program could not be invoked without a filename, could not save files, had no help text display, spell checker, and so forth. But over time it improved, and with the help of a few great coders it matured to the (hopefully) stable state it is in today.</p>
<p>In February 2001, nano was declared an official GNU program by Richard Stallman. nano also reached its first production release on March 22, 2001.</p></blockquote>
<h2><a name="1.5"></a>1.5. Why the name change from TIP?</h2>
<h2><a name="1.3"></a>1.3. Why the name change from TIP?</h2>
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program &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 version of nano <i>should</i> be <b>2.8.0</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<h2><a name="1.7"></a>1.7. I want to read the man page without having to download the program!</h2>
<h2><a name="1.4"></a>1.4. What is the current version of nano?</h2>
<blockquote><p>The current version of nano <i>should</i> be <b>2.8.2</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<h2><a name="1.5"></a>1.5. I want to read the man page without having to download the program!</h2>
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="https://nano-editor.org/dist/latest/nano.1.html">here</a>.</p></blockquote>
<hr width="100%">
@@ -138,24 +139,26 @@
<pre>
<b>--disable-browser</b> Disable the built-in file browser
<b>--disable-color</b> Disable color and syntax highlighting
<b>--disable-extra</b> Disable extra features (currently only an easter egg)
<b>--disable-help</b> Disable help functions
<b>--disable-comment</b> Disable the comment/uncomment function
<b>--disable-extra</b> Disable the easter egg
<b>--disable-help</b> Disable the built-in help texts
<b>--disable-histories</b> Disable the saving of search strings and cursor positions
<b>--disable-justify</b> Disable justify/unjustify functions
<b>--disable-justify</b> Disable the justify/unjustify functions
<b>--disable-libmagic</b> Disable the use of libmagic for determining a file's syntax
<b>--disable-linenumbers</b> Disable line numbering
<b>--disable-mouse</b> Disable mouse support
<b>--disable-multibuffer</b> Disable having multiple file buffers open
<b>--disable-multibuffer</b> Disable the opening of multiple file buffers
<b>--disable-nanorc</b> Disable the use of .nanorc files
<b>--disable-operatingdir</b> Disable the setting of an operating directory
<b>--disable-speller</b> Disable spell checker functions
<b>--disable-tabcomp</b> Disable tab completion functions
<b>--disable-wordcomp</b> Disable the word completion function
<b>--disable-speller</b> Disable the spell-checker functions
<b>--disable-tabcomp</b> Disable the tab-completion functions
<b>--disable-wordcomp</b> Disable the word-completion function
<b>--disable-wrapping</b> Disable all hard-wrapping of text</pre>
<p>There's also the <b>--enable-tiny</b> option which disables everything above, as well as some larger chunks of the program (like the marker code that you use with Control-^ to select text). Also, if you know you aren't going to be using other languages, you can use <b>--disable-nls</b> to disable internationalization and save a few K to a few dozen K depending on whether you have locale support on your system. And finally, there's always good old <b>strip</b> to strip all debugging code and code that exists in libraries on your system.</p>
<p>With <b>--disable-wrapping-as-root</b> you can disable any hard-wrapping by default when the user is root, useful to prevent accidentally changing long lines in system configuration files.</p>
</blockquote>
<h2><a name="3.7"></a>3.7. Tell me more about this multibuffer stuff!</h2>
<blockquote><p>To use multiple file buffers, you must not have configured nano with <b>--disable-multibuffer</b> nor with <b>--enable-tiny</b> (use <b>nano -V</b> to check the compilation options). Then when you want to insert a file into its own buffer instead of into the current file, just hit <b>Meta-F</b>, then insert the file as normal with <b>^R</b>. If you always want files to be loaded into their own buffers, use the <b>--multibuffer</b> or <b>-F</b> flag when you invoke nano.</p>
<blockquote><p>To use multiple file buffers, you must not have configured nano with <b>--disable-multibuffer</b> nor with <b>--enable-tiny</b> (use <b>nano -V</b> to check the compilation options). Then when you want to insert a file into its own buffer instead of into the current file, just hit <b>Meta-F</b> after typing <b>^R</b>. If you always want files to be loaded into their own buffers, use the <b>--multibuffer</b> or <b>-F</b> flag when you invoke nano.</p>
<p>You can move between the buffers you have open with the <b>Meta-&lt;</b> and <b>Meta-&gt;</b> keys, or more easily without holding Shift: <b>Meta-,</b> and <b>Meta-.</b> (clear as mud, right? =-). When you have more than one file buffer open, the ^X shortcut will say &quot;Close&quot;, instead of the normal &quot;Exit&quot; when only one buffer is open.</p></blockquote>
<h2><a name="3.8"></a>3.8. Tell me more about this verbatim input stuff!</h2>
<blockquote><p>When you want to insert a literal character into the file you're editing, such as a control character that nano usually treats as a command, first press <b>Meta-V</b> (if you're not at a prompt, you'll get the message &quot;Verbatim Input&quot; on the statusbar), then press the key(s) that generate the character you want.</p>
@@ -183,17 +186,19 @@
<h2><a name="4.3"></a>4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</h2>
<blockquote><p>You can use the <b>-K</b> or <b>--rebindkeypad</b> option on the command line, or add the line <b>set rebindkeypad</b> to your .nanorc. However, nano's mouse support won't work properly if you do any of these things.</p></blockquote>
<h2><a name="4.4"></a>4.4. Ack! When I hold down a Meta key combination for a while, the character of the held key gets inserted now and then. What gives?</h2>
<blockquote><p>This is a bug in the terminal, not in nano. When a key is repeating faster than nano can process it, the keyboard buffer becomes full and starts dropping incoming keystrokes. Unfortunately, it doesn't just drop whole keystrokes; it can also drop parts of multibyte key combinations, resulting in nano's receiving a wrong key.</p></blockquote>
<h2><a name="4.5"></a>4.5. How do I type the F13-F16 keys shown in the help browser? My keyboard only has F1-F12!</h2>
<blockquote><p>This was a bug in how nano handled consecutive escape sequences. It should be fixed since version 2.6.0.</p></blockquote>
<h2><a name="4.5"></a>4.5. How do I type the F13-F16 keys listed in the help viewer? My keyboard only has F1-F12!</h2>
<blockquote><p>It depends on the terminal type you're using. On some terminals, such as the FreeBSD console, xterm, konsole, and gnome-terminal, Shift-F1 to Shift-F4 will generate F13 to F16. On other terminals, such as the Linux console, rxvt, and Eterm, Shift-F3 to Shift-F6 will generate F13 to F16.</p></blockquote>
<h2><a name="4.6"></a>4.6. nano crashes when I type &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 tracker</a> on Savannah.</p></blockquote>
<h2><a name="4.7"></a>4.7. nano crashes when I resize my window. How can I fix that?</h2>
<blockquote><p>Older versions of nano had this problem. Please upgrade to version 2.7.0 or newer.</p></blockquote>
<h2><a name="4.8"></a>4.8. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</h2>
<h2><a name="4.8a"></a>4.8a. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</h2>
<blockquote><p>You have the autoindent feature turned on. Hit Meta-I to turn it off, paste your text, and then hit Meta-I again to turn it back on.</p></blockquote>
<h2><a name="4.8b"></a>4.8b. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?</h2>
<blockquote><p>When pasting from Windows, in some situations linefeeds are sent instead of carriage returns (Enters). And linefeeds are <b>^J</b>s, which make nano justify (rewrap) the current paragraph. To prevent these linefeeds from causing these unwanted justifications, add this line to your .nanorc on the remote Linux box: <b>unbind ^J main</b> or <b>bind ^J enter main</b>, depending on whether the paste contains CR + LF or only LF.</p></blockquote>
<h2><a name="4.9"></a>4.9. I've compiled nano with color support, but I don't see any color when I run it!</h2>
<blockquote><p>If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Several example configurations are in the <b>doc/syntax</b> subdirectory of the nano source, which are normally installed to <b>/usr/local/share/nano</b>. To enable all of them, uncomment the line <b># include "/usr/local/share/nano/*.nanorc"</b> in your nanorc. See also section <a href="#3.9a">3.9a</a>.</p></blockquote>
<blockquote><p>If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Several example configurations are in the <b>syntax/</b> subdirectory of the nano source, which are normally installed to <b>/usr/local/share/nano/</b>. To enable all of them, uncomment the line <b># include "/usr/local/share/nano/*.nanorc"</b> in your nanorc. See also section <a href="#3.9a">3.9a</a>.</p></blockquote>
<h2><a name="4.10"></a>4.10. How do I make nano my default editor (in Pine, mutt, etc.)?</h2>
<blockquote><p>You need to make nano your $EDITOR. If you want this to be saved, you should put a line like this in your <b>.bashrc</b> if you use bash (or <b>.zshrc</b> if you believe in zsh):</p>
<p><b>export EDITOR=/usr/local/bin/nano</b></p>
@@ -240,93 +245,22 @@
<hr width="100%">
<h1><a name="7"></a>7. Miscellaneous</h1>
<h2><a name="7.1"></a>7.1. nano-related mailing lists.</h2>
<h2><a name="7.1"></a>7.1. Where can I ask questions or send suggestions?</h2>
<blockquote><p>There are three mailing lists for nano hosted at <a href="http://savannah.gnu.org/">Savannah</a>: info-nano, help-nano and nano-devel. info-nano is a very low traffic list where new versions of nano are announced (surprise!). help-nano is for getting help with the editor without needing to hear all of the development issues surrounding it. nano-devel is a normally low, sometimes high traffic list for discussing the present and future development of nano. Here are links to where you can sign up for a given list:</p>
<p>info-nano - <a href="http://mail.gnu.org/mailman/listinfo/info-nano/">http://mail.gnu.org/mailman/listinfo/info-nano/</a><br>
help-nano - <a href="http://mail.gnu.org/mailman/listinfo/help-nano/">http://mail.gnu.org/mailman/listinfo/help-nano/</a><br>
nano-devel - <a href="http://mail.gnu.org/mailman/listinfo/nano-devel/">http://mail.gnu.org/mailman/listinfo/nano-devel/</a></p></blockquote>
<h2><a name="7.2"></a>7.2. I want to send the development team a big load of cash (or just a thank you).</h2>
<blockquote><p>That's fine. Send it <a href="mailto:nano-devel@gnu.org">our way</a>! Better yet, fix a <a href="https://savannah.gnu.org/bugs/?group=nano">bug</a> in the program or implement a <a href="https://nano-editor.org/dist/latest/TODO">cool feature</a> and send us that instead (though cash is fine too).</p></blockquote>
<h2><a name="7.3"></a>7.3. How do I submit a bug report or patch?</h2>
<h2><a name="7.2"></a>7.3. How do I submit a bug report or patch?</h2>
<blockquote>
<p>The best way to submit bugs is through the <a href="https://savannah.gnu.org/bugs/?group=nano">Savannah bug tracker</a>, as you can check whether the bug you are reporting has already been submitted, and it makes it easier for the maintainers to keep track of them.
<p>You can submit patches for nano via <a href="https://savannah.gnu.org/patch/?group=nano">Savannah's patch manager</a>.</p></blockquote>
<h2><a name="7.3"></a>7.3. I want to send the development team a big load of cash (or just a thank you).</h2>
<blockquote><p>That's fine. Send it <a href="mailto:nano-devel@gnu.org">our way</a>! Better yet, fix a <a href="https://savannah.gnu.org/bugs/?group=nano">bug</a> in the program or implement a <a href="https://nano-editor.org/dist/latest/TODO">cool feature</a> and send us that instead (though cash is fine too).</p></blockquote>
<h2><a name="7.4"></a>7.4. How do I join the development team?</h2>
<blockquote><p>The easiest way is to consistently send in good patches that add some needed functionality, fix a bug or two, and/or make the program more optimized/efficient. Then ask nicely and you will probably be added to the Savannah development list and be given write access after a while. There is a lot of responsibility that goes along with being a team member, so don't think it's just something to add to your resume.</p></blockquote>
<h2><a name="7.5"></a>7.5. Can I have write access to the git tree?</h2>
<blockquote><p>Re-read section <a href="#7.4">7.4</a> and you should know the answer.</p></blockquote>
<hr width="100%">
<h1><a name="8"></a>8. ChangeLog</h1>
<blockquote><p>
2017.01.09 - Delete some obsolete items and update a few others. (Benno)<br>
2016.04.17 - Update docs to refer to GIT instead of subversion. (Mike)<br>
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. (Chris)<br>
2007.12.21 - Update maintainer information. (DLR)<br>
2007.12.09 - Add minor punctuation and wording fixes, and update various sections to account for Alpine. (DLR)<br>
2007.08.26 - Update links to the Free Translation Project. (DLR)<br>
2007.07.29 - Update RPM links for nano 2.0.x. (DLR)<br>
2007.04.18 - Add a new section 4.14 to explain how autoindent affects pasted text. (John M. Gabriele, minor tweaks by DLR)<br>
2007.04.04 - Update email address. (DLR)<br>
2007.01.01 - Update section 4.1 to describe how to open files with names beginning with '+' at specified columns as well as lines. (DLR)<br>
2006.11.25 - Add miscellaneous wording and capitalization fixes. (DLR)<br>
2006.10.28 - Update various links for the 2.0 branch of nano. (DLR)<br>
2006.10.06 - Update the question in section 4.13 to match the version of it in the answer section. (DLR)<br>
2006.07.25 - Update section 5.3 again to not state &quot;the latest development version&quot; before 1.3.12, as it's no longer accurate. Also add some minor spacing fixes. (DLR)<br>
2006.06.12 - Update section 5.3, due to the display fix for two-column Unicode characters. (DLR)<br>
2006.06.05 - Add a new section 4.8, and move all section 4 entries after it down one number, to explain how to deal with glibc 2.2.3's crashes involving extended regular expressions. (DLR)<br>
2006.06.04 - Add minor punctuation, wording, and typo fixes. (DLR)<br>
2006.05.27 - Update section 3.8 to mention the new "Unicode Input" prompt, and how Unicode input only works when Unicode support is enabled. (DLR)<br>
2006.05.12 - Remove section 4.4, and move all section 4 entries after it up one number, since it no longer applies. Meta-] and Meta-[ are no longer used to indent and unindent marked text, since they require that the bracket matching key change to Ctrl-], which is used as the telnet escape key (found by Chris). Also, make the link to the nano CVS page a bit more readable. (DLR)<br>
2006.05.08 - Add a new section 4.5, and move all section 4 entries after it down one number, to explain a problem that can occur when holding down keys to generate Meta sequences. Also add a few more capitalization and wording fixes. (Benno Schulenberg, minor tweaks by DLR)<br>
2006.05.01 - Add a new section 4.4, and move all section 4 entries after it down one number, to explain how to deal with problems typing Meta-[. Also add a few capitalization and wording fixes. (DLR)<br>
2006.04.14 - Clarify section 1.4: help menu -> help text display. (DLR, suggested by Benno Schulenberg)<br>
2006.03.16 - Update the Free Translation Project's address, change the character set to UTF-8, and remove broken links to contributed RedHat nano packages. (DLR)<br>
2005.11.21 - Clarify section 5.3 to better explain how to enable Unicode support, and remove the mention of quirks, since they turned out to not be a nano problem. (Mike Frysinger and DLR)<br>
2005.11.19 - Add a new section 5.3 to explain the status of nano's Unicode support. (Mike Frysinger, minor tweaks by DLR)<br>
2005.08.27 - Update email address. (DLR)<br>
2005.08.10 - Add a new section 4.3, and move all section 4 entries after it down one number, to explain how to deal with numeric keypad problems. (DLR)<br>
2005.08.08 - Update section 3.8 to mention that verbatim input mode now takes a six-digit hexadecimal number. (DLR)<br>
2005.07.04 - Update section 4.10 to mention that pasting from the X clipboard via the middle mouse button also works when the Shift key is used. (DLR)<br>
2005.06.15 - Update description of --enable-extra, and add missing line breaks. (DLR)<br>
2005.06.13 - Minor capitalization and wording fixes. (DLR)<br>
2005.06.08 - Updated section 1.1 to mention the current maintainer. (DLR)<br>
2005.03.09 - Added question about opening files with names beginning with '+'s, and added a few more miscellaneous cosmetic fixes. (DLR)<br>
2005.01.03 - Removed now-inaccurate note about verbatim input's not working at prompts, and update its description to mention that it handles hexadecimal values now. (DLR)<br>
2004.11.21 - Listed sh as an example of a Bourne shell. (DLR)<br>
2004.11.05 - Fixed inaccuracy: Pico compatibility mode was made the default in nano 1.1.99pre1, not 1.2.2. Also added question about how to type F13-F16 on terminals lacking keys past F12 (suggested by Chris), question about how to select text for the clipboard in X terminals with nano's mouse support turned on (answer found by Joseph Birthisel), and misc. fixes and link updates. (DLR)<br>
2004.04.07 - Removed NumLock glitch question, as it's no longer needed. (DLR)<br>
2004.01.30 - Fixed inaccuracy: multibuffer mode was first in nano 1.1.0, not 1.1.12. (DLR)<br>
2003.12.31 - Added question about the new verbatim input function, and a few minor fixes. Removed reference to &quot;set pico&quot; (DLR).<br>
2003.07.02 - Added question about nano's not showing color when it's compiled with color support (DLR; suggested by Jordi).<br>
2003.02.23 - Updated RPM links for nano 1.2.x (DLR).<br>
2003.01.16 - Split section 4.5 into 4.5a and 4.5b for search string behavior. Added --enable-all docs.<br>
2002.12.28 - More misc. fixes (David Benbennick, DLR).<br>
2002.10.25 - Misc. fixes and link updates (DLR).<br>
2002.09.10 - Another typo fix (DLR).<br>
2002.05.15 - Typo fix (DLR).<br>
2001.12.26 - Misc. fixes (Aaron S. Hawley, DLR).<br>
2001.10.02 - Update for Free Translation Project.<br>
2001.10.02 - Assorted fixes, Debian additions.<br>
2001.06.30 - Silly typo fix.<br>
2001.05.05 - Spelling fixes by David Lawrence Ramsey.<br>
2001.05.02 - Misc fixes.<br>
2001.03.26 - Typo fix in an URL.<br>
2001.02.17 - Advocacy updates.<br>
2001.02.15 - Added GNU notes for 0.9.99pre3.<br>
2001.02.06 - Typo fixes.<br>
2001.01.14 - Added note about NumLock glitch.<br>
2001.01.10 - Linux -&gt; GNU/Linux.<br>
2001.01.09 - Added &quot;making exe smaller&quot; section.<br>
2000.12.19 - Typo and assorted error fixes.<br>
2000.11.28 - Added blurb about make install-strip.<br>
2000.11.19 - Changed Debian frozen to stable.<br>
2000.11.18 - Previous string display (4.5).<br>
2000.09.27 - Moved addresses to nano-editor.org.<br>
2000.06.31 - Initial framework.</p></blockquote>
</body>
</html>

View File

@@ -1,5 +1,4 @@
.\" Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
.\" 2009, 2010, 2013, 2014 Free Software Foundation, Inc.
.\" Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc.
.\"
.\" This document is dual-licensed. You may distribute and/or modify it
.\" under the terms of either of the following licenses:
@@ -17,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 2.8.0" "March 2017"
.TH NANO 1 "version 2.8.2" "May 2017"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
@@ -28,15 +27,14 @@ nano \- Nano's ANOther editor, an enhanced free Pico clone
.RI [ options "] [[+" line [, column "]]\ " file "]..."
.SH DESCRIPTION
\fBnano\fP is a small, free and friendly editor which aims to replace
Pico, the default editor included in the non-free Pine package. On
top of copying Pico's look and feel, \fBnano\fP also implements some
missing (or disabled by default) features in Pico, such as "search and
replace" and "go to line and column number".
\fBnano\fP is a small and friendly editor. It copies the look and feel
of Pico, but is free software, and implements several features that Pico
lacks, such as: opening multiple files, scrolling per line, undo/redo,
syntax coloring, line numbering, and soft-wrapping overlong lines.
When opening a file, the cursor can be put on a specific line by adding
the line number with a plus sign (\fB+\fR) before the filename, and even
in a specific column by adding it with a comma.
When giving a filename on the command line, the cursor can be put on a
specific line by adding the line number with a plus sign (\fB+\fR) before
the filename, and even in a specific column by adding it with a comma.
If the first file specified is a dash (\fB\-\fR), \fBnano\fR will read
data from standard input.
@@ -61,7 +59,7 @@ Since nano-2.7.0, text can also be selected by holding Shift and moving the
cursor with the arrow keys. Holding down the Alt key too will increase the
stride.
.PP
The two lines at the bottom of the screen show the most important commands;
The two lines at the bottom of the screen show some important commands;
the built-in help (\fB^G\fR) lists all the available ones.
The default key bindings can be changed via the .nanorc file -- see
.BR nanorc (5).
@@ -81,7 +79,7 @@ filename suffixed with a tilde (\fB~\fP).
.TP
.BR \-C\ \fIdirectory\fR ", " \-\-backupdir= \fIdirectory
Make and keep not just one backup file, but make and keep a uniquely
numbered one every time a file is saved -- when backups are enabled.
numbered one every time a file is saved -- when backups are enabled (\fB\-B\fR).
The uniquely numbered files are stored in the specified \fIdirectory\fR.
.TP
.BR \-D ", " \-\-boldtext
@@ -91,10 +89,10 @@ Use bold text instead of reverse video text.
Convert typed tabs to spaces.
.TP
.BR \-F ", " \-\-multibuffer
Enable multiple file buffers (if support for them has been compiled in).
Read a file into a new buffer by default.
.TP
.BR \-G ", " \-\-locking
Enable vim-style file locking when editing files.
Use vim-style file locking when editing files.
.TP
.BR \-H ", " \-\-historylog
Log search and replace strings to \fI~/.nano/search_history\fP, so they can be
@@ -138,7 +136,7 @@ This restricted mode is also accessible by invoking \fBnano\fP
with any name beginning with 'r' (e.g. "rnano").
.TP
.BR \-S ", " \-\-smooth
Enable smooth scrolling. Text will scroll line-by-line, instead of the
Use smooth scrolling: text will scroll line-by-line, instead of the
usual chunk-by-chunk behavior.
.TP
.BR \-T\ \fInumber\fR ", " \-\-tabsize= \fInumber
@@ -146,7 +144,7 @@ Set the size (width) of a tab to \fInumber\fP columns. The value of
\fInumber\fP must be greater than 0. The default value is 8.
.TP
.BR \-U ", " \-\-quickblank
Do quick statusbar blanking. Statusbar messages will disappear after 1
Do quick statusbar blanking: statusbar messages will disappear after 1
keystroke instead of 25. Note that \fB\-c\fP overrides this.
.TP
.BR \-V ", " \-\-version
@@ -166,7 +164,8 @@ Specify the name of the syntax highlighting to use from among the ones
defined in the \fInanorc\fP files.
.TP
.BR \-c ", " \-\-constantshow
Constantly show the cursor position. Note that this overrides \fB\-U\fP.
Constantly show the cursor position on the statusbar.
Note that this overrides \fB\-U\fP.
.TP
.BR \-d ", " \-\-rebinddelete
Interpret the Delete key differently so that both Backspace and Delete
@@ -301,7 +300,7 @@ Please report any other bugs that you encounter via:
\fIhttps://savannah.gnu.org/bugs/?group=nano\fR.
.SH HOMEPAGE
https://nano-editor.org/
\fIhttps://nano-editor.org/\fR
.SH SEE ALSO
.BR nanorc (5)

View File

@@ -6,8 +6,8 @@
@smallbook
@set EDITION 0.4
@set VERSION 2.8.0
@set UPDATED March 2017
@set VERSION 2.8.2
@set UPDATED May 2017
@dircategory Editors
@direntry
@@ -20,8 +20,8 @@
@titlepage
@title GNU @code{nano}
@subtitle a small and friendly text editor.
@subtitle version 2.8.0
@subtitle a small and friendly text editor
@subtitle version 2.8.2
@author Chris Allegretta
@page
@@ -30,8 +30,7 @@ This manual documents GNU @code{nano}, a small and friendly text editor.
This manual is part of the GNU @code{nano} distribution.@*
@sp 4
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
2009, 2014, 2015 Free Software Foundation, Inc.
Copyright (C) 1999-2009, 2014-2017 Free Software Foundation, Inc.
This document is dual-licensed. You may distribute and/or modify it
under the terms of either of the following licenses:
@@ -673,8 +672,9 @@ 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 @code{titlecolor}, @code{statuscolor}, and @code{keycolor}.
line numbers, and selected text. This can be overridden for the first four
by setting the options @code{titlecolor}, @code{statuscolor}, @code{keycolor},
and @code{numbercolor}.
@item set brackets "@var{string}"
Set the characters treated as closing brackets when justifying
@@ -893,12 +893,12 @@ via the following commands in a nanorc file:
@table @code
@item syntax "str" ["fileregex" @dots{}]
Defines a syntax named "str" which can be activated via the @code{-Y/--syntax}
@item syntax "name" ["fileregex" @dots{}]
Defines a syntax named "name" which can be activated via the @code{-Y/--syntax}
command-line option, or will be automatically activated if the current
filename matches the extended regular expression "fileregex". All
subsequent @code{color}, @code{icolor}, @code{header} and other such
statements will apply to this "str" syntax until a new @code{syntax}
statements will apply to this "name" syntax until a new @code{syntax}
command is encountered.
The "none" syntax is reserved; specifying it on the command line is the
@@ -947,26 +947,26 @@ terminal supports transparency, not specifying a "bgcolor" tells @code{nano}
to attempt to use a transparent background.
@item icolor fgcolor,bgcolor "regex" @dots{}
Same as above, except that the text matching is case insensitive.
Same as above, except that the matching is case insensitive.
@item color fgcolor,bgcolor start="sr" end="er"
@item color fgcolor,bgcolor start="fromrx" end="torx"
Display all pieces of text whose start matches extended regular expression
"sr" and whose end matches extended regular expression "er" with foreground
color "fgcolor" and background color "bgcolor", at least one of which
must be specified. This means that, after an initial instance of "sr",
all text will be highlighted until the first instance of "er".
"fromrx" and whose end matches extended regular expression "torx" with
foreground color "fgcolor" and background color "bgcolor", at least one of
which must be specified. This means that, after an initial instance of
"fromrx", all text until the first instance of "torx" will be colored.
This allows syntax highlighting to span multiple lines.
@item icolor fgcolor,bgcolor start="sr" end="er"
Same as above, except that the text matching is case insensitive.
@item icolor fgcolor,bgcolor start="fromrx" end="torx"
Same as above, except that the matching is case insensitive.
@item include "syntaxfile"
Read in self-contained color syntaxes from "syntaxfile". Note that
"syntaxfile" may contain only the above commands, from @code{syntax}
to @code{icolor}.
@item extendsyntax str directive [arg @dots{}]
Extend the syntax previously defined as str to include new information.
@item extendsyntax name directive [arg @dots{}]
Extend the syntax previously defined as "name" to include new information.
This allows you to add a new @code{color}, @code{icolor}, @code{header},
@code{magic}, @code{comment}, @code{linter}, or @code{formatter} directive to an already
defined syntax --- useful when you want to slightly improve a syntax defined
@@ -1428,6 +1428,13 @@ it can also be appended or prepended to an existing file.
When using the Read-File key (^R), @code{nano} can not just read a file,
it can also read the output of a command to be run (^X).
@item Reading from Working Directory
By default, Pico will read files from the user's home directory (when
using ^R), but it will write files to the current working directory
(when using ^O). @code{nano} makes this symmetrical: always reading
from and writing to the current working directory --- the directory
that @code{nano} was started in.
@item File Browser
In the file browser, @code{nano} does not implement the Add, Copy,
Rename, and Delete commands that Pico provides. In @code{nano} the
@@ -1473,15 +1480,18 @@ The possible options to @code{./configure} are:
@table @code
@item --disable-browser
Disable the mini file browser when reading or writing files.
Disable the mini file browser that can be called with ^T when reading
or writing files.
@item --disable-color
Disable support for the syntax coloring of files. This also eliminates
the @code{-Y} command-line option, which chooses a specific syntax.
@item --disable-comment
Disable the single-keystroke comment/uncomment function (M-3).
@item --disable-extra
Disable extra features. At the moment, this is just easter-egg-type
stuff.
Disable the Easter egg: a crawl of major contributors.
@item --disable-help
Disable the help function. Doing this makes the binary much smaller,
@@ -1503,6 +1513,10 @@ Disable the use of the library of magic-number tests (for determining
the file type and thus which syntax to use for colouring --- often the
tests on filename extension and header line will be enough).
@item --disable-linenumbers
Disable the line-numbering function (M-#). This also eliminates the
@code{-l} command-line option, which turns line numbering on.
@item --disable-mouse
Disable all mouse functionality. This also eliminates the @code{-m}
command-line option, which enables the mouse functionality.
@@ -1533,7 +1547,7 @@ command-line option, which allows specifying an alternate spell checker.
Disable tab completion (when nano asks for a filename or a search string).
@item --disable-wordcomp
Disable word completion.
Disable word completion (^]).
@item --disable-wrapping
Disable all hard-wrapping of overlong lines. This also eliminates the

View File

@@ -1,5 +1,4 @@
.\" Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
.\" 2013, 2014, 2015 Free Software Foundation, Inc.
.\" Copyright (C) 2003-2011, 2013-2017 Free Software Foundation, Inc.
.\"
.\" This document is dual-licensed. You may distribute and/or modify it
.\" under the terms of either of the following licenses:
@@ -17,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 2.8.0" "March 2017"
.TH NANORC 5 "version 2.8.2" "May 2017"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
@@ -76,8 +75,9 @@ Do backwards searches by default.
.TP
.B set boldtext
Use bold instead of reverse video for the titlebar, statusbar, key combos,
and selected text. This can be overridden for the first three by setting
the options \fBtitlecolor\fP, \fBstatuscolor\fP, and \fBkeycolor\fP.
line numbers, and selected text. This can be overridden for the first four
by setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, \fBkeycolor\fP,
and \fBnumbercolor\fP.
.TP
.B set brackets "\fIstring\fP"
Set the characters treated as closing brackets when justifying
@@ -289,14 +289,14 @@ good fit for a small editor like \fBnano\fR.
A separate syntax can be defined for each kind of file
via the following commands:
.TP
.BR syntax " ""\fIstr\fR"" [""\fIfileregex\fR"" ...]"
Defines a syntax named \fIstr\fP which can be activated via the
.BR syntax " ""\fIname\fR"" [""\fIfileregex\fR"" ...]"
Defines a syntax named \fIname\fP which can be activated via the
.BR \-Y / \-\-syntax
command-line option, or will be automatically activated if
the current filename matches the extended regular expression
\fIfileregex\fP. All subsequent \fBcolor\fR, \fBicolor\fR,
\fBheader\fR and other such statements will apply to this
\fIstr\fP syntax until a new \fBsyntax\fR command is encountered.
\fIname\fP syntax until a new \fBsyntax\fR command is encountered.
The \fBnone\fP syntax is reserved; specifying it on the command line is
the same as not having a syntax at all. The \fBdefault\fP syntax is
@@ -346,32 +346,33 @@ foreground. If your terminal supports transparency, not specifying a
background.
.TP
.B icolor \fIfgcolor\fR,\fIbgcolor\fR """\fIregex\fR""" ...
Same as above, except that the text matching is case insensitive.
Same as above, except that the matching is case insensitive.
.TP
.BR color " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIsr\fR"" " end= """\fIer\fR""
.BR color " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIfromrx\fR"" " end= """\fItorx\fR""
Display all pieces of text whose start matches extended regular expression
\fIsr\fP and whose end matches extended regular expression \fIer\fP with
\fIfromrx\fP and whose end matches extended regular expression \fItorx\fP with
foreground color \fIfgcolor\fP and background color \fIbgcolor\fP,
at least one of which must be specified. This means that, after an
initial instance of \fIsr\fP, all text will be highlighted until the
first instance of \fIer\fP. This allows syntax highlighting to span
initial instance of \fIfromrx\fP, all text until the first instance of
\fItorx\fP will be colored. This allows syntax highlighting to span
multiple lines.
.TP
.BR icolor " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIsr\fR"" " end= """\fIer\fR""
Same as above, except that the text matching is case insensitive.
.BR icolor " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIfromrx\fR"" " end= """\fItorx\fR""
Same as above, except that the matching is case insensitive.
.TP
.BR include " ""\fIsyntaxfile\fR"""
Read in self-contained color syntaxes from \fIsyntaxfile\fP. Note that
\fIsyntaxfile\fP may contain only the above commands, from \fBsyntax\fP
to \fBicolor\fP.
.TP
.BI extendsyntax " str directive " \fR[ "arg " \fR...]
Extend the syntax previously defined as \fIstr\fP to include
new information. This allows you to add a new \fBcolor\fP, \fBicolor\fP,
\fBheader\fP, \fBmagic\fP, \fBcomment\fP, \fBlinter\fP, or \fBformatter\fP directive
to an already defined syntax -- useful when you want to
.BI extendsyntax " name directive " \fR[ "arg " \fR...]
Extend the syntax previously defined as \fIname\fP to include
new information. This allows adding a new \fBcolor\fP, \fBicolor\fP,
\fBheader\fP, \fBmagic\fP, \fBcomment\fP, \fBlinter\fP, or \fBformatter\fP
directive to an already defined syntax -- useful when you want to
slightly improve a syntax defined in one of the system-installed
files (which are normally not writable)
files (which are normally not writable).
.SH REBINDING KEYS
Key bindings can be changed via the following two commands:
.TP

View File

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

1066
po/bg.po

File diff suppressed because it is too large Load Diff

1066
po/ca.po

File diff suppressed because it is too large Load Diff

1066
po/cs.po

File diff suppressed because it is too large Load Diff

1169
po/da.po

File diff suppressed because it is too large Load Diff

1068
po/de.po

File diff suppressed because it is too large Load Diff

1068
po/eo.po

File diff suppressed because it is too large Load Diff

1096
po/es.po

File diff suppressed because it is too large Load Diff

1066
po/eu.po

File diff suppressed because it is too large Load Diff

1106
po/fi.po

File diff suppressed because it is too large Load Diff

1140
po/fr.po

File diff suppressed because it is too large Load Diff

1068
po/ga.po

File diff suppressed because it is too large Load Diff

1066
po/gl.po

File diff suppressed because it is too large Load Diff

2064
po/hr.po

File diff suppressed because it is too large Load Diff

1262
po/hu.po

File diff suppressed because it is too large Load Diff

1122
po/id.po

File diff suppressed because it is too large Load Diff

1066
po/it.po

File diff suppressed because it is too large Load Diff

1242
po/ja.po

File diff suppressed because it is too large Load Diff

1066
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1068
po/nb.po

File diff suppressed because it is too large Load Diff

1090
po/nl.po

File diff suppressed because it is too large Load Diff

1122
po/nn.po

File diff suppressed because it is too large Load Diff

1066
po/pl.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1130
po/ro.po

File diff suppressed because it is too large Load Diff

1064
po/ru.po

File diff suppressed because it is too large Load Diff

1066
po/sl.po

File diff suppressed because it is too large Load Diff

1066
po/sr.po

File diff suppressed because it is too large Load Diff

1066
po/sv.po

File diff suppressed because it is too large Load Diff

1986
po/tr.po

File diff suppressed because it is too large Load Diff

1066
po/uk.po

File diff suppressed because it is too large Load Diff

1070
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

@@ -1,8 +1,7 @@
/**************************************************************************
* browser.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, *
* 2010, 2011, 2013, 2014, 2015 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2015, 2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -123,7 +122,7 @@ char *do_browser(char *path)
kbinput = get_kbinput(edit);
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y;
@@ -152,7 +151,7 @@ char *do_browser(char *path)
continue;
}
#endif /* !DISABLE_MOUSE */
#endif /* ENABLE_MOUSE */
func = parse_browser_input(&kbinput);
@@ -163,7 +162,7 @@ char *do_browser(char *path)
kbinput = KEY_WINCH;
#endif
} else if (func == do_help_void) {
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
do_help_void();
#ifndef NANO_TINY
/* The window dimensions might have changed, so act as if. */
@@ -198,6 +197,17 @@ char *do_browser(char *path)
} else if (func == do_down_void) {
if (selected + width <= filelist_len - 1)
selected += width;
} else if (func == do_prev_block) {
selected = ((selected / (editwinrows * width)) *
editwinrows * width) + selected % width;
} else if (func == do_next_block) {
selected = ((selected / (editwinrows * width)) *
editwinrows * width) + selected % width +
editwinrows * width - width;
if (selected >= filelist_len)
selected = (filelist_len / width) * width + selected % width;
if (selected >= filelist_len)
selected -= width;
} else if (func == do_page_up) {
if (selected < width)
selected = 0;
@@ -480,7 +490,11 @@ functionptrtype parse_browser_input(int *kbinput)
return do_enter;
case 'W':
case 'w':
case '/':
return do_search;
case 'N':
case 'n':
return do_research;
}
}
return func_from_key(kbinput);

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* chars.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, *
* 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -71,13 +70,11 @@ void mbtowc_reset(void)
/* This function is equivalent to isalpha() for multibyte characters. */
bool is_alpha_mbchar(const char *c)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
return 0;
}
@@ -91,13 +88,11 @@ bool is_alpha_mbchar(const char *c)
/* This function is equivalent to isalnum() for multibyte characters. */
bool is_alnum_mbchar(const char *c)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
return 0;
}
@@ -111,13 +106,11 @@ bool is_alnum_mbchar(const char *c)
/* This function is equivalent to isblank() for multibyte characters. */
bool is_blank_mbchar(const char *c)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
return 0;
}
@@ -159,13 +152,11 @@ bool is_cntrl_mbchar(const char *c)
/* This function is equivalent to ispunct() for multibyte characters. */
bool is_punct_mbchar(const char *c)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
return 0;
}
@@ -188,7 +179,7 @@ bool is_word_mbchar(const char *c, bool allow_punct)
return TRUE;
if (word_chars != NULL && *word_chars != '\0') {
char symbol[mb_cur_max() + 1];
char symbol[MAXCHARLEN + 1];
int symlen = parse_mbchar(c, symbol, NULL);
symbol[symlen] = '\0';
@@ -235,12 +226,10 @@ char control_mbrep(const char *c, bool isdata)
* return the number of columns that the character occupies. */
int length_of_char(const char *c, int *width)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
int charlen = mbtowc(&wc, c, MB_CUR_MAX);
int charlen = mbtowc(&wc, c, MAXCHARLEN);
/* If the sequence is invalid... */
if (charlen < 0) {
@@ -266,14 +255,12 @@ int length_of_char(const char *c, int *width)
/* This function is equivalent to wcwidth() for multibyte characters. */
int mbwidth(const char *c)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
int width;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
return 1;
}
@@ -289,17 +276,6 @@ int mbwidth(const char *c)
return 1;
}
/* Return the maximum length (in bytes) of a character. */
int mb_cur_max(void)
{
#ifdef ENABLE_UTF8
if (use_utf8)
return MB_CUR_MAX;
else
#endif
return 1;
}
/* Convert the Unicode value in chr to a multibyte character, if possible.
* If the conversion succeeds, return the (dynamically allocated) multibyte
* character and its length. Otherwise, return an undefined (dynamically
@@ -310,7 +286,7 @@ char *make_mbchar(long chr, int *chr_mb_len)
#ifdef ENABLE_UTF8
if (use_utf8) {
chr_mb = charalloc(MB_CUR_MAX);
chr_mb = charalloc(MAXCHARLEN);
*chr_mb_len = wctomb(chr_mb, (wchar_t)chr);
/* Reject invalid Unicode characters. */
@@ -333,14 +309,10 @@ char *make_mbchar(long chr, int *chr_mb_len)
* col isn't NULL, add the character's width (in columns) to it. */
int parse_mbchar(const char *buf, char *chr, size_t *col)
{
int length;
assert(buf != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
/* Get the number of bytes in the multibyte character. */
length = mblen(buf, MB_CUR_MAX);
int length = mblen(buf, MAXCHARLEN);
/* When the multibyte sequence is invalid, only take the first byte. */
if (length <= 0) {
@@ -370,12 +342,11 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
} else
*col += mbwidth(buf);
}
return length;
} else
#endif
{
/* A byte character is one byte long. */
length = 1;
/* When requested, store the byte character in chr. */
if (chr != NULL)
*chr = *buf;
@@ -394,9 +365,9 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
else
(*col)++;
}
}
return length;
return 1;
}
}
/* Return the index in buf of the beginning of the multibyte character
@@ -405,15 +376,15 @@ size_t move_mbleft(const char *buf, size_t pos)
{
size_t before, char_len = 0;
assert(buf != NULL && pos <= strlen(buf));
assert(pos <= strlen(buf));
/* There is no library function to move backward one multibyte
* character. So we just start groping for one at the farthest
* possible point. */
if (mb_cur_max() > pos)
if (pos < MAXCHARLEN)
before = 0;
else
before = pos - mb_cur_max();
before = pos - MAXCHARLEN;
while (before < pos) {
char_len = parse_mbchar(buf + before, NULL, NULL);
@@ -446,12 +417,12 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
while (*s1 != '\0' && *s2 != '\0' && n > 0) {
bool bad1 = FALSE, bad2 = FALSE;
if (mbtowc(&wc1, s1, MB_CUR_MAX) < 0) {
if (mbtowc(&wc1, s1, MAXCHARLEN) < 0) {
mbtowc_reset();
bad1 = TRUE;
}
if (mbtowc(&wc2, s2, MB_CUR_MAX) < 0) {
if (mbtowc(&wc2, s2, MAXCHARLEN) < 0) {
mbtowc_reset();
bad2 = TRUE;
}
@@ -485,12 +456,7 @@ char *mbstrcasestr(const char *haystack, const char *needle)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
size_t needle_len;
if (*needle == '\0')
return (char *)haystack;
needle_len = mbstrlen(needle);
size_t needle_len = mbstrlen(needle);
while (*haystack != '\0') {
if (mbstrncasecmp(haystack, needle, needle_len) == 0)
@@ -506,19 +472,13 @@ char *mbstrcasestr(const char *haystack, const char *needle)
}
/* This function is equivalent to strstr(), except in that it scans the
* string in reverse, starting at rev_start. */
* string in reverse, starting at pointer. */
char *revstrstr(const char *haystack, const char *needle,
const char *pointer)
{
size_t needle_len = strlen(needle);
size_t tail_len = strlen(pointer);
if (needle_len == 0)
return (char *)pointer;
if (strlen(haystack) < needle_len)
return NULL;
if (tail_len < needle_len)
pointer += tail_len - needle_len;
@@ -532,65 +492,53 @@ char *revstrstr(const char *haystack, const char *needle,
}
/* This function is equivalent to strcasestr(), except in that it scans
* the string in reverse, starting at rev_start. */
char *revstrcasestr(const char *haystack, const char *needle, const char
*rev_start)
* the string in reverse, starting at pointer. */
char *revstrcasestr(const char *haystack, const char *needle,
const char *pointer)
{
size_t rev_start_len, needle_len;
size_t needle_len = strlen(needle);
size_t tail_len = strlen(pointer);
if (*needle == '\0')
return (char *)rev_start;
if (tail_len < needle_len)
pointer += tail_len - needle_len;
needle_len = strlen(needle);
if (strlen(haystack) < needle_len)
return NULL;
rev_start_len = strlen(rev_start);
for (; rev_start >= haystack; rev_start--, rev_start_len++) {
if (rev_start_len >= needle_len && strncasecmp(rev_start,
needle, needle_len) == 0)
return (char *)rev_start;
while (pointer >= haystack) {
if (strncasecmp(pointer, needle, needle_len) == 0)
return (char *)pointer;
pointer--;
}
return NULL;
}
/* This function is equivalent to strcasestr() for multibyte strings,
* except in that it scans the string in reverse, starting at rev_start. */
char *mbrevstrcasestr(const char *haystack, const char *needle, const
char *rev_start)
* except in that it scans the string in reverse, starting at pointer. */
char *mbrevstrcasestr(const char *haystack, const char *needle,
const char *pointer)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
size_t rev_start_len, needle_len;
size_t needle_len = mbstrlen(needle);
size_t tail_len = mbstrlen(pointer);
if (*needle == '\0')
return (char *)rev_start;
if (tail_len < needle_len)
pointer += tail_len - needle_len;
needle_len = mbstrlen(needle);
if (mbstrlen(haystack) < needle_len)
if (pointer < haystack)
return NULL;
rev_start_len = mbstrlen(rev_start);
while (TRUE) {
if (rev_start_len >= needle_len &&
mbstrncasecmp(rev_start, needle, needle_len) == 0)
return (char *)rev_start;
if (mbstrncasecmp(pointer, needle, needle_len) == 0)
return (char *)pointer;
/* If we've reached the head of the haystack, we found nothing. */
if (rev_start == haystack)
if (pointer == haystack)
return NULL;
rev_start = haystack + move_mbleft(haystack, rev_start - haystack);
rev_start_len++;
pointer = haystack + move_mbleft(haystack, pointer - haystack);
}
} else
#endif
return revstrcasestr(haystack, needle, rev_start);
return revstrcasestr(haystack, needle, pointer);
}
/* This function is equivalent to strlen() for multibyte strings. */
@@ -620,16 +568,14 @@ size_t mbstrnlen(const char *s, size_t maxlen)
/* This function is equivalent to strchr() for multibyte strings. */
char *mbstrchr(const char *s, const char *c)
{
assert(s != NULL && c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
bool bad_s_mb = FALSE, bad_c_mb = FALSE;
char symbol[MB_CUR_MAX];
char symbol[MAXCHARLEN];
const char *q = s;
wchar_t ws, wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
wc = (unsigned char)*c;
bad_c_mb = TRUE;
@@ -678,55 +624,50 @@ char *mbstrpbrk(const char *s, const char *accept)
return (char *) strpbrk(s, accept);
}
/* This function is equivalent to strpbrk(), except in that it scans the
* string in reverse, starting at rev_start. */
char *revstrpbrk(const char *s, const char *accept, const char
*rev_start)
/* Locate, in the string that starts at head, the first occurrence of any of
* the characters in the string accept, starting from pointer and searching
* backwards. */
char *revstrpbrk(const char *head, const char *accept, const char *pointer)
{
assert(s != NULL && accept != NULL && rev_start != NULL);
if (*rev_start == '\0') {
if (rev_start == s)
if (*pointer == '\0') {
if (pointer == head)
return NULL;
rev_start--;
pointer--;
}
for (; rev_start >= s; rev_start--) {
if (strchr(accept, *rev_start) != NULL)
return (char *)rev_start;
while (pointer >= head) {
if (strchr(accept, *pointer) != NULL)
return (char *)pointer;
pointer--;
}
return NULL;
}
/* This function is equivalent to strpbrk() for multibyte strings,
* except in that it scans the string in reverse, starting at rev_start. */
char *mbrevstrpbrk(const char *s, const char *accept, const char
*rev_start)
/* The same as the preceding function but then for multibyte strings. */
char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer)
{
assert(s != NULL && accept != NULL && rev_start != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
if (*rev_start == '\0') {
if (rev_start == s)
if (*pointer == '\0') {
if (pointer == head)
return NULL;
rev_start = s + move_mbleft(s, rev_start - s);
pointer = head + move_mbleft(head, pointer - head);
}
while (TRUE) {
if (mbstrchr(accept, rev_start) != NULL)
return (char *)rev_start;
if (mbstrchr(accept, pointer) != NULL)
return (char *)pointer;
/* If we've reached the head of the string, we found nothing. */
if (rev_start == s)
if (pointer == head)
return NULL;
rev_start = s + move_mbleft(s, rev_start - s);
pointer = head + move_mbleft(head, pointer - head);
}
} else
#endif
return revstrpbrk(s, accept, rev_start);
return revstrpbrk(head, accept, pointer);
}
#endif /* !NANO_TINY */
@@ -749,7 +690,7 @@ bool has_blank_mbchars(const char *s)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
char symbol[MB_CUR_MAX];
char symbol[MAXCHARLEN];
for (; *s != '\0'; s += move_mbright(s, 0)) {
parse_mbchar(s, symbol, NULL);

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* color.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, *
* 2010, 2011, 2013, 2014, 2015 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2014, 2015, 2016, 2017 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -133,6 +132,8 @@ void color_init(void)
fprintf(stderr, "init_pair(): fg = %hd, bg = %hd\n", foreground, background);
#endif
}
have_palette = TRUE;
}
/* Try to match the given shibboleth string with one of the regexes in

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* cut.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2014 Mark Majeres *
* Copyright (C) 2016 Benno Schulenberg *
* *
@@ -109,8 +108,8 @@ void cut_to_eof(void)
}
#endif /* !NANO_TINY */
/* Move text from the current filestruct into the cutbuffer. If
* copy_text is TRUE, copy the text back into the filestruct afterward.
/* Move text from the current buffer into the cutbuffer. If
* copy_text is TRUE, copy the text back into the buffer afterward.
* If cut_till_eof is TRUE, move all text from the current cursor
* position to the end of the file into the cutbuffer. */
void do_cut_text(bool copy_text, bool cut_till_eof)
@@ -202,7 +201,7 @@ void do_cut_text(bool copy_text, bool cut_till_eof)
#endif
}
/* Move text from the current filestruct into the cutbuffer. */
/* Move text from the current buffer into the cutbuffer. */
void do_cut_text_void(void)
{
#ifndef NANO_TINY
@@ -215,8 +214,8 @@ void do_cut_text_void(void)
}
#ifndef NANO_TINY
/* Move text from the current filestruct into the cutbuffer, and copy it
* back into the filestruct afterward. If the mark is set or the cursor
/* Move text from the current buffer into the cutbuffer, and copy it
* back into the buffer afterward. If the mark is set or the cursor
* was moved, blow away previous contents of the cutbuffer. */
void do_copy_text(void)
{
@@ -255,7 +254,7 @@ void do_cut_till_eof(void)
}
#endif /* !NANO_TINY */
/* Copy text from the cutbuffer into the current filestruct. */
/* Copy text from the cutbuffer into the current buffer. */
void do_uncut_text(void)
{
ssize_t was_lineno = openfile->current->lineno;
@@ -274,7 +273,7 @@ void do_uncut_text(void)
was_leftedge = (xplustabs() / editwincols) * editwincols;
#endif
/* Add a copy of the text in the cutbuffer to the current filestruct
/* Add a copy of the text in the cutbuffer to the current buffer
* at the current cursor position. */
copy_from_buffer(cutbuffer);
@@ -292,8 +291,8 @@ void do_uncut_text(void)
/* Mark the file as modified. */
set_modified();
/* Update the cursor position to account for the inserted lines. */
reset_cursor();
/* Update current_y to account for the inserted lines. */
place_the_cursor();
refresh_needed = TRUE;

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* files.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2015, 2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -63,32 +62,29 @@ bool has_valid_path(const char *filename)
return validity;
}
/* Add an entry to the circular list of openfile structs. */
/* Add an item to the circular list of openfile structs. */
void make_new_buffer(void)
{
openfilestruct *newnode = make_new_opennode();
if (openfile == NULL) {
openfile = make_new_opennode();
/* Make the first open file the only element in the list. */
openfile->prev = openfile;
openfile->next = openfile;
newnode->prev = newnode;
newnode->next = newnode;
} else {
openfilestruct *newnode = make_new_opennode();
/* Add the new open file after the current one in the list. */
newnode->prev = openfile;
newnode->next = openfile->next;
openfile->next->prev = newnode;
openfile->next = newnode;
/* Make the new file the current one. */
openfile = newnode;
/* There is more than one file open: show Close in help lines. */
/* There is more than one file open: show "Close" in help lines. */
exitfunc->desc = close_tag;
}
/* Start initializing the new buffer. */
/* Make the new buffer the current one, and start initializing it. */
openfile = newnode;
openfile->filename = mallocstrcpy(NULL, "");
initialize_buffer_text();
@@ -118,11 +114,9 @@ void make_new_buffer(void)
#endif
}
/* Initialize the text of the current openfile struct. */
/* Initialize the text and pointers of the current openfile struct. */
void initialize_buffer_text(void)
{
assert(openfile != NULL);
openfile->fileage = make_new_node(NULL);
openfile->fileage->data = mallocstrcpy(NULL, "");
@@ -471,12 +465,12 @@ bool open_buffer(const char *filename, bool undoable)
if (new_buffer) {
make_new_buffer();
if (has_valid_path(realname)) {
if (!inhelp && has_valid_path(realname)) {
#ifndef NANO_TINY
if (ISSET(LOCKING) && filename[0] != '\0') {
/* When not overriding an existing lock, discard the buffer. */
if (do_lockfile(realname) < 0) {
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
close_buffer();
#endif
free(realname);
@@ -490,7 +484,7 @@ bool open_buffer(const char *filename, bool undoable)
/* If the filename isn't blank, and we are not in NOREAD_MODE,
* open the file. Otherwise, treat it as a new file. */
rc = (filename[0] != '\0' && !ISSET(NOREAD_MODE)) ?
open_file(realname, new_buffer, FALSE, &f) : -2;
open_file(realname, new_buffer, inhelp, &f) : -2;
/* If we have a file, and we're loading into a new buffer, update
* the filename. */
@@ -584,31 +578,29 @@ void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
if (!old_no_newlines)
UNSET(NO_NEWLINES);
}
#endif /* !ENABLE_TINY */
#endif /* !NANO_TINY */
#endif /* !DISABLE_SPELLER */
/* Update the screen to account for the current buffer. */
void display_buffer(void)
/* Update the titlebar and the multiline cache to match the current buffer. */
void prepare_for_display(void)
{
/* Update the titlebar, since the filename may have changed. */
titlebar(NULL);
if (!inhelp)
titlebar(NULL);
#ifndef DISABLE_COLOR
/* Make sure we're using the buffer's associated colors. */
color_init();
/* If there are multiline coloring regexes, and there is no
* multiline cache data yet, precalculate it now. */
if (openfile->syntax && openfile->syntax->nmultis > 0 &&
openfile->fileage->multidata == NULL)
precalc_multicolorinfo();
#endif
/* Update the content of the edit window straightaway. */
edit_refresh();
have_palette = FALSE;
#endif
refresh_needed = TRUE;
}
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
/* Switch to a neighbouring file buffer; to the next if to_next is TRUE;
* otherwise, to the previous one. */
void switch_to_prevnext_buffer(bool to_next)
@@ -616,7 +608,7 @@ void switch_to_prevnext_buffer(bool to_next)
assert(openfile != NULL);
/* If only one file buffer is open, say so and get out. */
if (openfile == openfile->next) {
if (openfile == openfile->next && !inhelp) {
statusbar(_("No more open file buffers"));
return;
}
@@ -636,13 +628,14 @@ void switch_to_prevnext_buffer(bool to_next)
openfile->firstcolumn = 0;
#endif
/* Update the screen to account for the current buffer. */
display_buffer();
/* Update titlebar and multiline info to match the current buffer. */
prepare_for_display();
/* Indicate the switch on the statusbar. */
statusline(HUSH, _("Switched to %s"),
((openfile->filename[0] == '\0') ?
_("New Buffer") : openfile->filename));
if (!inhelp)
statusline(HUSH, _("Switched to %s"),
((openfile->filename[0] == '\0') ?
_("New Buffer") : openfile->filename));
#ifdef DEBUG
dump_filestruct(openfile->current);
@@ -690,7 +683,7 @@ bool close_buffer(void)
return TRUE;
}
#endif /* !DISABLE_MULTIBUFFER */
#endif /* ENABLE_MULTIBUFFER */
/* Do a quick permissions check by verifying whether the file is appendable.
* Err on the side of permissiveness (reporting TRUE when it might be wrong)
@@ -909,6 +902,10 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
/* Set the desired x position at the end of what was inserted. */
openfile->placewewant = xplustabs();
/* If we've read a help file, don't give any feedback. */
if (inhelp)
return;
if (!writable)
statusline(ALERT, _("File '%s' is unwritable"), filename);
#ifndef NANO_TINY
@@ -1002,7 +999,7 @@ int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
if (*f == NULL) {
statusline(ALERT, _("Error reading %s: %s"), filename, strerror(errno));
close(fd);
} else
} else if (!inhelp)
statusbar(_("Reading File"));
}
@@ -1067,7 +1064,7 @@ void do_insertfile(void)
while (TRUE) {
#ifndef NANO_TINY
if (execute) {
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER))
/* TRANSLATORS: The next four messages are prompts. */
msg = _("Command to execute in new buffer");
@@ -1077,7 +1074,7 @@ void do_insertfile(void)
} else
#endif /* NANO_TINY */
{
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER))
msg = _("File to insert into new buffer [from %s]");
else
@@ -1115,7 +1112,7 @@ void do_insertfile(void)
given = mallocstrcpy(given, answer);
#ifndef NANO_TINY
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
if (func == new_buffer_void) {
/* Don't allow toggling when in view mode. */
if (!ISSET(VIEW_MODE))
@@ -1150,7 +1147,7 @@ void do_insertfile(void)
#ifndef NANO_TINY
if (execute) {
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
/* When in multibuffer mode, first open a blank buffer. */
if (ISSET(MULTIBUFFER))
open_buffer("", FALSE);
@@ -1158,7 +1155,7 @@ void do_insertfile(void)
/* Save the command's output in the current buffer. */
execute_command(answer);
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
/* If this is a new buffer, put the cursor at the top. */
if (ISSET(MULTIBUFFER)) {
openfile->current = openfile->fileage;
@@ -1179,7 +1176,7 @@ void do_insertfile(void)
open_buffer(answer, TRUE);
}
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER)) {
#ifndef DISABLE_HISTORIES
if (ISSET(POS_HISTORY)) {
@@ -1192,17 +1189,17 @@ void do_insertfile(void)
}
#endif /* !DISABLE_HISTORIES */
/* Update stuff to account for the current buffer. */
display_buffer();
prepare_for_display();
} else
#endif /* !DISABLE_MULTIBUFFER */
#endif /* ENABLE_MULTIBUFFER */
{
/* Mark the file as modified if it changed. */
if (openfile->current->lineno != was_current_lineno ||
openfile->current_x != was_current_x)
set_modified();
/* Update the cursor position to account for inserted lines. */
reset_cursor();
/* Update current_y to account for inserted lines. */
place_the_cursor();
refresh_needed = TRUE;
}
@@ -1219,7 +1216,7 @@ void do_insertfile_void(void)
{
if (ISSET(RESTRICTED))
show_restricted_warning();
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
else if (ISSET(VIEW_MODE) && !ISSET(MULTIBUFFER))
statusbar(_("Key invalid in non-multibuffer mode"));
#endif
@@ -1541,12 +1538,14 @@ void init_backup_dir(void)
/* Read from inn, write to out. We assume inn is opened for reading,
* and out for writing. We return 0 on success, -1 on read error, or -2
* on write error. */
int copy_file(FILE *inn, FILE *out)
* on write error. inn is always closed by this function, out is closed
* only if close_out is true. */
int copy_file(FILE *inn, FILE *out, bool close_out)
{
int retval = 0;
char buf[BUFSIZ];
size_t charsread;
int (*flush_out_fnc)(FILE *) = (close_out) ? fclose : fflush;
assert(inn != NULL && out != NULL && inn != out);
@@ -1564,7 +1563,7 @@ int copy_file(FILE *inn, FILE *out)
if (fclose(inn) == EOF)
retval = -1;
if (fclose(out) == EOF)
if (flush_out_fnc(out) == EOF)
retval = -2;
return retval;
@@ -1655,13 +1654,12 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
int backup_fd;
FILE *backup_file;
char *backupname;
struct utimbuf filetime;
int copy_status;
static struct timespec filetime[2];
int backup_cflags;
/* Save the original file's access and modification times. */
filetime.actime = openfile->current_stat->st_atime;
filetime.modtime = openfile->current_stat->st_mtime;
filetime[0].tv_sec = openfile->current_stat->st_atime;
filetime[1].tv_sec = openfile->current_stat->st_mtime;
if (f_open == NULL) {
/* Open the original file to copy to the backup. */
@@ -1753,35 +1751,36 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
statusline(HUSH, _("Error writing backup file %s: %s"),
backupname, strerror(errno));
free(backupname);
/* If we can't make a backup, DON'T go on, since whatever caused
* the backup to fail (e.g. disk full) may well cause the real
* file write to fail, in which case we could lose both the
* backup and the original! */
goto cleanup_and_exit;
}
/* We shouldn't worry about chown()ing something if we're not
* root, since it's likely to fail! */
if (geteuid() == NANO_ROOT_UID && fchown(backup_fd,
openfile->current_stat->st_uid, openfile->current_stat->st_gid) == -1
&& !ISSET(INSECURE_BACKUP)) {
/* Only try chowning the backup when we're root. */
if (geteuid() == NANO_ROOT_UID &&
fchown(backup_fd, openfile->current_stat->st_uid,
openfile->current_stat->st_gid) == -1 &&
!ISSET(INSECURE_BACKUP)) {
fclose(backup_file);
if (prompt_failed_backupwrite(backupname))
goto skip_backup;
statusline(HUSH, _("Error writing backup file %s: %s"),
backupname, strerror(errno));
free(backupname);
fclose(backup_file);
goto cleanup_and_exit;
}
if (fchmod(backup_fd, openfile->current_stat->st_mode) == -1
&& !ISSET(INSECURE_BACKUP)) {
/* Set the backup's mode bits. */
if (fchmod(backup_fd, openfile->current_stat->st_mode) == -1 &&
!ISSET(INSECURE_BACKUP)) {
fclose(backup_file);
if (prompt_failed_backupwrite(backupname))
goto skip_backup;
statusline(HUSH, _("Error writing backup file %s: %s"),
backupname, strerror(errno));
free(backupname);
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
* means we could lose both the backup and the original! */
goto cleanup_and_exit;
}
@@ -1790,27 +1789,24 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
#endif
/* Copy the file. */
copy_status = copy_file(f, backup_file);
if (copy_status != 0) {
if (copy_file(f, backup_file, FALSE) != 0) {
fclose(backup_file);
statusline(ALERT, _("Error reading %s: %s"), realname,
strerror(errno));
goto cleanup_and_exit;
}
/* And set its metadata. */
if (utime(backupname, &filetime) == -1 && !ISSET(INSECURE_BACKUP)) {
/* And set the backup's timestamps. */
if (futimens(backup_fd, filetime) == -1 && !ISSET(INSECURE_BACKUP)) {
fclose(backup_file);
if (prompt_failed_backupwrite(backupname))
goto skip_backup;
statusline(HUSH, _("Error writing backup file %s: %s"),
backupname, strerror(errno));
/* If we can't write to the backup, DON'T go on, since
* whatever caused the backup file to fail (e.g. disk 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;
}
fclose(backup_file);
free(backupname);
}
@@ -1867,7 +1863,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
}
}
if (f_source == NULL || copy_file(f_source, f) != 0) {
if (f_source == NULL || copy_file(f_source, f, TRUE) != 0) {
statusline(ALERT, _("Error writing temp file: %s"),
strerror(errno));
unlink(tempname);
@@ -1975,7 +1971,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
goto cleanup_and_exit;
}
if (copy_file(f_source, f) == -1) {
if (copy_file(f_source, f, TRUE) != 0) {
statusline(ALERT, _("Error writing %s: %s"), realname,
strerror(errno));
goto cleanup_and_exit;
@@ -2051,7 +2047,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
filestruct *top, *bot;
size_t top_x, bot_x;
/* Partition the filestruct so that it contains only the marked text. */
/* Partition the buffer so that it contains only the marked text. */
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, NULL);
filepart = partition_filestruct(top, top_x, bot, bot_x);
@@ -2069,7 +2065,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
if (added_magicline)
remove_magicline();
/* Unpartition the filestruct so that it contains all the text again. */
/* Unpartition the buffer so that it contains all the text again. */
unpartition_filestruct(&filepart);
if (old_modified)
@@ -2202,15 +2198,15 @@ int do_writeout(bool exiting)
} else if (func == backup_file_void) {
TOGGLE(BACKUP_FILE);
continue;
} else
#endif /* !NANO_TINY */
if (func == prepend_void) {
} else if (func == prepend_void) {
method = (method == PREPEND) ? OVERWRITE : PREPEND;
continue;
} else if (func == append_void) {
method = (method == APPEND) ? OVERWRITE : APPEND;
continue;
} else if (func == do_help_void) {
} else
#endif /* !NANO_TINY */
if (func == do_help_void) {
continue;
}
@@ -2634,7 +2630,7 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
char *mzero, *glued;
const char *lastslash = revstrstr(buf, "/", buf + *place);
size_t lastslash_len = (lastslash == NULL) ? 0 : lastslash - buf + 1;
char char1[mb_cur_max()], char2[mb_cur_max()];
char char1[MAXCHARLEN], char2[MAXCHARLEN];
int len1, len2;
/* Get the number of characters that all matches have in common. */

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* global.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2014, 2015, 2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -53,15 +52,29 @@ int margin = 0;
int editwincols = -1;
/* The number of usable columns in the edit window: COLS - margin. */
#ifndef DISABLE_COLOR
bool have_palette = FALSE;
/* Whether the colors for the current syntax have been initialized. */
#endif
message_type lastmessage = HUSH;
/* Messages of type HUSH should not overwrite type MILD nor ALERT. */
filestruct *pletion_line = NULL;
/* The line where the last completion was found, if any. */
int controlleft, controlright, controlup, controldown;
bool inhelp = FALSE;
/* Whether we are in the help viewer. */
char *title = NULL;
/* When not NULL: the title of the current help text. */
int didfind = 0;
/* Whether the last search found something. */
int controlleft, controlright, controlup, controldown, controlhome, controlend;
#ifndef NANO_TINY
int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown;
int shiftcontrolhome, shiftcontrolend;
int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown;
#endif
@@ -309,7 +322,7 @@ void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *h
f->menus = menus;
f->desc = desc;
f->viewok = viewok;
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
f->help = help;
f->blank_after = blank_after;
#endif
@@ -475,7 +488,7 @@ void shortcut_init(void)
/* TRANSLATORS: Try to keep this string at most 12 characters. */
const char *whereis_next_tag = N_("WhereIs Next");
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
#ifndef DISABLE_JUSTIFY
/* TRANSLATORS: The next long series of strings are shortcut descriptions;
* they are best kept shorter than 56 characters, but may be longer. */
@@ -484,7 +497,7 @@ void shortcut_init(void)
const char *nano_cancel_msg = N_("Cancel the current function");
const char *nano_help_msg = N_("Display this help text");
const char *nano_exit_msg =
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
N_("Close the current file buffer / Exit from nano")
#else
N_("Exit from nano")
@@ -502,6 +515,8 @@ void shortcut_init(void)
#ifndef NANO_TINY
const char *nano_browser_lefthand_msg = N_("Go to lefthand column");
const char *nano_browser_righthand_msg = N_("Go to righthand column");
const char *nano_browser_toprow_msg = N_("Go to first row in this column");
const char *nano_browser_bottomrow_msg = N_("Go to last row in this column");
#endif
#endif
const char *nano_prevpage_msg = N_("Go one screenful up");
@@ -551,7 +566,7 @@ void shortcut_init(void)
const char *nano_scrolldown_msg =
N_("Scroll down one line without scrolling the cursor");
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
const char *nano_prevfile_msg = N_("Switch to the previous file buffer");
const char *nano_nextfile_msg = N_("Switch to the next file buffer");
#endif
@@ -614,11 +629,11 @@ void shortcut_init(void)
const char *nano_prepend_msg = N_("Toggle prepending");
const char *nano_backup_msg = N_("Toggle backing up of the original file");
const char *nano_execute_msg = N_("Execute external command");
#ifdef ENABLE_MULTIBUFFER
const char *nano_newbuffer_msg = N_("Toggle the use of a new buffer");
#endif
#endif
const char *nano_discard_buffer_msg = N_("Close buffer without saving it");
#ifndef DISABLE_MULTIBUFFER
const char *nano_multibuffer_msg = N_("Toggle the use of a new buffer");
#endif
#ifndef DISABLE_BROWSER
const char *nano_exitbrowser_msg = N_("Exit from the file browser");
const char *nano_firstfile_msg = N_("Go to the first file in the list");
@@ -635,9 +650,9 @@ void shortcut_init(void)
const char *nano_formatter_msg = N_("Invoke formatter, if available");
#endif
#endif
#endif /* !DISABLE_HELP */
#endif /* ENABLE_HELP */
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
#define IFSCHELP(help) help
#else
#define IFSCHELP(help) ""
@@ -676,7 +691,7 @@ void shortcut_init(void)
read_file_tag, IFSCHELP(nano_insert_msg), BLANKAFTER,
/* We allow inserting files in view mode if multibuffer mode
* is switched on, so that we can view multiple files. */
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
VIEW);
#else
NOVIEW);
@@ -702,13 +717,16 @@ void shortcut_init(void)
N_("Go To Dir"), IFSCHELP(nano_gotodir_msg), BLANKAFTER, VIEW);
#endif
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
/* The description ("x") and blank_after (0) are irrelevant,
* because the help viewer does not have a help text. */
add_to_funcs(do_exit, MHELP, exit_tag, "x", 0, VIEW);
add_to_funcs(total_refresh, MHELP, refresh_tag, "x", 0, VIEW);
add_to_funcs(do_search, MHELP, whereis_tag, "x", 0, VIEW);
add_to_funcs(do_research, MHELP, whereis_next_tag, "x", 0, VIEW);
add_to_funcs(do_up_void, MHELP, prev_line_tag, "x", 0, VIEW);
add_to_funcs(do_down_void, MHELP, next_line_tag, "x" , 0, VIEW);
#endif
@@ -851,7 +869,7 @@ void shortcut_init(void)
add_to_funcs(do_last_line, MMAIN|MHELP|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE,
N_("Last Line"), IFSCHELP(nano_lastline_msg), BLANKAFTER, VIEW);
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
add_to_funcs(switch_to_prev_buffer_void, MMAIN,
N_("Prev File"), IFSCHELP(nano_prevfile_msg), TOGETHER, VIEW);
add_to_funcs(switch_to_next_buffer_void, MMAIN,
@@ -870,9 +888,6 @@ void shortcut_init(void)
whereis_next_tag, IFSCHELP(nano_whereis_next_msg), TOGETHER, VIEW);
#endif
add_to_funcs(do_verbatim_input, MMAIN,
N_("Verbatim"), IFSCHELP(nano_verbatim_msg), TOGETHER, NOVIEW);
add_to_funcs(do_tab, MMAIN,
N_("Tab"), IFSCHELP(nano_tab_msg), TOGETHER, NOVIEW);
add_to_funcs(do_enter, MMAIN,
@@ -909,6 +924,9 @@ void shortcut_init(void)
N_("Word Count"), IFSCHELP(nano_wordcount_msg), TOGETHER, VIEW);
#endif
add_to_funcs(do_verbatim_input, MMAIN,
N_("Verbatim"), IFSCHELP(nano_verbatim_msg), BLANKAFTER, NOVIEW);
add_to_funcs(total_refresh, MMAIN,
refresh_tag, IFSCHELP(nano_refresh_msg), TOGETHER, VIEW);
@@ -980,9 +998,9 @@ void shortcut_init(void)
add_to_funcs(flip_execute_void, MEXTCMD,
read_file_tag, IFSCHELP(nano_insert_msg), TOGETHER, NOVIEW);
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
add_to_funcs(new_buffer_void, MINSERTFILE|MEXTCMD,
N_("New Buffer"), IFSCHELP(nano_multibuffer_msg), TOGETHER, NOVIEW);
N_("New Buffer"), IFSCHELP(nano_newbuffer_msg), TOGETHER, NOVIEW);
#endif
}
#endif /* !NANO_TINY */
@@ -1015,7 +1033,11 @@ void shortcut_init(void)
add_to_funcs(do_prev_word_void, MBROWSER,
N_("Left Column"), IFSCHELP(nano_browser_lefthand_msg), TOGETHER, VIEW);
add_to_funcs(do_next_word_void, MBROWSER,
N_("Right Column"), IFSCHELP(nano_browser_righthand_msg), BLANKAFTER, VIEW);
N_("Right Column"), IFSCHELP(nano_browser_righthand_msg), TOGETHER, VIEW);
add_to_funcs(do_prev_block, MBROWSER,
N_("Top Row"), IFSCHELP(nano_browser_toprow_msg), TOGETHER, VIEW);
add_to_funcs(do_next_block, MBROWSER,
N_("Bottom Row"), IFSCHELP(nano_browser_bottomrow_msg), BLANKAFTER, VIEW);
#endif
#endif
@@ -1029,8 +1051,8 @@ void shortcut_init(void)
/* Start associating key combos with functions in specific menus. */
add_to_sclist(MMOST, "^G", 0, do_help_void, 0);
add_to_sclist(MMOST, "F1", 0, do_help_void, 0);
add_to_sclist(MMOST & ~MFINDINHELP, "^G", 0, do_help_void, 0);
add_to_sclist(MMOST & ~MFINDINHELP, "F1", 0, do_help_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^X", 0, do_exit, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", 0, do_exit, 0);
add_to_sclist(MMAIN, "^O", 0, do_writeout_void, 0);
@@ -1038,8 +1060,8 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "^R", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN, "F5", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN, "Ins", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN|MBROWSER, "^W", 0, do_search, 0);
add_to_sclist(MMAIN|MBROWSER, "F6", 0, do_search, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^W", 0, do_search, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "F6", 0, do_search, 0);
add_to_sclist(MMAIN, "^\\", 0, do_replace, 0);
add_to_sclist(MMAIN, "M-R", 0, do_replace, 0);
add_to_sclist(MMAIN, "F14", 0, do_replace, 0);
@@ -1068,22 +1090,26 @@ void shortcut_init(void)
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^Y", 0, do_page_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F7", 0, do_page_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgUp", KEY_PPAGE, do_page_up, 0);
add_to_sclist(MHELP|MBROWSER, "Bsp", KEY_BACKSPACE, do_page_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^V", 0, do_page_down, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F8", 0, do_page_down, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgDn", KEY_NPAGE, do_page_down, 0);
add_to_sclist(MMAIN|MHELP, "M-\\", 0, do_first_line, 0);
add_to_sclist(MMAIN|MHELP, "^Home", CONTROL_HOME, do_first_line, 0);
add_to_sclist(MMAIN|MHELP, "M-|", 0, do_first_line, 0);
add_to_sclist(MMAIN|MHELP, "M-/", 0, do_last_line, 0);
add_to_sclist(MMAIN|MHELP, "^End", CONTROL_END, do_last_line, 0);
add_to_sclist(MMAIN|MHELP, "M-?", 0, do_last_line, 0);
add_to_sclist(MMAIN|MBROWSER, "M-W", 0, do_research, 0);
add_to_sclist(MMAIN|MBROWSER, "F16", 0, do_research, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "M-W", 0, do_research, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "F16", 0, do_research, 0);
#ifndef NANO_TINY
add_to_sclist(MMAIN, "M-]", 0, do_find_bracket, 0);
add_to_sclist(MMAIN, "^^", 0, do_mark, 0);
add_to_sclist(MMAIN, "M-A", 0, do_mark, 0);
add_to_sclist(MMAIN, "^6", 0, do_mark, 0);
add_to_sclist(MMAIN, "^^", 0, do_mark, 0);
add_to_sclist(MMAIN, "F15", 0, do_mark, 0);
add_to_sclist(MMAIN, "M-^", 0, do_copy_text, 0);
add_to_sclist(MMAIN, "M-6", 0, do_copy_text, 0);
add_to_sclist(MMAIN, "M-^", 0, do_copy_text, 0);
add_to_sclist(MMAIN, "M-}", 0, do_indent_void, 0);
add_to_sclist(MMAIN, "M-{", 0, do_unindent, 0);
add_to_sclist(MMAIN, "M-U", 0, do_undo, 0);
@@ -1096,16 +1122,18 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "M-3", 0, do_comment, 0);
#endif
add_to_sclist(MMOST, "^B", 0, do_left, 0);
add_to_sclist(MMOST, "Left", KEY_LEFT, do_left, 0);
add_to_sclist(MMOST, "^F", 0, do_right, 0);
add_to_sclist(MMOST, "Right", KEY_RIGHT, do_right, 0);
#ifdef ENABLE_UTF8
if (using_utf8()) {
add_to_sclist(MMOST, "\xE2\x86\x90", KEY_LEFT, do_left, 0);
add_to_sclist(MMOST, "\xE2\x86\x92", KEY_RIGHT, do_right, 0);
add_to_sclist(MMOST, "^\xE2\x86\x90", CONTROL_LEFT, do_prev_word_void, 0);
add_to_sclist(MMOST, "^\xE2\x86\x92", CONTROL_RIGHT, do_next_word_void, 0);
} else
#endif
{
add_to_sclist(MMOST, "Left", KEY_LEFT, do_left, 0);
add_to_sclist(MMOST, "Right", KEY_RIGHT, do_right, 0);
add_to_sclist(MMOST, "^Left", CONTROL_LEFT, do_prev_word_void, 0);
add_to_sclist(MMOST, "^Right", CONTROL_RIGHT, do_next_word_void, 0);
}
@@ -1116,18 +1144,20 @@ void shortcut_init(void)
add_to_sclist((MMOST & ~MBROWSER), "^E", 0, do_end_void, 0);
add_to_sclist((MMOST & ~MBROWSER), "End", KEY_END, do_end_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^P", 0, do_up_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "Up", KEY_UP, do_up_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^N", 0, do_down_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "Down", KEY_DOWN, do_down_void, 0);
#ifdef ENABLE_UTF8
if (using_utf8()) {
add_to_sclist(MMAIN, "^\xE2\x86\x91", CONTROL_UP, do_prev_block, 0);
add_to_sclist(MMAIN, "^\xE2\x86\x93", CONTROL_DOWN, do_next_block, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "\xE2\x86\x91", KEY_UP, do_up_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "\xE2\x86\x93", KEY_DOWN, do_down_void, 0);
add_to_sclist(MMAIN|MBROWSER, "^\xE2\x86\x91", CONTROL_UP, do_prev_block, 0);
add_to_sclist(MMAIN|MBROWSER, "^\xE2\x86\x93", CONTROL_DOWN, do_next_block, 0);
} else
#endif
{
add_to_sclist(MMAIN, "^Up", CONTROL_UP, do_prev_block, 0);
add_to_sclist(MMAIN, "^Down", CONTROL_DOWN, do_next_block, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "Up", KEY_UP, do_up_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "Down", KEY_DOWN, do_down_void, 0);
add_to_sclist(MMAIN|MBROWSER, "^Up", CONTROL_UP, do_prev_block, 0);
add_to_sclist(MMAIN|MBROWSER, "^Down", CONTROL_DOWN, do_next_block, 0);
}
add_to_sclist(MMAIN, "M-7", 0, do_prev_block, 0);
add_to_sclist(MMAIN, "M-8", 0, do_next_block, 0);
@@ -1143,7 +1173,7 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "M-+", 0, do_scroll_down, 0);
add_to_sclist(MMAIN, "M-=", 0, do_scroll_down, 0);
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
add_to_sclist(MMAIN, "M-<", 0, switch_to_prev_buffer_void, 0);
add_to_sclist(MMAIN, "M-,", 0, switch_to_prev_buffer_void, 0);
add_to_sclist(MMAIN, "M->", 0, switch_to_next_buffer_void, 0);
@@ -1163,7 +1193,7 @@ void shortcut_init(void)
#ifndef NANO_TINY
/* Group of "Appearance" toggles. */
add_to_sclist(MMAIN, "M-X", 0, do_toggle_void, NO_HELP);
add_to_sclist(MMAIN, "M-C", 0, do_toggle_void, CONST_UPDATE);
add_to_sclist(MMAIN, "M-C", 0, do_toggle_void, CONSTANT_SHOW);
add_to_sclist(MMAIN, "M-O", 0, do_toggle_void, MORE_SPACE);
add_to_sclist(MMAIN, "M-S", 0, do_toggle_void, SMOOTH_SCROLL);
add_to_sclist(MMAIN, "M-$", 0, do_toggle_void, SOFTWRAP);
@@ -1186,10 +1216,10 @@ void shortcut_init(void)
/* Group of "Peripheral-feature" toggles. */
add_to_sclist(MMAIN, "M-B", 0, do_toggle_void, BACKUP_FILE);
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
add_to_sclist(MMAIN, "M-F", 0, do_toggle_void, MULTIBUFFER);
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
add_to_sclist(MMAIN, "M-M", 0, do_toggle_void, USE_MOUSE);
#endif
add_to_sclist(MMAIN, "M-N", 0, do_toggle_void, NO_CONVERT);
@@ -1214,20 +1244,30 @@ void shortcut_init(void)
add_to_sclist(MWHEREIS, "^T", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MGOTOLINE, "^T", 0, gototext_void, 0);
#ifndef DISABLE_HISTORIES
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^P", 0, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Up", KEY_UP, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^N", 0, get_history_newer_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Down", KEY_DOWN, get_history_newer_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "^P", 0, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "^N", 0, get_history_newer_void, 0);
#ifdef ENABLE_UTF8
if (using_utf8()) {
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "\xE2\x86\x91", KEY_UP, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "\xE2\x86\x93", KEY_DOWN, get_history_newer_void, 0);
} else
#endif
{
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "Up", KEY_UP, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "Down", KEY_DOWN, get_history_newer_void, 0);
}
#endif
#ifndef DISABLE_BROWSER
add_to_sclist(MWHEREISFILE, "^Y", 0, do_first_file, 0);
add_to_sclist(MWHEREISFILE, "^V", 0, do_last_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-\\", 0, do_first_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", 0, do_first_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-/", 0, do_last_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", 0, do_last_file, 0);
add_to_sclist(MBROWSER, "Home", KEY_HOME, do_first_file, 0);
add_to_sclist(MBROWSER, "End", KEY_END, do_last_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", 0, do_first_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", 0, do_last_file, 0);
add_to_sclist(MBROWSER, "^Home", CONTROL_HOME, do_first_file, 0);
add_to_sclist(MBROWSER, "^End", CONTROL_END, do_last_file, 0);
add_to_sclist(MBROWSER, "^_", 0, goto_dir_void, 0);
add_to_sclist(MBROWSER, "M-G", 0, goto_dir_void, 0);
add_to_sclist(MBROWSER, "F13", 0, goto_dir_void, 0);
@@ -1235,26 +1275,31 @@ void shortcut_init(void)
#endif
if (ISSET(TEMP_FILE))
add_to_sclist(MWRITEFILE, "^Q", 0, discard_buffer, 0);
#ifndef NANO_TINY
add_to_sclist(MWRITEFILE, "M-D", 0, dos_format_void, 0);
add_to_sclist(MWRITEFILE, "M-M", 0, mac_format_void, 0);
/* In restricted mode, don't allow Appending, Prepending, nor making
* backups, nor executing a command, nor opening a new buffer. */
if (!ISSET(RESTRICTED)) {
/* Don't allow Appending, Prepending, nor Backups in restricted mode. */
add_to_sclist(MWRITEFILE, "M-A", 0, append_void, 0);
add_to_sclist(MWRITEFILE, "M-P", 0, prepend_void, 0);
add_to_sclist(MWRITEFILE, "M-B", 0, backup_file_void, 0);
#ifndef DISABLE_BROWSER
add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", 0, to_files_void, 0);
#endif
add_to_sclist(MINSERTFILE|MEXTCMD, "^X", 0, flip_execute_void, 0);
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, new_buffer_void, 0);
}
#endif
#ifndef DISABLE_BROWSER
/* In restricted mode, don't allow entering the file browser. */
if (!ISSET(RESTRICTED))
add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", 0, to_files_void, 0);
#endif
add_to_sclist(MHELP|MBROWSER, "^C", 0, do_exit, 0);
/* Allow exiting from the file browser and the help viewer with
* the same key as they were entered. */
#ifndef DISABLE_BROWSER
add_to_sclist(MBROWSER, "^T", 0, do_exit, 0);
#endif
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
add_to_sclist(MHELP, "^G", 0, do_exit, 0);
add_to_sclist(MHELP, "Home", KEY_HOME, do_first_line, 0);
add_to_sclist(MHELP, "End", KEY_END, do_last_line, 0);
@@ -1316,7 +1361,7 @@ const char *flagtostr(int flag)
/* TRANSLATORS: The next seventeen strings are toggle descriptions;
* they are best kept shorter than 40 characters, but may be longer. */
return N_("Help mode");
case CONST_UPDATE:
case CONSTANT_SHOW:
return N_("Constant cursor position display");
case MORE_SPACE:
return N_("Use of one more line for editing");
@@ -1367,7 +1412,7 @@ sc *strtosc(const char *input)
s->toggle = 0;
#endif
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
if (!strcasecmp(input, "help"))
s->scfunc = do_help_void;
else
@@ -1499,7 +1544,7 @@ sc *strtosc(const char *input)
s->scfunc = do_first_line;
else if (!strcasecmp(input, "lastline"))
s->scfunc = do_last_line;
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
else if (!strcasecmp(input, "prevbuf"))
s->scfunc = switch_to_prev_buffer_void;
else if (!strcasecmp(input, "nextbuf"))
@@ -1537,6 +1582,7 @@ sc *strtosc(const char *input)
else if (!strcasecmp(input, "nexthistory"))
s->scfunc = get_history_newer_void;
#endif
#ifndef NANO_TINY
else if (!strcasecmp(input, "dosformat"))
s->scfunc = dos_format_void;
else if (!strcasecmp(input, "macformat"))
@@ -1547,11 +1593,10 @@ sc *strtosc(const char *input)
s->scfunc = prepend_void;
else if (!strcasecmp(input, "backup"))
s->scfunc = backup_file_void;
#ifndef ENABLE_TINY
else if (!strcasecmp(input, "flipexecute"))
s->scfunc = flip_execute_void;
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
else if (!strcasecmp(input, "flipnewbuffer") ||
!strcasecmp(input, "newbuffer")) /* Deprecated. Remove in 2018. */
s->scfunc = new_buffer_void;
@@ -1573,7 +1618,7 @@ sc *strtosc(const char *input)
if (!strcasecmp(input, "nohelp"))
s->toggle = NO_HELP;
else if (!strcasecmp(input, "constupdate"))
s->toggle = CONST_UPDATE;
s->toggle = CONSTANT_SHOW;
else if (!strcasecmp(input, "morespace"))
s->toggle = MORE_SPACE;
else if (!strcasecmp(input, "smoothscroll"))
@@ -1600,11 +1645,11 @@ sc *strtosc(const char *input)
s->toggle = TABS_TO_SPACES;
else if (!strcasecmp(input, "backupfile"))
s->toggle = BACKUP_FILE;
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
else if (!strcasecmp(input, "multibuffer"))
s->toggle = MULTIBUFFER;
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
else if (!strcasecmp(input, "mouse"))
s->toggle = USE_MOUSE;
#endif
@@ -1645,7 +1690,7 @@ int strtomenu(const char *input)
else if (!strcasecmp(input, "externalcmd") ||
!strcasecmp(input, "extcmd"))
return MEXTCMD;
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
else if (!strcasecmp(input, "help"))
return MHELP;
#endif

View File

@@ -1,9 +1,9 @@
/**************************************************************************
* help.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, *
* 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 2014, 2015, 2016 Benno Schulenberg *
* Copyright (C) 2000-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2017 Rishabh Dave *
* Copyright (C) 2014-2017 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -25,165 +25,265 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
static char *help_text = NULL;
/* The text displayed in the help window. */
static const char *start_of_body = NULL;
/* The point in the help text just after the title. */
static char *end_of_intro = NULL;
/* The point in the help text where the introductory paragraphs end
* and the shortcut descriptions begin. */
/* The point in the help text where the shortcut descriptions begin. */
static size_t location;
/* The offset (in bytes) of the topleft of the shown help text. */
char *tempfilename = NULL;
/* Name of the temporary file used for wrapping the help text. */
/* Hard-wrap the help text, write it to the existing temporary file, and
* read that file into a new buffer. */
void wrap_the_help_text(bool redisplaying)
{
int sum = 0;
const char *ptr = start_of_body;
FILE *tempfile = fopen(tempfilename, "w+b");
/* If re-opening the temporary file failed, give up. */
if (tempfile == NULL) {
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
return;
}
/* Write the body of the help_text into the temporary file. */
while (*ptr != '\0') {
int length = help_line_len(ptr);
fwrite(ptr, sizeof(char), length, tempfile);
ptr += length;
/* Hard-wrap the lines in the help text. */
if (*ptr != '\n')
fwrite("\n", sizeof(char), 1, tempfile);
else while (*ptr == '\n')
fwrite(ptr++, sizeof(char), 1, tempfile);
}
fclose(tempfile);
if (redisplaying)
close_buffer();
open_buffer(tempfilename, FALSE);
remove_magicline();
prepare_for_display();
/* Move to the position in the file where we were before. */
while (TRUE) {
sum += strlen(openfile->current->data);
if (sum > location)
break;
openfile->current = openfile->current->next;
}
openfile->edittop = openfile->current;
}
/* Our main help-viewer function. */
void do_help(void)
{
int kbinput = ERR;
bool old_no_help = ISSET(NO_HELP);
size_t line = 0;
/* The line number in help_text of the first displayed help
* line. This variable is zero-based. */
size_t last_line = 0;
/* The line number in help_text of the last help line. This
* variable is zero-based. */
int oldmenu = currmenu;
/* The menu we were called from. */
const char *ptr;
/* The current line of the help text. */
size_t old_line = (size_t)-1;
/* The line we were on before the current line. */
functionptrtype func;
/* The function of the key the user typed in. */
int oldmenu = currmenu;
/* The menu we were called from. */
#ifdef ENABLE_LINENUMBERS
int was_margin = margin;
#endif
ssize_t was_tabsize = tabsize;
#ifndef DISABLE_COLOR
char *was_syntax = syntaxstr;
#endif
char *saved_answer = (answer != NULL) ? strdup(answer) : NULL;
/* The current answer when the user invokes help at the prompt. */
unsigned stash[sizeof(flags) / sizeof(flags[0])];
/* A storage place for the current flag settings. */
filestruct *line;
int length;
FILE *fp;
/* Don't show a cursor in the help screen. */
curs_set(0);
blank_edit();
blank_statusbar();
/* Set help_text as the string to display. */
help_init();
/* Get a temporary file for the help text. If it fails, give up. */
tempfilename = safe_tempfile(&fp);
if (tempfilename == NULL) {
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
free(saved_answer);
return;
}
assert(help_text != NULL);
fclose(fp);
if (ISSET(NO_HELP)) {
/* Make sure that the help screen's shortcut list will actually
* be displayed. */
/* Save the settings of all flags. */
memcpy(stash, flags, sizeof(flags));
/* Ensure that the help screen's shortcut list can be displayed. */
if (ISSET(NO_HELP) && LINES > 4) {
UNSET(NO_HELP);
window_init();
}
/* When searching, do it forward, case insensitive, and without regexes. */
UNSET(BACKWARDS_SEARCH);
UNSET(CASE_SENSITIVE);
UNSET(USE_REGEXP);
UNSET(WHITESPACE_DISPLAY);
UNSET(NOREAD_MODE);
SET(MULTIBUFFER);
#ifdef ENABLE_LINENUMBERS
UNSET(LINE_NUMBERS);
margin = 0;
#endif
tabsize = 8;
#ifndef DISABLE_COLOR
syntaxstr = "nanohelp";
#endif
curs_set(0);
/* Compose the help text from all the pieces. */
help_init();
inhelp = TRUE;
location = 0;
bottombars(MHELP);
wnoutrefresh(bottomwin);
/* Extract the title from the head of the help text. */
length = break_line(help_text, MAX_BUF_SIZE, TRUE);
title = charalloc(length * sizeof(char) + 1);
strncpy(title, help_text, length);
title[length] = '\0';
titlebar(title);
/* Skip over the title to point at the start of the body text. */
start_of_body = help_text + length;
while (*start_of_body == '\n')
start_of_body++;
wrap_the_help_text(FALSE);
edit_refresh();
while (TRUE) {
size_t i;
ptr = help_text;
/* Find the line number of the last line of the help text. */
for (last_line = 0; *ptr != '\0'; last_line++) {
ptr += help_line_len(ptr);
if (*ptr == '\n')
ptr++;
}
if (last_line > 0)
last_line--;
/* Redisplay if the text was scrolled or an invalid key was pressed. */
if (line != old_line || kbinput == ERR) {
blank_edit();
ptr = help_text;
/* Advance in the text to the first line to be displayed. */
for (i = 0; i < line; i++) {
ptr += help_line_len(ptr);
if (*ptr == '\n')
ptr++;
}
/* Now display as many lines as the window will hold. */
for (i = 0; i < editwinrows && *ptr != '\0'; i++) {
size_t j = help_line_len(ptr);
mvwaddnstr(edit, i, 0, ptr, j);
ptr += j;
if (*ptr == '\n')
ptr++;
}
}
wnoutrefresh(edit);
old_line = line;
lastmessage = HUSH;
focusing = TRUE;
didfind = 0;
kbinput = get_kbinput(edit);
#ifndef NANO_TINY
if (kbinput == KEY_WINCH) {
kbinput = ERR;
continue; /* Redraw the screen. */
}
#endif
#ifndef DISABLE_MOUSE
if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y;
get_mouseinput(&mouse_x, &mouse_y, TRUE);
continue; /* Redraw the screen. */
}
#endif
func = parse_help_input(&kbinput);
if (func == total_refresh) {
total_redraw();
} else if (func == do_up_void) {
if (line > 0)
line--;
do_up(TRUE);
} else if (func == do_down_void) {
if (line + (editwinrows - 1) < last_line)
line++;
if (openfile->edittop->lineno + editwinrows - 1 <
openfile->filebot->lineno)
do_down(TRUE);
} else if (func == do_page_up) {
if (line > editwinrows - 2)
line -= editwinrows - 2;
else
line = 0;
do_page_up();
} else if (func == do_page_down) {
if (line + (editwinrows - 1) < last_line)
line += editwinrows - 2;
do_page_down();
} else if (func == do_first_line) {
line = 0;
do_first_line();
} else if (func == do_last_line) {
if (line + (editwinrows - 1) < last_line)
line = last_line - (editwinrows - 1);
do_last_line();
} else if (func == do_search) {
do_search();
bottombars(MHELP);
} else if (func == do_research) {
do_research();
currmenu = MHELP;
#ifndef NANO_TINY
} else if (kbinput == KEY_WINCH) {
; /* Nothing to do. */
#endif
#ifdef ENABLE_MOUSE
} else if (kbinput == KEY_MOUSE) {
int dummy_x, dummy_y;
get_mouseinput(&dummy_x, &dummy_y, TRUE);
#endif
} else if (func == do_exit) {
/* Exit from the help viewer. */
close_buffer();
break;
} else
unbound_key(kbinput);
/* If we searched and found something, let the cursor show it. */
if (didfind == 1)
curs_set(1);
else
curs_set(0);
edit_refresh();
location = 0;
line = openfile->fileage;
/* Count how far (in bytes) edittop is into the file. */
while (line != openfile->edittop) {
location += strlen(line->data);
line = line->next;
}
}
if (old_no_help) {
/* Restore the settings of all flags. */
memcpy(flags, stash, sizeof(flags));
#ifdef ENABLE_LINENUMBERS
margin = was_margin;
#endif
tabsize = was_tabsize;
#ifndef DISABLE_COLOR
syntaxstr = was_syntax;
#endif
/* Switch back to the buffer we were invoked from. */
switch_to_prev_buffer_void();
if (ISSET(NO_HELP)) {
blank_bottombars();
wnoutrefresh(bottomwin);
currmenu = oldmenu;
SET(NO_HELP);
window_init();
} else
bottombars(oldmenu);
free(title);
title = NULL;
inhelp = FALSE;
#ifndef DISABLE_BROWSER
if (oldmenu == MBROWSER || oldmenu == MWHEREISFILE || oldmenu == MGOTODIR)
browser_refresh();
else
#endif
edit_refresh();
total_refresh();
free(answer);
answer = saved_answer;
remove(tempfilename);
free(tempfilename);
/* We're exiting from the help screen. */
free(help_text);
}
@@ -200,12 +300,6 @@ void help_init(void)
const subnfunc *f;
const sc *s;
#ifndef NANO_TINY
bool old_whitespace = ISSET(WHITESPACE_DISPLAY);
UNSET(WHITESPACE_DISPLAY);
#endif
/* First, set up the initial help text for the current function. */
if (currmenu == MWHEREIS || currmenu == MREPLACE || currmenu == MREPLACEWITH) {
htx[0] = N_("Search Command Help Text\n\n "
@@ -370,7 +464,7 @@ void help_init(void)
* plus one or two \n's. */
for (f = allfuncs; f != NULL; f = f->next)
if (f->menus & currmenu)
allocsize += (16 * mb_cur_max()) + strlen(f->help) + 2;
allocsize += (16 * MAXCHARLEN) + strlen(_(f->help)) + 2;
#ifndef NANO_TINY
/* If we're on the main list, we also count the toggle help text.
@@ -385,7 +479,7 @@ void help_init(void)
}
#endif
/* Allocate space for the help text. */
/* Allocate memory for the help text. */
help_text = charalloc(allocsize + 1);
/* Now add the text we want. */
@@ -418,9 +512,9 @@ void help_init(void)
/* Make the first column narrower (6) than the second (10),
* but allow it to spill into the second, for "M-Space". */
if (scsfound == 1) {
sprintf(ptr, "%s ", s->keystr);
sprintf(ptr, "%s ", s->keystr);
/* Unicode arrows take three bytes instead of one. */
if (s->keystr[1] == '\xE2')
if (s->keystr[0] == '\xE2' || s->keystr[1] == '\xE2')
ptr += 8;
else
ptr += 6;
@@ -465,13 +559,10 @@ void help_init(void)
}
}
}
if (old_whitespace)
SET(WHITESPACE_DISPLAY);
#endif /* !NANO_TINY */
/* If all went well, we didn't overwrite the allocated space. */
assert(strlen(help_text) <= allocsize + 1);
if (strlen(help_text) > allocsize)
statusline(ALERT, "Help text spilled over -- please report a bug");
}
/* Return the function that is bound to the given key, accepting certain
@@ -484,6 +575,13 @@ functionptrtype parse_help_input(int *kbinput)
return do_page_down;
case '-':
return do_page_up;
case 'W':
case 'w':
case '/':
return do_search;
case 'N':
case 'n':
return do_research;
case 'E':
case 'e':
case 'Q':
@@ -525,17 +623,17 @@ size_t help_line_len(const char *ptr)
return 0;
}
#endif /* !DISABLE_HELP */
#endif /* ENABLE_HELP */
/* Start the help viewer. */
void do_help_void(void)
{
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
do_help();
#else
if (currmenu == MMAIN)
say_there_is_no_help();
else
beep();
#endif /* !DISABLE_HELP */
#endif
}

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* move.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2014, 2015, 2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -96,7 +95,7 @@ void do_page_up(void)
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
/* Scroll the edit window up a page. */
/* Move the viewport so that the cursor stays immobile, if possible. */
adjust_viewport(STATIONARY);
refresh_needed = TRUE;
}
@@ -128,16 +127,15 @@ void do_page_down(void)
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
/* Scroll the edit window down a page. */
/* Move the viewport so that the cursor stays immobile, if possible. */
adjust_viewport(STATIONARY);
refresh_needed = TRUE;
}
#ifndef DISABLE_JUSTIFY
/* Move up to the beginning of the last beginning-of-paragraph line
* before the current line. If allow_update is TRUE, update the screen
* afterwards. */
void do_para_begin(bool allow_update)
/* Move to the beginning of the last beginning-of-paragraph line before the
* current line. If update_screen is TRUE, update the screen afterwards. */
void do_para_begin(bool update_screen)
{
filestruct *was_current = openfile->current;
@@ -149,12 +147,11 @@ void do_para_begin(bool allow_update)
openfile->current_x = 0;
if (allow_update)
if (update_screen)
edit_redraw(was_current);
}
/* Move up to the beginning of the last beginning-of-paragraph line
* before the current line, and update the screen afterwards. */
/* Move up to first start of a paragraph before the current line. */
void do_para_begin_void(void)
{
do_para_begin(TRUE);
@@ -162,11 +159,11 @@ void do_para_begin_void(void)
/* Move down to the beginning of the last line of the current paragraph.
* Then move down one line farther if there is such a line, or to the
* end of the current line if not. If allow_update is TRUE, update the
* end of the current line if not. If update_screen is TRUE, update the
* screen afterwards. A line is the last line of a paragraph if it is
* in a paragraph, and the next line either is the beginning line of a
* paragraph or isn't in a paragraph. */
void do_para_end(bool allow_update)
void do_para_end(bool update_screen)
{
filestruct *was_current = openfile->current;
@@ -186,13 +183,11 @@ void do_para_end(bool allow_update)
} else
openfile->current_x = strlen(openfile->current->data);
if (allow_update)
if (update_screen)
edit_redraw(was_current);
}
/* Move down to the beginning of the last line of the current paragraph.
* Then move down one line farther if there is such a line, or to the
* end of the current line if not, and update the screen afterwards. */
/* Move down to just after the first end of a paragraph. */
void do_para_end_void(void)
{
do_para_end(TRUE);
@@ -240,9 +235,9 @@ void do_next_block(void)
}
/* Move to the previous word in the file. If allow_punct is TRUE, treat
* punctuation as part of a word. If allow_update is TRUE, update the
* punctuation as part of a word. If update_screen is TRUE, update the
* screen afterwards. */
void do_prev_word(bool allow_punct, bool allow_update)
void do_prev_word(bool allow_punct, bool update_screen)
{
filestruct *was_current = openfile->current;
bool seen_a_word = FALSE, step_forward = FALSE;
@@ -279,8 +274,7 @@ void do_prev_word(bool allow_punct, bool allow_update)
openfile->current_x = move_mbright(openfile->current->data,
openfile->current_x);
/* If allow_update is TRUE, update the screen. */
if (allow_update) {
if (update_screen) {
focusing = FALSE;
edit_redraw(was_current);
}
@@ -294,10 +288,10 @@ void do_prev_word_void(void)
}
/* Move to the next word in the file. If allow_punct is TRUE, treat
* punctuation as part of a word. If allow_update is TRUE, update the
* punctuation as part of a word. If update_screen is TRUE, update the
* screen afterwards. Return TRUE if we started on a word, and FALSE
* otherwise. */
bool do_next_word(bool allow_punct, bool allow_update)
bool do_next_word(bool allow_punct, bool update_screen)
{
filestruct *was_current = openfile->current;
bool started_on_word = is_word_mbchar(openfile->current->data +
@@ -329,8 +323,7 @@ bool do_next_word(bool allow_punct, bool allow_update)
break;
}
/* If allow_update is TRUE, update the screen. */
if (allow_update) {
if (update_screen) {
focusing = FALSE;
edit_redraw(was_current);
}
@@ -348,12 +341,12 @@ void do_next_word_void(void)
/* Move to the beginning of the current line (or softwrapped chunk).
* If be_clever is TRUE, do a smart home when wanted and possible,
* and do a dynamic home when in softwrap mode and it'spossible.
* and do a dynamic home when in softwrap mode and it's possible.
* If be_clever is FALSE, just do a simple home. */
void do_home(bool be_clever)
{
filestruct *was_current = openfile->current;
size_t was_column = xplustabs();
size_t was_column = openfile->placewewant;
bool moved_off_chunk = TRUE;
#ifndef NANO_TINY
bool moved = FALSE;
@@ -383,17 +376,19 @@ void do_home(bool be_clever)
if (!moved && ISSET(SOFTWRAP)) {
/* If already at the left edge of the screen, move fully home.
* Otherwise, move to the left edge. */
if (openfile->current_x == leftedge_x && be_clever)
if (was_column % editwincols == 0 && be_clever)
openfile->current_x = 0;
else {
openfile->current_x = leftedge_x;
openfile->placewewant = (was_column / editwincols) * editwincols;
moved_off_chunk = FALSE;
}
} else if (!moved)
#endif
openfile->current_x = 0;
openfile->placewewant = xplustabs();
if (moved_off_chunk)
openfile->placewewant = 0;
/* If we changed chunk, we might be offscreen. Otherwise,
* update current if the mark is on or we changed "page". */
@@ -416,7 +411,7 @@ void do_home_void(void)
void do_end(bool be_clever)
{
filestruct *was_current = openfile->current;
size_t was_column = xplustabs();
size_t was_column = openfile->placewewant;
size_t line_len = strlen(openfile->current->data);
bool moved_off_chunk = TRUE;

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* nano.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2014, 2015, 2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -42,7 +41,7 @@
#include <sys/ioctl.h>
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
static int oldinterval = -1;
/* Used to store the user's original mouse click interval. */
#endif
@@ -52,19 +51,19 @@ static bool no_rcfiles = FALSE;
#endif
#ifdef HAVE_TERMIOS_H
static struct termios oldterm;
/* The user's original terminal settings. */
#else
# define tcsetattr(...)
# define tcgetattr(...)
#endif
/* The user's original terminal settings. */
static struct sigaction act;
/* Used to set up all our fun signal handlers. */
/* Create a new filestruct node. Note that we do not set prevnode->next
/* Create a new linestruct node. Note that we do not set prevnode->next
* to the new line. */
filestruct *make_new_node(filestruct *prevnode)
{
filestruct *newnode = (filestruct *)nmalloc(sizeof(filestruct));
filestruct *newnode = nmalloc(sizeof(filestruct));
newnode->data = NULL;
newnode->prev = prevnode;
@@ -78,17 +77,16 @@ filestruct *make_new_node(filestruct *prevnode)
return newnode;
}
/* Make a copy of a filestruct node. */
/* Make a copy of a linestruct node. */
filestruct *copy_node(const filestruct *src)
{
filestruct *dst;
dst = (filestruct *)nmalloc(sizeof(filestruct));
filestruct *dst = nmalloc(sizeof(filestruct));
dst->data = mallocstrcpy(NULL, src->data);
dst->next = src->next;
dst->prev = src->prev;
dst->lineno = src->lineno;
#ifndef DISABLE_COLOR
dst->multidata = NULL;
#endif
@@ -96,7 +94,7 @@ filestruct *copy_node(const filestruct *src)
return dst;
}
/* Splice a new node into an existing linked list of filestructs. */
/* Splice a new node into an existing linked list of linestructs. */
void splice_node(filestruct *afterthis, filestruct *newnode)
{
newnode->next = afterthis->next;
@@ -110,7 +108,7 @@ void splice_node(filestruct *afterthis, filestruct *newnode)
openfile->filebot = newnode;
}
/* Disconnect a node from a linked list of filestructs and delete it. */
/* Disconnect a node from a linked list of linestructs and delete it. */
void unlink_node(filestruct *fileptr)
{
if (fileptr->prev != NULL)
@@ -135,7 +133,7 @@ void delete_node(filestruct *fileptr)
free(fileptr);
}
/* Duplicate a whole filestruct. */
/* Duplicate an entire linked list of linestructs. */
filestruct *copy_filestruct(const filestruct *src)
{
filestruct *head, *copy;
@@ -158,7 +156,7 @@ filestruct *copy_filestruct(const filestruct *src)
return head;
}
/* Free a whole linked list of filestructs. */
/* Free an entire linked list of linestructs. */
void free_filestruct(filestruct *src)
{
if (src == NULL)
@@ -172,7 +170,7 @@ void free_filestruct(filestruct *src)
delete_node(src);
}
/* Renumber all entries in a filestruct, starting with fileptr. */
/* Renumber the lines in a buffer, starting with fileptr. */
void renumber(filestruct *fileptr)
{
ssize_t line;
@@ -188,8 +186,8 @@ void renumber(filestruct *fileptr)
fileptr->lineno = ++line;
}
/* Partition a filestruct so that it begins at (top, top_x) and ends at
* (bot, bot_x). */
/* Partition the current buffer so that it appears to begin at (top, top_x)
* and appears to end at (bot, bot_x). */
partition *partition_filestruct(filestruct *top, size_t top_x,
filestruct *bot, size_t bot_x)
{
@@ -201,7 +199,7 @@ partition *partition_filestruct(filestruct *top, size_t top_x,
p = (partition *)nmalloc(sizeof(partition));
/* If the top and bottom of the partition are different from the top
* and bottom of the filestruct, save the latter and then set them
* and bottom of the buffer, save the latter and then set them
* to top and bot. */
if (top != openfile->fileage) {
p->fileage = openfile->fileage;
@@ -237,8 +235,8 @@ partition *partition_filestruct(filestruct *top, size_t top_x,
return p;
}
/* Unpartition a filestruct so that it begins at (fileage, 0) and ends
* at (filebot, strlen(filebot->data)) again. */
/* Unpartition the current buffer so that it stretches from (fileage, 0)
* to (filebot, $) again. */
void unpartition_filestruct(partition **p)
{
assert(p != NULL && openfile->fileage != NULL && openfile->filebot != NULL);
@@ -267,7 +265,7 @@ void unpartition_filestruct(partition **p)
strcat(openfile->filebot->data, (*p)->bot_data);
free((*p)->bot_data);
/* Restore the top and bottom of the filestruct, if they were
/* Restore the top and bottom of the buffer, if they were
* different from the top and bottom of the partition. */
if ((*p)->fileage != NULL)
openfile->fileage = (*p)->fileage;
@@ -280,7 +278,7 @@ void unpartition_filestruct(partition **p)
}
/* Move all the text between (top, top_x) and (bot, bot_x) in the
* current filestruct to a filestruct beginning with file_top and ending
* current buffer to a new buffer beginning with file_top and ending
* with file_bot. If no text is between (top, top_x) and (bot, bot_x),
* don't do anything. */
void extract_buffer(filestruct **file_top, filestruct **file_bot,
@@ -299,7 +297,7 @@ void extract_buffer(filestruct **file_top, filestruct **file_bot,
if (top == bot && top_x == bot_x)
return;
/* Partition the filestruct so that it contains only the text from
/* Partition the buffer so that it contains only the text from
* (top, top_x) to (bot, bot_x), keep track of whether the top of
* the edit window is inside the partition, and keep track of
* whether the mark begins inside the partition. */
@@ -357,7 +355,7 @@ void extract_buffer(filestruct **file_top, filestruct **file_bot,
renumber(file_bot_save->next);
}
/* Since the text has now been saved, remove it from the filestruct. */
/* Since the text has now been saved, remove it from the buffer. */
openfile->fileage = make_new_node(NULL);
openfile->fileage->data = mallocstrcpy(NULL, "");
openfile->filebot = openfile->fileage;
@@ -378,7 +376,7 @@ void extract_buffer(filestruct **file_top, filestruct **file_bot,
top_save = openfile->fileage;
/* Unpartition the filestruct so that it contains all the text
/* Unpartition the buffer so that it contains all the text
* again, minus the saved text. */
unpartition_filestruct(&filepart);
@@ -424,14 +422,14 @@ void ingraft_buffer(filestruct *somebuffer)
}
#endif
/* Partition the filestruct so that it contains no text, and remember
/* Partition the buffer so that it contains no text, and remember
* whether the current line is at the top of the edit window. */
filepart = partition_filestruct(openfile->current, openfile->current_x,
openfile->current, openfile->current_x);
edittop_inside = (openfile->edittop == openfile->fileage);
free_filestruct(openfile->fileage);
/* Put the top and bottom of the current filestruct at the top and
/* Put the top and bottom of the current buffer at the top and
* bottom of the passed buffer. */
openfile->fileage = somebuffer;
openfile->filebot = openfile->fileage;
@@ -477,7 +475,7 @@ void ingraft_buffer(filestruct *somebuffer)
top_save = openfile->fileage;
/* Unpartition the filestruct so that it contains all the text
/* Unpartition the buffer so that it contains all the text
* again, plus the copied text. */
unpartition_filestruct(&filepart);
@@ -497,13 +495,13 @@ void copy_from_buffer(filestruct *somebuffer)
ingraft_buffer(the_copy);
}
/* Create a new openfilestruct node. */
/* Create a new openfile node. */
openfilestruct *make_new_opennode(void)
{
return (openfilestruct *)nmalloc(sizeof(openfilestruct));
}
/* Unlink a node from the rest of the openfilestruct, and delete it. */
/* Unlink a node from the rest of the circular list, and delete it. */
void unlink_opennode(openfilestruct *fileptr)
{
assert(fileptr != fileptr->prev && fileptr != fileptr->next);
@@ -541,7 +539,7 @@ void show_restricted_warning(void)
beep();
}
#ifdef DISABLE_HELP
#ifndef ENABLE_HELP
/* Indicate that help texts are unavailable. */
void say_there_is_no_help(void)
{
@@ -601,14 +599,14 @@ void die(const char *msg, ...)
/* If the current file buffer was modified, save it. */
if (openfile && openfile->modified) {
/* If the filestruct is partitioned, unpartition it first. */
/* If the buffer is partitioned, unpartition it first. */
if (filepart != NULL)
unpartition_filestruct(&filepart);
die_save_file(openfile->filename, openfile->current_stat);
}
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
/* Save all of the other modified file buffers, if any. */
if (openfile != NULL) {
openfilestruct *firstone = openfile;
@@ -725,23 +723,20 @@ void window_init(void)
#endif
}
#ifndef DISABLE_MOUSE
/* Disable mouse support. */
#ifdef ENABLE_MOUSE
void disable_mouse_support(void)
{
mousemask(0, NULL);
mouseinterval(oldinterval);
}
/* Enable mouse support. */
void enable_mouse_support(void)
{
mousemask(ALL_MOUSE_EVENTS, NULL);
oldinterval = mouseinterval(50);
}
/* Initialize mouse support. Enable it if the USE_MOUSE flag is set,
* and disable it otherwise. */
/* Switch mouse support on or off, as needed. */
void mouse_init(void)
{
if (ISSET(USE_MOUSE))
@@ -749,7 +744,7 @@ void mouse_init(void)
else
disable_mouse_support();
}
#endif /* !DISABLE_MOUSE */
#endif /* ENABLE_MOUSE */
/* Print one usage string to the screen. This cuts down on duplicate
* strings to translate, and leaves out the parts that shouldn't be
@@ -796,7 +791,7 @@ void usage(void)
#ifndef NANO_TINY
print_opt("-E", "--tabstospaces", N_("Convert typed tabs to spaces"));
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
if (!ISSET(RESTRICTED))
print_opt("-F", "--multibuffer",
N_("Read a file into a new buffer by default"));
@@ -837,9 +832,7 @@ void usage(void)
#endif
print_opt(_("-T <#cols>"), _("--tabsize=<#cols>"),
N_("Set width of a tab to #cols columns"));
#ifndef NANO_TINY
print_opt("-U", "--quickblank", N_("Do quick statusbar blanking"));
#endif
print_opt("-V", "--version", N_("Print version information and exit"));
#ifndef NANO_TINY
print_opt("-W", "--wordbounds",
@@ -867,7 +860,7 @@ void usage(void)
#ifdef ENABLE_LINENUMBERS
print_opt("-l", "--linenumbers", N_("Show line numbers in front of the text"));
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
print_opt("-m", "--mouse", N_("Enable the use of the mouse"));
#endif
print_opt("-n", "--noread", N_("Do not read the file (only write it)"));
@@ -916,10 +909,9 @@ void version(void)
#else
printf(_(" GNU nano, version %s\n"), VERSION);
#endif
printf(" (C) 1999..2016 Free Software Foundation, Inc.\n");
printf(_(" (C) 2014..%s the contributors to nano\n"), "2017");
printf(
_(" Email: nano@nano-editor.org Web: https://nano-editor.org/"));
printf(" (C) 1999-2011, 2013-2017 Free Software Foundation, Inc.\n");
printf(_(" (C) 2014-%s the contributors to nano\n"), "2017");
printf(_(" Email: nano@nano-editor.org Web: https://nano-editor.org/"));
printf(_("\n Compiled options:"));
#ifdef NANO_TINY
@@ -933,7 +925,7 @@ void version(void)
#ifndef DISABLE_EXTRA
printf(" --enable-extra");
#endif
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
printf(" --enable-help");
#endif
#ifndef DISABLE_HISTORIES
@@ -948,13 +940,13 @@ void version(void)
#ifdef ENABLE_LINENUMBERS
printf(" --enable-linenumbers");
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
printf(" --enable-mouse");
#endif
#ifndef DISABLE_NANORC
printf(" --enable-nanorc");
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
printf(" --enable-multibuffer");
#endif
#ifndef DISABLE_OPERATINGDIR
@@ -982,7 +974,7 @@ void version(void)
#ifdef DISABLE_EXTRA
printf(" --disable-extra");
#endif
#ifdef DISABLE_HELP
#ifndef ENABLE_HELP
printf(" --disable-help");
#endif
#ifdef DISABLE_HISTORIES
@@ -997,10 +989,10 @@ void version(void)
#ifndef ENABLE_LINENUMBERS
printf(" --disable-linenumbers");
#endif
#ifdef DISABLE_MOUSE
#ifndef ENABLE_MOUSE
printf(" --disable-mouse");
#endif
#ifdef DISABLE_MULTIBUFFER
#ifndef ENABLE_MULTIBUFFER
printf(" --disable-multibuffer");
#endif
#ifdef DISABLE_NANORC
@@ -1092,7 +1084,7 @@ void close_and_go(void)
if (ISSET(LOCKING) && openfile->lock_filename)
delete_lockfile(openfile->lock_filename);
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
/* If there are no more open file buffers, jump off a cliff. */
if (!close_buffer())
#endif
@@ -1233,8 +1225,7 @@ RETSIGTYPE handle_hupterm(int signal)
/* Handler for SIGTSTP (suspend). */
RETSIGTYPE do_suspend(int signal)
{
#ifndef DISABLE_MOUSE
/* Turn mouse support off. */
#ifdef ENABLE_MOUSE
disable_mouse_support();
#endif
@@ -1277,8 +1268,7 @@ void do_suspend_void(void)
/* Handler for SIGCONT (continue after suspend). */
RETSIGTYPE do_continue(int signal)
{
#ifndef DISABLE_MOUSE
/* Turn mouse support back on if it was on before. */
#ifdef ENABLE_MOUSE
if (ISSET(USE_MOUSE))
enable_mouse_support();
#endif
@@ -1388,7 +1378,7 @@ void do_toggle(int flag)
TOGGLE(flag);
switch (flag) {
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
case USE_MOUSE:
mouse_init();
break;
@@ -1421,7 +1411,7 @@ void do_toggle(int flag)
enabled = !enabled;
statusline(HUSH, "%s %s", _(flagtostr(flag)),
enabled ? _("enabled") : _("disabled"));
enabled ? _("enabled") : _("disabled"));
}
/* Bleh. */
@@ -1566,7 +1556,7 @@ void unbound_key(int code)
statusline(ALERT, _("Unbound key: M-%c"), toupper(code));
} else if (code < 0x20)
statusline(ALERT, _("Unbound key: ^%c"), code + 0x40);
else
else if (currmenu != MHELP)
statusline(ALERT, _("Unbound key: %c"), code);
}
@@ -1594,7 +1584,7 @@ int do_input(bool allow_funcs)
return KEY_WINCH;
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
if (input == KEY_MOUSE) {
/* We received a mouse click. */
if (do_mouse() == 1)
@@ -1749,7 +1739,7 @@ void xoff_complaint(void)
}
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
/* Handle a mouse click on the edit window or the shortcut list. */
int do_mouse(void)
{
@@ -1762,13 +1752,13 @@ int do_mouse(void)
/* If the click was in the edit window, put the cursor in that spot. */
if (wmouse_trafo(edit, &mouse_row, &mouse_col, FALSE)) {
bool sameline = (mouse_row == openfile->current_y);
/* Whether the click was on the row where the cursor is. */
filestruct *current_save = openfile->current;
ssize_t row_count = mouse_row - openfile->current_y;
size_t leftedge;
#ifndef NANO_TINY
size_t current_x_save = openfile->current_x;
bool sameline = (mouse_row == openfile->current_y);
/* Whether the click was on the row where the cursor is. */
if (ISSET(SOFTWRAP))
leftedge = (xplustabs() / editwincols) * editwincols;
@@ -1805,14 +1795,14 @@ int do_mouse(void)
/* No more handling is needed. */
return 2;
}
#endif /* !DISABLE_MOUSE */
#endif /* ENABLE_MOUSE */
/* The user typed output_len multibyte characters. Add them to the edit
* buffer, filtering out all ASCII control characters if allow_cntrls is
* TRUE. */
void do_output(char *output, size_t output_len, bool allow_cntrls)
{
char *char_buf = charalloc(mb_cur_max());
char onechar[MAXCHARLEN];
int char_len;
size_t current_len = strlen(openfile->current->data);
size_t i = 0;
@@ -1832,7 +1822,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
output[i] = '\n';
/* Get the next multibyte character. */
char_len = parse_mbchar(output + i, char_buf, NULL);
char_len = parse_mbchar(output + i, onechar, NULL);
i += char_len;
@@ -1853,7 +1843,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
charmove(openfile->current->data + openfile->current_x + char_len,
openfile->current->data + openfile->current_x,
current_len - openfile->current_x + 1);
strncpy(openfile->current->data + openfile->current_x, char_buf,
strncpy(openfile->current->data + openfile->current_x, onechar,
char_len);
current_len += char_len;
openfile->totsize++;
@@ -1893,8 +1883,6 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
refresh_needed = TRUE;
#endif
free(char_buf);
openfile->placewewant = xplustabs();
#ifndef DISABLE_COLOR
@@ -1918,14 +1906,14 @@ int main(int argc, char **argv)
/* Should long lines be automatically hard wrapped? */
#endif
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
bool old_multibuffer;
/* The old value of the multibuffer option, restored after we
* load all files on the command line. */
#endif
const struct option long_options[] = {
{"boldtext", 0, NULL, 'D'},
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
{"multibuffer", 0, NULL, 'F'},
#endif
#ifndef DISABLE_NANORC
@@ -1939,6 +1927,7 @@ int main(int argc, char **argv)
#endif
{"restricted", 0, NULL, 'R'},
{"tabsize", 1, NULL, 'T'},
{"quickblank", 0, NULL, 'U'},
{"version", 0, NULL, 'V'},
#ifndef DISABLE_COLOR
{"syntax", 1, NULL, 'Y'},
@@ -1952,7 +1941,7 @@ int main(int argc, char **argv)
#ifdef ENABLE_LINENUMBERS
{"linenumbers", 0, NULL, 'l'},
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
{"mouse", 0, NULL, 'm'},
#endif
{"noread", 0, NULL, 'n'},
@@ -1985,7 +1974,6 @@ int main(int argc, char **argv)
{"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'},
{"wordchars", 1, NULL, 'X'},
{"autoindent", 0, NULL, 'i'},
@@ -2000,18 +1988,14 @@ int main(int argc, char **argv)
tcgetattr(0, &oldterm);
#ifdef ENABLE_UTF8
{
/* If the locale set exists and uses UTF-8, we should use
* UTF-8. */
char *locale = setlocale(LC_ALL, "");
if (locale != NULL && (strcmp(nl_langinfo(CODESET),
"UTF-8") == 0)) {
/* If setting the locale is successful and it uses UTF-8, we need
* to use the multibyte functions for text processing. */
if (setlocale(LC_ALL, "") != NULL &&
strcmp(nl_langinfo(CODESET), "UTF-8") == 0) {
#ifdef USE_SLANG
SLutf8_enable(1);
SLutf8_enable(1);
#endif
utf8_init();
}
utf8_init();
}
#else
setlocale(LC_ALL, "");
@@ -2022,6 +2006,12 @@ int main(int argc, char **argv)
textdomain(PACKAGE);
#endif
#ifdef ENABLE_UTF8
if (MB_CUR_MAX > MAXCHARLEN)
fprintf(stderr, "Unexpected large character size: %i bytes"
" -- please report a bug\n", (int)MB_CUR_MAX);
#endif
#if defined(DISABLE_NANORC) && defined(DISABLE_ROOTWRAPPING)
/* If we don't have rcfile support, --disable-wrapping-as-root is
* used, and we're root, turn wrapping off. */
@@ -2064,7 +2054,7 @@ int main(int argc, char **argv)
SET(TABS_TO_SPACES);
break;
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
case 'F':
SET(MULTIBUFFER);
break;
@@ -2123,11 +2113,9 @@ int main(int argc, char **argv)
exit(1);
}
break;
#ifndef NANO_TINY
case 'U':
SET(QUICK_BLANK);
break;
#endif
case 'V':
version();
exit(0);
@@ -2145,7 +2133,7 @@ int main(int argc, char **argv)
break;
#endif
case 'c':
SET(CONST_UPDATE);
SET(CONSTANT_SHOW);
break;
case 'd':
SET(REBIND_DELETE);
@@ -2161,7 +2149,7 @@ int main(int argc, char **argv)
SET(CUT_TO_END);
break;
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
case 'm':
SET(USE_MOUSE);
break;
@@ -2496,7 +2484,7 @@ int main(int argc, char **argv)
/* Set up the signal handlers. */
signal_init();
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
/* Initialize mouse support. */
mouse_init();
#endif
@@ -2516,12 +2504,18 @@ int main(int argc, char **argv)
controlright = get_keycode("kRIT5", CONTROL_RIGHT);
controlup = get_keycode("kUP5", CONTROL_UP);
controldown = get_keycode("kDN5", CONTROL_DOWN);
/* Ask for the codes for Control+Home/End. */
controlhome = get_keycode("kHOM5", CONTROL_HOME);
controlend = get_keycode("kEND5", CONTROL_END);
#ifndef NANO_TINY
/* Ask for the codes for Shift+Control+Left/Right/Up/Down. */
shiftcontrolleft = get_keycode("kLFT6", SHIFT_CONTROL_LEFT);
shiftcontrolright = get_keycode("kRIT6", SHIFT_CONTROL_RIGHT);
shiftcontrolup = get_keycode("kUP6", SHIFT_CONTROL_UP);
shiftcontroldown = get_keycode("kDN6", SHIFT_CONTROL_DOWN);
/* Ask for the codes for Shift+Control+Home/End. */
shiftcontrolhome = get_keycode("kHOM6", SHIFT_CONTROL_HOME);
shiftcontrolend = get_keycode("kEND6", SHIFT_CONTROL_END);
/* Ask for the codes for Shift+Alt+Left/Right/Up/Down. */
shiftaltleft = get_keycode("kLFT4", SHIFT_ALT_LEFT);
shiftaltright = get_keycode("kRIT4", SHIFT_ALT_RIGHT);
@@ -2554,7 +2548,7 @@ int main(int argc, char **argv)
optind++;
}
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
old_multibuffer = ISSET(MULTIBUFFER);
SET(MULTIBUFFER);
@@ -2593,7 +2587,7 @@ int main(int argc, char **argv)
}
}
}
#endif /* !DISABLE_MULTIBUFFER */
#endif /* ENABLE_MULTIBUFFER */
/* Now read the first file on the command line into a new buffer. */
if (optind < argc)
@@ -2607,7 +2601,7 @@ int main(int argc, char **argv)
UNSET(VIEW_MODE);
}
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
if (!old_multibuffer)
UNSET(MULTIBUFFER);
#endif
@@ -2625,10 +2619,10 @@ int main(int argc, char **argv)
#endif
#ifdef DEBUG
fprintf(stderr, "Main: show buffer contents, and enter main loop\n");
fprintf(stderr, "Main: show title bar, and enter main loop\n");
#endif
display_buffer();
prepare_for_display();
while (TRUE) {
#ifdef ENABLE_LINENUMBERS
@@ -2658,12 +2652,12 @@ int main(int argc, char **argv)
/* Update the displayed current cursor position only when there
* are no keys waiting in the input buffer. */
if (ISSET(CONST_UPDATE) && get_key_buffer_len() == 0)
if (ISSET(CONSTANT_SHOW) && get_key_buffer_len() == 0)
do_cursorpos(FALSE);
/* Refresh just the cursor position or the entire edit window. */
if (!refresh_needed) {
reset_cursor();
place_the_cursor();
wnoutrefresh(edit);
} else
edit_refresh();

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* nano.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2014, 2015, 2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -68,6 +67,13 @@
#define charmove(dest, src, n) memmove(dest, src, (n) * sizeof(char))
#define charset(dest, src, n) memset(dest, src, (n) * sizeof(char))
/* In UTF-8 a character is at most six bytes long. */
#ifdef ENABLE_UTF8
#define MAXCHARLEN 6
#else
#define MAXCHARLEN 1
#endif
/* Set a default value for PATH_MAX if there isn't one. */
#ifndef PATH_MAX
#define PATH_MAX 4096
@@ -118,10 +124,10 @@
#include <signal.h>
#include <assert.h>
/* If we aren't using ncurses with mouse support, turn the mouse support
* off, as it's useless then. */
/* If we aren't using an ncurses with mouse support, exclude any
* mouse routines, as they are useless then. */
#ifndef NCURSES_MOUSE_VERSION
#define DISABLE_MOUSE 1
#undef ENABLE_MOUSE
#endif
#if defined(DISABLE_WRAPPING) && defined(DISABLE_JUSTIFY)
@@ -436,7 +442,7 @@ typedef struct subnfunc {
/* In what menus this function applies. */
const char *desc;
/* The function's short description, for example "Where Is". */
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
const char *help;
/* The help-screen text for this function. */
bool blank_after;
@@ -474,7 +480,7 @@ enum
{
DONTUSE,
CASE_SENSITIVE,
CONST_UPDATE,
CONSTANT_SHOW,
NO_HELP,
SUSPEND,
NO_WRAP,
@@ -532,9 +538,10 @@ enum
#define MGOTODIR (1<<12)
#define MYESNO (1<<13)
#define MLINTER (1<<14)
#define MFINDINHELP (1<<15)
/* This is an abbreviation for all menus except Help and YesNo. */
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\
MEXTCMD|MBROWSER|MWHEREISFILE|MGOTODIR|MSPELL|MLINTER)
MEXTCMD|MBROWSER|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER)
/* Basic control codes. */
#define TAB_CODE 0x09
@@ -546,10 +553,14 @@ enum
#define CONTROL_RIGHT 0x402
#define CONTROL_UP 0x403
#define CONTROL_DOWN 0x404
#define CONTROL_HOME 0x411
#define CONTROL_END 0x412
#define SHIFT_CONTROL_LEFT 0x405
#define SHIFT_CONTROL_RIGHT 0x406
#define SHIFT_CONTROL_UP 0x407
#define SHIFT_CONTROL_DOWN 0x408
#define SHIFT_CONTROL_HOME 0x413
#define SHIFT_CONTROL_END 0x414
#define SHIFT_ALT_LEFT 0x409
#define SHIFT_ALT_RIGHT 0x40a
#define SHIFT_ALT_UP 0x40b

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* prompt.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -58,7 +57,7 @@ int do_statusbar_input(bool *ran_func, bool *finished)
return KEY_WINCH;
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
/* If we got a mouse click and it was on a shortcut, read in the
* shortcut character. */
if (input == KEY_MOUSE) {
@@ -165,7 +164,7 @@ int do_statusbar_input(bool *ran_func, bool *finished)
return input;
}
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
/* Handle a mouse click on the statusbar prompt or the shortcut list. */
int do_statusbar_mouse(void)
{
@@ -197,7 +196,7 @@ void do_statusbar_output(int *the_input, size_t input_len,
bool filtering)
{
char *output = charalloc(input_len + 1);
char *char_buf = charalloc(mb_cur_max());
char onechar[MAXCHARLEN];
int i, char_len;
/* Copy the typed stuff so it can be treated. */
@@ -213,7 +212,7 @@ void do_statusbar_output(int *the_input, size_t input_len,
output[i] = '\n';
/* Interpret the next multibyte character. */
char_len = parse_mbchar(output + i, char_buf, NULL);
char_len = parse_mbchar(output + i, onechar, NULL);
i += char_len;
@@ -225,12 +224,11 @@ void do_statusbar_output(int *the_input, size_t input_len,
answer = charealloc(answer, strlen(answer) + char_len + 1);
charmove(answer + statusbar_x + char_len, answer + statusbar_x,
strlen(answer) - statusbar_x + 1);
strncpy(answer + statusbar_x, char_buf, char_len);
strncpy(answer + statusbar_x, onechar, char_len);
statusbar_x += char_len;
}
free(char_buf);
free(output);
update_the_statusbar();
@@ -385,35 +383,18 @@ void reinit_statusbar_x(void)
statusbar_x = HIGHEST_POSITIVE;
}
/* Put the cursor in the answer at statusbar_x. */
void reset_statusbar_cursor(void)
{
size_t start_col = strlenpt(prompt) + 2;
size_t xpt = statusbar_xplustabs();
/* Work around a cursor-misplacement bug in VTEs. */
wmove(bottomwin, 0, 0);
wnoutrefresh(bottomwin);
doupdate();
wmove(bottomwin, 0, start_col + xpt -
get_statusbar_page_start(start_col, start_col + xpt));
wnoutrefresh(bottomwin);
}
/* Repaint the statusbar. */
/* Redraw the promptbar and place the cursor at the right spot. */
void update_the_statusbar(void)
{
size_t base, the_page, end_page;
size_t base = strlenpt(prompt) + 2;
size_t the_page, end_page, column;
char *expanded;
base = strlenpt(prompt) + 2;
the_page = get_statusbar_page_start(base, base + strnlenpt(answer, statusbar_x));
end_page = get_statusbar_page_start(base, base + strlenpt(answer) - 1);
/* Color the promptbar over its full width. */
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
blank_statusbar();
mvwaddstr(bottomwin, 0, 0, prompt);
@@ -428,7 +409,15 @@ void update_the_statusbar(void)
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
reset_statusbar_cursor();
/* Work around a cursor-misplacement bug in VTEs. */
wmove(bottomwin, 0, 0);
wnoutrefresh(bottomwin);
doupdate();
/* Place the cursor at statusbar_x in the answer. */
column = base + statusbar_xplustabs();
wmove(bottomwin, 0, column - get_statusbar_page_start(base, column));
wnoutrefresh(bottomwin);
}
/* Get a string of input at the statusbar prompt. */
@@ -470,10 +459,6 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
update_the_statusbar();
/* Refresh edit window and statusbar before getting input. */
wnoutrefresh(edit);
wnoutrefresh(bottomwin);
while (TRUE) {
/* Ensure the cursor is shown when waiting for input. */
curs_set(1);
@@ -622,8 +607,9 @@ int do_prompt(bool allow_tabs, bool allow_files,
int retval;
functionptrtype func = NULL;
bool listed = FALSE;
/* Save a possible current statusbar x position. */
/* Save a possible current statusbar x position and prompt. */
size_t was_statusbar_x = statusbar_x;
char *saved_prompt = prompt;
bottombars(menu);
@@ -632,9 +618,9 @@ int do_prompt(bool allow_tabs, bool allow_files,
#ifndef NANO_TINY
redo_theprompt:
#endif
prompt = charalloc((COLS * mb_cur_max()) + 1);
prompt = charalloc((COLS * MAXCHARLEN) + 1);
va_start(ap, msg);
vsnprintf(prompt, COLS * mb_cur_max(), msg, ap);
vsnprintf(prompt, COLS * MAXCHARLEN, msg, ap);
va_end(ap);
/* Reserve five columns for colon plus angles plus answer, ":<aa>". */
prompt[actual_x(prompt, (COLS < 5) ? 0 : COLS - 5)] = '\0';
@@ -646,7 +632,7 @@ int do_prompt(bool allow_tabs, bool allow_files,
refresh_func);
free(prompt);
prompt = NULL;
prompt = saved_prompt;
#ifndef NANO_TINY
if (retval == KEY_WINCH)
@@ -753,7 +739,7 @@ int do_yesno_prompt(bool all, const char *msg)
if (func == do_cancel)
response = -1;
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
else if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y;
/* We can click on the Yes/No/All shortcuts to select an answer. */
@@ -775,7 +761,7 @@ int do_yesno_prompt(bool all, const char *msg)
response = -2;
}
}
#endif /* !DISABLE_MOUSE */
#endif /* ENABLE_MOUSE */
else {
/* Look for the kbinput in the Yes, No (and All) strings. */
if (strchr(yesstr, kbinput) != NULL)

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* proto.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -25,6 +24,7 @@
#include "nano.h"
/* All external variables. See global.c for their descriptions. */
#ifndef NANO_TINY
extern volatile sig_atomic_t the_window_resized;
#endif
@@ -43,19 +43,32 @@ extern bool as_an_at;
extern int margin;
extern int editwincols;
#ifndef DISABLE_COLOR
extern bool have_palette;
#endif
extern message_type lastmessage;
extern filestruct *pletion_line;
extern bool inhelp;
extern char *title;
extern int didfind;
extern int controlleft;
extern int controlright;
extern int controlup;
extern int controldown;
extern int controlhome;
extern int controlend;
#ifndef NANO_TINY
extern int shiftcontrolleft;
extern int shiftcontrolright;
extern int shiftcontrolup;
extern int shiftcontroldown;
extern int shiftcontrolhome;
extern int shiftcontrolend;
extern int shiftaltleft;
extern int shiftaltright;
extern int shiftaltup;
@@ -162,17 +175,13 @@ extern char *homedir;
typedef void (*functionptrtype)(void);
/* All functions in browser.c. */
/* Most functions in browser.c. */
#ifndef DISABLE_BROWSER
char *do_browser(char *path);
char *do_browse_from(const char *inpath);
void read_the_list(const char *path, DIR *dir);
functionptrtype parse_browser_input(int *kbinput);
void browser_refresh(void);
void browser_select_dirname(const char *needle);
int filesearch_init(void);
void findnextfile(const char *needle);
void filesearch_abort(void);
void do_filesearch(void);
void do_fileresearch(void);
void do_first_file(void);
@@ -188,18 +197,13 @@ bool using_utf8(void);
char *addstrings(char* str1, size_t len1, char* str2, size_t len2);
bool is_byte(int c);
bool is_alpha_mbchar(const char *c);
bool is_alnum_mbchar(const char *c);
bool is_blank_mbchar(const char *c);
bool is_ascii_cntrl_char(int c);
bool is_cntrl_char(int c);
bool is_cntrl_mbchar(const char *c);
bool is_punct_mbchar(const char *c);
bool is_word_mbchar(const char *c, bool allow_punct);
char control_rep(const signed char c);
char control_mbrep(const char *c, bool isdata);
int length_of_char(const char *c, int *width);
int mbwidth(const char *c);
int mb_cur_max(void);
char *make_mbchar(long chr, int *chr_mb_len);
int parse_mbchar(const char *buf, char *chr, size_t *col);
size_t move_mbleft(const char *buf, size_t pos);
@@ -208,11 +212,9 @@ int mbstrcasecmp(const char *s1, const char *s2);
int mbstrncasecmp(const char *s1, const char *s2, size_t n);
char *mbstrcasestr(const char *haystack, const char *needle);
char *revstrstr(const char *haystack, const char *needle,
const char *pointer);
char *revstrcasestr(const char *haystack, const char *needle, const char
*rev_start);
char *mbrevstrcasestr(const char *haystack, const char *needle, const
char *rev_start);
const char *index);
char *mbrevstrcasestr(const char *haystack, const char *needle,
const char *index);
size_t mbstrlen(const char *s);
size_t mbstrnlen(const char *s, size_t maxlen);
#if !defined(NANO_TINY) || !defined(DISABLE_JUSTIFY)
@@ -220,13 +222,10 @@ char *mbstrchr(const char *s, const char *c);
#endif
#ifndef NANO_TINY
char *mbstrpbrk(const char *s, const char *accept);
char *revstrpbrk(const char *s, const char *accept, const char
*rev_start);
char *mbrevstrpbrk(const char *s, const char *accept, const char
*rev_start);
char *revstrpbrk(const char *head, const char *accept, const char *index);
char *mbrevstrpbrk(const char *head, const char *accept, const char *index);
#endif
#if !defined(DISABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
bool has_blank_chars(const char *s);
bool has_blank_mbchars(const char *s);
#endif
#ifdef ENABLE_UTF8
@@ -246,14 +245,11 @@ void alloc_multidata_if_needed(filestruct *fileptr);
void precalc_multicolorinfo(void);
#endif
/* All functions in cut.c. */
/* Most functions in cut.c. */
void cutbuffer_reset(void);
bool keeping_cutbuffer(void);
void cut_line(void);
#ifndef NANO_TINY
void cut_marked(bool *right_side_up);
void cut_to_eol(void);
void cut_to_eof(void);
#endif
void do_cut_text(bool copy_text, bool cut_till_eof);
void do_cut_text_void(void);
@@ -264,7 +260,6 @@ void do_cut_till_eof(void);
void do_uncut_text(void);
/* Most functions in files.c. */
void make_new_buffer(void);
void initialize_buffer_text(void);
bool open_buffer(const char *filename, bool undoable);
#ifndef DISABLE_SPELLER
@@ -274,20 +269,18 @@ void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
filestruct *bot, size_t bot_x);
#endif
#endif
void display_buffer(void);
#ifndef DISABLE_MULTIBUFFER
void prepare_for_display(void);
#ifdef ENABLE_MULTIBUFFER
void switch_to_prev_buffer_void(void);
void switch_to_next_buffer_void(void);
bool close_buffer(void);
#endif
char *encode_data(char *buf, size_t buf_len);
void read_file(FILE *f, int fd, const char *filename, bool undoable,
bool checkwritable);
int open_file(const char *filename, bool newfie, bool quiet, FILE **f);
char *get_next_filename(const char *name, const char *suffix);
void do_insertfile_void(void);
char *get_full_path(const char *origpath);
char *check_writable_directory(const char *path);
char *safe_tempfile(FILE **f);
#ifndef DISABLE_OPERATINGDIR
void init_operating_dir(void);
@@ -298,7 +291,7 @@ void init_backup_dir(void);
int delete_lockfile(const char *lockfilename);
int write_lockfile(const char *lockfilename, const char *origfilename, bool modified);
#endif
int copy_file(FILE *inn, FILE *out);
int copy_file(FILE *inn, FILE *out, bool close_out);
bool write_file(const char *name, FILE *f_open, bool tmp,
kind_of_writing_type method, bool nonamechange);
#ifndef NANO_TINY
@@ -316,19 +309,12 @@ int diralphasort(const void *va, const void *vb);
void free_chararray(char **array, size_t len);
#endif
#ifndef DISABLE_TABCOMP
bool is_dir(const char *buf);
char **username_tab_completion(const char *buf, size_t *num_matches,
size_t buf_len);
char **cwd_tab_completion(const char *buf, bool allow_files, size_t
*num_matches, size_t buf_len);
char *input_tab(char *buf, bool allow_files, size_t *place,
bool *lastwastab, void (*refresh_func)(void), bool *listed);
#endif
const char *tail(const char *path);
#ifndef DISABLE_HISTORIES
char *histfilename(void);
void load_history(void);
bool writehist(FILE *hist, const filestruct *head);
void save_history(void);
int check_dotnano(void);
void load_poshistory(void);
@@ -358,7 +344,8 @@ void thanks_for_all_the_fish(void);
#endif
/* All functions in help.c. */
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
void wrap_the_help_text(bool redisplaying);
void do_help(void);
void help_init(void);
functionptrtype parse_help_input(int *kbinput);
@@ -372,16 +359,16 @@ void do_last_line(void);
void do_page_up(void);
void do_page_down(void);
#ifndef DISABLE_JUSTIFY
void do_para_begin(bool allow_update);
void do_para_begin(bool update_screen);
void do_para_begin_void(void);
void do_para_end(bool allow_update);
void do_para_end(bool update_screen);
void do_para_end_void(void);
#endif
void do_prev_block(void);
void do_next_block(void);
void do_prev_word(bool allow_punct, bool allow_update);
void do_prev_word(bool allow_punct, bool update_screen);
void do_prev_word_void(void);
bool do_next_word(bool allow_punct, bool allow_update);
bool do_next_word(bool allow_punct, bool update_screen);
void do_next_word_void(void);
void do_home(bool be_clever);
void do_home_void(void);
@@ -398,9 +385,8 @@ void do_scroll_down(void);
void do_left(void);
void do_right(void);
/* All functions in nano.c. */
/* Most functions in nano.c. */
filestruct *make_new_node(filestruct *prevnode);
filestruct *copy_node(const filestruct *src);
void splice_node(filestruct *afterthis, filestruct *newnode);
void unlink_node(filestruct *fileptr);
void delete_node(filestruct *fileptr);
@@ -419,24 +405,15 @@ void unlink_opennode(openfilestruct *fileptr);
void delete_opennode(openfilestruct *fileptr);
void print_view_warning(void);
void show_restricted_warning(void);
#ifdef DISABLE_HELP
#ifndef ENABLE_HELP
void say_there_is_no_help(void);
#endif
void finish(void);
void die(const char *msg, ...);
void die_save_file(const char *die_filename, struct stat *die_stat);
void window_init(void);
#ifndef DISABLE_MOUSE
void disable_mouse_support(void);
void enable_mouse_support(void);
void mouse_init(void);
#endif
void print_opt(const char *shortflag, const char *longflag, const char *desc);
void usage(void);
void version(void);
void do_exit(void);
void close_and_go(void);
void signal_init(void);
RETSIGTYPE handle_hupterm(int signal);
RETSIGTYPE do_suspend(int signal);
RETSIGTYPE do_continue(int signal);
@@ -453,13 +430,13 @@ void enable_flow_control(void);
void terminal_init(void);
void unbound_key(int code);
int do_input(bool allow_funcs);
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
int do_mouse(void);
#endif
void do_output(char *output, size_t output_len, bool allow_cntrls);
/* Most functions in prompt.c. */
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
int do_statusbar_mouse(void);
#endif
void do_statusbar_output(int *the_input, size_t input_len,
@@ -479,7 +456,6 @@ void do_statusbar_verbatim_input(void);
size_t statusbar_xplustabs(void);
size_t get_statusbar_page_start(size_t start_col, size_t column);
void reinit_statusbar_x(void);
void reset_statusbar_cursor(void);
void update_the_statusbar(void);
int do_prompt(bool allow_tabs, bool allow_files,
int menu, const char *curranswer,
@@ -490,9 +466,6 @@ int do_prompt(bool allow_tabs, bool allow_files,
int do_yesno_prompt(bool all, const char *msg);
/* Most functions in rcfile.c. */
#if !defined(DISABLE_NANORC) || !defined(DISABLE_HISTORIES)
char *parse_next_word(char *ptr);
#endif
#ifndef DISABLE_NANORC
#ifndef DISABLE_COLOR
bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright);
@@ -502,12 +475,9 @@ void parse_rcfile(FILE *rcstream, bool syntax_only);
void do_rcfiles(void);
#endif /* !DISABLE_NANORC */
/* All functions in search.c. */
bool regexp_init(const char *regexp);
void regexp_cleanup(void);
/* Most functions in search.c. */
void not_found_msg(const char *str);
void search_replace_abort(void);
int search_init(bool replacing, bool use_answer);
int findnextstr(const char *needle, bool whole_word_only, bool have_region,
size_t *match_len, bool skipone, const filestruct *begin, size_t begin_x);
void do_search(void);
@@ -517,8 +487,6 @@ void do_findnext(void);
#endif
void do_research(void);
void go_looking(void);
int replace_regexp(char *string, bool create);
char *replace_line(const char *needle);
ssize_t do_replace_loop(const char *needle, bool whole_word_only,
const filestruct *real_current, size_t *real_current_x);
void do_replace(void);
@@ -527,7 +495,6 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
bool interactive);
void do_gotolinecolumn_void(void);
#ifndef NANO_TINY
bool find_bracket_match(bool reverse, const char *bracket_set);
void do_find_bracket(void);
#ifndef DISABLE_TABCOMP
char *get_history_completion(filestruct **h, char *s, size_t len);
@@ -537,8 +504,6 @@ char *get_history_completion(filestruct **h, char *s, size_t len);
bool history_has_changed(void);
void history_init(void);
void history_reset(const filestruct *h);
filestruct *find_history(const filestruct *h_start, const filestruct
*h_end, const char *s, size_t len);
void update_history(filestruct **h, const char *s);
char *get_history_older(filestruct **h);
char *get_history_newer(filestruct **h);
@@ -546,7 +511,7 @@ void get_history_older_void(void);
void get_history_newer_void(void);
#endif
/* All functions in text.c. */
/* Most functions in text.c. */
#ifndef NANO_TINY
void do_mark(void);
#endif
@@ -584,7 +549,7 @@ void update_undo(undo_type action);
void wrap_reset(void);
bool do_wrap(filestruct *line);
#endif
#if !defined(DISABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
#if defined(ENABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl);
#endif
#if !defined(NANO_TINY) || !defined(DISABLE_JUSTIFY)
@@ -592,23 +557,13 @@ size_t indent_length(const char *line);
#endif
#ifndef DISABLE_JUSTIFY
void justify_format(filestruct *paragraph, size_t skip);
size_t quote_length(const char *line);
bool quotes_match(const char *a_line, size_t a_quote, const char
*b_line);
bool indents_match(const char *a_line, size_t a_indent, const char
*b_line, size_t b_indent);
bool begpar(const filestruct *const foo);
bool inpar(const filestruct *const foo);
void backup_lines(filestruct *first_line, size_t par_len);
bool find_paragraph(size_t *const quote, size_t *const par);
void do_justify(bool full_justify);
void do_justify_void(void);
void do_full_justify(void);
#endif
#ifndef DISABLE_SPELLER
bool do_int_spell_fix(const char *word);
const char *do_int_speller(const char *tempfile_name);
const char *do_alt_speller(char *tempfile_name);
void do_spell(void);
#endif
#ifndef DISABLE_COLOR
@@ -650,8 +605,10 @@ size_t actual_x(const char *s, size_t column);
size_t strnlenpt(const char *s, size_t maxlen);
size_t strlenpt(const char *s);
void new_magicline(void);
#ifndef NANO_TINY
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
void remove_magicline(void);
#endif
#ifndef NANO_TINY
void mark_order(const filestruct **top, size_t *top_x, const filestruct
**bot, size_t *bot_x, bool *right_side_up);
#endif
@@ -667,34 +624,25 @@ void dump_filestruct_reverse(void);
/* Most functions in winio.c. */
void get_key_buffer(WINDOW *win);
size_t get_key_buffer_len(void);
void unget_input(int *input, size_t input_len);
void unget_kbinput(int kbinput, bool metakey);
int *get_input(WINDOW *win, size_t input_len);
int get_kbinput(WINDOW *win);
int parse_kbinput(WINDOW *win);
int arrow_from_abcd(int kbinput);
int parse_escape_sequence(WINDOW *win, int kbinput);
int get_byte_kbinput(int kbinput);
#ifdef ENABLE_UTF8
long add_unicode_digit(int kbinput, long factor, long *uni);
long get_unicode_kbinput(WINDOW *win, int kbinput);
#endif
int get_control_kbinput(int kbinput);
void unparse_kbinput(char *output, size_t output_len);
int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len);
int *parse_verbatim_kbinput(WINDOW *win, size_t *count);
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts);
#endif
const sc *get_shortcut(int *kbinput);
void blank_row(WINDOW *win, int y, int x, int n);
void blank_titlebar(void);
void blank_edit(void);
void blank_statusbar(void);
void blank_bottombars(void);
void check_statusblank(void);
char *display_string(const char *buf, size_t start_col, size_t span,
bool dollars);
char *display_string(const char *buf, size_t column, size_t span, bool isdata);
void titlebar(const char *path);
extern void set_modified(void);
void statusbar(const char *msg);
@@ -702,7 +650,7 @@ void warn_and_shortly_pause(const char *msg);
void statusline(message_type importance, const char *msg, ...);
void bottombars(int menu);
void onekey(const char *keystroke, const char *desc, int length);
void reset_cursor(void);
void place_the_cursor(void);
void edit_draw(filestruct *fileptr, const char *converted,
int line, size_t from_col);
int update_line(filestruct *fileptr, size_t index);
@@ -715,9 +663,6 @@ int go_forward_chunks(int nrows, filestruct **line, size_t *leftedge);
bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge);
void edit_scroll(scroll_dir direction, int nrows);
void ensure_firstcolumn_is_aligned(void);
bool current_is_above_screen(void);
bool current_is_below_screen(void);
bool current_is_offscreen(void);
void edit_redraw(filestruct *old_current);
void edit_refresh(void);
void adjust_viewport(update_type location);

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* rcfile.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, *
* 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2014 Mike Frysinger *
* Copyright (C) 2014, 2015, 2016 Benno Schulenberg *
* *
@@ -45,8 +44,8 @@ static const rcoption rcopts[] = {
#ifndef DISABLE_JUSTIFY
{"brackets", 0},
#endif
{"const", CONST_UPDATE}, /* deprecated form, remove in 2018 */
{"constantshow", CONST_UPDATE},
{"const", CONSTANT_SHOW}, /* deprecated form, remove in 2018 */
{"constantshow", CONSTANT_SHOW},
#ifndef DISABLE_WRAPJUSTIFY
{"fill", 0},
#endif
@@ -54,10 +53,10 @@ static const rcoption rcopts[] = {
{"historylog", HISTORYLOG},
#endif
{"morespace", MORE_SPACE},
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
{"mouse", USE_MOUSE},
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
{"multibuffer", MULTIBUFFER},
#endif
{"nohelp", NO_HELP},
@@ -78,6 +77,7 @@ static const rcoption rcopts[] = {
{"punct", 0},
{"quotestr", 0},
#endif
{"quickblank", QUICK_BLANK},
{"rebinddelete", REBIND_DELETE},
{"rebindkeypad", REBIND_KEYPAD},
{"regexp", USE_REGEXP},
@@ -100,7 +100,6 @@ static const rcoption rcopts[] = {
{"locking", LOCKING},
{"matchbrackets", 0},
{"noconvert", NO_CONVERT},
{"quickblank", QUICK_BLANK},
{"quiet", QUIET},
{"showcursor", SHOW_CURSOR},
{"smarthome", SMART_HOME},

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* search.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2015, 2016, 2017 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -144,7 +143,8 @@ int search_init(bool replacing, bool use_answer)
/* This is now one simple call. It just does a lot. */
i = do_prompt(FALSE, FALSE,
replacing ? MREPLACE : MWHEREIS, backupstring,
inhelp ? MFINDINHELP : (replacing ? MREPLACE : MWHEREIS),
backupstring,
#ifndef DISABLE_HISTORIES
&search_history,
#endif
@@ -438,7 +438,6 @@ void go_looking(void)
{
filestruct *was_current = openfile->current;
size_t was_current_x = openfile->current_x;
int didfind;
#ifdef DEBUG
clock_t start = clock();
#endif
@@ -994,7 +993,7 @@ void do_find_bracket(void)
* the bracket at the current cursor position. */
int wanted_ch_len;
/* The length of wanted_ch in bytes. */
char *bracket_set;
char bracket_set[MAXCHARLEN * 2 + 1];
/* The pair of characters in ch and wanted_ch. */
size_t i;
/* Generic loop variable. */
@@ -1008,8 +1007,6 @@ void do_find_bracket(void)
/* The initial bracket count. */
bool reverse;
/* The direction we search. */
char *found_ch;
/* The character we find. */
assert(mbstrlen(matchbrackets) % 2 == 0);
@@ -1057,20 +1054,16 @@ void do_find_bracket(void)
wanted_ch_len = parse_mbchar(wanted_ch, NULL, NULL);
/* Fill bracket_set in with the values of ch and wanted_ch. */
bracket_set = charalloc((mb_cur_max() * 2) + 1);
strncpy(bracket_set, ch, ch_len);
strncpy(bracket_set + ch_len, wanted_ch, wanted_ch_len);
bracket_set[ch_len + wanted_ch_len] = '\0';
found_ch = charalloc(mb_cur_max() + 1);
while (TRUE) {
if (find_bracket_match(reverse, bracket_set)) {
/* If we found an identical bracket, increment count. If we
* found a complementary bracket, decrement it. */
parse_mbchar(openfile->current->data + openfile->current_x,
found_ch, NULL);
count += (strncmp(found_ch, ch, ch_len) == 0) ? 1 : -1;
count += (strncmp(openfile->current->data + openfile->current_x,
ch, ch_len) == 0) ? 1 : -1;
/* If count is zero, we've found a matching bracket. Update
* the screen and get out. */
@@ -1088,10 +1081,6 @@ void do_find_bracket(void)
break;
}
}
/* Clean up. */
free(bracket_set);
free(found_ch);
}
#endif /* !NANO_TINY */

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* text.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2014, 2015 Mark Majeres *
* Copyright (C) 2016 Mike Scalora *
* Copyright (C) 2015, 2016 Benno Schulenberg *
@@ -768,11 +767,13 @@ void do_undo(void)
break;
}
undidmsg = _("line break");
size_t from_x = (u->begin == 0) ? 0 : u->mark_begin_x;
size_t to_x = (u->begin == 0) ? u->mark_begin_x : u->begin;
f->data = charealloc(f->data, strlen(f->data) +
strlen(&f->next->data[u->mark_begin_x]) + 1);
strcat(f->data, &f->next->data[u->mark_begin_x]);
strlen(&u->strdata[from_x]) + 1);
strcat(f->data, &u->strdata[from_x]);
unlink_node(f->next);
goto_line_posx(u->lineno, u->begin);
goto_line_posx(u->lineno, to_x);
break;
#ifdef ENABLE_COMMENT
case COMMENT:
@@ -982,11 +983,8 @@ void do_enter(void)
{
filestruct *newnode = make_new_node(openfile->current);
size_t extra = 0;
assert(openfile->current != NULL && openfile->current->data != NULL);
#ifndef NANO_TINY
add_undo(ENTER);
bool allblanks = FALSE;
if (ISSET(AUTOINDENT)) {
extra = indent_length(openfile->current->data);
@@ -995,6 +993,8 @@ void do_enter(void)
* indentation to the current x position. */
if (extra > openfile->current_x)
extra = openfile->current_x;
else if (extra == openfile->current_x)
allblanks = TRUE;
}
#endif
newnode->data = charalloc(strlen(openfile->current->data +
@@ -1005,13 +1005,19 @@ void do_enter(void)
if (ISSET(AUTOINDENT)) {
/* Copy the whitespace from the current line to the new one. */
strncpy(newnode->data, openfile->current->data, extra);
openfile->totsize += extra;
/* If there were only blanks before the cursor, trim them. */
if (allblanks)
openfile->current_x = 0;
else
openfile->totsize += extra;
}
#endif
null_at(&openfile->current->data, openfile->current_x);
#ifndef NANO_TINY
add_undo(ENTER);
/* Adjust the mark if it was on the current line after the cursor. */
if (openfile->mark_set && openfile->current == openfile->mark_begin &&
openfile->current_x < openfile->mark_begin_x) {
@@ -1221,7 +1227,7 @@ void add_undo(undo_type action)
u->xflags = WAS_FINAL_BACKSPACE;
case DEL:
if (openfile->current->data[openfile->current_x] != '\0') {
char *char_buf = charalloc(mb_cur_max() + 1);
char *char_buf = charalloc(MAXCHARLEN + 1);
int char_len = parse_mbchar(&openfile->current->data[u->begin],
char_buf, NULL);
char_buf[char_len] = '\0';
@@ -1354,7 +1360,7 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
fprintf(stderr, " >> openfile->current->data = \"%s\", current_x = %lu, u->begin = %lu\n",
openfile->current->data, (unsigned long)openfile->current_x, (unsigned long)u->begin);
#endif
char *char_buf = charalloc(mb_cur_max());
char *char_buf = charalloc(MAXCHARLEN);
int char_len = parse_mbchar(&openfile->current->data[u->mark_begin_x], char_buf, NULL);
u->strdata = addstrings(u->strdata, u->strdata ? strlen(u->strdata) : 0, char_buf, char_len);
#ifdef DEBUG
@@ -1366,7 +1372,7 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
}
case BACK:
case DEL: {
char *char_buf = charalloc(mb_cur_max());
char *char_buf = charalloc(MAXCHARLEN);
int char_len = parse_mbchar(&openfile->current->data[openfile->current_x], char_buf, NULL);
if (openfile->current_x == u->begin) {
/* They deleted more: add removed character after earlier stuff. */
@@ -1602,7 +1608,7 @@ bool do_wrap(filestruct *line)
}
#endif /* !DISABLE_WRAPPING */
#if !defined(DISABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
#if defined(ENABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
/* We are trying to break a chunk off line. We find the last blank such
* that the display length to there is at most (goal + 1). If there is
* no such blank, then we find the first blank. We then take the last
@@ -1637,7 +1643,7 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
if (column <= goal)
return index;
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
/* If we're wrapping a help text and no blank was found, or was
* found only as the first character, force a line break. */
if (snap_at_nl && lastblank < 1)
@@ -1674,7 +1680,7 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
return lastblank;
}
#endif /* !DISABLE_HELP || !DISABLE_WRAPJUSTIFY */
#endif /* ENABLE_HELP || !DISABLE_WRAPJUSTIFY */
#if !defined(NANO_TINY) || !defined(DISABLE_JUSTIFY)
/* The "indentation" of a line is the whitespace between the quote part
@@ -1682,25 +1688,19 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
size_t indent_length(const char *line)
{
size_t len = 0;
char *blank_mb;
int blank_mb_len;
assert(line != NULL);
blank_mb = charalloc(mb_cur_max());
char onechar[MAXCHARLEN];
int charlen;
while (*line != '\0') {
blank_mb_len = parse_mbchar(line, blank_mb, NULL);
charlen = parse_mbchar(line, onechar, NULL);
if (!is_blank_mbchar(blank_mb))
if (!is_blank_mbchar(onechar))
break;
line += blank_mb_len;
len += blank_mb_len;
line += charlen;
len += charlen;
}
free(blank_mb);
return len;
}
#endif /* !NANO_TINY || !DISABLE_JUSTIFY */
@@ -2009,13 +2009,11 @@ void backup_lines(filestruct *first_line, size_t par_len)
for (i = par_len; i > 0 && bot != openfile->filebot; i--)
bot = bot->next;
/* Move the paragraph from the current buffer's filestruct to the
* justify buffer. */
/* Move the paragraph from the current buffer to the justify buffer. */
extract_buffer(&jusbuffer, &jusbottom, top, 0, bot,
(i == 1 && bot == openfile->filebot) ? strlen(bot->data) : 0);
/* Copy the paragraph back to the current buffer's filestruct from
* the justify buffer. */
/* Copy the paragraph back to the current buffer. */
copy_from_buffer(jusbuffer);
/* Move upward from the last line of the paragraph to the first
@@ -2441,7 +2439,7 @@ void do_justify(bool full_justify)
do {
#endif
statusbar(_("Can now UnJustify!"));
reset_cursor();
place_the_cursor();
curs_set(1);
kbinput = do_input(FALSE);
#ifndef NANO_TINY
@@ -2450,7 +2448,7 @@ void do_justify(bool full_justify)
/* If needed, unset the cursor-position suppression flag, so the cursor
* position /will/ be displayed upon a return to the main loop. */
if (ISSET(CONST_UPDATE))
if (ISSET(CONSTANT_SHOW))
do_cursorpos(FALSE);
func = func_from_key(&kbinput);
@@ -3265,30 +3263,55 @@ void do_linter(void)
SET(MULTIBUFFER);
open_buffer(curlint->filename, FALSE);
} else {
char *dontwantfile = curlint->filename;
char *dontwantfile = mallocstrcpy(NULL, curlint->filename);
lintstruct *restlint = NULL;
while (curlint != NULL && !strcmp(curlint->filename, dontwantfile))
curlint = curlint->next;
if (curlint == NULL) {
while (curlint != NULL) {
if (strcmp(curlint->filename, dontwantfile) == 0) {
if (curlint == lints)
lints = curlint->next;
else
curlint->prev->next = curlint->next;
if (curlint->next != NULL)
curlint->next->prev = curlint->prev;
tmplint = curlint;
curlint = curlint->next;
free(tmplint->msg);
free(tmplint->filename);
free(tmplint);
} else {
if (restlint == NULL)
restlint = curlint;
curlint = curlint->next;
}
}
if (restlint == NULL) {
statusbar(_("No more errors in unopened files, cancelling"));
napms(2400);
break;
} else
} else {
curlint = restlint;
goto new_lint_loop;
}
free(dontwantfile);
}
} else
openfile = tmpof;
}
}
#endif /* !NANO_TINY */
do_gotolinecolumn(curlint->lineno, curlint->colno, FALSE, FALSE);
goto_line_posx(curlint->lineno, curlint->colno - 1);
titlebar(NULL);
adjust_viewport(CENTERING);
edit_refresh();
statusbar(curlint->msg);
bottombars(MLINTER);
}
/* Place and show the cursor to indicate the affected line. */
reset_cursor();
place_the_cursor();
wnoutrefresh(edit);
curs_set(1);
@@ -3363,8 +3386,10 @@ void do_formatter(void)
return;
}
#ifndef NANO_TINY
/* We're not supporting partial formatting, oi vey. */
openfile->mark_set = FALSE;
#endif
status = write_file(temp, temp_file, TRUE, OVERWRITE, FALSE);
if (!status) {
@@ -3430,10 +3455,11 @@ void do_formatter(void)
set_modified();
#ifndef NANO_TINY
/* Flush the undo stack, to avoid a mess or crash when
* the user tries to undo things in reformatted lines. */
discard_until(NULL, openfile);
#endif
finalstatus = _("Finished formatting");
}
@@ -3471,7 +3497,7 @@ void do_wordlinechar_count(void)
filestruct *top, *bot;
size_t top_x, bot_x;
/* If the mark is on, partition the filestruct so that it
/* If the mark is on, partition the buffer so that it
* contains only the marked text, and turn the mark off. */
if (old_mark_set) {
mark_order((const filestruct **)&top, &top_x,
@@ -3501,7 +3527,7 @@ void do_wordlinechar_count(void)
nlines = openfile->filebot->lineno - openfile->fileage->lineno + 1;
chars = get_totsize(openfile->fileage, openfile->filebot);
/* Unpartition the filestruct so that it contains all the text
/* Unpartition the buffer so that it contains all the text
* again, and turn the mark back on. */
unpartition_filestruct(&filepart);
openfile->mark_set = TRUE;
@@ -3532,14 +3558,14 @@ void do_verbatim_input(void)
/* TRANSLATORS: This is displayed when the next keystroke will be
* inserted verbatim. */
statusbar(_("Verbatim Input"));
reset_cursor();
place_the_cursor();
curs_set(1);
/* Read in all the verbatim characters. */
kbinput = get_verbatim_kbinput(edit, &kbinput_len);
/* Unsuppress cursor-position display or blank the statusbar. */
if (ISSET(CONST_UPDATE))
if (ISSET(CONSTANT_SHOW))
do_cursorpos(FALSE);
else {
blank_statusbar();

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* utils.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -215,7 +214,7 @@ const char *fixbounds(const char *r)
* a separate word? That is: is it not part of a longer word?*/
bool is_separate_word(size_t position, size_t length, const char *buf)
{
char before[mb_cur_max()], after[mb_cur_max()];
char before[MAXCHARLEN], after[MAXCHARLEN];
size_t word_end = position + length;
/* Get the characters before and after the word, if any. */
@@ -238,6 +237,10 @@ bool is_separate_word(size_t position, size_t length, const char *buf)
const char *strstrwrapper(const char *haystack, const char *needle,
const char *start)
{
/* Just in case we search for an empty needle. :/ */
if (*needle == '\0')
return (char *)start;
if (ISSET(USE_REGEXP)) {
if (ISSET(BACKWARDS_SEARCH)) {
size_t last_find, ceiling, far_end;
@@ -393,10 +396,10 @@ size_t xplustabs(void)
* not overshoot the given column. */
size_t actual_x(const char *text, size_t column)
{
size_t index = 0;
/* The index in text, returned. */
const char *start = text;
/* From where we start walking through the text. */
size_t width = 0;
/* The screen display width to text[index], in columns. */
/* The current accumulated span, in columns. */
while (*text != '\0') {
int charlen = parse_mbchar(text, NULL, &width);
@@ -404,11 +407,10 @@ size_t actual_x(const char *text, size_t column)
if (width > column)
break;
index += charlen;
text += charlen;
}
return index;
return (text - start);
}
/* A strnlen() with tabs and multicolumn characters factored in:
@@ -454,7 +456,7 @@ void new_magicline(void)
openfile->totsize++;
}
#ifndef NANO_TINY
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
/* Remove the magicline from filebot, if there is one and it isn't the
* only line in the file. Assume that edittop and current are not at
* filebot. */
@@ -468,7 +470,9 @@ void remove_magicline(void)
openfile->totsize--;
}
}
#endif
#ifndef NANO_TINY
/* Set top_x and bot_x to the top and bottom x-coordinates of the mark,
* respectively, based on the locations of top and bot. If
* right_side_up isn't NULL, set it to TRUE if the mark begins with
@@ -537,7 +541,7 @@ size_t get_totsize(const filestruct *begin, const filestruct *end)
}
#ifdef DEBUG
/* Dump the filestruct inptr to stderr. */
/* Dump the given buffer to stderr. */
void dump_filestruct(const filestruct *inptr)
{
if (inptr == openfile->fileage)
@@ -553,7 +557,7 @@ void dump_filestruct(const filestruct *inptr)
}
}
/* Dump the current buffer's filestruct to stderr in reverse. */
/* Dump the current buffer to stderr in reverse. */
void dump_filestruct_reverse(void)
{
const filestruct *fileptr = openfile->filebot;

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* winio.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2014, 2015, 2016, 2017 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -505,6 +504,10 @@ int parse_kbinput(WINDOW *win)
return CONTROL_UP;
else if (retval == controldown)
return CONTROL_DOWN;
else if (retval == controlhome)
return CONTROL_HOME;
else if (retval == controlend)
return CONTROL_END;
#ifndef NANO_TINY
else if (retval == shiftcontrolleft) {
shift_held = TRUE;
@@ -518,6 +521,12 @@ int parse_kbinput(WINDOW *win)
} else if (retval == shiftcontroldown) {
shift_held = TRUE;
return CONTROL_DOWN;
} else if (retval == shiftcontrolhome) {
shift_held = TRUE;
return CONTROL_HOME;
} else if (retval == shiftcontrolend) {
shift_held = TRUE;
return CONTROL_END;
} else if (retval == shiftaltleft) {
shift_held = TRUE;
return KEY_HOME;
@@ -554,6 +563,10 @@ int parse_kbinput(WINDOW *win)
return CONTROL_LEFT;
else if (retval == KEY_RIGHT)
return CONTROL_RIGHT;
else if (retval == KEY_HOME)
return CONTROL_HOME;
else if (retval == KEY_END)
return CONTROL_END;
}
#ifndef NANO_TINY
/* Are both Shift and Alt being held? */
@@ -953,6 +966,10 @@ int convert_sequence(const int *seq, size_t seq_len)
return CONTROL_RIGHT;
case 'D': /* Esc [ 1 ; 5 D == Ctrl-Left on xterm. */
return CONTROL_LEFT;
case 'F': /* Esc [ 1 ; 5 F == Ctrl-End on xterm. */
return CONTROL_END;
case 'H': /* Esc [ 1 ; 5 H == Ctrl-Home on xterm. */
return CONTROL_HOME;
}
break;
#ifndef NANO_TINY
@@ -966,6 +983,10 @@ int convert_sequence(const int *seq, size_t seq_len)
return shiftcontrolright;
case 'D': /* Esc [ 1 ; 6 D == Shift-Ctrl-Left on xterm. */
return shiftcontrolleft;
case 'F': /* Esc [ 1 ; 6 F == Shift-Ctrl-End on xterm. */
return shiftcontrolend;
case 'H': /* Esc [ 1 ; 6 H == Shift-Ctrl-Home on xterm. */
return shiftcontrolhome;
}
break;
#endif
@@ -1030,19 +1051,35 @@ int convert_sequence(const int *seq, size_t seq_len)
if (seq_len > 2 && (seq[2] == '~' || seq[2] == '^'))
return KEY_NPAGE;
break;
case '7': /* Esc [ 7 ~ == Home on Eterm/rxvt,
* Esc [ 7 $ == Shift-Home on Eterm/rxvt. */
case '7': /* Esc [ 7 ~ == Home on Eterm/rxvt;
* Esc [ 7 $ == Shift-Home on Eterm/rxvt;
* Esc [ 7 ^ == Control-Home on Eterm/rxvt;
* Esc [ 7 @ == Shift-Control-Home on same. */
if (seq_len > 2 && seq[2] == '~')
return KEY_HOME;
else if (seq_len > 2 && seq[2] == '$')
return SHIFT_HOME;
else if (seq_len > 2 && seq[2] == '^')
return CONTROL_HOME;
#ifndef NANO_TINY
else if (seq_len > 2 && seq[2] == '@')
return shiftcontrolhome;
#endif
break;
case '8': /* Esc [ 8 ~ == End on Eterm/rxvt.
* Esc [ 8 $ == Shift-End on Eterm/rxvt. */
case '8': /* Esc [ 8 ~ == End on Eterm/rxvt;
* Esc [ 8 $ == Shift-End on Eterm/rxvt;
* Esc [ 8 ^ == Control-End on Eterm/rxvt;
* Esc [ 8 @ == Shift-Control-End on same. */
if (seq_len > 2 && seq[2] == '~')
return KEY_END;
else if (seq_len > 2 && seq[2] == '$')
return SHIFT_END;
else if (seq_len > 2 && seq[2] == '^')
return CONTROL_END;
#ifndef NANO_TINY
else if (seq_len > 2 && seq[2] == '@')
return shiftcontrolend;
#endif
break;
case '9': /* Esc [ 9 == Delete on Mach console. */
return KEY_DC;
@@ -1198,7 +1235,7 @@ int parse_escape_sequence(WINDOW *win, int kbinput)
suppress_cursorpos = FALSE;
lastmessage = HUSH;
if (currmenu == MMAIN) {
reset_cursor();
place_the_cursor();
curs_set(1);
}
}
@@ -1408,26 +1445,6 @@ int get_control_kbinput(int kbinput)
return retval;
}
/* Put the output-formatted characters in output back into the keystroke
* buffer, so that they can be parsed and displayed as output again. */
void unparse_kbinput(char *output, size_t output_len)
{
int *input;
size_t i;
if (output_len == 0)
return;
input = (int *)nmalloc(output_len * sizeof(int));
for (i = 0; i < output_len; i++)
input[i] = (int)output[i];
unget_input(input, output_len);
free(input);
}
/* Read in a stream of characters verbatim, and return the length of the
* string in kbinput_len. Assume nodelay(win) is FALSE. */
int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len)
@@ -1446,7 +1463,8 @@ int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len)
retval = parse_verbatim_kbinput(win, kbinput_len);
/* If the code is invalid in the current mode, discard it. */
if ((*retval == '\n' && as_an_at) || (*retval == '\0' && !as_an_at)) {
if (retval != NULL && ((*retval == '\n' && as_an_at) ||
(*retval == '\0' && !as_an_at))) {
*kbinput_len = 0;
beep();
}
@@ -1535,7 +1553,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
return get_input(NULL, *count);
}
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
/* Handle any mouse event that may have occurred. We currently handle
* releases/clicks of the first mouse button. If allow_shortcuts is
* TRUE, releasing/clicking on a visible shortcut will put back the
@@ -1689,7 +1707,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
/* Ignore all other mouse events. */
return 2;
}
#endif /* !DISABLE_MOUSE */
#endif /* ENABLE_MOUSE */
/* Return the shortcut that corresponds to the values of kbinput (the
* key itself) and meta_key (whether the key is a meta sequence). The
@@ -1774,14 +1792,12 @@ void check_statusblank(void)
statusblank--;
/* When editing and 'constantshow' is active, skip the blanking. */
if (currmenu == MMAIN && ISSET(CONST_UPDATE))
if (currmenu == MMAIN && ISSET(CONSTANT_SHOW))
return;
if (statusblank == 0) {
blank_statusbar();
wnoutrefresh(bottomwin);
reset_cursor();
wnoutrefresh(edit);
}
/* If the subwindows overlap, make sure to show the edit window now. */
@@ -1789,68 +1805,60 @@ void check_statusblank(void)
edit_refresh();
}
/* Convert buf into a string that can be displayed on screen. The
* caller wants to display buf starting with column start_col, and
* extending for at most span columns. start_col is zero-based. span
* is one-based, so span == 0 means you get "" returned. The returned
* string is dynamically allocated, and should be freed. If isdata is
* TRUE, the caller might put "$" at the beginning or end of the line if
* it's too long. */
char *display_string(const char *buf, size_t start_col, size_t span,
bool isdata)
/* Convert buf into a string that can be displayed on screen. The caller
* wants to display buf starting with the given column, and extending for
* at most span columns. column is zero-based, and span is one-based, so
* span == 0 means you get "" returned. The returned string is dynamically
* allocated, and should be freed. If isdata is TRUE, the caller might put
* "$" at the beginning or end of the line if it's too long. */
char *display_string(const char *buf, size_t column, size_t span, bool isdata)
{
size_t start_index;
/* Index in buf of the first character shown. */
size_t column;
/* Screen column that start_index corresponds to. */
size_t start_index = actual_x(buf, column);
/* The index of the first character that the caller wishes to show. */
size_t start_col = strnlenpt(buf, start_index);
/* The actual column where that first character starts. */
char *converted;
/* The string we return. */
size_t index;
/* The expanded string we will return. */
size_t index = 0;
/* Current position in converted. */
size_t beyond = start_col + span;
size_t beyond = column + span;
/* The column number just beyond the last shown character. */
start_index = actual_x(buf, start_col);
column = strnlenpt(buf, start_index);
assert(column <= start_col);
index = 0;
#ifdef USING_OLD_NCURSES
seen_wide = FALSE;
#endif
buf += start_index;
/* Allocate enough space for converting the relevant part of the line. */
converted = charalloc(strlen(buf) * (mb_cur_max() + tabsize) + 1);
converted = charalloc(strlen(buf) * (MAXCHARLEN + tabsize) + 1);
/* If the first character starts before the left edge, or would be
* overwritten by a "$" token, then show spaces instead. */
if (*buf != '\0' && *buf != '\t' && (column < start_col ||
(column > 0 && isdata && !ISSET(SOFTWRAP)))) {
* overwritten by a "$" token, then show placeholders instead. */
if (*buf != '\0' && *buf != '\t' && (start_col < column ||
(start_col > 0 && isdata && !ISSET(SOFTWRAP)))) {
if (is_cntrl_mbchar(buf)) {
if (column < start_col) {
if (start_col < column) {
converted[index++] = control_mbrep(buf, isdata);
start_col++;
column++;
buf += parse_mbchar(buf, NULL, NULL);
}
}
#ifdef ENABLE_UTF8
else if (using_utf8() && mbwidth(buf) == 2) {
if (column >= start_col) {
else if (mbwidth(buf) == 2) {
if (start_col == column) {
converted[index++] = ' ';
start_col++;
column++;
}
converted[index++] = ' ';
start_col++;
/* Display the right half of a two-column character as '<'. */
converted[index++] = '<';
column++;
buf += parse_mbchar(buf, NULL, NULL);
}
#endif
}
while (*buf != '\0' && start_col < beyond) {
while (*buf != '\0' && column < beyond) {
int charlength, charwidth = 1;
if (*buf == ' ') {
@@ -1864,7 +1872,7 @@ char *display_string(const char *buf, size_t start_col, size_t span,
} else
#endif
converted[index++] = ' ';
start_col++;
column++;
buf++;
continue;
} else if (*buf == '\t') {
@@ -1878,11 +1886,11 @@ char *display_string(const char *buf, size_t start_col, size_t span,
} else
#endif
converted[index++] = ' ';
start_col++;
column++;
/* Fill the tab up with the required number of spaces. */
while (start_col % tabsize != 0) {
while (column % tabsize != 0) {
converted[index++] = ' ';
start_col++;
column++;
}
buf++;
continue;
@@ -1894,7 +1902,7 @@ char *display_string(const char *buf, size_t start_col, size_t span,
if (is_cntrl_mbchar(buf)) {
converted[index++] = '^';
converted[index++] = control_mbrep(buf, isdata);
start_col += 2;
column += 2;
buf += charlength;
continue;
}
@@ -1904,7 +1912,7 @@ char *display_string(const char *buf, size_t start_col, size_t span,
for (; charlength > 0; charlength--)
converted[index++] = *(buf++);
start_col += charwidth;
column += charwidth;
#ifdef USING_OLD_NCURSES
if (charwidth > 1)
seen_wide = TRUE;
@@ -1916,8 +1924,7 @@ char *display_string(const char *buf, size_t start_col, size_t span,
converted[index++] = '\xEF';
converted[index++] = '\xBF';
converted[index++] = '\xBD';
start_col += 1;
column++;
buf++;
/* For invalid codepoints, skip extra bytes. */
@@ -1925,10 +1932,17 @@ char *display_string(const char *buf, size_t start_col, size_t span,
buf += charlength + 7;
}
/* If there is more text than can be shown, make room for the $. */
if (*buf != '\0' && isdata && !ISSET(SOFTWRAP))
/* If there is more text than can be shown, make room for the $ or >. */
if (*buf != '\0' && (column > beyond || (isdata && !ISSET(SOFTWRAP)))) {
index = move_mbleft(converted, index);
#ifdef ENABLE_UTF8
/* Display the left half of a two-column character as '>'. */
if (mbwidth(converted + index) == 2)
converted[index++] = '>';
#endif
}
/* Null-terminate the converted string. */
converted[index] = '\0';
@@ -1937,10 +1951,9 @@ char *display_string(const char *buf, size_t start_col, size_t span,
/* If path is NULL, we're in normal editing mode, so display the current
* version of nano, the current filename, and whether the current file
* has been modified on the titlebar. If path isn't NULL, we're in the
* file browser, and path contains the directory to start the file
* browser in, so display the current version of nano and the contents
* of path on the titlebar. */
* has been modified on the titlebar. If path isn't NULL, we're either
* in the file browser or the help viewer, so show either the current
* directory or the title of help text, that is: whatever is in path. */
void titlebar(const char *path)
{
size_t verlen, prefixlen, pathlen, statelen;
@@ -1949,6 +1962,8 @@ void titlebar(const char *path)
/* The width that "Modified" would take up. */
size_t offset = 0;
/* The position at which the center part of the titlebar starts. */
const char *branding = BRANDING;
/* What is shown in the top left corner. */
const char *prefix = "";
/* What is shown before the path -- "File:", "DIR:", or "". */
const char *state = "";
@@ -1972,12 +1987,13 @@ void titlebar(const char *path)
* then sacrifice the prefix, and only then start dottifying. */
/* Figure out the path, prefix and state strings. */
if (inhelp)
branding = "";
#ifndef DISABLE_BROWSER
if (path != NULL)
else if (path != NULL)
prefix = _("DIR:");
else
#endif
{
else {
if (openfile->filename[0] == '\0')
path = _("New Buffer");
else {
@@ -1994,7 +2010,7 @@ void titlebar(const char *path)
}
/* Determine the widths of the four elements, including their padding. */
verlen = strlenpt(BRANDING) + 3;
verlen = strlenpt(branding) + 3;
prefixlen = strlenpt(prefix);
if (prefixlen > 0)
prefixlen++;
@@ -2007,7 +2023,7 @@ void titlebar(const char *path)
/* Only print the version message when there is room for it. */
if (verlen + prefixlen + pathlen + pluglen + statelen <= COLS)
mvwaddstr(topwin, 0, 2, BRANDING);
mvwaddstr(topwin, 0, 2, branding);
else {
verlen = 2;
/* If things don't fit yet, give up the placeholder. */
@@ -2055,8 +2071,7 @@ void titlebar(const char *path)
wattroff(topwin, interface_color_pair[TITLE_BAR]);
wnoutrefresh(topwin);
reset_cursor();
wnoutrefresh(edit);
doupdate();
}
/* Display a normal message on the statusbar, quietly. */
@@ -2128,8 +2143,8 @@ void statusline(message_type importance, const char *msg, ...)
blank_statusbar();
/* Construct the message out of all the arguments. */
compound = charalloc(mb_cur_max() * (COLS + 1));
vsnprintf(compound, mb_cur_max() * (COLS + 1), msg, ap);
compound = charalloc(MAXCHARLEN * (COLS + 1));
vsnprintf(compound, MAXCHARLEN * (COLS + 1), msg, ap);
va_end(ap);
message = display_string(compound, 0, COLS, FALSE);
free(compound);
@@ -2156,13 +2171,13 @@ void statusline(message_type importance, const char *msg, ...)
#ifndef NANO_TINY
if (old_whitespace)
SET(WHITESPACE_DISPLAY);
#endif
/* If doing quick blanking, blank the statusbar after just one keystroke.
* Otherwise, blank it after twenty-six keystrokes, as Pico does. */
if (ISSET(QUICK_BLANK))
statusblank = 1;
else
#endif
statusblank = 26;
}
@@ -2229,9 +2244,6 @@ void bottombars(int menu)
wmove(bottomwin, 0, 0);
wnoutrefresh(bottomwin);
doupdate();
reset_cursor();
wnoutrefresh(edit);
}
/* Write a shortcut key to the help area at the bottom of the window.
@@ -2259,7 +2271,7 @@ void onekey(const char *keystroke, const char *desc, int length)
/* Redetermine current_y from the position of current relative to edittop,
* and put the cursor in the edit window at (current_y, "current_x"). */
void reset_cursor(void)
void place_the_cursor(void)
{
ssize_t row = 0;
size_t col, xpt = xplustabs();
@@ -2279,6 +2291,12 @@ void reset_cursor(void)
/* Add the number of wraps in the current line before the cursor. */
row += xpt / editwincols;
col = xpt % editwincols;
/* If the cursor ought to be in column zero, nudge it there. */
if (openfile->placewewant % editwincols == 0 && col != 0) {
row++;
col = 0;
}
} else
#endif
{
@@ -2883,9 +2901,13 @@ void edit_scroll(scroll_dir direction, int nrows)
nrows -= go_forward_chunks(nrows, &openfile->edittop, &openfile->firstcolumn);
/* Don't bother scrolling zero rows, nor more than the window can hold. */
if (nrows == 0)
if (nrows == 0) {
statusline(ALERT, "Underscrolling -- please report a bug");
return;
}
if (nrows >= editwinrows) {
if (editwinrows > 1)
statusline(ALERT, "Overscrolling -- please report a bug");
refresh_needed = TRUE;
return;
}
@@ -2912,10 +2934,12 @@ void edit_scroll(scroll_dir direction, int nrows)
go_forward_chunks(editwinrows - nrows, &line, &leftedge);
#ifndef NANO_TINY
/* Compensate for the earlier onscreen chunks of a softwrapped line
* when the first blank row happens to be in the middle of that line. */
if (ISSET(SOFTWRAP) && line != openfile->edittop)
nrows += leftedge / editwincols;
/* Compensate for the earlier chunks of a softwrapped line. */
nrows += leftedge / editwincols;
/* Don't compensate for the chunks that are offscreen. */
if (line == openfile->edittop)
nrows -= openfile->firstcolumn / editwincols;
#endif
/* Draw new content on the blank rows inside the scrolled region
@@ -3030,6 +3054,12 @@ void edit_refresh(void)
filestruct *line;
int row = 0;
#ifndef DISABLE_COLOR
/* When needed, initialize the colors for the current syntax. */
if (!have_palette)
color_init();
#endif
/* If the current line is out of view, get it back on screen. */
if (current_is_offscreen()) {
#ifdef DEBUG
@@ -3056,44 +3086,29 @@ void edit_refresh(void)
while (row < editwinrows)
blank_row(edit, row++, 0, COLS);
reset_cursor();
place_the_cursor();
wnoutrefresh(edit);
refresh_needed = FALSE;
}
/* Move edittop so that current is on the screen. manner says how it
* should be moved: CENTERING means that current should end up in the
* middle of the screen, STATIONARY means that it should stay at the
* same vertical position, and FLOWING means that it should scroll no
* more than needed to bring current into view. */
/* Move edittop so that current is on the screen. manner says how:
* STATIONARY means that the cursor should stay on the same screen row,
* CENTERING means that current should end up in the middle of the screen,
* and FLOWING means that it should scroll no more than needed to bring
* current into view. */
void adjust_viewport(update_type manner)
{
int goal = 0;
/* If manner is CENTERING, move edittop half the number of window rows
* back from current. If manner is FLOWING, move edittop back 0 rows
* or (editwinrows - 1) rows, depending on where current has moved.
* This puts the cursor on the first or the last row. If manner is
* STATIONARY, move edittop back current_y rows if current_y is in range
* of the screen, 0 rows if current_y is below zero, or (editwinrows - 1)
* rows if current_y is too big. This puts current at the same place on
* the screen as before, or... at some undefined place. */
if (manner == CENTERING)
goal = editwinrows / 2;
else if (manner == FLOWING) {
if (!current_is_above_screen())
goal = editwinrows - 1;
} else {
if (manner == STATIONARY)
goal = openfile->current_y;
/* Limit goal to (editwinrows - 1) rows maximum. */
if (goal > editwinrows - 1)
goal = editwinrows - 1;
}
else if (manner == CENTERING)
goal = editwinrows / 2;
else if (!current_is_above_screen())
goal = editwinrows - 1;
openfile->edittop = openfile->current;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP))
openfile->firstcolumn = (xplustabs() / editwincols) * editwincols;
@@ -3125,8 +3140,13 @@ void total_redraw(void)
void total_refresh(void)
{
total_redraw();
titlebar(NULL);
edit_refresh();
titlebar(title);
#ifdef ENABLE_HELP
if (inhelp)
wrap_the_help_text(TRUE);
else
#endif
edit_refresh();
bottombars(currmenu);
}
@@ -3225,7 +3245,7 @@ void spotlight(bool active, const char *word)
room--;
}
reset_cursor();
place_the_cursor();
if (active)
wattron(edit, hilite_attribute);
@@ -3304,7 +3324,7 @@ void do_credits(void)
"",
"",
"",
"(C) 1999 - 2016",
"(C) 2017",
"Free Software Foundation, Inc.",
"",
"",
@@ -3351,12 +3371,9 @@ void do_credits(void)
const char *what;
size_t start_col;
if (credits[crpos] == NULL) {
assert(0 <= xlpos && xlpos < XLCREDIT_LEN);
what = _(xlcredits[xlpos]);
xlpos++;
} else
if (credits[crpos] == NULL)
what = _(xlcredits[xlpos++]);
else
what = credits[crpos];
start_col = COLS / 2 - strlenpt(what) / 2 - 1;

View File

@@ -22,6 +22,7 @@ pkgdata_DATA = asm.nanorc \
man.nanorc \
mgp.nanorc \
mutt.nanorc \
nanohelp.nanorc \
nanorc.nanorc \
nftables.nanorc \
objc.nanorc \

12
syntax/nanohelp.nanorc Normal file
View File

@@ -0,0 +1,12 @@
## This is meant for highlighting key combos in a nano help text.
# It should not apply to any normal file, so no fileregex.
syntax "nanohelp"
# Key combos:
color cyan "\^([]A-Z^\_←→↑↓]|Home|End)" "[←→↑↓]"
color cyan "\<(Tab|Enter|Home|End|Ins|Del|Bsp|PgUp|PgDn)\>"
color cyan "\<M-." "\<F1?[0-9]" "(\^|M-)Space"
# Quoted indicators:
color brightred "'(\^|M-)'"