Compare commits
171 Commits
v2.3.99pre
...
v2.4.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5190ab9c9b | ||
|
|
b60f555843 | ||
|
|
953ccc990f | ||
|
|
296ff1ed2a | ||
|
|
6062a040e1 | ||
|
|
954f98c448 | ||
|
|
076fcbf631 | ||
|
|
38e8ed14ca | ||
|
|
ecffb85656 | ||
|
|
f0bb50306c | ||
|
|
412b9fc0a2 | ||
|
|
75ac24b25e | ||
|
|
4499520c03 | ||
|
|
7f0003a54b | ||
|
|
57f52a8a20 | ||
|
|
e219bb9dba | ||
|
|
4310139117 | ||
|
|
11fa458677 | ||
|
|
e06472a249 | ||
|
|
a267699440 | ||
|
|
025553769e | ||
|
|
7c2f53b2a9 | ||
|
|
3021a04c1c | ||
|
|
86cbd959f6 | ||
|
|
ef2593695d | ||
|
|
6404101407 | ||
|
|
67667af233 | ||
|
|
82373d85f9 | ||
|
|
c32a58a826 | ||
|
|
26ae9dbd12 | ||
|
|
d49c267f91 | ||
|
|
2e121fa08c | ||
|
|
e00b3e8587 | ||
|
|
87e963a2c7 | ||
|
|
74ac8ce407 | ||
|
|
f87de12b96 | ||
|
|
1a3fa549a9 | ||
|
|
0424243e3c | ||
|
|
a1c4da8b04 | ||
|
|
7b2ea40575 | ||
|
|
1f3148db4b | ||
|
|
24f39d3ad1 | ||
|
|
40bfc729ca | ||
|
|
01e39f4ff9 | ||
|
|
d297784b87 | ||
|
|
72b437bbd2 | ||
|
|
3e8dadfb1b | ||
|
|
2661d6d397 | ||
|
|
59187b8051 | ||
|
|
75d64e677e | ||
|
|
c5710d0ef8 | ||
|
|
de6da120a0 | ||
|
|
f111c0d6ab | ||
|
|
55d1e1a9b8 | ||
|
|
2da9cbf1a1 | ||
|
|
a338798559 | ||
|
|
46464105f2 | ||
|
|
7f3bd26593 | ||
|
|
9233c98a7e | ||
|
|
ec8d51bee3 | ||
|
|
3739016e45 | ||
|
|
df7524d7e8 | ||
|
|
b454d9c89b | ||
|
|
af708843f6 | ||
|
|
ca1983adb4 | ||
|
|
1cf22d4d4f | ||
|
|
583a30e971 | ||
|
|
6bdcc8faa9 | ||
|
|
e68759bf12 | ||
|
|
ec0e0235fa | ||
|
|
7edd350593 | ||
|
|
455a918071 | ||
|
|
296152ec67 | ||
|
|
6ff772b8d9 | ||
|
|
3de2c704ef | ||
|
|
cc65a42035 | ||
|
|
5b83d7df51 | ||
|
|
45772652ff | ||
|
|
f225991b05 | ||
|
|
4d2b198403 | ||
|
|
5ea46cacb6 | ||
|
|
fd759d5ca3 | ||
|
|
f34c8fdc6b | ||
|
|
1cf9deb603 | ||
|
|
4e5ea18394 | ||
|
|
4e9b3687ba | ||
|
|
99d2358510 | ||
|
|
08a52c1dab | ||
|
|
ce48ca2223 | ||
|
|
2dc9cbefd3 | ||
|
|
0f7b99b433 | ||
|
|
057348e1da | ||
|
|
ab21161a69 | ||
|
|
d8b6dbfffe | ||
|
|
d5177059e8 | ||
|
|
a9647b0508 | ||
|
|
37fd348a1d | ||
|
|
2aac470cb9 | ||
|
|
25ce5f6759 | ||
|
|
5d0b267aaa | ||
|
|
c2ed8277c2 | ||
|
|
d7ade1f346 | ||
|
|
de53c53c6e | ||
|
|
5ac108188d | ||
|
|
e683e32c74 | ||
|
|
7fe830fd20 | ||
|
|
07e199ff0e | ||
|
|
6f2da6b9b2 | ||
|
|
14a9c8aa0b | ||
|
|
52d7d5f55a | ||
|
|
0b6d6f45d2 | ||
|
|
0a79c78e05 | ||
|
|
ad827a6aef | ||
|
|
41580848e3 | ||
|
|
b455fa3a16 | ||
|
|
ff4a457d82 | ||
|
|
eae9f282de | ||
|
|
e39cf37026 | ||
|
|
6440aa9e47 | ||
|
|
745fab8293 | ||
|
|
a37ebcf2f8 | ||
|
|
92142bed34 | ||
|
|
83ec9e7d50 | ||
|
|
a0a0556993 | ||
|
|
33ac317132 | ||
|
|
9007c58bdd | ||
|
|
2456dd2a85 | ||
|
|
a44cf41d37 | ||
|
|
76e7aaf514 | ||
|
|
cb776fad88 | ||
|
|
a4f28694c8 | ||
|
|
82d737ee6d | ||
|
|
138add24c8 | ||
|
|
532d55c8bd | ||
|
|
3345e3407d | ||
|
|
52d1c20973 | ||
|
|
6898c60ba6 | ||
|
|
69d26c35fb | ||
|
|
4d9b5e92b3 | ||
|
|
18a2edfb84 | ||
|
|
4e95ee9f6e | ||
|
|
79ff393dc2 | ||
|
|
03bcaf6067 | ||
|
|
5891c4a542 | ||
|
|
3131d0c48a | ||
|
|
336b0ecbca | ||
|
|
32e76c4386 | ||
|
|
7d77521794 | ||
|
|
7f61fa1b55 | ||
|
|
98485c96d8 | ||
|
|
184cf609c0 | ||
|
|
e73e02fe10 | ||
|
|
ed2f0b349f | ||
|
|
d4e1d31ea4 | ||
|
|
bb4edd0136 | ||
|
|
c9b3a71d02 | ||
|
|
1b65b19abd | ||
|
|
35cd49ec50 | ||
|
|
6c7764862b | ||
|
|
9c88cab78c | ||
|
|
651bb5009f | ||
|
|
86c6cd1725 | ||
|
|
bd98ff02f6 | ||
|
|
057ef182cd | ||
|
|
67cdd5ee1e | ||
|
|
92896a708d | ||
|
|
57fa775f25 | ||
|
|
8d53aa3ad2 | ||
|
|
5b1fb56a8f | ||
|
|
6948d2e779 | ||
|
|
69429ce274 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -14,6 +14,7 @@ core
|
||||
/INSTALL
|
||||
/aclocal.m4
|
||||
/autom4te.cache
|
||||
/compile
|
||||
/config.cache
|
||||
/config.guess
|
||||
/config.h
|
||||
|
||||
448
ChangeLog
448
ChangeLog
@@ -1,3 +1,451 @@
|
||||
GNU nano 2.4.2 - 2015.07.05
|
||||
2015-06-28 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/browser.c (browser_refresh): Limit the selected file to the
|
||||
available ones in the list -- after a refresh the number may have
|
||||
decreased. This fixes Savannah bug #45424.
|
||||
* src/text.c (do_deletion): There is no need to check again for the
|
||||
line ending -- it was done already in the encompassing 'if'.
|
||||
* src/text.c: Unwrap some lines, rewrap some others more logically,
|
||||
plus several other esthetic tweaks.
|
||||
* doc/syntax/xml.nanorc: Recognize many more kinds of XML files.
|
||||
This addresses Debian bug #790017 reported by Emmanuel Bourg.
|
||||
Also colour the strings in tags differently, and add some comments.
|
||||
|
||||
2015-06-27 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/text.c (do_undo, add_undo): Skip undoing a backspace *only* when
|
||||
it really tried to delete the final, magic newline.
|
||||
* src/nano.h, src/text.c: Rename three flags for clarity.
|
||||
* src/files.c (replace_buffer): This function is only ever called with
|
||||
a temporary file as parameter, so forget the case of an empty filename.
|
||||
Also, don't bother putting the pointer at the top of the buffer, as the
|
||||
first action after this function is to restore the cursor position.
|
||||
* src/files.c: Normalize whitespace and comments.
|
||||
* src/nano.h: Remove obsolete execute flag from the shortcut struct.
|
||||
* src/global.c (shortcut_init): Remove a duplicate binding of ^T, to
|
||||
prevent it being shown twice in the ^G help text. It will be rebound
|
||||
dynamically when for the current syntax another function is available.
|
||||
|
||||
2015-06-23 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/winio.c (edit_draw): Verify that there exists multidata for the
|
||||
found starting line before trying to use it. When a file is inserted
|
||||
(^R), it will not have any precalculated multidata associated with it.
|
||||
This fixes Savannah bug #45377 reported by Cody A. Taylor.
|
||||
|
||||
2015-06-20 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/search.c (do_research): If nothing was searched for yet during
|
||||
this run of nano, take the most recent item from the search history.
|
||||
This makes M-W work also right after startup, like <n> in vim/less.
|
||||
* src/utils.c (get_homedir): Keep homedir NULL when no home directory
|
||||
could be determined, so that nano will show a message about it. This
|
||||
is a fix for Savannah bug #45343.
|
||||
* doc/syntax/nanorc.nanorc: Colour key-binding lines affirmatively
|
||||
only when the specified menu name is an existing one.
|
||||
* doc/syntax/changelog.nanorc: Stop the changed-files colour from
|
||||
spilling beyond a blank line. Also highlight releases.
|
||||
* src/nano.c (main), src/rcfile.c: Remove the obsolete long option
|
||||
--undo. And sort --help and the softwrap option more consistently.
|
||||
|
||||
2015-06-18 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/rcfile.c: Allow a tiny nano's ~/.nanorc to enable search and
|
||||
position histories. Also sort the options more strictly.
|
||||
* src/nano.h: Delete two unused things, and add two comments.
|
||||
|
||||
2015-06-17 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/text.c (do_undo, add_undo): When undoing a Backspace at the tail
|
||||
of the file and nonewlines is not set, then don't add another newline
|
||||
but just reposition the cursor. Also, when doing a Delete at the tail
|
||||
of the file, don't add a superfluous undo structure. This prevents
|
||||
the appearance of an extra newline when undoing the Backspace/Delete.
|
||||
Patch partially by Mark Majeres. The problem was first reported in
|
||||
https://lists.gnu.org/archive/html/nano-devel/2015-06/msg00003.html.
|
||||
* src/text.c (do_undo): Adjust whitespace after the previous change.
|
||||
* src/text.c (add_undo): Elide an unneeded variable and correct two
|
||||
comments. And try to put the more frequent condition first.
|
||||
* src/text.c (add_undo): Rename the parameter 'current_action' to
|
||||
'action', to match the other functions.
|
||||
* src/text.c (do_undo, add_undo, update_undo): Improve the visibility
|
||||
of the undo-related debugging messages.
|
||||
|
||||
2015-06-14 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/winio.c (edit_draw): Add some debugging code to track which
|
||||
multidata codes (for multiline regexes) get assigned to which lines.
|
||||
* src/winio.c (edit_draw): Start and end regexes can be very similar;
|
||||
so if a found start has been qualified as an end earlier, believe it
|
||||
and skip to the next step. This helps with Python's docstrings.
|
||||
* src/winio.c (edit_draw): When the whole line has been coloured,
|
||||
don't bother looking for any more starts. This prevents some lines
|
||||
from being erroneously marked as CENDAFTER instead of CWHOLELINE.
|
||||
* src/*.c: Don't check for non-NULL before freeing; it's unneeded.
|
||||
|
||||
2015-06-11 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/winio.c (get_key_buffer): Add some debugging code to make it
|
||||
easy to see what codes a key stroke produces.
|
||||
|
||||
2015-06-07 Benno Schulenberg <bensberg@justemail.net>
|
||||
* doc/texinfo/nano.texi: Show the node with the command-line options
|
||||
in the main menu, to make it easy to find.
|
||||
* doc/texinfo/nano.texi: Improve some formatting, hyphenation, wording
|
||||
and dashes. And remove some confusing, historical things.
|
||||
* doc/man/nano.1, doc/man/nanorc.5, doc/texinfo/nano.texi: Clarify the
|
||||
meaning of --backupdir: it doesn't just specify a directory for saving
|
||||
backup files, it mainly causes uniquely numbered backups to be made.
|
||||
* doc/man/nano.1: Add a section on the non-obvious functioning of the
|
||||
cutbuffer and the mark.
|
||||
|
||||
2015-06-04 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/nano.h: Fix compilation with --enable-tiny.
|
||||
* nano.spec.in: Add the post-install and pre-uninstall rules for the
|
||||
Info document, plus some tweaks. (Patch was tested by Kamil Dudka.)
|
||||
|
||||
2015-06-02 Benno Schulenberg <bensberg@justemail.net>
|
||||
* doc/man/nanorc.5, doc/texinfo/nano.texi: Tweak some wordings, and
|
||||
add some missing formatting to the Info document, and fix an mdash.
|
||||
* doc/syntax/debian.nanorc: Colour also an optional option.
|
||||
This addresses Debian bug #664456 reported by Shawn Landden.
|
||||
Also shorten the name of the syntax to "sources.list".
|
||||
* doc/syntax/python.nanorc: Require again that the triple quote that
|
||||
starts a docstring is followed by some character -- it is better to
|
||||
*not* colour some strings than far too often colour far too much.
|
||||
This addresses Debian bug #785508 reported by Alexandre Detiste.
|
||||
|
||||
2015-05-31 Mahyar Abbaspour <mahyar.abaspour@gmail.com>
|
||||
* src/prompt.c (get_statusbar_page_start): Prevent a floating-point
|
||||
exception when the available length for an answer becomes zero.
|
||||
|
||||
2015-05-28 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/help.c (do_help), src/prompt.c (do_yesno_prompt): Normalize
|
||||
the whitespace after the recent changes in logic.
|
||||
* src/prompt.c (do_yesno_prompt): Use 'width' instead of hardcoded
|
||||
16. Also always first set the string and then position the cursor.
|
||||
* TODO: Mark window resizes and better file-type detection as done.
|
||||
* doc/syntax/debian.nanorc: Allow a CD name to contain any character.
|
||||
This addresses Debian bug #688892 reported by Dani Möller Montull.
|
||||
|
||||
2015-05-28 Mahyar Abbaspour <mahyar.abaspour@gmail.com>
|
||||
* src/nano.c (handle_sigwinch, regenerate_screen), src/global.c,
|
||||
src/prompt.c (do_statusbar_input, get_prompt_string, do_yesno_prompt),
|
||||
src/browser.c (do_browser, browser_refresh), src/help.c (do_help),
|
||||
src/winio.c (get_key_buffer, unget_input, get_input, parse_kbinput),
|
||||
src/text.c (do_justify, do_linter), src/nano.h, src/proto.h:
|
||||
Handle a SIGWINCH (signalling a change in window size) not when it
|
||||
happens but only when checking for input. Report the SIGWINCH via
|
||||
a special key value to the calling routine, to allow not only the
|
||||
main editor but also the help viewer and the file browser to adapt
|
||||
their display to the new size. (Patch edited by Benno.)
|
||||
|
||||
2015-05-20 Devrim Gündüz <devrim@gunduz.org>
|
||||
* doc/syntax/postgresql.nanorc: New file -- syntax highlighting for
|
||||
PostgreSQL, first posted as Savannah patch #8601. Trimmed by Benno.
|
||||
|
||||
2015-05-08 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/browser.c (browser_refresh): Take the distant possibility of
|
||||
terabyte files into account, and in the bargain get rid of the need
|
||||
to calculate the number of digits in UINT_MAX.
|
||||
* src/files.c (get_next_filename): Limit the number of backup files
|
||||
to one hundred thousand -- which should be far more than enough --
|
||||
before finding an unused filename takes an annoying amount of time.
|
||||
* src/utils.c (digits): Delete this now unneeded function.
|
||||
|
||||
2015-05-03 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/browser.c (browser_refresh): Display an ellipsis only when the
|
||||
filename is longer than the available space, not when it still fits.
|
||||
* src/browser.c, src/nano.c: Adjust a few comments and line wrappings.
|
||||
* doc/syntax/groff.nanorc: Use character classes correctly.
|
||||
|
||||
2015-04-28 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/color.c (color_update): Match the file regex of a syntax against
|
||||
the absolute, canonical path instead of against the path the user gave.
|
||||
This fixes Savannah bug #44288, reported by Mike Frysinger.
|
||||
* doc/syntax/po.nanorc: Improve the colouring of message tags.
|
||||
* src/winio.c (get_escape_seq_kbinput): Unwrap a bunch of comments.
|
||||
|
||||
2015-04-25 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/search.c (do_replace_loop): Remove the unintended special
|
||||
case for replacing multiple occurrences of a literal ^ or $; see
|
||||
https://lists.gnu.org/archive/html/nano-devel/2015-04/msg00065.html.
|
||||
* src/search.c (findnextstr): Delete an always-FALSE parameter.
|
||||
* src/search.c (findnextstr): Rename the parameter 'whole_word'
|
||||
to 'whole_word_only', for clarity.
|
||||
|
||||
2015-04-21 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/browser.c (findnextfile): Save the settings of the global
|
||||
case-sens, direction, and regexp flags, and restore them on exit.
|
||||
And do this not in do_filesearch() but in findnextfile(), so that
|
||||
it will also work for do_fileresearch().
|
||||
* src/text.c (do_int_spell_fix): Save and restore the global flags
|
||||
in the same short and quick way as above.
|
||||
* src/nano.c (main): Initialize the search and replace strings in
|
||||
a central place, to get rid of a bunch of ifs.
|
||||
* src/search.c (search_init_globals): Elide this tiny function.
|
||||
|
||||
2015-04-20 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/winio.c (need_horizontal_update, need_vertical_update): Fuse
|
||||
two identical functions into one: need_screen_update().
|
||||
* src/prompt.c (need_statusbar_horizontal_update): Rename function
|
||||
to need_statusbar_update() as there is no vertical counterpart.
|
||||
* src/search.c (do_search, do_research): Delete redundant reprises
|
||||
of a regex search: finding an occurrence only at the very starting
|
||||
point of the search necessarily means it is the only occurrence.
|
||||
|
||||
2015-04-18 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/global.c, src/nano.c, doc/man/nanorc.5, doc/texinfo/nano.texi:
|
||||
Make the descriptions of the multibuffer feature more accurate.
|
||||
* src/winio.c (display_string): Make sure an invalid starting byte
|
||||
of a multibyte sequence is properly terminated, so that it doesn't
|
||||
pick up lingering bytes of any previous content. This prevents the
|
||||
displaying of ghosts -- characters that aren't really there -- when a
|
||||
file contains valid ánd invalid UTF-8 sequences. For an example see:
|
||||
https://lists.gnu.org/archive/html/nano-devel/2015-04/msg00052.html.
|
||||
Also make two comments more accurate: an invalid multibyte sequence
|
||||
will never be categorized as a control character or anything else.
|
||||
|
||||
2015-04-18 Mark Oteiza <mvoteiza@udel.edu>
|
||||
* doc/syntax/{python,ruby,sh,tex}.nanorc: Add a linter definition.
|
||||
* doc/syntax/elisp.nanorc: New file; syntax highlighting for Elisp.
|
||||
* doc/syntax/guile.nanorc: New file; syntax highlighting for Guile.
|
||||
|
||||
2015-04-17 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/text.c (do_alt_speller, do_linter, do_formatter): Distinguish
|
||||
a failure to launch the linter from receiving zero parsable lines;
|
||||
add a new function to glue together the invocation-error string.
|
||||
* src/global.c (shortcut_init): In the Help Viewer and File Browswer,
|
||||
bind the unbound Home and End keys to goto_top and goto_bottom, to
|
||||
mimic the behaviour of these keys in file viewers and web browsers.
|
||||
Also show ^Y and ^V in the WhereisFile menu instead of M-\ and M-/,
|
||||
for similarity with the WhereIs menu.
|
||||
* src/global.c (shortcut_init): Arrange the movement keys in the File
|
||||
Browser in the order of ascending stride, as in the Help Viewer.
|
||||
|
||||
GNU nano 2.4.1 - 2015.04.14
|
||||
2015-04-13 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/search.c (do_replace_loop): Fix compilation with --enable-tiny.
|
||||
* README: Mention also the Savannah page for reporting bugs.
|
||||
|
||||
2015-04-12 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/browser.c (filesearch_init): Stop M-\ and M-/ in WhereisFile
|
||||
menu (reached via ^R ^T ^W) from doing also an unrequested search
|
||||
after having performed their function. Fixes Savannah bug #44790.
|
||||
* src/global.c (shortcut_init): Rebind ^Y and ^V in the WhereisFile
|
||||
menu from the pointless page_up() and page_down() to the effective
|
||||
first_file() and last_file(). Also unbind some other useless keys.
|
||||
* src/browser.c (filesearch_init): Remove an unused variable, and
|
||||
adjust the introductory comment for the recently tweaked logic.
|
||||
* src/rcfile.c (parse_linter, parse_formatter): Use mallocstrcpy()
|
||||
in a correct manner; don't let it free an unrelated string.
|
||||
|
||||
2015-04-11 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/search.c (do_replace_loop): Do not split off the marked region
|
||||
into a separate partition, but do the replacings in the current one,
|
||||
taking good care to stay within the boundaries of the region. This
|
||||
fixes an undo bug where the first part of a line would disappear if
|
||||
the region started in the middle of a line. Bug was reported here:
|
||||
https://lists.gnu.org/archive/html/nano-devel/2015-03/msg00077.html.
|
||||
Original idea and patch were by Mark Majeres.
|
||||
|
||||
2015-04-08 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/browser.c (browser_select_dirname, findnextfile): Rename
|
||||
'currselected' to 'looking_at', for more contrast with 'selected',
|
||||
and rename browser_select_filename() to browser_select_dirname().
|
||||
* src/text.c: Correct and adjust some comments.
|
||||
|
||||
2015-04-07 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/browser.c (do_fileresearch): Don't search for the empty string
|
||||
when nothing was sought yet (when historylog is set).
|
||||
* src/browser.c (filesearch_init): Remove an unfitting comment
|
||||
(there are no toggles here) and tweak some others.
|
||||
* src/search.c (do_search, do_research): Use the same variable as
|
||||
in the surrounding code, for consistency.
|
||||
* src/browser.c (findnextfile_wrap_reset): Elide this function,
|
||||
and rename 'search_last_file' to 'came_full_circle'.
|
||||
* src/browser.c (filesearch_init, do_fileresearch): Avoid setting
|
||||
'focusing' when searching only for filenames.
|
||||
* src/browser.c (findnextfile, do_filesearch, do_fileresearch):
|
||||
Greatly simplify the searching for the next matching filename.
|
||||
* src/{browser,files,help,prompt,text,winio}.c: Let the function
|
||||
bottombars() set the global variable 'currmenu' -- the displayed
|
||||
menu must necessarily be the active one.
|
||||
* src/browser.c (filesearch_abort): Elide this tiny function.
|
||||
* THANKS: Add the names of recent translators, and sort the list.
|
||||
* THANKS: A neater layout, plus two table headers.
|
||||
|
||||
2015-04-05 Benno Schulenberg <bensberg@justemail.net>
|
||||
* doc/texinfo/nano.texi: Expand on nano's features, condense the
|
||||
synopsis, and "online" means something else to most people.
|
||||
|
||||
2015-04-03 Benno Schulenberg <bensberg@justemail.net>
|
||||
* README: Update text to the fifth milestone, 2.4.x, plus tweaks.
|
||||
* src/rcfile.c: Remove two superfluous (because nested) #ifndefs.
|
||||
* src/rcfile.c (parse_rcfile): Ignore any magic when libmagic was
|
||||
disabled, and ignore a formatter when spell checking was disabled.
|
||||
|
||||
2015-03-28 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/search.c (search_init_globals, search_replace_abort),
|
||||
src/winio.c (edit_redraw), src/proto.h, src/global.c: When finding
|
||||
an off-screen string, put it on the center line of the screen and
|
||||
not on the bottom or top line. This restores the old behaviour
|
||||
that was unintentionally changed in r5149 six days ago.
|
||||
* src/winio.c (edit_refresh): When pasting lines on the bottom line,
|
||||
only scroll the required number of lines and not half a screen --
|
||||
that is, when smooth scrolling is enabled.
|
||||
* doc/syntax/changelog.nanorc: Also colour a series of changed files
|
||||
that spans more than one line.
|
||||
|
||||
2015-03-27 Mark Majeres <mark@engine12.com>
|
||||
* src/text.c (do_alt_speller): Adjust the end point of the marked
|
||||
region for any change in length of the region's last line.
|
||||
|
||||
2015-03-27 Benno Schulenberg <bensberg@justemail.net>
|
||||
* doc/syntax/patch.nanorc: Recognize also Debian package diffs.
|
||||
Fixes https://bugs.launchpad.net/ubuntu/+source/nano/+bug/1300565
|
||||
requested by Rolf Leggewie.
|
||||
* src/search.c (do_replace_loop): Adjust some whitespace and wrapping.
|
||||
* src/search.c (do_replace_loop): Place a call to edit_refresh better,
|
||||
and remove two unneeded ones. This greatly speeds up nano when doing
|
||||
a Replace All with *lots* of occurrences.
|
||||
* src/{color,global,nano,text,utils}.c: Normalize some whitespace.
|
||||
* src/global.c (strtosc): The linter is only available when colour is.
|
||||
* src/global.c, src/text.c: Treat the formatter like a speller, to fix
|
||||
compilation with --disable-speller. Fixes Savannah bug #44607.
|
||||
|
||||
2015-03-25 Benno Schulenberg <bensberg@justemail.net>
|
||||
* doc/syntax/debian.nanorc: Slightly widen and relax the header regex.
|
||||
* doc/syntax/python.nanorc: Hashes inside triple-quoted strings should
|
||||
not cause comment colouring. (Inside single-qouted strings neither,
|
||||
but then quotes in comments will be coloured like strings.) This
|
||||
solves https://bugs.launchpad.net/ubuntu/+source/nano/+bug/481363.
|
||||
* src/global.c (strtomenu): Remove mistaken menu name -- as the
|
||||
formatter allows no interaction it needs no associated menu.
|
||||
* src/text.c (do_formatter): Remove unneeded statement -- nothing
|
||||
has changed the value of 'currmenu'.
|
||||
* src/global.c (strtosc), doc/man/nanorc.5: Allow rebinding the
|
||||
linter when nano was configured with --disable-speller.
|
||||
|
||||
2015-03-23 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/text.c (do_alt_speller): Avoid the spell checker reporting
|
||||
an error when the marked region is zero bytes long. The message
|
||||
is not needed -- it gets printed by the caller. This generalizes
|
||||
the fix for Savannah bug #29393.
|
||||
* src/text.c (do_alt_speller): Do not unset the mark before the
|
||||
possible bailout because of a zero-sized region.
|
||||
* NEWS: Option --noread allows writing, not reading, to named pipes.
|
||||
|
||||
2015-03-22 Chris Allegretta <chrisa@asty.org>
|
||||
* src/text.c (do_alt_speller): timestamp can just be a time_t.
|
||||
Fixes compilation on win32 and macOS.
|
||||
|
||||
GNU nano 2.4.0 - 2015.03.22
|
||||
2015-03-22 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/chars.c (move_mbleft): Start looking for a multibyte char
|
||||
not at the start of the string, but only as far back as such a
|
||||
char can possibly be. Change suggested by Mark Majeres.
|
||||
* src/search.c (findnextstr): Step backward or forward not simply
|
||||
one byte but one character (possibly multibyte). Fixes Savannah
|
||||
bug #42175, reported by myself, and the finding of ghosts seen in
|
||||
https://lists.gnu.org/archive/html/nano-devel/2015-03/msg00055.html.
|
||||
* src/winio.c (edit_redraw): Do not center the current line when
|
||||
smooth scrolling is used. This fixes Savannah bug #42654.
|
||||
|
||||
2015-03-21 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/text.c (do_alt_speller): Remove some leftovers.
|
||||
* src/search.c: Place some comments better and unwrap some lines.
|
||||
|
||||
2015-03-21 Mark Majeres <mark@engine12.com>
|
||||
* src/text.c (do_alt_speller): Restore the positions of the mark
|
||||
and the cursor in a better way: to the columns where they were.
|
||||
This fixes Savannah bug #44542, reported by Benno Schulenberg.
|
||||
|
||||
2015-03-20 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/nano.c (finish_stdin_pager, cancel_stdin_pager, stdin_pager):
|
||||
Normalize the whitespace, remove an old comment, and place another
|
||||
one better.
|
||||
* src/text.c (do_undo): Make a message equal to another one. It
|
||||
was mistakenly changed in r4950. (This is translation-neutral.)
|
||||
* src/global.c (shortcut_init): Keep related items together in the
|
||||
^G help screen.
|
||||
|
||||
2015-03-17 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/text.c (do_alt_speller): Do not set the modified flag when
|
||||
an external spell checker didn't make any changes. This fixes
|
||||
Savannah bug #44320, reported by Cody A. Taylor.
|
||||
|
||||
2015-03-14 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/text.c (do_formatter): Fix a message plus a few comments.
|
||||
|
||||
2015-03-14 Mark Majeres <mark@engine12.com>
|
||||
* src/nano.c (renumber): Get out if there is nothing to renumber,
|
||||
to prevent do_undo() from falling over trying to renumber emptiness.
|
||||
This fixes Savannah bug #44488, reported by Dennis Decker Jensen.
|
||||
|
||||
2015-03-08 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/proto.h, src/nano.c: Fix compilation with --enable-tiny plus
|
||||
--enable-nanorc.
|
||||
* src/rcfile.c (parse_binding): Fix the rebinding of toggles.
|
||||
* doc/man/{nano.1,rnano.1,nanorc.5}, doc/texinfo/nano.texi: Update
|
||||
years and version numbers in the docs in anticipation of a release.
|
||||
* src/nano.c (version): Drop compile time from version information
|
||||
to enable a reproducible build. Proposed by Jérémy Bobbio and Jordi
|
||||
Mallach (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=774388).
|
||||
|
||||
2015-03-07 Benno Schulenberg <bensberg@justemail.net>
|
||||
* doc/man/nanorc.5, doc/texinfo/nano.texi: Add a note about the
|
||||
inherent imperfection of using regular expressions for syntax
|
||||
highlighting, as suggested by Mike Frysinger in bug #30962.
|
||||
* doc/man/nanorc.5: Improve the indentation of some lists.
|
||||
* doc/man/nanorc.5, doc/texinfo/nano.texi: Remove the mistaken
|
||||
square brackets around the arguments of "header" and "magic" --
|
||||
those arguments are not optional. Also add "formatter" to the
|
||||
texinfo document, and slightly improve its punctuation.
|
||||
|
||||
GNU nano 2.3.99pre3 - 2015.02.27
|
||||
2015-02-25 Chris Allegretta <chrisa@asty.org>
|
||||
* src/rcfile.c (parse_binding): Add an exception for do_toggle() as
|
||||
rebinding toggles broke with r5022. (Fixed in r5134.)
|
||||
|
||||
2015-02-21 Benno Schulenberg <bensberg@justemail.net>
|
||||
* README: Fix the explanation of how to subscribe to a mailing list.
|
||||
* doc/syntax/{java,lua,python,ruby}.nanorc: Wrap some overlong lines.
|
||||
|
||||
2015-02-18 Mike Frysinger <vapier@gentoo.org>
|
||||
* doc/syntax/sh.nanorc: Recognize also dash, openrc and runscript.
|
||||
|
||||
2015-02-16 Mike Frysinger <vapier@gentoo.org>
|
||||
* .gitignore: Ignore the autotools 'compile' file.
|
||||
|
||||
2015-02-15 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/file.c (do_lockfile): Also show the name of the affected file
|
||||
when finding a lock file, for when many files are opened at once.
|
||||
* src/file.c (do_lockfile): The user does the editing, not the editor.
|
||||
|
||||
2015-02-09 Chris Allegretta <chrisa@asty.org>
|
||||
* nano.spec.in: Add dependency on texinfo, docdir files for
|
||||
RPM file creation.
|
||||
|
||||
GNU nano 2.3.99pre2 - 2015.02.06
|
||||
2015-02-03 Alex Henrie <alexhenrie24@gmail.com>
|
||||
* src/cut.c (do_cut_text): Make sure to set modified even when
|
||||
using --enable-tiny.
|
||||
|
||||
2015-02-01 Kamil Dudka <kdudka@redhat.com>
|
||||
* src/files.c (write_lockfile): Avoid writing uninitialized bytes to
|
||||
the lock file -- a simple null_at() would not initialize the buffer.
|
||||
* src/files.c (do_lockfile): Make sure that 'lockprog' and 'lockuser'
|
||||
are terminated -- strncpy() does not guarantee that on its own.
|
||||
* src/files.c (do_lockfile): Avoid printing a wrong PID on the status
|
||||
bar due to treating serialized PID bytes as signed integers. This
|
||||
addresses https://bugzilla.redhat.com/1186384 reported by Don Swaner.
|
||||
* src/files.c (write_lockfile): Do not trim the nano version number
|
||||
-- snprintf() counts the trailing zero into the size limit.
|
||||
|
||||
2015-02-01 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/winio.c (do_credits): Add a general entry for all translators.
|
||||
* src/nano.c (version), src/winio.c (do_credits): Update the copyright
|
||||
years to include 2015.
|
||||
|
||||
2015-01-13 Chris Allegretta <chrisa@asty.org>
|
||||
* src/files.c (open_buffer): Check here for locking and properly
|
||||
handle choosing to not open a file when locked instead of in
|
||||
open_file(). Fixes Savannah bug #42373 reported by Benno Schulenberg.
|
||||
|
||||
GNU nano 2.3.99pre1 - 2015.01.06
|
||||
2015-01-03 Chris Allegretta <chrisa@asty.org>
|
||||
* New formatter code to support syntaxes like
|
||||
|
||||
55
NEWS
55
NEWS
@@ -1,9 +1,56 @@
|
||||
2015.07.05 - GNU nano 2.4.1 "Portorož" is released. This release
|
||||
includes several fixes, including the ability to resize
|
||||
when in modes other than the main editing window,
|
||||
proper displaying of invalid UTF-8 bytes, new syntax
|
||||
definitions for Elisp, Guile, and PostgreSQL, and
|
||||
better display of shortcuts in the help menu and file
|
||||
browser. Thanks for your patience and using nano!
|
||||
|
||||
2015.04.14 - GNU nano 2.4.1 "Glitch Gremlin" is released. This release
|
||||
includes several fixes for issues with the file browser
|
||||
menu, linter and formatter functions, spell checker,
|
||||
undo/redo with some specific marked-cutting situations,
|
||||
and some small improvements to the color syntax
|
||||
highlighting definitions. There are also various
|
||||
documentation and code comment updates included, and
|
||||
finally, fixes for compilation on non-GNU/Linux systems
|
||||
and certain configure combinations. Toasters!
|
||||
|
||||
2015.03.22 - GNU nano 2.4.0 "lizf" is released. This is the first
|
||||
stable release in many years, and brings together many
|
||||
new features from the 2.3 series, including:
|
||||
a fully functional undo system (now enabled by default),
|
||||
vim-compatible file locking, linter support, formatter
|
||||
support, syntax highlighting flexibility, and many fixes
|
||||
for issues reported since 2.2. Many sincere thanks
|
||||
to all of the bug reports, patches, well wishes and
|
||||
contributions from everyone who has continued to
|
||||
support us. Thank you for using nano!
|
||||
|
||||
|
||||
2015.02.27 - GNU nano 2.3.99pre3 "Ashley" is released. This is likely
|
||||
to be the last release before the next major (2.4.0)
|
||||
release. Please test it out and send us any feedback
|
||||
via the Savannah bug page for nano
|
||||
(https://savannah.gnu.org/bugs/?group=nano). This
|
||||
release includes fixes for rebinding toggles via
|
||||
nanorc, several memory alignment fixes, and documentation
|
||||
and build updates. As always thank you for using
|
||||
nano - Share and Enjoy!
|
||||
|
||||
2015.02.06 - GNU nano 2.3.99pre2 "Snowblind" is released. This release
|
||||
contains only fixes, including: a long-standing problem
|
||||
with cutting in nano-tiny, several memory alignment
|
||||
improvements, and issues with leftover file locks. Please
|
||||
keep reporting bugs so we can get a happy and healthy
|
||||
2.4.0 soon. Thanks for using nano!
|
||||
|
||||
2015.01.06 - GNU nano 2.3.99pre1 "Junior" is released. As the first
|
||||
2.4 release candidate there will be fewer new features
|
||||
but many bugfixes going forward. This release contains
|
||||
new support for language reformatters like go's gofmt
|
||||
new support for language reformatters like Go's gofmt
|
||||
command which takes the place of the spelling checker.
|
||||
Fixes in this release include many syntax highlighting
|
||||
Fixes in this release include many syntax highlighting
|
||||
fixes and improvements, and documentation formatting updates.
|
||||
As always please report bugs via the Savannah bug page for
|
||||
nano (https://savannah.gnu.org/bugs/?group=nano), so we can
|
||||
@@ -41,7 +88,7 @@
|
||||
substantial improvements to the undo/redo code, UTF-8
|
||||
handling, the configure script, and display of shortcuts
|
||||
on very wide terminals, New features include the
|
||||
ability to read named pipes (--noread), as well as
|
||||
ability to write to named pipes (--noread), as well as
|
||||
linter support (see the nanorc man page for details). Also
|
||||
included are much improved syntax highlighting code, and
|
||||
configurations for JSON, texinfo, Go, and a default syntax
|
||||
@@ -337,7 +384,7 @@
|
||||
2008.03.18 - GNU nano 2.1.0 "under old mismanagement" is released.
|
||||
This first release in the 2.1 development series
|
||||
introduces rebinadble keys for most actions inside
|
||||
the editor. Please see the nanorc(5) page for
|
||||
the editor. Please see the nanorc(5) page for
|
||||
more information on configuring key bindings. Please
|
||||
also report all keybinding bugs (crashes, missing
|
||||
menu functions) using the Savannah bug tracker URL,
|
||||
|
||||
63
README
63
README
@@ -6,24 +6,24 @@ Overview
|
||||
The nano project was started because of a few "problems" with the
|
||||
wonderfully easy-to-use and friendly Pico text editor.
|
||||
|
||||
First and foremost is its license: the Pine suite does not use the
|
||||
GPL or a GPL-friendly license, and has unclear restrictions on
|
||||
First and foremost was its license: the Pine suite does not use
|
||||
the GPL or a GPL-friendly license, and has unclear restrictions on
|
||||
redistribution. Because of this, Pine and Pico are not included
|
||||
with many GNU/Linux distributions. Also, other features (like go
|
||||
to line number or search and replace) were unavailable until
|
||||
recently or require a command line flag. Yuck.
|
||||
with many GNU/Linux distributions. Also, other features (like
|
||||
go-to-line-number or search-and-replace) were unavailable until
|
||||
recently or require a command-line flag. Yuck.
|
||||
|
||||
nano aims to solve these problems by emulating the functionality of
|
||||
Pico as closely as possible while addressing the problems above and
|
||||
perhaps providing other extra functionality.
|
||||
providing other extra functionality.
|
||||
|
||||
The nano editor is now an official GNU package. For more
|
||||
information on GNU and the Free Software Foundation, please see
|
||||
http://www.gnu.org/.
|
||||
The nano editor is an official GNU package. For more information on
|
||||
GNU and the Free Software Foundation, please see http://www.gnu.org/.
|
||||
|
||||
How to compile and install nano
|
||||
|
||||
Download the nano source code, then:
|
||||
|
||||
tar zxvf nano-x.y.z.tar.gz
|
||||
cd nano-x.y.z
|
||||
./configure
|
||||
@@ -32,41 +32,42 @@ How to compile and install nano
|
||||
|
||||
It's that simple. Use --prefix with configure to override the
|
||||
default installation directory of /usr/local.
|
||||
|
||||
If you configured with the "--enable-nanorc" option, after
|
||||
installation you might copy the doc/nanorc.sample to your home
|
||||
directory, rename it to ".nanorc", and then edit it according to
|
||||
your taste.
|
||||
|
||||
If you haven't configured with the "--disable-nanorc" option, after
|
||||
installation you may want to copy the doc/nanorc.sample to your
|
||||
home directory, rename it to ".nanorc", and then edit it according
|
||||
to your taste.
|
||||
|
||||
Web Page
|
||||
|
||||
http://www.nano-editor.org/
|
||||
|
||||
Mailing List and Bug Reports
|
||||
Mailing Lists and Bug Reports
|
||||
|
||||
Savannah hosts all the nano-related mailing-lists.
|
||||
|
||||
+ info-nano@gnu.org is a very low traffic list
|
||||
used to announce new nano versions or other important
|
||||
information about the project.
|
||||
+ info-nano@gnu.org is a very low traffic list used to announce
|
||||
new nano versions or other important information about the
|
||||
project.
|
||||
+ help-nano@gnu.org is for those seeking to get help without
|
||||
wanting to hear about the technical details of its
|
||||
development.
|
||||
+ nano-devel@gnu.org is the list used by the people
|
||||
that make nano and a general development discussion list, with
|
||||
moderate traffic.
|
||||
wanting to hear about the technical details of its development.
|
||||
+ nano-devel@gnu.org is the list used by the people that make
|
||||
nano and a general development discussion list, with moderate
|
||||
traffic.
|
||||
|
||||
To subscribe, send email to nano-<name>-request@gnu.org with a
|
||||
To subscribe, send email to <name>-request@gnu.org with a
|
||||
subject of "subscribe", where <name> is the list you want to
|
||||
subscribe to.
|
||||
|
||||
For general bug reports, send a description of the problem to
|
||||
nano@nano-editor.org or directly to the development list.
|
||||
For general bug reports, please file a description of the problem
|
||||
on the Savannah bug tracker page for nano
|
||||
(https://savannah.gnu.org/bugs/?group=nano). The issue may have
|
||||
already been reported, and we are better able to track the state
|
||||
of the issue and whom to notify when fixed, the more the bug
|
||||
tracker is used.
|
||||
|
||||
Current Status
|
||||
|
||||
GNU nano has reached its fourth stable milestone, 2.2.x.
|
||||
Development of new features continues in the 2.3.x branch, while
|
||||
2.2.x versions are dedicated to bug-fixing and polishing.
|
||||
|
||||
$Id$
|
||||
GNU nano has reached its fifth stable milestone, 2.4.x.
|
||||
Development of new features will continue in the 2.5.x branch,
|
||||
while 2.4.x versions are dedicated to bug-fixing and polishing.
|
||||
|
||||
142
THANKS
142
THANKS
@@ -2,82 +2,87 @@ The following people have helped GNU nano in some way or another.
|
||||
If we missed you here, let us know!
|
||||
|
||||
|
||||
Sharuzzaman Ahmat Raslan <sharuzzaman@excite.com>
|
||||
Malay translator
|
||||
Laurentiu Buzdugan <buzdugan@voyager.net> Romanian translator
|
||||
CHAO Wei-Lun <chaoweilun@pcmail.com.tw> Chinese (traditional) translator
|
||||
Ricardo Cárdenes Medina <ricardo@conisys.com> Spanish translator
|
||||
Marco Colombo <magicdice@inwind.it> Italian translator
|
||||
Yavor Doganov <yavor@doganov.org> Bulgarian translator
|
||||
Karl Eichwalder <keichwa@gmx.net> German translator
|
||||
Doruk Fisek <dfisek@fisek.com.tr> Turkish translator
|
||||
Jean-Philippe Guérard <jean-philippe.guerard@laposte.net>
|
||||
French translator
|
||||
Geir Helland <pjallabais@users.sourceforge.net> Norwegian Bokmål translator
|
||||
Tedi Heriyanto <tedi_h@gmx.net> Indonesian translator
|
||||
Václav Haisman <V.Haisman@sh.cvut.cz> Czech translator
|
||||
Szabolcs Horvath <horvaths@janus.gimsz.sulinet.hu>
|
||||
Hungarian translator
|
||||
Kalle Kivimaa <kalle.kivimaa@iki.fi> Finnish translator
|
||||
Eivind Kjørstad <ekj@vestdata.no> Norwegian Nynorsk translator
|
||||
Florian König <floki@bigfoot.com> German translator
|
||||
Wojciech Kotwica <wkotwica@post.pl> Polish translator
|
||||
Clement Laforet <clem_laf@wanadoo.fr> French translator
|
||||
Daniele Medri <madrid@linux.it> Italian translator
|
||||
Gergely Nagy <algernon@debian.org> Hungarian translator
|
||||
Kalle Olavi Niemitalo <kon@iki.fi> Finnish translator
|
||||
A. Murat EREN <meren@comu.edu.tr> Turkish translator
|
||||
Claudio Neves <cneves@nextis.com> Brazilian Portuguese translator
|
||||
Daniel Nylander <po@danielnylander.se> Swedish translator
|
||||
Michael Piefel <piefel@informatik.hu-berlin.de> German translator
|
||||
Sergey A. Ribalchenko <fisher@obu.ck.ua> Ukrainian and Russian translator
|
||||
Michel Robitaille <robitail@IRO.UMontreal.CA> French translator
|
||||
Christian Rose <menthos@menthos.com> Swedish translator
|
||||
Stig E Sandø <stig@ii.uib.no> Norwegian Bokmål translator
|
||||
Benno Schulenberg <benno@vertaalt.nl> Dutch and Esperanto translator
|
||||
Danilo Segan <dsegan@gmx.net> Serbian translator
|
||||
Keld Simonsen <keld@dkuug.dk> Danish translator
|
||||
Guus Sliepen <guus@nl.linux.org> Dutch translator
|
||||
Cezary Sliwa <sliwa@cft.edu.pl> Polish translator
|
||||
Pierre Tane <tanep@bigfoot.com> French translator
|
||||
Jacobo Tarrío <jtarrio@trasno.net> Galician translator
|
||||
Kjetil Torgrim Homme <kjetilho@linpro.no> Norwegian Nynorsk translator
|
||||
Miquel Vidal <miquel@sindominio.net> Catalan translator
|
||||
Phan Vinh Thinh <teppi82@gmail.com> Vietnamese translator
|
||||
Pauli Virtanen <pauli.virtanen@saunalahti.fi> Finnish translator
|
||||
Peio Ziarsolo <peio@sindominio.net> Basque translator
|
||||
Anton Zinoviev <zinoviev@debian.org> Bulgarian translator
|
||||
João Victor Duarte Martins <jvdm@sdf.lonestar.org>
|
||||
Brazilian Portuguese translator
|
||||
Kevin Patrick Scannell <kscanne@gmail.com> Irish translator
|
||||
Gabor Kelemen <kelemeng@gnome.hu> Hungarian translator
|
||||
Francisco Javier Tsao Santín <tsao@members.fsf.org>
|
||||
Galician translator
|
||||
Dimitriy Ryazantcev <DJm00n@mail.ru> Russian translator
|
||||
Clytie Siddall <clytie@riverland.net.au> Vietnamese translator
|
||||
LI Daobing <lidaobing@gmail.com> Chinese (simplified) translator
|
||||
Jorma Karvonen <karvonen.jorma@gmail.com> Finnish translator
|
||||
Aron Xu <happyaron.xu@gmail.com> Chinese (simplified) translator
|
||||
Pavel Fric <pavelfric@seznam.cz> Czech translator
|
||||
Pavel Maryanov <acid@jack.kiev.ua> Russian translator
|
||||
Sergey Poznyakoff <gray@gnu.org> Polish translator
|
||||
Ask Hjorth Larsen <asklarsen@gmail.com> Danish translator
|
||||
Trần Ngọc Quân <vnwildman@gmail.com> Vietnamese translator
|
||||
Klemen Košir <klemen913@gmail.com> Slovenian translator
|
||||
Yasuaki Taniguchi <yasuakit@gmail.com> Japanese translator
|
||||
Jorge González <aloriel@gmail.com> Spanish translator
|
||||
Johnny A. Solbu <johnny@solbu.net> Norwegian Bokmål translator
|
||||
Мирослав Николић <miroslavnikolic@rocketmail.com>
|
||||
Serbian translator
|
||||
Translations:
|
||||
============
|
||||
Sharuzzaman Ahmat Raslan <sharuzzaman@excite.com> Malay
|
||||
Josef Andersson <josef.andersson@fripost.org> Swedish
|
||||
Laurentiu Buzdugan <buzdugan@voyager.net> Romanian
|
||||
Mario Blättermann <mario.blaettermann@gmail.com> German
|
||||
Wei-Lun CHAO <chaoweilun@pcmail.com.tw> Chinese (traditional)
|
||||
Ricardo Cárdenes Medina <ricardo@conisys.com> Spanish
|
||||
Yuri Chornoivan <yurchor@ukr.net> Ukrainian
|
||||
Mihai Cristescu <mihai.cristescu@archlinux.info> Romanian
|
||||
Marco Colombo <magicdice@inwind.it> Italian
|
||||
Yavor Doganov <yavor@doganov.org> Bulgarian
|
||||
Karl Eichwalder <keichwa@gmx.net> German
|
||||
A. Murat EREN <meren@comu.edu.tr> Turkish
|
||||
Rafael Ferreira <rafael.f.f1@gmail.com> Brazilian Portuguese
|
||||
Doruk Fisek <dfisek@fisek.com.tr> Turkish
|
||||
Pavel Fric <pavelfric@seznam.cz> Czech
|
||||
Jorge González <aloriel@gmail.com> Spanish
|
||||
Jean-Philippe Guérard <jean-philippe.guerard@laposte.net> French
|
||||
Geir Helland <pjallabais@users.sourceforge.net> Norwegian Bokmål
|
||||
Tedi Heriyanto <tedi_h@gmx.net> Indonesian
|
||||
Václav Haisman <V.Haisman@sh.cvut.cz> Czech
|
||||
Kjetil Torgrim Homme <kjetilho@linpro.no> Norwegian Nynorsk
|
||||
Szabolcs Horvath <horvaths@janus.gimsz.sulinet.hu> Hungarian
|
||||
Jorma Karvonen <karvonen.jorma@gmail.com> Finnish
|
||||
Gabor Kelemen <kelemeng@gnome.hu> Hungarian
|
||||
Kalle Kivimaa <kalle.kivimaa@iki.fi> Finnish
|
||||
Eivind Kjørstad <ekj@vestdata.no> Norwegian Nynorsk
|
||||
Florian König <floki@bigfoot.com> German
|
||||
Klemen Košir <klemen913@gmail.com> Slovenian
|
||||
Wojciech Kotwica <wkotwica@post.pl> Polish
|
||||
Ask Hjorth Larsen <asklarsen@gmail.com> Danish
|
||||
Clement Laforet <clem_laf@wanadoo.fr> French
|
||||
LI Daobing <lidaobing@gmail.com> Chinese (simplified)
|
||||
João Victor Duarte Martins <jvdm@sdf.lonestar.org> Brazilian Portuguese
|
||||
Pavel Maryanov <acid@jack.kiev.ua> Russian
|
||||
Daniele Medri <madrid@linux.it> Italian
|
||||
Gergely Nagy <algernon@debian.org> Hungarian
|
||||
Kalle Olavi Niemitalo <kon@iki.fi> Finnish
|
||||
Мирослав Николић <miroslavnikolic@rocketmail.com> Serbian
|
||||
Claudio Neves <cneves@nextis.com> Brazilian Portuguese
|
||||
Daniel Nylander <po@danielnylander.se> Swedish
|
||||
Mikel Olasagasti <hey_neken@mundurat.net> Basque
|
||||
Michael Piefel <piefel@informatik.hu-berlin.de> German
|
||||
Sergey Poznyakoff <gray@gnu.org> Polish
|
||||
Trần Ngọc Quân <vnwildman@gmail.com> Vietnamese
|
||||
Sergey A. Ribalchenko <fisher@obu.ck.ua> Ukrainian and Russian
|
||||
Michel Robitaille <robitail@IRO.UMontreal.CA> French
|
||||
Christian Rose <menthos@menthos.com> Swedish
|
||||
Dimitriy Ryazantcev <DJm00n@mail.ru> Russian
|
||||
Stig E Sandø <stig@ii.uib.no> Norwegian Bokmål
|
||||
Kevin Patrick Scannell <kscanne@gmail.com> Irish
|
||||
Benno Schulenberg <benno@vertaalt.nl> Dutch and Esperanto
|
||||
Danilo Segan <dsegan@gmx.net> Serbian
|
||||
Clytie Siddall <clytie@riverland.net.au> Vietnamese
|
||||
Keld Simonsen <keld@dkuug.dk> Danish
|
||||
Guus Sliepen <guus@nl.linux.org> Dutch
|
||||
Cezary Sliwa <sliwa@cft.edu.pl> Polish
|
||||
Johnny A. Solbu <johnny@solbu.net> Norwegian Bokmål
|
||||
Pierre Tane <tanep@bigfoot.com> French
|
||||
Yasuaki Taniguchi <yasuakit@gmail.com> Japanese
|
||||
Jacobo Tarrío <jtarrio@trasno.net> Galician
|
||||
Francisco Javier Tsao Santín <tsao@members.fsf.org> Galician
|
||||
Miquel Vidal <miquel@sindominio.net> Catalan
|
||||
Phan Vinh Thinh <teppi82@gmail.com> Vietnamese
|
||||
Pauli Virtanen <pauli.virtanen@saunalahti.fi> Finnish
|
||||
Aron Xu <happyaron.xu@gmail.com> Chinese (simplified)
|
||||
Peio Ziarsolo <peio@sindominio.net> Basque
|
||||
Anton Zinoviev <zinoviev@debian.org> Bulgarian
|
||||
|
||||
|
||||
Other stuff:
|
||||
===========
|
||||
Ben Armstrong <synrg@sanctuary.nslug.ns.ca> Negative -r value idea, code
|
||||
Thomas Dickey <dickey@herndon4.his.com> Curses help and advice
|
||||
Sven Guckes <guckes@math.fu-berlin.de> Advice and Advocacy
|
||||
Sven Guckes <guckes@math.fu-berlin.de> Advice and advocacy
|
||||
Thijs Kinkhorst <thijs@kinkhorst.com> rnano.1 manpage
|
||||
Jim Knoble <jmknoble@pobox.com> Pico compat for browser
|
||||
Ryan Krebs <fluffy@highwire.stanford.edu> Many bug fixes and testing
|
||||
Roy Lanek <lanek@ranahminang.net> Advice and advocacy
|
||||
Mark Majeres <mark@engine12.com> Working undo/redo code
|
||||
Chuck Mead <csm@MoonGroup.com> Feedback and RPM stuff
|
||||
Mike Melanson <melanson@pcisys.net> Bugs
|
||||
Neil Parks <nparks@acsmail.com> Bug reports and fixes
|
||||
@@ -85,4 +90,5 @@ Jeremy Robichaud <robicj@yahoo.com> Beta tester
|
||||
Bill Soudan <wes0472@rit.edu> Regex code, etc
|
||||
Ken Tyler <kent@werple.net.au> Search fixes and more
|
||||
|
||||
|
||||
$Id$
|
||||
|
||||
20
TODO
20
TODO
@@ -17,30 +17,32 @@ For the future (no targeted version, catch-all)
|
||||
- Allow color syntaxes to apply to more than just color, so that we can
|
||||
e.g. specify a different alternate spell checker depending on which
|
||||
file type we have open.
|
||||
- Allow even better file type detection than we have currently, e.g.
|
||||
through libmagic?
|
||||
- Allow setting marks (saved positions, not to be confused with the mark
|
||||
set via Ctrl-^) at various lines and/or columns in the buffer, and
|
||||
allow movement between them with a single keystroke? (we're running
|
||||
out of keystrokes)
|
||||
allow movement between them with a single keystroke? (We're running
|
||||
out of keystrokes, though.)
|
||||
- Allow searching for and replacing newlines.
|
||||
- Fix handling of bad/incomplete UTF-8 sequences to display one Unicode
|
||||
FFFD (Replacement Character) per sequence instead of one per byte.
|
||||
|
||||
For version 2.4:
|
||||
For version 2.6:
|
||||
- New regression framework built on expect.
|
||||
- Allow text searches in the help browser.
|
||||
- Handle window resizes better. After we resize, we should stay
|
||||
wherever we were before we resized, as Pico does.
|
||||
- Allow text searches in the help viewer.
|
||||
- Add the ability to move to different lines of the screen with a single
|
||||
keystroke, e.g. M-` (M-~) to go to the top line, M-& (M-7) to go to
|
||||
the center line, and M-' (M-") to go to the last line.
|
||||
- Detect when we're pasting text, so that we can handle it differently
|
||||
(i.e. faster than currently with screen redraws)
|
||||
(i.e. faster than currently with screen redraws).
|
||||
- Allow piping marked text to an external command and replacing it with
|
||||
the command's output (as the internal spell checker already does with
|
||||
the "spell" command)?
|
||||
|
||||
For version 2.4:
|
||||
- Handle window resizes better. After we've resized, we should stay
|
||||
wherever we were before we resized, as Pico does. [DONE]
|
||||
- Allow even better file-type detection than we have currently, e.g.
|
||||
through libmagic. [DONE]
|
||||
|
||||
For version 2.2:
|
||||
- Rebindable keys? [DONE]
|
||||
- Undo/Redo keys (M-U and M-E)? [DONE]
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#
|
||||
# $Id$
|
||||
|
||||
AC_INIT([GNU nano], [2.3.99pre1], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [2.4.2], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AC_CANONICAL_HOST
|
||||
AM_INIT_AUTOMAKE
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANO 1 "version 2.3.7" "August 2014"
|
||||
.TH NANO 1 "version 2.4.2" "June 2015"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
|
||||
@@ -38,6 +38,27 @@ top of copying Pico's look and feel, \fBnano\fP also implements some
|
||||
missing (or disabled by default) features in Pico, such as "search and
|
||||
replace" and "go to line and column number".
|
||||
|
||||
.SH EDITING
|
||||
Entering text and moving around in a file is straightforward: typing the
|
||||
letters and using the normal cursor movement keys. Commands are entered
|
||||
by using the Control (^) and the Alt or Meta (M-) keys.
|
||||
Typing \fB^K\fR deletes the current line and puts it in the cutbuffer.
|
||||
Consecutive \fB^K\fRs will put all deleted lines together in the cutbuffer.
|
||||
Any cursor movement or executing any other command will cause the next
|
||||
\fB^K\fR to overwrite the cutbuffer. A \fB^U\fR will paste the current
|
||||
contents of the cutbuffer at the current cursor position.
|
||||
.PP
|
||||
When a more precise piece of text needs to be cut or copied, one can mark
|
||||
its start with \fB^6\fR, move the cursor to its end (the marked text will be
|
||||
highlighted), and then use \fB^K\fR to cut it, or \fBM-6\fR to copy it to the
|
||||
cutbuffer. One can also save the marked text to a file with \fB^O\fR, or
|
||||
spell check it with \fB^T\fR.
|
||||
.PP
|
||||
The two lines at the bottom of the screen show the most important commands;
|
||||
the built-in help (\fB^G\fR) lists all the available ones.
|
||||
The default key bindings can be changed via the .nanorc file -- see
|
||||
.BR nanorc (5).
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B +\fIline\fP,\fIcolumn\fP
|
||||
@@ -53,12 +74,13 @@ already at that position, it will jump to the true beginning of the
|
||||
line.
|
||||
.TP
|
||||
.BR \-B ", " \-\-backup
|
||||
When saving a file, back up the previous version of it to the current
|
||||
When saving a file, back up the previous version of it, using the current
|
||||
filename suffixed with a tilde (\fB~\fP).
|
||||
.TP
|
||||
.BR \-C\ \fIdirectory\fR ", " \-\-backupdir= \fIdirectory
|
||||
Set the directory where \fBnano\fP puts unique backup files, if file
|
||||
backups are enabled.
|
||||
Make and keep not just one backup file, but make and keep a uniquely
|
||||
numbered one every time a file is saved -- when backups are enabled.
|
||||
The uniquely numbered files are stored in the specified \fIdirectory\fR.
|
||||
.TP
|
||||
.BR \-D ", " \-\-boldtext
|
||||
Use bold text instead of reverse video text.
|
||||
|
||||
109
doc/man/nanorc.5
109
doc/man/nanorc.5
@@ -2,7 +2,7 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
|
||||
.\" 2013, 2014 Free Software Foundation, Inc.
|
||||
.\" 2013, 2014, 2015 Free Software Foundation, Inc.
|
||||
.\"
|
||||
.\" This document is dual-licensed. You may distribute and/or modify it
|
||||
.\" under the terms of either of the following licenses:
|
||||
@@ -20,7 +20,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANORC 5 "version 2.3.5" "June 2014"
|
||||
.TH NANORC 5 "version 2.4.2" "June 2015"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
.SH NAME
|
||||
@@ -64,11 +64,14 @@ NOT enable this option unless you are sure you need it.
|
||||
Use auto-indentation.
|
||||
.TP
|
||||
.B set backup
|
||||
Create backup files by adding a tilde (\fB~\fP) to each file's name.
|
||||
When saving a file, create a backup file by adding a tilde (\fB~\fP) to
|
||||
the file's name.
|
||||
.TP
|
||||
.B set backupdir "\fIdirectory\fP"
|
||||
Set the directory where \fBnano\fP puts unique backup files, if file
|
||||
backups are enabled.
|
||||
Make and keep not just one backup file, but make and keep a uniquely
|
||||
numbered one every time a file is saved --- when backups are enabled
|
||||
with \fBset backup\fR or \fB\-\-backup\fR or \fB\-B\fR.
|
||||
The uniquely numbered files are stored in the specified \fIdirectory\fR.
|
||||
.TP
|
||||
.B set backwards
|
||||
Do backwards searches by default.
|
||||
@@ -132,7 +135,7 @@ System, and on the console when gpm is running. Text can still be
|
||||
selected through dragging by holding down the Shift key.
|
||||
.TP
|
||||
.B set multibuffer
|
||||
Allow inserting files into their own buffers.
|
||||
When reading in a file with ^R, insert it into a new buffer by default.
|
||||
.TP
|
||||
.B set noconvert
|
||||
Don't convert files from DOS/Mac format.
|
||||
@@ -250,38 +253,44 @@ characters as parts of words.
|
||||
|
||||
.SH SYNTAX HIGHLIGHTING
|
||||
Coloring the different syntactic elements of a file
|
||||
can be defined via the following commands:
|
||||
is done via regular expressions (see the \fBcolor\fR command below).
|
||||
This is inherently imperfect, because regular expressions are not
|
||||
powerful enough to fully parse a file. Nevertheless, regular
|
||||
expressions can do a lot and are easy to make, so they are a
|
||||
good fit for a small editor like \fBnano\fR.
|
||||
.sp
|
||||
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 \-Y / \-\-syntax
|
||||
command-line option, or will be automatically activated if
|
||||
the current filename matches the extended regular expression
|
||||
\fIfileregex\fP. All following \fBcolor\fP and \fBicolor\fP statements
|
||||
will apply to this \fIstr\fP syntax until a new syntax is defined.
|
||||
\fIfileregex\fP. All subsequent \fBcolor\fR, \fBicolor\fR,
|
||||
\fBheader\fR and other such statements will apply to this
|
||||
\fIstr\fP syntax until a new \fBsyntax\fR command is encountered.
|
||||
|
||||
The \fBnone\fP syntax is reserved; specifying it on the command line is
|
||||
the same as not having a syntax at all. The \fBdefault\fP syntax is
|
||||
special: it takes no \fIfileregex\fP, and applies to files that don't
|
||||
match any other syntax's \fIfileregex\fP.
|
||||
match any syntax's \fIfileregex\fP.
|
||||
.TP
|
||||
.BI linter " program " \fR[ "arg " \fR...]
|
||||
For the currently defined syntax, use the given \fIprogram\fR
|
||||
to invoke the linter (this overrides the speller function when
|
||||
defined).
|
||||
Use the given \fIprogram\fR to run a syntax check on the current file
|
||||
(this overrides the speller function when defined).
|
||||
.TP
|
||||
.BI formatter " program " \fR[ "arg " \fR...]
|
||||
For the currently defined syntax, use the given \fIprogram\fR
|
||||
to automatically re-format text, useful in certain programming
|
||||
languages (e.g. go)
|
||||
Use the given \fIprogram\fR to automatically reformat text.
|
||||
Useful in certain programming languages (e.g. Go).
|
||||
.TP
|
||||
.BR header " [""\fIregex\fR"" ...]
|
||||
For the currently defined syntax, add one or more regexes which will
|
||||
.BR header " \fIregex\fR " ...
|
||||
Add one or more regexes which will
|
||||
be compared against the very first line of the file to be edited,
|
||||
to determine whether this syntax should be used for that file.
|
||||
.TP
|
||||
.BR magic " [""\fIregex\fR"" ...]
|
||||
For the currently defined syntax, add one or more regexes which
|
||||
.BR magic " \fIregex\fR " ...
|
||||
Add one or more regexes which
|
||||
will be compared against the result of querying the \fBmagic\fP
|
||||
database about the file to be edited, to determine whether this
|
||||
syntax should be used for that file. This
|
||||
@@ -289,7 +298,7 @@ functionality only works when \fBlibmagic\fP is installed on the
|
||||
system and will be silently ignored otherwise.
|
||||
.TP
|
||||
.B color \fIfgcolor\fR,\fIbgcolor\fR """\fIregex\fR""" ...
|
||||
For the currently defined syntax, display all expressions matching
|
||||
Display all pieces of text that match
|
||||
the extended regular expression \fIregex\fP with foreground color
|
||||
\fIfgcolor\fP and background color \fIbgcolor\fP, at least one of which
|
||||
must be specified. Valid colors for foreground and background
|
||||
@@ -300,32 +309,32 @@ foreground. If your terminal supports transparency, not specifying a
|
||||
background.
|
||||
.TP
|
||||
.B icolor \fIfgcolor\fR,\fIbgcolor\fR """\fIregex\fR""" ...
|
||||
Same as above, except that the expression matching is case insensitive.
|
||||
Same as above, except that the text matching is case insensitive.
|
||||
.TP
|
||||
.BR color " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIsr\fR"" " end= """\fIer\fR""
|
||||
Display expressions which start with the extended regular expression
|
||||
\fIsr\fP and end with the extended regular expression \fIer\fP with
|
||||
Display all pieces of text whose start matches extended regular expression
|
||||
\fIsr\fP and whose end matches extended regular expression \fIer\fP with
|
||||
foreground color \fIfgcolor\fP and background color \fIbgcolor\fP,
|
||||
at least one of which must be specified. This allows syntax
|
||||
highlighting to span multiple lines. Note that all subsequent instances
|
||||
of \fIsr\fP after an initial \fIsr\fP is found will be highlighted until
|
||||
the first instance of \fIer\fP.
|
||||
at least one of which must be specified. This means that, after an
|
||||
initial instance of \fIsr\fP, all text will be highlighted until the
|
||||
first instance of \fIer\fP. This allows syntax highlighting to span
|
||||
multiple lines.
|
||||
.TP
|
||||
.BR icolor " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIsr\fR"" " end= """\fIer\fR""
|
||||
Same as above, except that the expression matching is case insensitive.
|
||||
Same as above, except that the text matching is case insensitive.
|
||||
.TP
|
||||
.BR include " ""\fIsyntaxfile\fR"""
|
||||
Read in self-contained color syntaxes from \fIsyntaxfile\fP. Note that
|
||||
\fIsyntaxfile\fP can only contain the above commands, from \fBsyntax\fP
|
||||
\fIsyntaxfile\fP may contain only the above commands, from \fBsyntax\fP
|
||||
to \fBicolor\fP.
|
||||
.TP
|
||||
.BI extendsyntax " str directive " \fR[ "arg " \fR...]
|
||||
Extend the syntax previously defined as \fIstr\fP to include
|
||||
new information. This allows you to add a new \fIcolor\fP, \fIicolor\fP,
|
||||
\fImagic\fP, \fIheader\fP, or \fIlinter\fP directive to an already
|
||||
defined syntax -- useful when you want to add to definitions from the
|
||||
system-installed syntax definitions (which are normally not writable).
|
||||
|
||||
new information. This allows you to add a new \fBcolor\fP, \fBicolor\fP,
|
||||
\fBheader\fP, \fBmagic\fP, \fBlinter\fP, or \fBformatter\fP directive
|
||||
to an already defined syntax -- useful when you want to
|
||||
slightly improve a syntax defined in one of the system-installed
|
||||
files (which are normally not writable)
|
||||
.SH REBINDING KEYS
|
||||
Key bindings may be reassigned via the following commands:
|
||||
.TP
|
||||
@@ -340,7 +349,8 @@ menus where it exists by using \fBall\fP).
|
||||
|
||||
.TP
|
||||
The format of \fIkey\fP should be one of:
|
||||
.TP
|
||||
.RS 3
|
||||
.TP 3
|
||||
.B ^
|
||||
followed by an alpha character or the word "Space".
|
||||
Example: ^C
|
||||
@@ -352,10 +362,11 @@ Example: M-C
|
||||
.B F
|
||||
followed by a numeric value from 1 to 16.
|
||||
Example: F10
|
||||
.RE
|
||||
|
||||
.TP
|
||||
|
||||
Valid \fIfunction\fP names to be bound include:
|
||||
|
||||
.RS 3
|
||||
.TP 2
|
||||
.B help
|
||||
Invokes the help viewer.
|
||||
@@ -370,8 +381,8 @@ Exits from the program (or from the help viewer or the file browser).
|
||||
Writes the current buffer to disk.
|
||||
.TP
|
||||
.B insert
|
||||
Inserts a file into the current buffer (or into a new buffer when multibuffer
|
||||
is enabled).
|
||||
Inserts a file into the current buffer (at the current cursor position),
|
||||
or into a new buffer when option \fBmultibuffer\fR is set.
|
||||
.TP
|
||||
.B whereis
|
||||
Searches for text in the current buffer -- or for filenames matching
|
||||
@@ -409,6 +420,9 @@ Counts the number of words, lines and characters in the current buffer.
|
||||
Invokes a spell-checking program (or a linting program, if the current
|
||||
syntax highlighting defines one).
|
||||
.TP
|
||||
.B linter
|
||||
A synonym of \fBspeller\fR (for when the speller has not been configured).
|
||||
.TP
|
||||
.B justify
|
||||
Justifies the current paragraph.
|
||||
.TP
|
||||
@@ -480,10 +494,10 @@ Moves the cursor to the bracket (brace, parenthesis, etc.) that matches
|
||||
(pairs) with the one under the cursor.
|
||||
.TP
|
||||
.B prevbuf
|
||||
Switches to editing/viewing the previous buffer when using multibuffer mode.
|
||||
Switches to editing/viewing the previous buffer when multiple buffers are open.
|
||||
.TP
|
||||
.B nextbuf
|
||||
Switches to editing/viewing the next buffer when using multibuffer mode.
|
||||
Switches to editing/viewing the next buffer when multiple buffers are open.
|
||||
.TP
|
||||
.B verbatim
|
||||
Inserts the next character verbatim into the file.
|
||||
@@ -604,10 +618,11 @@ Toggles whether long lines will be hard-wrapped to the next line.
|
||||
Toggles whether typed tabs will be converted to spaces.
|
||||
.TP
|
||||
.B backupfile
|
||||
Toggles whether a backup will be made of the file to be edited.
|
||||
Toggles whether a backup will be made of the file being edited.
|
||||
.TP
|
||||
.B multibuffer
|
||||
Toggles the use of multiple file buffers (if support for them has been compiled in).
|
||||
Toggles whether a file is inserted into the current buffer
|
||||
or read into a new buffer.
|
||||
.TP
|
||||
.B mouse
|
||||
Toggles mouse support.
|
||||
@@ -617,10 +632,11 @@ Toggles automatic conversion of files from DOS/Mac format.
|
||||
.TP
|
||||
.B suspendenable
|
||||
Toggles whether the suspend sequence (normally ^Z) will suspend the editor window.
|
||||
.RE
|
||||
|
||||
.TP
|
||||
|
||||
Valid \fImenu\fP sections are:
|
||||
|
||||
.RS 3
|
||||
.TP 2
|
||||
.B main
|
||||
The main editor window where text is entered and edited.
|
||||
@@ -668,6 +684,7 @@ The 'go to directory' menu in the file browser.
|
||||
A special name that encompasses all menus.
|
||||
For \fBbind\fR it means all menus where the specified \fIfunction\fR exists;
|
||||
for \fBunbind\fR it means all menus where the specified \fIkey\fR exists.
|
||||
.RE
|
||||
|
||||
.SH FILES
|
||||
.TP
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH RNANO 1 "version 2.3.7" "August 2014"
|
||||
.TH RNANO 1 "version 2.4.0" "March 2015"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
.SH NAME
|
||||
|
||||
@@ -6,10 +6,12 @@ pkgdata_DATA = asm.nanorc \
|
||||
css.nanorc \
|
||||
debian.nanorc \
|
||||
default.nanorc \
|
||||
elisp.nanorc \
|
||||
fortran.nanorc \
|
||||
gentoo.nanorc \
|
||||
go.nanorc \
|
||||
groff.nanorc \
|
||||
guile.nanorc \
|
||||
html.nanorc \
|
||||
java.nanorc \
|
||||
javascript.nanorc \
|
||||
@@ -26,6 +28,7 @@ pkgdata_DATA = asm.nanorc \
|
||||
perl.nanorc \
|
||||
php.nanorc \
|
||||
po.nanorc \
|
||||
postgresql.nanorc \
|
||||
pov.nanorc \
|
||||
python.nanorc \
|
||||
ruby.nanorc \
|
||||
|
||||
@@ -9,17 +9,20 @@ color red "^(19|20)[0-9-]{8}"
|
||||
# Email addresses.
|
||||
color yellow "<[^>]*@[^>]*>"
|
||||
|
||||
# Changed files.
|
||||
color magenta "[[:space:]]\*[[:space:]].*:"
|
||||
|
||||
# Command-line options.
|
||||
color cyan "[[:space:]]-[a-zA-Z\$]" "--[8a-z-]+"
|
||||
# Bug numbers.
|
||||
color cyan "bug #[0-9]{5}"
|
||||
# Probable variables, for variety.
|
||||
# Bug and patch numbers.
|
||||
color cyan "bug #[0-9]{5,6}" "patch #[0-9]{4,5}"
|
||||
# Probable constants, for variety.
|
||||
color brightred "\<[A-Z_][0-9A-Z_]+\>"
|
||||
# Key sequences.
|
||||
color brightblue "\^[A-Z]" "\<M-." "\<F1?[0-9]" "(\^|M-)Space"
|
||||
|
||||
# Changed files.
|
||||
color magenta start="^( | {8})\* " end="(:( |$)|^$)"
|
||||
|
||||
# Release markers.
|
||||
color brightblue "^(GNU )?nano[- ][0-9]\.[0-9]\.[^ ]+"
|
||||
|
||||
# Trailing whitespace.
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
## Here is an example for apt's sources.list.
|
||||
|
||||
syntax "apt/sources.list" "sources\.list(\.old|~)?$" "apt/sources\.list\.d/.*\.list$"
|
||||
syntax "sources.list" "sources\.list(~|\.old|\.save)?$" "sources\.list\.d/.*\.list(~|\.old|\.save)?$"
|
||||
|
||||
# Coloring the deb lines, working from tail to head. First the
|
||||
# components -- well, everything, and thus also the components.
|
||||
color brightmagenta "^deb.*"
|
||||
# Distribution -- well, everything, except the components.
|
||||
color brightred "^deb(-src)? ((http(s)?|ftp|rsh|ssh|file|copy|tor|spacewalk):/[^ ]+|cdrom:\[[-a-zA-Z0-9\._\(\) ]+\]/) [^ ]+"
|
||||
color brightred "^deb(-src)?\s+.*((ftp|https?|rsh|ssh|copy|file|spacewalk|tor):/\S+|cdrom:\[.+\]/)\s+\S+"
|
||||
# URIs.
|
||||
color brightgreen "(http(s)?|ftp|rsh|ssh|file|copy|tor|spacewalk):/[^ ]+"
|
||||
color brightgreen "^deb(-src)?\s+.*(ftp|https?|rsh|ssh|copy|file|spacewalk|tor):/\S+"
|
||||
# CDroms.
|
||||
color brightgreen "cdrom:\[[-a-zA-Z0-9\._\(\) ]+\]/"
|
||||
color brightgreen "^deb(-src)?\s+.*cdrom:\[.+\]/"
|
||||
# Options.
|
||||
color brightcyan "^deb(-src)?\s+\[.+\]\s+"
|
||||
# And finally the initial deb tag.
|
||||
color yellow "^deb(-src)?"
|
||||
|
||||
# Comments.
|
||||
color brightblue "#.*"
|
||||
|
||||
|
||||
31
doc/syntax/elisp.nanorc
Normal file
31
doc/syntax/elisp.nanorc
Normal file
@@ -0,0 +1,31 @@
|
||||
## Here is an example for Emacs Lisp.
|
||||
|
||||
syntax "elisp" "\.el$"
|
||||
|
||||
# Basic functions/macros
|
||||
color brightcyan "\<(if|when|unless|cond|and|or|lambda|let|progn|while|dolist|dotimes)\>"
|
||||
color brightcyan "\<save-((window-)?excursion|restriction)\>"
|
||||
color brightcyan "\<eval-(and|when)-compile\>"
|
||||
# Defining functions
|
||||
color brightcyan "\<def(un|macro|subst|generic|alias)\>"
|
||||
color brightcyan "\<cl-def(un|macro|subst|generic|struct|type)\>"
|
||||
color brightcyan "\<define-(derived|minor|generic)-mode\>"
|
||||
# Defining variables
|
||||
color brightcyan "\<def(class|const|var(-local|alias)?)\>"
|
||||
# Customization functions
|
||||
color brightcyan "\<def(custom|face|group|theme)\>"
|
||||
# Setting values
|
||||
color brightcyan "\<(setq(-default|-local)?|setf|push|pop|declare(-function)?)\>"
|
||||
# Feature functions
|
||||
color brightcyan "\<(require|provide)\>"
|
||||
# Quoted symbols
|
||||
color brightyellow "#?'\<(\w|-)+\>"
|
||||
# Booleans
|
||||
color brightred "\<(t|nil)\>"
|
||||
# Keywords
|
||||
color blue ":(\w|[?-])+"
|
||||
# Strings
|
||||
color yellow start="^[[:blank:]]+\"" end="[^\]\""
|
||||
color yellow ""(\\.|[^"])*""
|
||||
# Comments
|
||||
color cyan "(^|[[:space:]]);.*$"
|
||||
@@ -3,7 +3,7 @@
|
||||
syntax "groff" "\.m[ems]$" "\.rof" "\.tmac$" "^tmac."
|
||||
|
||||
# The argument of .ds or .nr
|
||||
color cyan "^\.(ds|nr) [^[[:space:]]]*"
|
||||
color cyan "^\.(ds|nr) [^[:space:]]*"
|
||||
# Single-character escapes
|
||||
color brightmagenta "\\."
|
||||
# The argument of \f or \s in the same color
|
||||
@@ -12,7 +12,7 @@ color brightmagenta "\\f." "\\f\(.." "\\s(\+|\-)?[0-9]"
|
||||
color cyan "(\\|\\\\)n(.|\(..)"
|
||||
color cyan start="(\\|\\\\)n\[" end="]"
|
||||
# Requests
|
||||
color brightgreen "^\.[[:space:]]*[^[[:space:]]]*"
|
||||
color brightgreen "^\.[[:space:]]*[^[:space:]]*"
|
||||
# Comments
|
||||
color yellow "^\.\\".*$"
|
||||
# Strings
|
||||
|
||||
24
doc/syntax/guile.nanorc
Normal file
24
doc/syntax/guile.nanorc
Normal file
@@ -0,0 +1,24 @@
|
||||
## Here is an example for Guile Scheme.
|
||||
|
||||
syntax "guile" "\.scm$"
|
||||
header "^#!.*guile"
|
||||
magic "guile"
|
||||
|
||||
# Basic scheme functions
|
||||
color green "\<(do|if|lambda|let(rec)?|map|unless|when)\>"
|
||||
# Defining things
|
||||
color brightcyan "\<define(-macro|-module|-public|-syntax)?\>"
|
||||
# Quoted symbols
|
||||
color brightyellow "'\<(\w|-)+\>"
|
||||
# Chars
|
||||
color brightmagenta "#\\."
|
||||
color brightmagenta "#\\\w+\>"
|
||||
# Booleans
|
||||
color brightred "(#t|#f)\>"
|
||||
# Keywords
|
||||
color blue "#?:(\w|[?-])+"
|
||||
# Strings
|
||||
color yellow start="^[[:blank:]]+\"" end="[^\]\""
|
||||
color yellow ""(\\.|[^"])*""
|
||||
# Comments
|
||||
color cyan "(^|[[:space:]]);.*$"
|
||||
@@ -5,7 +5,8 @@ magic "Java "
|
||||
|
||||
color green "\<(boolean|byte|char|double|float|int|long|new|short|this|transient|void)\>"
|
||||
color red "\<(break|case|catch|continue|default|do|else|finally|for|if|return|switch|throw|try|while)\>"
|
||||
color cyan "\<(abstract|class|extends|final|implements|import|instanceof|interface|native|package|private|protected|public|static|strictfp|super|synchronized|throws|volatile)\>"
|
||||
color cyan "\<(abstract|class|extends|final|implements|import|instanceof|interface|native)\>"
|
||||
color cyan "\<(package|private|protected|public|static|strictfp|super|synchronized|throws|volatile)\>"
|
||||
color red ""[^"]*""
|
||||
color yellow "\<(true|false|null)\>"
|
||||
color blue "//.*"
|
||||
|
||||
@@ -15,18 +15,20 @@ color brightyellow ":|\*|/|%|\+|-|\^|>|>=|<|<=|~=|=|\.\.|\<(not|and|or)\>"
|
||||
color brightblue "\<(do|end|while|repeat|until|if|elseif|then|else|for|in|function|local|return|break)\>"
|
||||
|
||||
# Keywords
|
||||
color brightyellow "\<(debug|string|math|table|io|coroutine|os)\>\."
|
||||
color brightyellow "\<(io|math|os|string|table|coroutine|debug)\>\."
|
||||
color brightyellow "\<(_G|_VERSION|assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|module|next|pairs|pcall|print|rawequal|rawget|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\s*\("
|
||||
|
||||
# Standard library
|
||||
color brightyellow "io\.\<(close|flush|input|lines|open|output|popen|read|tmpfile|type|write|stdin|stdout|stderr)\>"
|
||||
color brightyellow "math\.\<(abs|acos|asin|atan2|atan|ceil|cosh|cos|deg|exp|floor|fmod|frexp|huge|ldexp|log10|log|max|min|mod|modf|pi|pow|rad|random|randomseed|sinh|tan)\>"
|
||||
color brightyellow "math\.\<(abs|acos|asin|atan2|atan|ceil|cosh|cos|deg|exp|floor|fmod|frexp|huge|ldexp|log10|log)\>"
|
||||
color brightyellow "math\.\<(max|min|mod|modf|pi|pow|rad|random|randomseed|sinh|tan)\>"
|
||||
color brightyellow "os\.\<(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)\>"
|
||||
color brightyellow "package\.\<(cpath|loaded|loadlib|path|preload|seeall)\>"
|
||||
color brightyellow "string\.\<(byte|char|dump|find|format|gmatch|gsub|len|lower|match|rep|reverse|sub|upper)\>"
|
||||
color brightyellow "table\.\<(concat|insert|maxn|remove|sort)\>"
|
||||
color brightyellow "coroutine\.\<(create|resume|running|status|wrap|yield)\>"
|
||||
color brightyellow "debug\.\<(debug|getfenv|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue|setfenv|sethook|setlocal|setmetatable|setupvalue|traceback)\>"
|
||||
color brightyellow "debug\.\<(debug|getfenv|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue)\>"
|
||||
color brightyellow "debug\.\<(setfenv|sethook|setlocal|setmetatable|setupvalue|traceback)\>"
|
||||
|
||||
# File handle methods
|
||||
color brightyellow "\:\<(close|flush|lines|read|seek|setvbuf|write)\>"
|
||||
|
||||
@@ -9,10 +9,10 @@ icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|lint
|
||||
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|const|cut|fill|historylog|locking|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|poslog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|suspend|tabsize|tabstospaces|tempfile|view|wordbounds)\>"
|
||||
icolor yellow "^[[:space:]]*set[[:space:]]+(functioncolor|keycolor|statuscolor|titlecolor)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
|
||||
icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|functioncolor|keycolor|matchbrackets|operatingdir|punct|quotestr|speller|statuscolor|titlecolor|whitespace)[[:space:]]+"
|
||||
icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^|M-)([[:alpha:]]|space|[]]|[0-9_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]+[[:alpha:]]+[[:space:]]*$"
|
||||
icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^|M-)([[:alpha:]]|space|[]]|[0-9_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]*$"
|
||||
icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^|M-)([[:alpha:]]|space|[]]|[0-9_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]+(all|main|search|replace(2|with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)+[[:space:]]*$"
|
||||
icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^|M-)([[:alpha:]]|space|[]]|[0-9_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+(all|main|search|replace(2|with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)+[[:space:]]*$"
|
||||
icolor brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|linter|formatter)[[:space:]]+.*$"
|
||||
icolor green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|linter|extendsyntax)\>"
|
||||
icolor green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|linter|formatter|extendsyntax)\>"
|
||||
|
||||
# Colors
|
||||
icolor yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## Here is an example for patch files.
|
||||
|
||||
syntax "patch" "\.(patch|diff)$"
|
||||
syntax "patch" "\.(patch|diff|debdiff)$"
|
||||
magic "diff output text"
|
||||
|
||||
# Added lines.
|
||||
|
||||
@@ -25,7 +25,7 @@ color brightyellow "<[^= ]*>" ""(\.|[^"])*""
|
||||
color brightblue "//.*"
|
||||
color brightblue start="/\*" end="\*/"
|
||||
##color blue start="<" end=">"
|
||||
##color red "&[^;[[:space:]]]*;"
|
||||
##color red "&[^;[:space:]]*;"
|
||||
|
||||
# Trailing whitespace.
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
@@ -6,16 +6,16 @@ syntax "po" "\.pot?$"
|
||||
color green "^#.*$"
|
||||
color yellow "Copyright|\(C\)"
|
||||
# Header fields.
|
||||
color brightmagenta "\<(Project\-Id\-Version|Report\-Msgid\-Bugs\-To|Last\-Translator|Language\-Team|Language|X\-Generator|Plural\-Forms)\>"
|
||||
color brightmagenta "\<(Project\-Id\-Version|Report\-Msgid\-Bugs\-To|Last\-Translator|Language(\-Team)?|X\-Generator|Plural\-Forms)\>"
|
||||
color cyan "\<(POT\-Creation\-Date|PO\-Revision\-Date|MIME\-Version|Content\-Type|Content\-Transfer\-Encoding)\>"
|
||||
# Encodings and numbers.
|
||||
color yellow "\<(UTF|ISO|Windows|Mac|IBM)\>\-[0-9]"
|
||||
color yellow "[0-9]|pre[0-9]|[0-9]bit"
|
||||
# Msgids.
|
||||
color brightblue "\<(msgid|msgid_plural|msgstr)\>"
|
||||
color brightblue "^(msgid|msgid_plural|msgstr)\>"
|
||||
# Tags.
|
||||
color red "\<fuzzy\>"
|
||||
color yellow "\<c-format\>"
|
||||
color red " fuzzy(,|$)"
|
||||
color yellow " (no-)?[-[:alpha:]]+-format(,|$)"
|
||||
# Format specifiers.
|
||||
color brightmagenta "%([1-9]\$)?[a-z]*"
|
||||
# Quotes and newlines.
|
||||
|
||||
75
doc/syntax/postgresql.nanorc
Normal file
75
doc/syntax/postgresql.nanorc
Normal file
@@ -0,0 +1,75 @@
|
||||
## Here is an example for PostgreSQL.
|
||||
|
||||
syntax "sql" "\.sql[2345s~]?$"
|
||||
magic "PostgreSQL script text"
|
||||
|
||||
# Functions.
|
||||
color white "\<[a-z_]*\("
|
||||
|
||||
# Types.
|
||||
color green "\<(int2|smallint|int4|int|integer|int8|bigint|decimal|numeric|real|double precision|(small|big)?serial)\>"
|
||||
color green "\<(bit( varying)?|boolean|bytea|enum|money|tsvector|uuid)\>"
|
||||
color green "\<(char|varchar|character( varying)?|text)\>"
|
||||
color green "\<(date|interval|time(stamp)?( with time zone| without time zone)?)\>"
|
||||
color green "\<(point|line|lseg|path|box|polygon|circle)\>"
|
||||
color green "\<(cidr|inet|macaddr)\>"
|
||||
color green "\<(daterange|int4range|int8range|numrange|tsrange|tstzrange)\>"
|
||||
|
||||
# Structure.
|
||||
color brightyellow "\<(CASE|CLASS|DEFAULT|DO|ELSE|ELSEIF|FOR|FOREACH|FUNCTION|IF|IS NULL)\>"
|
||||
color brightyellow "\<(NEW|PRIVATE|PUBLIC|RETURN|RETURNS|SETOF|SWITCH|THEN|WHEN|WHILE)>"
|
||||
|
||||
# Control flow.
|
||||
color magenta "\<(EXCEPTION|NOTICE|RAISE|RETURN)\>"
|
||||
|
||||
# SQL keywords.
|
||||
color blue "\<(ABORT|AGGREGATE|ALTER|ANALYZE|AND|AS|AUTHORIZATION|BEGIN|CAST|CHECKPOINT|CLASS|CLOSE)\>"
|
||||
color blue "\<(CLUSTER|COLLATION|COMMENT|COMMIT|CONFIGURATION|CONSTRAINTS|CONVERSION|COPY|CREATE)\>"
|
||||
color blue "\<(DATA|DATABASE|DEALLOCATE|DECLARE|DEFAULT|DELETE|DICTIONARY|DISCARD|DO|DOMAIN|DROP)\>"
|
||||
color blue "\<(END|EVENT|EXECUTE|EXPLAIN|EXTENSION|FAMILY|FETCH|FOREIGN|FROM|FUNCTION)\>"
|
||||
color blue "\<(GRANT|GROUP|IF NOT EXISTS|IMMUTABLE|INDEX|INSERT|INTO|LABEL|LANGUAGE|LARGE|LOAD|LOCK)\>"
|
||||
color blue "\<(MAPPING FOR|MATERIALIZED|MOVE|NOTIFY|OBJECT|OPERATOR|OPTIONS|OWNED|OWNER)\>"
|
||||
color blue "\<(PARSER|PREPARED?|PRIVILEGES|REASSIGN|REFRESH|RELEASE|RESET|REVOKE|ROLE|ROLLBACK|RULE)\>"
|
||||
color blue "\<(SAVEPOINT|SCHEMA|SEARCH|SECURITY|SELECT|SEQUENCE|SERVER|SESSION|SET|SHOW|SPACE|START|SYSTEM)\>"
|
||||
color blue "\<(TABLE|TEXT|TO|TRANSACTION|TYPE|UPDATE|USER|VACUUM|VALUES|VIEW|WHERE|WITH|WRAPPER)\>"
|
||||
|
||||
# Strings.
|
||||
color brightyellow "<[^= ]*>" ""(\.|[^"])*""
|
||||
|
||||
# Trailing whitespace.
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
# Regular expressions.
|
||||
color brightmagenta "/([^/]|(\\/))*/[iomx]*" "%r\{([^}]|(\\}))*\}[iomx]*"
|
||||
|
||||
# Shell command expansion is in `backticks` or like %x{this}. These are
|
||||
# "double-quotish" (to use a perlism).
|
||||
color brightblue "`[^`]*`" "%x\{[^}]*\}"
|
||||
|
||||
# Strings, double-quoted.
|
||||
color green ""([^"]|(\\"))*"" "%[QW]?\{[^}]*\}" "%[QW]?\([^)]*\)" "%[QW]?<[^>]*>"
|
||||
color green "%[QW]?\[[^]]*\]" "%[QW]?\$[^$]*\$" "%[QW]?\^[^^]*\^" "%[QW]?![^!]*!"
|
||||
|
||||
# Expression substitution. These go inside double-quoted strings,
|
||||
# "like #{this}".
|
||||
color brightgreen "#\{[^}]*\}"
|
||||
|
||||
# Strings, single-quoted.
|
||||
color green "'([^']|(\\'))*'" "%[qw]\{[^}]*\}" "%[qw]\([^)]*\)" "%[qw]<[^>]*>"
|
||||
color green "%[qw]\[[^]]*\]" "%[qw]\$[^$]*\$" "%[qw]\^[^^]*\^" "%[qw]![^!]*!"
|
||||
|
||||
# Comments.
|
||||
color red "#[^{].*$" "#$"
|
||||
color red "--[^{].*$" "#$"
|
||||
color red "##[^{].*$" "##$"
|
||||
color brightblue "//.*"
|
||||
color brightblue start="/\*" end="\*/"
|
||||
|
||||
# PostgreSQL markings.
|
||||
color red "(--)"
|
||||
|
||||
# PostgreSQL default schemas.
|
||||
color brightred "(pg_catalog|public)"
|
||||
|
||||
# PostgreSQL PLs.
|
||||
color brightblue "(pljava|plperlu?|plpgsql|plpy|plpythonu?|plr|plruby|plsh|pltcl|plscheme)"
|
||||
@@ -2,21 +2,23 @@
|
||||
|
||||
syntax "python" "\.py$"
|
||||
header "^#!.*python[-0-9._]*"
|
||||
linter pyflakes
|
||||
|
||||
# Function definitions.
|
||||
icolor brightblue "def [0-9A-Z_]+"
|
||||
# Keywords.
|
||||
color brightcyan "\<(and|as|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|raise|return|try|while|with|yield)\>"
|
||||
color brightcyan "\<(and|as|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from)\>"
|
||||
color brightcyan "\<(global|if|import|in|is|lambda|not|or|pass|print|raise|return|try|while|with|yield)\>"
|
||||
|
||||
# Strings.
|
||||
color brightgreen "['][^']*[^\\][']" "[']{3}.*[^\\][']{3}"
|
||||
color brightgreen "["][^"]*[^\\]["]" "["]{3}.*[^\\]["]{3}"
|
||||
# Multiline strings.
|
||||
color brightgreen start="\"\"\"([^"),]|$)" end="(^|[^(])\"\"\""
|
||||
color brightgreen start="'''([^'),]|$)" end="(^|[^(])'''"
|
||||
|
||||
# Comments.
|
||||
color brightred "(^|[[:blank:]])#.*$"
|
||||
# Multiline strings.
|
||||
color brightgreen start="\"\"\"[^"),]" end="(^|[^(])\"\"\""
|
||||
color brightgreen start="'''[^'),]" end="(^|[^(])'''"
|
||||
|
||||
# Reminders.
|
||||
color ,yellow "(FIXME|TODO|XXX)"
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
syntax "ruby" "\.rb$"
|
||||
header "^#!.*ruby[-0-9._]*"
|
||||
linter ruby -w -c
|
||||
|
||||
# Asciibetical list of reserved words.
|
||||
color yellow "\<(BEGIN|END|alias|and|begin|break|case|class|def|defined\?|do|else|elsif|end|ensure|false|for|if|in|module|next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\>"
|
||||
# Reserved words.
|
||||
color yellow "\<(BEGIN|END|alias|and|begin|break|case|class|def|defined\?|do|else|elsif|end|ensure|false|for|if|in|module)\>"
|
||||
color yellow "\<(next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\>"
|
||||
# Constants.
|
||||
color brightblue "(\$|@|@@)?\<[A-Z]+[0-9A-Z_a-z]*"
|
||||
# Ruby "symbols".
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
## Here is an example for Bourne shell scripts.
|
||||
|
||||
syntax "sh" "\.sh$"
|
||||
header "^#!.*(ba|k|pdk)?sh[-0-9_]*"
|
||||
header "^#!.*((ba|da|k|pdk)?sh[-0-9_]*|openrc-run|runscript)"
|
||||
magic "(POSIX|Bourne.*) shell script text"
|
||||
linter dash -n
|
||||
|
||||
icolor brightgreen "^[0-9A-Z_]+\(\)"
|
||||
color green "\<(break|case|continue|do|done|elif|else|esac|exit|fi|for|function|if|in|read|return|select|shift|then|time|until|while)\>"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
## Here is a short example for TeX files.
|
||||
|
||||
syntax "tex" "\.tex$"
|
||||
linter chktex -v0 -q -I
|
||||
|
||||
icolor green "\\.|\\[A-Z]*"
|
||||
color magenta "[{}]"
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
## Here is an example for XML files.
|
||||
|
||||
syntax "xml" "\.([jrs]html?|sgml?|xml|xslt?)$"
|
||||
syntax "xml" "\.([jrsx]html?|jnlp|mml|pom|rng|sgml?|svg|w[as]dl|wsdd|xjb|xml|xs(d|lt?)|xul)$"
|
||||
magic "(XML|SGML) (sub)?document text"
|
||||
|
||||
# The entire content of the tag:
|
||||
color green start="<" end=">"
|
||||
color cyan "<[^> ]+"
|
||||
color cyan ">"
|
||||
|
||||
# The start and the end of the tag:
|
||||
color cyan "<[^> ]+" ">"
|
||||
|
||||
# The strings inside the tag:
|
||||
color magenta "\"[^"]*\""
|
||||
|
||||
# Comments:
|
||||
color yellow start="<!DOCTYPE" end="[/]?>"
|
||||
color yellow start="<!--" end="-->"
|
||||
|
||||
# Escapes:
|
||||
color red "&[^;]*;"
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
\input texinfo @c -*-texinfo-*-
|
||||
@c %**start of header
|
||||
@setfilename nano.info
|
||||
@settitle nano Command Manual
|
||||
@settitle nano
|
||||
@c %**end of header
|
||||
|
||||
@c This file has the new style title page commands.
|
||||
@c Run 'makeinfo' rather than 'texinfo-format-buffer'.
|
||||
@smallbook
|
||||
@set EDITION 0.3
|
||||
@set VERSION 2.3.7
|
||||
@set UPDATED August 2014
|
||||
@set VERSION 2.4.2
|
||||
@set UPDATED June 2015
|
||||
|
||||
@dircategory Editors
|
||||
@direntry
|
||||
@@ -23,7 +21,7 @@
|
||||
@titlepage
|
||||
@title GNU @code{nano}
|
||||
@subtitle a small and friendly text editor.
|
||||
@subtitle version 2.3.7
|
||||
@subtitle version 2.4.2
|
||||
|
||||
@author Chris Allegretta
|
||||
@page
|
||||
@@ -34,7 +32,7 @@ editor.
|
||||
This manual is part of the GNU @code{nano} distribution.@*
|
||||
@sp 4
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
|
||||
2009, 2014 Free Software Foundation, Inc.
|
||||
2009, 2014, 2015 Free Software Foundation, Inc.
|
||||
|
||||
This document is dual-licensed. You may distribute and/or modify it
|
||||
under the terms of either of the following licenses:
|
||||
@@ -63,8 +61,10 @@ editor.
|
||||
|
||||
@menu
|
||||
* Introduction::
|
||||
* Invoking::
|
||||
* Command-line Options::
|
||||
* Editor Basics::
|
||||
* Online Help::
|
||||
* Built-in Help::
|
||||
* Feature Toggles::
|
||||
* Nanorc Files::
|
||||
* The File Browser::
|
||||
@@ -77,51 +77,49 @@ editor.
|
||||
@chapter Introduction
|
||||
|
||||
GNU @code{nano} is a small and friendly text editor. Besides basic text
|
||||
editing, @code{nano} offers many extra features, like an interactive
|
||||
search-and-replace, go-to-line-and-column-number, auto-indentation,
|
||||
feature toggles, internationalization support, and filename tab
|
||||
completion.
|
||||
editing, @code{nano} offers many extra features, such as an interactive
|
||||
search-and-replace, undo/redo, syntax coloring, smooth scrolling,
|
||||
auto-indentation, go-to-line-and-column-number, feature toggles,
|
||||
file locking, backup files, and internationalization support.
|
||||
|
||||
@menu
|
||||
* Overview::
|
||||
* Command Line Options::
|
||||
@end menu
|
||||
|
||||
@node Overview
|
||||
@section Overview
|
||||
|
||||
The original goal for @code{nano} was a complete bug-for-bug compatible
|
||||
emulation of Pico, but @code{nano}'s current goal is to be as compatible
|
||||
The original goal for @code{nano} was to be a complete bug-for-bug
|
||||
emulation of Pico. But currently the goal is to be as compatible
|
||||
as possible while offering a superset of Pico's functionality. See
|
||||
@xref{Pico Compatibility}, for more info.
|
||||
|
||||
Please report bugs via @url{https://savannah.gnu.org/bugs/?group=nano}.
|
||||
|
||||
@node Invoking
|
||||
@chapter Invoking
|
||||
|
||||
The usual way to invoke @code{nano} is:
|
||||
|
||||
@quotation
|
||||
@code{nano [OPTION]@dots{} [FILE]}
|
||||
@code{nano [FILE]}
|
||||
@end quotation
|
||||
|
||||
But it is also possible to edit several files in a row. Additionally,
|
||||
the cursor can be put on a desired line number by adding this number
|
||||
with a plus sign before any filename, and even in a desired column by
|
||||
adding it with a comma. So the complete synopsis is:
|
||||
But it is also possible to specify one or more options, and to edit
|
||||
several files in a row. Additionally, the cursor can be put on a
|
||||
specific line of a file by adding the line number
|
||||
with a plus sign before the filename, and even in a specific column by
|
||||
adding it with a comma. So the complete command synopsis is:
|
||||
|
||||
@quotation
|
||||
@code{nano [OPTION]@dots{} [[+LINE] FILE]@dots{}}
|
||||
|
||||
@code{nano [OPTION]@dots{} [[+,COLUMN] FILE]@dots{}}
|
||||
|
||||
@code{nano [OPTION]@dots{} [[+LINE,COLUMN] FILE]@dots{}}
|
||||
@code{nano [OPTION]@dots{} [[+LINE[,COLUMN]|+,COLUMN] FILE]@dots{}}
|
||||
@end quotation
|
||||
|
||||
Email bug reports to @email{nano@@nano-editor.org}.
|
||||
But normallly you would set your preferred options in your
|
||||
@file{.nanorc} file. And when the @code{poslog} option is set
|
||||
(making @code{nano} remember the cursor position), you will rarely
|
||||
need to specify a line number.
|
||||
|
||||
@node Command Line Options
|
||||
@section Command Line Options
|
||||
@node Command-line Options
|
||||
@chapter Command-line Options
|
||||
|
||||
@command{nano} takes the following options from the command line:
|
||||
|
||||
@table @option
|
||||
|
||||
@item +@var{line},@var{column}
|
||||
Start at line number @var{line} and column number @var{column} (at least one of
|
||||
which must be specified) instead of the default of line 1, column 1.
|
||||
@@ -136,13 +134,14 @@ line.
|
||||
|
||||
@item -B
|
||||
@itemx --backup
|
||||
When saving a file, back up the previous version of it to the current
|
||||
filename suffixed with a @samp{~}.
|
||||
When saving a file, back up the previous version of it, using the current
|
||||
filename suffixed with a tilde (@samp{~}).
|
||||
|
||||
@item -C @var{directory}
|
||||
@itemx --backupdir=@var{directory}
|
||||
Set the directory where @command{nano} puts unique backup files if file
|
||||
backups are enabled.
|
||||
Make and keep not just one backup file, but make and keep a uniquely
|
||||
numbered one every time a file is saved --- when backups are enabled.
|
||||
The uniquely numbered files are stored in the specified directory.
|
||||
|
||||
@item -D
|
||||
@itemx --boldtext
|
||||
@@ -154,7 +153,7 @@ Convert typed tabs to spaces.
|
||||
|
||||
@item -F
|
||||
@itemx --multibuffer
|
||||
Enable multiple file buffers (if support for them has been compiled in).
|
||||
Read a file into a new buffer by default.
|
||||
|
||||
@item -G
|
||||
@itemx --locking
|
||||
@@ -334,7 +333,7 @@ implement a read-only file.
|
||||
@item -w
|
||||
@itemx --nowrap
|
||||
Don't hard-wrap long lines at any length. This option conflicts with
|
||||
@option{-r} -- the last one given takes effect.
|
||||
@option{-r} --- the last one given takes effect.
|
||||
|
||||
@anchor{Expert Mode}
|
||||
@item -x
|
||||
@@ -367,6 +366,7 @@ separately (e.g. @code{nano -wS -$}).
|
||||
@itemx -g
|
||||
@itemx -j
|
||||
Ignored, for compatibility with Pico.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@@ -487,77 +487,77 @@ The mouse will work in the X Window System, and on the console when gpm
|
||||
is running.
|
||||
|
||||
|
||||
@node Online Help
|
||||
@chapter Online Help
|
||||
@node Built-in Help
|
||||
@chapter Built-in Help
|
||||
|
||||
The online help system in @code{nano} is available by pressing ^G.
|
||||
It is fairly self-explanatory, documenting the various parts of the
|
||||
editor and available keystrokes. Navigation is via the ^Y (Page Up)
|
||||
The built-in help system in @code{nano} is available by pressing ^G.
|
||||
It is fairly self-explanatory. It documents the various parts of the
|
||||
editor and the available keystrokes. Navigation is via the ^Y (Page Up)
|
||||
and ^V (Page Down) keys. ^X exits the help system.
|
||||
|
||||
|
||||
@node Feature Toggles
|
||||
@chapter Feature Toggles
|
||||
|
||||
Toggles allow you to change certain aspects of the editor that would
|
||||
normally be done via command-line options. They are invoked via Meta
|
||||
key sequences. See @xref{Special Functions}, for more info. The
|
||||
following global toggles are available:
|
||||
Toggles allow you to change on-the-fly certain aspects of the editor
|
||||
which would normally be specified via command-line options. They are
|
||||
invoked via Meta-key sequences. See @xref{Special Functions}, for more info.
|
||||
The following global toggles are available:
|
||||
|
||||
@table @code
|
||||
|
||||
@item Backup Files Toggle (Meta-B)
|
||||
toggles the -B (@code{--backup}) command line option.
|
||||
toggles the -B (@code{--backup}) command-line option.
|
||||
|
||||
@item Constant Cursor Position Display Toggle (Meta-C)
|
||||
toggles the -c (@code{--const}) command line option.
|
||||
toggles the -c (@code{--const}) command-line option.
|
||||
|
||||
@item Multiple File Buffers Toggle (Meta-F)
|
||||
toggles the -F (@code{--multibuffer}) command line option.
|
||||
toggles the -F (@code{--multibuffer}) command-line option.
|
||||
|
||||
@item Smart Home Key Toggle (Meta-H)
|
||||
toggles the -A (@code{--smarthome}) command line option.
|
||||
toggles the -A (@code{--smarthome}) command-line option.
|
||||
|
||||
@item Auto Indent Toggle (Meta-I)
|
||||
toggles the -i (@code{--autoindent}) command line option.
|
||||
toggles the -i (@code{--autoindent}) command-line option.
|
||||
|
||||
@item Cut To End Toggle (Meta-K)
|
||||
toggles the -k (@code{--cut}) command line option.
|
||||
toggles the -k (@code{--cut}) command-line option.
|
||||
|
||||
@item Long Line Wrapping Toggle (Meta-L)
|
||||
toggles the -w (@code{--nowrap}) command line option.
|
||||
toggles the -w (@code{--nowrap}) command-line option.
|
||||
|
||||
@item Mouse Support Toggle (Meta-M)
|
||||
toggles the -m (@code{--mouse}) command line option.
|
||||
toggles the -m (@code{--mouse}) command-line option.
|
||||
|
||||
@item No Conversion From DOS/Mac Format Toggle (Meta-N)
|
||||
toggles the -N (@code{--noconvert}) command line option.
|
||||
toggles the -N (@code{--noconvert}) command-line option.
|
||||
|
||||
@item More Space For Editing Toggle (Meta-O)
|
||||
toggles the -O (@code{--morespace}) command line option.
|
||||
toggles the -O (@code{--morespace}) command-line option.
|
||||
|
||||
@item Whitespace Display Toggle (Meta-P)
|
||||
toggles whitespace-display mode.
|
||||
toggles the whitespace-display mode.
|
||||
See @xref{Whitespace}, for more info.
|
||||
|
||||
@item Tabs to Spaces Toggle (Meta-Q)
|
||||
toggles the -E (@code{--tabstospaces}) command line option.
|
||||
toggles the -E (@code{--tabstospaces}) command-line option.
|
||||
|
||||
@item Smooth Scrolling Toggle (Meta-S)
|
||||
toggles the -S (@code{--smooth}) command line option.
|
||||
toggles the -S (@code{--smooth}) command-line option.
|
||||
|
||||
@item Expert/No Help Toggle (Meta-X)
|
||||
toggles the -x (@code{--nohelp}) command line option.
|
||||
toggles the -x (@code{--nohelp}) command-line option.
|
||||
|
||||
@item Color Syntax Highlighting Toggle (Meta-Y)
|
||||
toggles color syntax highlighting if you have color syntaxes in your
|
||||
nanorc. See @xref{Syntax Highlighting}, for more info.
|
||||
|
||||
@item Suspend Toggle (Meta-Z)
|
||||
toggles the -z (@code{--suspend}) command line option.
|
||||
toggles the -z (@code{--suspend}) command-line option.
|
||||
|
||||
@item Soft Wrapping Toggle (Meta-$)
|
||||
toggles the -$ (@code{--softwrap}) command line option.
|
||||
toggles the -$ (@code{--softwrap}) command-line option.
|
||||
|
||||
@end table
|
||||
|
||||
@@ -574,7 +574,7 @@ from ~/.nanorc.
|
||||
A nanorc file accepts a series of "set" and "unset" commands, which can
|
||||
be used to configure @code{nano} on startup without using command-line
|
||||
options. Additionally, there are some commands to define syntax highlighting
|
||||
and to rebind keys -- @xref{Syntax Highlighting}, and @xref{Rebinding Keys}.
|
||||
and to rebind keys --- @xref{Syntax Highlighting}, and @xref{Rebinding Keys}.
|
||||
@code{nano} will read one command per line.
|
||||
|
||||
Options in nanorc files take precedence over @code{nano}'s defaults, and
|
||||
@@ -611,12 +611,14 @@ You should NOT enable this option unless you are sure you need it.
|
||||
Use auto-indentation.
|
||||
|
||||
@item set backup
|
||||
When saving a file, back up the previous version of it to the current
|
||||
When saving a file, back up the previous version of it, using the current
|
||||
filename suffixed with a tilde (@code{~}).
|
||||
|
||||
@item set backupdir "directory"
|
||||
Set the directory where @code{nano} puts unique backup files, if file
|
||||
backups are enabled.
|
||||
Make and keep not just one backup file, but make and keep a uniquely
|
||||
numbered one every time a file is saved --- when backups are enabled
|
||||
with @code{set backup} or @code{--backup} or @code{-B}.
|
||||
The uniquely numbered files are stored in the specified directory.
|
||||
|
||||
@item set backwards
|
||||
Do backwards searches by default.
|
||||
@@ -685,7 +687,7 @@ Enable mouse support, so that mouse clicks can be used to place the
|
||||
cursor, set the mark (with a double click), or execute shortcuts.
|
||||
|
||||
@item set multibuffer
|
||||
Allow inserting files into their own buffers.
|
||||
When reading in a file with ^R, insert it into a new buffer by default.
|
||||
|
||||
@item set noconvert
|
||||
Don't convert files from DOS/Mac format.
|
||||
@@ -812,41 +814,53 @@ characters as part of a word.
|
||||
@node Syntax Highlighting
|
||||
@section Syntax Highlighting
|
||||
|
||||
Coloring the different syntactic elements of a file can be defined
|
||||
Coloring the different syntactic elements of a file
|
||||
is done via regular expressions (see the @code{color} command below).
|
||||
This is inherently imperfect, because regular expressions are not
|
||||
powerful enough to fully parse a file. Nevertheless, regular
|
||||
expressions can do a lot and are easy to make, so they are a
|
||||
good fit for a small editor like @code{nano}.
|
||||
|
||||
A separate syntax can be defined for each kind of file
|
||||
via the following commands in a nanorc file:
|
||||
|
||||
@table @code
|
||||
|
||||
@item syntax "str" ["fileregex" @dots{}]
|
||||
Defines a syntax named "str" which can be activated via the -Y/--syntax
|
||||
Defines a syntax named "str" which can be activated via the @code{-Y/--syntax}
|
||||
command-line option, or will be automatically activated if the current
|
||||
filename matches the extended regular expression "fileregex". All
|
||||
following "color" and "icolor" statements will apply to this "str"
|
||||
syntax until a new syntax is defined.
|
||||
subsequent @code{color}, @code{icolor}, @code{header} and other such
|
||||
statements will apply to this "str" syntax until a new @code{syntax}
|
||||
command is encountered.
|
||||
|
||||
The "none" syntax is reserved; specifying it on the command line is the
|
||||
same as not having a syntax at all. The "default" syntax is special: it
|
||||
takes no "fileregex", and applies to files that don't match any other
|
||||
takes no "fileregex", and applies to files that don't match any
|
||||
syntax's "fileregex".
|
||||
|
||||
@item linter program [arg @dots{}]
|
||||
For the currently defined syntax, use the given program to invoke the
|
||||
linter (this overrides the speller function when defined).
|
||||
Use the given program to do a syntax check on the current file
|
||||
(this overrides the speller function when defined).
|
||||
|
||||
@item formatter program [arg @dots{}]
|
||||
Use the given program to automatically reformat text.
|
||||
Useful in certain programming languages (e.g. Go).
|
||||
|
||||
@item header "regex" @dots{}
|
||||
For the currently defined syntax, add one or more regexes which will
|
||||
Add one or more regexes which will
|
||||
be compared against the very first line of the file to be edited,
|
||||
to determine whether this syntax should be used for that file.
|
||||
|
||||
@item magic ["regex" @dots{}]
|
||||
For the currently defined syntax, add one or more regexes which will be
|
||||
@item magic "regex" @dots{}
|
||||
Add one or more regexes which will be
|
||||
compared against the result of querying the magic database about the file
|
||||
to be edited, to determine whether this syntax should be used for that
|
||||
file. This functionality only works when libmagic is installed on the
|
||||
system and will be silently ignored otherwise.
|
||||
|
||||
@item color fgcolor,bgcolor "regex" @dots{}
|
||||
For the currently defined syntax, display all expressions matching the
|
||||
Display all pieces of text that match the
|
||||
extended regular expression "regex" with foreground color "fgcolor" and
|
||||
background color "bgcolor", at least one of which must be specified.
|
||||
Valid colors for foreground and background are: white, black, red,
|
||||
@@ -856,29 +870,30 @@ terminal supports transparency, not specifying a "bgcolor" tells @code{nano}
|
||||
to attempt to use a transparent background.
|
||||
|
||||
@item icolor fgcolor,bgcolor "regex" @dots{}
|
||||
Same as above, except that the expression matching is case insensitive.
|
||||
Same as above, except that the text matching is case insensitive.
|
||||
|
||||
@item color fgcolor,bgcolor start="sr" end="er"
|
||||
Display expressions which start with the extended regular expression
|
||||
"sr" and end with the extended regular expression "er" with foreground
|
||||
Display all pieces of text whose start matches extended regular expression
|
||||
"sr" and whose end matches extended regular expression "er" with foreground
|
||||
color "fgcolor" and background color "bgcolor", at least one of which
|
||||
must be specified. This allows syntax highlighting to span multiple
|
||||
lines. Note that all subsequent instances of "sr" after an initial "sr"
|
||||
is found will be highlighted until the first instance of "er".
|
||||
must be specified. This means that, after an initial instance of "sr",
|
||||
all text will be highlighted until the first instance of "er".
|
||||
This allows syntax highlighting to span multiple lines.
|
||||
|
||||
@item icolor fgcolor,bgcolor start="sr" end="er"
|
||||
Same as above, except that the expression matching is case insensitive.
|
||||
Same as above, except that the text matching is case insensitive.
|
||||
|
||||
@item include "syntaxfile"
|
||||
Read in self-contained color syntaxes from "syntaxfile". Note that
|
||||
"syntaxfile" can only contain the above commands, from "syntax" to
|
||||
"icolor".
|
||||
"syntaxfile" may contain only the above commands, from @code{syntax}
|
||||
to @code{icolor}.
|
||||
|
||||
@item extendsyntax str directive [arg @dots{}]
|
||||
Extend the syntax previously defined as str to include new information.
|
||||
Allows you to add a new color, icolor, magic, header, or linter directive
|
||||
to an already defined syntax. Useful when you want to add to definitions
|
||||
from the system-installed syntax definitions (which are normally not writable).
|
||||
This allows you to add a new @code{color}, @code{icolor}, @code{header},
|
||||
@code{magic}, @code{linter}, or @code{formatter} directive to an already
|
||||
defined syntax --- useful when you want to slightly improve a syntax defined
|
||||
in one of the system-installed files (which are normally not writable).
|
||||
|
||||
@end table
|
||||
|
||||
@@ -935,11 +950,11 @@ Exits from the program (or from the help viewer or the file browser).
|
||||
Writes the current buffer to disk.
|
||||
|
||||
@item insert
|
||||
Inserts a file into the current buffer (or into a new buffer when multibuffer
|
||||
is enabled).
|
||||
Inserts a file into the current buffer (at the current cursor position),
|
||||
or into a new buffer when option @code{multibuffer} is set.
|
||||
|
||||
@item whereis
|
||||
Searches for text in the current buffer -- or for filenames matching
|
||||
Searches for text in the current buffer --- or for filenames matching
|
||||
a string in the current list in the file browser
|
||||
|
||||
@item searchagain
|
||||
@@ -1045,10 +1060,10 @@ Moves the cursor to the bracket (brace, parenthesis, etc.) that matches
|
||||
(pairs) with the one under the cursor.
|
||||
|
||||
@item prevbuf
|
||||
Switches to editing/viewing the previous buffer when using multibuffer mode.
|
||||
Switches to editing/viewing the previous buffer when multiple buffers are open.
|
||||
|
||||
@item nextbuf
|
||||
Switches to editing/viewing the next buffer when using multibuffer mode.
|
||||
Switches to editing/viewing the next buffer when multiple buffers are open.
|
||||
|
||||
@item verbatim
|
||||
Inserts the next character verbatim into the file.
|
||||
@@ -1172,7 +1187,8 @@ Toggles whether typed tabs will be converted to spaces.
|
||||
Toggles whether a backup will be made of the file to be edited.
|
||||
|
||||
@item multibuffer
|
||||
Toggles the use of multiple file buffers (if available).
|
||||
Toggles whether a file is inserted into the current buffer
|
||||
or read into a new buffer.
|
||||
|
||||
@item mouse
|
||||
Toggles mouse support.
|
||||
@@ -1235,6 +1251,7 @@ The 'go to directory' menu in the file browser.
|
||||
A special name that encompasses all menus. For @code{bind} it means
|
||||
all menus where the specified @code{function} exists; for @code{unbind}
|
||||
it means all menus where the specified @code{key} exists.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@@ -1262,20 +1279,19 @@ browser exits.
|
||||
are certain differences between the editors:
|
||||
|
||||
@table @code
|
||||
@item Search and Replace History
|
||||
As of version 1.1.99pre1 of @code{nano}, text entered as search or
|
||||
replace strings will be stored and can be accessed with the up/down
|
||||
arrow keys. Previously, @code{nano} offered a more consistent, but
|
||||
incompatible with Pico, method for entering search and replace strings.
|
||||
In the old method, previous entries would be displayed by default as
|
||||
editable text in front of the cursor, as opposed to being bracketed and
|
||||
uneditable as it is in Pico. The old behavior could be made compatible
|
||||
with Pico via the @code{-p} option, but recent versions of Pico use the
|
||||
@code{-p} option to preserve the XON and XOFF sequences within the
|
||||
editor. Since, with the new method, search and replace strings can
|
||||
still be edited by simply hitting the up arrow key once, the old method
|
||||
was removed completely.
|
||||
|
||||
@item Interactive Replace
|
||||
Instead of allowing you to replace either just one occurrence of a search
|
||||
string or all of them, @code{nano}'s replace function is interactive: it
|
||||
will pause at each found search string and query whether to replace this
|
||||
instance. You can then choose Yes, or No (skip this one), or All (don't
|
||||
ask any more), or Cancel (stop with replacing).
|
||||
|
||||
@item Search and Replace History
|
||||
When the option @code{-H} or @code{--historylog} is given (or set in
|
||||
the .nanorc file), text entered as search or replace strings is stored.
|
||||
These strings can be accessed with the up/down arrow keys. A retrieved
|
||||
string can subsequently be edited.
|
||||
|
||||
@item Writing, Appending, or Prepending Selected Text to Files
|
||||
Text selected using the marking key (^^) can be written out, appended,
|
||||
@@ -1284,26 +1300,20 @@ or prepended to a new or existing file using the WriteOut key (^O).
|
||||
@item Toggles
|
||||
Many options which alter the functionality of the program can be
|
||||
"toggled" on or off using Meta key sequences, meaning the program does
|
||||
not have to be restarted to turn a particular feature of the editor on
|
||||
or off. Please see the internal help function (^G) for a list of what
|
||||
functions can be toggled for a particular version of @code{nano}. See
|
||||
@xref{Feature Toggles}, for more info.
|
||||
not have to be restarted to turn a particular feature on or off.
|
||||
See the internal help function (^G) for a list of features that
|
||||
can be toggled. Or see @xref{Feature Toggles} instead.
|
||||
|
||||
@item Cursor Position Display
|
||||
The output of the "Display Cursor Position" in @code{nano} displays
|
||||
the current line position of the cursor, as well as the column and
|
||||
total character position.
|
||||
@item Current Cursor Position
|
||||
The output of the "Display Cursor Position" command (^C) displays
|
||||
not only the current line and character position of the cursor,
|
||||
but also (between the two) the current column position.
|
||||
|
||||
@item Interactive Replace and Spell Checker
|
||||
It is worth noting that @code{nano}'s replace function is interactive,
|
||||
i.e. it does not stop after one search string was found and automatically
|
||||
replaced. The @code{nano} implementation will pause at each found
|
||||
search string and query whether to replace this instance or not. The
|
||||
internal spell checker operates similarly. Note that there is no way to
|
||||
force these functions to behave in the Pico fashion. As of version
|
||||
1.1.99pre1, misspelled words are sorted and trimmed for uniqueness in
|
||||
the internal spell checker such that the words 'apple' and 'Apple' will
|
||||
@item Spell Checking
|
||||
In the internal spell checker misspelled words are sorted alphabetically
|
||||
and trimmed for uniqueness, such that the words 'apple' and 'Apple' will
|
||||
be prompted for correction separately.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@@ -1331,7 +1341,7 @@ Disable the mini file browser when reading or writing files.
|
||||
|
||||
@item --disable-color
|
||||
Disable support for the syntax coloring of files. This also eliminates
|
||||
the -Y command-line option, which chooses a specific syntax.
|
||||
the @code{-Y} command-line option, which chooses a specific syntax.
|
||||
|
||||
@item --disable-extra
|
||||
Disable extra features. At the moment, this is just easter-egg-type
|
||||
@@ -1345,57 +1355,57 @@ things about using the editor.
|
||||
@item --disable-histories
|
||||
Disable the code for the handling of the history files: the search and
|
||||
replace strings that were used, and the cursor position at which each
|
||||
file was closed. This also eliminates the -H and -P command-line
|
||||
options, which switch on the logging of search/replace strings and
|
||||
cursor positions.
|
||||
file was closed. This also eliminates the @code{-H} and @code{-P}
|
||||
command-line options, which switch on the logging of search/replace
|
||||
strings and cursor positions.
|
||||
|
||||
@item --disable-justify
|
||||
Disable the justify and unjustify functions.
|
||||
|
||||
@item --disable-libmagic
|
||||
Disable the use of the library of magic-number tests (for determining
|
||||
the file type and thus which syntax to use for colouring -- often the
|
||||
the file type and thus which syntax to use for colouring --- often the
|
||||
tests on filename extension and header line will be enough).
|
||||
|
||||
@item --disable-mouse
|
||||
Disable all mouse functionality. This also eliminates the -m
|
||||
Disable all mouse functionality. This also eliminates the @code{-m}
|
||||
command-line option, which enables the mouse functionality.
|
||||
|
||||
@item --disable-multibuffer
|
||||
Disable support for opening multiple files at a time and switching
|
||||
between them on the fly. This also eliminates the -F command-line
|
||||
option, which switches the use of multiple file buffers on.
|
||||
between them on the fly. This also eliminates the @code{-F} command-line
|
||||
option, which causes a file to be read into a separate buffer by default.
|
||||
|
||||
@item --disable-nanorc
|
||||
Disable support for reading the nanorc files at startup. With such
|
||||
support, you can store custom settings in a system-wide and a per-user
|
||||
nanorc file rather than having to pass command-line options to get
|
||||
the desired behavior. See @xref{Nanorc Files}, for more info.
|
||||
Disabling this also eliminates the -I and -q command-line options;
|
||||
the first inhibits the reading of nanorcfiles, and the second
|
||||
Disabling this also eliminates the @code{-I} and @code{-q} command-line
|
||||
options; the first inhibits the reading of nanorcfiles, and the second
|
||||
suppresses warnings about errors in those files.
|
||||
|
||||
@item --disable-operatingdir
|
||||
Disable setting the operating directory. This also eliminates the -o
|
||||
Disable setting the operating directory. This also eliminates the @code{-o}
|
||||
command-line option, which sets the operating directory.
|
||||
|
||||
@item --disable-speller
|
||||
Disable use of the spell checker. This also eliminates the -s
|
||||
Disable use of the spell checker. This also eliminates the @code{-s}
|
||||
command-line option, which allows specifying an alternate spell checker.
|
||||
|
||||
@item --disable-tabcomp
|
||||
Disable the tab completion code when reading or writing files.
|
||||
|
||||
@item --disable-wrapping
|
||||
Disable hard-wrapping of overlong lines. This also eliminates the -w
|
||||
Disable hard-wrapping of overlong lines. This also eliminates the @code{-w}
|
||||
command-line option, which enables long-line wrapping.
|
||||
|
||||
@item --enable-tiny
|
||||
This option disables all the above. It also disables some of the larger
|
||||
internals of the editor, like the marking code and the cut-to-end-of-line
|
||||
code. It also disables the function toggles. By using the enabling
|
||||
counterpart of the above options together with --enable-tiny, specific
|
||||
features can be switched back on.
|
||||
counterpart of the above options together with @code{--enable-tiny},
|
||||
specific features can be switched back on.
|
||||
|
||||
@item --enable-debug
|
||||
Enable support for runtime debug output. This can get pretty messy, so
|
||||
|
||||
25
nano.spec.in
25
nano.spec.in
@@ -2,20 +2,24 @@
|
||||
%define version @VERSION@
|
||||
%define release 1
|
||||
|
||||
Summary : Pico editor clone with enhancements
|
||||
Name : %{name}
|
||||
Version : %{version}
|
||||
Release : %{release}
|
||||
Summary : a user-friendly editor, a Pico clone with enhancements
|
||||
|
||||
License : GPLv3+
|
||||
Group : Applications/Editors
|
||||
URL : http://www.nano-editor.org/
|
||||
Source : http://www.nano-editor.org/dist/v2.3/%{name}-%{version}.tar.gz
|
||||
Source : http://www.nano-editor.org/dist/v2.4/%{name}-%{version}.tar.gz
|
||||
|
||||
BuildRoot : %{_tmppath}/%{name}-%{version}-root
|
||||
BuildRequires : autoconf, automake, gettext-devel, ncurses-devel
|
||||
BuildRequires : autoconf, automake, gettext-devel, ncurses-devel, texinfo
|
||||
Requires(post) : info
|
||||
Requires(preun) : info
|
||||
|
||||
%description
|
||||
GNU nano is a small and friendly text editor. It aims to emulate the
|
||||
Pico text editor while also offering a few enhancements.
|
||||
Pico text editor while also offering several enhancements.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
@@ -26,13 +30,22 @@ make
|
||||
|
||||
%install
|
||||
make DESTDIR="%{buildroot}" install
|
||||
#ln -s nano %{buildroot}%{_bindir}/pico
|
||||
rm -f %{buildroot}%{_infodir}/dir
|
||||
#ln -s nano %{buildroot}/%{_bindir}/pico
|
||||
rm -f %{buildroot}/%{_infodir}/dir
|
||||
|
||||
%post
|
||||
/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir || :
|
||||
|
||||
%preun
|
||||
if [ $1 = 0 ] ; then
|
||||
/sbin/install-info --delete %{_infodir}/%{name}.info %{_infodir}/dir || :
|
||||
fi
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%doc AUTHORS COPYING ChangeLog INSTALL NEWS README THANKS TODO doc/faq.html doc/nanorc.sample
|
||||
%{_bindir}/*
|
||||
%{_docdir}/nano/*
|
||||
%{_mandir}/man*/*
|
||||
%{_mandir}/fr/man*/*
|
||||
%{_infodir}/nano.info*
|
||||
|
||||
999
po/nano.pot
999
po/nano.pot
File diff suppressed because it is too large
Load Diff
978
po/pt_BR.po
978
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
1015
po/zh_CN.po
1015
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
1015
po/zh_TW.po
1015
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
313
src/browser.c
313
src/browser.c
@@ -3,7 +3,8 @@
|
||||
* browser.c *
|
||||
* *
|
||||
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, *
|
||||
* 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
|
||||
* 2010, 2011, 2013, 2014, 2015 Free Software Foundation, Inc. *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3, or (at your option) *
|
||||
@@ -39,10 +40,9 @@ static int width = 0;
|
||||
static int longest = 0;
|
||||
/* The number of columns in the longest filename in the list. */
|
||||
static size_t selected = 0;
|
||||
/* The currently selected filename in the list. This variable
|
||||
* is zero-based. */
|
||||
static bool search_last_file = FALSE;
|
||||
/* Have we gone past the last file while searching? */
|
||||
/* The currently selected filename in the list; zero-based. */
|
||||
static char *path_save = NULL;
|
||||
/* A copy of the current path. */
|
||||
|
||||
/* Our main file browser function. path is the tilde-expanded path we
|
||||
* start browsing from. */
|
||||
@@ -52,8 +52,7 @@ char *do_browser(char *path, DIR *dir)
|
||||
int kbinput;
|
||||
bool old_const_update = ISSET(CONST_UPDATE);
|
||||
char *prev_dir = NULL;
|
||||
/* The directory we were in, if any, before backing up via
|
||||
* browsing to "..". */
|
||||
/* The directory we were in before backing up to "..". */
|
||||
char *ans = NULL;
|
||||
/* The last answer the user typed at the statusbar prompt. */
|
||||
size_t old_selected;
|
||||
@@ -63,7 +62,6 @@ char *do_browser(char *path, DIR *dir)
|
||||
|
||||
curs_set(0);
|
||||
blank_statusbar();
|
||||
currmenu = MBROWSER;
|
||||
bottombars(MBROWSER);
|
||||
wnoutrefresh(bottomwin);
|
||||
|
||||
@@ -79,6 +77,9 @@ char *do_browser(char *path, DIR *dir)
|
||||
|
||||
path = mallocstrassn(path, get_full_path(path));
|
||||
|
||||
/* Save the current path in order to be used later. */
|
||||
path_save = path;
|
||||
|
||||
assert(path != NULL && path[strlen(path) - 1] == '/');
|
||||
|
||||
/* Get the file list, and set longest and width in the process. */
|
||||
@@ -92,7 +93,7 @@ char *do_browser(char *path, DIR *dir)
|
||||
/* If prev_dir isn't NULL, select the directory saved in it, and
|
||||
* then blow it away. */
|
||||
if (prev_dir != NULL) {
|
||||
browser_select_filename(prev_dir);
|
||||
browser_select_dirname(prev_dir);
|
||||
|
||||
free(prev_dir);
|
||||
prev_dir = NULL;
|
||||
@@ -122,6 +123,14 @@ char *do_browser(char *path, DIR *dir)
|
||||
|
||||
kbinput = get_kbinput(edit);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (kbinput == KEY_WINCH) {
|
||||
kbinput = ERR;
|
||||
curs_set(0);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
if (kbinput == KEY_MOUSE) {
|
||||
int mouse_x, mouse_y;
|
||||
@@ -137,19 +146,16 @@ char *do_browser(char *path, DIR *dir)
|
||||
width) + (mouse_x / (longest + 2));
|
||||
|
||||
/* If they clicked beyond the end of a row,
|
||||
* select the filename at the end of that
|
||||
* row. */
|
||||
* select the last filename in that row. */
|
||||
if (mouse_x > width * (longest + 2))
|
||||
selected--;
|
||||
|
||||
/* If we're off the screen, select the last
|
||||
* filename. */
|
||||
/* If we're off the screen, select the last filename. */
|
||||
if (selected > filelist_len - 1)
|
||||
selected = filelist_len - 1;
|
||||
|
||||
/* If we selected the same filename as last
|
||||
* time, put back the Enter key so that it's
|
||||
* read in. */
|
||||
/* If we selected the same filename as last time,
|
||||
* put back the Enter key so that it's read in. */
|
||||
if (old_selected == selected)
|
||||
unget_kbinput(sc_seq_or(do_enter_void, 0), FALSE, FALSE);
|
||||
}
|
||||
@@ -163,6 +169,8 @@ char *do_browser(char *path, DIR *dir)
|
||||
} else if (func == do_help_void) {
|
||||
#ifndef DISABLE_HELP
|
||||
do_help_void();
|
||||
/* Perhaps the window dimensions have changed. */
|
||||
browser_refresh();
|
||||
curs_set(0);
|
||||
#else
|
||||
nano_disabled_msg();
|
||||
@@ -203,7 +211,6 @@ char *do_browser(char *path, DIR *dir)
|
||||
browser_refresh, _("Go To Directory"));
|
||||
|
||||
curs_set(0);
|
||||
currmenu = MBROWSER;
|
||||
bottombars(MBROWSER);
|
||||
|
||||
/* If the directory begins with a newline (i.e. an
|
||||
@@ -398,8 +405,7 @@ char *do_browse_from(const char *inpath)
|
||||
|
||||
/* If we can't open the path, get out. */
|
||||
if (dir == NULL) {
|
||||
if (path != NULL)
|
||||
free(path);
|
||||
free(path);
|
||||
beep();
|
||||
return NULL;
|
||||
}
|
||||
@@ -549,20 +555,21 @@ functionptrtype parse_browser_input(int *kbinput)
|
||||
* necessary, and display the list of files. */
|
||||
void browser_refresh(void)
|
||||
{
|
||||
static int uimax_digits = -1;
|
||||
size_t i;
|
||||
int col = 0;
|
||||
/* The maximum number of columns that the filenames will take
|
||||
* up. */
|
||||
int line = 0;
|
||||
/* The maximum number of lines that the filenames will take
|
||||
* up. */
|
||||
int line = 0, col = 0;
|
||||
/* The current line and column while the list is getting displayed. */
|
||||
char *foo;
|
||||
/* The file information that we'll display. */
|
||||
/* The additional information that we'll display about a file. */
|
||||
|
||||
if (uimax_digits == -1)
|
||||
uimax_digits = digits(UINT_MAX);
|
||||
/* Perhaps window dimensions have changed; reinitialize the browser. */
|
||||
browser_init(path_save, opendir(path_save));
|
||||
qsort(filelist, filelist_len, sizeof(char *), diralphasort);
|
||||
|
||||
/* Make sure the selected file is within range. */
|
||||
if (selected >= filelist_len)
|
||||
selected = filelist_len - 1;
|
||||
|
||||
titlebar(path_save);
|
||||
blank_edit();
|
||||
|
||||
wmove(edit, 0, 0);
|
||||
@@ -581,7 +588,7 @@ void browser_refresh(void)
|
||||
/* The maximum length of the file information in
|
||||
* columns: seven for "--", "(dir)", or the file size,
|
||||
* and 12 for "(parent dir)". */
|
||||
bool dots = (COLS >= 15 && filetaillen >= longest - foomaxlen - 1);
|
||||
bool dots = (COLS >= 15 && filetaillen >= longest - foomaxlen);
|
||||
/* Do we put an ellipsis before the filename? Don't set
|
||||
* this to TRUE if we have fewer than 15 columns (i.e.
|
||||
* one column for padding, plus seven columns for a
|
||||
@@ -593,15 +600,13 @@ void browser_refresh(void)
|
||||
* "(dir)", or the file size, plus three columns for the
|
||||
* ellipsis. */
|
||||
|
||||
/* Start highlighting the currently selected file or
|
||||
* directory. */
|
||||
/* Start highlighting the currently selected file or directory. */
|
||||
if (i == selected)
|
||||
wattron(edit, hilite_attribute);
|
||||
|
||||
blank_line(edit, line, col, longest);
|
||||
|
||||
/* If dots is TRUE, we will display something like
|
||||
* "...ename". */
|
||||
/* If dots is TRUE, we will display something like "...ename". */
|
||||
if (dots)
|
||||
mvwaddstr(edit, line, col, "...");
|
||||
mvwaddstr(edit, line, dots ? col + 3 : col, disp);
|
||||
@@ -621,14 +626,12 @@ void browser_refresh(void)
|
||||
/* If the file is a symlink that points to a directory,
|
||||
* display it as a directory. */
|
||||
else
|
||||
/* TRANSLATORS: Try to keep this at most 7
|
||||
* characters. */
|
||||
/* TRANSLATORS: Try to keep this at most 7 characters. */
|
||||
foo = mallocstrcpy(NULL, _("(dir)"));
|
||||
} else if (S_ISDIR(st.st_mode)) {
|
||||
/* If the file is a directory, display it as such. */
|
||||
if (strcmp(filetail, "..") == 0) {
|
||||
/* TRANSLATORS: Try to keep this at most 12
|
||||
* characters. */
|
||||
/* TRANSLATORS: Try to keep this at most 12 characters. */
|
||||
foo = mallocstrcpy(NULL, _("(parent dir)"));
|
||||
foomaxlen = 12;
|
||||
} else
|
||||
@@ -637,26 +640,29 @@ void browser_refresh(void)
|
||||
unsigned long result = st.st_size;
|
||||
char modifier;
|
||||
|
||||
foo = charalloc(uimax_digits + 4);
|
||||
foo = charalloc(foomaxlen + 1);
|
||||
|
||||
/* Bytes. */
|
||||
if (st.st_size < (1 << 10))
|
||||
modifier = ' ';
|
||||
/* Kilobytes. */
|
||||
modifier = ' '; /* bytes */
|
||||
else if (st.st_size < (1 << 20)) {
|
||||
result >>= 10;
|
||||
modifier = 'K';
|
||||
/* Megabytes. */
|
||||
modifier = 'K'; /* kilobytes */
|
||||
} else if (st.st_size < (1 << 30)) {
|
||||
result >>= 20;
|
||||
modifier = 'M';
|
||||
/* Gigabytes. */
|
||||
modifier = 'M'; /* megabytes */
|
||||
} else {
|
||||
result >>= 30;
|
||||
modifier = 'G';
|
||||
modifier = 'G'; /* gigabytes */
|
||||
}
|
||||
|
||||
sprintf(foo, "%4lu %cB", result, modifier);
|
||||
/* If less than a terabyte, or if numbers can't even go
|
||||
* that high, show the size, otherwise show "(huge)". */
|
||||
if (st.st_size < (1 << 40) || (1 << 40) == 0)
|
||||
sprintf(foo, "%4lu %cB", result, modifier);
|
||||
else
|
||||
/* TRANSLATORS: Try to keep this at most 7 characters.
|
||||
* If necessary, you can leave out the parentheses. */
|
||||
foo = mallocstrcpy(foo, _("(huge)"));
|
||||
}
|
||||
|
||||
/* Make sure foo takes up no more than foomaxlen columns. */
|
||||
@@ -668,8 +674,7 @@ void browser_refresh(void)
|
||||
|
||||
mvwaddstr(edit, line, col - foolen, foo);
|
||||
|
||||
/* Finish highlighting the currently selected file or
|
||||
* directory. */
|
||||
/* Finish highlighting the currently selected file or directory. */
|
||||
if (i == selected)
|
||||
wattroff(edit, hilite_attribute);
|
||||
|
||||
@@ -691,56 +696,34 @@ void browser_refresh(void)
|
||||
wnoutrefresh(edit);
|
||||
}
|
||||
|
||||
/* Look for needle. If we find it, set selected to its location. Note
|
||||
* that needle must be an exact match for a file in the list. The
|
||||
* return value specifies whether we found anything. */
|
||||
bool browser_select_filename(const char *needle)
|
||||
/* Look for needle. If we find it, set selected to its location.
|
||||
* Note that needle must be an exact match for a file in the list. */
|
||||
void browser_select_dirname(const char *needle)
|
||||
{
|
||||
size_t currselected;
|
||||
bool found = FALSE;
|
||||
size_t looking_at = 0;
|
||||
|
||||
for (currselected = 0; currselected < filelist_len;
|
||||
currselected++) {
|
||||
if (strcmp(filelist[currselected], needle) == 0) {
|
||||
found = TRUE;
|
||||
for (; looking_at < filelist_len; looking_at++) {
|
||||
if (strcmp(filelist[looking_at], needle) == 0) {
|
||||
selected = looking_at;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found)
|
||||
selected = currselected;
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/* Set up the system variables for a filename search. Return -1 if the
|
||||
* search should be canceled (due to Cancel, a blank search string, or a
|
||||
* failed regcomp()), return 0 on success, and return 1 on rerun calling
|
||||
* program. */
|
||||
/* Set up the system variables for a filename search. Return -1 or -2 if
|
||||
* the search should be canceled (due to Cancel or a blank search string),
|
||||
* return 0 when we have a string, and return a positive value when some
|
||||
* function was run. */
|
||||
int filesearch_init(void)
|
||||
{
|
||||
int i = 0;
|
||||
int input;
|
||||
char *buf;
|
||||
static char *backupstring = NULL;
|
||||
/* The search string we'll be using. */
|
||||
|
||||
/* If backupstring doesn't exist, initialize it to "". */
|
||||
if (backupstring == NULL)
|
||||
backupstring = mallocstrcpy(NULL, "");
|
||||
|
||||
/* We display the search prompt below. If the user types a partial
|
||||
* search string and then Replace or a toggle, we will return to
|
||||
* do_search() or do_replace() and be called again. In that case,
|
||||
* we should put the same search string back up. */
|
||||
|
||||
search_init_globals();
|
||||
|
||||
if (last_search[0] != '\0') {
|
||||
char *disp = display_string(last_search, 0, COLS / 3, FALSE);
|
||||
|
||||
buf = charalloc(strlen(disp) + 7);
|
||||
/* We use (COLS / 3) here because we need to see more on the
|
||||
* line. */
|
||||
/* We use (COLS / 3) here because we need to see more on the line. */
|
||||
sprintf(buf, " [%s%s]", disp,
|
||||
(strlenpt(last_search) > COLS / 3) ? "..." : "");
|
||||
free(disp);
|
||||
@@ -748,11 +731,11 @@ int filesearch_init(void)
|
||||
buf = mallocstrcpy(NULL, "");
|
||||
|
||||
/* This is now one simple call. It just does a lot. */
|
||||
i = do_prompt(FALSE,
|
||||
input = do_prompt(FALSE,
|
||||
#ifndef DISABLE_TABCOMP
|
||||
TRUE,
|
||||
#endif
|
||||
MWHEREISFILE, backupstring,
|
||||
MWHEREISFILE, NULL,
|
||||
#ifndef DISABLE_HISTORIES
|
||||
&search_history,
|
||||
#endif
|
||||
@@ -761,100 +744,92 @@ int filesearch_init(void)
|
||||
/* Release buf now that we don't need it anymore. */
|
||||
free(buf);
|
||||
|
||||
free(backupstring);
|
||||
backupstring = NULL;
|
||||
/* If only Enter was pressed but we have a previous string, it's okay. */
|
||||
if (input == -2 && *last_search != '\0')
|
||||
return 0;
|
||||
|
||||
/* Cancel any search, or just return with no previous search. */
|
||||
if (i == -1 || (i < 0 && *last_search == '\0') || (i == 0 &&
|
||||
*answer == '\0')) {
|
||||
/* Otherwise negative inputs are a bailout. */
|
||||
if (input < 0)
|
||||
statusbar(_("Cancelled"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return input;
|
||||
}
|
||||
|
||||
/* Look for needle. If no_sameline is TRUE, skip over selected when
|
||||
* looking for needle. begin is the location of the filename where we
|
||||
* first started searching. The return value specifies whether we found
|
||||
* anything. */
|
||||
bool findnextfile(bool no_sameline, size_t begin, const char *needle)
|
||||
/* Look for the given needle in the list of files. */
|
||||
void findnextfile(const char *needle)
|
||||
{
|
||||
size_t currselected = selected;
|
||||
/* The location in the current file list of the match we
|
||||
* find. */
|
||||
const char *filetail = tail(filelist[currselected]);
|
||||
size_t looking_at = selected;
|
||||
/* The location in the file list of the filename we're looking at. */
|
||||
bool came_full_circle = FALSE;
|
||||
/* Have we reached the starting file again? */
|
||||
const char *filetail = tail(filelist[looking_at]);
|
||||
/* The filename we display, minus the path. */
|
||||
const char *rev_start = filetail, *found = NULL;
|
||||
unsigned stash[sizeof(flags) / sizeof(flags[0])];
|
||||
/* A storage place for the current flag settings. */
|
||||
|
||||
/* Look for needle in the current filename we're searching. */
|
||||
/* Save the settings of all flags. */
|
||||
memcpy(stash, flags, sizeof(flags));
|
||||
|
||||
/* Search forward, case insensitive and without regexes. */
|
||||
UNSET(BACKWARDS_SEARCH);
|
||||
UNSET(CASE_SENSITIVE);
|
||||
UNSET(USE_REGEXP);
|
||||
|
||||
/* Step through each filename in the list until a match is found or
|
||||
* we've come back to the point where we started. */
|
||||
while (TRUE) {
|
||||
found = strstrwrapper(filetail, needle, rev_start);
|
||||
|
||||
/* We've found a potential match. If we're not allowed to find
|
||||
* a match on the same filename we started on and this potential
|
||||
* match is on that line, continue searching. */
|
||||
if (found != NULL && (!no_sameline || currselected != begin))
|
||||
/* If we've found a match and it's not the same filename where
|
||||
* we started, then we're done. */
|
||||
if (found != NULL && looking_at != selected)
|
||||
break;
|
||||
|
||||
/* We've finished processing the filenames, so get out. */
|
||||
if (search_last_file) {
|
||||
/* If we've found a match and we're back at the beginning, then
|
||||
* it's the only occurrence. */
|
||||
if (found != NULL && came_full_circle) {
|
||||
statusbar(_("This is the only occurrence"));
|
||||
break;
|
||||
}
|
||||
|
||||
if (came_full_circle) {
|
||||
/* We're back at the beginning and didn't find anything. */
|
||||
not_found_msg(needle);
|
||||
return FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Move to the next filename in the list. If we've reached the
|
||||
* end of the list, wrap around. */
|
||||
if (currselected < filelist_len - 1)
|
||||
currselected++;
|
||||
if (looking_at < filelist_len - 1)
|
||||
looking_at++;
|
||||
else {
|
||||
currselected = 0;
|
||||
looking_at = 0;
|
||||
statusbar(_("Search Wrapped"));
|
||||
}
|
||||
|
||||
/* We've reached the original starting file. */
|
||||
if (currselected == begin)
|
||||
search_last_file = TRUE;
|
||||
if (looking_at == selected)
|
||||
/* We've reached the original starting file. */
|
||||
came_full_circle = TRUE;
|
||||
|
||||
filetail = tail(filelist[currselected]);
|
||||
filetail = tail(filelist[looking_at]);
|
||||
|
||||
rev_start = filetail;
|
||||
}
|
||||
|
||||
/* We've definitely found something. */
|
||||
selected = currselected;
|
||||
/* Restore the settings of all flags. */
|
||||
memcpy(flags, stash, sizeof(flags));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Clear the flag indicating that a search reached the last file in the
|
||||
* list. We need to do this just before a new search. */
|
||||
void findnextfile_wrap_reset(void)
|
||||
{
|
||||
search_last_file = FALSE;
|
||||
}
|
||||
|
||||
/* Abort the current filename search. Clean up by setting the current
|
||||
* shortcut list to the browser shortcut list, and displaying it. */
|
||||
void filesearch_abort(void)
|
||||
{
|
||||
currmenu = MBROWSER;
|
||||
bottombars(MBROWSER);
|
||||
/* Select the one we've found. */
|
||||
selected = looking_at;
|
||||
}
|
||||
|
||||
/* Search for a filename. */
|
||||
void do_filesearch(void)
|
||||
{
|
||||
size_t begin = selected;
|
||||
bool didfind;
|
||||
|
||||
UNSET(CASE_SENSITIVE);
|
||||
UNSET(USE_REGEXP);
|
||||
UNSET(BACKWARDS_SEARCH);
|
||||
|
||||
if (filesearch_init() != 0) {
|
||||
/* Cancelled or a blank search string. */
|
||||
filesearch_abort();
|
||||
/* Cancelled, or a blank search string, or done something. */
|
||||
bottombars(MBROWSER);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -871,50 +846,18 @@ void do_filesearch(void)
|
||||
update_history(&search_history, answer);
|
||||
#endif
|
||||
|
||||
findnextfile_wrap_reset();
|
||||
didfind = findnextfile(FALSE, begin, answer);
|
||||
findnextfile(answer);
|
||||
|
||||
/* Check to see if there's only one occurrence of the string and
|
||||
* we're on it now. */
|
||||
if (selected == begin && didfind) {
|
||||
/* Do the search again, skipping over the current line. We
|
||||
* should only end up back at the same position if the string
|
||||
* isn't found again, in which case it's the only occurrence. */
|
||||
didfind = findnextfile(TRUE, begin, answer);
|
||||
if (selected == begin && !didfind)
|
||||
statusbar(_("This is the only occurrence"));
|
||||
}
|
||||
|
||||
filesearch_abort();
|
||||
bottombars(MBROWSER);
|
||||
}
|
||||
|
||||
/* Search for the last filename without prompting. */
|
||||
/* Search for the last given filename again without prompting. */
|
||||
void do_fileresearch(void)
|
||||
{
|
||||
size_t begin = selected;
|
||||
bool didfind;
|
||||
|
||||
search_init_globals();
|
||||
|
||||
if (last_search[0] != '\0') {
|
||||
findnextfile_wrap_reset();
|
||||
didfind = findnextfile(FALSE, begin, answer);
|
||||
|
||||
/* Check to see if there's only one occurrence of the string and
|
||||
* we're on it now. */
|
||||
if (selected == begin && didfind) {
|
||||
/* Do the search again, skipping over the current line. We
|
||||
* should only end up back at the same position if the
|
||||
* string isn't found again, in which case it's the only
|
||||
* occurrence. */
|
||||
didfind = findnextfile(TRUE, begin, answer);
|
||||
if (selected == begin && !didfind)
|
||||
statusbar(_("This is the only occurrence"));
|
||||
}
|
||||
} else
|
||||
statusbar(_("No current search pattern"));
|
||||
|
||||
filesearch_abort();
|
||||
if (last_search[0] == '\0')
|
||||
statusbar(_("No current search pattern"));
|
||||
else
|
||||
findnextfile(last_search);
|
||||
}
|
||||
|
||||
/* Select the first file in the list. */
|
||||
|
||||
10
src/chars.c
10
src/chars.c
@@ -484,12 +484,18 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
|
||||
* before the one at pos. */
|
||||
size_t move_mbleft(const char *buf, size_t pos)
|
||||
{
|
||||
size_t before = 0, char_len = 0;
|
||||
size_t before, char_len = 0;
|
||||
|
||||
assert(buf != NULL && pos <= strlen(buf));
|
||||
|
||||
/* There is no library function to move backward one multibyte
|
||||
* character. Here is the naive, O(pos) way to do it. */
|
||||
* character. So we just start groping for one at the farthest
|
||||
* possible point. */
|
||||
if (mb_cur_max() > pos)
|
||||
before = 0;
|
||||
else
|
||||
before = pos - mb_cur_max();
|
||||
|
||||
while (before < pos) {
|
||||
char_len = parse_mbchar(buf + before, NULL, NULL);
|
||||
before += char_len;
|
||||
|
||||
33
src/color.c
33
src/color.c
@@ -3,7 +3,7 @@
|
||||
* color.c *
|
||||
* *
|
||||
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, *
|
||||
* 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
|
||||
* 2010, 2011, 2013, 2014, 2015 Free Software Foundation, Inc. *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3, or (at your option) *
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_MAGIC_H
|
||||
#include <magic.h>
|
||||
@@ -69,10 +70,8 @@ void set_colorpairs(void)
|
||||
interface_color_pair[i].pairnum = A_NORMAL;
|
||||
}
|
||||
|
||||
if (specified_color_combo[i] != NULL) {
|
||||
free(specified_color_combo[i]);
|
||||
specified_color_combo[i] = NULL;
|
||||
}
|
||||
free(specified_color_combo[i]);
|
||||
specified_color_combo[i] = NULL;
|
||||
}
|
||||
|
||||
for (; this_syntax != NULL; this_syntax = this_syntax->next) {
|
||||
@@ -187,6 +186,21 @@ void color_update(void)
|
||||
* there was no syntax by that name, get the syntax based on the
|
||||
* file extension, then try the headerline, and then try magic. */
|
||||
if (openfile->colorstrings == NULL) {
|
||||
char *currentdir = getcwd(NULL, PATH_MAX + 1);
|
||||
char *joinednames = charalloc(PATH_MAX + 1);
|
||||
char *fullname = NULL;
|
||||
|
||||
if (currentdir != NULL) {
|
||||
/* Concatenate the current working directory with the
|
||||
* specified filename, and canonicalize the result. */
|
||||
sprintf(joinednames, "%s/%s", currentdir, openfile->filename);
|
||||
fullname = realpath(joinednames, NULL);
|
||||
free(currentdir);
|
||||
}
|
||||
|
||||
if (fullname == NULL)
|
||||
fullname = mallocstrcpy(fullname, openfile->filename);
|
||||
|
||||
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
|
||||
tmpsyntax = tmpsyntax->next) {
|
||||
|
||||
@@ -211,7 +225,7 @@ void color_update(void)
|
||||
}
|
||||
|
||||
/* Set colorstrings if we match the extension regex. */
|
||||
if (regexec(e->ext, openfile->filename, 0, NULL, 0) == 0) {
|
||||
if (regexec(e->ext, fullname, 0, NULL, 0) == 0) {
|
||||
openfile->syntax = tmpsyntax;
|
||||
openfile->colorstrings = tmpsyntax->color;
|
||||
break;
|
||||
@@ -224,6 +238,9 @@ void color_update(void)
|
||||
}
|
||||
}
|
||||
|
||||
free(joinednames);
|
||||
free(fullname);
|
||||
|
||||
/* Check the headerline if the extension didn't match anything. */
|
||||
if (openfile->colorstrings == NULL) {
|
||||
#ifdef DEBUG
|
||||
@@ -269,9 +286,9 @@ void color_update(void)
|
||||
/* Open the magic database and get a diagnosis of the file. */
|
||||
cookie = magic_open(MAGIC_SYMLINK |
|
||||
#ifdef DEBUG
|
||||
MAGIC_DEBUG | MAGIC_CHECK |
|
||||
MAGIC_DEBUG | MAGIC_CHECK |
|
||||
#endif
|
||||
MAGIC_ERROR);
|
||||
MAGIC_ERROR);
|
||||
if (cookie == NULL || magic_load(cookie, NULL) < 0)
|
||||
statusbar(_("magic_load() failed: %s"), strerror(errno));
|
||||
else {
|
||||
|
||||
@@ -219,10 +219,9 @@ void do_cut_text(
|
||||
|
||||
/* Leave the text in the cutbuffer, and mark the file as
|
||||
* modified. */
|
||||
if (!copy_text) {
|
||||
set_modified();
|
||||
}
|
||||
if (!copy_text)
|
||||
#endif /* !NANO_TINY */
|
||||
set_modified();
|
||||
|
||||
/* Update the screen. */
|
||||
edit_refresh_needed = TRUE;
|
||||
|
||||
295
src/files.c
295
src/files.c
@@ -126,6 +126,7 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
|
||||
pid_t mypid;
|
||||
uid_t myuid;
|
||||
struct passwd *mypwuid;
|
||||
struct stat fileinfo;
|
||||
char *lockdata = charalloc(1024);
|
||||
char myhostname[32];
|
||||
ssize_t lockdatalen = 1024;
|
||||
@@ -135,41 +136,45 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
|
||||
* old state. */
|
||||
myuid = geteuid();
|
||||
if ((mypwuid = getpwuid(myuid)) == NULL) {
|
||||
statusbar(_("Couldn't determine my identity for lock file (getpwuid() failed)"));
|
||||
return -1;
|
||||
statusbar(_("Couldn't determine my identity for lock file (getpwuid() failed)"));
|
||||
return -1;
|
||||
}
|
||||
mypid = getpid();
|
||||
|
||||
if (gethostname(myhostname, 31) < 0) {
|
||||
statusbar(_("Couldn't determine hostname for lock file: %s"), strerror(errno));
|
||||
return -1;
|
||||
statusbar(_("Couldn't determine hostname for lock file: %s"), strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (delete_lockfile(lockfilename) < 0)
|
||||
return -1;
|
||||
/* Check if the lock exists before we try to delete it...*/
|
||||
if (stat(lockfilename, &fileinfo) != -1)
|
||||
if (delete_lockfile(lockfilename) < 0)
|
||||
return -1;
|
||||
|
||||
if (ISSET(INSECURE_BACKUP))
|
||||
cflags = O_WRONLY | O_CREAT | O_APPEND;
|
||||
cflags = O_WRONLY | O_CREAT | O_APPEND;
|
||||
else
|
||||
cflags = O_WRONLY | O_CREAT | O_EXCL | O_APPEND;
|
||||
cflags = O_WRONLY | O_CREAT | O_EXCL | O_APPEND;
|
||||
|
||||
fd = open(lockfilename, cflags,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
|
||||
/* Maybe we just don't have write access. Don't stop us from
|
||||
* opening the file at all, just don't set the lock_filename and
|
||||
* return success. */
|
||||
if (fd < 0 && errno == EACCES)
|
||||
return 1;
|
||||
/* Maybe we just don't have write access. Print an error message
|
||||
* and continue. */
|
||||
if (fd < 0) {
|
||||
statusbar(_("Error writing lock file %s: %s"), lockfilename,
|
||||
strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Now we've got a safe file stream. If the previous open() call
|
||||
* failed, this will return NULL. */
|
||||
filestream = fdopen(fd, "wb");
|
||||
|
||||
if (fd < 0 || filestream == NULL) {
|
||||
statusbar(_("Error writing lock file %s: %s"), lockfilename,
|
||||
statusbar(_("Error writing lock file %s: %s"), lockfilename,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Okay, so at the moment we're following this state for how to
|
||||
@@ -190,23 +195,23 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
|
||||
* our lockfile' message in here...
|
||||
*
|
||||
* This is likely very wrong, so this is a WIP. */
|
||||
null_at(&lockdata, lockdatalen);
|
||||
memset(lockdata, 0, lockdatalen);
|
||||
lockdata[0] = 0x62;
|
||||
lockdata[1] = 0x30;
|
||||
lockdata[24] = mypid % 256;
|
||||
lockdata[25] = mypid / 256;
|
||||
snprintf(&lockdata[2], 10, "nano %s", VERSION);
|
||||
snprintf(&lockdata[2], 11, "nano %s", VERSION);
|
||||
strncpy(&lockdata[28], mypwuid->pw_name, 16);
|
||||
strncpy(&lockdata[68], myhostname, 31);
|
||||
strncpy(&lockdata[108], origfilename, 768);
|
||||
if (modified == TRUE)
|
||||
lockdata[1007] = 0x55;
|
||||
lockdata[1007] = 0x55;
|
||||
|
||||
wroteamt = fwrite(lockdata, sizeof(char), lockdatalen, filestream);
|
||||
if (wroteamt < lockdatalen) {
|
||||
statusbar(_("Error writing lock file %s: %s"),
|
||||
lockfilename, ferror(filestream));
|
||||
return -1;
|
||||
statusbar(_("Error writing lock file %s: %s"),
|
||||
lockfilename, ferror(filestream));
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -214,9 +219,9 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
|
||||
#endif
|
||||
|
||||
if (fclose(filestream) == EOF) {
|
||||
statusbar(_("Error writing lock file %s: %s"),
|
||||
lockfilename, strerror(errno));
|
||||
return -1;
|
||||
statusbar(_("Error writing lock file %s: %s"),
|
||||
lockfilename, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
openfile->lock_filename = lockfilename;
|
||||
@@ -229,9 +234,9 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
|
||||
int delete_lockfile(const char *lockfilename)
|
||||
{
|
||||
if (unlink(lockfilename) < 0 && errno != ENOENT) {
|
||||
statusbar(_("Error deleting lock file %s: %s"), lockfilename,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
statusbar(_("Error deleting lock file %s: %s"), lockfilename,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -248,53 +253,52 @@ int do_lockfile(const char *filename)
|
||||
+ strlen(locking_suffix) + 3;
|
||||
char *lockfilename = charalloc(lockfilesize);
|
||||
char *lockfiledir = NULL;
|
||||
char lockprog[12], lockuser[16];
|
||||
static char lockprog[11], lockuser[17];
|
||||
struct stat fileinfo;
|
||||
int lockfd, lockpid;
|
||||
|
||||
snprintf(lockfilename, lockfilesize, "%s/%s%s%s", lockdir,
|
||||
locking_prefix, lockbase, locking_suffix);
|
||||
locking_prefix, lockbase, locking_suffix);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "lock file name is %s\n", lockfilename);
|
||||
#endif
|
||||
if (stat(lockfilename, &fileinfo) != -1) {
|
||||
ssize_t readtot = 0;
|
||||
ssize_t readamt = 0;
|
||||
char *lockbuf = charalloc(8192);
|
||||
char *promptstr = charalloc(128);
|
||||
int ans;
|
||||
if ((lockfd = open(lockfilename, O_RDONLY)) < 0) {
|
||||
statusbar(_("Error opening lock file %s: %s"),
|
||||
lockfilename, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
do {
|
||||
readamt = read(lockfd, &lockbuf[readtot], BUFSIZ);
|
||||
readtot += readamt;
|
||||
} while (readtot < 8192 && readamt > 0);
|
||||
ssize_t readtot = 0;
|
||||
ssize_t readamt = 0;
|
||||
char *lockbuf = charalloc(8192);
|
||||
char *promptstr = charalloc(128);
|
||||
int ans;
|
||||
if ((lockfd = open(lockfilename, O_RDONLY)) < 0) {
|
||||
statusbar(_("Error opening lock file %s: %s"),
|
||||
lockfilename, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
do {
|
||||
readamt = read(lockfd, &lockbuf[readtot], BUFSIZ);
|
||||
readtot += readamt;
|
||||
} while (readtot < 8192 && readamt > 0);
|
||||
|
||||
if (readtot < 48) {
|
||||
statusbar(_("Error reading lock file %s: Not enough data read"),
|
||||
lockfilename);
|
||||
return -1;
|
||||
}
|
||||
strncpy(lockprog, &lockbuf[2], 10);
|
||||
lockpid = lockbuf[25] * 256 + lockbuf[24];
|
||||
strncpy(lockuser, &lockbuf[28], 16);
|
||||
if (readtot < 48) {
|
||||
statusbar(_("Error reading lock file %s: Not enough data read"),
|
||||
lockfilename);
|
||||
return -1;
|
||||
}
|
||||
strncpy(lockprog, &lockbuf[2], 10);
|
||||
lockpid = (unsigned char)lockbuf[25] * 256 + (unsigned char)lockbuf[24];
|
||||
strncpy(lockuser, &lockbuf[28], 16);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "lockpid = %d\n", lockpid);
|
||||
fprintf(stderr, "program name which created this lock file should be %s\n",
|
||||
lockprog);
|
||||
fprintf(stderr, "user which created this lock file should be %s\n",
|
||||
lockuser);
|
||||
fprintf(stderr, "lockpid = %d\n", lockpid);
|
||||
fprintf(stderr, "program name which created this lock file should be %s\n", lockprog);
|
||||
fprintf(stderr, "user which created this lock file should be %s\n", lockuser);
|
||||
#endif
|
||||
sprintf(promptstr, _("File is being edited (by %s, PID %d, user %s); continue?"),
|
||||
lockprog, lockpid, lockuser);
|
||||
ans = do_yesno_prompt(FALSE, promptstr);
|
||||
if (ans < 1) {
|
||||
blank_statusbar();
|
||||
return -1;
|
||||
}
|
||||
/* TRANSLATORS: The second %s is the name of the user, the third that of the editor. */
|
||||
sprintf(promptstr, _("File %s is being edited (by %s with %s, PID %d); continue?"),
|
||||
filename, lockuser, lockprog, lockpid);
|
||||
ans = do_yesno_prompt(FALSE, promptstr);
|
||||
if (ans < 1) {
|
||||
blank_statusbar();
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
lockfiledir = mallocstrcpy(NULL, lockfilename);
|
||||
lockfiledir = dirname(lockfiledir);
|
||||
@@ -305,7 +309,6 @@ int do_lockfile(const char *filename)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return write_lockfile(lockfilename, filename, FALSE);
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
@@ -314,6 +317,7 @@ int do_lockfile(const char *filename)
|
||||
* necessary, and then open and read the file, if applicable. */
|
||||
void open_buffer(const char *filename, bool undoable)
|
||||
{
|
||||
bool quiet = FALSE;
|
||||
bool new_buffer = (openfile == NULL
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
|| ISSET(MULTIBUFFER)
|
||||
@@ -337,13 +341,30 @@ void open_buffer(const char *filename, bool undoable)
|
||||
|
||||
/* If we're loading into a new buffer, add a new entry to
|
||||
* openfile. */
|
||||
if (new_buffer)
|
||||
if (new_buffer) {
|
||||
make_new_buffer();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(LOCKING) && filename[0] != '\0') {
|
||||
int lockstatus = do_lockfile(filename);
|
||||
if (lockstatus < 0) {
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
if (openfile->next) {
|
||||
close_buffer(TRUE);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
} else if (lockstatus == 0) {
|
||||
quiet = TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* 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(filename, new_buffer, &f) : -2;
|
||||
open_file(filename, new_buffer, quiet, &f) : -2;
|
||||
|
||||
/* If we have a file, and we're loading into a new buffer, update
|
||||
* the filename. */
|
||||
@@ -380,35 +401,25 @@ void open_buffer(const char *filename, bool undoable)
|
||||
}
|
||||
|
||||
#ifndef DISABLE_SPELLER
|
||||
/* If it's not "", filename is a file to open. We blow away the text of
|
||||
* the current buffer, and then open and read the file, if
|
||||
* applicable. Note that we skip the operating directory test when
|
||||
* doing this. */
|
||||
/* Blow away the text of the current buffer, and then open and read
|
||||
* the specified file into its place. */
|
||||
void replace_buffer(const char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
int rc;
|
||||
/* rc == -2 means that we have a new file. -1 means that the
|
||||
* open() failed. 0 means that the open() succeeded. */
|
||||
int descriptor;
|
||||
|
||||
assert(filename != NULL);
|
||||
assert(filename != NULL && filename[0] != '\0');
|
||||
|
||||
/* If the filename isn't blank, open the file. Otherwise, treat it
|
||||
* as a new file. */
|
||||
rc = (filename[0] != '\0') ? open_file(filename, TRUE, &f) : -2;
|
||||
/* Open the file quietly. */
|
||||
descriptor = open_file(filename, TRUE, FALSE, &f);
|
||||
|
||||
/* Reinitialize the text of the current buffer. */
|
||||
free_filestruct(openfile->fileage);
|
||||
initialize_buffer_text();
|
||||
|
||||
/* If we have a non-new file, read it in. */
|
||||
if (rc > 0)
|
||||
read_file(f, rc, filename, FALSE, TRUE);
|
||||
|
||||
/* Move back to the beginning of the first line of the buffer. */
|
||||
openfile->current = openfile->fileage;
|
||||
openfile->current_x = 0;
|
||||
openfile->placewewant = 0;
|
||||
/* If opening the file succeeded, read it in. */
|
||||
if (descriptor > 0)
|
||||
read_file(f, descriptor, filename, FALSE, TRUE);
|
||||
}
|
||||
#endif /* !DISABLE_SPELLER */
|
||||
|
||||
@@ -431,14 +442,15 @@ void display_buffer(void)
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
/* Switch to the next file buffer if next_buf is TRUE. Otherwise,
|
||||
* switch to the previous file buffer. */
|
||||
void switch_to_prevnext_buffer(bool next_buf)
|
||||
void switch_to_prevnext_buffer(bool next_buf, bool quiet)
|
||||
{
|
||||
assert(openfile != NULL);
|
||||
|
||||
/* If only one file buffer is open, indicate it on the statusbar and
|
||||
* get out. */
|
||||
if (openfile == openfile->next) {
|
||||
statusbar(_("No more open file buffers"));
|
||||
if (quiet == FALSE)
|
||||
statusbar(_("No more open file buffers"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -454,9 +466,10 @@ void switch_to_prevnext_buffer(bool next_buf)
|
||||
display_buffer();
|
||||
|
||||
/* Indicate the switch on the statusbar. */
|
||||
statusbar(_("Switched to %s"),
|
||||
((openfile->filename[0] == '\0') ? _("New Buffer") :
|
||||
openfile->filename));
|
||||
if (quiet == FALSE)
|
||||
statusbar(_("Switched to %s"),
|
||||
((openfile->filename[0] == '\0') ?
|
||||
_("New Buffer") : openfile->filename));
|
||||
|
||||
#ifdef DEBUG
|
||||
dump_filestruct(openfile->current);
|
||||
@@ -467,19 +480,21 @@ void switch_to_prevnext_buffer(bool next_buf)
|
||||
/* Switch to the previous entry in the openfile filebuffer. */
|
||||
void switch_to_prev_buffer_void(void)
|
||||
{
|
||||
switch_to_prevnext_buffer(FALSE);
|
||||
switch_to_prevnext_buffer(FALSE, FALSE);
|
||||
}
|
||||
|
||||
/* Switch to the next entry in the openfile filebuffer. */
|
||||
void switch_to_next_buffer_void(void)
|
||||
{
|
||||
switch_to_prevnext_buffer(TRUE);
|
||||
switch_to_prevnext_buffer(TRUE, FALSE);
|
||||
}
|
||||
|
||||
/* Delete an entry from the openfile filebuffer, and switch to the one
|
||||
* after it. Return TRUE on success, or FALSE if there are no more open
|
||||
* file buffers. */
|
||||
bool close_buffer(void)
|
||||
* file buffers.
|
||||
* quiet - should we print messages switching bufers
|
||||
*/
|
||||
bool close_buffer(bool quiet)
|
||||
{
|
||||
assert(openfile != NULL);
|
||||
|
||||
@@ -492,7 +507,7 @@ bool close_buffer(void)
|
||||
#endif
|
||||
|
||||
/* Switch to the next file buffer. */
|
||||
switch_to_next_buffer_void();
|
||||
switch_to_prevnext_buffer(TRUE, quiet);
|
||||
|
||||
/* Close the file buffer we had open before. */
|
||||
unlink_opennode(openfile->prev);
|
||||
@@ -527,17 +542,17 @@ int is_file_writable(const char *filename)
|
||||
full_filename = get_full_path(filename);
|
||||
|
||||
/* Okay, if we can't stat the path due to a component's
|
||||
permissions, just try the relative one. */
|
||||
if (full_filename == NULL
|
||||
|| (stat(full_filename, &fileinfo) == -1 && stat(filename, &fileinfo2) != -1))
|
||||
full_filename = mallocstrcpy(NULL, filename);
|
||||
*permissions, just try the relative one. */
|
||||
if (full_filename == NULL ||
|
||||
(stat(full_filename, &fileinfo) == -1 && stat(filename, &fileinfo2) != -1))
|
||||
full_filename = mallocstrcpy(NULL, filename);
|
||||
|
||||
if ((fd = open(full_filename, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR |
|
||||
S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) == -1
|
||||
|| (f = fdopen(fd, "a")) == NULL)
|
||||
S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) == -1 ||
|
||||
(f = fdopen(fd, "a")) == NULL)
|
||||
ans = FALSE;
|
||||
else
|
||||
fclose(f);
|
||||
fclose(f);
|
||||
close(fd);
|
||||
|
||||
free(full_filename);
|
||||
@@ -801,10 +816,8 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
|
||||
/* Move fileptr back one line and blow away the old fileptr,
|
||||
* since its text has been saved. */
|
||||
fileptr = fileptr->prev;
|
||||
if (fileptr != NULL) {
|
||||
if (fileptr->next != NULL)
|
||||
free(fileptr->next);
|
||||
}
|
||||
if (fileptr != NULL)
|
||||
free(fileptr->next);
|
||||
}
|
||||
|
||||
/* Attach the line at current after the line at fileptr. */
|
||||
@@ -888,10 +901,10 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
|
||||
* Return -2 if we say "New File", -1 if the file isn't opened, and the
|
||||
* fd opened otherwise. The file might still have an error while reading
|
||||
* with a 0 return value. *f is set to the opened file. */
|
||||
int open_file(const char *filename, bool newfie, FILE **f)
|
||||
int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
|
||||
{
|
||||
struct stat fileinfo, fileinfo2;
|
||||
int fd, quiet = 0;
|
||||
int fd;
|
||||
char *full_filename;
|
||||
|
||||
assert(filename != NULL && f != NULL);
|
||||
@@ -900,26 +913,16 @@ int open_file(const char *filename, bool newfie, FILE **f)
|
||||
full_filename = get_full_path(filename);
|
||||
|
||||
/* Okay, if we can't stat the path due to a component's
|
||||
permissions, just try the relative one. */
|
||||
* permissions, just try the relative one. */
|
||||
if (full_filename == NULL
|
||||
|| (stat(full_filename, &fileinfo) == -1 && stat(filename, &fileinfo2) != -1))
|
||||
full_filename = mallocstrcpy(NULL, filename);
|
||||
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(LOCKING)) {
|
||||
int lockstatus = do_lockfile(full_filename);
|
||||
if (lockstatus < 0)
|
||||
return -1;
|
||||
else if (lockstatus == 0)
|
||||
quiet = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (stat(full_filename, &fileinfo) == -1) {
|
||||
/* Well, maybe we can open the file even if the OS says it's
|
||||
* not there. */
|
||||
if ((fd = open(filename, O_RDONLY)) != -1) {
|
||||
if ((fd = open(filename, O_RDONLY)) != -1) {
|
||||
if (!quiet)
|
||||
statusbar(_("Reading File"));
|
||||
free(full_filename);
|
||||
@@ -948,7 +951,7 @@ int open_file(const char *filename, bool newfie, FILE **f)
|
||||
strerror(errno));
|
||||
beep();
|
||||
return -1;
|
||||
} else {
|
||||
} else {
|
||||
/* The file is A-OK. Open it. */
|
||||
*f = fdopen(fd, "rb");
|
||||
|
||||
@@ -972,20 +975,17 @@ int open_file(const char *filename, bool newfie, FILE **f)
|
||||
* extension exists, we return "". */
|
||||
char *get_next_filename(const char *name, const char *suffix)
|
||||
{
|
||||
static int ulmax_digits = -1;
|
||||
unsigned long i = 0;
|
||||
char *buf;
|
||||
size_t namelen, suffixlen;
|
||||
size_t wholenamelen;
|
||||
|
||||
assert(name != NULL && suffix != NULL);
|
||||
|
||||
if (ulmax_digits == -1)
|
||||
ulmax_digits = digits(ULONG_MAX);
|
||||
wholenamelen = strlen(name) + strlen(suffix);
|
||||
|
||||
namelen = strlen(name);
|
||||
suffixlen = strlen(suffix);
|
||||
|
||||
buf = charalloc(namelen + suffixlen + ulmax_digits + 2);
|
||||
/* Reserve space for: the name plus the suffix plus a dot plus
|
||||
* possibly five digits plus a null byte. */
|
||||
buf = charalloc(wholenamelen + 7);
|
||||
sprintf(buf, "%s%s", name, suffix);
|
||||
|
||||
while (TRUE) {
|
||||
@@ -993,11 +993,12 @@ char *get_next_filename(const char *name, const char *suffix)
|
||||
|
||||
if (stat(buf, &fs) == -1)
|
||||
return buf;
|
||||
if (i == ULONG_MAX)
|
||||
|
||||
/* Limit the number of backup files to a hundred thousand. */
|
||||
if (++i == 100000)
|
||||
break;
|
||||
|
||||
i++;
|
||||
sprintf(buf + namelen + suffixlen, ".%lu", i);
|
||||
sprintf(buf + wholenamelen, ".%lu", i);
|
||||
}
|
||||
|
||||
/* We get here only if there is no possible save file. Blank out
|
||||
@@ -1030,8 +1031,6 @@ void do_insertfile(
|
||||
bool right_side_up = FALSE, single_line = FALSE;
|
||||
#endif
|
||||
|
||||
currmenu = MINSERTFILE;
|
||||
|
||||
while (TRUE) {
|
||||
#ifndef NANO_TINY
|
||||
if (execute) {
|
||||
@@ -1439,8 +1438,7 @@ char *get_full_path(const char *origpath)
|
||||
}
|
||||
|
||||
/* Free d_there_file, since we're done using it. */
|
||||
if (d_there_file != NULL)
|
||||
free(d_there_file);
|
||||
free(d_there_file);
|
||||
|
||||
return d_there;
|
||||
}
|
||||
@@ -1596,11 +1594,11 @@ int prompt_failed_backupwrite(const char *filename)
|
||||
{
|
||||
static int i;
|
||||
static char *prevfile = NULL; /* What was the last file we were
|
||||
* passed so we don't keep asking
|
||||
* this? Though maybe we should... */
|
||||
* passed so we don't keep asking
|
||||
* this? Though maybe we should... */
|
||||
if (prevfile == NULL || strcmp(filename, prevfile)) {
|
||||
i = do_yesno_prompt(FALSE,
|
||||
_("Failed to write backup file, continue saving? (Say N if unsure) "));
|
||||
_("Failed to write backup file, continue saving? (Say N if unsure) "));
|
||||
prevfile = mallocstrcpy(prevfile, filename);
|
||||
}
|
||||
return i;
|
||||
@@ -1893,9 +1891,9 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
free(backupname);
|
||||
fclose(backup_file);
|
||||
/* If we can't write to the backup, DONT go on, since
|
||||
whatever caused the backup file to fail (e.g. disk
|
||||
full may well cause the real file write to fail, which
|
||||
means we could lose both the backup and the original! */
|
||||
* whatever caused the backup file to fail (e.g. disk
|
||||
* full may well cause the real file write to fail, which
|
||||
* means we could lose both the backup and the original! */
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
@@ -2162,8 +2160,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
|
||||
cleanup_and_exit:
|
||||
free(realname);
|
||||
if (tempname != NULL)
|
||||
free(tempname);
|
||||
free(tempname);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -2233,8 +2230,6 @@ bool do_writeout(bool exiting)
|
||||
#endif
|
||||
bool retval = FALSE;
|
||||
|
||||
currmenu = MWRITEFILE;
|
||||
|
||||
if (exiting && openfile->filename[0] != '\0' && ISSET(TEMP_FILE)) {
|
||||
retval = write_file(openfile->filename, NULL, FALSE, OVERWRITE,
|
||||
FALSE);
|
||||
@@ -2388,10 +2383,8 @@ bool do_writeout(bool exiting)
|
||||
* string's real length. */
|
||||
unsunder(answer, answer_len);
|
||||
|
||||
if (full_filename != NULL)
|
||||
free(full_filename);
|
||||
if (full_answer != NULL)
|
||||
free(full_answer);
|
||||
free(full_filename);
|
||||
free(full_answer);
|
||||
|
||||
if (do_warning) {
|
||||
/* If we're using restricted mode, we aren't allowed
|
||||
|
||||
250
src/global.c
250
src/global.c
@@ -30,18 +30,16 @@
|
||||
|
||||
/* Global variables. */
|
||||
#ifndef NANO_TINY
|
||||
sigjmp_buf jump_buf;
|
||||
/* Used to return to either main() or the unjustify routine in
|
||||
* do_justify() after a SIGWINCH. */
|
||||
bool jump_buf_main = FALSE;
|
||||
/* Have we set jump_buf so that we return to main() after a
|
||||
* SIGWINCH? */
|
||||
volatile sig_atomic_t sigwinch_counter = 0;
|
||||
/* Is incremented by the handler whenever a SIGWINCH occurs. */
|
||||
#endif
|
||||
|
||||
bool meta_key;
|
||||
/* Whether the current keystroke is a Meta key. */
|
||||
bool func_key;
|
||||
/* Whether the current keystroke is an extended keypad value. */
|
||||
bool focusing = FALSE;
|
||||
/* Whether an update of the edit window should center the cursor. */
|
||||
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
ssize_t fill = 0;
|
||||
@@ -137,9 +135,9 @@ char *backup_dir = NULL;
|
||||
/* The directory where we store backup files. */
|
||||
|
||||
const char *locking_prefix = ".";
|
||||
/* Prefix of how to store the vim-style lock file. */
|
||||
/* Prefix of how to store the vim-style lock file. */
|
||||
const char *locking_suffix = ".swp";
|
||||
/* Suffix of the vim-style lock file. */
|
||||
/* Suffix of the vim-style lock file. */
|
||||
#endif
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
char *operating_dir = NULL;
|
||||
@@ -223,7 +221,7 @@ size_t length_of_list(int menu)
|
||||
size_t i = 0;
|
||||
|
||||
for (f = allfuncs; f != NULL; f = f->next)
|
||||
if ((f->menus & menu) != 0
|
||||
if ((f->menus & menu) != 0
|
||||
#ifndef DISABLE_HELP
|
||||
&& strlen(f->help) > 0
|
||||
#endif
|
||||
@@ -374,7 +372,7 @@ int sc_seq_or(void (*func)(void), int defaultval)
|
||||
|
||||
if (s) {
|
||||
meta_key = (s->type == META);
|
||||
return s->seq;
|
||||
return s->seq;
|
||||
}
|
||||
/* else */
|
||||
return defaultval;
|
||||
@@ -409,16 +407,16 @@ key_type strtokeytype(const char *str)
|
||||
void assign_keyinfo(sc *s)
|
||||
{
|
||||
if (s->type == CONTROL) {
|
||||
assert(strlen(s->keystr) > 1);
|
||||
s->seq = s->keystr[1] - 64;
|
||||
assert(strlen(s->keystr) > 1);
|
||||
s->seq = s->keystr[1] - 64;
|
||||
} else if (s->type == META) {
|
||||
assert(strlen(s->keystr) > 2);
|
||||
s->seq = tolower((int) s->keystr[2]);
|
||||
assert(strlen(s->keystr) > 2);
|
||||
s->seq = tolower((int) s->keystr[2]);
|
||||
} else if (s->type == FKEY) {
|
||||
assert(strlen(s->keystr) > 1);
|
||||
s->seq = KEY_F0 + atoi(&s->keystr[1]);
|
||||
assert(strlen(s->keystr) > 1);
|
||||
s->seq = KEY_F0 + atoi(&s->keystr[1]);
|
||||
} else /* RAWINPUT */
|
||||
s->seq = (int) s->keystr[0];
|
||||
s->seq = (int) s->keystr[0];
|
||||
|
||||
/* Override some keys which don't bind as easily as we'd like. */
|
||||
if (s->type == CONTROL && (!strcasecmp(&s->keystr[1], "space")))
|
||||
@@ -488,12 +486,14 @@ const char *whereis_next_tag = N_("WhereIs Next");
|
||||
/* Initialize the list of functions and the list of shortcuts. */
|
||||
void shortcut_init(void)
|
||||
{
|
||||
/* TRANSLATORS: Try to keep the next eight strings at most 10 characters. */
|
||||
/* TRANSLATORS: Try to keep the next ten strings at most 10 characters. */
|
||||
const char *whereis_tag = N_("Where Is");
|
||||
const char *replace_tag = N_("Replace");
|
||||
const char *gotoline_tag = N_("Go To Line");
|
||||
const char *prev_line_tag = N_("Prev Line");
|
||||
const char *next_line_tag = N_("Next Line");
|
||||
const char *prev_page_tag = N_("Prev Page");
|
||||
const char *next_page_tag = N_("Next Page");
|
||||
const char *read_file_tag = N_("Read File");
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
const char *fulljustify_tag = N_("FullJstify");
|
||||
@@ -639,8 +639,10 @@ void shortcut_init(void)
|
||||
const char *nano_lint_msg = N_("Invoke the linter, if available");
|
||||
const char *nano_prevlint_msg = N_("Go to previous linter msg");
|
||||
const char *nano_nextlint_msg = N_("Go to next linter msg");
|
||||
#ifndef DISABLE_SPELLER
|
||||
const char *nano_formatter_msg = N_("Invoke formatter, if available");
|
||||
#endif
|
||||
#endif
|
||||
#endif /* !DISABLE_HELP */
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
@@ -650,9 +652,9 @@ void shortcut_init(void)
|
||||
#endif
|
||||
|
||||
while (allfuncs != NULL) {
|
||||
subnfunc *f = allfuncs;
|
||||
allfuncs = allfuncs->next;
|
||||
free(f);
|
||||
subnfunc *f = allfuncs;
|
||||
allfuncs = allfuncs->next;
|
||||
free(f);
|
||||
}
|
||||
|
||||
/* Start populating the different menus with functions. */
|
||||
@@ -735,9 +737,11 @@ void shortcut_init(void)
|
||||
|
||||
#ifndef DISABLE_COLOR
|
||||
add_to_funcs(do_linter, MMAIN,
|
||||
N_("To Linter"), IFSCHELP(nano_lint_msg), BLANKAFTER, NOVIEW);
|
||||
N_("To Linter"), IFSCHELP(nano_lint_msg), TOGETHER, NOVIEW);
|
||||
#ifndef DISABLE_SPELLER
|
||||
add_to_funcs(do_formatter, MMAIN,
|
||||
N_("Formatter"), IFSCHELP(nano_formatter_msg), TOGETHER, NOVIEW);
|
||||
N_("Formatter"), IFSCHELP(nano_formatter_msg), BLANKAFTER, NOVIEW);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -776,10 +780,10 @@ void shortcut_init(void)
|
||||
gotoline_tag, IFSCHELP(nano_gotoline_msg), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(do_page_up, MMAIN|MHELP|MBROWSER,
|
||||
N_("Prev Page"), IFSCHELP(nano_prevpage_msg), TOGETHER, VIEW);
|
||||
add_to_funcs(do_page_down, MMAIN|MHELP|MBROWSER,
|
||||
N_("Next Page"), IFSCHELP(nano_nextpage_msg), TOGETHER, VIEW);
|
||||
add_to_funcs(do_page_up, MMAIN|MHELP,
|
||||
prev_page_tag, IFSCHELP(nano_prevpage_msg), TOGETHER, VIEW);
|
||||
add_to_funcs(do_page_down, MMAIN|MHELP,
|
||||
next_page_tag, IFSCHELP(nano_nextpage_msg), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(do_first_line, MMAIN|MHELP|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE,
|
||||
N_("First Line"), IFSCHELP(nano_firstline_msg), TOGETHER, VIEW);
|
||||
@@ -924,28 +928,28 @@ void shortcut_init(void)
|
||||
* specified on the command line, and the fifth is useless since
|
||||
* backups are disabled. */
|
||||
if (!ISSET(RESTRICTED)) {
|
||||
add_to_funcs(dos_format_void, MWRITEFILE,
|
||||
N_("DOS Format"), IFSCHELP(nano_dos_msg), TOGETHER, NOVIEW);
|
||||
add_to_funcs(dos_format_void, MWRITEFILE,
|
||||
N_("DOS Format"), IFSCHELP(nano_dos_msg), TOGETHER, NOVIEW);
|
||||
|
||||
add_to_funcs(mac_format_void, MWRITEFILE,
|
||||
N_("Mac Format"), IFSCHELP(nano_mac_msg), TOGETHER, NOVIEW);
|
||||
add_to_funcs(mac_format_void, MWRITEFILE,
|
||||
N_("Mac Format"), IFSCHELP(nano_mac_msg), TOGETHER, NOVIEW);
|
||||
|
||||
add_to_funcs(append_void, MWRITEFILE,
|
||||
N_("Append"), IFSCHELP(nano_append_msg), TOGETHER, NOVIEW);
|
||||
add_to_funcs(prepend_void, MWRITEFILE,
|
||||
N_("Prepend"), IFSCHELP(nano_prepend_msg), TOGETHER, NOVIEW);
|
||||
add_to_funcs(append_void, MWRITEFILE,
|
||||
N_("Append"), IFSCHELP(nano_append_msg), TOGETHER, NOVIEW);
|
||||
add_to_funcs(prepend_void, MWRITEFILE,
|
||||
N_("Prepend"), IFSCHELP(nano_prepend_msg), TOGETHER, NOVIEW);
|
||||
|
||||
add_to_funcs(backup_file_void, MWRITEFILE,
|
||||
N_("Backup File"), IFSCHELP(nano_backup_msg), TOGETHER, NOVIEW);
|
||||
add_to_funcs(backup_file_void, MWRITEFILE,
|
||||
N_("Backup File"), IFSCHELP(nano_backup_msg), TOGETHER, NOVIEW);
|
||||
}
|
||||
|
||||
/* If we're using restricted mode, file insertion is disabled, and
|
||||
* thus command execution and the multibuffer toggle have no place. */
|
||||
if (!ISSET(RESTRICTED)) {
|
||||
add_to_funcs(flip_execute_void, MINSERTFILE,
|
||||
add_to_funcs(flip_execute_void, MINSERTFILE,
|
||||
N_("Execute Command"), IFSCHELP(nano_execute_msg), TOGETHER, NOVIEW);
|
||||
|
||||
add_to_funcs(flip_execute_void, MEXTCMD,
|
||||
add_to_funcs(flip_execute_void, MEXTCMD,
|
||||
read_file_tag, IFSCHELP(nano_insert_msg), TOGETHER, NOVIEW);
|
||||
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
@@ -960,10 +964,15 @@ void shortcut_init(void)
|
||||
add_to_funcs(to_files_void, MWRITEFILE|MINSERTFILE,
|
||||
N_("To Files"), IFSCHELP(nano_tofiles_msg), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(do_page_up, MBROWSER,
|
||||
prev_page_tag, IFSCHELP(nano_prevpage_msg), TOGETHER, VIEW);
|
||||
add_to_funcs(do_page_down, MBROWSER,
|
||||
next_page_tag, IFSCHELP(nano_nextpage_msg), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(do_first_file, (MBROWSER|MWHEREISFILE),
|
||||
N_("First File"), IFSCHELP(nano_firstfile_msg), TOGETHER, VIEW);
|
||||
add_to_funcs(do_last_file, (MBROWSER|MWHEREISFILE),
|
||||
N_("Last File"), IFSCHELP(nano_lastfile_msg), TOGETHER, VIEW);
|
||||
N_("Last File"), IFSCHELP(nano_lastfile_msg), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
#if !defined(NANO_TINY) && !defined(DISABLE_BROWSER)
|
||||
@@ -1010,8 +1019,6 @@ void shortcut_init(void)
|
||||
#ifndef DISABLE_COLOR
|
||||
add_to_sclist(MMAIN, "^T", do_linter, 0);
|
||||
add_to_sclist(MMAIN, "F12", do_linter, 0);
|
||||
add_to_sclist(MMAIN, "^T", do_formatter, 0);
|
||||
add_to_sclist(MMAIN, "F12", do_formatter, 0);
|
||||
#endif
|
||||
#endif
|
||||
add_to_sclist(MMAIN, "^C", do_cursorpos_void, 0);
|
||||
@@ -1019,12 +1026,12 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN, "^_", do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN, "M-G", do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN, "F13", do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE|MLINTER, "^Y", do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE|MLINTER, "F7", do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE|MLINTER, "PgUp", do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE|MLINTER, "^V", do_page_down, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE|MLINTER, "F8", do_page_down, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE|MLINTER, "PgDn", do_page_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^Y", do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F7", do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgUp", do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^V", do_page_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F8", do_page_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgDn", do_page_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-\\", do_first_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-|", do_first_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-/", do_last_line, 0);
|
||||
@@ -1051,10 +1058,10 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMOST, "M-Space", do_prev_word_void, 0);
|
||||
add_to_sclist(MMOST, "^Space", do_next_word_void, 0);
|
||||
#endif
|
||||
add_to_sclist(MMOST, "^A", do_home, 0);
|
||||
add_to_sclist(MMOST, "Home", do_home, 0);
|
||||
add_to_sclist(MMOST, "^E", do_end, 0);
|
||||
add_to_sclist(MMOST, "End", do_end, 0);
|
||||
add_to_sclist((MMOST & ~MBROWSER), "^A", do_home, 0);
|
||||
add_to_sclist((MMOST & ~MBROWSER), "Home", do_home, 0);
|
||||
add_to_sclist((MMOST & ~MBROWSER), "^E", do_end, 0);
|
||||
add_to_sclist((MMOST & ~MBROWSER), "End", do_end, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "^P", do_up_void, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "Up", do_up_void, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "^N", do_down_void, 0);
|
||||
@@ -1147,13 +1154,17 @@ void shortcut_init(void)
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Down", get_history_newer_void, 0);
|
||||
#endif
|
||||
#ifndef DISABLE_BROWSER
|
||||
add_to_sclist(MWHEREISFILE, "^Y", do_first_file, 0);
|
||||
add_to_sclist(MWHEREISFILE, "^V", do_last_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-\\", do_first_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", do_first_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-/", do_last_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", do_last_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "^_", goto_dir_void, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-G", goto_dir_void, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "F13", goto_dir_void, 0);
|
||||
add_to_sclist(MBROWSER, "Home", do_first_file, 0);
|
||||
add_to_sclist(MBROWSER, "End", do_last_file, 0);
|
||||
add_to_sclist(MBROWSER, "^_", goto_dir_void, 0);
|
||||
add_to_sclist(MBROWSER, "M-G", goto_dir_void, 0);
|
||||
add_to_sclist(MBROWSER, "F13", goto_dir_void, 0);
|
||||
#endif
|
||||
add_to_sclist(MWRITEFILE, "M-D", dos_format_void, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-M", mac_format_void, 0);
|
||||
@@ -1168,6 +1179,8 @@ void shortcut_init(void)
|
||||
add_to_sclist(MHELP|MBROWSER, "^C", do_exit, 0);
|
||||
#ifndef DISABLE_HELP
|
||||
add_to_sclist(MHELP, "^G", do_exit, 0);
|
||||
add_to_sclist(MHELP, "Home", do_first_line, 0);
|
||||
add_to_sclist(MHELP, "End", do_last_line, 0);
|
||||
#endif
|
||||
add_to_sclist(MMOST, "^I", do_tab, 0);
|
||||
add_to_sclist(MMOST, "^M", do_enter_void, 0);
|
||||
@@ -1221,44 +1234,44 @@ const subnfunc *sctofunc(sc *s)
|
||||
const char *flagtostr(int flag)
|
||||
{
|
||||
switch (flag) {
|
||||
case NO_HELP:
|
||||
/* TRANSLATORS: The next seventeen strings are toggle descriptions;
|
||||
* they are best kept shorter than 40 characters, but may be longer. */
|
||||
return N_("Help mode");
|
||||
case CONST_UPDATE:
|
||||
return N_("Constant cursor position display");
|
||||
case MORE_SPACE:
|
||||
return N_("Use of one more line for editing");
|
||||
case SMOOTH_SCROLL:
|
||||
return N_("Smooth scrolling");
|
||||
case SOFTWRAP:
|
||||
return N_("Soft wrapping of overlong lines");
|
||||
case WHITESPACE_DISPLAY:
|
||||
return N_("Whitespace display");
|
||||
case NO_COLOR_SYNTAX:
|
||||
return N_("Color syntax highlighting");
|
||||
case SMART_HOME:
|
||||
return N_("Smart home key");
|
||||
case AUTOINDENT:
|
||||
return N_("Auto indent");
|
||||
case CUT_TO_END:
|
||||
return N_("Cut to end");
|
||||
case NO_WRAP:
|
||||
return N_("Hard wrapping of overlong lines");
|
||||
case TABS_TO_SPACES:
|
||||
return N_("Conversion of typed tabs to spaces");
|
||||
case BACKUP_FILE:
|
||||
return N_("Backup files");
|
||||
case MULTIBUFFER:
|
||||
return N_("Multiple file buffers");
|
||||
case USE_MOUSE:
|
||||
return N_("Mouse support");
|
||||
case NO_CONVERT:
|
||||
return N_("No conversion from DOS/Mac format");
|
||||
case SUSPEND:
|
||||
return N_("Suspension");
|
||||
default:
|
||||
return "?????";
|
||||
case NO_HELP:
|
||||
/* TRANSLATORS: The next seventeen strings are toggle descriptions;
|
||||
* they are best kept shorter than 40 characters, but may be longer. */
|
||||
return N_("Help mode");
|
||||
case CONST_UPDATE:
|
||||
return N_("Constant cursor position display");
|
||||
case MORE_SPACE:
|
||||
return N_("Use of one more line for editing");
|
||||
case SMOOTH_SCROLL:
|
||||
return N_("Smooth scrolling");
|
||||
case SOFTWRAP:
|
||||
return N_("Soft wrapping of overlong lines");
|
||||
case WHITESPACE_DISPLAY:
|
||||
return N_("Whitespace display");
|
||||
case NO_COLOR_SYNTAX:
|
||||
return N_("Color syntax highlighting");
|
||||
case SMART_HOME:
|
||||
return N_("Smart home key");
|
||||
case AUTOINDENT:
|
||||
return N_("Auto indent");
|
||||
case CUT_TO_END:
|
||||
return N_("Cut to end");
|
||||
case NO_WRAP:
|
||||
return N_("Hard wrapping of overlong lines");
|
||||
case TABS_TO_SPACES:
|
||||
return N_("Conversion of typed tabs to spaces");
|
||||
case BACKUP_FILE:
|
||||
return N_("Backup files");
|
||||
case MULTIBUFFER:
|
||||
return N_("Reading file into separate buffer");
|
||||
case USE_MOUSE:
|
||||
return N_("Mouse support");
|
||||
case NO_CONVERT:
|
||||
return N_("No conversion from DOS/Mac format");
|
||||
case SUSPEND:
|
||||
return N_("Suspension");
|
||||
default:
|
||||
return "?????";
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
@@ -1310,6 +1323,10 @@ sc *strtosc(char *input)
|
||||
else if (!strcasecmp(input, "tospell") ||
|
||||
!strcasecmp(input, "speller"))
|
||||
s->scfunc = do_spell;
|
||||
#endif
|
||||
#ifndef DISABLE_COLOR
|
||||
else if (!strcasecmp(input, "linter"))
|
||||
s->scfunc = do_linter;
|
||||
#endif
|
||||
else if (!strcasecmp(input, "curpos") ||
|
||||
!strcasecmp(input, "cursorpos"))
|
||||
@@ -1528,7 +1545,7 @@ int strtomenu(char *input)
|
||||
return MHELP;
|
||||
#endif
|
||||
#ifndef DISABLE_SPELLER
|
||||
else if (!strcasecmp(input, "spell") || !strcasecmp(input, "formatter"))
|
||||
else if (!strcasecmp(input, "spell"))
|
||||
return MSPELL;
|
||||
#endif
|
||||
else if (!strcasecmp(input, "linter"))
|
||||
@@ -1559,34 +1576,25 @@ void thanks_for_all_the_fish(void)
|
||||
delwin(bottomwin);
|
||||
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
if (quotestr != NULL)
|
||||
free(quotestr);
|
||||
free(quotestr);
|
||||
#ifdef HAVE_REGEX_H
|
||||
regfree("ereg);
|
||||
if (quoteerr != NULL)
|
||||
free(quoteerr);
|
||||
free(quoteerr);
|
||||
#endif
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
if (backup_dir != NULL)
|
||||
free(backup_dir);
|
||||
free(backup_dir);
|
||||
#endif
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
if (operating_dir != NULL)
|
||||
free(operating_dir);
|
||||
if (full_operating_dir != NULL)
|
||||
free(full_operating_dir);
|
||||
free(operating_dir);
|
||||
free(full_operating_dir);
|
||||
#endif
|
||||
if (last_search != NULL)
|
||||
free(last_search);
|
||||
if (last_replace != NULL)
|
||||
free(last_replace);
|
||||
free(answer);
|
||||
free(last_search);
|
||||
free(last_replace);
|
||||
#ifndef DISABLE_SPELLER
|
||||
if (alt_speller != NULL)
|
||||
free(alt_speller);
|
||||
free(alt_speller);
|
||||
#endif
|
||||
if (answer != NULL)
|
||||
free(answer);
|
||||
if (cutbuffer != NULL)
|
||||
free_filestruct(cutbuffer);
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
@@ -1597,8 +1605,7 @@ void thanks_for_all_the_fish(void)
|
||||
if (openfile != NULL)
|
||||
free_openfilestruct(openfile);
|
||||
#ifndef DISABLE_COLOR
|
||||
if (syntaxstr != NULL)
|
||||
free(syntaxstr);
|
||||
free(syntaxstr);
|
||||
while (syntaxes != NULL) {
|
||||
syntaxtype *bill = syntaxes;
|
||||
|
||||
@@ -1663,18 +1670,17 @@ void thanks_for_all_the_fish(void)
|
||||
#endif
|
||||
/* Free the functions and shortcuts lists. */
|
||||
while (allfuncs != NULL) {
|
||||
subnfunc *f = allfuncs;
|
||||
allfuncs = allfuncs->next;
|
||||
free(f);
|
||||
subnfunc *f = allfuncs;
|
||||
allfuncs = allfuncs->next;
|
||||
free(f);
|
||||
}
|
||||
while (sclist != NULL) {
|
||||
sc *s = sclist;
|
||||
sclist = sclist->next;
|
||||
free(s);
|
||||
sc *s = sclist;
|
||||
sclist = sclist->next;
|
||||
free(s);
|
||||
}
|
||||
#ifndef DISABLE_NANORC
|
||||
if (homedir != NULL)
|
||||
free(homedir);
|
||||
free(homedir);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
43
src/help.c
43
src/help.c
@@ -62,10 +62,6 @@ void do_help(void (*refresh_func)(void))
|
||||
|
||||
assert(help_text != NULL);
|
||||
|
||||
/* Set currmenu to allow clicking on the help screen's shortcut
|
||||
* list, after help_init() is called. */
|
||||
currmenu = MHELP;
|
||||
|
||||
if (ISSET(NO_HELP)) {
|
||||
/* Make sure that the help screen's shortcut list will actually
|
||||
* be displayed. */
|
||||
@@ -76,20 +72,21 @@ void do_help(void (*refresh_func)(void))
|
||||
bottombars(MHELP);
|
||||
wnoutrefresh(bottomwin);
|
||||
|
||||
/* Get the last line of the help text. */
|
||||
ptr = help_text;
|
||||
|
||||
for (; *ptr != '\0'; last_line++) {
|
||||
ptr += help_line_len(ptr);
|
||||
if (*ptr == '\n')
|
||||
ptr++;
|
||||
}
|
||||
if (last_line > 0)
|
||||
last_line--;
|
||||
|
||||
while (TRUE) {
|
||||
size_t i;
|
||||
|
||||
/* Get the last line of the help text. */
|
||||
ptr = 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--;
|
||||
|
||||
/* Display the help text if we don't have a key, or if the help
|
||||
* text has moved. */
|
||||
if (kbinput == ERR || line != old_line) {
|
||||
@@ -121,6 +118,14 @@ void do_help(void (*refresh_func)(void))
|
||||
|
||||
kbinput = get_kbinput(edit);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (kbinput == KEY_WINCH) {
|
||||
kbinput = ERR;
|
||||
curs_set(0);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
if (kbinput == KEY_MOUSE) {
|
||||
int mouse_x, mouse_y;
|
||||
@@ -158,15 +163,14 @@ void do_help(void (*refresh_func)(void))
|
||||
}
|
||||
}
|
||||
|
||||
currmenu = oldmenu;
|
||||
|
||||
if (old_no_help) {
|
||||
blank_bottombars();
|
||||
wnoutrefresh(bottomwin);
|
||||
currmenu = oldmenu;
|
||||
SET(NO_HELP);
|
||||
window_init();
|
||||
} else
|
||||
bottombars(currmenu);
|
||||
bottombars(oldmenu);
|
||||
|
||||
curs_set(1);
|
||||
refresh_func();
|
||||
@@ -383,8 +387,7 @@ void help_init(void)
|
||||
|
||||
/* help_text has been freed and set to NULL unless the user resized
|
||||
* while in the help screen. */
|
||||
if (help_text != NULL)
|
||||
free(help_text);
|
||||
free(help_text);
|
||||
|
||||
/* Allocate space for the help text. */
|
||||
help_text = charalloc(allocsize + 1);
|
||||
|
||||
12
src/move.c
12
src/move.c
@@ -471,7 +471,7 @@ void do_home(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (need_horizontal_update(pww_save))
|
||||
if (need_screen_update(pww_save))
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
}
|
||||
|
||||
@@ -483,7 +483,7 @@ void do_end(void)
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
if (need_horizontal_update(pww_save))
|
||||
if (need_screen_update(pww_save))
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
}
|
||||
|
||||
@@ -534,7 +534,7 @@ void do_up(
|
||||
* needs to be redrawn if we're not on the first page, and the
|
||||
* latter needs to be drawn unconditionally. */
|
||||
if (openfile->current_y > 0) {
|
||||
if (need_vertical_update(0))
|
||||
if (need_screen_update(0))
|
||||
update_line(openfile->current->next, 0);
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
}
|
||||
@@ -632,7 +632,7 @@ void do_down(
|
||||
|| ISSET(SOFTWRAP)
|
||||
#endif
|
||||
) {
|
||||
if (need_vertical_update(0))
|
||||
if (need_screen_update(0))
|
||||
update_line(openfile->current->prev, 0);
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
}
|
||||
@@ -671,7 +671,7 @@ void do_left(void)
|
||||
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
if (need_horizontal_update(pww_save))
|
||||
if (need_screen_update(pww_save))
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
}
|
||||
|
||||
@@ -692,6 +692,6 @@ void do_right(void)
|
||||
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
if (need_horizontal_update(pww_save))
|
||||
if (need_screen_update(pww_save))
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
}
|
||||
|
||||
160
src/nano.c
160
src/nano.c
@@ -25,7 +25,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
@@ -124,14 +123,10 @@ void delete_node(filestruct *fileptr)
|
||||
{
|
||||
assert(fileptr != NULL && fileptr->data != NULL);
|
||||
|
||||
if (fileptr->data != NULL)
|
||||
free(fileptr->data);
|
||||
|
||||
free(fileptr->data);
|
||||
#ifndef DISABLE_COLOR
|
||||
if (fileptr->multidata)
|
||||
free(fileptr->multidata);
|
||||
free(fileptr->multidata);
|
||||
#endif
|
||||
|
||||
free(fileptr);
|
||||
}
|
||||
|
||||
@@ -178,7 +173,8 @@ void renumber(filestruct *fileptr)
|
||||
{
|
||||
ssize_t line;
|
||||
|
||||
assert(fileptr != NULL);
|
||||
if (fileptr == NULL)
|
||||
return;
|
||||
|
||||
line = (fileptr->prev == NULL) ? 0 : fileptr->prev->lineno;
|
||||
|
||||
@@ -365,8 +361,7 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
|
||||
|
||||
/* Renumber starting with the line after the original
|
||||
* file_bot. */
|
||||
if (file_bot_save->next != NULL)
|
||||
renumber(file_bot_save->next);
|
||||
renumber(file_bot_save->next);
|
||||
}
|
||||
|
||||
/* Since the text has now been saved, remove it from the
|
||||
@@ -556,7 +551,8 @@ void splice_opennode(openfilestruct *begin, openfilestruct *newnode,
|
||||
/* Unlink a node from the rest of the openfilestruct, and delete it. */
|
||||
void unlink_opennode(openfilestruct *fileptr)
|
||||
{
|
||||
assert(fileptr != NULL && fileptr->prev != NULL && fileptr->next != NULL && fileptr != fileptr->prev && fileptr != fileptr->next);
|
||||
assert(fileptr != NULL && fileptr->prev != NULL && fileptr->next != NULL &&
|
||||
fileptr != fileptr->prev && fileptr != fileptr->next);
|
||||
|
||||
fileptr->prev->next = fileptr->next;
|
||||
fileptr->next->prev = fileptr->prev;
|
||||
@@ -572,10 +568,8 @@ void delete_opennode(openfilestruct *fileptr)
|
||||
free(fileptr->filename);
|
||||
free_filestruct(fileptr->fileage);
|
||||
#ifndef NANO_TINY
|
||||
if (fileptr->current_stat != NULL)
|
||||
free(fileptr->current_stat);
|
||||
free(fileptr->current_stat);
|
||||
#endif
|
||||
|
||||
free(fileptr);
|
||||
}
|
||||
|
||||
@@ -719,9 +713,9 @@ void die_save_file(const char *die_filename
|
||||
_("Too many backup files?"));
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Try and chmod/chown the save file to the values of the original file, but
|
||||
dont worry if it fails because we're supposed to be bailing as fast
|
||||
as possible. */
|
||||
/* Try and chmod/chown the save file to the values of the original file,
|
||||
* but don't worry if it fails because we're supposed to be bailing as
|
||||
* fast as possible. */
|
||||
if (die_stat) {
|
||||
int shush;
|
||||
shush = chmod(retval, die_stat->st_mode);
|
||||
@@ -851,26 +845,23 @@ void usage(void)
|
||||
print_opt(_("-C <dir>"), _("--backupdir=<dir>"),
|
||||
N_("Directory for saving unique backup files"));
|
||||
#endif
|
||||
print_opt("-D", "--boldtext",
|
||||
N_("Use bold instead of reverse video text"));
|
||||
print_opt("-D", "--boldtext", N_("Use bold instead of reverse video text"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-E", "--tabstospaces",
|
||||
N_("Convert typed tabs to spaces"));
|
||||
print_opt("-E", "--tabstospaces", N_("Convert typed tabs to spaces"));
|
||||
#endif
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
print_opt("-F", "--multibuffer", N_("Enable multiple file buffers"));
|
||||
print_opt("-F", "--multibuffer",
|
||||
N_("Read a file into a new buffer by default"));
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-G", "--locking",
|
||||
N_("Use (vim-style) lock files"));
|
||||
print_opt("-G", "--locking", N_("Use (vim-style) lock files"));
|
||||
#endif
|
||||
#ifndef DISABLE_HISTORIES
|
||||
print_opt("-H", "--historylog",
|
||||
N_("Log & read search/replace string history"));
|
||||
#endif
|
||||
#ifndef DISABLE_NANORC
|
||||
print_opt("-I", "--ignorercfiles",
|
||||
N_("Don't look at nanorc files"));
|
||||
print_opt("-I", "--ignorercfiles", N_("Don't look at nanorc files"));
|
||||
#endif
|
||||
print_opt("-K", "--rebindkeypad",
|
||||
N_("Fix numeric keypad key confusion problem"));
|
||||
@@ -882,25 +873,21 @@ void usage(void)
|
||||
#endif
|
||||
print_opt("-O", "--morespace", N_("Use one more line for editing"));
|
||||
#ifndef DISABLE_HISTORIES
|
||||
print_opt("-P", "--poslog",
|
||||
N_("Log & read location of cursor position"));
|
||||
print_opt("-P", "--poslog", N_("Log & read location of cursor position"));
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
print_opt(_("-Q <str>"), _("--quotestr=<str>"),
|
||||
N_("Quoting string"));
|
||||
print_opt(_("-Q <str>"), _("--quotestr=<str>"), N_("Quoting string"));
|
||||
#endif
|
||||
print_opt("-R", "--restricted", N_("Restricted mode"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-S", "--smooth",
|
||||
N_("Scroll by line instead of half-screen"));
|
||||
print_opt("-S", "--smooth", N_("Scroll by line instead of half-screen"));
|
||||
#endif
|
||||
print_opt(_("-T <#cols>"), _("--tabsize=<#cols>"),
|
||||
N_("Set width of a tab to #cols columns"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-U", "--quickblank", N_("Do quick statusbar blanking"));
|
||||
#endif
|
||||
print_opt("-V", "--version",
|
||||
N_("Print version information and exit"));
|
||||
print_opt("-V", "--version", N_("Print version information and exit"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-W", "--wordbounds",
|
||||
N_("Detect word boundaries more accurately"));
|
||||
@@ -914,12 +901,10 @@ void usage(void)
|
||||
N_("Fix Backspace/Delete confusion problem"));
|
||||
print_opt("-h", "--help", N_("Show this help text"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-i", "--autoindent",
|
||||
N_("Automatically indent new lines"));
|
||||
print_opt("-i", "--autoindent", N_("Automatically indent new lines"));
|
||||
print_opt("-k", "--cut", N_("Cut from cursor to end of line"));
|
||||
#endif
|
||||
print_opt("-l", "--nofollow",
|
||||
N_("Don't follow symbolic links, overwrite"));
|
||||
print_opt("-l", "--nofollow", N_("Don't follow symbolic links, overwrite"));
|
||||
#ifndef DISABLE_MOUSE
|
||||
print_opt("-m", "--mouse", N_("Enable the use of the mouse"));
|
||||
#endif
|
||||
@@ -928,8 +913,7 @@ void usage(void)
|
||||
print_opt(_("-o <dir>"), _("--operatingdir=<dir>"),
|
||||
N_("Set operating directory"));
|
||||
#endif
|
||||
print_opt("-p", "--preserve",
|
||||
N_("Preserve XON (^Q) and XOFF (^S) keys"));
|
||||
print_opt("-p", "--preserve", N_("Preserve XON (^Q) and XOFF (^S) keys"));
|
||||
#ifndef DISABLE_NANORC
|
||||
print_opt("-q", "--quiet",
|
||||
N_("Silently ignore startup issues like rc file errors"));
|
||||
@@ -942,8 +926,7 @@ void usage(void)
|
||||
print_opt(_("-s <prog>"), _("--speller=<prog>"),
|
||||
N_("Enable alternate speller"));
|
||||
#endif
|
||||
print_opt("-t", "--tempfile",
|
||||
N_("Auto save on exit, don't prompt"));
|
||||
print_opt("-t", "--tempfile", N_("Auto save on exit, don't prompt"));
|
||||
print_opt("-v", "--view", N_("View mode (read-only)"));
|
||||
#ifndef DISABLE_WRAPPING
|
||||
print_opt("-w", "--nowrap", N_("Don't hard-wrap long lines"));
|
||||
@@ -960,9 +943,8 @@ void usage(void)
|
||||
* it was compiled with. */
|
||||
void version(void)
|
||||
{
|
||||
printf(_(" GNU nano version %s (compiled %s, %s)\n"), VERSION,
|
||||
__TIME__, __DATE__);
|
||||
printf(" (C) 1999..2014 Free Software Foundation, Inc.\n");
|
||||
printf(_(" GNU nano, version %s\n"), VERSION);
|
||||
printf(" (C) 1999..2015 Free Software Foundation, Inc.\n");
|
||||
printf(
|
||||
_(" Email: nano@nano-editor.org Web: http://www.nano-editor.org/"));
|
||||
printf(_("\n Compiled options:"));
|
||||
@@ -1146,13 +1128,13 @@ void do_exit(void)
|
||||
if (i == 0 || (i == 1 && do_writeout(TRUE))) {
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(LOCKING) && openfile->lock_filename)
|
||||
delete_lockfile(openfile->lock_filename);
|
||||
if (ISSET(LOCKING) && openfile->lock_filename)
|
||||
delete_lockfile(openfile->lock_filename);
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
/* Exit only if there are no more open file buffers. */
|
||||
if (!close_buffer())
|
||||
if (!close_buffer(FALSE))
|
||||
#endif
|
||||
finish();
|
||||
/* If the user canceled, we go on. */
|
||||
@@ -1168,9 +1150,12 @@ void do_cancel(void)
|
||||
;
|
||||
}
|
||||
|
||||
static struct sigaction pager_oldaction, pager_newaction; /* Original and temporary handlers for SIGINT. */
|
||||
static bool pager_sig_failed = FALSE; /* Did sigaction() fail without changing the signal handlers? */
|
||||
static bool pager_input_aborted = FALSE; /* Did someone invoke the pager and abort it via ^C? */
|
||||
static struct sigaction pager_oldaction, pager_newaction;
|
||||
/* Original and temporary handlers for SIGINT. */
|
||||
static bool pager_sig_failed = FALSE;
|
||||
/* Did sigaction() fail without changing the signal handlers? */
|
||||
static bool pager_input_aborted = FALSE;
|
||||
/* Did someone invoke the pager and abort it via ^C? */
|
||||
|
||||
/* Things which need to be run regardless of whether
|
||||
* we finished the stdin pipe correctly or not. */
|
||||
@@ -1181,20 +1166,20 @@ void finish_stdin_pager(void)
|
||||
|
||||
/* Read whatever we did get from stdin. */
|
||||
f = fopen("/dev/stdin", "rb");
|
||||
if (f == NULL)
|
||||
nperror("fopen");
|
||||
if (f == NULL)
|
||||
nperror("fopen");
|
||||
|
||||
read_file(f, 0, "stdin", TRUE, FALSE);
|
||||
ttystdin = open("/dev/tty", O_RDONLY);
|
||||
if (!ttystdin)
|
||||
die(_("Couldn't reopen stdin from keyboard, sorry\n"));
|
||||
die(_("Couldn't reopen stdin from keyboard, sorry\n"));
|
||||
|
||||
dup2(ttystdin,0);
|
||||
close(ttystdin);
|
||||
if (!pager_input_aborted)
|
||||
tcgetattr(0, &oldterm);
|
||||
if (!pager_sig_failed && sigaction(SIGINT, &pager_oldaction, NULL) == -1)
|
||||
nperror("sigaction");
|
||||
nperror("sigaction");
|
||||
terminal_init();
|
||||
doupdate();
|
||||
}
|
||||
@@ -1202,7 +1187,6 @@ void finish_stdin_pager(void)
|
||||
/* Cancel reading from stdin like a pager. */
|
||||
RETSIGTYPE cancel_stdin_pager(int signal)
|
||||
{
|
||||
/* Currently do nothing, just handle the intr silently. */
|
||||
pager_input_aborted = TRUE;
|
||||
}
|
||||
|
||||
@@ -1214,13 +1198,13 @@ void stdin_pager(void)
|
||||
tcsetattr(0, TCSANOW, &oldterm);
|
||||
fprintf(stderr, _("Reading from stdin, ^C to abort\n"));
|
||||
|
||||
/* Set things up so that Ctrl-C will cancel the new process. */
|
||||
/* Enable interpretation of the special control keys so that
|
||||
* we get SIGINT when Ctrl-C is pressed. */
|
||||
#ifndef NANO_TINY
|
||||
enable_signals();
|
||||
#endif
|
||||
|
||||
/* Set things up so that SIGINT will cancel the new process. */
|
||||
if (sigaction(SIGINT, NULL, &pager_newaction) == -1) {
|
||||
pager_sig_failed = TRUE;
|
||||
nperror("sigaction");
|
||||
@@ -1239,8 +1223,7 @@ void stdin_pager(void)
|
||||
/* Initialize the signal handlers. */
|
||||
void signal_init(void)
|
||||
{
|
||||
/* Trap SIGINT and SIGQUIT because we want them to do useful
|
||||
* things. */
|
||||
/* Trap SIGINT and SIGQUIT because we want them to do useful things. */
|
||||
memset(&act, 0, sizeof(struct sigaction));
|
||||
act.sa_handler = SIG_IGN;
|
||||
sigaction(SIGINT, &act, NULL);
|
||||
@@ -1255,7 +1238,6 @@ void signal_init(void)
|
||||
/* Trap SIGWINCH because we want to handle window resizes. */
|
||||
act.sa_handler = handle_sigwinch;
|
||||
sigaction(SIGWINCH, &act, NULL);
|
||||
allow_pending_sigwinch(FALSE);
|
||||
#endif
|
||||
|
||||
/* Trap normal suspend (^Z) so we can handle it ourselves. */
|
||||
@@ -1284,9 +1266,8 @@ RETSIGTYPE handle_hupterm(int signal)
|
||||
/* Handler for SIGTSTP (suspend). */
|
||||
RETSIGTYPE do_suspend(int signal)
|
||||
{
|
||||
|
||||
if (ISSET(RESTRICTED)) {
|
||||
nano_disabled_msg();
|
||||
nano_disabled_msg();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1316,7 +1297,7 @@ RETSIGTYPE do_suspend(int signal)
|
||||
kill(0, SIGSTOP);
|
||||
}
|
||||
|
||||
/* the subnfunc version */
|
||||
/* The version of above function that is bound to a key. */
|
||||
void do_suspend_void(void)
|
||||
{
|
||||
if (ISSET(SUSPEND))
|
||||
@@ -1354,6 +1335,13 @@ RETSIGTYPE do_continue(int signal)
|
||||
#ifndef NANO_TINY
|
||||
/* Handler for SIGWINCH (window size change). */
|
||||
RETSIGTYPE handle_sigwinch(int signal)
|
||||
{
|
||||
/* Let the input routine know that a SIGWINCH has occurred. */
|
||||
sigwinch_counter++;
|
||||
}
|
||||
|
||||
/* Reinitialize and redraw the screen completely. */
|
||||
void regenerate_screen(void)
|
||||
{
|
||||
const char *tty = ttyname(0);
|
||||
int fd, result = 0;
|
||||
@@ -1378,10 +1366,6 @@ RETSIGTYPE handle_sigwinch(int signal)
|
||||
LINES = win.ws_row;
|
||||
#endif
|
||||
|
||||
/* If we've partitioned the filestruct, unpartition it now. */
|
||||
if (filepart != NULL)
|
||||
unpartition_filestruct(&filepart);
|
||||
|
||||
#ifdef USE_SLANG
|
||||
/* Slang curses emulation brain damage, part 1: If we just do what
|
||||
* curses does here, it'll only work properly if the resize made the
|
||||
@@ -1408,14 +1392,7 @@ RETSIGTYPE handle_sigwinch(int signal)
|
||||
window_init();
|
||||
|
||||
/* Redraw the contents of the windows that need it. */
|
||||
blank_statusbar();
|
||||
wnoutrefresh(bottomwin);
|
||||
currmenu = MMAIN;
|
||||
total_refresh();
|
||||
|
||||
/* Jump back to either main() or the unjustify routine in
|
||||
* do_justify(). */
|
||||
siglongjmp(jump_buf, 1);
|
||||
}
|
||||
|
||||
/* If allow is TRUE, block any SIGWINCH signals that we get, so that we
|
||||
@@ -1482,13 +1459,13 @@ void do_toggle(int flag)
|
||||
desc = (char *) _(flagtostr(flag));
|
||||
statusbar("%s %s", desc, enabled ? _("enabled") : _("disabled"));
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Bleh. */
|
||||
void do_toggle_void(void)
|
||||
{
|
||||
;
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Disable extended input and output processing in our terminal
|
||||
* settings. */
|
||||
@@ -1610,6 +1587,11 @@ int do_input(bool allow_funcs)
|
||||
/* Read in a character. */
|
||||
input = get_kbinput(edit);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (input == KEY_WINCH)
|
||||
return KEY_WINCH;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
if (func_key && input == KEY_MOUSE) {
|
||||
/* We received a mouse click. */
|
||||
@@ -1806,7 +1788,7 @@ int do_mouse(void)
|
||||
mouse_x, (unsigned long)openfile->current_x);
|
||||
#endif
|
||||
} else {
|
||||
openfile->current_x = actual_x(openfile->current->data, mouse_x);
|
||||
openfile->current_x = actual_x(openfile->current->data, mouse_x);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_mouse(): i <= mouse_y, mouse_x = %d, setting current_x to = %lu\n",
|
||||
mouse_x, (unsigned long)openfile->current_x);
|
||||
@@ -2121,7 +2103,6 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
const struct option long_options[] = {
|
||||
{"help", 0, NULL, 'h'},
|
||||
{"boldtext", 0, NULL, 'D'},
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
{"multibuffer", 0, NULL, 'F'},
|
||||
@@ -2143,6 +2124,7 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
{"const", 0, NULL, 'c'},
|
||||
{"rebinddelete", 0, NULL, 'd'},
|
||||
{"help", 0, NULL, 'h'},
|
||||
{"nofollow", 0, NULL, 'l'},
|
||||
#ifndef DISABLE_MOUSE
|
||||
{"mouse", 0, NULL, 'm'},
|
||||
@@ -2177,7 +2159,6 @@ int main(int argc, char **argv)
|
||||
{"poslog", 0, NULL, 'P'},
|
||||
{"smooth", 0, NULL, 'S'},
|
||||
{"quickblank", 0, NULL, 'U'},
|
||||
{"undo", 0, NULL, 'u'},
|
||||
{"wordbounds", 0, NULL, 'W'},
|
||||
{"autoindent", 0, NULL, 'i'},
|
||||
{"cut", 0, NULL, 'k'},
|
||||
@@ -2483,8 +2464,8 @@ int main(int argc, char **argv)
|
||||
do_rcfile();
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "After rebinding keys...\n");
|
||||
print_sclist();
|
||||
fprintf(stderr, "After rebinding keys...\n");
|
||||
print_sclist();
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
@@ -2650,6 +2631,10 @@ int main(int argc, char **argv)
|
||||
#endif /* !DISABLE_NANORC */
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Initialize the search and replace strings. */
|
||||
last_search = mallocstrcpy(NULL, "");
|
||||
last_replace = mallocstrcpy(NULL, "");
|
||||
|
||||
/* If tabsize wasn't specified, set its default value. */
|
||||
if (tabsize == -1)
|
||||
tabsize = WIDTH_OF_TAB;
|
||||
@@ -2741,7 +2726,7 @@ int main(int argc, char **argv)
|
||||
icol = 1;
|
||||
}
|
||||
#ifndef DISABLE_HISTORIES
|
||||
else {
|
||||
else {
|
||||
/* See if we have a POS history to use if we haven't overridden it. */
|
||||
ssize_t savedposline, savedposcol;
|
||||
if (check_poshistory(argv[i], &savedposline, &savedposcol))
|
||||
@@ -2805,17 +2790,6 @@ int main(int argc, char **argv)
|
||||
reset_cursor();
|
||||
wnoutrefresh(edit);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (!jump_buf_main) {
|
||||
/* If we haven't already, we're going to set jump_buf so
|
||||
* that we return here after a SIGWINCH. Indicate this. */
|
||||
jump_buf_main = TRUE;
|
||||
|
||||
/* Return here after a SIGWINCH. */
|
||||
sigsetjmp(jump_buf, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Just in case we were at the statusbar prompt, make sure the
|
||||
* statusbar cursor position is reset. */
|
||||
do_prompt_abort();
|
||||
@@ -2826,7 +2800,7 @@ int main(int argc, char **argv)
|
||||
if (ISSET(CONST_UPDATE) && get_key_buffer_len() == 0)
|
||||
do_cursorpos(TRUE);
|
||||
|
||||
currmenu = MMAIN;
|
||||
currmenu = MMAIN;
|
||||
|
||||
/* Read in and interpret characters. */
|
||||
do_input(TRUE);
|
||||
|
||||
28
src/nano.h
28
src/nano.h
@@ -116,9 +116,7 @@
|
||||
#ifdef HAVE_REGEX_H
|
||||
#include <regex.h>
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
#include <setjmp.h>
|
||||
#endif
|
||||
#include <signal.h>
|
||||
#include <assert.h>
|
||||
|
||||
/* If no vsnprintf(), use the version from glib 2.x. */
|
||||
@@ -194,6 +192,7 @@ typedef enum {
|
||||
JOIN, PASTE, INSERT, ENTER, OTHER
|
||||
} undo_type;
|
||||
|
||||
/* Structure types. */
|
||||
typedef struct color_pair {
|
||||
int pairnum;
|
||||
/* The color pair number used for this foreground color and
|
||||
@@ -274,7 +273,7 @@ typedef struct lintstruct {
|
||||
/* Previous error. */
|
||||
} lintstruct;
|
||||
|
||||
|
||||
/* Flags that indicate how a multiline regex applies to a line. */
|
||||
#define CNONE (1<<1)
|
||||
/* Yay, regex doesn't apply to this line at all! */
|
||||
#define CBEGINBEFORE (1<<2)
|
||||
@@ -285,13 +284,9 @@ typedef struct lintstruct {
|
||||
/* Whole line engulfed by the regex, start < me, end > me. */
|
||||
#define CSTARTENDHERE (1<<5)
|
||||
/* Regex starts and ends within this line. */
|
||||
#define CWTF (1<<6)
|
||||
/* Something else. */
|
||||
|
||||
#endif /* !DISABLE_COLOR */
|
||||
|
||||
|
||||
/* Structure types. */
|
||||
/* More structure types. */
|
||||
typedef struct filestruct {
|
||||
char *data;
|
||||
/* The text of this line. */
|
||||
@@ -457,9 +452,6 @@ typedef struct sc {
|
||||
/* The function we're going to run. */
|
||||
int toggle;
|
||||
/* If a toggle, what we're toggling. */
|
||||
bool execute;
|
||||
/* Whether to execute the function in question or just return
|
||||
* so the sequence can be caught by the calling code. */
|
||||
struct sc *next;
|
||||
/* Next in the list. */
|
||||
} sc;
|
||||
@@ -571,11 +563,13 @@ enum
|
||||
#define CONTROL_RIGHT 554
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Extra bits for the undo function. */
|
||||
#define UNdel_del (1<<0)
|
||||
#define UNdel_backspace (1<<1)
|
||||
#define UNcut_marked_forward (1<<2)
|
||||
#define UNcut_cutline (1<<3)
|
||||
/* An imaginary key for when we get a SIGWINCH (window resize). */
|
||||
#define KEY_WINCH -2
|
||||
|
||||
/* Some extra flags for the undo function. */
|
||||
#define WAS_FINAL_BACKSPACE (1<<1)
|
||||
#define WAS_MARKED_FORWARD (1<<2)
|
||||
#define WAS_WHOLE_LINE (1<<3)
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* The maximum number of entries displayed in the main shortcut list. */
|
||||
|
||||
134
src/prompt.c
134
src/prompt.c
@@ -66,6 +66,11 @@ int do_statusbar_input(bool *ran_func, bool *finished,
|
||||
/* Read in a character. */
|
||||
input = get_kbinput(bottomwin);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (input == KEY_WINCH)
|
||||
return KEY_WINCH;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
/* If we got a mouse click and it was on a shortcut, read in the
|
||||
* shortcut character. */
|
||||
@@ -245,7 +250,7 @@ int do_statusbar_mouse(void)
|
||||
statusbar_xplustabs()) + mouse_x - start_col);
|
||||
statusbar_pww = statusbar_xplustabs();
|
||||
|
||||
if (need_statusbar_horizontal_update(pww_save))
|
||||
if (need_statusbar_update(pww_save))
|
||||
update_statusbar_line(answer, statusbar_x);
|
||||
}
|
||||
}
|
||||
@@ -347,7 +352,7 @@ void do_statusbar_home(void)
|
||||
statusbar_pww = statusbar_xplustabs();
|
||||
}
|
||||
|
||||
if (need_statusbar_horizontal_update(pww_save))
|
||||
if (need_statusbar_update(pww_save))
|
||||
update_statusbar_line(answer, statusbar_x);
|
||||
}
|
||||
|
||||
@@ -359,7 +364,7 @@ void do_statusbar_end(void)
|
||||
statusbar_x = strlen(answer);
|
||||
statusbar_pww = statusbar_xplustabs();
|
||||
|
||||
if (need_statusbar_horizontal_update(pww_save))
|
||||
if (need_statusbar_update(pww_save))
|
||||
update_statusbar_line(answer, statusbar_x);
|
||||
}
|
||||
|
||||
@@ -372,7 +377,7 @@ void do_statusbar_left(void)
|
||||
statusbar_x = move_mbleft(answer, statusbar_x);
|
||||
statusbar_pww = statusbar_xplustabs();
|
||||
|
||||
if (need_statusbar_horizontal_update(pww_save))
|
||||
if (need_statusbar_update(pww_save))
|
||||
update_statusbar_line(answer, statusbar_x);
|
||||
}
|
||||
}
|
||||
@@ -386,7 +391,7 @@ void do_statusbar_right(void)
|
||||
statusbar_x = move_mbright(answer, statusbar_x);
|
||||
statusbar_pww = statusbar_xplustabs();
|
||||
|
||||
if (need_statusbar_horizontal_update(pww_save))
|
||||
if (need_statusbar_update(pww_save))
|
||||
update_statusbar_line(answer, statusbar_x);
|
||||
}
|
||||
}
|
||||
@@ -500,7 +505,7 @@ bool do_statusbar_next_word(bool allow_punct)
|
||||
|
||||
statusbar_pww = statusbar_xplustabs();
|
||||
|
||||
if (need_statusbar_horizontal_update(pww_save))
|
||||
if (need_statusbar_update(pww_save))
|
||||
update_statusbar_line(answer, statusbar_x);
|
||||
|
||||
/* Return whether we started on a word. */
|
||||
@@ -595,7 +600,7 @@ bool do_statusbar_prev_word(bool allow_punct)
|
||||
|
||||
statusbar_pww = statusbar_xplustabs();
|
||||
|
||||
if (need_statusbar_horizontal_update(pww_save))
|
||||
if (need_statusbar_update(pww_save))
|
||||
update_statusbar_line(answer, statusbar_x);
|
||||
|
||||
/* Return whether we started on a word. */
|
||||
@@ -645,7 +650,7 @@ size_t statusbar_xplustabs(void)
|
||||
* get_statusbar_page_start(column) < COLS). */
|
||||
size_t get_statusbar_page_start(size_t start_col, size_t column)
|
||||
{
|
||||
if (column == start_col || column < COLS - 1)
|
||||
if (column == start_col || column < COLS - 1 || COLS == start_col + 1)
|
||||
return 0;
|
||||
else
|
||||
return column - start_col - (column - start_col) % (COLS -
|
||||
@@ -698,10 +703,10 @@ void update_statusbar_line(const char *curranswer, size_t index)
|
||||
wnoutrefresh(bottomwin);
|
||||
}
|
||||
|
||||
/* Return TRUE if we need an update after moving horizontally, and FALSE
|
||||
* otherwise. We need one if pww_save and statusbar_pww are on
|
||||
/* Return TRUE if we need an update after moving the cursor, and FALSE
|
||||
* otherwise. We need an update if pww_save and statusbar_pww are on
|
||||
* different pages. */
|
||||
bool need_statusbar_horizontal_update(size_t pww_save)
|
||||
bool need_statusbar_update(size_t pww_save)
|
||||
{
|
||||
size_t start_col = strlenpt(prompt) + 2;
|
||||
|
||||
@@ -794,6 +799,14 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs,
|
||||
kbinput = do_statusbar_input(&ran_func, &finished, refresh_func);
|
||||
assert(statusbar_x <= strlen(answer));
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (kbinput == KEY_WINCH) {
|
||||
refresh_func();
|
||||
update_statusbar_line(answer, statusbar_x);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
func = func_from_key(&kbinput);
|
||||
|
||||
if (func == do_cancel || func == do_enter_void)
|
||||
@@ -905,8 +918,7 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs,
|
||||
if (history_list != NULL) {
|
||||
history_reset(*history_list);
|
||||
|
||||
if (magichistory != NULL)
|
||||
free(magichistory);
|
||||
free(magichistory);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -964,12 +976,10 @@ int do_prompt(bool allow_tabs,
|
||||
|
||||
/* prompt has been freed and set to NULL unless the user resized
|
||||
* while at the statusbar prompt. */
|
||||
if (prompt != NULL)
|
||||
free(prompt);
|
||||
free(prompt);
|
||||
|
||||
prompt = charalloc(((COLS - 4) * mb_cur_max()) + 1);
|
||||
|
||||
currmenu = menu;
|
||||
bottombars(menu);
|
||||
|
||||
va_start(ap, msg);
|
||||
@@ -1056,49 +1066,6 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
nostr = _("Nn");
|
||||
allstr = _("Aa");
|
||||
|
||||
if (!ISSET(NO_HELP)) {
|
||||
char shortstr[3];
|
||||
/* Temp string for Yes, No, All. */
|
||||
|
||||
if (COLS < 32)
|
||||
width = COLS / 2;
|
||||
|
||||
/* Clear the shortcut list from the bottom of the screen. */
|
||||
blank_bottombars();
|
||||
|
||||
sprintf(shortstr, " %c", yesstr[0]);
|
||||
wmove(bottomwin, 1, 0);
|
||||
onekey(shortstr, _("Yes"), width);
|
||||
|
||||
if (all) {
|
||||
wmove(bottomwin, 1, width);
|
||||
shortstr[1] = allstr[0];
|
||||
onekey(shortstr, _("All"), width);
|
||||
}
|
||||
|
||||
wmove(bottomwin, 2, 0);
|
||||
shortstr[1] = nostr[0];
|
||||
onekey(shortstr, _("No"), width);
|
||||
|
||||
wmove(bottomwin, 2, 16);
|
||||
onekey("^C", _("Cancel"), width);
|
||||
}
|
||||
|
||||
if (interface_color_pair[TITLE_BAR].bright)
|
||||
wattron(bottomwin, A_BOLD);
|
||||
wattron(bottomwin, interface_color_pair[TITLE_BAR].pairnum);
|
||||
|
||||
blank_statusbar();
|
||||
mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));
|
||||
|
||||
wattroff(bottomwin, A_BOLD);
|
||||
wattroff(bottomwin, interface_color_pair[TITLE_BAR].pairnum);
|
||||
|
||||
/* Refresh the edit window and the statusbar before getting
|
||||
* input. */
|
||||
wnoutrefresh(edit);
|
||||
wnoutrefresh(bottomwin);
|
||||
|
||||
do {
|
||||
int kbinput;
|
||||
functionptrtype func;
|
||||
@@ -1106,8 +1073,57 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
int mouse_x, mouse_y;
|
||||
#endif
|
||||
|
||||
if (!ISSET(NO_HELP)) {
|
||||
char shortstr[3];
|
||||
/* Temporary string for (translated) " Y", " N" and " A". */
|
||||
|
||||
if (COLS < 32)
|
||||
width = COLS / 2;
|
||||
|
||||
/* Clear the shortcut list from the bottom of the screen. */
|
||||
blank_bottombars();
|
||||
|
||||
/* Now show the ones for "Yes", "No", "Cancel" and maybe "All". */
|
||||
sprintf(shortstr, " %c", yesstr[0]);
|
||||
wmove(bottomwin, 1, 0);
|
||||
onekey(shortstr, _("Yes"), width);
|
||||
|
||||
if (all) {
|
||||
shortstr[1] = allstr[0];
|
||||
wmove(bottomwin, 1, width);
|
||||
onekey(shortstr, _("All"), width);
|
||||
}
|
||||
|
||||
shortstr[1] = nostr[0];
|
||||
wmove(bottomwin, 2, 0);
|
||||
onekey(shortstr, _("No"), width);
|
||||
|
||||
wmove(bottomwin, 2, width);
|
||||
onekey("^C", _("Cancel"), width);
|
||||
}
|
||||
|
||||
if (interface_color_pair[TITLE_BAR].bright)
|
||||
wattron(bottomwin, A_BOLD);
|
||||
wattron(bottomwin, interface_color_pair[TITLE_BAR].pairnum);
|
||||
|
||||
blank_statusbar();
|
||||
mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));
|
||||
|
||||
wattroff(bottomwin, A_BOLD);
|
||||
wattroff(bottomwin, interface_color_pair[TITLE_BAR].pairnum);
|
||||
|
||||
/* Refresh edit window and statusbar before getting input. */
|
||||
wnoutrefresh(edit);
|
||||
wnoutrefresh(bottomwin);
|
||||
|
||||
currmenu = MYESNO;
|
||||
kbinput = get_kbinput(bottomwin);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (kbinput == KEY_WINCH)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
func = func_from_key(&kbinput);
|
||||
|
||||
if (func == do_cancel)
|
||||
|
||||
36
src/proto.h
36
src/proto.h
@@ -28,12 +28,12 @@
|
||||
|
||||
/* All external variables. See global.c for their descriptions. */
|
||||
#ifndef NANO_TINY
|
||||
extern sigjmp_buf jump_buf;
|
||||
extern bool jump_buf_main;
|
||||
extern volatile sig_atomic_t sigwinch_counter;
|
||||
#endif
|
||||
|
||||
extern bool meta_key;
|
||||
extern bool func_key;
|
||||
extern bool focusing;
|
||||
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
extern ssize_t fill;
|
||||
@@ -148,10 +148,9 @@ char *do_browse_from(const char *inpath);
|
||||
void browser_init(const char *path, DIR *dir);
|
||||
functionptrtype parse_browser_input(int *kbinput);
|
||||
void browser_refresh(void);
|
||||
bool browser_select_filename(const char *needle);
|
||||
void browser_select_dirname(const char *needle);
|
||||
int filesearch_init(void);
|
||||
bool findnextfile(bool no_sameline, size_t begin, const char *needle);
|
||||
void findnextfile_wrap_reset(void);
|
||||
void findnextfile(const char *needle);
|
||||
void filesearch_abort(void);
|
||||
void do_filesearch(void);
|
||||
void do_fileresearch(void);
|
||||
@@ -283,15 +282,15 @@ void replace_buffer(const char *filename);
|
||||
#endif
|
||||
void display_buffer(void);
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
void switch_to_prevnext_buffer(bool next);
|
||||
void switch_to_prevnext_buffer(bool next, bool quiet);
|
||||
void switch_to_prev_buffer_void(void);
|
||||
void switch_to_next_buffer_void(void);
|
||||
bool close_buffer(void);
|
||||
bool close_buffer(bool quiet);
|
||||
#endif
|
||||
filestruct *read_line(char *buf, filestruct *prevnode, bool
|
||||
*first_line_ins, size_t buf_len);
|
||||
void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkwritable);
|
||||
int open_file(const char *filename, bool newfie, FILE **f);
|
||||
int open_file(const char *filename, bool newfie, bool quiet, FILE **f);
|
||||
char *get_next_filename(const char *name, const char *suffix);
|
||||
void do_insertfile(
|
||||
#ifndef NANO_TINY
|
||||
@@ -478,10 +477,11 @@ RETSIGTYPE do_suspend(int signal);
|
||||
RETSIGTYPE do_continue(int signal);
|
||||
#ifndef NANO_TINY
|
||||
RETSIGTYPE handle_sigwinch(int signal);
|
||||
void regenerate_screen(void);
|
||||
void allow_pending_sigwinch(bool allow);
|
||||
void do_toggle(int flag);
|
||||
void do_toggle_void(void);
|
||||
#endif
|
||||
void do_toggle_void(void);
|
||||
void disable_extended_io(void);
|
||||
#ifdef USE_SLANG
|
||||
void disable_signals(void);
|
||||
@@ -522,7 +522,7 @@ size_t statusbar_xplustabs(void);
|
||||
size_t get_statusbar_page_start(size_t start_col, size_t column);
|
||||
void reset_statusbar_cursor(void);
|
||||
void update_statusbar_line(const char *curranswer, size_t index);
|
||||
bool need_statusbar_horizontal_update(size_t pww_save);
|
||||
bool need_statusbar_update(size_t pww_save);
|
||||
void total_statusbar_refresh(void (*refresh_func)(void));
|
||||
functionptrtype get_prompt_string(int *value, bool allow_tabs,
|
||||
#ifndef DISABLE_TABCOMP
|
||||
@@ -579,14 +579,13 @@ void regexp_cleanup(void);
|
||||
#endif
|
||||
void not_found_msg(const char *str);
|
||||
void search_replace_abort(void);
|
||||
void search_init_globals(void);
|
||||
int search_init(bool replacing, bool use_answer);
|
||||
bool findnextstr(
|
||||
#ifndef DISABLE_SPELLER
|
||||
bool whole_word,
|
||||
bool whole_word_only,
|
||||
#endif
|
||||
bool no_sameline, const filestruct *begin, size_t begin_x, const
|
||||
char *needle, size_t *needle_len);
|
||||
const filestruct *begin, size_t begin_x,
|
||||
const char *needle, size_t *needle_len);
|
||||
void findnextstr_wrap_reset(void);
|
||||
void do_search(void);
|
||||
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
|
||||
@@ -598,7 +597,7 @@ int replace_regexp(char *string, bool create);
|
||||
char *replace_line(const char *needle);
|
||||
ssize_t do_replace_loop(
|
||||
#ifndef DISABLE_SPELLER
|
||||
bool whole_word,
|
||||
bool whole_word_only,
|
||||
#endif
|
||||
bool *canceled, const filestruct *real_current, size_t
|
||||
*real_current_x, const char *needle);
|
||||
@@ -696,7 +695,6 @@ void do_wordlinechar_count(void);
|
||||
void do_verbatim_input(void);
|
||||
|
||||
/* All functions in utils.c. */
|
||||
int digits(size_t n);
|
||||
void get_homedir(void);
|
||||
bool parse_num(const char *str, ssize_t *val);
|
||||
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column);
|
||||
@@ -713,7 +711,6 @@ ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef HAVE_REGEX_H
|
||||
bool regexp_bol_or_eol(const regex_t *preg, const char *string);
|
||||
const char *fixbounds(const char *r);
|
||||
#endif
|
||||
#ifndef DISABLE_SPELLER
|
||||
@@ -737,7 +734,7 @@ void new_magicline(void);
|
||||
void remove_magicline(void);
|
||||
void mark_order(const filestruct **top, size_t *top_x, const filestruct
|
||||
**bot, size_t *bot_x, bool *right_side_up);
|
||||
void add_undo(undo_type current_action);
|
||||
void add_undo(undo_type action);
|
||||
void update_undo(undo_type action);
|
||||
#endif
|
||||
size_t get_totsize(const filestruct *begin, const filestruct *end);
|
||||
@@ -789,8 +786,7 @@ void reset_cursor(void);
|
||||
void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
line, size_t start);
|
||||
int update_line(filestruct *fileptr, size_t index);
|
||||
bool need_horizontal_update(size_t pww_save);
|
||||
bool need_vertical_update(size_t pww_save);
|
||||
bool need_screen_update(size_t pww_save);
|
||||
void edit_scroll(scroll_dir direction, ssize_t nlines);
|
||||
void edit_redraw(filestruct *old_current, size_t pww_save);
|
||||
void edit_refresh(void);
|
||||
|
||||
57
src/rcfile.c
57
src/rcfile.c
@@ -42,16 +42,16 @@ static const rcoption rcopts[] = {
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
{"fill", 0},
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
{"locking", LOCKING},
|
||||
#ifndef DISABLE_HISTORIES
|
||||
{"historylog", HISTORYLOG},
|
||||
#endif
|
||||
{"morespace", MORE_SPACE},
|
||||
#ifndef DISABLE_MOUSE
|
||||
{"mouse", USE_MOUSE},
|
||||
#endif
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
{"multibuffer", MULTIBUFFER},
|
||||
#endif
|
||||
{"morespace", MORE_SPACE},
|
||||
{"nofollow", NOFOLLOW_SYMLINKS},
|
||||
{"nohelp", NO_HELP},
|
||||
{"nonewlines", NO_NEWLINES},
|
||||
@@ -60,6 +60,9 @@ static const rcoption rcopts[] = {
|
||||
#endif
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
{"operatingdir", 0},
|
||||
#endif
|
||||
#ifndef DISABLE_HISTORIES
|
||||
{"poslog", POS_HISTORY},
|
||||
#endif
|
||||
{"preserve", PRESERVE},
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
@@ -79,25 +82,24 @@ static const rcoption rcopts[] = {
|
||||
{"tempfile", TEMP_FILE},
|
||||
{"view", VIEW_MODE},
|
||||
#ifndef NANO_TINY
|
||||
{"allow_insecure_backup", INSECURE_BACKUP},
|
||||
{"autoindent", AUTOINDENT},
|
||||
{"backup", BACKUP_FILE},
|
||||
{"allow_insecure_backup", INSECURE_BACKUP},
|
||||
{"backupdir", 0},
|
||||
{"backwards", BACKWARDS_SEARCH},
|
||||
{"casesensitive", CASE_SENSITIVE},
|
||||
{"cut", CUT_TO_END},
|
||||
{"historylog", HISTORYLOG},
|
||||
{"locking", LOCKING},
|
||||
{"matchbrackets", 0},
|
||||
{"noconvert", NO_CONVERT},
|
||||
{"poslog", POS_HISTORY},
|
||||
{"quiet", QUIET},
|
||||
{"quickblank", QUICK_BLANK},
|
||||
{"quiet", QUIET},
|
||||
{"smarthome", SMART_HOME},
|
||||
{"smooth", SMOOTH_SCROLL},
|
||||
{"softwrap", SOFTWRAP},
|
||||
{"tabstospaces", TABS_TO_SPACES},
|
||||
{"whitespace", 0},
|
||||
{"wordbounds", WORD_BOUNDS},
|
||||
{"softwrap", SOFTWRAP},
|
||||
#endif
|
||||
#ifndef DISABLE_COLOR
|
||||
{"titlecolor", 0},
|
||||
@@ -514,6 +516,10 @@ void parse_binding(char *ptr, bool dobind)
|
||||
if (f->scfunc == newsc->scfunc)
|
||||
mask = mask | f->menus;
|
||||
|
||||
/* Handle the special case of the toggles. */
|
||||
if (newsc->scfunc == do_toggle_void)
|
||||
mask = MMAIN;
|
||||
|
||||
/* Now limit the given menu to those where the function exists. */
|
||||
if (is_universal(newsc->scfunc))
|
||||
menu = menu & MMOST;
|
||||
@@ -597,11 +603,7 @@ static void _parse_include(char *file)
|
||||
fprintf(stderr, "Parsing file \"%s\"\n", file);
|
||||
#endif
|
||||
|
||||
parse_rcfile(rcstream
|
||||
#ifndef DISABLE_COLOR
|
||||
, TRUE
|
||||
#endif
|
||||
);
|
||||
parse_rcfile(rcstream, TRUE);
|
||||
}
|
||||
|
||||
void parse_include(char *ptr)
|
||||
@@ -903,11 +905,10 @@ void parse_header_exp(char *ptr)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef DISABLE_COLOR
|
||||
#ifdef HAVE_LIBMAGIC
|
||||
/* Parse the magic regexes that may influence the choice of syntax. */
|
||||
void parse_magic_exp(char *ptr)
|
||||
{
|
||||
#ifdef HAVE_LIBMAGIC
|
||||
regexlisttype *endmagic = NULL;
|
||||
|
||||
assert(ptr != NULL);
|
||||
@@ -967,11 +968,10 @@ void parse_magic_exp(char *ptr)
|
||||
} else
|
||||
free(newmagic);
|
||||
}
|
||||
#endif /* HAVE_LIBMAGIC */
|
||||
}
|
||||
#endif /* !DISABLE_COLOR */
|
||||
#endif /* HAVE_LIBMAGIC */
|
||||
|
||||
/* Parse the linter requested for this syntax. Simple? */
|
||||
/* Parse the linter requested for this syntax. */
|
||||
void parse_linter(char *ptr)
|
||||
{
|
||||
assert(ptr != NULL);
|
||||
@@ -987,16 +987,17 @@ void parse_linter(char *ptr)
|
||||
return;
|
||||
}
|
||||
|
||||
if (endsyntax->linter != NULL)
|
||||
free(endsyntax->linter);
|
||||
free(endsyntax->linter);
|
||||
|
||||
/* Let them unset the linter by using "". */
|
||||
if (!strcmp(ptr, "\"\""))
|
||||
endsyntax->linter = NULL;
|
||||
else
|
||||
endsyntax->linter = mallocstrcpy(syntaxes->linter, ptr);
|
||||
endsyntax->linter = mallocstrcpy(NULL, ptr);
|
||||
}
|
||||
|
||||
#ifndef DISABLE_SPELLER
|
||||
/* Parse the formatter requested for this syntax. */
|
||||
void parse_formatter(char *ptr)
|
||||
{
|
||||
assert(ptr != NULL);
|
||||
@@ -1012,15 +1013,15 @@ void parse_formatter(char *ptr)
|
||||
return;
|
||||
}
|
||||
|
||||
if (endsyntax->formatter != NULL)
|
||||
free(endsyntax->formatter);
|
||||
free(endsyntax->formatter);
|
||||
|
||||
/* Let them unset the formatter by using "". */
|
||||
if (!strcmp(ptr, "\"\""))
|
||||
endsyntax->formatter = NULL;
|
||||
else
|
||||
endsyntax->formatter = mallocstrcpy(syntaxes->formatter, ptr);
|
||||
endsyntax->formatter = mallocstrcpy(NULL, ptr);
|
||||
}
|
||||
#endif /* !DISABLE_SPELLER */
|
||||
#endif /* !DISABLE_COLOR */
|
||||
|
||||
/* Check whether the user has unmapped every shortcut for a
|
||||
@@ -1147,7 +1148,11 @@ void parse_rcfile(FILE *rcstream
|
||||
parse_syntax(ptr);
|
||||
}
|
||||
else if (strcasecmp(keyword, "magic") == 0)
|
||||
#ifdef HAVE_LIBMAGIC
|
||||
parse_magic_exp(ptr);
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
else if (strcasecmp(keyword, "header") == 0)
|
||||
parse_header_exp(ptr);
|
||||
else if (strcasecmp(keyword, "color") == 0)
|
||||
@@ -1157,7 +1162,11 @@ void parse_rcfile(FILE *rcstream
|
||||
else if (strcasecmp(keyword, "linter") == 0)
|
||||
parse_linter(ptr);
|
||||
else if (strcasecmp(keyword, "formatter") == 0)
|
||||
#ifndef DISABLE_SPELLER
|
||||
parse_formatter(ptr);
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
#endif /* !DISABLE_COLOR */
|
||||
else if (strcasecmp(keyword, "bind") == 0)
|
||||
parse_binding(ptr, TRUE);
|
||||
|
||||
245
src/search.c
245
src/search.c
@@ -106,6 +106,7 @@ void not_found_msg(const char *str)
|
||||
void search_replace_abort(void)
|
||||
{
|
||||
display_main_list();
|
||||
focusing = FALSE;
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->mark_set)
|
||||
edit_refresh();
|
||||
@@ -115,15 +116,6 @@ void search_replace_abort(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Initialize the global search and replace strings. */
|
||||
void search_init_globals(void)
|
||||
{
|
||||
if (last_search == NULL)
|
||||
last_search = mallocstrcpy(NULL, "");
|
||||
if (last_replace == NULL)
|
||||
last_replace = mallocstrcpy(NULL, "");
|
||||
}
|
||||
|
||||
/* Set up the system variables for a search or replace. If use_answer
|
||||
* is TRUE, only set backupstring to answer. Return -2 to run the
|
||||
* opposite program (search -> replace, replace -> search), return -1 if
|
||||
@@ -155,14 +147,13 @@ int search_init(bool replacing, bool use_answer)
|
||||
* do_search() or do_replace() and be called again. In that case,
|
||||
* we should put the same search string back up. */
|
||||
|
||||
search_init_globals();
|
||||
focusing = TRUE;
|
||||
|
||||
if (last_search[0] != '\0') {
|
||||
char *disp = display_string(last_search, 0, COLS / 3, FALSE);
|
||||
|
||||
buf = charalloc(strlen(disp) + 7);
|
||||
/* We use (COLS / 3) here because we need to see more on the
|
||||
* line. */
|
||||
/* We use (COLS / 3) here because we need to see more on the line. */
|
||||
sprintf(buf, " [%s%s]", disp,
|
||||
(strlenpt(last_search) > COLS / 3) ? "..." : "");
|
||||
free(disp);
|
||||
@@ -258,17 +249,16 @@ int search_init(bool replacing, bool use_answer)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Look for needle, starting at (current, current_x). If no_sameline is
|
||||
* TRUE, skip over begin when looking for needle. begin is the line
|
||||
/* Look for needle, starting at (current, current_x). begin is the line
|
||||
* where we first started searching, at column begin_x. The return
|
||||
* value specifies whether we found anything. If we did, set needle_len
|
||||
* to the length of the string we found if it isn't NULL. */
|
||||
bool findnextstr(
|
||||
#ifndef DISABLE_SPELLER
|
||||
bool whole_word,
|
||||
bool whole_word_only,
|
||||
#endif
|
||||
bool no_sameline, const filestruct *begin, size_t begin_x, const
|
||||
char *needle, size_t *needle_len)
|
||||
const filestruct *begin, size_t begin_x,
|
||||
const char *needle, size_t *needle_len)
|
||||
{
|
||||
size_t found_len;
|
||||
/* The length of the match we find. */
|
||||
@@ -287,9 +277,9 @@ bool findnextstr(
|
||||
rev_start +=
|
||||
#ifndef NANO_TINY
|
||||
ISSET(BACKWARDS_SEARCH) ?
|
||||
openfile->current_x - 1 :
|
||||
((openfile->current_x == 0) ? -1 : move_mbleft(fileptr->data, openfile->current_x)) :
|
||||
#endif
|
||||
openfile->current_x + 1;
|
||||
move_mbright(fileptr->data, openfile->current_x);
|
||||
|
||||
/* Look for needle in the current line we're searching. */
|
||||
enable_nodelay();
|
||||
@@ -325,7 +315,7 @@ bool findnextstr(
|
||||
#ifndef DISABLE_SPELLER
|
||||
/* If we're searching for whole words, see if this potential
|
||||
* match is a whole word. */
|
||||
if (whole_word) {
|
||||
if (whole_word_only) {
|
||||
char *word = mallocstrncpy(NULL, found, found_len + 1);
|
||||
word[found_len] = '\0';
|
||||
|
||||
@@ -333,22 +323,16 @@ bool findnextstr(
|
||||
fileptr->data, word);
|
||||
free(word);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If we're searching for whole words and this potential
|
||||
* match isn't a whole word, or if we're not allowed to find
|
||||
* a match on the same line we started on and this potential
|
||||
* match is on that line, continue searching. */
|
||||
if (
|
||||
#ifndef DISABLE_SPELLER
|
||||
(!whole_word || found_whole) &&
|
||||
* match isn't a whole word, continue searching. */
|
||||
if (!whole_word_only || found_whole)
|
||||
#endif
|
||||
(!no_sameline || fileptr != openfile->current))
|
||||
break;
|
||||
}
|
||||
|
||||
/* We've finished processing the file, so get out. */
|
||||
if (search_last_line) {
|
||||
/* We've finished processing the file, so get out. */
|
||||
not_found_msg(needle);
|
||||
disable_nodelay();
|
||||
return FALSE;
|
||||
@@ -367,9 +351,8 @@ bool findnextstr(
|
||||
}
|
||||
#endif
|
||||
|
||||
/* We've reached the start or end of the buffer, so wrap
|
||||
* around. */
|
||||
if (fileptr == NULL) {
|
||||
/* We've reached the start or end of the buffer, so wrap around. */
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(BACKWARDS_SEARCH)) {
|
||||
fileptr = openfile->filebot;
|
||||
@@ -384,8 +367,8 @@ bool findnextstr(
|
||||
statusbar(_("Search Wrapped"));
|
||||
}
|
||||
|
||||
/* We've reached the original starting line. */
|
||||
if (fileptr == begin)
|
||||
/* We've reached the original starting line. */
|
||||
search_last_line = TRUE;
|
||||
|
||||
rev_start = fileptr->data;
|
||||
@@ -445,8 +428,7 @@ void do_search(void)
|
||||
i = search_init(FALSE, FALSE);
|
||||
|
||||
if (i == -1)
|
||||
/* Cancel, Go to Line, blank search string, or regcomp()
|
||||
* failed. */
|
||||
/* Cancel, Go to Line, blank search string, or regcomp() failed. */
|
||||
search_replace_abort();
|
||||
else if (i == -2)
|
||||
/* Replace. */
|
||||
@@ -478,35 +460,13 @@ void do_search(void)
|
||||
#ifndef DISABLE_SPELLER
|
||||
FALSE,
|
||||
#endif
|
||||
FALSE, openfile->current, openfile->current_x, answer, NULL);
|
||||
openfile->current, openfile->current_x, answer, NULL);
|
||||
|
||||
/* Check to see if there's only one occurrence of the string and
|
||||
* we're on it now. */
|
||||
/* If we found something, and we're back at the exact same spot where
|
||||
* we started searching, then this is the only occurrence. */
|
||||
if (fileptr == openfile->current && fileptr_x ==
|
||||
openfile->current_x && didfind) {
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* Do the search again, skipping over the current line, if we're
|
||||
* doing a bol and/or eol regex search ("^", "$", or "^$"), so
|
||||
* that we find one only once per line. We should only end up
|
||||
* back at the same position if the string isn't found again, in
|
||||
* which case it's the only occurrence. */
|
||||
if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp,
|
||||
last_search)) {
|
||||
didfind = findnextstr(
|
||||
#ifndef DISABLE_SPELLER
|
||||
FALSE,
|
||||
#endif
|
||||
TRUE, openfile->current,
|
||||
openfile->current_x, answer, NULL);
|
||||
if (fileptr == openfile->current && fileptr_x ==
|
||||
openfile->current_x && !didfind)
|
||||
statusbar(_("This is the only occurrence"));
|
||||
} else {
|
||||
#endif
|
||||
statusbar(_("This is the only occurrence"));
|
||||
#ifdef HAVE_REGEX_H
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
openfile->placewewant = xplustabs();
|
||||
@@ -523,7 +483,14 @@ void do_research(void)
|
||||
size_t pww_save = openfile->placewewant;
|
||||
bool didfind;
|
||||
|
||||
search_init_globals();
|
||||
focusing = TRUE;
|
||||
|
||||
#ifndef DISABLE_HISTORIES
|
||||
/* If nothing was searched for yet during this run of nano, but
|
||||
* there is a search history, take the most recent item. */
|
||||
if (last_search[0] == '\0' && searchbot->prev != NULL)
|
||||
last_search = mallocstrcpy(last_search, searchbot->prev->data);
|
||||
#endif
|
||||
|
||||
if (last_search[0] != '\0') {
|
||||
#ifdef HAVE_REGEX_H
|
||||
@@ -537,36 +504,13 @@ void do_research(void)
|
||||
#ifndef DISABLE_SPELLER
|
||||
FALSE,
|
||||
#endif
|
||||
FALSE, openfile->current, openfile->current_x,
|
||||
last_search, NULL);
|
||||
openfile->current, openfile->current_x, last_search, NULL);
|
||||
|
||||
/* Check to see if there's only one occurrence of the string and
|
||||
* we're on it now. */
|
||||
/* If we found something, and we're back at the exact same spot
|
||||
* where we started searching, then this is the only occurrence. */
|
||||
if (fileptr == openfile->current && fileptr_x ==
|
||||
openfile->current_x && didfind) {
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* Do the search again, skipping over the current line, if
|
||||
* we're doing a bol and/or eol regex search ("^", "$", or
|
||||
* "^$"), so that we find one only once per line. We should
|
||||
* only end up back at the same position if the string isn't
|
||||
* found again, in which case it's the only occurrence. */
|
||||
if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp,
|
||||
last_search)) {
|
||||
didfind = findnextstr(
|
||||
#ifndef DISABLE_SPELLER
|
||||
FALSE,
|
||||
#endif
|
||||
TRUE, openfile->current, openfile->current_x,
|
||||
answer, NULL);
|
||||
if (fileptr == openfile->current && fileptr_x ==
|
||||
openfile->current_x && !didfind)
|
||||
statusbar(_("This is the only occurrence"));
|
||||
} else {
|
||||
#endif /* HAVE_REGEX_H */
|
||||
statusbar(_("This is the only occurrence"));
|
||||
#ifdef HAVE_REGEX_H
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} else
|
||||
statusbar(_("No current search pattern"));
|
||||
@@ -679,7 +623,7 @@ char *replace_line(const char *needle)
|
||||
* canceled isn't NULL, set it to TRUE if we canceled. */
|
||||
ssize_t do_replace_loop(
|
||||
#ifndef DISABLE_SPELLER
|
||||
bool whole_word,
|
||||
bool whole_word_only,
|
||||
#endif
|
||||
bool *canceled, const filestruct *real_current, size_t
|
||||
*real_current_x, const char *needle)
|
||||
@@ -687,31 +631,28 @@ ssize_t do_replace_loop(
|
||||
ssize_t numreplaced = -1;
|
||||
size_t match_len;
|
||||
bool replaceall = FALSE;
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* The starting-line match and bol/eol regex flags. */
|
||||
bool begin_line = FALSE, bol_or_eol = FALSE;
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
bool old_mark_set = openfile->mark_set;
|
||||
filestruct *edittop_save = openfile->edittop, *top, *bot;
|
||||
filestruct *top, *bot;
|
||||
size_t top_x, bot_x;
|
||||
bool right_side_up = FALSE;
|
||||
/* TRUE if (mark_begin, mark_begin_x) is the top of the mark,
|
||||
* FALSE if (current, current_x) is. */
|
||||
|
||||
if (old_mark_set) {
|
||||
/* If the mark is on, partition the filestruct so that it
|
||||
* contains only the marked text, set edittop to the top of the
|
||||
* partition, turn the mark off, and refresh the screen. */
|
||||
/* If the mark is on, frame the region, and turn the mark off. */
|
||||
mark_order((const filestruct **)&top, &top_x,
|
||||
(const filestruct **)&bot, &bot_x, &right_side_up);
|
||||
filepart = partition_filestruct(top, top_x, bot, bot_x);
|
||||
openfile->edittop = openfile->fileage;
|
||||
openfile->mark_set = FALSE;
|
||||
#ifndef DISABLE_COLOR
|
||||
reset_multis(openfile->current, TRUE);
|
||||
#endif
|
||||
edit_refresh();
|
||||
|
||||
/* Start either at the top or the bottom of the marked region. */
|
||||
if (!ISSET(BACKWARDS_SEARCH)) {
|
||||
openfile->current = top;
|
||||
openfile->current_x = (top_x == 0 ? 0 : top_x - 1);
|
||||
} else {
|
||||
openfile->current = bot;
|
||||
openfile->current_x = bot_x;
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
@@ -721,41 +662,23 @@ ssize_t do_replace_loop(
|
||||
findnextstr_wrap_reset();
|
||||
while (findnextstr(
|
||||
#ifndef DISABLE_SPELLER
|
||||
whole_word,
|
||||
whole_word_only,
|
||||
#endif
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* We should find a bol and/or eol regex only once per line. If
|
||||
* the bol_or_eol flag is set, it means that the last search
|
||||
* found one on the beginning line, so we should skip over the
|
||||
* beginning line when doing this search. */
|
||||
bol_or_eol
|
||||
#else
|
||||
FALSE
|
||||
#endif
|
||||
, real_current, *real_current_x, needle, &match_len)) {
|
||||
real_current, *real_current_x, needle, &match_len)) {
|
||||
int i = 0;
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* If the bol_or_eol flag is set, we've found a match on the
|
||||
* beginning line already, and we're still on the beginning line
|
||||
* after the search, it means that we've wrapped around, so
|
||||
* we're done. */
|
||||
if (bol_or_eol && begin_line && openfile->current ==
|
||||
real_current)
|
||||
break;
|
||||
/* Otherwise, set the begin_line flag if we've found a match on
|
||||
* the beginning line, reset the bol_or_eol flag, and
|
||||
* continue. */
|
||||
else {
|
||||
if (openfile->current == real_current)
|
||||
begin_line = TRUE;
|
||||
bol_or_eol = FALSE;
|
||||
#ifndef NANO_TINY
|
||||
if (old_mark_set) {
|
||||
/* When we've found an occurrence outside of the marked region,
|
||||
* stop the fanfare. */
|
||||
if (openfile->current->lineno > bot->lineno ||
|
||||
openfile->current->lineno < top->lineno ||
|
||||
(openfile->current == bot && openfile->current_x > bot_x) ||
|
||||
(openfile->current == top && openfile->current_x < top_x))
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!replaceall)
|
||||
edit_refresh();
|
||||
|
||||
/* Indicate that we found the search string. */
|
||||
if (numreplaced == -1)
|
||||
numreplaced = 0;
|
||||
@@ -766,6 +689,8 @@ ssize_t do_replace_loop(
|
||||
xpt, strnlenpt(openfile->current->data,
|
||||
openfile->current_x + match_len) - xpt, FALSE);
|
||||
|
||||
edit_refresh();
|
||||
|
||||
curs_set(0);
|
||||
|
||||
do_replace_highlight(TRUE, exp_word);
|
||||
@@ -786,28 +711,19 @@ ssize_t do_replace_loop(
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* Set the bol_or_eol flag if we're doing a bol and/or eol regex
|
||||
* replace ("^", "$", or "^$"). */
|
||||
if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp,
|
||||
needle))
|
||||
bol_or_eol = TRUE;
|
||||
#endif
|
||||
|
||||
if (i > 0 || replaceall) { /* Yes, replace it!!!! */
|
||||
char *copy;
|
||||
size_t length_change;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
update_undo(REPLACE);
|
||||
add_undo(REPLACE);
|
||||
#endif
|
||||
if (i == 2)
|
||||
replaceall = TRUE;
|
||||
|
||||
copy = replace_line(needle);
|
||||
|
||||
length_change = strlen(copy) -
|
||||
strlen(openfile->current->data);
|
||||
length_change = strlen(copy) - strlen(openfile->current->data);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If the mark was on and (mark_begin, mark_begin_x) was the
|
||||
@@ -821,6 +737,7 @@ ssize_t do_replace_loop(
|
||||
openfile->mark_begin_x = openfile->current_x;
|
||||
else
|
||||
openfile->mark_begin_x += length_change;
|
||||
bot_x = openfile->mark_begin_x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -831,15 +748,14 @@ ssize_t do_replace_loop(
|
||||
/* Keep real_current_x in sync with the text changes. */
|
||||
if (openfile->current == real_current &&
|
||||
openfile->current_x <= *real_current_x) {
|
||||
if (*real_current_x <
|
||||
openfile->current_x + match_len)
|
||||
*real_current_x = openfile->current_x +
|
||||
match_len;
|
||||
if (*real_current_x < openfile->current_x + match_len)
|
||||
*real_current_x = openfile->current_x + match_len;
|
||||
*real_current_x += length_change;
|
||||
}
|
||||
#ifndef NANO_TINY
|
||||
}
|
||||
bot_x = *real_current_x;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Set the cursor at the last character of the replacement
|
||||
* text, so searching will resume after the replacement
|
||||
@@ -850,16 +766,19 @@ ssize_t do_replace_loop(
|
||||
#endif
|
||||
openfile->current_x += match_len + length_change - 1;
|
||||
|
||||
/* Cleanup. */
|
||||
/* Clean up. */
|
||||
openfile->totsize += mbstrlen(copy) -
|
||||
mbstrlen(openfile->current->data);
|
||||
free(openfile->current->data);
|
||||
openfile->current->data = copy;
|
||||
|
||||
#ifndef DISABLE_COLOR
|
||||
reset_multis(openfile->current, TRUE);
|
||||
/* Reset the precalculated multiline-regex hints only when
|
||||
* the first replacement has been made. */
|
||||
if (numreplaced == 0)
|
||||
reset_multis(openfile->current, TRUE);
|
||||
#endif
|
||||
edit_refresh();
|
||||
|
||||
if (!replaceall) {
|
||||
#ifndef DISABLE_COLOR
|
||||
/* If color syntaxes are available and turned on, we
|
||||
@@ -877,16 +796,12 @@ ssize_t do_replace_loop(
|
||||
}
|
||||
}
|
||||
|
||||
if (numreplaced == -1)
|
||||
not_found_msg(needle);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (old_mark_set) {
|
||||
/* If the mark was on, unpartition the filestruct so that it
|
||||
* contains all the text again, set edittop back to what it was
|
||||
* before, turn the mark back on, and refresh the screen. */
|
||||
unpartition_filestruct(&filepart);
|
||||
openfile->edittop = edittop_save;
|
||||
if (old_mark_set)
|
||||
openfile->mark_set = TRUE;
|
||||
edit_refresh();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If the NO_NEWLINES flag isn't set, and text has been added to the
|
||||
@@ -913,8 +828,7 @@ void do_replace(void)
|
||||
|
||||
i = search_init(TRUE, FALSE);
|
||||
if (i == -1) {
|
||||
/* Cancel, Go to Line, blank search string, or regcomp()
|
||||
* failed. */
|
||||
/* Cancel, Go to Line, blank search string, or regcomp() failed. */
|
||||
search_replace_abort();
|
||||
return;
|
||||
} else if (i == -2) {
|
||||
@@ -951,8 +865,7 @@ void do_replace(void)
|
||||
edit_refresh, _("Replace with"));
|
||||
|
||||
#ifndef DISABLE_HISTORIES
|
||||
/* Add this replace string to the replace history list. i == 0
|
||||
* means that the string is not "". */
|
||||
/* If the replace string is not "", add it to the replace history list. */
|
||||
if (i == 0)
|
||||
update_history(&replace_history, answer);
|
||||
#endif
|
||||
@@ -1085,7 +998,6 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
/* If allow_update is TRUE, update the screen. */
|
||||
if (allow_update) {
|
||||
edit_refresh();
|
||||
|
||||
display_main_list();
|
||||
}
|
||||
}
|
||||
@@ -1144,8 +1056,8 @@ bool find_bracket_match(bool reverse, const char *bracket_set)
|
||||
mbrevstrpbrk(fileptr->data, bracket_set, rev_start) :
|
||||
mbstrpbrk(rev_start, bracket_set));
|
||||
|
||||
/* We've found a potential match. */
|
||||
if (found != NULL)
|
||||
/* We've found a potential match. */
|
||||
break;
|
||||
|
||||
if (reverse) {
|
||||
@@ -1156,8 +1068,8 @@ bool find_bracket_match(bool reverse, const char *bracket_set)
|
||||
current_y_find++;
|
||||
}
|
||||
|
||||
/* We've reached the start or end of the buffer, so get out. */
|
||||
if (fileptr == NULL)
|
||||
/* We've reached the start or end of the buffer, so get out. */
|
||||
return FALSE;
|
||||
|
||||
rev_start = fileptr->data;
|
||||
@@ -1373,8 +1285,7 @@ void update_history(filestruct **h, const char *s)
|
||||
bar = p->next;
|
||||
unlink_node(foo);
|
||||
delete_node(foo);
|
||||
if (bar != NULL)
|
||||
renumber(bar);
|
||||
renumber(bar);
|
||||
}
|
||||
|
||||
/* If the history is full, delete the beginning entry to make room
|
||||
|
||||
430
src/text.c
430
src/text.c
@@ -63,6 +63,18 @@ void do_mark(void)
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
#if !defined(DISABLE_COLOR) || !defined(DISABLE_SPELLER)
|
||||
/* Return an error message containing the given name. */
|
||||
char *invocation_error(const char *name)
|
||||
{
|
||||
char *message, *invoke_error = _("Error invoking \"%s\"");
|
||||
|
||||
message = charalloc(strlen(invoke_error) + strlen(name) + 1);
|
||||
sprintf(message, invoke_error, name);
|
||||
return message;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Delete the character under the cursor. */
|
||||
void do_deletion(undo_type action)
|
||||
{
|
||||
@@ -70,7 +82,8 @@ void do_deletion(undo_type action)
|
||||
size_t orig_lenpt = 0;
|
||||
#endif
|
||||
|
||||
assert(openfile->current != NULL && openfile->current->data != NULL && openfile->current_x <= strlen(openfile->current->data));
|
||||
assert(openfile->current != NULL && openfile->current->data != NULL &&
|
||||
openfile->current_x <= strlen(openfile->current->data));
|
||||
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
@@ -97,9 +110,8 @@ void do_deletion(undo_type action)
|
||||
null_at(&openfile->current->data, openfile->current_x +
|
||||
line_len - char_buf_len);
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->mark_set && openfile->mark_begin ==
|
||||
openfile->current && openfile->current_x <
|
||||
openfile->mark_begin_x)
|
||||
if (openfile->mark_set && openfile->mark_begin == openfile->current &&
|
||||
openfile->current_x < openfile->mark_begin_x)
|
||||
openfile->mark_begin_x -= char_buf_len;
|
||||
#endif
|
||||
openfile->totsize--;
|
||||
@@ -111,17 +123,13 @@ void do_deletion(undo_type action)
|
||||
#ifndef NANO_TINY
|
||||
add_undo(action);
|
||||
#endif
|
||||
/* If we're deleting at the end of a line, we need to call
|
||||
* edit_refresh(). */
|
||||
if (openfile->current->data[openfile->current_x] == '\0')
|
||||
edit_refresh_needed = TRUE;
|
||||
|
||||
openfile->current->data = charealloc(openfile->current->data,
|
||||
strlen(openfile->current->data) + strlen(foo->data) + 1);
|
||||
strcat(openfile->current->data, foo->data);
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->mark_set && openfile->mark_begin ==
|
||||
openfile->current->next) {
|
||||
if (openfile->mark_set &&
|
||||
openfile->mark_begin == openfile->current->next) {
|
||||
openfile->mark_begin = openfile->current;
|
||||
openfile->mark_begin_x += openfile->current_x;
|
||||
}
|
||||
@@ -134,11 +142,14 @@ void do_deletion(undo_type action)
|
||||
renumber(openfile->current);
|
||||
openfile->totsize--;
|
||||
|
||||
/* Two lines were joined, so we need to refresh the screen. */
|
||||
edit_refresh_needed = TRUE;
|
||||
|
||||
/* If the NO_NEWLINES flag isn't set, and text has been added to
|
||||
* the magicline as a result of deleting at the end of the line
|
||||
* before filebot, add a new magicline. */
|
||||
if (!ISSET(NO_NEWLINES) && openfile->current ==
|
||||
openfile->filebot && openfile->current->data[0] != '\0')
|
||||
if (!ISSET(NO_NEWLINES) && openfile->current == openfile->filebot &&
|
||||
openfile->current->data[0] != '\0')
|
||||
new_magicline();
|
||||
} else
|
||||
return;
|
||||
@@ -155,6 +166,7 @@ void do_deletion(undo_type action)
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
}
|
||||
|
||||
/* Delete the character under the cursor. */
|
||||
void do_delete(void)
|
||||
{
|
||||
do_deletion(DEL);
|
||||
@@ -164,8 +176,7 @@ void do_delete(void)
|
||||
* character, and then delete the character under the cursor. */
|
||||
void do_backspace(void)
|
||||
{
|
||||
if (openfile->current != openfile->fileage ||
|
||||
openfile->current_x > 0) {
|
||||
if (openfile->current != openfile->fileage || openfile->current_x > 0) {
|
||||
do_left();
|
||||
do_deletion(BACK);
|
||||
}
|
||||
@@ -193,12 +204,9 @@ void do_tab(void)
|
||||
do_output(output, output_len, TRUE);
|
||||
|
||||
free(output);
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
do_output((char *) "\t", 1, TRUE);
|
||||
#ifndef NANO_TINY
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -277,8 +285,7 @@ void do_indent(ssize_t cols)
|
||||
if (!unindent) {
|
||||
/* If we're indenting, add the characters in line_indent to
|
||||
* the beginning of the non-whitespace text of this line. */
|
||||
f->data = charealloc(f->data, line_len +
|
||||
line_indent_len + 1);
|
||||
f->data = charealloc(f->data, line_len + line_indent_len + 1);
|
||||
charmove(&f->data[indent_len + line_indent_len],
|
||||
&f->data[indent_len], line_len - indent_len + 1);
|
||||
strncpy(f->data + indent_len, line_indent, line_indent_len);
|
||||
@@ -286,11 +293,10 @@ void do_indent(ssize_t cols)
|
||||
|
||||
/* Keep track of the change in the current line. */
|
||||
if (openfile->mark_set && f == openfile->mark_begin &&
|
||||
openfile->mark_begin_x >= indent_len)
|
||||
openfile->mark_begin_x >= indent_len)
|
||||
openfile->mark_begin_x += line_indent_len;
|
||||
|
||||
if (f == openfile->current && openfile->current_x >=
|
||||
indent_len)
|
||||
if (f == openfile->current && openfile->current_x >= indent_len)
|
||||
openfile->current_x += line_indent_len;
|
||||
|
||||
/* If the NO_NEWLINES flag isn't set, and this is the
|
||||
@@ -299,12 +305,10 @@ void do_indent(ssize_t cols)
|
||||
new_magicline();
|
||||
} else {
|
||||
size_t indent_col = strnlenpt(f->data, indent_len);
|
||||
/* The length in columns of the indentation on this
|
||||
* line. */
|
||||
/* The length in columns of the indentation on this line. */
|
||||
|
||||
if (cols <= indent_col) {
|
||||
size_t indent_new = actual_x(f->data, indent_col -
|
||||
cols);
|
||||
size_t indent_new = actual_x(f->data, indent_col - cols);
|
||||
/* The length of the indentation remaining on
|
||||
* this line after we unindent. */
|
||||
size_t indent_shift = indent_len - indent_new;
|
||||
@@ -328,17 +332,16 @@ void do_indent(ssize_t cols)
|
||||
openfile->mark_begin_x -= indent_shift;
|
||||
}
|
||||
|
||||
if (f == openfile->current && openfile->current_x >
|
||||
indent_new) {
|
||||
if (f == openfile->current &&
|
||||
openfile->current_x > indent_new) {
|
||||
if (openfile->current_x <= indent_len)
|
||||
openfile->current_x = indent_new;
|
||||
else
|
||||
openfile->current_x -= indent_shift;
|
||||
}
|
||||
|
||||
/* We've unindented, so set indent_changed to TRUE. */
|
||||
if (!indent_changed)
|
||||
indent_changed = TRUE;
|
||||
/* We've unindented, so the indentation changed. */
|
||||
indent_changed = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -381,14 +384,14 @@ void undo_cut(undo *u)
|
||||
return;
|
||||
|
||||
/* Get to where we need to uncut from. */
|
||||
if (u->xflags == UNcut_cutline)
|
||||
if (u->xflags == WAS_WHOLE_LINE)
|
||||
goto_line_posx(u->mark_begin_lineno, 0);
|
||||
else
|
||||
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
|
||||
|
||||
copy_from_filestruct(u->cutbuffer);
|
||||
|
||||
if (u->xflags != UNcut_marked_forward && u->type != PASTE)
|
||||
if (u->xflags != WAS_MARKED_FORWARD && u->type != PASTE)
|
||||
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
|
||||
}
|
||||
|
||||
@@ -412,7 +415,7 @@ void redo_cut(undo *u)
|
||||
|
||||
openfile->mark_set = TRUE;
|
||||
openfile->mark_begin = fsfromline(u->mark_begin_lineno);
|
||||
openfile->mark_begin_x = (u->xflags == UNcut_cutline) ? 0 : u->mark_begin_x;
|
||||
openfile->mark_begin_x = (u->xflags == WAS_WHOLE_LINE) ? 0 : u->mark_begin_x;
|
||||
|
||||
do_cut_text(FALSE, FALSE, TRUE);
|
||||
|
||||
@@ -442,12 +445,12 @@ void do_undo(void)
|
||||
|
||||
filestruct *f = fsfromline(u->mark_begin_lineno);
|
||||
if (!f) {
|
||||
statusbar(_("Internal error: can't match line %ld. Please save your work."), (long)u->mark_begin_lineno);
|
||||
statusbar(_("Internal error: can't match line %d. Please save your work."), u->mark_begin_lineno);
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "data we're about to undo = \"%s\"\n", f->data);
|
||||
fprintf(stderr, "Undo running for type %d\n", u->type);
|
||||
fprintf(stderr, " >> Undoing a type %d...\n", u->type);
|
||||
fprintf(stderr, " >> Data we're about to undo = \"%s\"\n", f->data);
|
||||
#endif
|
||||
|
||||
openfile->current_x = u->begin;
|
||||
@@ -486,18 +489,22 @@ void do_undo(void)
|
||||
case SPLIT_BEGIN:
|
||||
undidmsg = _("text add");
|
||||
break;
|
||||
#endif /* !DISABLE_WRAPPING */
|
||||
#endif
|
||||
case JOIN:
|
||||
undidmsg = _("line join");
|
||||
t = make_new_node(f);
|
||||
t->data = mallocstrcpy(NULL, u->strdata);
|
||||
data = mallocstrncpy(NULL, f->data, u->mark_begin_x + 1);
|
||||
data[u->mark_begin_x] = '\0';
|
||||
free(f->data);
|
||||
f->data = data;
|
||||
splice_node(f, t, f->next);
|
||||
if (f == openfile->filebot)
|
||||
openfile->filebot = t;
|
||||
/* When the join was done by a Backspace at the tail of the file,
|
||||
* don't actually add another line; just position the cursor. */
|
||||
if (ISSET(NO_NEWLINES) || u->xflags != WAS_FINAL_BACKSPACE) {
|
||||
t = make_new_node(f);
|
||||
t->data = mallocstrcpy(NULL, u->strdata);
|
||||
data = mallocstrncpy(NULL, f->data, u->mark_begin_x + 1);
|
||||
data[u->mark_begin_x] = '\0';
|
||||
free(f->data);
|
||||
f->data = data;
|
||||
splice_node(f, t, f->next);
|
||||
if (f == openfile->filebot)
|
||||
openfile->filebot = t;
|
||||
}
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
break;
|
||||
case CUT_EOF:
|
||||
@@ -636,7 +643,7 @@ void do_redo(void)
|
||||
case SPLIT_END:
|
||||
redidmsg = _("text add");
|
||||
break;
|
||||
#endif /* !DISABLE_WRAPPING */
|
||||
#endif
|
||||
case JOIN:
|
||||
redidmsg = _("line join");
|
||||
len = strlen(f->data) + strlen(u->strdata) + 1;
|
||||
@@ -724,9 +731,8 @@ void do_enter(bool undoing)
|
||||
#endif
|
||||
null_at(&openfile->current->data, openfile->current_x);
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->mark_set && openfile->current ==
|
||||
openfile->mark_begin && openfile->current_x <
|
||||
openfile->mark_begin_x) {
|
||||
if (openfile->mark_set && openfile->current == openfile->mark_begin &&
|
||||
openfile->current_x < openfile->mark_begin_x) {
|
||||
openfile->mark_begin = newnode;
|
||||
openfile->mark_begin_x += extra - openfile->current_x;
|
||||
}
|
||||
@@ -735,8 +741,7 @@ void do_enter(bool undoing)
|
||||
|
||||
if (openfile->current == openfile->filebot)
|
||||
openfile->filebot = newnode;
|
||||
splice_node(openfile->current, newnode,
|
||||
openfile->current->next);
|
||||
splice_node(openfile->current, newnode, openfile->current->next);
|
||||
|
||||
renumber(openfile->current);
|
||||
openfile->current = newnode;
|
||||
@@ -854,35 +859,41 @@ bool execute_command(const char *command)
|
||||
}
|
||||
|
||||
/* Add a new undo struct to the top of the current pile. */
|
||||
void add_undo(undo_type current_action)
|
||||
void add_undo(undo_type action)
|
||||
{
|
||||
undo *u;
|
||||
char *data;
|
||||
openfilestruct *fs = openfile;
|
||||
/* Last thing we cut to set up the undo for uncut. */
|
||||
undo *u = fs->current_undo;
|
||||
/* The thing we did previously. */
|
||||
|
||||
/* Ugh, if we were called while cutting not-to-end, non-marked, and
|
||||
* on the same lineno, we need to abort here. */
|
||||
u = fs->current_undo;
|
||||
/* When doing contiguous adds or contiguous cuts -- which means: with
|
||||
* no cursor movement in between -- don't add a new undo item. */
|
||||
if (u && u->mark_begin_lineno == fs->current->lineno &&
|
||||
((current_action == CUT && u->type == CUT && !u->mark_set && keeping_cutbuffer()) ||
|
||||
(current_action == ADD && u->type == ADD && u->mark_begin_x == fs->current_x)))
|
||||
((action == ADD && u->type == ADD && u->mark_begin_x == fs->current_x) ||
|
||||
(action == CUT && u->type == CUT && !u->mark_set && keeping_cutbuffer())))
|
||||
return;
|
||||
/* When trying to delete the final newline, don't add an undo for it. */
|
||||
if (action == DEL && openfile->current->next == openfile->filebot &&
|
||||
openfile->current->data[openfile->current_x] == '\0' &&
|
||||
openfile->current_x != 0 && !ISSET(NO_NEWLINES))
|
||||
return;
|
||||
|
||||
/* Blow away the old undo stack if we are starting from the middle. */
|
||||
while (fs->undotop != NULL && fs->undotop != fs->current_undo) {
|
||||
undo *u2 = fs->undotop;
|
||||
fs->undotop = fs->undotop->next;
|
||||
if (u2->strdata != NULL)
|
||||
free(u2->strdata);
|
||||
free(u2->strdata);
|
||||
if (u2->cutbuffer)
|
||||
free_filestruct(u2->cutbuffer);
|
||||
free(u2);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " >> Adding an undo...\n");
|
||||
#endif
|
||||
|
||||
/* Allocate and initialize a new undo type. */
|
||||
u = (undo *) nmalloc(sizeof(undo));
|
||||
u->type = current_action;
|
||||
u->type = action;
|
||||
u->lineno = fs->current->lineno;
|
||||
u->begin = fs->current_x;
|
||||
#ifndef DISABLE_WRAPPING
|
||||
@@ -913,6 +924,10 @@ void add_undo(undo_type current_action)
|
||||
case ADD:
|
||||
break;
|
||||
case BACK:
|
||||
/* If the next line is the magic line, don't ever undo this
|
||||
* backspace, as it won't actually have deleted anything. */
|
||||
if (fs->current->next == fs->filebot && fs->current->data[0] != '\0')
|
||||
u->xflags = WAS_FINAL_BACKSPACE;
|
||||
case DEL:
|
||||
if (u->begin != strlen(fs->current->data)) {
|
||||
char *char_buf = charalloc(mb_cur_max() + 1);
|
||||
@@ -930,23 +945,21 @@ void add_undo(undo_type current_action)
|
||||
u->lineno = fs->current->next->lineno;
|
||||
u->begin = 0;
|
||||
}
|
||||
data = mallocstrcpy(NULL, fs->current->next->data);
|
||||
u->strdata = data;
|
||||
u->strdata = mallocstrcpy(NULL, fs->current->next->data);
|
||||
}
|
||||
current_action = u->type = JOIN;
|
||||
action = u->type = JOIN;
|
||||
break;
|
||||
#ifndef DISABLE_WRAPPING
|
||||
case SPLIT_BEGIN:
|
||||
current_action = fs->undotop->type;
|
||||
action = fs->undotop->type;
|
||||
break;
|
||||
case SPLIT_END:
|
||||
break;
|
||||
#endif /* !DISABLE_WRAPPING */
|
||||
#endif
|
||||
case INSERT:
|
||||
break;
|
||||
case REPLACE:
|
||||
data = mallocstrcpy(NULL, fs->current->data);
|
||||
u->strdata = data;
|
||||
u->strdata = mallocstrcpy(NULL, fs->current->data);
|
||||
break;
|
||||
case CUT_EOF:
|
||||
cutbuffer_reset();
|
||||
@@ -961,7 +974,7 @@ void add_undo(undo_type current_action)
|
||||
else if (!ISSET(CUT_TO_END)) {
|
||||
/* The entire line is being cut regardless of the cursor position. */
|
||||
u->begin = 0;
|
||||
u->xflags = UNcut_cutline;
|
||||
u->xflags = WAS_WHOLE_LINE;
|
||||
}
|
||||
break;
|
||||
case PASTE:
|
||||
@@ -985,11 +998,10 @@ void add_undo(undo_type current_action)
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "fs->current->data = \"%s\", current_x = %lu, u->begin = %lu, type = %d\n",
|
||||
fs->current->data, (unsigned long)fs->current_x, (unsigned long)u->begin, current_action);
|
||||
fprintf(stderr, "left add_undo...\n");
|
||||
fprintf(stderr, " >> fs->current->data = \"%s\", current_x = %lu, u->begin = %lu, type = %d\n",
|
||||
fs->current->data, (unsigned long)fs->current_x, (unsigned long)u->begin, action);
|
||||
#endif
|
||||
fs->last_action = current_action;
|
||||
fs->last_action = action;
|
||||
}
|
||||
|
||||
/* Update an undo item, or determine whether a new one is really needed
|
||||
@@ -1002,10 +1014,10 @@ void update_undo(undo_type action)
|
||||
openfilestruct *fs = openfile;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno = %ld",
|
||||
fprintf(stderr, " >> Updating... action = %d, fs->last_action = %d, openfile->current->lineno = %ld",
|
||||
action, fs->last_action, (long)openfile->current->lineno);
|
||||
if (fs->current_undo)
|
||||
fprintf(stderr, "fs->current_undo->lineno = %ld\n", (long)fs->current_undo->lineno);
|
||||
fprintf(stderr, ", fs->current_undo->lineno = %ld\n", (long)fs->current_undo->lineno);
|
||||
else
|
||||
fprintf(stderr, "\n");
|
||||
#endif
|
||||
@@ -1025,14 +1037,14 @@ fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno =
|
||||
switch (u->type) {
|
||||
case ADD: {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "fs->current->data = \"%s\", current_x = %lu, u->begin = %lu\n",
|
||||
fprintf(stderr, " >> fs->current->data = \"%s\", current_x = %lu, u->begin = %lu\n",
|
||||
fs->current->data, (unsigned long)fs->current_x, (unsigned long)u->begin);
|
||||
#endif
|
||||
char *char_buf = charalloc(mb_cur_max());
|
||||
size_t char_buf_len = parse_mbchar(&fs->current->data[u->mark_begin_x], char_buf, NULL);
|
||||
u->strdata = addstrings(u->strdata, u->strdata ? strlen(u->strdata) : 0, char_buf, char_buf_len);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "current undo data now \"%s\"\n", u->strdata);
|
||||
fprintf(stderr, " >> current undo data is \"%s\"\n", u->strdata);
|
||||
#endif
|
||||
u->mark_begin_lineno = fs->current->lineno;
|
||||
u->mark_begin_x = fs->current_x;
|
||||
@@ -1057,7 +1069,7 @@ fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno =
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "current undo data now \"%s\"\nu->begin = %lu\n", u->strdata, (unsigned long)u->begin);
|
||||
fprintf(stderr, " >> current undo data is \"%s\"\nu->begin = %lu\n", u->strdata, (unsigned long)u->begin);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
@@ -1081,7 +1093,7 @@ fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno =
|
||||
u->lineno = u->mark_begin_lineno;
|
||||
u->mark_begin_lineno = line;
|
||||
} else
|
||||
u->xflags = UNcut_marked_forward;
|
||||
u->xflags = WAS_MARKED_FORWARD;
|
||||
} else {
|
||||
/* Compute cutbottom for the uncut using our copy. */
|
||||
u->cutbottom = u->cutbuffer;
|
||||
@@ -1090,8 +1102,8 @@ fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno =
|
||||
u->lineno = u->mark_begin_lineno + u->cutbottom->lineno - u->cutbuffer->lineno;
|
||||
if (ISSET(CUT_TO_END) || u->type == CUT_EOF) {
|
||||
u->begin = strlen(u->cutbottom->data);
|
||||
if(u->lineno == u->mark_begin_lineno)
|
||||
u->begin += u->mark_begin_x;
|
||||
if (u->lineno == u->mark_begin_lineno)
|
||||
u->begin += u->mark_begin_x;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1109,7 +1121,7 @@ fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno =
|
||||
#ifndef DISABLE_WRAPPING
|
||||
case SPLIT_BEGIN:
|
||||
case SPLIT_END:
|
||||
#endif /* !DISABLE_WRAPPING */
|
||||
#endif
|
||||
case JOIN:
|
||||
/* These cases are handled by the earlier check for a new line and action. */
|
||||
case OTHER:
|
||||
@@ -1117,7 +1129,7 @@ fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno =
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Done in update_undo (type was %d)\n", action);
|
||||
fprintf(stderr, " >> Done in update_undo (type was %d)\n", action);
|
||||
#endif
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
@@ -1910,10 +1922,6 @@ void do_justify(bool full_justify)
|
||||
if (full_justify)
|
||||
openfile->current = openfile->fileage;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
allow_pending_sigwinch(FALSE);
|
||||
#endif
|
||||
|
||||
while (TRUE) {
|
||||
size_t i;
|
||||
/* Generic loop variable. */
|
||||
@@ -2195,17 +2203,6 @@ void do_justify(bool full_justify)
|
||||
|
||||
edit_refresh();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* We're going to set jump_buf so that we return here after a
|
||||
* SIGWINCH instead of to main(). Indicate this. */
|
||||
jump_buf_main = FALSE;
|
||||
|
||||
/* Return here after a SIGWINCH. */
|
||||
sigsetjmp(jump_buf, 1);
|
||||
#endif
|
||||
|
||||
statusbar(_("Can now UnJustify!"));
|
||||
|
||||
/* If constant cursor position display is on, make sure the current
|
||||
* cursor position will be properly displayed on the statusbar. */
|
||||
if (ISSET(CONST_UPDATE))
|
||||
@@ -2213,12 +2210,19 @@ void do_justify(bool full_justify)
|
||||
|
||||
/* Display the shortcut list with UnJustify. */
|
||||
uncutfunc->desc = unjust_tag;
|
||||
currmenu = MMAIN;
|
||||
display_main_list();
|
||||
|
||||
/* Now get a keystroke and see if it's unjustify. If not, put back
|
||||
* the keystroke and return. */
|
||||
kbinput = do_input(FALSE);
|
||||
#ifndef NANO_TINY
|
||||
do {
|
||||
#endif
|
||||
statusbar(_("Can now UnJustify!"));
|
||||
kbinput = do_input(FALSE);
|
||||
#ifndef NANO_TINY
|
||||
} while (kbinput == KEY_WINCH);
|
||||
#endif
|
||||
|
||||
func = func_from_key(&kbinput);
|
||||
|
||||
if (func == do_uncut_text) {
|
||||
@@ -2246,8 +2250,8 @@ void do_justify(bool full_justify)
|
||||
* replaced with the unjustified paragraph. */
|
||||
unpartition_filestruct(&filepart);
|
||||
|
||||
/* Renumber starting with the beginning line of the old
|
||||
* partition. */
|
||||
/* Renumber, starting with the beginning line of the old
|
||||
* partition. */
|
||||
renumber(top_save);
|
||||
|
||||
/* Restore the justify we just did (ungrateful user!). */
|
||||
@@ -2284,10 +2288,6 @@ void do_justify(bool full_justify)
|
||||
/* Display the shortcut list with UnCut. */
|
||||
uncutfunc->desc = uncut_tag;
|
||||
display_main_list();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
allow_pending_sigwinch(TRUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Justify the current paragraph. */
|
||||
@@ -2316,13 +2316,8 @@ bool do_int_spell_fix(const char *word)
|
||||
/* Save where we are. */
|
||||
bool canceled = FALSE;
|
||||
/* The return value. */
|
||||
bool case_sens_set = ISSET(CASE_SENSITIVE);
|
||||
#ifndef NANO_TINY
|
||||
bool backwards_search_set = ISSET(BACKWARDS_SEARCH);
|
||||
#endif
|
||||
#ifdef HAVE_REGEX_H
|
||||
bool regexp_set = ISSET(USE_REGEXP);
|
||||
#endif
|
||||
unsigned stash[sizeof(flags) / sizeof(flags[0])];
|
||||
/* A storage place for the current flag settings. */
|
||||
#ifndef NANO_TINY
|
||||
bool old_mark_set = openfile->mark_set;
|
||||
bool added_magicline = FALSE;
|
||||
@@ -2334,6 +2329,9 @@ bool do_int_spell_fix(const char *word)
|
||||
size_t top_x, bot_x;
|
||||
#endif
|
||||
|
||||
/* Save the settings of the global flags. */
|
||||
memcpy(stash, flags, sizeof(flags));
|
||||
|
||||
/* Make sure spell-check is case sensitive. */
|
||||
SET(CASE_SENSITIVE);
|
||||
|
||||
@@ -2347,7 +2345,6 @@ bool do_int_spell_fix(const char *word)
|
||||
#endif
|
||||
|
||||
/* Save the current search/replace strings. */
|
||||
search_init_globals();
|
||||
save_search = last_search;
|
||||
save_replace = last_replace;
|
||||
|
||||
@@ -2355,6 +2352,8 @@ bool do_int_spell_fix(const char *word)
|
||||
last_search = mallocstrcpy(NULL, word);
|
||||
last_replace = mallocstrcpy(NULL, word);
|
||||
|
||||
focusing = TRUE;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (old_mark_set) {
|
||||
/* If the mark is on, partition the filestruct so that it
|
||||
@@ -2379,8 +2378,7 @@ bool do_int_spell_fix(const char *word)
|
||||
|
||||
/* Find the first whole occurrence of word. */
|
||||
findnextstr_wrap_reset();
|
||||
while (findnextstr(TRUE, FALSE, openfile->fileage, 0, word,
|
||||
&match_len)) {
|
||||
while (findnextstr(TRUE, openfile->fileage, 0, word, &match_len)) {
|
||||
if (is_whole_word(openfile->current_x, openfile->current->data,
|
||||
word)) {
|
||||
size_t xpt = xplustabs();
|
||||
@@ -2441,7 +2439,7 @@ bool do_int_spell_fix(const char *word)
|
||||
unpartition_filestruct(&filepart);
|
||||
openfile->mark_set = TRUE;
|
||||
}
|
||||
#endif
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Restore the search/replace strings. */
|
||||
free(last_search);
|
||||
@@ -2455,20 +2453,8 @@ bool do_int_spell_fix(const char *word)
|
||||
openfile->current_x = current_x_save;
|
||||
openfile->placewewant = pww_save;
|
||||
|
||||
/* Restore case sensitivity setting. */
|
||||
if (!case_sens_set)
|
||||
UNSET(CASE_SENSITIVE);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Restore search/replace direction. */
|
||||
if (backwards_search_set)
|
||||
SET(BACKWARDS_SEARCH);
|
||||
#endif
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* Restore regular expression usage setting. */
|
||||
if (regexp_set)
|
||||
SET(USE_REGEXP);
|
||||
#endif
|
||||
/* Restore the settings of the global flags. */
|
||||
memcpy(flags, stash, sizeof(flags));
|
||||
|
||||
return !canceled;
|
||||
}
|
||||
@@ -2523,7 +2509,7 @@ const char *do_int_speller(const char *tempfile_name)
|
||||
|
||||
/* A new process to run sort in. */
|
||||
if ((pid_sort = fork()) == 0) {
|
||||
/* Child continues (i.e. future spell process). Replace the
|
||||
/* Child continues (i.e. future sort process). Replace the
|
||||
* standard input with the standard output of the old pipe. */
|
||||
if (dup2(spell_fd[0], STDIN_FILENO) != STDIN_FILENO)
|
||||
goto close_pipes_and_exit;
|
||||
@@ -2536,8 +2522,7 @@ const char *do_int_speller(const char *tempfile_name)
|
||||
|
||||
close(sort_fd[1]);
|
||||
|
||||
/* Start the sort program. Use -f to remove mixed case. If
|
||||
* this isn't portable, let me know. */
|
||||
/* Start the sort program. Use -f to ignore case. */
|
||||
execlp("sort", "sort", "-f", NULL);
|
||||
|
||||
/* This should not be reached if sort is found. */
|
||||
@@ -2626,7 +2611,7 @@ const char *do_int_speller(const char *tempfile_name)
|
||||
search_replace_abort();
|
||||
edit_refresh_needed = TRUE;
|
||||
|
||||
/* Process the end of the spell process. */
|
||||
/* Process the end of the three processes. */
|
||||
waitpid(pid_spell, &spell_status, 0);
|
||||
waitpid(pid_sort, &sort_status, 0);
|
||||
waitpid(pid_uniq, &uniq_status, 0);
|
||||
@@ -2661,9 +2646,10 @@ const char *do_alt_speller(char *tempfile_name)
|
||||
{
|
||||
int alt_spell_status;
|
||||
size_t current_x_save = openfile->current_x;
|
||||
size_t pww_save = openfile->placewewant;
|
||||
ssize_t current_y_save = openfile->current_y;
|
||||
ssize_t lineno_save = openfile->current->lineno;
|
||||
struct stat spellfileinfo;
|
||||
time_t timestamp;
|
||||
pid_t pid_spell;
|
||||
char *ptr;
|
||||
static int arglen = 3;
|
||||
@@ -2672,11 +2658,9 @@ const char *do_alt_speller(char *tempfile_name)
|
||||
bool old_mark_set = openfile->mark_set;
|
||||
bool added_magicline = FALSE;
|
||||
/* Whether we added a magicline after filebot. */
|
||||
bool right_side_up = FALSE;
|
||||
/* TRUE if (mark_begin, mark_begin_x) is the top of the mark,
|
||||
* FALSE if (current, current_x) is. */
|
||||
filestruct *top, *bot;
|
||||
size_t top_x, bot_x;
|
||||
bool right_side_up = FALSE;
|
||||
ssize_t mb_lineno_save = 0;
|
||||
/* We're going to close the current file, and open the output of
|
||||
* the alternate spell command. The line that mark_begin points
|
||||
@@ -2685,7 +2669,17 @@ const char *do_alt_speller(char *tempfile_name)
|
||||
size_t totsize_save = openfile->totsize;
|
||||
/* Our saved value of totsize, used when we spell-check a marked
|
||||
* selection. */
|
||||
#endif
|
||||
|
||||
/* Get the timestamp and the size of the temporary file. */
|
||||
stat(tempfile_name, &spellfileinfo);
|
||||
timestamp = spellfileinfo.st_mtime;
|
||||
|
||||
/* If the number of bytes to check is zero, get out. */
|
||||
if (spellfileinfo.st_size == 0)
|
||||
return NULL;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (old_mark_set) {
|
||||
/* If the mark is on, save the number of the line it starts on,
|
||||
* and then turn the mark off. */
|
||||
@@ -2694,14 +2688,9 @@ const char *do_alt_speller(char *tempfile_name)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (openfile->totsize == 0) {
|
||||
statusbar(_("Finished checking spelling"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
endwin();
|
||||
|
||||
/* Set up an argument list to pass execvp(). */
|
||||
/* Set up an argument list to pass to execvp(). */
|
||||
if (spellargs == NULL) {
|
||||
spellargs = (char **)nmalloc(arglen * sizeof(char *));
|
||||
|
||||
@@ -2751,21 +2740,12 @@ const char *do_alt_speller(char *tempfile_name)
|
||||
* the windows based on the new screen dimensions. */
|
||||
window_init();
|
||||
|
||||
if (!WIFEXITED(alt_spell_status) ||
|
||||
WEXITSTATUS(alt_spell_status) != 0) {
|
||||
char *alt_spell_error;
|
||||
char *invoke_error = _("Error invoking \"%s\"");
|
||||
|
||||
if (!WIFEXITED(alt_spell_status) || WEXITSTATUS(alt_spell_status) != 0) {
|
||||
#ifndef NANO_TINY
|
||||
/* Turn the mark back on if it was on before. */
|
||||
openfile->mark_set = old_mark_set;
|
||||
#endif
|
||||
|
||||
alt_spell_error =
|
||||
charalloc(strlen(invoke_error) +
|
||||
strlen(alt_speller) + 1);
|
||||
sprintf(alt_spell_error, invoke_error, alt_speller);
|
||||
return alt_spell_error;
|
||||
return invocation_error(alt_speller);
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -2794,24 +2774,18 @@ const char *do_alt_speller(char *tempfile_name)
|
||||
#ifndef NANO_TINY
|
||||
if (old_mark_set) {
|
||||
filestruct *top_save = openfile->fileage;
|
||||
/* Adjust the end point of the marked region for any change in
|
||||
length of the region's last line. */
|
||||
if (right_side_up)
|
||||
current_x_save = strlen(openfile->filebot->data);
|
||||
else
|
||||
openfile->mark_begin_x = strlen(openfile->filebot->data);
|
||||
|
||||
/* If the mark was on, the NO_NEWLINES flag isn't set, and we
|
||||
* added a magicline, remove it now. */
|
||||
if (!ISSET(NO_NEWLINES) && added_magicline)
|
||||
remove_magicline();
|
||||
|
||||
/* Put the beginning and the end of the mark at the beginning
|
||||
* and the end of the spell-checked text. */
|
||||
if (openfile->fileage == openfile->filebot)
|
||||
bot_x += top_x;
|
||||
if (right_side_up) {
|
||||
openfile->mark_begin_x = top_x;
|
||||
current_x_save = bot_x;
|
||||
} else {
|
||||
current_x_save = top_x;
|
||||
openfile->mark_begin_x = bot_x;
|
||||
}
|
||||
|
||||
/* Unpartition the filestruct so that it contains all the text
|
||||
* again. Note that we've replaced the marked text originally
|
||||
* in the partition with the spell-checked marked text in the
|
||||
@@ -2827,23 +2801,23 @@ const char *do_alt_speller(char *tempfile_name)
|
||||
openfile->totsize = totsize_save;
|
||||
|
||||
/* Assign mark_begin to the line where the mark began before. */
|
||||
do_gotopos(mb_lineno_save, openfile->mark_begin_x,
|
||||
current_y_save, 0);
|
||||
openfile->mark_begin = openfile->current;
|
||||
|
||||
/* Assign mark_begin_x to the location in mark_begin where the
|
||||
* mark began before, adjusted for any shortening of the
|
||||
* line. */
|
||||
openfile->mark_begin_x = openfile->current_x;
|
||||
openfile->mark_begin = fsfromline(mb_lineno_save);
|
||||
|
||||
/* Turn the mark back on. */
|
||||
openfile->mark_set = TRUE;
|
||||
}
|
||||
#endif
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Go back to the old position, and mark the file as modified. */
|
||||
do_gotopos(lineno_save, current_x_save, current_y_save, pww_save);
|
||||
set_modified();
|
||||
/* Go back to the old position. */
|
||||
goto_line_posx(lineno_save, current_x_save);
|
||||
openfile->current_y = current_y_save;
|
||||
edit_update(NONE);
|
||||
|
||||
/* Stat the temporary file again, and mark the buffer as modified only
|
||||
* if this file was changed since it was written. */
|
||||
stat(tempfile_name, &spellfileinfo);
|
||||
if (spellfileinfo.st_mtime != timestamp)
|
||||
set_modified();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Handle a pending SIGWINCH again. */
|
||||
@@ -2916,11 +2890,9 @@ void do_spell(void)
|
||||
/* Cleanup things to do after leaving the linter. */
|
||||
void lint_cleanup(void)
|
||||
{
|
||||
currmenu = MMAIN;
|
||||
display_main_list();
|
||||
}
|
||||
|
||||
|
||||
/* Run linter. Based on alt-speller code. Return NULL for normal
|
||||
* termination, and the error string otherwise. */
|
||||
void do_linter(void)
|
||||
@@ -2973,7 +2945,7 @@ void do_linter(void)
|
||||
statusbar(_("Invoking linter, please wait"));
|
||||
doupdate();
|
||||
|
||||
/* Set up an argument list to pass execvp(). */
|
||||
/* Set up an argument list to pass to execvp(). */
|
||||
if (lintargs == NULL) {
|
||||
lintargs = (char **)nmalloc(arglen * sizeof(char *));
|
||||
|
||||
@@ -2988,25 +2960,25 @@ void do_linter(void)
|
||||
}
|
||||
lintargs[arglen - 2] = openfile->filename;
|
||||
|
||||
/* A new process to run linter. */
|
||||
/* A new process to run the linter in. */
|
||||
if ((pid_lint = fork()) == 0) {
|
||||
|
||||
/* Child continues (i.e. future spell process). */
|
||||
/* Child continues (i.e. future linting process). */
|
||||
close(lint_fd[0]);
|
||||
|
||||
/* Send spell's standard output/err to the pipe. */
|
||||
/* Send the linter's standard output + err to the pipe. */
|
||||
if (dup2(lint_fd[1], STDOUT_FILENO) != STDOUT_FILENO)
|
||||
exit(1);
|
||||
exit(9);
|
||||
if (dup2(lint_fd[1], STDERR_FILENO) != STDERR_FILENO)
|
||||
exit(1);
|
||||
exit(9);
|
||||
|
||||
close(lint_fd[1]);
|
||||
|
||||
/* Start the linter program; we are using $PATH. */
|
||||
execvp(lintargs[0], lintargs);
|
||||
|
||||
/* This should not be reached if linter is found. */
|
||||
exit(1);
|
||||
/* This is only reached when the linter is not found. */
|
||||
exit(9);
|
||||
}
|
||||
|
||||
/* Parent continues here. */
|
||||
@@ -3028,7 +3000,7 @@ void do_linter(void)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Read in the returned spelling errors. */
|
||||
/* Read in the returned syntax errors. */
|
||||
read_buff_read = 0;
|
||||
read_buff_size = pipe_buff_size + 1;
|
||||
read_buff = read_buff_ptr = charalloc(read_buff_size);
|
||||
@@ -3052,7 +3024,7 @@ void do_linter(void)
|
||||
fprintf(stderr, "text.c:do_lint:Raw output: %s\n", read_buff);
|
||||
#endif
|
||||
|
||||
/* Process output. */
|
||||
/* Process the output. */
|
||||
read_buff_word = read_buff_ptr = read_buff;
|
||||
|
||||
while (*read_buff_ptr != '\0') {
|
||||
@@ -3120,9 +3092,15 @@ void do_linter(void)
|
||||
read_buff_ptr++;
|
||||
}
|
||||
|
||||
/* Process the end of the lint process. */
|
||||
/* Process the end of the linting process. */
|
||||
waitpid(pid_lint, &lint_status, 0);
|
||||
|
||||
if (!WIFEXITED(lint_status) || WEXITSTATUS(lint_status) > 2) {
|
||||
statusbar(invocation_error(openfile->syntax->linter));
|
||||
lint_cleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
free(read_buff);
|
||||
|
||||
if (parsesuccess == 0) {
|
||||
@@ -3131,7 +3109,6 @@ void do_linter(void)
|
||||
return;
|
||||
}
|
||||
|
||||
currmenu = MLINTER;
|
||||
bottombars(MLINTER);
|
||||
tmplint = NULL;
|
||||
curlint = lints;
|
||||
@@ -3194,6 +3171,12 @@ void do_linter(void)
|
||||
}
|
||||
|
||||
kbinput = get_kbinput(bottomwin);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (kbinput == KEY_WINCH)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
func = func_from_key(&kbinput);
|
||||
tmplint = curlint;
|
||||
|
||||
@@ -3216,7 +3199,7 @@ void do_linter(void)
|
||||
}
|
||||
blank_statusbar();
|
||||
#ifndef NANO_TINY
|
||||
free_lints_and_return:
|
||||
free_lints_and_return:
|
||||
#endif
|
||||
for (tmplint = lints; tmplint != NULL; tmplint = tmplint->next) {
|
||||
free(tmplint->msg);
|
||||
@@ -3226,12 +3209,10 @@ free_lints_and_return:
|
||||
lint_cleanup();
|
||||
}
|
||||
|
||||
/* Run a formatter for the given syntax.
|
||||
* Expects the formatter to be non-interactive and
|
||||
* operate on a file in-place, which we'll pass it
|
||||
* on the command line. Another mashuhp of the speller
|
||||
* and alt_speller routines.
|
||||
*/
|
||||
#ifndef DISABLE_SPELLER
|
||||
/* Run a formatter for the current syntax. This expects the formatter
|
||||
* to be non-interactive and operate on a file in-place, which we'll
|
||||
* pass it on the command line. */
|
||||
void do_formatter(void)
|
||||
{
|
||||
bool status;
|
||||
@@ -3249,10 +3230,9 @@ void do_formatter(void)
|
||||
char *finalstatus = NULL;
|
||||
|
||||
/* Check whether we're using syntax highlighting
|
||||
* and formatter option it set
|
||||
*/
|
||||
* and the formatter option is set. */
|
||||
if (openfile->syntax == NULL || openfile->syntax->formatter == NULL) {
|
||||
statusbar(_("Error: no linter defined"));
|
||||
statusbar(_("Error: no formatter defined"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3266,7 +3246,7 @@ void do_formatter(void)
|
||||
return;
|
||||
}
|
||||
|
||||
/* we're not supporting partial formatting, oi vey */
|
||||
/* We're not supporting partial formatting, oi vey. */
|
||||
openfile->mark_set = FALSE;
|
||||
status = write_file(temp, temp_file, TRUE, OVERWRITE, FALSE);
|
||||
|
||||
@@ -3287,7 +3267,7 @@ void do_formatter(void)
|
||||
|
||||
endwin();
|
||||
|
||||
/* Set up an argument list to pass execvp(). */
|
||||
/* Set up an argument list to pass to execvp(). */
|
||||
if (formatargs == NULL) {
|
||||
formatargs = (char **)nmalloc(arglen * sizeof(char *));
|
||||
|
||||
@@ -3304,10 +3284,10 @@ void do_formatter(void)
|
||||
|
||||
/* Start a new process for the formatter. */
|
||||
if ((pid_format = fork()) == 0) {
|
||||
/* Start alternate format program; we are using $PATH. */
|
||||
/* Start the formatting program; we are using $PATH. */
|
||||
execvp(formatargs[0], formatargs);
|
||||
|
||||
/* Should not be reached, if alternate formatter is found!!! */
|
||||
/* Should not be reached, if the formatter is found! */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -3339,20 +3319,10 @@ void do_formatter(void)
|
||||
* the windows based on the new screen dimensions. */
|
||||
window_init();
|
||||
|
||||
if (!WIFEXITED(format_status) ||
|
||||
WEXITSTATUS(format_status) != 0) {
|
||||
char *format_error;
|
||||
char *invoke_error = _("Error invoking \"%s\"");
|
||||
|
||||
format_error =
|
||||
charalloc(strlen(invoke_error) +
|
||||
strlen(openfile->syntax->formatter) + 1);
|
||||
sprintf(format_error, invoke_error, openfile->syntax->formatter);
|
||||
finalstatus = format_error;
|
||||
} else {
|
||||
|
||||
/* Replace the text of the current buffer with the format-checked
|
||||
* text. */
|
||||
if (!WIFEXITED(format_status) || WEXITSTATUS(format_status) != 0)
|
||||
finalstatus = invocation_error(openfile->syntax->formatter);
|
||||
else {
|
||||
/* Replace the text of the current buffer with the formatted text. */
|
||||
replace_buffer(temp);
|
||||
|
||||
/* Go back to the old position, and mark the file as modified. */
|
||||
@@ -3370,15 +3340,13 @@ void do_formatter(void)
|
||||
unlink(temp);
|
||||
free(temp);
|
||||
|
||||
currmenu = MMAIN;
|
||||
|
||||
/* If the spell-checker printed any error messages onscreen, make
|
||||
/* If the formatter printed any error messages onscreen, make
|
||||
* sure that they're cleared off. */
|
||||
total_refresh();
|
||||
|
||||
statusbar(finalstatus);
|
||||
}
|
||||
|
||||
#endif /* !DISABLE_SPELLER */
|
||||
#endif /* !DISABLE_COLOR */
|
||||
|
||||
#ifndef NANO_TINY
|
||||
|
||||
37
src/utils.c
37
src/utils.c
@@ -30,21 +30,6 @@
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* Return the number of decimal digits in n. */
|
||||
int digits(size_t n)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (n == 0)
|
||||
i = 1;
|
||||
else {
|
||||
for (i = 0; n != 0; n /= 10, i++)
|
||||
;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Return the user's home directory. We use $HOME, and if that fails,
|
||||
* we fall back on the home directory of the effective user ID. */
|
||||
void get_homedir(void)
|
||||
@@ -58,7 +43,11 @@ void get_homedir(void)
|
||||
if (userage != NULL)
|
||||
homenv = userage->pw_dir;
|
||||
}
|
||||
homedir = mallocstrcpy(NULL, homenv);
|
||||
|
||||
/* Only set homedir if some home directory could be determined,
|
||||
* otherwise keep homedir NULL. */
|
||||
if (homenv != NULL && strcmp(homenv, "") != 0)
|
||||
homedir = mallocstrcpy(NULL, homenv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,15 +239,6 @@ ssize_t ngetline(char **lineptr, size_t *n, FILE *stream)
|
||||
#endif /* !DISABLE_NANORC */
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* Do the compiled regex in preg and the regex in string match the
|
||||
* beginning or end of a line? */
|
||||
bool regexp_bol_or_eol(const regex_t *preg, const char *string)
|
||||
{
|
||||
return (regexec(preg, string, 0, NULL, 0) == 0 &&
|
||||
regexec(preg, string, 0, NULL, REG_NOTBOL | REG_NOTEOL) ==
|
||||
REG_NOMATCH);
|
||||
}
|
||||
|
||||
/* Fix the regex if we're on platforms which require an adjustment
|
||||
* from GNU-style to BSD-style word boundaries. */
|
||||
const char *fixbounds(const char *r)
|
||||
@@ -290,12 +270,11 @@ const char *fixbounds(const char *r)
|
||||
fprintf(stderr, "fixbounds(): Ending string = \"%s\"\n", r3);
|
||||
#endif
|
||||
return (const char *) r3;
|
||||
#endif
|
||||
#endif /* !GNU_WORDBOUNDS */
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* HAVE_REGEX_H */
|
||||
|
||||
#ifndef DISABLE_SPELLER
|
||||
/* Is the word starting at position pos in buf a whole word? */
|
||||
@@ -643,7 +622,7 @@ filestruct *fsfromline(ssize_t lineno)
|
||||
for (; f->lineno != lineno && f != openfile->fileage; f = f->prev)
|
||||
;
|
||||
else
|
||||
for (; f->lineno != lineno && f->next != NULL; f = f->next)
|
||||
for (; f->lineno != lineno && f->next != NULL; f = f->next)
|
||||
;
|
||||
|
||||
if (f->lineno != lineno)
|
||||
|
||||
306
src/winio.c
306
src/winio.c
@@ -41,6 +41,8 @@ static bool disable_cursorpos = FALSE;
|
||||
/* Should we temporarily disable constant cursor position
|
||||
* display? */
|
||||
|
||||
static sig_atomic_t sigwinch_counter_save = 0;
|
||||
|
||||
/* Control character compatibility:
|
||||
*
|
||||
* - NANO_BACKSPACE_KEY is Ctrl-H, which is Backspace under ASCII, ANSI,
|
||||
@@ -112,10 +114,6 @@ void get_key_buffer(WINDOW *win)
|
||||
if (key_buffer != NULL)
|
||||
return;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
allow_pending_sigwinch(TRUE);
|
||||
#endif
|
||||
|
||||
/* Just before reading in the first character, display any pending
|
||||
* screen updates. */
|
||||
doupdate();
|
||||
@@ -125,8 +123,17 @@ void get_key_buffer(WINDOW *win)
|
||||
if (nodelay_mode) {
|
||||
if ((input = wgetch(win)) == ERR)
|
||||
return;
|
||||
} else
|
||||
} else {
|
||||
while ((input = wgetch(win)) == ERR) {
|
||||
#ifndef NANO_TINY
|
||||
/* Did we get SIGWINCH since we were last here? */
|
||||
if (sigwinch_counter != sigwinch_counter_save) {
|
||||
sigwinch_counter_save = sigwinch_counter;
|
||||
regenerate_screen();
|
||||
input = KEY_WINCH;
|
||||
break;
|
||||
} else
|
||||
#endif
|
||||
errcount++;
|
||||
|
||||
/* If we've failed to get a character MAX_BUF_SIZE times in a
|
||||
@@ -137,10 +144,7 @@ void get_key_buffer(WINDOW *win)
|
||||
if (errcount == MAX_BUF_SIZE)
|
||||
handle_hupterm(0);
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
allow_pending_sigwinch(FALSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Increment the length of the keystroke buffer, and save the value
|
||||
* of the keystroke at the end of it. */
|
||||
@@ -148,14 +152,17 @@ void get_key_buffer(WINDOW *win)
|
||||
key_buffer = (int *)nmalloc(sizeof(int));
|
||||
key_buffer[0] = input;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If we got SIGWINCH, get out immediately since the win argument is
|
||||
* no longer valid. */
|
||||
if (input == KEY_WINCH)
|
||||
return;
|
||||
#endif
|
||||
|
||||
/* Read in the remaining characters using non-blocking input. */
|
||||
nodelay(win, TRUE);
|
||||
|
||||
while (TRUE) {
|
||||
#ifndef NANO_TINY
|
||||
allow_pending_sigwinch(TRUE);
|
||||
#endif
|
||||
|
||||
input = wgetch(win);
|
||||
|
||||
/* If there aren't any more characters, stop reading. */
|
||||
@@ -168,17 +175,19 @@ void get_key_buffer(WINDOW *win)
|
||||
key_buffer = (int *)nrealloc(key_buffer, key_buffer_len *
|
||||
sizeof(int));
|
||||
key_buffer[key_buffer_len - 1] = input;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
allow_pending_sigwinch(FALSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Switch back to waiting mode for input. */
|
||||
nodelay(win, FALSE);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "get_key_buffer(): key_buffer_len = %lu\n", (unsigned long)key_buffer_len);
|
||||
{
|
||||
size_t i;
|
||||
fprintf(stderr, "get_key_buffer(): the series of codes:");
|
||||
for (i = 0; i < key_buffer_len; i++)
|
||||
fprintf(stderr, " %3x", key_buffer[i]);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -191,11 +200,6 @@ size_t get_key_buffer_len(void)
|
||||
/* Add the keystrokes in input to the keystroke buffer. */
|
||||
void unget_input(int *input, size_t input_len)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
allow_pending_sigwinch(TRUE);
|
||||
allow_pending_sigwinch(FALSE);
|
||||
#endif
|
||||
|
||||
/* If input is empty, get out. */
|
||||
if (input_len == 0)
|
||||
return;
|
||||
@@ -249,11 +253,6 @@ int *get_input(WINDOW *win, size_t input_len)
|
||||
{
|
||||
int *input;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
allow_pending_sigwinch(TRUE);
|
||||
allow_pending_sigwinch(FALSE);
|
||||
#endif
|
||||
|
||||
if (key_buffer_len == 0) {
|
||||
if (win != NULL) {
|
||||
get_key_buffer(win);
|
||||
@@ -643,6 +642,11 @@ int parse_kbinput(WINDOW *win)
|
||||
retval = sc_seq_or(do_next_word_void, 0);
|
||||
#endif
|
||||
break;
|
||||
#ifndef NANO_TINY
|
||||
case KEY_WINCH:
|
||||
retval = KEY_WINCH;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* If our result is an extended keypad value (i.e. a value
|
||||
@@ -692,20 +696,16 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
* Terminal. */
|
||||
retval = get_escape_seq_abcd(seq[4]);
|
||||
break;
|
||||
case 'P': /* Esc O 1 ; 2 P == F13 on
|
||||
* Terminal. */
|
||||
case 'P': /* Esc O 1 ; 2 P == F13 on Terminal. */
|
||||
retval = KEY_F(13);
|
||||
break;
|
||||
case 'Q': /* Esc O 1 ; 2 Q == F14 on
|
||||
* Terminal. */
|
||||
case 'Q': /* Esc O 1 ; 2 Q == F14 on Terminal. */
|
||||
retval = KEY_F(14);
|
||||
break;
|
||||
case 'R': /* Esc O 1 ; 2 R == F15 on
|
||||
* Terminal. */
|
||||
case 'R': /* Esc O 1 ; 2 R == F15 on Terminal. */
|
||||
retval = KEY_F(15);
|
||||
break;
|
||||
case 'S': /* Esc O 1 ; 2 S == F16 on
|
||||
* Terminal. */
|
||||
case 'S': /* Esc O 1 ; 2 S == F16 on Terminal. */
|
||||
retval = KEY_F(16);
|
||||
break;
|
||||
}
|
||||
@@ -714,18 +714,14 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
case '5':
|
||||
if (seq_len >= 5) {
|
||||
switch (seq[4]) {
|
||||
case 'A': /* Esc O 1 ; 5 A == Ctrl-Up on
|
||||
* Terminal. */
|
||||
case 'B': /* Esc O 1 ; 5 B == Ctrl-Down on
|
||||
* Terminal. */
|
||||
case 'A': /* Esc O 1 ; 5 A == Ctrl-Up on Terminal. */
|
||||
case 'B': /* Esc O 1 ; 5 B == Ctrl-Down on Terminal. */
|
||||
retval = get_escape_seq_abcd(seq[4]);
|
||||
break;
|
||||
case 'C': /* Esc O 1 ; 5 C == Ctrl-Right on
|
||||
* Terminal. */
|
||||
case 'C': /* Esc O 1 ; 5 C == Ctrl-Right on Terminal. */
|
||||
retval = CONTROL_RIGHT;
|
||||
break;
|
||||
case 'D': /* Esc O 1 ; 5 D == Ctrl-Left on
|
||||
* Terminal. */
|
||||
case 'D': /* Esc O 1 ; 5 D == Ctrl-Left on Terminal. */
|
||||
retval = CONTROL_LEFT;
|
||||
break;
|
||||
}
|
||||
@@ -740,32 +736,25 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
case '2':
|
||||
if (seq_len >= 3) {
|
||||
switch (seq[2]) {
|
||||
case 'P': /* Esc O 2 P == F13 on
|
||||
* xterm. */
|
||||
case 'P': /* Esc O 2 P == F13 on xterm. */
|
||||
retval = KEY_F(13);
|
||||
break;
|
||||
case 'Q': /* Esc O 2 Q == F14 on
|
||||
* xterm. */
|
||||
case 'Q': /* Esc O 2 Q == F14 on xterm. */
|
||||
retval = KEY_F(14);
|
||||
break;
|
||||
case 'R': /* Esc O 2 R == F15 on
|
||||
* xterm. */
|
||||
case 'R': /* Esc O 2 R == F15 on xterm. */
|
||||
retval = KEY_F(15);
|
||||
break;
|
||||
case 'S': /* Esc O 2 S == F16 on
|
||||
* xterm. */
|
||||
case 'S': /* Esc O 2 S == F16 on xterm. */
|
||||
retval = KEY_F(16);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'A': /* Esc O A == Up on VT100/VT320/xterm. */
|
||||
case 'B': /* Esc O B == Down on
|
||||
* VT100/VT320/xterm. */
|
||||
case 'C': /* Esc O C == Right on
|
||||
* VT100/VT320/xterm. */
|
||||
case 'D': /* Esc O D == Left on
|
||||
* VT100/VT320/xterm. */
|
||||
case 'B': /* Esc O B == Down on VT100/VT320/xterm. */
|
||||
case 'C': /* Esc O C == Right on VT100/VT320/xterm. */
|
||||
case 'D': /* Esc O D == Left on VT100/VT320/xterm. */
|
||||
retval = get_escape_seq_abcd(seq[1]);
|
||||
break;
|
||||
case 'E': /* Esc O E == Center (5) on numeric keypad
|
||||
@@ -928,20 +917,16 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
case '1':
|
||||
if (seq_len >= 3) {
|
||||
switch (seq[2]) {
|
||||
case '1': /* Esc [ 1 1 ~ == F1 on rxvt/
|
||||
* Eterm. */
|
||||
case '1': /* Esc [ 1 1 ~ == F1 on rxvt/Eterm. */
|
||||
retval = KEY_F(1);
|
||||
break;
|
||||
case '2': /* Esc [ 1 2 ~ == F2 on rxvt/
|
||||
* Eterm. */
|
||||
case '2': /* Esc [ 1 2 ~ == F2 on rxvt/Eterm. */
|
||||
retval = KEY_F(2);
|
||||
break;
|
||||
case '3': /* Esc [ 1 3 ~ == F3 on rxvt/
|
||||
* Eterm. */
|
||||
case '3': /* Esc [ 1 3 ~ == F3 on rxvt/Eterm. */
|
||||
retval = KEY_F(3);
|
||||
break;
|
||||
case '4': /* Esc [ 1 4 ~ == F4 on rxvt/
|
||||
* Eterm. */
|
||||
case '4': /* Esc [ 1 4 ~ == F4 on rxvt/Eterm. */
|
||||
retval = KEY_F(4);
|
||||
break;
|
||||
case '5': /* Esc [ 1 5 ~ == F5 on xterm/
|
||||
@@ -969,14 +954,10 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
case '2':
|
||||
if (seq_len >= 5) {
|
||||
switch (seq[4]) {
|
||||
case 'A': /* Esc [ 1 ; 2 A == Shift-Up on
|
||||
* xterm. */
|
||||
case 'B': /* Esc [ 1 ; 2 B == Shift-Down on
|
||||
* xterm. */
|
||||
case 'C': /* Esc [ 1 ; 2 C == Shift-Right on
|
||||
* xterm. */
|
||||
case 'D': /* Esc [ 1 ; 2 D == Shift-Left on
|
||||
* xterm. */
|
||||
case 'A': /* Esc [ 1 ; 2 A == Shift-Up on xterm. */
|
||||
case 'B': /* Esc [ 1 ; 2 B == Shift-Down on xterm. */
|
||||
case 'C': /* Esc [ 1 ; 2 C == Shift-Right on xterm. */
|
||||
case 'D': /* Esc [ 1 ; 2 D == Shift-Left on xterm. */
|
||||
retval = get_escape_seq_abcd(seq[4]);
|
||||
break;
|
||||
}
|
||||
@@ -985,18 +966,14 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
case '5':
|
||||
if (seq_len >= 5) {
|
||||
switch (seq[4]) {
|
||||
case 'A': /* Esc [ 1 ; 5 A == Ctrl-Up on
|
||||
* xterm. */
|
||||
case 'B': /* Esc [ 1 ; 5 B == Ctrl-Down on
|
||||
* xterm. */
|
||||
case 'A': /* Esc [ 1 ; 5 A == Ctrl-Up on xterm. */
|
||||
case 'B': /* Esc [ 1 ; 5 B == Ctrl-Down on xterm. */
|
||||
retval = get_escape_seq_abcd(seq[4]);
|
||||
break;
|
||||
case 'C': /* Esc [ 1 ; 5 C == Ctrl-Right on
|
||||
* xterm. */
|
||||
case 'C': /* Esc [ 1 ; 5 C == Ctrl-Right on xterm. */
|
||||
retval = CONTROL_RIGHT;
|
||||
break;
|
||||
case 'D': /* Esc [ 1 ; 5 D == Ctrl-Left on
|
||||
* xterm. */
|
||||
case 'D': /* Esc [ 1 ; 5 D == Ctrl-Left on xterm. */
|
||||
retval = CONTROL_LEFT;
|
||||
break;
|
||||
}
|
||||
@@ -1015,49 +992,40 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
case '2':
|
||||
if (seq_len >= 3) {
|
||||
switch (seq[2]) {
|
||||
case '0': /* Esc [ 2 0 ~ == F9 on
|
||||
* VT220/VT320/Linux console/
|
||||
* xterm/rxvt/Eterm. */
|
||||
case '0': /* Esc [ 2 0 ~ == F9 on VT220/VT320/
|
||||
* Linux console/xterm/rxvt/Eterm. */
|
||||
retval = KEY_F(9);
|
||||
break;
|
||||
case '1': /* Esc [ 2 1 ~ == F10 on
|
||||
* VT220/VT320/Linux console/
|
||||
* xterm/rxvt/Eterm. */
|
||||
case '1': /* Esc [ 2 1 ~ == F10 on VT220/VT320/
|
||||
* Linux console/xterm/rxvt/Eterm. */
|
||||
retval = KEY_F(10);
|
||||
break;
|
||||
case '3': /* Esc [ 2 3 ~ == F11 on
|
||||
* VT220/VT320/Linux console/
|
||||
* xterm/rxvt/Eterm. */
|
||||
case '3': /* Esc [ 2 3 ~ == F11 on VT220/VT320/
|
||||
* Linux console/xterm/rxvt/Eterm. */
|
||||
retval = KEY_F(11);
|
||||
break;
|
||||
case '4': /* Esc [ 2 4 ~ == F12 on
|
||||
* VT220/VT320/Linux console/
|
||||
* xterm/rxvt/Eterm. */
|
||||
case '4': /* Esc [ 2 4 ~ == F12 on VT220/VT320/
|
||||
* Linux console/xterm/rxvt/Eterm. */
|
||||
retval = KEY_F(12);
|
||||
break;
|
||||
case '5': /* Esc [ 2 5 ~ == F13 on
|
||||
* VT220/VT320/Linux console/
|
||||
* rxvt/Eterm. */
|
||||
case '5': /* Esc [ 2 5 ~ == F13 on VT220/VT320/
|
||||
* Linux console/rxvt/Eterm. */
|
||||
retval = KEY_F(13);
|
||||
break;
|
||||
case '6': /* Esc [ 2 6 ~ == F14 on
|
||||
* VT220/VT320/Linux console/
|
||||
* rxvt/Eterm. */
|
||||
case '6': /* Esc [ 2 6 ~ == F14 on VT220/VT320/
|
||||
* Linux console/rxvt/Eterm. */
|
||||
retval = KEY_F(14);
|
||||
break;
|
||||
case '8': /* Esc [ 2 8 ~ == F15 on
|
||||
* VT220/VT320/Linux console/
|
||||
* rxvt/Eterm. */
|
||||
case '8': /* Esc [ 2 8 ~ == F15 on VT220/VT320/
|
||||
* Linux console/rxvt/Eterm. */
|
||||
retval = KEY_F(15);
|
||||
break;
|
||||
case '9': /* Esc [ 2 9 ~ == F16 on
|
||||
* VT220/VT320/Linux console/
|
||||
* rxvt/Eterm. */
|
||||
case '9': /* Esc [ 2 9 ~ == F16 on VT220/VT320/
|
||||
* Linux console/rxvt/Eterm. */
|
||||
retval = KEY_F(16);
|
||||
break;
|
||||
default: /* Esc [ 2 ~ == Insert on
|
||||
* VT220/VT320/Linux console/
|
||||
* xterm/Terminal. */
|
||||
default: /* Esc [ 2 ~ == Insert on VT220/VT320/
|
||||
* Linux console/xterm/Terminal. */
|
||||
retval = sc_seq_or(do_insertfile_void, 0);
|
||||
break;
|
||||
}
|
||||
@@ -1112,24 +1080,20 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
* Terminal. */
|
||||
retval = KEY_B2;
|
||||
break;
|
||||
case 'F': /* Esc [ F == End on FreeBSD
|
||||
* console/Eterm. */
|
||||
case 'F': /* Esc [ F == End on FreeBSD console/Eterm. */
|
||||
retval = sc_seq_or(do_end, 0);
|
||||
break;
|
||||
case 'G': /* Esc [ G == PageDown on FreeBSD
|
||||
* console. */
|
||||
case 'G': /* Esc [ G == PageDown on FreeBSD console. */
|
||||
retval = sc_seq_or(do_page_down, 0);
|
||||
break;
|
||||
case 'H': /* Esc [ H == Home on ANSI/VT220/FreeBSD
|
||||
* console/Mach console/Eterm. */
|
||||
retval = sc_seq_or(do_home, 0);
|
||||
break;
|
||||
case 'I': /* Esc [ I == PageUp on FreeBSD
|
||||
* console. */
|
||||
case 'I': /* Esc [ I == PageUp on FreeBSD console. */
|
||||
retval = sc_seq_or(do_page_up, 0);
|
||||
break;
|
||||
case 'L': /* Esc [ L == Insert on ANSI/FreeBSD
|
||||
* console. */
|
||||
case 'L': /* Esc [ L == Insert on ANSI/FreeBSD console. */
|
||||
retval = sc_seq_or(do_insertfile_void, 0);
|
||||
break;
|
||||
case 'M': /* Esc [ M == F1 on FreeBSD console. */
|
||||
@@ -1141,20 +1105,16 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
case 'O':
|
||||
if (seq_len >= 3) {
|
||||
switch (seq[2]) {
|
||||
case 'P': /* Esc [ O P == F1 on
|
||||
* xterm. */
|
||||
case 'P': /* Esc [ O P == F1 on xterm. */
|
||||
retval = KEY_F(1);
|
||||
break;
|
||||
case 'Q': /* Esc [ O Q == F2 on
|
||||
* xterm. */
|
||||
case 'Q': /* Esc [ O Q == F2 on xterm. */
|
||||
retval = KEY_F(2);
|
||||
break;
|
||||
case 'R': /* Esc [ O R == F3 on
|
||||
* xterm. */
|
||||
case 'R': /* Esc [ O R == F3 on xterm. */
|
||||
retval = KEY_F(3);
|
||||
break;
|
||||
case 'S': /* Esc [ O S == F4 on
|
||||
* xterm. */
|
||||
case 'S': /* Esc [ O S == F4 on xterm. */
|
||||
retval = KEY_F(4);
|
||||
break;
|
||||
}
|
||||
@@ -1197,8 +1157,7 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
break;
|
||||
case 'a': /* Esc [ a == Shift-Up on rxvt/Eterm. */
|
||||
case 'b': /* Esc [ b == Shift-Down on rxvt/Eterm. */
|
||||
case 'c': /* Esc [ c == Shift-Right on rxvt/
|
||||
* Eterm. */
|
||||
case 'c': /* Esc [ c == Shift-Right on rxvt/Eterm. */
|
||||
case 'd': /* Esc [ d == Shift-Left on rxvt/Eterm. */
|
||||
retval = get_escape_seq_abcd(seq[1]);
|
||||
break;
|
||||
@@ -2004,9 +1963,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
|
||||
converted[index++] = ' ';
|
||||
start_col++;
|
||||
}
|
||||
/* If buf contains a control character, interpret it. If buf
|
||||
* contains an invalid multibyte control character, display it
|
||||
* as such. */
|
||||
/* If buf contains a control character, interpret it. */
|
||||
} else if (is_cntrl_mbchar(buf_mb)) {
|
||||
char *ctrl_buf_mb = charalloc(mb_cur_max());
|
||||
int ctrl_buf_mb_len, i;
|
||||
@@ -2036,13 +1993,17 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
|
||||
#endif
|
||||
converted[index++] = ' ';
|
||||
start_col++;
|
||||
/* If buf contains a non-control character, interpret it. If
|
||||
* buf contains an invalid multibyte non-control character,
|
||||
* display it as such. */
|
||||
/* If buf contains a non-control character, interpret it. If buf
|
||||
* contains an invalid multibyte sequence, display it as such. */
|
||||
} else {
|
||||
char *nctrl_buf_mb = charalloc(mb_cur_max());
|
||||
int nctrl_buf_mb_len, i;
|
||||
|
||||
/* Make sure an invalid sequence-starter byte is properly
|
||||
* terminated, so that it doesn't pick up lingering bytes
|
||||
* of any previous content. */
|
||||
null_at(&buf_mb, buf_mb_len);
|
||||
|
||||
nctrl_buf_mb = mbrep(buf_mb, nctrl_buf_mb,
|
||||
&nctrl_buf_mb_len);
|
||||
|
||||
@@ -2344,6 +2305,9 @@ void bottombars(int menu)
|
||||
subnfunc *f;
|
||||
const sc *s;
|
||||
|
||||
/* Set the global variable to the given menu. */
|
||||
currmenu = menu;
|
||||
|
||||
if (ISSET(NO_HELP))
|
||||
return;
|
||||
|
||||
@@ -2528,7 +2492,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) {
|
||||
int x_start;
|
||||
/* Starting column for mvwaddnstr. Zero-based. */
|
||||
int paintlen;
|
||||
int paintlen = 0;
|
||||
/* Number of chars to paint on this line. There are
|
||||
* COLS characters on a whole line. */
|
||||
size_t index;
|
||||
@@ -2636,6 +2600,12 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
start_line = start_line->prev;
|
||||
}
|
||||
|
||||
/* If the found start has been qualified as an end earlier,
|
||||
* believe it and skip to the next step. */
|
||||
if (start_line != NULL && start_line->multidata != NULL &&
|
||||
start_line->multidata[tmpcolor->id] == CBEGINBEFORE)
|
||||
goto step_two;
|
||||
|
||||
/* Skip over a zero-length regex match. */
|
||||
if (startmatch.rm_so == startmatch.rm_eo)
|
||||
startmatch.rm_eo++;
|
||||
@@ -2690,13 +2660,23 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
if (end_line != fileptr) {
|
||||
paintlen = -1;
|
||||
fileptr->multidata[tmpcolor->id] = CWHOLELINE;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " Marking for id %i line %i as CWHOLELINE\n", tmpcolor->id, line);
|
||||
#endif
|
||||
} else {
|
||||
paintlen = actual_x(converted,
|
||||
strnlenpt(fileptr->data,
|
||||
endmatch.rm_eo) - start);
|
||||
fileptr->multidata[tmpcolor->id] = CBEGINBEFORE;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " Marking for id %i line %i as CBEGINBEFORE\n", tmpcolor->id, line);
|
||||
#endif
|
||||
}
|
||||
mvwaddnstr(edit, line, 0, converted, paintlen);
|
||||
/* If the whole line has been painted, don't bother
|
||||
* looking for any more starts. */
|
||||
if (paintlen < 0)
|
||||
goto end_of_loop;
|
||||
step_two:
|
||||
/* Second step, we look for starts on this line. */
|
||||
start_col = 0;
|
||||
@@ -2741,9 +2721,12 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
|
||||
mvwaddnstr(edit, line, x_start,
|
||||
converted + index, paintlen);
|
||||
if (paintlen > 0)
|
||||
if (paintlen > 0) {
|
||||
fileptr->multidata[tmpcolor->id] = CSTARTENDHERE;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " Marking for id %i line %i as CSTARTENDHERE\n", tmpcolor->id, line);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* There is no end on this line. But we
|
||||
@@ -2764,6 +2747,9 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
/* We painted to the end of the line, so
|
||||
* don't bother checking any more
|
||||
* starts. */
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " Marking for id %i line %i as CENDAFTER\n", tmpcolor->id, line);
|
||||
#endif
|
||||
fileptr->multidata[tmpcolor->id] = CENDAFTER;
|
||||
break;
|
||||
}
|
||||
@@ -2944,23 +2930,10 @@ int update_line(filestruct *fileptr, size_t index)
|
||||
return extralinesused;
|
||||
}
|
||||
|
||||
/* Return TRUE if we need an update after moving horizontally, and FALSE
|
||||
* otherwise. We need one if the mark is on or if pww_save and
|
||||
* placewewant are on different pages. */
|
||||
bool need_horizontal_update(size_t pww_save)
|
||||
{
|
||||
return
|
||||
#ifndef NANO_TINY
|
||||
openfile->mark_set ||
|
||||
#endif
|
||||
get_page_start(pww_save) !=
|
||||
get_page_start(openfile->placewewant);
|
||||
}
|
||||
|
||||
/* Return TRUE if we need an update after moving vertically, and FALSE
|
||||
* otherwise. We need one if the mark is on or if pww_save and
|
||||
* placewewant are on different pages. */
|
||||
bool need_vertical_update(size_t pww_save)
|
||||
/* Return TRUE if we need an update after moving the cursor, and
|
||||
* FALSE otherwise. We need an update if the mark is on, or if
|
||||
* pww_save and placewewant are on different pages. */
|
||||
bool need_screen_update(size_t pww_save)
|
||||
{
|
||||
return
|
||||
#ifndef NANO_TINY
|
||||
@@ -3007,15 +2980,12 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
{
|
||||
ssize_t i;
|
||||
filestruct *foo;
|
||||
bool do_redraw = FALSE;
|
||||
bool do_redraw = need_screen_update(0);
|
||||
|
||||
/* Don't bother scrolling less than one line. */
|
||||
if (nlines < 1)
|
||||
return;
|
||||
|
||||
if (need_vertical_update(0))
|
||||
do_redraw = TRUE;
|
||||
|
||||
/* Part 1: nlines is the number of lines we're going to scroll the
|
||||
* text of the edit window. */
|
||||
|
||||
@@ -3117,9 +3087,8 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
* updated. Use this if we've moved without changing any text. */
|
||||
void edit_redraw(filestruct *old_current, size_t pww_save)
|
||||
{
|
||||
bool do_redraw = need_vertical_update(0) ||
|
||||
need_vertical_update(pww_save);
|
||||
filestruct *foo = NULL;
|
||||
bool do_redraw = need_screen_update(0) || need_screen_update(pww_save);
|
||||
|
||||
/* If either old_current or current is offscreen, scroll the edit
|
||||
* window until it's onscreen and get out. */
|
||||
@@ -3160,10 +3129,8 @@ void edit_redraw(filestruct *old_current, size_t pww_save)
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Put edittop in range of current, get the difference in lines
|
||||
* between the original edittop and the current edittop, and
|
||||
* then restore the original edittop. */
|
||||
edit_update(CENTER);
|
||||
/* Make sure the current line is on the screen. */
|
||||
edit_update((ISSET(SMOOTH_SCROLL) && !focusing) ? NONE : CENTER);
|
||||
|
||||
/* Update old_current if we're not on the same page as
|
||||
* before. */
|
||||
@@ -3229,9 +3196,8 @@ void edit_refresh(void)
|
||||
(long)openfile->current->lineno, (long)openfile->edittop->lineno, maxrows);
|
||||
#endif
|
||||
|
||||
/* Put the top line of the edit window in range of the current
|
||||
* line. */
|
||||
edit_update(CENTER);
|
||||
/* Make sure the current line is on the screen. */
|
||||
edit_update(ISSET(SMOOTH_SCROLL) ? NONE : CENTER);
|
||||
}
|
||||
|
||||
foo = openfile->edittop;
|
||||
@@ -3436,8 +3402,8 @@ void do_replace_highlight(bool highlight, const char *word)
|
||||
}
|
||||
|
||||
#ifndef DISABLE_EXTRA
|
||||
#define CREDIT_LEN 53
|
||||
#define XLCREDIT_LEN 8
|
||||
#define CREDIT_LEN 54
|
||||
#define XLCREDIT_LEN 9
|
||||
|
||||
/* Easter egg: Display credits. Assume nodelay(edit) and scrollok(edit)
|
||||
* are FALSE. */
|
||||
@@ -3482,6 +3448,7 @@ void do_credits(void)
|
||||
"Richard Kolb II",
|
||||
NULL, /* "The Free Software Foundation" */
|
||||
"Linus Torvalds",
|
||||
NULL, /* "the many translators and the TP" */
|
||||
NULL, /* "For ncurses:" */
|
||||
"Thomas Dickey",
|
||||
"Pavel Curtis",
|
||||
@@ -3493,7 +3460,7 @@ void do_credits(void)
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"(C) 1999 - 2014",
|
||||
"(C) 1999 - 2015",
|
||||
"Free Software Foundation, Inc.",
|
||||
"",
|
||||
"",
|
||||
@@ -3508,6 +3475,7 @@ void do_credits(void)
|
||||
N_("Brought to you by:"),
|
||||
N_("Special thanks to:"),
|
||||
N_("The Free Software Foundation"),
|
||||
N_("the many translators and the TP"),
|
||||
N_("For ncurses:"),
|
||||
N_("and anyone else we forgot..."),
|
||||
N_("Thank you for using nano!")
|
||||
|
||||
Reference in New Issue
Block a user