Compare commits

...

238 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
Benno Schulenberg
be62368d54 po: update translations and regenerate POT file and PO files 2017-03-31 11:07:01 +02:00
Benno Schulenberg
032030566c bump version numbers and add a news item for the 2.8.0 release 2017-03-31 10:54:55 +02:00
Benno Schulenberg
bc9862fbff tweaks: condense some declarations by reshuffling 2017-03-29 21:35:56 +02:00
Benno Schulenberg
582a624998 tweaks: frob some parentheses and other things, to be more consistent 2017-03-29 19:30:37 +02:00
Benno Schulenberg
c7282e8821 tweaks: reshuffle two declarations for a more consistent order 2017-03-29 10:35:11 +02:00
Benno Schulenberg
1f9a6ab336 tweaks: factor out a bit of common code 2017-03-29 10:30:41 +02:00
Benno Schulenberg
33cefa9208 tweaks: elide an intermediate variable 2017-03-29 10:20:41 +02:00
Benno Schulenberg
873e3d6fa6 tweaks: don't loop over an initializer 2017-03-29 10:13:08 +02:00
Benno Schulenberg
54e4505b2f tweaks: frob a couple of comments 2017-03-28 19:44:41 +02:00
Benno Schulenberg
8091d0a574 tweaks: simplify and correct a computation
The leftedge variable is a column number, not an x position.
2017-03-28 19:24:37 +02:00
David Lawrence Ramsey
93c6248956 display: don't compensate for chunks before firstcolumn
The number of rows to draw shouldn't be compensated for the chunks
of edittop that are before firstcolumn, because they are offscreen.

This completes the fix for https://savannah.gnu.org/bugs/?50621.
2017-03-28 19:10:45 +02:00
David Lawrence Ramsey
66ef8f45a3 display: don't draw more chunks than the screen can hold
There is no need to always increase nrows by 1 or 2 -- an increase
of 1 is only needed when the line that borders on the scrolled region
needs to redrawn too: when this line was horizontally scrolled or when
the mark is on.

This fixes https://savannah.gnu.org/bugs/?50621.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-03-28 12:32:51 +02:00
David Lawrence Ramsey
d01756bb69 moving: determine the correct leftedge when paging up/down too
The change in commit 244a503d for the <Up> and <Down> keys
needs to be done for <PageUp> and <PageDown> too.
2017-03-28 12:32:47 +02:00
Benno Schulenberg
644fedcb61 tweaks: reshuffle some more lines and improve four comments 2017-03-28 11:24:32 +02:00
Benno Schulenberg
da3a015f7d tweaks: reshuffle some lines and adjust some comments 2017-03-28 10:38:08 +02:00
Benno Schulenberg
bc876ca729 moving: /do/ redraw the prior line when the viewport hasn't changed
The complementary test on current_y should only be done when doing
a scroll-only, because only then the prior line can be offscreen.

This fixes https://savannah.gnu.org/bugs/?50658.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-03-28 10:31:45 +02:00
Benno Schulenberg
9cf980700c moving: don't try to redraw lines that have gone outside the viewport
When scrolling backward, it is not just the bottom line of the screen
that doesn't need to be redrawn: also the line /before/ the top line
doesn't need a redraw.  Mutatis mutandis for scrolling forward.

This fixes https://savannah.gnu.org/bugs/?50657.
2017-03-27 19:44:21 +02:00
Benno Schulenberg
244a503ddc moving: the current chunk cannot be beyond the last chunk of a line
When determining the leftedge of the current chunk, it is not simply
the leftedge that corresponds to the placewewant, but the leftedge that
corresponds to the minimum of the placewewant and the full line span.

This fixes https://savannah.gnu.org/bugs/?50653.
2017-03-27 17:45:39 +02:00
Benno Schulenberg
c277cd6e5b tweaks: reshuffle some statements, to avoid double assignments 2017-03-27 11:38:52 +02:00
David Lawrence Ramsey
384332d08c display: make PageUp/PageDown use the correct beginning of the viewport
When typing PageUp or PageDOwn in non-smooth-scrolling mode, the cursor
should be placed at the start of the top line of the edit window.  This
means that, when the line at edittop is partially scrolled offscreen,
the cursor should be placed at openfile->firstcolumn, not at zero.

This fixes https://savannah.gnu.org/bugs/?50645.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-03-27 11:19:44 +02:00
David Lawrence Ramsey
6b1ad96f34 docs: update README.GIT for gnulib-related changes 2017-03-26 12:54:57 +02:00
David Lawrence Ramsey
0276e45465 configure: don't check for the existence of iswspace() anymore
The iswspace() was only used when iswblank() was missing.  The latter
is now provided by gnulib, so it is always available, so iswspace()
is not used at all anymore.
2017-03-26 12:50:33 +02:00
Benno Schulenberg
42ae3e377f docs: mention some more differences with Pico in the Info document
Mention the ability to use <Tab> in the search history, the ability
to restore the cursor position when reopening a file, the ability to
read output of a command, and the lack of file-managing commands in
the file browser.
2017-03-26 12:41:44 +02:00
Benno Schulenberg
58faff50ae tweaks: shorten a bit of logic 2017-03-24 21:37:06 +01:00
David Lawrence Ramsey
87a7c2e42d tweaks: fix a comment typo 2017-03-24 21:21:51 +01:00
David Lawrence Ramsey
f4ee83a76d syntax: nanorc: color also the option "linenumbers" as being valid 2017-03-24 21:18:17 +01:00
Benno Schulenberg
59412b572f files: on second thought... keep the "[from ./]"
The "./" is a shorthand for "current working directory".
It is better to specify it, because it differs from what
Pico does: reading always from the user's home directory
no matter where the editor was started.
2017-03-24 12:19:30 +01:00
Benno Schulenberg
261b5b28c4 tweaks: gettextize a forgotten error message 2017-03-23 22:12:27 +01:00
Benno Schulenberg
f987508891 files: drop the pointless "[from ./]" from the insert-file prompt
Only use the "from" thing when an operating directory is in effect,
because /only/ then the indicated directory can be something other
than "./".

Also, make it so that there is no space before the colon.
2017-03-23 22:10:47 +01:00
Benno Schulenberg
19b7021076 tweaks: suggest a separate color scheme for root
And slightly change the existing one for normal users.
2017-03-23 19:28:33 +01:00
Benno Schulenberg
9e7e88e157 bindings: accept "q" and "x" to exit from help viewer and file browser
"Q" is a pretty standard key to exit from something, and "X" is fairly
mnemonic -- better than "E" at least.
2017-03-23 12:42:53 +01:00
Benno Schulenberg
c01d6a8f74 tweaks: reshuffle the bindings to group things more logically
Put all the movement keys together, in order of ascending stride.

Also, move the Undo/Redo keystrokes further up, so that, when the
user has a somewhat wider terminal than the usual 80 characters,
these keystrokes will be shown -- they are far more interesting
than the ^Y and ^V ones, for which PgUp and PgDn can be used.
2017-03-23 11:37:36 +01:00
Benno Schulenberg
e46c6c9607 tweaks: ehm... the warning is more important for the softwrap case
But apparently none of these cases occur, because I can't trigger them.
2017-03-22 11:05:22 +01:00
Benno Schulenberg
8b7bbebeeb tweaks: add a warning for a condition that should never occur 2017-03-22 10:50:59 +01:00
Benno Schulenberg
55159b7b39 painting: don't try to start highlighting before column zero
This could happen when a tab or a double-width character straddles
the boundary between two softwrapped chunks.
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey
0389a1d939 softwrap: adjust firstcolumn when the window width changes
If the number of columns in the edit window changes (which currently
only happens in two places: in regenerate_screen(), called when the
window is resized; and in main(), when line numbering mode is toggled),
the display will break if we're in softwrap mode and firstcolumn is
nonzero.  This is because the column width of softwrapped chunks has
changed, and firstcolumn is no longer the starting column of a chunk,
an assumption that all code using firstcolumn relies on.

To fix this problem, add a new function, ensure_firstcolumn_is_aligned(),
to adjust firstcolumn to the starting column of the chunk it's on, and
use it when the number of columns in the edit window changes.

(Note that this function uses the simplest possible fix, and could
probably be made more sophisticated.)
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey
c1f70185ba softwrap: save and restore firstcolumn when replacing text
In do_replace(), replacing text may change firstcolumn if the next match
is offscreen, and replacing text after that will not change it back.  In
order to keep the viewport unchanged, we have to save and restore not
just edittop, but firstcolumn as well.
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey
c888edf409 softwrap: save and restore firstcolumn when internally spell-fixing text
In do_int_spell_fix(), spell-checking text may change firstcolumn if
the next match is offscreen, and spell-checking text after that will
not change it back.  In order to keep the viewport unchanged, we have
to save and restore not just edittop, but firstcolumn as well.
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey
7cd50b8c02 softwrap: save firstcolumn when justifying, restore it when unjustifying
In do_justify(), justifying text may change firstcolumn if the paragraph
ends offscreen, and unjustifying the text again will not change it back.
In order to keep the viewport unchanged, we have to save and restore not
just edittop, but firstcolumn as well.
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey
6f0ed2075c softwrap: save and restore firstcolumn when copying text
Copying text involves first cutting it and then quickly pasting it back.
However, cutting the text may change firstcolumn if the mark is offscreen.
To keep the viewport unchanged, copy_text() has to save and restore not
just edittop, but firstcolumn as well.
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey
dd08b638c1 softwrap: account for softwrapped chunks when adding text
Now that we can add text to the bottom right corner of the screen
without scrolling the full line onscreen, do_output() needs to refresh
the screen in that case, since it would put the cursor offscreen
otherwise.  Accomplish this by borrowing logic from do_right().
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey
93152d3258 softwrap: account for firstcolumn when scrolling up a line
In do_up() when scroll_only is TRUE, if we're at the top of the screen
in softwrap mode, it's not enough to check that edittop is on fileage.
We also need to check that firstcolumn is zero.

In do_up() when scroll_only is FALSE, if we're at the top of the screen
in softwrap mode, current_y should be zero.  This is equivalent to how,
in do_down() when scroll_only is FALSE, current_y is (editwinrows - 1)
at the bottom of the screen in softwrap mode.  Since edittop can now
be partially scrolled off the screen even when it takes up the entire
screen, checking for edittop's being equal to openfile->current->next
there no longer applies.
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey
2f6c8987ea softwrap: move the updating of a softwrapped line to a new function
The new function, update_softwrapped_line(), is called from inside
update_line() when softwrap mode is on, so that existing calls remain
unchanged.  It takes no index, instead displaying edittop from column
firstcolumn, and all other lines from column zero.

If current is on edittop, it's displayed using the edittop rules, but
this is not a problem: if current[current_x] is above edittop at column
firstcolumn, it's offscreen, and that should be handled before calling
update_line() anyway.

Together with the preceding bunch of changes,
this fixes https://savannah.gnu.org/bugs/?47667.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
98b029cf3e softwrap: account for firstcolumn in reset_cursor()
When counting rows in softwrap mode, reset_cursor() should compensate for
the number of softwrapped chunks that edittop takes up before firstcolumn.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
c0fa3f04b1 softwrap: account for firstcolumn when checking for offscreen current
Make current_is_above_screen() check for current[current_x] being above
edittop at column firstcolumn, and make current_is_below_screen() start
counting down from edittop at column firstcolumn instead of edittop at
column zero.  This means that both functions now account for softwrapped
chunks properly.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
e52d5b0672 softwrap: remove and replace workarounds for firstcolumn
Actually enable scrolling edittop partially off the screen by making
edit_scroll() and adjust_viewport() use firstcolumn properly when
iterating through softwrapped chunks in softwrap mode, or lines in
non-softwrap mode.

In non-softwrap mode, firstcolumn should still always be zero, because
it's initially set to that, and because passing it through the iterators
will maintain it at that.

This fixes https://savannah.gnu.org/bugs/?49100.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
4144f76e19 softwrap: prepare for a more flexible viewport
We want to be able to scroll the line at edittop partially off the
screen.  For this to be possible, the new variable firstcolumn stores
the starting column of the viewport -- the starting column in the line
that edittop points to.

Since firstcolumn is used by go_back_chunks() and go_forward_chunks(),
it can't be completely #ifdefed out when NANO_TINY is set, but outside
of softwrap mode it should always be zero.

Currently firstcolumn is initialized to zero, reset to zero when
toggling softwrap mode off, and reset to zero when switching buffers
while softwrap mode is off.  It's otherwise unused, but its uses are
forthcoming.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
80b3a3011b weeding: remove ensure_line_is_visible()
Since all lines can be partially scrolled off the screen now
(except for the top line of the edit window, which is forthcoming),
ensure_line_is_visible() is no longer needed.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
812ecaeb0c weeding: remove maxlines and related code
Since all lines can be partially scrolled off the screen now
(except for edittop, which is forthcoming), the maxlines global
variable and its computation mechanism are no longer needed.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
d0c3084eb5 softwrap: improve PageUp and PageDown's behavior with softwrapped chunks
Use go_back_chunks() and go_forward_chunks() to move a screenful of
lines or chunks up or down, instead of using special computations in
the softwrap case.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
eb647dfb44 softwrap: improve Up and Down's behavior with softwrapped chunks
Use go_back_chunks() and go_forward_chunks() in do_up() and do_down()
(instead of using a special and complicated computation in do_down())
so that they now properly move vertically to the previous/next chunk
in softwrap mode.  This also means that do_left() and do_right() will
now properly move vertically at actual line boundaries.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
56402e7589 softwrap: improve Left and Right's behavior with softwrapped chunks
Use the new "unclever" functionality of Home and End to make do_left()
and do_right() move properly to the end of the previous chunk or to the
start of the next chunk in softwrap mode when crossing a line boundary.
(Furthermore, doing Up plus End, or Down plus Home, does all needed
screen updates, which simplifies the code.)

The do_left() and do_right() functions don't yet properly move vertically
at line boundaries, but that will be fixed once do_up() and do_down() are
updated for softwrap mode, which is forthcoming.

This fixes https://savannah.gnu.org/bugs/?49384.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
a5e106d764 tweaks: add a parameter to do_home() and do_end()
Add the parameter be_clever to both functions.  When be_clever is FALSE,
smart home and dynamic home are disabled in do_home(), and dynamic end is
disabled in do_end(), so that these functions only move to the beginning
or end of the current line or chunk.

This simple home and end functionality is needed to improve do_left()
and do_right()'s horizontal behavior with softwrapped chunks, which is
forthcoming.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
e478682c55 softwrap: improve End's behavior with softwrapped chunks
Make do_end() more useful in softwrap mode: let it move to the end of the
current chunk instead of the end of the line; only when already at the end
of a chunk, let it move to the end of the line.  This is "dynamic end".
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
bd2d0863d6 softwrap: improve Home's behavior with softwrapped lines
Make do_home() more useful in softwrap mode: let it move to the beginning
of the current chunk instead of to the beginning of the whole line; only
when already at the beginning of a chunk, let it move to the beginning of
the line.  This is called "dynamic home'.

The above rules are ignored when --smarthome is in effect and the cursor
is somewhere in the leading whitespace of a line -- then the cursor is
moved to the first non-whitespace character of the line.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey
d8189703b1 tweaks: prepare for improvements to do_home() and do_end()
These improvements will eventually make do_home() and do_end() take
parameters.  Since the global function lists can hold only functions
without parameters, preemptively add do_home_void() and do_end_void(),
and make the global function lists use them.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
52087408ef softwrap: iterate through softwrapped chunks better in do_mouse()
Use go_back_chunks() and go_forward_chunks() to move from the row
current_y is on to the row mouse_row is on.  Now softwrap mode and
non-softwrap mode will behave the same way when we can scroll edittop
partially off the screen, which is forthcoming.  Accordingly, remove
the call to ensure_line_is_visible(), as it no longer applies.

The old code did work, but it behaved differently between softwrap mode
(which counted down from edittop) and non-softwrap mode (which counted
up or down from current_y to take less time, and used a double loop to
keep current from going to NULL).

The new code counts up or down from current_y in both softwrap mode and
non-softwrap mode.  In non-softwrap mode, it also avoids the double loop,
since go_back_chunks() and go_forward_chunks() keep the filestructs they
operate on from going to NULL.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
2abf7b755b softwrap: iterate through softwrapped chunks in adjust_viewport()
Use go_back_chunks() to adjust edittop, instead of special casing
the computation of goal when softwrapping.  Now softwrap mode and
non-softwrap mode will behave the same way when edittop can be
partially scrolled off the screen, which is forthcoming.

(Note that the top line of the screen can't be partially scrolled
yet, so we have to work around that for now.)
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
ba4858de83 softwrap: iterate through softwrapped chunks in edit_scroll()
Use go_back_chunks() and go_forward_chunks() to adjust edittop and to
move up or down to the scrolled region before updating the rows there.
Now softwrap mode and non-softwrap mode will behave the same way when
we can scroll the top line of the screen partially off the screen,
which is forthcoming.

(Note that the top line of the screen can't be partially scrolled yet,
so we have to work around that for now.)
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
fa025f0ca3 display: limit an optimization to non-softwrap mode
Not drawing a line on a row if we're on the top row and scrolled down,
or if we're on the bottom row and scrolled up, will only work properly
if the line on that row takes up only that row.  The latter might not
be the case in softwrap mode: if the line occupies multiple chunks and
begins on that row -- in that case none of the chunks would be drawn.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
eb369c0e00 tweaks: rename need_horizontal_scroll() to line_needs_update()
The old name made it sound as if it didn't apply in softwrap mode.  But
it does: in softwrap mode a line needs updating  when the mark is on.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
df2a4679d5 softwrap: account for softwrap in get_page_start()
In softwrap mode, nano doesn't horizontally scroll lines at all, so in
this case get_page_start() should always return zero.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
380ad30a53 softwrap: account for softwrap when checking whether current is offscreen
Add the new functions current_is_above_screen() (which doesn't account
for softwrapped chunks yet, but will when we can scroll edittop partially
off the screen, which is forthcoming), current_is_below_screen() (which
determines whether current[current_x] is past the softwrapped chunk at
the bottom of the screen), and current_is_offscreen() (the union of the
previous two functions).

edit_redraw() and edit_refresh() now use current_is_offscreen() to check
whether they should adjust the viewport, and adjust_viewport() now uses
current_is_above_screen() to determine whether current is on or below
the screen in FLOWING mode.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
fd82989e29 softwrap: count softwrapped chunks properly in read_file()
Use less_than_a_screenful() again, just as in do_uncut_text().
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
4f9c563e6b softwrap: count softwrapped chunks properly in do_uncut_text()
Add the new function less_than_a_screenful() to accomplish this.
It uses go_back_chunks() to count the number of softwrapped chunks
between the end point and the starting point of the paste.

Now softwrap mode and non-softwrap mode behave the same way when
uncutting fewer than editwinrows rows of text.  Accordingly, remove
the call to ensure_line_is_visible(), as it no longer applies.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
1570651e30 softwrap: count softwrapped chunks properly in do_gotolinecolumn()
Use go_forward_chunks() to count softwrapped chunks between the current
cursor position and the bottom of the file.  Now softwrap mode and
non-softwrap mode behave the same way when moving to a line and column
non-interactively, instead of the former's always centering the screen.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey
456d66b904 softwrap: add two chunk-iterator functions
These functions, go_back_chunks() and go_forward_chunks(), take a number
of softwrapped chunks (screen rows) to move, a pointer to a buffer, and
a location (specifically, a starting column of a softwrapped chunk).  If
they move successfully, they will update the buffer pointer and location
to point to the beginning of the softwrapped chunk they moved to.

Since non-softwrap mode is effectively just a subset of softwrap mode
in which every line takes up one chunk, these functions also work in
non-softwrap mode.  In this case, their starting column will always be
zero, as it would be in softwrap mode on a line that takes up one chunk.

Nothing uses these functions yet, but that is forthcoming.
2017-03-22 10:44:04 +01:00
Benno Schulenberg
da62ef8a43 tweaks: correct some formatting irregularities in the FAQ
And modify a few wordings too.
2017-03-20 20:33:47 +01:00
Benno Schulenberg
9b336a9d66 bindings: group the three search-again shortcuts together 2017-03-20 15:59:41 +01:00
Benno Schulenberg
d42f71a2ef tweaks: avoid a few needless reallocations
Most of these variables are freed moments later -- reallocating
them is thus a waste of time.
2017-03-20 13:07:57 +01:00
Benno Schulenberg
f48e15f2a3 tweaks: rename and shorten a small helper function 2017-03-20 12:24:42 +01:00
Benno Schulenberg
6d873d3760 startup: add option 'nopauses' to disable pausing after a warning
This addresses a followup of https://savannah.gnu.org/bugs/?50362.
Reported-by: Mike Frysinger <vapier@gentoo.org>
2017-03-16 19:26:39 +01:00
Mike Frysinger
85a8e5cfd2 tweaks: disable gnulib's workaround for the globbing of broken symlinks
Our use of globbing (for syntax files) doesn't care about such symlinks.

This avoids an unnecessary increase in size of eight kilobytes -- see
https://lists.gnu.org/archive/html/nano-devel/2017-03/msg00036.html.
2017-03-14 21:28:21 +01:00
Benno Schulenberg
5283acdcf3 tweaks: trim a displayable string in a more efficient manner
Instead of redetermining the entire span of the converted string,
simply move one character left, and then bite it off to make place
for the trailing $.
2017-03-14 21:20:50 +01:00
Mike Frysinger
0d9a734724 pull in the nl_langinfo & wcwidth modules from gnulib
These functions aren't available on mingw toolchains, so include the
gnulib modules so we can fall back on them.
2017-03-09 14:37:57 +01:00
Benno Schulenberg
69784d51db screen: don't push the longer-line indicator ($) to the next row
If the last two columns of a row would be taken up by a double-width
character (and the line is longer than that), don't print it, because
it wouldn't leave any room for the $ character.

This fixes https://savannah.gnu.org/bugs/?50491.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-03-08 21:24:13 +01:00
David Lawrence Ramsey
3c3eb4909d usage: mention the -g/--showcursor option
It's already in the external documentation; it should be here as well.
2017-03-06 21:09:59 +01:00
Hans-Bernhard Broeker
636b7348a6 tweaks: make sure calls to <ctype.h> functions/macros use "unsigned char"
The platform's default char type might be signed, which could cause
problems in 8-bit locales.

This addresses https://savannah.gnu.org/bugs/?50289.
Reported-by: Hans-Bernhard Broeker <HBBroeker@T-Online.de>
2017-03-06 20:58:25 +01:00
Mike Frysinger
0176cb5b30 pull in the sys_wait module from gnulib
This is used by systems that lack sys/wait.h, like Windows.
2017-03-06 12:02:32 +01:00
Mike Frysinger
ca86045918 handle builds on systems without termios.h
Windows doesn't have this, so add some build time checks.
2017-03-06 12:02:28 +01:00
Mike Frysinger
cab33779ae handle deficient signal systems
Pull in the sigaction module from gnulib, and add ifdef checks
for a bunch of signals that don't exist on Windows.
2017-03-06 12:02:25 +01:00
Mike Frysinger
7c2cfd6e0c pull in the lstat module from gnulib
This is used by systems that lack lstat(), like Windows.
2017-03-06 12:02:20 +01:00
Mike Frysinger
a8deac5845 add an explicit test for set_escdelay()
Not all curses implementations provide this function, so drop it
from depending on slang (and assuming ncurses) to a general build
time test.
2017-03-06 12:02:16 +01:00
Mike Frysinger
a9a45f2b55 fix build on systems without pwd.h
Windows doesn't have *nix style account databases.
2017-03-06 12:02:09 +01:00
Mike Frysinger
a0fb55235a pull in the glob module from gnulib
This is used by systems that lack glob.h, like Windows.
2017-03-06 12:02:06 +01:00
Mike Frysinger
e7c43521fc drop the wchar.h/wctype.h/stdarg.h checks
Since gnulib provides these now, we can assume them.
2017-03-06 12:01:21 +01:00
Mike Frysinger
9a2deb4182 drop the glib fallback for snprintf/vsnprintf
The gnulib imports handle this for us now.
2017-03-06 12:01:17 +01:00
Mike Frysinger
272345ccf9 assume getopt_long support is always available
Now that we pull in the gnulib getopt-gnu module, we can assume it exists.
2017-03-06 12:01:12 +01:00
Mike Frysinger
3deec4352b assume regex.h support is always available
Now that we pull in the gnulib regex module, we can assume it exists.
2017-03-06 12:01:08 +01:00
Mike Frysinger
63cae0c199 drop the isblank/iswblank fallback functions
Switch over to gnulib for these.
2017-03-06 12:01:05 +01:00
Mike Frysinger
e9a3f858bc drop the getdelim/getline fallback functions
Switch over to gnulib for these.
2017-03-06 12:01:02 +01:00
Mike Frysinger
28133e934d drop various str fallback functions
These are provided by gnulib now.
2017-03-06 12:00:57 +01:00
Mike Frysinger
ba8d71f447 add support for gnulib
On a system with up-to-date GNU tools, this does not change
the size of nano's binary.

We start off with importing only a few modules, although we
don't yet delete the fallback logic for them.
2017-03-06 11:56:02 +01:00
Mike Frysinger
9d0331dea2 configure: require gettext-0.18.3, and drop our bundled m4 files
The gettext-0.18.3 release was made in Jul 2013, while the 0.11.5
release was made in Aug 2002.  Time to update :).

Also drop all the bundled gettext m4 files.  When you run autogen.sh,
these will get copied in automatically for you.
2017-03-06 11:52:16 +01:00
Mike Frysinger
c04a8ce654 configure: require autoconf-2.69/automake-1.14
The autoconf-2.69 release was made in Apr 2012.
The automake-1.14 release was made in Jun 2013.

Update the requirements so we know we can rely on macros/features
available in those versions.
2017-03-06 11:52:04 +01:00
Benno Schulenberg
83a841cd06 tweaks: chuck some debugging stuff and some useless asserts 2017-03-01 13:56:08 +01:00
Benno Schulenberg
0af5788a94 tweaks: reduce the scope of five variables, and frob some comments 2017-03-01 09:56:38 +01:00
Benno Schulenberg
d5b950cc29 tweaks: don't turn the mark off before it's needed
The mark only needs to be off when calling replace_marked_buffer(),
because this indirectly calls ingraft_buffer(), which fiddles with
the end points if the mark is on.
2017-03-01 09:35:45 +01:00
Benno Schulenberg
adf69a05f1 spelling: keep the cursor at end-of-line if it was there
This fixes https://savannah.gnu.org/bugs/?50415.
2017-02-28 20:45:49 +01:00
Benno Schulenberg
355a07bbce tweaks: don't optimize for the wrong case
Running strlenpt() on a string that takes up more than 80 columns
(the width of an average terminal) takes /more/ time than simply
converting an extra character (the one that will be overwritten
by the "$" at the edge of the terminal).  So... just convert one
more character than necessary when the line is overlong.  In the
most common case, however, the line will fit fully onscreen, and
we save a whole call of strlenpt().
2017-02-28 17:07:38 +01:00
David Lawrence Ramsey
0404474ec2 tweaks: stop converting text once we overshoot span columns
Since we only need span columns of the string, stop scanning the string
as soon as we have that many columns, instead of scanning the string all
the way to the end.  This speeds up the conversion of very long lines.
2017-02-28 16:50:22 +01:00
Benno Schulenberg
a80ade38d7 tweaks: rename two variables, to be more distinctive 2017-02-28 15:17:03 +01:00
Benno Schulenberg
48643cbdf3 tweaks: elide a small intermediate buffer 2017-02-28 15:05:02 +01:00
Benno Schulenberg
aa013aa007 tweaks: elide a variable 2017-02-28 14:53:10 +01:00
Benno Schulenberg
91910b2364 input: count a manually entered unicode as one character
This fixes https://savannah.gnu.org/bugs/?50403.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-02-28 14:47:45 +01:00
David Lawrence Ramsey
29681e0e9f weeding: remove partitioning and related stuff from do_justify()
Replace partitioning with calls to extract_buffer() and ingraft_buffer().

