Compare commits

...

116 Commits

Author SHA1 Message Date
Benno Schulenberg
3db2beefd3 po: regenerate POT file and PO files 2017-05-21 10:57:12 +02:00
Benno Schulenberg
5907f8801b bump version numbers and add a news item for the 2.8.4 release 2017-05-21 10:21:03 +02:00
Benno Schulenberg
c68398f18f syntax: php: color "static" again as "function", like it used to be 2017-05-21 10:11:42 +02:00
Benno Schulenberg
d653aeab93 syntax: default: color also hash comments and email addresses 2017-05-19 21:09:15 +02:00
Benno Schulenberg
491e02f532 tweaks: reorder three items in the Info document 2017-05-19 21:09:02 +02:00
Benno Schulenberg
f1a47a2aae tweaks: reshuffle a few things to reduce duplication
It is no longer necessary to assign up() and down() separately for
the help viewer because by now the movement keys have been sorted
in order of ascending stride also in the main menu.

The two string definitions are relocated just to reduce the number
of #ifdefs.
2017-05-19 17:57:39 +02:00
Benno Schulenberg
7b23878b42 tweaks: do actual screen refreshes in a single call, when possible 2017-05-19 16:31:08 +02:00
Benno Schulenberg
5cdadc3eb1 tweaks: avoid an unused-variable warning when using --disable-comment 2017-05-19 11:55:37 +02:00
Benno Schulenberg
8f89e23adb tweaks: adjust the indentation after the preceding change
Also, change two error messages a bit.
2017-05-19 11:47:13 +02:00
Benno Schulenberg
8302ff700b tweaks: remove the no-op x$disable tests 2017-05-19 11:47:13 +02:00
Benno Schulenberg
a32d21c759 build: correct the inverted logic for the nanorc man page
All this "not is no" has me turning around in circles
at least ten times before I know which side is which.

This fixes https://savannah.gnu.org/bugs/?51061
Reported-by: Vicente Olivert Riera <vincent.riera@imgtec.com>
2017-05-19 11:46:18 +02:00
Benno Schulenberg
f8214440c2 gnulib: update to its current state 2017-05-18 20:09:04 +02:00
Benno Schulenberg
c1b08302df po: update translations and regenerate POT file and PO files 2017-05-18 14:27:00 +02:00
Benno Schulenberg
afd8a4e804 bump version numbers and add a news item for the 2.8.3 release 2017-05-18 11:53:19 +02:00
Benno Schulenberg
88b740179a tweaks: rewrap a couple of old items in NEWS, and fix an article
Also fix a URL that mistaken points to a specific bug.
2017-05-18 11:02:16 +02:00
Benno Schulenberg
9ce41543ed startup: don't call delwin() with NULL, to avoid crashing on Solaris
Apparently the curses on SunOS is less forgiving than the one on GNU.
Or rather: delwin(NULL) should just return an error, it shouldn't crash.

This fixes https://savannah.gnu.org/bugs/?51053.
Reported-by: John Wiersba <jrw32982@yahoo.com>
Solved-by: John Wiersba <jrw32982@yahoo.com>
2017-05-18 10:26:11 +02:00
Benno Schulenberg
e4775c2060 syntax: php: color also variable names, and color more reserved words
Most of the keywords listed on the following URL are now highlighted:
  http://php.net/manual/en/reserved.keywords.php

Also color single-quoted strings, and require that //-type comments
are preceded by whitespace or are alone on a line.

With-feedback-from: M <taur@mail.com>
2017-05-18 10:03:43 +02:00
Benno Schulenberg
cd7c3483b4 build: for Solaris, tell the linker where to find clock_gettime()
This fixes https://savannah.gnu.org/bugs/?50972.
Reported-by: John Wiersba <jrw32982@yahoo.com>
2017-05-17 10:53:21 +02:00
Benno Schulenberg
8075e454a9 history: don't save the cursor position for temporary help files
It's useless, because the position doesn't get restored, and it
cannot be restored because the name is different every time.
2017-05-17 10:48:04 +02:00
Benno Schulenberg
93b1c1bea6 files: don't ask "save anyway" when user orders to discard the buffer
This extra question was included upon Chris' request, but I find it
confusing and angering.
2017-05-16 22:14:45 +02:00
Benno Schulenberg
aa14526cb3 tweaks: exclude from the tiny version five error-betraying messages 2017-05-16 22:13:10 +02:00
Benno Schulenberg
d29d49aece tweaks: remove an old fault-catching message 2017-05-16 20:09:03 +02:00
Benno Schulenberg
e8f90789e9 tweaks: exclude from the tiny version two messages that will never occur 2017-05-16 20:00:42 +02:00
Benno Schulenberg
c830b8f51c syntax: php: recognize also the .phtml and .php7 extensions
(And in the bargain sort or group some of the keywords.)

This addresses https://savannah.gnu.org/patch/?9342.
Suggested-by: M <taur@mail.com>
2017-05-15 10:57:57 +02:00
Benno Schulenberg
28beb3f9c5 replacing: don't let placewewant influence the placement of the cursor
When spotlighting the string to be replaced, placewewant isn't valid,
so tell place_the_cursor() to ignore its value to avoid the cursor
getting mistakenly placed at the beginning of the next row.

This fixes https://savannah.gnu.org/bugs/?50997.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-05-11 22:28:34 +02:00
Benno Schulenberg
08fd5b349b moving: limit the target column when it is beyond the last chunk
When the column given in gotoline() is beyond the last available
column in the row of the last chunk, then set placewewant to the
actual end of the chunk, to prevent surprising jumps to the left
when moving up or down from there.

This fixes https://savannah.gnu.org/bugs/?50995.
2017-05-11 21:00:37 +02:00
Benno Schulenberg
6971db773b tweaks: swap a comparison, to be clearer 2017-05-11 10:28:43 +02:00
Benno Schulenberg
c620fc6aa9 build: use backticks to avoid a warning during autoreconf 2017-05-09 20:23:04 +02:00
Benno Schulenberg
7e09f2c64a syntax: makefile: color comments only at start of line or after whitespace 2017-05-09 17:37:05 +02:00
Benno Schulenberg
968c07fc81 build: use the "force" mechanism to always run the revision rule
Whenever 'make' is run, it should check whether the revision has
changed, and if so, it should update src/revision.h.

This portable FORCE mechanism should have been the replacement for
the phony target that was removed in a33a4f00, five commits ago.

