Compare commits
243 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c26a940167 | ||
|
|
26347ed38e | ||
|
|
1b293ff34c | ||
|
|
83475b0d84 | ||
|
|
113cd506c9 | ||
|
|
ec4ee1c489 | ||
|
|
ebbb5b5d1e | ||
|
|
1ac2c4cd4f | ||
|
|
6d6cda24c8 | ||
|
|
9962e3b65c | ||
|
|
9d72efa474 | ||
|
|
22557df600 | ||
|
|
9e6b9a29a5 | ||
|
|
0dd351a5c1 | ||
|
|
dd29c56993 | ||
|
|
7a08fa63f5 | ||
|
|
539a4b42be | ||
|
|
42a761e77f | ||
|
|
0d85c8c68c | ||
|
|
a5bc70a541 | ||
|
|
37712fb120 | ||
|
|
5765e9675f | ||
|
|
c916ca87bf | ||
|
|
97e9476df5 | ||
|
|
9eca195990 | ||
|
|
46db638435 | ||
|
|
1592ca0585 | ||
|
|
8f0262f51e | ||
|
|
33bc96ab5c | ||
|
|
26bc037b19 | ||
|
|
37d8ad8687 | ||
|
|
ae598e79a6 | ||
|
|
480b6a320f | ||
|
|
31e1af646c | ||
|
|
a0eea607ba | ||
|
|
8cc6308f9c | ||
|
|
1bebe34b56 | ||
|
|
277f58f8d8 | ||
|
|
451b299c1d | ||
|
|
454f6ebb97 | ||
|
|
bd91785d73 | ||
|
|
46082bd00c | ||
|
|
dd1b2dce98 | ||
|
|
31f0456e9a | ||
|
|
5737fe3461 | ||
|
|
72760159e7 | ||
|
|
22e9283520 | ||
|
|
d63912947a | ||
|
|
4fc16848fa | ||
|
|
8295a88ff0 | ||
|
|
a77efae609 | ||
|
|
9a6f62ff67 | ||
|
|
5834638d53 | ||
|
|
a64bfbee8b | ||
|
|
77c0357868 | ||
|
|
cac3c3399f | ||
|
|
5d27910d6d | ||
|
|
a955b332e3 | ||
|
|
1233e8e37a | ||
|
|
4eb4d08038 | ||
|
|
fa695744fd | ||
|
|
c4a6725ad6 | ||
|
|
bb31118fcb | ||
|
|
26151189ba | ||
|
|
40e1fd37d7 | ||
|
|
f2da466388 | ||
|
|
ba8f806705 | ||
|
|
c12d1b87d4 | ||
|
|
ccc9b24f16 | ||
|
|
4bc8ff1e6d | ||
|
|
8651fefc68 | ||
|
|
ee5cdcbce5 | ||
|
|
a41968eeef | ||
|
|
e76bbc8832 | ||
|
|
6fa1e98c8d | ||
|
|
1fbcf0b23d | ||
|
|
1ea76eb51b | ||
|
|
5634d7d717 | ||
|
|
ad1f1bce7f | ||
|
|
c9e91df4e4 | ||
|
|
07e806e7f2 | ||
|
|
eee07d5755 | ||
|
|
3d6378b153 | ||
|
|
ae22fe03eb | ||
|
|
4ea55c3bf7 | ||
|
|
6a88d8a737 | ||
|
|
42ac5368e1 | ||
|
|
66e21416af | ||
|
|
6b1566023a | ||
|
|
0129299dc9 | ||
|
|
98f2f852dd | ||
|
|
ee33503402 | ||
|
|
e19a16f0e6 | ||
|
|
9e22e8b1b5 | ||
|
|
6135e28878 | ||
|
|
f9a6eb8bec | ||
|
|
b1d6d7f95c | ||
|
|
be01647a18 | ||
|
|
4a59b12ed4 | ||
|
|
793d8490de | ||
|
|
cf0c9403e1 | ||
|
|
530c7862c9 | ||
|
|
b255b01b50 | ||
|
|
1b69dd629a | ||
|
|
438cb110ff | ||
|
|
e0d0ca4b97 | ||
|
|
fbe4376822 | ||
|
|
9c821dfe2e | ||
|
|
9dc47fdfe5 | ||
|
|
f08d79d204 | ||
|
|
72caa54020 | ||
|
|
81f3177a33 | ||
|
|
6007d6227b | ||
|
|
d6bd276c8c | ||
|
|
c706b79b63 | ||
|
|
1f027a838e | ||
|
|
c9e8370cec | ||
|
|
f9274a5a29 | ||
|
|
ec26fd5e7c | ||
|
|
bde996db67 | ||
|
|
7be493047c | ||
|
|
54c2f6b5ae | ||
|
|
f1d9fcc77b | ||
|
|
619f28077c | ||
|
|
02a3a25aa0 | ||
|
|
c43c048783 | ||
|
|
4a23a171b8 | ||
|
|
a1c03ed5c1 | ||
|
|
b66e4bfa5b | ||
|
|
a3c9dfa391 | ||
|
|
53fbcf77f2 | ||
|
|
4ede3b494f | ||
|
|
452066bc88 | ||
|
|
d0e8887e3b | ||
|
|
bf84e5972d | ||
|
|
5cbb5115c6 | ||
|
|
2418b9486b | ||
|
|
df80bfd2fc | ||
|
|
4a1835fd93 | ||
|
|
c67ab656dc | ||
|
|
3c40b35055 | ||
|
|
499c2af385 | ||
|
|
bf64514283 | ||
|
|
b0a2f9853b | ||
|
|
0d9397e5b0 | ||
|
|
d0b72552bf | ||
|
|
26eed9d406 | ||
|
|
3059e16c25 | ||
|
|
08e5eea5b6 | ||
|
|
17b46f04da | ||
|
|
b4103321e6 | ||
|
|
6620de0091 | ||
|
|
954d04bc59 | ||
|
|
9205c28865 | ||
|
|
459d9f8ba8 | ||
|
|
213294e69c | ||
|
|
86bbe50a3b | ||
|
|
8925eabd5e | ||
|
|
149b1fe439 | ||
|
|
a5b29539b1 | ||
|
|
9e438cdce1 | ||
|
|
7a1959fb11 | ||
|
|
427eff6780 | ||
|
|
5440796f31 | ||
|
|
a9aa0ef997 | ||
|
|
f811846dc5 | ||
|
|
8a058d1f9a | ||
|
|
677e9474f7 | ||
|
|
58a0ddebac | ||
|
|
07fdf46154 | ||
|
|
c9337dd4ed | ||
|
|
f5234e583f | ||
|
|
ea2b51a41d | ||
|
|
eac0446c86 | ||
|
|
90798fbfba | ||
|
|
2a5bd555e7 | ||
|
|
7e1bc82d98 | ||
|
|
30daf4d43f | ||
|
|
24d6b7fcf7 | ||
|
|
052ad10d11 | ||
|
|
70cbbda87c | ||
|
|
95e1f55574 | ||
|
|
455fb4f063 | ||
|
|
3d2784e113 | ||
|
|
8a06dfa4d7 | ||
|
|
ace151778b | ||
|
|
45f873a6a7 | ||
|
|
e919c22793 | ||
|
|
b3e4051ded | ||
|
|
20ba559b9f | ||
|
|
b7f7df93df | ||
|
|
6847616aee | ||
|
|
104ea6b0c3 | ||
|
|
2ee18d635f | ||
|
|
efbf7b6ef3 | ||
|
|
5885e34b23 | ||
|
|
e4294a211e | ||
|
|
0b15c42a5c | ||
|
|
bff6a905af | ||
|
|
c7f5691637 | ||
|
|
17ab9a2dba | ||
|
|
f7e8861770 | ||
|
|
4990f74f83 | ||
|
|
8ffc33cd89 | ||
|
|
ee7b095678 | ||
|
|
25c775af21 | ||
|
|
b967368d41 | ||
|
|
f47813eefa | ||
|
|
474b390816 | ||
|
|
b58676f3c9 | ||
|
|
d52f108526 | ||
|
|
9dc544acbd | ||
|
|
59fdd4db7a | ||
|
|
f1bd958851 | ||
|
|
74e7521478 | ||
|
|
3f1878d9a9 | ||
|
|
6039cd7f6e | ||
|
|
1dc298d28b | ||
|
|
98ffb642f3 | ||
|
|
8cde95e170 | ||
|
|
aa0fd889af | ||
|
|
1f866c29db | ||
|
|
cadb4f3689 | ||
|
|
79526151d5 | ||
|
|
5e53c6ee9e | ||
|
|
42f307ef75 | ||
|
|
674ab835e8 | ||
|
|
badbc676fb | ||
|
|
aee86996de | ||
|
|
3d01486409 | ||
|
|
5bb096d32f | ||
|
|
aff252aed6 | ||
|
|
08d9f572a4 | ||
|
|
ea4b775a3e | ||
|
|
93e391eba3 | ||
|
|
9fcde23009 | ||
|
|
6095ff3d39 | ||
|
|
fc7825d00d | ||
|
|
8f5fa24e51 | ||
|
|
619666460e | ||
|
|
5ac6a87522 | ||
|
|
05fb283034 | ||
|
|
6edb7a43f2 |
15
AUTHORS
15
AUTHORS
@@ -9,8 +9,8 @@ Chris Allegretta <chrisa@asty.org>
|
||||
David Lawrence Ramsey <pooka109@gmail.com>
|
||||
* Former stable series maintainer. Multiple buffer support,
|
||||
operating dir (-o) option, bug fixes for display routines,
|
||||
wrapping code, spelling fixes, const mode, parts of the UTF-8
|
||||
support, and various other fixes.
|
||||
wrapping code, spelling fixes, const mode, parts of the
|
||||
UTF-8 support, and various other fixes.
|
||||
|
||||
Jordi Mallach <jordi@gnu.org>
|
||||
* Debian package maintainer, fellow bug squasher.
|
||||
@@ -23,8 +23,8 @@ Adam Rogoyski <rogoyski@cs.utexas.edu>
|
||||
|
||||
Robert Siemborski <rjs3@andrew.cmu.edu>
|
||||
* Miscellaneous cut, display, replace, and other bug fixes,
|
||||
original and new "magic line" code, read_line() function, new
|
||||
edit display routines.
|
||||
original and new "magic line" code, read_line() function,
|
||||
new edit display routines.
|
||||
|
||||
Rocco Corsi <rocco.corsi@sympatico.ca>
|
||||
* Internal spelling code, many optimizations and bug fixes for
|
||||
@@ -41,3 +41,10 @@ Mike Frysinger <vapier@gentoo.org>
|
||||
--enable-utf8/--disable-utf8 configure options for ncurses,
|
||||
many new color regexes and improvements to existing color
|
||||
regexes for nanorc.sample, and miscellaneous bug fixes.
|
||||
|
||||
Mark Majeres <mark@engine12.com>
|
||||
* A functional undo/redo system, and coloring nano's interface.
|
||||
|
||||
Benno Schulenberg <bensberg@justemail.net>
|
||||
* A bunch of small bug fixes, the cutword routines, some extra
|
||||
key bindings. Current maintainer.
|
||||
|
||||
48
NEWS
48
NEWS
@@ -1,4 +1,34 @@
|
||||
2015.07.05 - GNU nano 2.4.1 "Portorož" is released. This release
|
||||
2016.01.11 - GNU nano 2.5.1 "Salzburg" is released. It includes fixes
|
||||
for a syntax-highlighting bug and a positionlog bug, it
|
||||
disables a time-eating multiline regex in the C syntax,
|
||||
and it adds an escape hatch to the WriteOut menu when
|
||||
--tempfile is used: the discardbuffer command, ^Q. It
|
||||
also has translation updates for fifteen languages, and
|
||||
a small fix in the softwrap code. So... you are heartily
|
||||
invited to upgrade. Enjoy!
|
||||
|
||||
2015.12.05 - GNU nano 2.5.0 "Karma", the first release of the 2.5 series,
|
||||
is now available. Please note that as of this release,
|
||||
there will no longer be separate stable and unstable
|
||||
branches. The development team will prioritize bug fixes
|
||||
as needed, and make new releases in proportion to the
|
||||
severity of the bugs which are fixed.
|
||||
This release includes all of the fixes now in
|
||||
2.4.3, as well as color syntax highlighting improvements,
|
||||
undo fixes, and many more improvements! Thank you for
|
||||
using nano!
|
||||
|
||||
2015.11.18 - GNU nano 2.4.3 "Apocalypse" is now available for your
|
||||
downloading pleasure. This release includes a myriad
|
||||
of fixes including several memory leaks, issues with
|
||||
color syntax highlighting, search/replace, file
|
||||
insertion and help menu bugs. Many thanks to
|
||||
Benno Schulenberg for tireless efforts on the vast
|
||||
majority of fixes for some time now. As always please
|
||||
report bugs via the Savannah page, and remember to
|
||||
Share and Enjoy.
|
||||
|
||||
2015.07.05 - GNU nano 2.4.2 "Portorož" is released. This release
|
||||
includes several fixes, including the ability to resize
|
||||
when in modes other than the main editing window,
|
||||
proper displaying of invalid UTF-8 bytes, new syntax
|
||||
@@ -11,7 +41,7 @@
|
||||
menu, linter and formatter functions, spell checker,
|
||||
undo/redo with some specific marked-cutting situations,
|
||||
and some small improvements to the color syntax
|
||||
highlighting definitions. There are also various
|
||||
highlighting definitions. There are also various
|
||||
documentation and code comment updates included, and
|
||||
finally, fixes for compilation on non-GNU/Linux systems
|
||||
and certain configure combinations. Toasters!
|
||||
@@ -76,12 +106,12 @@
|
||||
https://savannah.gnu.org/bugs/index.php?42639 and
|
||||
thanks for using nano.
|
||||
|
||||
2014.06.02 - GNU nano 2.3.4 won't leave you high, won't leave you dry. This
|
||||
2014.06.02 - GNU nano 2.3.4 won't leave you high, won't leave you dry. This
|
||||
release contains only a small number of fixes, but in
|
||||
particular allows nano to compile on non-UTF8 curses
|
||||
implementations (i.e. libncursesw). Other small fixes to
|
||||
the undo implementation and the default syntax config are
|
||||
also included. As always, Share and Enjoy!
|
||||
also included. As always, Share and Enjoy!
|
||||
|
||||
2014.05.28 - GNU nano 2.3.3 is in its right place. This release contains
|
||||
many many improvements to the core system, including
|
||||
@@ -92,7 +122,7 @@
|
||||
linter support (see the nanorc man page for details). Also
|
||||
included are much improved syntax highlighting code, and
|
||||
configurations for JSON, texinfo, Go, and a default syntax
|
||||
for catch all highlighting. Finally, nano now has the
|
||||
for catch all highlighting. Finally, nano now has the
|
||||
ability to set the color of the title bar, status bar, and
|
||||
shortcut keys (e.g. "^X") and their descriptions. Again
|
||||
see the nanorc page for details. There's much more, too
|
||||
@@ -127,7 +157,7 @@
|
||||
in your .nanorc. Also included are some fixes for
|
||||
compilation with g++, and better handling of issues
|
||||
writing the backup file, which should reduce the need
|
||||
for the 'set allow_insecure_backup" nanorc option.
|
||||
for the "set allow_insecure_backup" nanorc option.
|
||||
Don't stop, get it get it, don't stop, get it get it.
|
||||
|
||||
2010.11.22 - GNU nano 2.2.6 "Pimp my BBS" wants you to go to
|
||||
@@ -173,7 +203,7 @@
|
||||
This release contains a fix for only one bug, but a
|
||||
rather irritating one: when paging up/down with smooth
|
||||
scrolling, the cursor position was not being preserved
|
||||
due to a bug in 2.2.2. With such a targeted fix
|
||||
due to a bug in 2.2.2. With such a targeted fix
|
||||
like this what could POSSIBLY go WRONG? Hahaha.
|
||||
Enjoy and if you find new bugs, as always please
|
||||
use Savannah's bug tracker.
|
||||
@@ -214,7 +244,7 @@
|
||||
the help keys and replace menu text), more 'final'
|
||||
fixes for soft wrapping, and several typo and documentation
|
||||
updates including nanorc tweaks and a new syntax
|
||||
highlighting file for makefiles. Also included is a long
|
||||
highlighting file for makefiles. Also included is a long
|
||||
standing fix for random crashing when using nanorc on
|
||||
FreeBSD, and nano will no longer clear the screen on
|
||||
suspend to maintain compatibility with other *nix editors.
|
||||
@@ -253,7 +283,7 @@
|
||||
2009.09.14 - GNU nano 2.1.11 is on very thin ice, very thin ice, very thin
|
||||
ice. This release includes two new features: first, nano
|
||||
will check whether the current file is writable when it
|
||||
is opened, and warn if it is not on the status bar. Secondly,
|
||||
is opened, and warn if it is not on the status bar. Secondly,
|
||||
a new soft-wrapping (AKA full line display) option is
|
||||
available, which will attempt to fully display the contents
|
||||
of lines longer than the width of the screen without the
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#
|
||||
# $Id$
|
||||
|
||||
AC_INIT([GNU nano], [2.4.2], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [2.5.1], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AC_CANONICAL_HOST
|
||||
AM_INIT_AUTOMAKE
|
||||
@@ -527,6 +527,7 @@ else
|
||||
fi
|
||||
|
||||
AC_CHECK_LIB([$CURSES_LIB_NAME], use_default_colors, AC_DEFINE(HAVE_USE_DEFAULT_COLORS, 1, [Define this if your curses library has the use_default_colors() command.]))
|
||||
AC_CHECK_LIB([$CURSES_LIB_NAME], key_defined, AC_DEFINE(HAVE_KEY_DEFINED, 1, [Define this if your curses library has the key_defined() command.]))
|
||||
|
||||
dnl Parse any configure options.
|
||||
|
||||
@@ -656,9 +657,9 @@ AC_MSG_RESULT(no),
|
||||
AC_MSG_WARN([*** Can't check for macro redefinability when cross-compiling]))
|
||||
|
||||
AS_IF([test "x$enable_libmagic" != "xno"], [
|
||||
AC_CHECK_HEADERS_ONCE([magic.h])
|
||||
AC_CHECK_HEADERS([magic.h])
|
||||
AC_CHECK_LIB(magic, magic_open)
|
||||
AC_CHECK_HEADERS_ONCE([zlib.h])
|
||||
AC_CHECK_HEADERS([zlib.h])
|
||||
AC_CHECK_LIB(z, inflate)
|
||||
])
|
||||
|
||||
|
||||
46
doc/faq.html
46
doc/faq.html
@@ -28,8 +28,8 @@
|
||||
<a href="#3.6">3.6. How can I make the executable smaller? This is too bloated!</a><br>
|
||||
<a href="#3.7">3.7. Tell me more about this multibuffer stuff!</a><br>
|
||||
<a href="#3.8">3.8. Tell me more about this verbatim input stuff!</a><br>
|
||||
<a href="#3.9">3.9. How do I make a .nanorc file that nano will read when I start it?</a></br>
|
||||
<a href="#3.9.1">3.9.1. How about in Win32?</a></p></blockquote>
|
||||
<a href="#3.9a">3.9a. How do I make a .nanorc file that nano will read when I start it?</a><br>
|
||||
<a href="#3.9b">3.9b. How about in Win32?</a></p></blockquote>
|
||||
<h2><a href="#4">4. Running</a></h2>
|
||||
<blockquote><p><a href="#4.1">4.1. How do I open a file with a name beginning with '+' from the command line?</a><br>
|
||||
<a href="#4.2">4.2. Ack! My Backspace/Delete/Enter/Meta/double bucky key doesn't seem to work! What can I do?</a><br>
|
||||
@@ -84,9 +84,9 @@
|
||||
<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.2.6. Of course, you should always check the nano homepage to see what the latest and greatest version is.</p></blockquote>
|
||||
<blockquote><p>The current stable version of nano *should* be 2.4.2. Of course, you should always check the <a href="http://www.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="http://www.nano-editor.org/dist/v2.2/nano.1.html">here</a>.</p></blockquote>
|
||||
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="http://www.nano-editor.org/dist/v2.4/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>
|
||||
@@ -135,18 +135,20 @@
|
||||
<h2><a name="3.6"></a>3.6. How can I make the executable smaller? This is too bloated!</h2>
|
||||
<blockquote><p>Actually, there are several parts of the editor that can be disabled. You can pass arguments to the <b>configure</b> script that disable certain features. Here's a brief list:</p>
|
||||
<pre>
|
||||
<b>--disable-browser</b> Disable built-in file browser
|
||||
<b>--disable-browser</b> Disable the built-in file browser
|
||||
<b>--disable-color</b> Disable color and syntax highlighting
|
||||
<b>--disable-extra</b> Disable extra features, currently only an easter egg
|
||||
<b>--disable-extra</b> Disable extra features (currently only an easter egg)
|
||||
<b>--disable-help</b> Disable help functions
|
||||
<b>--disable-histories</b> Disable the saving of search strings and cursor positions
|
||||
<b>--disable-justify</b> Disable justify/unjustify functions
|
||||
<b>--disable-mouse</b> Disable mouse support (and -m flag)
|
||||
<b>--disable-libmagic</b> Disable the use of libmagic for determining a file's syntax
|
||||
<b>--disable-mouse</b> Disable mouse support
|
||||
<b>--disable-multibuffer</b> Disable having multiple file buffers open
|
||||
<b>--disable-nanorc</b> Disable the use of .nanorc files
|
||||
<b>--disable-operatingdir</b> Disable setting of operating directory
|
||||
<b>--disable-operatingdir</b> Disable the setting of an operating directory
|
||||
<b>--disable-speller</b> Disable spell checker functions
|
||||
<b>--disable-tabcomp</b> Disable tab completion functions
|
||||
<b>--disable-wrapping</b> Disable all wrapping of text (and -w flag)</pre>
|
||||
<b>--disable-wrapping</b> Disable all hard-wrapping of text</pre>
|
||||
<p>There's also the <b>--enable-tiny</b> option which disables everything above, as well as some larger chunks of the program (like the marker code that you use with Control-^ to select text). Also, if you know you aren't going to be using other languages you can use <b>--disable-nls</b> to disable internationalization and save a few K to a few dozen K depending on if you have locale support on your system. And finally there's always good old <b>strip</b> to strip all debugging code and code that exists in libraries on your system.</p>
|
||||
<p>With <b>--disable-wrapping-as-root</b> you can disable any hard-wrapping by default when the user is root, useful to prevent accidentally changing long lines in system configuration files.</p>
|
||||
</blockquote>
|
||||
@@ -156,12 +158,12 @@
|
||||
<h2><a name="3.8"></a>3.8. Tell me more about this verbatim input stuff!</h2>
|
||||
<blockquote><p>To use verbatim input, you must be using nano 1.3.1 or newer. When you want to insert a literal character into the file you're editing, such as a control character that nano usually treats as a command, first press <b>Meta-V</b> (if you're not at a prompt, you'll get the message "Verbatim Input"), then press the key(s) that generate the character you want.</p>
|
||||
<p>Alternatively, if you've enabled Unicode support (see section <a href="#5.3">5.3</a>), you can press <b>Meta-V</b> and then type a six-digit hexadecimal code (from 000000 to 10FFFF, case-insensitive), and the character with the corresponding value will be inserted instead. The prompt will change to "Unicode Input" when you do this.</p></blockquote>
|
||||
<h2><a name="3.9"></a>3.9. How do I make a .nanorc file that nano will read when I start it?</h2>
|
||||
<blockquote><p>It's not hard at all! But, your version of nano must not have been compiled with <b>--disable-nanorc</b>, and must be version 1.1.12 or newer (use nano -V to check your version and compiled features). Then simply copy the <b>nanorc.sample</b> that came with the nano source or your nano package (most likely in /usr/doc/nano) to .nanorc in your home directory. If you didn't get one, the syntax is simple. Flags are turned on and off by using the word <b>set</b> and the getopt_long flag for the feature, for example "set nowrap" or "set suspend".</p></blockquote>
|
||||
<h2><a name="3.9.1"></a>3.9. How about in Win32?</h2>
|
||||
<blockquote><p>If you're using the official nano .zip file and have extracted all the files, you should take the file nano.rc and place it somewhere on your Win32 system (for example if you have write permission to do so, at the top of C:\). Then you must create an Environment variable called HOME which points to the directory where you put nano.rc. In Windows XP, you can get to Environment variables by right-clicking "My Computer" either on the desktop or in the Start Menu, and selecting Properties. This should bring up the System Properties panel. Then click the Advanced Tab, and there should be a button called Environment Variables. Click that to bring up the Environment Variables section. Now, under User Variables you should be able to click the New button, and make a new Variables Name called HOME, with the Variable Value of whatever path you copied nano.rc into (just the directory name; don't add nano.rc onto the end).</p>
|
||||
<p>We're still working on documentation for enabling synax highlighting on Win32; please bear with us.</p>
|
||||
<p>Note that the nano.rc file must remain Unix-formated in order for nano to understand it. In other words, you should probably use only nano to edit its config file. Other programs like Wordpad and Notepad will convert the file to DOS format when saving, and the latter does not even properly read Unix-formatted files to begin with.</p></blockquote>
|
||||
<h2><a name="3.9a"></a>3.9a. How do I make a .nanorc file that nano will read when I start it?</h2>
|
||||
<blockquote><p>It's not hard at all! But, your version of nano must <b>not</b> have been compiled with <b>--disable-nanorc</b>, and must be version 1.1.12 or newer (use nano -V to check your version and compiled features). Then simply copy the <b>nanorc.sample</b> that came with the nano source or your nano package (most likely in /usr/doc/nano) to .nanorc in your home directory. If you didn't get one, the syntax is simple. Flags are turned on and off by using the words <b>set</b> and <b>unset</b> plus the long option name for the feature. For example, "set nowrap" or "set smarthome".</p></blockquote>
|
||||
<h2><a name="3.9b"></a>3.9b. How about in Win32?</h2>
|
||||
<blockquote><p>If you're using the official nano .zip file and have extracted all the files, you should take the file nano.rc and place it somewhere on your Win32 system (for example, if you have write permission to do so, at the top of C:\). Then you must create an Environment variable called HOME which points to the directory where you put nano.rc. In Windows XP, you can get to Environment variables by right-clicking "My Computer" either on the desktop or in the Start Menu, and selecting Properties. This should bring up the System Properties panel. Then click the Advanced Tab, and there should be a button called Environment Variables. Click that to bring up the Environment Variables section. Now, under User Variables you should be able to click the New button, and make a new Variables Name called HOME, with the Variable Value of whatever path you copied nano.rc into (just the directory name; don't add nano.rc onto the end).</p>
|
||||
<p>We're still working on documentation for enabling syntax highlighting on Win32; please bear with us.</p>
|
||||
<p>Note that the nano.rc file must remain Unix-formatted in order for nano to understand it. In other words, you should probably use only nano to edit its config file. Other programs like Wordpad and Notepad will convert the file to DOS format when saving, and the latter does not even properly read Unix-formatted files to begin with.</p></blockquote>
|
||||
<hr width="100%">
|
||||
<h1><a name="4"></a>4. Running</h1>
|
||||
<h2><a name="4.1"></a>4.1. How do I open a file with a name beginning with '+' from the command line?</h2>
|
||||
@@ -182,9 +184,9 @@
|
||||
<h2><a name="4.5"></a>4.5. How do I type the F13-F16 keys shown in the help browser? My keyboard only has F1-F12!</h2>
|
||||
<blockquote><p>It depends on the terminal type you're using. On some terminals, such as the FreeBSD console, xterm, konsole, and gnome-terminal, Shift-F1 to Shift-F4 will generate F13 to F16. On other terminals, such as the Linux console, rxvt, and Eterm, Shift-F3 to Shift-F6 will generate F13 to F16.</p></blockquote>
|
||||
<h2><a name="4.6"></a>4.6. nano crashes when I type <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 database</a> on Savannah.</p></blockquote>
|
||||
<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.2.6 is recommended).</p></blockquote>
|
||||
<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>
|
||||
<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>
|
||||
@@ -207,15 +209,15 @@
|
||||
<p><b>my_hdr X-Composer: nano x.y.z</b></p>
|
||||
<p>Again, replace x.y.z with the version of nano you use.</p></blockquote>
|
||||
<h2><a name="4.12"></a>4.12. I've compiled nano with color support, but I don't see any color when I run it!</h2>
|
||||
<blockquote><p>If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Several example configurations are in the <b>doc/syntax</b> subdirectory of the nano source, which are normally installed to <b>/usr/local/share/nano</b>. To enable all of them, uncomment the line <b># include "/usr/local/share/nano/*.nanorc"</b> in your nanorc. See also section <a href="#3.9">3.9</a>.</p></blockquote>
|
||||
<blockquote><p>If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Several example configurations are in the <b>doc/syntax</b> subdirectory of the nano source, which are normally installed to <b>/usr/local/share/nano</b>. To enable all of them, uncomment the line <b># include "/usr/local/share/nano/*.nanorc"</b> in your nanorc. See also section <a href="#3.9a">3.9a</a>.</p></blockquote>
|
||||
<h2><a name="4.13"></a>4.13. How do I select text for or paste text from the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?</h2>
|
||||
<blockquote><p>Try holding down the Shift key and selecting or pasting the text as you normally would.</p></blockquote>
|
||||
<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>
|
||||
mv ~/.nano/search_history ~/.nano_history<br>
|
||||
ln -sf ~/.nano_history ~/.nano/search_history<br>
|
||||
<p><b>mv ~/.nano/search_history ~/.nano_history</b><br>
|
||||
<b>ln -sf ~/.nano_history ~/.nano/search_history</b></p>
|
||||
</p></blockquote>
|
||||
<hr width="100%">
|
||||
<h1><a name="5"></a>5. Internationalization</h1>
|
||||
@@ -256,7 +258,9 @@ Of course, due to the license change you can now use the <A HREF="http://www.was
|
||||
<h2><a name="7.5"></a>7.5. Can I have write access to the subversion tree?</h2>
|
||||
<blockquote><p>Re-read Section <a href="#7.4">7.4</a> and you should know the answer.</p></blockquote>
|
||||
<h2><a name="8"></a>8. ChangeLog</h2>
|
||||
<blockquote><p>2014/04/24 - A bunch of small fixes and updates. (Benno)<br>
|
||||
<blockquote><p>
|
||||
2015/07/18 - More small fixes and updates. (Benno)<br>
|
||||
2014/04/24 - A bunch of small fixes and updates. (Benno)<br>
|
||||
2009/11/30 - Update various bits for nano 2.2.x. (DLR)<br>
|
||||
2009/11/18 - Typo fix. (j.mader@gmail.com)<br>
|
||||
2008/03/16 - Update docs to refer to subversion instead of CVS, add more words about Alpine, and refer to Savannah for bugs and patches. (chrisa)<br>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANO 1 "version 2.4.2" "June 2015"
|
||||
.TH NANO 1 "version 2.5.1" "January 2016"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
|
||||
@@ -115,9 +115,9 @@ Disable automatic conversion of files from DOS/Mac format.
|
||||
.BR \-O ", " \-\-morespace
|
||||
Use the blank line below the titlebar as extra editing space.
|
||||
.TP
|
||||
.BR \-P ", " \-\-poslog
|
||||
.BR \-P ", " \-\-positionlog
|
||||
Log and later read back the location of the cursor and place it there
|
||||
again.
|
||||
again. (The old form of this option, \fB\-\-poslog\fR, is deprecated.)
|
||||
.TP
|
||||
.BR "\-Q ""\fIcharacters\fB""" ", " "\-\-quotestr=""" \fIcharacters\fR """
|
||||
Set the quoting string for justifying. The default is
|
||||
@@ -157,7 +157,7 @@ characters as part of a word.
|
||||
Specify the name of the syntax highlighting to use from among the ones
|
||||
defined in the \fInanorc\fP files.
|
||||
.TP
|
||||
.BR \-c ", " \-\-const
|
||||
.BR \-c ", " \-\-constantshow
|
||||
Constantly show the cursor position. Note that this overrides \fB\-U\fP.
|
||||
.TP
|
||||
.BR \-d ", " \-\-rebinddelete
|
||||
@@ -222,6 +222,11 @@ Use this alternative spell checker command.
|
||||
Always save a changed buffer without prompting. Same as Pico's \fB\-t\fP
|
||||
option.
|
||||
.TP
|
||||
.BR \-u ", " \-\-unix
|
||||
Save a file by default in Unix format. This overrides nano's
|
||||
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.
|
||||
.TP
|
||||
@@ -270,12 +275,14 @@ it unique. In multibuffer mode, \fBnano\fP will write all the open
|
||||
buffers to their respective emergency files.
|
||||
|
||||
.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".
|
||||
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.
|
||||
|
||||
.SH HOMEPAGE
|
||||
http://www.nano-editor.org/
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANORC 5 "version 2.4.2" "June 2015"
|
||||
.TH NANORC 5 "version 2.5.1" "January 2016"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
.SH NAME
|
||||
@@ -90,8 +90,9 @@ closing brackets, can end sentences. The default value is "\fB"')>]}\fP".
|
||||
.B set casesensitive
|
||||
Do case-sensitive searches by default.
|
||||
.TP
|
||||
.B set const
|
||||
.B set constantshow
|
||||
Constantly display the cursor position in the status bar.
|
||||
(The old form of this option, '\fBset const\fR', is deprecated.)
|
||||
.TP
|
||||
.B set cut
|
||||
Use cut-to-end-of-line by default, instead of cutting the whole line.
|
||||
@@ -158,8 +159,9 @@ subdirectories. Also, the current directory is changed to here, so
|
||||
files are inserted from this directory. By default, the operating
|
||||
directory feature is turned off.
|
||||
.TP
|
||||
.B set poslog
|
||||
.B set positionlog
|
||||
Save the cursor position of files between editing sessions.
|
||||
(The old form of this option, '\fBset poslog\fR', is deprecated.)
|
||||
.TP
|
||||
.B set preserve
|
||||
Preserve the XON and XOFF keys (^Q and ^S).
|
||||
@@ -240,6 +242,11 @@ Valid color names for foreground and background are:
|
||||
.BR white , \ black , \ red , \ blue , \ green , \ yellow , \ magenta ", and " cyan .
|
||||
And either "\fIfgcolor\fR" or ",\fIbgcolor\fR" may be left out.
|
||||
.TP
|
||||
.B set unix
|
||||
Save a file by default in Unix format. This overrides nano's
|
||||
default behavior of saving a file in the format that it had.
|
||||
(This option has no effect when you also use \fBset noconvert\fR.)
|
||||
.TP
|
||||
.B set view
|
||||
Disallow file modification.
|
||||
.TP
|
||||
@@ -336,7 +343,7 @@ to an already defined syntax -- useful when you want to
|
||||
slightly improve a syntax defined in one of the system-installed
|
||||
files (which are normally not writable)
|
||||
.SH REBINDING KEYS
|
||||
Key bindings may be reassigned via the following commands:
|
||||
Key bindings can be changed via the following two commands:
|
||||
.TP
|
||||
.BI bind " key function menu"
|
||||
Rebinds the key \fIkey\fP to a new function named \fIfunction\fP in the
|
||||
@@ -365,7 +372,7 @@ Example: F10
|
||||
.RE
|
||||
|
||||
.TP
|
||||
Valid \fIfunction\fP names to be bound include:
|
||||
Valid \fIfunction\fP names to be bound are:
|
||||
.RS 3
|
||||
.TP 2
|
||||
.B help
|
||||
@@ -378,7 +385,10 @@ Cancels the current command.
|
||||
Exits from the program (or from the help viewer or the file browser).
|
||||
.TP
|
||||
.B writeout
|
||||
Writes the current buffer to disk.
|
||||
Writes the current buffer to disk, asking for a name.
|
||||
.TP
|
||||
.B savefile
|
||||
Writes the current file to disk without prompting or warning.
|
||||
.TP
|
||||
.B insert
|
||||
Inserts a file into the current buffer (at the current cursor position),
|
||||
@@ -389,7 +399,13 @@ Searches for text in the current buffer -- or for filenames matching
|
||||
a string in the current list in the file browser.
|
||||
.TP
|
||||
.B searchagain
|
||||
Repeats the last search command.
|
||||
Repeats the last search command without prompting.
|
||||
.TP
|
||||
.B findprevious
|
||||
As \fBsearchagain\fR, but always in the backward direction.
|
||||
.TP
|
||||
.B findnext
|
||||
As \fBsearchagain\fR, but always in the forward direction.
|
||||
.TP
|
||||
.B replace
|
||||
Interactively replaces text within the current buffer.
|
||||
@@ -407,6 +423,12 @@ current cursor position.
|
||||
.B mark
|
||||
Sets the mark at the current position, to start selecting text.
|
||||
.TP
|
||||
.B cutwordleft
|
||||
Cuts from the cursor position to the beginning of the preceding word.
|
||||
.TP
|
||||
.B cutwordright
|
||||
Cuts from the cursor position to the beginning of the next word.
|
||||
.TP
|
||||
.B cutrestoffile
|
||||
Cuts all text from the cursor position till the end of the buffer.
|
||||
.TP
|
||||
@@ -453,12 +475,12 @@ Scrolls up one line of text from the current position.
|
||||
.B scrolldown
|
||||
Scrolls down one line of text from the current position.
|
||||
.TP
|
||||
.B nextword
|
||||
Moves the cursor to the beginning of the next word.
|
||||
.TP
|
||||
.B prevword
|
||||
Moves the cursor to the beginning of the previous word.
|
||||
.TP
|
||||
.B nextword
|
||||
Moves the cursor to the beginning of the next word.
|
||||
.TP
|
||||
.B home
|
||||
Moves the cursor to the beginning of the current line.
|
||||
.TP
|
||||
@@ -552,13 +574,6 @@ Toggles between inserting a file and executing a command.
|
||||
Toggles between inserting into the current buffer and into a new
|
||||
empty buffer.
|
||||
.TP
|
||||
.B tofiles
|
||||
Starts the file browser, allowing to select a file from a list.
|
||||
.TP
|
||||
.B gotodir
|
||||
Goes to a directory to be specified, allowing to browse anywhere
|
||||
in the filesystem.
|
||||
.TP
|
||||
.B dosformat
|
||||
When writing a file, switches to writing a DOS format (CR/LF).
|
||||
.TP
|
||||
@@ -574,6 +589,18 @@ When writing a file, 'prepends' (writes at the beginning) instead of overwriting
|
||||
.B backup
|
||||
When writing a file, creates a backup of the current file.
|
||||
.TP
|
||||
.B discardbuffer
|
||||
When about to write a file, discard the current buffer without saving.
|
||||
(This function is bound by default only when option \fB\-\-tempfile\fR
|
||||
is in effect.)
|
||||
.TP
|
||||
.B tofiles
|
||||
Starts the file browser, allowing to select a file from a list.
|
||||
.TP
|
||||
.B gotodir
|
||||
Goes to a directory to be specified, allowing to browse anywhere
|
||||
in the filesystem.
|
||||
.TP
|
||||
.B firstfile
|
||||
Goes to the first file when using the file browser (reading or writing files).
|
||||
.TP
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH RNANO 1 "version 2.4.0" "March 2015"
|
||||
.TH RNANO 1 "version 2.5.1" "January 2016"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
.SH NAME
|
||||
|
||||
@@ -46,7 +46,8 @@
|
||||
|
||||
## Constantly display the cursor position in the statusbar. Note that
|
||||
## this overrides "quickblank".
|
||||
# set const
|
||||
# set constantshow
|
||||
## (The old form, 'const', is deprecated.)
|
||||
|
||||
## Use cut-to-end-of-line by default.
|
||||
# set cut
|
||||
@@ -104,7 +105,8 @@
|
||||
# set operatingdir ""
|
||||
|
||||
## Remember the cursor position in each file for the next editing session.
|
||||
# set poslog
|
||||
# set positionlog
|
||||
## (The old form, 'poslog', is deprecated.)
|
||||
|
||||
## Preserve the XON and XOFF keys (^Q and ^S).
|
||||
# set preserve
|
||||
@@ -235,13 +237,15 @@
|
||||
|
||||
|
||||
## Key bindings.
|
||||
## See nanorc(5) for more details on this.
|
||||
## See nanorc(5) (section REBINDING KEYS) for more details on this.
|
||||
##
|
||||
## Here are a few samples to get you going.
|
||||
##
|
||||
# bind M-W nowrap main
|
||||
# bind M-A casesens search
|
||||
# bind ^S research main
|
||||
## The following five functions are not bound to any key by default.
|
||||
## You may wish to choose different keys than the ones suggested here.
|
||||
# bind ^S savefile main
|
||||
# bind M-Q findprevious main
|
||||
# bind M-W findnext main
|
||||
# bind M-B cutwordleft main
|
||||
# bind M-N cutwordright main
|
||||
|
||||
## Set this if your backspace key sends Del most of the time.
|
||||
## Set this if your Backspace key sends Del most of the time.
|
||||
# bind Del backspace all
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
pkgdata_DATA = asm.nanorc \
|
||||
autoconf.nanorc \
|
||||
awk.nanorc \
|
||||
changelog.nanorc \
|
||||
cmake.nanorc \
|
||||
@@ -21,6 +22,7 @@ pkgdata_DATA = asm.nanorc \
|
||||
man.nanorc \
|
||||
mgp.nanorc \
|
||||
mutt.nanorc \
|
||||
nftables.nanorc \
|
||||
nanorc.nanorc \
|
||||
objc.nanorc \
|
||||
ocaml.nanorc \
|
||||
|
||||
@@ -12,8 +12,9 @@ color brightcyan "^[[:space:]]*#[[:space:]]*(define|undef|include|ifn?def|endif|
|
||||
|
||||
# Strings.
|
||||
color brightyellow "<[^= ]*>" ""(\\.|[^"])*""
|
||||
# Multiline strings (note: VERY resource intensive).
|
||||
color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
|
||||
# Multiline strings. This regex is VERY resource intensive,
|
||||
# and sometimes colours things that shouldn't be coloured.
|
||||
###color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
|
||||
|
||||
# Comments.
|
||||
color brightblue "//.*"
|
||||
|
||||
31
doc/syntax/autoconf.nanorc
Normal file
31
doc/syntax/autoconf.nanorc
Normal file
@@ -0,0 +1,31 @@
|
||||
## Here is an example for Autoconf.
|
||||
|
||||
syntax "autoconf" "\.(ac|m4)$"
|
||||
|
||||
# Keywords:
|
||||
color yellow "\<(if|test|then|elif|else|fi|for|in|do|done)\>"
|
||||
color yellow "(=|!=|&&|\|\|)"
|
||||
|
||||
# Macros:
|
||||
color cyan "\<[[:upper:]_[:digit:]]+\>"
|
||||
|
||||
# Version numbers:
|
||||
color red "\<[-_.0-9]+\>"
|
||||
|
||||
# Strings:
|
||||
color red "\"[^"]*\"" "\'[^']*\'"
|
||||
|
||||
# Backticks:
|
||||
color green "`[^`]*`"
|
||||
|
||||
# Error lines:
|
||||
color black "^\*\*\*.*"
|
||||
|
||||
# Brackets:
|
||||
color magenta "\[|\]|\(|\)"
|
||||
|
||||
# Comments:
|
||||
color blue "^[[:blank:]]*#.*" "\<dnl.*"
|
||||
|
||||
# Trailing whitespace:
|
||||
color ,green "[[:space:]]+$"
|
||||
@@ -19,8 +19,9 @@ color cyan "__attribute__[[:space:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidd
|
||||
# Strings. In general you will want your strings and comments to come last,
|
||||
# because highlighting rules are applied in the order they are read in.
|
||||
color brightyellow "<[^= ]*>" ""(\\.|[^"])*""
|
||||
# Multiline strings. This regex is VERY resource intensive!
|
||||
color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
|
||||
# Multiline strings. This regex is VERY resource intensive,
|
||||
# and sometimes colours things that shouldn't be coloured.
|
||||
###color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
|
||||
|
||||
# Comments.
|
||||
color brightblue "//.*"
|
||||
|
||||
@@ -12,7 +12,7 @@ color yellow "<[^>]*@[^>]*>"
|
||||
# Command-line options.
|
||||
color cyan "[[:space:]]-[a-zA-Z\$]" "--[8a-z-]+"
|
||||
# Bug and patch numbers.
|
||||
color cyan "bug #[0-9]{5,6}" "patch #[0-9]{4,5}"
|
||||
color cyan "bug #[0-9]{5,9}" "patch #[0-9]{4,9}"
|
||||
# Probable constants, for variety.
|
||||
color brightred "\<[A-Z_][0-9A-Z_]+\>"
|
||||
# Key sequences.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## Here is an example for Makefiles.
|
||||
|
||||
syntax "makefile" "Makefile[^/]*$"
|
||||
syntax "makefile" "Makefile[^/]*$" "\.(make|mk)$"
|
||||
|
||||
color red "[:=]"
|
||||
color magenta "\<(if|ifeq|else|endif)\>"
|
||||
|
||||
@@ -6,7 +6,7 @@ syntax "nanorc" "\.?nanorc$"
|
||||
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|linter|i?color|extendsyntax).*$"
|
||||
|
||||
# Keywords
|
||||
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|const|cut|fill|historylog|locking|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|poslog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|suspend|tabsize|tabstospaces|tempfile|view|wordbounds)\>"
|
||||
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|const(antshow)?|cut|fill|historylog|locking|morespace|mouse|multibuffer|noconvert|nofollow|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:]]*$"
|
||||
|
||||
29
doc/syntax/nftables.nanorc
Normal file
29
doc/syntax/nftables.nanorc
Normal file
@@ -0,0 +1,29 @@
|
||||
## Here is an example for nftables.
|
||||
|
||||
syntax "nftables" "\.(nft|nftables)$"
|
||||
header "^#!.*(nft|nftables)"
|
||||
|
||||
# Objects and operations
|
||||
color green "\<(chain|hook|policy|priority|ruleset|set|table|type|v?map)\>"
|
||||
color green "\<(define|include)\>"
|
||||
color red "\<(add|delete|flush|insert|remove|replace)\>"
|
||||
|
||||
# Families
|
||||
color yellow "\<(arp|bridge|inet|ip6?)\>"
|
||||
|
||||
# Terminal statements
|
||||
color red "\<(drop|reject)\>"
|
||||
color brightblue "\<(accept|continue|(d|s)nat|goto|jump|masquerade|return)\>"
|
||||
|
||||
# Comments
|
||||
color cyan "(^|[[:space:]])#.*$"
|
||||
|
||||
# Trailing whitespace
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
# Strings and others
|
||||
color yellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"
|
||||
color green "[{}():;|`$<>!=&\\]" "(\]|\[)"
|
||||
|
||||
# Basic variable names
|
||||
color brightred "\$[[:alpha:]_][[:alnum:]_.]*"
|
||||
@@ -25,8 +25,9 @@ color white "\[[^][:space:]]*\]"
|
||||
color brightblack "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
|
||||
color brightblack "<[^= ]*>" ""(\\.|[^"])*""
|
||||
color brightblue "@"(\\.|[^"])*""
|
||||
# Multiline strings. This regex is VERY resource intensive!
|
||||
## color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
|
||||
# Multiline strings. This regex is VERY resource intensive,
|
||||
# and sometimes colours things that shouldn't be coloured.
|
||||
###color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
|
||||
|
||||
# Preprocessor commands.
|
||||
color brightblue "^[[:space:]]*#[[:space:]]*(define|include|import|(un|ifn?)def|endif|el(if|se)|if|warning|error)"
|
||||
|
||||
@@ -2,27 +2,27 @@
|
||||
|
||||
syntax "ocaml" "\.mli?$"
|
||||
|
||||
#uid
|
||||
# Uid:
|
||||
color red "\<[A-Z][0-9a-z_]{2,}\>"
|
||||
#declarations
|
||||
# Declarations:
|
||||
color green "\<(let|val|method|in|and|rec|private|virtual|constraint)\>"
|
||||
#structure items
|
||||
# Structure items:
|
||||
color red "\<(type|open|class|module|exception|external)\>"
|
||||
#patterns
|
||||
# Patterns:
|
||||
color blue "\<(fun|function|functor|match|try|with)\>"
|
||||
#patterns-modifiers
|
||||
# Pattern modifiers:
|
||||
color yellow "\<(as|when|of)\>"
|
||||
#conditions
|
||||
# Conditions:
|
||||
color cyan "\<(if|then|else)\>"
|
||||
#blocs
|
||||
# Blocks:
|
||||
color magenta "\<(begin|end|object|struct|sig|for|while|do|done|to|downto)\>"
|
||||
#constantes
|
||||
# Constants:
|
||||
color green "\<(true|false)\>"
|
||||
#modules/classes
|
||||
# Modules/classes:
|
||||
color green "\<(include|inherit|initializer)\>"
|
||||
#expr modifiers
|
||||
# Expression modifiers:
|
||||
color yellow "\<(new|ref|mutable|lazy|assert|raise)\>"
|
||||
#comments
|
||||
# Comments:
|
||||
color white start="\(\*" end="\*\)"
|
||||
#strings (no multiline handling yet)
|
||||
# Strings: (no multiline handling yet)
|
||||
color brightblack ""[^\"]*""
|
||||
|
||||
@@ -10,14 +10,14 @@ icolor brightblue "def [0-9A-Z_]+"
|
||||
color brightcyan "\<(and|as|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from)\>"
|
||||
color brightcyan "\<(global|if|import|in|is|lambda|not|or|pass|print|raise|return|try|while|with|yield)\>"
|
||||
|
||||
# Strings.
|
||||
color brightgreen "['][^']*[^\\][']" "[']{3}.*[^\\][']{3}"
|
||||
color brightgreen "["][^"]*[^\\]["]" "["]{3}.*[^\\]["]{3}"
|
||||
# Single-quoted strings.
|
||||
color brightgreen "'([^'\]|\\.)+'"
|
||||
color brightgreen ""([^"\]|\\.)+""
|
||||
# Comments.
|
||||
color brightred "(^|[[:blank:]])#.*$"
|
||||
# Multiline strings.
|
||||
color brightgreen start="\"\"\"[^"),]" end="(^|[^(])\"\"\""
|
||||
color brightgreen start="'''[^'),]" end="(^|[^(])'''"
|
||||
# Triple-quoted strings.
|
||||
color brightgreen start="'''[^'),]" end="(^|[^(\])'''"
|
||||
color brightgreen start="\"\"\"[^"),]" end="(^|[^(\])\"\"\""
|
||||
|
||||
# Reminders.
|
||||
color ,yellow "(FIXME|TODO|XXX)"
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
@smallbook
|
||||
@set EDITION 0.3
|
||||
@set VERSION 2.4.2
|
||||
@set UPDATED June 2015
|
||||
@set VERSION 2.5.1
|
||||
@set UPDATED December 2015
|
||||
|
||||
@dircategory Editors
|
||||
@direntry
|
||||
@@ -21,7 +21,7 @@
|
||||
@titlepage
|
||||
@title GNU @code{nano}
|
||||
@subtitle a small and friendly text editor.
|
||||
@subtitle version 2.4.2
|
||||
@subtitle version 2.5.1
|
||||
|
||||
@author Chris Allegretta
|
||||
@page
|
||||
@@ -109,9 +109,9 @@ adding it with a comma. So the complete command synopsis is:
|
||||
@end quotation
|
||||
|
||||
But normallly you would set your preferred options in your
|
||||
@file{.nanorc} file. And when the @code{poslog} option is set
|
||||
(making @code{nano} remember the cursor position), you will rarely
|
||||
need to specify a line number.
|
||||
@file{.nanorc} file. And when the @code{positionlog} option is set
|
||||
(making @code{nano} remember the cursor position when you close a file),
|
||||
you will rarely need to specify a line number.
|
||||
|
||||
@node Command-line Options
|
||||
@chapter Command-line Options
|
||||
@@ -135,7 +135,7 @@ line.
|
||||
@item -B
|
||||
@itemx --backup
|
||||
When saving a file, back up the previous version of it, using the current
|
||||
filename suffixed with a tilde (@samp{~}).
|
||||
filename suffixed with a tilde (@code{~}).
|
||||
|
||||
@item -C @var{directory}
|
||||
@itemx --backupdir=@var{directory}
|
||||
@@ -187,20 +187,17 @@ Disable automatic conversion of files from DOS/Mac format.
|
||||
Use the blank line below the titlebar as extra editing space.
|
||||
|
||||
@item -P
|
||||
@itemx --poslog
|
||||
@itemx --positionlog
|
||||
Log for each file the last location of the cursor, and read it
|
||||
back upon reopening the file and place it there again.
|
||||
(The old form of this option, @code{--poslog}, is deprecated.)
|
||||
|
||||
@item -Q "@var{characters}"
|
||||
@itemx --quotestr="@var{characters}"
|
||||
Set the quoting string for justifying. The default value is
|
||||
|
||||
@quotation
|
||||
"^([ \t]*[|>:@}#])+"
|
||||
@end quotation
|
||||
|
||||
if extended regular expression support is available, or @code{> } otherwise.
|
||||
Note that @code{\t} above stands for a literal Tab character.
|
||||
@t{"^([ \t]*[|>:@}#])+"} if extended regular expression support
|
||||
is available, and @t{"> "} otherwise.
|
||||
Note that @code{\t} stands for a literal Tab character.
|
||||
|
||||
@item -R
|
||||
@itemx --restricted
|
||||
@@ -210,7 +207,7 @@ suspending nor spell checking; don't
|
||||
allow a file to be appended to, prepended to, or saved under a different
|
||||
name if it already has one; and don't use backup files.
|
||||
This restricted mode is also accessible by invoking @command{nano} with
|
||||
any name beginning with @samp{r} (e.g. @command{rnano}).
|
||||
any name beginning with @code{r} (e.g.@: @command{rnano}).
|
||||
|
||||
@item -S
|
||||
@itemx --smooth
|
||||
@@ -220,12 +217,13 @@ usual chunk-by-chunk behavior.
|
||||
@item -T @var{number}
|
||||
@itemx --tabsize=@var{number}
|
||||
Set the displayed tab length to @var{number} columns. The value of
|
||||
@var{number} must be greater than 0. The default value is @samp{8}.
|
||||
@var{number} must be greater than 0. The default value is @t{8}.
|
||||
|
||||
@item -U
|
||||
@itemx --quickblank
|
||||
Do quick statusbar blanking. Statusbar messages will disappear after 1
|
||||
keystroke instead of 25. Note that @option{-c} overrides this.
|
||||
keystroke instead of 25. Note that option @option{-c}
|
||||
(@option{--constantshow}) overrides this.
|
||||
|
||||
@item -V
|
||||
@itemx --version
|
||||
@@ -242,9 +240,9 @@ Specify a specific syntax from the nanorc files to use for highlighting.
|
||||
See @xref{Syntax Highlighting}, for more info.
|
||||
|
||||
@item -c
|
||||
@itemx --const
|
||||
@itemx --constantshow
|
||||
Constantly display the cursor position and line number on the statusbar.
|
||||
Note that this overrides @option{-U}.
|
||||
Note that this overrides option @option{-U} (@option{--quickblank}).
|
||||
|
||||
@item -d
|
||||
@itemx --rebinddelete
|
||||
@@ -308,8 +306,8 @@ Hard-wrap lines at column @var{number} (by inserting a newline character).
|
||||
If the given value is 0 or less, wrapping will occur at the width of
|
||||
the screen minus the given amount, allowing the wrapping width to
|
||||
vary along with the width of the screen if and when it is resized.
|
||||
The default value is @samp{-8}. This option conflicts with @option{-w}
|
||||
-- the last one given takes effect.
|
||||
The default value is @t{-8}. This option conflicts with @option{-w}
|
||||
(@option{--nowrap}); the last one given takes effect.
|
||||
|
||||
@item -s @var{program}
|
||||
@itemx --speller=@var{program}
|
||||
@@ -324,6 +322,12 @@ 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
|
||||
composer of a mailer program.
|
||||
|
||||
@item -u
|
||||
@item --unix
|
||||
Save a file by default in Unix format. This overrides nano's
|
||||
default behavior of saving a file in the format that it had.
|
||||
(This option has no effect when you also use @code{--noconvert}.)
|
||||
|
||||
@item -v
|
||||
@itemx --view
|
||||
Don't allow the contents of the file to be altered. Note that this
|
||||
@@ -333,7 +337,7 @@ implement a read-only file.
|
||||
@item -w
|
||||
@itemx --nowrap
|
||||
Don't hard-wrap long lines at any length. This option conflicts with
|
||||
@option{-r} --- the last one given takes effect.
|
||||
@option{-r} (@option{--fill}); the last one given takes effect.
|
||||
|
||||
@anchor{Expert Mode}
|
||||
@item -x
|
||||
@@ -355,9 +359,9 @@ keystroke (usually ^Z).
|
||||
Enable 'soft wrapping'. This will make @command{nano} attempt to display the
|
||||
entire contents of any line, even if it is longer than the screen width, by
|
||||
continuing it over multiple screen lines. Since
|
||||
@samp{$} normally refers to a variable in the Unix shell, you should specify
|
||||
this option last when using other options (e.g. @code{nano -wS$}) or pass it
|
||||
separately (e.g. @code{nano -wS -$}).
|
||||
@code{$} normally refers to a variable in the Unix shell, you should specify
|
||||
this option last when using other options (e.g.@: @code{nano -wS$}) or pass it
|
||||
separately (e.g.@: @code{nano -wS -$}).
|
||||
|
||||
@item -a
|
||||
@itemx -b
|
||||
@@ -382,6 +386,7 @@ Ignored, for compatibility with Pico.
|
||||
* The Statusbar::
|
||||
* Shortcut Lists::
|
||||
* Using the Mouse::
|
||||
* Limitation::
|
||||
@end menu
|
||||
|
||||
@node Entering Text
|
||||
@@ -486,11 +491,20 @@ Shift key during those actions.
|
||||
The mouse will work in the X Window System, and on the console when gpm
|
||||
is running.
|
||||
|
||||
@node Limitation
|
||||
@section Limitation
|
||||
|
||||
Justifications (@code{^J}) and reindentations (@code{M-@{} and @code{M-@}})
|
||||
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.
|
||||
|
||||
|
||||
@node Built-in Help
|
||||
@chapter Built-in Help
|
||||
|
||||
The built-in help system in @code{nano} is available by pressing ^G.
|
||||
The built-in help system in @code{nano} is available by pressing ^G@.
|
||||
It is fairly self-explanatory. It documents the various parts of the
|
||||
editor and the available keystrokes. Navigation is via the ^Y (Page Up)
|
||||
and ^V (Page Down) keys. ^X exits the help system.
|
||||
@@ -507,57 +521,57 @@ The following global toggles are available:
|
||||
@table @code
|
||||
|
||||
@item Backup Files Toggle (Meta-B)
|
||||
toggles the -B (@code{--backup}) command-line option.
|
||||
toggles the @code{-B} (@code{--backup}) command-line option.
|
||||
|
||||
@item Constant Cursor Position Display Toggle (Meta-C)
|
||||
toggles the -c (@code{--const}) command-line option.
|
||||
toggles the @code{-c} (@code{--constantshow}) command-line option.
|
||||
|
||||
@item Multiple File Buffers Toggle (Meta-F)
|
||||
toggles the -F (@code{--multibuffer}) command-line option.
|
||||
toggles the @code{-F} (@code{--multibuffer}) command-line option.
|
||||
|
||||
@item Smart Home Key Toggle (Meta-H)
|
||||
toggles the -A (@code{--smarthome}) command-line option.
|
||||
toggles the @code{-A} (@code{--smarthome}) command-line option.
|
||||
|
||||
@item Auto Indent Toggle (Meta-I)
|
||||
toggles the -i (@code{--autoindent}) command-line option.
|
||||
toggles the @code{-i} (@code{--autoindent}) command-line option.
|
||||
|
||||
@item Cut To End Toggle (Meta-K)
|
||||
toggles the -k (@code{--cut}) command-line option.
|
||||
toggles the @code{-k} (@code{--cut}) command-line option.
|
||||
|
||||
@item Long Line Wrapping Toggle (Meta-L)
|
||||
toggles the -w (@code{--nowrap}) command-line option.
|
||||
toggles the @code{-w} (@code{--nowrap}) command-line option.
|
||||
|
||||
@item Mouse Support Toggle (Meta-M)
|
||||
toggles the -m (@code{--mouse}) command-line option.
|
||||
toggles the @code{-m} (@code{--mouse}) command-line option.
|
||||
|
||||
@item No Conversion From DOS/Mac Format Toggle (Meta-N)
|
||||
toggles the -N (@code{--noconvert}) command-line option.
|
||||
toggles the @code{-N} (@code{--noconvert}) command-line option.
|
||||
|
||||
@item More Space For Editing Toggle (Meta-O)
|
||||
toggles the -O (@code{--morespace}) command-line option.
|
||||
toggles the @code{-O} (@code{--morespace}) command-line option.
|
||||
|
||||
@item Whitespace Display Toggle (Meta-P)
|
||||
toggles the whitespace-display mode.
|
||||
See @xref{Whitespace}, for more info.
|
||||
|
||||
@item Tabs to Spaces Toggle (Meta-Q)
|
||||
toggles the -E (@code{--tabstospaces}) command-line option.
|
||||
toggles the @code{-E} (@code{--tabstospaces}) command-line option.
|
||||
|
||||
@item Smooth Scrolling Toggle (Meta-S)
|
||||
toggles the -S (@code{--smooth}) command-line option.
|
||||
toggles the @code{-S} (@code{--smooth}) command-line option.
|
||||
|
||||
@item Expert/No Help Toggle (Meta-X)
|
||||
toggles the -x (@code{--nohelp}) command-line option.
|
||||
toggles the @code{-x} (@code{--nohelp}) command-line option.
|
||||
|
||||
@item Color Syntax Highlighting Toggle (Meta-Y)
|
||||
toggles color syntax highlighting if you have color syntaxes in your
|
||||
nanorc. See @xref{Syntax Highlighting}, for more info.
|
||||
|
||||
@item Suspend Toggle (Meta-Z)
|
||||
toggles the -z (@code{--suspend}) command-line option.
|
||||
@item Suspension Toggle (Meta-Z)
|
||||
toggles the @code{-z} (@code{--suspend}) command-line option.
|
||||
|
||||
@item Soft Wrapping Toggle (Meta-$)
|
||||
toggles the -$ (@code{--softwrap}) command-line option.
|
||||
toggles the @code{-$} (@code{--softwrap}) command-line option.
|
||||
|
||||
@end table
|
||||
|
||||
@@ -569,7 +583,7 @@ The nanorc files contain the default settings for @code{nano}. They
|
||||
should be in Unix format, not in DOS or Mac format. During startup,
|
||||
@code{nano} will first read the system-wide settings, from /etc/nanorc
|
||||
(the exact path might be different), and then the user-specific settings,
|
||||
from ~/.nanorc.
|
||||
from @file{~/.nanorc}.
|
||||
|
||||
A nanorc file accepts a series of "set" and "unset" commands, which can
|
||||
be used to configure @code{nano} on startup without using command-line
|
||||
@@ -586,7 +600,7 @@ be unset.
|
||||
|
||||
Quotes inside string parameters don't have to be escaped with
|
||||
backslashes. The last double quote in the string will be treated as its
|
||||
end. For example, for the "brackets" option, @code{""')>]@}"} will match
|
||||
end. For example, for the @code{brackets} option, @t{""')>]@}"} will match
|
||||
@code{"}, @code{'}, @code{)}, @code{>}, @code{]}, and @code{@}}.
|
||||
|
||||
@menu
|
||||
@@ -626,23 +640,21 @@ Do backwards searches by default.
|
||||
@item set boldtext
|
||||
Use bold instead of reverse video for the titlebar, statusbar, key combos,
|
||||
and selected text. This can be overridden for the first three by setting
|
||||
the options "titlecolor", "statuscolor", and "keycolor".
|
||||
the options @code{titlecolor}, @code{statuscolor}, and @code{keycolor}.
|
||||
|
||||
@item set brackets "@var{string}"
|
||||
Set the characters treated as closing brackets when justifying
|
||||
paragraphs. This may not include blank characters. Only closing
|
||||
punctuation (see "punct"), optionally followed by the specified
|
||||
punctuation (see @code{set punct}), optionally followed by the specified
|
||||
closing brackets, can end sentences. The default value is
|
||||
|
||||
@quotation
|
||||
""')>]@}"
|
||||
@end quotation
|
||||
@t{"')>]@}"}.
|
||||
|
||||
@item set casesensitive
|
||||
Do case-sensitive searches by default.
|
||||
|
||||
@item set const
|
||||
@item set constantshow
|
||||
Constantly display the cursor position in the status bar.
|
||||
(The old form of this option, @code{set const}, is deprecated.)
|
||||
|
||||
@item set cut
|
||||
Use cut-to-end-of-line by default, instead of cutting the whole line.
|
||||
@@ -650,7 +662,7 @@ Use cut-to-end-of-line by default, instead of cutting the whole line.
|
||||
@item set fill @var{number}
|
||||
Hard-wrap lines at column number @var{number}. If @var{number} is 0 or less,
|
||||
the maximum line length will be the screen width less @var{number} columns.
|
||||
The default value is -8.
|
||||
The default value is @t{-8}.
|
||||
|
||||
@item set functioncolor @var{fgcolor},@var{bgcolor}
|
||||
Specify the color combination to use for the function descriptions
|
||||
@@ -673,11 +685,7 @@ Enable vim-style lock-files for when editing files.
|
||||
Set the opening and closing brackets that can be found by bracket
|
||||
searches. This may not include blank characters. The opening set must
|
||||
come before the closing set, and the two sets must be in the same order.
|
||||
The default value is
|
||||
|
||||
@quotation
|
||||
"(<[@{)>]@}"
|
||||
@end quotation
|
||||
The default value is @t{"(<[@{)>]@}"}.
|
||||
|
||||
@item set morespace
|
||||
Use the blank line below the titlebar as extra editing space.
|
||||
@@ -710,8 +718,9 @@ subdirectories. Also, the current directory is changed to here, so
|
||||
files are inserted from this directory. By default, the operating
|
||||
directory feature is turned off.
|
||||
|
||||
@item set poslog
|
||||
@item set positionlog
|
||||
Save the cursor position of files between editing sessions.
|
||||
(The old form of this option, @code{set poslog}, is deprecated.)
|
||||
|
||||
@item set preserve
|
||||
Preserve the XON and XOFF keys (^Q and ^S).
|
||||
@@ -720,7 +729,8 @@ Preserve the XON and XOFF keys (^Q and ^S).
|
||||
Set the characters treated as closing punctuation when justifying
|
||||
paragraphs. This may not include blank characters. Only the
|
||||
specified closing punctuation, optionally followed by closing brackets
|
||||
(see "brackets"), can end sentences. The default value is "!.?".
|
||||
(see @code{set brackets}), can end sentences.
|
||||
The default value is @t{"!.?"}.
|
||||
|
||||
@item set quickblank
|
||||
Do quick statusbar blanking. Statusbar messages will disappear after 1
|
||||
@@ -735,13 +745,9 @@ should be placed at the top of the file to be fully effective.
|
||||
The email-quote string, used to justify email-quoted paragraphs. This
|
||||
is an extended regular expression if your system supports them,
|
||||
otherwise a literal string. The default value is
|
||||
|
||||
@quotation
|
||||
"^([ \\t]*[#:>\\|@}])+"
|
||||
@end quotation
|
||||
|
||||
if you have extended regular expression support, and "> " otherwise.
|
||||
Note that '\\t' stands for a literal Tab character.
|
||||
@t{"^([ \\t]*[#:>\\|@}])+"} if you have extended regular expression
|
||||
support, and @t{"> "} otherwise.
|
||||
Note that @code{\t} stands for a literal Tab character.
|
||||
|
||||
@item set rebinddelete
|
||||
Interpret the Delete key differently so that both Backspace and Delete
|
||||
@@ -782,7 +788,7 @@ Allow @code{nano} to be suspended.
|
||||
|
||||
@item set tabsize @var{number}
|
||||
Use a tab size of @var{number} columns. The value of @var{number} must be
|
||||
greater than 0. The default value is 8.
|
||||
greater than 0. The default value is @t{8}.
|
||||
|
||||
@item set tabstospaces
|
||||
Convert typed tabs to spaces.
|
||||
@@ -796,6 +802,11 @@ Valid color names for foreground and background are:
|
||||
white, black, red, blue, green, yellow, magenta, and cyan.
|
||||
And either @var{fgcolor} or @var{,bgcolor} may be left out.
|
||||
|
||||
@item set unix
|
||||
Save a file by default in Unix format. This overrides nano's
|
||||
default behavior of saving a file in the format that it had.
|
||||
(This option has no effect when you also use @code{set noconvert}.)
|
||||
|
||||
@item set view
|
||||
Disallow file modification.
|
||||
|
||||
@@ -803,7 +814,7 @@ Disallow file modification.
|
||||
@item set whitespace "@var{string}"
|
||||
Set the two characters used to indicate the presence of tabs and
|
||||
spaces. They must be single-column characters. The default pair
|
||||
for a UTF-8 locale is "»·", and for other locales ">.".
|
||||
for a UTF-8 locale is @t{"»·"}, and for other locales @t{">."}.
|
||||
|
||||
@item set wordbounds
|
||||
Detect word boundaries more accurately by treating punctuation
|
||||
@@ -845,7 +856,7 @@ Use the given program to do a syntax check on the current file
|
||||
|
||||
@item formatter program [arg @dots{}]
|
||||
Use the given program to automatically reformat text.
|
||||
Useful in certain programming languages (e.g. Go).
|
||||
Useful in certain programming languages (e.g.@: Go).
|
||||
|
||||
@item header "regex" @dots{}
|
||||
Add one or more regexes which will
|
||||
@@ -900,7 +911,7 @@ in one of the system-installed files (which are normally not writable).
|
||||
@node Rebinding Keys
|
||||
@section Rebinding Keys
|
||||
|
||||
Key bindings may be reassigned via the following two commands in a
|
||||
Key bindings can be changed via the following two commands in a
|
||||
nanorc file:
|
||||
|
||||
@table @code
|
||||
@@ -947,7 +958,10 @@ Cancels the current command.
|
||||
Exits from the program (or from the help viewer or the file browser).
|
||||
|
||||
@item writeout
|
||||
Writes the current buffer to disk.
|
||||
Writes the current buffer to disk, asking for a name.
|
||||
|
||||
@item savefile
|
||||
Writes the current file to disk without prompting or warning.
|
||||
|
||||
@item insert
|
||||
Inserts a file into the current buffer (at the current cursor position),
|
||||
@@ -958,7 +972,13 @@ Searches for text in the current buffer --- or for filenames matching
|
||||
a string in the current list in the file browser
|
||||
|
||||
@item searchagain
|
||||
Repeats the last search command.
|
||||
Repeats the last search command without prompting.
|
||||
|
||||
@item findprevious
|
||||
As @code{searchagain}, but always in the backward direction.
|
||||
|
||||
@item findnext
|
||||
As @code{searchagain}, but always in the forward direction.
|
||||
|
||||
@item replace
|
||||
Interactively replaces text within the current buffer.
|
||||
@@ -976,6 +996,12 @@ current cursor position.
|
||||
@item mark
|
||||
Sets the mark at the current position, to start selecting text.
|
||||
|
||||
@item cutwordleft
|
||||
Cuts from the cursor position to the beginning of the preceding word.
|
||||
|
||||
@item cutwordright
|
||||
Cuts from the cursor position to the beginning of the next word.
|
||||
|
||||
@item cutrestoffile
|
||||
Cuts all text from the cursor position till the end of the buffer.
|
||||
|
||||
@@ -1019,12 +1045,12 @@ Scrolls up one line of text from the current position.
|
||||
@item scrolldown
|
||||
Scrolls down one line of text from the current position.
|
||||
|
||||
@item nextword
|
||||
Moves the cursor to the beginning of the next word.
|
||||
|
||||
@item prevword
|
||||
Moves the cursor to the beginning of the previous word.
|
||||
|
||||
@item nextword
|
||||
Moves the cursor to the beginning of the next word.
|
||||
|
||||
@item home
|
||||
Moves the cursor to the beginning of the current line.
|
||||
|
||||
@@ -1103,10 +1129,10 @@ Toggles whether searching/replacing is based on literal strings or regular expre
|
||||
Toggles whether searching/replacing goes forward or backward.
|
||||
|
||||
@item prevhistory
|
||||
Shows the previous history entry in the prompt menus (e.g. search).
|
||||
Shows the previous history entry in the prompt menus (e.g.@: search).
|
||||
|
||||
@item nexthistory
|
||||
Shows the next history entry in the prompt menus (e.g. search).
|
||||
Shows the next history entry in the prompt menus (e.g.@: search).
|
||||
|
||||
@item flipreplace
|
||||
Toggles between searching for something and replacing something.
|
||||
@@ -1133,6 +1159,11 @@ When writing a file, 'prepends' (writes at the beginning) instead of overwriting
|
||||
@item backup
|
||||
When writing a file, creates a backup of the current file.
|
||||
|
||||
@item discardbuffer
|
||||
When about to write a file, discard the current buffer without saving.
|
||||
(This function is bound by default only when option @option{--tempfile}
|
||||
is in effect.)
|
||||
|
||||
@item tofiles
|
||||
Starts the file browser, allowing to select a file from a list.
|
||||
|
||||
|
||||
1133
po/nano.pot
1133
po/nano.pot
File diff suppressed because it is too large
Load Diff
1116
po/pt_BR.po
1116
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
1103
po/zh_CN.po
1103
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
1088
po/zh_TW.po
1088
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "proto.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
@@ -157,7 +158,7 @@ char *do_browser(char *path, DIR *dir)
|
||||
/* If we selected the same filename as last time,
|
||||
* put back the Enter key so that it's read in. */
|
||||
if (old_selected == selected)
|
||||
unget_kbinput(sc_seq_or(do_enter_void, 0), FALSE, FALSE);
|
||||
unget_kbinput(sc_seq_or(do_enter, 0), FALSE, FALSE);
|
||||
}
|
||||
}
|
||||
#endif /* !DISABLE_MOUSE */
|
||||
@@ -173,7 +174,7 @@ char *do_browser(char *path, DIR *dir)
|
||||
browser_refresh();
|
||||
curs_set(0);
|
||||
#else
|
||||
nano_disabled_msg();
|
||||
say_there_is_no_help();
|
||||
#endif
|
||||
} else if (func == do_search) {
|
||||
/* Search for a filename. */
|
||||
@@ -284,7 +285,7 @@ char *do_browser(char *path, DIR *dir)
|
||||
} else if (func == do_right) {
|
||||
if (selected < filelist_len - 1)
|
||||
selected++;
|
||||
} else if (func == do_enter_void) {
|
||||
} else if (func == do_enter) {
|
||||
/* We can't move up from "/". */
|
||||
if (strcmp(filelist[selected], "/..") == 0) {
|
||||
statusbar(_("Can't move up a directory"));
|
||||
@@ -435,31 +436,31 @@ void browser_init(const char *path, DIR *dir)
|
||||
|
||||
assert(path != NULL && path[strlen(path) - 1] == '/' && dir != NULL);
|
||||
|
||||
/* Set longest to zero, just before we initialize it. */
|
||||
longest = 0;
|
||||
|
||||
/* Find the length of the longest filename in the current folder. */
|
||||
while ((nextdir = readdir(dir)) != NULL) {
|
||||
size_t d_len;
|
||||
size_t name_len = strlenpt(nextdir->d_name);
|
||||
|
||||
/* Don't show the "." entry. */
|
||||
if (strcmp(nextdir->d_name, ".") == 0)
|
||||
continue;
|
||||
|
||||
d_len = strlenpt(nextdir->d_name);
|
||||
if (d_len > longest)
|
||||
longest = (d_len > COLS) ? COLS : d_len;
|
||||
if (name_len > longest)
|
||||
longest = name_len;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
rewinddir(dir);
|
||||
|
||||
/* Put 10 columns' worth of blank space between columns of filenames
|
||||
/* Put 10 characters' worth of blank space between columns of filenames
|
||||
* in the list whenever possible, as Pico does. */
|
||||
longest += 10;
|
||||
|
||||
if (filelist != NULL)
|
||||
free_chararray(filelist, filelist_len);
|
||||
/* Make sure longest is between 15 and COLS. */
|
||||
if (longest < 15)
|
||||
longest = 15;
|
||||
if (longest > COLS)
|
||||
longest = COLS;
|
||||
|
||||
rewinddir(dir);
|
||||
|
||||
free_chararray(filelist, filelist_len);
|
||||
|
||||
filelist_len = i;
|
||||
|
||||
@@ -485,12 +486,6 @@ void browser_init(const char *path, DIR *dir)
|
||||
|
||||
closedir(dir);
|
||||
|
||||
/* Make sure longest is between 15 and COLS. */
|
||||
if (longest < 15)
|
||||
longest = 15;
|
||||
if (longest > COLS)
|
||||
longest = COLS;
|
||||
|
||||
/* Set width to zero, just before we initialize it. */
|
||||
width = 0;
|
||||
|
||||
@@ -542,7 +537,7 @@ functionptrtype parse_browser_input(int *kbinput)
|
||||
return goto_dir_void;
|
||||
case 'S':
|
||||
case 's':
|
||||
return do_enter_void;
|
||||
return do_enter;
|
||||
case 'W':
|
||||
case 'w':
|
||||
return do_search;
|
||||
@@ -637,7 +632,7 @@ void browser_refresh(void)
|
||||
} else
|
||||
foo = mallocstrcpy(NULL, _("(dir)"));
|
||||
} else {
|
||||
unsigned long result = st.st_size;
|
||||
off_t result = st.st_size;
|
||||
char modifier;
|
||||
|
||||
foo = charalloc(foomaxlen + 1);
|
||||
@@ -655,10 +650,10 @@ void browser_refresh(void)
|
||||
modifier = 'G'; /* gigabytes */
|
||||
}
|
||||
|
||||
/* If less than a terabyte, or if numbers can't even go
|
||||
* that high, show the size, otherwise show "(huge)". */
|
||||
if (st.st_size < (1 << 40) || (1 << 40) == 0)
|
||||
sprintf(foo, "%4lu %cB", result, modifier);
|
||||
/* Show the size if less than a terabyte,
|
||||
* otherwise show "(huge)". */
|
||||
if (result < (1 << 10))
|
||||
sprintf(foo, "%4ju %cB", (intmax_t)result, modifier);
|
||||
else
|
||||
/* TRANSLATORS: Try to keep this at most 7 characters.
|
||||
* If necessary, you can leave out the parentheses. */
|
||||
|
||||
@@ -636,7 +636,8 @@ char *mbstrcasestr(const char *haystack, const char *needle)
|
||||
|
||||
for (; *haystack != '\0' && haystack_len >= needle_len;
|
||||
haystack += move_mbright(haystack, 0), haystack_len--) {
|
||||
if (mbstrncasecmp(haystack, needle, needle_len) == 0)
|
||||
if (mbstrncasecmp(haystack, needle, needle_len) == 0 &&
|
||||
mblen(haystack, MB_CUR_MAX) > 0)
|
||||
return (char *)haystack;
|
||||
}
|
||||
|
||||
@@ -729,8 +730,9 @@ char *mbrevstrcasestr(const char *haystack, const char *needle, const
|
||||
rev_start_len = mbstrlen(rev_start);
|
||||
|
||||
while (!begin_line) {
|
||||
if (rev_start_len >= needle_len && mbstrncasecmp(rev_start,
|
||||
needle, needle_len) == 0)
|
||||
if (rev_start_len >= needle_len &&
|
||||
mbstrncasecmp(rev_start, needle, needle_len) == 0 &&
|
||||
mblen(rev_start, MB_CUR_MAX) > 0)
|
||||
return (char *)rev_start;
|
||||
|
||||
if (rev_start == haystack)
|
||||
|
||||
364
src/color.c
364
src/color.c
@@ -26,6 +26,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_MAGIC_H
|
||||
@@ -34,31 +35,34 @@
|
||||
|
||||
#ifndef DISABLE_COLOR
|
||||
|
||||
/* For each syntax list entry, go through the list of colors and assign
|
||||
* the color pairs. */
|
||||
/* Initialize the colors for nano's interface, and assign pair numbers
|
||||
* for the colors in each syntax. */
|
||||
void set_colorpairs(void)
|
||||
{
|
||||
const syntaxtype *this_syntax = syntaxes;
|
||||
bool defok = FALSE;
|
||||
short fg, bg;
|
||||
bool using_defaults = FALSE;
|
||||
short foreground, background;
|
||||
size_t i;
|
||||
|
||||
/* Tell ncurses to enable colors. */
|
||||
start_color();
|
||||
|
||||
#ifdef HAVE_USE_DEFAULT_COLORS
|
||||
/* Use the default colors, if available. */
|
||||
defok = (use_default_colors() != ERR);
|
||||
/* Allow using the default colors, if available. */
|
||||
using_defaults = (use_default_colors() != ERR);
|
||||
#endif
|
||||
|
||||
/* Initialize the color pairs for nano's interface elements. */
|
||||
for (i = 0; i < NUMBER_OF_ELEMENTS; i++) {
|
||||
bool bright = FALSE;
|
||||
|
||||
if (parse_color_names(specified_color_combo[i], &fg, &bg, &bright)) {
|
||||
if (fg == -1 && !defok)
|
||||
fg = COLOR_WHITE;
|
||||
if (bg == -1 && !defok)
|
||||
bg = COLOR_BLACK;
|
||||
init_pair(i + 1, fg, bg);
|
||||
if (parse_color_names(specified_color_combo[i],
|
||||
&foreground, &background, &bright)) {
|
||||
if (foreground == -1 && !using_defaults)
|
||||
foreground = COLOR_WHITE;
|
||||
if (background == -1 && !using_defaults)
|
||||
background = COLOR_BLACK;
|
||||
init_pair(i + 1, foreground, background);
|
||||
interface_color_pair[i].bright = bright;
|
||||
interface_color_pair[i].pairnum = COLOR_PAIR(i + 1);
|
||||
}
|
||||
@@ -74,6 +78,8 @@ void set_colorpairs(void)
|
||||
specified_color_combo[i] = NULL;
|
||||
}
|
||||
|
||||
/* For each syntax, go through its list of colors and assign each
|
||||
* its pair number, giving identical color pairs the same number. */
|
||||
for (; this_syntax != NULL; this_syntax = this_syntax->next) {
|
||||
colortype *this_color = this_syntax->color;
|
||||
int clr_pair = NUMBER_OF_ELEMENTS + 1;
|
||||
@@ -81,12 +87,11 @@ void set_colorpairs(void)
|
||||
for (; this_color != NULL; this_color = this_color->next) {
|
||||
const colortype *beforenow = this_syntax->color;
|
||||
|
||||
for (; beforenow != this_color &&
|
||||
(beforenow->fg != this_color->fg ||
|
||||
beforenow->bg != this_color->bg ||
|
||||
beforenow->bright != this_color->bright);
|
||||
beforenow = beforenow->next)
|
||||
;
|
||||
while (beforenow != this_color &&
|
||||
(beforenow->fg != this_color->fg ||
|
||||
beforenow->bg != this_color->bg ||
|
||||
beforenow->bright != this_color->bright))
|
||||
beforenow = beforenow->next;
|
||||
|
||||
if (beforenow != this_color)
|
||||
this_color->pairnum = beforenow->pairnum;
|
||||
@@ -101,38 +106,36 @@ void set_colorpairs(void)
|
||||
/* Initialize the color information. */
|
||||
void color_init(void)
|
||||
{
|
||||
colortype *tmpcolor = openfile->colorstrings;
|
||||
bool using_defaults = FALSE;
|
||||
short foreground, background;
|
||||
|
||||
assert(openfile != NULL);
|
||||
|
||||
if (has_colors()) {
|
||||
const colortype *tmpcolor;
|
||||
/* If the terminal is not capable of colors, forget it. */
|
||||
if (!has_colors())
|
||||
return;
|
||||
|
||||
#ifdef HAVE_USE_DEFAULT_COLORS
|
||||
/* Use the default colors, if available. */
|
||||
bool defok = (use_default_colors() != ERR);
|
||||
/* Allow using the default colors, if available. */
|
||||
using_defaults = (use_default_colors() != ERR);
|
||||
#endif
|
||||
|
||||
for (tmpcolor = openfile->colorstrings; tmpcolor != NULL;
|
||||
tmpcolor = tmpcolor->next) {
|
||||
short foreground = tmpcolor->fg, background = tmpcolor->bg;
|
||||
if (foreground == -1) {
|
||||
#ifdef HAVE_USE_DEFAULT_COLORS
|
||||
if (!defok)
|
||||
#endif
|
||||
foreground = COLOR_WHITE;
|
||||
}
|
||||
/* For each coloring expression, initialize the color pair. */
|
||||
for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) {
|
||||
foreground = tmpcolor->fg;
|
||||
background = tmpcolor->bg;
|
||||
|
||||
if (background == -1) {
|
||||
#ifdef HAVE_USE_DEFAULT_COLORS
|
||||
if (!defok)
|
||||
#endif
|
||||
background = COLOR_BLACK;
|
||||
}
|
||||
if (foreground == -1 && !using_defaults)
|
||||
foreground = COLOR_WHITE;
|
||||
|
||||
init_pair(tmpcolor->pairnum, foreground, background);
|
||||
if (background == -1 && !using_defaults)
|
||||
background = COLOR_BLACK;
|
||||
|
||||
init_pair(tmpcolor->pairnum, foreground, background);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "init_pair(): fg = %hd, bg = %hd\n", tmpcolor->fg, tmpcolor->bg);
|
||||
fprintf(stderr, "init_pair(): fg = %hd, bg = %hd\n", foreground, background);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,6 +183,9 @@ void color_update(void)
|
||||
if (openfile->colorstrings != NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
if (openfile->colorstrings == NULL)
|
||||
statusbar(_("Unknown syntax name: %s"), syntaxstr);
|
||||
}
|
||||
|
||||
/* If we didn't specify a syntax override string, or if we did and
|
||||
@@ -362,107 +368,235 @@ void color_update(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset the multicolor info cache for records for any lines which need
|
||||
* to be recalculated. */
|
||||
void reset_multis_after(filestruct *fileptr, int mindex)
|
||||
/* Reset the multiline coloring cache for one specific regex (given by
|
||||
* index) for lines that need reevaluation. */
|
||||
void reset_multis_for_id(filestruct *fileptr, int index)
|
||||
{
|
||||
filestruct *oof;
|
||||
for (oof = fileptr->next; oof != NULL; oof = oof->next) {
|
||||
alloc_multidata_if_needed(oof);
|
||||
if (oof->multidata == NULL)
|
||||
continue;
|
||||
if (oof->multidata[mindex] != CNONE)
|
||||
oof->multidata[mindex] = -1;
|
||||
else
|
||||
filestruct *row;
|
||||
|
||||
/* Reset the cache of earlier lines, as far back as needed. */
|
||||
for (row = fileptr->prev; row != NULL; row = row->prev) {
|
||||
alloc_multidata_if_needed(row);
|
||||
if (row->multidata[index] == CNONE)
|
||||
break;
|
||||
row->multidata[index] = -1;
|
||||
}
|
||||
for (; oof != NULL; oof = oof->next) {
|
||||
alloc_multidata_if_needed(oof);
|
||||
if (oof->multidata == NULL)
|
||||
continue;
|
||||
if (oof->multidata[mindex] == CNONE)
|
||||
oof->multidata[mindex] = -1;
|
||||
else
|
||||
for (; row != NULL; row = row->prev) {
|
||||
alloc_multidata_if_needed(row);
|
||||
if (row->multidata[index] != CNONE)
|
||||
break;
|
||||
row->multidata[index] = -1;
|
||||
}
|
||||
|
||||
/* Reset the cache of the current line. */
|
||||
fileptr->multidata[index] = -1;
|
||||
|
||||
/* Reset the cache of later lines, as far ahead as needed. */
|
||||
for (row = fileptr->next; row != NULL; row = row->next) {
|
||||
alloc_multidata_if_needed(row);
|
||||
if (row->multidata[index] == CNONE)
|
||||
break;
|
||||
row->multidata[index] = -1;
|
||||
}
|
||||
for (; row != NULL; row = row->next) {
|
||||
alloc_multidata_if_needed(row);
|
||||
if (row->multidata[index] != CNONE)
|
||||
break;
|
||||
row->multidata[index] = -1;
|
||||
}
|
||||
|
||||
edit_refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
void reset_multis_before(filestruct *fileptr, int mindex)
|
||||
{
|
||||
filestruct *oof;
|
||||
for (oof = fileptr->prev; oof != NULL; oof = oof->prev) {
|
||||
alloc_multidata_if_needed(oof);
|
||||
if (oof->multidata == NULL)
|
||||
continue;
|
||||
if (oof->multidata[mindex] != CNONE)
|
||||
oof->multidata[mindex] = -1;
|
||||
else
|
||||
break;
|
||||
}
|
||||
for (; oof != NULL; oof = oof->prev) {
|
||||
alloc_multidata_if_needed(oof);
|
||||
if (oof->multidata == NULL)
|
||||
continue;
|
||||
if (oof->multidata[mindex] == CNONE)
|
||||
oof->multidata[mindex] = -1;
|
||||
else
|
||||
break;
|
||||
}
|
||||
edit_refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
/* Reset one multiline regex info. */
|
||||
void reset_multis_for_id(filestruct *fileptr, int num)
|
||||
{
|
||||
reset_multis_before(fileptr, num);
|
||||
reset_multis_after(fileptr, num);
|
||||
fileptr->multidata[num] = -1;
|
||||
}
|
||||
|
||||
/* Reset multi-line strings around a filestruct ptr, trying to be smart
|
||||
* about stopping. Bool force means: reset everything regardless, useful
|
||||
* when we don't know how much screen state has changed. */
|
||||
/* Reset multi-line strings around the filestruct fileptr, trying to be
|
||||
* smart about stopping. Bool force means: reset everything regardless,
|
||||
* useful when we don't know how much screen state has changed. */
|
||||
void reset_multis(filestruct *fileptr, bool force)
|
||||
{
|
||||
int nobegin, noend;
|
||||
regmatch_t startmatch, endmatch;
|
||||
const colortype *tmpcolor = openfile->colorstrings;
|
||||
|
||||
if (!openfile->syntax)
|
||||
/* If there is no syntax or no multiline regex, there is nothing to do. */
|
||||
if (openfile->syntax == NULL || openfile->syntax->nmultis == 0)
|
||||
return;
|
||||
|
||||
for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) {
|
||||
|
||||
/* If it's not a multi-line regex, amscray. */
|
||||
if (tmpcolor->end == NULL)
|
||||
continue;
|
||||
|
||||
alloc_multidata_if_needed(fileptr);
|
||||
if (force == TRUE) {
|
||||
reset_multis_for_id(fileptr, tmpcolor->id);
|
||||
continue;
|
||||
|
||||
if (force == FALSE) {
|
||||
/* Check whether the multidata still matches the current situation. */
|
||||
nobegin = regexec(tmpcolor->start, fileptr->data, 1, &startmatch, 0);
|
||||
noend = regexec(tmpcolor->end, fileptr->data, 1, &endmatch, 0);
|
||||
if ((fileptr->multidata[tmpcolor->id] == CWHOLELINE ||
|
||||
fileptr->multidata[tmpcolor->id] == CNONE) &&
|
||||
nobegin && noend)
|
||||
continue;
|
||||
else if (fileptr->multidata[tmpcolor->id] == CSTARTENDHERE &&
|
||||
!nobegin && !noend && startmatch.rm_so < endmatch.rm_so)
|
||||
continue;
|
||||
else if (fileptr->multidata[tmpcolor->id] == CBEGINBEFORE &&
|
||||
nobegin && !noend)
|
||||
continue;
|
||||
else if (fileptr->multidata[tmpcolor->id] == CENDAFTER &&
|
||||
!nobegin && noend)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Figure out where the first begin and end are to determine if
|
||||
* things changed drastically for the precalculated multi values. */
|
||||
nobegin = regexec(tmpcolor->start, fileptr->data, 1, &startmatch, 0);
|
||||
noend = regexec(tmpcolor->end, fileptr->data, 1, &endmatch, 0);
|
||||
if (fileptr->multidata[tmpcolor->id] == CWHOLELINE) {
|
||||
if (nobegin && noend)
|
||||
continue;
|
||||
} else if (fileptr->multidata[tmpcolor->id] == CNONE) {
|
||||
if (nobegin && noend)
|
||||
continue;
|
||||
} else if (fileptr->multidata[tmpcolor->id] & CBEGINBEFORE && !noend
|
||||
&& (nobegin || endmatch.rm_eo > startmatch.rm_eo)) {
|
||||
reset_multis_after(fileptr, tmpcolor->id);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If we got here, assume the worst. */
|
||||
/* If we got here, things have changed. */
|
||||
reset_multis_for_id(fileptr, tmpcolor->id);
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate (for one line) the cache space for multiline color regexes. */
|
||||
void alloc_multidata_if_needed(filestruct *fileptr)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (fileptr->multidata == NULL) {
|
||||
fileptr->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
|
||||
for (i = 0; i < openfile->syntax->nmultis; i++)
|
||||
fileptr->multidata[i] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Poll the keyboard every second to see if the user starts typing. */
|
||||
bool key_was_pressed(void)
|
||||
{
|
||||
static time_t last_time = 0;
|
||||
|
||||
if (time(NULL) != last_time) {
|
||||
last_time = time(NULL);
|
||||
return (wgetch(edit) != ERR);
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Precalculate the multi-line start and end regex info so we can
|
||||
* speed up rendering (with any hope at all...). */
|
||||
void precalc_multicolorinfo(void)
|
||||
{
|
||||
const colortype *tmpcolor = openfile->colorstrings;
|
||||
regmatch_t startmatch, endmatch;
|
||||
filestruct *fileptr, *endptr;
|
||||
|
||||
if (openfile->colorstrings == NULL || ISSET(NO_COLOR_SYNTAX))
|
||||
return;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Entering precalculation of multiline color info\n");
|
||||
#endif
|
||||
/* Let us get keypresses to see if the user is trying to start
|
||||
* editing. Later we may want to throw up a statusbar message
|
||||
* before starting this if it takes too long to do this routine.
|
||||
* For now silently abort if they hit a key. */
|
||||
nodelay(edit, TRUE);
|
||||
|
||||
for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) {
|
||||
/* If this is not a multi-line regex, skip it. */
|
||||
if (tmpcolor->end == NULL)
|
||||
continue;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Starting work on color id %d\n", tmpcolor->id);
|
||||
#endif
|
||||
|
||||
for (fileptr = openfile->fileage; fileptr != NULL; fileptr = fileptr->next) {
|
||||
int startx = 0, nostart = 0;
|
||||
|
||||
if (key_was_pressed())
|
||||
goto precalc_cleanup;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "working on lineno %ld... ", (long)fileptr->lineno);
|
||||
#endif
|
||||
alloc_multidata_if_needed(fileptr);
|
||||
|
||||
while ((nostart = regexec(tmpcolor->start, &fileptr->data[startx],
|
||||
1, &startmatch, (startx == 0) ? 0 : REG_NOTBOL)) == 0) {
|
||||
/* Look for an end, and start marking how many lines are
|
||||
* encompassed, which should speed up rendering later. */
|
||||
startx += startmatch.rm_eo;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "start found at pos %lu... ", (unsigned long)startx);
|
||||
#endif
|
||||
/* Look first on this line for an end. */
|
||||
if (regexec(tmpcolor->end, &fileptr->data[startx], 1,
|
||||
&endmatch, (startx == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
startx += endmatch.rm_eo;
|
||||
/* Step ahead when both start and end are mere anchors. */
|
||||
if (startmatch.rm_so == startmatch.rm_eo &&
|
||||
endmatch.rm_so == endmatch.rm_eo)
|
||||
startx += 1;
|
||||
fileptr->multidata[tmpcolor->id] = CSTARTENDHERE;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "end found on this line\n");
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Nice, we didn't find the end regex on this line. Let's start looking for it. */
|
||||
for (endptr = fileptr->next; endptr != NULL; endptr = endptr->next) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "\nadvancing to line %ld to find end... ", (long)endptr->lineno);
|
||||
#endif
|
||||
/* Check for interrupting keyboard input again. */
|
||||
if (key_was_pressed())
|
||||
goto precalc_cleanup;
|
||||
|
||||
if (regexec(tmpcolor->end, endptr->data, 1, &endmatch, 0) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (endptr == NULL) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "no end found, breaking out\n");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "end found\n");
|
||||
#endif
|
||||
/* We found it, we found it, la la la la la. Mark all
|
||||
* the lines in between and the end properly. */
|
||||
fileptr->multidata[tmpcolor->id] = CENDAFTER;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "marking line %ld as CENDAFTER\n", (long)fileptr->lineno);
|
||||
#endif
|
||||
for (fileptr = fileptr->next; fileptr != endptr; fileptr = fileptr->next) {
|
||||
alloc_multidata_if_needed(fileptr);
|
||||
fileptr->multidata[tmpcolor->id] = CWHOLELINE;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "marking intermediary line %ld as CWHOLELINE\n", (long)fileptr->lineno);
|
||||
#endif
|
||||
}
|
||||
|
||||
alloc_multidata_if_needed(endptr);
|
||||
fileptr->multidata[tmpcolor->id] = CBEGINBEFORE;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "marking line %ld as CBEGINBEFORE\n", (long)fileptr->lineno);
|
||||
#endif
|
||||
/* Skip to the end point of the match. */
|
||||
startx = endmatch.rm_eo;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "jumping to line %ld pos %lu to continue\n", (long)fileptr->lineno, (unsigned long)startx);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (nostart && startx == 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "no match\n");
|
||||
#endif
|
||||
fileptr->multidata[tmpcolor->id] = CNONE;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
precalc_cleanup:
|
||||
nodelay(edit, FALSE);
|
||||
}
|
||||
|
||||
#endif /* !DISABLE_COLOR */
|
||||
|
||||
24
src/cut.c
24
src/cut.c
@@ -50,11 +50,6 @@ inline bool keeping_cutbuffer(void)
|
||||
* current line. */
|
||||
void cut_line(void)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
if (!openfile->mark_begin)
|
||||
openfile->mark_begin = openfile->current;
|
||||
#endif
|
||||
|
||||
if (openfile->current != openfile->filebot)
|
||||
move_to_filestruct(&cutbuffer, &cutbottom, openfile->current, 0,
|
||||
openfile->current->next, 0);
|
||||
@@ -124,7 +119,7 @@ void cut_to_eof(void)
|
||||
* position to the end of the file into the cutbuffer. */
|
||||
void do_cut_text(
|
||||
#ifndef NANO_TINY
|
||||
bool copy_text, bool cut_till_eof, bool undoing
|
||||
bool copy_text, bool cut_till_eof
|
||||
#else
|
||||
void
|
||||
#endif
|
||||
@@ -214,8 +209,7 @@ void do_cut_text(
|
||||
* disturbing the text. */
|
||||
if (!old_no_newlines)
|
||||
UNSET(NO_NEWLINES);
|
||||
} else if (!undoing)
|
||||
update_undo(cut_till_eof ? CUT_EOF : CUT);
|
||||
}
|
||||
|
||||
/* Leave the text in the cutbuffer, and mark the file as
|
||||
* modified. */
|
||||
@@ -240,12 +234,11 @@ void do_cut_text_void(void)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
add_undo(CUT);
|
||||
do_cut_text(FALSE, FALSE);
|
||||
update_undo(CUT);
|
||||
#else
|
||||
do_cut_text();
|
||||
#endif
|
||||
do_cut_text(
|
||||
#ifndef NANO_TINY
|
||||
FALSE, FALSE, FALSE
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -260,7 +253,7 @@ void do_copy_text(void)
|
||||
if (mark_set || openfile->current != next_contiguous_line)
|
||||
cutbuffer_reset();
|
||||
|
||||
do_cut_text(TRUE, FALSE, FALSE);
|
||||
do_cut_text(TRUE, FALSE);
|
||||
|
||||
/* If the mark was set, blow away the cutbuffer on the next copy. */
|
||||
next_contiguous_line = (mark_set ? NULL : openfile->current);
|
||||
@@ -270,7 +263,8 @@ void do_copy_text(void)
|
||||
void do_cut_till_eof(void)
|
||||
{
|
||||
add_undo(CUT_EOF);
|
||||
do_cut_text(FALSE, TRUE, FALSE);
|
||||
do_cut_text(FALSE, TRUE);
|
||||
update_undo(CUT_EOF);
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
|
||||
456
src/files.c
456
src/files.c
File diff suppressed because it is too large
Load Diff
222
src/global.c
222
src/global.c
@@ -41,6 +41,11 @@ bool func_key;
|
||||
bool focusing = FALSE;
|
||||
/* Whether an update of the edit window should center the cursor. */
|
||||
|
||||
#ifndef NANO_TINY
|
||||
int controlleft = CONTROL_LEFT;
|
||||
int controlright = CONTROL_RIGHT;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
ssize_t fill = 0;
|
||||
/* The column where we will wrap lines. */
|
||||
@@ -89,14 +94,10 @@ openfilestruct *openfile = NULL;
|
||||
char *matchbrackets = NULL;
|
||||
/* The opening and closing brackets that can be found by bracket
|
||||
* searches. */
|
||||
#endif
|
||||
|
||||
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
|
||||
char *whitespace = NULL;
|
||||
/* The characters used when displaying the first characters of
|
||||
* tabs and spaces. */
|
||||
/* The characters used when visibly showing tabs and spaces. */
|
||||
int whitespace_len[2];
|
||||
/* The length of these characters. */
|
||||
/* The length in bytes of these characters. */
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
@@ -221,11 +222,7 @@ size_t length_of_list(int menu)
|
||||
size_t i = 0;
|
||||
|
||||
for (f = allfuncs; f != NULL; f = f->next)
|
||||
if ((f->menus & menu) != 0
|
||||
#ifndef DISABLE_HELP
|
||||
&& strlen(f->help) > 0
|
||||
#endif
|
||||
) {
|
||||
if ((f->menus & menu) != 0) {
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
@@ -273,6 +270,9 @@ void prepend_void(void)
|
||||
void backup_file_void(void)
|
||||
{
|
||||
}
|
||||
void discard_buffer(void)
|
||||
{
|
||||
}
|
||||
void new_buffer_void(void)
|
||||
{
|
||||
}
|
||||
@@ -311,9 +311,10 @@ 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 menu, const char *scstring, void (*func)(void), int toggle)
|
||||
void add_to_sclist(int menus, const char *scstring, void (*func)(void), int toggle)
|
||||
{
|
||||
static sc *tailsc;
|
||||
static int counter = 0;
|
||||
sc *s = (sc *)nmalloc(sizeof(sc));
|
||||
|
||||
/* Start the list, or tack on the next item. */
|
||||
@@ -325,15 +326,17 @@ void add_to_sclist(int menu, const char *scstring, void (*func)(void), int toggl
|
||||
s->next = NULL;
|
||||
|
||||
/* Fill in the data. */
|
||||
s->menu = menu;
|
||||
s->menus = menus;
|
||||
s->scfunc = func;
|
||||
s->toggle = toggle;
|
||||
if (toggle)
|
||||
s->ordinal = ++counter;
|
||||
s->keystr = (char *) scstring;
|
||||
s->type = strtokeytype(scstring);
|
||||
assign_keyinfo(s);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Setting sequence to %d for shortcut \"%s\" in menu %x\n", s->seq, scstring, (int)s->menu);
|
||||
fprintf(stderr, "Setting sequence to %d for shortcut \"%s\" in menus %x\n", s->seq, scstring, s->menus);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -354,7 +357,7 @@ const sc *first_sc_for(int menu, void (*func)(void))
|
||||
const sc *s;
|
||||
|
||||
for (s = sclist; s != NULL; s = s->next)
|
||||
if ((s->menu & menu) && s->scfunc == func)
|
||||
if ((s->menus & menu) && s->scfunc == func)
|
||||
return s;
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -438,20 +441,21 @@ void assign_keyinfo(sc *s)
|
||||
s->seq = KEY_DC;
|
||||
else if (!strcasecmp(s->keystr, "Bsp"))
|
||||
s->seq = 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(s->keystr, "Tab"))
|
||||
s->seq = NANO_CONTROL_I;
|
||||
else if (!strcasecmp(s->keystr, "Enter"))
|
||||
s->seq = KEY_ENTER;
|
||||
else if (!strcasecmp(s->keystr, "PgUp"))
|
||||
s->seq = KEY_PPAGE;
|
||||
else if (!strcasecmp(s->keystr, "PgDn"))
|
||||
s->seq = KEY_NPAGE;
|
||||
#ifdef KEY_HOME
|
||||
else if (!strcasecmp(s->keystr, "Home"))
|
||||
s->seq = KEY_HOME;
|
||||
#endif
|
||||
#ifdef KEY_END
|
||||
else if (!strcasecmp(s->keystr, "End"))
|
||||
s->seq = KEY_END;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -471,22 +475,19 @@ void print_sclist(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* TRANSLATORS: Try to keep the next four strings at most 10 characters. */
|
||||
/* These four tags are used elsewhere too, so they are global. */
|
||||
/* TRANSLATORS: Try to keep the next fifteen strings at most 10 characters. */
|
||||
const char *exit_tag = N_("Exit");
|
||||
const char *close_tag = N_("Close");
|
||||
const char *uncut_tag = N_("Uncut Text");
|
||||
#ifndef DISABLE_JUSITIFY
|
||||
const char *unjust_tag = N_("Unjustify");
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
/* TRANSLATORS: Try to keep this at most 12 characters. */
|
||||
const char *whereis_next_tag = N_("WhereIs Next");
|
||||
#endif
|
||||
|
||||
/* Initialize the list of functions and the list of shortcuts. */
|
||||
void shortcut_init(void)
|
||||
{
|
||||
/* TRANSLATORS: Try to keep the next ten strings at most 10 characters. */
|
||||
const char *read_file_tag = N_("Read File");
|
||||
const char *whereis_tag = N_("Where Is");
|
||||
const char *replace_tag = N_("Replace");
|
||||
const char *gotoline_tag = N_("Go To Line");
|
||||
@@ -494,11 +495,15 @@ void shortcut_init(void)
|
||||
const char *next_line_tag = N_("Next Line");
|
||||
const char *prev_page_tag = N_("Prev Page");
|
||||
const char *next_page_tag = N_("Next Page");
|
||||
const char *read_file_tag = N_("Read File");
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
const char *justify_tag = N_("Justify");
|
||||
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
|
||||
@@ -583,6 +588,10 @@ void shortcut_init(void)
|
||||
const char *nano_backspace_msg =
|
||||
N_("Delete the character to the left of the cursor");
|
||||
#ifndef NANO_TINY
|
||||
const char *nano_cut_word_left_msg =
|
||||
N_("Cut backward from cursor to word start");
|
||||
const char *nano_cut_word_right_msg =
|
||||
N_("Cut forward from cursor to next word start");
|
||||
const char *nano_cut_till_eof_msg =
|
||||
N_("Cut from the cursor position to the end of the file");
|
||||
#endif
|
||||
@@ -596,8 +605,11 @@ void shortcut_init(void)
|
||||
const char *nano_refresh_msg =
|
||||
N_("Refresh (redraw) the current screen");
|
||||
const char *nano_suspend_msg =
|
||||
N_("Suspend the editor (if suspend is enabled)");
|
||||
N_("Suspend the editor (if suspension is enabled)");
|
||||
#ifndef NANO_TINY
|
||||
const char *nano_savefile_msg = N_("Save file without prompting");
|
||||
const char *nano_findprev_msg = N_("Search next occurrence backward");
|
||||
const char *nano_findnext_msg = N_("Search next occurrence forward");
|
||||
const char *nano_case_msg =
|
||||
N_("Toggle the case sensitivity of the search");
|
||||
const char *nano_reverse_msg =
|
||||
@@ -624,6 +636,7 @@ void shortcut_init(void)
|
||||
const char *nano_backup_msg = N_("Toggle backing up of the original file");
|
||||
const char *nano_execute_msg = N_("Execute external command");
|
||||
#endif
|
||||
const char *nano_discard_buffer_msg = N_("Close buffer without saving it");
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
const char *nano_multibuffer_msg = N_("Toggle the use of a new buffer");
|
||||
#endif
|
||||
@@ -651,12 +664,6 @@ void shortcut_init(void)
|
||||
#define IFSCHELP(help) ""
|
||||
#endif
|
||||
|
||||
while (allfuncs != NULL) {
|
||||
subnfunc *f = allfuncs;
|
||||
allfuncs = allfuncs->next;
|
||||
free(f);
|
||||
}
|
||||
|
||||
/* Start populating the different menus with functions. */
|
||||
|
||||
add_to_funcs(do_help_void, MMOST,
|
||||
@@ -679,18 +686,28 @@ void shortcut_init(void)
|
||||
add_to_funcs(do_writeout_void, MMAIN,
|
||||
N_("Write Out"), IFSCHELP(nano_writeout_msg), TOGETHER, NOVIEW);
|
||||
|
||||
/* We allow inserting files in view mode if multibuffers are
|
||||
* available, so that we can view multiple files. If we're using
|
||||
* restricted mode, inserting files is disabled, since it allows
|
||||
* reading from or writing to files not specified on the command
|
||||
* line. */
|
||||
add_to_funcs(do_insertfile_void, MMAIN,
|
||||
read_file_tag, IFSCHELP(nano_insert_msg), BLANKAFTER,
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
VIEW);
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
if (!ISSET(RESTRICTED)) {
|
||||
#else
|
||||
NOVIEW);
|
||||
/* If we can't replace Insert with Justify, show Insert anyway, to
|
||||
* keep the help items nicely paired also in restricted mode. */
|
||||
if (TRUE) {
|
||||
#endif
|
||||
add_to_funcs(do_insertfile_void, MMAIN,
|
||||
read_file_tag, IFSCHELP(nano_insert_msg), BLANKAFTER,
|
||||
/* We allow inserting files in view mode if multibuffer mode
|
||||
* is switched on, so that we can view multiple files. */
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
VIEW);
|
||||
#else
|
||||
NOVIEW);
|
||||
#endif
|
||||
} else {
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
add_to_funcs(do_justify_void, MMAIN,
|
||||
justify_tag, IFSCHELP(nano_justify_msg), BLANKAFTER, NOVIEW);
|
||||
#endif
|
||||
}
|
||||
|
||||
add_to_funcs(do_search, MMAIN,
|
||||
whereis_tag, IFSCHELP(nano_whereis_msg), TOGETHER, VIEW);
|
||||
@@ -725,24 +742,25 @@ void shortcut_init(void)
|
||||
/* Remember the entry for Uncut, to be able to replace it with Unjustify. */
|
||||
uncutfunc = tailfunc;
|
||||
|
||||
if (!ISSET(RESTRICTED)) {
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
add_to_funcs(do_justify_void, MMAIN,
|
||||
N_("Justify"), IFSCHELP(nano_justify_msg), TOGETHER, NOVIEW);
|
||||
add_to_funcs(do_justify_void, MMAIN,
|
||||
justify_tag, IFSCHELP(nano_justify_msg), TOGETHER, NOVIEW);
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_SPELLER
|
||||
add_to_funcs(do_spell, MMAIN,
|
||||
N_("To Spell"), IFSCHELP(nano_spell_msg), TOGETHER, NOVIEW);
|
||||
add_to_funcs(do_spell, MMAIN,
|
||||
N_("To Spell"), IFSCHELP(nano_spell_msg), TOGETHER, NOVIEW);
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_COLOR
|
||||
add_to_funcs(do_linter, MMAIN,
|
||||
N_("To Linter"), IFSCHELP(nano_lint_msg), TOGETHER, NOVIEW);
|
||||
add_to_funcs(do_linter, MMAIN,
|
||||
N_("To Linter"), IFSCHELP(nano_lint_msg), TOGETHER, NOVIEW);
|
||||
#ifndef DISABLE_SPELLER
|
||||
add_to_funcs(do_formatter, MMAIN,
|
||||
N_("Formatter"), IFSCHELP(nano_formatter_msg), BLANKAFTER, NOVIEW);
|
||||
add_to_funcs(do_formatter, MMAIN,
|
||||
N_("Formatter"), IFSCHELP(nano_formatter_msg), BLANKAFTER, NOVIEW);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(case_sens_void, MWHEREIS|MREPLACE,
|
||||
@@ -874,8 +892,9 @@ void shortcut_init(void)
|
||||
|
||||
add_to_funcs(do_tab, MMAIN,
|
||||
N_("Tab"), IFSCHELP(nano_tab_msg), TOGETHER, NOVIEW);
|
||||
add_to_funcs(do_enter_void, MMAIN,
|
||||
N_("Enter"), IFSCHELP(nano_enter_msg), TOGETHER, NOVIEW);
|
||||
add_to_funcs(do_enter, MMAIN,
|
||||
N_("Enter"), IFSCHELP(nano_enter_msg), BLANKAFTER, NOVIEW);
|
||||
|
||||
add_to_funcs(do_delete, MMAIN,
|
||||
N_("Delete"), IFSCHELP(nano_delete_msg), TOGETHER, NOVIEW);
|
||||
add_to_funcs(do_backspace, MMAIN,
|
||||
@@ -888,6 +907,10 @@ void shortcut_init(void)
|
||||
NOVIEW);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(do_cut_prev_word, MMAIN,
|
||||
N_("Cut Left"), IFSCHELP(nano_cut_word_left_msg), TOGETHER, NOVIEW);
|
||||
add_to_funcs(do_cut_next_word, MMAIN,
|
||||
N_("Cut Right"), IFSCHELP(nano_cut_word_right_msg), TOGETHER, NOVIEW);
|
||||
add_to_funcs(do_cut_till_eof, MMAIN,
|
||||
N_("CutTillEnd"), IFSCHELP(nano_cut_till_eof_msg), BLANKAFTER, NOVIEW);
|
||||
#endif
|
||||
@@ -908,6 +931,16 @@ void shortcut_init(void)
|
||||
add_to_funcs(do_suspend_void, MMAIN,
|
||||
N_("Suspend"), IFSCHELP(nano_suspend_msg), BLANKAFTER, VIEW);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(do_savefile, MMAIN,
|
||||
N_("Save"), IFSCHELP(nano_savefile_msg), BLANKAFTER, NOVIEW);
|
||||
|
||||
add_to_funcs(do_findprevious, MMAIN,
|
||||
N_("Previous"), IFSCHELP(nano_findprev_msg), TOGETHER, VIEW);
|
||||
add_to_funcs(do_findnext, MMAIN,
|
||||
N_("Next"), IFSCHELP(nano_findnext_msg), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_HISTORIES
|
||||
add_to_funcs(get_history_older_void,
|
||||
(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE),
|
||||
@@ -921,19 +954,16 @@ void shortcut_init(void)
|
||||
N_("Go To Text"), IFSCHELP(nano_whereis_msg), BLANKAFTER, VIEW);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If we're using restricted mode, the DOS format, Mac format,
|
||||
* append, prepend, and backup toggles are disabled. The first and
|
||||
* second are useless since inserting files is disabled, the third
|
||||
* and fourth are disabled because they allow writing to files not
|
||||
* specified on the command line, and the fifth is useless since
|
||||
* backups are disabled. */
|
||||
add_to_funcs(dos_format_void, MWRITEFILE,
|
||||
N_("DOS Format"), IFSCHELP(nano_dos_msg), TOGETHER, NOVIEW);
|
||||
add_to_funcs(mac_format_void, MWRITEFILE,
|
||||
N_("Mac Format"), IFSCHELP(nano_mac_msg), TOGETHER, NOVIEW);
|
||||
|
||||
/* If we're using restricted mode, the Append, Prepend, and Backup toggles
|
||||
* are disabled. The first and second are not useful as they only allow
|
||||
* reduplicating the current file, and the third is not allowed as it
|
||||
* would write to a file not specified on the command line. */
|
||||
if (!ISSET(RESTRICTED)) {
|
||||
add_to_funcs(dos_format_void, MWRITEFILE,
|
||||
N_("DOS Format"), IFSCHELP(nano_dos_msg), TOGETHER, NOVIEW);
|
||||
|
||||
add_to_funcs(mac_format_void, MWRITEFILE,
|
||||
N_("Mac Format"), IFSCHELP(nano_mac_msg), TOGETHER, NOVIEW);
|
||||
|
||||
add_to_funcs(append_void, MWRITEFILE,
|
||||
N_("Append"), IFSCHELP(nano_append_msg), TOGETHER, NOVIEW);
|
||||
add_to_funcs(prepend_void, MWRITEFILE,
|
||||
@@ -975,6 +1005,9 @@ void shortcut_init(void)
|
||||
N_("Last File"), IFSCHELP(nano_lastfile_msg), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(discard_buffer, MWRITEFILE,
|
||||
N_("Discard buffer"), IFSCHELP(nano_discard_buffer_msg), BLANKAFTER, NOVIEW);
|
||||
|
||||
#if !defined(NANO_TINY) && !defined(DISABLE_BROWSER)
|
||||
add_to_funcs(do_research, MBROWSER,
|
||||
whereis_next_tag, IFSCHELP(nano_whereis_next_msg), TOGETHER, VIEW);
|
||||
@@ -1166,25 +1199,36 @@ void shortcut_init(void)
|
||||
add_to_sclist(MBROWSER, "M-G", goto_dir_void, 0);
|
||||
add_to_sclist(MBROWSER, "F13", goto_dir_void, 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, "M-A", append_void, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-P", prepend_void, 0);
|
||||
add_to_sclist(MWRITEFILE, "M-B", backup_file_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);
|
||||
#ifndef DISABLE_BROWSER
|
||||
add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", to_files_void, 0);
|
||||
add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", 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", flip_execute_void, 0);
|
||||
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", new_buffer_void, 0);
|
||||
}
|
||||
add_to_sclist(MHELP|MBROWSER, "^C", 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);
|
||||
#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);
|
||||
#endif
|
||||
add_to_sclist(MMOST, "^I", do_tab, 0);
|
||||
add_to_sclist(MMOST, "^M", do_enter_void, 0);
|
||||
add_to_sclist(MMOST, "Enter", do_enter_void, 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);
|
||||
@@ -1218,12 +1262,12 @@ void set_spell_shortcuts(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
const subnfunc *sctofunc(sc *s)
|
||||
const subnfunc *sctofunc(const sc *s)
|
||||
{
|
||||
subnfunc *f;
|
||||
subnfunc *f = allfuncs;
|
||||
|
||||
for (f = allfuncs; f != NULL && s->scfunc != f->scfunc; f = f->next)
|
||||
;
|
||||
while (f != NULL && f->scfunc != s->scfunc)
|
||||
f = f->next;
|
||||
|
||||
return f;
|
||||
}
|
||||
@@ -1279,7 +1323,7 @@ const char *flagtostr(int flag)
|
||||
#ifndef DISABLE_NANORC
|
||||
/* Interpret a function string given in the rc file, and return a
|
||||
* shortcut struct with the corresponding function filled in. */
|
||||
sc *strtosc(char *input)
|
||||
sc *strtosc(const char *input)
|
||||
{
|
||||
sc *s;
|
||||
|
||||
@@ -1294,8 +1338,14 @@ sc *strtosc(char *input)
|
||||
s->scfunc = do_cancel;
|
||||
else if (!strcasecmp(input, "exit"))
|
||||
s->scfunc = do_exit;
|
||||
else if (!strcasecmp(input, "discardbuffer"))
|
||||
s->scfunc = discard_buffer;
|
||||
else if (!strcasecmp(input, "writeout"))
|
||||
s->scfunc = do_writeout_void;
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcasecmp(input, "savefile"))
|
||||
s->scfunc = do_savefile;
|
||||
#endif
|
||||
else if (!strcasecmp(input, "insert"))
|
||||
s->scfunc = do_insertfile_void;
|
||||
else if (!strcasecmp(input, "whereis"))
|
||||
@@ -1304,6 +1354,10 @@ sc *strtosc(char *input)
|
||||
else if (!strcasecmp(input, "searchagain") ||
|
||||
!strcasecmp(input, "research"))
|
||||
s->scfunc = do_research;
|
||||
else if (!strcasecmp(input, "findprevious"))
|
||||
s->scfunc = do_findprevious;
|
||||
else if (!strcasecmp(input, "findnext"))
|
||||
s->scfunc = do_findnext;
|
||||
#endif
|
||||
else if (!strcasecmp(input, "replace"))
|
||||
s->scfunc = do_replace;
|
||||
@@ -1356,6 +1410,10 @@ sc *strtosc(char *input)
|
||||
s->scfunc = do_prev_word_void;
|
||||
else if (!strcasecmp(input, "nextword"))
|
||||
s->scfunc = do_next_word_void;
|
||||
else if (!strcasecmp(input, "cutwordleft"))
|
||||
s->scfunc = do_cut_prev_word;
|
||||
else if (!strcasecmp(input, "cutwordright"))
|
||||
s->scfunc = do_cut_next_word;
|
||||
else if (!strcasecmp(input, "findbracket"))
|
||||
s->scfunc = do_find_bracket;
|
||||
else if (!strcasecmp(input, "wordcount"))
|
||||
@@ -1402,7 +1460,7 @@ sc *strtosc(char *input)
|
||||
else if (!strcasecmp(input, "tab"))
|
||||
s->scfunc = do_tab;
|
||||
else if (!strcasecmp(input, "enter"))
|
||||
s->scfunc = do_enter_void;
|
||||
s->scfunc = do_enter;
|
||||
else if (!strcasecmp(input, "delete"))
|
||||
s->scfunc = do_delete;
|
||||
else if (!strcasecmp(input, "backspace"))
|
||||
@@ -1518,7 +1576,7 @@ sc *strtosc(char *input)
|
||||
}
|
||||
|
||||
/* Interpret a menu name and return the corresponding menu flag. */
|
||||
int strtomenu(char *input)
|
||||
int strtomenu(const char *input)
|
||||
{
|
||||
if (!strcasecmp(input, "all"))
|
||||
return (MMOST|MHELP|MYESNO);
|
||||
@@ -1610,6 +1668,8 @@ void thanks_for_all_the_fish(void)
|
||||
syntaxtype *bill = syntaxes;
|
||||
|
||||
free(syntaxes->desc);
|
||||
free(syntaxes->linter);
|
||||
free(syntaxes->formatter);
|
||||
while (syntaxes->extensions != NULL) {
|
||||
regexlisttype *bob = syntaxes->extensions;
|
||||
syntaxes->extensions = bob->next;
|
||||
|
||||
157
src/help.c
157
src/help.c
@@ -32,9 +32,12 @@
|
||||
static char *help_text = NULL;
|
||||
/* The text displayed in the help window. */
|
||||
|
||||
/* Our main help browser function. refresh_func is the function we will
|
||||
* call to refresh the edit window. */
|
||||
void do_help(void (*refresh_func)(void))
|
||||
static char *end_of_intro = NULL;
|
||||
/* The point in the help text where the introductory paragraphs end
|
||||
* and the shortcut descriptions begin. */
|
||||
|
||||
/* Our main help-viewer function. */
|
||||
void do_help(void)
|
||||
{
|
||||
int kbinput = ERR;
|
||||
bool old_no_help = ISSET(NO_HELP);
|
||||
@@ -75,9 +78,9 @@ void do_help(void (*refresh_func)(void))
|
||||
while (TRUE) {
|
||||
size_t i;
|
||||
|
||||
/* Get the last line of the help text. */
|
||||
ptr = help_text;
|
||||
|
||||
/* Find the line number of the last line of the help text. */
|
||||
for (last_line = 0; *ptr != '\0'; last_line++) {
|
||||
ptr += help_line_len(ptr);
|
||||
if (*ptr == '\n')
|
||||
@@ -87,21 +90,20 @@ void do_help(void (*refresh_func)(void))
|
||||
if (last_line > 0)
|
||||
last_line--;
|
||||
|
||||
/* Display the help text if we don't have a key, or if the help
|
||||
* text has moved. */
|
||||
if (kbinput == ERR || line != old_line) {
|
||||
/* Redisplay if the text was scrolled or an invalid key was pressed. */
|
||||
if (line != old_line || kbinput == ERR) {
|
||||
blank_edit();
|
||||
|
||||
ptr = help_text;
|
||||
|
||||
/* Calculate where in the text we should be, based on the
|
||||
* page. */
|
||||
/* Advance in the text to the first line to be displayed. */
|
||||
for (i = 0; i < line; i++) {
|
||||
ptr += help_line_len(ptr);
|
||||
if (*ptr == '\n')
|
||||
ptr++;
|
||||
}
|
||||
|
||||
/* Now display as many lines as the window will hold. */
|
||||
for (i = 0; i < editwinrows && *ptr != '\0'; i++) {
|
||||
size_t j = help_line_len(ptr);
|
||||
|
||||
@@ -122,7 +124,7 @@ void do_help(void (*refresh_func)(void))
|
||||
if (kbinput == KEY_WINCH) {
|
||||
kbinput = ERR;
|
||||
curs_set(0);
|
||||
continue;
|
||||
continue; /* Redraw the screen. */
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -158,7 +160,7 @@ void do_help(void (*refresh_func)(void))
|
||||
if (line + (editwinrows - 1) < last_line)
|
||||
line = last_line - (editwinrows - 1);
|
||||
} else if (func == do_exit) {
|
||||
/* Exit from the help browser. */
|
||||
/* Exit from the help viewer. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -173,35 +175,35 @@ void do_help(void (*refresh_func)(void))
|
||||
bottombars(oldmenu);
|
||||
|
||||
curs_set(1);
|
||||
refresh_func();
|
||||
|
||||
/* The help_init() at the beginning allocated help_text. Since
|
||||
* help_text has now been written to the screen, we don't need it
|
||||
* anymore. */
|
||||
#ifndef DISABLE_BROWSER
|
||||
if (oldmenu == MBROWSER || oldmenu == MWHEREISFILE || oldmenu == MGOTODIR)
|
||||
browser_refresh();
|
||||
else
|
||||
#endif
|
||||
edit_refresh();
|
||||
|
||||
/* We're exiting from the help screen. */
|
||||
free(help_text);
|
||||
help_text = NULL;
|
||||
}
|
||||
|
||||
/* This function allocates help_text, and stores the help string in it.
|
||||
* help_text should be NULL initially. */
|
||||
/* Allocate space for the help text for the current menu, and concatenate
|
||||
* the different pieces of text into it. */
|
||||
void help_init(void)
|
||||
{
|
||||
size_t allocsize = 0; /* Space needed for help_text. */
|
||||
const char *htx[3]; /* Untranslated help message. We break
|
||||
* it up into three chunks in case the
|
||||
* full string is too long for the
|
||||
* compiler to handle. */
|
||||
size_t allocsize = 0;
|
||||
/* Space needed for help_text. */
|
||||
const char *htx[3];
|
||||
/* Untranslated help introduction. We break it up into three chunks
|
||||
* in case the full string is too long for the compiler to handle. */
|
||||
char *ptr;
|
||||
const subnfunc *f;
|
||||
const sc *s;
|
||||
int scsfound = 0;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_NANORC
|
||||
bool old_whitespace = ISSET(WHITESPACE_DISPLAY);
|
||||
|
||||
UNSET(WHITESPACE_DISPLAY);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* First, set up the initial help text for the current function. */
|
||||
@@ -368,9 +370,9 @@ void help_init(void)
|
||||
/* Calculate the length of the shortcut help text. Each entry has
|
||||
* one or two keys, which fill 16 columns, plus translated text,
|
||||
* plus one or two \n's. */
|
||||
for (f = allfuncs; f != NULL; f = f->next)
|
||||
if (f->menus & currmenu)
|
||||
allocsize += (16 * mb_cur_max()) + strlen(f->help) + 2;
|
||||
for (f = allfuncs; f != NULL; f = f->next)
|
||||
if (f->menus & currmenu)
|
||||
allocsize += (16 * mb_cur_max()) + strlen(f->help) + 2;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If we're on the main list, we also count the toggle help text.
|
||||
@@ -385,10 +387,6 @@ void help_init(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* help_text has been freed and set to NULL unless the user resized
|
||||
* while in the help screen. */
|
||||
free(help_text);
|
||||
|
||||
/* Allocate space for the help text. */
|
||||
help_text = charalloc(allocsize + 1);
|
||||
|
||||
@@ -401,19 +399,20 @@ void help_init(void)
|
||||
|
||||
ptr = help_text + strlen(help_text);
|
||||
|
||||
/* Remember this end-of-introduction, start-of-shortcuts. */
|
||||
end_of_intro = ptr;
|
||||
|
||||
/* Now add our shortcut info. */
|
||||
for (f = allfuncs; f != NULL; f = f->next) {
|
||||
int scsfound = 0;
|
||||
|
||||
if ((f->menus & currmenu) == 0)
|
||||
continue;
|
||||
|
||||
/* Let's simply show the first two shortcuts from the list. */
|
||||
for (s = sclist, scsfound = 0; s != NULL; s = s->next) {
|
||||
for (s = sclist; s != NULL; s = s->next) {
|
||||
|
||||
if (s->type == RAWINPUT)
|
||||
continue;
|
||||
|
||||
if ((s->menu & currmenu) == 0)
|
||||
if ((s->menus & currmenu) == 0)
|
||||
continue;
|
||||
|
||||
if (s->scfunc == f->scfunc) {
|
||||
@@ -444,23 +443,32 @@ void help_init(void)
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* And the toggles... */
|
||||
if (currmenu == MMAIN)
|
||||
for (s = sclist; s != NULL; s = s->next) {
|
||||
if (s->scfunc == do_toggle_void)
|
||||
ptr += sprintf(ptr, "%s\t\t%s %s\n", (s->menu == MMAIN ? s->keystr : ""),
|
||||
_(flagtostr(s->toggle)), _("enable/disable"));
|
||||
if (s->toggle == NO_COLOR_SYNTAX || s->toggle == TABS_TO_SPACES)
|
||||
ptr += sprintf(ptr, "\n");
|
||||
}
|
||||
if (currmenu == MMAIN) {
|
||||
int maximum = 0, counter = 0;
|
||||
|
||||
/* First see how many toggles there are. */
|
||||
for (s = sclist; s != NULL; s = s->next)
|
||||
maximum = (s->toggle && s->ordinal > maximum) ? s->ordinal : maximum;
|
||||
|
||||
/* Now show them in the original order. */
|
||||
while (counter < maximum) {
|
||||
counter++;
|
||||
for (s = sclist; s != NULL; s = s->next)
|
||||
if (s->toggle && s->ordinal == counter) {
|
||||
ptr += sprintf(ptr, "%s\t\t%s %s\n", (s->menus == MMAIN ? s->keystr : ""),
|
||||
_(flagtostr(s->toggle)), _("enable/disable"));
|
||||
if (s->toggle == NO_COLOR_SYNTAX || s->toggle == TABS_TO_SPACES)
|
||||
ptr += sprintf(ptr, "\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef DISABLE_NANORC
|
||||
if (old_whitespace)
|
||||
SET(WHITESPACE_DISPLAY);
|
||||
#endif
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* If all went well, we didn't overwrite the allocated space for
|
||||
* help_text. */
|
||||
/* If all went well, we didn't overwrite the allocated space. */
|
||||
assert(strlen(help_text) <= allocsize + 1);
|
||||
}
|
||||
|
||||
@@ -482,46 +490,45 @@ functionptrtype parse_help_input(int *kbinput)
|
||||
return func_from_key(kbinput);
|
||||
}
|
||||
|
||||
/* Calculate the next line of help_text, starting at ptr. */
|
||||
/* Calculate the displayable length of the help-text line starting at ptr. */
|
||||
size_t help_line_len(const char *ptr)
|
||||
{
|
||||
int help_cols = (COLS > 24) ? COLS - 1 : 24;
|
||||
size_t wrapping_point = (COLS > 24) ? COLS - 1 : 24;
|
||||
/* The target width for wrapping long lines. */
|
||||
ssize_t wrap_location;
|
||||
/* Actual position where the line can be wrapped. */
|
||||
size_t length = 0;
|
||||
/* Full length of the line, until the first newline. */
|
||||
|
||||
/* Try to break the line at (COLS - 1) columns if we have more than
|
||||
* 24 columns, and at 24 columns otherwise. */
|
||||
ssize_t wrap_loc = break_line(ptr, help_cols, TRUE);
|
||||
size_t retval = (wrap_loc < 0) ? 0 : wrap_loc;
|
||||
size_t retval_save = retval;
|
||||
/* Avoid overwide paragraphs in the introductory text. */
|
||||
if (ptr < end_of_intro && COLS > 74)
|
||||
wrapping_point = 74;
|
||||
|
||||
wrap_location = break_line(ptr, wrapping_point, TRUE);
|
||||
|
||||
/* Get the length of the entire line up to a null or a newline. */
|
||||
while (*(ptr + retval) != '\0' && *(ptr + retval) != '\n')
|
||||
retval += move_mbright(ptr + retval, 0);
|
||||
while (*(ptr + length) != '\0' && *(ptr + length) != '\n')
|
||||
length = move_mbright(ptr, length);
|
||||
|
||||
/* If the entire line doesn't go more than one column beyond where
|
||||
* we tried to break it, we should display it as-is. Otherwise, we
|
||||
* should display it only up to the break. */
|
||||
if (strnlenpt(ptr, retval) > help_cols + 1)
|
||||
retval = retval_save;
|
||||
|
||||
return retval;
|
||||
/* If the entire line will just fit the screen, don't wrap it. */
|
||||
if (strnlenpt(ptr, length) <= wrapping_point + 1)
|
||||
return length;
|
||||
else if (wrap_location > 0)
|
||||
return wrap_location;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* !DISABLE_HELP */
|
||||
|
||||
/* Start the help browser. */
|
||||
/* Start the help viewer. */
|
||||
void do_help_void(void)
|
||||
{
|
||||
#ifndef DISABLE_HELP
|
||||
/* Start the help browser, with the correct refresher for afterwards. */
|
||||
#ifndef DISABLE_BROWSER
|
||||
if (currmenu == MBROWSER || currmenu == MWHEREISFILE || currmenu == MGOTODIR)
|
||||
do_help(&browser_refresh);
|
||||
else
|
||||
#endif
|
||||
do_help(&edit_refresh);
|
||||
do_help();
|
||||
#else
|
||||
if (currmenu == MMAIN)
|
||||
nano_disabled_msg();
|
||||
say_there_is_no_help();
|
||||
else
|
||||
beep();
|
||||
#endif /* !DISABLE_HELP */
|
||||
|
||||
230
src/move.c
230
src/move.c
@@ -52,9 +52,8 @@ void do_page_up(void)
|
||||
{
|
||||
int i, skipped = 0;
|
||||
|
||||
/* If there's less than a page of text left on the screen, put the
|
||||
* cursor at the beginning of the first line of the file, and then
|
||||
* update the edit window. */
|
||||
/* If the cursor is less than a page away from the top of the file,
|
||||
* put it at the beginning of the first line. */
|
||||
if (openfile->current->lineno == 1 || (
|
||||
#ifndef NANO_TINY
|
||||
!ISSET(SOFTWRAP) &&
|
||||
@@ -106,9 +105,8 @@ void do_page_down(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* If there's less than a page of text left on the screen, put the
|
||||
* cursor at the beginning of the last line of the file, and then
|
||||
* update the edit window. */
|
||||
/* If the cursor is less than a page away from the bottom of the file,
|
||||
* put it at the end of the last line. */
|
||||
if (openfile->current->lineno + maxrows - 2 >=
|
||||
openfile->filebot->lineno) {
|
||||
do_last_line();
|
||||
@@ -225,75 +223,37 @@ bool do_next_word(bool allow_punct, bool allow_update)
|
||||
{
|
||||
size_t pww_save = openfile->placewewant;
|
||||
filestruct *current_save = openfile->current;
|
||||
char *char_mb;
|
||||
int char_mb_len;
|
||||
bool end_line = FALSE, started_on_word = FALSE;
|
||||
bool started_on_word = is_word_mbchar(openfile->current->data +
|
||||
openfile->current_x, allow_punct);
|
||||
bool seen_space = !started_on_word;
|
||||
|
||||
assert(openfile->current != NULL && openfile->current->data != NULL);
|
||||
|
||||
char_mb = charalloc(mb_cur_max());
|
||||
|
||||
/* Move forward until we find the character after the last letter of
|
||||
* the current word. */
|
||||
while (!end_line) {
|
||||
char_mb_len = parse_mbchar(openfile->current->data +
|
||||
openfile->current_x, char_mb, NULL);
|
||||
|
||||
/* If we've found it, stop moving forward through the current
|
||||
* line. */
|
||||
if (!is_word_mbchar(char_mb, allow_punct))
|
||||
break;
|
||||
|
||||
/* If we haven't found it, then we've started on a word, so set
|
||||
* started_on_word to TRUE. */
|
||||
started_on_word = TRUE;
|
||||
|
||||
if (openfile->current->data[openfile->current_x] == '\0')
|
||||
end_line = TRUE;
|
||||
else
|
||||
openfile->current_x += char_mb_len;
|
||||
}
|
||||
|
||||
/* Move forward until we find the first letter of the next word. */
|
||||
if (openfile->current->data[openfile->current_x] == '\0')
|
||||
end_line = TRUE;
|
||||
else
|
||||
openfile->current_x += char_mb_len;
|
||||
|
||||
for (; openfile->current != NULL;
|
||||
openfile->current = openfile->current->next) {
|
||||
while (!end_line) {
|
||||
char_mb_len = parse_mbchar(openfile->current->data +
|
||||
openfile->current_x, char_mb, NULL);
|
||||
|
||||
/* If we've found it, stop moving forward through the
|
||||
* current line. */
|
||||
if (is_word_mbchar(char_mb, allow_punct))
|
||||
/* Move forward until we reach the start of a word. */
|
||||
while (TRUE) {
|
||||
/* If at the end of a line, move to the beginning of the next one. */
|
||||
if (openfile->current->data[openfile->current_x] == '\0') {
|
||||
/* If at the end of the file, stop. */
|
||||
if (openfile->current->next == NULL)
|
||||
break;
|
||||
|
||||
if (openfile->current->data[openfile->current_x] == '\0')
|
||||
end_line = TRUE;
|
||||
else
|
||||
openfile->current_x += char_mb_len;
|
||||
}
|
||||
|
||||
/* If we've found it, stop moving forward to the beginnings of
|
||||
* subsequent lines. */
|
||||
if (!end_line)
|
||||
break;
|
||||
|
||||
if (openfile->current != openfile->filebot) {
|
||||
end_line = FALSE;
|
||||
openfile->current = openfile->current->next;
|
||||
openfile->current_x = 0;
|
||||
seen_space = TRUE;
|
||||
} else {
|
||||
/* Step forward one character. */
|
||||
openfile->current_x = move_mbright(openfile->current->data,
|
||||
openfile->current_x);
|
||||
}
|
||||
|
||||
/* If this is not a word character, then it's a separator; else
|
||||
* if we've already seen a separator, then it's a word start. */
|
||||
if (!is_word_mbchar(openfile->current->data + openfile->current_x,
|
||||
allow_punct))
|
||||
seen_space = TRUE;
|
||||
else if (seen_space)
|
||||
break;
|
||||
}
|
||||
|
||||
free(char_mb);
|
||||
|
||||
/* If we haven't found it, move to the end of the file. */
|
||||
if (openfile->current == NULL)
|
||||
openfile->current = openfile->filebot;
|
||||
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
/* If allow_update is TRUE, update the screen. */
|
||||
@@ -314,125 +274,51 @@ void do_next_word_void(void)
|
||||
|
||||
/* Move to the previous word in the file. If allow_punct is TRUE, treat
|
||||
* punctuation as part of a word. If allow_update is TRUE, update the
|
||||
* screen afterwards. Return TRUE if we started on a word, and FALSE
|
||||
* otherwise. */
|
||||
bool do_prev_word(bool allow_punct, bool allow_update)
|
||||
* screen afterwards. */
|
||||
void do_prev_word(bool allow_punct, bool allow_update)
|
||||
{
|
||||
size_t pww_save = openfile->placewewant;
|
||||
filestruct *current_save = openfile->current;
|
||||
char *char_mb;
|
||||
int char_mb_len;
|
||||
bool begin_line = FALSE, started_on_word = FALSE;
|
||||
bool seen_a_word = FALSE, step_forward = FALSE;
|
||||
|
||||
assert(openfile->current != NULL && openfile->current->data != NULL);
|
||||
|
||||
char_mb = charalloc(mb_cur_max());
|
||||
/* Move backward until we pass over the start of a word. */
|
||||
while (TRUE) {
|
||||
/* If at the head of a line, move to the end of the preceding one. */
|
||||
if (openfile->current_x == 0) {
|
||||
if (openfile->current->prev == NULL)
|
||||
break;
|
||||
openfile->current = openfile->current->prev;
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
}
|
||||
|
||||
/* Move backward until we find the character before the first letter
|
||||
* of the current word. */
|
||||
while (!begin_line) {
|
||||
char_mb_len = parse_mbchar(openfile->current->data +
|
||||
openfile->current_x, char_mb, NULL);
|
||||
|
||||
/* If we've found it, stop moving backward through the current
|
||||
* line. */
|
||||
if (!is_word_mbchar(char_mb, allow_punct))
|
||||
break;
|
||||
|
||||
/* If we haven't found it, then we've started on a word, so set
|
||||
* started_on_word to TRUE. */
|
||||
started_on_word = TRUE;
|
||||
|
||||
if (openfile->current_x == 0)
|
||||
begin_line = TRUE;
|
||||
else
|
||||
openfile->current_x = move_mbleft(openfile->current->data,
|
||||
openfile->current_x);
|
||||
}
|
||||
|
||||
/* Move backward until we find the last letter of the previous
|
||||
* word. */
|
||||
if (openfile->current_x == 0)
|
||||
begin_line = TRUE;
|
||||
else
|
||||
/* Step back one character. */
|
||||
openfile->current_x = move_mbleft(openfile->current->data,
|
||||
openfile->current_x);
|
||||
|
||||
for (; openfile->current != NULL;
|
||||
openfile->current = openfile->current->prev) {
|
||||
while (!begin_line) {
|
||||
char_mb_len = parse_mbchar(openfile->current->data +
|
||||
openfile->current_x, char_mb, NULL);
|
||||
|
||||
/* If we've found it, stop moving backward through the
|
||||
* current line. */
|
||||
if (is_word_mbchar(char_mb, allow_punct))
|
||||
break;
|
||||
openfile->current_x);
|
||||
|
||||
if (is_word_mbchar(openfile->current->data + openfile->current_x,
|
||||
allow_punct)) {
|
||||
seen_a_word = TRUE;
|
||||
/* If at the head of a line now, this surely is a word start. */
|
||||
if (openfile->current_x == 0)
|
||||
begin_line = TRUE;
|
||||
else
|
||||
openfile->current_x =
|
||||
move_mbleft(openfile->current->data,
|
||||
openfile->current_x);
|
||||
}
|
||||
|
||||
/* If we've found it, stop moving backward to the ends of
|
||||
* previous lines. */
|
||||
if (!begin_line)
|
||||
break;
|
||||
} else if (seen_a_word) {
|
||||
/* This is space now: we've overshot the start of the word. */
|
||||
step_forward = TRUE;
|
||||
break;
|
||||
|
||||
if (openfile->current != openfile->fileage) {
|
||||
begin_line = FALSE;
|
||||
openfile->current_x = strlen(openfile->current->prev->data);
|
||||
}
|
||||
}
|
||||
|
||||
/* If we haven't found it, move to the beginning of the file. */
|
||||
if (openfile->current == NULL)
|
||||
openfile->current = openfile->fileage;
|
||||
/* If we've found it, move backward until we find the character
|
||||
* before the first letter of the previous word. */
|
||||
else if (!begin_line) {
|
||||
if (openfile->current_x == 0)
|
||||
begin_line = TRUE;
|
||||
else
|
||||
openfile->current_x = move_mbleft(openfile->current->data,
|
||||
openfile->current_x);
|
||||
|
||||
while (!begin_line) {
|
||||
char_mb_len = parse_mbchar(openfile->current->data +
|
||||
openfile->current_x, char_mb, NULL);
|
||||
|
||||
/* If we've found it, stop moving backward through the
|
||||
* current line. */
|
||||
if (!is_word_mbchar(char_mb, allow_punct))
|
||||
break;
|
||||
|
||||
if (openfile->current_x == 0)
|
||||
begin_line = TRUE;
|
||||
else
|
||||
openfile->current_x =
|
||||
move_mbleft(openfile->current->data,
|
||||
openfile->current_x);
|
||||
}
|
||||
|
||||
/* If we've found it, move forward to the first letter of the
|
||||
* previous word. */
|
||||
if (!begin_line)
|
||||
openfile->current_x += char_mb_len;
|
||||
}
|
||||
|
||||
free(char_mb);
|
||||
|
||||
if (step_forward)
|
||||
/* Move one character forward again to sit on the start of the word. */
|
||||
openfile->current_x = move_mbright(openfile->current->data,
|
||||
openfile->current_x);
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
/* If allow_update is TRUE, update the screen. */
|
||||
if (allow_update)
|
||||
edit_redraw(current_save, pww_save);
|
||||
|
||||
/* Return whether we started on a word. */
|
||||
return started_on_word;
|
||||
}
|
||||
|
||||
/* Move to the previous word in the file, treating punctuation as part
|
||||
@@ -574,10 +460,12 @@ void do_down(
|
||||
#endif
|
||||
|
||||
/* If we're at the bottom of the file, get out. */
|
||||
if (openfile->current == openfile->filebot || !openfile->current->next)
|
||||
if (openfile->current == openfile->filebot)
|
||||
return;
|
||||
|
||||
assert(ISSET(SOFTWRAP) || openfile->current_y == openfile->current->lineno - openfile->edittop->lineno);
|
||||
assert(ISSET(SOFTWRAP) || openfile->current_y ==
|
||||
openfile->current->lineno - openfile->edittop->lineno);
|
||||
assert(openfile->current->next != NULL);
|
||||
|
||||
/* Move the current line of the edit window down. */
|
||||
openfile->current = openfile->current->next;
|
||||
@@ -592,11 +480,11 @@ void do_down(
|
||||
topline = openfile->edittop;
|
||||
/* Reduce the amount when there are overlong lines at the top. */
|
||||
for (enough = 1; enough < amount; enough++) {
|
||||
if (amount <= strlenpt(topline->data) / COLS) {
|
||||
amount -= strlenpt(topline->data) / COLS;
|
||||
if (amount <= 0) {
|
||||
amount = enough;
|
||||
break;
|
||||
}
|
||||
amount -= strlenpt(topline->data) / COLS;
|
||||
topline = topline->next;
|
||||
}
|
||||
}
|
||||
|
||||
569
src/nano.c
569
src/nano.c
@@ -31,7 +31,6 @@
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <locale.h>
|
||||
#include <time.h>
|
||||
#ifdef ENABLE_UTF8
|
||||
#include <langinfo.h>
|
||||
#endif
|
||||
@@ -94,21 +93,24 @@ filestruct *copy_node(const filestruct *src)
|
||||
return dst;
|
||||
}
|
||||
|
||||
/* Splice a node into an existing filestruct. */
|
||||
void splice_node(filestruct *begin, filestruct *newnode, filestruct
|
||||
*end)
|
||||
/* Splice a new node into an existing linked list of filestructs. */
|
||||
void splice_node(filestruct *afterthis, filestruct *newnode)
|
||||
{
|
||||
assert(newnode != NULL && begin != NULL);
|
||||
assert(afterthis != NULL && newnode != NULL);
|
||||
|
||||
newnode->next = end;
|
||||
newnode->prev = begin;
|
||||
begin->next = newnode;
|
||||
if (end != NULL)
|
||||
end->prev = newnode;
|
||||
newnode->next = afterthis->next;
|
||||
newnode->prev = afterthis;
|
||||
if (afterthis->next != NULL)
|
||||
afterthis->next->prev = newnode;
|
||||
afterthis->next = newnode;
|
||||
|
||||
/* Update filebot when inserting a node at the end of file. */
|
||||
if (openfile && openfile->filebot == afterthis)
|
||||
openfile->filebot = newnode;
|
||||
}
|
||||
|
||||
/* Unlink a node from the rest of the filestruct. */
|
||||
void unlink_node(const filestruct *fileptr)
|
||||
/* Disconnect a node from a linked list of filestructs and delete it. */
|
||||
void unlink_node(filestruct *fileptr)
|
||||
{
|
||||
assert(fileptr != NULL);
|
||||
|
||||
@@ -116,9 +118,15 @@ void unlink_node(const filestruct *fileptr)
|
||||
fileptr->prev->next = fileptr->next;
|
||||
if (fileptr->next != NULL)
|
||||
fileptr->next->prev = fileptr->prev;
|
||||
|
||||
/* Update filebot when removing a node at the end of file. */
|
||||
if (openfile && openfile->filebot == fileptr)
|
||||
openfile->filebot = fileptr->prev;
|
||||
|
||||
delete_node(fileptr);
|
||||
}
|
||||
|
||||
/* Delete a node from the filestruct. */
|
||||
/* Free the data structures in the given node. */
|
||||
void delete_node(filestruct *fileptr)
|
||||
{
|
||||
assert(fileptr != NULL && fileptr->data != NULL);
|
||||
@@ -384,7 +392,7 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
|
||||
openfile->mark_begin = openfile->current;
|
||||
openfile->mark_begin_x = openfile->current_x;
|
||||
} else if (same_line)
|
||||
/* Update the content of this partially cut line. */
|
||||
/* Update the pointer to this partially cut line. */
|
||||
openfile->mark_begin = openfile->current;
|
||||
#endif
|
||||
|
||||
@@ -451,34 +459,31 @@ void copy_from_filestruct(filestruct *somebuffer)
|
||||
while (openfile->filebot->next != NULL)
|
||||
openfile->filebot = openfile->filebot->next;
|
||||
|
||||
/* Restore the current line and cursor position. If the mark begins
|
||||
* inside the partition, adjust the mark coordinates to compensate
|
||||
* for the change in the current line. */
|
||||
/* Put the cursor at the end of the pasted text. */
|
||||
openfile->current = openfile->filebot;
|
||||
openfile->current_x = strlen(openfile->filebot->data);
|
||||
|
||||
/* Refresh the mark's pointer, and compensate the mark's
|
||||
* x coordinate for the change in the current line. */
|
||||
if (openfile->fileage == openfile->filebot) {
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->mark_set) {
|
||||
if (openfile->mark_set && single_line) {
|
||||
openfile->mark_begin = openfile->current;
|
||||
if (!right_side_up)
|
||||
openfile->mark_begin_x += openfile->current_x;
|
||||
}
|
||||
#endif
|
||||
/* When the pasted stuff contains no newline, adjust the cursor's
|
||||
* x coordinate for the text that is before the pasted stuff. */
|
||||
openfile->current_x += current_x_save;
|
||||
}
|
||||
#ifndef NANO_TINY
|
||||
else if (openfile->mark_set) {
|
||||
if (right_side_up) {
|
||||
if (single_line)
|
||||
/* Get the new data, stuff was inserted on the mark line. */
|
||||
openfile->mark_begin = openfile->fileage;
|
||||
/* The x is okay, it did not move. */
|
||||
} else {
|
||||
if (single_line) {
|
||||
openfile->mark_begin = openfile->current;
|
||||
openfile->mark_begin_x -= current_x_save;
|
||||
} else
|
||||
openfile->mark_begin_x -= openfile->current_x;
|
||||
else if (openfile->mark_set && single_line) {
|
||||
if (right_side_up)
|
||||
openfile->mark_begin = openfile->fileage;
|
||||
else {
|
||||
openfile->mark_begin = openfile->current;
|
||||
openfile->mark_begin_x += openfile->current_x - current_x_save;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -517,21 +522,7 @@ void copy_from_filestruct(filestruct *somebuffer)
|
||||
/* Create a new openfilestruct node. */
|
||||
openfilestruct *make_new_opennode(void)
|
||||
{
|
||||
openfilestruct *newnode =
|
||||
(openfilestruct *)nmalloc(sizeof(openfilestruct));
|
||||
|
||||
newnode->filename = NULL;
|
||||
newnode->fileage = NULL;
|
||||
newnode->filebot = NULL;
|
||||
newnode->edittop = NULL;
|
||||
newnode->current = NULL;
|
||||
#ifndef NANO_TINY
|
||||
newnode->current_stat = NULL;
|
||||
newnode->last_action = OTHER;
|
||||
newnode->lock_filename = NULL;
|
||||
#endif
|
||||
|
||||
return newnode;
|
||||
return (openfilestruct *)nmalloc(sizeof(openfilestruct));
|
||||
}
|
||||
|
||||
/* Splice a node into an existing openfilestruct. */
|
||||
@@ -569,6 +560,7 @@ void delete_opennode(openfilestruct *fileptr)
|
||||
free_filestruct(fileptr->fileage);
|
||||
#ifndef NANO_TINY
|
||||
free(fileptr->current_stat);
|
||||
free(fileptr->lock_filename);
|
||||
#endif
|
||||
free(fileptr);
|
||||
}
|
||||
@@ -592,18 +584,31 @@ void free_openfilestruct(openfilestruct *src)
|
||||
/* Display a warning about a key disabled in view mode. */
|
||||
void print_view_warning(void)
|
||||
{
|
||||
statusbar(_("Key invalid in view mode"));
|
||||
statusbar(_("Key is invalid in view mode"));
|
||||
}
|
||||
|
||||
/* Indicate that something is disabled in restricted mode. */
|
||||
void show_restricted_warning(void)
|
||||
{
|
||||
statusbar(_("This function is disabled in restricted mode"));
|
||||
beep();
|
||||
}
|
||||
|
||||
#ifdef DISABLE_HELP
|
||||
/* Indicate that help texts are unavailable. */
|
||||
void say_there_is_no_help(void)
|
||||
{
|
||||
statusbar(_("Help is not available"));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make nano exit gracefully. */
|
||||
void finish(void)
|
||||
{
|
||||
/* Blank the statusbar (and shortcut list, if applicable), and move
|
||||
* the cursor to the last line of the screen. */
|
||||
if (!ISSET(NO_HELP))
|
||||
blank_bottombars();
|
||||
else
|
||||
blank_statusbar();
|
||||
/* Blank the statusbar and (if applicable) the shortcut list,
|
||||
* and move the cursor to the last line of the screen. */
|
||||
blank_statusbar();
|
||||
blank_bottombars();
|
||||
wrefresh(bottomwin);
|
||||
endwin();
|
||||
|
||||
@@ -841,27 +846,32 @@ void usage(void)
|
||||
N_("Start at line LINE, column COLUMN"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-A", "--smarthome", N_("Enable smart home key"));
|
||||
print_opt("-B", "--backup", N_("Save backups of existing files"));
|
||||
print_opt(_("-C <dir>"), _("--backupdir=<dir>"),
|
||||
N_("Directory for saving unique backup files"));
|
||||
if (!ISSET(RESTRICTED)) {
|
||||
print_opt("-B", "--backup", N_("Save backups of existing files"));
|
||||
print_opt(_("-C <dir>"), _("--backupdir=<dir>"),
|
||||
N_("Directory for saving unique backup files"));
|
||||
}
|
||||
#endif
|
||||
print_opt("-D", "--boldtext", N_("Use bold instead of reverse video text"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-E", "--tabstospaces", N_("Convert typed tabs to spaces"));
|
||||
#endif
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
print_opt("-F", "--multibuffer",
|
||||
N_("Read a file into a new buffer by default"));
|
||||
if (!ISSET(RESTRICTED))
|
||||
print_opt("-F", "--multibuffer",
|
||||
N_("Read a file into a new buffer by default"));
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-G", "--locking", N_("Use (vim-style) lock files"));
|
||||
#endif
|
||||
#ifndef DISABLE_HISTORIES
|
||||
print_opt("-H", "--historylog",
|
||||
N_("Log & read search/replace string history"));
|
||||
if (!ISSET(RESTRICTED))
|
||||
print_opt("-H", "--historylog",
|
||||
N_("Log & read search/replace string history"));
|
||||
#endif
|
||||
#ifndef DISABLE_NANORC
|
||||
print_opt("-I", "--ignorercfiles", N_("Don't look at nanorc files"));
|
||||
if (!ISSET(RESTRICTED))
|
||||
print_opt("-I", "--ignorercfiles", N_("Don't look at nanorc files"));
|
||||
#endif
|
||||
print_opt("-K", "--rebindkeypad",
|
||||
N_("Fix numeric keypad key confusion problem"));
|
||||
@@ -873,12 +883,15 @@ void usage(void)
|
||||
#endif
|
||||
print_opt("-O", "--morespace", N_("Use one more line for editing"));
|
||||
#ifndef DISABLE_HISTORIES
|
||||
print_opt("-P", "--poslog", N_("Log & read location of cursor position"));
|
||||
if (!ISSET(RESTRICTED))
|
||||
print_opt("-P", "--positionlog",
|
||||
N_("Log & read location of cursor position"));
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
print_opt(_("-Q <str>"), _("--quotestr=<str>"), N_("Quoting string"));
|
||||
#endif
|
||||
print_opt("-R", "--restricted", N_("Restricted mode"));
|
||||
if (!ISSET(RESTRICTED))
|
||||
print_opt("-R", "--restricted", N_("Restricted mode"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-S", "--smooth", N_("Scroll by line instead of half-screen"));
|
||||
#endif
|
||||
@@ -893,13 +906,14 @@ void usage(void)
|
||||
N_("Detect word boundaries more accurately"));
|
||||
#endif
|
||||
#ifndef DISABLE_COLOR
|
||||
print_opt(_("-Y <str>"), _("--syntax=<str>"),
|
||||
N_("Syntax definition to use for coloring"));
|
||||
if (!ISSET(RESTRICTED))
|
||||
print_opt(_("-Y <str>"), _("--syntax=<str>"),
|
||||
N_("Syntax definition to use for coloring"));
|
||||
#endif
|
||||
print_opt("-c", "--const", N_("Constantly show cursor position"));
|
||||
print_opt("-c", "--constantshow", N_("Constantly show cursor position"));
|
||||
print_opt("-d", "--rebinddelete",
|
||||
N_("Fix Backspace/Delete confusion problem"));
|
||||
print_opt("-h", "--help", N_("Show this help text"));
|
||||
print_opt("-h", "--help", N_("Show this help text and exit"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-i", "--autoindent", N_("Automatically indent new lines"));
|
||||
print_opt("-k", "--cut", N_("Cut from cursor to end of line"));
|
||||
@@ -915,24 +929,30 @@ void usage(void)
|
||||
#endif
|
||||
print_opt("-p", "--preserve", N_("Preserve XON (^Q) and XOFF (^S) keys"));
|
||||
#ifndef DISABLE_NANORC
|
||||
print_opt("-q", "--quiet",
|
||||
N_("Silently ignore startup issues like rc file errors"));
|
||||
if (!ISSET(RESTRICTED))
|
||||
print_opt("-q", "--quiet",
|
||||
N_("Silently ignore startup issues like rc file errors"));
|
||||
#endif
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
print_opt(_("-r <#cols>"), _("--fill=<#cols>"),
|
||||
N_("Set hard-wrapping point at column #cols"));
|
||||
#endif
|
||||
#ifndef DISABLE_SPELLER
|
||||
print_opt(_("-s <prog>"), _("--speller=<prog>"),
|
||||
N_("Enable alternate speller"));
|
||||
if (!ISSET(RESTRICTED))
|
||||
print_opt(_("-s <prog>"), _("--speller=<prog>"),
|
||||
N_("Enable alternate speller"));
|
||||
#endif
|
||||
print_opt("-t", "--tempfile", N_("Auto save on exit, don't prompt"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-u", "--unix", N_("Save a file by default in Unix format"));
|
||||
#endif
|
||||
print_opt("-v", "--view", N_("View mode (read-only)"));
|
||||
#ifndef DISABLE_WRAPPING
|
||||
print_opt("-w", "--nowrap", N_("Don't hard-wrap long lines"));
|
||||
#endif
|
||||
print_opt("-x", "--nohelp", N_("Don't show the two help lines"));
|
||||
print_opt("-z", "--suspend", N_("Enable suspension"));
|
||||
if (!ISSET(RESTRICTED))
|
||||
print_opt("-z", "--suspend", N_("Enable suspension"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-$", "--softwrap", N_("Enable soft line wrapping"));
|
||||
#endif
|
||||
@@ -944,7 +964,7 @@ void usage(void)
|
||||
void version(void)
|
||||
{
|
||||
printf(_(" GNU nano, version %s\n"), VERSION);
|
||||
printf(" (C) 1999..2015 Free Software Foundation, Inc.\n");
|
||||
printf(" (C) 1999..2016 Free Software Foundation, Inc.\n");
|
||||
printf(
|
||||
_(" Email: nano@nano-editor.org Web: http://www.nano-editor.org/"));
|
||||
printf(_("\n Compiled options:"));
|
||||
@@ -1073,10 +1093,22 @@ int no_help(void)
|
||||
return ISSET(NO_HELP) ? 2 : 0;
|
||||
}
|
||||
|
||||
/* Indicate a disabled function on the statusbar. */
|
||||
void nano_disabled_msg(void)
|
||||
/* Indicate that the current file has no name, in a way that gets the
|
||||
* user's attention. This is used when trying to save a file with no
|
||||
* name with the TEMP_FILE flag set, just before the filename prompt. */
|
||||
void no_current_file_name_warning(void)
|
||||
{
|
||||
statusbar(_("Sorry, support for this function has been disabled"));
|
||||
curs_set(0);
|
||||
|
||||
/* Warn that the current file has no name. */
|
||||
statusbar(_("No file name"));
|
||||
beep();
|
||||
|
||||
/* Ensure that we see the warning. */
|
||||
doupdate();
|
||||
napms(1800);
|
||||
|
||||
curs_set(1);
|
||||
}
|
||||
|
||||
/* If the current file buffer has been modified, and the TEMP_FILE flag
|
||||
@@ -1100,20 +1132,9 @@ void do_exit(void)
|
||||
/* Otherwise, ask the user whether or not to save. */
|
||||
else {
|
||||
/* If the TEMP_FILE flag is set, and the current file doesn't
|
||||
* have a name, handle it the same way Pico does. */
|
||||
if (ISSET(TEMP_FILE)) {
|
||||
curs_set(0);
|
||||
|
||||
/* Warn that the current file has no name. */
|
||||
statusbar(_("No file name"));
|
||||
beep();
|
||||
|
||||
/* Ensure that we see the warning. */
|
||||
doupdate();
|
||||
napms(2000);
|
||||
|
||||
curs_set(1);
|
||||
}
|
||||
* have a name, warn the user before prompting for a name. */
|
||||
if (ISSET(TEMP_FILE))
|
||||
no_current_file_name_warning();
|
||||
|
||||
i = do_yesno_prompt(FALSE,
|
||||
_("Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? "));
|
||||
@@ -1125,25 +1146,29 @@ void do_exit(void)
|
||||
|
||||
/* If the user chose not to save, or if the user chose to save and
|
||||
* the save succeeded, we're ready to exit. */
|
||||
if (i == 0 || (i == 1 && do_writeout(TRUE))) {
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(LOCKING) && openfile->lock_filename)
|
||||
delete_lockfile(openfile->lock_filename);
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
/* Exit only if there are no more open file buffers. */
|
||||
if (!close_buffer(FALSE))
|
||||
#endif
|
||||
finish();
|
||||
/* If the user canceled, we go on. */
|
||||
} else if (i != 1)
|
||||
if (i == 0 || (i == 1 && do_writeout(TRUE)))
|
||||
close_and_go();
|
||||
else if (i != 1)
|
||||
statusbar(_("Cancelled"));
|
||||
|
||||
display_main_list();
|
||||
}
|
||||
|
||||
/* Close the current buffer, and terminate nano if it was the last. */
|
||||
void close_and_go(void)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
/* If there is a lockfile, remove it. */
|
||||
if (ISSET(LOCKING) && openfile->lock_filename)
|
||||
delete_lockfile(openfile->lock_filename);
|
||||
#endif
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
/* If there are no more open file buffers, jump off a cliff. */
|
||||
if (!close_buffer(FALSE))
|
||||
#endif
|
||||
finish();
|
||||
}
|
||||
|
||||
/* Another placeholder for function mapping. */
|
||||
void do_cancel(void)
|
||||
{
|
||||
@@ -1266,11 +1291,6 @@ RETSIGTYPE handle_hupterm(int signal)
|
||||
/* Handler for SIGTSTP (suspend). */
|
||||
RETSIGTYPE do_suspend(int signal)
|
||||
{
|
||||
if (ISSET(RESTRICTED)) {
|
||||
nano_disabled_msg();
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
/* Turn mouse support off. */
|
||||
disable_mouse_support();
|
||||
@@ -1302,6 +1322,10 @@ void do_suspend_void(void)
|
||||
{
|
||||
if (ISSET(SUSPEND))
|
||||
do_suspend(0);
|
||||
else {
|
||||
statusbar(_("Suspension is not enabled"));
|
||||
beep();
|
||||
}
|
||||
}
|
||||
|
||||
/* Handler for SIGCONT (continue after suspend). */
|
||||
@@ -1395,12 +1419,12 @@ void regenerate_screen(void)
|
||||
total_refresh();
|
||||
}
|
||||
|
||||
/* If allow is TRUE, block any SIGWINCH signals that we get, so that we
|
||||
* can deal with them later. If allow is FALSE, unblock any SIGWINCH
|
||||
* signals that we have, so that we can deal with them now. */
|
||||
void allow_pending_sigwinch(bool allow)
|
||||
/* If allow is FALSE, block any SIGWINCH signal. If allow is TRUE,
|
||||
* unblock SIGWINCH so any pending ones can be dealt with. */
|
||||
void allow_sigwinch(bool allow)
|
||||
{
|
||||
sigset_t winch;
|
||||
|
||||
sigemptyset(&winch);
|
||||
sigaddset(&winch, SIGWINCH);
|
||||
sigprocmask(allow ? SIG_UNBLOCK : SIG_BLOCK, &winch, NULL);
|
||||
@@ -1412,7 +1436,12 @@ void allow_pending_sigwinch(bool allow)
|
||||
void do_toggle(int flag)
|
||||
{
|
||||
bool enabled;
|
||||
const char *desc;
|
||||
|
||||
if (ISSET(RESTRICTED) && (flag == SUSPEND || flag == MULTIBUFFER ||
|
||||
flag == BACKUP_FILE || flag == NO_COLOR_SYNTAX)) {
|
||||
show_restricted_warning();
|
||||
return;
|
||||
}
|
||||
|
||||
TOGGLE(flag);
|
||||
|
||||
@@ -1430,12 +1459,10 @@ void do_toggle(int flag)
|
||||
case SUSPEND:
|
||||
signal_init();
|
||||
break;
|
||||
#ifndef DISABLE_NANORC
|
||||
case WHITESPACE_DISPLAY:
|
||||
titlebar(NULL);
|
||||
edit_refresh();
|
||||
break;
|
||||
#endif
|
||||
#ifndef DISABLE_COLOR
|
||||
case NO_COLOR_SYNTAX:
|
||||
#endif
|
||||
@@ -1456,8 +1483,7 @@ void do_toggle(int flag)
|
||||
)
|
||||
enabled = !enabled;
|
||||
|
||||
desc = (char *) _(flagtostr(flag));
|
||||
statusbar("%s %s", desc, enabled ? _("enabled") : _("disabled"));
|
||||
statusbar("%s %s", _(flagtostr(flag)), enabled ? _("enabled") : _("disabled"));
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
@@ -1637,7 +1663,6 @@ int do_input(bool allow_funcs)
|
||||
kbinput = (int *)nrealloc(kbinput, kbinput_len *
|
||||
sizeof(int));
|
||||
kbinput[kbinput_len - 1] = input;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1676,6 +1701,7 @@ int do_input(bool allow_funcs)
|
||||
}
|
||||
|
||||
if (have_shortcut) {
|
||||
const subnfunc *f = sctofunc(s);
|
||||
/* If the function associated with this shortcut is
|
||||
* cutting or copying text, remember this. */
|
||||
if (s->scfunc == do_cut_text_void
|
||||
@@ -1685,34 +1711,35 @@ int do_input(bool allow_funcs)
|
||||
)
|
||||
preserve = TRUE;
|
||||
|
||||
if (s->scfunc != 0) {
|
||||
const subnfunc *f = sctofunc((sc *) s);
|
||||
if (ISSET(VIEW_MODE) && f && !f->viewok)
|
||||
print_view_warning();
|
||||
else {
|
||||
if (s->scfunc == NULL) {
|
||||
statusbar("Internal error: shortcut without function!");
|
||||
return ERR;
|
||||
}
|
||||
if (ISSET(VIEW_MODE) && f && !f->viewok)
|
||||
print_view_warning();
|
||||
else {
|
||||
#ifndef NANO_TINY
|
||||
if (s->scfunc == do_toggle_void) {
|
||||
do_toggle(s->toggle);
|
||||
if (s->toggle != CUT_TO_END)
|
||||
preserve = TRUE;
|
||||
} else
|
||||
if (s->scfunc == do_toggle_void) {
|
||||
do_toggle(s->toggle);
|
||||
if (s->toggle != CUT_TO_END)
|
||||
preserve = TRUE;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/* Execute the function of the shortcut. */
|
||||
s->scfunc();
|
||||
{
|
||||
/* Execute the function of the shortcut. */
|
||||
s->scfunc();
|
||||
#ifndef DISABLE_COLOR
|
||||
if (f && !f->viewok && openfile->syntax != NULL
|
||||
&& openfile->syntax->nmultis > 0)
|
||||
reset_multis(openfile->current, FALSE);
|
||||
if (f && !f->viewok)
|
||||
reset_multis(openfile->current, FALSE);
|
||||
#endif
|
||||
if (edit_refresh_needed) {
|
||||
if (edit_refresh_needed) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "running edit_refresh() as edit_refresh_needed is true\n");
|
||||
fprintf(stderr, "running edit_refresh() as edit_refresh_needed is true\n");
|
||||
#endif
|
||||
edit_refresh();
|
||||
edit_refresh_needed = FALSE;
|
||||
}
|
||||
}
|
||||
edit_refresh();
|
||||
edit_refresh_needed = FALSE;
|
||||
} else if (s->scfunc == do_delete || s->scfunc == do_backspace)
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1830,140 +1857,6 @@ int do_mouse(void)
|
||||
}
|
||||
#endif /* !DISABLE_MOUSE */
|
||||
|
||||
#ifndef DISABLE_COLOR
|
||||
void alloc_multidata_if_needed(filestruct *fileptr)
|
||||
{
|
||||
if (!fileptr->multidata)
|
||||
fileptr->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
}
|
||||
|
||||
/* Precalculate the multi-line start and end regex info so we can
|
||||
* speed up rendering (with any hope at all...). */
|
||||
void precalc_multicolorinfo(void)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Entering precalculation of multiline color info\n");
|
||||
#endif
|
||||
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX)) {
|
||||
const colortype *tmpcolor = openfile->colorstrings;
|
||||
regmatch_t startmatch, endmatch;
|
||||
filestruct *fileptr, *endptr;
|
||||
time_t last_check = time(NULL), cur_check = 0;
|
||||
|
||||
/* Let us get keypresses to see if the user is trying to start
|
||||
* editing. Later we may want to throw up a statusbar message
|
||||
* before starting this if it takes too long to do this routine.
|
||||
* For now silently abort if they hit a key. */
|
||||
nodelay(edit, TRUE);
|
||||
|
||||
for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) {
|
||||
|
||||
/* If it's not a multi-line regex, amscray. */
|
||||
if (tmpcolor->end == NULL)
|
||||
continue;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Starting work on color id %d\n", tmpcolor->id);
|
||||
#endif
|
||||
|
||||
for (fileptr = openfile->fileage; fileptr != NULL; fileptr = fileptr->next) {
|
||||
int startx = 0;
|
||||
int nostart = 0;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "working on lineno %ld... ", (long)fileptr->lineno);
|
||||
#endif
|
||||
|
||||
alloc_multidata_if_needed(fileptr);
|
||||
|
||||
if ((cur_check = time(NULL)) - last_check > 1) {
|
||||
last_check = cur_check;
|
||||
if (wgetch(edit) != ERR)
|
||||
goto precalc_cleanup;
|
||||
}
|
||||
|
||||
while ((nostart = regexec(tmpcolor->start, &fileptr->data[startx], 1, &startmatch,
|
||||
(startx == 0) ? 0 : REG_NOTBOL)) == 0) {
|
||||
/* Look for an end, and start marking how many lines are
|
||||
* encompassed, which should speed up rendering later. */
|
||||
startx += startmatch.rm_eo;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "start found at pos %lu... ", (unsigned long)startx);
|
||||
#endif
|
||||
|
||||
/* Look first on this line for an end. */
|
||||
if (regexec(tmpcolor->end, &fileptr->data[startx], 1, &endmatch,
|
||||
(startx == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
startx += endmatch.rm_eo;
|
||||
fileptr->multidata[tmpcolor->id] |= CSTARTENDHERE;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "end found on this line\n");
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Nice, we didn't find the end regex on this line. Let's start looking for it. */
|
||||
for (endptr = fileptr->next; endptr != NULL; endptr = endptr->next) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "\nadvancing to line %ld to find end... ", (long)endptr->lineno);
|
||||
#endif
|
||||
/* Check for keyboard input, again. */
|
||||
if ((cur_check = time(NULL)) - last_check > 1) {
|
||||
last_check = cur_check;
|
||||
if (wgetch(edit) != ERR)
|
||||
goto precalc_cleanup;
|
||||
}
|
||||
if (regexec(tmpcolor->end, endptr->data, 1, &endmatch, 0) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (endptr == NULL) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "no end found, breaking out\n");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "end found\n");
|
||||
#endif
|
||||
/* We found it, we found it, la la la la la. Mark all
|
||||
* the lines in between and the end properly. */
|
||||
fileptr->multidata[tmpcolor->id] |= CENDAFTER;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "marking line %ld as CENDAFTER\n", (long)fileptr->lineno);
|
||||
#endif
|
||||
for (fileptr = fileptr->next; fileptr != endptr; fileptr = fileptr->next) {
|
||||
alloc_multidata_if_needed(fileptr);
|
||||
fileptr->multidata[tmpcolor->id] = CWHOLELINE;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "marking intermediary line %ld as CWHOLELINE\n", (long)fileptr->lineno);
|
||||
#endif
|
||||
}
|
||||
alloc_multidata_if_needed(endptr);
|
||||
fileptr->multidata[tmpcolor->id] |= CBEGINBEFORE;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "marking line %ld as CBEGINBEFORE\n", (long)fileptr->lineno);
|
||||
#endif
|
||||
/* Skip to the end point of the match. */
|
||||
startx = endmatch.rm_eo;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "jumping to line %ld pos %lu to continue\n", (long)fileptr->lineno, (unsigned long)startx);
|
||||
#endif
|
||||
}
|
||||
if (nostart && startx == 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "no match\n");
|
||||
#endif
|
||||
fileptr->multidata[tmpcolor->id] = CNONE;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
precalc_cleanup:
|
||||
nodelay(edit, FALSE);
|
||||
}
|
||||
#endif /* !DISABLE_COLOR */
|
||||
|
||||
/* The user typed output_len multibyte characters. Add them to the edit
|
||||
* buffer, filtering out all ASCII control characters if allow_cntrls is
|
||||
* TRUE. */
|
||||
@@ -1987,15 +1880,14 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
#endif
|
||||
|
||||
while (i < output_len) {
|
||||
/* If allow_cntrls is TRUE, convert nulls and newlines
|
||||
* properly. */
|
||||
/* If allow_cntrls is TRUE, convert nulls and newlines properly. */
|
||||
if (allow_cntrls) {
|
||||
/* Null to newline, if needed. */
|
||||
if (output[i] == '\0')
|
||||
output[i] = '\n';
|
||||
/* Newline to Enter, if needed. */
|
||||
else if (output[i] == '\n') {
|
||||
do_enter(FALSE);
|
||||
do_enter();
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
@@ -2006,28 +1898,24 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
|
||||
i += char_buf_len;
|
||||
|
||||
/* If allow_cntrls is FALSE, filter out an ASCII control
|
||||
* character. */
|
||||
if (!allow_cntrls && is_ascii_cntrl_char(*(output + i -
|
||||
char_buf_len)))
|
||||
/* If allow_cntrls is FALSE, filter out an ASCII control character. */
|
||||
if (!allow_cntrls && is_ascii_cntrl_char(*(output + i - char_buf_len)))
|
||||
continue;
|
||||
|
||||
/* If the NO_NEWLINES flag isn't set, when a character is
|
||||
* added to the magicline, it means we need a new magicline. */
|
||||
if (!ISSET(NO_NEWLINES) && openfile->filebot ==
|
||||
openfile->current)
|
||||
if (!ISSET(NO_NEWLINES) && openfile->filebot == openfile->current)
|
||||
new_magicline();
|
||||
|
||||
/* More dangerousness fun =) */
|
||||
openfile->current->data = charealloc(openfile->current->data,
|
||||
current_len + (char_buf_len * 2));
|
||||
current_len + (char_buf_len * 2));
|
||||
|
||||
assert(openfile->current_x <= current_len);
|
||||
|
||||
charmove(openfile->current->data + openfile->current_x +
|
||||
char_buf_len, openfile->current->data +
|
||||
openfile->current_x, current_len - openfile->current_x +
|
||||
char_buf_len);
|
||||
charmove(openfile->current->data + openfile->current_x + char_buf_len,
|
||||
openfile->current->data + openfile->current_x,
|
||||
current_len - openfile->current_x + char_buf_len);
|
||||
strncpy(openfile->current->data + openfile->current_x, char_buf,
|
||||
char_buf_len);
|
||||
current_len += char_buf_len;
|
||||
@@ -2038,9 +1926,8 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
add_undo(ADD);
|
||||
|
||||
/* Note that current_x has not yet been incremented. */
|
||||
if (openfile->mark_set && openfile->current ==
|
||||
openfile->mark_begin && openfile->current_x <
|
||||
openfile->mark_begin_x)
|
||||
if (openfile->mark_set && openfile->current == openfile->mark_begin &&
|
||||
openfile->current_x < openfile->mark_begin_x)
|
||||
openfile->mark_begin_x += char_buf_len;
|
||||
#endif
|
||||
|
||||
@@ -2056,13 +1943,6 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
if (do_wrap(openfile->current))
|
||||
edit_refresh_needed = TRUE;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_COLOR
|
||||
/* If color syntaxes are available and turned on, we need to
|
||||
* call edit_refresh(). */
|
||||
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX))
|
||||
edit_refresh_needed = TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -2080,6 +1960,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
#ifndef DISABLE_COLOR
|
||||
reset_multis(openfile->current, FALSE);
|
||||
#endif
|
||||
|
||||
if (edit_refresh_needed == TRUE) {
|
||||
edit_refresh();
|
||||
edit_refresh_needed = FALSE;
|
||||
@@ -2094,7 +1975,9 @@ int main(int argc, char **argv)
|
||||
/* Target line and column when specified on the command line. */
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
bool fill_used = FALSE;
|
||||
/* Was the fill option used? */
|
||||
/* Was the fill option used on the command line? */
|
||||
bool forced_wrapping = FALSE;
|
||||
/* Should long lines be automatically hard wrapped? */
|
||||
#endif
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
bool old_multibuffer;
|
||||
@@ -2122,7 +2005,7 @@ int main(int argc, char **argv)
|
||||
#ifndef DISABLE_COLOR
|
||||
{"syntax", 1, NULL, 'Y'},
|
||||
#endif
|
||||
{"const", 0, NULL, 'c'},
|
||||
{"constantshow", 0, NULL, 'c'},
|
||||
{"rebinddelete", 0, NULL, 'd'},
|
||||
{"help", 0, NULL, 'h'},
|
||||
{"nofollow", 0, NULL, 'l'},
|
||||
@@ -2156,12 +2039,14 @@ int main(int argc, char **argv)
|
||||
{"locking", 0, NULL, 'G'},
|
||||
{"historylog", 0, NULL, 'H'},
|
||||
{"noconvert", 0, NULL, 'N'},
|
||||
{"poslog", 0, NULL, 'P'},
|
||||
{"poslog", 0, NULL, 'P'}, /* deprecated form, remove in 2018 */
|
||||
{"positionlog", 0, NULL, 'P'},
|
||||
{"smooth", 0, NULL, 'S'},
|
||||
{"quickblank", 0, NULL, 'U'},
|
||||
{"wordbounds", 0, NULL, 'W'},
|
||||
{"autoindent", 0, NULL, 'i'},
|
||||
{"cut", 0, NULL, 'k'},
|
||||
{"unix", 0, NULL, 'u'},
|
||||
{"softwrap", 0, NULL, '$'},
|
||||
#endif
|
||||
{NULL, 0, NULL, 0}
|
||||
@@ -2201,11 +2086,11 @@ int main(int argc, char **argv)
|
||||
while ((optchr =
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
getopt_long(argc, argv,
|
||||
"ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tvwxz$",
|
||||
"ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tuvwxz$",
|
||||
long_options, NULL)
|
||||
#else
|
||||
getopt(argc, argv,
|
||||
"ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tvwxz$")
|
||||
"ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tuvwxz$")
|
||||
#endif
|
||||
) != -1) {
|
||||
switch (optchr) {
|
||||
@@ -2359,6 +2244,7 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
fill_used = TRUE;
|
||||
forced_wrapping = TRUE;
|
||||
break;
|
||||
#endif
|
||||
#ifndef DISABLE_SPELLER
|
||||
@@ -2369,6 +2255,11 @@ int main(int argc, char **argv)
|
||||
case 't':
|
||||
SET(TEMP_FILE);
|
||||
break;
|
||||
#ifndef NANO_TINY
|
||||
case 'u':
|
||||
SET(MAKE_IT_UNIX);
|
||||
break;
|
||||
#endif
|
||||
case 'v':
|
||||
SET(VIEW_MODE);
|
||||
break;
|
||||
@@ -2377,7 +2268,7 @@ int main(int argc, char **argv)
|
||||
SET(NO_WRAP);
|
||||
/* If both --fill and --nowrap are given on the
|
||||
* command line, the last given option wins. */
|
||||
fill_used = FALSE;
|
||||
forced_wrapping = FALSE;
|
||||
break;
|
||||
#endif
|
||||
case 'x':
|
||||
@@ -2511,9 +2402,9 @@ int main(int argc, char **argv)
|
||||
#endif /* !DISABLE_NANORC */
|
||||
|
||||
#ifndef DISABLE_WRAPPING
|
||||
/* Overwrite an rcfile "set nowrap" or --disable-wrapping-as-root
|
||||
* if a --fill option was given on the command line. */
|
||||
if (fill_used)
|
||||
/* Override a "set nowrap" in an rcfile (or a --disable-wrapping-as-root)
|
||||
* if --fill was given on the command line and not undone by --nowrap. */
|
||||
if (forced_wrapping)
|
||||
UNSET(NO_WRAP);
|
||||
#endif
|
||||
|
||||
@@ -2609,7 +2500,6 @@ int main(int argc, char **argv)
|
||||
if (matchbrackets == NULL)
|
||||
matchbrackets = mallocstrcpy(NULL, "(<[{)>]}");
|
||||
|
||||
#ifndef DISABLE_NANORC
|
||||
/* If whitespace wasn't specified, set its default value. If we're
|
||||
* using UTF-8, it's Unicode 00BB (Right-Pointing Double Angle
|
||||
* Quotation Mark) and Unicode 00B7 (Middle Dot). Otherwise, it's
|
||||
@@ -2628,7 +2518,6 @@ int main(int argc, char **argv)
|
||||
whitespace_len[1] = 1;
|
||||
}
|
||||
}
|
||||
#endif /* !DISABLE_NANORC */
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Initialize the search and replace strings. */
|
||||
@@ -2681,6 +2570,17 @@ int main(int argc, char **argv)
|
||||
interface_color_pair[FUNCTION_TAG].bright = FALSE;
|
||||
#endif
|
||||
|
||||
#if !defined(NANO_TINY) && defined(HAVE_KEY_DEFINED)
|
||||
const char *keyvalue;
|
||||
/* Ask ncurses for the key codes for Control+Left and Control+Right. */
|
||||
keyvalue = tigetstr("kLFT5");
|
||||
if (keyvalue != 0 && keyvalue != (char *)-1)
|
||||
controlleft = key_defined(keyvalue);
|
||||
keyvalue = tigetstr("kRIT5");
|
||||
if (keyvalue != 0 && keyvalue != (char *)-1)
|
||||
controlright = key_defined(keyvalue);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Main: open file\n");
|
||||
#endif
|
||||
@@ -2710,28 +2610,28 @@ int main(int argc, char **argv)
|
||||
ssize_t iline = 0, icol = 0;
|
||||
|
||||
for (; i < argc; i++) {
|
||||
/* If there's a +LINE or +LINE,COLUMN flag here, it is
|
||||
* followed by at least one other argument, the filename it
|
||||
* applies to. */
|
||||
if (i < argc - 1 && argv[i][0] == '+' && iline == 1 &&
|
||||
icol == 1)
|
||||
/* If there's a +LINE or +LINE,COLUMN flag here, it is followed
|
||||
* by at least one other argument: the filename it applies to. */
|
||||
if (i < argc - 1 && argv[i][0] == '+')
|
||||
parse_line_column(&argv[i][1], &iline, &icol);
|
||||
else {
|
||||
open_buffer(argv[i], FALSE);
|
||||
/* If opening fails, don't try to position the cursor. */
|
||||
if (!open_buffer(argv[i], FALSE))
|
||||
continue;
|
||||
|
||||
/* If a position was given on the command line, go there. */
|
||||
if (iline > 0 || icol > 0) {
|
||||
do_gotolinecolumn(iline, icol, FALSE, FALSE, FALSE,
|
||||
FALSE);
|
||||
iline = 1;
|
||||
icol = 1;
|
||||
do_gotolinecolumn(iline, icol, FALSE, FALSE);
|
||||
iline = 0;
|
||||
icol = 0;
|
||||
}
|
||||
#ifndef DISABLE_HISTORIES
|
||||
else {
|
||||
/* See if we have a POS history to use if we haven't overridden it. */
|
||||
ssize_t savedposline, savedposcol;
|
||||
/* If edited before, restore the last cursor position. */
|
||||
if (check_poshistory(argv[i], &savedposline, &savedposcol))
|
||||
do_gotolinecolumn(savedposline, savedposcol, FALSE, FALSE, FALSE,
|
||||
FALSE);
|
||||
do_gotolinecolumn(savedposline, savedposcol,
|
||||
FALSE, FALSE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -2739,16 +2639,13 @@ int main(int argc, char **argv)
|
||||
}
|
||||
#endif /* !DISABLE_MULTIBUFFER */
|
||||
|
||||
/* Read the first file on the command line into either the current
|
||||
* buffer or a new buffer, depending on whether multibuffer mode is
|
||||
* enabled. */
|
||||
/* Now read the first file on the command line into a new buffer. */
|
||||
if (optind < argc)
|
||||
open_buffer(argv[optind], FALSE);
|
||||
|
||||
/* We didn't open any files if all the command line arguments were
|
||||
* invalid files like directories or if there were no command line
|
||||
* arguments given. In this case, we have to load a blank buffer.
|
||||
* Also, we unset view mode to allow editing. */
|
||||
/* If all the command-line arguments were invalid files like directories,
|
||||
* or if there were no filenames given, we didn't open any file. In this
|
||||
* case, load a blank buffer. Also, unset view mode to allow editing. */
|
||||
if (openfile == NULL) {
|
||||
open_buffer("", FALSE);
|
||||
UNSET(VIEW_MODE);
|
||||
@@ -2763,21 +2660,15 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "Main: top and bottom win\n");
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_COLOR
|
||||
if (openfile->syntax)
|
||||
if (openfile->syntax->nmultis > 0)
|
||||
precalc_multicolorinfo();
|
||||
#endif
|
||||
|
||||
/* If a starting position was given on the command line, go there. */
|
||||
if (startline > 0 || startcol > 0)
|
||||
do_gotolinecolumn(startline, startcol, FALSE, FALSE, FALSE,
|
||||
FALSE);
|
||||
do_gotolinecolumn(startline, startcol, FALSE, FALSE);
|
||||
#ifndef DISABLE_HISTORIES
|
||||
else {
|
||||
/* See if we have a POS history to use if we haven't overridden it. */
|
||||
ssize_t savedposline, savedposcol;
|
||||
/* If the file was edited before, restore the last cursor position. */
|
||||
if (check_poshistory(argv[optind], &savedposline, &savedposcol))
|
||||
do_gotolinecolumn(savedposline, savedposcol, FALSE, FALSE, FALSE, FALSE);
|
||||
do_gotolinecolumn(savedposline, savedposcol, FALSE, FALSE);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
98
src/nano.h
98
src/nano.h
@@ -329,6 +329,10 @@ typedef struct undo {
|
||||
/* Where did this action begin or end. */
|
||||
char *strdata;
|
||||
/* String type data we will use for copying the affected line back. */
|
||||
size_t wassize;
|
||||
/* The file size before the action. */
|
||||
size_t newsize;
|
||||
/* The file size after the action. */
|
||||
int xflags;
|
||||
/* Some flag data we need. */
|
||||
|
||||
@@ -361,75 +365,57 @@ typedef struct poshiststruct {
|
||||
|
||||
typedef struct openfilestruct {
|
||||
char *filename;
|
||||
/* The current file's name. */
|
||||
/* The file's name. */
|
||||
filestruct *fileage;
|
||||
/* The current file's first line. */
|
||||
/* The file's first line. */
|
||||
filestruct *filebot;
|
||||
/* The current file's last line. */
|
||||
/* The file's last line. */
|
||||
filestruct *edittop;
|
||||
/* The current top of the edit window. */
|
||||
/* The current top of the edit window for this file. */
|
||||
filestruct *current;
|
||||
/* The current file's current line. */
|
||||
/* The current line for this file. */
|
||||
size_t totsize;
|
||||
/* The current file's total number of characters. */
|
||||
/* The file's total number of characters. */
|
||||
size_t current_x;
|
||||
/* The current file's x-coordinate position. */
|
||||
/* The file's x-coordinate position. */
|
||||
size_t placewewant;
|
||||
/* The current file's x position we would like. */
|
||||
/* The file's x position we would like. */
|
||||
ssize_t current_y;
|
||||
/* The current file's y-coordinate position. */
|
||||
/* The file's y-coordinate position. */
|
||||
bool modified;
|
||||
/* Whether the current file has been modified. */
|
||||
/* Whether the file has been modified. */
|
||||
#ifndef NANO_TINY
|
||||
bool mark_set;
|
||||
/* Whether the mark is on in the current file. */
|
||||
/* Whether the mark is on in this file. */
|
||||
filestruct *mark_begin;
|
||||
/* The current file's beginning marked line, if any. */
|
||||
/* The file's line where the mark is, if any. */
|
||||
size_t mark_begin_x;
|
||||
/* The current file's beginning marked line's x-coordinate
|
||||
* position, if any. */
|
||||
/* The file's mark's x-coordinate position, if any. */
|
||||
file_format fmt;
|
||||
/* The current file's format. */
|
||||
/* The file's format. */
|
||||
struct stat *current_stat;
|
||||
/* The current file's stat. */
|
||||
/* The file's current stat information. */
|
||||
undo *undotop;
|
||||
/* Top of the undo list. */
|
||||
/* The top of the undo list. */
|
||||
undo *current_undo;
|
||||
/* The current (i.e. next) level of undo. */
|
||||
undo_type last_action;
|
||||
const char *lock_filename;
|
||||
/* The type of the last action the user performed. */
|
||||
char *lock_filename;
|
||||
/* The path of the lockfile, if we created one. */
|
||||
#endif
|
||||
#ifndef DISABLE_COLOR
|
||||
syntaxtype *syntax;
|
||||
/* The syntax struct for this file, if any. */
|
||||
colortype *colorstrings;
|
||||
/* The current file's associated colors. */
|
||||
/* The file's associated colors. */
|
||||
#endif
|
||||
struct openfilestruct *next;
|
||||
/* Next node. */
|
||||
/* The next open file, if any. */
|
||||
struct openfilestruct *prev;
|
||||
/* Previous node. */
|
||||
/* The preceding open file, if any. */
|
||||
} openfilestruct;
|
||||
|
||||
typedef struct shortcut {
|
||||
const char *desc;
|
||||
/* The function's description, e.g. "Page Up". */
|
||||
#ifndef DISABLE_HELP
|
||||
const char *help;
|
||||
/* The help file entry text for this function. */
|
||||
bool blank_after;
|
||||
/* Whether there should be a blank line after the help entry
|
||||
* text for this function. */
|
||||
#endif
|
||||
bool viewok;
|
||||
/* Is this function allowed when in view mode? */
|
||||
void (*func)(void);
|
||||
/* The function to call when we get this key. */
|
||||
struct shortcut *next;
|
||||
/* Next shortcut. */
|
||||
} shortcut;
|
||||
|
||||
#ifndef DISABLE_NANORC
|
||||
typedef struct rcoption {
|
||||
const char *name;
|
||||
@@ -445,35 +431,38 @@ typedef struct sc {
|
||||
key_type type;
|
||||
/* What kind of command key it is, for convenience later. */
|
||||
int seq;
|
||||
/* The actual sequence to check on the type is determined. */
|
||||
int menu;
|
||||
/* What list this applies to. */
|
||||
/* The actual sequence to check once the type is determined. */
|
||||
int menus;
|
||||
/* Which menus this applies to. */
|
||||
void (*scfunc)(void);
|
||||
/* The function we're going to run. */
|
||||
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. */
|
||||
struct sc *next;
|
||||
/* Next in the list. */
|
||||
} sc;
|
||||
|
||||
typedef struct subnfunc {
|
||||
void (*scfunc)(void);
|
||||
/* What function this is. */
|
||||
/* The actual function to call. */
|
||||
int menus;
|
||||
/* In what menus this function applies. */
|
||||
const char *desc;
|
||||
/* The function's description, e.g. "Page Up". */
|
||||
/* The function's short description, for example "Where Is". */
|
||||
#ifndef DISABLE_HELP
|
||||
const char *help;
|
||||
/* The help file entry text for this function. */
|
||||
/* The help-screen text for this function. */
|
||||
bool blank_after;
|
||||
/* Whether there should be a blank line after the help entry
|
||||
* text for this function. */
|
||||
/* Whether there should be a blank line after the help text
|
||||
* for this function. */
|
||||
#endif
|
||||
bool viewok;
|
||||
/* Is this function allowed when in view mode? */
|
||||
long toggle;
|
||||
/* If this is a toggle, if nonzero what toggle to set. */
|
||||
/* If this is a toggle, which toggle to affect. */
|
||||
struct subnfunc *next;
|
||||
/* Next item in the list. */
|
||||
} subnfunc;
|
||||
@@ -528,7 +517,8 @@ enum
|
||||
SOFTWRAP,
|
||||
POS_HISTORY,
|
||||
LOCKING,
|
||||
NOREAD_MODE
|
||||
NOREAD_MODE,
|
||||
MAKE_IT_UNIX
|
||||
};
|
||||
|
||||
/* Flags for the menus in which a given function should be present. */
|
||||
@@ -548,7 +538,8 @@ enum
|
||||
#define MYESNO (1<<13)
|
||||
#define MLINTER (1<<14)
|
||||
/* This is an abbreviation for all menus except Help and YesNo. */
|
||||
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|MEXTCMD|MBROWSER|MWHEREISFILE|MGOTODIR|MSPELL|MLINTER)
|
||||
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\
|
||||
MEXTCMD|MBROWSER|MWHEREISFILE|MGOTODIR|MSPELL|MLINTER)
|
||||
|
||||
/* Control key sequences. Changing these would be very, very bad. */
|
||||
#define NANO_CONTROL_SPACE 0
|
||||
@@ -557,10 +548,9 @@ enum
|
||||
#define NANO_CONTROL_7 31
|
||||
#define NANO_CONTROL_8 127
|
||||
|
||||
/* Codes for "modified" Arrow keys. Chosen like this because some
|
||||
* terminals produce them, and they are beyond KEY_MAX of ncurses. */
|
||||
#define CONTROL_LEFT 539
|
||||
#define CONTROL_RIGHT 554
|
||||
/* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */
|
||||
#define CONTROL_LEFT 0x401
|
||||
#define CONTROL_RIGHT 0x402
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* An imaginary key for when we get a SIGWINCH (window resize). */
|
||||
|
||||
12
src/prompt.c
12
src/prompt.c
@@ -145,7 +145,7 @@ int do_statusbar_input(bool *ran_func, bool *finished,
|
||||
}
|
||||
|
||||
if (have_shortcut) {
|
||||
if (s->scfunc == do_tab || s->scfunc == do_enter_void)
|
||||
if (s->scfunc == do_tab || s->scfunc == do_enter)
|
||||
;
|
||||
else if (s->scfunc == total_refresh)
|
||||
total_statusbar_refresh(refresh_func);
|
||||
@@ -186,7 +186,7 @@ int do_statusbar_input(bool *ran_func, bool *finished,
|
||||
* set finished to TRUE to indicate that we're done. */
|
||||
if (got_enter) {
|
||||
get_input(NULL, 1);
|
||||
input = sc_seq_or(do_enter_void, 0);
|
||||
input = sc_seq_or(do_enter, 0);
|
||||
*finished = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -210,7 +210,7 @@ int do_statusbar_input(bool *ran_func, bool *finished,
|
||||
* functions and setting finished to TRUE to indicate
|
||||
* that we're done after running or trying to run their
|
||||
* associated functions. */
|
||||
f = sctofunc((sc *) s);
|
||||
f = sctofunc(s);
|
||||
if (s->scfunc != NULL) {
|
||||
*ran_func = TRUE;
|
||||
if (f && (!ISSET(VIEW_MODE) || f->viewok) &&
|
||||
@@ -809,7 +809,7 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs,
|
||||
|
||||
func = func_from_key(&kbinput);
|
||||
|
||||
if (func == do_cancel || func == do_enter_void)
|
||||
if (func == do_cancel || func == do_enter)
|
||||
break;
|
||||
|
||||
#ifndef DISABLE_TABCOMP
|
||||
@@ -927,7 +927,7 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs,
|
||||
* we've finished putting in an answer, reset the statusbar cursor
|
||||
* position too. */
|
||||
if (func) {
|
||||
if (func == do_cancel || func == do_enter_void || ran_func) {
|
||||
if (func == do_cancel || func == do_enter || ran_func) {
|
||||
statusbar_x = old_statusbar_x;
|
||||
statusbar_pww = old_pww;
|
||||
|
||||
@@ -1010,7 +1010,7 @@ int do_prompt(bool allow_tabs,
|
||||
* properly. */
|
||||
if (func == do_cancel)
|
||||
retval = -1;
|
||||
else if (func == do_enter_void)
|
||||
else if (func == do_enter)
|
||||
retval = (*answer == '\0') ? -2 : 0;
|
||||
|
||||
blank_statusbar();
|
||||
|
||||
79
src/proto.h
79
src/proto.h
@@ -35,6 +35,11 @@ extern bool meta_key;
|
||||
extern bool func_key;
|
||||
extern bool focusing;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
extern int controlleft;
|
||||
extern int controlright;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
extern ssize_t fill;
|
||||
extern ssize_t wrap_at;
|
||||
@@ -62,7 +67,7 @@ extern openfilestruct *openfile;
|
||||
extern char *matchbrackets;
|
||||
#endif
|
||||
|
||||
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
|
||||
#ifndef NANO_TINY
|
||||
extern char *whitespace;
|
||||
extern int whitespace_len[2];
|
||||
#endif
|
||||
@@ -247,6 +252,9 @@ bool is_valid_mbstring(const char *s);
|
||||
void set_colorpairs(void);
|
||||
void color_init(void);
|
||||
void color_update(void);
|
||||
void reset_multis(filestruct *fileptr, bool force);
|
||||
void alloc_multidata_if_needed(filestruct *fileptr);
|
||||
void precalc_multicolorinfo(void);
|
||||
#endif
|
||||
|
||||
/* All functions in cut.c. */
|
||||
@@ -260,7 +268,7 @@ void cut_to_eof(void);
|
||||
#endif
|
||||
void do_cut_text(
|
||||
#ifndef NANO_TINY
|
||||
bool copy_text, bool cut_till_eof, bool undoing
|
||||
bool copy_text, bool cut_till_eof
|
||||
#else
|
||||
void
|
||||
#endif
|
||||
@@ -274,9 +282,8 @@ void do_uncut_text(void);
|
||||
|
||||
/* All functions in files.c. */
|
||||
void make_new_buffer(void);
|
||||
void initialize_buffer(void);
|
||||
void initialize_buffer_text(void);
|
||||
void open_buffer(const char *filename, bool undoable);
|
||||
bool open_buffer(const char *filename, bool undoable);
|
||||
#ifndef DISABLE_SPELLER
|
||||
void replace_buffer(const char *filename);
|
||||
#endif
|
||||
@@ -287,8 +294,7 @@ void switch_to_prev_buffer_void(void);
|
||||
void switch_to_next_buffer_void(void);
|
||||
bool close_buffer(bool quiet);
|
||||
#endif
|
||||
filestruct *read_line(char *buf, filestruct *prevnode, bool
|
||||
*first_line_ins, size_t buf_len);
|
||||
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);
|
||||
@@ -319,8 +325,11 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
bool write_marked_file(const char *name, FILE *f_open, bool tmp,
|
||||
append_type append);
|
||||
#endif
|
||||
bool do_writeout(bool exiting);
|
||||
int do_writeout(bool exiting);
|
||||
void do_writeout_void(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_savefile(void);
|
||||
#endif
|
||||
char *real_dir_from_tilde(const char *buf);
|
||||
#if !defined(DISABLE_TABCOMP) || !defined(DISABLE_BROWSER)
|
||||
int diralphasort(const void *va, const void *vb);
|
||||
@@ -361,17 +370,17 @@ void shortcut_init(void);
|
||||
void set_lint_or_format_shortcuts(void);
|
||||
void set_spell_shortcuts(void);
|
||||
#endif
|
||||
const subnfunc *sctofunc(sc *s);
|
||||
const subnfunc *sctofunc(const sc *s);
|
||||
const char *flagtostr(int flag);
|
||||
sc *strtosc(char *input);
|
||||
int strtomenu(char *input);
|
||||
sc *strtosc(const char *input);
|
||||
int strtomenu(const char *input);
|
||||
#ifdef DEBUG
|
||||
void thanks_for_all_the_fish(void);
|
||||
#endif
|
||||
|
||||
/* All functions in help.c. */
|
||||
#ifndef DISABLE_HELP
|
||||
void do_help(void (*refresh_func)(void));
|
||||
void do_help(void);
|
||||
void help_init(void);
|
||||
functionptrtype parse_help_input(int *kbinput);
|
||||
size_t help_line_len(const char *ptr);
|
||||
@@ -392,7 +401,7 @@ void do_para_end_void(void);
|
||||
#ifndef NANO_TINY
|
||||
bool do_next_word(bool allow_punct, bool allow_update);
|
||||
void do_next_word_void(void);
|
||||
bool do_prev_word(bool allow_punct, bool allow_update);
|
||||
void do_prev_word(bool allow_punct, bool allow_update);
|
||||
void do_prev_word_void(void);
|
||||
#endif
|
||||
void do_home(void);
|
||||
@@ -425,9 +434,8 @@ void do_right(void);
|
||||
/* All functions in nano.c. */
|
||||
filestruct *make_new_node(filestruct *prevnode);
|
||||
filestruct *copy_node(const filestruct *src);
|
||||
void splice_node(filestruct *begin, filestruct *newnode, filestruct
|
||||
*end);
|
||||
void unlink_node(const filestruct *fileptr);
|
||||
void splice_node(filestruct *afterthis, filestruct *newnode);
|
||||
void unlink_node(filestruct *fileptr);
|
||||
void delete_node(filestruct *fileptr);
|
||||
filestruct *copy_filestruct(const filestruct *src);
|
||||
void free_filestruct(filestruct *src);
|
||||
@@ -447,6 +455,10 @@ void delete_opennode(openfilestruct *fileptr);
|
||||
void free_openfilestruct(openfilestruct *src);
|
||||
#endif
|
||||
void print_view_warning(void);
|
||||
void show_restricted_warning(void);
|
||||
#ifdef DISABLE_HELP
|
||||
void say_there_is_no_help(void);
|
||||
#endif
|
||||
void finish(void);
|
||||
void die(const char *msg, ...);
|
||||
void die_save_file(const char *die_filename
|
||||
@@ -469,8 +481,9 @@ void usage(void);
|
||||
void version(void);
|
||||
int more_space(void);
|
||||
int no_help(void);
|
||||
void nano_disabled_msg(void);
|
||||
void no_current_file_name_warning(void);
|
||||
void do_exit(void);
|
||||
void close_and_go(void);
|
||||
void signal_init(void);
|
||||
RETSIGTYPE handle_hupterm(int signal);
|
||||
RETSIGTYPE do_suspend(int signal);
|
||||
@@ -478,7 +491,7 @@ RETSIGTYPE do_continue(int signal);
|
||||
#ifndef NANO_TINY
|
||||
RETSIGTYPE handle_sigwinch(int signal);
|
||||
void regenerate_screen(void);
|
||||
void allow_pending_sigwinch(bool allow);
|
||||
void allow_sigwinch(bool allow);
|
||||
void do_toggle(int flag);
|
||||
#endif
|
||||
void do_toggle_void(void);
|
||||
@@ -561,8 +574,6 @@ void parse_include(char *ptr);
|
||||
short color_to_short(const char *colorname, bool *bright);
|
||||
void parse_colors(char *ptr, bool icase);
|
||||
bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright);
|
||||
void reset_multis(filestruct *fileptr, bool force);
|
||||
void alloc_multidata_if_needed(filestruct *fileptr);
|
||||
#endif
|
||||
void parse_rcfile(FILE *rcstream
|
||||
#ifndef DISABLE_COLOR
|
||||
@@ -588,6 +599,10 @@ bool findnextstr(
|
||||
const char *needle, size_t *needle_len);
|
||||
void findnextstr_wrap_reset(void);
|
||||
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
|
||||
@@ -602,14 +617,10 @@ ssize_t do_replace_loop(
|
||||
bool *canceled, const filestruct *real_current, size_t
|
||||
*real_current_x, const char *needle);
|
||||
void do_replace(void);
|
||||
void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
bool interactive, bool save_pos, bool allow_update);
|
||||
void do_gotolinecolumn_void(void);
|
||||
#ifndef DISABLE_SPELLER
|
||||
void do_gotopos(ssize_t pos_line, size_t pos_x, ssize_t pos_y, size_t
|
||||
pos_pww);
|
||||
#endif
|
||||
void goto_line_posx(ssize_t line, size_t pos_x);
|
||||
void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
bool interactive);
|
||||
void do_gotolinecolumn_void(void);
|
||||
#ifndef NANO_TINY
|
||||
bool find_bracket_match(bool reverse, const char *bracket_set);
|
||||
void do_find_bracket(void);
|
||||
@@ -636,6 +647,10 @@ void do_mark(void);
|
||||
#endif
|
||||
void do_delete(void);
|
||||
void do_backspace(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_cut_prev_word(void);
|
||||
void do_cut_next_word(void);
|
||||
#endif
|
||||
void do_tab(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_indent(ssize_t cols);
|
||||
@@ -644,8 +659,7 @@ void do_unindent(void);
|
||||
void do_undo(void);
|
||||
void do_redo(void);
|
||||
#endif
|
||||
void do_enter(bool undoing);
|
||||
void do_enter_void(void);
|
||||
void do_enter(void);
|
||||
#ifndef NANO_TINY
|
||||
RETSIGTYPE cancel_command(int signal);
|
||||
bool execute_command(const char *command);
|
||||
@@ -734,6 +748,7 @@ void new_magicline(void);
|
||||
void remove_magicline(void);
|
||||
void mark_order(const filestruct **top, size_t *top_x, const filestruct
|
||||
**bot, size_t *bot_x, bool *right_side_up);
|
||||
void discard_until(undo *thisone);
|
||||
void add_undo(undo_type action);
|
||||
void update_undo(undo_type action);
|
||||
#endif
|
||||
@@ -744,7 +759,7 @@ void dump_filestruct(const filestruct *inptr);
|
||||
void dump_filestruct_reverse(void);
|
||||
#endif
|
||||
|
||||
/* All functions in winio.c. */
|
||||
/* Most functions in winio.c. */
|
||||
void get_key_buffer(WINDOW *win);
|
||||
size_t get_key_buffer_len(void);
|
||||
void unget_input(int *input, size_t input_len);
|
||||
@@ -752,9 +767,8 @@ void unget_kbinput(int kbinput, bool metakey, bool funckey);
|
||||
int *get_input(WINDOW *win, size_t input_len);
|
||||
int get_kbinput(WINDOW *win);
|
||||
int parse_kbinput(WINDOW *win);
|
||||
int get_escape_seq_kbinput(const int *seq, size_t seq_len);
|
||||
int get_escape_seq_abcd(int kbinput);
|
||||
int parse_escape_seq_kbinput(WINDOW *win, int kbinput);
|
||||
int arrow_from_abcd(int kbinput);
|
||||
int parse_escape_sequence(WINDOW *win, int kbinput);
|
||||
int get_byte_kbinput(int kbinput);
|
||||
#ifdef ENABLE_UTF8
|
||||
long add_unicode_digit(int kbinput, long factor, long *uni);
|
||||
@@ -819,6 +833,7 @@ void mac_format_void(void);
|
||||
void append_void(void);
|
||||
void prepend_void(void);
|
||||
void backup_file_void(void);
|
||||
void discard_buffer(void);
|
||||
void new_buffer_void(void);
|
||||
void backwards_void(void);
|
||||
void goto_dir_void(void);
|
||||
|
||||
44
src/rcfile.c
44
src/rcfile.c
@@ -38,7 +38,8 @@ static const rcoption rcopts[] = {
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
{"brackets", 0},
|
||||
#endif
|
||||
{"const", CONST_UPDATE},
|
||||
{"const", CONST_UPDATE}, /* deprecated form, remove in 2018 */
|
||||
{"constantshow", CONST_UPDATE},
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
{"fill", 0},
|
||||
#endif
|
||||
@@ -62,7 +63,8 @@ static const rcoption rcopts[] = {
|
||||
{"operatingdir", 0},
|
||||
#endif
|
||||
#ifndef DISABLE_HISTORIES
|
||||
{"poslog", POS_HISTORY},
|
||||
{"poslog", POS_HISTORY}, /* deprecated form, remove in 2018 */
|
||||
{"positionlog", POS_HISTORY},
|
||||
#endif
|
||||
{"preserve", PRESERVE},
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
@@ -98,6 +100,7 @@ static const rcoption rcopts[] = {
|
||||
{"smooth", SMOOTH_SCROLL},
|
||||
{"softwrap", SOFTWRAP},
|
||||
{"tabstospaces", TABS_TO_SPACES},
|
||||
{"unix", MAKE_IT_UNIX},
|
||||
{"whitespace", 0},
|
||||
{"wordbounds", WORD_BOUNDS},
|
||||
#endif
|
||||
@@ -442,7 +445,7 @@ void parse_binding(char *ptr, bool dobind)
|
||||
|
||||
if (strlen(keycopy) < 2) {
|
||||
rcfile_error(N_("Key name is too short"));
|
||||
return;
|
||||
goto free_copy;
|
||||
}
|
||||
|
||||
/* Uppercase only the first two or three characters of the key name. */
|
||||
@@ -453,7 +456,7 @@ void parse_binding(char *ptr, bool dobind)
|
||||
keycopy[2] = toupper(keycopy[2]);
|
||||
else {
|
||||
rcfile_error(N_("Key name is too short"));
|
||||
return;
|
||||
goto free_copy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,7 +466,7 @@ void parse_binding(char *ptr, bool dobind)
|
||||
keycopy[1] = tolower(keycopy[1]);
|
||||
else if (keycopy[0] != '^' && keycopy[0] != 'M' && keycopy[0] != 'F') {
|
||||
rcfile_error(N_("Key name must begin with \"^\", \"M\", or \"F\""));
|
||||
return;
|
||||
goto free_copy;
|
||||
}
|
||||
|
||||
if (dobind) {
|
||||
@@ -472,7 +475,7 @@ void parse_binding(char *ptr, bool dobind)
|
||||
|
||||
if (funcptr[0] == '\0') {
|
||||
rcfile_error(N_("Must specify a function to bind the key to"));
|
||||
return;
|
||||
goto free_copy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -482,21 +485,21 @@ void parse_binding(char *ptr, bool dobind)
|
||||
if (menuptr[0] == '\0') {
|
||||
/* TRANSLATORS: Do not translate the word "all". */
|
||||
rcfile_error(N_("Must specify a menu (or \"all\") in which to bind/unbind the key"));
|
||||
return;
|
||||
goto free_copy;
|
||||
}
|
||||
|
||||
if (dobind) {
|
||||
newsc = strtosc(funcptr);
|
||||
if (newsc == NULL) {
|
||||
rcfile_error(N_("Cannot map name \"%s\" to a function"), funcptr);
|
||||
return;
|
||||
goto free_copy;
|
||||
}
|
||||
}
|
||||
|
||||
menu = strtomenu(menuptr);
|
||||
if (menu < 1) {
|
||||
rcfile_error(N_("Cannot map name \"%s\" to a menu"), menuptr);
|
||||
return;
|
||||
goto free_copy;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -529,11 +532,11 @@ void parse_binding(char *ptr, bool dobind)
|
||||
if (!menu) {
|
||||
rcfile_error(N_("Function '%s' does not exist in menu '%s'"), funcptr, menuptr);
|
||||
free(newsc);
|
||||
return;
|
||||
goto free_copy;
|
||||
}
|
||||
|
||||
newsc->keystr = keycopy;
|
||||
newsc->menu = menu;
|
||||
newsc->menus = menu;
|
||||
newsc->type = strtokeytype(newsc->keystr);
|
||||
assign_keyinfo(newsc);
|
||||
#ifdef DEBUG
|
||||
@@ -544,25 +547,36 @@ void parse_binding(char *ptr, bool dobind)
|
||||
if (check_bad_binding(newsc)) {
|
||||
rcfile_error(N_("Sorry, keystroke \"%s\" may not be rebound"), newsc->keystr);
|
||||
free(newsc);
|
||||
return;
|
||||
goto free_copy;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now find and delete any existing same shortcut in the menu(s). */
|
||||
for (s = sclist; s != NULL; s = s->next) {
|
||||
if (((s->menu & menu)) && !strcmp(s->keystr, keycopy)) {
|
||||
if ((s->menus & menu) && !strcmp(s->keystr, keycopy)) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "deleting entry from menu %x\n", s->menu);
|
||||
fprintf(stderr, "deleting entry from among menus %x\n", s->menus);
|
||||
#endif
|
||||
s->menu &= ~menu;
|
||||
s->menus &= ~menu;
|
||||
}
|
||||
}
|
||||
|
||||
if (dobind) {
|
||||
/* If this is a toggle, copy its sequence number. */
|
||||
if (newsc->scfunc == do_toggle_void) {
|
||||
for (s = sclist; s != NULL; s = s->next)
|
||||
if (s->scfunc == do_toggle_void && s->toggle == newsc->toggle)
|
||||
newsc->ordinal = s->ordinal;
|
||||
} else
|
||||
newsc->ordinal = 0;
|
||||
/* Add the new shortcut at the start of the list. */
|
||||
newsc->next = sclist;
|
||||
sclist = newsc;
|
||||
return;
|
||||
}
|
||||
|
||||
free_copy:
|
||||
free(keycopy);
|
||||
}
|
||||
|
||||
|
||||
|
||||
145
src/search.c
145
src/search.c
@@ -236,8 +236,7 @@ int search_init(bool replacing, bool use_answer)
|
||||
return -2; /* Call the opposite search function. */
|
||||
} else if (func == do_gotolinecolumn_void) {
|
||||
do_gotolinecolumn(openfile->current->lineno,
|
||||
openfile->placewewant + 1, TRUE, TRUE, FALSE,
|
||||
TRUE);
|
||||
openfile->placewewant + 1, TRUE, TRUE);
|
||||
/* Put answer up on the statusbar and
|
||||
* fall through. */
|
||||
return 3;
|
||||
@@ -474,6 +473,31 @@ void do_search(void)
|
||||
search_replace_abort();
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Search in the backward direction for the next occurrence. */
|
||||
void do_findprevious(void)
|
||||
{
|
||||
if ISSET(BACKWARDS_SEARCH)
|
||||
do_research();
|
||||
else {
|
||||
SET(BACKWARDS_SEARCH);
|
||||
do_research();
|
||||
UNSET(BACKWARDS_SEARCH);
|
||||
}
|
||||
}
|
||||
|
||||
/* Search in the forward direction for the next occurrence. */
|
||||
void do_findnext(void)
|
||||
{
|
||||
if ISSET(BACKWARDS_SEARCH) {
|
||||
UNSET(BACKWARDS_SEARCH);
|
||||
do_research();
|
||||
SET(BACKWARDS_SEARCH);
|
||||
} else
|
||||
do_research();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
|
||||
/* Search for the last string without prompting. */
|
||||
void do_research(void)
|
||||
@@ -522,17 +546,13 @@ void do_research(void)
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* Calculate the size of the replacement text, taking possible
|
||||
* subexpressions \1 to \9 into account. Return the replacement
|
||||
* text in the passed string only when create is TRUE. */
|
||||
int replace_regexp(char *string, bool create)
|
||||
{
|
||||
/* We have a split personality here. If create is FALSE, just
|
||||
* calculate the size of the replacement line (necessary because of
|
||||
* subexpressions \1 to \9 in the replaced text). */
|
||||
|
||||
const char *c = last_replace;
|
||||
size_t search_match_count = regmatches[0].rm_eo -
|
||||
regmatches[0].rm_so;
|
||||
size_t new_line_size = strlen(openfile->current->data) + 1 -
|
||||
search_match_count;
|
||||
size_t replacement_size = 0;
|
||||
|
||||
/* Iterate through the replacement text to handle subexpression
|
||||
* replacement using \1, \2, \3, etc. */
|
||||
@@ -544,7 +564,7 @@ int replace_regexp(char *string, bool create)
|
||||
if (create)
|
||||
*string++ = *c;
|
||||
c++;
|
||||
new_line_size++;
|
||||
replacement_size++;
|
||||
} else {
|
||||
size_t i = regmatches[num].rm_eo - regmatches[num].rm_so;
|
||||
|
||||
@@ -552,7 +572,7 @@ int replace_regexp(char *string, bool create)
|
||||
c += 2;
|
||||
|
||||
/* But add the length of the subexpression to new_size. */
|
||||
new_line_size += i;
|
||||
replacement_size += i;
|
||||
|
||||
/* And if create is TRUE, append the result of the
|
||||
* subexpression match to the new line. */
|
||||
@@ -567,25 +587,26 @@ int replace_regexp(char *string, bool create)
|
||||
if (create)
|
||||
*string = '\0';
|
||||
|
||||
return new_line_size;
|
||||
return replacement_size;
|
||||
}
|
||||
#endif /* HAVE_REGEX_H */
|
||||
|
||||
/* Return a copy of the current line with one needle replaced. */
|
||||
char *replace_line(const char *needle)
|
||||
{
|
||||
char *copy;
|
||||
size_t new_line_size, search_match_count;
|
||||
size_t match_len;
|
||||
size_t new_line_size = strlen(openfile->current->data) + 1;
|
||||
|
||||
/* Calculate the size of the new line. */
|
||||
/* First adjust the size of the new line for the change. */
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(USE_REGEXP)) {
|
||||
search_match_count = regmatches[0].rm_eo - regmatches[0].rm_so;
|
||||
new_line_size = replace_regexp(NULL, FALSE);
|
||||
match_len = regmatches[0].rm_eo - regmatches[0].rm_so;
|
||||
new_line_size += replace_regexp(NULL, FALSE) - match_len;
|
||||
} else {
|
||||
#endif
|
||||
search_match_count = strlen(needle);
|
||||
new_line_size = strlen(openfile->current->data) -
|
||||
search_match_count + strlen(answer) + 1;
|
||||
match_len = strlen(needle);
|
||||
new_line_size += strlen(answer) - match_len;
|
||||
#ifdef HAVE_REGEX_H
|
||||
}
|
||||
#endif
|
||||
@@ -593,10 +614,10 @@ char *replace_line(const char *needle)
|
||||
/* Create the buffer. */
|
||||
copy = charalloc(new_line_size);
|
||||
|
||||
/* The head of the original line. */
|
||||
/* Copy the head of the original line. */
|
||||
strncpy(copy, openfile->current->data, openfile->current_x);
|
||||
|
||||
/* The replacement text. */
|
||||
/* Add the replacement text. */
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(USE_REGEXP))
|
||||
replace_regexp(copy + openfile->current_x, TRUE);
|
||||
@@ -604,11 +625,10 @@ char *replace_line(const char *needle)
|
||||
#endif
|
||||
strcpy(copy + openfile->current_x, answer);
|
||||
|
||||
/* The tail of the original line. */
|
||||
assert(openfile->current_x + search_match_count <= strlen(openfile->current->data));
|
||||
assert(openfile->current_x + match_len <= strlen(openfile->current->data));
|
||||
|
||||
strcat(copy, openfile->current->data + openfile->current_x +
|
||||
search_match_count);
|
||||
/* Copy the tail of the original line. */
|
||||
strcat(copy, openfile->current->data + openfile->current_x + match_len);
|
||||
|
||||
return copy;
|
||||
}
|
||||
@@ -726,14 +746,12 @@ ssize_t do_replace_loop(
|
||||
length_change = strlen(copy) - strlen(openfile->current->data);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If the mark was on and (mark_begin, mark_begin_x) was the
|
||||
* top of it, don't change mark_begin_x. */
|
||||
if (!old_mark_set || !right_side_up) {
|
||||
/* Keep mark_begin_x in sync with the text changes. */
|
||||
/* If the mark was on and it was located after the cursor,
|
||||
* then adjust its x position for any text length changes. */
|
||||
if (old_mark_set && !right_side_up) {
|
||||
if (openfile->current == openfile->mark_begin &&
|
||||
openfile->mark_begin_x > openfile->current_x) {
|
||||
if (openfile->mark_begin_x < openfile->current_x +
|
||||
match_len)
|
||||
if (openfile->mark_begin_x < openfile->current_x + match_len)
|
||||
openfile->mark_begin_x = openfile->current_x;
|
||||
else
|
||||
openfile->mark_begin_x += length_change;
|
||||
@@ -741,11 +759,10 @@ ssize_t do_replace_loop(
|
||||
}
|
||||
}
|
||||
|
||||
/* If the mark was on and (current, current_x) was the top
|
||||
* of it, don't change real_current_x. */
|
||||
/* If the mark was not on or it was before the cursor, then
|
||||
* adjust the cursor's x position for any text length changes. */
|
||||
if (!old_mark_set || right_side_up) {
|
||||
#endif
|
||||
/* Keep real_current_x in sync with the text changes. */
|
||||
if (openfile->current == real_current &&
|
||||
openfile->current_x <= *real_current_x) {
|
||||
if (*real_current_x < openfile->current_x + match_len)
|
||||
@@ -757,6 +774,12 @@ ssize_t do_replace_loop(
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* Don't find the same zero-length match again. */
|
||||
if (match_len == 0)
|
||||
match_len++;
|
||||
#endif
|
||||
|
||||
/* Set the cursor at the last character of the replacement
|
||||
* text, so searching will resume after the replacement
|
||||
* text. Note that current_x might be set to (size_t)-1
|
||||
@@ -766,9 +789,8 @@ ssize_t do_replace_loop(
|
||||
#endif
|
||||
openfile->current_x += match_len + length_change - 1;
|
||||
|
||||
/* Clean up. */
|
||||
openfile->totsize += mbstrlen(copy) -
|
||||
mbstrlen(openfile->current->data);
|
||||
/* Update the file size, and put the changed line into place. */
|
||||
openfile->totsize += mbstrlen(copy) - mbstrlen(openfile->current->data);
|
||||
free(openfile->current->data);
|
||||
openfile->current->data = copy;
|
||||
|
||||
@@ -913,8 +935,8 @@ void do_replace(void)
|
||||
/* Go to the specified line and x position. */
|
||||
void goto_line_posx(ssize_t line, size_t pos_x)
|
||||
{
|
||||
for (openfile->current = openfile->fileage; openfile->current != openfile->filebot &&
|
||||
openfile->current->next != NULL && line > 1; line--)
|
||||
for (openfile->current = openfile->fileage; line > 1 &&
|
||||
openfile->current != openfile->filebot; line--)
|
||||
openfile->current = openfile->current->next;
|
||||
|
||||
openfile->current_x = pos_x;
|
||||
@@ -924,11 +946,10 @@ void goto_line_posx(ssize_t line, size_t pos_x)
|
||||
}
|
||||
|
||||
/* Go to the specified line and column, or ask for them if interactive
|
||||
* is TRUE. Save the x-coordinate and y-coordinate if save_pos is TRUE.
|
||||
* Update the screen afterwards if allow_update is TRUE. Note that both
|
||||
* the line and column numbers should be one-based. */
|
||||
* is TRUE. In the latter case also update the screen afterwards.
|
||||
* Note that both the line and column number should be one-based. */
|
||||
void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
bool interactive, bool save_pos, bool allow_update)
|
||||
bool interactive)
|
||||
{
|
||||
if (interactive) {
|
||||
char *ans = mallocstrcpy(NULL, answer);
|
||||
@@ -990,13 +1011,11 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
openfile->current_x = actual_x(openfile->current->data, column - 1);
|
||||
openfile->placewewant = column - 1;
|
||||
|
||||
/* Put the top line of the edit window in range of the current line.
|
||||
* If save_pos is TRUE, don't change the cursor position when doing
|
||||
* it. */
|
||||
edit_update(save_pos ? NONE : CENTER);
|
||||
/* Put the top line of the edit window in range of the current line. */
|
||||
edit_update(CENTER);
|
||||
|
||||
/* If allow_update is TRUE, update the screen. */
|
||||
if (allow_update) {
|
||||
/* When in interactive mode, update the screen. */
|
||||
if (interactive) {
|
||||
edit_refresh();
|
||||
display_main_list();
|
||||
}
|
||||
@@ -1006,27 +1025,9 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
void do_gotolinecolumn_void(void)
|
||||
{
|
||||
do_gotolinecolumn(openfile->current->lineno,
|
||||
openfile->placewewant + 1, FALSE, TRUE, FALSE, TRUE);
|
||||
openfile->placewewant + 1, FALSE, TRUE);
|
||||
}
|
||||
|
||||
#ifndef DISABLE_SPELLER
|
||||
/* Go to the line with the number specified in pos_line, the
|
||||
* x-coordinate specified in pos_x, the y-coordinate specified in pos_y,
|
||||
* and the place we want specified in pos_pww. */
|
||||
void do_gotopos(ssize_t pos_line, size_t pos_x, ssize_t pos_y, size_t
|
||||
pos_pww)
|
||||
{
|
||||
/* Since do_gotolinecolumn() resets the x-coordinate but not the
|
||||
* y-coordinate, set the coordinates up this way. */
|
||||
openfile->current_y = pos_y;
|
||||
do_gotolinecolumn(pos_line, pos_x + 1, FALSE, FALSE, TRUE, TRUE);
|
||||
|
||||
/* Set the rest of the coordinates up. */
|
||||
openfile->placewewant = pos_pww;
|
||||
update_line(openfile->current, pos_x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Search for a match to one of the two characters in bracket_set. If
|
||||
* reverse is TRUE, search backwards for the leftmost bracket.
|
||||
@@ -1123,7 +1124,7 @@ void do_find_bracket(void)
|
||||
|
||||
ch = openfile->current->data + openfile->current_x;
|
||||
|
||||
if (ch == '\0' || (ch = mbstrchr(matchbrackets, ch)) == NULL) {
|
||||
if ((ch = mbstrchr(matchbrackets, ch)) == NULL) {
|
||||
statusbar(_("Not a bracket"));
|
||||
return;
|
||||
}
|
||||
@@ -1284,7 +1285,6 @@ void update_history(filestruct **h, const char *s)
|
||||
foo = p;
|
||||
bar = p->next;
|
||||
unlink_node(foo);
|
||||
delete_node(foo);
|
||||
renumber(bar);
|
||||
}
|
||||
|
||||
@@ -1296,13 +1296,12 @@ void update_history(filestruct **h, const char *s)
|
||||
|
||||
*hage = (*hage)->next;
|
||||
unlink_node(foo);
|
||||
delete_node(foo);
|
||||
renumber(*hage);
|
||||
}
|
||||
|
||||
/* Add the new entry to the end. */
|
||||
(*hbot)->data = mallocstrcpy((*hbot)->data, s);
|
||||
splice_node(*hbot, make_new_node(*hbot), (*hbot)->next);
|
||||
splice_node(*hbot, make_new_node(*hbot));
|
||||
*hbot = (*hbot)->next;
|
||||
(*hbot)->data = mallocstrcpy(NULL, "");
|
||||
|
||||
|
||||
667
src/text.c
667
src/text.c
File diff suppressed because it is too large
Load Diff
@@ -404,8 +404,7 @@ void *nrealloc(void *ptr, size_t howmuch)
|
||||
}
|
||||
|
||||
/* Copy the first n characters of one malloc()ed string to another
|
||||
* pointer. Should be used as: "dest = mallocstrncpy(dest, src,
|
||||
* n);". */
|
||||
* pointer. Should be used as: "dest = mallocstrncpy(dest, src, n);". */
|
||||
char *mallocstrncpy(char *dest, const char *src, size_t n)
|
||||
{
|
||||
if (src == NULL)
|
||||
@@ -424,8 +423,7 @@ char *mallocstrncpy(char *dest, const char *src, size_t n)
|
||||
* "dest = mallocstrcpy(dest, src);". */
|
||||
char *mallocstrcpy(char *dest, const char *src)
|
||||
{
|
||||
return mallocstrncpy(dest, src, (src == NULL) ? 1 :
|
||||
strlen(src) + 1);
|
||||
return mallocstrncpy(dest, src, (src == NULL) ? 1 : strlen(src) + 1);
|
||||
}
|
||||
|
||||
/* Free the malloc()ed string at dest and return the malloc()ed string
|
||||
|
||||
746
src/winio.c
746
src/winio.c
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user