In addition to pasting the unjustified text back into the buffer at
current[current_x], ingraft_buffer() also deals with renumbering and
updating totsize, so do_justify() doesn't need to do those anymore
when unjustifying.
2017-02-28 14:35:44 +01:00
David Lawrence Ramsey
234bd9c9be speller: fix replacing marked text in the alternate spell checker
With read_file() revamped, it now uses partition_filestruct() indirectly
via ingraft_buffer(), so we can't use partition_filestruct() to replace
marked text in the alternate spell checker anymore without segfaulting.

Add the new function replace_marked_buffer() to accomplish this instead.
Based on replace_buffer(), it uses extract_buffer() to throw away the
marked un-spell-checked text, and then uses read_file() to insert the
spell-checked text at the position where the mark was.

Accordingly, remove unneeded partitioning and related stuff from
do_alt_speller().  Besides pasting the file into the buffer at
current[current_x], ingraft_buffer() also deals with renumbering,
updating totsize, and handling a magicline, so do_alt_speller()
doesn't need to do those anymore.
2017-02-28 14:35:44 +01:00
David Lawrence Ramsey
0d9313763d undo: fix undoing/redoing insertions, since they no longer do partitioning 2017-02-28 14:35:44 +01:00
David Lawrence Ramsey
ef43ebfef4 weeding: remove partitioning and related stuff from do_insertfile()
With read_file() revamped to handle inserting a file at the current
position, partitioning the buffer is no longer needed.
2017-02-28 14:35:44 +01:00
David Lawrence Ramsey
86f7bc1868 files: revamp the insertion of a file, to be more like pasting text
Move buffer handling and '\r' stripping from read_line() to read_file(),
so that the file gets its format determined and gets stored in its own
buffer entirely in one function.  Then use ingraft_buffer() to insert
this new buffer into the current one.

In addition to pasting the file at current[current_x], ingraft_buffer()
also deals with renumbering, the updating of totsize, and the handling
of a magicline, so read_file() doesn't need to do those anymore.

Note that all this makes read_file() depend on the position of
current[current_x] to know where to insert the file.  Accordingly,
set current_x to zero in initialize_buffer_text() instead of in
make_new_buffer(), so that replace_buffer() keeps working properly.
2017-02-28 14:35:44 +01:00
Benno Schulenberg
3d9a4d6257 tweaks: make WhereIsNext available in browser in tiny version
Also, avoid a warning with with --enable-tiny --enable-browser.
2017-02-27 19:22:50 +01:00
Benno Schulenberg
eb67af9347 tweaks: fix compilation with --enable-tiny --enable-help 2017-02-27 19:10:39 +01:00
Benno Schulenberg
efdd73922e oops -- that's what you get when you don't test things before pushing
Of course 'row' needs to be initialized to zero for the softwrap case.
2017-02-26 18:29:18 +01:00
Benno Schulenberg
2e53ed2928 tweaks: use two extra variables to make it clearer what is being done
This addresses https://savannah.gnu.org/patch/?9215.
Inspired-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-02-26 17:33:10 +01:00
Benno Schulenberg
59e10bdef2 usage: don't mention +LINE,COLUMN as an option, because it isn't
Add its explanation as a separate paragraph.

Also: improve the argument of the --syntax option, as this is a <name>
and not merely a bundle of characters like the other <str> arguments.
2017-02-25 14:05:07 +01:00
David Lawrence Ramsey
6eefad4fff tweaks: mention nano's ability to read from standard input in usage() 2017-02-25 14:00:27 +01:00
Benno Schulenberg
e5731fe198 tweaks: reshuffle three statements, and shorten a comment 2017-02-25 12:33:01 +01:00
Benno Schulenberg
2bbb6cfeb5 wrapping: add the correct char length when skipping consecutive blanks
In this last loop of break_line(), the pointer 'line' is one step ahead
of the index 'lastblank'.  So the loop should first add the length of
the preceding character to 'lastblank' before determining the length
of the current character (and using this to advance 'line').
2017-02-25 11:18:24 +01:00
Benno Schulenberg
1623bc7779 tweaks: rename three variables, to better distinguish bytes from columns
(There is something wrong in the last loop: line is one character ahead
of lastblank, but the current character length is added to both of them.
It thus assumes that all blank characters are the same number of bytes.
For spaces and tabs this works fine.  But for more exotic blanks...)
2017-02-24 22:08:55 +01:00
Benno Schulenberg
99ecd33c18 tweaks: elide two variables, and condense some statements
Also, remove an assert and adjust some comments.
2017-02-24 21:11:37 +01:00
David Lawrence Ramsey
6500f769aa tweaks: move comments outside of if blocks in break_line() 2017-02-24 21:04:31 +01:00
David Lawrence Ramsey
f95836a951 tweaks: remove cluttering #ifdefs from break_line()
Also, rename a parameter to be less cryptic, and remove an entire
condition because the relevant block will never be reached when
getting called from the help routines: if blank_loc is negative,
the function will have bailed out in the preceding if.
2017-02-24 17:33:39 +01:00
Benno Schulenberg
0378146add tweaks: rename a variable, drop a false assert, and reshuffle a bit 2017-02-24 15:07:04 +01:00
David Lawrence Ramsey
6e9d6a08b9 replacing: fix spotlight() to highlight words properly in softwrap mode
In softwrap mode, the entire line is onscreen, so the word is never
partially offscreen, so we always have enough columns to show it.

This fixes https://savannah.gnu.org/bugs/?50389.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-02-24 15:06:44 +01:00
Benno Schulenberg
07ebba5e99 tweaks: rename a variable and invert its logic 2017-02-24 12:21:59 +01:00
Benno Schulenberg
9e6e1ebe58 tweaks: remove a disabled warning, and adjust a translator hint 2017-02-24 12:06:15 +01:00
Benno Schulenberg
d365ca80bf tweaks: optimize determining the number of columns that a text spans
Give the strlenpt() routine its own implementation, so that it avoids
a needless comparison plus subtraction in the inner loop.
2017-02-24 11:01:24 +01:00
David Lawrence Ramsey
f1d214c0ef tweaks: slightly optimize an allocation in display_string()
Instead of allocating enough space to convert the entire passed string,
just allocate space for converting the part that will be converted --
that is: starting from start_index.  This still allocates far too much
(if the passed string is very long and its tail part won't fit on the
screen), but it's better than before.
2017-02-24 10:52:04 +01:00
Benno Schulenberg
1d3f3a6e25 tweaks: mark a message for translation 2017-02-23 15:22:07 +01:00
93 changed files with 26739 additions and 27491 deletions

42
.gitignore vendored
View File

@@ -16,6 +16,7 @@ core
/ABOUT-NLS
/INSTALL
/aclocal.m4
/ar-lib
/autom4te.cache
/compile
/config.cache
@@ -34,6 +35,47 @@ core
/mkinstalldirs
/stamp-h1
# gettext m4 files.
/m4/codeset.m4
/m4/extern-inline.m4
/m4/fcntl-o.m4
/m4/gettext.m4
/m4/glibc2.m4
/m4/glibc21.m4
/m4/iconv.m4
/m4/intdiv0.m4
/m4/intl.m4
/m4/intldir.m4
/m4/intlmacosx.m4
/m4/intmax.m4
/m4/inttypes-pri.m4
/m4/inttypes_h.m4
/m4/lcmessage.m4
/m4/lib-ld.m4
/m4/lib-link.m4
/m4/lib-prefix.m4
/m4/lock.m4
/m4/longlong.m4
/m4/nls.m4
/m4/po.m4
/m4/printf-posix.m4
/m4/progtest.m4
/m4/size_max.m4
/m4/stdint_h.m4
/m4/threadlib.m4
/m4/uintmax_t.m4
/m4/visibility.m4
/m4/wchar_t.m4
/m4/wint_t.m4
/m4/xsize.m4
# gnulib entries
/gnulib/
/lib/
/m4/.gitignore
/m4/gnulib-cache.m4
/snippet/
/nano.spec
/src/nano
/src/revision.h

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

269
ChangeLog
View File

@@ -1,3 +1,272 @@
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:
----------------------------------
Benno Schulenberg (56):
bindings: accept "q" and "x" to exit from help viewer and file browser
bindings: group the three search-again shortcuts together
bump version numbers and add a news item for the 2.8.0 release
docs: mention some more differences with Pico in the Info document
files: drop the pointless "[from ./]" from the insert-file prompt
files: on second thought... keep the "[from ./]"
input: count a manually entered unicode as one character
moving: don't try to redraw lines that have gone outside the viewport
moving: /do/ redraw the prior line when the viewport hasn't changed
moving: the current chunk cannot be beyond the last chunk of a line
oops -- that's what you get when you don't test things before pushing
painting: don't try to start highlighting before column zero
screen: don't push the longer-line indicator ($) to the next row
spelling: keep the cursor at end-of-line if it was there
startup: add option 'nopauses' to disable pausing after a warning
tweaks: add a warning for a condition that should never occur
tweaks: avoid a few needless reallocations
tweaks: chuck some debugging stuff and some useless asserts
tweaks: condense some declarations by reshuffling
tweaks: correct some formatting irregularities in the FAQ
tweaks: don't loop over an initializer
tweaks: don't optimize for the wrong case
tweaks: don't turn the mark off before it's needed
tweaks: ehm... the warning is more important for the softwrap case
tweaks: elide an intermediate variable
tweaks: elide a small intermediate buffer
tweaks: elide a variable
tweaks: elide two variables, and condense some statements
tweaks: factor out a bit of common code
tweaks: fix compilation with --enable-tiny --enable-help
tweaks: frob a couple of comments
tweaks: frob some parentheses and other things, to be more consistent
tweaks: gettextize a forgotten error message
tweaks: make WhereIsNext available in browser in tiny version
tweaks: mark a message for translation
tweaks: optimize determining the number of columns that a text spans
tweaks: reduce the scope of five variables, and frob some comments
tweaks: remove a disabled warning, and adjust a translator hint
tweaks: rename and shorten a small helper function
tweaks: rename a variable and invert its logic
tweaks: rename a variable, drop a false assert, and reshuffle a bit
tweaks: rename three variables, to better distinguish bytes from columns
tweaks: rename two variables, to be more distinctive
tweaks: reshuffle some lines and adjust some comments
tweaks: reshuffle some more lines and improve four comments
tweaks: reshuffle some statements, to avoid double assignments
tweaks: reshuffle the bindings to group things more logically
tweaks: reshuffle three statements, and shorten a comment
tweaks: reshuffle two declarations for a more consistent order
tweaks: shorten a bit of logic
tweaks: simplify and correct a computation
tweaks: suggest a separate color scheme for root
tweaks: trim a displayable string in a more efficient manner
tweaks: use two extra variables to make it clearer what is being done
usage: don't mention +LINE,COLUMN as an option, because it isn't
wrapping: add the correct char length when skipping consecutive blanks
David Lawrence Ramsey (52):
configure: don't check for the existence of iswspace() anymore
display: don't compensate for chunks before firstcolumn
display: don't draw more chunks than the screen can hold
display: limit an optimization to non-softwrap mode
display: make PageUp/PageDown use the correct beginning of the viewport
docs: update README.GIT for gnulib-related changes
files: revamp the insertion of a file, to be more like pasting text
moving: determine the correct leftedge when paging up/down too
replacing: fix spotlight() to highlight words properly in softwrap mode
softwrap: account for firstcolumn in reset_cursor()
softwrap: account for firstcolumn when checking for offscreen current
softwrap: account for firstcolumn when scrolling up a line
softwrap: account for softwrap in get_page_start()
softwrap: account for softwrapped chunks when adding text
softwrap: account for softwrap when checking whether current is offscreen
softwrap: add two chunk-iterator functions
softwrap: adjust firstcolumn when the window width changes
softwrap: count softwrapped chunks properly in do_gotolinecolumn()
softwrap: count softwrapped chunks properly in do_uncut_text()
softwrap: count softwrapped chunks properly in read_file()
softwrap: improve End's behavior with softwrapped chunks
softwrap: improve Home's behavior with softwrapped lines
softwrap: improve Left and Right's behavior with softwrapped chunks
softwrap: improve PageUp and PageDown's behavior with softwrapped chunks
softwrap: improve Up and Down's behavior with softwrapped chunks
softwrap: iterate through softwrapped chunks better in do_mouse()
softwrap: iterate through softwrapped chunks in adjust_viewport()
softwrap: iterate through softwrapped chunks in edit_scroll()
softwrap: move the updating of a softwrapped line to a new function
softwrap: prepare for a more flexible viewport
softwrap: remove and replace workarounds for firstcolumn
softwrap: save and restore firstcolumn when copying text
softwrap: save and restore firstcolumn when internally spell-fixing text
softwrap: save and restore firstcolumn when replacing text
softwrap: save firstcolumn when justifying, restore it when unjustifying
speller: fix replacing marked text in the alternate spell checker
syntax: nanorc: color also the option "linenumbers" as being valid
tweaks: add a parameter to do_home() and do_end()
tweaks: fix a comment typo
tweaks: mention nano's ability to read from standard input in usage()
tweaks: move comments outside of if blocks in break_line()
tweaks: prepare for improvements to do_home() and do_end()
tweaks: remove cluttering #ifdefs from break_line()
tweaks: rename need_horizontal_scroll() to line_needs_update()
tweaks: slightly optimize an allocation in display_string()
tweaks: stop converting text once we overshoot span columns
undo: fix undoing/redoing insertions, since they no longer do partitioning
usage: mention the -g/--showcursor option
weeding: remove ensure_line_is_visible()
weeding: remove maxlines and related code
weeding: remove partitioning and related stuff from do_insertfile()
weeding: remove partitioning and related stuff from do_justify()
Hans-Bernhard Broeker (1):
tweaks: make sure calls to <ctype.h> functions/macros use "unsigned char"
Mike Frysinger (19):
add an explicit test for set_escdelay()
add support for gnulib
assume getopt_long support is always available
assume regex.h support is always available
configure: require autoconf-2.69/automake-1.14
configure: require gettext-0.18.3, and drop our bundled m4 files
drop the getdelim/getline fallback functions
drop the glib fallback for snprintf/vsnprintf
drop the isblank/iswblank fallback functions
drop the wchar.h/wctype.h/stdarg.h checks
drop various str fallback functions
fix build on systems without pwd.h
handle builds on systems without termios.h
handle deficient signal systems
pull in the glob module from gnulib
pull in the lstat module from gnulib
pull in the nl_langinfo & wcwidth modules from gnulib
pull in the sys_wait module from gnulib
tweaks: disable gnulib's workaround for the globbing of broken symlinks
Changes between v2.7.4 and v2.7.5:
----------------------------------

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-#).

View File

@@ -1,6 +1,6 @@
AUTOMAKE_OPTIONS = gnu no-dependencies
SUBDIRS = doc m4 po src
SUBDIRS = doc lib m4 po src
if USE_COLOR
SUBDIRS += syntax

54
NEWS
View File

@@ -1,3 +1,43 @@
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
logical lines, and the Home and End keys now move to
the start and end of a row, and only when already
there, then to the start and end of the logical line.
Furthermore, the screen can now scroll per row instead
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 from the
new softwrap navigation). The conversion to gnulib
was done by Mike Frysinger, the softwrap overhaul by
David Ramsey.
2017.02.23 - GNU nano 2.7.5 "Nijntje" can properly search and replace
the \B and \b regex anchors, correctly repaints things
when multiline regexes with identical start and end are
@@ -35,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.
@@ -277,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.
@@ -301,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.
@@ -1221,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
@@ -1237,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.

View File

@@ -11,10 +11,10 @@ Prerequisites
To successfully compile GNU nano from git, you'll need the following
packages:
- autoconf (version >= 2.61)
- automake (version >= 1.7)
- autopoint (version >= 0.11.5)
- gettext (version >= 0.11.5)
- autoconf (version >= 2.69)
- automake (version >= 1.14)
- autopoint (version >= 0.18.3)
- gettext (version >= 0.18.3)
- git (version >= 2.7.4)
- groff (version >= 1.12)
- pkg-config (version >= 0.22)
@@ -24,8 +24,6 @@ packages:
If you want UTF-8 support, you will also need libncursesw5-dev installed
(version >= 5.7), or libslang2-dev (version >= 2.0) if you use --with-slang.
If your system doesn't have 'snprintf' or 'vsnprintf' (which the configure
script will check for), you will also need glib-2.x installed.
These should all be available in your distro's package manager or software
center, or otherwise on any GNU mirror.

47
TODO
View File

@@ -1,31 +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. Maybe use glib's
iconv() if the system's iconv() is inadequate, since we already use
glib's vsnprintf() if the system lacks vsnprintf()?
- 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.
@@ -33,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]
@@ -65,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]
@@ -83,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