This fixes https://savannah.gnu.org/bugs/?50956 in a better way.
2017-05-09 17:30:49 +02:00
Benno Schulenberg
858e75e4cf tweaks: transform the token DISABLE_NANORC to ENABLE_NANORC
Also, allow rebinding the word and block jumping functions
in the tiny version when nanorc files are reenabled.
2017-05-09 11:59:34 +02:00
Benno Schulenberg
a05180ed2d tweaks: transform the token DISABLE_TABCOMP to ENABLE_TABCOMP 2017-05-09 11:31:54 +02:00
Benno Schulenberg
00533854c0 tweaks: fix compilation with --enable-tiny ...-help and ...-multibuffer
(This should have been part of 9ea5eef2, four commits ago.)
2017-05-08 22:01:34 +02:00
Benno Schulenberg
dc3610fc8e tweaks: transform the token DISABLE_BROWSER to ENABLE_BROWSER
Also, allow Ctrl+Left/Right with --enable-tiny --enable-browser.
2017-05-08 21:56:50 +02:00
Benno Schulenberg
a33a4f00e5 build: don't use a dummy dependency, as it breaks non-GNU makes
This fixes https://savannah.gnu.org/bugs/?50956.
Reported-by: John Wiersba <jrw32982@yahoo.com>
2017-05-08 21:27:07 +02:00
Benno Schulenberg
509b091c47 tweaks: rename three empty functions, and reshuffle some others
Also remove a superfluous check for 'do_replace' -- it never gets
bound in the Search/Replace menus.
2017-05-08 14:33:18 +02:00
Benno Schulenberg
9ea5eef200 bindings: allow toggling a new buffer when multiple buffers are enabled
When configured with --enable-tiny --enable-multibuffer,
/do/ include the new-buffer toggle in the Read-File menu.
2017-05-08 13:36:57 +02:00
Benno Schulenberg
e701bb01aa tweaks: remove five dummy function definitions from the tiny version 2017-05-08 13:04:26 +02:00
Benno Schulenberg
a3102cd4cf syntax: xml: recognize an XML file also by its first line
Some .rdf files are XML, but the .rdf extension seems to be used
also for other things.  So... use the 'header' mechanism.
2017-05-07 20:02:20 +02:00
Benno Schulenberg
da67883508 syntax: nanohelp: color also ^6 as a shortcut keystroke
(Hadn't seen that one because of my additional bindings.)
2017-05-07 20:00:52 +02:00
David Lawrence Ramsey
03c3e2b7c0 tweaks: fix several whitespace irregularities
Add missing spaces, remove excess spaces, and
replace groups of indentation spaces with tabs.
2017-05-07 18:20:01 +02:00
Benno Schulenberg
4953dcec20 tweaks: add another warning for an impossible condition 2017-05-05 22:00:04 +02:00
Benno Schulenberg
f5155786e1 tweaks: adjust whitespace and comments after the preceding change 2017-05-05 21:54:23 +02:00
Benno Schulenberg
a9abc3d95f chars: optimize moving a character left in the non-UTF-8 case
When not in a UTF-8 locale, each character is just a single byte.
2017-05-05 21:40:00 +02:00
Benno Schulenberg
09cabcad5d chars: probe for a valid UTF-8 starter byte, instead of overstepping
Instead of always stepping back four bytes and then tentatively
moving forward again (which is wasteful when most codes are just
one or two bytes long), inspect the preceding bytes one by one
and begin the move forward at the first valid starter byte.

This reduces the backwards searching time by close to 40 percent.
2017-05-05 21:36:45 +02:00
Benno Schulenberg
f162a6a2ab chars: valid UTF-8 codes are at most 4 bytes long, so look only that far
This reduces the backwards searching time by a good 20 percent.
2017-05-05 21:34:23 +02:00
Benno Schulenberg
5a3de7f117 tweaks: avoid an empty function call in tiny version with line numbers 2017-05-05 12:39:20 +02:00
Benno Schulenberg
7b5cc1dcda display: keep the cursor put, also when toggling nohelp or morespace
Also when toggling the help lines back on or the extra editing space
back off, keep the cursor near the bottom of the screen if it /was/
there, instead of centering it -- if smooth scrolling is on, that is.

This supplements the fix for https://savannah.gnu.org/bugs/?50933.
2017-05-05 12:37:45 +02:00
David Lawrence Ramsey
2b38547875 display: ensure smooth scrolling when the edit window is resized
When the editing space gets narrower, either by toggling line numbers on
or making nano's window smaller, and when the cursor is near the bottom,
it can be pushed offscreen.  In that case, don't get it back onscreen by
centering the current line but by putting it on the bottom row.  This
makes for a smoother experience.

This fixes http://savannah.gnu.org/bugs/?50933.
2017-05-05 12:31:02 +02:00
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
70 changed files with 17661 additions and 17723 deletions

10
AUTHORS
View File

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

137
ChangeLog
View File

@@ -1,3 +1,140 @@
Changes between v2.8.3 and v2.8.4:
----------------------------------
Benno Schulenberg (11):
build: correct the inverted logic for the nanorc man page
bump version numbers and add a news item for the 2.8.4 release
gnulib: update to its current state
syntax: default: color also hash comments and email addresses
syntax: php: color "static" again as "function", like it used to be
tweaks: adjust the indentation after the preceding change
tweaks: avoid an unused-variable warning when using --disable-comment
tweaks: do actual screen refreshes in a single call, when possible
tweaks: remove the no-op x$disable tests
tweaks: reorder three items in the Info document
tweaks: reshuffle a few things to reduce duplication
Changes between v2.8.2 and v2.8.3:
----------------------------------
Benno Schulenberg (34):
bindings: allow toggling a new buffer when multiple buffers are enabled
build: don't use a dummy dependency, as it breaks non-GNU makes
build: for Solaris, tell the linker where to find clock_gettime()
build: use backticks to avoid a warning during autoreconf
build: use the "force" mechanism to always run the revision rule
bump version numbers and add a news item for the 2.8.3 release
chars: optimize moving a character left in the non-UTF-8 case
chars: probe for a valid UTF-8 starter byte, instead of overstepping
chars: valid UTF-8 codes are at most 4 bytes long, so look only that far
display: keep the cursor put, also when toggling nohelp or morespace
files: don't ask "save anyway" when user orders to discard the buffer
history: don't save the cursor position for temporary help files
moving: limit the target column when it is beyond the last chunk
replacing: don't let placewewant influence the placement of the cursor
startup: don't call delwin() with NULL, to avoid crashing on Solaris
syntax: makefile: color comments only at start of line or after whitespace
syntax: nanohelp: color also ^6 as a shortcut keystroke
syntax: php: color also variable names, and color more reserved words
syntax: php: recognize also the .phtml and .php7 extensions
syntax: xml: recognize an XML file also by its first line
tweaks: add another warning for an impossible condition
tweaks: adjust whitespace and comments after the preceding change
tweaks: avoid an empty function call in tiny version with line numbers
tweaks: exclude from the tiny version five error-betraying messages
tweaks: exclude from the tiny version two messages that will never occur
tweaks: fix compilation with --enable-tiny ...-help and ...-multibuffer
tweaks: remove an old fault-catching message
tweaks: remove five dummy function definitions from the tiny version
tweaks: rename three empty functions, and reshuffle some others
tweaks: rewrap a couple of old items in NEWS, and fix an article
tweaks: swap a comparison, to be clearer
tweaks: transform the token DISABLE_BROWSER to ENABLE_BROWSER
tweaks: transform the token DISABLE_NANORC to ENABLE_NANORC
tweaks: transform the token DISABLE_TABCOMP to ENABLE_TABCOMP
David Lawrence Ramsey (2):
display: ensure smooth scrolling when the edit window is resized
tweaks: fix several whitespace irregularities
Changes between v2.8.1 and v2.8.2:
----------------------------------
Benno Schulenberg (64):
bindings: allow using <Backspace> to scroll back up in the help viewer
bindings: allow using '/' to start a search in the help viewer
bindings: show Home and End in browser help text, instead of M-| and M-?
browser: make ^End work properly by fixing a paste error
build: make --enable-help properly depend on --enable-multibuffer
bump version numbers and add a news item for the 2.8.2 release
display: initialize the colors only when starting to draw the content
display: push the titlebar to the screen as soon as it has been drawn
docs: add an item to the FAQ, about pasting from Windows to a remote nano
docs: harmonize the nanorc man page and Info document a bit
docs: in the FAQ, extend the answer to the pasting problem
docs: reword the main paragraph of the man page
docs: update the list of who authored what
gnulib: update to its current state in git
help: after a search, show the cursor only when something was found
help: allocate enough space for the descriptions, so we don't crash
help: don't crash when nano was started with --noread
help: don't cycle forward in the buffers when exiting from help
help: keep the same position also after M-\ or M-/ has been used
help: keep the text at the same position when the screen is resized
help: remove the final blank line, so <End> does the same as all <Down>
help: set tabsize to the default width while showing a help text
help: suppress nano's name and number to make it clearer this is help
help: use a dedicated syntax to color shortcuts in a help text
help: when searching, do it forward, without case, and without regexes
input: avoid crashing when resizing the window during verbatim input
options: allow -U (--quickblank) to be used in the tiny version
scrolling: don't bother to limit the number of lines to step back
startup: warn about a strange character size only in the UTF-8 case
syntax: nanohelp: change the hue of the keystrokes to match sample.nanorc
tweaks: add a warning for a condition that should never occur
tweaks: add three warnings for conditions that should never occur
tweaks: avoid an unused-variable warning
tweaks: be more precise about what --disable-extra does
tweaks: check for an empty needle in a central place
tweaks: complete the exclusion of backups and such from the tiny version
tweaks: condense two bits of code, and drop two asserts
tweaks: distinguish (in the comments) between buffers and linestructs
tweaks: drop a bunch of asserts
tweaks: elide a function that is used just once
tweaks: fix compilation with --enable-tiny --enable-color --enable-speller
tweaks: fix two typos
tweaks: remove a superfluous check
tweaks: remove a superfluous strlen() call from the reverse searches
tweaks: remove some superfluous placements of the cursor
tweaks: remove two superfluous calls of wnoutrefresh()
tweaks: rename a constant, to match the corresponding option
tweaks: rename a function, to be more accurate
tweaks: rename a function, to better suit what it does
tweaks: rename another function, to better describe what it does
tweaks: rename a parameter, to be more imperative
tweaks: rename a variable, use a faster comparison, and reshuffle a bit
tweaks: rename one variable again
tweaks: rename some more of these 'rev_start' variables
tweaks: rename three variables, elide another, and reshuffle some stuff
tweaks: rename two variables, because this 'rev_start' is irksome
tweaks: reshuffle a couple of lines to avoid a duplicate call
tweaks: reshuffle help-text initialization, to elide a save-and-restore
tweaks: reshuffle some more stuff, and rename two more variables
tweaks: swap the names of two variables, to make more sense
tweaks: transform the token DISABLE_MOUSE to ENABLE_MOUSE
tweaks: transform the token DISABLE_MULTIBUFFER to ENABLE_MULTIBUFFER
tweaks: use the logic from revstrstr() also in mbrevstrcasestr()
tweaks: use the logic from revstrstr() also in revstrcasestr()
David Lawrence Ramsey (1):
docs: mention that also numbercolor overrides boldtext
Rishabh Dave (1):
new feature: add a search facility to the help viewer
Changes between v2.8.0 and v2.8.1:
----------------------------------

View File

@@ -2,6 +2,7 @@ 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.

72
NEWS
View File

@@ -1,3 +1,21 @@
2017.05.21 - GNU nano 2.8.4 includes the nanorc man page again.
2017.05.18 - GNU nano 2.8.3 "Hirsch" fixes a misplacement of the spotlight
during interactive replacing, avoids build failures on AIX
and Solaris, fixes a crash on Solaris, speeds up backwards
searching, improves PHP syntax highlighting, and no longer
asks “save anyway?” when the user ^Q discards the buffer.
2017.05.04 - GNU nano 2.8.2 "Krats" adds another new feature: it makes
the ^G help texts searchable with ^W. Apart from that,
it fixes a crash when resizing the window in the middle
of verbatim input, avoids an unlikely crash when used
without UTF-8 support in some locales, avoids redrawing
the screen twice when switching between buffers while
line numbers are active, and works around a coloring
bug on musl. Plus tweaks to the documentation; plus
translation updates for fifteen languages.
2017.04.12 - GNU nano 2.8.1 "Ellert" fixes build failures on MacOS and
on musl, fixes scrolling problems in softwrap mode when
double-width characters on row boundaries are involved,
@@ -256,13 +274,12 @@
handling of --tempfile mode, and better handling of
command line arguments when also attempting to specify
+<line number>. As always, please file any bugs you
find at the Savannah page for nano, at
https://savannah.gnu.org/bugs/index.php?42639 and
thanks for using nano.
find via https://savannah.gnu.org/bugs/?group=nano
and thanks for using nano.
2014.06.02 - GNU nano 2.3.4 won't leave you high, won't leave you dry. This
release contains only a small number of fixes, but in
particular allows nano to compile on non-UTF-8 curses
2014.06.02 - GNU nano 2.3.4 won't leave you high, won't leave you dry.
This release contains only a small number of fixes, but
in particular allows nano to compile on non-UTF-8 curses
implementations (i.e. libncursesw). Other small fixes to
the undo implementation and the default syntax config are
also included. As always, Share and Enjoy!
@@ -522,16 +539,16 @@
an internal error occurs in the undo code, and fixes for
various combinations of configure-time options and
compiler flags. Also included is new support for
changing the rc file name at configure time, and
using GNU-style regexes for word-boundaries on systems
which do not support them natively, as well as the ever
popular translation updates. Rock the tarball.
changing the rc file name at configure time, and using
GNU-style regexes for word-boundaries on systems which
do not support them natively, as well as the ever popular
translation updates. Rock the tarball.
2008.08.09 - GNU nano 2.1.4 "I told you so!" is released. This release
includes fixes for several severe issues with the new
undo/redo code. Also the behavior of writing
files when using backup mode has changed as well: if writing
the backup file fails, nano will not attempt to write the
undo/redo code. Also the behavior of writing files when
using backup mode has changed as well: if writing the
backup file fails, nano will not attempt to write the
current file. This should help folks who enjoy "extreme
text editing", i.e. editing files on file systems which
are likely to run out of space; see Savannah bug #24000.
@@ -1237,28 +1254,27 @@
Have fun with it.
2001.03.22 - GNU Nano 1.0 is released! The autoindent wrapping bug
has been fixed, as well as strange bug when using Pico
has been fixed, as well as a strange bug when using Pico
mode and regex search. There have also been some minor
spelling and documentation updates. As stated on the
website, there are currently no known bugs with nano,
but some will pop up eventually and they will be
addressed in subsequent releases. We hope you enjoy
this first stable release of nano, and as always,
feedback is welcome! nano@nano-editor.org.
feedback is welcome! <nano@nano-editor.org>
2001.02.19 - Nano 0.9.99pre3 brings a lot of changes! The most
important being that nano is now officially a GNU
program. Some changes have been made for GNU
compatibility (like the default list of shortcuts, "^G
Get Help" is now listed and "^_ Goto Line" is not). The
Yes/No/All keys have finally been internationalized
also. All in all, quite a few changes, considering nano
is supposed to be in a code freeze. But there are the
usual helping of bugfixes, a nasty bug when cutting text
in -k mode and some compatibility issues with older
ncurses libraries have also been fixed. All in all, a
lot to see.
2001.02.19 - Nano 0.9.99pre3 brings a lot of changes! The most important
being that nano is now officially a GNU program. Some
changes have been made for GNU compatibility (like in the
default list of shortcuts: "^G Get Help" is now listed
and "^_ Goto Line" is not). The Yes/No/All keys have
finally been internationalized also. All in all, quite
a few changes, considering nano is supposed to be in
a code freeze. But there are the usual helping of
bugfixes, a nasty bug when cutting text in -k mode and
some compatibility issues with older ncurses libraries
have also been fixed. All in all, a lot to see.
2001.01.31 - Nano 0.9.99pre2 is released. Not surprisingly, all that is
new is bugfixes, bugfixes, bugfixes. There were a few
@@ -1267,7 +1283,7 @@
is now a preliminary (read: needs testing) fix for
resizing the editor in any mode other than normal edit
mode. Other fixes include some more tab completion
segfaults, and an silly segfault that occurred when
segfaults, and a silly segfault that occurred when
successfully writing a file on the 2nd try (i.e. after
an initial write error). Slowly but surely, on toward
1.0 we travel.

5
TODO
View File

@@ -3,8 +3,6 @@ A list of desired features
Somewhat urgent:
- Make undo/redo work also for justifying and indenting.
- Allow text searches in the help viewer.
See https://savannah.gnu.org/bugs/?28994.
- Detect when text is being pasted, so that we can handle it faster.
See https://savannah.gnu.org/bugs/?40060.
- Allow to define and execute a macro: a stored sequence of keystrokes.
@@ -27,6 +25,9 @@ Vague musings:
- Allow indentation to add just enough columns to reach the nearest
multiple of tabsize, rather than always adding tabsize columns?
For version 2.8:
- Allow text searches in the help viewer. [DONE]
For version 2.4:
- Handle window resizes better. After we've resized, we should stay
wherever we were before we resized, as Pico does. [DONE]

View File

@@ -2,7 +2,7 @@
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="06d9e7302a736d7fa3db9cf1eb9850b60aee612f"
gnulib_hash="4be488081b917f98a2fd3e2766324043649cca6e"
modules="
futimens

View File

@@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
AC_INIT([GNU nano], [2.8.1], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [2.8.4], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.14])
@@ -63,9 +63,14 @@ AC_CHECK_HEADERS(libintl.h limits.h pwd.h termios.h sys/param.h)
dnl Checks for options.
AC_ARG_ENABLE(browser,
AS_HELP_STRING([--disable-browser], [Disable built-in file browser]))
if test "x$enable_browser" = xno; then
AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in file browser.])
AS_HELP_STRING([--disable-browser], [Disable the built-in file browser]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_browser" != xyes; then
enable_browser=no
fi
fi
if test "x$enable_browser" != xno; then
AC_DEFINE(ENABLE_BROWSER, 1, [Define this to enable the built-in file browser.])
fi
AC_ARG_ENABLE(color,
@@ -85,7 +90,7 @@ else
fi
AC_ARG_ENABLE(comment,
AS_HELP_STRING([--disable-comment], [Disable comment/uncomment functions]))
AS_HELP_STRING([--disable-comment], [Disable the comment/uncomment function]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_comment" = xyes; then
AC_MSG_ERROR([--enable-comment cannot work with --enable-tiny])
@@ -93,22 +98,37 @@ if test "x$enable_tiny" = xyes; then
enable_comment=no
fi
fi
if test "x$disable_comment" != xyes; then
if test "x$enable_comment" != xno; then
AC_DEFINE(ENABLE_COMMENT, 1, [Define this to enable the comment/uncomment function.])
fi
if test "x$enable_comment" != xno; then
AC_DEFINE(ENABLE_COMMENT, 1, [Define this to enable the comment/uncomment function.])
fi
AC_ARG_ENABLE(extra,
AS_HELP_STRING([--disable-extra], [Disable extra features, currently only easter eggs]))
AS_HELP_STRING([--disable-extra], [Disable the Easter egg]))
if test "x$enable_extra" = xno; then
AC_DEFINE(DISABLE_EXTRA, 1, [Define this to disable extra stuff.])
fi
AC_ARG_ENABLE(help,
AS_HELP_STRING([--disable-help], [Disable help functions]))
if test "x$enable_help" = xno; then
AC_DEFINE(DISABLE_HELP, 1, [Define this to disable the help text display.])
AS_HELP_STRING([--disable-help], [Disable the built-in help texts]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_help" = xyes; then
if test "x$enable_multibuffer" != xyes; then
AC_MSG_ERROR([--enable-help needs --enable-multibuffer to work])
fi
else
enable_help=no
fi
fi
if test "x$enable_multibuffer" = xno; then
if test "x$enable_help" = xyes; then
AC_MSG_ERROR([--enable-help cannot work with --disable-multibuffer])
else
# Disabling multibuffer silently disables the help texts.
enable_help=no
fi
fi
if test "x$enable_help" != xno; then
AC_DEFINE(ENABLE_HELP, 1, [Define this to enable the Ctrl+G help texts.])
fi
AC_ARG_ENABLE(histories,
@@ -118,7 +138,7 @@ if test "x$enable_histories" = xno; then
fi
AC_ARG_ENABLE(justify,
AS_HELP_STRING([--disable-justify], [Disable justify/unjustify functions]))
AS_HELP_STRING([--disable-justify], [Disable the justify/unjustify functions]))
if test "x$enable_justify" = xno; then
AC_DEFINE(DISABLE_JUSTIFY, 1, [Define this to disable the justify routines.])
fi
@@ -133,52 +153,69 @@ if test "x$enable_tiny" = xyes; then
enable_linenumbers=no
fi
fi
if test "x$disable_linenumbers" != xyes; then
if test "x$enable_linenumbers" != xno; then
AC_DEFINE(ENABLE_LINENUMBERS, 1, [Define this to enable line numbering.])
fi
if test "x$enable_linenumbers" != xno; then
AC_DEFINE(ENABLE_LINENUMBERS, 1, [Define this to enable line numbering.])
fi
AC_ARG_ENABLE(mouse,
AS_HELP_STRING([--disable-mouse], [Disable mouse support (and -m flag)]))
if test "x$enable_mouse" = xno; then
AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable the mouse support.])
AS_HELP_STRING([--disable-mouse], [Disable mouse support]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_mouse" != xyes; then
enable_mouse=no
fi
fi
if test "x$enable_mouse" != xno; then
AC_DEFINE(ENABLE_MOUSE, 1, [Define this to enable mouse support.])
fi
AC_ARG_ENABLE(multibuffer,
AS_HELP_STRING([--disable-multibuffer], [Disable multiple file buffers]))
if test "x$enable_multibuffer" = xno; then
AC_DEFINE(DISABLE_MULTIBUFFER, 1, [Define this to disable multiple file buffers.])
if test "x$enable_tiny" = xyes; then
if test "x$enable_multibuffer" != xyes; then
enable_multibuffer=no
fi
fi
if test "x$enable_multibuffer" != xno; then
AC_DEFINE(ENABLE_MULTIBUFFER, 1, [Define this to enable multiple file buffers.])
fi
AC_ARG_ENABLE(nanorc,
AS_HELP_STRING([--disable-nanorc], [Disable use of .nanorc files]))
if test "x$enable_nanorc" = xno; then
AC_DEFINE(DISABLE_NANORC, 1, [Define this to disable the use of .nanorc files.])
else
AS_HELP_STRING([--disable-nanorc], [Disable the use of .nanorc files]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_nanorc" != xyes; then
enable_nanorc=no
fi
fi
if test "x$enable_nanorc" != xno; then
AC_DEFINE(ENABLE_NANORC, 1, [Define this to enable the use of .nanorc files.])
nanorc_support=yes
fi
AC_ARG_ENABLE(operatingdir,
AS_HELP_STRING([--disable-operatingdir], [Disable setting of operating directory (chroot of sorts)]))
AS_HELP_STRING([--disable-operatingdir], [Disable the setting of an operating directory]))
if test "x$enable_operatingdir" = xno; then
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of the operating directory (chroot of sorts).])
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of an operating directory (a chroot of sorts).])
fi
AC_ARG_ENABLE(speller,
AS_HELP_STRING([--disable-speller], [Disable spell checker functions]))
AS_HELP_STRING([--disable-speller], [Disable the spell-checker functions]))
if test "x$enable_speller" = xno; then
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell checker functions.])
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell-checker functions.])
fi
AC_ARG_ENABLE(tabcomp,
AS_HELP_STRING([--disable-tabcomp], [Disable tab completion functions]))
if test "x$enable_tabcomp" = xno; then
AC_DEFINE(DISABLE_TABCOMP, 1, [Define this to disable the tab completion functions for filenames and search strings.])
AS_HELP_STRING([--disable-tabcomp], [Disable the tab-completion functions]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_tabcomp" != xyes; then
enable_tabcomp=no
fi
fi
if test "x$enable_tabcomp" != xno; then
AC_DEFINE(ENABLE_TABCOMP, 1, [Define this to have tab completion for filenames and search strings.])
fi
AC_ARG_ENABLE(wordcomp,
AS_HELP_STRING([--disable-wordcomp], [Disable the word completion function]))
AS_HELP_STRING([--disable-wordcomp], [Disable the word-completion function]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_wordcomp" = xyes; then
AC_MSG_ERROR([--enable-wordcomp cannot work with --enable-tiny])
@@ -186,16 +223,14 @@ if test "x$enable_tiny" = xyes; then
enable_wordcomp=no
fi
fi
if test "x$disable_wordcomp" != xyes; then
if test "x$enable_wordcomp" != xno; then
AC_DEFINE(ENABLE_WORDCOMPLETION, 1, [Define this to enable the word completion function.])
fi
if test "x$enable_wordcomp" != xno; then
AC_DEFINE(ENABLE_WORDCOMPLETION, 1, [Define this to enable the word-completion function.])
fi
AC_ARG_ENABLE(wrapping,
AS_HELP_STRING([--disable-wrapping], [Disable all wrapping of text (and -w flag)]))
AS_HELP_STRING([--disable-wrapping], [Disable all hard-wrapping of text]))
if test "x$enable_wrapping" = xno; then
AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable all text wrapping.])
AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable all hard text wrapping.])
fi
AC_ARG_ENABLE(wrapping-as-root,
@@ -207,7 +242,7 @@ fi
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug], [Enable debugging (disabled by default)]))
if test "x$enable_debug" = xyes; then
AC_DEFINE(DEBUG, 1, [Define this to enable debug messages and assert warnings.])
AC_DEFINE(DEBUG, 1, [Define this to enable debug messages and abortion on failing asserts.])
else
AC_DEFINE(NDEBUG, 1, [Shut up assert warnings :-)])
fi
@@ -216,23 +251,17 @@ AC_ARG_ENABLE(tiny,
AS_HELP_STRING([--enable-tiny], [Disable features for the sake of size]))
if test "x$enable_tiny" = xyes; then
AC_DEFINE(NANO_TINY, 1, [Define this to make the nano executable as small as possible.])
if test "x$enable_browser" != xyes; then
AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in file browser.])
fi
if test "x$enable_color" != xyes; then
AC_DEFINE(DISABLE_COLOR, 1, [Define this to disable syntax highlighting.])
color_support=no
else
if test "x$enable_nanorc" != xyes; then
AC_MSG_ERROR([--enable-color with --enable-tiny cannot work without --enable-nanorc])
AC_MSG_ERROR([--enable-color needs --enable-nanorc to work])
fi
fi
if test "x$enable_extra" != xyes; then
AC_DEFINE(DISABLE_EXTRA, 1, [Define this to disable extra stuff.])
fi
if test "x$enable_help" != xyes; then
AC_DEFINE(DISABLE_HELP, 1, [Define this to disable the help text display.])
fi
if test "x$enable_histories" != xyes; then
AC_DEFINE(DISABLE_HISTORIES, 1, [Define this to disable search and position histories.])
fi
@@ -242,23 +271,11 @@ if test "x$enable_tiny" = xyes; then
if test "x$enable_libmagic" != xyes; then
enable_libmagic=no
fi
if test "x$enable_mouse" != xyes; then
AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable the mouse support.])
fi
if test "x$enable_multibuffer" != xyes; then
AC_DEFINE(DISABLE_MULTIBUFFER, 1, [Define this to disable multiple file buffers.])
fi
if test "x$enable_nanorc" != xyes; then
AC_DEFINE(DISABLE_NANORC, 1, [Define this to disable the use of .nanorc files.])
fi
if test "x$enable_operatingdir" != xyes; then
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of the operating directory (chroot of sorts).])
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of an operating directory (a chroot of sorts).])
fi
if test "x$enable_speller" != xyes; then
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell checker functions.])
fi
if test "x$enable_tabcomp" != xyes; then
AC_DEFINE(DISABLE_TABCOMP, 1, [Define this to disable the tab completion functions for files and search strings.])
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell-checker functions.])
fi
if test "x$enable_wrapping" != xyes; then
AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable all text wrapping.])
@@ -545,13 +562,13 @@ else
fi
AC_CHECK_LIB([$CURSES_LIB_NAME], [use_default_colors],
[AC_DEFINE(HAVE_USE_DEFAULT_COLORS, 1, [Define this if your curses library has the use_default_colors() command.])],
[AC_DEFINE(HAVE_USE_DEFAULT_COLORS, 1, [Define this if your curses library has the use_default_colors() function.])],
[], [$CURSES_LIB])
AC_CHECK_LIB([$CURSES_LIB_NAME], [set_escdelay],
[AC_DEFINE(HAVE_SET_ESCDELAY, 1, [Define this if your curses library has the set_escdelay() function.])],
[], [$CURSES_LIB])
AC_CHECK_LIB([$CURSES_LIB_NAME], [key_defined],
[AC_DEFINE(HAVE_KEY_DEFINED, 1, [Define this if your curses library has the key_defined() command.])],
[AC_DEFINE(HAVE_KEY_DEFINED, 1, [Define this if your curses library has the key_defined() function.])],
[], [$CURSES_LIB])
dnl Parse any configure options.
@@ -678,7 +695,7 @@ int main(void)
int testcolor = COLOR_WHITE;
return 0;
}],
AC_DEFINE(NEED_XOPEN_SOURCE_EXTENDED, 1, [Define this if you need the _XOPEN_SOURCE_EXTENDED macro for color support])
AC_DEFINE(NEED_XOPEN_SOURCE_EXTENDED, 1, [Define this if you need the _XOPEN_SOURCE_EXTENDED macro for color support.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(not sure)
AC_MSG_WARN([*** Couldn't successfully compile basic color test with or without _XOPEN_SOURCE_EXTENDED])
@@ -696,7 +713,7 @@ int main(void)
COLS = 25;
return 0;
}],
AC_DEFINE(REDEFINING_MACROS_OK, 1, [Define this if you know your curses library allows LINES and COLS to be redefined to deal with a resizing bug])
AC_DEFINE(REDEFINING_MACROS_OK, 1, [Define this if you know your curses library allows LINES and COLS to be redefined to deal with a resizing bug.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no),
AC_MSG_WARN([*** Can't check for macro redefinability when cross-compiling]))

View File

@@ -38,10 +38,11 @@
<a href="#4.2">4.2. Ack! My Backspace/Delete/Enter/Meta/double bucky key doesn't seem to work! What can I do?</a><br>
<a href="#4.3">4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</a><br>
<a href="#4.4">4.4. Ack! When I hold down a Meta key combination for a while, the character of the held key gets inserted now and then. What gives?</a><br>
<a href="#4.5">4.5. How do I type the F13-F16 keys shown in the help browser? My keyboard only has F1-F12!</a><br>
<a href="#4.5">4.5. How do I type the F13-F16 keys listed in the help viewer? My keyboard only has F1-F12!</a><br>
<a href="#4.6">4.6. nano crashes when I type &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>
@@ -82,7 +83,7 @@
<h2><a name="1.3"></a>1.3. Why the name change from TIP?</h2>
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program &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.4"></a>1.4. What is the current version of nano?</h2>
<blockquote><p>The current version of nano <i>should</i> be <b>2.8.1</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<blockquote><p>The current version of nano <i>should</i> be <b>2.8.4</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>
@@ -184,16 +187,18 @@
<blockquote><p>You can use the <b>-K</b> or <b>--rebindkeypad</b> option on the command line, or add the line <b>set rebindkeypad</b> to your .nanorc. However, nano's mouse support won't work properly if you do any of these things.</p></blockquote>
<h2><a name="4.4"></a>4.4. Ack! When I hold down a Meta key combination for a while, the character of the held key gets inserted now and then. What gives?</h2>
<blockquote><p>This was a bug in how nano handled consecutive escape sequences. It should be fixed since version 2.6.0.</p></blockquote>
<h2><a name="4.5"></a>4.5. How do I type the F13-F16 keys shown in the help browser? My keyboard only has F1-F12!</h2>
<h2><a name="4.5"></a>4.5. How do I type the F13-F16 keys listed in the help viewer? My keyboard only has F1-F12!</h2>
<blockquote><p>It depends on the terminal type you're using. On some terminals, such as the FreeBSD console, xterm, konsole, and gnome-terminal, Shift-F1 to Shift-F4 will generate F13 to F16. On other terminals, such as the Linux console, rxvt, and Eterm, Shift-F3 to Shift-F6 will generate F13 to F16.</p></blockquote>
<h2><a name="4.6"></a>4.6. nano crashes when I type &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>

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 2.8.1" "April 2017"
.TH NANO 1 "version 2.8.4" "May 2017"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
@@ -27,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.
@@ -60,7 +59,7 @@ Since nano-2.7.0, text can also be selected by holding Shift and moving the
cursor with the arrow keys. Holding down the Alt key too will increase the
stride.
.PP
The two lines at the bottom of the screen show the most important commands;
The two lines at the bottom of the screen show some important commands;
the built-in help (\fB^G\fR) lists all the available ones.
The default key bindings can be changed via the .nanorc file -- see
.BR nanorc (5).
@@ -80,7 +79,7 @@ filename suffixed with a tilde (\fB~\fP).
.TP
.BR \-C\ \fIdirectory\fR ", " \-\-backupdir= \fIdirectory
Make and keep not just one backup file, but make and keep a uniquely
numbered one every time a file is saved -- when backups are enabled.
numbered one every time a file is saved -- when backups are enabled (\fB\-B\fR).
The uniquely numbered files are stored in the specified \fIdirectory\fR.
.TP
.BR \-D ", " \-\-boldtext
@@ -90,10 +89,10 @@ Use bold text instead of reverse video text.
Convert typed tabs to spaces.
.TP
.BR \-F ", " \-\-multibuffer
Enable multiple file buffers (if support for them has been compiled in).
Read a file into a new buffer by default.
.TP
.BR \-G ", " \-\-locking
Enable vim-style file locking when editing files.
Use vim-style file locking when editing files.
.TP
.BR \-H ", " \-\-historylog
Log search and replace strings to \fI~/.nano/search_history\fP, so they can be
@@ -137,7 +136,7 @@ This restricted mode is also accessible by invoking \fBnano\fP
with any name beginning with 'r' (e.g. "rnano").
.TP
.BR \-S ", " \-\-smooth
Enable smooth scrolling. Text will scroll line-by-line, instead of the
Use smooth scrolling: text will scroll line-by-line, instead of the
usual chunk-by-chunk behavior.
.TP
.BR \-T\ \fInumber\fR ", " \-\-tabsize= \fInumber
@@ -145,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
@@ -165,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
@@ -300,7 +300,7 @@ Please report any other bugs that you encounter via:
\fIhttps://savannah.gnu.org/bugs/?group=nano\fR.
.SH HOMEPAGE
https://nano-editor.org/
\fIhttps://nano-editor.org/\fR
.SH SEE ALSO
.BR nanorc (5)

View File

@@ -6,8 +6,8 @@
@smallbook
@set EDITION 0.4
@set VERSION 2.8.1
@set UPDATED April 2017
@set VERSION 2.8.4
@set UPDATED May 2017
@dircategory Editors
@direntry
@@ -21,7 +21,7 @@
@titlepage
@title GNU @code{nano}
@subtitle a small and friendly text editor
@subtitle version 2.8.1
@subtitle version 2.8.4
@author Chris Allegretta
@page
@@ -600,12 +600,12 @@ nanorc. See @xref{Syntax Highlighting}, for more info.
@item Suspension Toggle (Meta-Z)
toggles the @code{-z} (@code{--suspend}) command-line option.
@item Soft Wrapping Toggle (Meta-$)
toggles the @code{-$} (@code{--softwrap}) command-line option.
@item Line Numbers Toggle (Meta-#)
toggles the @code{-l} (@code{--linenumbers}) command-line option.
@item Soft Wrapping Toggle (Meta-$)
toggles the @code{-$} (@code{--softwrap}) command-line option.
@end table
@@ -672,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
@@ -892,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
@@ -946,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
@@ -1418,6 +1419,16 @@ 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 Current Cursor Position
The output of the "Display Cursor Position" command (^C) displays
not only the current line and character position of the cursor,
but also (between the two) the current column position.
@item Spell Checking
In the internal spell checker misspelled words are sorted alphabetically
and trimmed for uniqueness, such that the words 'apple' and 'Apple' will
be prompted for correction separately.
@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,
@@ -1446,16 +1457,6 @@ not have to be restarted to turn a particular feature on or off.
See the internal help function (^G) for a list of features that
can be toggled. Or see @xref{Feature Toggles} instead.
@item Current Cursor Position
The output of the "Display Cursor Position" command (^C) displays
not only the current line and character position of the cursor,
but also (between the two) the current column position.
@item Spell Checking
In the internal spell checker misspelled words are sorted alphabetically
and trimmed for uniqueness, such that the words 'apple' and 'Apple' will
be prompted for correction separately.
@end table
@@ -1479,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,
@@ -1509,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.
@@ -1539,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

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 2.8.1" "April 2017"
.TH NANORC 5 "version 2.8.4" "May 2017"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
@@ -75,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
@@ -288,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
@@ -345,32 +346,33 @@ foreground. If your terminal supports transparency, not specifying a
background.
.TP
.B icolor \fIfgcolor\fR,\fIbgcolor\fR """\fIregex\fR""" ...
Same as above, except that the text matching is case insensitive.
Same as above, except that the matching is case insensitive.
.TP
.BR color " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIsr\fR"" " end= """\fIer\fR""
.BR color " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIfromrx\fR"" " end= """\fItorx\fR""
Display all pieces of text whose start matches extended regular expression
\fIsr\fP and whose end matches extended regular expression \fIer\fP with
\fIfromrx\fP and whose end matches extended regular expression \fItorx\fP with
foreground color \fIfgcolor\fP and background color \fIbgcolor\fP,
at least one of which must be specified. This means that, after an
initial instance of \fIsr\fP, all text will be highlighted until the
first instance of \fIer\fP. This allows syntax highlighting to span
initial instance of \fIfromrx\fP, all text until the first instance of
\fItorx\fP will be colored. This allows syntax highlighting to span
multiple lines.
.TP
.BR icolor " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIsr\fR"" " end= """\fIer\fR""
Same as above, except that the text matching is case insensitive.
.BR icolor " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIfromrx\fR"" " end= """\fItorx\fR""
Same as above, except that the matching is case insensitive.
.TP
.BR include " ""\fIsyntaxfile\fR"""
Read in self-contained color syntaxes from \fIsyntaxfile\fP. Note that
\fIsyntaxfile\fP may contain only the above commands, from \fBsyntax\fP
to \fBicolor\fP.
.TP
.BI extendsyntax " str directive " \fR[ "arg " \fR...]
Extend the syntax previously defined as \fIstr\fP to include
new information. This allows you to add a new \fBcolor\fP, \fBicolor\fP,
\fBheader\fP, \fBmagic\fP, \fBcomment\fP, \fBlinter\fP, or \fBformatter\fP directive
to an already defined syntax -- useful when you want to
.BI extendsyntax " name directive " \fR[ "arg " \fR...]
Extend the syntax previously defined as \fIname\fP to include
new information. This allows adding a new \fBcolor\fP, \fBicolor\fP,
\fBheader\fP, \fBmagic\fP, \fBcomment\fP, \fBlinter\fP, or \fBformatter\fP
directive to an already defined syntax -- useful when you want to
slightly improve a syntax defined in one of the system-installed
files (which are normally not writable)
files (which are normally not writable).
.SH REBINDING KEYS
Key bindings can be changed via the following two commands:
.TP

View File

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

910
po/bg.po

File diff suppressed because it is too large Load Diff

931
po/ca.po

File diff suppressed because it is too large Load Diff

913
po/cs.po

File diff suppressed because it is too large Load Diff

1026
po/da.po

File diff suppressed because it is too large Load Diff

931
po/de.po

File diff suppressed because it is too large Load Diff

931
po/eo.po

File diff suppressed because it is too large Load Diff

959
po/es.po

File diff suppressed because it is too large Load Diff

910
po/eu.po

File diff suppressed because it is too large Load Diff

913
po/fi.po

File diff suppressed because it is too large Load Diff

997
po/fr.po

File diff suppressed because it is too large Load Diff

931
po/ga.po

File diff suppressed because it is too large Load Diff

913
po/gl.po

File diff suppressed because it is too large Load Diff

1987
po/hr.po

File diff suppressed because it is too large Load Diff

1123
po/hu.po

File diff suppressed because it is too large Load Diff

942
po/id.po

File diff suppressed because it is too large Load Diff

913
po/it.po

File diff suppressed because it is too large Load Diff

913
po/ja.po

File diff suppressed because it is too large Load Diff

912
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

931
po/nb.po

File diff suppressed because it is too large Load Diff

953
po/nl.po

File diff suppressed because it is too large Load Diff

986
po/nn.po

File diff suppressed because it is too large Load Diff

913
po/pl.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

991
po/ro.po

File diff suppressed because it is too large Load Diff

911
po/ru.po

File diff suppressed because it is too large Load Diff

910
po/sl.po

File diff suppressed because it is too large Load Diff

969
po/sr.po

File diff suppressed because it is too large Load Diff

913
po/sv.po

File diff suppressed because it is too large Load Diff

913
po/tr.po

File diff suppressed because it is too large Load Diff

929
po/uk.po

File diff suppressed because it is too large Load Diff

933
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

@@ -4,7 +4,7 @@ AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -DSYSCONFDIR=\"$(sysconfdir)\" \
CLEANFILES = revision.h
if BUILDING_FROM_GIT
SOMETHING = "REVISION \"$(shell git describe --tags 2>/dev/null)\""
SOMETHING = "REVISION \"`git describe --tags 2>/dev/null`\""
else
SOMETHING = "NOTHING \"from tarball\""
endif
@@ -12,12 +12,13 @@ endif
nano.o: revision.h
winio.o: revision.h
revision.h: update_revision
# Always run the commands in this rule. But update the target
# only when the revision actually changed.
revision.h: FORCE
@[ -f $@ ] || touch $@
@echo "#define $(SOMETHING)" | cmp -s $@ - || \
echo "#define $(SOMETHING)" > $@
.PHONY: update_revision
echo "#define $(SOMETHING)" > $@
FORCE:
bin_PROGRAMS = nano
nano_SOURCES = browser.c \
@@ -38,7 +39,7 @@ nano_SOURCES = browser.c \
utils.c \
winio.c
nano_LDADD = @LIBINTL@ $(top_builddir)/lib/libgnu.a
nano_LDADD = @LIBINTL@ $(top_builddir)/lib/libgnu.a $(LIB_CLOCK_GETTIME)
install-exec-hook:
cd $(DESTDIR)$(bindir) && rm -f rnano && $(LN_S) nano rnano

View File

@@ -27,7 +27,7 @@
#include <unistd.h>
#include <errno.h>
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
static char **filelist = NULL;
/* The list of files to display in the file browser. */
@@ -122,7 +122,7 @@ char *do_browser(char *path)
kbinput = get_kbinput(edit);
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y;
@@ -151,7 +151,7 @@ char *do_browser(char *path)
continue;
}
#endif /* !DISABLE_MOUSE */
#endif /* ENABLE_MOUSE */
func = parse_browser_input(&kbinput);
@@ -162,7 +162,7 @@ char *do_browser(char *path)
kbinput = KEY_WINCH;
#endif
} else if (func == do_help_void) {
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
do_help_void();
#ifndef NANO_TINY
/* The window dimensions might have changed, so act as if. */
@@ -183,14 +183,12 @@ char *do_browser(char *path)
} else if (func == do_right) {
if (selected < filelist_len - 1)
selected++;
#ifndef NANO_TINY
} else if (func == do_prev_word_void) {
selected -= (selected % width);
} else if (func == do_next_word_void) {
selected += width - 1 - (selected % width);
if (selected >= filelist_len)
selected = filelist_len - 1;
#endif
} else if (func == do_up_void) {
if (selected >= width)
selected -= width;
@@ -490,7 +488,11 @@ functionptrtype parse_browser_input(int *kbinput)
return do_enter;
case 'W':
case 'w':
case '/':
return do_search;
case 'N':
case 'n':
return do_research;
}
}
return func_from_key(kbinput);
@@ -808,4 +810,4 @@ char *strip_last_component(const char *path)
return copy;
}
#endif /* !DISABLE_BROWSER */
#endif /* ENABLE_BROWSER */

View File

@@ -70,8 +70,6 @@ void mbtowc_reset(void)
/* This function is equivalent to isalpha() for multibyte characters. */
bool is_alpha_mbchar(const char *c)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
@@ -90,8 +88,6 @@ bool is_alpha_mbchar(const char *c)
/* This function is equivalent to isalnum() for multibyte characters. */
bool is_alnum_mbchar(const char *c)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
@@ -110,8 +106,6 @@ bool is_alnum_mbchar(const char *c)
/* This function is equivalent to isblank() for multibyte characters. */
bool is_blank_mbchar(const char *c)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
@@ -158,8 +152,6 @@ bool is_cntrl_mbchar(const char *c)
/* This function is equivalent to ispunct() for multibyte characters. */
bool is_punct_mbchar(const char *c)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
@@ -234,8 +226,6 @@ char control_mbrep(const char *c, bool isdata)
* return the number of columns that the character occupies. */
int length_of_char(const char *c, int *width)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
@@ -265,8 +255,6 @@ int length_of_char(const char *c, int *width)
/* This function is equivalent to wcwidth() for multibyte characters. */
int mbwidth(const char *c)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
@@ -321,14 +309,10 @@ char *make_mbchar(long chr, int *chr_mb_len)
* col isn't NULL, add the character's width (in columns) to it. */
int parse_mbchar(const char *buf, char *chr, size_t *col)
{
int length;
assert(buf != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
/* Get the number of bytes in the multibyte character. */
length = mblen(buf, MAXCHARLEN);
int length = mblen(buf, MAXCHARLEN);
/* When the multibyte sequence is invalid, only take the first byte. */
if (length <= 0) {
@@ -358,12 +342,11 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
} else
*col += mbwidth(buf);
}
return length;
} else
#endif
{
/* A byte character is one byte long. */
length = 1;
/* When requested, store the byte character in chr. */
if (chr != NULL)
*chr = *buf;
@@ -382,33 +365,48 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
else
(*col)++;
}
}
return length;
return 1;
}
}
/* Return the index in buf of the beginning of the multibyte character
* before the one at pos. */
size_t move_mbleft(const char *buf, size_t pos)
{
size_t before, char_len = 0;
#ifdef ENABLE_UTF8
if (use_utf8) {
size_t before, char_len = 0;
assert(buf != NULL && pos <= strlen(buf));
if (pos < 4)
before = 0;
else {
const char *ptr = buf + pos;
/* There is no library function to move backward one multibyte
* character. So we just start groping for one at the farthest
* possible point. */
if (pos < MAXCHARLEN)
before = 0;
else
before = pos - MAXCHARLEN;
/* Probe for a valid starter byte in the preceding four bytes. */
if ((signed char)*(--ptr) > -65)
before = pos - 1;
else if ((signed char)*(--ptr) > -65)
before = pos - 2;
else if ((signed char)*(--ptr) > -65)
before = pos - 3;
else if ((signed char)*(--ptr) > -65)
before = pos - 4;
else
before = pos - 1;
}
while (before < pos) {
char_len = parse_mbchar(buf + before, NULL, NULL);
before += char_len;
}
/* Move forward again until we reach the original character,
* so we know the length of its preceding the character. */
while (before < pos) {
char_len = parse_mbchar(buf + before, NULL, NULL);
before += char_len;
}
return before - char_len;
return before - char_len;
} else
#endif
return (pos == 0 ? 0 : pos - 1);
}
/* Return the index in buf of the beginning of the multibyte character
@@ -473,12 +471,7 @@ char *mbstrcasestr(const char *haystack, const char *needle)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
size_t needle_len;
if (*needle == '\0')
return (char *)haystack;
needle_len = mbstrlen(needle);
size_t needle_len = mbstrlen(needle);
while (*haystack != '\0') {
if (mbstrncasecmp(haystack, needle, needle_len) == 0)
@@ -494,19 +487,13 @@ char *mbstrcasestr(const char *haystack, const char *needle)
}
/* This function is equivalent to strstr(), except in that it scans the
* string in reverse, starting at rev_start. */
* string in reverse, starting at pointer. */
char *revstrstr(const char *haystack, const char *needle,
const char *pointer)
{
size_t needle_len = strlen(needle);
size_t tail_len = strlen(pointer);
if (needle_len == 0)
return (char *)pointer;
if (strlen(haystack) < needle_len)
return NULL;
if (tail_len < needle_len)
pointer += tail_len - needle_len;
@@ -520,65 +507,53 @@ char *revstrstr(const char *haystack, const char *needle,
}
/* This function is equivalent to strcasestr(), except in that it scans
* the string in reverse, starting at rev_start. */
char *revstrcasestr(const char *haystack, const char *needle, const char
*rev_start)
* the string in reverse, starting at pointer. */
char *revstrcasestr(const char *haystack, const char *needle,
const char *pointer)
{
size_t rev_start_len, needle_len;
size_t needle_len = strlen(needle);
size_t tail_len = strlen(pointer);
if (*needle == '\0')
return (char *)rev_start;
if (tail_len < needle_len)
pointer += tail_len - needle_len;
needle_len = strlen(needle);
if (strlen(haystack) < needle_len)
return NULL;
rev_start_len = strlen(rev_start);
for (; rev_start >= haystack; rev_start--, rev_start_len++) {
if (rev_start_len >= needle_len && strncasecmp(rev_start,
needle, needle_len) == 0)
return (char *)rev_start;
while (pointer >= haystack) {
if (strncasecmp(pointer, needle, needle_len) == 0)
return (char *)pointer;
pointer--;
}
return NULL;
}
/* This function is equivalent to strcasestr() for multibyte strings,
* except in that it scans the string in reverse, starting at rev_start. */
char *mbrevstrcasestr(const char *haystack, const char *needle, const
char *rev_start)
* except in that it scans the string in reverse, starting at pointer. */
char *mbrevstrcasestr(const char *haystack, const char *needle,
const char *pointer)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
size_t rev_start_len, needle_len;
size_t needle_len = mbstrlen(needle);
size_t tail_len = mbstrlen(pointer);
if (*needle == '\0')
return (char *)rev_start;
if (tail_len < needle_len)
pointer += tail_len - needle_len;
needle_len = mbstrlen(needle);
if (mbstrlen(haystack) < needle_len)
if (pointer < haystack)
return NULL;
rev_start_len = mbstrlen(rev_start);
while (TRUE) {
if (rev_start_len >= needle_len &&
mbstrncasecmp(rev_start, needle, needle_len) == 0)
return (char *)rev_start;
if (mbstrncasecmp(pointer, needle, needle_len) == 0)
return (char *)pointer;
/* If we've reached the head of the haystack, we found nothing. */
if (rev_start == haystack)
if (pointer == haystack)
return NULL;
rev_start = haystack + move_mbleft(haystack, rev_start - haystack);
rev_start_len++;
pointer = haystack + move_mbleft(haystack, pointer - haystack);
}
} else
#endif
return revstrcasestr(haystack, needle, rev_start);
return revstrcasestr(haystack, needle, pointer);
}
/* This function is equivalent to strlen() for multibyte strings. */
@@ -608,8 +583,6 @@ size_t mbstrnlen(const char *s, size_t maxlen)
/* This function is equivalent to strchr() for multibyte strings. */
char *mbstrchr(const char *s, const char *c)
{
assert(s != NULL && c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
bool bad_s_mb = FALSE, bad_c_mb = FALSE;
@@ -666,59 +639,54 @@ char *mbstrpbrk(const char *s, const char *accept)
return (char *) strpbrk(s, accept);
}
/* This function is equivalent to strpbrk(), except in that it scans the
* string in reverse, starting at rev_start. */
char *revstrpbrk(const char *s, const char *accept, const char
*rev_start)
/* Locate, in the string that starts at head, the first occurrence of any of
* the characters in the string accept, starting from pointer and searching
* backwards. */
char *revstrpbrk(const char *head, const char *accept, const char *pointer)
{
assert(s != NULL && accept != NULL && rev_start != NULL);
if (*rev_start == '\0') {
if (rev_start == s)
if (*pointer == '\0') {
if (pointer == head)
return NULL;
rev_start--;
pointer--;
}
for (; rev_start >= s; rev_start--) {
if (strchr(accept, *rev_start) != NULL)
return (char *)rev_start;
while (pointer >= head) {
if (strchr(accept, *pointer) != NULL)
return (char *)pointer;
pointer--;
}
return NULL;
}
/* This function is equivalent to strpbrk() for multibyte strings,
* except in that it scans the string in reverse, starting at rev_start. */
char *mbrevstrpbrk(const char *s, const char *accept, const char
*rev_start)
/* The same as the preceding function but then for multibyte strings. */
char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer)
{
assert(s != NULL && accept != NULL && rev_start != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
if (*rev_start == '\0') {
if (rev_start == s)
if (*pointer == '\0') {
if (pointer == head)
return NULL;
rev_start = s + move_mbleft(s, rev_start - s);
pointer = head + move_mbleft(head, pointer - head);
}
while (TRUE) {
if (mbstrchr(accept, rev_start) != NULL)
return (char *)rev_start;
if (mbstrchr(accept, pointer) != NULL)
return (char *)pointer;
/* If we've reached the head of the string, we found nothing. */
if (rev_start == s)
if (pointer == head)
return NULL;
rev_start = s + move_mbleft(s, rev_start - s);
pointer = head + move_mbleft(head, pointer - head);
}
} else
#endif
return revstrpbrk(s, accept, rev_start);
return revstrpbrk(head, accept, pointer);
}
#endif /* !NANO_TINY */
#if !defined(DISABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
/* Return TRUE if the string s contains one or more blank characters,
* and FALSE otherwise. */
bool has_blank_chars(const char *s)
@@ -751,7 +719,7 @@ bool has_blank_mbchars(const char *s)
#endif
return has_blank_chars(s);
}
#endif /* !DISABLE_NANORC && (!NANO_TINY || !DISABLE_JUSTIFY) */
#endif /* ENABLE_NANORC && (!NANO_TINY || !DISABLE_JUSTIFY) */
#ifdef ENABLE_UTF8
/* Return TRUE if wc is valid Unicode, and FALSE otherwise. */
@@ -764,7 +732,7 @@ bool is_valid_unicode(wchar_t wc)
}
#endif
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
/* Check if the string s is a valid multibyte string. Return TRUE if it
* is, and FALSE otherwise. */
bool is_valid_mbstring(const char *s)
@@ -776,4 +744,4 @@ bool is_valid_mbstring(const char *s)
#endif
return TRUE;
}
#endif /* !DISABLE_NANORC */
#endif /* ENABLE_NANORC */

