Compare commits
74 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea1afac9db | ||
|
|
04aab233d0 | ||
|
|
33bc848c5b | ||
|
|
4c476bc872 | ||
|
|
9c2e270b3e | ||
|
|
0eef5610eb | ||
|
|
2a55d2b29a | ||
|
|
5416b9c09d | ||
|
|
7287300e0d | ||
|
|
ffeb0f9d4b | ||
|
|
10c9093942 | ||
|
|
b38cbfe173 | ||
|
|
702b09c859 | ||
|
|
2cd8ca4eb1 | ||
|
|
55b1403542 | ||
|
|
9d5ee16614 | ||
|
|
01bbf7e82f | ||
|
|
3ed5ddba31 | ||
|
|
6cacd1e320 | ||
|
|
d9cae81a0e | ||
|
|
83ee1feda4 | ||
|
|
c7610ba356 | ||
|
|
ae648778e2 | ||
|
|
023edffe3d | ||
|
|
2789bb0813 | ||
|
|
4d996e4c39 | ||
|
|
de2aa4f24a | ||
|
|
de95ca68f7 | ||
|
|
55878efe5d | ||
|
|
43f35fc7a9 | ||
|
|
d66ea08473 | ||
|
|
8476bf86a1 | ||
|
|
c92982d60f | ||
|
|
7a274d621a | ||
|
|
fdee0df849 | ||
|
|
00efa50385 | ||
|
|
a35803d502 | ||
|
|
7013039c3a | ||
|
|
925ad6393a | ||
|
|
3264d0c5be | ||
|
|
d9148e7b3f | ||
|
|
0a18d8912b | ||
|
|
815b326864 | ||
|
|
01bf034bb6 | ||
|
|
d716809228 | ||
|
|
8041627cc3 | ||
|
|
598e0af7af | ||
|
|
8ba57cf87b | ||
|
|
e2027aee15 | ||
|
|
97f6ae5267 | ||
|
|
fc9c7b4917 | ||
|
|
77a1a5c3e4 | ||
|
|
bc8bb7e942 | ||
|
|
08cd197bf1 | ||
|
|
4de0a5049b | ||
|
|
dc76e84657 | ||
|
|
1c2b35675e | ||
|
|
add0d698b7 | ||
|
|
09e95b2d91 | ||
|
|
03fd6f3af8 | ||
|
|
b92d35d1f2 | ||
|
|
9eeb1c8fb8 | ||
|
|
ad83ed22d9 | ||
|
|
3ddf6ff955 | ||
|
|
d04c0b7555 | ||
|
|
f13707fd1d | ||
|
|
ed9e5d7183 | ||
|
|
2fd497e3ef | ||
|
|
fd6308d6d3 | ||
|
|
1dbebbcadc | ||
|
|
57d1755d10 | ||
|
|
bace664fbc | ||
|
|
acd8809d71 | ||
|
|
7b7d2bf7c9 |
3
AUTHORS
3
AUTHORS
@@ -50,6 +50,9 @@ Mahyar Abbaspour <mahyar.abaspour@gmail.com>
|
||||
Mike Scalora <mike@scalora.org>
|
||||
* The comment/uncomment feature.
|
||||
|
||||
Faissal Bensefia <faissaloo@gmail.com>
|
||||
* Line numbers.
|
||||
|
||||
Benno Schulenberg <bensberg@justemail.net>
|
||||
* An array of small bug fixes, the cut-word and block-jump
|
||||
routines, text selection by holding Shift, and some extra
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
Improvements in GNU nano
|
||||
========================
|
||||
|
||||
Since 2.7.0:
|
||||
- The ability to display line numbers in front of the text.
|
||||
|
||||
Since 2.6.0:
|
||||
- Shift plus the cursor keys can be used for selecting text.
|
||||
- Ctrl+Arrow should now work also on a Linux virtual console.
|
||||
|
||||
11
NEWS
11
NEWS
@@ -1,3 +1,14 @@
|
||||
2016.10.29 - GNU nano 2.7.1 "Leuven" adds an often-asked-for feature: the
|
||||
ability to display line numbers beside the text. This can
|
||||
be activated with -l or --linenumbers on the command line,
|
||||
or with 'set linenumbers' in your nanorc, or toggled with
|
||||
M-#. The coloring of these numbers can be chosen via the
|
||||
option 'set numbercolor'. This release furthermore fixes
|
||||
some bugs with scrolling in softwrap mode, is more strict
|
||||
in the parsing of key rebindings, and marks a new buffer
|
||||
as modified when the output of a command (^R ^X) has been
|
||||
read into it. Come and check it out!
|
||||
|
||||
2016.09.01 - GNU nano 2.7.0 "Suni" adds a new feature: allowing text to be
|
||||
selected by holding Shift together with the cursor keys.
|
||||
Besides that, nano now works also when run in very tiny
|
||||
|
||||
40
TODO
40
TODO
@@ -1,9 +1,8 @@
|
||||
TODO file (? means the feature may be implemented, but not definitely)
|
||||
------------------------------------------------------------------------
|
||||
A list of desired features
|
||||
--------------------------
|
||||
|
||||
For the future (no targeted version, catch-all)
|
||||
Vague musings:
|
||||
- FriBidi support?
|
||||
- Port to DJGPP?
|
||||
- Make matching bracket searches sophisticated enough to skip over
|
||||
brackets inside comments?
|
||||
- Allow indentation of marked text by spaces as well as tabs?
|
||||
@@ -12,26 +11,27 @@ For the future (no targeted version, catch-all)
|
||||
- Allow conversion between different character sets. Maybe use glib's
|
||||
iconv() if the system's iconv() is inadequate, since we already use
|
||||
glib's vsnprintf() if the system lacks vsnprintf()?
|
||||
- Allow setting marks (saved positions, not to be confused with the mark
|
||||
set via Ctrl-^) at various lines and/or columns in the buffer, and
|
||||
allow movement between them with a single keystroke?
|
||||
- Allow searching for and replacing newlines?
|
||||
See also https://savannah.gnu.org/bugs/?47053.
|
||||
- New regression framework built on expect?
|
||||
- Add the ability to move to different lines of the screen with a single
|
||||
keystroke, e.g. M-` (M-~) to go to the top line, M-& (M-7) to go to
|
||||
the center line, and M-' (M-") to go to the last line?
|
||||
|
||||
Somewhat urgent:
|
||||
- Allow text searches in the help viewer.
|
||||
See https://savannah.gnu.org/bugs/?28994.
|
||||
- Detect when text is being pasted, so that we can handle it faster.
|
||||
See https://savannah.gnu.org/bugs/?40060.
|
||||
- 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 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, though.)
|
||||
- Allow searching for and replacing newlines.
|
||||
|
||||
For version 2.6:
|
||||
- New regression framework built on expect.
|
||||
- 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).
|
||||
- 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)?
|
||||
the command's output -- that is: generalize the spell-check flow.
|
||||
See also https://savannah.gnu.org/bugs/?28993.
|
||||
|
||||
For version 2.4:
|
||||
- Handle window resizes better. After we've resized, we should stay
|
||||
|
||||
15
configure.ac
15
configure.ac
@@ -16,7 +16,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
AC_INIT([GNU nano], [2.7.0], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [2.7.1], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AC_CANONICAL_HOST
|
||||
AM_INIT_AUTOMAKE
|
||||
@@ -125,6 +125,19 @@ fi
|
||||
AC_ARG_ENABLE(libmagic,
|
||||
AS_HELP_STRING([--disable-libmagic], [Disable detection of file types via libmagic]))
|
||||
|
||||
AC_ARG_ENABLE(linenumbers,
|
||||
AS_HELP_STRING([--disable-linenumbers], [Disable line numbering]))
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
if test "x$enable_linenumbers" != xyes; then
|
||||
enable_linenumbers=no
|
||||
fi
|
||||
fi
|
||||
if test "x$disable_linenumbers" != xyes; then
|
||||
if test "x$enable_linenumbers" != xno; then
|
||||
AC_DEFINE(ENABLE_LINENUMBERS, 1, [Define this to enable line numbering.])
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(mouse,
|
||||
AS_HELP_STRING([--disable-mouse], [Disable mouse support (and -m flag)]))
|
||||
if test "x$enable_mouse" = xno; then
|
||||
|
||||
27
doc/faq.html
27
doc/faq.html
@@ -84,24 +84,26 @@
|
||||
<h2><a name="1.5"></a>1.5. Why the name change from TIP?</h2>
|
||||
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program "establishes a full duplex terminal connection to a remote host", and was included with many older Unix systems (and newer ones like Solaris). The conflict was not noticed at first because there is no 'tip' utility included with most GNU/Linux distributions (where nano was developed).</p></blockquote>
|
||||
<h2><a name="1.6"></a>1.6. What is the current version of nano?</h2>
|
||||
<blockquote><p>The current stable version of nano *should* be 2.4.2. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
|
||||
<blockquote><p>The current version of nano *should* be 2.7.0. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
|
||||
<h2><a name="1.7"></a>1.7. I want to read the man page without having to download the program!</h2>
|
||||
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="https://nano-editor.org/dist/v2.6/nano.1.html">here</a>.</p></blockquote>
|
||||
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="https://nano-editor.org/dist/latest/nano.1.html">here</a>.</p></blockquote>
|
||||
<hr width="100%">
|
||||
<h1><a name="2"></a>2. Where to get GNU nano.</h1>
|
||||
<h2><a name="2.1"></a>2.1. FTP and WWW sites that carry nano.</h2>
|
||||
<blockquote><p>The nano distribution can be downloaded at the following web sites:</p>
|
||||
<h2><a name="2.1"></a>2.1. Web sites that carry nano.</h2>
|
||||
<blockquote><p>The nano source tarballs can be downloaded from the following web sites:</p>
|
||||
<ul>
|
||||
<li><a href="https://nano-editor.org/dist/">https://nano-editor.org/dist/</a></li>
|
||||
<li><a href="https://ftp.gnu.org/gnu/nano/">https://ftp.gnu.org/gnu/nano/</a></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<h2><a name="2.2"></a>2.2. RedHat and derivatives (.rpm) packages.</h2>
|
||||
<h2><a name="2.2"></a>2.2. RPM packages (RedHat, OpenSuse, and derivatives).</h2>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li><a href="https://nano-editor.org/dist/v2.5/RPMS/">https://nano-editor.org/dist/v2.5/RPMS/</a></li>
|
||||
<li><a href="https://kojipkgs.fedoraproject.org//packages/nano/">https://kojipkgs.fedoraproject.org//packages/nano/</a></li>
|
||||
<li><a href="https://software.opensuse.org/package/nano">https://software.opensuse.org/package/nano</a></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<h2><a name="2.3"></a>2.3. Debian (.deb) packages.</h2>
|
||||
<h2><a name="2.3"></a>2.3. Deb packages (Debian and derivatives):</h2>
|
||||
<blockquote><p>Debian users can check out the current nano packages for:</p>
|
||||
<ul>
|
||||
<li><a href="http://packages.debian.org/stable/editors/nano">stable</a></li>
|
||||
@@ -185,7 +187,7 @@
|
||||
<h2><a name="4.6"></a>4.6. nano crashes when I type <insert keystroke here>!</h2>
|
||||
<blockquote><p>If you aren't trying some bizarre keystroke combination with some bizarre $TERM entry, chances are you have found a bug. You are welcome to submit it to the <a href="mailto:nano-devel@gnu.org">nano-devel</a> list or in the <a href="https://savannah.gnu.org/bugs/?group=nano">bug tracker</a> on Savannah.</p></blockquote>
|
||||
<h2><a name="4.7"></a>4.7. nano crashes when I resize my window. How can I fix that?</h2>
|
||||
<blockquote><p>Older versions of nano had this problem, please upgrade to a newer version (at least 0.9.9, but 2.4.2 is recommended).</p></blockquote>
|
||||
<blockquote><p>Older versions of nano had this problem. Please upgrade to version 2.7.0 or newer.</p></blockquote>
|
||||
<h2><a name="4.8"></a>4.8. [version 1.3.12 and later] I'm using glibc 2.2.3, and nano crashes when I use color support or do regular expression searches. How can I fix that?</h2>
|
||||
<blockquote><p>It's a bug in glibc 2.2.3. You should upgrade to at least glibc 2.2.4.</p></blockquote>
|
||||
<h2><a name="4.9"></a>4.9. [version 1.1.12 and earlier] Why does nano show ^\ in the shortcut list instead of ^J?</h2>
|
||||
@@ -214,10 +216,9 @@
|
||||
<h2><a name="4.14"></a>4.14. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</h2>
|
||||
<blockquote><p>You have the autoindent feature turned on. Hit Meta-I to turn it off, paste your text, and then hit Meta-I again to turn it back on.</p></blockquote>
|
||||
<h2><a name="4.15"></a>4.15. On startup I get a message that says "Detected a legacy nano history file". Now older nano versions can't find my search history!</h2>
|
||||
<blockquote><p>In nano 2.3.0, cursor-position history was introduced, and both history files now reside under a .nano directory in your home. nano was trying to move this file into the new location so it could continue to use it. This means that if you try and use an earlier version of nano, it will be unable to see your current search history. To fix this, run the following commands:<br>
|
||||
<p><b>mv ~/.nano/search_history ~/.nano_history</b><br>
|
||||
<b>ln -sf ~/.nano_history ~/.nano/search_history</b></p>
|
||||
</p></blockquote>
|
||||
<blockquote><p>In nano 2.3.0, cursor-position history was introduced, and both history files now reside in a .nano subdirectory in your home directory. A newer nano will move an existing search-history file to this new location so it can continue to be used. This means that if you then try and use an earlier version of nano, it will be unable to see your current search history. To fix this, run the following command:<br>
|
||||
<p><b>ln -sf ~/.nano/search_history ~/.nano_history</b></p>
|
||||
</p><p>The "migration service" (moving the search-history file to its new location) will be deleted from nano in early 2018.</p></blockquote>
|
||||
<hr width="100%">
|
||||
<h1><a name="5"></a>5. Internationalization</h1>
|
||||
<h2><a name="5.1"></a>5.1. There's no translation for my language!</h2>
|
||||
@@ -247,7 +248,7 @@ Of course, due to the license change you can now use the <A HREF="http://www.was
|
||||
help-nano - <a href="http://mail.gnu.org/mailman/listinfo/help-nano/">http://mail.gnu.org/mailman/listinfo/help-nano/</a><br>
|
||||
nano-devel - <a href="http://mail.gnu.org/mailman/listinfo/nano-devel/">http://mail.gnu.org/mailman/listinfo/nano-devel/</a></p></blockquote>
|
||||
<h2><a name="7.2"></a>7.2. I want to send the development team a big load of cash (or just a thank you).</h2>
|
||||
<blockquote><p>That's fine. Send it <a href="mailto:nano-devel@gnu.org">our way</a>! Better yet, fix a <a href="https://savannah.gnu.org/bugs/?group=nano">bug</a> in the program or implement a <a href="https://nano-editor.org/dist/v2.6/TODO">cool feature</a> and send us that instead (though cash is fine too).</p></blockquote>
|
||||
<blockquote><p>That's fine. Send it <a href="mailto:nano-devel@gnu.org">our way</a>! Better yet, fix a <a href="https://savannah.gnu.org/bugs/?group=nano">bug</a> in the program or implement a <a href="https://nano-editor.org/dist/latest/TODO">cool feature</a> and send us that instead (though cash is fine too).</p></blockquote>
|
||||
<h2><a name="7.3"></a>7.3. How do I submit a bug report or patch?</h2>
|
||||
<blockquote>
|
||||
<p>The best place to submit bugs is to the <a href="https://savannah.gnu.org/bugs/?group=nano">Savannah bug tracker</a> as you can check whether the bug you are submitting has already been submitted.
|
||||
|
||||
@@ -17,16 +17,15 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANO 1 "version 2.7.0" "September 2016"
|
||||
.TH NANO 1 "version 2.7.1" "October 2016"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
|
||||
.SH NAME
|
||||
nano \- Nano's ANOther editor, an enhanced free Pico clone
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B nano
|
||||
.RI [ options "] [[+" line , column "]\ " file "]..."
|
||||
.RI [ options "] [[+" line [, column "]]\ " file "]..."
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fBnano\fP is a small, free and friendly editor which aims to replace
|
||||
@@ -38,7 +37,7 @@ 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.
|
||||
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
|
||||
@@ -47,7 +46,7 @@ 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
|
||||
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
|
||||
@@ -172,6 +171,10 @@ Interpret the Delete key differently so that both Backspace and Delete
|
||||
work properly. You should only need to use this option if Backspace
|
||||
acts like Delete on your system.
|
||||
.TP
|
||||
.BR \-g ", " \-\-showcursor
|
||||
Make the cursor visible in the file browser, putting it on the
|
||||
highlighted item. Useful for braille users.
|
||||
.TP
|
||||
.BR \-h ", " \-\-help
|
||||
Show a summary of the available command-line options and exit.
|
||||
.TP
|
||||
@@ -180,9 +183,12 @@ Indent new lines to the previous line's indentation. Useful when
|
||||
editing source code.
|
||||
.TP
|
||||
.BR \-k ", " \-\-cut
|
||||
Make the 'Cut Text' command (normally ^K) cut from the current cursor
|
||||
Make the 'Cut Text' command (normally \fB^K\fR) cut from the current cursor
|
||||
position to the end of the line, instead of cutting the entire line.
|
||||
.TP
|
||||
.BR \-l ", " \-\-linenumbers
|
||||
Display line numbers to the left of the text area.
|
||||
.TP
|
||||
.BR \-m ", " \-\-mouse
|
||||
Enable mouse support, if available for your system. When enabled, mouse
|
||||
clicks can be used to place the cursor, set the mark (with a double
|
||||
@@ -214,15 +220,13 @@ Hard-wrap lines at column \fInumber\fP. If this value is 0 or less, wrapping
|
||||
will occur at the width of the screen less \fInumber\fP columns, allowing
|
||||
the wrap point to vary along with the width of the screen if the screen
|
||||
is resized. The default value is \-8. This option conflicts with
|
||||
.B \-w
|
||||
-- the last one given takes effect.
|
||||
\fB\-w\fR -- the last one given takes effect.
|
||||
.TP
|
||||
.BR \-s\ \fIprogram\fR ", " \-\-speller= \fIprogram
|
||||
Use this alternative spell checker command.
|
||||
.TP
|
||||
.BR \-t ", " \-\-tempfile
|
||||
Always save a changed buffer without prompting. Same as Pico's \fB\-t\fP
|
||||
option.
|
||||
Save a changed buffer without prompting (when exiting with \fB^X\fR).
|
||||
.TP
|
||||
.BR \-u ", " \-\-unix
|
||||
Save a file by default in Unix format. This overrides nano's
|
||||
@@ -230,12 +234,11 @@ default behavior of saving a file in the format that it had.
|
||||
(This option has no effect when you also use \fB\-\-noconvert\fR.)
|
||||
.TP
|
||||
.BR \-v ", " \-\-view
|
||||
View-file (read-only) mode.
|
||||
Just view the file and disallow editing: read-only mode.
|
||||
.TP
|
||||
.BR \-w ", " \-\-nowrap
|
||||
Disable the hard-wrapping of long lines. This option conflicts with
|
||||
.B \-r
|
||||
-- the last one given takes effect.
|
||||
\fB\-r\fR -- the last one given takes effect.
|
||||
.TP
|
||||
.BR \-x ", " \-\-nohelp
|
||||
Don't show the two help lines at the bottom of the screen.
|
||||
@@ -251,9 +254,17 @@ continuing it over multiple screen lines. Since
|
||||
this option last when using other options (e.g.\& 'nano \-wS$') or pass it
|
||||
separately (e.g.\& 'nano \-wS \-$').
|
||||
.TP
|
||||
.BR \-a ", " \-b ", " \-e ", " \-f ", " \-g ", " \-j
|
||||
.BR \-a ", " \-b ", " \-e ", " \-f ", " \-j
|
||||
Ignored, for compatibility with Pico.
|
||||
|
||||
.SH TOGGLES
|
||||
Several of the above options can be switched on and off also while
|
||||
\fBnano\fR is running. For example, \fBM\-L\fR toggles the
|
||||
hard-wrapping of long lines, \fBM\-$\fR toggles soft-wrapping,
|
||||
\fBM\-#\fR toggles line numbers, \fBM\-M\fR toggles the mouse,
|
||||
\fBM\-I\fR auto-indentation, and \fBM\-X\fR the help lines.
|
||||
See at the end of the \fB^G\fR help text for a complete list.
|
||||
|
||||
.SH INITIALIZATION FILE
|
||||
\fBnano\fP will read initialization files in the following order:
|
||||
the system's \fBnanorc\fP (if it exists), and then the user's
|
||||
@@ -265,7 +276,7 @@ for more information on the possible contents of those files.
|
||||
If no alternative spell checker command is specified on the command
|
||||
line nor in one of the \fInanorc\fP files, \fBnano\fP will check the
|
||||
\fBSPELL\fP environment variable for one.
|
||||
|
||||
.sp
|
||||
In some cases \fBnano\fP will try to dump the buffer into an emergency
|
||||
file. This will happen mainly if \fBnano\fP receives a SIGHUP or
|
||||
SIGTERM or runs out of memory. It will write the buffer into a file
|
||||
@@ -277,27 +288,24 @@ it unique. In multibuffer mode, \fBnano\fP will write all the open
|
||||
buffers to their respective emergency files.
|
||||
|
||||
.SH BUGS
|
||||
Justifications (\fB^J\fR) and reindentations (\fBM-{\fR and \fBM-}\fR)
|
||||
Justifications (\fB^J\fR) and reindentations (\fBM\-{\fR and \fBM\-}\fR)
|
||||
are not yet covered by the general undo system. So after a justification
|
||||
that is not immediately undone, or after any reindentation, earlier edits
|
||||
cannot be undone any more. The workaround is, of course, to exit without
|
||||
saving.
|
||||
.sp
|
||||
Please report any other bugs that you encounter via
|
||||
https://savannah.gnu.org/bugs/?group=nano.
|
||||
\fIhttps://savannah.gnu.org/bugs/?group=nano\fR.
|
||||
|
||||
.SH HOMEPAGE
|
||||
https://nano-editor.org/
|
||||
|
||||
.SH SEE ALSO
|
||||
.PD 0
|
||||
.TP
|
||||
\fBnanorc\fP(5)
|
||||
.BR nanorc (5)
|
||||
.PP
|
||||
\fI/usr/share/doc/nano/\fP (or equivalent on your system)
|
||||
|
||||
.SH AUTHOR
|
||||
Chris Allegretta <chrisa@asty.org>, et al (see the files \fIAUTHORS\fP and
|
||||
Chris Allegretta and others (see the files \fIAUTHORS\fR and
|
||||
\fITHANKS\fP for details). This manual page was originally written by
|
||||
Jordi Mallach <jordi@gnu.org>, for the Debian system (but may be used by
|
||||
others).
|
||||
Jordi Mallach for the Debian system (but may be used by others).
|
||||
|
||||
@@ -17,11 +17,12 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANORC 5 "version 2.7.0" "September 2016"
|
||||
.TH NANORC 5 "version 2.7.1" "October 2016"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
|
||||
.SH NAME
|
||||
nanorc \- GNU nano's rcfile
|
||||
nanorc \- GNU nano's configuration file
|
||||
|
||||
.SH DESCRIPTION
|
||||
The \fInanorc\fP file contains the default settings for \fBnano\fP, a
|
||||
small and friendly editor. The file should be in Unix format, not in
|
||||
@@ -116,6 +117,9 @@ Specify the color combination to use for the shortcut key combos
|
||||
in the two help lines at the bottom of the screen.
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
.B set linenumbers
|
||||
Display line numbers to the left of the text area.
|
||||
.TP
|
||||
.B set locking
|
||||
Enable vim-style lock-files for when editing files.
|
||||
.TP
|
||||
@@ -150,6 +154,10 @@ Don't automatically add a newline to the ends of files.
|
||||
.B set nowrap
|
||||
Don't hard-wrap text at all.
|
||||
.TP
|
||||
.B set numbercolor \fIfgcolor\fR,\fIbgcolor\fR
|
||||
Specify the color combination to use for line numbers.
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
.B set operatingdir "\fIdirectory\fP"
|
||||
\fBnano\fP will only read and write files inside \fIdirectory\fP and its
|
||||
subdirectories. Also, the current directory is changed to here, so
|
||||
@@ -200,6 +208,10 @@ won't work properly with this option enabled.
|
||||
.B set regexp
|
||||
Do extended regular expression searches by default.
|
||||
.TP
|
||||
.B set showcursor
|
||||
Put the cursor on the highlighted item in the file browser, to aid
|
||||
braille users.
|
||||
.TP
|
||||
.B set smarthome
|
||||
Make the Home key smarter. When Home is pressed anywhere but at the
|
||||
very beginning of non-whitespace characters on a line, the cursor will
|
||||
@@ -413,6 +425,7 @@ a string in the current list in the file browser.
|
||||
.TP
|
||||
.B searchagain
|
||||
Repeats the last search command without prompting.
|
||||
(The form 'research' is deprecated.)
|
||||
.TP
|
||||
.B findprevious
|
||||
As \fBsearchagain\fR, but always in the backward direction.
|
||||
@@ -447,6 +460,7 @@ Cuts all text from the cursor position till the end of the buffer.
|
||||
.TP
|
||||
.B curpos
|
||||
Shows the current cursor position: the line, column, and character positions.
|
||||
(The form 'cursorpos' is deprecated.)
|
||||
.TP
|
||||
.B wordcount
|
||||
Counts the number of words, lines and characters in the current buffer.
|
||||
@@ -579,6 +593,7 @@ Toggles case sensitivity in searching (search/replace menus only).
|
||||
.TP
|
||||
.B regexp
|
||||
Toggles whether searching/replacing is based on literal strings or regular expressions.
|
||||
(The form 'regex' is deprecated.)
|
||||
.TP
|
||||
.B backwards
|
||||
Toggles whether searching/replacing goes forward or backward.
|
||||
@@ -591,6 +606,7 @@ Shows the next history entry in the prompt menus (e.g. search).
|
||||
.TP
|
||||
.B flipreplace
|
||||
Toggles between searching for something and replacing something.
|
||||
(The form 'dontreplace' is deprecated.)
|
||||
.TP
|
||||
.B flipexecute
|
||||
Toggles between inserting a file and executing a command.
|
||||
@@ -598,6 +614,7 @@ Toggles between inserting a file and executing a command.
|
||||
.B flipnewbuffer
|
||||
Toggles between inserting into the current buffer and into a new
|
||||
empty buffer.
|
||||
(The form 'newbuffer' is deprecated.)
|
||||
.TP
|
||||
.B dosformat
|
||||
When writing a file, switches to writing a DOS format (CR/LF).
|
||||
@@ -701,6 +718,7 @@ The 'search to replace' menu.
|
||||
.TP
|
||||
.B replacewith
|
||||
The 'replace with' menu, which comes up after 'search to replace'.
|
||||
(The form 'replace2' is deprecated.)
|
||||
.TP
|
||||
.B gotoline
|
||||
The 'goto line (and column)' menu.
|
||||
@@ -745,14 +763,11 @@ System-wide configuration file.
|
||||
.TP
|
||||
.B ~/.nanorc
|
||||
Per-user configuration file.
|
||||
|
||||
.SH SEE ALSO
|
||||
.TP
|
||||
\fBnano\fP(1)
|
||||
.PP
|
||||
\fI/usr/share/doc/nano/examples/nanorc.sample\fP (or equivalent on your
|
||||
system)
|
||||
.BR nano (1)
|
||||
|
||||
.SH AUTHOR
|
||||
Chris Allegretta <chrisa@asty.org>, et al (see \fIAUTHORS\fP and
|
||||
Chris Allegretta and others (see the files \fIAUTHORS\fP and
|
||||
\fITHANKS\fP for details). This manual page was originally written by
|
||||
Jordi Mallach <jordi@gnu.org>, for the Debian system (but may be used by
|
||||
others).
|
||||
Jordi Mallach for the Debian system (but may be used by others).
|
||||
|
||||
@@ -16,64 +16,52 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH RNANO 1 "version 2.7.0" "September 2016"
|
||||
.TH RNANO 1 "version 2.7.1" "October 2016"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
|
||||
.SH NAME
|
||||
rnano \- Restricted mode for Nano's ANOther editor, an enhanced free
|
||||
Pico clone
|
||||
rnano \- a restricted nano
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B rnano
|
||||
.RI [ options "] [[+" line , column "]\ " file "]..."
|
||||
.RI [ options "] [[+" line [, column "]]\ " file "]..."
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fBnano\fP is a small, free and friendly editor which aims to replace
|
||||
Pico, the default editor included in the non-free Pine package. On
|
||||
top of copying Pico's look and feel, \fBnano\fP also implements some
|
||||
missing (or disabled by default) features in Pico, such as "search and
|
||||
replace" and "go to line and column number".
|
||||
\fBrnano\fR runs the \fBnano\fR editor in restricted mode. This allows
|
||||
editing only the specified file or files, and doesn't allow the user
|
||||
access to the filesystem nor to a command shell.
|
||||
.PP
|
||||
\fBrnano\fP is a restricted version of \fBnano\fP, which only edits
|
||||
specific files and doesn't allow the user access to the filesystem or a
|
||||
command shell.
|
||||
.PP
|
||||
In restricted mode, \fBnano\fP will \fInot\/\fP:
|
||||
In restricted mode, \fBnano\fR will:
|
||||
.IP \[bu] 2
|
||||
read or write to any file not specified on the command line;
|
||||
not read any nanorc files;
|
||||
.IP \[bu]
|
||||
read any nanorc files;
|
||||
not allow suspending;
|
||||
.IP \[bu]
|
||||
allow suspending;
|
||||
not read nor write any file not specified on the command line;
|
||||
.IP \[bu]
|
||||
allow a file to be appended to, prepended to, or saved under a different
|
||||
name;
|
||||
not allow saving a file under a different name;
|
||||
.IP \[bu]
|
||||
use backup files or spell checking.
|
||||
not allow appending or prepending to any file;
|
||||
.IP \[bu]
|
||||
not make backup files nor do spell checking.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.BR \-h ", " \-\-help
|
||||
Show a summary of command-line options and exit.
|
||||
.TP
|
||||
.BR \-V ", " \-\-version
|
||||
Show the current version number and exit.
|
||||
.PP
|
||||
See the \fBnano\fP(1) manpage for all of the possible options.
|
||||
See the \fBnano\fP(1) manpage for all available options.
|
||||
|
||||
.SH BUGS
|
||||
Please send any comments or bug reports to \fBnano@nano-editor.org\fP.
|
||||
|
||||
The \fBnano\fP mailing list is available from \fBnano-devel@gnu.org\fP.
|
||||
|
||||
To subscribe, email to \fBnano-devel-request@gnu.org\fP with a subject
|
||||
of "subscribe".
|
||||
Please report bugs via \fIhttps://savannah.gnu.org/bugs/?group=nano\fR.
|
||||
|
||||
.SH HOMEPAGE
|
||||
http://www.nano-editor.org/
|
||||
https://nano-editor.org/
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR nano (1)
|
||||
|
||||
.SH AUTHOR
|
||||
Chris Allegretta <chrisa@asty.org>, et al (see the file AUTHORS for details).
|
||||
This manual page was originally written by Thijs Kinkhorst
|
||||
<thijs@kinkhorst.com>, for the Debian system (but may be used by
|
||||
others).
|
||||
Chris Allegretta and others (see the files \fIAUTHORS\fR and \fITHANKS\fR
|
||||
for details). This manual page was originally written by Thijs Kinkhorst
|
||||
for the Debian system (but may be used by others).
|
||||
|
||||
@@ -63,6 +63,9 @@
|
||||
## Make the justify command kill whitespace at the end of lines.
|
||||
# set justifytrim
|
||||
|
||||
## Display line numbers to the left of the text.
|
||||
# set linenumbers
|
||||
|
||||
## Enable vim-style lock-files. This is just to let a vim user know you
|
||||
## are editing a file [s]he is trying to edit and vice versa. There are
|
||||
## no plans to implement vim-style undo state in these files.
|
||||
@@ -138,6 +141,10 @@
|
||||
## Do extended regular expression searches by default.
|
||||
# set regexp
|
||||
|
||||
## Put the cursor on the highlighted item in the file browser;
|
||||
## useful for people who use a braille display.
|
||||
# set showcursor
|
||||
|
||||
## Make the Home key smarter. When Home is pressed anywhere but at the
|
||||
## very beginning of non-whitespace characters on a line, the cursor
|
||||
## will jump to that beginning (either forwards or backwards). If the
|
||||
@@ -189,8 +196,9 @@
|
||||
|
||||
|
||||
## Paint the interface elements of nano.
|
||||
## This is an example; by default there are no colors.
|
||||
## These are examples; by default there are no colors.
|
||||
# set titlecolor brightwhite,blue
|
||||
# set numbercolor cyan
|
||||
# set statuscolor brightwhite,green
|
||||
# set keycolor green
|
||||
# set functioncolor yellow
|
||||
|
||||
@@ -7,11 +7,11 @@ comment "#"
|
||||
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|comment|magic|linter|i?color|extendsyntax).*$"
|
||||
|
||||
# Keywords
|
||||
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|const(antshow)?|cut|fill|historylog|justifytrim|locking|morespace|mouse|multibuffer|noconvert|nohelp|nonewlines|nowrap|pos(ition)?log|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|suspend|tabsize|tabstospaces|tempfile|unix|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:]]+(all|main|search|replace(2|with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[: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:]]+#|[[:space:]]*$)"
|
||||
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cut|fill|historylog|justifytrim|locking|morespace|mouse|multibuffer|noconvert|nohelp|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize|tabstospaces|tempfile|unix|view|wordbounds)\>"
|
||||
icolor yellow "^[[:space:]]*set[[:space:]]+((function|key|number|status|title)color)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
|
||||
icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|speller|statuscolor|titlecolor|whitespace|wordchars)[[:space:]]+"
|
||||
icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^([[:alpha:]]|[]0-9\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]+(all|main|search|replace(with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
|
||||
icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([[:alpha:]]|[]0-9\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+(all|main|search|replace(with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
|
||||
icolor brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|comment|linter|formatter)[[:space:]]+.*$"
|
||||
icolor green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|formatter|extendsyntax)\>"
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ comment "#"
|
||||
color green "^#.*$"
|
||||
color yellow "Copyright|\(C\)"
|
||||
# Header fields.
|
||||
color brightmagenta "\<(Project\-Id\-Version|Report\-Msgid\-Bugs\-To|Last\-Translator|Language(\-Team)?|X\-Generator|Plural\-Forms)\>"
|
||||
color brightred "^\"X-Bugs:.*\"$"
|
||||
color brightmagenta "\<(Project\-Id\-Version|Report\-Msgid\-Bugs\-To|Last\-Translator|Language(\-Team)?|X-Bugs|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]"
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
@smallbook
|
||||
@set EDITION 0.4
|
||||
@set VERSION 2.7.0
|
||||
@set UPDATED September 2016
|
||||
@set VERSION 2.7.1
|
||||
@set UPDATED October 2016
|
||||
|
||||
@dircategory Editors
|
||||
@direntry
|
||||
@@ -21,7 +21,7 @@
|
||||
@titlepage
|
||||
@title GNU @code{nano}
|
||||
@subtitle a small and friendly text editor.
|
||||
@subtitle version 2.7.0
|
||||
@subtitle version 2.7.1
|
||||
|
||||
@author Chris Allegretta
|
||||
@page
|
||||
@@ -256,6 +256,11 @@ Interpret the Delete key differently so that both Backspace and Delete
|
||||
work properly. You should only need to use this option if Backspace
|
||||
acts like Delete on your system.
|
||||
|
||||
@item -g
|
||||
@itemx --showcursor
|
||||
Make the cursor visible in the file browser, putting it on the
|
||||
highlighted item. Useful for braille users.
|
||||
|
||||
@item -h
|
||||
@itemx --help
|
||||
Show a summary of command-line options and exit.
|
||||
@@ -270,6 +275,10 @@ the previous line.
|
||||
Make the 'Cut Text' command (normally ^K) cut from the current cursor
|
||||
position to the end of the line, instead of cutting the entire line.
|
||||
|
||||
@item -l
|
||||
@itemx --linenumbers
|
||||
Display line numbers to the left of the text area.
|
||||
|
||||
@item -m
|
||||
@itemx --mouse
|
||||
Enable mouse support, if available for your system. When enabled, mouse
|
||||
@@ -319,8 +328,8 @@ the @command{spell} program to be installed on your system.
|
||||
|
||||
@item -t
|
||||
@itemx --tempfile
|
||||
Don't ask whether or not to save the current contents of the file when
|
||||
exiting, assume yes. This is most useful when using @command{nano} as the
|
||||
Don't ask whether to save a modified buffer when exiting with ^X, but
|
||||
assume yes. This option is useful when @command{nano} is used as the
|
||||
composer of a mailer program.
|
||||
|
||||
@item -u
|
||||
@@ -368,7 +377,6 @@ separately (e.g.@: @code{nano -wS -$}).
|
||||
@itemx -b
|
||||
@itemx -e
|
||||
@itemx -f
|
||||
@itemx -g
|
||||
@itemx -j
|
||||
Ignored, for compatibility with Pico.
|
||||
|
||||
@@ -592,6 +600,9 @@ toggles the @code{-z} (@code{--suspend}) command-line option.
|
||||
@item Soft Wrapping Toggle (Meta-$)
|
||||
toggles the @code{-$} (@code{--softwrap}) command-line option.
|
||||
|
||||
@item Line Numbers Toggle (Meta-#)
|
||||
toggles the @code{-l} (@code{--linenumbers}) command-line option.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@@ -700,6 +711,9 @@ Specify the color combination to use for the shortcut key combos
|
||||
in the two help lines at the bottom of the screen.
|
||||
See @code{set titlecolor} for more details.
|
||||
|
||||
@item set linenumbers
|
||||
Display line numbers to the left of the text area.
|
||||
|
||||
@item set locking
|
||||
Enable vim-style lock-files for when editing files.
|
||||
|
||||
@@ -731,6 +745,10 @@ Don't add newlines to the ends of files.
|
||||
@item set nowrap
|
||||
Don't hard-wrap text at all.
|
||||
|
||||
@item set numbercolor @var{fgcolor},@var{bgcolor}
|
||||
Specify the color combination to use for line numbers.
|
||||
See @code{set titlecolor} for more details.
|
||||
|
||||
@item set operatingdir "directory"
|
||||
@code{nano} will only read and write files inside "directory" and its
|
||||
subdirectories. Also, the current directory is changed to here, so
|
||||
@@ -782,6 +800,10 @@ won't work properly with this option enabled.
|
||||
@item set regexp
|
||||
Do extended regular expression searches by default.
|
||||
|
||||
@item set showcursor
|
||||
Put the cursor on the highlighted item in the file browser, to aid
|
||||
braille users.
|
||||
|
||||
@item set smarthome
|
||||
Make the Home key smarter. When Home is pressed anywhere but at the
|
||||
very beginning of non-whitespace characters on a line, the cursor will
|
||||
@@ -1008,6 +1030,7 @@ a string in the current list in the file browser
|
||||
|
||||
@item searchagain
|
||||
Repeats the last search command without prompting.
|
||||
(The form 'research' is deprecated.)
|
||||
|
||||
@item findprevious
|
||||
As @code{searchagain}, but always in the backward direction.
|
||||
@@ -1042,6 +1065,7 @@ Cuts all text from the cursor position till the end of the buffer.
|
||||
|
||||
@item curpos
|
||||
Shows the current cursor position: the line, column, and character positions.
|
||||
(The form 'cursorpos' is deprecated.)
|
||||
|
||||
@item wordcount
|
||||
Counts the number of words, lines and characters in the current buffer.
|
||||
@@ -1171,6 +1195,7 @@ Toggles case sensitivity in searching (search/replace menus only).
|
||||
|
||||
@item regexp
|
||||
Toggles whether searching/replacing is based on literal strings or regular expressions.
|
||||
(The form 'regex' is deprecated.)
|
||||
|
||||
@item backwards
|
||||
Toggles whether searching/replacing goes forward or backward.
|
||||
@@ -1183,6 +1208,7 @@ Shows the next history entry in the prompt menus (e.g.@: search).
|
||||
|
||||
@item flipreplace
|
||||
Toggles between searching for something and replacing something.
|
||||
(The form 'dontreplace' is deprecated.)
|
||||
|
||||
@item flipexecute
|
||||
Toggles between inserting a file and executing a command.
|
||||
@@ -1190,6 +1216,7 @@ Toggles between inserting a file and executing a command.
|
||||
@item flipnewbuffer
|
||||
Toggles between inserting into the current buffer and into a new
|
||||
empty buffer.
|
||||
(The form 'newbuffer' is deprecated.)
|
||||
|
||||
@item dosformat
|
||||
When writing a file, switches to writing a DOS format (CR/LF).
|
||||
@@ -1294,6 +1321,7 @@ The 'search to replace' menu.
|
||||
|
||||
@item replacewith
|
||||
The 'replace with' menu, which comes up after 'search to replace'.
|
||||
(The form 'replace2' is deprecated.)
|
||||
|
||||
@item gotoline
|
||||
The 'goto line (and column)' menu.
|
||||
|
||||
964
po/nano.pot
964
po/nano.pot
File diff suppressed because it is too large
Load Diff
973
po/pt_BR.po
973
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
@@ -17,3 +17,10 @@ fi
|
||||
|
||||
echo "Regenerating POT file and remerging and recompiling PO files..."
|
||||
make update-po
|
||||
|
||||
# Ensure that the PO files are newer than the POT.
|
||||
touch *.po
|
||||
|
||||
# If needed, fix a problem in the Makefile template.
|
||||
grep -q '^datarootdir' Makefile.in.in || \
|
||||
sed -i 's/^\(datadir.*\)/datarootdir = @datarootdir@\n\1/' Makefile.in.in
|
||||
|
||||
965
po/zh_CN.po
965
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
965
po/zh_TW.po
965
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
@@ -59,7 +59,6 @@ char *do_browser(char *path)
|
||||
|
||||
/* Don't show a cursor in the file list. */
|
||||
curs_set(0);
|
||||
blank_statusbar();
|
||||
|
||||
read_directory_contents:
|
||||
/* We come here when we refresh or select a new directory. */
|
||||
@@ -503,6 +502,8 @@ void browser_refresh(void)
|
||||
size_t i;
|
||||
int line = 0, col = 0;
|
||||
/* The current line and column while the list is getting displayed. */
|
||||
int the_line = 0, the_column = 0;
|
||||
/* The line and column of the selected item. */
|
||||
char *info;
|
||||
/* The additional information that we'll display about a file. */
|
||||
|
||||
@@ -522,28 +523,27 @@ void browser_refresh(void)
|
||||
size_t infolen;
|
||||
/* The length of the file information in columns. */
|
||||
int infomaxlen = 7;
|
||||
/* The maximum length of the file information in
|
||||
* columns: seven for "--", "(dir)", or the file size,
|
||||
* and 12 for "(parent dir)". */
|
||||
/* The maximum length of the file information in columns:
|
||||
* normally seven, but will be twelve for "(parent dir)". */
|
||||
bool dots = (COLS >= 15 && namelen >= longest - infomaxlen);
|
||||
/* 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
|
||||
* filename other than ".."). */
|
||||
char *disp = display_string(thename, dots ? namelen -
|
||||
longest + infomaxlen + 4 : 0, longest, FALSE);
|
||||
/* If we put an ellipsis before the filename, reserve
|
||||
* one column for padding, plus seven columns for "--",
|
||||
* "(dir)", or the file size, plus three columns for the
|
||||
* ellipsis. */
|
||||
/* Whether to put an ellipsis before the filename? We don't
|
||||
* waste space on dots when there are fewer than 15 columns. */
|
||||
char *disp = display_string(thename, dots ?
|
||||
namelen + infomaxlen + 4 - longest : 0, longest, FALSE);
|
||||
/* The filename (or a fragment of it) in displayable format.
|
||||
* When a fragment, account for dots plus one space padding. */
|
||||
|
||||
/* Start highlighting the currently selected file or directory. */
|
||||
if (i == selected)
|
||||
/* If this is the selected item, start its highlighting, and
|
||||
* remember its location to be able to place the cursor on it. */
|
||||
if (i == selected) {
|
||||
wattron(edit, hilite_attribute);
|
||||
the_line = line;
|
||||
the_column = col;
|
||||
}
|
||||
|
||||
blank_line(edit, line, col, longest);
|
||||
|
||||
/* If dots is TRUE, we will display something like "...ename". */
|
||||
/* If the name is too long, we display something like "...ename". */
|
||||
if (dots)
|
||||
mvwaddstr(edit, line, col, "...");
|
||||
mvwaddstr(edit, line, dots ? col + 3 : col, disp);
|
||||
@@ -552,21 +552,16 @@ void browser_refresh(void)
|
||||
|
||||
col += longest;
|
||||
|
||||
/* Show information about the file. We don't want to report
|
||||
* file sizes for links, so we use lstat(). */
|
||||
/* Show information about the file: "--" for symlinks (except when
|
||||
* they point to a directory) and for files that have disappeared,
|
||||
* "(dir)" for directories, and the file size for normal files. */
|
||||
if (lstat(filelist[i], &st) == -1 || S_ISLNK(st.st_mode)) {
|
||||
/* If the file doesn't exist (i.e. it's been deleted while
|
||||
* the file browser is open), or it's a symlink that doesn't
|
||||
* point to a directory, display "--". */
|
||||
if (stat(filelist[i], &st) == -1 || !S_ISDIR(st.st_mode))
|
||||
info = mallocstrcpy(NULL, "--");
|
||||
/* 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. */
|
||||
info = mallocstrcpy(NULL, _("(dir)"));
|
||||
} else if (S_ISDIR(st.st_mode)) {
|
||||
/* If the file is a directory, display it as such. */
|
||||
if (strcmp(thename, "..") == 0) {
|
||||
/* TRANSLATORS: Try to keep this at most 12 characters. */
|
||||
info = mallocstrcpy(NULL, _("(parent dir)"));
|
||||
@@ -579,6 +574,7 @@ void browser_refresh(void)
|
||||
|
||||
info = charalloc(infomaxlen + 1);
|
||||
|
||||
/* Massage the file size into a human-readable form. */
|
||||
if (st.st_size < (1 << 10))
|
||||
modifier = ' '; /* bytes */
|
||||
else if (st.st_size < (1 << 20)) {
|
||||
@@ -592,8 +588,7 @@ void browser_refresh(void)
|
||||
modifier = 'G'; /* gigabytes */
|
||||
}
|
||||
|
||||
/* Show the size if less than a terabyte,
|
||||
* otherwise show "(huge)". */
|
||||
/* Show the size if less than a terabyte, else show "(huge)". */
|
||||
if (result < (1 << 10))
|
||||
sprintf(info, "%4ju %cB", (intmax_t)result, modifier);
|
||||
else
|
||||
@@ -611,7 +606,7 @@ void browser_refresh(void)
|
||||
|
||||
mvwaddstr(edit, line, col - infolen, info);
|
||||
|
||||
/* Finish highlighting the currently selected file or directory. */
|
||||
/* If this is the selected item, finish its highlighting. */
|
||||
if (i == selected)
|
||||
wattroff(edit, hilite_attribute);
|
||||
|
||||
@@ -626,8 +621,12 @@ void browser_refresh(void)
|
||||
line++;
|
||||
col = 0;
|
||||
}
|
||||
}
|
||||
|
||||
wmove(edit, line, col);
|
||||
/* If requested, put the cursor on the selected item and switch it on. */
|
||||
if (ISSET(SHOW_CURSOR)) {
|
||||
wmove(edit, the_line, the_column);
|
||||
curs_set(1);
|
||||
}
|
||||
|
||||
wnoutrefresh(edit);
|
||||
|
||||
@@ -600,7 +600,6 @@ char *mbstrcasestr(const char *haystack, const char *needle)
|
||||
return (char *) strcasestr(haystack, needle);
|
||||
}
|
||||
|
||||
#if !defined(NANO_TINY) || !defined(DISABLE_TABCOMP)
|
||||
/* This function is equivalent to strstr(), except in that it scans the
|
||||
* string in reverse, starting at rev_start. */
|
||||
char *revstrstr(const char *haystack, const char *needle, const char
|
||||
@@ -628,9 +627,7 @@ char *revstrstr(const char *haystack, const char *needle, const char
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif /* !NANO_TINY || !DISABLE_TABCOMP */
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* This function is equivalent to strcasestr(), except in that it scans
|
||||
* the string in reverse, starting at rev_start. */
|
||||
char *revstrcasestr(const char *haystack, const char *needle, const char
|
||||
@@ -696,7 +693,6 @@ char *mbrevstrcasestr(const char *haystack, const char *needle, const
|
||||
#endif
|
||||
return revstrcasestr(haystack, needle, rev_start);
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* This function is equivalent to strlen() for multibyte strings. */
|
||||
size_t mbstrlen(const char *s)
|
||||
|
||||
12
src/cut.c
12
src/cut.c
@@ -115,13 +115,7 @@ void cut_to_eof(void)
|
||||
* copy_text is TRUE, copy the text back into the filestruct afterward.
|
||||
* If cut_till_eof is TRUE, move all text from the current cursor
|
||||
* position to the end of the file into the cutbuffer. */
|
||||
void do_cut_text(
|
||||
#ifndef NANO_TINY
|
||||
bool copy_text, bool cut_till_eof
|
||||
#else
|
||||
void
|
||||
#endif
|
||||
)
|
||||
void do_cut_text(bool copy_text, bool cut_till_eof)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
filestruct *cb_save = NULL;
|
||||
@@ -221,10 +215,10 @@ void do_cut_text_void(void)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
add_undo(CUT);
|
||||
#endif
|
||||
do_cut_text(FALSE, FALSE);
|
||||
#ifndef NANO_TINY
|
||||
update_undo(CUT);
|
||||
#else
|
||||
do_cut_text();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
140
src/files.c
140
src/files.c
@@ -264,7 +264,7 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
|
||||
wroteamt = fwrite(lockdata, sizeof(char), lockdatalen, filestream);
|
||||
if (wroteamt < lockdatalen) {
|
||||
statusline(MILD, _("Error writing lock file %s: %s"),
|
||||
lockfilename, ferror(filestream));
|
||||
lockfilename, ferror(filestream));
|
||||
goto free_the_data;
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
|
||||
|
||||
if (fclose(filestream) == EOF) {
|
||||
statusline(MILD, _("Error writing lock file %s: %s"),
|
||||
lockfilename, strerror(errno));
|
||||
lockfilename, strerror(errno));
|
||||
goto free_the_data;
|
||||
}
|
||||
|
||||
@@ -567,8 +567,7 @@ void display_buffer(void)
|
||||
precalc_multicolorinfo();
|
||||
#endif
|
||||
|
||||
/* Update the edit window. */
|
||||
edit_refresh();
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
@@ -912,39 +911,37 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
|
||||
* file we inserted. */
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (undoable)
|
||||
update_undo(INSERT);
|
||||
|
||||
if (!writable)
|
||||
statusline(ALERT, "File '%s' is unwritable", filename);
|
||||
#ifndef NANO_TINY
|
||||
else if (format == 3) {
|
||||
statusline(HUSH,
|
||||
/* TRANSLATORS: Keep the next four messages at most 76 characters. */
|
||||
P_("Read %lu line (Converted from DOS and Mac format)",
|
||||
"Read %lu lines (Converted from DOS and Mac format)",
|
||||
(unsigned long)num_lines), (unsigned long)num_lines);
|
||||
/* TRANSLATORS: Keep the next four messages at most 78 characters. */
|
||||
statusline(HUSH, P_("Read %lu line (Converted from DOS and Mac format)",
|
||||
"Read %lu lines (Converted from DOS and Mac format)",
|
||||
(unsigned long)num_lines), (unsigned long)num_lines);
|
||||
} else if (format == 2) {
|
||||
openfile->fmt = MAC_FILE;
|
||||
statusline(HUSH,
|
||||
P_("Read %lu line (Converted from Mac format)",
|
||||
"Read %lu lines (Converted from Mac format)",
|
||||
(unsigned long)num_lines), (unsigned long)num_lines);
|
||||
statusline(HUSH, P_("Read %lu line (Converted from Mac format)",
|
||||
"Read %lu lines (Converted from Mac format)",
|
||||
(unsigned long)num_lines), (unsigned long)num_lines);
|
||||
} else if (format == 1) {
|
||||
openfile->fmt = DOS_FILE;
|
||||
statusline(HUSH,
|
||||
P_("Read %lu line (Converted from DOS format)",
|
||||
"Read %lu lines (Converted from DOS format)",
|
||||
(unsigned long)num_lines), (unsigned long)num_lines);
|
||||
} else
|
||||
#endif /* !NANO_TINY */
|
||||
statusline(HUSH, P_("Read %lu line", "Read %lu lines",
|
||||
(unsigned long)num_lines), (unsigned long)num_lines);
|
||||
statusline(HUSH, P_("Read %lu line (Converted from DOS format)",
|
||||
"Read %lu lines (Converted from DOS format)",
|
||||
(unsigned long)num_lines), (unsigned long)num_lines);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
statusline(HUSH, P_("Read %lu line", "Read %lu lines",
|
||||
(unsigned long)num_lines), (unsigned long)num_lines);
|
||||
|
||||
if (num_lines < editwinrows)
|
||||
focusing = FALSE;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (undoable)
|
||||
update_undo(INSERT);
|
||||
|
||||
if (ISSET(MAKE_IT_UNIX))
|
||||
openfile->fmt = NIX_FILE;
|
||||
#endif
|
||||
@@ -971,7 +968,7 @@ int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
|
||||
/* 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))
|
||||
stat(filename, &fileinfo2) != -1))
|
||||
full_filename = mallocstrcpy(full_filename, filename);
|
||||
|
||||
if (stat(full_filename, &fileinfo) == -1) {
|
||||
@@ -1061,28 +1058,16 @@ char *get_next_filename(const char *name, const char *suffix)
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* Insert a file into a new buffer if the MULTIBUFFER flag is set, or
|
||||
* into the current buffer if it isn't. If execute is TRUE, insert the
|
||||
* output of an executed command instead of a file. */
|
||||
void do_insertfile(
|
||||
#ifndef NANO_TINY
|
||||
bool execute
|
||||
#else
|
||||
void
|
||||
#endif
|
||||
)
|
||||
/* Insert a file into the current buffer, or into a new buffer when
|
||||
* the MULTIBUFFER flag is set. */
|
||||
void do_insertfile(void)
|
||||
{
|
||||
int i;
|
||||
const char *msg;
|
||||
char *given = mallocstrcpy(NULL, "");
|
||||
/* The last answer the user typed at the statusbar prompt. */
|
||||
filestruct *edittop_save = openfile->edittop;
|
||||
ssize_t was_current_lineno = openfile->current->lineno;
|
||||
size_t was_current_x = openfile->current_x;
|
||||
ssize_t was_current_y = openfile->current_y;
|
||||
bool edittop_inside = FALSE;
|
||||
#ifndef NANO_TINY
|
||||
bool right_side_up = FALSE, single_line = FALSE;
|
||||
bool execute = FALSE, right_side_up = FALSE, single_line = FALSE;
|
||||
#endif
|
||||
|
||||
while (TRUE) {
|
||||
@@ -1129,14 +1114,15 @@ void do_insertfile(
|
||||
* blank, open a new buffer instead of canceling. If the
|
||||
* filename or command begins with a newline (i.e. an encoded
|
||||
* null), treat it as though it's blank. */
|
||||
if (i == -1 || ((i == -2 || *answer == '\n')
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
&& !ISSET(MULTIBUFFER)
|
||||
#endif
|
||||
)) {
|
||||
if (i == -1 || (!ISSET(MULTIBUFFER) && (i == -2 || *answer == '\n'))) {
|
||||
statusbar(_("Cancelled"));
|
||||
break;
|
||||
} else {
|
||||
filestruct *edittop_save = openfile->edittop;
|
||||
ssize_t was_current_lineno = openfile->current->lineno;
|
||||
size_t was_current_x = openfile->current_x;
|
||||
ssize_t was_current_y = openfile->current_y;
|
||||
bool current_was_at_top = FALSE;
|
||||
size_t pww_save = openfile->placewewant;
|
||||
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
|
||||
functionptrtype func = func_from_key(&i);
|
||||
@@ -1146,7 +1132,7 @@ void do_insertfile(
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
if (func == new_buffer_void) {
|
||||
/* Don't allow toggling if we're in view mode. */
|
||||
/* Don't allow toggling when in view mode. */
|
||||
if (!ISSET(VIEW_MODE))
|
||||
TOGGLE(MULTIBUFFER);
|
||||
else
|
||||
@@ -1164,21 +1150,17 @@ void do_insertfile(
|
||||
if (func == to_files_void) {
|
||||
char *chosen = do_browse_from(answer);
|
||||
|
||||
/* If no file was chosen, go back to the prompt. */
|
||||
if (chosen == NULL)
|
||||
continue;
|
||||
|
||||
/* We have a file now. Indicate this. */
|
||||
free(answer);
|
||||
answer = chosen;
|
||||
i = 0;
|
||||
}
|
||||
#endif
|
||||
/* If we don't have a file yet, go back to the statusbar prompt. */
|
||||
if (i != 0
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
&& (i != -2 || !ISSET(MULTIBUFFER))
|
||||
#endif
|
||||
)
|
||||
/* If we don't have a file yet, go back to the prompt. */
|
||||
if (i != 0 && (!ISSET(MULTIBUFFER) || i != -2))
|
||||
continue;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -1194,19 +1176,14 @@ void do_insertfile(
|
||||
single_line = (top == bot);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
if (!ISSET(MULTIBUFFER))
|
||||
#endif
|
||||
{
|
||||
/* If we're not inserting into a new buffer, partition
|
||||
* the filestruct so that it contains no text and hence
|
||||
* looks like a new buffer, and keep track of whether
|
||||
* the top of the edit window is inside the partition. */
|
||||
/* When not inserting into a new buffer, partition the filestruct
|
||||
* so that it contains no text and hence looks like a new buffer,
|
||||
* and remember whether the current line is the first on screen. */
|
||||
if (!ISSET(MULTIBUFFER)) {
|
||||
filepart = partition_filestruct(openfile->current,
|
||||
openfile->current_x, openfile->current,
|
||||
openfile->current_x);
|
||||
edittop_inside = (openfile->edittop == openfile->fileage);
|
||||
current_was_at_top = (openfile->edittop == openfile->fileage);
|
||||
}
|
||||
|
||||
/* Convert newlines to nulls in the given filename. */
|
||||
@@ -1216,21 +1193,21 @@ void do_insertfile(
|
||||
#ifndef NANO_TINY
|
||||
if (execute) {
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
/* When in multibuffer mode, first open a blank buffer. */
|
||||
if (ISSET(MULTIBUFFER))
|
||||
/* Open a blank buffer. */
|
||||
open_buffer("", FALSE);
|
||||
#endif
|
||||
|
||||
/* Save the command's output in the current buffer. */
|
||||
execute_command(answer);
|
||||
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
/* If this is a new buffer, put the cursor at the top. */
|
||||
if (ISSET(MULTIBUFFER)) {
|
||||
/* Move back to the beginning of the first line of
|
||||
* the buffer. */
|
||||
openfile->current = openfile->fileage;
|
||||
openfile->current_x = 0;
|
||||
openfile->placewewant = 0;
|
||||
|
||||
set_modified();
|
||||
}
|
||||
#endif
|
||||
} else
|
||||
@@ -1256,17 +1233,16 @@ void do_insertfile(
|
||||
do_gotolinecolumn(priorline, priorcol, FALSE, FALSE);
|
||||
}
|
||||
#endif /* !DISABLE_HISTORIES */
|
||||
/* Update the screen to account for the current buffer. */
|
||||
/* Update stuff to account for the current buffer. */
|
||||
display_buffer();
|
||||
} else
|
||||
#endif /* !DISABLE_MULTIBUFFER */
|
||||
{
|
||||
filestruct *top_save = openfile->fileage;
|
||||
|
||||
/* If we were at the top of the edit window before, set
|
||||
* the saved value of edittop to the new top of the edit
|
||||
* window. */
|
||||
if (edittop_inside)
|
||||
/* If we were at the top of the edit window before, change the
|
||||
* saved value of edittop to the start of inserted stuff. */
|
||||
if (current_was_at_top)
|
||||
edittop_save = openfile->fileage;
|
||||
|
||||
/* Update the current x-coordinate to account for the
|
||||
@@ -1296,7 +1272,6 @@ void do_insertfile(
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Update the current y-coordinate to account for the
|
||||
* number of lines inserted. */
|
||||
openfile->current_y += was_current_y;
|
||||
@@ -1322,8 +1297,7 @@ void do_insertfile(
|
||||
openfile->current_x != was_current_x)
|
||||
set_modified();
|
||||
|
||||
/* Update the screen. */
|
||||
edit_refresh();
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -1348,11 +1322,7 @@ void do_insertfile_void(void)
|
||||
statusbar(_("Key invalid in non-multibuffer mode"));
|
||||
else
|
||||
#endif
|
||||
do_insertfile(
|
||||
#ifndef NANO_TINY
|
||||
FALSE
|
||||
#endif
|
||||
);
|
||||
do_insertfile();
|
||||
}
|
||||
|
||||
/* When passed "[relative path]" or "[relative path][filename]" in
|
||||
@@ -2940,8 +2910,8 @@ char *histfilename(void)
|
||||
return construct_filename("/.nano/search_history");
|
||||
}
|
||||
|
||||
/* Construct the legacy history filename.
|
||||
* (Deprecate in 2.5, delete later.) */
|
||||
/* Construct the legacy history filename. */
|
||||
/* (To be removed in 2018.) */
|
||||
char *legacyhistfilename(void)
|
||||
{
|
||||
return construct_filename("/.nano_history");
|
||||
@@ -3001,6 +2971,8 @@ void load_history(void)
|
||||
char *legacyhist = legacyhistfilename();
|
||||
struct stat hstat;
|
||||
|
||||
/* If there is an old history file, migrate it. */
|
||||
/* (To be removed in 2018.) */
|
||||
if (stat(legacyhist, &hstat) != -1 && stat(nanohist, &hstat) == -1) {
|
||||
if (rename(legacyhist, nanohist) == -1)
|
||||
history_error(N_("Detected a legacy nano history file (%s) which I tried to move\n"
|
||||
|
||||
504
src/global.c
504
src/global.c
@@ -1,5 +1,5 @@
|
||||
/**************************************************************************
|
||||
* global.c -- This file is part of GNU nano. *
|
||||
* global.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
|
||||
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
|
||||
@@ -33,7 +33,7 @@ volatile sig_atomic_t sigwinch_counter = 0;
|
||||
/* Is incremented by the handler whenever a SIGWINCH occurs. */
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) && !defined(NANO_TINY)
|
||||
#ifdef __linux__
|
||||
bool console;
|
||||
/* Whether we're running on a Linux VC (TRUE) or under X (FALSE). */
|
||||
#endif
|
||||
@@ -45,11 +45,22 @@ bool shift_held;
|
||||
bool focusing = TRUE;
|
||||
/* Whether an update of the edit window should center the cursor. */
|
||||
|
||||
int margin = 0;
|
||||
/* The amount of space reserved at the left for line numbers. */
|
||||
int editwincols = -1;
|
||||
/* The number of usable columns in the edit window: COLS - margin. */
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
int last_drawn_line = 0;
|
||||
/* The line number of the last drawn line. */
|
||||
int last_line_y;
|
||||
/* The y coordinate of the last drawn line. */
|
||||
#endif
|
||||
|
||||
message_type lastmessage = HUSH;
|
||||
/* Messages of type HUSH should not overwrite type MILD nor ALERT. */
|
||||
|
||||
#ifndef NANO_TINY
|
||||
int controlleft, controlright, controlup, controldown;
|
||||
#ifndef NANO_TINY
|
||||
int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown;
|
||||
int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown;
|
||||
#endif
|
||||
@@ -89,13 +100,9 @@ int maxrows = 0;
|
||||
filestruct *cutbuffer = NULL;
|
||||
/* The buffer where we store cut text. */
|
||||
filestruct *cutbottom = NULL;
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
filestruct *jusbuffer = NULL;
|
||||
/* The buffer where we store unjustified text. */
|
||||
#endif
|
||||
/* The last line in the cutbuffer. */
|
||||
partition *filepart = NULL;
|
||||
/* The partition where we store a portion of the current
|
||||
* file. */
|
||||
/* The "partition" where we store a portion of the current file. */
|
||||
openfilestruct *openfile = NULL;
|
||||
/* The list of all open file buffers. */
|
||||
|
||||
@@ -128,7 +135,7 @@ char *quoteerr = NULL;
|
||||
size_t quotelen;
|
||||
/* The length of the quoting string in bytes. */
|
||||
#endif
|
||||
#endif
|
||||
#endif /* !DISABLE_JUSTIFY */
|
||||
|
||||
char *word_chars = NULL;
|
||||
/* Nonalphanumeric characters that also form words. */
|
||||
@@ -140,8 +147,7 @@ char *answer = NULL;
|
||||
/* The answer string used by the statusbar prompt. */
|
||||
|
||||
ssize_t tabsize = -1;
|
||||
/* The width of a tab in spaces. The default value is set in
|
||||
* main(). */
|
||||
/* The width of a tab in spaces. The default is set in main(). */
|
||||
|
||||
#ifndef NANO_TINY
|
||||
char *backup_dir = NULL;
|
||||
@@ -179,15 +185,15 @@ bool refresh_needed = FALSE;
|
||||
int currmenu = MMOST;
|
||||
/* The currently active menu, initialized to a dummy value. */
|
||||
sc *sclist = NULL;
|
||||
/* Pointer to the start of the shortcuts list. */
|
||||
/* The start of the shortcuts list. */
|
||||
subnfunc *allfuncs = NULL;
|
||||
/* Pointer to the start of the functions list. */
|
||||
/* The start of the functions list. */
|
||||
subnfunc *tailfunc;
|
||||
/* Pointer to the last function in the list. */
|
||||
/* The last function in the list. */
|
||||
subnfunc *exitfunc;
|
||||
/* Pointer to the special Exit/Close item. */
|
||||
/* A pointer to the special Exit/Close item. */
|
||||
subnfunc *uncutfunc;
|
||||
/* Pointer to the special Uncut/Unjustify item. */
|
||||
/* A pointer to the special Uncut/Unjustify item. */
|
||||
|
||||
#ifndef DISABLE_HISTORIES
|
||||
filestruct *search_history = NULL;
|
||||
@@ -206,7 +212,6 @@ poshiststruct *position_history = NULL;
|
||||
/* The cursor position history list. */
|
||||
#endif
|
||||
|
||||
/* Regular expressions. */
|
||||
#ifdef HAVE_REGEX_H
|
||||
regex_t search_regexp;
|
||||
/* The compiled regular expression to use in searches. */
|
||||
@@ -216,7 +221,7 @@ regmatch_t regmatches[10];
|
||||
#endif
|
||||
|
||||
int hilite_attribute = A_REVERSE;
|
||||
/* The curses attribute we use for reverse video. */
|
||||
/* The curses attribute we use to highlight something. */
|
||||
#ifndef DISABLE_COLOR
|
||||
char* specified_color_combo[] = {};
|
||||
/* The color combinations as specified in the rcfile. */
|
||||
@@ -227,6 +232,7 @@ int interface_color_pair[] = {};
|
||||
char *homedir = NULL;
|
||||
/* The user's home directory, from $HOME or /etc/passwd. */
|
||||
|
||||
|
||||
/* Return the number of entries in the shortcut list for a given menu. */
|
||||
size_t length_of_list(int menu)
|
||||
{
|
||||
@@ -323,10 +329,13 @@ void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *h
|
||||
}
|
||||
|
||||
/* Add a key combo to the shortcut list. */
|
||||
void add_to_sclist(int menus, const char *scstring, void (*func)(void), int toggle)
|
||||
void add_to_sclist(int menus, const char *scstring, const int keycode,
|
||||
void (*func)(void), int toggle)
|
||||
{
|
||||
static sc *tailsc;
|
||||
#ifndef NANO_TINY
|
||||
static int counter = 0;
|
||||
#endif
|
||||
sc *s = (sc *)nmalloc(sizeof(sc));
|
||||
|
||||
/* Start the list, or tack on the next item. */
|
||||
@@ -340,10 +349,12 @@ void add_to_sclist(int menus, const char *scstring, void (*func)(void), int togg
|
||||
/* Fill in the data. */
|
||||
s->menus = menus;
|
||||
s->scfunc = func;
|
||||
#ifndef NANO_TINY
|
||||
s->toggle = toggle;
|
||||
if (toggle)
|
||||
s->ordinal = ++counter;
|
||||
assign_keyinfo(s, scstring);
|
||||
#endif
|
||||
assign_keyinfo(s, scstring, keycode);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Setting keycode to %d for shortcut \"%s\" in menus %x\n", s->keycode, scstring, s->menus);
|
||||
@@ -403,53 +414,31 @@ functionptrtype func_from_key(int *kbinput)
|
||||
}
|
||||
|
||||
/* Set the string and its corresponding keycode for the given shortcut s. */
|
||||
void assign_keyinfo(sc *s, const char *keystring)
|
||||
void assign_keyinfo(sc *s, const char *keystring, const int keycode)
|
||||
{
|
||||
s->keystr = keystring;
|
||||
s->meta = (keystring[0] == 'M');
|
||||
|
||||
assert(strlen(keystring) > 1 && (!s->meta || strlen(keystring) > 2));
|
||||
|
||||
if (keystring[0] == '^') {
|
||||
s->keycode = keystring[1] - 64;
|
||||
if (keycode)
|
||||
s->keycode = keycode;
|
||||
else if (keystring[0] == '^') {
|
||||
if (strcasecmp(keystring, "^Space") == 0)
|
||||
s->keycode = 0;
|
||||
else
|
||||
s->keycode = keystring[1] - 64;
|
||||
} else if (s->meta) {
|
||||
s->keycode = tolower((int)keystring[2]);
|
||||
if (strcasecmp(keystring, "M-Space") == 0)
|
||||
s->keycode = (int)' ';
|
||||
else
|
||||
s->keycode = tolower((int)keystring[2]);
|
||||
} else if (keystring[0] == 'F')
|
||||
s->keycode = KEY_F0 + atoi(&keystring[1]);
|
||||
/* Catch the strings that don't bind as easily as we'd like. */
|
||||
else if (!strcasecmp(keystring, "Up"))
|
||||
s->keycode = KEY_UP;
|
||||
else if (!strcasecmp(keystring, "Down"))
|
||||
s->keycode = KEY_DOWN;
|
||||
else if (!strcasecmp(keystring, "Left"))
|
||||
s->keycode = KEY_LEFT;
|
||||
else if (!strcasecmp(keystring, "Right"))
|
||||
s->keycode = KEY_RIGHT;
|
||||
else if (!strcasecmp(keystring, "Ins"))
|
||||
s->keycode = KEY_IC;
|
||||
else if (!strcasecmp(keystring, "Del"))
|
||||
s->keycode = KEY_DC;
|
||||
else if (!strcasecmp(keystring, "Bsp"))
|
||||
s->keycode = KEY_BACKSPACE;
|
||||
/* The Tab and Enter keys don't actually produce special codes
|
||||
* but the exact integer values of ^I and ^M. Rebinding the
|
||||
* latter therefore also rebinds Tab and Enter. */
|
||||
else if (!strcasecmp(keystring, "Tab"))
|
||||
s->keycode = TAB_CODE;
|
||||
else if (!strcasecmp(keystring, "Enter"))
|
||||
s->keycode = KEY_ENTER;
|
||||
else if (!strcasecmp(keystring, "PgUp"))
|
||||
s->keycode = KEY_PPAGE;
|
||||
else if (!strcasecmp(keystring, "PgDn"))
|
||||
s->keycode = KEY_NPAGE;
|
||||
else if (!strcasecmp(keystring, "Home"))
|
||||
s->keycode = KEY_HOME;
|
||||
else if (!strcasecmp(keystring, "End"))
|
||||
s->keycode = KEY_END;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -493,10 +482,8 @@ void shortcut_init(void)
|
||||
const char *fulljustify_tag = N_("FullJstify");
|
||||
#endif
|
||||
const char *refresh_tag = N_("Refresh");
|
||||
#ifndef NANO_TINY
|
||||
/* TRANSLATORS: Try to keep this string at most 12 characters. */
|
||||
const char *whereis_next_tag = N_("WhereIs Next");
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
@@ -552,18 +539,14 @@ void shortcut_init(void)
|
||||
#endif
|
||||
const char *nano_back_msg = N_("Go back one character");
|
||||
const char *nano_forward_msg = N_("Go forward one character");
|
||||
#ifndef NANO_TINY
|
||||
const char *nano_prevword_msg = N_("Go back one word");
|
||||
const char *nano_nextword_msg = N_("Go forward one word");
|
||||
#endif
|
||||
const char *nano_prevline_msg = N_("Go to previous line");
|
||||
const char *nano_nextline_msg = N_("Go to next line");
|
||||
const char *nano_home_msg = N_("Go to beginning of current line");
|
||||
const char *nano_end_msg = N_("Go to end of current line");
|
||||
#ifndef NANO_TINY
|
||||
const char *nano_prevblock_msg = N_("Go to previous block of text");
|
||||
const char *nano_nextblock_msg = N_("Go to next block of text");
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
const char *nano_parabegin_msg =
|
||||
N_("Go to beginning of paragraph; then of previous paragraph");
|
||||
@@ -764,20 +747,25 @@ void shortcut_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(case_sens_void, MWHEREIS|MREPLACE,
|
||||
N_("Case Sens"), IFSCHELP(nano_case_msg), TOGETHER, VIEW);
|
||||
add_to_funcs(do_cursorpos_void, MMAIN,
|
||||
N_("Cur Pos"), IFSCHELP(nano_cursorpos_msg), TOGETHER, VIEW);
|
||||
|
||||
#if (!defined(DISABLE_JUSTIFY) && (!defined(DISABLE_SPELLER) || !defined(DISABLE_COLOR)) || \
|
||||
defined(DISABLE_JUSTIFY) && defined(DISABLE_SPELLER) && defined(DISABLE_COLOR))
|
||||
/* Conditionally placing this one here or further on, to keep the
|
||||
* help items nicely paired in most conditions. */
|
||||
add_to_funcs(do_gotolinecolumn_void, MMAIN,
|
||||
gotoline_tag, IFSCHELP(nano_gotoline_msg), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(case_sens_void, MWHEREIS|MREPLACE,
|
||||
N_("Case Sens"), IFSCHELP(nano_case_msg), TOGETHER, VIEW);
|
||||
#ifdef HAVE_REGEX_H
|
||||
add_to_funcs(regexp_void, MWHEREIS|MREPLACE,
|
||||
N_("Regexp"), IFSCHELP(nano_regexp_msg), TOGETHER, VIEW);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(backwards_void, MWHEREIS|MREPLACE,
|
||||
N_("Backwards"), IFSCHELP(nano_reverse_msg), TOGETHER, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(flip_replace_void, MWHEREIS,
|
||||
replace_tag, IFSCHELP(nano_replace_msg), BLANKAFTER, VIEW);
|
||||
@@ -788,15 +776,8 @@ void shortcut_init(void)
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
add_to_funcs(do_full_justify, MWHEREIS,
|
||||
fulljustify_tag, IFSCHELP(nano_fulljustify_msg), TOGETHER, NOVIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(do_cursorpos_void, MMAIN,
|
||||
N_("Cur Pos"), IFSCHELP(nano_cursorpos_msg), TOGETHER, VIEW);
|
||||
|
||||
#if defined(DISABLE_COLOR) || !defined(DISABLE_JUSTIFY)
|
||||
/* Conditionally placing this one here or further on, to keep the
|
||||
* help items nicely paired in most conditions. */
|
||||
add_to_funcs(do_gotolinecolumn_void, MMAIN|MWHEREIS,
|
||||
add_to_funcs(do_gotolinecolumn_void, MWHEREIS,
|
||||
gotoline_tag, IFSCHELP(nano_gotoline_msg), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
@@ -846,12 +827,10 @@ void shortcut_init(void)
|
||||
N_("Forward"), IFSCHELP(nano_forwardfile_msg), TOGETHER, VIEW);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(do_prev_word_void, MMAIN,
|
||||
N_("Prev Word"), IFSCHELP(nano_prevword_msg), TOGETHER, VIEW);
|
||||
add_to_funcs(do_next_word_void, MMAIN,
|
||||
N_("Next Word"), IFSCHELP(nano_nextword_msg), TOGETHER, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(do_home, MMAIN,
|
||||
N_("Home"), IFSCHELP(nano_home_msg), TOGETHER, VIEW);
|
||||
@@ -863,12 +842,10 @@ void shortcut_init(void)
|
||||
add_to_funcs(do_down_void, MMAIN|MBROWSER,
|
||||
next_line_tag, IFSCHELP(nano_nextline_msg), BLANKAFTER, VIEW);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(do_prev_block, MMAIN,
|
||||
N_("Prev Block"), IFSCHELP(nano_prevblock_msg), TOGETHER, VIEW);
|
||||
add_to_funcs(do_next_block, MMAIN,
|
||||
N_("Next Block"), IFSCHELP(nano_nextblock_msg), TOGETHER, VIEW);
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
add_to_funcs(do_para_begin_void, MMAIN|MWHEREIS,
|
||||
@@ -891,11 +868,18 @@ void shortcut_init(void)
|
||||
N_("Next File"), IFSCHELP(nano_nextfile_msg), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
#if !defined(DISABLE_COLOR) && defined(DISABLE_JUSTIFY)
|
||||
#if (defined(DISABLE_JUSTIFY) && (!defined(DISABLE_SPELLER) || !defined(DISABLE_COLOR)) || \
|
||||
!defined(DISABLE_JUSTIFY) && defined(DISABLE_SPELLER) && defined(DISABLE_COLOR))
|
||||
add_to_funcs(do_gotolinecolumn_void, MMAIN,
|
||||
gotoline_tag, IFSCHELP(nano_gotoline_msg), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
#ifdef NANO_TINY
|
||||
/* Place this one here only in the tiny version; otherwise further up. */
|
||||
add_to_funcs(do_research, MMAIN,
|
||||
whereis_next_tag, IFSCHELP(nano_whereis_next_msg), TOGETHER, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(do_verbatim_input, MMAIN,
|
||||
N_("Verbatim"), IFSCHELP(nano_verbatim_msg), TOGETHER, NOVIEW);
|
||||
|
||||
@@ -964,7 +948,7 @@ void shortcut_init(void)
|
||||
N_("NextHstory"), IFSCHELP(nano_next_history_msg), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
#if !defined(DISABLE_COLOR) && defined(DISABLE_JUSTIFY)
|
||||
#ifdef DISABLE_JUSTIFY
|
||||
add_to_funcs(do_gotolinecolumn_void, MWHEREIS,
|
||||
gotoline_tag, IFSCHELP(nano_gotoline_msg), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
@@ -1052,224 +1036,241 @@ void shortcut_init(void)
|
||||
|
||||
/* Start associating key combos with functions in specific menus. */
|
||||
|
||||
add_to_sclist(MMOST, "^G", do_help_void, 0);
|
||||
add_to_sclist(MMOST, "F1", do_help_void, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "^X", do_exit, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", do_exit, 0);
|
||||
add_to_sclist(MMAIN, "^O", do_writeout_void, 0);
|
||||
add_to_sclist(MMAIN, "F3", do_writeout_void, 0);
|
||||
add_to_sclist(MMAIN, "^R", do_insertfile_void, 0);
|
||||
add_to_sclist(MMAIN, "F5", do_insertfile_void, 0);
|
||||
add_to_sclist(MMAIN, "Ins", do_insertfile_void, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER, "^W", do_search, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER, "F6", do_search, 0);
|
||||
add_to_sclist(MMAIN, "^\\", do_replace, 0);
|
||||
add_to_sclist(MMAIN, "M-R", do_replace, 0);
|
||||
add_to_sclist(MMAIN, "F14", do_replace, 0);
|
||||
add_to_sclist(MMOST, "^K", do_cut_text_void, 0);
|
||||
add_to_sclist(MMOST, "F9", do_cut_text_void, 0);
|
||||
add_to_sclist(MMAIN, "^U", do_uncut_text, 0);
|
||||
add_to_sclist(MMAIN, "F10", do_uncut_text, 0);
|
||||
add_to_sclist(MMOST, "^G", 0, do_help_void, 0);
|
||||
add_to_sclist(MMOST, "F1", 0, do_help_void, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "^X", 0, do_exit, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", 0, do_exit, 0);
|
||||
add_to_sclist(MMAIN, "^O", 0, do_writeout_void, 0);
|
||||
add_to_sclist(MMAIN, "F3", 0, do_writeout_void, 0);
|
||||
add_to_sclist(MMAIN, "^R", 0, do_insertfile_void, 0);
|
||||
add_to_sclist(MMAIN, "F5", 0, do_insertfile_void, 0);
|
||||
add_to_sclist(MMAIN, "Ins", 0, do_insertfile_void, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER, "^W", 0, do_search, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER, "F6", 0, do_search, 0);
|
||||
add_to_sclist(MMAIN, "^\\", 0, do_replace, 0);
|
||||
add_to_sclist(MMAIN, "M-R", 0, do_replace, 0);
|
||||
add_to_sclist(MMAIN, "F14", 0, do_replace, 0);
|
||||
add_to_sclist(MMOST, "^K", 0, do_cut_text_void, 0);
|
||||
add_to_sclist(MMOST, "F9", 0, do_cut_text_void, 0);
|
||||
add_to_sclist(MMAIN, "^U", 0, do_uncut_text, 0);
|
||||
add_to_sclist(MMAIN, "F10", 0, do_uncut_text, 0);
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
add_to_sclist(MMAIN, "^J", do_justify_void, 0);
|
||||
add_to_sclist(MMAIN, "F4", do_justify_void, 0);
|
||||
add_to_sclist(MMAIN, "^J", 0, do_justify_void, 0);
|
||||
add_to_sclist(MMAIN, "F4", 0, do_justify_void, 0);
|
||||
#endif
|
||||
#ifndef DISABLE_SPELLER
|
||||
add_to_sclist(MMAIN, "^T", do_spell, 0);
|
||||
add_to_sclist(MMAIN, "F12", do_spell, 0);
|
||||
add_to_sclist(MMAIN, "^T", 0, do_spell, 0);
|
||||
add_to_sclist(MMAIN, "F12", 0, do_spell, 0);
|
||||
#else
|
||||
#ifndef DISABLE_COLOR
|
||||
add_to_sclist(MMAIN, "^T", do_linter, 0);
|
||||
add_to_sclist(MMAIN, "F12", do_linter, 0);
|
||||
add_to_sclist(MMAIN, "^T", 0, do_linter, 0);
|
||||
add_to_sclist(MMAIN, "F12", 0, do_linter, 0);
|
||||
#endif
|
||||
#endif
|
||||
add_to_sclist(MMAIN, "^C", do_cursorpos_void, 0);
|
||||
add_to_sclist(MMAIN, "F11", do_cursorpos_void, 0);
|
||||
add_to_sclist(MMAIN, "^_", do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN, "M-G", do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN, "F13", do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^Y", do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F7", do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgUp", do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^V", do_page_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F8", do_page_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgDn", do_page_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-\\", do_first_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-|", do_first_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-/", do_last_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-?", do_last_line, 0);
|
||||
add_to_sclist(MMAIN, "^C", 0, do_cursorpos_void, 0);
|
||||
add_to_sclist(MMAIN, "F11", 0, do_cursorpos_void, 0);
|
||||
add_to_sclist(MMAIN, "^_", 0, do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN, "M-G", 0, do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN, "F13", 0, do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^Y", 0, do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F7", 0, do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgUp", KEY_PPAGE, do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^V", 0, do_page_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F8", 0, do_page_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgDn", KEY_NPAGE, do_page_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-\\", 0, do_first_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-|", 0, do_first_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-/", 0, do_last_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-?", 0, do_last_line, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER, "M-W", 0, do_research, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER, "F16", 0, do_research, 0);
|
||||
#ifndef NANO_TINY
|
||||
add_to_sclist(MMAIN|MBROWSER, "M-W", do_research, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER, "F16", do_research, 0);
|
||||
add_to_sclist(MMAIN, "M-]", do_find_bracket, 0);
|
||||
add_to_sclist(MMAIN, "^^", do_mark, 0);
|
||||
add_to_sclist(MMAIN, "M-A", do_mark, 0);
|
||||
add_to_sclist(MMAIN, "F15", do_mark, 0);
|
||||
add_to_sclist(MMAIN, "M-^", do_copy_text, 0);
|
||||
add_to_sclist(MMAIN, "M-6", do_copy_text, 0);
|
||||
add_to_sclist(MMAIN, "M-}", do_indent_void, 0);
|
||||
add_to_sclist(MMAIN, "M-{", do_unindent, 0);
|
||||
add_to_sclist(MMAIN, "M-U", do_undo, 0);
|
||||
add_to_sclist(MMAIN, "M-E", do_redo, 0);
|
||||
add_to_sclist(MMAIN, "M-]", 0, do_find_bracket, 0);
|
||||
add_to_sclist(MMAIN, "^^", 0, do_mark, 0);
|
||||
add_to_sclist(MMAIN, "M-A", 0, do_mark, 0);
|
||||
add_to_sclist(MMAIN, "F15", 0, do_mark, 0);
|
||||
add_to_sclist(MMAIN, "M-^", 0, do_copy_text, 0);
|
||||
add_to_sclist(MMAIN, "M-6", 0, do_copy_text, 0);
|
||||
add_to_sclist(MMAIN, "M-}", 0, do_indent_void, 0);
|
||||
add_to_sclist(MMAIN, "M-{", 0, do_unindent, 0);
|
||||
add_to_sclist(MMAIN, "M-U", 0, do_undo, 0);
|
||||
add_to_sclist(MMAIN, "M-E", 0, do_redo, 0);
|
||||
#endif
|
||||
#ifdef ENABLE_COMMENT
|
||||
add_to_sclist(MMAIN, "M-3", do_comment, 0);
|
||||
add_to_sclist(MMAIN, "M-3", 0, do_comment, 0);
|
||||
#endif
|
||||
add_to_sclist(MMOST, "^B", do_left, 0);
|
||||
add_to_sclist(MMOST, "Left", do_left, 0);
|
||||
add_to_sclist(MMOST, "^F", do_right, 0);
|
||||
add_to_sclist(MMOST, "Right", do_right, 0);
|
||||
#ifndef NANO_TINY
|
||||
add_to_sclist(MMOST, "M-Space", do_prev_word_void, 0);
|
||||
add_to_sclist(MMOST, "^Space", do_next_word_void, 0);
|
||||
add_to_sclist(MMOST, "^B", 0, do_left, 0);
|
||||
add_to_sclist(MMOST, "Left", KEY_LEFT, do_left, 0);
|
||||
add_to_sclist(MMOST, "^F", 0, do_right, 0);
|
||||
add_to_sclist(MMOST, "Right", KEY_RIGHT, do_right, 0);
|
||||
#ifdef ENABLE_UTF8
|
||||
if (using_utf8()) {
|
||||
add_to_sclist(MMOST, "^\xE2\x86\x90", CONTROL_LEFT, do_prev_word_void, 0);
|
||||
add_to_sclist(MMOST, "^\xE2\x86\x92", CONTROL_RIGHT, do_next_word_void, 0);
|
||||
} else
|
||||
#endif
|
||||
add_to_sclist((MMOST & ~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);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "Down", do_down_void, 0);
|
||||
#ifndef NANO_TINY
|
||||
add_to_sclist(MMAIN, "M-7", do_prev_block, 0);
|
||||
add_to_sclist(MMAIN, "M-8", do_next_block, 0);
|
||||
{
|
||||
add_to_sclist(MMOST, "^Left", CONTROL_LEFT, do_prev_word_void, 0);
|
||||
add_to_sclist(MMOST, "^Right", CONTROL_RIGHT, do_next_word_void, 0);
|
||||
}
|
||||
add_to_sclist(MMOST, "M-Space", 0, do_prev_word_void, 0);
|
||||
add_to_sclist(MMOST, "^Space", 0, do_next_word_void, 0);
|
||||
add_to_sclist((MMOST & ~MBROWSER), "^A", 0, do_home, 0);
|
||||
add_to_sclist((MMOST & ~MBROWSER), "Home", KEY_HOME, do_home, 0);
|
||||
add_to_sclist((MMOST & ~MBROWSER), "^E", 0, do_end, 0);
|
||||
add_to_sclist((MMOST & ~MBROWSER), "End", KEY_END, do_end, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "^P", 0, do_up_void, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "Up", KEY_UP, do_up_void, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "^N", 0, do_down_void, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "Down", KEY_DOWN, do_down_void, 0);
|
||||
#ifdef ENABLE_UTF8
|
||||
if (using_utf8()) {
|
||||
add_to_sclist(MMAIN, "^\xE2\x86\x91", CONTROL_UP, do_prev_block, 0);
|
||||
add_to_sclist(MMAIN, "^\xE2\x86\x93", CONTROL_DOWN, do_next_block, 0);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
add_to_sclist(MMAIN, "^Up", CONTROL_UP, do_prev_block, 0);
|
||||
add_to_sclist(MMAIN, "^Down", CONTROL_DOWN, do_next_block, 0);
|
||||
}
|
||||
add_to_sclist(MMAIN, "M-7", 0, do_prev_block, 0);
|
||||
add_to_sclist(MMAIN, "M-8", 0, do_next_block, 0);
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
add_to_sclist(MMAIN, "M-(", do_para_begin_void, 0);
|
||||
add_to_sclist(MMAIN, "M-9", do_para_begin_void, 0);
|
||||
add_to_sclist(MMAIN, "M-)", do_para_end_void, 0);
|
||||
add_to_sclist(MMAIN, "M-0", do_para_end_void, 0);
|
||||
add_to_sclist(MMAIN, "M-(", 0, do_para_begin_void, 0);
|
||||
add_to_sclist(MMAIN, "M-9", 0, do_para_begin_void, 0);
|
||||
add_to_sclist(MMAIN, "M-)", 0, do_para_end_void, 0);
|
||||
add_to_sclist(MMAIN, "M-0", 0, do_para_end_void, 0);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
add_to_sclist(MMAIN, "M--", do_scroll_up, 0);
|
||||
add_to_sclist(MMAIN, "M-_", do_scroll_up, 0);
|
||||
add_to_sclist(MMAIN, "M-+", do_scroll_down, 0);
|
||||
add_to_sclist(MMAIN, "M-=", do_scroll_down, 0);
|
||||
add_to_sclist(MMAIN, "M--", 0, do_scroll_up, 0);
|
||||
add_to_sclist(MMAIN, "M-_", 0, do_scroll_up, 0);
|
||||
add_to_sclist(MMAIN, "M-+", 0, do_scroll_down, 0);
|
||||
add_to_sclist(MMAIN, "M-=", 0, do_scroll_down, 0);
|
||||
#endif
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
add_to_sclist(MMAIN, "M-<", switch_to_prev_buffer_void, 0);
|
||||
add_to_sclist(MMAIN, "M-,", switch_to_prev_buffer_void, 0);
|
||||
add_to_sclist(MMAIN, "M->", switch_to_next_buffer_void, 0);
|
||||
add_to_sclist(MMAIN, "M-.", switch_to_next_buffer_void, 0);
|
||||
add_to_sclist(MMAIN, "M-<", 0, switch_to_prev_buffer_void, 0);
|
||||
add_to_sclist(MMAIN, "M-,", 0, switch_to_prev_buffer_void, 0);
|
||||
add_to_sclist(MMAIN, "M->", 0, switch_to_next_buffer_void, 0);
|
||||
add_to_sclist(MMAIN, "M-.", 0, switch_to_next_buffer_void, 0);
|
||||
#endif
|
||||
add_to_sclist(MMOST, "M-V", do_verbatim_input, 0);
|
||||
add_to_sclist(MMOST, "M-V", 0, do_verbatim_input, 0);
|
||||
#ifndef NANO_TINY
|
||||
add_to_sclist(MMAIN, "M-T", do_cut_till_eof, 0);
|
||||
add_to_sclist(MMAIN, "M-D", do_wordlinechar_count, 0);
|
||||
add_to_sclist(MMAIN, "M-T", 0, do_cut_till_eof, 0);
|
||||
add_to_sclist(MMAIN, "M-D", 0, do_wordlinechar_count, 0);
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
add_to_sclist(MMAIN|MWHEREIS, "M-J", do_full_justify, 0);
|
||||
add_to_sclist(MMAIN|MWHEREIS, "M-J", 0, do_full_justify, 0);
|
||||
#endif
|
||||
add_to_sclist(MMAIN|MHELP, "^L", total_refresh, 0);
|
||||
add_to_sclist(MMAIN, "^Z", do_suspend_void, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "^L", 0, total_refresh, 0);
|
||||
add_to_sclist(MMAIN, "^Z", 0, do_suspend_void, 0);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Group of "Appearance" toggles. */
|
||||
add_to_sclist(MMAIN, "M-X", do_toggle_void, NO_HELP);
|
||||
add_to_sclist(MMAIN, "M-C", do_toggle_void, CONST_UPDATE);
|
||||
add_to_sclist(MMAIN, "M-O", do_toggle_void, MORE_SPACE);
|
||||
add_to_sclist(MMAIN, "M-S", do_toggle_void, SMOOTH_SCROLL);
|
||||
add_to_sclist(MMAIN, "M-$", do_toggle_void, SOFTWRAP);
|
||||
add_to_sclist(MMAIN, "M-P", do_toggle_void, WHITESPACE_DISPLAY);
|
||||
add_to_sclist(MMAIN, "M-X", 0, do_toggle_void, NO_HELP);
|
||||
add_to_sclist(MMAIN, "M-C", 0, do_toggle_void, CONST_UPDATE);
|
||||
add_to_sclist(MMAIN, "M-O", 0, do_toggle_void, MORE_SPACE);
|
||||
add_to_sclist(MMAIN, "M-S", 0, do_toggle_void, SMOOTH_SCROLL);
|
||||
add_to_sclist(MMAIN, "M-$", 0, do_toggle_void, SOFTWRAP);
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
add_to_sclist(MMAIN, "M-#", 0, do_toggle_void, LINE_NUMBERS);
|
||||
#endif
|
||||
add_to_sclist(MMAIN, "M-P", 0, do_toggle_void, WHITESPACE_DISPLAY);
|
||||
#ifndef DISABLE_COLOR
|
||||
add_to_sclist(MMAIN, "M-Y", do_toggle_void, NO_COLOR_SYNTAX);
|
||||
add_to_sclist(MMAIN, "M-Y", 0, do_toggle_void, NO_COLOR_SYNTAX);
|
||||
#endif
|
||||
|
||||
/* Group of "Editing-behavior" toggles. */
|
||||
add_to_sclist(MMAIN, "M-H", do_toggle_void, SMART_HOME);
|
||||
add_to_sclist(MMAIN, "M-I", do_toggle_void, AUTOINDENT);
|
||||
add_to_sclist(MMAIN, "M-K", do_toggle_void, CUT_TO_END);
|
||||
add_to_sclist(MMAIN, "M-H", 0, do_toggle_void, SMART_HOME);
|
||||
add_to_sclist(MMAIN, "M-I", 0, do_toggle_void, AUTOINDENT);
|
||||
add_to_sclist(MMAIN, "M-K", 0, do_toggle_void, CUT_TO_END);
|
||||
#ifndef DISABLE_WRAPPING
|
||||
add_to_sclist(MMAIN, "M-L", do_toggle_void, NO_WRAP);
|
||||
add_to_sclist(MMAIN, "M-L", 0, do_toggle_void, NO_WRAP);
|
||||
#endif
|
||||
add_to_sclist(MMAIN, "M-Q", do_toggle_void, TABS_TO_SPACES);
|
||||
add_to_sclist(MMAIN, "M-Q", 0, do_toggle_void, TABS_TO_SPACES);
|
||||
|
||||
/* Group of "Peripheral-feature" toggles. */
|
||||
add_to_sclist(MMAIN, "M-B", do_toggle_void, BACKUP_FILE);
|
||||
add_to_sclist(MMAIN, "M-B", 0, do_toggle_void, BACKUP_FILE);
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
add_to_sclist(MMAIN, "M-F", do_toggle_void, MULTIBUFFER);
|
||||
add_to_sclist(MMAIN, "M-F", 0, do_toggle_void, MULTIBUFFER);
|
||||
#endif
|
||||
#ifndef DISABLE_MOUSE
|
||||
add_to_sclist(MMAIN, "M-M", do_toggle_void, USE_MOUSE);
|
||||
add_to_sclist(MMAIN, "M-M", 0, do_toggle_void, USE_MOUSE);
|
||||
#endif
|
||||
add_to_sclist(MMAIN, "M-N", do_toggle_void, NO_CONVERT);
|
||||
add_to_sclist(MMAIN, "M-Z", do_toggle_void, SUSPEND);
|
||||
add_to_sclist(MMAIN, "M-N", 0, do_toggle_void, NO_CONVERT);
|
||||
add_to_sclist(MMAIN, "M-Z", 0, do_toggle_void, SUSPEND);
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
add_to_sclist(MMAIN, "^Q", xon_complaint, 0);
|
||||
add_to_sclist(MMAIN, "^S", xoff_complaint, 0);
|
||||
add_to_sclist(MMAIN, "^Q", 0, xon_complaint, 0);
|
||||
add_to_sclist(MMAIN, "^S", 0, xoff_complaint, 0);
|
||||
|
||||
add_to_sclist(((MMOST & ~MMAIN & ~MBROWSER) | MYESNO), "^C", do_cancel, 0);
|
||||
add_to_sclist(((MMOST & ~MMAIN & ~MBROWSER) | MYESNO), "^C", 0, do_cancel, 0);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_sclist(MWHEREIS|MREPLACE, "M-B", backwards_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE, "M-C", case_sens_void, 0);
|
||||
#endif
|
||||
add_to_sclist(MWHEREIS|MREPLACE, "M-R", regexp_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE, "^R", flip_replace_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^Y", do_first_line, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^V", do_last_line, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE, "M-C", 0, case_sens_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE, "M-R", 0, regexp_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE, "M-B", 0, backwards_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE, "^R", 0, flip_replace_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^Y", 0, do_first_line, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^V", 0, do_last_line, 0);
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH, "^W", do_para_begin_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH, "^O", do_para_end_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH, "^W", 0, do_para_begin_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH, "^O", 0, do_para_end_void, 0);
|
||||
#endif
|
||||
add_to_sclist(MWHEREIS, "^T", do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MGOTOLINE, "^T", gototext_void, 0);
|
||||
add_to_sclist(MWHEREIS, "^T", 0, do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MGOTOLINE, "^T", 0, gototext_void, 0);
|
||||
#ifndef DISABLE_HISTORIES
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^P", get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Up", get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^N", get_history_newer_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Down", get_history_newer_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^P", 0, get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Up", KEY_UP, get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^N", 0, get_history_newer_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Down", KEY_DOWN, get_history_newer_void, 0);
|
||||
#endif
|
||||
#ifndef DISABLE_BROWSER
|
||||
add_to_sclist(MWHEREISFILE, "^Y", do_first_file, 0);
|
||||
add_to_sclist(MWHEREISFILE, "^V", do_last_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-\\", do_first_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", do_first_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-/", do_last_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", do_last_file, 0);
|
||||
add_to_sclist(MBROWSER, "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);
|
||||
add_to_sclist(MBROWSER, "^L", total_refresh, 0);
|
||||
add_to_sclist(MWHEREISFILE, "^Y", 0, do_first_file, 0);
|
||||
add_to_sclist(MWHEREISFILE, "^V", 0, do_last_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-\\", 0, do_first_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", 0, do_first_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-/", 0, do_last_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", 0, do_last_file, 0);
|
||||
add_to_sclist(MBROWSER, "Home", KEY_HOME, do_first_file, 0);
|
||||
add_to_sclist(MBROWSER, "End", KEY_END, do_last_file, 0);
|
||||
add_to_sclist(MBROWSER, "^_", 0, goto_dir_void, 0);
|
||||
add_to_sclist(MBROWSER, "M-G", 0, goto_dir_void, 0);
|
||||
add_to_sclist(MBROWSER, "F13", 0, goto_dir_void, 0);
|
||||
add_to_sclist(MBROWSER, "^L", 0, total_refresh, 0);
|
||||
#endif
|
||||
if (ISSET(TEMP_FILE))
|
||||
add_to_sclist(MWRITEFILE, "^Q", discard_buffer, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-D", dos_format_void, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-M", mac_format_void, 0);
|
||||
add_to_sclist(MWRITEFILE, "^Q", 0, discard_buffer, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-D", 0, dos_format_void, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-M", 0, mac_format_void, 0);
|
||||
if (!ISSET(RESTRICTED)) {
|
||||
/* Don't allow Appending, Prepending, nor Backups in restricted mode. */
|
||||
add_to_sclist(MWRITEFILE, "M-A", append_void, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-P", prepend_void, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-B", backup_file_void, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-A", 0, append_void, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-P", 0, prepend_void, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-B", 0, backup_file_void, 0);
|
||||
#ifndef DISABLE_BROWSER
|
||||
add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", to_files_void, 0);
|
||||
add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", 0, to_files_void, 0);
|
||||
#endif
|
||||
add_to_sclist(MINSERTFILE|MEXTCMD, "^X", flip_execute_void, 0);
|
||||
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", new_buffer_void, 0);
|
||||
add_to_sclist(MINSERTFILE|MEXTCMD, "^X", 0, flip_execute_void, 0);
|
||||
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, new_buffer_void, 0);
|
||||
}
|
||||
add_to_sclist(MHELP|MBROWSER, "^C", do_exit, 0);
|
||||
add_to_sclist(MHELP|MBROWSER, "^C", 0, do_exit, 0);
|
||||
/* Allow exiting from the file browser and the help viewer with
|
||||
* the same key as they were entered. */
|
||||
#ifndef DISABLE_BROWSER
|
||||
add_to_sclist(MBROWSER, "^T", do_exit, 0);
|
||||
add_to_sclist(MBROWSER, "^T", 0, do_exit, 0);
|
||||
#endif
|
||||
#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);
|
||||
add_to_sclist(MHELP, "^G", 0, do_exit, 0);
|
||||
add_to_sclist(MHELP, "Home", KEY_HOME, do_first_line, 0);
|
||||
add_to_sclist(MHELP, "End", KEY_END, do_last_line, 0);
|
||||
#endif
|
||||
add_to_sclist(MMOST, "^I", do_tab, 0);
|
||||
add_to_sclist(MMOST, "Tab", do_tab, 0);
|
||||
add_to_sclist(MMOST, "^M", do_enter, 0);
|
||||
add_to_sclist(MMOST, "Enter", do_enter, 0);
|
||||
add_to_sclist(MMOST, "^D", do_delete, 0);
|
||||
add_to_sclist(MMOST, "Del", do_delete, 0);
|
||||
add_to_sclist(MMOST, "^H", do_backspace, 0);
|
||||
add_to_sclist(MMOST, "Bsp", do_backspace, 0);
|
||||
add_to_sclist(MMOST, "^I", 0, do_tab, 0);
|
||||
add_to_sclist(MMOST, "Tab", TAB_CODE, do_tab, 0);
|
||||
add_to_sclist(MMOST, "^M", 0, do_enter, 0);
|
||||
add_to_sclist(MMOST, "Enter", KEY_ENTER, do_enter, 0);
|
||||
add_to_sclist(MMOST, "^D", 0, do_delete, 0);
|
||||
add_to_sclist(MMOST, "Del", 0, do_delete, 0);
|
||||
add_to_sclist(MMOST, "^H", 0, do_backspace, 0);
|
||||
add_to_sclist(MMOST, "Bsp", KEY_BACKSPACE, do_backspace, 0);
|
||||
|
||||
#ifdef DEBUG
|
||||
print_sclist();
|
||||
@@ -1351,6 +1352,8 @@ const char *flagtostr(int flag)
|
||||
return N_("No conversion from DOS/Mac format");
|
||||
case SUSPEND:
|
||||
return N_("Suspension");
|
||||
case LINE_NUMBERS:
|
||||
return N_("Line numbering");
|
||||
default:
|
||||
return "?????";
|
||||
}
|
||||
@@ -1362,10 +1365,11 @@ const char *flagtostr(int flag)
|
||||
* shortcut struct with the corresponding function filled in. */
|
||||
sc *strtosc(const char *input)
|
||||
{
|
||||
sc *s;
|
||||
sc *s = nmalloc(sizeof(sc));
|
||||
|
||||
s = (sc *)nmalloc(sizeof(sc));
|
||||
#ifndef NANO_TINY
|
||||
s->toggle = 0;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
if (!strcasecmp(input, "help"))
|
||||
@@ -1388,10 +1392,10 @@ sc *strtosc(const char *input)
|
||||
s->scfunc = do_insertfile_void;
|
||||
else if (!strcasecmp(input, "whereis"))
|
||||
s->scfunc = do_search;
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcasecmp(input, "searchagain") ||
|
||||
!strcasecmp(input, "research"))
|
||||
!strcasecmp(input, "research")) /* Deprecated. Remove in 2018. */
|
||||
s->scfunc = do_research;
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcasecmp(input, "findprevious"))
|
||||
s->scfunc = do_findprevious;
|
||||
else if (!strcasecmp(input, "findnext"))
|
||||
@@ -1421,7 +1425,7 @@ sc *strtosc(const char *input)
|
||||
s->scfunc = do_linter;
|
||||
#endif
|
||||
else if (!strcasecmp(input, "curpos") ||
|
||||
!strcasecmp(input, "cursorpos"))
|
||||
!strcasecmp(input, "cursorpos")) /* Deprecated. Remove in 2018. */
|
||||
s->scfunc = do_cursorpos_void;
|
||||
else if (!strcasecmp(input, "gotoline"))
|
||||
s->scfunc = do_gotolinecolumn_void;
|
||||
@@ -1517,15 +1521,13 @@ sc *strtosc(const char *input)
|
||||
s->scfunc = do_suspend_void;
|
||||
else if (!strcasecmp(input, "casesens"))
|
||||
s->scfunc = case_sens_void;
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcasecmp(input, "regexp") ||
|
||||
!strcasecmp(input, "regex"))
|
||||
!strcasecmp(input, "regex")) /* Deprecated. Remove in 2018. */
|
||||
s->scfunc = regexp_void;
|
||||
else if (!strcasecmp(input, "backwards"))
|
||||
s->scfunc = backwards_void;
|
||||
#endif
|
||||
else if (!strcasecmp(input, "flipreplace") ||
|
||||
!strcasecmp(input, "dontreplace"))
|
||||
!strcasecmp(input, "dontreplace")) /* Deprecated. Remove in 2018. */
|
||||
s->scfunc = flip_replace_void;
|
||||
else if (!strcasecmp(input, "gototext"))
|
||||
s->scfunc = gototext_void;
|
||||
@@ -1551,7 +1553,7 @@ sc *strtosc(const char *input)
|
||||
#endif
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
else if (!strcasecmp(input, "flipnewbuffer") ||
|
||||
!strcasecmp(input, "newbuffer"))
|
||||
!strcasecmp(input, "newbuffer")) /* Deprecated. Remove in 2018. */
|
||||
s->scfunc = new_buffer_void;
|
||||
#endif
|
||||
#ifndef DISABLE_BROWSER
|
||||
@@ -1565,8 +1567,8 @@ sc *strtosc(const char *input)
|
||||
else if (!strcasecmp(input, "lastfile"))
|
||||
s->scfunc = do_last_file;
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
else {
|
||||
#ifndef NANO_TINY
|
||||
s->scfunc = do_toggle_void;
|
||||
if (!strcasecmp(input, "nohelp"))
|
||||
s->toggle = NO_HELP;
|
||||
@@ -1610,14 +1612,13 @@ sc *strtosc(const char *input)
|
||||
s->toggle = NO_CONVERT;
|
||||
else if (!strcasecmp(input, "suspendenable"))
|
||||
s->toggle = SUSPEND;
|
||||
else
|
||||
#endif /* !NANO_TINY */
|
||||
else {
|
||||
{
|
||||
free(s);
|
||||
return NULL;
|
||||
}
|
||||
#ifndef NANO_TINY
|
||||
}
|
||||
#endif
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -1632,7 +1633,7 @@ int strtomenu(const char *input)
|
||||
return MWHEREIS;
|
||||
else if (!strcasecmp(input, "replace"))
|
||||
return MREPLACE;
|
||||
else if (!strcasecmp(input, "replace2") ||
|
||||
else if (!strcasecmp(input, "replace2") || /* Deprecated. Remove in 2018. */
|
||||
!strcasecmp(input, "replacewith"))
|
||||
return MREPLACEWITH;
|
||||
else if (!strcasecmp(input, "gotoline"))
|
||||
@@ -1701,9 +1702,6 @@ void thanks_for_all_the_fish(void)
|
||||
free(alt_speller);
|
||||
#endif
|
||||
free_filestruct(cutbuffer);
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
free_filestruct(jusbuffer);
|
||||
#endif
|
||||
/* Free the memory associated with each open file buffer. */
|
||||
while (openfile != openfile->next) {
|
||||
openfile = openfile->next;
|
||||
|
||||
@@ -419,7 +419,11 @@ void help_init(void)
|
||||
* but allow it to spill into the second, for "M-Space". */
|
||||
if (scsfound == 1) {
|
||||
sprintf(ptr, "%s ", s->keystr);
|
||||
ptr += 6;
|
||||
/* Unicode arrows take three bytes instead of one. */
|
||||
if (s->keystr[1] == '\xE2')
|
||||
ptr += 8;
|
||||
else
|
||||
ptr += 6;
|
||||
} else {
|
||||
ptr += sprintf(ptr, "(%s)\t", s->keystr);
|
||||
break;
|
||||
|
||||
107
src/move.c
107
src/move.c
@@ -28,7 +28,7 @@
|
||||
/* Move to the first line of the file. */
|
||||
void do_first_line(void)
|
||||
{
|
||||
openfile->current = openfile->edittop = openfile->fileage;
|
||||
openfile->current = openfile->fileage;
|
||||
openfile->current_x = 0;
|
||||
openfile->placewewant = 0;
|
||||
|
||||
@@ -41,6 +41,8 @@ void do_last_line(void)
|
||||
openfile->current = openfile->filebot;
|
||||
openfile->current_x = strlen(openfile->filebot->data);
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
/* Set the last line of the screen as the target for the cursor. */
|
||||
openfile->current_y = editwinrows - 1;
|
||||
|
||||
refresh_needed = TRUE;
|
||||
@@ -97,7 +99,7 @@ void do_page_up(void)
|
||||
#endif
|
||||
|
||||
/* Scroll the edit window up a page. */
|
||||
edit_update(STATIONARY);
|
||||
adjust_viewport(STATIONARY);
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
@@ -137,7 +139,7 @@ void do_page_down(void)
|
||||
openfile->placewewant);
|
||||
|
||||
/* Scroll the edit window down a page. */
|
||||
edit_update(STATIONARY);
|
||||
adjust_viewport(STATIONARY);
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
@@ -147,7 +149,7 @@ void do_page_down(void)
|
||||
* afterwards. */
|
||||
void do_para_begin(bool allow_update)
|
||||
{
|
||||
filestruct *current_save = openfile->current;
|
||||
filestruct *was_current = openfile->current;
|
||||
|
||||
if (openfile->current != openfile->fileage) {
|
||||
do {
|
||||
@@ -159,7 +161,7 @@ void do_para_begin(bool allow_update)
|
||||
openfile->current_x = 0;
|
||||
|
||||
if (allow_update)
|
||||
edit_redraw(current_save);
|
||||
edit_redraw(was_current);
|
||||
}
|
||||
|
||||
/* Move up to the beginning of the last beginning-of-paragraph line
|
||||
@@ -177,7 +179,7 @@ void do_para_begin_void(void)
|
||||
* paragraph or isn't in a paragraph. */
|
||||
void do_para_end(bool allow_update)
|
||||
{
|
||||
filestruct *const current_save = openfile->current;
|
||||
filestruct *was_current = openfile->current;
|
||||
|
||||
while (openfile->current != openfile->filebot &&
|
||||
!inpar(openfile->current))
|
||||
@@ -197,7 +199,7 @@ void do_para_end(bool allow_update)
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
|
||||
if (allow_update)
|
||||
edit_redraw(current_save);
|
||||
edit_redraw(was_current);
|
||||
}
|
||||
|
||||
/* Move down to the beginning of the last line of the current paragraph.
|
||||
@@ -209,7 +211,6 @@ void do_para_end_void(void)
|
||||
}
|
||||
#endif /* !DISABLE_JUSTIFY */
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Move to the preceding block of text in the file. */
|
||||
void do_prev_block(void)
|
||||
{
|
||||
@@ -255,7 +256,7 @@ void do_next_block(void)
|
||||
* screen afterwards. */
|
||||
void do_prev_word(bool allow_punct, bool allow_update)
|
||||
{
|
||||
filestruct *current_save = openfile->current;
|
||||
filestruct *was_current = openfile->current;
|
||||
bool seen_a_word = FALSE, step_forward = FALSE;
|
||||
|
||||
assert(openfile->current != NULL && openfile->current->data != NULL);
|
||||
@@ -295,7 +296,7 @@ void do_prev_word(bool allow_punct, bool allow_update)
|
||||
/* If allow_update is TRUE, update the screen. */
|
||||
if (allow_update) {
|
||||
focusing = FALSE;
|
||||
edit_redraw(current_save);
|
||||
edit_redraw(was_current);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,7 +313,7 @@ void do_prev_word_void(void)
|
||||
* otherwise. */
|
||||
bool do_next_word(bool allow_punct, bool allow_update)
|
||||
{
|
||||
filestruct *current_save = openfile->current;
|
||||
filestruct *was_current = openfile->current;
|
||||
bool started_on_word = is_word_mbchar(openfile->current->data +
|
||||
openfile->current_x, allow_punct);
|
||||
bool seen_space = !started_on_word;
|
||||
@@ -347,7 +348,7 @@ bool do_next_word(bool allow_punct, bool allow_update)
|
||||
/* If allow_update is TRUE, update the screen. */
|
||||
if (allow_update) {
|
||||
focusing = FALSE;
|
||||
edit_redraw(current_save);
|
||||
edit_redraw(was_current);
|
||||
}
|
||||
|
||||
/* Return whether we started on a word. */
|
||||
@@ -360,7 +361,19 @@ void do_next_word_void(void)
|
||||
{
|
||||
do_next_word(ISSET(WORD_BOUNDS), TRUE);
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Make sure that the current line, when it is partially scrolled off the
|
||||
* screen in softwrap mode, is scrolled fully into view. */
|
||||
void ensure_line_is_visible(void)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP) && strlenpt(openfile->current->data) / editwincols +
|
||||
openfile->current_y >= editwinrows) {
|
||||
adjust_viewport(ISSET(SMOOTH_SCROLL) ? FLOWING : CENTERING);
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Move to the beginning of the current line. If the SMART_HOME flag is
|
||||
* set, move to the first non-whitespace character of the current line
|
||||
@@ -399,6 +412,8 @@ void do_end(void)
|
||||
|
||||
if (need_horizontal_scroll(was_column, openfile->placewewant))
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
|
||||
ensure_line_is_visible();
|
||||
}
|
||||
|
||||
/* If scroll_only is FALSE, move up one line. If scroll_only is TRUE,
|
||||
@@ -423,21 +438,12 @@ void do_up(bool scroll_only)
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
openfile->placewewant);
|
||||
|
||||
/* If scroll_only is FALSE and if we're on the first line of the
|
||||
* edit window, scroll the edit window up one line if we're in
|
||||
* smooth scrolling mode, or up half a page if we're not. If
|
||||
* scroll_only is TRUE, scroll the edit window up one line
|
||||
* unconditionally. */
|
||||
if (openfile->current_y == 0
|
||||
#ifndef NANO_TINY
|
||||
|| (ISSET(SOFTWRAP) && openfile->edittop->lineno == openfile->current->next->lineno) || scroll_only
|
||||
#endif
|
||||
)
|
||||
edit_scroll(UPWARD,
|
||||
#ifndef NANO_TINY
|
||||
(ISSET(SMOOTH_SCROLL) || scroll_only) ? 1 :
|
||||
#endif
|
||||
editwinrows / 2 + 1);
|
||||
/* When the cursor was on the first line of the edit window (or when just
|
||||
* scrolling without moving the cursor), scroll the edit window up -- one
|
||||
* line if we're in smooth scrolling mode, and half a page otherwise. */
|
||||
if (openfile->current->next == openfile->edittop || scroll_only)
|
||||
edit_scroll(UPWARD, (ISSET(SMOOTH_SCROLL) || scroll_only) ?
|
||||
1 : editwinrows / 2 + 1);
|
||||
|
||||
/* If the lines weren't already redrawn, see if they need to be. */
|
||||
if (openfile->current_y > 0) {
|
||||
@@ -477,18 +483,20 @@ void do_down(bool scroll_only)
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
/* Compute the number of lines to scroll. */
|
||||
amount = strlenpt(openfile->current->data) / COLS - xplustabs() / COLS +
|
||||
strlenpt(openfile->current->next->data) / COLS +
|
||||
amount = strlenpt(openfile->current->data) / editwincols -
|
||||
xplustabs() / editwincols +
|
||||
strlenpt(openfile->current->next->data) / editwincols +
|
||||
openfile->current_y - editwinrows + 2;
|
||||
topline = openfile->edittop;
|
||||
/* Reduce the amount when there are overlong lines at the top. */
|
||||
for (enough = 1; enough < amount; enough++) {
|
||||
amount -= strlenpt(topline->data) / COLS;
|
||||
if (amount <= 0) {
|
||||
amount -= strlenpt(topline->data) / editwincols;
|
||||
if (amount > 0)
|
||||
topline = topline->next;
|
||||
if (amount < enough) {
|
||||
amount = enough;
|
||||
break;
|
||||
}
|
||||
topline = topline->next;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -503,26 +511,23 @@ void do_down(bool scroll_only)
|
||||
* smooth scrolling mode, or down half a page if we're not. If
|
||||
* scroll_only is TRUE, scroll the edit window down one line
|
||||
* unconditionally. */
|
||||
if (openfile->current_y == editwinrows - 1
|
||||
#ifndef NANO_TINY
|
||||
|| amount > 0 || scroll_only
|
||||
#endif
|
||||
) {
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->current_y == editwinrows - 1 || amount > 0 || scroll_only) {
|
||||
if (amount < 1 || scroll_only)
|
||||
amount = 1;
|
||||
#endif
|
||||
edit_scroll(DOWNWARD,
|
||||
#ifndef NANO_TINY
|
||||
(ISSET(SMOOTH_SCROLL) || scroll_only) ? amount :
|
||||
#endif
|
||||
editwinrows / 2 + 1);
|
||||
|
||||
edit_scroll(DOWNWARD, (ISSET(SMOOTH_SCROLL) || scroll_only) ?
|
||||
amount : editwinrows / 2 + 1);
|
||||
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
refresh_needed = TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (openfile->current_y == editwinrows - 1)
|
||||
edit_scroll(DOWNWARD, editwinrows / 2 + 1);
|
||||
#endif
|
||||
|
||||
/* If the lines weren't already redrawn, see if they need to be. */
|
||||
if (openfile->current_y < editwinrows - 1) {
|
||||
@@ -586,15 +591,19 @@ void do_right(void)
|
||||
openfile->current_x);
|
||||
else if (openfile->current != openfile->filebot) {
|
||||
openfile->current_x = 0;
|
||||
openfile->placewewant = 0;
|
||||
if (need_horizontal_scroll(was_column, 0))
|
||||
update_line(openfile->current, 0);
|
||||
do_down_void();
|
||||
return;
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP))
|
||||
openfile->current_y -= strlenpt(openfile->current->data) / COLS;
|
||||
#endif
|
||||
}
|
||||
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
if (need_horizontal_scroll(was_column, openfile->placewewant))
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
|
||||
if (openfile->current_x == 0)
|
||||
do_down_void();
|
||||
else
|
||||
ensure_line_is_visible();
|
||||
}
|
||||
|
||||
105
src/nano.c
105
src/nano.c
@@ -395,7 +395,7 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
|
||||
/* If the top of the edit window was inside the old partition, put
|
||||
* it in range of current. */
|
||||
if (edittop_inside) {
|
||||
edit_update(STATIONARY);
|
||||
adjust_viewport(STATIONARY);
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
@@ -797,13 +797,11 @@ void print_opt_full(const char *shortflag
|
||||
void usage(void)
|
||||
{
|
||||
printf(_("Usage: nano [OPTIONS] [[+LINE,COLUMN] FILE]...\n\n"));
|
||||
printf(
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
_("Option\t\tGNU long option\t\tMeaning\n")
|
||||
printf(_("Option\t\tGNU long option\t\tMeaning\n"));
|
||||
#else
|
||||
_("Option\t\tMeaning\n")
|
||||
printf(_("Option\t\tMeaning\n"));
|
||||
#endif
|
||||
);
|
||||
print_opt(_("+LINE,COLUMN"), "",
|
||||
/* TRANSLATORS: The next forty or so strings are option descriptions
|
||||
* for the --help output. Try to keep them at most 40 characters. */
|
||||
@@ -884,6 +882,9 @@ void usage(void)
|
||||
print_opt("-i", "--autoindent", N_("Automatically indent new lines"));
|
||||
print_opt("-k", "--cut", N_("Cut from cursor to end of line"));
|
||||
#endif
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
print_opt("-l", "--linenumbers", N_("Show line numbers in front of the text"));
|
||||
#endif
|
||||
#ifndef DISABLE_MOUSE
|
||||
print_opt("-m", "--mouse", N_("Enable the use of the mouse"));
|
||||
#endif
|
||||
@@ -962,6 +963,9 @@ void version(void)
|
||||
#ifdef HAVE_LIBMAGIC
|
||||
printf(" --enable-libmagic");
|
||||
#endif
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
printf(" --enable-linenumbers");
|
||||
#endif
|
||||
#ifndef DISABLE_MOUSE
|
||||
printf(" --enable-mouse");
|
||||
#endif
|
||||
@@ -1008,6 +1012,9 @@ void version(void)
|
||||
#ifndef HAVE_LIBMAGIC
|
||||
printf(" --disable-libmagic");
|
||||
#endif
|
||||
#ifndef ENABLE_LINENUMBERS
|
||||
printf(" --disable-linenumbers");
|
||||
#endif
|
||||
#ifdef DISABLE_MOUSE
|
||||
printf(" --disable-mouse");
|
||||
#endif
|
||||
@@ -1178,9 +1185,9 @@ void stdin_pager(void)
|
||||
tcsetattr(0, TCSANOW, &oldterm);
|
||||
fprintf(stderr, _("Reading from stdin, ^C to abort\n"));
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Enable interpretation of the special control keys so that
|
||||
* we get SIGINT when Ctrl-C is pressed. */
|
||||
#ifndef NANO_TINY
|
||||
enable_signals();
|
||||
#endif
|
||||
|
||||
@@ -1300,7 +1307,7 @@ RETSIGTYPE do_continue(int signal)
|
||||
/* Restore the terminal to its previous state. */
|
||||
terminal_init();
|
||||
|
||||
/* Redraw the contents of the windows that need it. */
|
||||
/* Wipe statusbar; redraw titlebar and edit window (and help lines). */
|
||||
blank_statusbar();
|
||||
wnoutrefresh(bottomwin);
|
||||
total_refresh();
|
||||
@@ -1340,6 +1347,7 @@ void regenerate_screen(void)
|
||||
COLS = win.ws_col;
|
||||
LINES = win.ws_row;
|
||||
#endif
|
||||
editwincols = COLS - margin;
|
||||
|
||||
#ifdef USE_SLANG
|
||||
/* Slang curses emulation brain damage, part 1: If we just do what
|
||||
@@ -1413,9 +1421,12 @@ void do_toggle(int flag)
|
||||
break;
|
||||
#ifndef DISABLE_COLOR
|
||||
case NO_COLOR_SYNTAX:
|
||||
#endif
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
case LINE_NUMBERS:
|
||||
#endif
|
||||
case SOFTWRAP:
|
||||
edit_refresh();
|
||||
refresh_needed = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1434,13 +1445,13 @@ void do_toggle(int flag)
|
||||
statusline(HUSH, "%s %s", _(flagtostr(flag)),
|
||||
enabled ? _("enabled") : _("disabled"));
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Bleh. */
|
||||
void do_toggle_void(void)
|
||||
{
|
||||
;
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Disable extended input and output processing in our terminal
|
||||
* settings. */
|
||||
@@ -1542,7 +1553,7 @@ void terminal_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(NANO_TINY) && defined(HAVE_KEY_DEFINED)
|
||||
#ifdef HAVE_KEY_DEFINED
|
||||
/* Ask ncurses for a keycode, or assign a default one. */
|
||||
int get_keycode(const char *keyname, const int standard)
|
||||
{
|
||||
@@ -1720,13 +1731,7 @@ int do_input(bool allow_funcs)
|
||||
if (f && !f->viewok)
|
||||
reset_multis(openfile->current, FALSE);
|
||||
#endif
|
||||
if (refresh_needed) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "running edit_refresh() as refresh_needed is true\n");
|
||||
#endif
|
||||
edit_refresh();
|
||||
refresh_needed = FALSE;
|
||||
} else if (s->scfunc == do_delete || s->scfunc == do_backspace)
|
||||
if (!refresh_needed && (s->scfunc == do_delete || s->scfunc == do_backspace))
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
}
|
||||
}
|
||||
@@ -1885,8 +1890,11 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
continue;
|
||||
|
||||
/* If we're adding to the magicline, create a new magicline. */
|
||||
if (!ISSET(NO_NEWLINES) && openfile->filebot == openfile->current)
|
||||
if (!ISSET(NO_NEWLINES) && openfile->filebot == openfile->current) {
|
||||
new_magicline();
|
||||
if (margin > 0)
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
assert(openfile->current_x <= current_len);
|
||||
|
||||
@@ -1926,6 +1934,8 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
ensure_line_is_visible();
|
||||
|
||||
/* Well, we might also need a full refresh if we've changed the
|
||||
* line length to be a new multiple of COLS. */
|
||||
if (ISSET(SOFTWRAP) && refresh_needed == FALSE)
|
||||
@@ -1941,10 +1951,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
reset_multis(openfile->current, FALSE);
|
||||
#endif
|
||||
|
||||
if (refresh_needed == TRUE) {
|
||||
edit_refresh();
|
||||
refresh_needed = FALSE;
|
||||
} else
|
||||
if (!refresh_needed)
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
}
|
||||
|
||||
@@ -1989,7 +1996,13 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
{"constantshow", 0, NULL, 'c'},
|
||||
{"rebinddelete", 0, NULL, 'd'},
|
||||
#ifndef DISABLE_BROWSER
|
||||
{"showcursor", 0, NULL, 'g'},
|
||||
#endif
|
||||
{"help", 0, NULL, 'h'},
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
{"linenumbers", 0, NULL, 'l'},
|
||||
#endif
|
||||
#ifndef DISABLE_MOUSE
|
||||
{"mouse", 0, NULL, 'm'},
|
||||
#endif
|
||||
@@ -2083,7 +2096,6 @@ int main(int argc, char **argv)
|
||||
case 'b':
|
||||
case 'e':
|
||||
case 'f':
|
||||
case 'g':
|
||||
case 'j':
|
||||
/* Pico compatibility flags. */
|
||||
break;
|
||||
@@ -2192,6 +2204,9 @@ int main(int argc, char **argv)
|
||||
case 'd':
|
||||
SET(REBIND_DELETE);
|
||||
break;
|
||||
case 'g':
|
||||
SET(SHOW_CURSOR);
|
||||
break;
|
||||
#ifndef NANO_TINY
|
||||
case 'i':
|
||||
SET(AUTOINDENT);
|
||||
@@ -2268,6 +2283,11 @@ int main(int argc, char **argv)
|
||||
case '$':
|
||||
SET(SOFTWRAP);
|
||||
break;
|
||||
#endif
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
case 'l':
|
||||
SET(LINE_NUMBERS);
|
||||
break;
|
||||
#endif
|
||||
case 'h':
|
||||
usage();
|
||||
@@ -2527,7 +2547,7 @@ int main(int argc, char **argv)
|
||||
/* Set up the terminal state. */
|
||||
terminal_init();
|
||||
|
||||
#if defined(__linux__) && !defined(NANO_TINY)
|
||||
#ifdef __linux__
|
||||
/* Check whether we're running on a Linux console. */
|
||||
console = (getenv("DISPLAY") == NULL);
|
||||
#endif
|
||||
@@ -2540,6 +2560,8 @@ int main(int argc, char **argv)
|
||||
* dimensions. */
|
||||
window_init();
|
||||
|
||||
editwincols = COLS;
|
||||
|
||||
/* Set up the signal handlers. */
|
||||
signal_init();
|
||||
|
||||
@@ -2552,17 +2574,20 @@ int main(int argc, char **argv)
|
||||
set_colorpairs();
|
||||
#else
|
||||
interface_color_pair[TITLE_BAR] = hilite_attribute;
|
||||
interface_color_pair[LINE_NUMBER] = hilite_attribute;
|
||||
interface_color_pair[STATUS_BAR] = hilite_attribute;
|
||||
interface_color_pair[KEY_COMBO] = hilite_attribute;
|
||||
interface_color_pair[FUNCTION_TAG] = A_NORMAL;
|
||||
#endif
|
||||
|
||||
#if !defined(NANO_TINY) && defined(HAVE_KEY_DEFINED)
|
||||
#ifdef HAVE_KEY_DEFINED
|
||||
/* Ask ncurses for the key codes for Control+Left/Right/Up/Down. */
|
||||
controlleft = get_keycode("kLFT5", CONTROL_LEFT);
|
||||
controlright = get_keycode("kRIT5", CONTROL_RIGHT);
|
||||
controlup = get_keycode("kUP5", CONTROL_UP);
|
||||
controldown = get_keycode("kDN5", CONTROL_DOWN);
|
||||
#endif
|
||||
#if !defined(NANO_TINY) && defined(HAVE_KEY_DEFINED)
|
||||
/* Ask for the codes for Shift+Control+Left/Right/Up/Down. */
|
||||
shiftcontrolleft = get_keycode("kLFT6", SHIFT_CONTROL_LEFT);
|
||||
shiftcontrolright = get_keycode("kRIT6", SHIFT_CONTROL_RIGHT);
|
||||
@@ -2675,6 +2700,24 @@ int main(int argc, char **argv)
|
||||
display_buffer();
|
||||
|
||||
while (TRUE) {
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
int needed_margin = digits(openfile->filebot->lineno) + 1;
|
||||
|
||||
/* Only enable line numbers when there is enough room for them. */
|
||||
if (ISSET(LINE_NUMBERS) && needed_margin < COLS - 3) {
|
||||
if (needed_margin != margin) {
|
||||
margin = needed_margin;
|
||||
editwincols = COLS - margin;
|
||||
/* The margin has changed -- schedule a full refresh. */
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
margin = 0;
|
||||
editwincols = COLS;
|
||||
}
|
||||
|
||||
if (currmenu != MMAIN)
|
||||
display_main_list();
|
||||
|
||||
@@ -2690,10 +2733,14 @@ int main(int argc, char **argv)
|
||||
/* Forget any earlier statusbar x position. */
|
||||
reinit_statusbar_x();
|
||||
|
||||
/* Place the cursor in the edit window and make it visible. */
|
||||
reset_cursor();
|
||||
curs_set(1);
|
||||
wnoutrefresh(edit);
|
||||
/* Refresh either the entire edit window or just the cursor. */
|
||||
if (refresh_needed)
|
||||
edit_refresh();
|
||||
else {
|
||||
reset_cursor();
|
||||
curs_set(1);
|
||||
wnoutrefresh(edit);
|
||||
}
|
||||
|
||||
/* Read in and interpret keystrokes. */
|
||||
do_input(TRUE);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
|
||||
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014, 2015, 2016 Benno Schulenberg *
|
||||
*
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published *
|
||||
* by the Free Software Foundation, either version 3 of the License, *
|
||||
@@ -451,11 +451,13 @@ typedef struct sc {
|
||||
/* Which menus this applies to. */
|
||||
void (*scfunc)(void);
|
||||
/* The function we're going to run. */
|
||||
#ifndef NANO_TINY
|
||||
int toggle;
|
||||
/* If a toggle, what we're toggling. */
|
||||
int ordinal;
|
||||
/* The how-manieth toggle this is, in order to be able to
|
||||
* keep them in sequence. */
|
||||
#endif
|
||||
struct sc *next;
|
||||
/* Next in the list. */
|
||||
} sc;
|
||||
@@ -486,6 +488,7 @@ typedef struct subnfunc {
|
||||
enum
|
||||
{
|
||||
TITLE_BAR = 0,
|
||||
LINE_NUMBER,
|
||||
STATUS_BAR,
|
||||
KEY_COMBO,
|
||||
FUNCTION_TAG,
|
||||
@@ -533,7 +536,9 @@ enum
|
||||
LOCKING,
|
||||
NOREAD_MODE,
|
||||
MAKE_IT_UNIX,
|
||||
JUSTIFY_TRIM
|
||||
JUSTIFY_TRIM,
|
||||
SHOW_CURSOR,
|
||||
LINE_NUMBERS
|
||||
};
|
||||
|
||||
/* Flags for the menus in which a given function should be present. */
|
||||
|
||||
69
src/proto.h
69
src/proto.h
@@ -29,7 +29,7 @@
|
||||
extern volatile sig_atomic_t sigwinch_counter;
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) && !defined(NANO_TINY)
|
||||
#ifdef __linux__
|
||||
extern bool console;
|
||||
#endif
|
||||
|
||||
@@ -38,13 +38,20 @@ extern bool shift_held;
|
||||
|
||||
extern bool focusing;
|
||||
|
||||
extern int margin;
|
||||
extern int editwincols;
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
extern int last_drawn_line;
|
||||
extern int last_line_y;
|
||||
#endif
|
||||
|
||||
extern message_type lastmessage;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
extern int controlleft;
|
||||
extern int controlright;
|
||||
extern int controlup;
|
||||
extern int controldown;
|
||||
#ifndef NANO_TINY
|
||||
extern int shiftcontrolleft;
|
||||
extern int shiftcontrolright;
|
||||
extern int shiftcontrolup;
|
||||
@@ -73,9 +80,6 @@ extern int maxrows;
|
||||
|
||||
extern filestruct *cutbuffer;
|
||||
extern filestruct *cutbottom;
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
extern filestruct *jusbuffer;
|
||||
#endif
|
||||
extern partition *filepart;
|
||||
extern openfilestruct *openfile;
|
||||
|
||||
@@ -225,16 +229,12 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n);
|
||||
char *nstrcasestr(const char *haystack, const char *needle);
|
||||
#endif
|
||||
char *mbstrcasestr(const char *haystack, const char *needle);
|
||||
#if !defined(NANO_TINY) || !defined(DISABLE_TABCOMP)
|
||||
char *revstrstr(const char *haystack, const char *needle, const char
|
||||
*rev_start);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
char *revstrcasestr(const char *haystack, const char *needle, const char
|
||||
*rev_start);
|
||||
char *mbrevstrcasestr(const char *haystack, const char *needle, const
|
||||
char *rev_start);
|
||||
#endif
|
||||
size_t mbstrlen(const char *s);
|
||||
#ifndef HAVE_STRNLEN
|
||||
size_t nstrnlen(const char *s, size_t maxlen);
|
||||
@@ -280,13 +280,7 @@ void cut_marked(void);
|
||||
void cut_to_eol(void);
|
||||
void cut_to_eof(void);
|
||||
#endif
|
||||
void do_cut_text(
|
||||
#ifndef NANO_TINY
|
||||
bool copy_text, bool cut_till_eof
|
||||
#else
|
||||
void
|
||||
#endif
|
||||
);
|
||||
void do_cut_text(bool copy_text, bool cut_till_eof);
|
||||
void do_cut_text_void(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_copy_text(void);
|
||||
@@ -311,13 +305,6 @@ filestruct *read_line(char *buf, size_t buf_len, filestruct *prevnode);
|
||||
void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkwritable);
|
||||
int open_file(const char *filename, bool newfie, bool quiet, FILE **f);
|
||||
char *get_next_filename(const char *name, const char *suffix);
|
||||
void do_insertfile(
|
||||
#ifndef NANO_TINY
|
||||
bool execute
|
||||
#else
|
||||
void
|
||||
#endif
|
||||
);
|
||||
void do_insertfile_void(void);
|
||||
char *get_full_path(const char *origpath);
|
||||
char *check_writable_directory(const char *path);
|
||||
@@ -375,7 +362,7 @@ size_t length_of_list(int menu);
|
||||
const sc *first_sc_for(int menu, void (*func)(void));
|
||||
int sc_seq_or(void (*func)(void), int defaultval);
|
||||
functionptrtype func_from_key(int *kbinput);
|
||||
void assign_keyinfo(sc *s, const char *keystring);
|
||||
void assign_keyinfo(sc *s, const char *keystring, const int keycode);
|
||||
void print_sclist(void);
|
||||
void shortcut_init(void);
|
||||
#ifndef DISABLE_COLOR
|
||||
@@ -410,14 +397,13 @@ void do_para_begin_void(void);
|
||||
void do_para_end(bool allow_update);
|
||||
void do_para_end_void(void);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
void do_prev_block(void);
|
||||
void do_next_block(void);
|
||||
void do_prev_word(bool allow_punct, bool allow_update);
|
||||
void do_prev_word_void(void);
|
||||
bool do_next_word(bool allow_punct, bool allow_update);
|
||||
void do_next_word_void(void);
|
||||
#endif
|
||||
void ensure_line_is_visible(void);
|
||||
void do_home(void);
|
||||
void do_end(void);
|
||||
void do_up(bool scroll_only);
|
||||
@@ -482,13 +468,7 @@ RETSIGTYPE handle_sigwinch(int signal);
|
||||
void regenerate_screen(void);
|
||||
void allow_sigwinch(bool allow);
|
||||
void do_toggle(int flag);
|
||||
#endif
|
||||
void do_toggle_void(void);
|
||||
void disable_extended_io(void);
|
||||
#ifdef USE_SLANG
|
||||
void disable_signals(void);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
void enable_signals(void);
|
||||
#endif
|
||||
void disable_flow_control(void);
|
||||
@@ -568,31 +548,21 @@ void regexp_cleanup(void);
|
||||
void not_found_msg(const char *str);
|
||||
void search_replace_abort(void);
|
||||
int search_init(bool replacing, bool use_answer);
|
||||
int findnextstr(
|
||||
#ifndef DISABLE_SPELLER
|
||||
bool whole_word_only,
|
||||
#endif
|
||||
const filestruct *begin, size_t begin_x,
|
||||
const char *needle, size_t *match_len);
|
||||
int findnextstr(const char *needle, bool whole_word_only, size_t *match_len,
|
||||
const filestruct *begin, size_t begin_x);
|
||||
void do_search(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_findprevious(void);
|
||||
void do_findnext(void);
|
||||
#endif
|
||||
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
|
||||
void do_research(void);
|
||||
#endif
|
||||
void go_looking(void);
|
||||
#ifdef HAVE_REGEX_H
|
||||
int replace_regexp(char *string, bool create);
|
||||
#endif
|
||||
char *replace_line(const char *needle);
|
||||
ssize_t do_replace_loop(
|
||||
#ifndef DISABLE_SPELLER
|
||||
bool whole_word_only,
|
||||
#endif
|
||||
const filestruct *real_current, size_t *real_current_x,
|
||||
const char *needle);
|
||||
ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
const filestruct *real_current, size_t *real_current_x);
|
||||
void do_replace(void);
|
||||
void goto_line_posx(ssize_t line, size_t pos_x);
|
||||
void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
@@ -633,11 +603,11 @@ void do_tab(void);
|
||||
void do_indent(ssize_t cols);
|
||||
void do_indent_void(void);
|
||||
void do_unindent(void);
|
||||
bool white_string(const char *s);
|
||||
void do_undo(void);
|
||||
void do_redo(void);
|
||||
#endif
|
||||
#ifndef DISABLE_COMMENT
|
||||
bool white_string(const char *s);
|
||||
#ifdef ENABLE_COMMENT
|
||||
void do_comment(void);
|
||||
#endif
|
||||
void do_enter(void);
|
||||
@@ -691,6 +661,7 @@ void do_verbatim_input(void);
|
||||
|
||||
/* All functions in utils.c. */
|
||||
void get_homedir(void);
|
||||
int digits(int n);
|
||||
bool parse_num(const char *str, ssize_t *val);
|
||||
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column);
|
||||
void align(char **str);
|
||||
@@ -789,7 +760,7 @@ bool need_horizontal_scroll(const size_t old_column, const size_t new_column);
|
||||
void edit_scroll(scroll_dir direction, ssize_t nlines);
|
||||
void edit_redraw(filestruct *old_current);
|
||||
void edit_refresh(void);
|
||||
void edit_update(update_type location);
|
||||
void adjust_viewport(update_type location);
|
||||
void total_redraw(void);
|
||||
void total_refresh(void);
|
||||
void display_main_list(void);
|
||||
|
||||
22
src/rcfile.c
22
src/rcfile.c
@@ -35,6 +35,9 @@
|
||||
|
||||
static const rcoption rcopts[] = {
|
||||
{"boldtext", BOLD_TEXT},
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
{"linenumbers", LINE_NUMBERS},
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
{"brackets", 0},
|
||||
#endif
|
||||
@@ -96,6 +99,7 @@ static const rcoption rcopts[] = {
|
||||
{"noconvert", NO_CONVERT},
|
||||
{"quickblank", QUICK_BLANK},
|
||||
{"quiet", QUIET},
|
||||
{"showcursor", SHOW_CURSOR},
|
||||
{"smarthome", SMART_HOME},
|
||||
{"smooth", SMOOTH_SCROLL},
|
||||
{"softwrap", SOFTWRAP},
|
||||
@@ -107,6 +111,7 @@ static const rcoption rcopts[] = {
|
||||
#endif
|
||||
#ifndef DISABLE_COLOR
|
||||
{"titlecolor", 0},
|
||||
{"numbercolor", 0},
|
||||
{"statuscolor", 0},
|
||||
{"keycolor", 0},
|
||||
{"functioncolor", 0},
|
||||
@@ -343,9 +348,7 @@ bool is_universal(void (*func))
|
||||
{
|
||||
if (func == do_left || func == do_right ||
|
||||
func == do_home || func == do_end ||
|
||||
#ifndef NANO_TINY
|
||||
func == do_prev_word_void || func == do_next_word_void ||
|
||||
#endif
|
||||
func == do_verbatim_input || func == do_cut_text_void ||
|
||||
func == do_delete || func == do_backspace ||
|
||||
func == do_tab || func == do_enter)
|
||||
@@ -400,7 +403,12 @@ void parse_binding(char *ptr, bool dobind)
|
||||
else if (keycopy[0] != '^' && keycopy[0] != 'M' && keycopy[0] != 'F') {
|
||||
rcfile_error(N_("Key name must begin with \"^\", \"M\", or \"F\""));
|
||||
goto free_copy;
|
||||
} else if (keycopy[0] == '^' && (keycopy[1] < 64 || keycopy[1] > 127)) {
|
||||
} else if ((keycopy[0] == 'M' && keycopy[1] != '-') ||
|
||||
(keycopy[0] == '^' && ((keycopy[1] < 'A' || keycopy[1] > 'z') ||
|
||||
keycopy[1] == '[' || keycopy[1] == '`' ||
|
||||
(strlen(keycopy) > 2 && strcmp(keycopy, "^Space") != 0))) ||
|
||||
(strlen(keycopy) > 3 && strcmp(keycopy, "^Space") != 0 &&
|
||||
strcmp(keycopy, "M-Space") != 0)) {
|
||||
rcfile_error(N_("Key name %s is invalid"), keycopy);
|
||||
goto free_copy;
|
||||
}
|
||||
@@ -455,9 +463,11 @@ void parse_binding(char *ptr, bool dobind)
|
||||
if (f->scfunc == newsc->scfunc)
|
||||
mask = mask | f->menus;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Handle the special case of the toggles. */
|
||||
if (newsc->scfunc == do_toggle_void)
|
||||
mask = MMAIN;
|
||||
#endif
|
||||
|
||||
/* Now limit the given menu to those where the function exists. */
|
||||
if (is_universal(newsc->scfunc))
|
||||
@@ -472,7 +482,7 @@ void parse_binding(char *ptr, bool dobind)
|
||||
}
|
||||
|
||||
newsc->menus = menu;
|
||||
assign_keyinfo(newsc, keycopy);
|
||||
assign_keyinfo(newsc, keycopy, 0);
|
||||
|
||||
/* Do not allow rebinding a frequent escape-sequence starter: Esc [. */
|
||||
if (newsc->meta && newsc->keycode == 91) {
|
||||
@@ -497,6 +507,7 @@ void parse_binding(char *ptr, bool dobind)
|
||||
}
|
||||
|
||||
if (dobind) {
|
||||
#ifndef NANO_TINY
|
||||
/* If this is a toggle, copy its sequence number. */
|
||||
if (newsc->scfunc == do_toggle_void) {
|
||||
for (s = sclist; s != NULL; s = s->next)
|
||||
@@ -504,6 +515,7 @@ void parse_binding(char *ptr, bool dobind)
|
||||
newsc->ordinal = s->ordinal;
|
||||
} else
|
||||
newsc->ordinal = 0;
|
||||
#endif
|
||||
/* Add the new shortcut at the start of the list. */
|
||||
newsc->next = sclist;
|
||||
sclist = newsc;
|
||||
@@ -1110,6 +1122,8 @@ void parse_rcfile(FILE *rcstream
|
||||
#ifndef DISABLE_COLOR
|
||||
if (strcasecmp(rcopts[i].name, "titlecolor") == 0)
|
||||
specified_color_combo[TITLE_BAR] = option;
|
||||
else if (strcasecmp(rcopts[i].name, "numbercolor") == 0)
|
||||
specified_color_combo[LINE_NUMBER] = option;
|
||||
else if (strcasecmp(rcopts[i].name, "statuscolor") == 0)
|
||||
specified_color_combo[STATUS_BAR] = option;
|
||||
else if (strcasecmp(rcopts[i].name, "keycolor") == 0)
|
||||
|
||||
100
src/search.c
100
src/search.c
@@ -47,11 +47,8 @@ bool regexp_init(const char *regexp)
|
||||
|
||||
assert(!regexp_compiled);
|
||||
|
||||
rc = regcomp(&search_regexp, fixbounds(regexp), NANO_REG_EXTENDED
|
||||
#ifndef NANO_TINY
|
||||
| (ISSET(CASE_SENSITIVE) ? 0 : REG_ICASE)
|
||||
#endif
|
||||
);
|
||||
rc = regcomp(&search_regexp, fixbounds(regexp),
|
||||
NANO_REG_EXTENDED | (ISSET(CASE_SENSITIVE) ? 0 : REG_ICASE));
|
||||
|
||||
if (rc != 0) {
|
||||
size_t len = regerror(rc, &search_regexp, NULL, 0);
|
||||
@@ -163,19 +160,13 @@ int search_init(bool replacing, bool use_answer)
|
||||
#endif
|
||||
/* TRANSLATORS: This is the main search prompt. */
|
||||
edit_refresh, "%s%s%s%s%s%s", _("Search"),
|
||||
#ifndef NANO_TINY
|
||||
/* TRANSLATORS: The next three modify the search prompt. */
|
||||
ISSET(CASE_SENSITIVE) ? _(" [Case Sensitive]") :
|
||||
#endif
|
||||
"",
|
||||
ISSET(CASE_SENSITIVE) ? _(" [Case Sensitive]") : "",
|
||||
#ifdef HAVE_REGEX_H
|
||||
ISSET(USE_REGEXP) ? _(" [Regexp]") :
|
||||
#endif
|
||||
"",
|
||||
#ifndef NANO_TINY
|
||||
ISSET(BACKWARDS_SEARCH) ? _(" [Backwards]") :
|
||||
#endif
|
||||
"", replacing ?
|
||||
ISSET(BACKWARDS_SEARCH) ? _(" [Backwards]") : "", replacing ?
|
||||
#ifndef NANO_TINY
|
||||
/* TRANSLATORS: The next two modify the search prompt. */
|
||||
openfile->mark_set ? _(" (to replace) in selection") :
|
||||
@@ -214,7 +205,6 @@ int search_init(bool replacing, bool use_answer)
|
||||
|
||||
func = func_from_key(&i);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (func == case_sens_void) {
|
||||
TOGGLE(CASE_SENSITIVE);
|
||||
backupstring = mallocstrcpy(backupstring, answer);
|
||||
@@ -224,7 +214,6 @@ int search_init(bool replacing, bool use_answer)
|
||||
backupstring = mallocstrcpy(backupstring, answer);
|
||||
return 1;
|
||||
} else
|
||||
#endif
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (func == regexp_void) {
|
||||
TOGGLE(USE_REGEXP);
|
||||
@@ -248,12 +237,8 @@ int search_init(bool replacing, bool use_answer)
|
||||
* where we first started searching, at column begin_x. Return 1 when we
|
||||
* found something, 0 when nothing, and -2 on cancel. When match_len is
|
||||
* not NULL, set it to the length of the found string, if any. */
|
||||
int findnextstr(
|
||||
#ifndef DISABLE_SPELLER
|
||||
bool whole_word_only,
|
||||
#endif
|
||||
const filestruct *begin, size_t begin_x,
|
||||
const char *needle, size_t *match_len)
|
||||
int findnextstr(const char *needle, bool whole_word_only, size_t *match_len,
|
||||
const filestruct *begin, size_t begin_x)
|
||||
{
|
||||
size_t found_len;
|
||||
/* The length of the match we find. */
|
||||
@@ -270,12 +255,13 @@ int findnextstr(
|
||||
* will return immediately and say that no match was found, and
|
||||
* rev_start will be properly set when the search continues on the
|
||||
* previous or next line. */
|
||||
rev_start +=
|
||||
#ifndef NANO_TINY
|
||||
ISSET(BACKWARDS_SEARCH) ?
|
||||
((openfile->current_x == 0) ? -1 : move_mbleft(fileptr->data, openfile->current_x)) :
|
||||
#endif
|
||||
move_mbright(fileptr->data, openfile->current_x);
|
||||
if (ISSET(BACKWARDS_SEARCH)) {
|
||||
if (openfile->current_x == 0)
|
||||
rev_start += -1;
|
||||
else
|
||||
rev_start += move_mbleft(fileptr->data, openfile->current_x);
|
||||
} else
|
||||
rev_start += move_mbright(fileptr->data, openfile->current_x);
|
||||
|
||||
enable_nodelay();
|
||||
|
||||
@@ -343,11 +329,9 @@ int findnextstr(
|
||||
}
|
||||
|
||||
/* Move to the previous or next line in the file. */
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(BACKWARDS_SEARCH))
|
||||
fileptr = fileptr->prev;
|
||||
else
|
||||
#endif
|
||||
fileptr = fileptr->next;
|
||||
|
||||
/* If we've reached the start or end of the buffer, wrap around. */
|
||||
@@ -359,11 +343,9 @@ int findnextstr(
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(BACKWARDS_SEARCH))
|
||||
fileptr = openfile->filebot;
|
||||
else
|
||||
#endif
|
||||
fileptr = openfile->fileage;
|
||||
|
||||
statusbar(_("Search Wrapped"));
|
||||
@@ -377,23 +359,15 @@ int findnextstr(
|
||||
|
||||
/* Set the starting x to the start or end of the line. */
|
||||
rev_start = fileptr->data;
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(BACKWARDS_SEARCH))
|
||||
rev_start += strlen(fileptr->data);
|
||||
#endif
|
||||
}
|
||||
|
||||
found_x = found - fileptr->data;
|
||||
|
||||
/* Ensure that the found occurrence is not beyond the starting x. */
|
||||
if (came_full_circle &&
|
||||
#ifndef NANO_TINY
|
||||
((!ISSET(BACKWARDS_SEARCH) && found_x > begin_x) ||
|
||||
(ISSET(BACKWARDS_SEARCH) && found_x < begin_x))
|
||||
#else
|
||||
found_x > begin_x
|
||||
#endif
|
||||
) {
|
||||
if (came_full_circle && ((!ISSET(BACKWARDS_SEARCH) && found_x > begin_x) ||
|
||||
(ISSET(BACKWARDS_SEARCH) && found_x < begin_x))) {
|
||||
not_found_msg(needle);
|
||||
disable_nodelay();
|
||||
return 0;
|
||||
@@ -425,10 +399,8 @@ void do_search(void)
|
||||
search_replace_abort();
|
||||
else if (i == -2) /* Do a replace instead. */
|
||||
do_replace();
|
||||
#if !defined(NANO_TINY) || defined(HAVE_REGEX_H)
|
||||
else if (i == 1) /* Toggled something. */
|
||||
do_search();
|
||||
#endif
|
||||
|
||||
if (i == 0)
|
||||
go_looking();
|
||||
@@ -459,7 +431,6 @@ void do_findnext(void)
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
|
||||
/* Search for the last string without prompting. */
|
||||
void do_research(void)
|
||||
{
|
||||
@@ -485,7 +456,6 @@ void do_research(void)
|
||||
|
||||
go_looking();
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Search for the global string 'last_search'. Inform the user when
|
||||
* the string occurs only once. */
|
||||
@@ -500,11 +470,8 @@ void go_looking(void)
|
||||
|
||||
came_full_circle = FALSE;
|
||||
|
||||
didfind = findnextstr(
|
||||
#ifndef DISABLE_SPELLER
|
||||
FALSE,
|
||||
#endif
|
||||
openfile->current, openfile->current_x, last_search, NULL);
|
||||
didfind = findnextstr(last_search, FALSE, NULL,
|
||||
openfile->current, openfile->current_x);
|
||||
|
||||
/* If we found something, and we're back at the exact same spot
|
||||
* where we started searching, then this is the only occurrence. */
|
||||
@@ -613,12 +580,8 @@ char *replace_line(const char *needle)
|
||||
* allow the cursor position to be updated when a word before the cursor
|
||||
* is replaced by a shorter word. Return -1 if needle isn't found, -2 if
|
||||
* the seeking is aborted, else the number of replacements performed. */
|
||||
ssize_t do_replace_loop(
|
||||
#ifndef DISABLE_SPELLER
|
||||
bool whole_word_only,
|
||||
#endif
|
||||
const filestruct *real_current, size_t *real_current_x,
|
||||
const char *needle)
|
||||
ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
const filestruct *real_current, size_t *real_current_x)
|
||||
{
|
||||
ssize_t numreplaced = -1;
|
||||
size_t match_len;
|
||||
@@ -652,11 +615,8 @@ ssize_t do_replace_loop(
|
||||
|
||||
while (TRUE) {
|
||||
int i = 0;
|
||||
int result = findnextstr(
|
||||
#ifndef DISABLE_SPELLER
|
||||
whole_word_only,
|
||||
#endif
|
||||
real_current, *real_current_x, needle, &match_len);
|
||||
int result = findnextstr(needle, whole_word_only, &match_len,
|
||||
real_current, *real_current_x);
|
||||
|
||||
/* If nothing more was found, or the user aborted, stop looping. */
|
||||
if (result < 1) {
|
||||
@@ -757,9 +717,7 @@ ssize_t do_replace_loop(
|
||||
/* Set the cursor at the last character of the replacement
|
||||
* text, so that searching will continue /after/ it. Note
|
||||
* that current_x might be set to (size_t)-1 here. */
|
||||
#ifndef NANO_TINY
|
||||
if (!ISSET(BACKWARDS_SEARCH))
|
||||
#endif
|
||||
openfile->current_x += match_len + length_change - 1;
|
||||
|
||||
/* Update the file size, and put the changed line into place. */
|
||||
@@ -862,11 +820,7 @@ void do_replace(void)
|
||||
begin = openfile->current;
|
||||
begin_x = openfile->current_x;
|
||||
|
||||
numreplaced = do_replace_loop(
|
||||
#ifndef DISABLE_SPELLER
|
||||
FALSE,
|
||||
#endif
|
||||
begin, &begin_x, last_search);
|
||||
numreplaced = do_replace_loop(last_search, FALSE, begin, &begin_x);
|
||||
|
||||
/* Restore where we were. */
|
||||
openfile->edittop = edittop_save;
|
||||
@@ -970,9 +924,9 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
openfile->placewewant = column - 1;
|
||||
|
||||
/* When the position was manually given, center the target line. */
|
||||
if (interactive) {
|
||||
edit_update(CENTERING);
|
||||
edit_refresh();
|
||||
if (interactive || ISSET(SOFTWRAP)) {
|
||||
adjust_viewport(CENTERING);
|
||||
refresh_needed = TRUE;
|
||||
} else {
|
||||
/* If the target line is close to the tail of the file, put the last
|
||||
* line of the file on the bottom line of the screen; otherwise, just
|
||||
@@ -981,9 +935,9 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
editwinrows / 2) {
|
||||
openfile->current_y = editwinrows - openfile->filebot->lineno +
|
||||
openfile->current->lineno - 1;
|
||||
edit_update(STATIONARY);
|
||||
adjust_viewport(STATIONARY);
|
||||
} else
|
||||
edit_update(CENTERING);
|
||||
adjust_viewport(CENTERING);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
53
src/text.c
53
src/text.c
@@ -42,8 +42,10 @@ static bool prepend_wrap = FALSE;
|
||||
/* Should we prepend wrapped text to the next line? */
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
static filestruct *jusbuffer = NULL;
|
||||
/* The buffer where we store unjustified text. */
|
||||
static filestruct *jusbottom = NULL;
|
||||
/* Pointer to the end of the justify buffer. */
|
||||
/* A pointer to the end of the buffer with unjustified text. */
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -169,6 +171,8 @@ void do_deletion(undo_type action)
|
||||
return;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
ensure_line_is_visible();
|
||||
|
||||
if (ISSET(SOFTWRAP) && refresh_needed == FALSE)
|
||||
if (strlenpt(openfile->current->data) / COLS != orig_lenpt / COLS)
|
||||
refresh_needed = TRUE;
|
||||
@@ -435,7 +439,6 @@ void do_unindent(void)
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
#ifdef ENABLE_COMMENT
|
||||
/* Test whether the string is empty or consists of only blanks. */
|
||||
bool white_string(const char *s)
|
||||
{
|
||||
@@ -445,6 +448,7 @@ bool white_string(const char *s)
|
||||
return !*s;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_COMMENT
|
||||
/* Comment or uncomment the current line or the marked lines. */
|
||||
void do_comment()
|
||||
{
|
||||
@@ -2513,35 +2517,28 @@ void do_justify(bool full_justify)
|
||||
|| func == do_undo
|
||||
#endif
|
||||
) {
|
||||
/* Splice the justify buffer back into the file, but only if we
|
||||
* actually justified something. */
|
||||
/* If we actually justified something, then splice the preserved
|
||||
* unjustified text back into the file, */
|
||||
if (first_par_line != NULL) {
|
||||
filestruct *top_save;
|
||||
|
||||
/* Partition the filestruct so that it contains only the
|
||||
* text of the justified paragraph. */
|
||||
filepart = partition_filestruct(first_par_line, 0,
|
||||
last_par_line, filebot_inpar ?
|
||||
strlen(last_par_line->data) : 0);
|
||||
|
||||
/* Remove the text of the justified paragraph, and
|
||||
* replace it with the text in the justify buffer. */
|
||||
/* Throw away the justified paragraph, and replace it with
|
||||
* the preserved unjustified text. */
|
||||
free_filestruct(openfile->fileage);
|
||||
openfile->fileage = jusbuffer;
|
||||
openfile->filebot = jusbottom;
|
||||
|
||||
top_save = openfile->fileage;
|
||||
|
||||
/* Unpartition the filestruct so that it contains all the
|
||||
* text again. Note that the justified paragraph has been
|
||||
* replaced with the unjustified paragraph. */
|
||||
/* Unpartition the filestruct, to contain the entire text again. */
|
||||
unpartition_filestruct(&filepart);
|
||||
|
||||
/* Renumber, starting with the beginning line of the old
|
||||
* partition. */
|
||||
renumber(top_save);
|
||||
/* Renumber, from the beginning of the unjustified part. */
|
||||
renumber(jusbuffer);
|
||||
|
||||
/* Restore the justify we just did (ungrateful user!). */
|
||||
/* Restore the old position, the size, and the mark. */
|
||||
openfile->edittop = edittop_save;
|
||||
openfile->current = current_save;
|
||||
openfile->current_x = current_x_save;
|
||||
@@ -2553,12 +2550,9 @@ void do_justify(bool full_justify)
|
||||
}
|
||||
#endif
|
||||
openfile->modified = modified_save;
|
||||
|
||||
/* Clear the justify buffer. */
|
||||
jusbuffer = NULL;
|
||||
|
||||
if (!openfile->modified)
|
||||
titlebar(NULL);
|
||||
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
} else {
|
||||
@@ -2574,11 +2568,13 @@ void do_justify(bool full_justify)
|
||||
discard_until(NULL, openfile);
|
||||
openfile->current_undo = NULL;
|
||||
#endif
|
||||
/* Blow away the text in the justify buffer. */
|
||||
/* Blow away the unjustified text. */
|
||||
free_filestruct(jusbuffer);
|
||||
jusbuffer = NULL;
|
||||
}
|
||||
|
||||
/* Mark the buffer for unjustified text as empty. */
|
||||
jusbuffer = NULL;
|
||||
|
||||
blank_statusbar();
|
||||
|
||||
/* Display the shortcut list with UnCut. */
|
||||
@@ -2630,10 +2626,9 @@ bool do_int_spell_fix(const char *word)
|
||||
/* Make sure spell-check is case sensitive. */
|
||||
SET(CASE_SENSITIVE);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Make sure spell-check goes forward only. */
|
||||
UNSET(BACKWARDS_SEARCH);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* Make sure spell-check doesn't use regular expressions. */
|
||||
UNSET(USE_REGEXP);
|
||||
@@ -2668,7 +2663,7 @@ bool do_int_spell_fix(const char *word)
|
||||
}
|
||||
|
||||
/* Find the first whole occurrence of word. */
|
||||
result = findnextstr(TRUE, NULL, 0, word, NULL);
|
||||
result = findnextstr(word, TRUE, NULL, NULL, 0);
|
||||
|
||||
/* If the word isn't found, alert the user; if it is, allow correction. */
|
||||
if (result == 0) {
|
||||
@@ -2705,7 +2700,7 @@ bool do_int_spell_fix(const char *word)
|
||||
/* Replacements should happen only in the marked region. */
|
||||
openfile->mark_set = old_mark_set;
|
||||
#endif
|
||||
do_replace_loop(TRUE, current_save, ¤t_x_save, word);
|
||||
do_replace_loop(word, TRUE, current_save, ¤t_x_save);
|
||||
|
||||
/* TRANSLATORS: Shown after fixing misspellings in one word. */
|
||||
statusbar(_("Next word..."));
|
||||
@@ -3081,7 +3076,7 @@ const char *do_alt_speller(char *tempfile_name)
|
||||
goto_line_posx(lineno_save, current_x_save);
|
||||
openfile->current_y = current_y_save;
|
||||
openfile->placewewant = pww_save;
|
||||
edit_update(STATIONARY);
|
||||
adjust_viewport(STATIONARY);
|
||||
|
||||
/* Stat the temporary file again, and mark the buffer as modified only
|
||||
* if this file was changed since it was written. */
|
||||
@@ -3557,7 +3552,7 @@ void do_formatter(void)
|
||||
goto_line_posx(lineno_save, current_x_save);
|
||||
openfile->current_y = current_y_save;
|
||||
openfile->placewewant = pww_save;
|
||||
edit_update(STATIONARY);
|
||||
adjust_viewport(STATIONARY);
|
||||
|
||||
set_modified();
|
||||
|
||||
|
||||
62
src/utils.c
62
src/utils.c
@@ -52,6 +52,39 @@ void get_homedir(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
/* Return the number of digits that the given integer n takes up. */
|
||||
int digits(int n)
|
||||
{
|
||||
if (n < 100000) {
|
||||
if (n < 1000) {
|
||||
if (n < 100)
|
||||
return 2;
|
||||
else
|
||||
return 3;
|
||||
} else {
|
||||
if (n < 10000)
|
||||
return 4;
|
||||
else
|
||||
return 5;
|
||||
}
|
||||
} else {
|
||||
if (n < 10000000) {
|
||||
if (n < 1000000)
|
||||
return 6;
|
||||
else
|
||||
return 7;
|
||||
}
|
||||
else {
|
||||
if (n < 100000000)
|
||||
return 8;
|
||||
else
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Read a ssize_t from str, and store it in *val (if val is not NULL).
|
||||
* On error, we return FALSE and don't change *val. Otherwise, we
|
||||
* return TRUE. */
|
||||
@@ -321,10 +354,9 @@ const char *strstrwrapper(const char *haystack, const char *needle,
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(USE_REGEXP)) {
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(BACKWARDS_SEARCH)) {
|
||||
if (regexec(&search_regexp, haystack, 1, regmatches,
|
||||
0) == 0 && haystack + regmatches[0].rm_so <= start) {
|
||||
if (regexec(&search_regexp, haystack, 1, regmatches, 0) == 0 &&
|
||||
haystack + regmatches[0].rm_so <= start) {
|
||||
const char *retval = haystack + regmatches[0].rm_so;
|
||||
|
||||
/* Search forward until there are no more matches. */
|
||||
@@ -338,10 +370,8 @@ const char *strstrwrapper(const char *haystack, const char *needle,
|
||||
regexec(&search_regexp, retval, 10, regmatches, 0);
|
||||
return retval;
|
||||
}
|
||||
} else
|
||||
#endif /* !NANO_TINY */
|
||||
if (regexec(&search_regexp, start, 10, regmatches,
|
||||
(start > haystack) ? REG_NOTBOL : 0) == 0) {
|
||||
} else if (regexec(&search_regexp, start, 10, regmatches,
|
||||
(start > haystack) ? REG_NOTBOL : 0) == 0) {
|
||||
const char *retval = start + regmatches[0].rm_so;
|
||||
|
||||
regexec(&search_regexp, retval, 10, regmatches, 0);
|
||||
@@ -350,20 +380,14 @@ const char *strstrwrapper(const char *haystack, const char *needle,
|
||||
return NULL;
|
||||
}
|
||||
#endif /* HAVE_REGEX_H */
|
||||
#if !defined(NANO_TINY) || !defined(DISABLE_SPELLER)
|
||||
if (ISSET(CASE_SENSITIVE)) {
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(BACKWARDS_SEARCH))
|
||||
return revstrstr(haystack, needle, start);
|
||||
else
|
||||
#endif
|
||||
return strstr(start, needle);
|
||||
}
|
||||
#endif /* !DISABLE_SPELLER || !NANO_TINY */
|
||||
#ifndef NANO_TINY
|
||||
else if (ISSET(BACKWARDS_SEARCH))
|
||||
} else if (ISSET(BACKWARDS_SEARCH))
|
||||
return mbrevstrcasestr(haystack, needle, start);
|
||||
#endif
|
||||
|
||||
return mbstrcasestr(start, needle);
|
||||
}
|
||||
|
||||
@@ -439,12 +463,12 @@ char *free_and_assign(char *dest, char *src)
|
||||
* get_page_start(column) < COLS). */
|
||||
size_t get_page_start(size_t column)
|
||||
{
|
||||
if (column == 0 || column < COLS - 1)
|
||||
if (column == 0 || column < editwincols - 1)
|
||||
return 0;
|
||||
else if (COLS > 8)
|
||||
return column - 7 - (column - 7) % (COLS - 8);
|
||||
else if (editwincols > 8)
|
||||
return column - 7 - (column - 7) % (editwincols - 8);
|
||||
else
|
||||
return column - (COLS - 2);
|
||||
return column - (editwincols - 2);
|
||||
}
|
||||
|
||||
/* Return the placewewant associated with current_x, i.e. the zero-based
|
||||
|
||||
214
src/winio.c
214
src/winio.c
@@ -23,7 +23,7 @@
|
||||
#include "proto.h"
|
||||
#include "revision.h"
|
||||
|
||||
#if defined(__linux__) && !defined(NANO_TINY)
|
||||
#ifdef __linux__
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
@@ -308,11 +308,7 @@ int get_kbinput(WINDOW *win)
|
||||
int kbinput = ERR;
|
||||
|
||||
/* Extract one keystroke from the input stream. */
|
||||
#ifdef KEY_RESIZE
|
||||
while (kbinput == ERR || kbinput == KEY_RESIZE)
|
||||
#else
|
||||
while (kbinput == ERR)
|
||||
#endif
|
||||
kbinput = parse_kbinput(win);
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -403,14 +399,12 @@ int parse_kbinput(WINDOW *win)
|
||||
case 'B':
|
||||
retval = KEY_END;
|
||||
break;
|
||||
#ifndef NANO_TINY
|
||||
case 'C':
|
||||
retval = controlright;
|
||||
break;
|
||||
case 'D':
|
||||
retval = controlleft;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
double_esc = FALSE;
|
||||
escapes = 0;
|
||||
@@ -500,89 +494,92 @@ int parse_kbinput(WINDOW *win)
|
||||
if (retval == ERR)
|
||||
return ERR;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (retval == controlleft)
|
||||
return sc_seq_or(do_prev_word_void, 0);
|
||||
return CONTROL_LEFT;
|
||||
else if (retval == controlright)
|
||||
return sc_seq_or(do_next_word_void, 0);
|
||||
return CONTROL_RIGHT;
|
||||
else if (retval == controlup)
|
||||
return sc_seq_or(do_prev_block, 0);
|
||||
return CONTROL_UP;
|
||||
else if (retval == controldown)
|
||||
return sc_seq_or(do_next_block, 0);
|
||||
return CONTROL_DOWN;
|
||||
#ifndef NANO_TINY
|
||||
else if (retval == shiftcontrolleft) {
|
||||
shift_held = TRUE;
|
||||
return sc_seq_or(do_prev_word_void, 0);
|
||||
return sc_seq_or(do_prev_word_void, shiftcontrolleft);
|
||||
} else if (retval == shiftcontrolright) {
|
||||
shift_held = TRUE;
|
||||
return sc_seq_or(do_next_word_void, 0);
|
||||
return sc_seq_or(do_next_word_void, shiftcontrolright);
|
||||
} else if (retval == shiftcontrolup) {
|
||||
shift_held = TRUE;
|
||||
return sc_seq_or(do_prev_block, 0);
|
||||
return sc_seq_or(do_prev_block, shiftcontrolup);
|
||||
} else if (retval == shiftcontroldown) {
|
||||
shift_held = TRUE;
|
||||
return sc_seq_or(do_next_block, 0);
|
||||
return sc_seq_or(do_next_block, shiftcontroldown);
|
||||
} else if (retval == shiftaltleft) {
|
||||
shift_held = TRUE;
|
||||
return sc_seq_or(do_home, 0);
|
||||
return sc_seq_or(do_home, shiftaltleft);
|
||||
} else if (retval == shiftaltright) {
|
||||
shift_held = TRUE;
|
||||
return sc_seq_or(do_end, 0);
|
||||
return sc_seq_or(do_end, shiftaltright);
|
||||
} else if (retval == shiftaltup) {
|
||||
shift_held = TRUE;
|
||||
return sc_seq_or(do_page_up, 0);
|
||||
return sc_seq_or(do_page_up, shiftaltup);
|
||||
} else if (retval == shiftaltdown) {
|
||||
shift_held = TRUE;
|
||||
return sc_seq_or(do_page_down, 0);
|
||||
return sc_seq_or(do_page_down, shiftaltdown);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) && !defined(NANO_TINY)
|
||||
#ifdef __linux__
|
||||
/* When not running under X, check for the bare arrow keys whether
|
||||
* Shift/Ctrl/Alt are being held together with them. */
|
||||
unsigned char modifiers = 6;
|
||||
|
||||
if (console && ioctl(0, TIOCLINUX, &modifiers) >= 0) {
|
||||
if (modifiers & 0x01)
|
||||
shift_held =TRUE;
|
||||
|
||||
/* Is Ctrl being held? */
|
||||
if (modifiers & 0x04) {
|
||||
if (retval == KEY_UP)
|
||||
return sc_seq_or(do_prev_block, 0);
|
||||
return sc_seq_or(do_prev_block, controlup);
|
||||
else if (retval == KEY_DOWN)
|
||||
return sc_seq_or(do_next_block, 0);
|
||||
return sc_seq_or(do_next_block, controldown);
|
||||
else if (retval == KEY_LEFT)
|
||||
return sc_seq_or(do_prev_word_void, 0);
|
||||
return sc_seq_or(do_prev_word_void, controlleft);
|
||||
else if (retval == KEY_RIGHT)
|
||||
return sc_seq_or(do_next_word_void, 0);
|
||||
return sc_seq_or(do_next_word_void, controlright);
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Is Shift being held? */
|
||||
if (modifiers & 0x01)
|
||||
shift_held =TRUE;
|
||||
|
||||
/* Are both Shift and Alt being held? */
|
||||
if ((modifiers & 0x09) == 0x09) {
|
||||
if (retval == KEY_UP)
|
||||
return sc_seq_or(do_page_up, 0);
|
||||
return sc_seq_or(do_page_up, shiftaltup);
|
||||
else if (retval == KEY_DOWN)
|
||||
return sc_seq_or(do_page_down, 0);
|
||||
return sc_seq_or(do_page_down, shiftaltdown);
|
||||
else if (retval == KEY_LEFT)
|
||||
return sc_seq_or(do_home, 0);
|
||||
return sc_seq_or(do_home, shiftaltleft);
|
||||
else if (retval == KEY_RIGHT)
|
||||
return sc_seq_or(do_end, 0);
|
||||
return sc_seq_or(do_end, shiftaltright);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif /* __linux__ && !NANO_TINY */
|
||||
#endif /* __linux__ */
|
||||
|
||||
switch (retval) {
|
||||
#ifdef KEY_SLEFT
|
||||
/* Slang doesn't support KEY_SLEFT. */
|
||||
case KEY_SLEFT:
|
||||
shift_held = TRUE;
|
||||
return sc_seq_or(do_left, keycode);
|
||||
return KEY_LEFT;
|
||||
#endif
|
||||
#ifdef KEY_SRIGHT
|
||||
/* Slang doesn't support KEY_SRIGHT. */
|
||||
case KEY_SRIGHT:
|
||||
shift_held = TRUE;
|
||||
return sc_seq_or(do_right, keycode);
|
||||
return KEY_RIGHT;
|
||||
#endif
|
||||
#ifdef KEY_SR
|
||||
#ifdef KEY_SUP
|
||||
@@ -591,7 +588,7 @@ int parse_kbinput(WINDOW *win)
|
||||
#endif
|
||||
case KEY_SR: /* Scroll backward, on Xfce4-terminal. */
|
||||
shift_held = TRUE;
|
||||
return sc_seq_or(do_up_void, keycode);
|
||||
return KEY_UP;
|
||||
#endif
|
||||
#ifdef KEY_SF
|
||||
#ifdef KEY_SDOWN
|
||||
@@ -600,7 +597,7 @@ int parse_kbinput(WINDOW *win)
|
||||
#endif
|
||||
case KEY_SF: /* Scroll forward, on Xfce4-terminal. */
|
||||
shift_held = TRUE;
|
||||
return sc_seq_or(do_down_void, keycode);
|
||||
return KEY_DOWN;
|
||||
#endif
|
||||
#ifdef KEY_SHOME
|
||||
/* HP-UX 10-11 and Slang don't support KEY_SHOME. */
|
||||
@@ -609,7 +606,7 @@ int parse_kbinput(WINDOW *win)
|
||||
case SHIFT_HOME:
|
||||
shift_held = TRUE;
|
||||
case KEY_A1: /* Home (7) on keypad with NumLock off. */
|
||||
return sc_seq_or(do_home, keycode);
|
||||
return KEY_HOME;
|
||||
#ifdef KEY_SEND
|
||||
/* HP-UX 10-11 and Slang don't support KEY_SEND. */
|
||||
case KEY_SEND:
|
||||
@@ -617,32 +614,32 @@ int parse_kbinput(WINDOW *win)
|
||||
case SHIFT_END:
|
||||
shift_held = TRUE;
|
||||
case KEY_C1: /* End (1) on keypad with NumLock off. */
|
||||
return sc_seq_or(do_end, keycode);
|
||||
return KEY_END;
|
||||
#ifndef NANO_TINY
|
||||
case SHIFT_PAGEUP: /* Fake key, from Shift+Alt+Up. */
|
||||
shift_held = TRUE;
|
||||
#endif
|
||||
case KEY_A3: /* PageUp (9) on keypad with NumLock off. */
|
||||
return sc_seq_or(do_page_up, keycode);
|
||||
return KEY_PPAGE;
|
||||
#ifndef NANO_TINY
|
||||
case SHIFT_PAGEDOWN: /* Fake key, from Shift+Alt+Down. */
|
||||
shift_held = TRUE;
|
||||
#endif
|
||||
case KEY_C3: /* PageDown (3) on keypad with NumLock off. */
|
||||
return sc_seq_or(do_page_down, keycode);
|
||||
return KEY_NPAGE;
|
||||
#ifdef KEY_SDC
|
||||
/* Slang doesn't support KEY_SDC. */
|
||||
case KEY_SDC:
|
||||
#endif
|
||||
case DEL_CODE:
|
||||
if (ISSET(REBIND_DELETE))
|
||||
return sc_seq_or(do_delete, keycode);
|
||||
return sc_seq_or(do_delete, KEY_DC);
|
||||
else
|
||||
return sc_seq_or(do_backspace, keycode);
|
||||
return KEY_BACKSPACE;
|
||||
#ifdef KEY_SIC
|
||||
/* Slang doesn't support KEY_SIC. */
|
||||
case KEY_SIC:
|
||||
return sc_seq_or(do_insertfile_void, keycode);
|
||||
return sc_seq_or(do_insertfile_void, KEY_IC);
|
||||
#endif
|
||||
#ifdef KEY_SBEG
|
||||
/* Slang doesn't support KEY_SBEG. */
|
||||
@@ -670,7 +667,7 @@ int parse_kbinput(WINDOW *win)
|
||||
#endif
|
||||
/* Slang doesn't support KEY_SUSPEND. */
|
||||
case KEY_SUSPEND:
|
||||
return sc_seq_or(do_suspend_void, 0);
|
||||
return sc_seq_or(do_suspend_void, KEY_SUSPEND);
|
||||
#endif
|
||||
#ifdef PDCURSES
|
||||
case KEY_SHIFT_L:
|
||||
@@ -681,10 +678,8 @@ int parse_kbinput(WINDOW *win)
|
||||
case KEY_ALT_R:
|
||||
return ERR;
|
||||
#endif
|
||||
#if !defined(NANO_TINY) && defined(KEY_RESIZE)
|
||||
/* Since we don't change the default SIGWINCH handler when
|
||||
* NANO_TINY is defined, KEY_RESIZE is never generated.
|
||||
* Also, Slang and SunOS 5.7-5.9 don't support KEY_RESIZE. */
|
||||
#ifdef KEY_RESIZE
|
||||
/* Slang and SunOS 5.7-5.9 don't support KEY_RESIZE. */
|
||||
case KEY_RESIZE:
|
||||
return ERR;
|
||||
#endif
|
||||
@@ -1539,7 +1534,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
|
||||
return -1;
|
||||
|
||||
/* Save the screen coordinates where the mouse event took place. */
|
||||
*mouse_x = mevent.x;
|
||||
*mouse_x = mevent.x - margin;
|
||||
*mouse_y = mevent.y;
|
||||
|
||||
in_bottomwin = wenclose(bottomwin, *mouse_y, *mouse_x);
|
||||
@@ -1569,7 +1564,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
|
||||
if (*mouse_y == 0) {
|
||||
/* Restore the untranslated mouse event coordinates, so
|
||||
* that they're relative to the entire screen again. */
|
||||
*mouse_x = mevent.x;
|
||||
*mouse_x = mevent.x - margin;
|
||||
*mouse_y = mevent.y;
|
||||
|
||||
return 0;
|
||||
@@ -2185,7 +2180,11 @@ void bottombars(int menu)
|
||||
i++;
|
||||
}
|
||||
|
||||
/* Defeat a VTE bug by moving the cursor and forcing a screen update. */
|
||||
wmove(bottomwin, 0, 0);
|
||||
wnoutrefresh(bottomwin);
|
||||
doupdate();
|
||||
|
||||
reset_cursor();
|
||||
wnoutrefresh(edit);
|
||||
}
|
||||
@@ -2225,13 +2224,13 @@ void reset_cursor(void)
|
||||
openfile->current_y = 0;
|
||||
|
||||
while (line != NULL && line != openfile->current) {
|
||||
openfile->current_y += strlenpt(line->data) / COLS + 1;
|
||||
openfile->current_y += strlenpt(line->data) / editwincols + 1;
|
||||
line = line->next;
|
||||
}
|
||||
openfile->current_y += xpt / COLS;
|
||||
openfile->current_y += xpt / editwincols;
|
||||
|
||||
if (openfile->current_y < editwinrows)
|
||||
wmove(edit, openfile->current_y, xpt % COLS);
|
||||
wmove(edit, openfile->current_y, xpt % editwincols + margin);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
@@ -2239,7 +2238,7 @@ void reset_cursor(void)
|
||||
openfile->edittop->lineno;
|
||||
|
||||
if (openfile->current_y < editwinrows)
|
||||
wmove(edit, openfile->current_y, xpt - get_page_start(xpt));
|
||||
wmove(edit, openfile->current_y, xpt - get_page_start(xpt) + margin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2258,7 +2257,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
size_t startpos = actual_x(fileptr->data, start);
|
||||
/* The position in fileptr->data of the leftmost character
|
||||
* that displays at least partially on the window. */
|
||||
size_t endpos = actual_x(fileptr->data, start + COLS - 1) + 1;
|
||||
size_t endpos = actual_x(fileptr->data, start + editwincols - 1) + 1;
|
||||
/* The position in fileptr->data of the first character that is
|
||||
* completely off the window to the right.
|
||||
*
|
||||
@@ -2267,11 +2266,24 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
#endif
|
||||
|
||||
assert(openfile != NULL && fileptr != NULL && converted != NULL);
|
||||
assert(strlenpt(converted) <= COLS);
|
||||
assert(strlenpt(converted) <= editwincols);
|
||||
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
/* If line numbering is switched on, show a line number in front of
|
||||
* the text -- but only for the parts that are not softwrapped. */
|
||||
if (margin > 0) {
|
||||
wattron(edit, interface_color_pair[LINE_NUMBER]);
|
||||
if (last_drawn_line != fileptr->lineno || last_line_y >= line)
|
||||
mvwprintw(edit, line, 0, "%*i", margin - 1, fileptr->lineno);
|
||||
else
|
||||
mvwprintw(edit, line, 0, "%*s", margin - 1, " ");
|
||||
wattroff(edit, interface_color_pair[LINE_NUMBER]);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* First simply paint the line -- then we'll add colors or the
|
||||
* marking highlight on just the pieces that need it. */
|
||||
mvwaddstr(edit, line, 0, converted);
|
||||
mvwaddstr(edit, line, margin, converted);
|
||||
|
||||
#ifdef USING_OLD_NCURSES
|
||||
/* Tell ncurses to really redraw the line without trying to optimize
|
||||
@@ -2349,7 +2361,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
|
||||
assert(0 <= x_start && 0 <= paintlen);
|
||||
|
||||
mvwaddnstr(edit, line, x_start, converted +
|
||||
mvwaddnstr(edit, line, x_start + margin, converted +
|
||||
index, paintlen);
|
||||
}
|
||||
k = startmatch.rm_eo;
|
||||
@@ -2366,7 +2378,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
if (fileptr->multidata[varnish->id] == CNONE)
|
||||
goto tail_of_loop;
|
||||
else if (fileptr->multidata[varnish->id] == CWHOLELINE) {
|
||||
mvwaddnstr(edit, line, 0, converted, -1);
|
||||
mvwaddnstr(edit, line, margin, converted, -1);
|
||||
goto tail_of_loop;
|
||||
} else if (fileptr->multidata[varnish->id] == CBEGINBEFORE) {
|
||||
regexec(varnish->end, fileptr->data, 1, &endmatch, 0);
|
||||
@@ -2375,7 +2387,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
goto tail_of_loop;
|
||||
paintlen = actual_x(converted, strnlenpt(fileptr->data,
|
||||
endmatch.rm_eo) - start);
|
||||
mvwaddnstr(edit, line, 0, converted, paintlen);
|
||||
mvwaddnstr(edit, line, margin, converted, paintlen);
|
||||
goto tail_of_loop;
|
||||
} if (fileptr->multidata[varnish->id] == -1)
|
||||
/* Assume this until proven otherwise below. */
|
||||
@@ -2471,7 +2483,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
fprintf(stderr, " Marking for id %i line %i as CBEGINBEFORE\n", varnish->id, line);
|
||||
#endif
|
||||
}
|
||||
mvwaddnstr(edit, line, 0, converted, paintlen);
|
||||
mvwaddnstr(edit, line, margin, converted, paintlen);
|
||||
/* If the whole line has been painted, don't bother looking
|
||||
* for any more starts. */
|
||||
if (paintlen < 0)
|
||||
@@ -2517,9 +2529,9 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
strnlenpt(fileptr->data,
|
||||
endmatch.rm_eo) - start - x_start);
|
||||
|
||||
assert(0 <= x_start && x_start < COLS);
|
||||
assert(0 <= x_start && x_start < editwincols);
|
||||
|
||||
mvwaddnstr(edit, line, x_start,
|
||||
mvwaddnstr(edit, line, x_start + margin,
|
||||
converted + index, paintlen);
|
||||
if (paintlen > 0) {
|
||||
fileptr->multidata[varnish->id] = CSTARTENDHERE;
|
||||
@@ -2546,10 +2558,10 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
if (end_line == NULL)
|
||||
break;
|
||||
|
||||
assert(0 <= x_start && x_start < COLS);
|
||||
assert(0 <= x_start && x_start < editwincols);
|
||||
|
||||
/* Paint the rest of the line. */
|
||||
mvwaddnstr(edit, line, x_start, converted + index, -1);
|
||||
mvwaddnstr(edit, line, x_start + margin, converted + index, -1);
|
||||
fileptr->multidata[varnish->id] = CENDAFTER;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " Marking for id %i line %i as CENDAFTER\n", varnish->id, line);
|
||||
@@ -2627,11 +2639,15 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
paintlen = actual_x(converted + index, paintlen);
|
||||
|
||||
wattron(edit, hilite_attribute);
|
||||
mvwaddnstr(edit, line, x_start, converted + index, paintlen);
|
||||
mvwaddnstr(edit, line, x_start + margin, converted + index, paintlen);
|
||||
wattroff(edit, hilite_attribute);
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
last_drawn_line = fileptr->lineno;
|
||||
last_line_y = line;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Just update one line in the edit buffer. This is basically a wrapper
|
||||
@@ -2655,7 +2671,7 @@ int update_line(filestruct *fileptr, size_t index)
|
||||
filestruct *tmp;
|
||||
|
||||
for (tmp = openfile->edittop; tmp && tmp != fileptr; tmp = tmp->next)
|
||||
line += (strlenpt(tmp->data) / COLS) + 1;
|
||||
line += (strlenpt(tmp->data) / editwincols) + 1;
|
||||
} else
|
||||
#endif
|
||||
line = fileptr->lineno - openfile->edittop->lineno;
|
||||
@@ -2679,11 +2695,11 @@ int update_line(filestruct *fileptr, size_t index)
|
||||
/* Expand the line, replacing tabs with spaces, and control
|
||||
* characters with their displayed forms. */
|
||||
#ifdef NANO_TINY
|
||||
converted = display_string(fileptr->data, page_start, COLS, TRUE);
|
||||
converted = display_string(fileptr->data, page_start, editwincols, TRUE);
|
||||
#else
|
||||
converted = display_string(fileptr->data, page_start, COLS, !ISSET(SOFTWRAP));
|
||||
converted = display_string(fileptr->data, page_start, editwincols, !ISSET(SOFTWRAP));
|
||||
#ifdef DEBUG
|
||||
if (ISSET(SOFTWRAP) && strlen(converted) >= COLS - 2)
|
||||
if (ISSET(SOFTWRAP) && strlen(converted) >= editwincols - 2)
|
||||
fprintf(stderr, "update_line(): converted(1) line = %s\n", converted);
|
||||
#endif
|
||||
#endif /* !NANO_TINY */
|
||||
@@ -2696,13 +2712,13 @@ int update_line(filestruct *fileptr, size_t index)
|
||||
if (!ISSET(SOFTWRAP)) {
|
||||
#endif
|
||||
if (page_start > 0)
|
||||
mvwaddch(edit, line, 0, '$');
|
||||
if (strlenpt(fileptr->data) > page_start + COLS)
|
||||
mvwaddch(edit, line, margin, '$');
|
||||
if (strlenpt(fileptr->data) > page_start + editwincols)
|
||||
mvwaddch(edit, line, COLS - 1, '$');
|
||||
#ifndef NANO_TINY
|
||||
} else {
|
||||
size_t full_length = strlenpt(fileptr->data);
|
||||
for (index += COLS; index <= full_length && line < editwinrows - 1; index += COLS) {
|
||||
for (index += editwincols; index <= full_length && line < editwinrows - 1; index += editwincols) {
|
||||
line++;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "update_line(): softwrap code, moving to %d index %lu\n", line, (unsigned long)index);
|
||||
@@ -2711,9 +2727,9 @@ int update_line(filestruct *fileptr, size_t index)
|
||||
|
||||
/* Expand the line, replacing tabs with spaces, and control
|
||||
* characters with their displayed forms. */
|
||||
converted = display_string(fileptr->data, index, COLS, !ISSET(SOFTWRAP));
|
||||
converted = display_string(fileptr->data, index, editwincols, !ISSET(SOFTWRAP));
|
||||
#ifdef DEBUG
|
||||
if (ISSET(SOFTWRAP) && strlen(converted) >= COLS - 2)
|
||||
if (ISSET(SOFTWRAP) && strlen(converted) >= editwincols - 2)
|
||||
fprintf(stderr, "update_line(): converted(2) line = %s\n", converted);
|
||||
#endif
|
||||
|
||||
@@ -2754,7 +2770,7 @@ void compute_maxrows(void)
|
||||
maxrows = 0;
|
||||
for (n = 0; n < editwinrows && foo; n++) {
|
||||
maxrows++;
|
||||
n += strlenpt(foo->data) / COLS;
|
||||
n += strlenpt(foo->data) / editwincols;
|
||||
foo = foo->next;
|
||||
}
|
||||
|
||||
@@ -2799,7 +2815,7 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
#ifndef NANO_TINY
|
||||
/* Don't over-scroll on long lines. */
|
||||
if (ISSET(SOFTWRAP) && direction == UPWARD) {
|
||||
ssize_t len = strlenpt(openfile->edittop->data) / COLS;
|
||||
ssize_t len = strlenpt(openfile->edittop->data) / editwincols;
|
||||
i -= len;
|
||||
if (len > 0)
|
||||
refresh_needed = TRUE;
|
||||
@@ -2878,9 +2894,14 @@ void edit_redraw(filestruct *old_current)
|
||||
|
||||
/* If the current line is offscreen, scroll until it's onscreen. */
|
||||
if (openfile->current->lineno >= openfile->edittop->lineno + maxrows ||
|
||||
#ifndef NANO_TINY
|
||||
(openfile->current->lineno == openfile->edittop->lineno + maxrows - 1 &&
|
||||
ISSET(SOFTWRAP) && strlenpt(openfile->current->data) >= editwincols) ||
|
||||
#endif
|
||||
openfile->current->lineno < openfile->edittop->lineno) {
|
||||
edit_update((focusing || !ISSET(SMOOTH_SCROLL)) ? CENTERING : FLOWING);
|
||||
adjust_viewport((focusing || !ISSET(SMOOTH_SCROLL)) ? CENTERING : FLOWING);
|
||||
refresh_needed = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -2919,16 +2940,14 @@ void edit_refresh(void)
|
||||
/* Figure out what maxrows should really be. */
|
||||
compute_maxrows();
|
||||
|
||||
/* If the current line is out of view, get it back on screen. */
|
||||
if (openfile->current->lineno < openfile->edittop->lineno ||
|
||||
openfile->current->lineno >= openfile->edittop->lineno +
|
||||
maxrows) {
|
||||
openfile->current->lineno >= openfile->edittop->lineno + maxrows) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "edit_refresh(): line = %ld, edittop %ld + maxrows %d\n",
|
||||
(long)openfile->current->lineno, (long)openfile->edittop->lineno, maxrows);
|
||||
#endif
|
||||
|
||||
/* Make sure the current line is on the screen. */
|
||||
edit_update((focusing || !ISSET(SMOOTH_SCROLL)) ? CENTERING : STATIONARY);
|
||||
adjust_viewport((focusing || !ISSET(SMOOTH_SCROLL)) ? CENTERING : STATIONARY);
|
||||
}
|
||||
|
||||
foo = openfile->edittop;
|
||||
@@ -2939,7 +2958,7 @@ void edit_refresh(void)
|
||||
|
||||
for (nlines = 0; nlines < editwinrows && foo != NULL; nlines++) {
|
||||
nlines += update_line(foo, (foo == openfile->current) ?
|
||||
openfile->current_x : 0);
|
||||
openfile->current_x : 0);
|
||||
foo = foo->next;
|
||||
}
|
||||
|
||||
@@ -2947,7 +2966,10 @@ void edit_refresh(void)
|
||||
blank_line(edit, nlines, 0, COLS);
|
||||
|
||||
reset_cursor();
|
||||
curs_set(1);
|
||||
wnoutrefresh(edit);
|
||||
|
||||
refresh_needed = FALSE;
|
||||
}
|
||||
|
||||
/* Move edittop so that current is on the screen. manner says how it
|
||||
@@ -2955,7 +2977,7 @@ void edit_refresh(void)
|
||||
* middle of the screen, STATIONARY means that it should stay at the
|
||||
* same vertical position, and FLOWING means that it should scroll no
|
||||
* more than needed to bring current into view. */
|
||||
void edit_update(update_type manner)
|
||||
void adjust_viewport(update_type manner)
|
||||
{
|
||||
int goal = 0;
|
||||
|
||||
@@ -2971,8 +2993,13 @@ void edit_update(update_type manner)
|
||||
if (manner == CENTERING)
|
||||
goal = editwinrows / 2;
|
||||
else if (manner == FLOWING) {
|
||||
if (openfile->current->lineno >= openfile->edittop->lineno)
|
||||
if (openfile->current->lineno >= openfile->edittop->lineno) {
|
||||
goal = editwinrows - 1;
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP))
|
||||
goal -= strlenpt(openfile->current->data) / editwincols;
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
goal = openfile->current_y;
|
||||
|
||||
@@ -2985,14 +3012,17 @@ void edit_update(update_type manner)
|
||||
|
||||
while (goal > 0 && openfile->edittop->prev != NULL) {
|
||||
openfile->edittop = openfile->edittop->prev;
|
||||
goal --;
|
||||
goal--;
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP))
|
||||
goal -= strlenpt(openfile->edittop->data) / COLS;
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
goal -= strlenpt(openfile->edittop->data) / editwincols;
|
||||
if (goal < 0)
|
||||
openfile->edittop = openfile->edittop->next;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "edit_update(): setting edittop to lineno %ld\n", (long)openfile->edittop->lineno);
|
||||
fprintf(stderr, "adjust_viewport(): setting edittop to lineno %ld\n", (long)openfile->edittop->lineno);
|
||||
#endif
|
||||
compute_maxrows();
|
||||
}
|
||||
@@ -3107,7 +3137,7 @@ void spotlight(bool active, const char *word)
|
||||
size_t word_len = strlenpt(word), room;
|
||||
|
||||
/* Compute the number of columns that are available for the word. */
|
||||
room = COLS + get_page_start(xplustabs()) - xplustabs();
|
||||
room = editwincols + get_page_start(xplustabs()) - xplustabs();
|
||||
|
||||
assert(room > 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user