@@ -1,4 +1,48 @@
#!/bin/sh
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="3eee3a1e3c5b8883e0d4934bfc1326ee605cb7c1"
modules="
futimens
getdelim
getline
getopt-gnu
glob
isblank
iswblank
lstat
nl_langinfo
regex
sigaction
snprintf-posix
stdarg
strcase
strcasestr-simple
strnlen
sys_wait
vsnprintf-posix
wchar
wctype-h
wcwidth
"
# Make sure the local gnulib git repo is up-to-date.
if [ ! -d "gnulib" ]; then
git clone --depth=123 ${gnulib_url}
fi
cd gnulib >/dev/null || exit 1
curr_hash=$(git log -1 --format=%H)
if [ "${gnulib_hash}" != "${curr_hash}" ]; then
git pull
git checkout -f ${gnulib_hash}
fi
cd .. >/dev/null || exit 1
rm -rf lib
./gnulib/gnulib-tool \
--import \
${modules}
autoreconf -f -i -s

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,20 +16,30 @@
# 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.7.5], [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
AM_INIT_AUTOMAKE([1.14])
AC_CONFIG_HEADERS([config.h])
dnl Make sure the ONCE macros are available.
AC_PREREQ(2.61)
AC_PREREQ([2.69])
dnl Lie about gnulib features we don't use to speed up & shrink down.
gl_cv_func_printf_directive_n=yes
gl_cv_func_printf_infinite_long_double=yes
gl_cv_func_printf_long_double=yes
gl_cv_func_snprintf_directive_n=yes
gl_cv_glob_lists_symlinks=yes
dnl Checks for programs.
AC_GNU_SOURCE
AC_PROG_CC
gl_EARLY
gl_INIT
AC_PROG_LN_S
AC_ISC_POSIX
AC_SYS_LARGEFILE
@@ -37,7 +47,7 @@ PKG_PROG_PKG_CONFIG
dnl Internationalization macros.
AM_GNU_GETTEXT_VERSION(0.11.5)
AM_GNU_GETTEXT_VERSION([0.18.3])
AM_GNU_GETTEXT([external], [need-ngettext])
AM_CONDITIONAL(USE_NLS, test x$USE_NLS = xyes)
@@ -48,12 +58,12 @@ AC_DEFINE_DIR([PKGDATADIR], [pkgdatadir], [Where data are placed to.])
dnl Checks for header files.
AC_CHECK_HEADERS(getopt.h libintl.h limits.h regex.h sys/param.h wchar.h wctype.h stdarg.h)
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
@@ -71,19 +81,11 @@ fi
if test "x$enable_color" = xno; then
AC_DEFINE(DISABLE_COLOR, 1, [Define this to disable syntax highlighting.])
else
if test x$ac_cv_header_regex_h != xyes; then
AC_MSG_ERROR([
*** The header file regex.h was not found. If you wish to have
*** color support, this header file is required. Please either
*** install C libraries that include the regex.h file, or call
*** the configure script with --disable-color.])
else
color_support=yes
fi
color_support=yes
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])
@@ -98,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,
@@ -116,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
@@ -138,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
@@ -158,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])
@@ -186,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,
@@ -205,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
@@ -228,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
@@ -240,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.])
@@ -467,30 +493,9 @@ int main(void)
dnl Checks for functions.
AC_CHECK_FUNCS(getdelim getline isblank strcasecmp strcasestr strncasecmp strnlen snprintf vsnprintf)
if test "x$enable_utf8" != xno; then
AC_CHECK_FUNCS(iswalnum iswblank iswpunct iswspace nl_langinfo mblen mbstowcs mbtowc wctomb wcwidth)
AC_CHECK_FUNCS(iswalnum iswpunct mblen mbstowcs mbtowc wctomb)
fi
if test x$ac_cv_func_snprintf = xno; then
AM_PATH_GLIB_2_0(2.0.0,,
AC_MSG_ERROR([
*** snprintf() not found. GLIB 2.x not found either.
*** You should install the GLIB 2.x library which can
*** be found at http://ftp.gtk.org/.]),
glib)
fi
if test x$ac_cv_func_vsnprintf = xno; then
AM_PATH_GLIB_2_0(2.0.0,,
AC_MSG_ERROR([
*** vsnprintf() not found. GLIB 2.x not found either.
*** You should install the GLIB 2.x library which can
*** be found at http://ftp.gtk.org/.]),
glib)
fi
dnl Checks for typedefs, structures, and compiler characteristics.
dnl Checks for available flags.
@@ -500,8 +505,6 @@ AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"], [], [])
dnl Checks for library functions.
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(getopt_long)
dnl Checks for libraries.
@@ -566,10 +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.
@@ -578,25 +584,15 @@ LIBS="$LIBS $CURSES_LIB"
AC_SUBST(CURSES_LIB)
if test "x$GLIB_CFLAGS" != "x"; then
CFLAGS="$CFLAGS $GLIB_CFLAGS"
fi
if test "x$GLIB_LIBS" != "x"; then
LDFLAGS="$LDFLAGS $GLIB_LIBS"
fi
if test "x$enable_utf8" != xno && \
test x$CURSES_LIB_WIDE = xyes && \
test x$ac_cv_func_iswalnum = xyes && \
test x$ac_cv_func_iswpunct = xyes && \
(test x$ac_cv_func_iswblank = xyes || test x$ac_cv_func_iswspace = xyes) && \
test x$ac_cv_func_nl_langinfo = xyes && \
test x$ac_cv_func_mblen = xyes && \
test x$ac_cv_func_mbstowcs = xyes && \
test x$ac_cv_func_mbtowc = xyes && \
test x$ac_cv_func_wctomb = xyes && \
test x$ac_cv_func_wcwidth = xyes; then
AC_DEFINE(ENABLE_UTF8, 1, [Define this if your system has sufficient UTF-8 support (a wide curses library, iswalnum(), iswpunct(), iswblank() or iswspace(), nl_langinfo, mblen(), mbstowcs(), mbtowc(), wctomb(), and wcwidth()).])
test x$ac_cv_func_wctomb = xyes; then
AC_DEFINE(ENABLE_UTF8, 1, [Define this if your system has sufficient UTF-8 support.])
else
if test "x$enable_utf8" = xyes; then
AC_MSG_ERROR([
@@ -615,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
@@ -655,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
@@ -688,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])
@@ -706,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]))
@@ -747,6 +761,7 @@ AC_CONFIG_FILES([
Makefile
doc/Makefile
doc/sample.nanorc
lib/Makefile
m4/Makefile
po/Makefile.in
src/Makefile

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.7.5</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>
@@ -230,102 +235,32 @@
<h2><a name="6.1"></a>6.1. Why should I use nano instead of Pico?</h2>
<blockquote><p>There are many reasons to use nano instead of Pico. A more complete list can be found at the <a href="https://nano-editor.org/">nano homepage</a>.</p></blockquote>
<h2><a name="6.2"></a>6.2. Why should I use Pico instead of nano?</h2>
<blockquote><p>Again, check out the <a href="https://nano-editor.org/">nano homepage</a> for a good summary of reasons. It really is a matter of personal preference as to which editor you should use. If you're the type of person who likes using the original version of a program, then Pico is the editor for you. If you don't mind sacrificing mailer integration with Pine, and are looking for a few more features, as well as a 'better' license in terms of adding your own changes, nano is the way to go.</p><p>Note that the last of these no longer applies to the new version of Pine, <a href="http://www.washington.edu/alpine/">Alpine</a>, which is under the Apache License, version 2.0.</p></blockquote>
<blockquote><p>Again, check out the <a href="https://nano-editor.org/">nano homepage</a> for a good summary of reasons. It really is a matter of personal preference as to which editor you should use. If you're the type of person who likes using the original version of a program, then Pico is the editor for you. If you don't mind sacrificing mailer integration with Pine, and are looking for a few more features, as well as a 'better' license in terms of adding your own changes, nano is the way to go.</p>
<p>Note that the last of these no longer applies to the new version of Pine, <a href="http://www.washington.edu/alpine/">Alpine</a>, which is under the Apache License, version 2.0.</p></blockquote>
<h2><a name="6.3"></a>6.3. What is so bad about the older Pine license?</h2>
<blockquote><p>The U of W license for older versions of Pine and Pico is not considered truly Free Software according to both the Free Software Foundation and the <a href="http://www.debian.org/social_contract#guidelines">Debian Free Software Guidelines</a>. The main problem regards the limitations on distributing derived works: according to UW, you can distribute their software, and you can modify it, but you can not do both, i.e. distribute modified binaries.</p></blockquote>
<h2><a name="6.4"></a>6.4. Okay, well, what mail program should I use then?</h2>
<blockquote><p>If you are looking to use a Free Software program similar to Pine, and Emacs is not your thing, you should definitely take a look at <a href="http://www.mutt.org/">mutt</a>. It is a full-screen, console based mail program that actually has a lot more flexibility than Pine, but has a keymap included in the distribution that allows you to use the same keystrokes as Pine would to send and receive mail. It's also under the GNU General Public License, version 2.0.<P>
Of course, due to the license change you can now use the <A HREF="http://www.washington.edu/alpine/">Alpine distribution</A> of PINE as it is now considered Free Software, but you would be sacrificing many of nano's features to do so.</p></blockquote>
<blockquote><p>If you are looking to use a Free Software program similar to Pine, and Emacs is not your thing, you should definitely take a look at <a href="http://www.mutt.org/">mutt</a>. It is a full-screen, console based mail program that actually has a lot more flexibility than Pine, but has a keymap included in the distribution that allows you to use the same keystrokes as Pine would to send and receive mail. It's also under the GNU General Public License, version 2.0.</p>
<p>Of course, due to the license change you can now use the <a href="http://www.washington.edu/alpine/">Alpine distribution</a> of PINE as it is now considered Free Software, but you would be sacrificing many of nano's features to do so.</p></blockquote>
<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 place to submit bugs is to the <a href="https://savannah.gnu.org/bugs/?group=nano">Savannah bug tracker</a> as you can check whether the bug you are submitting has already been submitted.
<p>Please submit patches for nano via the <a href="https://savannah.gnu.org/patch/?group=nano">Savannah project's patch manager</a> for the nano project.</p></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.7.5" "February 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.7.5
@set UPDATED February 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.7.5
@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
@@ -743,6 +743,10 @@ Don't convert files from DOS/Mac format.
@item set nohelp
Don't display the help lists at the bottom of the screen.
@item set nopauses
Don't pause between warnings at startup. This means that only
the last one will be visible (when there are multiple ones).
@item set nonewlines
Don't add newlines to the ends of files.
@@ -889,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
@@ -943,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
@@ -1391,7 +1395,7 @@ browser exits.
@chapter Pico Compatibility
@code{nano} attempts to emulate Pico as closely as possible, but there
are certain differences between the editors:
are some differences between the editors:
@table @code
@@ -1405,12 +1409,36 @@ ask any more), or Cancel (stop with replacing).
@item Search and Replace History
When the option @code{-H} or @code{--historylog} is given (or set in
the .nanorc file), text entered as search or replace strings is stored.
These strings can be accessed with the up/down arrow keys. A retrieved
string can subsequently be edited.
These strings can be accessed with the up/down arrow keys, or you can
type the first few characters and then use Tab to cycle through the
matching strings. A retrieved string can subsequently be edited.
@item Writing, Appending, or Prepending Selected Text to Files
Text selected using the marking key (^^) can be written out, appended,
or prepended to a new or existing file using the WriteOut key (^O).
@item Position History
When the option @code{-P} or @code{--positionlog} is given (or set in
the .nanorc file), @code{nano} will store the position of the cursor
when you close a file, and will place the cursor in that position
again when you later reopen the file.
@item Writing Selected Text to Files
When using the Write-Out key (^O), text that has been selected using the
marking key (^^) can not just be written out to a new (or existing) file,
it can also be appended or prepended to an existing file.
@item Reading Text from a Command
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
browser is just a file browser, not a file manager.
@item Toggles
Many options which alter the functionality of the program can be
@@ -1452,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,
@@ -1482,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.
@@ -1512,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.7.5" "February 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
@@ -151,6 +151,10 @@ Don't display the two help lines at the bottom of the screen.
.B set nonewlines
Don't automatically add a newline to the ends of files.
.TP
.B set nopauses
Don't pause between warnings at startup. This means that only
the last one will be visible (when there are multiple ones).
.TP
.B set nowrap
Don't hard-wrap text at all.
.TP
@@ -285,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
@@ -342,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.7.5" "February 2017"
.TH RNANO 1 "version 2.8.2" "May 2017"
.\" Please adjust this date whenever revising the manpage.
.SH NAME

View File

@@ -95,6 +95,10 @@
## Don't display the helpful shortcut lists at the bottom of the screen.
# set nohelp
## Don't pause between warnings at startup. Which means that only the
## last one will be readable (when there are multiple ones).
# set nopauses
## Don't add newlines to the ends of files.
# set nonewlines
@@ -198,10 +202,16 @@
## Paint the interface elements of nano.
## These are examples; by default there are no colors.
# set titlecolor brightwhite,blue
# set numbercolor cyan
# set statuscolor brightwhite,green
# set keycolor green
# set functioncolor yellow
# set numbercolor cyan
# set keycolor cyan
# set functioncolor green
## In root's .nanorc you might want to use:
# set titlecolor brightwhite,red
# set statuscolor brightwhite,red
# set numbercolor magenta
# set keycolor brightmagenta
# set functioncolor magenta
## Setup of syntax coloring.

View File

@@ -1,5 +1,36 @@
EXTRA_DIST = ac_define_dir.m4 codeset.m4 gettext.m4 glib-2.0.m4 \
glibc21.m4 iconv.m4 intdiv0.m4 inttypes_h.m4 \
inttypes.m4 inttypes-pri.m4 isc-posix.m4 lcmessage.m4 \
lib-ld.m4 lib-link.m4 lib-prefix.m4 progtest.m4 \
stdint_h.m4 uintmax_t.m4 ulonglong.m4
EXTRA_DIST = \
ac_define_dir.m4 \
ax_check_compile_flag.m4 \
codeset.m4 \
extern-inline.m4 \
fcntl-o.m4 \
gettext.m4 \
glibc21.m4 \
glibc2.m4 \
gnulib-cache.m4 \
iconv.m4 \
intdiv0.m4 \
intldir.m4 \
intl.m4 \
intlmacosx.m4 \
intmax.m4 \
inttypes_h.m4 \
inttypes-pri.m4 \
lcmessage.m4 \
lib-ld.m4 \
lib-link.m4 \
lib-prefix.m4 \
lock.m4 \
longlong.m4 \
nls.m4 \
po.m4 \
printf-posix.m4 \
progtest.m4 \
size_max.m4 \
stdint_h.m4 \
threadlib.m4 \
uintmax_t.m4 \
visibility.m4 \
wchar_t.m4 \
wint_t.m4 \
xsize.m4

View File

@@ -1,23 +0,0 @@
# codeset.m4 serial AM1 (gettext-0.10.40)
dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Bruno Haible.
AC_DEFUN([AM_LANGINFO_CODESET],
[
AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
[AC_TRY_LINK([#include <langinfo.h>],
[char* cs = nl_langinfo(CODESET);],
am_cv_langinfo_codeset=yes,
am_cv_langinfo_codeset=no)
])
if test $am_cv_langinfo_codeset = yes; then
AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
[Define if you have <langinfo.h> and nl_langinfo(CODESET).])
fi
])

View File

@@ -1,587 +0,0 @@
# gettext.m4 serial 17 (gettext-0.11.5)
dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl
dnl This file can can be used in projects which are not available under
dnl the GNU General Public License or the GNU Library General Public
dnl License but which still want to provide support for the GNU gettext
dnl functionality.
dnl Please note that the actual code of the GNU gettext library is covered
dnl by the GNU Library General Public License, and the rest of the GNU
dnl gettext package package is covered by the GNU General Public License.
dnl They are *not* in the public domain.
dnl Authors:
dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
dnl Bruno Haible <haible@clisp.cons.org>, 2000-2002.
dnl Macro to add for using GNU gettext.
dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The
dnl default (if it is not specified or empty) is 'no-libtool'.
dnl INTLSYMBOL should be 'external' for packages with no intl directory,
dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory.
dnl If INTLSYMBOL is 'use-libtool', then a libtool library
dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static,
dnl depending on --{enable,disable}-{shared,static} and on the presence of
dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library
dnl $(top_builddir)/intl/libintl.a will be created.
dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
dnl implementations (in libc or libintl) without the ngettext() function
dnl will be ignored. If NEEDSYMBOL is specified and is
dnl 'need-formatstring-macros', then GNU gettext implementations that don't
dnl support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
dnl INTLDIR is used to find the intl libraries. If empty,
dnl the value `$(top_builddir)/intl/' is used.
dnl
dnl The result of the configuration is one of three cases:
dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
dnl and used.
dnl Catalog format: GNU --> install in $(datadir)
dnl Catalog extension: .mo after installation, .gmo in source tree
dnl 2) GNU gettext has been found in the system's C library.
dnl Catalog format: GNU --> install in $(datadir)
dnl Catalog extension: .mo after installation, .gmo in source tree
dnl 3) No internationalization, always use English msgid.
dnl Catalog format: none
dnl Catalog extension: none
dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur.
dnl The use of .gmo is historical (it was needed to avoid overwriting the
dnl GNU format catalogs when building on a platform with an X/Open gettext),
dnl but we keep it in order not to force irrelevant filename changes on the
dnl maintainers.
dnl
AC_DEFUN([AM_GNU_GETTEXT],
[
dnl Argument checking.
ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
[errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
])])])])])
ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
[errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
])])])])
define(gt_included_intl, ifelse([$1], [external], [no], [yes]))
define(gt_libtool_suffix_prefix, ifelse([$1], [use-libtool], [l], []))
AC_REQUIRE([AM_PO_SUBDIRS])dnl
ifelse(gt_included_intl, yes, [
AC_REQUIRE([AM_INTL_SUBDIR])dnl
])
dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
dnl Sometimes libintl requires libiconv, so first search for libiconv.
dnl Ideally we would do this search only after the
dnl if test "$USE_NLS" = "yes"; then
dnl if test "$gt_cv_func_gnugettext_libc" != "yes"; then
dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT
dnl the configure script would need to contain the same shell code
dnl again, outside any 'if'. There are two solutions:
dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not
dnl documented, we avoid it.
ifelse(gt_included_intl, yes, , [
AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
])
AC_MSG_CHECKING([whether NLS is requested])
dnl Default is enabled NLS
AC_ARG_ENABLE(nls,
[ --disable-nls do not use Native Language Support],
USE_NLS=$enableval, USE_NLS=yes)
AC_MSG_RESULT($USE_NLS)
AC_SUBST(USE_NLS)
ifelse(gt_included_intl, yes, [
BUILD_INCLUDED_LIBINTL=no
USE_INCLUDED_LIBINTL=no
])
LIBINTL=
LTLIBINTL=
POSUB=
dnl If we use NLS figure out what method
if test "$USE_NLS" = "yes"; then
gt_use_preinstalled_gnugettext=no
ifelse(gt_included_intl, yes, [
AC_MSG_CHECKING([whether included gettext is requested])
AC_ARG_WITH(included-gettext,
[ --with-included-gettext use the GNU gettext library included here],
nls_cv_force_use_gnu_gettext=$withval,
nls_cv_force_use_gnu_gettext=no)
AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
])
dnl User does not insist on using GNU NLS library. Figure out what
dnl to use. If GNU gettext is available we use this. Else we have
dnl to fall back to GNU NLS library.
dnl Add a version number to the cache macros.
define([gt_api_version], ifelse([$2], [need-formatstring-macros], 3, ifelse([$2], [need-ngettext], 2, 1)))
define([gt_cv_func_gnugettext_libc], [gt_cv_func_gnugettext]gt_api_version[_libc])
define([gt_cv_func_gnugettext_libintl], [gt_cv_func_gnugettext]gt_api_version[_libintl])
AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
[AC_TRY_LINK([#include <libintl.h>
]ifelse([$2], [need-formatstring-macros],
[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
#endif
changequote(,)dnl
typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
changequote([,])dnl
], [])[extern int _nl_msg_cat_cntr;
extern int *_nl_domain_bindings;],
[bindtextdomain ("", "");
return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_domain_bindings],
gt_cv_func_gnugettext_libc=yes,
gt_cv_func_gnugettext_libc=no)])
if test "$gt_cv_func_gnugettext_libc" != "yes"; then
dnl Sometimes libintl requires libiconv, so first search for libiconv.
ifelse(gt_included_intl, yes, , [
AM_ICONV_LINK
])
dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv])
dnl because that would add "-liconv" to LIBINTL and LTLIBINTL
dnl even if libiconv doesn't exist.
AC_LIB_LINKFLAGS_BODY([intl])
AC_CACHE_CHECK([for GNU gettext in libintl],
gt_cv_func_gnugettext_libintl,
[gt_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $INCINTL"
gt_save_LIBS="$LIBS"
LIBS="$LIBS $LIBINTL"
dnl Now see whether libintl exists and does not depend on libiconv.
AC_TRY_LINK([#include <libintl.h>
]ifelse([$2], [need-formatstring-macros],
[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
#endif
changequote(,)dnl
typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
changequote([,])dnl
], [])[extern int _nl_msg_cat_cntr;
extern
#ifdef __cplusplus
"C"
#endif
const char *_nl_expand_alias ();],
[bindtextdomain ("", "");
return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)],
gt_cv_func_gnugettext_libintl=yes,
gt_cv_func_gnugettext_libintl=no)
dnl Now see whether libintl exists and depends on libiconv.
if test "$gt_cv_func_gnugettext_libintl" != yes && test -n "$LIBICONV"; then
LIBS="$LIBS $LIBICONV"
AC_TRY_LINK([#include <libintl.h>
]ifelse([$2], [need-formatstring-macros],
[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
#endif
changequote(,)dnl
typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
changequote([,])dnl
], [])[extern int _nl_msg_cat_cntr;
extern
#ifdef __cplusplus
"C"
#endif
const char *_nl_expand_alias ();],
[bindtextdomain ("", "");
return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)],
[LIBINTL="$LIBINTL $LIBICONV"
LTLIBINTL="$LTLIBINTL $LTLIBICONV"
gt_cv_func_gnugettext_libintl=yes
])
fi
CPPFLAGS="$gt_save_CPPFLAGS"
LIBS="$gt_save_LIBS"])
fi
dnl If an already present or preinstalled GNU gettext() is found,
dnl use it. But if this macro is used in GNU gettext, and GNU
dnl gettext is already preinstalled in libintl, we update this
dnl libintl. (Cf. the install rule in intl/Makefile.in.)
if test "$gt_cv_func_gnugettext_libc" = "yes" \
|| { test "$gt_cv_func_gnugettext_libintl" = "yes" \
&& test "$PACKAGE" != gettext; }; then
gt_use_preinstalled_gnugettext=yes
else
dnl Reset the values set by searching for libintl.
LIBINTL=
LTLIBINTL=
INCINTL=
fi
ifelse(gt_included_intl, yes, [
if test "$gt_use_preinstalled_gnugettext" != "yes"; then
dnl GNU gettext is not found in the C library.
dnl Fall back on included GNU gettext library.
nls_cv_use_gnu_gettext=yes
fi
fi
if test "$nls_cv_use_gnu_gettext" = "yes"; then
dnl Mark actions used to generate GNU NLS library.
INTLOBJS="\$(GETTOBJS)"
BUILD_INCLUDED_LIBINTL=yes
USE_INCLUDED_LIBINTL=yes
LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV"
LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV"
LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
fi
if test "$gt_use_preinstalled_gnugettext" = "yes" \
|| test "$nls_cv_use_gnu_gettext" = "yes"; then
dnl Mark actions to use GNU gettext tools.
CATOBJEXT=.gmo
fi
])
if test "$gt_use_preinstalled_gnugettext" = "yes" \
|| test "$nls_cv_use_gnu_gettext" = "yes"; then
AC_DEFINE(ENABLE_NLS, 1,
[Define to 1 if translation of program messages to the user's native language
is requested.])
else
USE_NLS=no
fi
fi
if test "$USE_NLS" = "yes"; then
if test "$gt_use_preinstalled_gnugettext" = "yes"; then
if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
AC_MSG_CHECKING([how to link with libintl])
AC_MSG_RESULT([$LIBINTL])
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
fi
dnl For backward compatibility. Some packages may be using this.
AC_DEFINE(HAVE_GETTEXT, 1,
[Define if the GNU gettext() function is already present or preinstalled.])
AC_DEFINE(HAVE_DCGETTEXT, 1,
[Define if the GNU dcgettext() function is already present or preinstalled.])
fi
dnl We need to process the po/ directory.
POSUB=po
fi
ifelse(gt_included_intl, yes, [
dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
dnl to 'yes' because some of the testsuite requires it.
if test "$PACKAGE" = gettext; then
BUILD_INCLUDED_LIBINTL=yes
fi
dnl Make all variables we use known to autoconf.
AC_SUBST(BUILD_INCLUDED_LIBINTL)
AC_SUBST(USE_INCLUDED_LIBINTL)
AC_SUBST(CATOBJEXT)
AC_SUBST(INTLOBJS)
dnl For backward compatibility. Some configure.ins may be using this.
nls_cv_header_intl=
nls_cv_header_libgt=
dnl For backward compatibility. Some Makefiles may be using this.
DATADIRNAME=share
AC_SUBST(DATADIRNAME)
dnl For backward compatibility. Some Makefiles may be using this.
INSTOBJEXT=.mo
AC_SUBST(INSTOBJEXT)
dnl For backward compatibility. Some Makefiles may be using this.
GENCAT=gencat
AC_SUBST(GENCAT)
dnl Enable libtool support if the surrounding package wishes it.
INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
])
dnl For backward compatibility. Some Makefiles may be using this.
INTLLIBS="$LIBINTL"
AC_SUBST(INTLLIBS)
dnl Make all documented variables known to autoconf.
AC_SUBST(LIBINTL)
AC_SUBST(LTLIBINTL)
AC_SUBST(POSUB)
])
dnl Checks for all prerequisites of the po subdirectory,
dnl except for USE_NLS.
AC_DEFUN([AM_PO_SUBDIRS],
[
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AC_PROG_INSTALL])dnl
AC_REQUIRE([AM_MKINSTALLDIRS])dnl
dnl Perform the following tests also if --disable-nls has been given,
dnl because they are needed for "make dist" to work.
dnl Search for GNU msgfmt in the PATH.
dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions.
dnl The second test excludes FreeBSD msgfmt.
AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
[$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 &&
(if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
:)
AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
dnl Search for GNU xgettext 0.11 or newer in the PATH.
dnl The first test excludes Solaris xgettext and early GNU xgettext versions.
dnl The second test excludes FreeBSD xgettext.
AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
[$ac_dir/$ac_word --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 &&
(if $ac_dir/$ac_word --omit-header --copyright-holder= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
:)
dnl Remove leftover from FreeBSD xgettext call.
rm -f messages.po
dnl Search for GNU msgmerge 0.11 or newer in the PATH.
AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,
[$ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1], :)
dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
dnl Test whether we really found GNU msgfmt.
if test "$GMSGFMT" != ":"; then
dnl If it is no GNU msgfmt we define it as : so that the
dnl Makefiles still can work.
if $GMSGFMT --statistics /dev/null >/dev/null 2>&1 &&
(if $GMSGFMT --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then
: ;
else
GMSGFMT=`echo "$GMSGFMT" | sed -e 's,^.*/,,'`
AC_MSG_RESULT(
[found $GMSGFMT program is not GNU msgfmt; ignore it])
GMSGFMT=":"
fi
fi
dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
dnl Test whether we really found GNU xgettext.
if test "$XGETTEXT" != ":"; then
dnl If it is no GNU xgettext we define it as : so that the
dnl Makefiles still can work.
if $XGETTEXT --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 &&
(if $XGETTEXT --omit-header --copyright-holder= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then
: ;
else
AC_MSG_RESULT(
[found xgettext program is not GNU xgettext; ignore it])
XGETTEXT=":"
fi
dnl Remove leftover from FreeBSD xgettext call.
rm -f messages.po
fi
AC_OUTPUT_COMMANDS([
for ac_file in $CONFIG_FILES; do
# Support "outfile[:infile[:infile...]]"
case "$ac_file" in
*:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
esac
# PO directories have a Makefile.in generated from Makefile.in.in.
case "$ac_file" in */Makefile.in)
# Adjust a relative srcdir.
ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
# In autoconf-2.13 it is called $ac_given_srcdir.
# In autoconf-2.50 it is called $srcdir.
test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
case "$ac_given_srcdir" in
.) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
/*) top_srcdir="$ac_given_srcdir" ;;
*) top_srcdir="$ac_dots$ac_given_srcdir" ;;
esac
if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
rm -f "$ac_dir/POTFILES"
test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES"
# ALL_LINGUAS, POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES depend
# on $ac_dir but don't depend on user-specified configuration
# parameters.
if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
# The LINGUAS file contains the set of available languages.
if test -n "$ALL_LINGUAS"; then
test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
fi
ALL_LINGUAS_=`sed -e "/^#/d" "$ac_given_srcdir/$ac_dir/LINGUAS"`
# Hide the ALL_LINGUAS assigment from automake.
eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
fi
case "$ac_given_srcdir" in
.) srcdirpre= ;;
*) srcdirpre='$(srcdir)/' ;;
esac
POFILES=
GMOFILES=
UPDATEPOFILES=
DUMMYPOFILES=
for lang in $ALL_LINGUAS; do
POFILES="$POFILES $srcdirpre$lang.po"
GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
done
# CATALOGS depends on both $ac_dir and the user's LINGUAS
# environment variable.
INST_LINGUAS=
if test -n "$ALL_LINGUAS"; then
for presentlang in $ALL_LINGUAS; do
useit=no
if test "%UNSET%" != "$LINGUAS"; then
desiredlanguages="$LINGUAS"
else
desiredlanguages="$ALL_LINGUAS"
fi
for desiredlang in $desiredlanguages; do
# Use the presentlang catalog if desiredlang is
# a. equal to presentlang, or
# b. a variant of presentlang (because in this case,
# presentlang can be used as a fallback for messages
# which are not translated in the desiredlang catalog).
case "$desiredlang" in
"$presentlang"*) useit=yes;;
esac
done
if test $useit = yes; then
INST_LINGUAS="$INST_LINGUAS $presentlang"
fi
done
fi
CATALOGS=
if test -n "$INST_LINGUAS"; then
for lang in $INST_LINGUAS; do
CATALOGS="$CATALOGS $lang.gmo"
done
fi
test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do
if test -f "$f"; then
case "$f" in
*.orig | *.bak | *~) ;;
*) cat "$f" >> "$ac_dir/Makefile" ;;
esac
fi
done
fi
;;
esac
done],
[# Capture the value of obsolete ALL_LINGUAS because we need it to compute
# POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES, CATALOGS. But hide it
# from automake.
eval 'ALL_LINGUAS''="$ALL_LINGUAS"'
# Capture the value of LINGUAS because we need it to compute CATALOGS.
LINGUAS="${LINGUAS-%UNSET%}"
])
])
dnl Checks for all prerequisites of the intl subdirectory,
dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS,
dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL.
AC_DEFUN([AM_INTL_SUBDIR],
[
AC_REQUIRE([AC_PROG_INSTALL])dnl
AC_REQUIRE([AM_MKINSTALLDIRS])dnl
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_CANONICAL_HOST])dnl
AC_REQUIRE([AC_PROG_RANLIB])dnl
AC_REQUIRE([AC_ISC_POSIX])dnl
AC_REQUIRE([AC_HEADER_STDC])dnl
AC_REQUIRE([AC_C_CONST])dnl
AC_REQUIRE([AC_C_INLINE])dnl
AC_REQUIRE([AC_TYPE_OFF_T])dnl
AC_REQUIRE([AC_TYPE_SIZE_T])dnl
AC_REQUIRE([AC_FUNC_ALLOCA])dnl
AC_REQUIRE([AC_FUNC_MMAP])dnl
AC_REQUIRE([jm_GLIBC21])dnl
AC_REQUIRE([gt_INTDIV0])dnl
AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])dnl
AC_REQUIRE([gt_HEADER_INTTYPES_H])dnl
AC_REQUIRE([gt_INTTYPES_PRI])dnl
AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
stdlib.h string.h unistd.h sys/param.h])
AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getc_unlocked getcwd getegid \
geteuid getgid getuid mempcpy munmap putenv setenv setlocale stpcpy \
strcasecmp strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
AM_ICONV
AM_LANGINFO_CODESET
if test $ac_cv_header_locale_h = yes; then
AM_LC_MESSAGES
fi
dnl intl/plural.c is generated from intl/plural.y. It requires bison,
dnl because plural.y uses bison specific features. It requires at least
dnl bison-1.26 because earlier versions generate a plural.c that doesn't
dnl compile.
dnl bison is only needed for the maintainer (who touches plural.y). But in
dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
dnl the rule in general Makefile. Now, some people carelessly touch the
dnl files or have a broken "make" program, hence the plural.c rule will
dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
dnl present or too old.
AC_CHECK_PROGS([INTLBISON], [bison])
if test -z "$INTLBISON"; then
ac_verc_fail=yes
else
dnl Found it, now check the version.
AC_MSG_CHECKING([version of bison])
changequote(<<,>>)dnl
ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
case $ac_prog_version in
'') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
changequote([,])dnl
ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
*) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
esac
AC_MSG_RESULT([$ac_prog_version])
fi
if test $ac_verc_fail = yes; then
INTLBISON=:
fi
])
AC_DEFUN([AM_MKINSTALLDIRS],
[
dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
dnl find the mkinstalldirs script in another subdir but $(top_srcdir).
dnl Try to locate is.
MKINSTALLDIRS=
if test -n "$ac_aux_dir"; then
MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
fi
if test -z "$MKINSTALLDIRS"; then
MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
fi
AC_SUBST(MKINSTALLDIRS)
])
dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])

View File

@@ -1,215 +0,0 @@
# Configure paths for GLIB
# Owen Taylor 1997-2001
dnl AM_PATH_GLIB_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if gmodule, gobject or
dnl gthread is specified in MODULES, pass to pkg-config
dnl
AC_DEFUN([AM_PATH_GLIB_2_0],
[dnl
dnl Get the cflags and libraries from pkg-config
dnl
AC_ARG_ENABLE(glibtest, [ --disable-glibtest do not try to compile and run a test GLIB program],
, enable_glibtest=yes)
pkg_config_args=glib-2.0
for module in . $4
do
case "$module" in
gmodule)
pkg_config_args="$pkg_config_args gmodule-2.0"
;;
gmodule-no-export)
pkg_config_args="$pkg_config_args gmodule-no-export-2.0"
;;
gobject)
pkg_config_args="$pkg_config_args gobject-2.0"
;;
gthread)
pkg_config_args="$pkg_config_args gthread-2.0"
;;
esac
done
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
no_glib=""
if test x$PKG_CONFIG != xno ; then
if $PKG_CONFIG --atleast-pkgconfig-version 0.7 ; then
:
else
echo *** pkg-config too old; version 0.7 or better required.
no_glib=yes
PKG_CONFIG=no
fi
else
no_glib=yes
fi
min_glib_version=ifelse([$1], ,2.0.0,$1)
AC_MSG_CHECKING(for GLIB - version >= $min_glib_version)
if test x$PKG_CONFIG != xno ; then
## don't try to run the test against uninstalled libtool libs
if $PKG_CONFIG --uninstalled $pkg_config_args; then
echo "Will use uninstalled version of GLib found in PKG_CONFIG_PATH"
enable_glibtest=no
fi
if $PKG_CONFIG --atleast-version $min_glib_version $pkg_config_args; then
:
else
no_glib=yes
fi
fi
if test x"$no_glib" = x ; then
GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
GOBJECT_QUERY=`$PKG_CONFIG --variable=gobject_query glib-2.0`
GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
GLIB_CFLAGS=`$PKG_CONFIG --cflags $pkg_config_args`
GLIB_LIBS=`$PKG_CONFIG --libs $pkg_config_args`
glib_config_major_version=`$PKG_CONFIG --modversion glib-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
glib_config_minor_version=`$PKG_CONFIG --modversion glib-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
glib_config_micro_version=`$PKG_CONFIG --modversion glib-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
if test "x$enable_glibtest" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $GLIB_CFLAGS"
LIBS="$GLIB_LIBS $LIBS"
dnl
dnl Now check if the installed GLIB is sufficiently new. (Also sanity
dnl checks the results of pkg-config to some extent)
dnl
rm -f conf.glibtest
AC_TRY_RUN([
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
int
main ()
{
int major, minor, micro;
char *tmp_version;
system ("touch conf.glibtest");
/* HP/UX 9 (%@#!) writes to sscanf strings */
tmp_version = g_strdup("$min_glib_version");
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
printf("%s, bad version string\n", "$min_glib_version");
exit(1);
}
if ((glib_major_version != $glib_config_major_version) ||
(glib_minor_version != $glib_config_minor_version) ||
(glib_micro_version != $glib_config_micro_version))
{
printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n",
$glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version,
glib_major_version, glib_minor_version, glib_micro_version);
printf ("*** was found! If pkg-config was correct, then it is best\n");
printf ("*** to remove the old version of GLib. You may also be able to fix the error\n");
printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
printf("*** required on your system.\n");
printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
printf("*** to point to the correct configuration files\n");
}
else if ((glib_major_version != GLIB_MAJOR_VERSION) ||
(glib_minor_version != GLIB_MINOR_VERSION) ||
(glib_micro_version != GLIB_MICRO_VERSION))
{
printf("*** GLIB header files (version %d.%d.%d) do not match\n",
GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
printf("*** library (version %d.%d.%d)\n",
glib_major_version, glib_minor_version, glib_micro_version);
}
else
{
if ((glib_major_version > major) ||
((glib_major_version == major) && (glib_minor_version > minor)) ||
((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro)))
{
return 0;
}
else
{
printf("\n*** An old version of GLIB (%d.%d.%d) was found.\n",
glib_major_version, glib_minor_version, glib_micro_version);
printf("*** You need a version of GLIB newer than %d.%d.%d. The latest version of\n",
major, minor, micro);
printf("*** GLIB is always available from ftp://ftp.gtk.org.\n");
printf("***\n");
printf("*** If you have already installed a sufficiently new version, this error\n");
printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
printf("*** being found. The easiest way to fix this is to remove the old version\n");
printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n");
printf("*** correct copy of pkg-config. (In this case, you will have to\n");
printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
printf("*** so that the correct libraries are found at run-time))\n");
}
}
return 1;
}
],, no_glib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
if test "x$no_glib" = x ; then
AC_MSG_RESULT(yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version))
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
if test "$PKG_CONFIG" = "no" ; then
echo "*** A new enough version of pkg-config was not found."
echo "*** See http://www.freedesktop.org/software/pkgconfig/"
else
if test -f conf.glibtest ; then
:
else
echo "*** Could not run GLIB test program, checking why..."
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $GLIB_CFLAGS"
LIBS="$LIBS $GLIB_LIBS"
AC_TRY_LINK([
#include <glib.h>
#include <stdio.h>
], [ return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ],
[ echo "*** The test program compiled, but did not run. This usually means"
echo "*** that the run-time linker is not finding GLIB or finding the wrong"
echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your"
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
echo "*** to the installed location Also, make sure you have run ldconfig if that"
echo "*** is required on your system"
echo "***"
echo "*** If you have an old version installed, it is best to remove it, although"
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
[ echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means GLIB is incorrectly installed."])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
GLIB_CFLAGS=""
GLIB_LIBS=""
GLIB_GENMARSHAL=""
GOBJECT_QUERY=""
GLIB_MKENUMS=""
ifelse([$3], , :, [$3])
fi
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
AC_SUBST(GLIB_GENMARSHAL)
AC_SUBST(GOBJECT_QUERY)
AC_SUBST(GLIB_MKENUMS)
rm -f conf.glibtest
])

View File

@@ -1,32 +0,0 @@
# glibc21.m4 serial 2 (fileutils-4.1.3, gettext-0.10.40)
dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
# Test for the GNU C Library, version 2.1 or newer.
# From Bruno Haible.
AC_DEFUN([jm_GLIBC21],
[
AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
ac_cv_gnu_library_2_1,
[AC_EGREP_CPP([Lucky GNU user],
[
#include <features.h>
#ifdef __GNU_LIBRARY__
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
Lucky GNU user
#endif
#endif
],
ac_cv_gnu_library_2_1=yes,
ac_cv_gnu_library_2_1=no)
]
)
AC_SUBST(GLIBC21)
GLIBC21="$ac_cv_gnu_library_2_1"
]
)