View File

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

@@ -108,8 +108,8 @@ void cut_to_eof(void)
}
#endif /* !NANO_TINY */
/* Move text from the current filestruct into the cutbuffer. If
* copy_text is TRUE, copy the text back into the filestruct afterward.
/* Move text from the current buffer into the cutbuffer. If
* copy_text is TRUE, copy the text back into the buffer afterward.
* If cut_till_eof is TRUE, move all text from the current cursor
* position to the end of the file into the cutbuffer. */
void do_cut_text(bool copy_text, bool cut_till_eof)
@@ -201,7 +201,7 @@ void do_cut_text(bool copy_text, bool cut_till_eof)
#endif
}
/* Move text from the current filestruct into the cutbuffer. */
/* Move text from the current buffer into the cutbuffer. */
void do_cut_text_void(void)
{
#ifndef NANO_TINY
@@ -214,8 +214,8 @@ void do_cut_text_void(void)
}
#ifndef NANO_TINY
/* Move text from the current filestruct into the cutbuffer, and copy it
* back into the filestruct afterward. If the mark is set or the cursor
/* Move text from the current buffer into the cutbuffer, and copy it
* back into the buffer afterward. If the mark is set or the cursor
* was moved, blow away previous contents of the cutbuffer. */
void do_copy_text(void)
{
@@ -254,7 +254,7 @@ void do_cut_till_eof(void)
}
#endif /* !NANO_TINY */
/* Copy text from the cutbuffer into the current filestruct. */
/* Copy text from the cutbuffer into the current buffer. */
void do_uncut_text(void)
{
ssize_t was_lineno = openfile->current->lineno;
@@ -273,7 +273,7 @@ void do_uncut_text(void)
was_leftedge = (xplustabs() / editwincols) * editwincols;
#endif
/* Add a copy of the text in the cutbuffer to the current filestruct
/* Add a copy of the text in the cutbuffer to the current buffer
* at the current cursor position. */
copy_from_buffer(cutbuffer);
@@ -291,8 +291,8 @@ void do_uncut_text(void)
/* Mark the file as modified. */
set_modified();
/* Update the cursor position to account for the inserted lines. */
reset_cursor();
/* Update current_y to account for the inserted lines. */
place_the_cursor(TRUE);
refresh_needed = TRUE;

View File

@@ -62,32 +62,29 @@ bool has_valid_path(const char *filename)
return validity;
}
/* Add an entry to the circular list of openfile structs. */
/* Add an item to the circular list of openfile structs. */
void make_new_buffer(void)
{
openfilestruct *newnode = make_new_opennode();
if (openfile == NULL) {
openfile = make_new_opennode();
/* Make the first open file the only element in the list. */
openfile->prev = openfile;
openfile->next = openfile;
newnode->prev = newnode;
newnode->next = newnode;
} else {
openfilestruct *newnode = make_new_opennode();
/* Add the new open file after the current one in the list. */
newnode->prev = openfile;
newnode->next = openfile->next;
openfile->next->prev = newnode;
openfile->next = newnode;
/* Make the new file the current one. */
openfile = newnode;
/* There is more than one file open: show Close in help lines. */
/* There is more than one file open: show "Close" in help lines. */
exitfunc->desc = close_tag;
}
/* Start initializing the new buffer. */
/* Make the new buffer the current one, and start initializing it. */
openfile = newnode;
openfile->filename = mallocstrcpy(NULL, "");
initialize_buffer_text();
@@ -117,11 +114,9 @@ void make_new_buffer(void)
#endif
}
/* Initialize the text of the current openfile struct. */
/* Initialize the text and pointers of the current openfile struct. */
void initialize_buffer_text(void)
{
assert(openfile != NULL);
openfile->fileage = make_new_node(NULL);
openfile->fileage->data = mallocstrcpy(NULL, "");
@@ -470,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);
@@ -489,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. */
@@ -583,31 +578,29 @@ void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
if (!old_no_newlines)
UNSET(NO_NEWLINES);
}
#endif /* !ENABLE_TINY */
#endif /* !NANO_TINY */
#endif /* !DISABLE_SPELLER */
/* Update the screen to account for the current buffer. */
void display_buffer(void)
/* Update the titlebar and the multiline cache to match the current buffer. */
void prepare_for_display(void)
{
/* Update the titlebar, since the filename may have changed. */
titlebar(NULL);
if (!inhelp)
titlebar(NULL);
#ifndef DISABLE_COLOR
/* Make sure we're using the buffer's associated colors. */
color_init();
/* If there are multiline coloring regexes, and there is no
* multiline cache data yet, precalculate it now. */
if (openfile->syntax && openfile->syntax->nmultis > 0 &&
openfile->fileage->multidata == NULL)
precalc_multicolorinfo();
#endif
/* Update the content of the edit window straightaway. */
edit_refresh();
have_palette = FALSE;
#endif
refresh_needed = TRUE;
}
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
/* Switch to a neighbouring file buffer; to the next if to_next is TRUE;
* otherwise, to the previous one. */
void switch_to_prevnext_buffer(bool to_next)
@@ -615,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;
}
@@ -635,13 +628,14 @@ void switch_to_prevnext_buffer(bool to_next)
openfile->firstcolumn = 0;
#endif
/* Update the screen to account for the current buffer. */
display_buffer();
/* Update titlebar and multiline info to match the current buffer. */
prepare_for_display();
/* Indicate the switch on the statusbar. */
statusline(HUSH, _("Switched to %s"),
((openfile->filename[0] == '\0') ?
_("New Buffer") : openfile->filename));
if (!inhelp)
statusline(HUSH, _("Switched to %s"),
((openfile->filename[0] == '\0') ?
_("New Buffer") : openfile->filename));
#ifdef DEBUG
dump_filestruct(openfile->current);
@@ -689,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)
@@ -908,6 +902,10 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
/* Set the desired x position at the end of what was inserted. */
openfile->placewewant = xplustabs();
/* If we've read a help file, don't give any feedback. */
if (inhelp)
return;
if (!writable)
statusline(ALERT, _("File '%s' is unwritable"), filename);
#ifndef NANO_TINY
@@ -1001,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"));
}
@@ -1066,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");
@@ -1076,7 +1074,7 @@ void do_insertfile(void)
} else
#endif /* NANO_TINY */
{
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER))
msg = _("File to insert into new buffer [from %s]");
else
@@ -1108,14 +1106,13 @@ void do_insertfile(void)
} else {
ssize_t was_current_lineno = openfile->current->lineno;
size_t was_current_x = openfile->current_x;
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
#if !defined(NANO_TINY) || defined(ENABLE_BROWSER) || defined(ENABLE_MULTIBUFFER)
functionptrtype func = func_from_key(&i);
#endif
given = mallocstrcpy(given, answer);
#ifndef NANO_TINY
#ifndef DISABLE_MULTIBUFFER
if (func == new_buffer_void) {
#ifdef ENABLE_MULTIBUFFER
if (func == flip_newbuffer) {
/* Don't allow toggling when in view mode. */
if (!ISSET(VIEW_MODE))
TOGGLE(MULTIBUFFER);
@@ -1124,13 +1121,13 @@ void do_insertfile(void)
continue;
}
#endif
if (func == flip_execute_void) {
#ifndef NANO_TINY
if (func == flip_execute) {
execute = !execute;
continue;
}
#endif /* !NANO_TINY */
#ifndef DISABLE_BROWSER
#endif
#ifdef ENABLE_BROWSER
if (func == to_files_void) {
char *chosen = do_browse_from(answer);
@@ -1149,7 +1146,7 @@ void do_insertfile(void)
#ifndef NANO_TINY
if (execute) {
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
/* When in multibuffer mode, first open a blank buffer. */
if (ISSET(MULTIBUFFER))
open_buffer("", FALSE);
@@ -1157,7 +1154,7 @@ void do_insertfile(void)
/* Save the command's output in the current buffer. */
execute_command(answer);
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
/* If this is a new buffer, put the cursor at the top. */
if (ISSET(MULTIBUFFER)) {
openfile->current = openfile->fileage;
@@ -1178,7 +1175,7 @@ void do_insertfile(void)
open_buffer(answer, TRUE);
}
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER)) {
#ifndef DISABLE_HISTORIES
if (ISSET(POS_HISTORY)) {
@@ -1191,17 +1188,17 @@ void do_insertfile(void)
}
#endif /* !DISABLE_HISTORIES */
/* Update stuff to account for the current buffer. */
display_buffer();
prepare_for_display();
} else
#endif /* !DISABLE_MULTIBUFFER */
#endif /* ENABLE_MULTIBUFFER */
{
/* Mark the file as modified if it changed. */
if (openfile->current->lineno != was_current_lineno ||
openfile->current_x != was_current_x)
set_modified();
/* Update the cursor position to account for inserted lines. */
reset_cursor();
/* Update current_y to account for inserted lines. */
place_the_cursor(TRUE);
refresh_needed = TRUE;
}
@@ -1218,7 +1215,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
@@ -2049,7 +2046,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
filestruct *top, *bot;
size_t top_x, bot_x;
/* Partition the filestruct so that it contains only the marked text. */
/* Partition the buffer so that it contains only the marked text. */
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, NULL);
filepart = partition_filestruct(top, top_x, bot, bot_x);
@@ -2067,7 +2064,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
if (added_magicline)
remove_magicline();
/* Unpartition the filestruct so that it contains all the text again. */
/* Unpartition the buffer so that it contains all the text again. */
unpartition_filestruct(&filepart);
if (old_modified)
@@ -2130,11 +2127,12 @@ int do_writeout(bool exiting)
msg = (method == PREPEND) ? _("Prepend Selection to File") :
(method == APPEND) ? _("Append Selection to File") :
_("Write Selection to File");
else if (method != OVERWRITE)
msg = (method == PREPEND) ? _("File Name to Prepend to") :
_("File Name to Append to");
else
#endif /* !NANO_TINY */
msg = (method == PREPEND) ? _("File Name to Prepend to") :
(method == APPEND) ? _("File Name to Append to") :
_("File Name to Write");
msg = _("File Name to Write");
present_path = mallocstrcpy(present_path, "./");
@@ -2159,24 +2157,15 @@ int do_writeout(bool exiting)
} else {
functionptrtype func = func_from_key(&i);
/* Upon request, abandon the buffer, if user is sure. */
/* Upon request, abandon the buffer. */
if (func == discard_buffer) {
if (openfile->modified)
i = do_yesno_prompt(FALSE,
_("Save modified buffer anyway? "));
else
i = 0;
if (i == 0) {
free(given);
return 2; /* Yes, discard the buffer. */
} else
continue; /* Go back to the filename prompt. */
free(given);
return 2;
}
given = mallocstrcpy(given, answer);
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
if (func == to_files_void) {
char *chosen = do_browse_from(answer);
@@ -2187,7 +2176,7 @@ int do_writeout(bool exiting)
free(answer);
answer = chosen;
} else
#endif /* !DISABLE_BROWSER */
#endif
#ifndef NANO_TINY
if (func == dos_format_void) {
openfile->fmt = (openfile->fmt == DOS_FILE) ? NIX_FILE :
@@ -2200,15 +2189,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;
}
@@ -2388,7 +2377,7 @@ char *real_dir_from_tilde(const char *buf)
return retval;
}
#if !defined(DISABLE_TABCOMP) || !defined(DISABLE_BROWSER)
#if defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
/* Our sort routine for file listings. Sort alphabetically and
* case-insensitively, and sort directories before filenames. */
int diralphasort(const void *va, const void *vb)
@@ -2425,7 +2414,7 @@ void free_chararray(char **array, size_t len)
}
#endif
#ifndef DISABLE_TABCOMP
#ifdef ENABLE_TABCOMP
/* Is the given path a directory? */
bool is_dir(const char *buf)
{
@@ -2749,7 +2738,7 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
return buf;
}
#endif /* !DISABLE_TABCOMP */
#endif /* ENABLE_TABCOMP */
/* Return the filename part of the given path. */
const char *tail(const char *path)
@@ -3005,7 +2994,7 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
poshiststruct *posptr, *theone, *posprev = NULL;
char *fullpath = get_full_path(filename);
if (fullpath == NULL || fullpath[strlen(fullpath) - 1] == '/') {
if (fullpath == NULL || fullpath[strlen(fullpath) - 1] == '/' || inhelp) {
free(fullpath);
return;
}
@@ -3077,7 +3066,7 @@ bool has_old_position(const char *file, ssize_t *line, ssize_t *column)
free(fullpath);
if (posptr == NULL)
return FALSE;
return FALSE;
*line = posptr->lineno;
*column = posptr->xno;

View File

@@ -52,12 +52,25 @@ 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. */
bool inhelp = FALSE;
/* Whether we are in the help viewer. */
char *title = NULL;
/* When not NULL: the title of the current help text. */
int didfind = 0;
/* Whether the last search found something. */
int controlleft, controlright, controlup, controldown, controlhome, controlend;
#ifndef NANO_TINY
int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown;
@@ -82,14 +95,14 @@ char *present_path = NULL;
unsigned flags[4] = {0, 0, 0, 0};
/* Our flag containing the states of all global options. */
WINDOW *topwin;
WINDOW *topwin = NULL;
/* The top portion of the window, where we display the version
* number of nano, the name of the current file, and whether the
* current file has been modified. */
WINDOW *edit;
WINDOW *edit = NULL;
/* The middle portion of the window, i.e. the edit window, where
* we display the current file we're editing. */
WINDOW *bottomwin;
WINDOW *bottomwin = NULL;
/* The bottom portion of the window, where we display statusbar
* messages, the statusbar prompt, and a list of shortcuts. */
int editwinrows = 0;
@@ -253,10 +266,13 @@ void regexp_void(void)
void backwards_void(void)
{
}
void flip_replace(void)
{
}
void gototext_void(void)
{
}
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
void to_files_void(void)
{
}
@@ -264,6 +280,7 @@ void goto_dir_void(void)
{
}
#endif
#ifndef NANO_TINY
void dos_format_void(void)
{
}
@@ -279,18 +296,18 @@ void prepend_void(void)
void backup_file_void(void)
{
}
void flip_execute(void)
{
}
#endif
#ifdef ENABLE_MULTIBUFFER
void flip_newbuffer(void)
{
}
#endif
void discard_buffer(void)
{
}
void new_buffer_void(void)
{
}
void flip_replace_void(void)
{
}
void flip_execute_void(void)
{
}
/* Add a function to the function list. */
void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *help,
@@ -309,7 +326,7 @@ void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *h
f->menus = menus;
f->desc = desc;
f->viewok = viewok;
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
f->help = help;
f->blank_after = blank_after;
#endif
@@ -475,16 +492,13 @@ void shortcut_init(void)
/* TRANSLATORS: Try to keep this string at most 12 characters. */
const char *whereis_next_tag = N_("WhereIs Next");
#ifndef DISABLE_HELP
#ifndef DISABLE_JUSTIFY
#ifdef ENABLE_HELP
/* TRANSLATORS: The next long series of strings are shortcut descriptions;
* they are best kept shorter than 56 characters, but may be longer. */
const char *nano_justify_msg = N_("Justify the current paragraph");
#endif
const char *nano_cancel_msg = N_("Cancel the current function");
const char *nano_help_msg = N_("Display this help text");
const char *nano_exit_msg =
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
N_("Close the current file buffer / Exit from nano")
#else
N_("Exit from nano")
@@ -496,7 +510,7 @@ void shortcut_init(void)
N_("Insert another file into the current one");
const char *nano_whereis_msg =
N_("Search for a string or a regular expression");
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
const char *nano_browser_whereis_msg = N_("Search for a string");
const char *nano_browser_refresh_msg = N_("Refresh the file list");
#ifndef NANO_TINY
@@ -553,7 +567,7 @@ void shortcut_init(void)
const char *nano_scrolldown_msg =
N_("Scroll down one line without scrolling the cursor");
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
const char *nano_prevfile_msg = N_("Switch to the previous file buffer");
const char *nano_nextfile_msg = N_("Switch to the next file buffer");
#endif
@@ -572,6 +586,7 @@ void shortcut_init(void)
N_("Cut from the cursor position to the end of the file");
#endif
#ifndef DISABLE_JUSTIFY
const char *nano_justify_msg = N_("Justify the current paragraph");
const char *nano_fulljustify_msg = N_("Justify the entire file");
#endif
#ifndef NANO_TINY
@@ -606,9 +621,6 @@ void shortcut_init(void)
const char *nano_next_history_msg =
N_("Recall the next search/replace string");
#endif
#ifndef DISABLE_BROWSER
const char *nano_tofiles_msg = N_("Go to file browser");
#endif
#ifndef NANO_TINY
const char *nano_dos_msg = N_("Toggle the use of DOS format");
const char *nano_mac_msg = N_("Toggle the use of Mac format");
@@ -617,11 +629,12 @@ void shortcut_init(void)
const char *nano_backup_msg = N_("Toggle backing up of the original file");
const char *nano_execute_msg = N_("Execute external command");
#endif
const char *nano_discard_buffer_msg = N_("Close buffer without saving it");
#ifndef DISABLE_MULTIBUFFER
const char *nano_multibuffer_msg = N_("Toggle the use of a new buffer");
#ifdef ENABLE_MULTIBUFFER
const char *nano_newbuffer_msg = N_("Toggle the use of a new buffer");
#endif
#ifndef DISABLE_BROWSER
const char *nano_discard_buffer_msg = N_("Close buffer without saving it");
#ifdef ENABLE_BROWSER
const char *nano_tofiles_msg = N_("Go to file browser");
const char *nano_exitbrowser_msg = N_("Exit from the file browser");
const char *nano_firstfile_msg = N_("Go to the first file in the list");
const char *nano_lastfile_msg = N_("Go to the last file in the list");
@@ -637,9 +650,9 @@ void shortcut_init(void)
const char *nano_formatter_msg = N_("Invoke formatter, if available");
#endif
#endif
#endif /* !DISABLE_HELP */
#endif /* ENABLE_HELP */
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
#define IFSCHELP(help) help
#else
#define IFSCHELP(help) ""
@@ -654,12 +667,12 @@ void shortcut_init(void)
add_to_funcs(do_cancel, ((MMOST & ~MMAIN & ~MBROWSER) | MYESNO),
N_("Cancel"), IFSCHELP(nano_cancel_msg), BLANKAFTER, VIEW);
add_to_funcs(do_exit, MMAIN,
add_to_funcs(do_exit, MMAIN|MHELP,
exit_tag, IFSCHELP(nano_exit_msg), TOGETHER, VIEW);
/* Remember the entry for Exit, to be able to replace it with Close. */
exitfunc = tailfunc;
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
add_to_funcs(do_exit, MBROWSER,
exit_tag, IFSCHELP(nano_exitbrowser_msg), TOGETHER, VIEW);
#endif
@@ -678,7 +691,7 @@ void shortcut_init(void)
read_file_tag, IFSCHELP(nano_insert_msg), BLANKAFTER,
/* We allow inserting files in view mode if multibuffer mode
* is switched on, so that we can view multiple files. */
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
VIEW);
#else
NOVIEW);
@@ -696,7 +709,7 @@ void shortcut_init(void)
add_to_funcs(do_replace, MMAIN,
replace_tag, IFSCHELP(nano_replace_msg), TOGETHER, NOVIEW);
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
add_to_funcs(do_search, MBROWSER,
whereis_tag, IFSCHELP(nano_browser_whereis_msg), TOGETHER, VIEW);
@@ -704,15 +717,13 @@ 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_up_void, MHELP, prev_line_tag, "x", 0, VIEW);
add_to_funcs(do_down_void, MHELP, next_line_tag, "x" , 0, VIEW);
add_to_funcs(do_search, MHELP, whereis_tag, "x", 0, VIEW);
add_to_funcs(do_research, MHELP, whereis_next_tag, "x", 0, VIEW);
#endif
add_to_funcs(do_cut_text_void, MMAIN,
@@ -773,10 +784,10 @@ void shortcut_init(void)
add_to_funcs(backwards_void, MWHEREIS|MREPLACE,
N_("Backwards"), IFSCHELP(nano_reverse_msg), TOGETHER, VIEW);
add_to_funcs(flip_replace_void, MWHEREIS,
add_to_funcs(flip_replace, MWHEREIS,
replace_tag, IFSCHELP(nano_replace_msg), BLANKAFTER, VIEW);
add_to_funcs(flip_replace_void, MREPLACE,
add_to_funcs(flip_replace, MREPLACE,
N_("No Replace"), IFSCHELP(nano_whereis_msg), BLANKAFTER, VIEW);
#ifndef DISABLE_JUSTIFY
@@ -804,7 +815,7 @@ void shortcut_init(void)
N_("Back"), IFSCHELP(nano_back_msg), TOGETHER, VIEW);
add_to_funcs(do_right, MMAIN,
N_("Forward"), IFSCHELP(nano_forward_msg), TOGETHER, VIEW);
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
add_to_funcs(do_left, MBROWSER,
N_("Back"), IFSCHELP(nano_backfile_msg), TOGETHER, VIEW);
add_to_funcs(do_right, MBROWSER,
@@ -821,9 +832,9 @@ void shortcut_init(void)
add_to_funcs(do_end_void, MMAIN,
N_("End"), IFSCHELP(nano_end_msg), BLANKAFTER, VIEW);
add_to_funcs(do_up_void, MMAIN|MBROWSER,
add_to_funcs(do_up_void, MMAIN|MHELP|MBROWSER,
prev_line_tag, IFSCHELP(nano_prevline_msg), TOGETHER, VIEW);
add_to_funcs(do_down_void, MMAIN|MBROWSER,
add_to_funcs(do_down_void, MMAIN|MHELP|MBROWSER,
next_line_tag, IFSCHELP(nano_nextline_msg), TOGETHER, VIEW);
#ifndef NANO_TINY
add_to_funcs(do_scroll_up, MMAIN,
@@ -853,7 +864,7 @@ void shortcut_init(void)
add_to_funcs(do_last_line, MMAIN|MHELP|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE,
N_("Last Line"), IFSCHELP(nano_lastline_msg), BLANKAFTER, VIEW);
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
add_to_funcs(switch_to_prev_buffer_void, MMAIN,
N_("Prev File"), IFSCHELP(nano_prevfile_msg), TOGETHER, VIEW);
add_to_funcs(switch_to_next_buffer_void, MMAIN,
@@ -976,20 +987,20 @@ void shortcut_init(void)
/* If we're using restricted mode, file insertion is disabled, and
* thus command execution and the multibuffer toggle have no place. */
if (!ISSET(RESTRICTED)) {
add_to_funcs(flip_execute_void, MINSERTFILE,
add_to_funcs(flip_execute, MINSERTFILE,
N_("Execute Command"), IFSCHELP(nano_execute_msg), TOGETHER, NOVIEW);
add_to_funcs(flip_execute_void, MEXTCMD,
add_to_funcs(flip_execute, MEXTCMD,
read_file_tag, IFSCHELP(nano_insert_msg), TOGETHER, NOVIEW);
#ifndef DISABLE_MULTIBUFFER
add_to_funcs(new_buffer_void, MINSERTFILE|MEXTCMD,
N_("New Buffer"), IFSCHELP(nano_multibuffer_msg), TOGETHER, NOVIEW);
#endif
}
#endif /* !NANO_TINY */
#ifdef ENABLE_MULTIBUFFER
if (!ISSET(RESTRICTED))
add_to_funcs(flip_newbuffer, MINSERTFILE|MEXTCMD,
N_("New Buffer"), IFSCHELP(nano_newbuffer_msg), TOGETHER, NOVIEW);
#endif
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
if (!ISSET(RESTRICTED))
add_to_funcs(to_files_void, MWRITEFILE|MINSERTFILE,
N_("To Files"), IFSCHELP(nano_tofiles_msg), TOGETHER, VIEW);
@@ -1008,7 +1019,7 @@ void shortcut_init(void)
add_to_funcs(discard_buffer, MWRITEFILE,
N_("Discard buffer"), IFSCHELP(nano_discard_buffer_msg), BLANKAFTER, NOVIEW);
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
add_to_funcs(do_research, MBROWSER,
whereis_next_tag, IFSCHELP(nano_whereis_next_msg), TOGETHER, VIEW);
add_to_funcs(total_refresh, MBROWSER,
@@ -1035,8 +1046,8 @@ void shortcut_init(void)
/* Start associating key combos with functions in specific menus. */
add_to_sclist(MMOST, "^G", 0, do_help_void, 0);
add_to_sclist(MMOST, "F1", 0, do_help_void, 0);
add_to_sclist(MMOST & ~MFINDINHELP, "^G", 0, do_help_void, 0);
add_to_sclist(MMOST & ~MFINDINHELP, "F1", 0, do_help_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^X", 0, do_exit, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", 0, do_exit, 0);
add_to_sclist(MMAIN, "^O", 0, do_writeout_void, 0);
@@ -1044,8 +1055,8 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "^R", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN, "F5", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN, "Ins", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN|MBROWSER, "^W", 0, do_search, 0);
add_to_sclist(MMAIN|MBROWSER, "F6", 0, do_search, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^W", 0, do_search, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "F6", 0, do_search, 0);
add_to_sclist(MMAIN, "^\\", 0, do_replace, 0);
add_to_sclist(MMAIN, "M-R", 0, do_replace, 0);
add_to_sclist(MMAIN, "F14", 0, do_replace, 0);
@@ -1074,6 +1085,7 @@ void shortcut_init(void)
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^Y", 0, do_page_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F7", 0, do_page_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgUp", KEY_PPAGE, do_page_up, 0);
add_to_sclist(MHELP|MBROWSER, "Bsp", KEY_BACKSPACE, do_page_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^V", 0, do_page_down, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F8", 0, do_page_down, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgDn", KEY_NPAGE, do_page_down, 0);
@@ -1083,8 +1095,8 @@ void shortcut_init(void)
add_to_sclist(MMAIN|MHELP, "M-/", 0, do_last_line, 0);
add_to_sclist(MMAIN|MHELP, "^End", CONTROL_END, do_last_line, 0);
add_to_sclist(MMAIN|MHELP, "M-?", 0, do_last_line, 0);
add_to_sclist(MMAIN|MBROWSER, "M-W", 0, do_research, 0);
add_to_sclist(MMAIN|MBROWSER, "F16", 0, do_research, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "M-W", 0, do_research, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "F16", 0, do_research, 0);
#ifndef NANO_TINY
add_to_sclist(MMAIN, "M-]", 0, do_find_bracket, 0);
add_to_sclist(MMAIN, "M-A", 0, do_mark, 0);
@@ -1156,7 +1168,7 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "M-+", 0, do_scroll_down, 0);
add_to_sclist(MMAIN, "M-=", 0, do_scroll_down, 0);
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
add_to_sclist(MMAIN, "M-<", 0, switch_to_prev_buffer_void, 0);
add_to_sclist(MMAIN, "M-,", 0, switch_to_prev_buffer_void, 0);
add_to_sclist(MMAIN, "M->", 0, switch_to_next_buffer_void, 0);
@@ -1176,7 +1188,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);
@@ -1199,10 +1211,10 @@ void shortcut_init(void)
/* Group of "Peripheral-feature" toggles. */
add_to_sclist(MMAIN, "M-B", 0, do_toggle_void, BACKUP_FILE);
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
add_to_sclist(MMAIN, "M-F", 0, do_toggle_void, MULTIBUFFER);
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
add_to_sclist(MMAIN, "M-M", 0, do_toggle_void, USE_MOUSE);
#endif
add_to_sclist(MMAIN, "M-N", 0, do_toggle_void, NO_CONVERT);
@@ -1217,7 +1229,7 @@ void shortcut_init(void)
add_to_sclist(MWHEREIS|MREPLACE, "M-C", 0, case_sens_void, 0);
add_to_sclist(MWHEREIS|MREPLACE, "M-R", 0, regexp_void, 0);
add_to_sclist(MWHEREIS|MREPLACE, "M-B", 0, backwards_void, 0);
add_to_sclist(MWHEREIS|MREPLACE, "^R", 0, flip_replace_void, 0);
add_to_sclist(MWHEREIS|MREPLACE, "^R", 0, flip_replace, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^Y", 0, do_first_line, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^V", 0, do_last_line, 0);
#ifndef DISABLE_JUSTIFY
@@ -1227,30 +1239,30 @@ void shortcut_init(void)
add_to_sclist(MWHEREIS, "^T", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MGOTOLINE, "^T", 0, gototext_void, 0);
#ifndef DISABLE_HISTORIES
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^P", 0, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^N", 0, get_history_newer_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "^P", 0, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "^N", 0, get_history_newer_void, 0);
#ifdef ENABLE_UTF8
if (using_utf8()) {
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "\xE2\x86\x91", KEY_UP, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "\xE2\x86\x93", KEY_DOWN, get_history_newer_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "\xE2\x86\x91", KEY_UP, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "\xE2\x86\x93", KEY_DOWN, get_history_newer_void, 0);
} else
#endif
{
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Up", KEY_UP, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Down", KEY_DOWN, get_history_newer_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "Up", KEY_UP, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "Down", KEY_DOWN, get_history_newer_void, 0);
}
#endif
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
add_to_sclist(MWHEREISFILE, "^Y", 0, do_first_file, 0);
add_to_sclist(MWHEREISFILE, "^V", 0, do_last_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-\\", 0, do_first_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", 0, do_first_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-/", 0, do_last_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", 0, do_last_file, 0);
add_to_sclist(MBROWSER, "Home", KEY_HOME, do_first_file, 0);
add_to_sclist(MBROWSER, "End", KEY_END, do_last_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", 0, do_first_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", 0, do_last_file, 0);
add_to_sclist(MBROWSER, "^Home", CONTROL_HOME, do_first_file, 0);
add_to_sclist(MBROWSER, "^End", CONTROL_HOME, do_last_file, 0);
add_to_sclist(MBROWSER, "^End", CONTROL_END, do_last_file, 0);
add_to_sclist(MBROWSER, "^_", 0, goto_dir_void, 0);
add_to_sclist(MBROWSER, "M-G", 0, goto_dir_void, 0);
add_to_sclist(MBROWSER, "F13", 0, goto_dir_void, 0);
@@ -1258,26 +1270,34 @@ void shortcut_init(void)
#endif
if (ISSET(TEMP_FILE))
add_to_sclist(MWRITEFILE, "^Q", 0, discard_buffer, 0);
#ifndef NANO_TINY
add_to_sclist(MWRITEFILE, "M-D", 0, dos_format_void, 0);
add_to_sclist(MWRITEFILE, "M-M", 0, mac_format_void, 0);
/* In restricted mode, don't allow Appending, Prepending, nor making
* backups, nor executing a command, nor opening a new buffer. */
if (!ISSET(RESTRICTED)) {
/* Don't allow Appending, Prepending, nor Backups in restricted mode. */
add_to_sclist(MWRITEFILE, "M-A", 0, append_void, 0);
add_to_sclist(MWRITEFILE, "M-P", 0, prepend_void, 0);
add_to_sclist(MWRITEFILE, "M-B", 0, backup_file_void, 0);
#ifndef DISABLE_BROWSER
add_to_sclist(MINSERTFILE|MEXTCMD, "^X", 0, flip_execute, 0);
}
#endif
#ifdef ENABLE_MULTIBUFFER
if (!ISSET(RESTRICTED))
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, flip_newbuffer, 0);
#endif
#ifdef ENABLE_BROWSER
/* In restricted mode, don't allow entering the file browser. */
if (!ISSET(RESTRICTED))
add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", 0, to_files_void, 0);
#endif
add_to_sclist(MINSERTFILE|MEXTCMD, "^X", 0, flip_execute_void, 0);
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, new_buffer_void, 0);
}
add_to_sclist(MHELP|MBROWSER, "^C", 0, do_exit, 0);
/* Allow exiting from the file browser and the help viewer with
* the same key as they were entered. */
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
add_to_sclist(MBROWSER, "^T", 0, do_exit, 0);
#endif
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
add_to_sclist(MHELP, "^G", 0, do_exit, 0);
add_to_sclist(MHELP, "Home", KEY_HOME, do_first_line, 0);
add_to_sclist(MHELP, "End", KEY_END, do_last_line, 0);
@@ -1339,7 +1359,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");
@@ -1379,7 +1399,7 @@ const char *flagtostr(int flag)
}
#endif /* !NANO_TINY */
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
/* Interpret a function string given in the rc file, and return a
* shortcut struct with the corresponding function filled in. */
sc *strtosc(const char *input)
@@ -1390,7 +1410,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
@@ -1475,18 +1495,10 @@ sc *strtosc(const char *input)
s->scfunc = do_scroll_up;
else if (!strcasecmp(input, "scrolldown"))
s->scfunc = do_scroll_down;
else if (!strcasecmp(input, "prevword"))
s->scfunc = do_prev_word_void;
else if (!strcasecmp(input, "nextword"))
s->scfunc = do_next_word_void;
else if (!strcasecmp(input, "cutwordleft"))
s->scfunc = do_cut_prev_word;
else if (!strcasecmp(input, "cutwordright"))
s->scfunc = do_cut_next_word;
else if (!strcasecmp(input, "prevblock"))
s->scfunc = do_prev_block;
else if (!strcasecmp(input, "nextblock"))
s->scfunc = do_next_block;
else if (!strcasecmp(input, "findbracket"))
s->scfunc = do_find_bracket;
else if (!strcasecmp(input, "wordcount"))
@@ -1508,10 +1520,18 @@ sc *strtosc(const char *input)
else if (!strcasecmp(input, "down") ||
!strcasecmp(input, "nextline"))
s->scfunc = do_down_void;
else if (!strcasecmp(input, "prevword"))
s->scfunc = do_prev_word_void;
else if (!strcasecmp(input, "nextword"))
s->scfunc = do_next_word_void;
else if (!strcasecmp(input, "home"))
s->scfunc = do_home_void;
else if (!strcasecmp(input, "end"))
s->scfunc = do_end_void;
else if (!strcasecmp(input, "prevblock"))
s->scfunc = do_prev_block;
else if (!strcasecmp(input, "nextblock"))
s->scfunc = do_next_block;
else if (!strcasecmp(input, "pageup") ||
!strcasecmp(input, "prevpage"))
s->scfunc = do_page_up;
@@ -1522,7 +1542,7 @@ sc *strtosc(const char *input)
s->scfunc = do_first_line;
else if (!strcasecmp(input, "lastline"))
s->scfunc = do_last_line;
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
else if (!strcasecmp(input, "prevbuf"))
s->scfunc = switch_to_prev_buffer_void;
else if (!strcasecmp(input, "nextbuf"))
@@ -1551,7 +1571,7 @@ sc *strtosc(const char *input)
s->scfunc = backwards_void;
else if (!strcasecmp(input, "flipreplace") ||
!strcasecmp(input, "dontreplace")) /* Deprecated. Remove in 2018. */
s->scfunc = flip_replace_void;
s->scfunc = flip_replace;
else if (!strcasecmp(input, "gototext"))
s->scfunc = gototext_void;
#ifndef DISABLE_HISTORIES
@@ -1560,6 +1580,7 @@ sc *strtosc(const char *input)
else if (!strcasecmp(input, "nexthistory"))
s->scfunc = get_history_newer_void;
#endif
#ifndef NANO_TINY
else if (!strcasecmp(input, "dosformat"))
s->scfunc = dos_format_void;
else if (!strcasecmp(input, "macformat"))
@@ -1570,16 +1591,15 @@ sc *strtosc(const char *input)
s->scfunc = prepend_void;
else if (!strcasecmp(input, "backup"))
s->scfunc = backup_file_void;
#ifndef ENABLE_TINY
else if (!strcasecmp(input, "flipexecute"))
s->scfunc = flip_execute_void;
s->scfunc = flip_execute;
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
else if (!strcasecmp(input, "flipnewbuffer") ||
!strcasecmp(input, "newbuffer")) /* Deprecated. Remove in 2018. */
s->scfunc = new_buffer_void;
s->scfunc = flip_newbuffer;
#endif
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
else if (!strcasecmp(input, "tofiles") ||
!strcasecmp(input, "browser"))
s->scfunc = to_files_void;
@@ -1596,7 +1616,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"))
@@ -1623,11 +1643,11 @@ sc *strtosc(const char *input)
s->toggle = TABS_TO_SPACES;
else if (!strcasecmp(input, "backupfile"))
s->toggle = BACKUP_FILE;
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
else if (!strcasecmp(input, "multibuffer"))
s->toggle = MULTIBUFFER;
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
else if (!strcasecmp(input, "mouse"))
s->toggle = USE_MOUSE;
#endif
@@ -1668,7 +1688,7 @@ int strtomenu(const char *input)
else if (!strcasecmp(input, "externalcmd") ||
!strcasecmp(input, "extcmd"))
return MEXTCMD;
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
else if (!strcasecmp(input, "help"))
return MHELP;
#endif
@@ -1678,7 +1698,7 @@ int strtomenu(const char *input)
#endif
else if (!strcasecmp(input, "linter"))
return MLINTER;
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
else if (!strcasecmp(input, "browser"))
return MBROWSER;
else if (!strcasecmp(input, "whereisfile"))
@@ -1688,7 +1708,7 @@ int strtomenu(const char *input)
#endif
return -1;
}
#endif /* !DISABLE_NANORC */
#endif /* ENABLE_NANORC */
#ifdef DEBUG
@@ -1699,7 +1719,8 @@ int strtomenu(const char *input)
* function unless debugging is turned on. */
void thanks_for_all_the_fish(void)
{
delwin(topwin);
if (topwin != NULL)
delwin(topwin);
delwin(edit);
delwin(bottomwin);
@@ -1794,7 +1815,7 @@ void thanks_for_all_the_fish(void)
sclist = sclist->next;
free(s);
}
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
free(homedir);
#endif
}

