Compare commits
79 Commits
| 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 |
221
ChangeLog
221
ChangeLog
@@ -1,3 +1,222 @@
|
||||
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.
|
||||
@@ -114,7 +333,7 @@
|
||||
* 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
|
||||
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
|
||||
|
||||
8
NEWS
8
NEWS
@@ -1,3 +1,11 @@
|
||||
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,
|
||||
|
||||
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.4.1], [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.4.0" "March 2015"
|
||||
.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.
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANORC 5 "version 2.4.0" "March 2015"
|
||||
.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.
|
||||
@@ -264,31 +267,30 @@ 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 reformat 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
|
||||
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
|
||||
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
|
||||
@@ -296,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
|
||||
@@ -307,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
|
||||
@@ -379,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
|
||||
@@ -492,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.
|
||||
@@ -616,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.
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -13,13 +13,16 @@ color yellow "<[^>]*@[^>]*>"
|
||||
color cyan "[[:space:]]-[a-zA-Z\$]" "--[8a-z-]+"
|
||||
# Bug and patch numbers.
|
||||
color cyan "bug #[0-9]{5,6}" "patch #[0-9]{4,5}"
|
||||
# Probable variables, for variety.
|
||||
# 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=":( |$)"
|
||||
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|\.save)?$" "sources\.list\.d/.*\.list(~|\.old|\.save)?$"
|
||||
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:]]);.*$"
|
||||
@@ -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))?\>"
|
||||
|
||||
@@ -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,6 +2,7 @@
|
||||
|
||||
syntax "python" "\.py$"
|
||||
header "^#!.*python[-0-9._]*"
|
||||
linter pyflakes
|
||||
|
||||
# Function definitions.
|
||||
icolor brightblue "def [0-9A-Z_]+"
|
||||
@@ -15,8 +16,8 @@ color brightgreen "["][^"]*[^\\]["]" "["]{3}.*[^\\]["]{3}"
|
||||
# Comments.
|
||||
color brightred "(^|[[:blank:]])#.*$"
|
||||
# Multiline strings.
|
||||
color brightgreen start="\"\"\"([^"),]|$)" end="(^|[^(])\"\"\""
|
||||
color brightgreen start="'''([^'),]|$)" end="(^|[^(])'''"
|
||||
color brightgreen start="\"\"\"[^"),]" end="(^|[^(])\"\"\""
|
||||
color brightgreen start="'''[^'),]" end="(^|[^(])'''"
|
||||
|
||||
# Reminders.
|
||||
color ,yellow "(FIXME|TODO|XXX)"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
syntax "ruby" "\.rb$"
|
||||
header "^#!.*ruby[-0-9._]*"
|
||||
linter ruby -w -c
|
||||
|
||||
# Reserved words.
|
||||
color yellow "\<(BEGIN|END|alias|and|begin|break|case|class|def|defined\?|do|else|elsif|end|ensure|false|for|if|in|module)\>"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
syntax "sh" "\.sh$"
|
||||
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.4.1
|
||||
@set UPDATED April 2015
|
||||
@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.4.1
|
||||
@subtitle version 2.4.2
|
||||
|
||||
@author Chris Allegretta
|
||||
@page
|
||||
@@ -63,6 +61,8 @@ editor.
|
||||
|
||||
@menu
|
||||
* Introduction::
|
||||
* Invoking::
|
||||
* Command-line Options::
|
||||
* Editor Basics::
|
||||
* Built-in Help::
|
||||
* Feature Toggles::
|
||||
@@ -82,19 +82,16 @@ 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
|
||||
@@ -116,15 +113,13 @@ But normallly you would set your preferred options in your
|
||||
(making @code{nano} remember the cursor position), you will rarely
|
||||
need to specify a line number.
|
||||
|
||||
Please email any bug reports to @email{nano@@nano-editor.org}.
|
||||
Or file them at @url{https://savannah.gnu.org/bugs/?group=nano}.
|
||||
|
||||
@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.
|
||||
@@ -139,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
|
||||
@@ -157,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
|
||||
@@ -337,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
|
||||
@@ -370,6 +366,7 @@ separately (e.g. @code{nano -wS -$}).
|
||||
@itemx -g
|
||||
@itemx -j
|
||||
Ignored, for compatibility with Pico.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@@ -502,65 +499,65 @@ 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
|
||||
|
||||
@@ -577,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
|
||||
@@ -614,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.
|
||||
@@ -688,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.
|
||||
@@ -828,39 +827,40 @@ 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{}]
|
||||
For the currently defined syntax, use the given program to automatically
|
||||
reformat text. Useful in certain programming languages (e.g. go).
|
||||
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
|
||||
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,
|
||||
@@ -870,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
|
||||
|
||||
@@ -949,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
|
||||
@@ -1059,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.
|
||||
@@ -1186,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.
|
||||
@@ -1249,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
|
||||
|
||||
|
||||
@@ -1276,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,
|
||||
@@ -1298,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
|
||||
|
||||
|
||||
@@ -1345,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
|
||||
@@ -1359,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
|
||||
|
||||
22
nano.spec.in
22
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, 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,8 +30,16 @@ 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)
|
||||
|
||||
1087
po/nano.pot
1087
po/nano.pot
File diff suppressed because it is too large
Load Diff
941
po/pt_BR.po
941
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
1101
po/zh_CN.po
1101
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
1101
po/zh_TW.po
1101
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
102
src/browser.c
102
src/browser.c
@@ -41,6 +41,8 @@ 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; 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. */
|
||||
@@ -75,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. */
|
||||
@@ -118,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;
|
||||
@@ -156,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();
|
||||
@@ -390,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;
|
||||
}
|
||||
@@ -541,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);
|
||||
@@ -573,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
|
||||
@@ -585,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);
|
||||
@@ -613,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
|
||||
@@ -629,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. */
|
||||
@@ -660,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);
|
||||
|
||||
@@ -706,9 +719,6 @@ int filesearch_init(void)
|
||||
int input;
|
||||
char *buf;
|
||||
|
||||
if (last_search == NULL)
|
||||
last_search = mallocstrcpy(NULL, "");
|
||||
|
||||
if (last_search[0] != '\0') {
|
||||
char *disp = display_string(last_search, 0, COLS / 3, FALSE);
|
||||
|
||||
@@ -755,6 +765,16 @@ void findnextfile(const char *needle)
|
||||
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. */
|
||||
|
||||
/* 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. */
|
||||
@@ -797,6 +817,9 @@ void findnextfile(const char *needle)
|
||||
rev_start = filetail;
|
||||
}
|
||||
|
||||
/* Restore the settings of all flags. */
|
||||
memcpy(flags, stash, sizeof(flags));
|
||||
|
||||
/* Select the one we've found. */
|
||||
selected = looking_at;
|
||||
}
|
||||
@@ -804,10 +827,6 @@ void findnextfile(const char *needle)
|
||||
/* Search for a filename. */
|
||||
void do_filesearch(void)
|
||||
{
|
||||
UNSET(CASE_SENSITIVE);
|
||||
UNSET(USE_REGEXP);
|
||||
UNSET(BACKWARDS_SEARCH);
|
||||
|
||||
if (filesearch_init() != 0) {
|
||||
/* Cancelled, or a blank search string, or done something. */
|
||||
bottombars(MBROWSER);
|
||||
@@ -835,9 +854,6 @@ void do_filesearch(void)
|
||||
/* Search for the last given filename again without prompting. */
|
||||
void do_fileresearch(void)
|
||||
{
|
||||
if (last_search == NULL)
|
||||
last_search = mallocstrcpy(NULL, "");
|
||||
|
||||
if (last_search[0] == '\0')
|
||||
statusbar(_("No current search pattern"));
|
||||
else
|
||||
|
||||
29
src/color.c
29
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
|
||||
|
||||
214
src/files.c
214
src/files.c
@@ -136,14 +136,14 @@ 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;
|
||||
}
|
||||
|
||||
/* Check if the lock exists before we try to delete it...*/
|
||||
@@ -152,19 +152,19 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
|
||||
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. Print an error message
|
||||
and continue. */
|
||||
* and continue. */
|
||||
if (fd < 0) {
|
||||
statusbar(_("Error writing lock file %s: %s"), lockfilename,
|
||||
statusbar(_("Error writing lock file %s: %s"), lockfilename,
|
||||
strerror(errno));
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Now we've got a safe file stream. If the previous open() call
|
||||
@@ -172,9 +172,9 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
|
||||
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
|
||||
@@ -205,13 +205,13 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
|
||||
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
|
||||
@@ -219,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;
|
||||
@@ -236,7 +236,7 @@ int delete_lockfile(const char *lockfilename)
|
||||
if (unlink(lockfilename) < 0 && errno != ENOENT) {
|
||||
statusbar(_("Error deleting lock file %s: %s"), lockfilename,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -258,49 +258,47 @@ int do_lockfile(const char *filename)
|
||||
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 = (unsigned char)lockbuf[25] * 256 + (unsigned char)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
|
||||
/* 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;
|
||||
}
|
||||
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);
|
||||
@@ -311,7 +309,6 @@ int do_lockfile(const char *filename)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return write_lockfile(lockfilename, filename, FALSE);
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
@@ -360,11 +357,10 @@ void open_buffer(const char *filename, bool undoable)
|
||||
} 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)) ?
|
||||
@@ -405,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, FALSE, &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 */
|
||||
|
||||
@@ -482,8 +468,8 @@ void switch_to_prevnext_buffer(bool next_buf, bool quiet)
|
||||
/* Indicate the switch on the statusbar. */
|
||||
if (quiet == FALSE)
|
||||
statusbar(_("Switched to %s"),
|
||||
((openfile->filename[0] == '\0') ? _("New Buffer") :
|
||||
openfile->filename));
|
||||
((openfile->filename[0] == '\0') ?
|
||||
_("New Buffer") : openfile->filename));
|
||||
|
||||
#ifdef DEBUG
|
||||
dump_filestruct(openfile->current);
|
||||
@@ -521,7 +507,7 @@ bool close_buffer(bool quiet)
|
||||
#endif
|
||||
|
||||
/* Switch to the next file buffer. */
|
||||
switch_to_prevnext_buffer(TRUE, quiet);
|
||||
switch_to_prevnext_buffer(TRUE, quiet);
|
||||
|
||||
/* Close the file buffer we had open before. */
|
||||
unlink_opennode(openfile->prev);
|
||||
@@ -556,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);
|
||||
@@ -830,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. */
|
||||
@@ -929,7 +913,7 @@ int open_file(const char *filename, bool newfie, bool quiet, 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);
|
||||
@@ -938,7 +922,7 @@ int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
|
||||
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);
|
||||
@@ -967,7 +951,7 @@ int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
|
||||
strerror(errno));
|
||||
beep();
|
||||
return -1;
|
||||
} else {
|
||||
} else {
|
||||
/* The file is A-OK. Open it. */
|
||||
*f = fdopen(fd, "rb");
|
||||
|
||||
@@ -991,20 +975,17 @@ int open_file(const char *filename, bool newfie, bool quiet, 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) {
|
||||
@@ -1012,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
|
||||
@@ -1456,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;
|
||||
}
|
||||
@@ -1613,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;
|
||||
@@ -1910,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;
|
||||
}
|
||||
|
||||
@@ -2179,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;
|
||||
}
|
||||
@@ -2403,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
|
||||
|
||||
82
src/global.c
82
src/global.c
@@ -30,12 +30,8 @@
|
||||
|
||||
/* 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;
|
||||
@@ -490,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");
|
||||
@@ -782,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);
|
||||
@@ -966,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)
|
||||
@@ -1012,10 +1015,6 @@ void shortcut_init(void)
|
||||
#ifndef DISABLE_SPELLER
|
||||
add_to_sclist(MMAIN, "^T", do_spell, 0);
|
||||
add_to_sclist(MMAIN, "F12", do_spell, 0);
|
||||
#ifndef DISABLE_COLOR
|
||||
add_to_sclist(MMAIN, "^T", do_formatter, 0);
|
||||
add_to_sclist(MMAIN, "F12", do_formatter, 0);
|
||||
#endif
|
||||
#else
|
||||
#ifndef DISABLE_COLOR
|
||||
add_to_sclist(MMAIN, "^T", do_linter, 0);
|
||||
@@ -1059,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);
|
||||
@@ -1155,12 +1154,14 @@ 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(MWHEREISFILE, "^Y", 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(MWHEREISFILE, "^V", do_last_file, 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);
|
||||
@@ -1178,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);
|
||||
@@ -1260,7 +1263,7 @@ const char *flagtostr(int flag)
|
||||
case BACKUP_FILE:
|
||||
return N_("Backup files");
|
||||
case MULTIBUFFER:
|
||||
return N_("Multiple file buffers");
|
||||
return N_("Reading file into separate buffer");
|
||||
case USE_MOUSE:
|
||||
return N_("Mouse support");
|
||||
case NO_CONVERT:
|
||||
@@ -1573,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
|
||||
@@ -1611,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;
|
||||
|
||||
@@ -1687,8 +1680,7 @@ void thanks_for_all_the_fish(void)
|
||||
free(s);
|
||||
}
|
||||
#ifndef DISABLE_NANORC
|
||||
if (homedir != NULL)
|
||||
free(homedir);
|
||||
free(homedir);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
34
src/help.c
34
src/help.c
@@ -72,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) {
|
||||
@@ -117,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;
|
||||
@@ -378,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);
|
||||
}
|
||||
|
||||
111
src/nano.c
111
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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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"));
|
||||
@@ -1167,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. */
|
||||
@@ -1237,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);
|
||||
@@ -1253,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. */
|
||||
@@ -1313,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))
|
||||
@@ -1351,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;
|
||||
@@ -1375,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
|
||||
@@ -1405,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
|
||||
@@ -1607,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. */
|
||||
@@ -2118,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'},
|
||||
@@ -2140,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'},
|
||||
@@ -2174,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'},
|
||||
@@ -2647,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;
|
||||
@@ -2802,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();
|
||||
|
||||
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. */
|
||||
|
||||
133
src/prompt.c
133
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,8 +976,7 @@ 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);
|
||||
|
||||
@@ -1055,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;
|
||||
@@ -1105,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)
|
||||
|
||||
22
src/proto.h
22
src/proto.h
@@ -28,8 +28,7 @@
|
||||
|
||||
/* 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;
|
||||
@@ -478,6 +477,7 @@ 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);
|
||||
#endif
|
||||
@@ -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);
|
||||
|
||||
24
src/rcfile.c
24
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},
|
||||
@@ -985,8 +987,7 @@ 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, "\"\""))
|
||||
@@ -1012,8 +1013,7 @@ 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, "\"\""))
|
||||
|
||||
141
src/search.c
141
src/search.c
@@ -116,16 +116,6 @@ void search_replace_abort(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Initialize the global search and replace strings. */
|
||||
void search_init_globals(void)
|
||||
{
|
||||
focusing = TRUE;
|
||||
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
|
||||
@@ -157,7 +147,7 @@ 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);
|
||||
@@ -259,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. */
|
||||
@@ -326,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';
|
||||
|
||||
@@ -334,17 +323,11 @@ 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;
|
||||
}
|
||||
|
||||
@@ -477,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,
|
||||
answer)) {
|
||||
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();
|
||||
@@ -522,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
|
||||
@@ -536,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,
|
||||
last_search, 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"));
|
||||
@@ -678,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)
|
||||
@@ -686,10 +631,6 @@ 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 *top, *bot;
|
||||
@@ -721,18 +662,9 @@ 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;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -747,22 +679,6 @@ ssize_t do_replace_loop(
|
||||
}
|
||||
#endif
|
||||
|
||||
#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;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Indicate that we found the search string. */
|
||||
if (numreplaced == -1)
|
||||
numreplaced = 0;
|
||||
@@ -795,13 +711,6 @@ 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;
|
||||
|
||||
307
src/text.c
307
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);
|
||||
|
||||
@@ -446,8 +449,8 @@ void do_undo(void)
|
||||
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))
|
||||
@@ -2217,7 +2214,15 @@ void do_justify(bool full_justify)
|
||||
|
||||
/* 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) {
|
||||
@@ -2283,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. */
|
||||
@@ -2315,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;
|
||||
@@ -2333,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);
|
||||
|
||||
@@ -2346,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;
|
||||
|
||||
@@ -2354,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
|
||||
@@ -2378,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();
|
||||
@@ -2440,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);
|
||||
@@ -2454,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;
|
||||
}
|
||||
@@ -2753,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
|
||||
@@ -2828,7 +2806,7 @@ const char *do_alt_speller(char *tempfile_name)
|
||||
/* Turn the mark back on. */
|
||||
openfile->mark_set = TRUE;
|
||||
}
|
||||
#endif
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Go back to the old position. */
|
||||
goto_line_posx(lineno_save, current_x_save);
|
||||
@@ -2915,7 +2893,6 @@ void lint_cleanup(void)
|
||||
display_main_list();
|
||||
}
|
||||
|
||||
|
||||
/* Run linter. Based on alt-speller code. Return NULL for normal
|
||||
* termination, and the error string otherwise. */
|
||||
void do_linter(void)
|
||||
@@ -2991,17 +2968,17 @@ void do_linter(void)
|
||||
|
||||
/* 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. */
|
||||
@@ -3115,11 +3092,15 @@ void do_linter(void)
|
||||
read_buff_ptr++;
|
||||
}
|
||||
|
||||
/* Process the end of the linting process.
|
||||
* XXX: The return value should be checked.
|
||||
* Will make an invocation-error routine. */
|
||||
/* 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) {
|
||||
@@ -3190,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;
|
||||
|
||||
@@ -3212,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);
|
||||
@@ -3332,17 +3319,9 @@ 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 {
|
||||
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);
|
||||
|
||||
|
||||
35
src/utils.c
35
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? */
|
||||
|
||||
284
src/winio.c
284
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);
|
||||
|
||||
@@ -2531,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;
|
||||
@@ -2639,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++;
|
||||
@@ -2693,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;
|
||||
@@ -2744,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
|
||||
@@ -2767,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;
|
||||
}
|
||||
@@ -2947,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
|
||||
@@ -3010,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. */
|
||||
|
||||
@@ -3120,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. */
|
||||
|
||||
Reference in New Issue
Block a user