View File

@@ -1,103 +0,0 @@
# iconv.m4 serial AM4 (gettext-0.11.3)
dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Bruno Haible.
AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
[
dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
dnl accordingly.
AC_LIB_LINKFLAGS_BODY([iconv])
])
AC_DEFUN([AM_ICONV_LINK],
[
dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
dnl those with the standalone portable GNU libiconv installed).
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
dnl accordingly.
AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
dnl Add $INCICONV to CPPFLAGS before performing the following checks,
dnl because if the user has installed libiconv and not disabled its use
dnl via --without-libiconv-prefix, he wants to use it. The first
dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
am_save_CPPFLAGS="$CPPFLAGS"
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
am_cv_func_iconv="no, consider installing GNU libiconv"
am_cv_lib_iconv=no
AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>],
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);],
am_cv_func_iconv=yes)
if test "$am_cv_func_iconv" != yes; then
am_save_LIBS="$LIBS"
LIBS="$LIBS $LIBICONV"
AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>],
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);],
am_cv_lib_iconv=yes
am_cv_func_iconv=yes)
LIBS="$am_save_LIBS"
fi
])
if test "$am_cv_func_iconv" = yes; then
AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
fi
if test "$am_cv_lib_iconv" = yes; then
AC_MSG_CHECKING([how to link with libiconv])
AC_MSG_RESULT([$LIBICONV])
else
dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
dnl either.
CPPFLAGS="$am_save_CPPFLAGS"
LIBICONV=
LTLIBICONV=
fi
AC_SUBST(LIBICONV)
AC_SUBST(LTLIBICONV)
])
AC_DEFUN([AM_ICONV],
[
AM_ICONV_LINK
if test "$am_cv_func_iconv" = yes; then
AC_MSG_CHECKING([for iconv declaration])
AC_CACHE_VAL(am_cv_proto_iconv, [
AC_TRY_COMPILE([
#include <stdlib.h>
#include <iconv.h>
extern
#ifdef __cplusplus
"C"
#endif
#if defined(__STDC__) || defined(__cplusplus)
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
#else
size_t iconv();
#endif
], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
AC_MSG_RESULT([$]{ac_t:-
}[$]am_cv_proto_iconv)
AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
[Define as const if the declaration of iconv() needs const.])
fi
])

View File

@@ -1,72 +0,0 @@
# intdiv0.m4 serial 1 (gettext-0.11.3)
dnl Copyright (C) 2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Bruno Haible.
AC_DEFUN([gt_INTDIV0],
[
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_CANONICAL_HOST])dnl
AC_CACHE_CHECK([whether integer division by zero raises SIGFPE],
gt_cv_int_divbyzero_sigfpe,
[
AC_TRY_RUN([
#include <stdlib.h>
#include <signal.h>
static void
#ifdef __cplusplus
sigfpe_handler (int sig)
#else
sigfpe_handler (sig) int sig;
#endif
{
/* Exit with code 0 if SIGFPE, with code 1 if any other signal. */
exit (sig != SIGFPE);
}
int x = 1;
int y = 0;
int z;
int nan;
int main ()
{
signal (SIGFPE, sigfpe_handler);
/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */
#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP)
signal (SIGTRAP, sigfpe_handler);
#endif
/* Linux/SPARC yields signal SIGILL. */
#if defined (__sparc__) && defined (__linux__)
signal (SIGILL, sigfpe_handler);
#endif
z = x / y;
nan = y / y;
exit (1);
}
], gt_cv_int_divbyzero_sigfpe=yes, gt_cv_int_divbyzero_sigfpe=no,
[
# Guess based on the CPU.
case "$host_cpu" in
alpha* | i[34567]86 | m68k | s390*)
gt_cv_int_divbyzero_sigfpe="guessing yes";;
*)
gt_cv_int_divbyzero_sigfpe="guessing no";;
esac
])
])
case "$gt_cv_int_divbyzero_sigfpe" in
*yes) value=1;;
*) value=0;;
esac
AC_DEFINE_UNQUOTED(INTDIV0_RAISES_SIGFPE, $value,
[Define if integer division by zero raises signal SIGFPE.])
])

View File

@@ -1,32 +0,0 @@
# inttypes-pri.m4 serial 1 (gettext-0.11.4)
dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Bruno Haible.
# Define PRI_MACROS_BROKEN if <inttypes.h> exists and defines the PRI*
# macros to non-string values. This is the case on AIX 4.3.3.
AC_DEFUN([gt_INTTYPES_PRI],
[
AC_REQUIRE([gt_HEADER_INTTYPES_H])
if test $gt_cv_header_inttypes_h = yes; then
AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken],
gt_cv_inttypes_pri_broken,
[
AC_TRY_COMPILE([#include <inttypes.h>
#ifdef PRId32
char *p = PRId32;
#endif
], [], gt_cv_inttypes_pri_broken=no, gt_cv_inttypes_pri_broken=yes)
])
fi
if test "$gt_cv_inttypes_pri_broken" = yes; then
AC_DEFINE_UNQUOTED(PRI_MACROS_BROKEN, 1,
[Define if <inttypes.h> exists and defines unusable PRI* macros.])
fi
])

View File

@@ -1,27 +0,0 @@
# inttypes.m4 serial 1 (gettext-0.11.4)
dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Paul Eggert.
# Define HAVE_INTTYPES_H if <inttypes.h> exists and doesn't clash with
# <sys/types.h>.
AC_DEFUN([gt_HEADER_INTTYPES_H],
[
AC_CACHE_CHECK([for inttypes.h], gt_cv_header_inttypes_h,
[
AC_TRY_COMPILE(
[#include <sys/types.h>
#include <inttypes.h>],
[], gt_cv_header_inttypes_h=yes, gt_cv_header_inttypes_h=no)
])
if test $gt_cv_header_inttypes_h = yes; then
AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
[Define if <inttypes.h> exists and doesn't clash with <sys/types.h>.])
fi
])

View File

@@ -1,28 +0,0 @@
# inttypes_h.m4 serial 4 (gettext-0.11.4)
dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Paul Eggert.
# Define HAVE_INTTYPES_H_WITH_UINTMAX if <inttypes.h> exists,
# doesn't clash with <sys/types.h>, and declares uintmax_t.
AC_DEFUN([jm_AC_HEADER_INTTYPES_H],
[
AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
[AC_TRY_COMPILE(
[#include <sys/types.h>
#include <inttypes.h>],
[uintmax_t i = (uintmax_t) -1;],
jm_ac_cv_header_inttypes_h=yes,
jm_ac_cv_header_inttypes_h=no)])
if test $jm_ac_cv_header_inttypes_h = yes; then
AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H_WITH_UINTMAX, 1,
[Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
and declares uintmax_t. ])
fi
])

View File

@@ -1,26 +0,0 @@
# isc-posix.m4 serial 2 (gettext-0.11.2)
dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
# This file is not needed with autoconf-2.53 and newer. Remove it in 2005.
# This test replaces the one in autoconf.
# Currently this macro should have the same name as the autoconf macro
# because gettext's gettext.m4 (distributed in the automake package)
# still uses it. Otherwise, the use in gettext.m4 makes autoheader
# give these diagnostics:
# configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
# configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
undefine([AC_ISC_POSIX])
AC_DEFUN([AC_ISC_POSIX],
[
dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
]
)

View File

@@ -1,32 +0,0 @@
# lcmessage.m4 serial 3 (gettext-0.11.3)
dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl
dnl This file can can be used in projects which are not available under
dnl the GNU General Public License or the GNU Library General Public
dnl License but which still want to provide support for the GNU gettext
dnl functionality.
dnl Please note that the actual code of the GNU gettext library is covered
dnl by the GNU Library General Public License, and the rest of the GNU
dnl gettext package package is covered by the GNU General Public License.
dnl They are *not* in the public domain.
dnl Authors:
dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
# Check whether LC_MESSAGES is available in <locale.h>.
AC_DEFUN([AM_LC_MESSAGES],
[
AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
[AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
if test $am_cv_val_LC_MESSAGES = yes; then
AC_DEFINE(HAVE_LC_MESSAGES, 1,
[Define if your <locale.h> file defines LC_MESSAGES.])
fi
])

View File

@@ -1,97 +0,0 @@
# lib-ld.m4 serial 1 (gettext-0.11)
dnl Copyright (C) 1996-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl Subroutines of libtool.m4,
dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
dnl with libtool.m4.
dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
AC_DEFUN([AC_LIB_PROG_LD_GNU],
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
acl_cv_prog_gnu_ld=yes
else
acl_cv_prog_gnu_ld=no
fi])
with_gnu_ld=$acl_cv_prog_gnu_ld
])
dnl From libtool-1.4. Sets the variable LD.
AC_DEFUN([AC_LIB_PROG_LD],
[AC_ARG_WITH(gnu-ld,
[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_CANONICAL_HOST])dnl
ac_prog=ld
if test "$GCC" = yes; then
# Check if gcc -print-prog-name=ld gives a path.
AC_MSG_CHECKING([for ld used by GCC])
case $host in
*-*-mingw*)
# gcc leaves a trailing carriage return which upsets mingw
ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
*)
ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
esac
case $ac_prog in
# Accept absolute paths.
[[\\/]* | [A-Za-z]:[\\/]*)]
[re_direlt='/[^/][^/]*/\.\./']
# Canonicalize the path of ld
ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
done
test -z "$LD" && LD="$ac_prog"
;;
"")
# If it fails, then pretend we aren't using GCC.
ac_prog=ld
;;
*)
# If it is relative, then search for the first ld in PATH.
with_gnu_ld=unknown
;;
esac
elif test "$with_gnu_ld" = yes; then
AC_MSG_CHECKING([for GNU ld])
else
AC_MSG_CHECKING([for non-GNU ld])
fi
AC_CACHE_VAL(acl_cv_path_LD,
[if test -z "$LD"; then
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
for ac_dir in $PATH; do
test -z "$ac_dir" && ac_dir=.
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
acl_cv_path_LD="$ac_dir/$ac_prog"
# Check to see if the program is GNU ld. I'd rather use --version,
# but apparently some GNU ld's only accept -v.
# Break only if it was the GNU/non-GNU ld that we prefer.
if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
test "$with_gnu_ld" != no && break
else
test "$with_gnu_ld" != yes && break
fi
fi
done
IFS="$ac_save_ifs"
else
acl_cv_path_LD="$LD" # Let the user override the test with a path.
fi])
LD="$acl_cv_path_LD"
if test -n "$LD"; then
AC_MSG_RESULT($LD)
else
AC_MSG_RESULT(no)
fi
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
AC_LIB_PROG_LD_GNU
])

View File