View File

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

View File

@@ -55,7 +55,7 @@ void get_edge_and_target(size_t *leftedge, size_t *target_column)
if (ISSET(SOFTWRAP)) {
size_t realspan = strlenpt(openfile->current->data);
if (openfile->placewewant < realspan)
if (realspan > openfile->placewewant)
realspan = openfile->placewewant;
*leftedge = (realspan / editwincols) * editwincols;
@@ -133,10 +133,9 @@ void do_page_down(void)
}
#ifndef DISABLE_JUSTIFY
/* Move up to the beginning of the last beginning-of-paragraph line
* before the current line. If allow_update is TRUE, update the screen
* afterwards. */
void do_para_begin(bool allow_update)
/* Move to the beginning of the last beginning-of-paragraph line before the
* current line. If update_screen is TRUE, update the screen afterwards. */
void do_para_begin(bool update_screen)
{
filestruct *was_current = openfile->current;
@@ -148,7 +147,7 @@ void do_para_begin(bool allow_update)
openfile->current_x = 0;
if (allow_update)
if (update_screen)
edit_redraw(was_current);
}
@@ -160,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;
@@ -184,7 +183,7 @@ void do_para_end(bool allow_update)
} else
openfile->current_x = strlen(openfile->current->data);
if (allow_update)
if (update_screen)
edit_redraw(was_current);
}
@@ -236,9 +235,9 @@ void do_next_block(void)
}
/* Move to the previous word in the file. If allow_punct is TRUE, treat
* punctuation as part of a word. If allow_update is TRUE, update the
* punctuation as part of a word. If update_screen is TRUE, update the
* screen afterwards. */
void do_prev_word(bool allow_punct, bool allow_update)
void do_prev_word(bool allow_punct, bool update_screen)
{
filestruct *was_current = openfile->current;
bool seen_a_word = FALSE, step_forward = FALSE;
@@ -275,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);
}
@@ -290,10 +288,10 @@ void do_prev_word_void(void)
}
/* Move to the next word in the file. If allow_punct is TRUE, treat
* punctuation as part of a word. If allow_update is TRUE, update the
* punctuation as part of a word. If update_screen is TRUE, update the
* screen afterwards. Return TRUE if we started on a word, and FALSE
* otherwise. */
bool do_next_word(bool allow_punct, bool allow_update)
bool do_next_word(bool allow_punct, bool update_screen)
{
filestruct *was_current = openfile->current;
bool started_on_word = is_word_mbchar(openfile->current->data +
@@ -325,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);
}