@@ -1,554 +0,0 @@
# lib-link.m4 serial 3 (gettext-0.11.3)
dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Bruno Haible.
dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
dnl the libraries corresponding to explicit and implicit dependencies.
dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
dnl augments the CPPFLAGS variable.
AC_DEFUN([AC_LIB_LINKFLAGS],
[
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
define([Name],[translit([$1],[./-], [___])])
define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
AC_LIB_LINKFLAGS_BODY([$1], [$2])
ac_cv_lib[]Name[]_libs="$LIB[]NAME"
ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
])
LIB[]NAME="$ac_cv_lib[]Name[]_libs"
LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
AC_SUBST([LIB]NAME)
AC_SUBST([LTLIB]NAME)
dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
dnl results of this search when this library appears as a dependency.
HAVE_LIB[]NAME=yes
undefine([Name])
undefine([NAME])
])
dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
dnl searches for libname and the libraries corresponding to explicit and
dnl implicit dependencies, together with the specified include files and
dnl the ability to compile and link the specified testcode. If found, it
dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
[
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
define([Name],[translit([$1],[./-], [___])])
define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
dnl accordingly.
AC_LIB_LINKFLAGS_BODY([$1], [$2])
dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
dnl because if the user has installed lib[]Name and not disabled its use
dnl via --without-lib[]Name-prefix, he wants to use it.
ac_save_CPPFLAGS="$CPPFLAGS"
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
ac_save_LIBS="$LIBS"
LIBS="$LIBS $LIB[]NAME"
AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
LIBS="$ac_save_LIBS"
])
if test "$ac_cv_lib[]Name" = yes; then
HAVE_LIB[]NAME=yes
AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
AC_MSG_CHECKING([how to link with lib[]$1])
AC_MSG_RESULT([$LIB[]NAME])
else
HAVE_LIB[]NAME=no
dnl If $LIB[]NAME didn't lead to a usable library, we don't need
dnl $INC[]NAME either.
CPPFLAGS="$ac_save_CPPFLAGS"
LIB[]NAME=
LTLIB[]NAME=
fi
AC_SUBST([HAVE_LIB]NAME)
AC_SUBST([LIB]NAME)
AC_SUBST([LTLIB]NAME)
undefine([Name])
undefine([NAME])
])
dnl Determine the platform dependent parameters needed to use rpath:
dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
dnl hardcode_direct, hardcode_minus_L,
dnl sys_lib_search_path_spec, sys_lib_dlsearch_path_spec.
AC_DEFUN([AC_LIB_RPATH],
[
AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
. ./conftest.sh
rm -f ./conftest.sh
acl_cv_rpath=done
])
wl="$acl_cv_wl"
libext="$acl_cv_libext"
shlibext="$acl_cv_shlibext"
hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
hardcode_direct="$acl_cv_hardcode_direct"
hardcode_minus_L="$acl_cv_hardcode_minus_L"
sys_lib_search_path_spec="$acl_cv_sys_lib_search_path_spec"
sys_lib_dlsearch_path_spec="$acl_cv_sys_lib_dlsearch_path_spec"
dnl Determine whether the user wants rpath handling at all.
AC_ARG_ENABLE(rpath,
[ --disable-rpath do not hardcode runtime library paths],
:, enable_rpath=yes)
])
dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
dnl the libraries corresponding to explicit and implicit dependencies.
dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
[
define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
dnl By default, look in $includedir and $libdir.
use_additional=yes
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
AC_ARG_WITH([lib$1-prefix],
[ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib
--without-lib$1-prefix don't search for lib$1 in includedir and libdir],
[
if test "X$withval" = "Xno"; then
use_additional=no
else
if test "X$withval" = "X"; then
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
else
additional_includedir="$withval/include"
additional_libdir="$withval/lib"
fi
fi
])
dnl Search the library and its dependencies in $additional_libdir and
dnl $LDFLAGS. Using breadth-first-seach.
LIB[]NAME=
LTLIB[]NAME=
INC[]NAME=
rpathdirs=
ltrpathdirs=
names_already_handled=
names_next_round='$1 $2'
while test -n "$names_next_round"; do
names_this_round="$names_next_round"
names_next_round=
for name in $names_this_round; do
already_handled=
for n in $names_already_handled; do
if test "$n" = "$name"; then
already_handled=yes
break
fi
done
if test -z "$already_handled"; then
names_already_handled="$names_already_handled $name"
dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
dnl or AC_LIB_HAVE_LINKFLAGS call.
uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
eval value=\"\$HAVE_LIB$uppername\"
if test -n "$value"; then
if test "$value" = yes; then
eval value=\"\$LIB$uppername\"
test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
eval value=\"\$LTLIB$uppername\"
test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
else
dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
dnl that this library doesn't exist. So just drop it.
:
fi
else
dnl Search the library lib$name in $additional_libdir and $LDFLAGS
dnl and the already constructed $LIBNAME/$LTLIBNAME.
found_dir=
found_la=
found_so=
found_a=
if test $use_additional = yes; then
if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
found_dir="$additional_libdir"
found_so="$additional_libdir/lib$name.$shlibext"
if test -f "$additional_libdir/lib$name.la"; then
found_la="$additional_libdir/lib$name.la"
fi
else
if test -f "$additional_libdir/lib$name.$libext"; then
found_dir="$additional_libdir"
found_a="$additional_libdir/lib$name.$libext"
if test -f "$additional_libdir/lib$name.la"; then
found_la="$additional_libdir/lib$name.la"
fi
fi
fi
fi
if test "X$found_dir" = "X"; then
for x in $LDFLAGS $LTLIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
case "$x" in
-L*)
dir=`echo "X$x" | sed -e 's/^X-L//'`
if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
found_dir="$dir"
found_so="$dir/lib$name.$shlibext"
if test -f "$dir/lib$name.la"; then
found_la="$dir/lib$name.la"
fi
else
if test -f "$dir/lib$name.$libext"; then
found_dir="$dir"
found_a="$dir/lib$name.$libext"
if test -f "$dir/lib$name.la"; then
found_la="$dir/lib$name.la"
fi
fi
fi
;;
esac
if test "X$found_dir" != "X"; then
break
fi
done
fi
if test "X$found_dir" != "X"; then
dnl Found the library.
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
if test "X$found_so" != "X"; then
dnl Linking with a shared library. We attempt to hardcode its
dnl directory into the executable's runpath, unless it's the
dnl standard /usr/lib.
if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
dnl No hardcoding is needed.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
else
dnl Use an explicit option to hardcode DIR into the resulting
dnl binary.
dnl Potentially add DIR to ltrpathdirs.
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
haveit=
for x in $ltrpathdirs; do
if test "X$x" = "X$found_dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
ltrpathdirs="$ltrpathdirs $found_dir"
fi
dnl The hardcoding into $LIBNAME is system dependent.
if test "$hardcode_direct" = yes; then
dnl Using DIR/libNAME.so during linking hardcodes DIR into the
dnl resulting binary.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
else
if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
dnl Use an explicit option to hardcode DIR into the resulting
dnl binary.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
dnl Potentially add DIR to rpathdirs.
dnl The rpathdirs will be appended to $LIBNAME at the end.
haveit=
for x in $rpathdirs; do
if test "X$x" = "X$found_dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
rpathdirs="$rpathdirs $found_dir"
fi
else
dnl Rely on "-L$found_dir".
dnl But don't add it if it's already contained in the LDFLAGS
dnl or the already constructed $LIBNAME
haveit=
for x in $LDFLAGS $LIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$found_dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
fi
if test "$hardcode_minus_L" != no; then
dnl FIXME: Not sure whether we should use
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
dnl here.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
else
dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
dnl here, because this doesn't fit in flags passed to the
dnl compiler. So give up. No hardcoding. This affects only
dnl very old systems.
dnl FIXME: Not sure whether we should use
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
dnl here.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
fi
fi
fi
fi
else
if test "X$found_a" != "X"; then
dnl Linking with a static library.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
else
dnl We shouldn't come here, but anyway it's good to have a
dnl fallback.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
fi
fi
dnl Assume the include files are nearby.
additional_includedir=
case "$found_dir" in
*/lib | */lib/)
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
additional_includedir="$basedir/include"
;;
esac
if test "X$additional_includedir" != "X"; then
dnl Potentially add $additional_includedir to $INCNAME.
dnl But don't add it
dnl 1. if it's the standard /usr/include,
dnl 2. if it's /usr/local/include and we are using GCC on Linux,
dnl 3. if it's already present in $CPPFLAGS or the already
dnl constructed $INCNAME,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_includedir" != "X/usr/include"; then
haveit=
if test "X$additional_includedir" = "X/usr/local/include"; then
if test -n "$GCC"; then
case $host_os in
linux*) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
for x in $CPPFLAGS $INC[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-I$additional_includedir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test -d "$additional_includedir"; then
dnl Really add $additional_includedir to $INCNAME.
INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
fi
fi
fi
fi
fi
dnl Look for dependencies.
if test -n "$found_la"; then
dnl Read the .la file. It defines the variables
dnl dlname, library_names, old_library, dependency_libs, current,
dnl age, revision, installed, dlopen, dlpreopen, libdir.
save_libdir="$libdir"
case "$found_la" in
*/* | *\\*) . "$found_la" ;;
*) . "./$found_la" ;;
esac
libdir="$save_libdir"
dnl We use only dependency_libs.
for dep in $dependency_libs; do
case "$dep" in
-L*)
additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
dnl But don't add it
dnl 1. if it's the standard /usr/lib,
dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
dnl 3. if it's already present in $LDFLAGS or the already
dnl constructed $LIBNAME,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_libdir" != "X/usr/lib"; then
haveit=
if test "X$additional_libdir" = "X/usr/local/lib"; then
if test -n "$GCC"; then
case $host_os in
linux*) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
haveit=
for x in $LDFLAGS $LIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$additional_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test -d "$additional_libdir"; then
dnl Really add $additional_libdir to $LIBNAME.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
fi
fi
haveit=
for x in $LDFLAGS $LTLIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$additional_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test -d "$additional_libdir"; then
dnl Really add $additional_libdir to $LTLIBNAME.
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
fi
fi
fi
fi
;;
-R*)
dir=`echo "X$dep" | sed -e 's/^X-R//'`
if test "$enable_rpath" != no; then
dnl Potentially add DIR to rpathdirs.
dnl The rpathdirs will be appended to $LIBNAME at the end.
haveit=
for x in $rpathdirs; do
if test "X$x" = "X$dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
rpathdirs="$rpathdirs $dir"
fi
dnl Potentially add DIR to ltrpathdirs.
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
haveit=
for x in $ltrpathdirs; do
if test "X$x" = "X$dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
ltrpathdirs="$ltrpathdirs $dir"
fi
fi
;;
-l*)
dnl Handle this in the next round.
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
;;
*.la)
dnl Handle this in the next round. Throw away the .la's
dnl directory; it is already contained in a preceding -L
dnl option.
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
;;
*)
dnl Most likely an immediate library name.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
;;
esac
done
fi
else
dnl Didn't find the library; assume it is in the system directories
dnl known to the linker and runtime loader. (All the system
dnl directories known to the linker should also be known to the
dnl runtime loader, otherwise the system is severely misconfigured.)
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
fi
fi
fi
done
done
if test "X$rpathdirs" != "X"; then
if test -n "$hardcode_libdir_separator"; then
dnl Weird platform: only the last -rpath option counts, the user must
dnl pass all path elements in one option. We can arrange that for a
dnl single library, but not when more than one $LIBNAMEs are used.
alldirs=
for found_dir in $rpathdirs; do
alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
done
dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
acl_save_libdir="$libdir"
libdir="$alldirs"
eval flag=\"$hardcode_libdir_flag_spec\"
libdir="$acl_save_libdir"
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
else
dnl The -rpath options are cumulative.
for found_dir in $rpathdirs; do
acl_save_libdir="$libdir"
libdir="$found_dir"
eval flag=\"$hardcode_libdir_flag_spec\"
libdir="$acl_save_libdir"
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
done
fi
fi
if test "X$ltrpathdirs" != "X"; then
dnl When using libtool, the option that works for both libraries and
dnl executables is -R. The -R options are cumulative.
for found_dir in $ltrpathdirs; do
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
done
fi
])
dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
dnl unless already present in VAR.
dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
dnl contains two or three consecutive elements that belong together.
AC_DEFUN([AC_LIB_APPENDTOVAR],
[
for element in [$2]; do
haveit=
for x in $[$1]; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X$element"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
[$1]="${[$1]}${[$1]:+ }$element"
fi
done
])

View File

@@ -1,148 +0,0 @@
# lib-prefix.m4 serial 1 (gettext-0.11)
dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Bruno Haible.
dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
dnl to access previously installed libraries. The basic assumption is that
dnl a user will want packages to use other packages he previously installed
dnl with the same --prefix option.
dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
dnl libraries, but is otherwise very convenient.
AC_DEFUN([AC_LIB_PREFIX],
[
AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
dnl By default, look in $includedir and $libdir.
use_additional=yes
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
AC_ARG_WITH([lib-prefix],
[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
--without-lib-prefix don't search for libraries in includedir and libdir],
[
if test "X$withval" = "Xno"; then
use_additional=no
else
if test "X$withval" = "X"; then
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
else
additional_includedir="$withval/include"
additional_libdir="$withval/lib"
fi
fi
])
if test $use_additional = yes; then
dnl Potentially add $additional_includedir to $CPPFLAGS.
dnl But don't add it
dnl 1. if it's the standard /usr/include,
dnl 2. if it's already present in $CPPFLAGS,
dnl 3. if it's /usr/local/include and we are using GCC on Linux,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_includedir" != "X/usr/include"; then
haveit=
for x in $CPPFLAGS; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-I$additional_includedir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test "X$additional_includedir" = "X/usr/local/include"; then
if test -n "$GCC"; then
case $host_os in
linux*) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
if test -d "$additional_includedir"; then
dnl Really add $additional_includedir to $CPPFLAGS.
CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
fi
fi
fi
fi
dnl Potentially add $additional_libdir to $LDFLAGS.
dnl But don't add it
dnl 1. if it's the standard /usr/lib,
dnl 2. if it's already present in $LDFLAGS,
dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_libdir" != "X/usr/lib"; then
haveit=
for x in $LDFLAGS; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$additional_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test "X$additional_libdir" = "X/usr/local/lib"; then
if test -n "$GCC"; then
case $host_os in
linux*) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
if test -d "$additional_libdir"; then
dnl Really add $additional_libdir to $LDFLAGS.
LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
fi
fi
fi
fi
fi
])
dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
dnl acl_final_exec_prefix, containing the values to which $prefix and
dnl $exec_prefix will expand at the end of the configure script.
AC_DEFUN([AC_LIB_PREPARE_PREFIX],
[
dnl Unfortunately, prefix and exec_prefix get only finally determined
dnl at the end of configure.
if test "X$prefix" = "XNONE"; then
acl_final_prefix="$ac_default_prefix"
else
acl_final_prefix="$prefix"
fi
if test "X$exec_prefix" = "XNONE"; then
acl_final_exec_prefix='${prefix}'
else
acl_final_exec_prefix="$exec_prefix"
fi
acl_save_prefix="$prefix"
prefix="$acl_final_prefix"
eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
prefix="$acl_save_prefix"
])
dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
dnl variables prefix and exec_prefix bound to the values they will have
dnl at the end of the configure script.
AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
[
acl_save_prefix="$prefix"
prefix="$acl_final_prefix"
acl_save_exec_prefix="$exec_prefix"
exec_prefix="$acl_final_exec_prefix"
$1
exec_prefix="$acl_save_exec_prefix"
prefix="$acl_save_prefix"
])

View File

@@ -1,59 +0,0 @@
# progtest.m4 serial 2 (gettext-0.10.40)
dnl Copyright (C) 1996-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl
dnl This file can can be used in projects which are not available under
dnl the GNU General Public License or the GNU Library General Public
dnl License but which still want to provide support for the GNU gettext
dnl functionality.
dnl Please note that the actual code of the GNU gettext library is covered
dnl by the GNU Library General Public License, and the rest of the GNU
dnl gettext package package is covered by the GNU General Public License.
dnl They are *not* in the public domain.
dnl Authors:
dnl Ulrich Drepper <drepper@cygnus.com>, 1996.
# Search path for a program which passes the given test.
dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
AC_DEFUN([AM_PATH_PROG_WITH_TEST],
[# Extract the first word of "$2", so it can be a program name with args.
set dummy $2; ac_word=[$]2
AC_MSG_CHECKING([for $ac_word])
AC_CACHE_VAL(ac_cv_path_$1,
[case "[$]$1" in
/*)
ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
;;
*)
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
for ac_dir in ifelse([$5], , $PATH, [$5]); do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
if [$3]; then
ac_cv_path_$1="$ac_dir/$ac_word"
break
fi
fi
done
IFS="$ac_save_ifs"
dnl If no 4th arg is given, leave the cache variable unset,
dnl so AC_PATH_PROGS will keep looking.
ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
])dnl
;;
esac])dnl
$1="$ac_cv_path_$1"
if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
AC_MSG_RESULT([$]$1)
else
AC_MSG_RESULT(no)
fi
AC_SUBST($1)dnl
])

View File

@@ -1,28 +0,0 @@
# stdint_h.m4 serial 2 (gettext-0.11.4)
dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Paul Eggert.
# Define HAVE_STDINT_H_WITH_UINTMAX if <stdint.h> exists,
# doesn't clash with <sys/types.h>, and declares uintmax_t.
AC_DEFUN([jm_AC_HEADER_STDINT_H],
[
AC_CACHE_CHECK([for stdint.h], jm_ac_cv_header_stdint_h,
[AC_TRY_COMPILE(
[#include <sys/types.h>
#include <stdint.h>],
[uintmax_t i = (uintmax_t) -1;],
jm_ac_cv_header_stdint_h=yes,
jm_ac_cv_header_stdint_h=no)])
if test $jm_ac_cv_header_stdint_h = yes; then
AC_DEFINE_UNQUOTED(HAVE_STDINT_H_WITH_UINTMAX, 1,
[Define if <stdint.h> exists, doesn't clash with <sys/types.h>,
and declares uintmax_t. ])
fi
])

View File

@@ -1,29 +0,0 @@
# uintmax_t.m4 serial 6 (gettext-0.11)
dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Paul Eggert.
AC_PREREQ(2.13)
# Define uintmax_t to `unsigned long' or `unsigned long long'
# if <inttypes.h> does not exist.
AC_DEFUN([jm_AC_TYPE_UINTMAX_T],
[
AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
AC_REQUIRE([jm_AC_HEADER_STDINT_H])
if test $jm_ac_cv_header_inttypes_h = no && test $jm_ac_cv_header_stdint_h = no; then
AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
test $ac_cv_type_unsigned_long_long = yes \
&& ac_type='unsigned long long' \
|| ac_type='unsigned long'
AC_DEFINE_UNQUOTED(uintmax_t, $ac_type,
[Define to unsigned long or unsigned long long
if <inttypes.h> and <stdint.h> don't define.])
fi
])

View File

@@ -1,23 +0,0 @@
# ulonglong.m4 serial 2 (fileutils-4.0.32, gettext-0.10.40)
dnl Copyright (C) 1999-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Paul Eggert.
AC_DEFUN([jm_AC_TYPE_UNSIGNED_LONG_LONG],
[
AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
[AC_TRY_LINK([unsigned long long ull = 1; int i = 63;],
[unsigned long long ullmax = (unsigned long long) -1;
return ull << i | ull >> i | ullmax / ull | ullmax % ull;],
ac_cv_type_unsigned_long_long=yes,
ac_cv_type_unsigned_long_long=no)])
if test $ac_cv_type_unsigned_long_long = yes; then
AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1,
[Define if you have the unsigned long long type.])
fi
])

3
po/.gitignore vendored
View File

@@ -1,6 +1,7 @@
/*.gmo
/Makefile.in.in
/Makevars.template
/Rules-quot
/boldquot.sed
/en@boldquot.header
@@ -8,4 +9,6 @@
/insert-header.sin
/POTFILES
/quot.sed
/remove-potcdate.sed
/remove-potcdate.sin
/stamp-po

1369
po/bg.po

File diff suppressed because it is too large Load Diff

1273
po/ca.po

File diff suppressed because it is too large Load Diff

1253
po/cs.po

File diff suppressed because it is too large Load Diff

1284
po/da.po

File diff suppressed because it is too large Load Diff

1262
po/de.po

File diff suppressed because it is too large Load Diff

1264
po/eo.po

File diff suppressed because it is too large Load Diff

1287
po/es.po

File diff suppressed because it is too large Load Diff

1387
po/eu.po

File diff suppressed because it is too large Load Diff

1213
po/fi.po

File diff suppressed because it is too large Load Diff

1618
po/fr.po

File diff suppressed because it is too large Load Diff

1258
po/ga.po

File diff suppressed because it is too large Load Diff

1253
po/gl.po

File diff suppressed because it is too large Load Diff

2204
po/hr.po

File diff suppressed because it is too large Load Diff

1445
po/hu.po

File diff suppressed because it is too large Load Diff

1419
po/id.po

File diff suppressed because it is too large Load Diff

1312
po/it.po

File diff suppressed because it is too large Load Diff

1339
po/ja.po

File diff suppressed because it is too large Load Diff

1367
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1260
po/nb.po

File diff suppressed because it is too large Load Diff

1282
po/nl.po

File diff suppressed because it is too large Load Diff

1409
po/nn.po

File diff suppressed because it is too large Load Diff

1253
po/pl.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1299
po/ro.po

File diff suppressed because it is too large Load Diff

1371
po/ru.po

File diff suppressed because it is too large Load Diff

1367
po/sl.po

File diff suppressed because it is too large Load Diff

1253
po/sr.po

File diff suppressed because it is too large Load Diff

1253
po/sv.po

File diff suppressed because it is too large Load Diff

2293
po/tr.po

File diff suppressed because it is too large Load Diff

1263
po/uk.po

File diff suppressed because it is too large Load Diff

1260
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,4 +1,5 @@
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -DSYSCONFDIR=\"$(sysconfdir)\"
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -DSYSCONFDIR=\"$(sysconfdir)\" \
-I$(top_builddir)/lib -I$(top_srcdir)/lib
CLEANFILES = revision.h
@@ -37,7 +38,7 @@ nano_SOURCES = browser.c \
utils.c \
winio.c
nano_LDADD = @GLIB_LIBS@ @LIBINTL@
nano_LDADD = @LIBINTL@ $(top_builddir)/lib/libgnu.a
install-exec-hook:
cd $(DESTDIR)$(bindir) && rm -f rnano && $(LN_S) nano rnano

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;
@@ -297,7 +307,7 @@ char *do_browser(char *path)
/* If we are moving up one level, remember where we came from, so
* this directory can be highlighted and easily reentered. */
if (strcmp(tail(filelist[selected]), "..") == 0)
present_name = striponedir(filelist[selected]);
present_name = strip_last_component(filelist[selected]);
/* Try opening and reading the selected directory. */
path = mallocstrcpy(path, filelist[selected]);
@@ -353,7 +363,7 @@ char *do_browse_from(const char *inpath)
* at all. If so, we'll just pass the current directory to
* do_browser(). */
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
path = free_and_assign(path, striponedir(path));
path = free_and_assign(path, strip_last_component(path));
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
char * currentdir = charalloc(PATH_MAX + 1);
@@ -467,6 +477,10 @@ functionptrtype parse_browser_input(int *kbinput)
return do_help_void;
case 'E':
case 'e':
case 'Q':
case 'q':
case 'X':
case 'x':
return do_exit;
case 'G':
case 'g':
@@ -476,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);
@@ -587,7 +605,7 @@ void browser_refresh(void)
/* Make sure info takes up no more than infomaxlen columns. */
infolen = strlenpt(info);
if (infolen > infomaxlen) {
null_at(&info, actual_x(info, infomaxlen));
info[actual_x(info, infomaxlen)] = '\0';
infolen = infomaxlen;
}
@@ -781,21 +799,17 @@ void do_last_file(void)
selected = filelist_len - 1;
}
/* Strip one directory from the end of path, and return the stripped
* path. The returned string is dynamically allocated, and should be
* freed. */
char *striponedir(const char *path)
/* Strip one element from the end of path, and return the stripped path.
* The returned string is dynamically allocated, and should be freed. */
char *strip_last_component(const char *path)
{
char *retval, *tmp;
char *copy = mallocstrcpy(NULL, path);
char *last_slash = strrchr(copy, '/');
retval = mallocstrcpy(NULL, path);
if (last_slash != NULL)
*last_slash = '\0';
tmp = strrchr(retval, '/');
if (tmp != NULL)
null_at(&retval, tmp - retval);
return retval;
return copy;
}
#endif /* !DISABLE_BROWSER */

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 *
@@ -26,12 +25,8 @@
#include <ctype.h>
#ifdef ENABLE_UTF8
#ifdef HAVE_WCHAR_H
#include <wchar.h>
#endif
#ifdef HAVE_WCTYPE_H
#include <wctype.h>
#endif
static bool use_utf8 = FALSE;
/* Whether we've enabled UTF-8 support. */
@@ -61,22 +56,6 @@ char *addstrings(char* str1, size_t len1, char* str2, size_t len2)
return str1;
}
#ifndef HAVE_ISBLANK
/* This function is equivalent to isblank(). */
bool nisblank(int c)
{
return isspace(c) && (c == '\t' || !is_cntrl_char(c));
}
#endif
#if !defined(HAVE_ISWBLANK) && defined(ENABLE_UTF8)
/* This function is equivalent to iswblank(). */
bool niswblank(wchar_t wc)
{
return iswspace(wc) && (wc == '\t' || !is_cntrl_wchar(wc));
}
#endif
/* Return TRUE if the value of c is in byte range, and FALSE otherwise. */
bool is_byte(int c)
{
@@ -91,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;
}
@@ -111,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;
}
@@ -131,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;
}
@@ -179,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;
}
@@ -208,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';
@@ -255,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) {
@@ -286,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;
}
@@ -309,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
@@ -330,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. */
@@ -353,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) {
@@ -390,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;
@@ -414,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
@@ -425,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);
@@ -450,36 +401,12 @@ size_t move_mbright(const char *buf, size_t pos)
return pos + parse_mbchar(buf + pos, NULL, NULL);
}
#ifndef HAVE_STRCASECMP
/* This function is equivalent to strcasecmp(). */
int nstrcasecmp(const char *s1, const char *s2)
{
return strncasecmp(s1, s2, HIGHEST_POSITIVE);
}
#endif
/* This function is equivalent to strcasecmp() for multibyte strings. */
int mbstrcasecmp(const char *s1, const char *s2)
{
return mbstrncasecmp(s1, s2, HIGHEST_POSITIVE);
}
#ifndef HAVE_STRNCASECMP
/* This function is equivalent to strncasecmp(). */
int nstrncasecmp(const char *s1, const char *s2, size_t n)
{
if (s1 == s2)
return 0;
for (; *s1 != '\0' && *s2 != '\0' && n > 0; s1++, s2++, n--) {
if (tolower(*s1) != tolower(*s2))
break;
}
return (n > 0) ? tolower(*s1) - tolower(*s2) : 0;
}
#endif
/* This function is equivalent to strncasecmp() for multibyte strings. */
int mbstrncasecmp(const char *s1, const char *s2, size_t n)
{
@@ -490,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;
}
@@ -524,39 +451,12 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
return strncasecmp(s1, s2, n);
}
#ifndef HAVE_STRCASESTR
/* This function is equivalent to strcasestr(). */
char *nstrcasestr(const char *haystack, const char *needle)
{
size_t needle_len;
if (*needle == '\0')
return (char *)haystack;
needle_len = strlen(needle);
while (*haystack != '\0') {
if (strncasecmp(haystack, needle, needle_len) == 0)
return (char *)haystack;
haystack++;
}
return NULL;
}
#endif
/* This function is equivalent to strcasestr() for multibyte strings. */
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)
@@ -572,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;
@@ -598,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. */
@@ -665,19 +547,6 @@ size_t mbstrlen(const char *s)
return mbstrnlen(s, (size_t)-1);
}
#ifndef HAVE_STRNLEN
/* This function is equivalent to strnlen(). */
size_t nstrnlen(const char *s, size_t maxlen)
{
size_t n = 0;
for (; *s != '\0' && maxlen > 0; s++, maxlen--, n++)
;
return n;
}
#endif
/* This function is equivalent to strnlen() for multibyte strings. */
size_t mbstrnlen(const char *s, size_t maxlen)
{
@@ -699,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;
@@ -757,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 */
@@ -815,7 +677,7 @@ char *mbrevstrpbrk(const char *s, const char *accept, const char
bool has_blank_chars(const char *s)
{
for (; *s != '\0'; s++) {
if (isblank(*s))
if (isblank((unsigned char)*s))
return TRUE;
}
@@ -828,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)
{
@@ -225,6 +224,7 @@ void do_copy_text(void)
/* Remember the current viewport and cursor position. */
ssize_t is_edittop_lineno = openfile->edittop->lineno;
size_t is_firstcolumn = openfile->firstcolumn;
ssize_t is_current_lineno = openfile->current->lineno;
size_t is_current_x = openfile->current_x;
@@ -239,6 +239,7 @@ void do_copy_text(void)
if (mark_set) {
/* Restore the viewport and cursor position. */
openfile->edittop = fsfromline(is_edittop_lineno);
openfile->firstcolumn = is_firstcolumn;
openfile->current = fsfromline(is_current_lineno);
openfile->current_x = is_current_x;
}
@@ -253,10 +254,13 @@ 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;
/* The line number where we started the paste. */
size_t was_leftedge = 0;
/* The leftedge where we started the paste. */
/* If the cutbuffer is empty, there is nothing to do. */
if (cutbuffer == NULL)
@@ -264,9 +268,12 @@ void do_uncut_text(void)
#ifndef NANO_TINY
add_undo(PASTE);
if (ISSET(SOFTWRAP))
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);
@@ -274,7 +281,8 @@ void do_uncut_text(void)
update_undo(PASTE);
#endif
if (openfile->current->lineno - was_lineno < editwinrows)
/* If we pasted less than a screenful, don't center the cursor. */
if (less_than_a_screenful(was_lineno, was_leftedge))
focusing = FALSE;
/* Set the desired x position to where the pasted text ends. */
@@ -283,10 +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();
ensure_line_is_visible();
/* 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 *
@@ -29,7 +28,9 @@
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#include <libgen.h>
#define LOCKBUFSIZE 8192
@@ -61,37 +62,33 @@ 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();
openfile->current_x = 0;
openfile->placewewant = 0;
openfile->current_y = 0;
@@ -117,11 +114,9 @@ void make_new_buffer(void)
#endif
}
/* Initialize the text of the current openfile struct. */
/* Initialize the text and pointers of the current openfile struct. */
void initialize_buffer_text(void)
{
assert(openfile != NULL);
openfile->fileage = make_new_node(NULL);
openfile->fileage->data = mallocstrcpy(NULL, "");
@@ -129,6 +124,8 @@ void initialize_buffer_text(void)
openfile->edittop = openfile->fileage;
openfile->current = openfile->fileage;
openfile->firstcolumn = 0;
openfile->current_x = 0;
openfile->totsize = 0;
}
@@ -146,13 +143,9 @@ void set_modified(void)
if (!ISSET(LOCKING) || openfile->filename[0] == '\0')
return;
if (openfile->lock_filename == NULL) {
/* TRANSLATORS: Keep the next ten messages at most 76 characters. */
// statusline(ALERT, _("Warning: Modifying a file which is not locked,"
// " check directory permission?"));
;
} else {
if (openfile->lock_filename != NULL) {
char *fullname = get_full_path(openfile->filename);
write_lockfile(openfile->lock_filename, fullname, TRUE);
free(fullname);
}
@@ -172,6 +165,7 @@ void set_modified(void)
* Returns 1 on success, and 0 on failure (but continue anyway). */
int write_lockfile(const char *lockfilename, const char *origfilename, bool modified)
{
#ifdef HAVE_PWD_H
int cflags, fd;
FILE *filestream;
pid_t mypid;
@@ -188,6 +182,7 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
/* First run things that might fail before blowing away the old state. */
if ((mypwuid = getpwuid(myuid)) == NULL) {
/* TRANSLATORS: Keep the next eight messages at most 76 characters. */
statusline(MILD, _("Couldn't determine my identity for lock file "
"(getpwuid() failed)"));
goto free_the_data;
@@ -287,6 +282,9 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
free_the_data:
free(lockdata);
return 0;
#else
return 1;
#endif
}
/* Delete the lockfile. Return -1 if unsuccessful, and 1 otherwise. */
@@ -467,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);
@@ -486,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. */
@@ -548,30 +546,61 @@ void replace_buffer(const char *filename)
/* Put current at a place that is certain to exist. */
openfile->current = openfile->fileage;
}
#ifndef NANO_TINY
/* Open the specified file, and if that succeeds, blow away the text of
* the current buffer at the given coordinates and read the file
* contents into its place. */
void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
filestruct *bot, size_t bot_x)
{
FILE *f;
int descriptor;
bool old_no_newlines = ISSET(NO_NEWLINES);
filestruct *trash_top = NULL;
filestruct *trash_bot = NULL;
descriptor = open_file(filename, FALSE, TRUE, &f);
if (descriptor < 0)
return;
/* Don't add a magicline when replacing text in the buffer. */
SET(NO_NEWLINES);
/* Throw away the text under the mark, and insert the processed file
* where the marked text was. */
extract_buffer(&trash_top, &trash_bot, top, top_x, bot, bot_x);
free_filestruct(trash_top);
read_file(f, descriptor, filename, FALSE, TRUE);
/* Restore the magicline behavior now that we're done fiddling. */
if (!old_no_newlines)
UNSET(NO_NEWLINES);
}
#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)
@@ -579,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;
}
@@ -591,13 +620,22 @@ void switch_to_prevnext_buffer(bool to_next)
fprintf(stderr, "filename is %s\n", openfile->filename);
#endif
/* Update the screen to account for the current buffer. */
display_buffer();
#ifndef NANO_TINY
/* When not in softwrap mode, make sure firstcolumn is zero. It might
* be nonzero if we had softwrap mode on while in this buffer, and then
* turned softwrap mode off while in a different buffer. */
if (!ISSET(SOFTWRAP))
openfile->firstcolumn = 0;
#endif
/* 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);
@@ -645,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)
@@ -686,44 +724,14 @@ int is_file_writable(const char *filename)
return result;
}
/* Make a new line of text from the given buf, which is of length buf_len.
* Then attach this line after prevnode. */
filestruct *read_line(char *buf, size_t buf_len, filestruct *prevnode)
/* Encode any NUL bytes in the given line of text, which is of length buf_len,
* and return a dynamically allocated copy of the resultant string. */
char *encode_data(char *buf, size_t buf_len)
{
filestruct *freshline = (filestruct *)nmalloc(sizeof(filestruct));
/* Convert nulls to newlines. buf_len is the string's real length. */
unsunder(buf, buf_len);
buf[buf_len] = '\0';
assert(openfile->fileage != NULL && strlen(buf) == buf_len);
#ifndef NANO_TINY
/* If file conversion isn't disabled, strip a '\r' from the line. */
if (buf_len > 0 && buf[buf_len - 1] == '\r' && !ISSET(NO_CONVERT))
buf[buf_len - 1] = '\0';
#endif
freshline->data = mallocstrcpy(NULL, buf);
#ifndef DISABLE_COLOR
freshline->multidata = NULL;
#endif
freshline->prev = prevnode;
if (prevnode == NULL) {
/* Special case: we're inserting into the first line. */
freshline->next = openfile->fileage;
openfile->fileage = freshline;
freshline->lineno = 1;
} else {
prevnode->next = freshline;
freshline->next = NULL;
freshline->lineno = prevnode->lineno + 1;
}
return freshline;
return mallocstrcpy(NULL, buf);
}
/* Read an open file into the current buffer. f should be set to the
@@ -734,6 +742,10 @@ filestruct *read_line(char *buf, size_t buf_len, filestruct *prevnode)
void read_file(FILE *f, int fd, const char *filename, bool undoable,
bool checkwritable)
{
ssize_t was_lineno = openfile->current->lineno;
/* The line number where we start the insertion. */
size_t was_leftedge = 0;
/* The leftedge where we start the insertion. */
size_t num_lines = 0;
/* The number of lines in the file. */
size_t len = 0;
@@ -744,8 +756,10 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
/* The buffer in which we assemble each line of the file. */
size_t bufx = MAX_BUF_SIZE;
/* The allocated size of the line buffer; increased as needed. */
filestruct *fileptr = openfile->current->prev;
/* The line after which to start inserting. */
filestruct *topline;
/* The top of the new buffer where we store the read file. */
filestruct *bottomline;
/* The bottom of the new buffer. */
int input_int;
/* The current value we read from the file, whether an input
* character or EOF. */
@@ -761,9 +775,16 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
#ifndef NANO_TINY
if (undoable)
add_undo(INSERT);
if (ISSET(SOFTWRAP))
was_leftedge = (xplustabs() / editwincols) * editwincols;
#endif
/* Read the entire file into the filestruct. */
/* Create an empty buffer. */
topline = make_new_node(NULL);
bottomline = topline;
/* Read the entire file into the new buffer. */
while ((input_int = getc(f)) != EOF) {
input = (char)input_int;
@@ -780,14 +801,6 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
if (format == 0 || format == 2)
format++;
}
#endif
/* Read in the line properly. */
fileptr = read_line(buf, len, fileptr);
num_lines++;
/* Reset the length in preparation for the next line. */
len = 0;
#ifndef NANO_TINY
/* If it's a Mac file ('\r' without '\n' on the first line if we
* think it's a *nix file, or on any line otherwise), and file
* conversion isn't disabled, handle it! */
@@ -798,15 +811,6 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
* set format to both DOS and Mac. */
if (format == 0 || format == 1)
format += 2;
/* Read in the line properly. */
fileptr = read_line(buf, len, fileptr);
num_lines++;
/* Store the character after the \r as the first character
* of the next line. */
buf[0] = input;
len = 1;
#endif
} else {
/* Store the character. */
@@ -822,7 +826,30 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
bufx += MAX_BUF_SIZE;
buf = charealloc(buf, bufx);
}
continue;
}
#ifndef NANO_TINY
/* If it's a DOS or Mac line, strip the '\r' from it. */
if (len > 0 && buf[len - 1] == '\r' && !ISSET(NO_CONVERT))
buf[--len] = '\0';
#endif
/* Store the data and make a new line. */
bottomline->data = encode_data(buf, len);
bottomline->next = make_new_node(bottomline);
bottomline = bottomline->next;
num_lines++;
/* Reset the length in preparation for the next line. */
len = 0;
#ifndef NANO_TINY
/* If it happens to be a Mac line, store the character after the \r
* as the first character of the next line. */
if (input != '\n')
buf[len++] = input;
#endif
}
/* Perhaps this could use some better handling. */
@@ -834,82 +861,51 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
writable = is_file_writable(filename);
}
/* Did we not get a newline and still have stuff to do? */
if (len > 0) {
/* If the file ended with newline, or it was entirely empty, make the
* last line blank. Otherwise, put the last read data in. */
if (len == 0)
bottomline->data = mallocstrcpy(NULL, "");
else {
bool mac_line_needs_newline = FALSE;
#ifndef NANO_TINY
/* If file conversion isn't disabled and the last character in
* this file is '\r', set format to Mac if we currently think
* the file is a *nix file, or to both DOS and Mac if we
* currently think the file is a DOS file. */
if (buf[len - 1] == '\r' && !ISSET(NO_CONVERT) && format < 2)
format += 2;
/* If the final character is '\r', and file conversion isn't disabled,
* set format to Mac if we currently think the file is a *nix file, or
* to DOS-and-Mac if we currently think it is a DOS file. */
if (buf[len - 1] == '\r' && !ISSET(NO_CONVERT)) {
if (format < 2)
format += 2;
/* Strip the carriage return. */
buf[--len] = '\0';
/* Indicate we need to put a blank line in after this one. */
mac_line_needs_newline = TRUE;
}
#endif
/* Read in the last line properly. */
fileptr = read_line(buf, len, fileptr);
/* Store the data of the final line. */
bottomline->data = encode_data(buf, len);
num_lines++;
if (mac_line_needs_newline) {
bottomline->next = make_new_node(bottomline);
bottomline = bottomline->next;
bottomline->data = mallocstrcpy(NULL, "");
}
}
free(buf);
/* Attach the file we got to the filestruct. If we got a file of
* zero bytes, don't do anything. */
if (num_lines > 0) {
/* If the file we got doesn't end in a newline (nor in a Mac return),
* tack its last line onto the beginning of the line at current. */
if (len > 0 && (input != '\r' || ISSET(NO_CONVERT))) {
filestruct *dropline = fileptr;
size_t current_len = strlen(openfile->current->data);
/* Adjust the current x-coordinate to compensate for the
* change in the current line. */
if (num_lines == 1)
openfile->current_x += len;
else
openfile->current_x = len;
/* Tack the text at fileptr onto the beginning of the text
* at current. */
openfile->current->data = charealloc(openfile->current->data,
len + current_len + 1);
charmove(openfile->current->data + len, openfile->current->data,
current_len + 1);
strncpy(openfile->current->data, fileptr->data, len);
/* Step back one line, and blow away the unterminated line,
* since its text has been copied into current. */
fileptr = fileptr->prev;
delete_node(dropline);
}
if (fileptr == NULL)
/* After inserting a single unterminated line at the top,
* readjust the top-of-file pointer. */
openfile->fileage = openfile->current;
else {
/* Attach the line at current after the line at fileptr. */
fileptr->next = openfile->current;
openfile->current->prev = fileptr;
}
/* Renumber, starting with the last line of the file we inserted. */
renumber(openfile->current);
}
openfile->totsize += get_totsize(openfile->fileage, openfile->filebot);
/* If the NO_NEWLINES flag isn't set, and text has been added to
* the magicline (i.e. a file that doesn't end in a newline has been
* inserted at the end of the current buffer), add a new magicline,
* and move the current line down to it. */
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0') {
new_magicline();
openfile->current = openfile->filebot;
openfile->current_x = 0;
}
/* Insert the just read buffer into the current one. */
ingraft_buffer(topline);
/* 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
@@ -934,7 +930,8 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
statusline(HUSH, P_("Read %lu line", "Read %lu lines",
(unsigned long)num_lines), (unsigned long)num_lines);
if (num_lines < editwinrows)
/* If we inserted less than a screenful, don't center the cursor. */
if (less_than_a_screenful(was_lineno, was_leftedge))
focusing = FALSE;
#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"));
}
@@ -1043,9 +1040,8 @@ char *get_next_filename(const char *name, const char *suffix)
sprintf(buf + wholenamelen, ".%lu", i);
}
/* We get here only if there is no possible save file. Blank out
* the filename to indicate this. */
null_at(&buf, 0);
/* There is no possible save file: blank out the filename. */
*buf = '\0';
return buf;
}
@@ -1059,7 +1055,7 @@ void do_insertfile(void)
char *given = mallocstrcpy(NULL, "");
/* The last answer the user typed at the statusbar prompt. */
#ifndef NANO_TINY
bool execute = FALSE, right_side_up = FALSE, single_line = FALSE;
bool execute = FALSE;
#endif
/* Display newlines in filenames as ^J. */
@@ -1068,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");
@@ -1078,12 +1074,12 @@ 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] ");
msg = _("File to insert into new buffer [from %s]");
else
#endif
msg = _("File to insert [from %s] ");
msg = _("File to insert [from %s]");
}
present_path = mallocstrcpy(present_path, "./");
@@ -1098,8 +1094,7 @@ void do_insertfile(void)
#endif
edit_refresh, msg,
#ifndef DISABLE_OPERATINGDIR
operating_dir != NULL && strcmp(operating_dir, ".") != 0 ?
operating_dir :
operating_dir != NULL ? operating_dir :
#endif
"./");
@@ -1109,17 +1104,15 @@ void do_insertfile(void)
statusbar(_("Cancelled"));
break;
} else {
filestruct *edittop_save = openfile->edittop;
ssize_t was_current_lineno = openfile->current->lineno;
size_t was_current_x = openfile->current_x;
bool current_was_at_top = FALSE;
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
functionptrtype func = func_from_key(&i);
#endif
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))
@@ -1152,32 +1145,9 @@ void do_insertfile(void)
if (i != 0 && (!ISSET(MULTIBUFFER) || i != -2))
continue;
#ifndef NANO_TINY
/* Keep track of whether the mark begins inside the
* partition and will need adjustment. */
if (openfile->mark_set) {
filestruct *top, *bot;
size_t top_x, bot_x;
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, &right_side_up);
single_line = (top == bot);
}
#endif
/* When not inserting into a new buffer, partition the filestruct
* so that it contains no text and hence looks like a new buffer,
* and remember whether the current line is the first on screen. */
if (!ISSET(MULTIBUFFER)) {
filepart = partition_filestruct(openfile->current,
openfile->current_x, openfile->current,
openfile->current_x);
current_was_at_top = (openfile->edittop == openfile->fileage);
}
#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);
@@ -1185,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;
@@ -1206,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)) {
@@ -1219,70 +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 */
{
filestruct *top_save = openfile->fileage;
/* If we were at the top of the edit window before, change the
* saved value of edittop to the start of inserted stuff. */
if (current_was_at_top)
edittop_save = openfile->fileage;
/* Update the current x-coordinate to account for the
* number of characters inserted on the current line.
* If the mark was positioned after the cursor and on the
* same line, adjust the mark's coordinates to compensate
* for the change in this line. */
openfile->current_x = strlen(openfile->filebot->data);
if (openfile->fileage == openfile->filebot) {
#ifndef NANO_TINY
if (openfile->mark_set) {
openfile->mark_begin = openfile->current;
if (!right_side_up)
openfile->mark_begin_x += openfile->current_x;
}
#endif
openfile->current_x += was_current_x;
}
#ifndef NANO_TINY
else if (openfile->mark_set) {
if (!right_side_up) {
if (single_line) {
openfile->mark_begin = openfile->current;
openfile->mark_begin_x -= was_current_x;
} else
openfile->mark_begin_x -= openfile->current_x;
}
}
#endif
/* Unpartition the filestruct so that it contains all
* the text again. Note that we've replaced the
* non-text originally in the partition with the text in
* the inserted file/executed command output. */
unpartition_filestruct(&filepart);
/* Renumber starting with the beginning line of the old
* partition. */
renumber(top_save);
/* Restore the old edittop. */
openfile->edittop = edittop_save;
/* Set the desired x position to the current one. */
openfile->placewewant = xplustabs();
/* 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();
ensure_line_is_visible();
/* Update current_y to account for inserted lines. */
place_the_cursor();
refresh_needed = TRUE;
}
@@ -1299,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
@@ -1319,7 +1236,7 @@ char *get_full_path(const char *origpath)
/* How often we've tried climbing back up the tree. */
struct stat fileinfo;
char *currentdir, *d_here, *d_there, *d_there_file = NULL;
const char *last_slash;
char *last_slash;
bool path_only;
if (origpath == NULL)
@@ -1385,7 +1302,7 @@ char *get_full_path(const char *origpath)
d_there_file = mallocstrcpy(NULL, last_slash + 1);
/* Remove the filename portion of the answer from d_there. */
null_at(&d_there, last_slash - d_there + 1);
*(last_slash + 1) = '\0';
/* Go to the path specified in d_there. */
if (chdir(d_there) == -1) {
@@ -1521,7 +1438,7 @@ void init_operating_dir(void)
/* If the operating directory is inaccessible, fail. */
if (full_operating_dir == NULL || chdir(full_operating_dir) == -1)
die("Invalid operating directory\n");
die(_("Invalid operating directory\n"));
snuggly_fit(&full_operating_dir);
}
@@ -1621,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);
@@ -1644,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;
@@ -1735,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. */
@@ -1833,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;
}
@@ -1870,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);
}
@@ -1947,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);
@@ -2055,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;
@@ -2131,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);
@@ -2149,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)
@@ -2282,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;
}
@@ -2442,6 +2358,7 @@ char *real_dir_from_tilde(const char *buf)
get_homedir();
tilde_dir = mallocstrcpy(NULL, homedir);
} else {
#ifdef HAVE_PWD_H
const struct passwd *userdata;
tilde_dir = mallocstrncpy(NULL, buf, i + 1);
@@ -2454,6 +2371,9 @@ char *real_dir_from_tilde(const char *buf)
endpwent();
if (userdata != NULL)
tilde_dir = mallocstrcpy(tilde_dir, userdata->pw_dir);
#else
tilde_dir = strdup("");
#endif
}
retval = charalloc(strlen(tilde_dir) + strlen(buf + i) + 1);
@@ -2544,12 +2464,14 @@ char **username_tab_completion(const char *buf, size_t *num_matches,
size_t buf_len)
{
char **matches = NULL;
const struct passwd *userdata;
assert(buf != NULL && num_matches != NULL && buf_len > 0);
*num_matches = 0;
#ifdef HAVE_PWD_H
const struct passwd *userdata;
while ((userdata = getpwent()) != NULL) {
if (strncmp(userdata->pw_name, buf + 1, buf_len - 1) == 0) {
/* Cool, found a match. Add it to the list. This makes a
@@ -2570,6 +2492,7 @@ char **username_tab_completion(const char *buf, size_t *num_matches,
}
}
endpwent();
#endif
return matches;
}
@@ -2587,7 +2510,7 @@ char **cwd_tab_completion(const char *buf, bool allow_files, size_t
const struct dirent *nextdir;
*num_matches = 0;
null_at(&dirname, buf_len);
dirname[buf_len] = '\0';
/* If there's a / in the name, split out filename and directory parts. */
slash = strrchr(dirname, '/');
@@ -2707,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
@@ -94,8 +107,6 @@ WINDOW *bottomwin;
* messages, the statusbar prompt, and a list of shortcuts. */
int editwinrows = 0;
/* How many rows does the edit window take up? */
int maxlines = 0;
/* How many file lines can be shown (due to soft wrapping). */
filestruct *cutbuffer = NULL;
/* The buffer where we store cut text. */
@@ -124,17 +135,12 @@ char *brackets = NULL;
* can end sentences. */
char *quotestr = NULL;
/* The quoting string. The default value is set in main(). */
#ifdef HAVE_REGEX_H
regex_t quotereg;
/* The compiled regular expression from the quoting string. */
int quoterc;
/* Whether it was compiled successfully. */
char *quoteerr = NULL;
/* The error message, if it didn't. */
#else
size_t quotelen;
/* The length of the quoting string in bytes. */
#endif
#endif /* !DISABLE_JUSTIFY */
char *word_chars = NULL;
@@ -212,13 +218,11 @@ poshiststruct *position_history = NULL;
/* The cursor position history list. */
#endif
#ifdef HAVE_REGEX_H
regex_t search_regexp;
/* The compiled regular expression to use in searches. */
regmatch_t regmatches[10];
/* The match positions for parenthetical subexpressions, 10
* maximum, used in regular expression searches. */
#endif
int hilite_attribute = A_REVERSE;
/* The curses attribute we use to highlight something. */
@@ -318,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
@@ -431,7 +435,7 @@ void assign_keyinfo(sc *s, const char *keystring, const int keycode)
if (strcasecmp(keystring, "M-Space") == 0)
s->keycode = (int)' ';
else
s->keycode = tolower((int)keystring[2]);
s->keycode = tolower((unsigned char)keystring[2]);
} else if (keystring[0] == 'F')
s->keycode = KEY_F0 + atoi(&keystring[1]);
else if (!strcasecmp(keystring, "Ins"))
@@ -484,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. */
@@ -493,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")
@@ -508,8 +512,12 @@ void shortcut_init(void)
#ifndef DISABLE_BROWSER
const char *nano_browser_whereis_msg = N_("Search for a string");
const char *nano_browser_refresh_msg = N_("Refresh the file list");
#ifndef NANO_TINY
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");
const char *nano_nextpage_msg = N_("Go one screenful down");
@@ -523,9 +531,9 @@ void shortcut_init(void)
#endif
const char *nano_replace_msg = N_("Replace a string or a regular expression");
const char *nano_gotoline_msg = N_("Go to line and column number");
const char *nano_whereis_next_msg = N_("Repeat the last search");
#ifndef NANO_TINY
const char *nano_mark_msg = N_("Mark text starting from the cursor position");
const char *nano_whereis_next_msg = N_("Repeat the last search");
const char *nano_copy_msg =
N_("Copy the current line and store it in the cutbuffer");
const char *nano_indent_msg = N_("Indent the current line");
@@ -558,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
@@ -598,15 +606,13 @@ void shortcut_init(void)
const char *nano_savefile_msg = N_("Save file without prompting");
const char *nano_findprev_msg = N_("Search next occurrence backward");
const char *nano_findnext_msg = N_("Search next occurrence forward");
#endif
const char *nano_case_msg =
N_("Toggle the case sensitivity of the search");
const char *nano_reverse_msg =
N_("Reverse the direction of the search");
#endif
#ifdef HAVE_REGEX_H
const char *nano_regexp_msg =
N_("Toggle the use of regular expressions");
#endif
#ifndef DISABLE_HISTORIES
const char *nano_prev_history_msg =
N_("Recall the previous search/replace string");
@@ -623,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");
@@ -644,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) ""
@@ -685,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);
@@ -711,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
@@ -761,12 +770,22 @@ void shortcut_init(void)
gotoline_tag, IFSCHELP(nano_gotoline_msg), BLANKAFTER, VIEW);
#endif
#ifndef NANO_TINY
add_to_funcs(do_undo, MMAIN,
N_("Undo"), IFSCHELP(nano_undo_msg), TOGETHER, NOVIEW);
add_to_funcs(do_redo, MMAIN,
N_("Redo"), IFSCHELP(nano_redo_msg), BLANKAFTER, NOVIEW);
add_to_funcs(do_mark, MMAIN,
N_("Mark Text"), IFSCHELP(nano_mark_msg), TOGETHER, VIEW);
add_to_funcs(do_copy_text, MMAIN,
N_("Copy Text"), IFSCHELP(nano_copy_msg), BLANKAFTER, NOVIEW);
#endif
add_to_funcs(case_sens_void, MWHEREIS|MREPLACE,
N_("Case Sens"), IFSCHELP(nano_case_msg), TOGETHER, VIEW);
#ifdef HAVE_REGEX_H
add_to_funcs(regexp_void, MWHEREIS|MREPLACE,
N_("Regexp"), IFSCHELP(nano_regexp_msg), TOGETHER, VIEW);
#endif
add_to_funcs(backwards_void, MWHEREIS|MREPLACE,
N_("Backwards"), IFSCHELP(nano_reverse_msg), TOGETHER, VIEW);
@@ -784,45 +803,23 @@ void shortcut_init(void)
gotoline_tag, IFSCHELP(nano_gotoline_msg), BLANKAFTER, VIEW);
#endif
add_to_funcs(do_page_up, MMAIN|MHELP,
prev_page_tag, IFSCHELP(nano_prevpage_msg), TOGETHER, VIEW);
add_to_funcs(do_page_down, MMAIN|MHELP,
next_page_tag, IFSCHELP(nano_nextpage_msg), TOGETHER, VIEW);
add_to_funcs(do_first_line, MMAIN|MHELP|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE,
N_("First Line"), IFSCHELP(nano_firstline_msg), TOGETHER, VIEW);
add_to_funcs(do_last_line, MMAIN|MHELP|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE,
N_("Last Line"), IFSCHELP(nano_lastline_msg), BLANKAFTER, VIEW);
#ifndef NANO_TINY
add_to_funcs(do_find_bracket, MMAIN,
N_("To Bracket"), IFSCHELP(nano_bracket_msg), BLANKAFTER, VIEW);
add_to_funcs(do_research, MMAIN,
whereis_next_tag, IFSCHELP(nano_whereis_next_msg), TOGETHER, VIEW);
add_to_funcs(do_find_bracket, MMAIN,
N_("To Bracket"), IFSCHELP(nano_bracket_msg), TOGETHER, VIEW);
add_to_funcs(do_mark, MMAIN,
N_("Mark Text"), IFSCHELP(nano_mark_msg), TOGETHER, VIEW);
add_to_funcs(do_copy_text, MMAIN,
N_("Copy Text"), IFSCHELP(nano_copy_msg), BLANKAFTER, NOVIEW);
add_to_funcs(do_indent_void, MMAIN,
N_("Indent Text"), IFSCHELP(nano_indent_msg), TOGETHER, NOVIEW);
add_to_funcs(do_unindent, MMAIN,
N_("Unindent Text"), IFSCHELP(nano_unindent_msg), BLANKAFTER, NOVIEW);
add_to_funcs(do_undo, MMAIN,
N_("Undo"), IFSCHELP(nano_undo_msg), TOGETHER, NOVIEW);
add_to_funcs(do_redo, MMAIN,
N_("Redo"), IFSCHELP(nano_redo_msg), BLANKAFTER, NOVIEW);
add_to_funcs(do_findprevious, MMAIN,
N_("Previous"), IFSCHELP(nano_findprev_msg), TOGETHER, VIEW);
add_to_funcs(do_findnext, MMAIN,
N_("Next"), IFSCHELP(nano_findnext_msg), BLANKAFTER, VIEW);
#endif /* !NANO_TINY */
add_to_funcs(do_left, MMAIN,
N_("Back"), IFSCHELP(nano_back_msg), TOGETHER, VIEW);
add_to_funcs(do_right, MMAIN,
N_("Forward"), IFSCHELP(nano_forward_msg), TOGETHER, VIEW);
#ifndef DISABLE_BROWSER
add_to_funcs(do_left, MBROWSER,
N_("Back"), IFSCHELP(nano_backfile_msg), TOGETHER, VIEW);
@@ -835,28 +832,15 @@ void shortcut_init(void)
add_to_funcs(do_next_word_void, MMAIN,
N_("Next Word"), IFSCHELP(nano_nextword_msg), TOGETHER, VIEW);
add_to_funcs(do_home, MMAIN,
add_to_funcs(do_home_void, MMAIN,
N_("Home"), IFSCHELP(nano_home_msg), TOGETHER, VIEW);
add_to_funcs(do_end, MMAIN,
N_("End"), IFSCHELP(nano_end_msg), TOGETHER, VIEW);
add_to_funcs(do_end_void, MMAIN,
N_("End"), IFSCHELP(nano_end_msg), BLANKAFTER, VIEW);
add_to_funcs(do_up_void, MMAIN|MBROWSER,
prev_line_tag, IFSCHELP(nano_prevline_msg), TOGETHER, VIEW);
add_to_funcs(do_down_void, MMAIN|MBROWSER,
next_line_tag, IFSCHELP(nano_nextline_msg), BLANKAFTER, VIEW);
add_to_funcs(do_prev_block, MMAIN,
N_("Prev Block"), IFSCHELP(nano_prevblock_msg), TOGETHER, VIEW);
add_to_funcs(do_next_block, MMAIN,
N_("Next Block"), IFSCHELP(nano_nextblock_msg), TOGETHER, VIEW);
#ifndef DISABLE_JUSTIFY
add_to_funcs(do_para_begin_void, MMAIN|MWHEREIS,
N_("Beg of Par"), IFSCHELP(nano_parabegin_msg), TOGETHER, VIEW);
add_to_funcs(do_para_end_void, MMAIN|MWHEREIS,
N_("End of Par"), IFSCHELP(nano_paraend_msg), TOGETHER, VIEW);
#endif
next_line_tag, IFSCHELP(nano_nextline_msg), TOGETHER, VIEW);
#ifndef NANO_TINY
add_to_funcs(do_scroll_up, MMAIN,
N_("Scroll Up"), IFSCHELP(nano_scrollup_msg), TOGETHER, VIEW);
@@ -864,7 +848,28 @@ void shortcut_init(void)
N_("Scroll Down"), IFSCHELP(nano_scrolldown_msg), BLANKAFTER, VIEW);
#endif
#ifndef DISABLE_MULTIBUFFER
add_to_funcs(do_prev_block, MMAIN,
N_("Prev Block"), IFSCHELP(nano_prevblock_msg), TOGETHER, VIEW);
add_to_funcs(do_next_block, MMAIN,
N_("Next Block"), IFSCHELP(nano_nextblock_msg), TOGETHER, VIEW);
#ifndef DISABLE_JUSTIFY
add_to_funcs(do_para_begin_void, MMAIN|MWHEREIS,
N_("Beg of Par"), IFSCHELP(nano_parabegin_msg), TOGETHER, VIEW);
add_to_funcs(do_para_end_void, MMAIN|MWHEREIS,
N_("End of Par"), IFSCHELP(nano_paraend_msg), BLANKAFTER, VIEW);
#endif
add_to_funcs(do_page_up, MMAIN|MHELP,
prev_page_tag, IFSCHELP(nano_prevpage_msg), TOGETHER, VIEW);
add_to_funcs(do_page_down, MMAIN|MHELP,
next_page_tag, IFSCHELP(nano_nextpage_msg), TOGETHER, VIEW);
add_to_funcs(do_first_line, MMAIN|MHELP|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE,
N_("First Line"), IFSCHELP(nano_firstline_msg), TOGETHER, VIEW);
add_to_funcs(do_last_line, MMAIN|MHELP|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE,
N_("Last Line"), IFSCHELP(nano_lastline_msg), BLANKAFTER, VIEW);
#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,
@@ -883,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,
@@ -922,12 +924,21 @@ 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);
add_to_funcs(do_suspend_void, MMAIN,
N_("Suspend"), IFSCHELP(nano_suspend_msg), BLANKAFTER, VIEW);
#ifndef NANO_TINY
add_to_funcs(do_indent_void, MMAIN,
N_("Indent Text"), IFSCHELP(nano_indent_msg), TOGETHER, NOVIEW);
add_to_funcs(do_unindent, MMAIN,
N_("Unindent Text"), IFSCHELP(nano_unindent_msg), BLANKAFTER, NOVIEW);
#endif
#ifdef ENABLE_WORDCOMPLETION
add_to_funcs(complete_a_word, MMAIN,
N_("Complete"), IFSCHELP(nano_completion_msg), TOGETHER, NOVIEW);
@@ -939,11 +950,6 @@ void shortcut_init(void)
#ifndef NANO_TINY
add_to_funcs(do_savefile, MMAIN,
N_("Save"), IFSCHELP(nano_savefile_msg), BLANKAFTER, NOVIEW);
add_to_funcs(do_findprevious, MMAIN,
N_("Previous"), IFSCHELP(nano_findprev_msg), TOGETHER, VIEW);
add_to_funcs(do_findnext, MMAIN,
N_("Next"), IFSCHELP(nano_findnext_msg), BLANKAFTER, VIEW);
#endif
#ifndef DISABLE_HISTORIES
@@ -992,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 */
@@ -1018,18 +1024,20 @@ void shortcut_init(void)
add_to_funcs(discard_buffer, MWRITEFILE,
N_("Discard buffer"), IFSCHELP(nano_discard_buffer_msg), BLANKAFTER, NOVIEW);
#if !defined(NANO_TINY) && !defined(DISABLE_BROWSER)
#ifndef DISABLE_BROWSER
add_to_funcs(do_research, MBROWSER,
whereis_next_tag, IFSCHELP(nano_whereis_next_msg), TOGETHER, VIEW);
#endif
#ifndef DISABLE_BROWSER
add_to_funcs(total_refresh, MBROWSER,
refresh_tag, IFSCHELP(nano_browser_refresh_msg), BLANKAFTER, VIEW);
#ifndef NANO_TINY
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
@@ -1043,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);
@@ -1052,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);
@@ -1082,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);
@@ -1110,38 +1122,42 @@ 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);
}
add_to_sclist(MMOST, "M-Space", 0, do_prev_word_void, 0);
add_to_sclist(MMOST, "^Space", 0, do_next_word_void, 0);
add_to_sclist((MMOST & ~MBROWSER), "^A", 0, do_home, 0);
add_to_sclist((MMOST & ~MBROWSER), "Home", KEY_HOME, do_home, 0);
add_to_sclist((MMOST & ~MBROWSER), "^E", 0, do_end, 0);
add_to_sclist((MMOST & ~MBROWSER), "End", KEY_END, do_end, 0);
add_to_sclist((MMOST & ~MBROWSER), "^A", 0, do_home_void, 0);
add_to_sclist((MMOST & ~MBROWSER), "Home", KEY_HOME, do_home_void, 0);
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);
@@ -1157,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);
@@ -1177,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);
@@ -1200,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);
@@ -1228,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);
@@ -1249,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);
@@ -1330,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");
@@ -1381,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
@@ -1500,9 +1531,9 @@ sc *strtosc(const char *input)
!strcasecmp(input, "nextline"))
s->scfunc = do_down_void;
else if (!strcasecmp(input, "home"))
s->scfunc = do_home;
s->scfunc = do_home_void;
else if (!strcasecmp(input, "end"))
s->scfunc = do_end;
s->scfunc = do_end_void;
else if (!strcasecmp(input, "pageup") ||
!strcasecmp(input, "prevpage"))
s->scfunc = do_page_up;
@@ -1513,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"))
@@ -1551,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"))
@@ -1561,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;
@@ -1587,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"))
@@ -1614,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
@@ -1659,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
@@ -1697,11 +1728,9 @@ void thanks_for_all_the_fish(void)
free(word_chars);
#ifndef DISABLE_JUSTIFY
free(quotestr);
#ifdef HAVE_REGEX_H
regfree(&quotereg);
free(quoteerr);
#endif
#endif
#ifndef NANO_TINY
free(backup_dir);
#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,8 +575,19 @@ 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':
case 'q':
case 'X':
case 'x':
return do_exit;
}
}
@@ -521,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 *
@@ -44,97 +43,99 @@ void do_last_line(void)
/* Set the last line of the screen as the target for the cursor. */
openfile->current_y = editwinrows - 1;
ensure_line_is_visible();
refresh_needed = TRUE;
focusing = FALSE;
}
/* Move up one page. */
/* Determine the actual current chunk and the target column. */
void get_edge_and_target(size_t *leftedge, size_t *target_column)
{
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
size_t realspan = strlenpt(openfile->current->data);
if (openfile->placewewant < realspan)
realspan = openfile->placewewant;
*leftedge = (realspan / editwincols) * editwincols;
*target_column = openfile->placewewant % editwincols;
} else
#endif
{
*leftedge = 0;
*target_column = openfile->placewewant;
}
}
/* Move up nearly one screenful. */
void do_page_up(void)
{
int i, mustmove, skipped = 0;
int mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
size_t leftedge, target_column;
/* If the cursor is less than a page away from the top of the file,
* put it at the beginning of the first line. */
if (openfile->current->lineno == 1 || (!ISSET(SOFTWRAP) &&
openfile->current->lineno <= editwinrows - 2)) {
/* If we're not in smooth scrolling mode, put the cursor at the
* beginning of the top line of the edit window, as Pico does. */
if (!ISSET(SMOOTH_SCROLL)) {
openfile->current = openfile->edittop;
openfile->placewewant = openfile->firstcolumn;
openfile->current_y = 0;
}
get_edge_and_target(&leftedge, &target_column);
/* Move up the required number of lines or chunks. If we can't, we're
* at the top of the file, so put the cursor there and get out. */
if (go_back_chunks(mustmove, &openfile->current, &leftedge) > 0) {
do_first_line();
return;
}
/* If we're not in smooth scrolling mode, put the cursor at the
* beginning of the top line of the edit window, as Pico does. */
if (!ISSET(SMOOTH_SCROLL)) {
openfile->current = openfile->edittop;
openfile->placewewant = openfile->current_y = 0;
}
mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
for (i = mustmove; i - skipped > 0 && openfile->current != openfile->fileage; i--) {
openfile->current = openfile->current->prev;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP) && openfile->current) {
skipped += strlenpt(openfile->current->data) / editwincols;
#ifdef DEBUG
fprintf(stderr, "paging up: i = %d, skipped = %d based on line %ld len %lu\n",
i, skipped, (long)openfile->current->lineno, (unsigned long)strlenpt(openfile->current->data));
#endif
}
#endif
}
openfile->placewewant = leftedge + target_column;
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;
}
/* Move down one page. */
/* Move down nearly one screenful. */
void do_page_down(void)
{
int i, mustmove;
/* If the cursor is less than a page away from the bottom of the file,
* put it at the end of the last line. */
if (openfile->current->lineno + maxlines - 2 >= openfile->filebot->lineno) {
do_last_line();
return;
}
int mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
size_t leftedge, target_column;
/* If we're not in smooth scrolling mode, put the cursor at the
* beginning of the top line of the edit window, as Pico does. */
if (!ISSET(SMOOTH_SCROLL)) {
openfile->current = openfile->edittop;
openfile->placewewant = openfile->current_y = 0;
openfile->placewewant = openfile->firstcolumn;
openfile->current_y = 0;
}
mustmove = (maxlines < 3) ? 1 : maxlines - 2;
for (i = mustmove; i > 0 && openfile->current != openfile->filebot; i--) {
openfile->current = openfile->current->next;
#ifdef DEBUG
fprintf(stderr, "paging down: moving to line %lu\n", (unsigned long)openfile->current->lineno);
#endif
get_edge_and_target(&leftedge, &target_column);
/* Move down the required number of lines or chunks. If we can't, we're
* at the bottom of the file, so put the cursor there and get out. */
if (go_forward_chunks(mustmove, &openfile->current, &leftedge) > 0) {
do_last_line();
return;
}
openfile->placewewant = leftedge + target_column;
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;
@@ -146,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);
@@ -159,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;
@@ -183,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);
@@ -237,15 +235,13 @@ 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;
assert(openfile->current != NULL && openfile->current->data != NULL);
/* Move backward until we pass over the start of a word. */
while (TRUE) {
/* If at the head of a line, move to the end of the preceding one. */
@@ -278,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);
}
@@ -293,18 +288,16 @@ 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 +
openfile->current_x, allow_punct);
bool seen_space = !started_on_word;
assert(openfile->current != NULL && openfile->current->data != NULL);
/* Move forward until we reach the start of a word. */
while (TRUE) {
/* If at the end of a line, move to the beginning of the next one. */
@@ -330,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);
}
@@ -347,193 +339,218 @@ void do_next_word_void(void)
do_next_word(ISSET(WORD_BOUNDS), TRUE);
}
/* Make sure that the current line, when it is partially scrolled off the
* screen in softwrap mode, is scrolled fully into view. */
void ensure_line_is_visible(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'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 = openfile->placewewant;
bool moved_off_chunk = TRUE;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP) && strlenpt(openfile->current->data) / editwincols +
openfile->current_y >= editwinrows) {
adjust_viewport(ISSET(SMOOTH_SCROLL) ? FLOWING : CENTERING);
refresh_needed = TRUE;
bool moved = FALSE;
size_t leftedge_x = 0;
if (ISSET(SOFTWRAP))
leftedge_x = actual_x(openfile->current->data,
(was_column / editwincols) * editwincols);
if (ISSET(SMART_HOME) && be_clever) {
size_t indent_x = indent_length(openfile->current->data);
if (openfile->current->data[indent_x] != '\0') {
/* If we're exactly on the indent, move fully home. Otherwise,
* when not softwrapping or not after the first nonblank chunk,
* move to the first nonblank character. */
if (openfile->current_x == indent_x) {
openfile->current_x = 0;
moved = TRUE;
} else if (!ISSET(SOFTWRAP) || leftedge_x <= indent_x) {
openfile->current_x = indent_x;
moved = TRUE;
}
}
}
#endif
}
/* Move to the beginning of the current line. If the SMART_HOME flag is
* set, move to the first non-whitespace character of the current line
* if we aren't already there, or to the beginning of the current line
* if we are. */
void do_home(void)
{
size_t was_column = xplustabs();
#ifndef NANO_TINY
if (ISSET(SMART_HOME)) {
size_t current_x_save = openfile->current_x;
openfile->current_x = indent_length(openfile->current->data);
if (openfile->current_x == current_x_save ||
openfile->current->data[openfile->current_x] == '\0')
if (!moved && ISSET(SOFTWRAP)) {
/* If already at the left edge of the screen, move fully home.
* Otherwise, move to the left edge. */
if (was_column % editwincols == 0 && be_clever)
openfile->current_x = 0;
} else
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 (need_horizontal_scroll(was_column, openfile->placewewant))
/* If we changed chunk, we might be offscreen. Otherwise,
* update current if the mark is on or we changed "page". */
if (ISSET(SOFTWRAP) && moved_off_chunk) {
focusing = FALSE;
edit_redraw(was_current);
} else if (line_needs_update(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x);
}
/* Move to the end of the current line. */
void do_end(void)
/* Do a (smart or dynamic) home. */
void do_home_void(void)
{
size_t was_column = xplustabs();
openfile->current_x = strlen(openfile->current->data);
openfile->placewewant = xplustabs();
if (need_horizontal_scroll(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x);
ensure_line_is_visible();
do_home(TRUE);
}
/* If scroll_only is FALSE, move up one line. If scroll_only is TRUE,
* scroll up one line without scrolling the cursor. */
/* Move to the end of the current line (or softwrapped chunk).
* If be_clever is TRUE, do a dynamic end when in softwrap mode and
* it's possible. If be_clever is FALSE, just do a simple end. */
void do_end(bool be_clever)
{
filestruct *was_current = openfile->current;
size_t was_column = openfile->placewewant;
size_t line_len = strlen(openfile->current->data);
bool moved_off_chunk = TRUE;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
size_t rightedge_x = actual_x(openfile->current->data,
((was_column / editwincols) * editwincols) +
(editwincols - 1));
/* If already at the right edge of the screen, move fully to
* the end of the line. Otherwise, move to the right edge. */
if (openfile->current_x == rightedge_x && be_clever)
openfile->current_x = line_len;
else {
openfile->current_x = rightedge_x;
moved_off_chunk = FALSE;
}
} else
#endif
openfile->current_x = line_len;
openfile->placewewant = xplustabs();
/* If we changed chunk, we might be offscreen. Otherwise,
* update current if the mark is on or we changed "page". */
if (ISSET(SOFTWRAP) && moved_off_chunk) {
focusing = FALSE;
edit_redraw(was_current);
} else if (line_needs_update(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x);
}
/* Do a (dynamic) end. */
void do_end_void(void)
{
do_end(TRUE);
}
/* Move the cursor to the preceding line or chunk. If scroll_only is TRUE,
* also scroll the screen one row, so the cursor stays in the same spot. */
void do_up(bool scroll_only)
{
filestruct *was_current = openfile->current;
size_t was_column = xplustabs();
size_t leftedge, target_column;
/* If we're at the top of the file, or if scroll_only is TRUE and
* the top of the file is onscreen, get out. */
if (openfile->current == openfile->fileage ||
(scroll_only && openfile->edittop == openfile->fileage))
/* When just scrolling and the top of the file is onscreen, get out. */
if (scroll_only && openfile->edittop == openfile->fileage &&
openfile->firstcolumn == 0)
return;
assert(ISSET(SOFTWRAP) || openfile->current_y == openfile->current->lineno - openfile->edittop->lineno);
get_edge_and_target(&leftedge, &target_column);
/* Move the current line of the edit window up. */
openfile->current = openfile->current->prev;
/* If we can't move up one line or chunk, we're at top of file. */
if (go_back_chunks(1, &openfile->current, &leftedge) > 0)
return;
openfile->placewewant = leftedge + target_column;
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
/* When the cursor was on the first line of the edit window (or when just
* scrolling without moving the cursor), scroll the edit window up -- one
* line if we're in smooth scrolling mode, and half a page otherwise. */
if (openfile->current->next == openfile->edittop || scroll_only)
if (openfile->current_y == 0 || scroll_only)
edit_scroll(UPWARD, (ISSET(SMOOTH_SCROLL) || scroll_only) ?
1 : editwinrows / 2 + 1);
/* If the lines weren't already redrawn, see if they need to be. */
if (openfile->current_y > 0) {
/* Redraw the prior line if it was horizontally scrolled. */
if (need_horizontal_scroll(was_column, 0))
/* Redraw the prior line if it's not offscreen, and it's not the same
* line as the current one, and the line was horizontally scrolled. */
if ((!scroll_only || openfile->current_y < editwinrows - 1) &&
openfile->current != was_current &&
line_needs_update(was_column, 0))
update_line(openfile->current->next, 0);
/* Redraw the current line if it needs to be horizontally scrolled. */
if (need_horizontal_scroll(0, xplustabs()))
if (line_needs_update(0, xplustabs()))
update_line(openfile->current, openfile->current_x);
}
}
/* Move up one line. */
/* Move up one line or chunk. */
void do_up_void(void)
{
do_up(FALSE);
}
/* If scroll_only is FALSE, move down one line. If scroll_only is TRUE,
* scroll down one line without scrolling the cursor. */
/* Move the cursor to next line or chunk. If scroll_only is TRUE, also
* scroll the screen one row, so the cursor stays in the same spot. */
void do_down(bool scroll_only)
{
#ifndef NANO_TINY
int amount = 0, enough;
filestruct *topline;
#endif
filestruct *was_current = openfile->current;
size_t was_column = xplustabs();
size_t leftedge, target_column;
/* If we're at the bottom of the file, get out. */
if (openfile->current == openfile->filebot)
get_edge_and_target(&leftedge, &target_column);
/* If we can't move down one line or chunk, we're at bottom of file. */
if (go_forward_chunks(1, &openfile->current, &leftedge) > 0)
return;
assert(ISSET(SOFTWRAP) || openfile->current_y ==
openfile->current->lineno - openfile->edittop->lineno);
assert(openfile->current->next != NULL);
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
/* Compute the number of lines to scroll. */
amount = strlenpt(openfile->current->data) / editwincols -
xplustabs() / editwincols +
strlenpt(openfile->current->next->data) / editwincols +
openfile->current_y - editwinrows + 2;
topline = openfile->edittop;
/* Reduce the amount when there are overlong lines at the top. */
for (enough = 1; enough < amount; enough++) {
amount -= strlenpt(topline->data) / editwincols;
if (amount > 0)
topline = topline->next;
if (amount < enough) {
amount = enough;
break;
}
}
}
#endif
/* Move to the next line in the file. */
openfile->current = openfile->current->next;
openfile->placewewant = leftedge + target_column;
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
/* When the cursor was on the last line of the edit window (or when just
* scrolling without moving the cursor), scroll the edit window down -- one
* line if we're in smooth scrolling mode, and half a page otherwise. */
#ifndef NANO_TINY
if (openfile->current_y == editwinrows - 1 || amount > 0 || scroll_only) {
if (amount < 1 || scroll_only)
amount = 1;
if (openfile->current_y == editwinrows - 1 || scroll_only)
edit_scroll(DOWNWARD, (ISSET(SMOOTH_SCROLL) || scroll_only) ?
amount : editwinrows / 2 + 1);
1 : editwinrows / 2 + 1);
if (ISSET(SOFTWRAP)) {
refresh_needed = TRUE;
return;
}
}
#else
if (openfile->current_y == editwinrows - 1)
edit_scroll(DOWNWARD, editwinrows / 2 + 1);
#endif
/* If the lines weren't already redrawn, see if they need to be. */
if (openfile->current_y < editwinrows - 1) {
/* Redraw the prior line if it was horizontally scrolled. */
if (need_horizontal_scroll(was_column, 0))
/* Redraw the prior line if it's not offscreen, and it's not the same
* line as the current one, and the line was horizontally scrolled. */
if ((!scroll_only || openfile->current_y > 0) &&
openfile->current != was_current &&
line_needs_update(was_column, 0))
update_line(openfile->current->prev, 0);
/* Redraw the current line if it needs to be horizontally scrolled. */
if (need_horizontal_scroll(0, xplustabs()))
if (line_needs_update(0, xplustabs()))
update_line(openfile->current, openfile->current_x);
}
}
/* Move down one line. */
/* Move down one line or chunk. */
void do_down_void(void)
{
do_down(FALSE);
}
#ifndef NANO_TINY
/* Scroll up one line without scrolling the cursor. */
/* Scroll up one line or chunk without scrolling the cursor. */
void do_scroll_up(void)
{
do_up(TRUE);
}
/* Scroll down one line without scrolling the cursor. */
/* Scroll down one line or chunk without scrolling the cursor. */
void do_scroll_down(void)
{
do_down(TRUE);
@@ -544,18 +561,35 @@ void do_scroll_down(void)
void do_left(void)
{
size_t was_column = xplustabs();
#ifndef NANO_TINY
size_t was_chunk = (was_column / editwincols);
filestruct *was_current = openfile->current;
#endif
if (openfile->current_x > 0)
openfile->current_x = move_mbleft(openfile->current->data,
openfile->current_x);
else if (openfile->current != openfile->fileage) {
do_up_void();
openfile->current_x = strlen(openfile->current->data);
do_end(FALSE);
return;
}
openfile->placewewant = xplustabs();
if (need_horizontal_scroll(was_column, openfile->placewewant))
#ifndef NANO_TINY
/* If we were on the first line of the edit window, and we changed chunk,
* we're now above the first line of the edit window, so scroll up. */
if (ISSET(SOFTWRAP) && openfile->current_y == 0 &&
openfile->current == was_current &&
openfile->placewewant / editwincols != was_chunk) {
edit_scroll(UPWARD, ISSET(SMOOTH_SCROLL) ? 1 : editwinrows / 2 + 1);
return;
}
#endif
/* Update current if the mark is on or it has changed "page". */
if (line_needs_update(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x);
}
@@ -563,27 +597,34 @@ void do_left(void)
void do_right(void)
{
size_t was_column = xplustabs();
assert(openfile->current_x <= strlen(openfile->current->data));
#ifndef NANO_TINY
size_t was_chunk = (was_column / editwincols);
filestruct *was_current = openfile->current;
#endif
if (openfile->current->data[openfile->current_x] != '\0')
openfile->current_x = move_mbright(openfile->current->data,
openfile->current_x);
else if (openfile->current != openfile->filebot) {
openfile->current_x = 0;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP))
openfile->current_y -= strlenpt(openfile->current->data) / editwincols;
#endif
do_home(FALSE);
do_down_void();
return;
}
openfile->placewewant = xplustabs();
if (need_horizontal_scroll(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x);
#ifndef NANO_TINY
/* If we were on the last line of the edit window, and we changed chunk,
* we're now below the first line of the edit window, so scroll down. */
if (ISSET(SOFTWRAP) && openfile->current_y == editwinrows - 1 &&
openfile->current == was_current &&
openfile->placewewant / editwincols != was_chunk) {
edit_scroll(DOWNWARD, ISSET(SMOOTH_SCROLL) ? 1 : editwinrows / 2 + 1);
return;
}
#endif
if (openfile->current_x == 0)
do_down_void();
else
ensure_line_is_visible();
/* Update current if the mark is on or it has changed "page". */
if (line_needs_update(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x);
}

File diff suppressed because it is too large Load Diff

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 *
@@ -49,9 +48,7 @@
#include <sys/param.h>
#endif
#ifdef HAVE_STDARG_H
#include <stdarg.h>
#endif
/* Suppress warnings for __attribute__((warn_unused_result)). */
#define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0)
@@ -70,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
@@ -116,50 +120,14 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#ifdef HAVE_REGEX_H
#include <regex.h>
#endif
#include <signal.h>
#include <assert.h>
/* If no vsnprintf(), use the version from glib 2.x. */
#ifndef HAVE_VSNPRINTF
#include <glib.h>
#define vsnprintf g_vsnprintf
#endif
/* If no isblank(), iswblank(), strcasecmp(), strncasecmp(),
* strcasestr(), strnlen(), getdelim(), or getline(), use the versions
* we have. */
#ifndef HAVE_ISBLANK
#define isblank nisblank
#endif
#ifndef HAVE_ISWBLANK
#define iswblank niswblank
#endif
#ifndef HAVE_STRCASECMP
#define strcasecmp nstrcasecmp
#endif
#ifndef HAVE_STRNCASECMP
#define strncasecmp nstrncasecmp
#endif
#ifndef HAVE_STRCASESTR
#define strcasestr nstrcasestr
#endif
#ifndef HAVE_STRNLEN
#define strnlen nstrnlen
#endif
#ifndef HAVE_GETDELIM
#define getdelim ngetdelim
#endif
#ifndef HAVE_GETLINE
#define getline ngetline
#endif
/* 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)
@@ -391,6 +359,9 @@ typedef struct openfilestruct {
/* The current line for this file. */
size_t totsize;
/* The file's total number of characters. */
size_t firstcolumn;
/* The starting column of the top line of the edit window.
* When not in softwrap mode, it's always zero. */
size_t current_x;
/* The file's x-coordinate position. */
size_t placewewant;
@@ -471,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;
@@ -509,7 +480,7 @@ enum
{
DONTUSE,
CASE_SENSITIVE,
CONST_UPDATE,
CONSTANT_SHOW,
NO_HELP,
SUSPEND,
NO_WRAP,
@@ -547,7 +518,8 @@ enum
MAKE_IT_UNIX,
JUSTIFY_TRIM,
SHOW_CURSOR,
LINE_NUMBERS
LINE_NUMBERS,
NO_PAUSES
};
/* Flags for the menus in which a given function should be present. */
@@ -566,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
@@ -580,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) {
@@ -125,9 +124,9 @@ int do_statusbar_input(bool *ran_func, bool *finished)
else if (s->scfunc == do_next_word_void)
do_statusbar_next_word();
#endif
else if (s->scfunc == do_home)
else if (s->scfunc == do_home_void)
do_statusbar_home();
else if (s->scfunc == do_end)
else if (s->scfunc == do_end_void)
do_statusbar_end();
/* When in restricted mode at the "Write File" prompt and the
* filename isn't blank, disallow any input and deletion. */
@@ -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();
@@ -296,7 +294,7 @@ void do_statusbar_cut_text(void)
if (!ISSET(CUT_TO_END))
statusbar_x = 0;
null_at(&answer, statusbar_x);
answer[statusbar_x] = '\0';
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,12 +618,12 @@ 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>". */
null_at(&prompt, actual_x(prompt, (COLS < 5) ? 0 : COLS - 5));
prompt[actual_x(prompt, (COLS < 5) ? 0 : COLS - 5)] = '\0';
func = acquire_an_answer(&retval, allow_tabs, allow_files, &listed,
#ifndef DISABLE_HISTORIES
@@ -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;
@@ -76,7 +89,6 @@ extern WINDOW *topwin;
extern WINDOW *edit;
extern WINDOW *bottomwin;
extern int editwinrows;
extern int maxlines;
extern filestruct *cutbuffer;
extern filestruct *cutbottom;
@@ -100,13 +112,9 @@ extern const char *unjust_tag;
extern char *punct;
extern char *brackets;
extern char *quotestr;
#ifdef HAVE_REGEX_H
extern regex_t quotereg;
extern int quoterc;
extern char *quoteerr;
#else
extern size_t quotelen;
#endif
#endif /* !DISABLE_JUSTIFY */
extern char *word_chars;
@@ -154,10 +162,8 @@ extern filestruct *replacebot;
extern poshiststruct *position_history;
#endif
#ifdef HAVE_REGEX_H
extern regex_t search_regexp;
extern regmatch_t regmatches[10];
#endif
extern int hilite_attribute;
#ifndef DISABLE_COLOR
@@ -169,22 +175,18 @@ 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);
void do_last_file(void);
char *striponedir(const char *path);
char *strip_last_component(const char *path);
#endif
/* Most functions in chars.c. */
@@ -193,65 +195,37 @@ void utf8_init(void);
bool using_utf8(void);
#endif
char *addstrings(char* str1, size_t len1, char* str2, size_t len2);
#ifndef HAVE_ISBLANK
bool nisblank(int c);
#endif
#if !defined(HAVE_ISWBLANK) && defined(ENABLE_UTF8)
bool niswblank(wchar_t wc);
#endif
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);
size_t move_mbright(const char *buf, size_t pos);
#ifndef HAVE_STRCASECMP
int nstrcasecmp(const char *s1, const char *s2);
#endif
int mbstrcasecmp(const char *s1, const char *s2);
#ifndef HAVE_STRNCASECMP
int nstrncasecmp(const char *s1, const char *s2, size_t n);
#endif
int mbstrncasecmp(const char *s1, const char *s2, size_t n);
#ifndef HAVE_STRCASESTR
char *nstrcasestr(const char *haystack, const char *needle);
#endif
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);
#ifndef HAVE_STRNLEN
size_t nstrnlen(const char *s, size_t maxlen);
#endif
size_t mbstrnlen(const char *s, size_t maxlen);
#if !defined(NANO_TINY) || !defined(DISABLE_JUSTIFY)
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
@@ -271,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);
@@ -289,26 +260,27 @@ 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
void replace_buffer(const char *filename);
#ifndef NANO_TINY
void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
filestruct *bot, size_t bot_x);
#endif
void display_buffer(void);
#ifndef DISABLE_MULTIBUFFER
#endif
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
filestruct *read_line(char *buf, size_t buf_len, filestruct *prevnode);
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);
@@ -319,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
@@ -337,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);
@@ -379,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);
@@ -393,20 +359,21 @@ 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 ensure_line_is_visible(void);
void do_home(void);
void do_end(void);
void do_home(bool be_clever);
void do_home_void(void);
void do_end(bool be_clever);
void do_end_void(void);
void do_up(bool scroll_only);
void do_up_void(void);
void do_down(bool scroll_only);
@@ -418,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);
@@ -439,28 +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_full(const char *shortflag
#ifdef HAVE_GETOPT_LONG
, const char *longflag
#endif
, 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);
@@ -477,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,
@@ -503,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,
@@ -514,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);
@@ -526,14 +475,9 @@ void parse_rcfile(FILE *rcstream, bool syntax_only);
void do_rcfiles(void);
#endif /* !DISABLE_NANORC */
/* All functions in search.c. */
#ifdef HAVE_REGEX_H
bool regexp_init(const char *regexp);
void regexp_cleanup(void);
#endif
/* 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);
@@ -543,10 +487,6 @@ void do_findnext(void);
#endif
void do_research(void);
void go_looking(void);
#ifdef HAVE_REGEX_H
int replace_regexp(char *string, bool create);
#endif
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);
@@ -555,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);
@@ -565,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);
@@ -574,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
@@ -612,35 +549,21 @@ void update_undo(undo_type action);
void wrap_reset(void);
bool do_wrap(filestruct *line);
#endif
#if !defined(DISABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
ssize_t break_line(const char *line, ssize_t goal
#ifndef DISABLE_HELP
, bool newln
#endif
);
#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)
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
@@ -664,17 +587,7 @@ void snuggly_fit(char **str);
void null_at(char **data, size_t index);
void unsunder(char *str, size_t true_len);
void sunder(char *str);
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
#ifndef HAVE_GETLINE
ssize_t ngetline(char **lineptr, size_t *n, FILE *stream);
#endif
#ifndef HAVE_GETDELIM
ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream);
#endif
#endif
#ifdef HAVE_REGEX_H
const char *fixbounds(const char *r);
#endif
#ifndef DISABLE_SPELLER
bool is_separate_word(size_t position, size_t length, const char *buf);
#endif
@@ -692,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
@@ -709,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);
@@ -744,19 +650,26 @@ 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);
bool need_horizontal_scroll(const size_t old_column, const size_t new_column);
#ifndef NANO_TINY
int update_softwrapped_line(filestruct *fileptr);
#endif
bool line_needs_update(const size_t old_column, const size_t new_column);
int go_back_chunks(int nrows, filestruct **line, size_t *leftedge);
int go_forward_chunks(int nrows, filestruct **line, size_t *leftedge);
bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge);
void edit_scroll(scroll_dir direction, int nrows);
void ensure_firstcolumn_is_aligned(void);
void edit_redraw(filestruct *old_current);
void edit_refresh(void);
void adjust_viewport(update_type location);
void total_redraw(void);
void total_refresh(void);
void display_main_list(void);
void do_cursorpos(bool constant);
void do_cursorpos(bool force);
void do_cursorpos_void(void);
void spotlight(bool active, const char *word);
void xon_complaint(void);

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,14 +53,15 @@ 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},
{"nonewlines", NO_NEWLINES},
{"nopauses", NO_PAUSES},
#ifndef DISABLE_WRAPPING
{"nowrap", NO_WRAP},
#endif
@@ -77,11 +77,10 @@ static const rcoption rcopts[] = {
{"punct", 0},
{"quotestr", 0},
#endif
{"quickblank", QUICK_BLANK},
{"rebinddelete", REBIND_DELETE},
{"rebindkeypad", REBIND_KEYPAD},
#ifdef HAVE_REGEX_H
{"regexp", USE_REGEXP},
#endif
#ifndef DISABLE_SPELLER
{"speller", 0},
#endif
@@ -101,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},
@@ -169,7 +167,7 @@ void rcfile_error(const char *msg, ...)
* returned pointer will point to '\0' if we hit the end of the line. */
char *parse_next_word(char *ptr)
{
while (!isblank(*ptr) && *ptr != '\0')
while (!isblank((unsigned char)*ptr) && *ptr != '\0')
ptr++;
if (*ptr == '\0')
@@ -178,7 +176,7 @@ char *parse_next_word(char *ptr)
/* Null-terminate and advance ptr. */
*ptr++ = '\0';
while (isblank(*ptr))
while (isblank((unsigned char)*ptr))
ptr++;
return ptr;
@@ -217,7 +215,7 @@ char *parse_argument(char *ptr)
ptr = last_quote + 1;
}
if (ptr != NULL)
while (isblank(*ptr))
while (isblank((unsigned char)*ptr))
ptr++;
return ptr;
}
@@ -232,7 +230,7 @@ char *parse_next_regex(char *ptr)
/* Continue until the end of line, or until a " followed by a
* blank character or the end of line. */
while (*ptr != '\0' && (*ptr != '"' ||
(*(ptr + 1) != '\0' && !isblank(*(ptr + 1)))))
(*(ptr + 1) != '\0' && !isblank((unsigned char)ptr[1]))))
ptr++;
assert(*ptr == '"' || *ptr == '\0');
@@ -246,7 +244,7 @@ char *parse_next_regex(char *ptr)
/* Null-terminate and advance ptr. */
*ptr++ = '\0';
while (isblank(*ptr))
while (isblank((unsigned char)*ptr))
ptr++;
return ptr;
@@ -351,7 +349,7 @@ void parse_syntax(char *ptr)
bool is_universal(void (*func))
{
if (func == do_left || func == do_right ||
func == do_home || func == do_end ||
func == do_home_void || func == do_end_void ||
func == do_prev_word_void || func == do_next_word_void ||
func == do_verbatim_input || func == do_cut_text_void ||
func == do_delete || func == do_backspace ||
@@ -389,11 +387,11 @@ void parse_binding(char *ptr, bool dobind)
}
/* Uppercase only the first two or three characters of the key name. */
keycopy[0] = toupper(keycopy[0]);
keycopy[1] = toupper(keycopy[1]);
keycopy[0] = toupper((unsigned char)keycopy[0]);
keycopy[1] = toupper((unsigned char)keycopy[1]);
if (keycopy[0] == 'M' && keycopy[1] == '-') {
if (strlen(keycopy) > 2)
keycopy[2] = toupper(keycopy[2]);
keycopy[2] = toupper((unsigned char)keycopy[2]);
else {
rcfile_error(N_("Key name is too short"));
goto free_copy;
@@ -403,7 +401,7 @@ void parse_binding(char *ptr, bool dobind)
/* Allow the codes for Insert and Delete to be rebound, but apart
* from those two only Control, Meta and Function sequences. */
if (!strcasecmp(keycopy, "Ins") || !strcasecmp(keycopy, "Del"))
keycopy[1] = tolower(keycopy[1]);
keycopy[1] = tolower((unsigned char)keycopy[1]);
else if (keycopy[0] != '^' && keycopy[0] != 'M' && keycopy[0] != 'F') {
rcfile_error(N_("Key name must begin with \"^\", \"M\", or \"F\""));
goto free_copy;
@@ -968,7 +966,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
lineno++;
ptr = buf;
while (isblank(*ptr))
while (isblank((unsigned char)*ptr))
ptr++;
/* If we have a blank line or a comment, skip to the next
@@ -1294,7 +1292,7 @@ void do_rcfiles(void)
free(nanorc);
if (errors && !ISSET(QUIET)) {
if (errors && !ISSET(QUIET) && !ISSET(NO_PAUSES)) {
errors = FALSE;
fprintf(stderr, _("\nPress Enter to continue starting nano.\n"));
while (getchar() != '\n')

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 *
@@ -35,7 +34,6 @@ static bool came_full_circle = FALSE;
static bool history_changed = FALSE;
/* Have any of the history lists changed? */
#endif
#ifdef HAVE_REGEX_H
static bool regexp_compiled = FALSE;
/* Have we compiled any regular expressions? */
@@ -72,7 +70,6 @@ void regexp_cleanup(void)
regfree(&search_regexp);
}
}
#endif
/* Indicate on the statusbar that the string at str was not found by the
* last search. */
@@ -102,9 +99,7 @@ void search_replace_abort(void)
if (openfile->mark_set)
refresh_needed = TRUE;
#endif
#ifdef HAVE_REGEX_H
regexp_cleanup();
#endif
}
/* Set up the system variables for a search or replace. If use_answer
@@ -148,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
@@ -156,10 +152,7 @@ int search_init(bool replacing, bool use_answer)
edit_refresh, "%s%s%s%s%s%s", _("Search"),
/* TRANSLATORS: The next three modify the search prompt. */
ISSET(CASE_SENSITIVE) ? _(" [Case Sensitive]") : "",
#ifdef HAVE_REGEX_H
ISSET(USE_REGEXP) ? _(" [Regexp]") :
#endif
"",
ISSET(USE_REGEXP) ? _(" [Regexp]") : "",
ISSET(BACKWARDS_SEARCH) ? _(" [Backwards]") : "", replacing ?
#ifndef NANO_TINY
/* TRANSLATORS: The next two modify the search prompt. */
@@ -189,11 +182,9 @@ int search_init(bool replacing, bool use_answer)
update_history(&search_history, answer);
#endif
}
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP) && !regexp_init(last_search))
return -1;
else
#endif
return 0; /* We have a valid string or regex. */
}
@@ -207,15 +198,11 @@ int search_init(bool replacing, bool use_answer)
TOGGLE(BACKWARDS_SEARCH);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
} else
#ifdef HAVE_REGEX_H
if (func == regexp_void) {
} else if (func == regexp_void) {
TOGGLE(USE_REGEXP);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
} else
#endif
if (func == do_replace || func == flip_replace_void) {
} else if (func == do_replace || func == flip_replace_void) {
backupstring = mallocstrcpy(backupstring, answer);
return -2; /* Call the opposite search function. */
} else if (func == do_gotolinecolumn_void) {
@@ -297,11 +284,9 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region,
}
if (found != NULL) {
#ifdef HAVE_REGEX_H
/* When doing a regex search, compute the length of the match. */
if (ISSET(USE_REGEXP))
found_len = regmatches[0].rm_eo - regmatches[0].rm_so;
#endif
#ifndef DISABLE_SPELLER
/* When we're spell checking, a match should be a separate word;
* if it's not, continue looking in the rest of the line. */
@@ -438,10 +423,8 @@ void do_research(void)
return;
}
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP) && !regexp_init(last_search))
return;
#endif
/* Use the search-menu key bindings, to allow cancelling. */
currmenu = MWHEREIS;
@@ -455,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
@@ -479,7 +461,6 @@ void go_looking(void)
search_replace_abort();
}
#ifdef HAVE_REGEX_H
/* Calculate the size of the replacement text, taking possible
* subexpressions \1 to \9 into account. Return the replacement
* text in the passed string only when create is TRUE. */
@@ -522,7 +503,6 @@ int replace_regexp(char *string, bool create)
return replacement_size;
}
#endif /* HAVE_REGEX_H */
/* Return a copy of the current line with one needle replaced. */
char *replace_line(const char *needle)
@@ -532,17 +512,13 @@ char *replace_line(const char *needle)
size_t new_line_size = strlen(openfile->current->data) + 1;
/* First adjust the size of the new line for the change. */
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP)) {
match_len = regmatches[0].rm_eo - regmatches[0].rm_so;
new_line_size += replace_regexp(NULL, FALSE) - match_len;
} else {
#endif
match_len = strlen(needle);
new_line_size += strlen(answer) - match_len;
#ifdef HAVE_REGEX_H
}
#endif
/* Create the buffer. */
copy = charalloc(new_line_size);
@@ -551,11 +527,9 @@ char *replace_line(const char *needle)
strncpy(copy, openfile->current->data, openfile->current_x);
/* Add the replacement text. */
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP))
replace_regexp(copy + openfile->current_x, TRUE);
else
#endif
strcpy(copy + openfile->current_x, answer);
assert(openfile->current_x + match_len <= strlen(openfile->current->data));
@@ -706,11 +680,10 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
#endif
}
#ifdef HAVE_REGEX_H
/* Don't find the same zero-length or BOL match again. */
if (match_len == 0 || (*needle == '^' && ISSET(USE_REGEXP)))
skipone = TRUE;
#endif
/* When moving forward, put the cursor just after the replacement
* text, so that searching will continue there. */
if (!ISSET(BACKWARDS_SEARCH))
@@ -762,7 +735,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
void do_replace(void)
{
filestruct *edittop_save, *begin;
size_t begin_x;
size_t firstcolumn_save, begin_x;
ssize_t numreplaced;
int i;
@@ -806,6 +779,7 @@ void do_replace(void)
/* Save where we are. */
edittop_save = openfile->edittop;
firstcolumn_save = openfile->firstcolumn;
begin = openfile->current;
begin_x = openfile->current_x;
@@ -813,6 +787,7 @@ void do_replace(void)
/* Restore where we were. */
openfile->edittop = edittop_save;
openfile->firstcolumn = firstcolumn_save;
openfile->current = begin;
openfile->current_x = begin_x;
refresh_needed = TRUE;
@@ -909,17 +884,29 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
openfile->placewewant = column - 1;
/* When the position was manually given, center the target line. */
if (interactive || ISSET(SOFTWRAP)) {
if (interactive) {
adjust_viewport(CENTERING);
refresh_needed = TRUE;
} else {
int rows_from_tail;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
filestruct *line = openfile->current;
size_t leftedge = (xplustabs() / editwincols) * editwincols;
rows_from_tail = (editwinrows / 2) -
go_forward_chunks(editwinrows / 2, &line, &leftedge);
} else
#endif
rows_from_tail = openfile->filebot->lineno -
openfile->current->lineno;
/* If the target line is close to the tail of the file, put the last
* line of the file on the bottom line of the screen; otherwise, just
* line or chunk on the bottom line of the screen; otherwise, just
* center the target line. */
if (openfile->filebot->lineno - openfile->current->lineno <
editwinrows / 2) {
openfile->current_y = editwinrows - openfile->filebot->lineno +
openfile->current->lineno - 1;
if (rows_from_tail < editwinrows / 2) {
openfile->current_y = editwinrows - 1 - rows_from_tail;
adjust_viewport(STATIONARY);
} else
adjust_viewport(CENTERING);
@@ -1006,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. */
@@ -1020,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);
@@ -1069,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);
null_at(&bracket_set, ch_len + wanted_ch_len);
found_ch = charalloc(mb_cur_max() + 1);
bracket_set[ch_len + wanted_ch_len] = '\0';
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. */
@@ -1100,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 *
@@ -179,13 +178,11 @@ void do_deletion(undo_type action)
return;
#ifndef NANO_TINY
ensure_line_is_visible();
/* If the number of screen rows that a softwrapped line occupies
* has changed, we need a full refresh. */
if (ISSET(SOFTWRAP) && refresh_needed == FALSE)
if ((strlenpt(openfile->current->data) / editwincols) != orig_rows)
refresh_needed = TRUE;
if (ISSET(SOFTWRAP) && refresh_needed == FALSE &&
strlenpt(openfile->current->data) / editwincols != orig_rows)
refresh_needed = TRUE;
#endif
set_modified();
@@ -770,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:
@@ -791,10 +790,7 @@ void do_undo(void)
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
cutbuffer = NULL;
cutbottom = NULL;
/* Instead of a line number, u->mark_begin_lineno contains the number
* of lines of the inserted segment, because the file was partitioned
* when update_undo() was called; so, calculate the end-line number. */
openfile->mark_begin = fsfromline(u->lineno + u->mark_begin_lineno - 1);
openfile->mark_begin = fsfromline(u->mark_begin_lineno);
openfile->mark_begin_x = u->mark_begin_x;
openfile->mark_set = TRUE;
goto_line_posx(u->lineno, u->begin);
@@ -855,7 +851,7 @@ void do_redo(void)
return;
}
f = fsfromline(u->type == INSERT ? 1 : u->mark_begin_lineno);
f = fsfromline(u->mark_begin_lineno);
if (!f)
return;
@@ -987,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);
@@ -1000,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 +
@@ -1010,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) {
@@ -1226,10 +1227,10 @@ 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);
null_at(&char_buf, char_len);
char_buf[char_len] = '\0';
u->strdata = char_buf;
if (u->type == BACK)
u->mark_begin_x += char_len;
@@ -1359,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
@@ -1371,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. */
@@ -1434,14 +1435,8 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
u->lineno = openfile->current->lineno;
break;
case INSERT:
/* Store the number of lines (plus one) of the insertion. */
u->mark_begin_lineno = openfile->current->lineno;
/* When the insertion contains no newline, store the adjusted
* x position; otherwise, store the length of the last line. */
if (openfile->fileage == openfile->filebot)
u->mark_begin_x = openfile->current_x;
else
u->mark_begin_x = strlen(openfile->filebot->data);
u->mark_begin_x = openfile->current_x;
break;
case ENTER:
u->strdata = mallocstrcpy(NULL, openfile->current->data);
@@ -1509,11 +1504,7 @@ bool do_wrap(filestruct *line)
line_len = strlen(line->data);
/* Find the last blank where we can break the line. */
wrap_loc = break_line(line->data, fill
#ifndef DISABLE_HELP
, FALSE
#endif
);
wrap_loc = break_line(line->data, fill, FALSE);
/* If we couldn't break the line, or we've reached the end of it, we
* don't wrap. */
@@ -1617,105 +1608,79 @@ 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
* blank in that group of blanks. The terminating '\0' counts as a
* blank, as does a '\n' if newln is TRUE. */
ssize_t break_line(const char *line, ssize_t goal
#ifndef DISABLE_HELP
, bool newln
#endif
)
* blank, as does a '\n' if snap_at_nl is TRUE. */
ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
{
ssize_t blank_loc = -1;
/* Current tentative return value. Index of the last blank we
* found with short enough display width. */
ssize_t cur_loc = 0;
/* Current index in line. */
size_t cur_pos = 0;
/* Current column position in line. */
ssize_t lastblank = -1;
/* The index of the last blank we found. */
ssize_t index = 0;
/* The index of the character we are looking at. */
size_t column = 0;
/* The column position that corresponds with index. */
int char_len = 0;
/* Length of current character, in bytes. */
/* The length of the current character, in bytes. */
assert(line != NULL);
/* Find the last blank that does not overshoot the target column. */
while (*line != '\0' && column <= goal) {
if (is_blank_mbchar(line) || (snap_at_nl && *line == '\n')) {
lastblank = index;
while (*line != '\0' && goal >= cur_pos) {
char_len = parse_mbchar(line, NULL, &cur_pos);
if (is_blank_mbchar(line)
#ifndef DISABLE_HELP
|| (newln && *line == '\n')
#endif
) {
blank_loc = cur_loc;
#ifndef DISABLE_HELP
if (newln && *line == '\n')
if (*line == '\n')
break;
#endif
}
char_len = parse_mbchar(line, NULL, &column);
line += char_len;
cur_loc += char_len;
index += char_len;
}
if (goal >= cur_pos)
/* In fact, the whole line displays shorter than goal. */
return cur_loc;
/* If the whole line displays shorter than goal, we're done. */
if (column <= goal)
return index;
#ifndef DISABLE_HELP
if (newln && blank_loc <= 0) {
/* If no blank was found, or was found only as the first
* character, force a line break. */
cur_loc -= char_len;
return cur_loc;
}
#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)
return (index - char_len);
#endif
if (blank_loc == -1) {
/* No blank was found within the goal width,
* so now try and find a blank beyond it. */
bool found_blank = FALSE;
ssize_t found_blank_loc = 0;
/* If no blank was found within the goal width, seek one after it. */
if (lastblank < 0) {
while (*line != '\0') {
if (is_blank_mbchar(line))
lastblank = index;
else if (lastblank > 0)
return lastblank;
char_len = parse_mbchar(line, NULL, NULL);
if (is_blank_mbchar(line)
#ifndef DISABLE_HELP
|| (newln && *line == '\n')
#endif
) {
found_blank = TRUE;
found_blank_loc = cur_loc;
} else if (found_blank)
return found_blank_loc;
line += char_len;
cur_loc += char_len;
index += char_len;
}
return -1;
}
/* Move to the last blank after blank_loc, if there is one. */
line -= cur_loc;
line += blank_loc;
/* Move the pointer back to the last blank, and then step beyond it. */
line = line - index + lastblank;
char_len = parse_mbchar(line, NULL, NULL);
line += char_len;
/* Skip any consecutive blanks after the last blank. */
while (*line != '\0' && is_blank_mbchar(line)) {
lastblank += char_len;
char_len = parse_mbchar(line, NULL, NULL);
line += char_len;
blank_loc += char_len;
}
return blank_loc;
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
@@ -1723,25 +1688,19 @@ ssize_t break_line(const char *line, ssize_t goal
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 */
@@ -1903,13 +1862,9 @@ void justify_format(filestruct *paragraph, size_t skip)
/* The "quote part" of a line is the largest initial substring matching
* the quote string. This function returns the length of the quote part
* of the given line.
*
* Note that if !HAVE_REGEX_H then we match concatenated copies of
* quotestr. */
* of the given line. */
size_t quote_length(const char *line)
{
#ifdef HAVE_REGEX_H
regmatch_t matches;
int rc = regexec(&quotereg, line, 1, &matches, 0);
@@ -1918,14 +1873,6 @@ size_t quote_length(const char *line)
/* matches.rm_so should be 0, since the quote string should start
* with the caret ^. */
return matches.rm_eo;
#else /* !HAVE_REGEX_H */
size_t qdepth = 0;
/* Compute quote depth level. */
while (strncmp(line + qdepth, quotestr, quotelen) == 0)
qdepth += quotelen;
return qdepth;
#endif /* !HAVE_REGEX_H */
}
/* a_line and b_line are lines of text. The quotation part of a_line is
@@ -2062,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
@@ -2127,12 +2072,10 @@ bool find_paragraph(size_t *const quote, size_t *const par)
filestruct *current_save;
/* The line at the beginning of the paragraph we search for. */
#ifdef HAVE_REGEX_H
if (quoterc != 0) {
statusline(ALERT, _("Bad quote string %s: %s"), quotestr, quoteerr);
return FALSE;
}
#endif
assert(openfile->current != NULL);
@@ -2215,9 +2158,9 @@ void do_justify(bool full_justify)
/* We save these variables to be restored if the user
* unjustifies. */
filestruct *edittop_save = openfile->edittop;
size_t firstcolumn_save = openfile->firstcolumn;
filestruct *current_save = openfile->current;
size_t current_x_save = openfile->current_x;
size_t totsize_save = openfile->totsize;
#ifndef NANO_TINY
filestruct *mark_begin_save = openfile->mark_begin;
size_t mark_begin_x_save = openfile->mark_begin_x;
@@ -2396,11 +2339,7 @@ void do_justify(bool full_justify)
/* If this line is too long, try to wrap it to the next line
* to make it short enough. */
break_pos = break_line(openfile->current->data + indent_len,
fill - strnlenpt(openfile->current->data, indent_len)
#ifndef DISABLE_HELP
, FALSE
#endif
);
fill - strnlenpt(openfile->current->data, indent_len), FALSE);
/* We can't break the line, or don't need to, so get out. */
if (break_pos == -1 || break_pos + indent_len == line_len)
@@ -2500,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
@@ -2509,8 +2448,8 @@ 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))
do_cursorpos(TRUE);
if (ISSET(CONSTANT_SHOW))
do_cursorpos(FALSE);
func = func_from_key(&kbinput);
@@ -2522,29 +2461,20 @@ void do_justify(bool full_justify)
/* If we actually justified something, then splice the preserved
* unjustified text back into the file, */
if (first_par_line != NULL) {
/* Partition the filestruct so that it contains only the
* text of the justified paragraph. */
filepart = partition_filestruct(first_par_line, 0,
last_par_line, filebot_inpar ?
strlen(last_par_line->data) : 0);
filestruct *trash = NULL, *dummy = NULL;
/* Throw away the justified paragraph, and replace it with
* the preserved unjustified text. */
free_filestruct(openfile->fileage);
openfile->fileage = jusbuffer;
openfile->filebot = jusbottom;
extract_buffer(&trash, &dummy, first_par_line, 0, last_par_line,
filebot_inpar ? strlen(last_par_line->data) : 0);
free_filestruct(trash);
ingraft_buffer(jusbuffer);
/* Unpartition the filestruct, to contain the entire text again. */
unpartition_filestruct(&filepart);
/* Renumber, from the beginning of the unjustified part. */
renumber(jusbuffer);
/* Restore the old position, the size, and the mark. */
/* Restore the old position and the mark. */
openfile->edittop = edittop_save;
openfile->firstcolumn = firstcolumn_save;
openfile->current = current_save;
openfile->current_x = current_x_save;
openfile->totsize = totsize_save;
#ifndef NANO_TINY
if (openfile->mark_set) {
openfile->mark_begin = mark_begin_save;
@@ -2602,6 +2532,7 @@ void do_full_justify(void)
bool do_int_spell_fix(const char *word)
{
char *save_search, *exp_word;
size_t firstcolumn_save = openfile->firstcolumn;
size_t current_x_save = openfile->current_x;
filestruct *edittop_save = openfile->edittop;
filestruct *current_save = openfile->current;
@@ -2723,6 +2654,7 @@ bool do_int_spell_fix(const char *word)
/* Restore the viewport to where it was. */
openfile->edittop = edittop_save;
openfile->firstcolumn = firstcolumn_save;
/* Restore the settings of the global flags. */
memcpy(flags, stash, sizeof(flags));
@@ -2916,27 +2848,13 @@ const char *do_alt_speller(char *tempfile_name)
size_t current_x_save = openfile->current_x;
size_t pww_save = openfile->placewewant;
ssize_t lineno_save = openfile->current->lineno;
bool was_at_eol = (openfile->current->data[openfile->current_x] == '\0');
struct stat spellfileinfo;
time_t timestamp;
pid_t pid_spell;
char *ptr;
static int arglen = 3;
static char **spellargs = NULL;
#ifndef NANO_TINY
bool old_mark_set = openfile->mark_set;
bool added_magicline = FALSE;
/* Whether we added a magicline after filebot. */
filestruct *top, *bot;
size_t top_x, bot_x, was_x, new_x;
bool right_side_up = FALSE;
ssize_t mb_lineno_save = 0;
/* We're going to close the current file, and open the output of
* the alternate spell command. The line that mark_begin points
* to will be freed, so we save the line number and restore it
* afterwards. */
size_t size_of_surrounding = 0;
/* The size of the text outside of a marked region. */
#endif
/* Get the timestamp and the size of the temporary file. */
stat(tempfile_name, &spellfileinfo);
@@ -2946,18 +2864,10 @@ const char *do_alt_speller(char *tempfile_name)
if (spellfileinfo.st_size == 0)
return NULL;
#ifndef NANO_TINY
if (old_mark_set) {
/* If the mark is on, save the number of the line it starts on,
* and then turn the mark off. */
mb_lineno_save = openfile->mark_begin->lineno;
openfile->mark_set = FALSE;
}
#endif
/* Exit from curses mode. */
endwin();
/* Set up an argument list to pass to execvp(). */
/* Set up the argument list to pass to execvp(). */
if (spellargs == NULL) {
spellargs = (char **)nmalloc(arglen * sizeof(char *));
@@ -2972,17 +2882,13 @@ const char *do_alt_speller(char *tempfile_name)
}
spellargs[arglen - 2] = tempfile_name;
/* Start a new process for the alternate speller. */
/* Fork a child process and run the alternate spell program in it. */
if ((pid_spell = fork()) == 0) {
/* Start alternate spell program; we are using $PATH. */
execvp(spellargs[0], spellargs);
/* Should not be reached, if alternate speller is found!!! */
/* Terminate the child process if no alternate speller is found. */
exit(1);
}
/* If we couldn't fork, get out. */
if (pid_spell < 0)
} else if (pid_spell < 0)
return _("Could not fork");
#ifndef NANO_TINY
@@ -2999,78 +2905,42 @@ const char *do_alt_speller(char *tempfile_name)
/* Restore the terminal to its previous state. */
terminal_init();
if (!WIFEXITED(alt_spell_status) || WEXITSTATUS(alt_spell_status) != 0) {
#ifndef NANO_TINY
/* Turn the mark back on if it was on before. */
openfile->mark_set = old_mark_set;
#endif
if (!WIFEXITED(alt_spell_status) || WEXITSTATUS(alt_spell_status) != 0)
return invocation_error(alt_speller);
}
#ifndef NANO_TINY
if (old_mark_set) {
/* Trim the filestruct so that it contains only the marked text. */
/* Replace the marked text (or the entire text) of the current buffer
* with the spell-checked text. */
if (openfile->mark_set) {
filestruct *top, *bot;
size_t top_x, bot_x;
bool right_side_up;
ssize_t was_mark_lineno = openfile->mark_begin->lineno;
openfile->mark_set = FALSE;
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, &right_side_up);
filepart = partition_filestruct(top, top_x, bot, bot_x);
/* Foresay whether a magicline will be added when the
* spell-checked text is read back in. */
if (!ISSET(NO_NEWLINES))
added_magicline = (openfile->filebot->data[0] != '\0');
/* Compute the size of the text outside of the marked region. */
size_of_surrounding = openfile->totsize - get_totsize(top, bot);
}
#endif
/* Replace the text of the current buffer with the spell-checked text. */
replace_buffer(tempfile_name);
#ifndef NANO_TINY
if (old_mark_set) {
filestruct *top_save = openfile->fileage;
/* If a magicline was added, remove it again. */
if (added_magicline)
remove_magicline();
replace_marked_buffer(tempfile_name, top, top_x, bot, bot_x);
/* Adjust the end point of the marked region for any change in
* length of the region's last line. */
if (right_side_up)
was_x = current_x_save;
current_x_save = openfile->current_x;
else
was_x = openfile->mark_begin_x;
if (top == bot)
new_x = was_x - bot_x + top_x + strlen(openfile->filebot->data);
else
new_x = strlen(openfile->filebot->data);
if (right_side_up)
current_x_save = new_x;
else
openfile->mark_begin_x = new_x;
openfile->mark_begin_x = openfile->current_x;
/* Unpartition the filestruct so that it contains all the text
* again. Note that we've replaced the marked text originally
* in the partition with the spell-checked marked text in the
* temp file. */
unpartition_filestruct(&filepart);
/* Renumber, starting with the beginning line of the old partition. */
renumber(top_save);
/* Add back the size of the text surrounding the marked region. */
openfile->totsize += size_of_surrounding;
/* Restore the position of the mark, and turn it back on. */
openfile->mark_begin = fsfromline(mb_lineno_save);
/* Restore the mark's position and turn it back on. */
openfile->mark_begin = fsfromline(was_mark_lineno);
openfile->mark_set = TRUE;
}
#endif /* !NANO_TINY */
} else
#endif
replace_buffer(tempfile_name);
/* Go back to the old position. */
goto_line_posx(lineno_save, current_x_save);
if (openfile->current_x > strlen(openfile->current->data))
if (was_at_eol || openfile->current_x > strlen(openfile->current->data))
openfile->current_x = strlen(openfile->current->data);
openfile->placewewant = pww_save;
adjust_viewport(STATIONARY);
@@ -3086,6 +2956,7 @@ const char *do_alt_speller(char *tempfile_name)
discard_until(NULL, openfile);
#endif
}
#ifndef NANO_TINY
/* Unblock SIGWINCHes again. */
allow_sigwinch(TRUE);
@@ -3392,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);
@@ -3472,6 +3368,7 @@ void do_formatter(void)
ssize_t lineno_save = openfile->current->lineno;
size_t current_x_save = openfile->current_x;
size_t pww_save = openfile->placewewant;
bool was_at_eol = (openfile->current->data[openfile->current_x] == '\0');
pid_t pid_format;
static int arglen = 3;
static char **formatargs = NULL;
@@ -3489,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) {
@@ -3549,17 +3448,18 @@ void do_formatter(void)
/* Restore the cursor position. */
goto_line_posx(lineno_save, current_x_save);
if (openfile->current_x > strlen(openfile->current->data))
if (was_at_eol || openfile->current_x > strlen(openfile->current->data))
openfile->current_x = strlen(openfile->current->data);
openfile->placewewant = pww_save;
adjust_viewport(STATIONARY);
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");
}
@@ -3597,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,
@@ -3627,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;
@@ -3658,17 +3558,15 @@ void do_verbatim_input(void)
/* TRANSLATORS: This is displayed when the next keystroke will be
* inserted verbatim. */
statusbar(_("Verbatim Input"));
reset_cursor();
place_the_cursor();
curs_set(1);
/* Read in all the verbatim characters. */
kbinput = get_verbatim_kbinput(edit, &kbinput_len);
/* If constant cursor position display is on, make sure the current
* cursor position will be properly displayed on the statusbar.
* Otherwise, blank the statusbar. */
if (ISSET(CONST_UPDATE))
do_cursorpos(TRUE);
/* Unsuppress cursor-position display or blank the statusbar. */
if (ISSET(CONSTANT_SHOW))
do_cursorpos(FALSE);
else {
blank_statusbar();
wnoutrefresh(bottomwin);

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 *
@@ -25,7 +24,9 @@
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#include <ctype.h>
#include <errno.h>
@@ -36,6 +37,7 @@ void get_homedir(void)
if (homedir == NULL) {
const char *homenv = getenv("HOME");
#ifdef HAVE_PWD_H
/* When HOME isn't set, or when we're root, get the home directory
* from the password file instead. */
if (homenv == NULL || geteuid() == 0) {
@@ -44,6 +46,7 @@ void get_homedir(void)
if (userage != NULL)
homenv = userage->pw_dir;
}
#endif
/* Only set homedir if some home directory could be determined,
* otherwise keep homedir NULL. */
@@ -170,94 +173,6 @@ void sunder(char *str)
}
}
/* These functions, ngetline() (originally getline()) and ngetdelim()
* (originally getdelim()), were adapted from GNU mailutils 0.5
* (mailbox/getline.c). Here is the notice from that file, after
* converting to the GPL via LGPL clause 3, and with the Free Software
* Foundation's address and the copyright years updated:
*
* GNU Mailutils -- a suite of utilities for electronic mail
* Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007
* Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301, USA. */
#ifndef DISABLE_NANORC
#ifndef HAVE_GETDELIM
/* This function is equivalent to getdelim(). */
ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream)
{
size_t indx = 0;
int c;
/* Sanity checks. */
if (lineptr == NULL || n == NULL || stream == NULL ||
fileno(stream) == -1) {
errno = EINVAL;
return -1;
}
/* Allocate the line the first time. */
if (*lineptr == NULL) {
*n = MAX_BUF_SIZE;
*lineptr = charalloc(*n);
}
while ((c = getc(stream)) != EOF) {
/* Check if more memory is needed. */
if (indx >= *n) {
*n += MAX_BUF_SIZE;
*lineptr = charealloc(*lineptr, *n);
}
/* Put the result in the line. */
(*lineptr)[indx++] = (char)c;
/* Bail out. */
if (c == delim)
break;
}
/* Make room for the null character. */
if (indx >= *n) {
*n += MAX_BUF_SIZE;
*lineptr = charealloc(*lineptr, *n);
}
/* Null-terminate the buffer. */
null_at(lineptr, indx++);
*n = indx;
/* The last line may not have the delimiter. We have to return what
* we got, and the error will be seen on the next iteration. */
return (c == EOF && (indx - 1) == 0) ? -1 : indx - 1;
}
#endif
#ifndef HAVE_GETLINE
/* This function is equivalent to getline(). */
ssize_t ngetline(char **lineptr, size_t *n, FILE *stream)
{
return getdelim(lineptr, n, '\n', stream);
}
#endif
#endif /* !DISABLE_NANORC */
#ifdef HAVE_REGEX_H
/* Fix the regex if we're on platforms which require an adjustment
* from GNU-style to BSD-style word boundaries. */
const char *fixbounds(const char *r)
@@ -293,14 +208,13 @@ const char *fixbounds(const char *r)
return r;
}
#endif /* HAVE_REGEX_H */
#ifndef DISABLE_SPELLER
/* Is the word starting at the given position in buf and of the given length
* 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. */
@@ -323,7 +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)
{
#ifdef HAVE_REGEX_H
/* 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;
@@ -376,7 +293,6 @@ const char *strstrwrapper(const char *haystack, const char *needle,
else
return haystack + regmatches[0].rm_so;
}
#endif /* HAVE_REGEX_H */
if (ISSET(CASE_SENSITIVE)) {
if (ISSET(BACKWARDS_SEARCH))
return revstrstr(haystack, needle, start);
@@ -454,13 +370,14 @@ char *free_and_assign(char *dest, char *src)
return src;
}
/* nano scrolls horizontally within a line in chunks. Return the column
* number of the first character displayed in the edit window when the
/* When not in softwrap mode, nano scrolls horizontally within a line in
* chunks (a bit smaller than the chunks used in softwrapping). Return the
* column number of the first character displayed in the edit window when the
* cursor is at the given column. Note that (0 <= column -
* get_page_start(column) < COLS). */
size_t get_page_start(size_t column)
{
if (column == 0 || column < editwincols - 1)
if (column < editwincols - 1 || ISSET(SOFTWRAP) || column == 0)
return 0;
else if (editwincols > 8)
return column - 7 - (column - 7) % (editwincols - 8);
@@ -479,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);
@@ -490,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:
@@ -520,11 +436,15 @@ size_t strnlenpt(const char *text, size_t maxlen)
return width;
}
/* A strlen() with tabs and multicolumn characters factored in:
* how many columns wide is text? */
/* Return the number of columns that the given text occupies. */
size_t strlenpt(const char *text)
{
return strnlenpt(text, (size_t)-1);
size_t span = 0;
while (*text != '\0')
text += parse_mbchar(text, NULL, &span);
return span;
}
/* Append a new magicline to filebot. */
@@ -536,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. */
@@ -550,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
@@ -619,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)
@@ -635,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;

File diff suppressed because it is too large Load Diff

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-)'"

View File

@@ -7,7 +7,7 @@ comment "#"
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|comment|magic|linter|i?color|extendsyntax).*$"
# Keywords
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cut|fill[[:space:]]+[[:digit:]]+|historylog|justifytrim|locking|morespace|mouse|multibuffer|noconvert|nohelp|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize[[:space:]]+[[:digit:]]+|tabstospaces|tempfile|unix|view|wordbounds)\>"
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cut|fill[[:space:]]+[[:digit:]]+|historylog|justifytrim|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize[[:space:]]+[[:digit:]]+|tabstospaces|tempfile|unix|view|wordbounds)\>"
icolor yellow "^[[:space:]]*set[[:space:]]+((function|key|number|status|title)color)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>" "[[:space:]]+[[:digit:]]+$"
icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|speller|statuscolor|titlecolor|whitespace|wordchars)[[:space:]]+"
icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^([[:alpha:]]|[]0-9\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]+(all|main|search|replace(with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"