View File

@@ -41,29 +41,29 @@
#include <sys/ioctl.h>
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
static int oldinterval = -1;
/* Used to store the user's original mouse click interval. */
#endif
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
static bool no_rcfiles = FALSE;
/* Should we ignore all rcfiles? */
#endif
#ifdef HAVE_TERMIOS_H
static struct termios oldterm;
/* The user's original terminal settings. */
#else
# define tcsetattr(...)
# define tcgetattr(...)
#endif
/* The user's original terminal settings. */
static struct sigaction act;
/* Used to set up all our fun signal handlers. */
/* Create a new filestruct node. Note that we do not set prevnode->next
/* Create a new linestruct node. Note that we do not set prevnode->next
* to the new line. */
filestruct *make_new_node(filestruct *prevnode)
{
filestruct *newnode = (filestruct *)nmalloc(sizeof(filestruct));
filestruct *newnode = nmalloc(sizeof(filestruct));
newnode->data = NULL;
newnode->prev = prevnode;
@@ -77,17 +77,16 @@ filestruct *make_new_node(filestruct *prevnode)
return newnode;
}
/* Make a copy of a filestruct node. */
/* Make a copy of a linestruct node. */
filestruct *copy_node(const filestruct *src)
{
filestruct *dst;
dst = (filestruct *)nmalloc(sizeof(filestruct));
filestruct *dst = nmalloc(sizeof(filestruct));
dst->data = mallocstrcpy(NULL, src->data);
dst->next = src->next;
dst->prev = src->prev;
dst->lineno = src->lineno;
#ifndef DISABLE_COLOR
dst->multidata = NULL;
#endif
@@ -95,7 +94,7 @@ filestruct *copy_node(const filestruct *src)
return dst;
}
/* Splice a new node into an existing linked list of filestructs. */
/* Splice a new node into an existing linked list of linestructs. */
void splice_node(filestruct *afterthis, filestruct *newnode)
{
newnode->next = afterthis->next;
@@ -109,7 +108,7 @@ void splice_node(filestruct *afterthis, filestruct *newnode)
openfile->filebot = newnode;
}
/* Disconnect a node from a linked list of filestructs and delete it. */
/* Disconnect a node from a linked list of linestructs and delete it. */
void unlink_node(filestruct *fileptr)
{
if (fileptr->prev != NULL)
@@ -134,7 +133,7 @@ void delete_node(filestruct *fileptr)
free(fileptr);
}
/* Duplicate a whole filestruct. */
/* Duplicate an entire linked list of linestructs. */
filestruct *copy_filestruct(const filestruct *src)
{
filestruct *head, *copy;
@@ -157,7 +156,7 @@ filestruct *copy_filestruct(const filestruct *src)
return head;
}
/* Free a whole linked list of filestructs. */
/* Free an entire linked list of linestructs. */
void free_filestruct(filestruct *src)
{
if (src == NULL)
@@ -171,7 +170,7 @@ void free_filestruct(filestruct *src)
delete_node(src);
}
/* Renumber all entries in a filestruct, starting with fileptr. */
/* Renumber the lines in a buffer, starting with fileptr. */
void renumber(filestruct *fileptr)
{
ssize_t line;
@@ -187,8 +186,8 @@ void renumber(filestruct *fileptr)
fileptr->lineno = ++line;
}
/* Partition a filestruct so that it begins at (top, top_x) and ends at
* (bot, bot_x). */
/* Partition the current buffer so that it appears to begin at (top, top_x)
* and appears to end at (bot, bot_x). */
partition *partition_filestruct(filestruct *top, size_t top_x,
filestruct *bot, size_t bot_x)
{
@@ -200,7 +199,7 @@ partition *partition_filestruct(filestruct *top, size_t top_x,
p = (partition *)nmalloc(sizeof(partition));
/* If the top and bottom of the partition are different from the top
* and bottom of the filestruct, save the latter and then set them
* and bottom of the buffer, save the latter and then set them
* to top and bot. */
if (top != openfile->fileage) {
p->fileage = openfile->fileage;
@@ -236,8 +235,8 @@ partition *partition_filestruct(filestruct *top, size_t top_x,
return p;
}
/* Unpartition a filestruct so that it begins at (fileage, 0) and ends
* at (filebot, strlen(filebot->data)) again. */
/* Unpartition the current buffer so that it stretches from (fileage, 0)
* to (filebot, $) again. */
void unpartition_filestruct(partition **p)
{
assert(p != NULL && openfile->fileage != NULL && openfile->filebot != NULL);
@@ -266,7 +265,7 @@ void unpartition_filestruct(partition **p)
strcat(openfile->filebot->data, (*p)->bot_data);
free((*p)->bot_data);
/* Restore the top and bottom of the filestruct, if they were
/* Restore the top and bottom of the buffer, if they were
* different from the top and bottom of the partition. */
if ((*p)->fileage != NULL)
openfile->fileage = (*p)->fileage;
@@ -279,7 +278,7 @@ void unpartition_filestruct(partition **p)
}
/* Move all the text between (top, top_x) and (bot, bot_x) in the
* current filestruct to a filestruct beginning with file_top and ending
* current buffer to a new buffer beginning with file_top and ending
* with file_bot. If no text is between (top, top_x) and (bot, bot_x),
* don't do anything. */
void extract_buffer(filestruct **file_top, filestruct **file_bot,
@@ -298,7 +297,7 @@ void extract_buffer(filestruct **file_top, filestruct **file_bot,
if (top == bot && top_x == bot_x)
return;
/* Partition the filestruct so that it contains only the text from
/* Partition the buffer so that it contains only the text from
* (top, top_x) to (bot, bot_x), keep track of whether the top of
* the edit window is inside the partition, and keep track of
* whether the mark begins inside the partition. */
@@ -356,7 +355,7 @@ void extract_buffer(filestruct **file_top, filestruct **file_bot,
renumber(file_bot_save->next);
}
/* Since the text has now been saved, remove it from the filestruct. */
/* Since the text has now been saved, remove it from the buffer. */
openfile->fileage = make_new_node(NULL);
openfile->fileage->data = mallocstrcpy(NULL, "");
openfile->filebot = openfile->fileage;
@@ -377,7 +376,7 @@ void extract_buffer(filestruct **file_top, filestruct **file_bot,
top_save = openfile->fileage;
/* Unpartition the filestruct so that it contains all the text
/* Unpartition the buffer so that it contains all the text
* again, minus the saved text. */
unpartition_filestruct(&filepart);
@@ -423,14 +422,14 @@ void ingraft_buffer(filestruct *somebuffer)
}
#endif
/* Partition the filestruct so that it contains no text, and remember
/* Partition the buffer so that it contains no text, and remember
* whether the current line is at the top of the edit window. */
filepart = partition_filestruct(openfile->current, openfile->current_x,
openfile->current, openfile->current_x);
edittop_inside = (openfile->edittop == openfile->fileage);
free_filestruct(openfile->fileage);
/* Put the top and bottom of the current filestruct at the top and
/* Put the top and bottom of the current buffer at the top and
* bottom of the passed buffer. */
openfile->fileage = somebuffer;
openfile->filebot = openfile->fileage;
@@ -476,7 +475,7 @@ void ingraft_buffer(filestruct *somebuffer)
top_save = openfile->fileage;
/* Unpartition the filestruct so that it contains all the text
/* Unpartition the buffer so that it contains all the text
* again, plus the copied text. */
unpartition_filestruct(&filepart);
@@ -496,13 +495,13 @@ void copy_from_buffer(filestruct *somebuffer)
ingraft_buffer(the_copy);
}
/* Create a new openfilestruct node. */
/* Create a new openfile node. */
openfilestruct *make_new_opennode(void)
{
return (openfilestruct *)nmalloc(sizeof(openfilestruct));
}
/* Unlink a node from the rest of the openfilestruct, and delete it. */
/* Unlink a node from the rest of the circular list, and delete it. */
void unlink_opennode(openfilestruct *fileptr)
{
assert(fileptr != fileptr->prev && fileptr != fileptr->next);
@@ -540,7 +539,7 @@ void show_restricted_warning(void)
beep();
}
#ifdef DISABLE_HELP
#ifndef ENABLE_HELP
/* Indicate that help texts are unavailable. */
void say_there_is_no_help(void)
{
@@ -600,14 +599,14 @@ void die(const char *msg, ...)
/* If the current file buffer was modified, save it. */
if (openfile && openfile->modified) {
/* If the filestruct is partitioned, unpartition it first. */
/* If the buffer is partitioned, unpartition it first. */
if (filepart != NULL)
unpartition_filestruct(&filepart);
die_save_file(openfile->filename, openfile->current_stat);
}
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
/* Save all of the other modified file buffers, if any. */
if (openfile != NULL) {
openfilestruct *firstone = openfile;
@@ -678,14 +677,17 @@ void die_save_file(const char *die_filename, struct stat *die_stat)
/* Initialize the three window portions nano uses. */
void window_init(void)
{
/* First delete existing windows, in case of resizing. */
delwin(topwin);
topwin = NULL;
delwin(edit);
delwin(bottomwin);
/* When resizing, first delete the existing windows. */
if (edit != NULL) {
if (topwin != NULL)
delwin(topwin);
delwin(edit);
delwin(bottomwin);
}
/* If the terminal is very flat, don't set up a titlebar. */
if (LINES < 3) {
topwin = NULL;
editwinrows = 1;
/* Set up two subwindows. If the terminal is just one line,
* edit window and statusbar window will cover each other. */
@@ -724,23 +726,20 @@ void window_init(void)
#endif
}
#ifndef DISABLE_MOUSE
/* Disable mouse support. */
#ifdef ENABLE_MOUSE
void disable_mouse_support(void)
{
mousemask(0, NULL);
mouseinterval(oldinterval);
}
/* Enable mouse support. */
void enable_mouse_support(void)
{
mousemask(ALL_MOUSE_EVENTS, NULL);
oldinterval = mouseinterval(50);
}
/* Initialize mouse support. Enable it if the USE_MOUSE flag is set,
* and disable it otherwise. */
/* Switch mouse support on or off, as needed. */
void mouse_init(void)
{
if (ISSET(USE_MOUSE))
@@ -748,7 +747,7 @@ void mouse_init(void)
else
disable_mouse_support();
}
#endif /* !DISABLE_MOUSE */
#endif /* ENABLE_MOUSE */
/* Print one usage string to the screen. This cuts down on duplicate
* strings to translate, and leaves out the parts that shouldn't be
@@ -795,7 +794,7 @@ void usage(void)
#ifndef NANO_TINY
print_opt("-E", "--tabstospaces", N_("Convert typed tabs to spaces"));
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
if (!ISSET(RESTRICTED))
print_opt("-F", "--multibuffer",
N_("Read a file into a new buffer by default"));
@@ -808,7 +807,7 @@ void usage(void)
print_opt("-H", "--historylog",
N_("Log & read search/replace string history"));
#endif
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
if (!ISSET(RESTRICTED))
print_opt("-I", "--ignorercfiles", N_("Don't look at nanorc files"));
#endif
@@ -836,9 +835,7 @@ void usage(void)
#endif
print_opt(_("-T <#cols>"), _("--tabsize=<#cols>"),
N_("Set width of a tab to #cols columns"));
#ifndef NANO_TINY
print_opt("-U", "--quickblank", N_("Do quick statusbar blanking"));
#endif
print_opt("-V", "--version", N_("Print version information and exit"));
#ifndef NANO_TINY
print_opt("-W", "--wordbounds",
@@ -854,7 +851,7 @@ void usage(void)
print_opt("-c", "--constantshow", N_("Constantly show cursor position"));
print_opt("-d", "--rebinddelete",
N_("Fix Backspace/Delete confusion problem"));
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
if (!ISSET(RESTRICTED))
print_opt("-g", "--showcursor", N_("Show cursor in file browser"));
#endif
@@ -866,7 +863,7 @@ void usage(void)
#ifdef ENABLE_LINENUMBERS
print_opt("-l", "--linenumbers", N_("Show line numbers in front of the text"));
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
print_opt("-m", "--mouse", N_("Enable the use of the mouse"));
#endif
print_opt("-n", "--noread", N_("Do not read the file (only write it)"));
@@ -875,7 +872,7 @@ void usage(void)
N_("Set operating directory"));
#endif
print_opt("-p", "--preserve", N_("Preserve XON (^Q) and XOFF (^S) keys"));
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
if (!ISSET(RESTRICTED))
print_opt("-q", "--quiet",
N_("Silently ignore startup issues like rc file errors"));
@@ -922,7 +919,7 @@ void version(void)
#ifdef NANO_TINY
printf(" --enable-tiny");
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
printf(" --enable-browser");
#endif
#ifndef DISABLE_COLOR
@@ -931,7 +928,7 @@ void version(void)
#ifndef DISABLE_EXTRA
printf(" --enable-extra");
#endif
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
printf(" --enable-help");
#endif
#ifndef DISABLE_HISTORIES
@@ -946,13 +943,13 @@ void version(void)
#ifdef ENABLE_LINENUMBERS
printf(" --enable-linenumbers");
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
printf(" --enable-mouse");
#endif
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
printf(" --enable-nanorc");
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
printf(" --enable-multibuffer");
#endif
#ifndef DISABLE_OPERATINGDIR
@@ -961,14 +958,14 @@ void version(void)
#ifndef DISABLE_SPELLER
printf(" --enable-speller");
#endif
#ifndef DISABLE_TABCOMP
#ifdef ENABLE_TABCOMP
printf(" --enable-tabcomp");
#endif
#ifndef DISABLE_WRAPPING
printf(" --enable-wrapping");
#endif
#else /* !NANO_TINY */
#ifdef DISABLE_BROWSER
#ifndef ENABLE_BROWSER
printf(" --disable-browser");
#endif
#ifdef DISABLE_COLOR
@@ -980,7 +977,7 @@ void version(void)
#ifdef DISABLE_EXTRA
printf(" --disable-extra");
#endif
#ifdef DISABLE_HELP
#ifndef ENABLE_HELP
printf(" --disable-help");
#endif
#ifdef DISABLE_HISTORIES
@@ -995,13 +992,13 @@ void version(void)
#ifndef ENABLE_LINENUMBERS
printf(" --disable-linenumbers");
#endif
#ifdef DISABLE_MOUSE
#ifndef ENABLE_MOUSE
printf(" --disable-mouse");
#endif
#ifdef DISABLE_MULTIBUFFER
#ifndef ENABLE_MULTIBUFFER
printf(" --disable-multibuffer");
#endif
#ifdef DISABLE_NANORC
#ifndef ENABLE_NANORC
printf(" --disable-nanorc");
#endif
#ifdef DISABLE_OPERATINGDIR
@@ -1010,7 +1007,7 @@ void version(void)
#ifdef DISABLE_SPELLER
printf(" --disable-speller");
#endif
#ifdef DISABLE_TABCOMP
#ifndef ENABLE_TABCOMP
printf(" --disable-tabcomp");
#endif
#ifndef ENABLE_WORDCOMPLETION
@@ -1090,7 +1087,7 @@ void close_and_go(void)
if (ISSET(LOCKING) && openfile->lock_filename)
delete_lockfile(openfile->lock_filename);
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
/* If there are no more open file buffers, jump off a cliff. */
if (!close_buffer())
#endif
@@ -1231,8 +1228,7 @@ RETSIGTYPE handle_hupterm(int signal)
/* Handler for SIGTSTP (suspend). */
RETSIGTYPE do_suspend(int signal)
{
#ifndef DISABLE_MOUSE
/* Turn mouse support off. */
#ifdef ENABLE_MOUSE
disable_mouse_support();
#endif
@@ -1275,8 +1271,7 @@ void do_suspend_void(void)
/* Handler for SIGCONT (continue after suspend). */
RETSIGTYPE do_continue(int signal)
{
#ifndef DISABLE_MOUSE
/* Turn mouse support back on if it was on before. */
#ifdef ENABLE_MOUSE
if (ISSET(USE_MOUSE))
enable_mouse_support();
#endif
@@ -1386,7 +1381,7 @@ void do_toggle(int flag)
TOGGLE(flag);
switch (flag) {
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
case USE_MOUSE:
mouse_init();
break;
@@ -1394,6 +1389,7 @@ void do_toggle(int flag)
case MORE_SPACE:
case NO_HELP:
window_init();
focusing = FALSE;
total_refresh();
break;
case SUSPEND:
@@ -1419,7 +1415,7 @@ void do_toggle(int flag)
enabled = !enabled;
statusline(HUSH, "%s %s", _(flagtostr(flag)),
enabled ? _("enabled") : _("disabled"));
enabled ? _("enabled") : _("disabled"));
}
/* Bleh. */
@@ -1564,7 +1560,7 @@ void unbound_key(int code)
statusline(ALERT, _("Unbound key: M-%c"), toupper(code));
} else if (code < 0x20)
statusline(ALERT, _("Unbound key: ^%c"), code + 0x40);
else
else if (currmenu != MHELP)
statusline(ALERT, _("Unbound key: %c"), code);
}
@@ -1592,7 +1588,7 @@ int do_input(bool allow_funcs)
return KEY_WINCH;
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
if (input == KEY_MOUSE) {
/* We received a mouse click. */
if (do_mouse() == 1)
@@ -1627,7 +1623,7 @@ int do_input(bool allow_funcs)
/* If the keystroke isn't a shortcut nor a toggle, it's a normal text
* character: add the character to the input buffer -- or display a
* warning when we're in view mode. */
if (input != ERR && !have_shortcut) {
if (input != ERR && !have_shortcut) {
if (ISSET(VIEW_MODE))
print_view_warning();
else {
@@ -1747,7 +1743,7 @@ void xoff_complaint(void)
}
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
/* Handle a mouse click on the edit window or the shortcut list. */
int do_mouse(void)
{
@@ -1760,13 +1756,13 @@ int do_mouse(void)
/* If the click was in the edit window, put the cursor in that spot. */
if (wmouse_trafo(edit, &mouse_row, &mouse_col, FALSE)) {
bool sameline = (mouse_row == openfile->current_y);
/* Whether the click was on the row where the cursor is. */
filestruct *current_save = openfile->current;
ssize_t row_count = mouse_row - openfile->current_y;
size_t leftedge;
#ifndef NANO_TINY
size_t current_x_save = openfile->current_x;
bool sameline = (mouse_row == openfile->current_y);
/* Whether the click was on the row where the cursor is. */
if (ISSET(SOFTWRAP))
leftedge = (xplustabs() / editwincols) * editwincols;
@@ -1803,7 +1799,7 @@ int do_mouse(void)
/* No more handling is needed. */
return 2;
}
#endif /* !DISABLE_MOUSE */
#endif /* ENABLE_MOUSE */
/* The user typed output_len multibyte characters. Add them to the edit
* buffer, filtering out all ASCII control characters if allow_cntrls is
@@ -1914,17 +1910,17 @@ int main(int argc, char **argv)
/* Should long lines be automatically hard wrapped? */
#endif
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
bool old_multibuffer;
/* The old value of the multibuffer option, restored after we
* load all files on the command line. */
#endif
const struct option long_options[] = {
{"boldtext", 0, NULL, 'D'},
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
{"multibuffer", 0, NULL, 'F'},
#endif
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
{"ignorercfiles", 0, NULL, 'I'},
#endif
{"rebindkeypad", 0, NULL, 'K'},
@@ -1935,20 +1931,21 @@ int main(int argc, char **argv)
#endif
{"restricted", 0, NULL, 'R'},
{"tabsize", 1, NULL, 'T'},
{"quickblank", 0, NULL, 'U'},
{"version", 0, NULL, 'V'},
#ifndef DISABLE_COLOR
{"syntax", 1, NULL, 'Y'},
#endif
{"constantshow", 0, NULL, 'c'},
{"rebinddelete", 0, NULL, 'd'},
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
{"showcursor", 0, NULL, 'g'},
#endif
{"help", 0, NULL, 'h'},
#ifdef ENABLE_LINENUMBERS
{"linenumbers", 0, NULL, 'l'},
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
{"mouse", 0, NULL, 'm'},
#endif
{"noread", 0, NULL, 'n'},
@@ -1981,7 +1978,6 @@ int main(int argc, char **argv)
{"poslog", 0, NULL, 'P'}, /* deprecated form, remove in 2018 */
{"positionlog", 0, NULL, 'P'},
{"smooth", 0, NULL, 'S'},
{"quickblank", 0, NULL, 'U'},
{"wordbounds", 0, NULL, 'W'},
{"wordchars", 1, NULL, 'X'},
{"autoindent", 0, NULL, 'i'},
@@ -2014,11 +2010,13 @@ int main(int argc, char **argv)
textdomain(PACKAGE);
#endif
#if defined(ENABLE_UTF8) && !defined(NANO_TINY)
if (MB_CUR_MAX > MAXCHARLEN)
fprintf(stderr, "Unexpected large character size: %i bytes"
" -- please report a bug\n", (int)MB_CUR_MAX);
#endif
#if defined(DISABLE_NANORC) && defined(DISABLE_ROOTWRAPPING)
#if !defined(ENABLE_NANORC) && defined(DISABLE_ROOTWRAPPING)
/* If we don't have rcfile support, --disable-wrapping-as-root is
* used, and we're root, turn wrapping off. */
if (geteuid() == NANO_ROOT_UID)
@@ -2060,7 +2058,7 @@ int main(int argc, char **argv)
SET(TABS_TO_SPACES);
break;
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
case 'F':
SET(MULTIBUFFER);
break;
@@ -2075,7 +2073,7 @@ int main(int argc, char **argv)
SET(HISTORYLOG);
break;
#endif
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
case 'I':
no_rcfiles = TRUE;
break;
@@ -2119,11 +2117,9 @@ int main(int argc, char **argv)
exit(1);
}
break;
#ifndef NANO_TINY
case 'U':
SET(QUICK_BLANK);
break;
#endif
case 'V':
version();
exit(0);
@@ -2141,7 +2137,7 @@ int main(int argc, char **argv)
break;
#endif
case 'c':
SET(CONST_UPDATE);
SET(CONSTANT_SHOW);
break;
case 'd':
SET(REBIND_DELETE);
@@ -2157,7 +2153,7 @@ int main(int argc, char **argv)
SET(CUT_TO_END);
break;
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
case 'm':
SET(USE_MOUSE);
break;
@@ -2173,7 +2169,7 @@ int main(int argc, char **argv)
case 'p':
SET(PRESERVE);
break;
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
case 'q':
SET(QUIET);
break;
@@ -2246,7 +2242,7 @@ int main(int argc, char **argv)
if (ISSET(RESTRICTED)) {
UNSET(SUSPEND);
UNSET(BACKUP_FILE);
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
no_rcfiles = TRUE;
UNSET(HISTORYLOG);
UNSET(POS_HISTORY);
@@ -2257,11 +2253,9 @@ int main(int argc, char **argv)
* before reading the rcfile, to be able to rebind/unbind keys. */
shortcut_init();
/* We've read through the command line options. Now back up the flags
* and values that are set, and read the rcfile(s). If the values
* haven't changed afterward, restore the backed-up values. */
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
if (!no_rcfiles) {
/* Back up the command-line options, then read the rcfile(s). */
#ifndef DISABLE_OPERATINGDIR
char *operating_dir_cpy = operating_dir;
#endif
@@ -2305,6 +2299,7 @@ int main(int argc, char **argv)
print_sclist();
#endif
/* If the backed-up command-line options have a value, restore them. */
#ifndef DISABLE_OPERATINGDIR
if (operating_dir_cpy != NULL) {
free(operating_dir);
@@ -2340,6 +2335,7 @@ int main(int argc, char **argv)
if (tabsize_cpy != -1)
tabsize = tabsize_cpy;
/* Simply OR the boolean flags from rcfile and command line. */
for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++)
flags[i] |= flags_cpy[i];
}
@@ -2349,7 +2345,7 @@ int main(int argc, char **argv)
else if (geteuid() == NANO_ROOT_UID)
SET(NO_WRAP);
#endif
#endif /* !DISABLE_NANORC */
#endif /* ENABLE_NANORC */
#ifndef DISABLE_WRAPPING
/* Override a "set nowrap" in an rcfile (or a --disable-wrapping-as-root)
@@ -2492,7 +2488,7 @@ int main(int argc, char **argv)
/* Set up the signal handlers. */
signal_init();
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
/* Initialize mouse support. */
mouse_init();
#endif
@@ -2556,7 +2552,7 @@ int main(int argc, char **argv)
optind++;
}
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
old_multibuffer = ISSET(MULTIBUFFER);
SET(MULTIBUFFER);
@@ -2595,7 +2591,7 @@ int main(int argc, char **argv)
}
}
}
#endif /* !DISABLE_MULTIBUFFER */
#endif /* ENABLE_MULTIBUFFER */
/* Now read the first file on the command line into a new buffer. */
if (optind < argc)
@@ -2609,7 +2605,7 @@ int main(int argc, char **argv)
UNSET(VIEW_MODE);
}
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
if (!old_multibuffer)
UNSET(MULTIBUFFER);
#endif
@@ -2627,10 +2623,10 @@ int main(int argc, char **argv)
#endif
#ifdef DEBUG
fprintf(stderr, "Main: show buffer contents, and enter main loop\n");
fprintf(stderr, "Main: show title bar, and enter main loop\n");
#endif
display_buffer();
prepare_for_display();
while (TRUE) {
#ifdef ENABLE_LINENUMBERS
@@ -2644,9 +2640,10 @@ int main(int argc, char **argv)
margin = needed_margin;
editwincols = COLS - margin;
#ifndef NANO_TINY
/* Ensure that firstcolumn is the starting column of its chunk. */
ensure_firstcolumn_is_aligned();
#endif
/* The margin has changed -- schedule a full refresh. */
refresh_needed = TRUE;
}
@@ -2660,12 +2657,12 @@ int main(int argc, char **argv)
/* Update the displayed current cursor position only when there
* are no keys waiting in the input buffer. */
if (ISSET(CONST_UPDATE) && get_key_buffer_len() == 0)
if (ISSET(CONSTANT_SHOW) && get_key_buffer_len() == 0)
do_cursorpos(FALSE);
/* Refresh just the cursor position or the entire edit window. */
if (!refresh_needed) {
reset_cursor();
place_the_cursor(TRUE);
wnoutrefresh(edit);
} else
edit_refresh();

View File

@@ -124,10 +124,10 @@
#include <signal.h>
#include <assert.h>
/* If we aren't using ncurses with mouse support, turn the mouse support
* off, as it's useless then. */
/* If we aren't using an ncurses with mouse support, exclude any
* mouse routines, as they are useless then. */
#ifndef NCURSES_MOUSE_VERSION
#define DISABLE_MOUSE 1
#undef ENABLE_MOUSE
#endif
#if defined(DISABLE_WRAPPING) && defined(DISABLE_JUSTIFY)
@@ -404,7 +404,7 @@ typedef struct openfilestruct {
/* The preceding open file, if any. */
} openfilestruct;
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
typedef struct rcoption {
const char *name;
/* The name of the rcfile option. */
@@ -442,7 +442,7 @@ typedef struct subnfunc {
/* In what menus this function applies. */
const char *desc;
/* The function's short description, for example "Where Is". */
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
const char *help;
/* The help-screen text for this function. */
bool blank_after;
@@ -480,7 +480,7 @@ enum
{
DONTUSE,
CASE_SENSITIVE,
CONST_UPDATE,
CONSTANT_SHOW,
NO_HELP,
SUSPEND,
NO_WRAP,
@@ -538,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

View File

@@ -57,7 +57,7 @@ int do_statusbar_input(bool *ran_func, bool *finished)
return KEY_WINCH;
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
/* If we got a mouse click and it was on a shortcut, read in the
* shortcut character. */
if (input == KEY_MOUSE) {
@@ -95,7 +95,7 @@ int do_statusbar_input(bool *ran_func, bool *finished)
kbinput = (int *)nrealloc(kbinput, kbinput_len * sizeof(int));
kbinput[kbinput_len - 1] = input;
}
}
}
/* If we got a shortcut, or if there aren't any other keystrokes waiting
* after the one we read in, we need to insert all the characters in the
@@ -164,7 +164,7 @@ int do_statusbar_input(bool *ran_func, bool *finished)
return input;
}
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
/* Handle a mouse click on the statusbar prompt or the shortcut list. */
int do_statusbar_mouse(void)
{
@@ -383,35 +383,18 @@ void reinit_statusbar_x(void)
statusbar_x = HIGHEST_POSITIVE;
}
/* Put the cursor in the answer at statusbar_x. */
void reset_statusbar_cursor(void)
{
size_t start_col = strlenpt(prompt) + 2;
size_t xpt = statusbar_xplustabs();
/* Work around a cursor-misplacement bug in VTEs. */
wmove(bottomwin, 0, 0);
wnoutrefresh(bottomwin);
doupdate();
wmove(bottomwin, 0, start_col + xpt -
get_statusbar_page_start(start_col, start_col + xpt));
wnoutrefresh(bottomwin);
}
/* Repaint the statusbar. */
/* Redraw the promptbar and place the cursor at the right spot. */
void update_the_statusbar(void)
{
size_t base, the_page, end_page;
size_t base = strlenpt(prompt) + 2;
size_t the_page, end_page, column;
char *expanded;
base = strlenpt(prompt) + 2;
the_page = get_statusbar_page_start(base, base + strnlenpt(answer, statusbar_x));
end_page = get_statusbar_page_start(base, base + strlenpt(answer) - 1);
/* Color the promptbar over its full width. */
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
blank_statusbar();
mvwaddstr(bottomwin, 0, 0, prompt);
@@ -426,7 +409,14 @@ void update_the_statusbar(void)
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
reset_statusbar_cursor();
/* Work around a cursor-misplacement bug in VTEs. */
wmove(bottomwin, 0, 0);
wrefresh(bottomwin);
/* Place the cursor at statusbar_x in the answer. */
column = base + statusbar_xplustabs();
wmove(bottomwin, 0, column - get_statusbar_page_start(base, column));
wnoutrefresh(bottomwin);
}
/* Get a string of input at the statusbar prompt. */
@@ -440,7 +430,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
int kbinput = ERR;
bool ran_func, finished;
functionptrtype func;
#ifndef DISABLE_TABCOMP
#ifdef ENABLE_TABCOMP
bool tabbed = FALSE;
/* Whether we've pressed Tab. */
#endif
@@ -450,7 +440,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
char *magichistory = NULL;
/* The temporary string typed at the bottom of the history, if
* any. */
#ifndef DISABLE_TABCOMP
#ifdef ENABLE_TABCOMP
int last_kbinput = ERR;
/* The key we pressed before the current key. */
size_t complete_len = 0;
@@ -468,10 +458,6 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
update_the_statusbar();
/* Refresh edit window and statusbar before getting input. */
wnoutrefresh(edit);
wnoutrefresh(bottomwin);
while (TRUE) {
/* Ensure the cursor is shown when waiting for input. */
curs_set(1);
@@ -495,7 +481,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
if (func == do_cancel || func == do_enter)
break;
#ifndef DISABLE_TABCOMP
#ifdef ENABLE_TABCOMP
if (func != do_tab)
tabbed = FALSE;
@@ -516,7 +502,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
answer = input_tab(answer, allow_files, &statusbar_x,
&tabbed, refresh_func, listed);
} else
#endif /* !DISABLE_TABCOMP */
#endif /* ENABLE_TABCOMP */
#ifndef DISABLE_HISTORIES
if (func == get_history_older_void) {
if (history_list != NULL) {
@@ -580,7 +566,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
update_the_statusbar();
#if !defined(DISABLE_HISTORIES) && !defined(DISABLE_TABCOMP)
#if !defined(DISABLE_HISTORIES) && defined(ENABLE_TABCOMP)
last_kbinput = kbinput;
#endif
}
@@ -620,8 +606,9 @@ int do_prompt(bool allow_tabs, bool allow_files,
int retval;
functionptrtype func = NULL;
bool listed = FALSE;
/* Save a possible current statusbar x position. */
/* Save a possible current statusbar x position and prompt. */
size_t was_statusbar_x = statusbar_x;
char *saved_prompt = prompt;
bottombars(menu);
@@ -644,7 +631,7 @@ int do_prompt(bool allow_tabs, bool allow_files,
refresh_func);
free(prompt);
prompt = NULL;
prompt = saved_prompt;
#ifndef NANO_TINY
if (retval == KEY_WINCH)
@@ -670,7 +657,7 @@ int do_prompt(bool allow_tabs, bool allow_files,
fprintf(stderr, "answer = \"%s\"\n", answer);
#endif
#ifndef DISABLE_TABCOMP
#ifdef ENABLE_TABCOMP
/* If we've done tab completion, there might still be a list of
* filename matches on the edit window. Clear them off. */
if (listed)
@@ -751,7 +738,7 @@ int do_yesno_prompt(bool all, const char *msg)
if (func == do_cancel)
response = -1;
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
else if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y;
/* We can click on the Yes/No/All shortcuts to select an answer. */
@@ -773,7 +760,7 @@ int do_yesno_prompt(bool all, const char *msg)
response = -2;
}
}
#endif /* !DISABLE_MOUSE */
#endif /* ENABLE_MOUSE */
else {
/* Look for the kbinput in the Yes, No (and All) strings. */
if (strchr(yesstr, kbinput) != NULL)

View File

@@ -24,6 +24,7 @@
#include "nano.h"
/* All external variables. See global.c for their descriptions. */
#ifndef NANO_TINY
extern volatile sig_atomic_t the_window_resized;
#endif
@@ -42,10 +43,19 @@ 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;
@@ -166,7 +176,7 @@ extern char *homedir;
typedef void (*functionptrtype)(void);
/* Most functions in browser.c. */
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
char *do_browse_from(const char *inpath);
void read_the_list(const char *path, DIR *dir);
functionptrtype parse_browser_input(int *kbinput);
@@ -202,9 +212,9 @@ int mbstrcasecmp(const char *s1, const char *s2);
int mbstrncasecmp(const char *s1, const char *s2, size_t n);
char *mbstrcasestr(const char *haystack, const char *needle);
char *revstrstr(const char *haystack, const char *needle,
const char *pointer);
char *mbrevstrcasestr(const char *haystack, const char *needle, const
char *rev_start);
const char *index);
char *mbrevstrcasestr(const char *haystack, const char *needle,
const char *index);
size_t mbstrlen(const char *s);
size_t mbstrnlen(const char *s, size_t maxlen);
#if !defined(NANO_TINY) || !defined(DISABLE_JUSTIFY)
@@ -212,18 +222,16 @@ char *mbstrchr(const char *s, const char *c);
#endif
#ifndef NANO_TINY
char *mbstrpbrk(const char *s, const char *accept);
char *revstrpbrk(const char *s, const char *accept, const char
*rev_start);
char *mbrevstrpbrk(const char *s, const char *accept, const char
*rev_start);
char *revstrpbrk(const char *head, const char *accept, const char *index);
char *mbrevstrpbrk(const char *head, const char *accept, const char *index);
#endif
#if !defined(DISABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
bool has_blank_mbchars(const char *s);
#endif
#ifdef ENABLE_UTF8
bool is_valid_unicode(wchar_t wc);
#endif
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
bool is_valid_mbstring(const char *s);
#endif
@@ -261,8 +269,8 @@ void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
filestruct *bot, size_t bot_x);
#endif
#endif
void display_buffer(void);
#ifndef DISABLE_MULTIBUFFER
void prepare_for_display(void);
#ifdef ENABLE_MULTIBUFFER
void switch_to_prev_buffer_void(void);
void switch_to_next_buffer_void(void);
bool close_buffer(void);
@@ -296,11 +304,11 @@ void do_writeout_void(void);
void do_savefile(void);
#endif
char *real_dir_from_tilde(const char *buf);
#if !defined(DISABLE_TABCOMP) || !defined(DISABLE_BROWSER)
#if defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
int diralphasort(const void *va, const void *vb);
void free_chararray(char **array, size_t len);
#endif
#ifndef DISABLE_TABCOMP
#ifdef ENABLE_TABCOMP
char *input_tab(char *buf, bool allow_files, size_t *place,
bool *lastwastab, void (*refresh_func)(void), bool *listed);
#endif
@@ -336,7 +344,8 @@ void thanks_for_all_the_fish(void);
#endif
/* All functions in help.c. */
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
void wrap_the_help_text(bool redisplaying);
void do_help(void);
void help_init(void);
functionptrtype parse_help_input(int *kbinput);
@@ -350,16 +359,16 @@ void do_last_line(void);
void do_page_up(void);
void do_page_down(void);
#ifndef DISABLE_JUSTIFY
void do_para_begin(bool allow_update);
void do_para_begin(bool update_screen);
void do_para_begin_void(void);
void do_para_end(bool allow_update);
void do_para_end(bool update_screen);
void do_para_end_void(void);
#endif
void do_prev_block(void);
void do_next_block(void);
void do_prev_word(bool allow_punct, bool allow_update);
void do_prev_word(bool allow_punct, bool update_screen);
void do_prev_word_void(void);
bool do_next_word(bool allow_punct, bool allow_update);
bool do_next_word(bool allow_punct, bool update_screen);
void do_next_word_void(void);
void do_home(bool be_clever);
void do_home_void(void);
@@ -396,7 +405,7 @@ void unlink_opennode(openfilestruct *fileptr);
void delete_opennode(openfilestruct *fileptr);
void print_view_warning(void);
void show_restricted_warning(void);
#ifdef DISABLE_HELP
#ifndef ENABLE_HELP
void say_there_is_no_help(void);
#endif
void finish(void);
@@ -421,13 +430,13 @@ void enable_flow_control(void);
void terminal_init(void);
void unbound_key(int code);
int do_input(bool allow_funcs);
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
int do_mouse(void);
#endif
void do_output(char *output, size_t output_len, bool allow_cntrls);
/* Most functions in prompt.c. */
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
int do_statusbar_mouse(void);
#endif
void do_statusbar_output(int *the_input, size_t input_len,
@@ -457,14 +466,14 @@ int do_prompt(bool allow_tabs, bool allow_files,
int do_yesno_prompt(bool all, const char *msg);
/* Most functions in rcfile.c. */
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
#ifndef DISABLE_COLOR
bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright);
void grab_and_store(const char *kind, char *ptr, regexlisttype **storage);
#endif
void parse_rcfile(FILE *rcstream, bool syntax_only);
void do_rcfiles(void);
#endif /* !DISABLE_NANORC */
#endif /* ENABLE_NANORC */
/* Most functions in search.c. */
void not_found_msg(const char *str);
@@ -487,7 +496,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
void do_gotolinecolumn_void(void);
#ifndef NANO_TINY
void do_find_bracket(void);
#ifndef DISABLE_TABCOMP
#ifdef ENABLE_TABCOMP
char *get_history_completion(filestruct **h, char *s, size_t len);
#endif
#endif
@@ -540,7 +549,7 @@ void update_undo(undo_type action);
void wrap_reset(void);
bool do_wrap(filestruct *line);
#endif
#if !defined(DISABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
#if defined(ENABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl);
#endif
#if !defined(NANO_TINY) || !defined(DISABLE_JUSTIFY)
@@ -596,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
@@ -622,7 +633,7 @@ int get_byte_kbinput(int kbinput);
int get_control_kbinput(int kbinput);
int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len);
int *parse_verbatim_kbinput(WINDOW *win, size_t *count);
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts);
#endif
const sc *get_shortcut(int *kbinput);
@@ -631,8 +642,7 @@ void blank_edit(void);
void blank_statusbar(void);
void blank_bottombars(void);
void check_statusblank(void);
char *display_string(const char *buf, size_t start_col, size_t span,
bool dollars);
char *display_string(const char *buf, size_t column, size_t span, bool isdata);
void titlebar(const char *path);
extern void set_modified(void);
void statusbar(const char *msg);
@@ -640,7 +650,7 @@ void warn_and_shortly_pause(const char *msg);
void statusline(message_type importance, const char *msg, ...);
void bottombars(int menu);
void onekey(const char *keystroke, const char *desc, int length);
void reset_cursor(void);
void place_the_cursor(bool forreal);
void edit_draw(filestruct *fileptr, const char *converted,
int line, size_t from_col);
int update_line(filestruct *fileptr, size_t index);
@@ -652,7 +662,9 @@ int go_back_chunks(int nrows, filestruct **line, size_t *leftedge);
int go_forward_chunks(int nrows, filestruct **line, size_t *leftedge);
bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge);
void edit_scroll(scroll_dir direction, int nrows);
#ifndef NANO_TINY
void ensure_firstcolumn_is_aligned(void);
#endif
void edit_redraw(filestruct *old_current);
void edit_refresh(void);
void adjust_viewport(update_type location);
@@ -671,22 +683,28 @@ void disable_nodelay(void);
void do_credits(void);
#endif
/* May as well throw these here, since they are just placeholders. */
/* These are just name definitions. */
void do_cancel(void);
void case_sens_void(void);
void regexp_void(void);
void backwards_void(void);
void flip_replace(void);
void gototext_void(void);
#ifdef ENABLE_BROWSER
void to_files_void(void);
void goto_dir_void(void);
#endif
#ifndef NANO_TINY
void dos_format_void(void);
void mac_format_void(void);
void append_void(void);
void prepend_void(void);
void backup_file_void(void);
void flip_execute(void);
#endif
#ifdef ENABLE_MULTIBUFFER
void flip_newbuffer(void);
#endif
void discard_buffer(void);
void new_buffer_void(void);
void backwards_void(void);
void goto_dir_void(void);
void flip_replace_void(void);
void flip_execute_void(void);
#endif /* !PROTO_H */

View File

@@ -30,7 +30,7 @@
#include <unistd.h>
#include <ctype.h>
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
#ifndef RCFILE_NAME
#define RCFILE_NAME ".nanorc"
@@ -44,8 +44,8 @@ static const rcoption rcopts[] = {
#ifndef DISABLE_JUSTIFY
{"brackets", 0},
#endif
{"const", CONST_UPDATE}, /* deprecated form, remove in 2018 */
{"constantshow", CONST_UPDATE},
{"const", CONSTANT_SHOW}, /* deprecated form, remove in 2018 */
{"constantshow", CONSTANT_SHOW},
#ifndef DISABLE_WRAPJUSTIFY
{"fill", 0},
#endif
@@ -53,10 +53,10 @@ static const rcoption rcopts[] = {
{"historylog", HISTORYLOG},
#endif
{"morespace", MORE_SPACE},
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
{"mouse", USE_MOUSE},
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
{"multibuffer", MULTIBUFFER},
#endif
{"nohelp", NO_HELP},
@@ -77,6 +77,7 @@ static const rcoption rcopts[] = {
{"punct", 0},
{"quotestr", 0},
#endif
{"quickblank", QUICK_BLANK},
{"rebinddelete", REBIND_DELETE},
{"rebindkeypad", REBIND_KEYPAD},
{"regexp", USE_REGEXP},
@@ -99,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},
@@ -159,9 +159,9 @@ void rcfile_error(const char *msg, ...)
fprintf(stderr, "\n");
}
#endif /* !DISABLE_NANORC */
#endif /* ENABLE_NANORC */
#if !defined(DISABLE_NANORC) || !defined(DISABLE_HISTORIES)
#if defined(ENABLE_NANORC) || !defined(DISABLE_HISTORIES)
/* Parse the next word from the string, null-terminate it, and return
* a pointer to the first character after the null terminator. The
* returned pointer will point to '\0' if we hit the end of the line. */
@@ -181,9 +181,9 @@ char *parse_next_word(char *ptr)
return ptr;
}
#endif /* !DISABLE_NANORC || !DISABLE_HISTORIES */
#endif /* ENABLE_NANORC || !DISABLE_HISTORIES */
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
/* Parse an argument, with optional quotes, after a keyword that takes
* one. If the next word starts with a ", we say that it ends with the
* last " of the line. Otherwise, we interpret it as usual, so that the
@@ -1300,4 +1300,4 @@ void do_rcfiles(void)
}
}
#endif /* !DISABLE_NANORC */
#endif /* ENABLE_NANORC */

View File

@@ -143,7 +143,8 @@ int search_init(bool replacing, bool use_answer)
/* This is now one simple call. It just does a lot. */
i = do_prompt(FALSE, FALSE,
replacing ? MREPLACE : MWHEREIS, backupstring,
inhelp ? MFINDINHELP : (replacing ? MREPLACE : MWHEREIS),
backupstring,
#ifndef DISABLE_HISTORIES
&search_history,
#endif
@@ -201,7 +202,7 @@ int search_init(bool replacing, bool use_answer)
TOGGLE(USE_REGEXP);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
} else if (func == do_replace || func == flip_replace_void) {
} else if (func == flip_replace) {
backupstring = mallocstrcpy(backupstring, answer);
return -2; /* Call the opposite search function. */
} else if (func == do_gotolinecolumn_void) {
@@ -437,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
@@ -883,6 +883,12 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
openfile->current_x = actual_x(openfile->current->data, column - 1);
openfile->placewewant = column - 1;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP) && openfile->placewewant / editwincols >
strlenpt(openfile->current->data) / editwincols)
openfile->placewewant = strlenpt(openfile->current->data);
#endif
/* When the position was manually given, center the target line. */
if (interactive) {
adjust_viewport(CENTERING);
@@ -1224,7 +1230,7 @@ void get_history_older_void(void)
;
}
#ifndef DISABLE_TABCOMP
#ifdef ENABLE_TABCOMP
/* Move h to the next string that's a tab completion of the string s,
* looking at only the first len characters of s, and return that
* string. If there isn't one, or if len is 0, don't move h and return
@@ -1277,5 +1283,5 @@ char *get_history_completion(filestruct **h, char *s, size_t len)
* match, or len is 0. Return s. */
return (char *)s;
}
#endif /* !DISABLE_TABCOMP */
#endif /* ENSABLE_TABCOMP */
#endif /* !DISABLE_HISTORIES */

View File

@@ -983,11 +983,9 @@ void do_enter(void)
{
filestruct *newnode = make_new_node(openfile->current);
size_t extra = 0;
#ifndef NANO_TINY
bool allblanks = FALSE;
assert(openfile->current != NULL && openfile->current->data != NULL);
#ifndef NANO_TINY
if (ISSET(AUTOINDENT)) {
extra = indent_length(openfile->current->data);
@@ -1142,7 +1140,9 @@ bool execute_command(const char *command)
void discard_until(const undo *thisitem, openfilestruct *thefile)
{
undo *dropit = thefile->undotop;
#ifdef ENABLE_COMMENT
undo_group *group;
#endif
while (dropit != NULL && dropit != thisitem) {
thefile->undotop = dropit->next;
@@ -1610,7 +1610,7 @@ bool do_wrap(filestruct *line)
}
#endif /* !DISABLE_WRAPPING */
#if !defined(DISABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
#if defined(ENABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
/* We are trying to break a chunk off line. We find the last blank such
* that the display length to there is at most (goal + 1). If there is
* no such blank, then we find the first blank. We then take the last
@@ -1645,7 +1645,7 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
if (column <= goal)
return index;
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
/* If we're wrapping a help text and no blank was found, or was
* found only as the first character, force a line break. */
if (snap_at_nl && lastblank < 1)
@@ -1682,7 +1682,7 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
return lastblank;
}
#endif /* !DISABLE_HELP || !DISABLE_WRAPJUSTIFY */
#endif /* ENABLE_HELP || !DISABLE_WRAPJUSTIFY */
#if !defined(NANO_TINY) || !defined(DISABLE_JUSTIFY)
/* The "indentation" of a line is the whitespace between the quote part
@@ -2011,13 +2011,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
@@ -2443,7 +2441,7 @@ void do_justify(bool full_justify)
do {
#endif
statusbar(_("Can now UnJustify!"));
reset_cursor();
place_the_cursor(TRUE);
curs_set(1);
kbinput = do_input(FALSE);
#ifndef NANO_TINY
@@ -2452,7 +2450,7 @@ void do_justify(bool full_justify)
/* If needed, unset the cursor-position suppression flag, so the cursor
* position /will/ be displayed upon a return to the main loop. */
if (ISSET(CONST_UPDATE))
if (ISSET(CONSTANT_SHOW))
do_cursorpos(FALSE);
func = func_from_key(&kbinput);
@@ -3315,7 +3313,7 @@ void do_linter(void)
}
/* Place and show the cursor to indicate the affected line. */
reset_cursor();
place_the_cursor(TRUE);
wnoutrefresh(edit);
curs_set(1);
@@ -3390,8 +3388,10 @@ void do_formatter(void)
return;
}
#ifndef NANO_TINY
/* We're not supporting partial formatting, oi vey. */
openfile->mark_set = FALSE;
#endif
status = write_file(temp, temp_file, TRUE, OVERWRITE, FALSE);
if (!status) {
@@ -3457,10 +3457,11 @@ void do_formatter(void)
set_modified();
#ifndef NANO_TINY
/* Flush the undo stack, to avoid a mess or crash when
* the user tries to undo things in reformatted lines. */
discard_until(NULL, openfile);
#endif
finalstatus = _("Finished formatting");
}
@@ -3498,7 +3499,7 @@ void do_wordlinechar_count(void)
filestruct *top, *bot;
size_t top_x, bot_x;
/* If the mark is on, partition the filestruct so that it
/* If the mark is on, partition the buffer so that it
* contains only the marked text, and turn the mark off. */
if (old_mark_set) {
mark_order((const filestruct **)&top, &top_x,
@@ -3528,7 +3529,7 @@ void do_wordlinechar_count(void)
nlines = openfile->filebot->lineno - openfile->fileage->lineno + 1;
chars = get_totsize(openfile->fileage, openfile->filebot);
/* Unpartition the filestruct so that it contains all the text
/* Unpartition the buffer so that it contains all the text
* again, and turn the mark back on. */
unpartition_filestruct(&filepart);
openfile->mark_set = TRUE;
@@ -3559,14 +3560,14 @@ void do_verbatim_input(void)
/* TRANSLATORS: This is displayed when the next keystroke will be
* inserted verbatim. */
statusbar(_("Verbatim Input"));
reset_cursor();
place_the_cursor(TRUE);
curs_set(1);
/* Read in all the verbatim characters. */
kbinput = get_verbatim_kbinput(edit, &kbinput_len);
/* Unsuppress cursor-position display or blank the statusbar. */
if (ISSET(CONST_UPDATE))
if (ISSET(CONSTANT_SHOW))
do_cursorpos(FALSE);
else {
blank_statusbar();

View File

@@ -60,30 +60,29 @@ void get_homedir(void)
int digits(ssize_t n)
{
if (n < 100000) {
if (n < 1000) {
if (n < 100)
return 2;
else
return 3;
} else {
if (n < 10000)
return 4;
else
return 5;
}
if (n < 1000) {
if (n < 100)
return 2;
else
return 3;
} else {
if (n < 10000)
return 4;
else
return 5;
}
} else {
if (n < 10000000) {
if (n < 1000000)
return 6;
else
return 7;
}
else {
if (n < 100000000)
return 8;
else
return 9;
}
if (n < 10000000) {
if (n < 1000000)
return 6;
else
return 7;
} else {
if (n < 100000000)
return 8;
else
return 9;
}
}
}
#endif
@@ -117,7 +116,7 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
const char *comma;
while (*str == ' ')
str++;
str++;
comma = strpbrk(str, "m,. /;");
@@ -237,6 +236,13 @@ bool is_separate_word(size_t position, size_t length, const char *buf)
const char *strstrwrapper(const char *haystack, const char *needle,
const char *start)
{
if (*needle == '\0') {
#ifndef NANO_TINY
statusline(ALERT, "Searching for nothing -- please report a bug");
#endif
return (char *)start;
}
if (ISSET(USE_REGEXP)) {
if (ISSET(BACKWARDS_SEARCH)) {
size_t last_find, ceiling, far_end;
@@ -275,7 +281,7 @@ const char *strstrwrapper(const char *haystack, const char *needle,
regmatches[0].rm_eo = far_end;
if (regexec(&search_regexp, haystack, 10, regmatches,
REG_STARTEND) != 0)
statusline(ALERT, "BAD: failed to refind the match!");
return NULL;
return haystack + regmatches[0].rm_so;
}
@@ -452,7 +458,7 @@ void new_magicline(void)
openfile->totsize++;
}
#ifndef NANO_TINY
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
/* Remove the magicline from filebot, if there is one and it isn't the
* only line in the file. Assume that edittop and current are not at
* filebot. */
@@ -466,7 +472,9 @@ void remove_magicline(void)
openfile->totsize--;
}
}
#endif
#ifndef NANO_TINY
/* Set top_x and bot_x to the top and bottom x-coordinates of the mark,
* respectively, based on the locations of top and bot. If
* right_side_up isn't NULL, set it to TRUE if the mark begins with
@@ -535,7 +543,7 @@ size_t get_totsize(const filestruct *begin, const filestruct *end)
}
#ifdef DEBUG
/* Dump the filestruct inptr to stderr. */
/* Dump the given buffer to stderr. */
void dump_filestruct(const filestruct *inptr)
{
if (inptr == openfile->fileage)
@@ -551,7 +559,7 @@ void dump_filestruct(const filestruct *inptr)
}
}
/* Dump the current buffer's filestruct to stderr in reverse. */
/* Dump the current buffer to stderr in reverse. */
void dump_filestruct_reverse(void)
{
const filestruct *fileptr = openfile->filebot;

View File

@@ -1235,7 +1235,7 @@ int parse_escape_sequence(WINDOW *win, int kbinput)
suppress_cursorpos = FALSE;
lastmessage = HUSH;
if (currmenu == MMAIN) {
reset_cursor();
place_the_cursor(TRUE);
curs_set(1);
}
}
@@ -1463,7 +1463,8 @@ int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len)
retval = parse_verbatim_kbinput(win, kbinput_len);
/* If the code is invalid in the current mode, discard it. */
if ((*retval == '\n' && as_an_at) || (*retval == '\0' && !as_an_at)) {
if (retval != NULL && ((*retval == '\n' && as_an_at) ||
(*retval == '\0' && !as_an_at))) {
*kbinput_len = 0;
beep();
}
@@ -1552,7 +1553,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
return get_input(NULL, *count);
}
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
/* Handle any mouse event that may have occurred. We currently handle
* releases/clicks of the first mouse button. If allow_shortcuts is
* TRUE, releasing/clicking on a visible shortcut will put back the
@@ -1706,7 +1707,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
/* Ignore all other mouse events. */
return 2;
}
#endif /* !DISABLE_MOUSE */
#endif /* ENABLE_MOUSE */
/* Return the shortcut that corresponds to the values of kbinput (the
* key itself) and meta_key (whether the key is a meta sequence). The
@@ -1791,14 +1792,12 @@ void check_statusblank(void)
statusblank--;
/* When editing and 'constantshow' is active, skip the blanking. */
if (currmenu == MMAIN && ISSET(CONST_UPDATE))
if (currmenu == MMAIN && ISSET(CONSTANT_SHOW))
return;
if (statusblank == 0) {
blank_statusbar();
wnoutrefresh(bottomwin);
reset_cursor();
wnoutrefresh(edit);
}
/* If the subwindows overlap, make sure to show the edit window now. */
@@ -1806,33 +1805,25 @@ void check_statusblank(void)
edit_refresh();
}
/* Convert buf into a string that can be displayed on screen. The
* caller wants to display buf starting with column start_col, and
* extending for at most span columns. start_col is zero-based. span
* is one-based, so span == 0 means you get "" returned. The returned
* string is dynamically allocated, and should be freed. If isdata is
* TRUE, the caller might put "$" at the beginning or end of the line if
* it's too long. */
char *display_string(const char *buf, size_t start_col, size_t span,
bool isdata)
/* Convert buf into a string that can be displayed on screen. The caller
* wants to display buf starting with the given column, and extending for
* at most span columns. column is zero-based, and span is one-based, so
* span == 0 means you get "" returned. The returned string is dynamically
* allocated, and should be freed. If isdata is TRUE, the caller might put
* "$" at the beginning or end of the line if it's too long. */
char *display_string(const char *buf, size_t column, size_t span, bool isdata)
{
size_t start_index;
/* Index in buf of the first character shown. */
size_t column;
/* Screen column that start_index corresponds to. */
size_t start_index = actual_x(buf, column);
/* The index of the first character that the caller wishes to show. */
size_t start_col = strnlenpt(buf, start_index);
/* The actual column where that first character starts. */
char *converted;
/* The string we return. */
size_t index;
/* The expanded string we will return. */
size_t index = 0;
/* Current position in converted. */
size_t beyond = start_col + span;
size_t beyond = column + span;
/* The column number just beyond the last shown character. */
start_index = actual_x(buf, start_col);
column = strnlenpt(buf, start_index);
assert(column <= start_col);
index = 0;
#ifdef USING_OLD_NCURSES
seen_wide = FALSE;
#endif
@@ -1843,32 +1834,31 @@ char *display_string(const char *buf, size_t start_col, size_t span,
/* If the first character starts before the left edge, or would be
* overwritten by a "$" token, then show placeholders instead. */
if (*buf != '\0' && *buf != '\t' && (column < start_col ||
(column > 0 && isdata && !ISSET(SOFTWRAP)))) {
if (*buf != '\0' && *buf != '\t' && (start_col < column ||
(start_col > 0 && isdata && !ISSET(SOFTWRAP)))) {
if (is_cntrl_mbchar(buf)) {
if (column < start_col) {
if (start_col < column) {
converted[index++] = control_mbrep(buf, isdata);
start_col++;
column++;
buf += parse_mbchar(buf, NULL, NULL);
}
}
#ifdef ENABLE_UTF8
else if (using_utf8() && mbwidth(buf) == 2) {
if (column >= start_col) {
else if (mbwidth(buf) == 2) {
if (start_col == column) {
converted[index++] = ' ';
start_col++;
column++;
}
/* Display the right half of a two-column character as '<'. */
converted[index++] = '<';
start_col++;
column++;
buf += parse_mbchar(buf, NULL, NULL);
}
#endif
}
while (*buf != '\0' && start_col < beyond) {
while (*buf != '\0' && column < beyond) {
int charlength, charwidth = 1;
if (*buf == ' ') {
@@ -1882,7 +1872,7 @@ char *display_string(const char *buf, size_t start_col, size_t span,
} else
#endif
converted[index++] = ' ';
start_col++;
column++;
buf++;
continue;
} else if (*buf == '\t') {
@@ -1896,11 +1886,11 @@ char *display_string(const char *buf, size_t start_col, size_t span,
} else
#endif
converted[index++] = ' ';
start_col++;
column++;
/* Fill the tab up with the required number of spaces. */
while (start_col % tabsize != 0) {
while (column % tabsize != 0) {
converted[index++] = ' ';
start_col++;
column++;
}
buf++;
continue;
@@ -1912,7 +1902,7 @@ char *display_string(const char *buf, size_t start_col, size_t span,
if (is_cntrl_mbchar(buf)) {
converted[index++] = '^';
converted[index++] = control_mbrep(buf, isdata);
start_col += 2;
column += 2;
buf += charlength;
continue;
}
@@ -1922,7 +1912,7 @@ char *display_string(const char *buf, size_t start_col, size_t span,
for (; charlength > 0; charlength--)
converted[index++] = *(buf++);
start_col += charwidth;
column += charwidth;
#ifdef USING_OLD_NCURSES
if (charwidth > 1)
seen_wide = TRUE;
@@ -1934,8 +1924,7 @@ char *display_string(const char *buf, size_t start_col, size_t span,
converted[index++] = '\xEF';
converted[index++] = '\xBF';
converted[index++] = '\xBD';
start_col += 1;
column++;
buf++;
/* For invalid codepoints, skip extra bytes. */
@@ -1944,7 +1933,7 @@ char *display_string(const char *buf, size_t start_col, size_t span,
}
/* If there is more text than can be shown, make room for the $ or >. */
if (*buf != '\0' && (start_col > beyond || (isdata && !ISSET(SOFTWRAP)))) {
if (*buf != '\0' && (column > beyond || (isdata && !ISSET(SOFTWRAP)))) {
index = move_mbleft(converted, index);
#ifdef ENABLE_UTF8
@@ -1962,10 +1951,9 @@ char *display_string(const char *buf, size_t start_col, size_t span,
/* If path is NULL, we're in normal editing mode, so display the current
* version of nano, the current filename, and whether the current file
* has been modified on the titlebar. If path isn't NULL, we're in the
* file browser, and path contains the directory to start the file
* browser in, so display the current version of nano and the contents
* of path on the titlebar. */
* has been modified on the titlebar. If path isn't NULL, we're either
* in the file browser or the help viewer, so show either the current
* directory or the title of help text, that is: whatever is in path. */
void titlebar(const char *path)
{
size_t verlen, prefixlen, pathlen, statelen;
@@ -1974,6 +1962,8 @@ void titlebar(const char *path)
/* The width that "Modified" would take up. */
size_t offset = 0;
/* The position at which the center part of the titlebar starts. */
const char *branding = BRANDING;
/* What is shown in the top left corner. */
const char *prefix = "";
/* What is shown before the path -- "File:", "DIR:", or "". */
const char *state = "";
@@ -1997,12 +1987,13 @@ void titlebar(const char *path)
* then sacrifice the prefix, and only then start dottifying. */
/* Figure out the path, prefix and state strings. */
#ifndef DISABLE_BROWSER
if (path != NULL)
if (inhelp)
branding = "";
#ifdef ENABLE_BROWSER
else if (path != NULL)
prefix = _("DIR:");
else
#endif
{
else {
if (openfile->filename[0] == '\0')
path = _("New Buffer");
else {
@@ -2019,11 +2010,11 @@ void titlebar(const char *path)
}
/* Determine the widths of the four elements, including their padding. */
verlen = strlenpt(BRANDING) + 3;
verlen = strlenpt(branding) + 3;
prefixlen = strlenpt(prefix);
if (prefixlen > 0)
prefixlen++;
pathlen= strlenpt(path);
pathlen = strlenpt(path);
statelen = strlenpt(state) + 2;
if (statelen > 2) {
pathlen++;
@@ -2032,7 +2023,7 @@ void titlebar(const char *path)
/* Only print the version message when there is room for it. */
if (verlen + prefixlen + pathlen + pluglen + statelen <= COLS)
mvwaddstr(topwin, 0, 2, BRANDING);
mvwaddstr(topwin, 0, 2, branding);
else {
verlen = 2;
/* If things don't fit yet, give up the placeholder. */
@@ -2079,9 +2070,7 @@ void titlebar(const char *path)
wattroff(topwin, interface_color_pair[TITLE_BAR]);
wnoutrefresh(topwin);
reset_cursor();
wnoutrefresh(edit);
wrefresh(topwin);
}
/* Display a normal message on the statusbar, quietly. */
@@ -2173,21 +2162,20 @@ void statusline(message_type importance, const char *msg, ...)
wattroff(bottomwin, interface_color_pair[STATUS_BAR]);
/* Push the message to the screen straightaway. */
wnoutrefresh(bottomwin);
doupdate();
wrefresh(bottomwin);
suppress_cursorpos = TRUE;
#ifndef NANO_TINY
if (old_whitespace)
SET(WHITESPACE_DISPLAY);
#endif
/* If doing quick blanking, blank the statusbar after just one keystroke.
* Otherwise, blank it after twenty-six keystrokes, as Pico does. */
if (ISSET(QUICK_BLANK))
statusblank = 1;
else
#endif
statusblank = 26;
}
@@ -2252,11 +2240,7 @@ void bottombars(int menu)
/* Defeat a VTE bug by moving the cursor and forcing a screen update. */
wmove(bottomwin, 0, 0);
wnoutrefresh(bottomwin);
doupdate();
reset_cursor();
wnoutrefresh(edit);
wrefresh(bottomwin);
}
/* Write a shortcut key to the help area at the bottom of the window.
@@ -2284,7 +2268,7 @@ void onekey(const char *keystroke, const char *desc, int length)
/* Redetermine current_y from the position of current relative to edittop,
* and put the cursor in the edit window at (current_y, "current_x"). */
void reset_cursor(void)
void place_the_cursor(bool forreal)
{
ssize_t row = 0;
size_t col, xpt = xplustabs();
@@ -2306,7 +2290,7 @@ void reset_cursor(void)
col = xpt % editwincols;
/* If the cursor ought to be in column zero, nudge it there. */
if (openfile->placewewant % editwincols == 0 && col != 0) {
if (forreal && openfile->placewewant % editwincols == 0 && col != 0) {
row++;
col = 0;
}
@@ -2320,7 +2304,8 @@ void reset_cursor(void)
if (row < editwinrows)
wmove(edit, row, margin + col);
openfile->current_y = row;
if (forreal)
openfile->current_y = row;
}
/* edit_draw() takes care of the job of actually painting a line into
@@ -2699,8 +2684,10 @@ int update_line(filestruct *fileptr, size_t index)
/* If the line is offscreen, don't even try to display it. */
if (row < 0 || row >= editwinrows) {
#ifndef NANO_TINY
statusline(ALERT, "Badness: tried to display a line on row %i"
" -- please report a bug", row);
#endif
return 0;
}
@@ -2914,9 +2901,17 @@ void edit_scroll(scroll_dir direction, int nrows)
nrows -= go_forward_chunks(nrows, &openfile->edittop, &openfile->firstcolumn);
/* Don't bother scrolling zero rows, nor more than the window can hold. */
if (nrows == 0)
if (nrows == 0) {
#ifndef NANO_TINY
statusline(ALERT, "Underscrolling -- please report a bug");
#endif
return;
}
if (nrows >= editwinrows) {
#ifndef NANO_TINY
if (editwinrows > 1)
statusline(ALERT, "Overscrolling -- please report a bug");
#endif
refresh_needed = TRUE;
return;
}
@@ -2960,16 +2955,19 @@ void edit_scroll(scroll_dir direction, int nrows)
}
}
#ifndef NANO_TINY
/* Ensure that firstcolumn is at the starting column of the softwrapped chunk
* it's on. We need to do this when the number of columns of the edit window
* has changed, because then the width of softwrapped chunks has changed. */
void ensure_firstcolumn_is_aligned(void)
{
#ifndef NANO_TINY
if (openfile->firstcolumn % editwincols != 0)
openfile->firstcolumn -= (openfile->firstcolumn % editwincols);
#endif
/* If smooth scrolling is on, make sure the viewport doesn't center. */
focusing = FALSE;
}
#endif
/* Return TRUE if current[current_x] is above the top of the screen, and FALSE
* otherwise. */
@@ -3063,6 +3061,12 @@ void edit_refresh(void)
filestruct *line;
int row = 0;
#ifndef DISABLE_COLOR
/* When needed, initialize the colors for the current syntax. */
if (!have_palette)
color_init();
#endif
/* If the current line is out of view, get it back on screen. */
if (current_is_offscreen()) {
#ifdef DEBUG
@@ -3089,44 +3093,29 @@ void edit_refresh(void)
while (row < editwinrows)
blank_row(edit, row++, 0, COLS);
reset_cursor();
place_the_cursor(TRUE);
wnoutrefresh(edit);
refresh_needed = FALSE;
}
/* Move edittop so that current is on the screen. manner says how it
* should be moved: CENTERING means that current should end up in the
* middle of the screen, STATIONARY means that it should stay at the
* same vertical position, and FLOWING means that it should scroll no
* more than needed to bring current into view. */
/* Move edittop so that current is on the screen. manner says how:
* STATIONARY means that the cursor should stay on the same screen row,
* CENTERING means that current should end up in the middle of the screen,
* and FLOWING means that it should scroll no more than needed to bring
* current into view. */
void adjust_viewport(update_type manner)
{
int goal = 0;
/* If manner is CENTERING, move edittop half the number of window rows
* back from current. If manner is FLOWING, move edittop back 0 rows
* or (editwinrows - 1) rows, depending on where current has moved.
* This puts the cursor on the first or the last row. If manner is
* STATIONARY, move edittop back current_y rows if current_y is in range
* of the screen, 0 rows if current_y is below zero, or (editwinrows - 1)
* rows if current_y is too big. This puts current at the same place on
* the screen as before, or... at some undefined place. */
if (manner == CENTERING)
goal = editwinrows / 2;
else if (manner == FLOWING) {
if (!current_is_above_screen())
goal = editwinrows - 1;
} else {
if (manner == STATIONARY)
goal = openfile->current_y;
/* Limit goal to (editwinrows - 1) rows maximum. */
if (goal > editwinrows - 1)
goal = editwinrows - 1;
}
else if (manner == CENTERING)
goal = editwinrows / 2;
else if (!current_is_above_screen())
goal = editwinrows - 1;
openfile->edittop = openfile->current;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP))
openfile->firstcolumn = (xplustabs() / editwincols) * editwincols;
@@ -3158,8 +3147,13 @@ void total_redraw(void)
void total_refresh(void)
{
total_redraw();
titlebar(NULL);
edit_refresh();
titlebar(title);
#ifdef ENABLE_HELP
if (inhelp)
wrap_the_help_text(TRUE);
else
#endif
edit_refresh();
bottombars(currmenu);
}
@@ -3258,7 +3252,7 @@ void spotlight(bool active, const char *word)
room--;
}
reset_cursor();
place_the_cursor(FALSE);
if (active)
wattron(edit, hilite_attribute);
@@ -3337,7 +3331,7 @@ void do_credits(void)
"",
"",
"",
"(C) 1999 - 2016",
"(C) 2017",
"Free Software Foundation, Inc.",
"",
"",
@@ -3384,12 +3378,9 @@ void do_credits(void)
const char *what;
size_t start_col;
if (credits[crpos] == NULL) {
assert(0 <= xlpos && xlpos < XLCREDIT_LEN);
what = _(xlcredits[xlpos]);
xlpos++;
} else
if (credits[crpos] == NULL)
what = _(xlcredits[xlpos++]);
else
what = credits[crpos];
start_col = COLS / 2 - strlenpt(what) / 2 - 1;

View File

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

View File

@@ -1,11 +1,17 @@
## A default syntax, which is used
## for files that do not match any other syntax.
## An example of a default syntax. The default syntax is used for
## files that do not match any other syntax.
syntax "default"
comment "#"
# Comments.
color cyan "^#.*"
# Spaces in front of tabs.
color ,red " + +"
# Nano's name, including version.
color brightred "(GNU )?nano [1-9]\.[0-9]\.[^[:space:][:punct:]]+"
# Email addresses.
color yellow "<[[:alnum:].%_+-]+@[[:alnum:].-]+\.[[:alpha:]]{2,}>"

View File

@@ -7,7 +7,7 @@ color red "[:=]"
color magenta "\<(if|ifeq|else|endif)\>"
color blue "\$+[{(][a-zA-Z0-9_-]+[})]"
color brightblue "^[^ ]+:"
color green "#.*$"
color green "(^|[[:space:]]+)#.*"
## Trailing whitespace.
color ,green "[[:space:]]+$"

12
syntax/nanohelp.nanorc Normal file
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 "\^([]4-8A-Z^\_←→↑↓]|Home|End)" "[←→↑↓]"
color cyan "\<(Tab|Enter|Home|End|Ins|Del|Bsp|PgUp|PgDn)\>"
color cyan "\<M-." "\<F1?[0-9]" "(\^|M-)Space"
# Quoted indicators:
color brightred "'(\^|M-)'"

View File

@@ -1,32 +1,35 @@
## Here is an example for PHP.
syntax "php" "\.php[2345s~]?$"
syntax "php" "\.ph(p[23457s~]?|tml)$"
magic "PHP script text"
comment "//"
# PHP markings.
color brightgreen "(<\?(php)?|\?>)"
# Functions.
# Function names.
color white "\<[a-z_]*\("
# Variable names.
color cyan "\$[a-z_]+"
# Types.
color green "\<(var|float|global|double|bool|char|int|enum|const)\>"
color green "\<(array|bool|callable|const|float|global|int|object|string|var)\>"
# Structure.
color brightyellow "\<(class|new|private|public|function|for|foreach|if|while|do|else|elseif|case|default|switch)\>"
# Directives and structure.
color brightyellow "\<(abstract|as|class|clone|(end)?declare|extends|function|implements|include(_once)?|inst(ance|ead)of|interface|namespace|new|private|protected|public|require(_once)?|static|trait|use|yield)\>"
color brightyellow "\<(case|catch|default|do|echo|else(if)?|end(for(each)?|if|switch|while)|final(ly)?|for(each)?|if|print|switch|throw|try|while)\>"
# Operators.
color brightyellow "\<(and|or|xor)\>"
# Control flow.
color magenta "\<(goto|continue|break|return)\>"
color magenta "\<(break|continue|goto|return)\>"
# Strings.
color brightyellow "<[^= ]*>" ""(\.|[^"])*""
color brightyellow ""(\.|[^"])*"" "'(\.|[^'])*'"
# Comments.
color brightblue "//.*"
color brightblue "(^|[[:space:]]+)//.*"
color brightblue start="/\*" end="\*/"
##color blue start="<" end=">"
##color red "&[^;[:space:]]*;"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -1,6 +1,7 @@
## Here is an example for XML files.
syntax "xml" "\.([jrsx]html?|jnlp|mml|pom|rng|sgml?|svg|w[as]dl|wsdd|xjb|xml|xs(d|lt?)|xul)$"
header "<\?xml.*version=.*\?>"
magic "(XML|SGML) (sub)?document text"
comment "<!--|-->"