Compare commits
272 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4474bc0970 | ||
|
|
926fe5f789 | ||
|
|
d0c64e8086 | ||
|
|
de3260cdb1 | ||
|
|
23c3fd9bcd | ||
|
|
c118397a14 | ||
|
|
cd5d7faa4e | ||
|
|
3ca6c9241f | ||
|
|
a847d37b24 | ||
|
|
1cb945fe8e | ||
|
|
330741b650 | ||
|
|
f773d715e8 | ||
|
|
407f2d5bcf | ||
|
|
61e8b3d542 | ||
|
|
de36e1c120 | ||
|
|
a8c1dc1402 | ||
|
|
d60e7d374c | ||
|
|
2358badc65 | ||
|
|
efdb543f8c | ||
|
|
c24545fe9a | ||
|
|
8fbadecf0a | ||
|
|
a6605dce00 | ||
|
|
9ec546d293 | ||
|
|
fccfcccd37 | ||
|
|
03148804e6 | ||
|
|
3b86c7a190 | ||
|
|
7ef5c53263 | ||
|
|
6bd94040df | ||
|
|
b3bcc8eeac | ||
|
|
fb8fdcaa0a | ||
|
|
7fac9ec51c | ||
|
|
17f5c056ca | ||
|
|
914af36546 | ||
|
|
5c3d529761 | ||
|
|
8f10e364bb | ||
|
|
b1b9770c57 | ||
|
|
78037831f8 | ||
|
|
83ff644b6a | ||
|
|
3e22240fd5 | ||
|
|
34e086f038 | ||
|
|
f2ac20114e | ||
|
|
da5643853f | ||
|
|
437cb410e9 | ||
|
|
94e563232e | ||
|
|
ef7a7c5360 | ||
|
|
64aa8757a8 | ||
|
|
4ed3591703 | ||
|
|
3534d8ff25 | ||
|
|
a8a70f0f29 | ||
|
|
1d10d79860 | ||
|
|
8441887ec0 | ||
|
|
775f007348 | ||
|
|
414a1ecc8d | ||
|
|
e0bdf671b8 | ||
|
|
13fbf13b85 | ||
|
|
96f50b8d55 | ||
|
|
76d83070c4 | ||
|
|
1194a41cdb | ||
|
|
eba470a869 | ||
|
|
9a4a5454f2 | ||
|
|
af7201f9a0 | ||
|
|
2f80193d96 | ||
|
|
23595c8376 | ||
|
|
669453506c | ||
|
|
9de376deed | ||
|
|
94907aa534 | ||
|
|
7e5524bb66 | ||
|
|
e8c7cf2071 | ||
|
|
605f031833 | ||
|
|
c88d7ce530 | ||
|
|
9f884810b6 | ||
|
|
5d5666fba6 | ||
|
|
980e334e37 | ||
|
|
9bb64fccef | ||
|
|
6e3adf31b8 | ||
|
|
c67c431239 | ||
|
|
bf0268d41d | ||
|
|
b7c2513f7d | ||
|
|
892762d99c | ||
|
|
f7d320d932 | ||
|
|
0208ae7149 | ||
|
|
26fb907aa6 | ||
|
|
ea40765904 | ||
|
|
16a7fd4bfc | ||
|
|
eca6faee5b | ||
|
|
59edef55dc | ||
|
|
f119a90fe5 | ||
|
|
4920030384 | ||
|
|
a898fa5dcc | ||
|
|
c0aa5ad258 | ||
|
|
58c3dd6cd0 | ||
|
|
5ca765f107 | ||
|
|
cf75da9888 | ||
|
|
14c62dbf11 | ||
|
|
f6fbc1572d | ||
|
|
38d7362f20 | ||
|
|
26683a9e5f | ||
|
|
d35ecd02b8 | ||
|
|
61bc248555 | ||
|
|
c38f571d4b | ||
|
|
a89437219d | ||
|
|
aa28441071 | ||
|
|
5dbd288254 | ||
|
|
8f21d256fb | ||
|
|
08cfdbcbdb | ||
|
|
6103c47f1c | ||
|
|
88cf22f804 | ||
|
|
8177e62c18 | ||
|
|
124a859516 | ||
|
|
322120c980 | ||
|
|
54e6fe2b4a | ||
|
|
fa56310454 | ||
|
|
f35c3dbd57 | ||
|
|
acb394aec0 | ||
|
|
4223b83f75 | ||
|
|
4a1302ef55 | ||
|
|
cbf7e57ed0 | ||
|
|
e36e829ad0 | ||
|
|
121c53f3b8 | ||
|
|
5b9683cd64 | ||
|
|
7c1dfea59e | ||
|
|
4a073a0f3e | ||
|
|
f8841f0927 | ||
|
|
8d692a87dc | ||
|
|
13176792f0 | ||
|
|
d7fbc70a72 | ||
|
|
1dd01eb4e1 | ||
|
|
fd0589d8bc | ||
|
|
a381021ffc | ||
|
|
0b0ddb1e5f | ||
|
|
991e49a36a | ||
|
|
b1c20629f5 | ||
|
|
7373e4cd46 | ||
|
|
5f30775d62 | ||
|
|
69bd4d1f06 | ||
|
|
d3429a7a57 | ||
|
|
e1538e6dc3 | ||
|
|
1c46551ce8 | ||
|
|
f1b87f960c | ||
|
|
b0ef2e2803 | ||
|
|
6981294c9d | ||
|
|
fc89ac11d2 | ||
|
|
9f92fb3ec4 | ||
|
|
293423bdda | ||
|
|
32719d64a1 | ||
|
|
f4321250ef | ||
|
|
908663e8fc | ||
|
|
1fb820386b | ||
|
|
9973366685 | ||
|
|
e72db0e350 | ||
|
|
87b2df6dea | ||
|
|
c24caf5fb8 | ||
|
|
8db21b68d5 | ||
|
|
cb31e45f6c | ||
|
|
588daf949e | ||
|
|
d21a9c8fc3 | ||
|
|
edbc1e5950 | ||
|
|
dc18746cbd | ||
|
|
c92b9be6cd | ||
|
|
eef7d1047a | ||
|
|
d49d4f7b56 | ||
|
|
2fbb71d555 | ||
|
|
66356ec7e2 | ||
|
|
4edc83c3c2 | ||
|
|
e6350aaba4 | ||
|
|
8bf8682b17 | ||
|
|
a9b5a0e029 | ||
|
|
026393a91a | ||
|
|
db897b574f | ||
|
|
2b1bc6866a | ||
|
|
90b959a677 | ||
|
|
116d9e6f01 | ||
|
|
6620acbff4 | ||
|
|
1cb6619d6a | ||
|
|
79a4bf81dc | ||
|
|
b77e6bd99d | ||
|
|
2bcc6d7f66 | ||
|
|
cd705a7c4c | ||
|
|
ecd18c1694 | ||
|
|
bc8a3a50a4 | ||
|
|
9b90ec877a | ||
|
|
8b483c10ba | ||
|
|
f915a28d30 | ||
|
|
cb3fc8892a | ||
|
|
06d9ee89e5 | ||
|
|
0b0b812206 | ||
|
|
eafae5d417 | ||
|
|
dfff78dffe | ||
|
|
40acb8714c | ||
|
|
d7af590c6b | ||
|
|
8c7e4f5108 | ||
|
|
1144d38316 | ||
|
|
0562d27b9c | ||
|
|
c5f49167ea | ||
|
|
9765c2faa0 | ||
|
|
85ebe971e2 | ||
|
|
fc101a6ded | ||
|
|
eb88ad980a | ||
|
|
9fa95a3680 | ||
|
|
d6cc2c40fe | ||
|
|
1df4115013 | ||
|
|
ea9f62fc0f | ||
|
|
a772194102 | ||
|
|
faf77fb1ec | ||
|
|
b0b24d9c3a | ||
|
|
c9f743f676 | ||
|
|
bd920b1f49 | ||
|
|
29e094cd21 | ||
|
|
7a8ae90dac | ||
|
|
13ec5d8ce9 | ||
|
|
30591c5e01 | ||
|
|
3f8e30efb1 | ||
|
|
e9fde7d7dc | ||
|
|
fd3423f79a | ||
|
|
a4044a7e5d | ||
|
|
2fa93ae999 | ||
|
|
c8c6340ce8 | ||
|
|
6263416355 | ||
|
|
84d6f1a5b6 | ||
|
|
ecccb8d027 | ||
|
|
173bbe11ef | ||
|
|
7531b71fa1 | ||
|
|
964c10db17 | ||
|
|
0e01080983 | ||
|
|
68a0314500 | ||
|
|
dca4ab5d8f | ||
|
|
86121cf3fc | ||
|
|
f03f5d5b51 | ||
|
|
379b1556ed | ||
|
|
bfcce57b69 | ||
|
|
4eac699df3 | ||
|
|
454f5cbdce | ||
|
|
248d7be8ef | ||
|
|
372bd0f7dd | ||
|
|
f920e0d30c | ||
|
|
0f3e303d1a | ||
|
|
c9680b8b64 | ||
|
|
656563beda | ||
|
|
8f95f9b1aa | ||
|
|
c6512a9717 | ||
|
|
07ce01c189 | ||
|
|
b5400ffe65 | ||
|
|
ac41587d4e | ||
|
|
e4b8d6fab5 | ||
|
|
72e8bcb027 | ||
|
|
7401670d58 | ||
|
|
87fbe24283 | ||
|
|
e4d452424b | ||
|
|
d48071b2b2 | ||
|
|
c1a484270b | ||
|
|
981a1d39bf | ||
|
|
925a001658 | ||
|
|
77023a749b | ||
|
|
1762920808 | ||
|
|
281a56fb74 | ||
|
|
592d0d6c9a | ||
|
|
3cc561e36e | ||
|
|
0333b87ad7 | ||
|
|
059c8efb44 | ||
|
|
eb68cd1c6b | ||
|
|
ecea413802 | ||
|
|
95253231e8 | ||
|
|
eb5968f845 | ||
|
|
f2c72bf759 | ||
|
|
e472b72565 | ||
|
|
e332d2df74 | ||
|
|
ed165827bc | ||
|
|
65bf36baa5 | ||
|
|
7598b77e75 | ||
|
|
a4132e2e64 | ||
|
|
8a66c820ab | ||
|
|
af0f81f71d |
5
AUTHORS
5
AUTHORS
@@ -39,7 +39,7 @@ Mike Frysinger <vapier@gentoo.org>
|
||||
* Gentoo package maintainer. Whitespace display mode,
|
||||
--enable-utf8/--disable-utf8 configure options for ncurses,
|
||||
many new color regexes and improvements to existing color
|
||||
regexes for nanorc.sample, and miscellaneous bug fixes.
|
||||
regexes in syntax/*.nanorc, and miscellaneous bug fixes.
|
||||
|
||||
Mark Majeres <mark@engine12.com>
|
||||
* A functional undo/redo system, and coloring nano's interface.
|
||||
@@ -53,6 +53,9 @@ Mike Scalora <mike@scalora.org>
|
||||
Faissal Bensefia <faissaloo@gmail.com>
|
||||
* Line numbers.
|
||||
|
||||
Sumedh Pendurkar <sumedh.pendurkar@gmail.com>
|
||||
* The word-completion feature.
|
||||
|
||||
Benno Schulenberg <bensberg@justemail.net>
|
||||
* An array of small bug fixes, the cut-word and block-jump
|
||||
routines, text selection by holding Shift, and some extra
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
4010
ChangeLog.2007-2015
Normal file
4010
ChangeLog.2007-2015
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,8 @@ Improvements in GNU nano
|
||||
========================
|
||||
|
||||
Since 2.7.0:
|
||||
- The ability to display line numbers in front of the text.
|
||||
- The keystroke ^] to complete a fragment to an existing full word.
|
||||
- The ability to display line numbers in front of the text (M-#).
|
||||
|
||||
Since 2.6.0:
|
||||
- Shift plus the cursor keys can be used for selecting text.
|
||||
|
||||
@@ -2,6 +2,11 @@ AUTOMAKE_OPTIONS = gnu no-dependencies
|
||||
|
||||
SUBDIRS = doc m4 po src
|
||||
|
||||
EXTRA_DIST = ChangeLog.pre-2.1 IMPROVEMENTS README.GIT nano.spec
|
||||
if USE_COLOR
|
||||
SUBDIRS += syntax
|
||||
endif
|
||||
|
||||
EXTRA_DIST = ChangeLog.1999-2006 ChangeLog.2007-2015 \
|
||||
IMPROVEMENTS README.GIT nano.spec
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
77
NEWS
77
NEWS
@@ -1,3 +1,46 @@
|
||||
2017.02.23 - GNU nano 2.7.5 "Nijntje" can properly search and replace
|
||||
the \B and \b regex anchors, correctly repaints things
|
||||
when multiline regexes with identical start and end are
|
||||
involved, fixes a crash with zero-length regex matches,
|
||||
does replacements at the edges of a marked region right,
|
||||
no longer hides double-width characters at the head of
|
||||
softwrapped rows, displays at most three warnings at
|
||||
startup, and documents the ability to read a file from
|
||||
standard input. Come tickle my ears.
|
||||
|
||||
2017.01.10 - GNU nano 2.7.4 "Red dress" undoes deletions in an orderly
|
||||
manner again (bug was introduced in previous version),
|
||||
sets the preferred x position for vertical movements
|
||||
more consistently, avoids some scrolling problems in
|
||||
softwrap mode, installs the Info manual also when your
|
||||
system lacks 'makeinfo', and corrects the behavior of
|
||||
the beginning-of-word anchor (\<) in regex searches.
|
||||
|
||||
2016.12.28 - GNU nano 2.7.3 "Ontbijtkoek" wipes away a handful of bugs:
|
||||
your editor is now able to handle filenames that contain
|
||||
newlines, avoids a brief flash of color when switching
|
||||
between buffers that are governed by different syntaxes,
|
||||
makes the Shift+Ctrl+Arrow keys select text again on a
|
||||
Linux console, is more resistant against malformations
|
||||
in the positionlog file, and does not crash when ^C is
|
||||
typed on systems where it produces the code KEY_CANCEL.
|
||||
Oh, and it no longer mistakenly warns about editing an
|
||||
unlocked file just after saving a new one. That's it.
|
||||
Tastes great with thick butter.
|
||||
|
||||
2016.12.12 - GNU nano 2.7.2 "Shemesh! Shemesh!" brings another feature:
|
||||
the ability to complete with one keystroke (^] by default)
|
||||
a fragment of a word to a full word existing elsewhere in
|
||||
the current buffer. Besides, this release fixes two bugs
|
||||
related to using line numbers in softwrap mode, allows to
|
||||
use the PageUp and PageDown keys together with Shift on
|
||||
VTE-based terminals, stops the help lines from flickering
|
||||
during interactive replacing, makes a "set fill" override
|
||||
an earlier "set nowrap", properly restores the selected
|
||||
region after an external spell check, and improves a few
|
||||
other tidbits. If you should find any more bugs, please
|
||||
run 'man nano | grep bugs' and report them there.
|
||||
|
||||
2016.10.29 - GNU nano 2.7.1 "Leuven" adds an often-asked-for feature: the
|
||||
ability to display line numbers beside the text. This can
|
||||
be activated with -l or --linenumbers on the command line,
|
||||
@@ -203,7 +246,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
|
||||
@@ -1012,19 +1055,19 @@
|
||||
Also, the "show position" code now shows the starting
|
||||
column as 1 instead of 0. Have fun!
|
||||
|
||||
2002.03.05 - GNU nano 1.1.7 "lets change everything and see what breaks"
|
||||
is released. New features include new flags
|
||||
-N, --noconvert to stop any file format conversion and
|
||||
-Q, --quotestr for the new quoted text justification, a
|
||||
new tempnam() implementation to avoid silly warnings,
|
||||
2002.03.05 - GNU nano 1.1.7 "let's change everything and see what breaks"
|
||||
is released. New features include the new flags
|
||||
-N, --noconvert (to stop any file format conversion) and
|
||||
-Q, --quotestr (for the new quoted text justification),
|
||||
a new tempnam() implementation to avoid silly warnings,
|
||||
DOS and Mac file options in the Write File dialog,
|
||||
multiple save files (file.1) for abnormal exits, ^C now
|
||||
shows column as well as character position, and
|
||||
multibuffer allows duplicate files, even unnamed ones.
|
||||
Also, the static shortcut and toggle lengths are
|
||||
history, nano now reads SYSCONFDIR/nanorc if rc file
|
||||
support is enabled, and nano is now built with (and
|
||||
requires for rebuilding) autoconf 2.5.
|
||||
multiple save files (file.1) for abnormal exits,
|
||||
^C now showing column as well as character position, and
|
||||
multibuffer allowing duplicate files, even unnamed ones.
|
||||
Also, the static shortcut and toggle lengths are history,
|
||||
nano now reads SYSCONFDIR/nanorc if rc file support is
|
||||
enabled, and nano is now built with (and for rebuilding
|
||||
requires) autoconf 2.5.
|
||||
This release also includes fixes for some memory
|
||||
leaks, detecting DOS and Mac file format, justification,
|
||||
suspending keys, search & replace under various
|
||||
@@ -1300,7 +1343,7 @@
|
||||
New features include better (not yet perfect) binary
|
||||
display support and toggle support for most of the
|
||||
program flags (M-c, M-i, M-z, M-x, M-p, M-w, M-m, M-k
|
||||
and M-e for -c, -i, -x, -p, -w, -k, and -R).
|
||||
and M-e for -c, -i, -z, -x, -p, -w, -m, -k, and -R).
|
||||
|
||||
2000.08.09 - Nano 0.9.16, after some struggling, is released. This
|
||||
release should fix a few of the holes that 0.9.15 dug.
|
||||
@@ -1335,8 +1378,8 @@
|
||||
other major changes, this should be the feature set for
|
||||
nano 1.0, whenever it might be released =-)
|
||||
|
||||
2000.07.07 - Nano 0.9.12 (The "lucky day" release) is bursting with new
|
||||
features, bug fixes, and yummy fruit flavor. For
|
||||
2000.07.07 - Nano 0.9.12 (the "lucky day" release) is bursting with
|
||||
new features, bug fixes, and yummy fruit flavor. For
|
||||
changes, the alternate replace keystroke ^W^T is now
|
||||
^W^R to be compatible with later versions of Pico. ^W^T
|
||||
is now goto line, again for Pico compatibility. As for
|
||||
@@ -1433,7 +1476,7 @@
|
||||
path. The bug was in the new code for checking whether
|
||||
nano is invoked as 'pico'.
|
||||
|
||||
2000.04.14 - 0.9.1 has some more Pico compatibility built-in. The
|
||||
2000.04.14 - Nano 0.9.1 has some more Pico compatibility built-in. The
|
||||
option to switch to/from Search and Search/Replace (^T)
|
||||
is now available, and nano now displays the more
|
||||
Pico-like shortcut list when invoked as 'pico' (i.e. if
|
||||
|
||||
81
README
81
README
@@ -1,70 +1,67 @@
|
||||
|
||||
GNU nano - an enhanced clone of the Pico text editor.
|
||||
GNU nano -- an enhanced clone of the Pico text editor
|
||||
|
||||
Overview
|
||||
|
||||
The nano project was started because of a few "problems" with the
|
||||
wonderfully easy-to-use and friendly Pico text editor.
|
||||
The nano project was started because of a few "problems" with the
|
||||
wonderfully easy-to-use and friendly Pico text editor.
|
||||
|
||||
First and foremost was its license: the Pine suite does not use
|
||||
the GPL or a GPL-friendly license, and has unclear restrictions on
|
||||
redistribution. Because of this, Pine and Pico are not included
|
||||
with many GNU/Linux distributions. Also, other features (like
|
||||
go-to-line-number or search-and-replace) were unavailable until
|
||||
recently or require a command-line flag. Yuck.
|
||||
First and foremost was its license: the Pine suite does not use
|
||||
the GPL or a GPL-friendly license, and has unclear restrictions on
|
||||
redistribution. Because of this, Pine and Pico are not included
|
||||
with many GNU/Linux distributions. Also, other features (like
|
||||
go-to-line-number or search-and-replace) were unavailable until
|
||||
recently or require a command-line flag. Yuck.
|
||||
|
||||
nano aims to solve these problems by emulating the functionality of
|
||||
Pico as closely as possible while addressing the problems above and
|
||||
providing other extra functionality.
|
||||
nano aims to solve these problems by emulating the functionality of
|
||||
Pico as closely as possible while addressing the problems above and
|
||||
providing other extra functionality.
|
||||
|
||||
The nano editor is an official GNU package. For more information on
|
||||
GNU and the Free Software Foundation, please see http://www.gnu.org/.
|
||||
The nano editor is an official GNU package. For more information on
|
||||
GNU and the Free Software Foundation, please see http://www.gnu.org/.
|
||||
|
||||
How to compile and install nano
|
||||
|
||||
Download the nano source code, then:
|
||||
Download the nano source code, then:
|
||||
|
||||
tar zxvf nano-x.y.z.tar.gz
|
||||
cd nano-x.y.z
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
tar xvzf nano-x.y.z.tar.gz
|
||||
cd nano-x.y.z
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
|
||||
It's that simple. Use --prefix with configure to override the
|
||||
default installation directory of /usr/local.
|
||||
It's that simple. Use --prefix with configure to override the
|
||||
default installation directory of /usr/local.
|
||||
|
||||
If you haven't configured with the "--disable-nanorc" option, after
|
||||
installation you may want to copy the doc/nanorc.sample to your
|
||||
home directory, rename it to ".nanorc", and then edit it according
|
||||
to your taste.
|
||||
If you haven't configured with the --disable-nanorc option, after
|
||||
installation you may want to copy the doc/sample.nanorc file to
|
||||
your home directory, rename it to ".nanorc", and then edit it
|
||||
according to your taste.
|
||||
|
||||
Web Page
|
||||
|
||||
https://nano-editor.org/
|
||||
|
||||
Mailing Lists and Bug Reports
|
||||
Mailing Lists
|
||||
|
||||
Savannah hosts all the nano-related mailing-lists.
|
||||
There are three nano-related mailing-lists.
|
||||
|
||||
+ info-nano@gnu.org is a very low traffic list used to announce
|
||||
new nano versions or other important information about the
|
||||
project.
|
||||
new nano versions or other important info about the project.
|
||||
+ help-nano@gnu.org is for those seeking to get help without
|
||||
wanting to hear about the technical details of its development.
|
||||
+ nano-devel@gnu.org is the list used by the people that make
|
||||
nano and a general development discussion list, with moderate
|
||||
traffic.
|
||||
+ nano-devel@gnu.org is the list used by the people that make nano
|
||||
and a general development discussion list, with moderate traffic.
|
||||
|
||||
To subscribe, send email to <name>-request@gnu.org with a
|
||||
subject of "subscribe", where <name> is the list you want to
|
||||
subscribe to.
|
||||
To subscribe, send email to <name>-request@gnu.org with a subject
|
||||
of "subscribe", where <name> is the list you want to subscribe to.
|
||||
|
||||
For general bug reports, please file a description of the problem
|
||||
on the Savannah bug tracker page for nano
|
||||
(https://savannah.gnu.org/bugs/?group=nano). The issue may have
|
||||
already been reported, and we are better able to track the state
|
||||
of the issue and whom to notify when fixed, the more the bug
|
||||
tracker is used.
|
||||
Bug Reports
|
||||
|
||||
To report a bug, please file a description of the problem on nano's
|
||||
bug tracker (https://savannah.gnu.org/bugs/?group=nano -- hover on
|
||||
"Bugs", then click "Submit new"). The issue may have already been
|
||||
reported, so please look first.
|
||||
|
||||
Current Status
|
||||
|
||||
|
||||
31
README.GIT
31
README.GIT
@@ -1,39 +1,42 @@
|
||||
INSTRUCTIONS TO COMPILE AND INSTALL NANO GIT VERSIONS
|
||||
=====================================================
|
||||
INSTRUCTIONS FOR COMPILING AND INSTALLING NANO FROM GIT
|
||||
=======================================================
|
||||
|
||||
The latest version of GNU nano is available via git, but building this needs
|
||||
a bit more care than the official stable and unstable tarballs.
|
||||
The latest changes and fixes for GNU nano are available via git, but
|
||||
building this needs a bit more care than the official tarballs.
|
||||
|
||||
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
To successfully compile GNU nano from the git repo, you'll need the following
|
||||
To successfully compile GNU nano from git, you'll need the following
|
||||
packages:
|
||||
|
||||
- autoconf (version >= 2.61)
|
||||
- automake (version >= 1.7)
|
||||
- autopoint (version >= 0.11.5)
|
||||
- gettext (version >= 0.11.5)
|
||||
- git (version >= 2.7.4)
|
||||
- groff (version >= 1.12)
|
||||
- pkg-config (version >= 0.22)
|
||||
- texinfo (version >= 4.0)
|
||||
- glib 2.x (in case your system doesn't have vsnprintf(), which the
|
||||
configure script will check for)
|
||||
- make, gcc, and
|
||||
- the normal development libraries (curses or slang, etc.)
|
||||
- gcc (any version)
|
||||
- make (any version)
|
||||
|
||||
If you want UTF-8 support, you will also need libncursesw5-dev installed
|
||||
(version >= 5.7), or libslang2-dev (version >= 2.0) if you use --with-slang.
|
||||
If your system doesn't have 'snprintf' or 'vsnprintf' (which the configure
|
||||
script will check for), you will also need glib-2.x installed.
|
||||
|
||||
These should all be available in your distro's package manager or software
|
||||
center, or otherwise on any GNU mirror. Note that you'll need a version of
|
||||
curses or slang with wide character support if you want nano to use UTF-8.
|
||||
center, or otherwise on any GNU mirror.
|
||||
|
||||
|
||||
Download the source
|
||||
-------------------
|
||||
|
||||
To obtain the current nano development code (called 'master', or sometimes
|
||||
'trunk'), use the following command. It will create a copy of the files in
|
||||
a subdirectory of your current working directory called 'nano':
|
||||
To obtain the current nano development branch (called 'master'), use the
|
||||
following command. It will create in your current working directory a
|
||||
subdirectory called 'nano' containing a copy of all of the files:
|
||||
|
||||
$ git clone git://git.savannah.gnu.org/nano.git nano
|
||||
|
||||
|
||||
52
configure.ac
52
configure.ac
@@ -16,7 +16,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
AC_INIT([GNU nano], [2.7.1], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [2.7.5], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AC_CANONICAL_HOST
|
||||
AM_INIT_AUTOMAKE
|
||||
@@ -88,13 +88,12 @@ if test "x$enable_tiny" = xyes; then
|
||||
if test "x$enable_comment" = xyes; then
|
||||
AC_MSG_ERROR([--enable-comment cannot work with --enable-tiny])
|
||||
else
|
||||
# Disabling nanorc silently disables comment support.
|
||||
enable_comment=no
|
||||
fi
|
||||
fi
|
||||
if test "x$disable_comment" != xyes; then
|
||||
if test "x$enable_comment" != xno; then
|
||||
AC_DEFINE(ENABLE_COMMENT, 1, [Define this to disable the comment/uncomment functionality.])
|
||||
AC_DEFINE(ENABLE_COMMENT, 1, [Define this to enable the comment/uncomment function.])
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -173,7 +172,22 @@ fi
|
||||
AC_ARG_ENABLE(tabcomp,
|
||||
AS_HELP_STRING([--disable-tabcomp], [Disable tab completion functions]))
|
||||
if test "x$enable_tabcomp" = xno; then
|
||||
AC_DEFINE(DISABLE_TABCOMP, 1, [Define this to disable the tab completion functions for files and search strings.])
|
||||
AC_DEFINE(DISABLE_TABCOMP, 1, [Define this to disable the tab completion functions for filenames and search strings.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(wordcomp,
|
||||
AS_HELP_STRING([--disable-wordcomp], [Disable the word completion function]))
|
||||
if test "x$enable_tiny" = xyes; then
|
||||
if test "x$enable_wordcomp" = xyes; then
|
||||
AC_MSG_ERROR([--enable-wordcomp cannot work with --enable-tiny])
|
||||
else
|
||||
enable_wordcomp=no
|
||||
fi
|
||||
fi
|
||||
if test "x$disable_wordcomp" != xyes; then
|
||||
if test "x$enable_wordcomp" != xno; then
|
||||
AC_DEFINE(ENABLE_WORDCOMPLETION, 1, [Define this to enable the word completion function.])
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(wrapping,
|
||||
@@ -551,8 +565,12 @@ else
|
||||
AC_MSG_RESULT([Using $CURSES_LIB_NAME as the curses library])
|
||||
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.]))
|
||||
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.])],
|
||||
[], [$CURSES_LIB])
|
||||
AC_CHECK_LIB([$CURSES_LIB_NAME], [key_defined],
|
||||
[AC_DEFINE(HAVE_KEY_DEFINED, 1, [Define this if your curses library has the key_defined() command.])],
|
||||
[], [$CURSES_LIB])
|
||||
|
||||
dnl Parse any configure options.
|
||||
|
||||
@@ -610,12 +628,10 @@ AC_CACHE_CHECK([for enhanced regular expression flag], nano_cv_flag_reg_extended
|
||||
AC_DEFINE_UNQUOTED(NANO_REG_EXTENDED, $nano_cv_flag_reg_extended,
|
||||
[Flag(s) to use to get the full range of extended regular expressions])
|
||||
|
||||
if test x$color_support = xyes; then
|
||||
# Now check for the end-of-word boundary support (/< and />).
|
||||
AC_MSG_CHECKING([for GNU-style word boundary regex support])
|
||||
|
||||
AC_ARG_WITH(wordbounds,
|
||||
AS_HELP_STRING([--with-wordbounds], [Use GNU-style word boundary delimiters]),
|
||||
# Check for word-boundary support (/< and />).
|
||||
AC_MSG_CHECKING([for GNU-style word boundary regex support])
|
||||
AC_ARG_WITH(wordbounds,
|
||||
AS_HELP_STRING([--with-wordbounds], [Use GNU-style word boundary delimiters]),
|
||||
[ case "$with_wordbounds" in
|
||||
no)
|
||||
AC_MSG_RESULT(no)
|
||||
@@ -652,6 +668,7 @@ int main(void)
|
||||
)
|
||||
])
|
||||
|
||||
if test x$color_support = xyes; then
|
||||
# if test x$CURSES_LIB_NAME = xcurses; then
|
||||
AC_MSG_CHECKING([whether _XOPEN_SOURCE_EXTENDED is needed])
|
||||
AC_TRY_RUN([
|
||||
@@ -715,10 +732,6 @@ else
|
||||
fi
|
||||
AM_CONDITIONAL(GROFF_HTML, test x$groff_html_support = xyes)
|
||||
|
||||
# Check for the availability of makeinfo.
|
||||
AC_CHECK_PROG(haveit, makeinfo, yes, no)
|
||||
AM_CONDITIONAL(HAVE_MAKEINFO, test x$haveit = xyes)
|
||||
|
||||
# Check whether this is a git repository.
|
||||
AC_MSG_CHECKING([whether building from git])
|
||||
if test -d .git ; then
|
||||
@@ -733,14 +746,11 @@ AM_CONDITIONAL(BUILDING_FROM_GIT, test x$from_git = xyes)
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
doc/Makefile
|
||||
doc/nanorc.sample
|
||||
doc/man/Makefile
|
||||
doc/man/fr/Makefile
|
||||
doc/syntax/Makefile
|
||||
doc/texinfo/Makefile
|
||||
doc/sample.nanorc
|
||||
m4/Makefile
|
||||
po/Makefile.in
|
||||
src/Makefile
|
||||
syntax/Makefile
|
||||
nano.spec
|
||||
])
|
||||
|
||||
|
||||
8
doc/.gitignore
vendored
8
doc/.gitignore
vendored
@@ -1 +1,7 @@
|
||||
/nanorc.sample
|
||||
nano.1.html
|
||||
rnano.1.html
|
||||
nanorc.5.html
|
||||
texinfo.tex
|
||||
nano.info
|
||||
nano.html
|
||||
sample.nanorc
|
||||
|
||||
@@ -1,11 +1,33 @@
|
||||
SUBDIRS = man
|
||||
|
||||
if HAVE_MAKEINFO
|
||||
SUBDIRS += texinfo
|
||||
endif
|
||||
|
||||
if USE_COLOR
|
||||
SUBDIRS += syntax
|
||||
endif
|
||||
SUBDIRS =
|
||||
BUILT_SOURCES =
|
||||
|
||||
dist_html_DATA = faq.html
|
||||
|
||||
dist_man_MANS = nano.1 rnano.1
|
||||
html_pages = nano.1.html rnano.1.html
|
||||
|
||||
if USE_NANORC
|
||||
dist_man_MANS += nanorc.5
|
||||
html_pages += nanorc.5.html
|
||||
endif
|
||||
|
||||
nano.1.html: nano.1
|
||||
groff -t -mandoc -Thtml < $? > $@
|
||||
nanorc.5.html: nanorc.5
|
||||
groff -t -mandoc -Thtml < $? > $@
|
||||
rnano.1.html: rnano.1
|
||||
groff -t -mandoc -Thtml < $? > $@
|
||||
|
||||
if GROFF_HTML
|
||||
BUILT_SOURCES += $(html_pages)
|
||||
dist_html_DATA += $(html_pages)
|
||||
endif
|
||||
|
||||
info_TEXINFOS = nano.texi
|
||||
|
||||
BUILT_SOURCES += nano.html
|
||||
dist_html_DATA += nano.html
|
||||
|
||||
AM_MAKEINFOHTMLFLAGS = --no-split
|
||||
|
||||
EXTRA_DIST = $(BUILT_SOURCES) $(info_TEXINFOS)
|
||||
|
||||
222
doc/faq.html
222
doc/faq.html
@@ -5,6 +5,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head>
|
||||
<body text="#330000" bgcolor="#ffffff" link="#0000ef" vlink="#51188e" alink="#ff0000">
|
||||
|
||||
<h1>The GNU nano editor FAQ</h1>
|
||||
<h2>Table of Contents</h2>
|
||||
<h2><a href="#1">1. General</a></h2>
|
||||
@@ -38,15 +39,11 @@
|
||||
<a href="#4.5">4.5. How do I type the F13-F16 keys shown in the help browser? My keyboard only has F1-F12!</a><br>
|
||||
<a href="#4.6">4.6. nano crashes when I type <insert keystroke here>!</a><br>
|
||||
<a href="#4.7">4.7. nano crashes when I resize my window. How can I fix that?</a><br>
|
||||
<a href="#4.8">4.8. [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?</a><br>
|
||||
<a href="#4.9">4.9. [version 1.1.12 and earlier] Why does nano show ^\ in the shortcut list instead of ^J?</a><br>
|
||||
<a href="#4.10a">4.10a. [version 1.1.12 and earlier] When I type in a search string, the string I last searched for is already in front of my cursor! What happened?!</a><br>
|
||||
<a href="#4.10b">4.10b. [version 1.1.99pre1 and later] Hey, the search string behavior has reverted, it's now like Pico, what happened to the consistency?</a><br>
|
||||
<a href="#4.11">4.11. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
|
||||
<a href="#4.12">4.12. I've compiled nano with color support, but I don't see any color when I run it!</a><br>
|
||||
<a href="#4.13">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?</a><br>
|
||||
<a href="#4.14">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?</a><br>
|
||||
<a href="#4.15">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!</a></p></blockquote>
|
||||
<a href="#4.8">4.8. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</a><br>
|
||||
<a href="#4.9">4.9. I've compiled nano with color support, but I don't see any color when I run it!</a><br>
|
||||
<a href="#4.10">4.10. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
|
||||
<a href="#4.11">4.11. How do I select text for or paste text from the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?</a><br>
|
||||
<a href="#4.12">4.12. On startup I get a message that says "Detected a legacy nano history file". Now older nano versions can't find my search history!</a></p></blockquote>
|
||||
<h2><a href="#5">5. Internationalization</a></h2>
|
||||
<blockquote><p><a href="#5.1">5.1. There's no translation for my language!</a><br>
|
||||
<a href="#5.2">5.2. I don't like the translation for <x> in my language. How can I fix it?</a><br>
|
||||
@@ -64,13 +61,14 @@
|
||||
<a href="#7.5">7.5. Can I have write access to the GIT tree?</a></p></blockquote>
|
||||
<h2><a href="#8">8. ChangeLog</a></h2>
|
||||
<hr width="100%">
|
||||
|
||||
<h1><a name="1"></a>1. General</h1>
|
||||
<h2><a name="1.1"></a>1.1 About this FAQ</h2>
|
||||
<blockquote><p>This FAQ was originally written and maintained by Chris Allegretta <<a href="mailto:chrisa@asty.org">chrisa@asty.org</a>>, who also happens to be the creator of nano. It was then maintained by David Lawrence Ramsey <<a href="mailto:pooka109@gmail.com">pooka109@gmail.com</a>>. Maybe someone else will volunteer to maintain this FAQ someday, who knows...</p></blockquote>
|
||||
<h2><a name="1.2"></a>1.2. How do I contribute to it?</h2>
|
||||
<blockquote><p>Your best bet is to send it to the nano email address, <a href="mailto:nano@nano-editor.org">nano@nano-editor.org</a> and if it is useful enough it will be included in future versions.</p></blockquote>
|
||||
<h2><a name="1.3"></a>1.3. What is GNU nano?</h2>
|
||||
<blockquote><p>GNU nano is designed to be a free replacement for the Pico text editor, part of the Pine email suite from <a href="http://www.washington.edu/pine/">The University of Washington</a>. It aims to "emulate Pico as closely as possible and perhaps include extra functionality".</p></blockquote>
|
||||
<blockquote><p>GNU nano is designed to be a free replacement for the Pico text editor, part of the Pine email suite from <a href="http://www.washington.edu/pine/">The University of Washington</a>. It aims to "emulate Pico as closely as possible and then include extra functionality".</p></blockquote>
|
||||
<h2><a name="1.4"></a>1.4. What is the history behind nano?</h2>
|
||||
<blockquote><p>Funny you should ask!</p>
|
||||
<p><b>In the beginning...</b></p>
|
||||
@@ -79,15 +77,16 @@
|
||||
<p>The <a href="http://www.debian.org/">Debian GNU/Linux</a> distribution, known for its strict standards in distributing truly "free" software (i.e. software with no restrictions on redistribution), would not include a binary package for Pine or Pico. Many people had a serious dilemma: they loved these programs, but the versions available at the time were not truly free software in the <a href="http://www.gnu.org/philosophy/free-sw.html">GNU</a> sense of the word.</p>
|
||||
<p><b>The event...</b></p>
|
||||
<p>It was in late 1999 when Chris Allegretta (our hero) was yet again complaining to himself about the less-than-perfect license Pico was distributed under, the 1000 makefiles that came with it and how just a few small improvements could make it the Best Editor in the World (TM). Having been a convert from Slackware to Debian, he missed having a simple binary package that included Pine and Pico, and had grown tired of downloading them himself.</p>
|
||||
<p>Finally something snapped inside and Chris coded and hacked like a madman for many hours straight one weekend to make a (barely usable) Pico clone, at the time called TIP (Tip Isn't Pico). The program could not be invoked without a filename, could not save files, had no help text display, spell checker, and so forth. But over time it improved, and with the help of a few great coders it matured to the (hopefully) stable state it is today.</p>
|
||||
<p>Finally something snapped inside and Chris coded and hacked like a madman for many hours straight one weekend to make a (barely usable) Pico clone, at the time called TIP (Tip Isn't Pico). The program could not be invoked without a filename, could not save files, had no help text display, spell checker, and so forth. But over time it improved, and with the help of a few great coders it matured to the (hopefully) stable state it is in today.</p>
|
||||
<p>In February 2001, nano was declared an official GNU program by Richard Stallman. nano also reached its first production release on March 22, 2001.</p></blockquote>
|
||||
<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 version of nano *should* be 2.7.0. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
|
||||
<blockquote><p>The current version of nano <i>should</i> be <b>2.7.5</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
|
||||
<h2><a name="1.7"></a>1.7. I want to read the man page without having to download the program!</h2>
|
||||
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="https://nano-editor.org/dist/latest/nano.1.html">here</a>.</p></blockquote>
|
||||
<hr width="100%">
|
||||
|
||||
<h1><a name="2"></a>2. Where to get GNU nano.</h1>
|
||||
<h2><a name="2.1"></a>2.1. Web sites that carry nano.</h2>
|
||||
<blockquote><p>The nano source tarballs can be downloaded from the following web sites:</p>
|
||||
@@ -115,6 +114,7 @@
|
||||
<h2><a name="2.4"></a>2.4. By GIT (for the brave).</h2>
|
||||
<blockquote><p>For the 'bleeding edge' current version of nano, you can use GIT to download the current source code. <b>Note:</b> believe it or not, by downloading code that has not yet stabilized into an official release, there could quite possibly be bugs, in fact the code may not even compile! Anyway, see <a href="http://git.savannah.gnu.org/cgit/nano.git/tree/README.GIT">the nano GIT document</a> for info on anonymous GIT access to the nano source.</p></blockquote>
|
||||
<hr width="100%">
|
||||
|
||||
<h1><a name="3"></a>3. Installation and Configuration</h1>
|
||||
<h2><a name="3.1"></a>3.1. How do I install the RPM or DEB package?</h2>
|
||||
<blockquote><p>It's simple really! As root, type <b>rpm -Uvh nano-x.y.z-1.i386.rpm</b> if you have a RedHat-ish system or <b>dpkg -i nano_x.y.z-1.deb</b> if you have a Debian-ish system, where <b>x.y.z</b> is the release of nano. There are other programs to install packages, and if you wish to use those, knock yourself out.</p></blockquote>
|
||||
@@ -149,23 +149,25 @@
|
||||
<b>--disable-operatingdir</b> Disable the setting of an operating directory
|
||||
<b>--disable-speller</b> Disable spell checker functions
|
||||
<b>--disable-tabcomp</b> Disable tab completion functions
|
||||
<b>--disable-wordcomp</b> Disable the word completion function
|
||||
<b>--disable-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>There's also the <b>--enable-tiny</b> option which disables everything above, as well as some larger chunks of the program (like the marker code that you use with Control-^ to select text). Also, if you know you aren't going to be using other languages, you can use <b>--disable-nls</b> to disable internationalization and save a few K to a few dozen K depending on whether you have locale support on your system. And finally, there's always good old <b>strip</b> to strip all debugging code and code that exists in libraries on your system.</p>
|
||||
<p>With <b>--disable-wrapping-as-root</b> you can disable any hard-wrapping by default when the user is root, useful to prevent accidentally changing long lines in system configuration files.</p>
|
||||
</blockquote>
|
||||
<h2><a name="3.7"></a>3.7. Tell me more about this multibuffer stuff!</h2>
|
||||
<blockquote><p>To use multiple file buffers, you must be using nano 1.1.0 or newer, and you must not have configured it with <b>--disable-multibuffer</b> nor with <b>--enable-tiny</b> (use <b>nano -V</b> to check the compilation options). Then when you want to insert a file into its own buffer instead of into the current file, just hit <b>Meta-F</b>, then insert the file as normal with <b>^R</b>. If you always want files to be loaded into their own buffers, use the <b>--multibuffer</b> or <b>-F</b> flag when you invoke nano.</p>
|
||||
<p>You can move between the buffers you have open with the <b>Meta-<</b> and <b>Meta-></b> keys, or more easily with <b>Meta-,</b> and <b>Meta-.</b> (clear as mud, right? =-). When you have more than one file buffer open, the ^X shortcut will say "Close", instead of the normal "Exit" when only one buffer is open.</p></blockquote>
|
||||
<blockquote><p>To use multiple file buffers, you must not have configured nano with <b>--disable-multibuffer</b> nor with <b>--enable-tiny</b> (use <b>nano -V</b> to check the compilation options). Then when you want to insert a file into its own buffer instead of into the current file, just hit <b>Meta-F</b>, then insert the file as normal with <b>^R</b>. If you always want files to be loaded into their own buffers, use the <b>--multibuffer</b> or <b>-F</b> flag when you invoke nano.</p>
|
||||
<p>You can move between the buffers you have open with the <b>Meta-<</b> and <b>Meta-></b> keys, or more easily without holding Shift: <b>Meta-,</b> and <b>Meta-.</b> (clear as mud, right? =-). When you have more than one file buffer open, the ^X shortcut will say "Close", instead of the normal "Exit" when only one buffer is open.</p></blockquote>
|
||||
<h2><a name="3.8"></a>3.8. Tell me more about this verbatim input stuff!</h2>
|
||||
<blockquote><p>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.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>
|
||||
<blockquote><p>When you want to insert a literal character into the file you're editing, such as a control character that nano usually treats as a command, first press <b>Meta-V</b> (if you're not at a prompt, you'll get the message "Verbatim Input" on the statusbar), 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. The statubar will change to "Unicode Input: ......" when you do this.</p></blockquote>
|
||||
<h2><a name="3.9a"></a>3.9a. How do I make a .nanorc file that will be read when I start nano?</h2>
|
||||
<blockquote><p>It's not hard at all! But, your nano must <b>not</b> have been compiled with <b>--disable-nanorc</b>. Then simply copy the <b>sample.nanorc</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 of the file 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>
|
||||
<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>
|
||||
<blockquote><p>If a command-line option that begins with '+' is followed by another option, the former is always treated as a starting line and column number, and the latter is always treated as a filename. If a command-line option that begins with '+' isn't followed by another option, it's always treated as a filename. Examples:</p>
|
||||
@@ -188,15 +190,11 @@
|
||||
<blockquote><p>If you aren't trying some bizarre keystroke combination with some bizarre $TERM entry, chances are you have found a bug. You are welcome to submit it to the <a href="mailto:nano-devel@gnu.org">nano-devel</a> list or in the <a href="https://savannah.gnu.org/bugs/?group=nano">bug tracker</a> on Savannah.</p></blockquote>
|
||||
<h2><a name="4.7"></a>4.7. nano crashes when I resize my window. How can I fix that?</h2>
|
||||
<blockquote><p>Older versions of nano had this problem. Please upgrade to version 2.7.0 or newer.</p></blockquote>
|
||||
<h2><a name="4.8"></a>4.8. [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>
|
||||
<blockquote><p>The help (^G) and justify (^J) functions were among the last to be written. To show the improvements that nano had over Pico (go to line number, and replace), ^_ and ^\ were put on the shortcut list. Later, ^G came back in place of ^_ as it proved to be very valuable for new Unix users.</p></blockquote>
|
||||
<h2><a name="4.10a"></a>4.10a. [version 1.1.12 and earlier] When I type in a search string, the string I last searched for is already in front of my cursor! What happened?!</h2>
|
||||
<blockquote><p>Since nano version 0.9.20, the default was to have a completely consistent user interface across all user input functions. This means that regardless of whether you're being asked for a filename to insert or write, or a string to search for, the previous value is already inserted before the cursor.</p></blockquote>
|
||||
<h2><a name="4.10b"></a>4.10b. [version 1.1.99pre1 and later] Hey, the search string behavior has reverted, it's now like Pico, what happened to the consistency?</h2>
|
||||
<blockquote><p>It was decided that consistency was nice, but people are used to Pico's inconsistent behavior. Also, in version 1.1.99pre1, search and replace history was introduced. If you wish to edit your previous search/replace entry (or any previous entry), you can do so by hitting the up arrow to cycle through your history. This method allows the best of both worlds: You don't need to erase the previous string if you want to enter a new one, but you can with one keystroke recall previous entries for editing. Therefore there is now no "Pico mode", nano is and has always been a Pico <b>clone</b>, and clones by default should be compatible.</p></blockquote>
|
||||
<h2><a name="4.11"></a>4.11. How do I make nano my default editor (in Pine, mutt, etc.)?</h2>
|
||||
<h2><a name="4.8"></a>4.8. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</h2>
|
||||
<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.9"></a>4.9. I've compiled nano with color support, but I don't see any color when I run it!</h2>
|
||||
<blockquote><p>If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Several example configurations are in the <b>doc/syntax</b> subdirectory of the nano source, which are normally installed to <b>/usr/local/share/nano</b>. To enable all of them, uncomment the line <b># include "/usr/local/share/nano/*.nanorc"</b> in your nanorc. See also section <a href="#3.9a">3.9a</a>.</p></blockquote>
|
||||
<h2><a name="4.10"></a>4.10. How do I make nano my default editor (in Pine, mutt, etc.)?</h2>
|
||||
<blockquote><p>You need to make nano your $EDITOR. If you want this to be saved, you should put a line like this in your <b>.bashrc</b> if you use bash (or <b>.zshrc</b> if you believe in zsh):</p>
|
||||
<p><b>export EDITOR=/usr/local/bin/nano</b></p>
|
||||
<p>or, if you use tcsh, put this in your <b>.cshrc</b> file:</p>
|
||||
@@ -209,17 +207,14 @@
|
||||
<p>If you're a mutt user, you should see an effect immediately the next time you log in. No further configuration is needed. However, if you want to let people know you use nano to compose your email messages, you can put a line like this in your <b>.muttrc</b>:</p>
|
||||
<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.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>
|
||||
<h2><a name="4.11"></a>4.11. How do I select text for or paste text from the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?</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 in a .nano subdirectory in your home directory. A newer nano will move an existing search-history file to this new location so it can continue to be used. This means that if you then try and use an earlier version of nano, it will be unable to see your current search history. To fix this, run the following command:<br>
|
||||
<h2><a name="4.12"></a>4.12. 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 in a .nano subdirectory in your home directory. A newer nano will move an existing search-history file to this new location so it can continue to be used. This means that if you then try and use an earlier version of nano, it will be unable to see your current search history. To fix this, run the following command:</p>
|
||||
<p><b>ln -sf ~/.nano/search_history ~/.nano_history</b></p>
|
||||
</p><p>The "migration service" (moving the search-history file to its new location) will be deleted from nano in early 2018.</p></blockquote>
|
||||
<p>The "migration service" (moving the search-history file to its new location) will be deleted from nano in early 2018.</p></blockquote>
|
||||
<hr width="100%">
|
||||
|
||||
<h1><a name="5"></a>5. Internationalization</h1>
|
||||
<h2><a name="5.1"></a>5.1. There's no translation for my language!</h2>
|
||||
<blockquote><p>In June 2001, GNU nano entered the <a href="http://translationproject.org/html/welcome.html">Translation Project</a> and since then, translations should be managed from there.</p>
|
||||
@@ -228,8 +223,9 @@
|
||||
<h2><a name="5.2"></a>5.2. I don't like the translation for <x> in my language. How can I fix it?</h2>
|
||||
<blockquote><p>The best way would probably be to send an e-mail to the team's mailing listed mentione in the <code>Language-Team:</code> field in the <b><your_language>.po</b> file with your suggested corrections, and then they can make the changes reach the nano-devel list.</p></blockquote>
|
||||
<h2><a name="5.3"></a>5.3. What is the status of Unicode support?</h2>
|
||||
<blockquote><p>In version 1.3.12 or later, Unicode should be usable. With your terminal, locale (LC_ALL and similar environment variables), and encoding configured to properly support UTF-8, you should be able to enter and save Unicode text.</p></blockquote>
|
||||
<blockquote><p>Since versions 1.3.12, Unicode should be usable. With your terminal, locale (LC_ALL and similar environment variables), and encoding configured to properly support UTF-8, you should be able to enter and save Unicode text.</p></blockquote>
|
||||
<hr width="100%">
|
||||
|
||||
<h1><a name="6"></a>6. Advocacy and Licensing</h1>
|
||||
<h2><a name="6.1"></a>6.1. Why should I use nano instead of Pico?</h2>
|
||||
<blockquote><p>There are many reasons to use nano instead of Pico. A more complete list can be found at the <a href="https://nano-editor.org/">nano homepage</a>.</p></blockquote>
|
||||
@@ -241,6 +237,7 @@
|
||||
<blockquote><p>If you are looking to use a Free Software program similar to Pine, and Emacs is not your thing, you should definitely take a look at <a href="http://www.mutt.org/">mutt</a>. It is a full-screen, console based mail program that actually has a lot more flexibility than Pine, but has a keymap included in the distribution that allows you to use the same keystrokes as Pine would to send and receive mail. It's also under the GNU General Public License, version 2.0.<P>
|
||||
Of course, due to the license change you can now use the <A HREF="http://www.washington.edu/alpine/">Alpine distribution</A> of PINE as it is now considered Free Software, but you would be sacrificing many of nano's features to do so.</p></blockquote>
|
||||
<hr width="100%">
|
||||
|
||||
<h1><a name="7"></a>7. Miscellaneous</h1>
|
||||
<h2><a name="7.1"></a>7.1. nano-related mailing lists.</h2>
|
||||
<blockquote><p>There are three mailing lists for nano hosted at <a href="http://savannah.gnu.org/">Savannah</a>: info-nano, help-nano and nano-devel. info-nano is a very low traffic list where new versions of nano are announced (surprise!). help-nano is for getting help with the editor without needing to hear all of the development issues surrounding it. nano-devel is a normally low, sometimes high traffic list for discussing the present and future development of nano. Here are links to where you can sign up for a given list:</p>
|
||||
@@ -251,81 +248,84 @@ Of course, due to the license change you can now use the <A HREF="http://www.was
|
||||
<blockquote><p>That's fine. Send it <a href="mailto:nano-devel@gnu.org">our way</a>! Better yet, fix a <a href="https://savannah.gnu.org/bugs/?group=nano">bug</a> in the program or implement a <a href="https://nano-editor.org/dist/latest/TODO">cool feature</a> and send us that instead (though cash is fine too).</p></blockquote>
|
||||
<h2><a name="7.3"></a>7.3. How do I submit a bug report or patch?</h2>
|
||||
<blockquote>
|
||||
<p>The best place to submit bugs is to the <a href="https://savannah.gnu.org/bugs/?group=nano">Savannah bug tracker</a> as you can check whether the bug you are submitting has already been submitted.
|
||||
<p>Please submit patches for nano via the <a href="https://savannah.gnu.org/patch/?group=nano">Savannah project's patch manager</a> for the nano project.</p></blockquote>
|
||||
<p>The best place to submit bugs is to the <a href="https://savannah.gnu.org/bugs/?group=nano">Savannah bug tracker</a> as you can check whether the bug you are submitting has already been submitted.
|
||||
<p>Please submit patches for nano via the <a href="https://savannah.gnu.org/patch/?group=nano">Savannah project's patch manager</a> for the nano project.</p></blockquote>
|
||||
<h2><a name="7.4"></a>7.4. How do I join the development team?</h2>
|
||||
<blockquote><p>The easiest way is to consistently send in good patches that add some needed functionality, fix a bug or two, and/or make the program more optimized/efficient. Then ask nicely and you will probably be added to the Savannah development list and be given write access after a while. There is a lot of responsibility that goes along with being a team member, so don't think it's just something to add to your resume.</p></blockquote>
|
||||
<h2><a name="7.5"></a>7.5. Can I have write access to the git 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>Re-read section <a href="#7.4">7.4</a> and you should know the answer.</p></blockquote>
|
||||
<hr width="100%">
|
||||
|
||||
<h1><a name="8"></a>8. ChangeLog</h1>
|
||||
<blockquote><p>
|
||||
2016/04/17 - Update docs to refer to GIT instead of subversion. (Mike)<br>
|
||||
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>
|
||||
2007/12/21 - Update maintainer information. (DLR)<br>
|
||||
2007/12/09 - Add minor punctuation and wording fixes, and update various sections to account for Alpine. (DLR)<br>
|
||||
2007/08/26 - Update links to the Free Translation Project. (DLR)<br>
|
||||
2007/07/29 - Update RPM links for nano 2.0.x. (DLR)<br>
|
||||
2007/04/18 - Add a new section 4.14 to explain how autoindent affects pasted text. (John M. Gabriele, minor tweaks by DLR)<br>
|
||||
2007/04/04 - Update email address. (DLR)<br>
|
||||
2007/01/01 - Update section 4.1 to describe how to open files with names beginning with '+' at specified columns as well as lines. (DLR)<br>
|
||||
2006/11/25 - Add miscellaneous wording and capitalization fixes. (DLR)<br>
|
||||
2006/10/28 - Update various links for the 2.0 branch of nano. (DLR)<br>
|
||||
2006/10/06 - Update the question in section 4.13 to match the version of it in the answer section. (DLR)<br>
|
||||
2006/07/25 - Update section 5.3 again to not state "the latest development version" before 1.3.12, as it's no longer accurate. Also add some minor spacing fixes. (DLR)<br>
|
||||
2006/06/12 - Update section 5.3, due to the display fix for two-column Unicode characters. (DLR)<br>
|
||||
2006/06/05 - Add a new section 4.8, and move all section 4 entries after it down one number, to explain how to deal with glibc 2.2.3's crashes involving extended regular expressions. (DLR)<br>
|
||||
2006/06/04 - Add minor punctuation, wording, and typo fixes. (DLR)<br>
|
||||
2006/05/27 - Update section 3.8 to mention the new "Unicode Input" prompt, and how Unicode input only works when Unicode support is enabled. (DLR)<br>
|
||||
2006/05/12 - Remove section 4.4, and move all section 4 entries after it up one number, since it no longer applies. Meta-] and Meta-[ are no longer used to indent and unindent marked text, since they require that the bracket matching key change to Ctrl-], which is used as the telnet escape key (found by Chris). Also, make the link to the nano CVS page a bit more readable. (DLR)<br>
|
||||
2006/05/08 - Add a new section 4.5, and move all section 4 entries after it down one number, to explain a problem that can occur when holding down keys to generate Meta sequences. Also add a few more capitalization and wording fixes. (Benno Schulenberg, minor tweaks by DLR)<br>
|
||||
2006/05/01 - Add a new section 4.4, and move all section 4 entries after it down one number, to explain how to deal with problems typing Meta-[. Also add a few capitalization and wording fixes. (DLR)<br>
|
||||
2006/04/14 - Clarify section 1.4: help menu -> help text display. (DLR, suggested by Benno Schulenberg)<br>
|
||||
2006/03/16 - Update the Free Translation Project's address, change the character set to UTF-8, and remove broken links to contributed RedHat nano packages. (DLR)<br>
|
||||
2005/11/21 - Clarify section 5.3 to better explain how to enable Unicode support, and remove the mention of quirks, since they turned out to not be a nano problem. (Mike Frysinger and DLR)<br>
|
||||
2005/11/19 - Add a new section 5.3 to explain the status of nano's Unicode support. (Mike Frysinger, minor tweaks by DLR)<br>
|
||||
2005/08/27 - Update email address. (DLR)<br>
|
||||
2005/08/10 - Add a new section 4.3, and move all section 4 entries after it down one number, to explain how to deal with numeric keypad problems. (DLR)<br>
|
||||
2005/08/08 - Update section 3.8 to mention that verbatim input mode now takes a six-digit hexadecimal number. (DLR)<br>
|
||||
2005/07/04 - Update section 4.10 to mention that pasting from the X clipboard via the middle mouse button also works when the Shift key is used. (DLR)<br>
|
||||
2005/06/15 - Update description of --enable-extra, and add missing line breaks. (DLR)<br>
|
||||
2005/06/13 - Minor capitalization and wording fixes. (DLR)<br>
|
||||
2005/06/08 - Updated section 1.1 to mention the current maintainer. (DLR)<br>
|
||||
2005/03/09 - Added question about opening files with names beginning with '+'s, and added a few more miscellaneous cosmetic fixes. (DLR)<br>
|
||||
2005/01/03 - Removed now-inaccurate note about verbatim input's not working at prompts, and update its description to mention that it handles hexadecimal values now. (DLR)<br>
|
||||
2004/11/21 - Listed sh as an example of a Bourne shell. (DLR)<br>
|
||||
2004/11/05 - Fixed inaccuracy: Pico compatibility mode was made the default in nano 1.1.99pre1, not 1.2.2. Also added question about how to type F13-F16 on terminals lacking keys past F12 (suggested by Chris), question about how to select text for the clipboard in X terminals with nano's mouse support turned on (answer found by Joseph Birthisel), and misc. fixes and link updates. (DLR)<br>
|
||||
2004/04/07 - Removed NumLock glitch question, as it's no longer needed. (DLR)<br>
|
||||
2004/01/30 - Fixed inaccuracy: multibuffer mode was first in nano 1.1.0, not 1.1.12. (DLR)<br>
|
||||
2003/12/31 - Added question about the new verbatim input function, and a few minor fixes. Removed reference to "set pico" (DLR).<br>
|
||||
2003/07/02 - Added question about nano's not showing color when it's compiled with color support (DLR; suggested by Jordi).<br>
|
||||
2003/02/23 - Updated RPM links for nano 1.2.x (DLR).<br>
|
||||
2003/01/16 - Split section 4.5 into 4.5a and 4.5b for search string behavior. Added --enable-all docs.<br>
|
||||
2002/12/28 - More misc. fixes (David Benbennick, DLR).<br>
|
||||
2002/10/25 - Misc. fixes and link updates (DLR).<br>
|
||||
2002/09/10 - Another typo fix (DLR).<br>
|
||||
2002/05/15 - Typo fix (DLR).<br>
|
||||
2001/12/26 - Misc. fixes (Aaron S. Hawley, DLR).<br>
|
||||
2001/10/02 - Update for Free Translation Project.<br>
|
||||
2001/10/02 - Assorted fixes, Debian additions.<br>
|
||||
2001/06/30 - Silly typo fix.<br>
|
||||
2001/05/05 - Spelling fixes by David Lawrence Ramsey.<br>
|
||||
2001/05/02 - Misc fixes.<br>
|
||||
2001/03/26 - Typo fix in an URL.<br>
|
||||
2001/02/17 - Advocacy updates.<br>
|
||||
2001/02/15 - Added GNU notes for 0.9.99pre3.<br>
|
||||
2001/02/06 - Typo fixes.<br>
|
||||
2001/01/14 - Added note about NumLock glitch.<br>
|
||||
2001/01/10 - Linux -> GNU/Linux.<br>
|
||||
2001/01/09 - Added "making exe smaller" section.<br>
|
||||
2000/12/19 - Typo and assorted error fixes.<br>
|
||||
2000/11/28 - Added blurb about make install-strip.<br>
|
||||
2000/11/19 - Changed Debian frozen to stable.<br>
|
||||
2000/11/18 - Previous string display (4.5).<br>
|
||||
2000/09/27 - Moved addresses to nano-editor.org.<br>
|
||||
2000/06/31 - Initial framework.</p></blockquote>
|
||||
2017.01.09 - Delete some obsolete items and update a few others. (Benno)<br>
|
||||
2016.04.17 - Update docs to refer to GIT instead of subversion. (Mike)<br>
|
||||
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. (Chris)<br>
|
||||
2007.12.21 - Update maintainer information. (DLR)<br>
|
||||
2007.12.09 - Add minor punctuation and wording fixes, and update various sections to account for Alpine. (DLR)<br>
|
||||
2007.08.26 - Update links to the Free Translation Project. (DLR)<br>
|
||||
2007.07.29 - Update RPM links for nano 2.0.x. (DLR)<br>
|
||||
2007.04.18 - Add a new section 4.14 to explain how autoindent affects pasted text. (John M. Gabriele, minor tweaks by DLR)<br>
|
||||
2007.04.04 - Update email address. (DLR)<br>
|
||||
2007.01.01 - Update section 4.1 to describe how to open files with names beginning with '+' at specified columns as well as lines. (DLR)<br>
|
||||
2006.11.25 - Add miscellaneous wording and capitalization fixes. (DLR)<br>
|
||||
2006.10.28 - Update various links for the 2.0 branch of nano. (DLR)<br>
|
||||
2006.10.06 - Update the question in section 4.13 to match the version of it in the answer section. (DLR)<br>
|
||||
2006.07.25 - Update section 5.3 again to not state "the latest development version" before 1.3.12, as it's no longer accurate. Also add some minor spacing fixes. (DLR)<br>
|
||||
2006.06.12 - Update section 5.3, due to the display fix for two-column Unicode characters. (DLR)<br>
|
||||
2006.06.05 - Add a new section 4.8, and move all section 4 entries after it down one number, to explain how to deal with glibc 2.2.3's crashes involving extended regular expressions. (DLR)<br>
|
||||
2006.06.04 - Add minor punctuation, wording, and typo fixes. (DLR)<br>
|
||||
2006.05.27 - Update section 3.8 to mention the new "Unicode Input" prompt, and how Unicode input only works when Unicode support is enabled. (DLR)<br>
|
||||
2006.05.12 - Remove section 4.4, and move all section 4 entries after it up one number, since it no longer applies. Meta-] and Meta-[ are no longer used to indent and unindent marked text, since they require that the bracket matching key change to Ctrl-], which is used as the telnet escape key (found by Chris). Also, make the link to the nano CVS page a bit more readable. (DLR)<br>
|
||||
2006.05.08 - Add a new section 4.5, and move all section 4 entries after it down one number, to explain a problem that can occur when holding down keys to generate Meta sequences. Also add a few more capitalization and wording fixes. (Benno Schulenberg, minor tweaks by DLR)<br>
|
||||
2006.05.01 - Add a new section 4.4, and move all section 4 entries after it down one number, to explain how to deal with problems typing Meta-[. Also add a few capitalization and wording fixes. (DLR)<br>
|
||||
2006.04.14 - Clarify section 1.4: help menu -> help text display. (DLR, suggested by Benno Schulenberg)<br>
|
||||
2006.03.16 - Update the Free Translation Project's address, change the character set to UTF-8, and remove broken links to contributed RedHat nano packages. (DLR)<br>
|
||||
2005.11.21 - Clarify section 5.3 to better explain how to enable Unicode support, and remove the mention of quirks, since they turned out to not be a nano problem. (Mike Frysinger and DLR)<br>
|
||||
2005.11.19 - Add a new section 5.3 to explain the status of nano's Unicode support. (Mike Frysinger, minor tweaks by DLR)<br>
|
||||
2005.08.27 - Update email address. (DLR)<br>
|
||||
2005.08.10 - Add a new section 4.3, and move all section 4 entries after it down one number, to explain how to deal with numeric keypad problems. (DLR)<br>
|
||||
2005.08.08 - Update section 3.8 to mention that verbatim input mode now takes a six-digit hexadecimal number. (DLR)<br>
|
||||
2005.07.04 - Update section 4.10 to mention that pasting from the X clipboard via the middle mouse button also works when the Shift key is used. (DLR)<br>
|
||||
2005.06.15 - Update description of --enable-extra, and add missing line breaks. (DLR)<br>
|
||||
2005.06.13 - Minor capitalization and wording fixes. (DLR)<br>
|
||||
2005.06.08 - Updated section 1.1 to mention the current maintainer. (DLR)<br>
|
||||
2005.03.09 - Added question about opening files with names beginning with '+'s, and added a few more miscellaneous cosmetic fixes. (DLR)<br>
|
||||
2005.01.03 - Removed now-inaccurate note about verbatim input's not working at prompts, and update its description to mention that it handles hexadecimal values now. (DLR)<br>
|
||||
2004.11.21 - Listed sh as an example of a Bourne shell. (DLR)<br>
|
||||
2004.11.05 - Fixed inaccuracy: Pico compatibility mode was made the default in nano 1.1.99pre1, not 1.2.2. Also added question about how to type F13-F16 on terminals lacking keys past F12 (suggested by Chris), question about how to select text for the clipboard in X terminals with nano's mouse support turned on (answer found by Joseph Birthisel), and misc. fixes and link updates. (DLR)<br>
|
||||
2004.04.07 - Removed NumLock glitch question, as it's no longer needed. (DLR)<br>
|
||||
2004.01.30 - Fixed inaccuracy: multibuffer mode was first in nano 1.1.0, not 1.1.12. (DLR)<br>
|
||||
2003.12.31 - Added question about the new verbatim input function, and a few minor fixes. Removed reference to "set pico" (DLR).<br>
|
||||
2003.07.02 - Added question about nano's not showing color when it's compiled with color support (DLR; suggested by Jordi).<br>
|
||||
2003.02.23 - Updated RPM links for nano 1.2.x (DLR).<br>
|
||||
2003.01.16 - Split section 4.5 into 4.5a and 4.5b for search string behavior. Added --enable-all docs.<br>
|
||||
2002.12.28 - More misc. fixes (David Benbennick, DLR).<br>
|
||||
2002.10.25 - Misc. fixes and link updates (DLR).<br>
|
||||
2002.09.10 - Another typo fix (DLR).<br>
|
||||
2002.05.15 - Typo fix (DLR).<br>
|
||||
2001.12.26 - Misc. fixes (Aaron S. Hawley, DLR).<br>
|
||||
2001.10.02 - Update for Free Translation Project.<br>
|
||||
2001.10.02 - Assorted fixes, Debian additions.<br>
|
||||
2001.06.30 - Silly typo fix.<br>
|
||||
2001.05.05 - Spelling fixes by David Lawrence Ramsey.<br>
|
||||
2001.05.02 - Misc fixes.<br>
|
||||
2001.03.26 - Typo fix in an URL.<br>
|
||||
2001.02.17 - Advocacy updates.<br>
|
||||
2001.02.15 - Added GNU notes for 0.9.99pre3.<br>
|
||||
2001.02.06 - Typo fixes.<br>
|
||||
2001.01.14 - Added note about NumLock glitch.<br>
|
||||
2001.01.10 - Linux -> GNU/Linux.<br>
|
||||
2001.01.09 - Added "making exe smaller" section.<br>
|
||||
2000.12.19 - Typo and assorted error fixes.<br>
|
||||
2000.11.28 - Added blurb about make install-strip.<br>
|
||||
2000.11.19 - Changed Debian frozen to stable.<br>
|
||||
2000.11.18 - Previous string display (4.5).<br>
|
||||
2000.09.27 - Moved addresses to nano-editor.org.<br>
|
||||
2000.06.31 - Initial framework.</p></blockquote>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
3
doc/man/.gitignore
vendored
3
doc/man/.gitignore
vendored
@@ -1,3 +0,0 @@
|
||||
nano.1.html
|
||||
nanorc.5.html
|
||||
rnano.1.html
|
||||
@@ -1,28 +0,0 @@
|
||||
SUBDIRS =
|
||||
BUILT_SOURCES =
|
||||
|
||||
if USE_NLS
|
||||
SUBDIRS += fr
|
||||
endif
|
||||
|
||||
dist_man_MANS = nano.1 rnano.1
|
||||
html_pages = nano.1.html rnano.1.html
|
||||
|
||||
if USE_NANORC
|
||||
dist_man_MANS += nanorc.5
|
||||
html_pages += nanorc.5.html
|
||||
endif
|
||||
|
||||
nano.1.html: nano.1
|
||||
groff -t -mandoc -Thtml < $? > $@
|
||||
nanorc.5.html: nanorc.5
|
||||
groff -t -mandoc -Thtml < $? > $@
|
||||
rnano.1.html: rnano.1
|
||||
groff -t -mandoc -Thtml < $? > $@
|
||||
|
||||
if GROFF_HTML
|
||||
BUILT_SOURCES += $(html_pages)
|
||||
dist_html_DATA = $(html_pages)
|
||||
endif
|
||||
|
||||
EXTRA_DIST = $(BUILT_SOURCES)
|
||||
@@ -1,26 +0,0 @@
|
||||
mandir = @mandir@/fr
|
||||
htmldir = @htmldir@/fr
|
||||
|
||||
BUILT_SOURCES =
|
||||
|
||||
dist_man_MANS = nano.1 rnano.1
|
||||
html_pages = nano.1.html rnano.1.html
|
||||
|
||||
if USE_NANORC
|
||||
dist_man_MANS += nanorc.5
|
||||
html_pages += nanorc.5.html
|
||||
endif
|
||||
|
||||
nano.1.html: nano.1
|
||||
groff -t -mandoc -Thtml < $? > $@
|
||||
nanorc.5.html: nanorc.5
|
||||
groff -t -mandoc -Thtml < $? > $@
|
||||
rnano.1.html: rnano.1
|
||||
groff -t -mandoc -Thtml < $? > $@
|
||||
|
||||
if GROFF_HTML
|
||||
BUILT_SOURCES += $(html_pages)
|
||||
dist_html_DATA = $(html_pages)
|
||||
endif
|
||||
|
||||
EXTRA_DIST = $(BUILT_SOURCES)
|
||||
@@ -1,324 +0,0 @@
|
||||
.\" Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
|
||||
.\" Free Software Foundation, Inc.
|
||||
.\"
|
||||
.\" Le travail d'adaptation française de cette page de manuel a été
|
||||
.\" réalisé par Jean-Philippe Guérard, en 2003, 2004, 2005, 2006 et 2007.
|
||||
.\" Ce travail d'adaptation est dans le domaine public. Attention, la
|
||||
.\" page traduite reste soumise au droit d'auteur de ses auteurs
|
||||
.\" originaux.
|
||||
.\"
|
||||
.\" The French translation of this document is a public domain work of
|
||||
.\" Jean-Philippe Guérard. This translation work was made in 2003, 2004,
|
||||
.\" 2005, 2006 and 2007. The translated man page in itself is still
|
||||
.\" subject to the copyright of its original authors.
|
||||
.\"
|
||||
.\" This document is dual-licensed. You may distribute and/or modify it
|
||||
.\" under the terms of either of the following licenses:
|
||||
.\"
|
||||
.\" * The GNU General Public License, as published by the Free Software
|
||||
.\" Foundation, version 3 or (at your option) any later version. You
|
||||
.\" should have received a copy of the GNU General Public License
|
||||
.\" along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.\" * The GNU Free Documentation License, as published by the Free
|
||||
.\" Software Foundation, version 1.2 or (at your option) any later
|
||||
.\" version, with no Invariant Sections, no Front-Cover Texts, and no
|
||||
.\" Back-Cover Texts. You should have received a copy of the GNU Free
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.\" Ce document est publié sous une double licence. Vous pouvez
|
||||
.\" le distribuer et le modifier selon les termes de l'une des deux
|
||||
.\" licences ci-dessous :
|
||||
.\"
|
||||
.\" * La Licence publique générale GNU (GNU GPL) version 3 ou, à
|
||||
.\" votre choix, supérieure, telle que publiée par la Free
|
||||
.\" Software Foundation. Vous devriez avoir reçu une copie de la
|
||||
.\" Licence publique générale GNU avec ce programme. Si ce n'est pas
|
||||
.\" le cas, consultez <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.\" * La Licence de documentation libre GNU (GNU FDL), version 1.2 ou,
|
||||
.\" à votre choix, supérieure, telle que publiée par la Free
|
||||
.\" Software Foundation, sans section invariante, ni texte de
|
||||
.\" première ou de quatrième de couverture. Vous devriez avoir reçu
|
||||
.\" une copie de la Licence de documentation libre GNU avec ce
|
||||
.\" programme. Si ce n'est pas le cas, consultez
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANO 1 "version 2.0.0" "29\ novembre\ 2007"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\" Merci de modifier ces dates à chaque mise à jour de cette page.
|
||||
.\"
|
||||
|
||||
.SH NOM
|
||||
nano \- NAno un NOuvel éditeur, un clone libre et amélioré de Pico
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B nano
|
||||
.I [OPTIONS]\ [[+LIGNE,COLONNE]\ FICHIER]...
|
||||
.br
|
||||
|
||||
.SH DESCRIPTION
|
||||
Cette page de manuel décrit brièvement la commande \fBnano\fR.
|
||||
.PP
|
||||
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
|
||||
.\" \fI<whatever>\fP escape sequences to invoke bold face and italics,
|
||||
.\" respectively.
|
||||
\fBnano\fR est un éditeur petit, sympathique et libre, qui vise à remplacer
|
||||
Pico, l'éditeur par défaut du logiciel non libre Pine. \fBnano\fR ne se
|
||||
contentant pas de copier l'interface et l'ergonomie de Pico, il offre
|
||||
également certaines fonctions manquantes (ou désactivées par défaut)
|
||||
dans Pico. Ces fonctionnalités sont, par exemple, les fonctions de
|
||||
recherche et de remplacement, et la possibilité de sauter directement à
|
||||
une ligne et à une colonne précise.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B +\fILIGNE\fP,\fICOLONNE\fP
|
||||
Démarre avec le curseur positionné à la colonne \fICOLONNE\fP de
|
||||
la ligne \fILIGNE\fR (l'un des deux, au moins, devant être spécifié) au
|
||||
lieu de démarrer à la colonne\ 1, ligne\ 1.
|
||||
.TP
|
||||
.B \-?
|
||||
Identique à \fB\-h (\-\-help)\fP.
|
||||
.TP
|
||||
.B \-A (\-\-smarthome)
|
||||
Rend plus malin le fonctionnement de la touche «\ Début\ ». Lorsque l'on
|
||||
appuie sur cette touche à n'importe quel endroit excepté au tout début
|
||||
du texte d'une ligne (i.\ e. au premier caractère non blanc), le curseur
|
||||
se positionnera au début du texte de la ligne (qu'il soit en avant ou en
|
||||
arrière). Si le curseur est déjà là, il se placera au vrai début de la
|
||||
ligne.
|
||||
.TP
|
||||
.B \-B (\-\-backup)
|
||||
Lors de l'écriture d'un fichier, crée une copie de sécurité de la
|
||||
version précédente, en ajoutant un tilde (~) au nom du fichier.
|
||||
.TP
|
||||
.B \-D (\-\-boldtext)
|
||||
Utilise des caractères gras à la place de la vidéo inverse.
|
||||
.TP
|
||||
.B \-C \fIrépertoire\fP (\-\-backupdir=\fIrépertoire\fP)
|
||||
Définit le répertoire utilisé par \fBnano\fP pour enregistrer les copies
|
||||
de sécurité uniques si celles-ci sont activées.
|
||||
.TP
|
||||
.B \-E (\-\-tabstospaces)
|
||||
Convertit les tabulations clavier en espaces.
|
||||
.TP
|
||||
.B \-F (\-\-multibuffer)
|
||||
Active le mode multi-espace, autorisant l'édition simultanée de
|
||||
plusieurs fichiers, si ce mode est disponible.
|
||||
.TP
|
||||
.B \-H (\-\-historylog)
|
||||
Enregistre les chaînes ayant fait l'objet d'une recherche ou d'un
|
||||
remplacement dans le fichier \fI~/.nano_history\fR afin de permettre leur
|
||||
réutilisation. Ceci n'est possible que si \fBnano\fR est configuré pour
|
||||
utiliser les fichiers nanorc.
|
||||
.TP
|
||||
.B \-I (\-\-ignorercfiles)
|
||||
Ne pas utiliser pas les fichiers \fISYSCONFDIR/nanorc\fR et
|
||||
\fI~/.nanorc\fR (si \fBnano\fR est capable de les utiliser).
|
||||
.TP
|
||||
.B \-K (\-\-rebindkeypad)
|
||||
Interprète les touches du pavé numérique afin qu'elles fonctionnent
|
||||
toutes correctement. Vous ne devriez utiliser cette option que si ce
|
||||
n'est pas le cas, car nano ne sera plus capable d'utiliser la souris
|
||||
correctement lorsque cette option sera activée.
|
||||
.TP
|
||||
.B \-L (\-\-nonewlines)
|
||||
Ne pas ajouter de passage à la ligne à la fin des fichiers.
|
||||
.TP
|
||||
.B \-N (\-\-noconvert)
|
||||
Désactive la conversion automatique des fichiers depuis les formats Mac et
|
||||
DOS.
|
||||
.TP
|
||||
.B \-O (\-\-morespace)
|
||||
Utiliser la ligne blanche située sous la ligne de titre comme
|
||||
espace supplémentaire d'édition.
|
||||
.TP
|
||||
.B \-Q \fIchaîne\fP (\-\-quotestr=\fIchaîne\fP)
|
||||
Définit le préfixe par défaut des citations. Nano utilise ce préfixe
|
||||
pour réaliser une justification correcte des citations. Si nano est
|
||||
capable d'utiliser des expressions rationnelles, le préfixe par défaut
|
||||
sera "\fI^([\ \\t]*[#:>\\|}])+\fP", sinon, ce sera "\fI>\ \fP". Dans
|
||||
l'expression rationnelle précédente, «\ \fI\\t\fP\ » représente une
|
||||
tabulation.
|
||||
.TP
|
||||
.B \-R (\-\-restricted)
|
||||
Mode restreint\ : aucune lecture ou écriture de fichiers non indiqués
|
||||
sur la ligne de commande, pas de lecture des fichiers nanorc,
|
||||
interdiction de suspendre, interdiction d'ajouter au début, à la fin,
|
||||
de sauvegarder un fichier ayant déjà un nom sous un nom différent,
|
||||
d'utiliser une copie de sécurité ou le correcteur orthographique. Cette
|
||||
option peut aussi être activée en appelant \fBnano\fP sous un nom
|
||||
commençant par «\ r\ » (par exemple «\ rnano\ »).
|
||||
.TP
|
||||
.B \-S (\-\-smooth)
|
||||
Active le défilement progressif. Le texte défilera ligne-par-ligne au lieu
|
||||
de défiler morceau-par-morceau.
|
||||
.TP
|
||||
.B \-T \fInombre\fP (\-\-tabsize=\fInombre\fP)
|
||||
Définit la taille (largeur) des tabulations en nombre de colonnes. Le
|
||||
nombre indiqué doit être strictement supérieur à 0. La valeur par défaut
|
||||
est de 8.
|
||||
.TP
|
||||
.B \-U (\-\-quickblank)
|
||||
Effacement rapide de la ligne d'état. Les messages affichés par la ligne
|
||||
d'état disparaîtront après une frappe clavier au lieu de 25. Notez que
|
||||
l'option \fB-c\fP prend le pas sur cette option.
|
||||
.TP
|
||||
.B \-V (\-\-version)
|
||||
Affiche la version, puis s'arrête.
|
||||
.TP
|
||||
.B \-W (\-\-wordbounds)
|
||||
Détection plus précise des limites de mots, obtenue en considérant les
|
||||
caractères de ponctuation comme faisant partie des mots.
|
||||
.TP
|
||||
.B \-Y \fIchaîne\fP (\-\-syntax=\fIchaîne\fP)
|
||||
Indique quel mode de colorisation syntaxique adopter, parmi les modes
|
||||
définis dans le fichier \fI.nanorc\fR, si cette fonctionnalité est
|
||||
disponible.
|
||||
.TP
|
||||
.B \-c (\-\-const)
|
||||
Affiche en permanence la position du curseur. Notez que cette option
|
||||
prend le pas sur l'option \fB-U\fP.
|
||||
.TP
|
||||
.B \-d (\-\-rebinddelete)
|
||||
Interprète différemment la touche «\ Supprimer\ », afin que les touches
|
||||
«\ Effacement arrière\ » et «\ Supprimer\ » fonctionnent correctement.
|
||||
Vous ne devriez avoir besoin de cette option que si, sur votre système,
|
||||
la touche «\ Effacement arrière\ » produit l'effet de la touche
|
||||
«\ Supprimer\ ».
|
||||
.TP
|
||||
.B \-h (\-\-help)
|
||||
Affiche un résumé des options de lancement de nano, puis s'arrête.
|
||||
.TP
|
||||
.B \-i (\-\-autoindent)
|
||||
Indentation automatique. Commence chaque nouvelle ligne au même niveau que
|
||||
la ligne précédente. Utile pour l'édition de code source.
|
||||
.TP
|
||||
.B \-k (\-\-cut)
|
||||
Coupe le texte du curseur à la fin de la ligne, au lieu de couper la
|
||||
ligne entière.
|
||||
.TP
|
||||
.B \-l (\-\-nofollow)
|
||||
Si le fichier édité est un lien symbolique, au lieu de le suivre,
|
||||
remplace le lien par le nouveau fichier. Sans doute utile pour éditer
|
||||
les fichiers de \fI/tmp\fR, non\ ?
|
||||
.TP
|
||||
.B \-m (\-\-mouse)
|
||||
Active l'utilisation de la souris, si elle est disponible pour votre
|
||||
système. Lorsque celle-ci est activée, il est possible d'utiliser la
|
||||
souris pour positionner le curseur, pour marquer le texte (avec un
|
||||
double-clic) et pour lancer les fonctions correspondant aux raccourcis.
|
||||
Il est possible d'utiliser la souris sous X\ Window ou en mode console
|
||||
avec gpm.
|
||||
.TP
|
||||
.B \-o \fIrépertoire\fP (\-\-operatingdir=\fIrépertoire\fP)
|
||||
Définit le répertoire de travail. Demande à \fBnano\fP de mettre en place
|
||||
quelque chose de similaire à un environnement d'exécution restreint
|
||||
(\fIchroot\fR).
|
||||
.TP
|
||||
.B \-p (\-\-preserve)
|
||||
Préserve les séquences XON et XOFF (^Q et ^S), afin qu'elle soient reçues
|
||||
par le terminal.
|
||||
.TP
|
||||
.B \-r \fIcolonne\fP (\-\-fill=\fIcolonne\fP)
|
||||
Passe automatiquement à la ligne une fois arrivé à la colonne
|
||||
\fIcolonne\fR. Si la valeur indiquée est de 0 ou moins, le point de
|
||||
passage à la ligne aura lieu à la taille de l'écran moins \fIcolonne\fR.
|
||||
Cela permet de faire varier le point de passage à la ligne lorsque l'on
|
||||
change la taille de l'écran. La valeur par défaut est de \-8.
|
||||
.TP
|
||||
.B \-s \fIprogramme\fP (\-\-speller=\fIprogramme\fP)
|
||||
Choix d'un correcteur orthographique de remplacement.
|
||||
.TP
|
||||
.B \-t (\-\-tempfile)
|
||||
S'il a été modifié, le fichier sera sauvegardé automatiquement sans
|
||||
demande de confirmation. Identique à l'option \fB-t\fP de Pico.
|
||||
.TP
|
||||
.B \-v (\-\-view)
|
||||
Mode visualisation (lecture seule).
|
||||
.TP
|
||||
.B \-w (\-\-nowrap)
|
||||
Désactive le passage automatique à la ligne.
|
||||
.TP
|
||||
.B \-x (\-\-nohelp)
|
||||
Désactive la barre d'aide affichée en bas de l'écran.
|
||||
.TP
|
||||
.B \-z (\-\-suspend)
|
||||
Autorise à suspendre l'éditeur.
|
||||
.TP
|
||||
.B \-a, \-b, \-e, \-f, \-g, \-j
|
||||
Ignoré, pour être compatible avec Pico.
|
||||
|
||||
.SH "FICHIERS D'INITIALISATION"
|
||||
\fBnano\fR lit les fichiers d'initialisation dans l'ordre suivant\ :
|
||||
\fISYSCONFDIR/nanorc\fR, puis \fI~/.nanorc\fR. Référez-vous à la page de
|
||||
manuel de \fBnanorc(5)\fR et au fichier d'exemple \fInanorc.sample\fR,
|
||||
qui devraient tous les deux être livrés avec \fBnano\fR.
|
||||
|
||||
.SH NOTES
|
||||
Si aucun correcteur orthographique de remplacement n'est indiqué dans la
|
||||
ligne de commande ou dans l'un des fichiers nanorc, \fBnano\fR prendra
|
||||
la commande indiquée par la variable d'environnement \fBSPELL\fR si
|
||||
elle est définie.
|
||||
|
||||
Dans certains cas, \fBnano\fR essaiera de sauvegarder le fichier en cours
|
||||
d'édition dans un fichier de secours. Cela arrivera principalement si
|
||||
\fBnano\fR reçoit un signal SIGHUP ou SIGTERM, ou bien se trouve à court de
|
||||
mémoire. Le nom de ce fichier de secours sera \fInano.save\fR si le fichier en
|
||||
cours n'avait pas encore de nom, ou sera composé du nom du fichier en cours
|
||||
suivi du suffixe «\ .save\ ». Si un fichier de ce nom existe déjà dans
|
||||
le répertoire, un «\ .save\ » et un nombre seront ajoutés à la fin du
|
||||
nom du fichier en cours afin de le rendre unique (par exemple,
|
||||
«\ .save.1\ »). En mode multi-espace, \fBnano\fR réalisera une
|
||||
sauvegarde de tous les fichiers en cours dans leurs fichiers de secours
|
||||
respectifs.
|
||||
|
||||
.SH BOGUES
|
||||
Merci de nous faire parvenir vos commentaires et de nous signaler les
|
||||
bogues, en écrivant, en anglais, à \fBnano@nano-editor.org\fR.
|
||||
|
||||
La liste de discussion anglophone \fBnano\fR est disponible à l'adresse
|
||||
\fBnano-devel@gnu.org\fR.
|
||||
|
||||
Pour vous abonner, envoyez un courrier électronique à
|
||||
\fBnano-devel-request@gnu.org\fR, ayant pour objet «\ subscribe\ ».
|
||||
|
||||
N'hésitez pas également à envoyez vos commentaires, suggestions et
|
||||
corrections relatives à l'adaptation française de cette page de manuel
|
||||
ou du logiciel à \fBjean-philippe.guerard@tigreraye.org\fR.
|
||||
|
||||
.SH "SITE INTERNET"
|
||||
http://www.nano-editor.org/
|
||||
|
||||
.SH "VOIR AUSSI"
|
||||
.PD 0
|
||||
.TP
|
||||
\fBnanorc\fR(5)
|
||||
.PP
|
||||
\fI/usr/share/doc/nano/\fR (ou son équivalent sur votre système)
|
||||
|
||||
.SH AUTEUR
|
||||
Chris Allegretta <chrisa@asty.org> et d'autres (voir les fichiers
|
||||
\fIAUTHORS\fR et \fITHANKS\fR pour plus d'information). Cette page de
|
||||
manuel a été initialement rédigée par Jordi Mallach <jordi@gnu.org> pour
|
||||
le système Debian (mais elle peut être utilisée par d'autres).
|
||||
|
||||
.SH TRADUCTION
|
||||
Cette adaptation française a été réalisée par Jean-Philippe\ Guérard
|
||||
<jean-philippe.guerard@tigreraye.org> le 29\ novembre\ 2007 à partir
|
||||
de la version 1.54 du 11\ octobre\ 2007 de la page de manuel de nano
|
||||
2.0.0. Cette page a été relue par Gérard Delafond.
|
||||
|
||||
Un maximum de soin a été apporté lors de l'élaboration de cette
|
||||
traduction\ ; néanmoins, quelques imperfections peuvent subsister. Si
|
||||
vous en rencontrez, que ce soit dans la version française ou dans la
|
||||
version originale, n'hésitez pas à les signaler à l'auteur ou au
|
||||
traducteur.
|
||||
|
||||
La version originale la plus à jour de ce document est toujours
|
||||
consultable via la commande\ :
|
||||
|
||||
LANGUAGE=en man nano
|
||||
@@ -1,374 +0,0 @@
|
||||
.\" Copyright (C) 2003, 2004, 2005, 2006, 2007
|
||||
.\" Free Software Foundation, Inc.
|
||||
.\"
|
||||
.\" Le travail d'adaptation française de cette page de manuel a été
|
||||
.\" réalisé par Jean-Philippe Guérard, en 2003, 2004, 2005, 2006 et 2007.
|
||||
.\" Ce travail d'adaptation est dans le domaine public. Attention, la
|
||||
.\" page traduite reste soumise au droit d'auteur de ses auteurs
|
||||
.\" originaux.
|
||||
.\"
|
||||
.\" The French translation of this document is a public domain work of
|
||||
.\" Jean-Philippe Guérard. This translation work was made in 2003, 2004,
|
||||
.\" 2005, 2006 and 2007. The translated man page in itself is still
|
||||
.\" subject to the copyright of its original authors.
|
||||
.\"
|
||||
.\" This document is dual-licensed. You may distribute and/or modify it
|
||||
.\" under the terms of either of the following licenses:
|
||||
.\"
|
||||
.\" * The GNU General Public License, as published by the Free Software
|
||||
.\" Foundation, version 3 or (at your option) any later version. You
|
||||
.\" should have received a copy of the GNU General Public License
|
||||
.\" along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.\" * The GNU Free Documentation License, as published by the Free
|
||||
.\" Software Foundation, version 1.2 or (at your option) any later
|
||||
.\" version, with no Invariant Sections, no Front-Cover Texts, and no
|
||||
.\" Back-Cover Texts. You should have received a copy of the GNU Free
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.\" Ce document est publié sous une double licence. Vous pouvez
|
||||
.\" le distribuer et le modifier selon les termes de l'une des deux
|
||||
.\" licences ci-dessous :
|
||||
.\"
|
||||
.\" * La Licence publique générale GNU (GNU GPL) version 3 ou, à
|
||||
.\" votre choix, supérieure, telle que publiée par la Free
|
||||
.\" Software Foundation. Vous devriez avoir reçu une copie de la
|
||||
.\" Licence publique générale GNU avec ce programme. Si ce n'est
|
||||
.\" pas le cas, consultez <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.\" * La Licence de documentation libre GNU (GNU FDL), version 1.2
|
||||
.\" ou, à votre choix, supérieure, telle que publiée par la Free
|
||||
.\" Software Foundation, sans section invariante, ni texte de
|
||||
.\" première ou de quatrième de couverture. Vous devriez avoir reçu
|
||||
.\" une copie de la Licence de documentation libre GNU avec ce
|
||||
.\" programme. Si ce n'est pas le cas, consultez
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANORC 5 "version 2.0.0" "29\ novembre\ 2007"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\" Merci de modifier ces dates à chaque mise à jour de cette page.
|
||||
|
||||
.SH NOM
|
||||
nanorc \- fichier de configuration de l'éditeur nano du projet GNU
|
||||
|
||||
.SH DESCRIPTION
|
||||
Cette page de manuel décrit brièvement le fichier de configuration de
|
||||
l'éditeur \fBnano\fP GNU.
|
||||
.PP
|
||||
\fBnano\fP est un petit éditeur sympathique et libre, qui vise à
|
||||
remplacer Pico, l'éditeur par défaut du logiciel non libre Pine.
|
||||
\fBnano\fP ne se contentant pas de copier l'interface et l'ergonomie de
|
||||
Pico, il offre également certaines fonctionnalités manquantes (ou
|
||||
désactivées par défaut) de Pico. Ces fonctionnalités sont, par exemple,
|
||||
les fonctions de recherche et de remplacement et la possibilité de
|
||||
sauter directement à une ligne et à une colonne précise.
|
||||
.PP
|
||||
Le fichier \fInanorc\fP contient les paramètres par défaut de
|
||||
\fBnano\fP. Il ne doit pas être au format DOS ou Mac. Lors de son
|
||||
démarrage, nano commencera par lire le fichier de configuration général
|
||||
\fISYSCONFDIR/nanorc\fP, puis lira le fichier de configuration personnel
|
||||
de l'utilisateur \fI~/.nanorc\fP.
|
||||
|
||||
.SH OPTIONS
|
||||
Le fichier de configuration accepte une série de commandes \fBset\fP
|
||||
(activer) et \fBunset\fP (désactiver), qui permettent de définir le
|
||||
paramétrage de nano au démarrage sans avoir à utiliser d'options de
|
||||
ligne de commande. De plus, les mots clefs \fBsyntax\fP (syntaxe),
|
||||
\fBcolor\fP (couleur) et \fBicolor\fP (couleur insensible à la casse)
|
||||
sont utilisés pour définir les règles de colorisation pour différents
|
||||
motifs de texte. \fBnano\fP lit une commande par ligne.
|
||||
|
||||
Les options du fichier de configuration ont priorité sur les valeurs par
|
||||
défaut utilisées par nano. Les options de la ligne de commande sont
|
||||
prioritaires par rapport aux options du fichier de configuration. Les
|
||||
options sont désactivées (unset) par défaut, sauf les options prenant un
|
||||
argument.
|
||||
|
||||
Les apostrophes («\ \fI'\fP\ ») et les guillemets droits («\ \fI"\fP\ »)
|
||||
présents dans des chaînes de caractères utilisées comme paramètres n'ont
|
||||
pas besoin d'être précédées d'une barre oblique inversée
|
||||
(«\ \fI\\\fP\ »). La chaîne sera terminée par le dernier guillemet
|
||||
droit. Par exemple, pour l'option \fBbrackets\fP, "\fI"')>]}\fP"
|
||||
correspondra à \fI"\fP, \fI'\fP, \fI)\fP, \fI>\fP, \fI]\fP et \fI}\fP.
|
||||
|
||||
Les commandes et arguments reconnus sont\ :
|
||||
|
||||
.TP 3
|
||||
.B set/unset autoindent
|
||||
Active l'indentation automatique.
|
||||
.TP
|
||||
.B set/unset backup
|
||||
Crée des copies de sécurité nommées
|
||||
.IR nom_du_fichier~ .
|
||||
.TP
|
||||
.B set backupdir "\fIrépertoire\fP"
|
||||
Définit le répertoire utilisé par \fBnano\fP pour enregistrer les copies
|
||||
de sécurité uniques, si l'enregistrement de copies de sécurité est
|
||||
activé.
|
||||
.TP
|
||||
.B set/unset backwards
|
||||
Par défaut, les recherches se font vers l'arrière.
|
||||
.TP
|
||||
.B set/unset boldtext
|
||||
Utilise des caractères gras à la place de la vidéo inverse.
|
||||
.TP
|
||||
.B set brackets "\fIchaîne\fP"
|
||||
Définit les caractères considérés comme des crochets fermants lors de la
|
||||
justification des paragraphes. Ces caractères ne doivent pas contenir
|
||||
d'espaces. Seules les ponctuations terminales, éventuellement suivies
|
||||
de crochets fermants, peuvent terminer une phrase.
|
||||
|
||||
La valeur par défaut de cette option est\ : "\fI"')>]}\fP".
|
||||
|
||||
N.D.T.\ : reportez-vous au paragraphe sur l'option \fBpunct\fR pour
|
||||
plus d'informations.
|
||||
|
||||
.TP
|
||||
.B set/unset casesensitive
|
||||
Par défaut, les recherches ne tiennent pas compte de la casse.
|
||||
.TP
|
||||
.B set/unset const
|
||||
Affiche en permanence la position du curseur dans la ligne d'état.
|
||||
.TP
|
||||
.B set/unset cut
|
||||
Par défaut, coupe le texte du curseur à la fin de la ligne, au lieu de
|
||||
couper la ligne entière.
|
||||
.TP
|
||||
.B set fill \fIn\fP
|
||||
Passe automatiquement à la ligne une fois arrivé à la colonne
|
||||
\fIn\fR. Si la valeur indiquée est de 0 ou moins, le point de passage à
|
||||
la ligne aura lieu à la taille de l'écran moins \fIn\fR. Cela permet de
|
||||
faire varier le point de passage à la ligne lorsque l'on change la
|
||||
taille de l'écran. La valeur par défaut est de \-8.
|
||||
.TP
|
||||
.B set/unset historylog
|
||||
Active l'utilisation de
|
||||
.I ~/.nano_history
|
||||
pour enregistrer et relire les chaînes ayant fait l'objet d'une
|
||||
recherche ou d'un remplacement.
|
||||
.TP
|
||||
.B set matchbrackets "\fIchaîne\fP"
|
||||
Définit les crochets ouvrants et fermant pour la recherche de crochets
|
||||
correspondants. Cette liste ne doit pas contenir de blancs. L'ensemble
|
||||
des crochets ouvrants doit être indiqué en premier, suivi de l'ensemble
|
||||
des crochets fermant, qui doit être dans le même ordre. La valeur par
|
||||
défaut de cette option est "\fI(<[{)>]}\fP".
|
||||
.TP
|
||||
.B set/unset morespace
|
||||
Utiliser la ligne blanche située sous la ligne de titre comme espace
|
||||
supplémentaire d'édition.
|
||||
.TP
|
||||
.B set/unset mouse
|
||||
Active l'utilisation de la souris, si elle est disponible pour votre
|
||||
système. Lorsque celle-ci est activée, il est possible d'utiliser la
|
||||
souris pour positionner le curseur, pour marquer le texte (avec un
|
||||
double-clic) et pour lancer les fonctions correspondant aux raccourcis.
|
||||
Il est possible d'utiliser la souris sous X\ Window ou en mode console
|
||||
avec gpm.
|
||||
.TP
|
||||
.B set/unset multibuffer
|
||||
Mode multi-espace\ : permet de charger les fichiers dans leur propre
|
||||
espace.
|
||||
.TP
|
||||
.B set/unset noconvert
|
||||
Pas de conversion depuis les formats DOS et Mac.
|
||||
.TP
|
||||
.B set/unset nofollow
|
||||
Ne suit pas les liens symboliques lors de l'écriture des fichiers.
|
||||
.TP
|
||||
.B set/unset nohelp
|
||||
Désactive les lignes d'aide affichée en bas de l'écran.
|
||||
.TP
|
||||
.B set/unset nonewlines
|
||||
Ne pas ajouter de passage à la ligne à la fin des fichiers.
|
||||
.TP
|
||||
.B set/unset nowrap
|
||||
Désactive le passage automatique à la ligne.
|
||||
.TP
|
||||
.B set operatingdir "\fIrépertoire\fP"
|
||||
\fBnano\fP ne lira et n'écrira des fichiers qu'à l'intérieur du
|
||||
\fIrépertoire\fP et de ses sous-répertoires. De plus, celui-ci devient
|
||||
le répertoire courant, afin que les fichiers soient lus depuis ce
|
||||
répertoire. Par défaut, cette fonction est désactivée.
|
||||
.TP
|
||||
.B set/unset preserve
|
||||
Préserve les séquences XON et XOFF (^Q et ^S).
|
||||
.TP
|
||||
.B set punct "\fIchaîne\fP"
|
||||
Définit les caractères interprétés comme des ponctuations terminales
|
||||
lors de la justification des paragraphes. Ces caractères ne peuvent
|
||||
inclure de blancs. Seules les ponctuations terminales, éventuellement
|
||||
suivies de crochets fermants, peuvent terminer une phrase. La valeur par
|
||||
défaut de cette option est "\fI!.?\fP".
|
||||
|
||||
N.D.T.\ : ce réglage permet, lors de la justification, de conserver
|
||||
2\ espaces au lieu d'une derrière les ponctuations terminales, ce qui
|
||||
correspond aux normes typographiques anglo-saxonnes, mais n'a pas lieu
|
||||
d'être en français. Pour le français, le plus simple est d'indiquer,
|
||||
dans le fichier nanorc, une chaîne vide pour ce paramètre.
|
||||
.TP
|
||||
.B set/unset quickblank
|
||||
Effacement rapide de la ligne d'état. Les messages affichés par la ligne
|
||||
d'état disparaîtront après une frappe clavier au lieu de 25.
|
||||
.TP
|
||||
.B set quotestr "\fIchaîne\fP"
|
||||
Définit le préfixe par défaut utilisé pour les citations dans les
|
||||
courriers électroniques. Ce préfixe est utilisé pour réaliser une
|
||||
justification correcte de ces citations. Il s'agira, si votre système le
|
||||
permet, d'une expression rationnelle étendue. Dans le cas
|
||||
contraire, il s'agira d'une chaîne de texte brut. Si vous disposez des
|
||||
expressions rationnelles, la valeur par défaut de cette option sera
|
||||
"\fI^([\ \\t]*[#:>\\|}])+\fP", sinon, ce sera ">\ ". Notez que le
|
||||
«\ \\t\ » ci-dessus correspond à un caractère de tabulation.
|
||||
.TP
|
||||
.B set/unset rebinddelete
|
||||
Interprète différemment la touche «\ Supprimer\ », afin que les touches
|
||||
«\ Effacement arrière\ » et «\ Supprimer\ » fonctionnent correctement.
|
||||
Vous ne devriez avoir besoin de cette option que si, sur votre système,
|
||||
la touche «\ Effacement arrière\ » produit l'effet de la touche «\
|
||||
Supprimer\ ».
|
||||
.TP
|
||||
.B set/unset rebindkeypad
|
||||
Interprète les touches du pavé numérique afin qu'elles fonctionnent
|
||||
toutes correctement. Vous ne devriez utiliser cette option que si ce
|
||||
n'est pas le cas, car nano ne sera plus capable d'utiliser la souris
|
||||
correctement lorsque cette option sera activée.
|
||||
.TP
|
||||
.B set/unset regexp
|
||||
Utilise par défaut des expressions rationnelles étendues pour les
|
||||
recherches.
|
||||
.TP
|
||||
.B set/unset smarthome
|
||||
Rend plus malin le fonctionnement de la touche «\ Début\ ». Lorsque
|
||||
cette touche est pressée à n'importe quel endroit excepté au tout début
|
||||
du texte d'une ligne (i.\ e. au premier caractère non blanc), le curseur
|
||||
se positionnera au début du texte de la ligne (qu'il soit en avant ou en
|
||||
arrière). Si le curseur est déjà là, il se placera au vrai début de la
|
||||
ligne.
|
||||
.TP
|
||||
.B set/unset smooth
|
||||
Active le défilement ligne-par-ligne du texte.
|
||||
.TP
|
||||
.B set speller "\fIprogramme\fP"
|
||||
Utilise le correcteur orthographique \fIprogramme\fP au lieu du
|
||||
correcteur intégré, qui s'appuie sur \fIspell\fP.
|
||||
.TP
|
||||
.B set/unset suspend
|
||||
Autorise à suspendre \fBnano\fP.
|
||||
.TP
|
||||
.B set tabsize \fIn\fP
|
||||
Utilise une taille de tabulation de \fIn\fP colonnes. Cette valeur doit
|
||||
être strictement supérieure à 0. La valeur par défaut est de\ 8.
|
||||
.TP
|
||||
.B set/unset tabstospaces
|
||||
Convertit les tabulations clavier en espaces.
|
||||
.TP
|
||||
.B set/unset tempfile
|
||||
S'il a été modifié, le fichier sera sauvegardé automatiquement en
|
||||
quittant, sans demande de confirmation.
|
||||
.TP
|
||||
.B set/unset view
|
||||
Interdit de modifier les fichiers.
|
||||
.TP
|
||||
.B set whitespace "\fIchaîne\fP"
|
||||
Définit les deux caractères utilisés pour afficher les premiers
|
||||
caractères des tabulations et des espaces. Ces deux caractères doivent
|
||||
être mono-colonne.
|
||||
.TP
|
||||
.B set/unset wordbounds
|
||||
Détection plus précise des limites de mots, obtenue en considérant les
|
||||
caractères de ponctuation comme faisant partie des mots.
|
||||
.TP
|
||||
.B syntax "\fIchaîne\fP" ["\fImotif_de_fichier\fP" ... ]
|
||||
Définit une syntaxe nommée \fIchaîne\fP qui pourra être activé via
|
||||
l'option \fB-Y\fP (ou \fB--syntax\fP) ou qui sera automatiquement
|
||||
activée si le nom du fichier en cours correspond à l'expression
|
||||
rationnelle étendue \fImotif_de_fichier\fP. Toutes les instructions
|
||||
suivantes de colorisation \fBcolor\fP ou \fBicolor\fP s'appliqueront à
|
||||
cette syntaxe, jusqu'à la définition d'une nouvelle syntaxe.
|
||||
|
||||
La syntaxe nommée \fInone\fP (aucune) est réservée\ ; si elle est
|
||||
indiquée dans la ligne de commande, cela revient à ne définir aucune
|
||||
syntaxe. La syntaxe nommée \fIdefault\fP (par défaut) est spéciale, elle
|
||||
ne nécessite aucun motif de \fImotif_de_fichier\fP, et s'applique aux
|
||||
fichiers ne correspondant à aucun des \fImotif_de_fichier\fP des autres
|
||||
syntaxes.
|
||||
.TP
|
||||
.B color \fIcouleur_texte\fP[,\fIcouleur_fond\fP] "\fImotif\fP" ...
|
||||
Pour la syntaxe en cours, affiche toutes les expressions correspondant à
|
||||
l'expression rationnelle étendue \fImotif\fP en utilisant la couleur de
|
||||
texte \fIcouleur_texte\fP et la couleur de fond \fIcouleur_fond\fP,
|
||||
l'une de ces deux couleurs au moins devant être définie. Les couleurs
|
||||
acceptées par \fBnano\fP pour le texte et le fond sont\ : \fIwhite\fP
|
||||
(blanc), \fIblack\fP (noir), \fIred\fP (rouge), \fIblue\fP (bleu),
|
||||
\fIgreen\fP (vert), \fIyellow\fP (jaune), \fImagenta\fP, et \fIcyan\fP.
|
||||
Pour la couleur du texte, vous pouvez ajouter à ces couleurs le préfixe
|
||||
\fIbright\fP (lumineux) pour obtenir une couleur plus lumineuse. Si
|
||||
votre terminal est capable de gérer la transparence, ne pas spécifier de
|
||||
\fIcouleur_fond\fP indique à \fBnano\fP d'essayer d'utiliser un fond
|
||||
transparent.
|
||||
.TP
|
||||
.B icolor \fIcouleur_texte\fP[,\fIcouleur_fond\fP] "\fImotif\fP" ...
|
||||
Comme ci-dessus, mais la recherche des motifs est effectuée sans tenir
|
||||
compte de la casse.
|
||||
.TP
|
||||
.B color \fIcouleur_texte\fP[,\fIcouleur_fond\fP] start="\fImotif_début\fP" end="\fImotif_fin\fP"
|
||||
Affiche les expressions commençant par l'expression rationnelle étendue
|
||||
\fImotif_début\fP et se terminant par l'expression rationnelle étendue
|
||||
\fImotif_fin\fP en utilisant la couleur de texte \fIcouleur_texte\fP
|
||||
et la couleur de fond \fIcouleur_fond\fP, l'une de ces deux couleurs au
|
||||
moins devant être définie. Cela permet à la colorisation syntaxique de
|
||||
s'étendre sur plusieurs lignes. Notez que toutes les occurrences
|
||||
successives de \fImotif_début\fP après le \fImotif_début\fP initial
|
||||
seront surlignées jusqu'à la prochaine instance de \fImotif_fin\fP.
|
||||
.TP
|
||||
.B icolor \fIcouleur_texte\fP[,\fIcouleur_fond\fP] start="\fImotif_début\fP" end="\fImotif_fin\fP"
|
||||
Comme ci-dessus, mais la recherche des motifs est effectuée sans tenir
|
||||
compte de la casse.
|
||||
.TP
|
||||
.B include "\fIfichier_de_syntaxes\fP"
|
||||
Lit le fichier \fIfichier_de_syntaxes\fP contenant une liste
|
||||
autosuffisante de définitions de syntaxes. Ce fichier ne doit contenir
|
||||
que des commandes \fBsyntax\fP, \fBcolor\fP et \fBicolor\fP.
|
||||
|
||||
.SH FICHIERS
|
||||
.TP
|
||||
.I $SYSCONFDIR/nanorc
|
||||
Fichier de configuration général
|
||||
.TP
|
||||
.I ~/.nanorc
|
||||
Fichier de configuration personnel
|
||||
|
||||
.SH VOIR AUSSI
|
||||
.PD 0
|
||||
.TP
|
||||
\fBnano\fP(1)
|
||||
.PP
|
||||
\fI/usr/share/doc/nano/examples/nanorc.sample\fP (ou son équivalent sur
|
||||
votre système)
|
||||
|
||||
.SH AUTEUR
|
||||
Chris Allegretta <chrisa@asty.org> et d'autres (voir les fichiers
|
||||
\fIAUTHORS\fP et \fITHANKS\fP pour plus d'information). Cette page de
|
||||
manuel a été initialement rédigée par Jordi Mallach <jordi@gnu.org> pour
|
||||
le système Debian (mais elle peut être utilisée par d'autres).
|
||||
|
||||
.SH TRADUCTION
|
||||
Cette adaptation française a été réalisée par Jean-Philippe\ Guérard
|
||||
<jean-philippe.guerard@tigreraye.org> le 29\ novembre\ 2007 à partir de
|
||||
la version 1.56 du 11\ octobre\ 2007 de la page de manuel de nanorc
|
||||
(pour la version 2.0.0 de nano). Cette page a été relue par Gérard
|
||||
Delafond.
|
||||
|
||||
Un maximum de soin a été apporté lors de l'élaboration de cette
|
||||
traduction\ ; néanmoins, quelques imperfections peuvent subsister. Si
|
||||
vous en rencontrez, que ce soit dans la version française ou dans la
|
||||
version originale, n'hésitez pas à les signaler à l'auteur ou au
|
||||
traducteur.
|
||||
|
||||
La version originale la plus à jour de ce document est toujours
|
||||
consultable via la commande\ :
|
||||
|
||||
LANGUAGE=en man nano
|
||||
@@ -1,152 +0,0 @@
|
||||
.\" Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
.\" Skeleton based on nano-tiny.1:
|
||||
.\" Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
.\"
|
||||
.\" Le travail d'adaptation française de cette page de manuel a été
|
||||
.\" réalisé par Jean-Philippe Guérard, en 2006 et 2007. Ce travail
|
||||
.\" d'adaptation est dans le domaine public. Attention, la page traduite
|
||||
.\" reste soumise au droit d'auteur de ses auteurs originaux.
|
||||
.\"
|
||||
.\" The French translation of this document is a public domain work of
|
||||
.\" Jean-Philippe Guérard. This translation work was made in 2006 and
|
||||
.\" 2007. The translated man page in itself is still subject to the
|
||||
.\" copyright of its original authors.
|
||||
.\"
|
||||
.\" This document is dual-licensed. You may distribute and/or modify it
|
||||
.\" under the terms of either of the following licenses:
|
||||
.\"
|
||||
.\" * The GNU General Public License, as published by the Free Software
|
||||
.\" Foundation, version 3 or (at your option) any later version. You
|
||||
.\" should have received a copy of the GNU General Public License
|
||||
.\" along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.\" * The GNU Free Documentation License, as published by the Free
|
||||
.\" Software Foundation, version 1.2 or (at your option) any later
|
||||
.\" version, with no Invariant Sections, no Front-Cover Texts, and no
|
||||
.\" Back-Cover Texts. You should have received a copy of the GNU Free
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.\" Ce document est publié sous une double licence. Vous pouvez
|
||||
.\" le distribuer et le modifier selon les termes de l'une des deux
|
||||
.\" licences ci-dessous :
|
||||
.\"
|
||||
.\" * La Licence publique générale GNU (GNU GPL) version 3 ou, à
|
||||
.\" votre choix, supérieure, telle que publiée par la Free
|
||||
.\" Software Foundation. Vous devriez avoir reçu une copie de la
|
||||
.\" Licence publique générale GNU avec ce programme. Si ce n'est pas
|
||||
.\" le cas, consultez <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.\" * La Licence de documentation libre GNU (GNU FDL), version 1.2 ou,
|
||||
.\" à votre choix, supérieure, telle que publiée par la Free
|
||||
.\" Software Foundation, sans section invariante, ni texte de
|
||||
.\" première ou de quatrième de couverture. Vous devriez avoir reçu
|
||||
.\" une copie de la Licence de documentation libre GNU avec ce
|
||||
.\" programme. Si ce n'est pas le cas, consultez
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH RNANO 1 "version 2.0.0" "29\ novembre\ 20O7"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\" Merci de modifier ces dates à chaque mise à jour de cette page.
|
||||
.\"
|
||||
.SH NOM
|
||||
rnano \- Le mode restreint de NAno un NOuvel éditeur, un clone libre et
|
||||
amélioré de Pico
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B rnano
|
||||
.I [OPTIONS]\ [[+LIGNE,COLONNE]\ FICHIER]...
|
||||
.br
|
||||
|
||||
.SH DESCRIPTION
|
||||
Cette page de manuel décrit brièvement la commande \fBrnano\fR.
|
||||
.PP
|
||||
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
|
||||
.\" \fI<whatever>\fP escape sequences to invoke bold face and italics,
|
||||
.\" respectively.
|
||||
\fBnano\fR est un éditeur petit, sympathique et libre, qui vise à
|
||||
remplacer Pico, l'éditeur par défaut du logiciel non libre Pine.
|
||||
\fBnano\fR ne se contentant pas de copier l'interface et l'ergonomie de
|
||||
Pico, il offre également certaines fonctions manquantes (ou désactivées
|
||||
par défaut) dans Pico. Ces fonctionnalités sont, par exemple, les
|
||||
fonctions de recherche et de remplacement, et la possibilité de sauter
|
||||
directement à une ligne et à une colonne précise..
|
||||
.PP
|
||||
\fBrnano\fP est une version de \fBnano\fP fonctionnant en mode
|
||||
restreint, qui ne permet d'éditer que les fichiers indiqués et qui
|
||||
n'autorise pas l'utilisateur à accéder au système de fichier ou à un
|
||||
interpréteur de commandes.
|
||||
.PP
|
||||
En mode restreint, \fBnano\fP refusera\ :
|
||||
.IP \[bu] 2
|
||||
de lire ou d'écrire dans un fichier n'ayant pas été indiqué dans la
|
||||
ligne de commande\ ;
|
||||
.IP \[bu]
|
||||
de lire un fichier nanorc\ ;
|
||||
.IP \[bu]
|
||||
de permettre de suspendre l'édition\ ;
|
||||
.IP \[bu]
|
||||
de permettre d'ajouter en début ou en fin d'un fichier, ou de
|
||||
l'enregistrer sous un nom différent\ ;
|
||||
.IP \[bu]
|
||||
l'utilisation de copies de sécurité ou de la correction orthographique.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B +\fILIGNE\fP,\fICOLONNE\fP
|
||||
Démarre avec le curseur positionné à la colonne \fICOLONNE\fP de
|
||||
la ligne \fILIGNE\fR (l'un des deux, au moins, devant être spécifié) au
|
||||
lieu de démarrer à la colonne\ 1, ligne\ 1.
|
||||
.TP
|
||||
.B \-?
|
||||
Identique à \fB\-h (\-\-help)\fP.
|
||||
.TP
|
||||
.B \-h (\-\-help)
|
||||
Affiche un résumé des options de lancement de nano, puis s'arrête.
|
||||
.TP
|
||||
.B \-V (\-\-version)
|
||||
Affiche la version, puis s'arrête.
|
||||
.PP
|
||||
Reportez-vous à la page de manuel \fBnano\fP(1) si vous souhaitez
|
||||
consulter la documentation complète de \fBnano\fP.
|
||||
|
||||
.SH BOGUES
|
||||
Merci de nous faire parvenir vos commentaires et de nous signaler les
|
||||
bogues, en écrivant, en anglais, à \fBnano@nano-editor.org\fR.
|
||||
|
||||
La liste de discussion anglophone \fBnano\fR est disponible à l'adresse
|
||||
\fBnano-devel@gnu.org\fR.
|
||||
|
||||
Pour vous abonner, envoyez un courrier électronique à
|
||||
\fBnano-devel-request@gnu.org\fR, ayant pour objet «\ subscribe\ ».
|
||||
|
||||
N'hésitez pas également à envoyez vos commentaires, suggestions et
|
||||
corrections relatives à l'adaptation française de cette page de manuel
|
||||
ou du logiciel à \fBjean-philippe.guerard@tigreraye.org\fR.
|
||||
|
||||
.SH "SITE INTERNET"
|
||||
http://www.nano-editor.org/
|
||||
|
||||
.SH AUTEUR
|
||||
Chris Allegretta <chrisa@asty.org> et d'autres (voir le fichier
|
||||
\fIAUTHORS\fR). Cette page de manuel a été initialement rédigée par
|
||||
Thijs Kinkhorst <thijs@kinkhorst.com>, pour le système GNU Debian (mais
|
||||
elle peut être utilisée par d'autres).
|
||||
|
||||
.SH TRADUCTION
|
||||
Cette adaptation française a été réalisée par Jean-Philippe\ Guérard
|
||||
<jean-philippe.guerard@tigreraye.org> le 29\ novembre\ 2007 à partir
|
||||
de la version 1.19 du 6\ novembre\ 2007 de la page de manuel de rnano
|
||||
(pour la version 2.0.0 de nano).
|
||||
|
||||
Un maximum de soin a été apporté lors de l'élaboration de cette
|
||||
traduction\ ; néanmoins, quelques imperfections peuvent subsister. Si
|
||||
vous en rencontrez, que ce soit dans la version française ou dans la
|
||||
version originale, n'hésitez pas à les signaler à l'auteur ou au
|
||||
traducteur.
|
||||
|
||||
La version originale la plus à jour de ce document est toujours
|
||||
consultable via la commande\ :
|
||||
|
||||
LANGUAGE=en man nano
|
||||
@@ -17,7 +17,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANO 1 "version 2.7.1" "October 2016"
|
||||
.TH NANO 1 "version 2.7.5" "February 2017"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
|
||||
.SH NAME
|
||||
@@ -34,6 +34,13 @@ top of copying Pico's look and feel, \fBnano\fP also implements some
|
||||
missing (or disabled by default) features in Pico, such as "search and
|
||||
replace" and "go to line and column number".
|
||||
|
||||
When opening a file, the cursor can be put on a specific line by adding
|
||||
the line number with a plus sign (\fB+\fR) before the filename, and even
|
||||
in a specific column by adding it with a comma.
|
||||
|
||||
If the first file specified is a dash (\fB\-\fR), \fBnano\fR will read
|
||||
data from standard input.
|
||||
|
||||
.SH EDITING
|
||||
Entering text and moving around in a file is straightforward: typing the
|
||||
letters and using the normal cursor movement keys. Commands are entered
|
||||
@@ -61,11 +68,6 @@ The default key bindings can be changed via the .nanorc file -- see
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B +\fIline\fP,\fIcolumn\fP
|
||||
Places the cursor on line number \fIline\fP and at column number \fIcolumn\fP
|
||||
(at least one of which must be specified) on startup, instead of the
|
||||
default line 1, column 1.
|
||||
.TP
|
||||
.BR \-A ", " \-\-smarthome
|
||||
Make the Home key smarter. When Home is pressed anywhere but at the
|
||||
very beginning of non-whitespace characters on a line, the cursor will
|
||||
@@ -294,7 +296,8 @@ 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
|
||||
Please report any other bugs that you encounter via:
|
||||
.br
|
||||
\fIhttps://savannah.gnu.org/bugs/?group=nano\fR.
|
||||
|
||||
.SH HOMEPAGE
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
@smallbook
|
||||
@set EDITION 0.4
|
||||
@set VERSION 2.7.1
|
||||
@set UPDATED October 2016
|
||||
@set VERSION 2.7.5
|
||||
@set UPDATED February 2017
|
||||
|
||||
@dircategory Editors
|
||||
@direntry
|
||||
@@ -21,7 +21,7 @@
|
||||
@titlepage
|
||||
@title GNU @code{nano}
|
||||
@subtitle a small and friendly text editor.
|
||||
@subtitle version 2.7.1
|
||||
@subtitle version 2.7.5
|
||||
|
||||
@author Chris Allegretta
|
||||
@page
|
||||
@@ -97,21 +97,24 @@ The usual way to invoke @code{nano} is:
|
||||
@code{nano [FILE]}
|
||||
@end quotation
|
||||
|
||||
But it is also possible to specify one or more options, and to edit
|
||||
several files in a row. Additionally, the cursor can be put on a
|
||||
specific line of a file by adding the line number
|
||||
But it is also possible to specify one or more options (see the next
|
||||
section), and to edit several files in a row. Additionally, the cursor
|
||||
can be put on a specific line of a file by adding the line number
|
||||
with a plus sign before the filename, and even in a specific column by
|
||||
adding it with a comma. So the complete command synopsis is:
|
||||
adding it with a comma. So a more complete command synopsis is:
|
||||
|
||||
@quotation
|
||||
@code{nano [OPTION]@dots{} [[+LINE[,COLUMN]|+,COLUMN] FILE]@dots{}}
|
||||
@end quotation
|
||||
|
||||
But normallly you would set your preferred options in your
|
||||
@file{.nanorc} file. And when the @code{positionlog} option is set
|
||||
Normally, however, you set your preferred options in a @file{.nanorc}
|
||||
file (see @xref{Nanorc Files}). And when using @code{set positionlog}
|
||||
(making @code{nano} remember the cursor position when you close a file),
|
||||
you will rarely need to specify a line number.
|
||||
|
||||
As a special case: when the first file specified is a dash, @code{nano}
|
||||
will read data from standard input. Which means you can pipe the output
|
||||
of a command straight into a buffer.
|
||||
|
||||
@node Command-line Options
|
||||
@chapter Command-line Options
|
||||
@@ -120,10 +123,6 @@ you will rarely need to specify a line number.
|
||||
|
||||
@table @option
|
||||
|
||||
@item +@var{line},@var{column}
|
||||
Start at line number @var{line} and column number @var{column} (at least one of
|
||||
which must be specified) instead of the default of line 1, column 1.
|
||||
|
||||
@item -A
|
||||
@itemx --smarthome
|
||||
Make the Home key smarter. When Home is pressed anywhere but at the
|
||||
@@ -410,14 +409,19 @@ Characters not present on the keyboard can be entered in two ways:
|
||||
@item
|
||||
For characters with a single-byte code,
|
||||
pressing the Esc key twice and then typing a three-digit decimal number
|
||||
(from 000 to 255) will enter the character with the corresponding value.
|
||||
(from 000 to 255) will make @code{nano} behave as if you typed the key
|
||||
with that value.
|
||||
|
||||
@item
|
||||
For any possible character, pressing M-V (Alt+V) and then typing a
|
||||
six-digit hexadecimal number (starting with 0 or 1) will enter the
|
||||
character with the corresponding Unicode value.
|
||||
corresponding Unicode character into the buffer.
|
||||
@end itemize
|
||||
|
||||
For example, typing "Esc Esc 2 3 4" will enter the character "ê" ---
|
||||
useful when going to a French party. Typing "M-V 0 0 2 5 c 6" will
|
||||
enter the symbol "◆", a little black diamond.
|
||||
|
||||
@node Commands
|
||||
@section Commands
|
||||
|
||||
@@ -841,7 +845,8 @@ Save automatically on exit, don't prompt.
|
||||
@item set titlecolor @var{fgcolor},@var{bgcolor}
|
||||
Specify the color combination to use for the titlebar.
|
||||
Valid color names for foreground and background are:
|
||||
white, black, red, blue, green, yellow, magenta, and cyan.
|
||||
white, black, blue, green, red, cyan, yellow, and magenta.
|
||||
The name of the foreground color may be prefixed with 'bright'.
|
||||
And either @var{fgcolor} or @var{,bgcolor} may be left out.
|
||||
|
||||
@item set unix
|
||||
@@ -1090,6 +1095,10 @@ Unindents (shifts to the left) the currently marked text.
|
||||
Comments or uncomments the current line or marked lines, using the comment
|
||||
style specified in the active syntax.
|
||||
|
||||
@item complete
|
||||
Completes the fragment before the cursor to a full word found elsewhere
|
||||
in the current buffer.
|
||||
|
||||
@item left
|
||||
Goes left one position (in the editor or browser).
|
||||
|
||||
@@ -1500,18 +1509,21 @@ Disable use of the spell checker. This also eliminates the @code{-s}
|
||||
command-line option, which allows specifying an alternate spell checker.
|
||||
|
||||
@item --disable-tabcomp
|
||||
Disable the tab completion code when reading or writing files.
|
||||
Disable tab completion (when nano asks for a filename or a search string).
|
||||
|
||||
@item --disable-wordcomp
|
||||
Disable word completion.
|
||||
|
||||
@item --disable-wrapping
|
||||
Disable hard-wrapping of overlong lines. This also eliminates the @code{-w}
|
||||
command-line option, which enables long-line wrapping.
|
||||
Disable all hard-wrapping of overlong lines. This also eliminates the
|
||||
@code{-w} command-line option, which switches long-line wrapping off.
|
||||
|
||||
@item --enable-tiny
|
||||
This option disables all the above. It also disables some of the larger
|
||||
internals of the editor, like the marking code and the cut-to-end-of-line
|
||||
code. It also disables the function toggles. By using the enabling
|
||||
This option implies all of the above. It also disables some other
|
||||
internals of the editor, like the marking code, the cut-to-end-of-line
|
||||
code, and the function toggles. By using the enabling
|
||||
counterpart of the above options together with @code{--enable-tiny},
|
||||
specific features can be switched back on.
|
||||
specific features can be switched back on --- but a few cannot.
|
||||
|
||||
@item --enable-debug
|
||||
Enable support for runtime debug output. This can get pretty messy, so
|
||||
@@ -17,7 +17,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANORC 5 "version 2.7.1" "October 2016"
|
||||
.TH NANORC 5 "version 2.7.5" "February 2017"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
|
||||
.SH NAME
|
||||
@@ -248,8 +248,9 @@ Save automatically on exit, don't prompt.
|
||||
.TP
|
||||
.B set titlecolor \fIfgcolor\fR,\fIbgcolor\fR
|
||||
Specify the color combination to use for the titlebar.
|
||||
Valid color names for foreground and background are:
|
||||
.BR white , \ black , \ red , \ blue , \ green , \ yellow , \ magenta ", and " cyan .
|
||||
Valid names for the foreground and background colors are:
|
||||
.BR white ", " black ", " blue ", " green ", " red ", " cyan ", " yellow ", and " magenta .
|
||||
The name of the foreground color may be prefixed with \fBbright\fR.
|
||||
And either "\fIfgcolor\fR" or ",\fIbgcolor\fR" may be left out.
|
||||
.TP
|
||||
.B set unix
|
||||
@@ -488,6 +489,10 @@ Unindents (shifts to the left) the currently marked text.
|
||||
Comments or uncomments the current line or marked lines, using the comment
|
||||
style specified in the active syntax.
|
||||
.TP
|
||||
.B complete
|
||||
Completes the fragment before the cursor to a full word found elsewhere
|
||||
in the current buffer.
|
||||
.TP
|
||||
.B left
|
||||
Goes left one position (in the editor or browser).
|
||||
.TP
|
||||
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH RNANO 1 "version 2.7.1" "October 2016"
|
||||
.TH RNANO 1 "version 2.7.5" "February 2017"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
|
||||
.SH NAME
|
||||
@@ -1,11 +0,0 @@
|
||||
## Here is a short example for HTML.
|
||||
|
||||
syntax "html" "\.html?$"
|
||||
magic "HTML document text"
|
||||
comment "<!--|-->"
|
||||
|
||||
color cyan start="<" end=">"
|
||||
color red "&[^;[:space:]]*;"
|
||||
color green ""(\\.|[^"])*""
|
||||
|
||||
color yellow start="<!--" end="-->"
|
||||
3
doc/texinfo/.gitignore
vendored
3
doc/texinfo/.gitignore
vendored
@@ -1,3 +0,0 @@
|
||||
texinfo.tex
|
||||
nano.html
|
||||
nano.info
|
||||
@@ -1,10 +0,0 @@
|
||||
info_TEXINFOS = nano.texi
|
||||
|
||||
MAKEINFO = makeinfo --no-split
|
||||
|
||||
BUILT_SOURCES = nano.html
|
||||
|
||||
nano.html: nano.texi
|
||||
makeinfo --no-split --html < $< > $@
|
||||
|
||||
EXTRA_DIST = $(info_TEXINFOS) $(BUILT_SOURCES)
|
||||
@@ -43,7 +43,7 @@ fi
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%doc AUTHORS COPYING ChangeLog INSTALL NEWS README THANKS TODO doc/faq.html doc/nanorc.sample
|
||||
%doc AUTHORS COPYING ChangeLog INSTALL NEWS README THANKS TODO doc/faq.html doc/sample.nanorc
|
||||
%{_bindir}/*
|
||||
%{_docdir}/nano/*
|
||||
%{_mandir}/man*/*
|
||||
|
||||
1065
po/nano.pot
1065
po/nano.pot
File diff suppressed because it is too large
Load Diff
1089
po/pt_BR.po
1089
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
1056
po/zh_CN.po
1056
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
1065
po/zh_TW.po
1065
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,7 @@
|
||||
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -DSYSCONFDIR=\"$(sysconfdir)\"
|
||||
|
||||
CLEANFILES = revision.h
|
||||
|
||||
if BUILDING_FROM_GIT
|
||||
SOMETHING = "REVISION \"$(shell git describe --tags 2>/dev/null)\""
|
||||
else
|
||||
|
||||
@@ -35,7 +35,7 @@ static char **filelist = NULL;
|
||||
static size_t filelist_len = 0;
|
||||
/* The number of files in the list. */
|
||||
static int width = 0;
|
||||
/* The number of files that we can display per line. */
|
||||
/* The number of files that we can display per screen row. */
|
||||
static int longest = 0;
|
||||
/* The number of columns in the longest filename in the list. */
|
||||
static size_t selected = 0;
|
||||
@@ -69,7 +69,7 @@ char *do_browser(char *path)
|
||||
dir = opendir(path);
|
||||
|
||||
if (path == NULL || dir == NULL) {
|
||||
statusline(ALERT, "Cannot open directory: %s", strerror(errno));
|
||||
statusline(ALERT, _("Cannot open directory: %s"), strerror(errno));
|
||||
/* If we don't have a file list yet, there is nothing to show. */
|
||||
if (filelist == NULL) {
|
||||
napms(1200);
|
||||
@@ -147,7 +147,7 @@ char *do_browser(char *path)
|
||||
/* If we selected the same filename as last time, fake a
|
||||
* press of the Enter key so that the file is read in. */
|
||||
if (old_selected == selected)
|
||||
unget_kbinput(sc_seq_or(do_enter, 0), FALSE);
|
||||
unget_kbinput(KEY_ENTER, FALSE);
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -219,28 +219,18 @@ char *do_browser(char *path)
|
||||
selected = filelist_len - 1;
|
||||
} else if (func == goto_dir_void) {
|
||||
/* Ask for the directory to go to. */
|
||||
int i = do_prompt(TRUE,
|
||||
#ifndef DISABLE_TABCOMP
|
||||
FALSE,
|
||||
#endif
|
||||
MGOTODIR, NULL,
|
||||
int i = do_prompt(TRUE, FALSE, MGOTODIR, NULL,
|
||||
#ifndef DISABLE_HISTORIES
|
||||
NULL,
|
||||
#endif
|
||||
/* TRANSLATORS: This is a prompt. */
|
||||
browser_refresh, _("Go To Directory"));
|
||||
|
||||
/* If the directory begins with a newline (i.e. an
|
||||
* encoded null), treat it as though it's blank. */
|
||||
if (i < 0 || *answer == '\n') {
|
||||
if (i < 0) {
|
||||
statusbar(_("Cancelled"));
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Convert newlines to nulls in the directory name. */
|
||||
sunder(answer);
|
||||
align(&answer);
|
||||
|
||||
path = free_and_assign(path, real_dir_from_tilde(answer));
|
||||
|
||||
/* If the given path is relative, join it with the current path. */
|
||||
@@ -354,8 +344,6 @@ char *do_browse_from(const char *inpath)
|
||||
char *path;
|
||||
/* This holds the tilde-expanded version of inpath. */
|
||||
|
||||
assert(inpath != NULL);
|
||||
|
||||
path = real_dir_from_tilde(inpath);
|
||||
|
||||
/* Perhaps path is a directory. If so, we'll pass it to
|
||||
@@ -375,12 +363,11 @@ char *do_browse_from(const char *inpath)
|
||||
|
||||
if (path == NULL) {
|
||||
free(currentdir);
|
||||
statusline(MILD, "The working directory has disappeared");
|
||||
statusline(MILD, _("The working directory has disappeared"));
|
||||
beep();
|
||||
napms(1200);
|
||||
return NULL;
|
||||
} else
|
||||
align(&path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,7 +385,7 @@ char *do_browse_from(const char *inpath)
|
||||
* set filelist_len to the number of files in that list, set longest to
|
||||
* the width in columns of the longest filename in that list (between 15
|
||||
* and COLS), and set width to the number of files that we can display
|
||||
* per line. And sort the list too. */
|
||||
* per screen row. And sort the list too. */
|
||||
void read_the_list(const char *path, DIR *dir)
|
||||
{
|
||||
const struct dirent *nextdir;
|
||||
@@ -495,15 +482,15 @@ functionptrtype parse_browser_input(int *kbinput)
|
||||
return func_from_key(kbinput);
|
||||
}
|
||||
|
||||
/* Set width to the number of files that we can display per line, if
|
||||
* necessary, and display the list of files. */
|
||||
/* Set width to the number of files that we can display per screen row,
|
||||
* if necessary, and display the list of files. */
|
||||
void browser_refresh(void)
|
||||
{
|
||||
size_t i;
|
||||
int line = 0, col = 0;
|
||||
/* The current line and column while the list is getting displayed. */
|
||||
int the_line = 0, the_column = 0;
|
||||
/* The line and column of the selected item. */
|
||||
int row = 0, col = 0;
|
||||
/* The current row and column while the list is getting displayed. */
|
||||
int the_row = 0, the_column = 0;
|
||||
/* The row and column of the selected item. */
|
||||
char *info;
|
||||
/* The additional information that we'll display about a file. */
|
||||
|
||||
@@ -514,7 +501,7 @@ void browser_refresh(void)
|
||||
|
||||
i = selected - selected % (editwinrows * width);
|
||||
|
||||
for (; i < filelist_len && line < editwinrows; i++) {
|
||||
for (; i < filelist_len && row < editwinrows; i++) {
|
||||
struct stat st;
|
||||
const char *thename = tail(filelist[i]);
|
||||
/* The filename we display, minus the path. */
|
||||
@@ -537,16 +524,16 @@ void browser_refresh(void)
|
||||
* remember its location to be able to place the cursor on it. */
|
||||
if (i == selected) {
|
||||
wattron(edit, hilite_attribute);
|
||||
the_line = line;
|
||||
the_row = row;
|
||||
the_column = col;
|
||||
}
|
||||
|
||||
blank_line(edit, line, col, longest);
|
||||
blank_row(edit, row, col, longest);
|
||||
|
||||
/* If the name is too long, we display something like "...ename". */
|
||||
if (dots)
|
||||
mvwaddstr(edit, line, col, "...");
|
||||
mvwaddstr(edit, line, dots ? col + 3 : col, disp);
|
||||
mvwaddstr(edit, row, col, "...");
|
||||
mvwaddstr(edit, row, dots ? col + 3 : col, disp);
|
||||
|
||||
free(disp);
|
||||
|
||||
@@ -604,7 +591,7 @@ void browser_refresh(void)
|
||||
infolen = infomaxlen;
|
||||
}
|
||||
|
||||
mvwaddstr(edit, line, col - infolen, info);
|
||||
mvwaddstr(edit, row, col - infolen, info);
|
||||
|
||||
/* If this is the selected item, finish its highlighting. */
|
||||
if (i == selected)
|
||||
@@ -615,17 +602,17 @@ void browser_refresh(void)
|
||||
/* Add some space between the columns. */
|
||||
col += 2;
|
||||
|
||||
/* If the next entry isn't going to fit on the current line,
|
||||
* move to the next line. */
|
||||
/* If the next entry isn't going to fit on the current row,
|
||||
* move to the next row. */
|
||||
if (col > COLS - longest) {
|
||||
line++;
|
||||
row++;
|
||||
col = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* If requested, put the cursor on the selected item and switch it on. */
|
||||
if (ISSET(SHOW_CURSOR)) {
|
||||
wmove(edit, the_line, the_column);
|
||||
wmove(edit, the_row, the_column);
|
||||
curs_set(1);
|
||||
}
|
||||
|
||||
@@ -677,11 +664,7 @@ int filesearch_init(void)
|
||||
buf = mallocstrcpy(NULL, "");
|
||||
|
||||
/* This is now one simple call. It just does a lot. */
|
||||
input = do_prompt(FALSE,
|
||||
#ifndef DISABLE_TABCOMP
|
||||
TRUE,
|
||||
#endif
|
||||
MWHEREISFILE, NULL,
|
||||
input = do_prompt(FALSE, FALSE, MWHEREISFILE, NULL,
|
||||
#ifndef DISABLE_HISTORIES
|
||||
&search_history,
|
||||
#endif
|
||||
@@ -714,7 +697,7 @@ void findnextfile(const char *needle)
|
||||
/* Save the settings of all flags. */
|
||||
memcpy(stash, flags, sizeof(flags));
|
||||
|
||||
/* Search forward, case insensitive and without regexes. */
|
||||
/* Search forward, case insensitive, and without regexes. */
|
||||
UNSET(BACKWARDS_SEARCH);
|
||||
UNSET(CASE_SENSITIVE);
|
||||
UNSET(USE_REGEXP);
|
||||
@@ -805,8 +788,6 @@ char *striponedir(const char *path)
|
||||
{
|
||||
char *retval, *tmp;
|
||||
|
||||
assert(path != NULL);
|
||||
|
||||
retval = mallocstrcpy(NULL, path);
|
||||
|
||||
tmp = strrchr(retval, '/');
|
||||
|
||||
167
src/chars.c
167
src/chars.c
@@ -88,11 +88,6 @@ void mbtowc_reset(void)
|
||||
IGNORE_CALL_RESULT(mbtowc(NULL, NULL, 0));
|
||||
}
|
||||
|
||||
void wctomb_reset(void)
|
||||
{
|
||||
IGNORE_CALL_RESULT(wctomb(NULL, 0));
|
||||
}
|
||||
|
||||
/* This function is equivalent to isalpha() for multibyte characters. */
|
||||
bool is_alpha_mbchar(const char *c)
|
||||
{
|
||||
@@ -172,8 +167,6 @@ bool is_cntrl_char(int c)
|
||||
* their high bits set. */
|
||||
bool is_cntrl_mbchar(const char *c)
|
||||
{
|
||||
assert(c != NULL);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
return ((c[0] & 0xE0) == 0 || c[0] == 127 ||
|
||||
@@ -208,8 +201,6 @@ bool is_punct_mbchar(const char *c)
|
||||
* punctuation when allow_punct is TRUE), and FALSE otherwise. */
|
||||
bool is_word_mbchar(const char *c, bool allow_punct)
|
||||
{
|
||||
assert(c != NULL);
|
||||
|
||||
if (*c == '\0')
|
||||
return FALSE;
|
||||
|
||||
@@ -217,15 +208,11 @@ bool is_word_mbchar(const char *c, bool allow_punct)
|
||||
return TRUE;
|
||||
|
||||
if (word_chars != NULL && *word_chars != '\0') {
|
||||
bool wordforming;
|
||||
char *symbol = charalloc(MB_CUR_MAX + 1);
|
||||
char symbol[mb_cur_max() + 1];
|
||||
int symlen = parse_mbchar(c, symbol, NULL);
|
||||
|
||||
symbol[symlen] = '\0';
|
||||
wordforming = (strstr(word_chars, symbol) != NULL);
|
||||
free(symbol);
|
||||
|
||||
return wordforming;
|
||||
return (strstr(word_chars, symbol) != NULL);
|
||||
}
|
||||
|
||||
return (allow_punct && is_punct_mbchar(c));
|
||||
@@ -234,12 +221,7 @@ bool is_word_mbchar(const char *c, bool allow_punct)
|
||||
/* Return the visible representation of control character c. */
|
||||
char control_rep(const signed char c)
|
||||
{
|
||||
assert(is_cntrl_char(c));
|
||||
|
||||
/* An embedded newline is an encoded null. */
|
||||
if (c == '\n')
|
||||
return '@';
|
||||
else if (c == DEL_CODE)
|
||||
if (c == DEL_CODE)
|
||||
return '?';
|
||||
else if (c == -97)
|
||||
return '=';
|
||||
@@ -250,9 +232,11 @@ char control_rep(const signed char c)
|
||||
}
|
||||
|
||||
/* Return the visible representation of multibyte control character c. */
|
||||
char control_mbrep(const char *c)
|
||||
char control_mbrep(const char *c, bool isdata)
|
||||
{
|
||||
assert(c != NULL);
|
||||
/* An embedded newline is an encoded NUL if it is data. */
|
||||
if (*c == '\n' && (isdata || as_an_at))
|
||||
return '@';
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
@@ -325,27 +309,25 @@ int mbwidth(const char *c)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Return the maximum width in bytes of a multibyte character. */
|
||||
/* Return the maximum length (in bytes) of a character. */
|
||||
int mb_cur_max(void)
|
||||
{
|
||||
return
|
||||
#ifdef ENABLE_UTF8
|
||||
use_utf8 ? MB_CUR_MAX :
|
||||
if (use_utf8)
|
||||
return MB_CUR_MAX;
|
||||
else
|
||||
#endif
|
||||
1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Convert the Unicode value in chr to a multibyte character with the
|
||||
* same wide character value as chr, if possible. If the conversion
|
||||
* succeeds, return the (dynamically allocated) multibyte character and
|
||||
* its length. Otherwise, return an undefined (dynamically allocated)
|
||||
* multibyte character and a length of zero. */
|
||||
/* Convert the Unicode value in chr to a multibyte character, if possible.
|
||||
* If the conversion succeeds, return the (dynamically allocated) multibyte
|
||||
* character and its length. Otherwise, return an undefined (dynamically
|
||||
* allocated) multibyte character and a length of zero. */
|
||||
char *make_mbchar(long chr, int *chr_mb_len)
|
||||
{
|
||||
char *chr_mb;
|
||||
|
||||
assert(chr_mb_len != NULL);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
chr_mb = charalloc(MB_CUR_MAX);
|
||||
@@ -353,7 +335,7 @@ char *make_mbchar(long chr, int *chr_mb_len)
|
||||
|
||||
/* Reject invalid Unicode characters. */
|
||||
if (*chr_mb_len < 0 || !is_valid_unicode((wchar_t)chr)) {
|
||||
wctomb_reset();
|
||||
IGNORE_CALL_RESULT(wctomb(NULL, 0));
|
||||
*chr_mb_len = 0;
|
||||
}
|
||||
} else
|
||||
@@ -368,37 +350,35 @@ char *make_mbchar(long chr, int *chr_mb_len)
|
||||
|
||||
/* Parse a multibyte character from buf. Return the number of bytes
|
||||
* used. If chr isn't NULL, store the multibyte character in it. If
|
||||
* col isn't NULL, store the new display width in it. If *buf is '\t',
|
||||
* we expect col to have the current display width. */
|
||||
* col isn't NULL, add the character's width (in columns) to it. */
|
||||
int parse_mbchar(const char *buf, char *chr, size_t *col)
|
||||
{
|
||||
int buf_mb_len;
|
||||
int length;
|
||||
|
||||
assert(buf != NULL);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
/* Get the number of bytes in the multibyte character. */
|
||||
buf_mb_len = mblen(buf, MB_CUR_MAX);
|
||||
length = mblen(buf, MB_CUR_MAX);
|
||||
|
||||
/* When the multibyte sequence is invalid, only take the first byte. */
|
||||
if (buf_mb_len < 0) {
|
||||
if (length <= 0) {
|
||||
IGNORE_CALL_RESULT(mblen(NULL, 0));
|
||||
buf_mb_len = 1;
|
||||
} else if (buf_mb_len == 0)
|
||||
buf_mb_len++;
|
||||
length = 1;
|
||||
}
|
||||
|
||||
/* When requested, store the multibyte character in chr. */
|
||||
if (chr != NULL) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < buf_mb_len; i++)
|
||||
for (i = 0; i < length; i++)
|
||||
chr[i] = buf[i];
|
||||
}
|
||||
|
||||
/* When requested, store the width of the wide character in col. */
|
||||
/* When requested, add the width of the character to col. */
|
||||
if (col != NULL) {
|
||||
/* If we have a tab, get its width in columns using the
|
||||
/* If we have a tab, compute its width in columns based on the
|
||||
* current value of col. */
|
||||
if (*buf == '\t')
|
||||
*col += tabsize - *col % tabsize;
|
||||
@@ -406,8 +386,7 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
|
||||
* column for the "^", and one for the visible character. */
|
||||
else if (is_cntrl_mbchar(buf)) {
|
||||
*col += 2;
|
||||
/* If we have a normal character, get its width in columns
|
||||
* normally. */
|
||||
/* If we have a normal character, get its width normally. */
|
||||
} else
|
||||
*col += mbwidth(buf);
|
||||
}
|
||||
@@ -415,15 +394,15 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
|
||||
#endif
|
||||
{
|
||||
/* A byte character is one byte long. */
|
||||
buf_mb_len = 1;
|
||||
length = 1;
|
||||
|
||||
/* When requested, store the byte character in chr. */
|
||||
if (chr != NULL)
|
||||
*chr = *buf;
|
||||
|
||||
/* When requested, store the width of the wide character in col. */
|
||||
/* When requested, add the width of the character to col. */
|
||||
if (col != NULL) {
|
||||
/* If we have a tab, get its width in columns using the
|
||||
/* If we have a tab, compute its width in columns using the
|
||||
* current value of col. */
|
||||
if (*buf == '\t')
|
||||
*col += tabsize - *col % tabsize;
|
||||
@@ -437,7 +416,7 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
|
||||
}
|
||||
}
|
||||
|
||||
return buf_mb_len;
|
||||
return length;
|
||||
}
|
||||
|
||||
/* Return the index in buf of the beginning of the multibyte character
|
||||
@@ -492,8 +471,6 @@ int nstrncasecmp(const char *s1, const char *s2, size_t n)
|
||||
if (s1 == s2)
|
||||
return 0;
|
||||
|
||||
assert(s1 != NULL && s2 != NULL);
|
||||
|
||||
for (; *s1 != '\0' && *s2 != '\0' && n > 0; s1++, s2++, n--) {
|
||||
if (tolower(*s1) != tolower(*s2))
|
||||
break;
|
||||
@@ -510,8 +487,6 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
|
||||
if (use_utf8) {
|
||||
wchar_t wc1, wc2;
|
||||
|
||||
assert(s1 != NULL && s2 != NULL);
|
||||
|
||||
while (*s1 != '\0' && *s2 != '\0' && n > 0) {
|
||||
bool bad1 = FALSE, bad2 = FALSE;
|
||||
|
||||
@@ -555,8 +530,6 @@ char *nstrcasestr(const char *haystack, const char *needle)
|
||||
{
|
||||
size_t needle_len;
|
||||
|
||||
assert(haystack != NULL && needle != NULL);
|
||||
|
||||
if (*needle == '\0')
|
||||
return (char *)haystack;
|
||||
|
||||
@@ -580,8 +553,6 @@ char *mbstrcasestr(const char *haystack, const char *needle)
|
||||
if (use_utf8) {
|
||||
size_t needle_len;
|
||||
|
||||
assert(haystack != NULL && needle != NULL);
|
||||
|
||||
if (*needle == '\0')
|
||||
return (char *)haystack;
|
||||
|
||||
@@ -602,27 +573,25 @@ char *mbstrcasestr(const char *haystack, const char *needle)
|
||||
|
||||
/* This function is equivalent to strstr(), except in that it scans the
|
||||
* string in reverse, starting at rev_start. */
|
||||
char *revstrstr(const char *haystack, const char *needle, const char
|
||||
*rev_start)
|
||||
char *revstrstr(const char *haystack, const char *needle,
|
||||
const char *pointer)
|
||||
{
|
||||
size_t rev_start_len, needle_len;
|
||||
size_t needle_len = strlen(needle);
|
||||
size_t tail_len = strlen(pointer);
|
||||
|
||||
assert(haystack != NULL && needle != NULL && rev_start != NULL);
|
||||
|
||||
if (*needle == '\0')
|
||||
return (char *)rev_start;
|
||||
|
||||
needle_len = strlen(needle);
|
||||
if (needle_len == 0)
|
||||
return (char *)pointer;
|
||||
|
||||
if (strlen(haystack) < needle_len)
|
||||
return NULL;
|
||||
|
||||
rev_start_len = strlen(rev_start);
|
||||
if (tail_len < needle_len)
|
||||
pointer += tail_len - needle_len;
|
||||
|
||||
for (; rev_start >= haystack; rev_start--, rev_start_len++) {
|
||||
if (rev_start_len >= needle_len && strncmp(rev_start, needle,
|
||||
needle_len) == 0)
|
||||
return (char *)rev_start;
|
||||
while (pointer >= haystack) {
|
||||
if (strncmp(pointer, needle, needle_len) == 0)
|
||||
return (char *)pointer;
|
||||
pointer--;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -635,8 +604,6 @@ char *revstrcasestr(const char *haystack, const char *needle, const char
|
||||
{
|
||||
size_t rev_start_len, needle_len;
|
||||
|
||||
assert(haystack != NULL && needle != NULL && rev_start != NULL);
|
||||
|
||||
if (*needle == '\0')
|
||||
return (char *)rev_start;
|
||||
|
||||
@@ -665,8 +632,6 @@ char *mbrevstrcasestr(const char *haystack, const char *needle, const
|
||||
if (use_utf8) {
|
||||
size_t rev_start_len, needle_len;
|
||||
|
||||
assert(haystack != NULL && needle != NULL && rev_start != NULL);
|
||||
|
||||
if (*needle == '\0')
|
||||
return (char *)rev_start;
|
||||
|
||||
@@ -706,8 +671,6 @@ size_t nstrnlen(const char *s, size_t maxlen)
|
||||
{
|
||||
size_t n = 0;
|
||||
|
||||
assert(s != NULL);
|
||||
|
||||
for (; *s != '\0' && maxlen > 0; s++, maxlen--, n++)
|
||||
;
|
||||
|
||||
@@ -718,8 +681,6 @@ size_t nstrnlen(const char *s, size_t maxlen)
|
||||
/* This function is equivalent to strnlen() for multibyte strings. */
|
||||
size_t mbstrnlen(const char *s, size_t maxlen)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
size_t n = 0;
|
||||
@@ -743,7 +704,7 @@ char *mbstrchr(const char *s, const char *c)
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
bool bad_s_mb = FALSE, bad_c_mb = FALSE;
|
||||
char *s_mb = charalloc(MB_CUR_MAX);
|
||||
char symbol[MB_CUR_MAX];
|
||||
const char *q = s;
|
||||
wchar_t ws, wc;
|
||||
|
||||
@@ -754,9 +715,9 @@ char *mbstrchr(const char *s, const char *c)
|
||||
}
|
||||
|
||||
while (*s != '\0') {
|
||||
int s_mb_len = parse_mbchar(s, s_mb, NULL);
|
||||
int sym_len = parse_mbchar(s, symbol, NULL);
|
||||
|
||||
if (mbtowc(&ws, s_mb, s_mb_len) < 0) {
|
||||
if (mbtowc(&ws, symbol, sym_len) < 0) {
|
||||
mbtowc_reset();
|
||||
ws = (unsigned char)*s;
|
||||
bad_s_mb = TRUE;
|
||||
@@ -765,12 +726,10 @@ char *mbstrchr(const char *s, const char *c)
|
||||
if (bad_s_mb == bad_c_mb && ws == wc)
|
||||
break;
|
||||
|
||||
s += s_mb_len;
|
||||
q += s_mb_len;
|
||||
s += sym_len;
|
||||
q += sym_len;
|
||||
}
|
||||
|
||||
free(s_mb);
|
||||
|
||||
if (*s == '\0')
|
||||
q = NULL;
|
||||
|
||||
@@ -785,8 +744,6 @@ char *mbstrchr(const char *s, const char *c)
|
||||
/* This function is equivalent to strpbrk() for multibyte strings. */
|
||||
char *mbstrpbrk(const char *s, const char *accept)
|
||||
{
|
||||
assert(s != NULL && accept != NULL);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
for (; *s != '\0'; s += move_mbright(s, 0)) {
|
||||
@@ -857,8 +814,6 @@ char *mbrevstrpbrk(const char *s, const char *accept, const char
|
||||
* and FALSE otherwise. */
|
||||
bool has_blank_chars(const char *s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
for (; *s != '\0'; s++) {
|
||||
if (isblank(*s))
|
||||
return TRUE;
|
||||
@@ -871,25 +826,18 @@ bool has_blank_chars(const char *s)
|
||||
* multibyte characters, and FALSE otherwise. */
|
||||
bool has_blank_mbchars(const char *s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
bool retval = FALSE;
|
||||
char *chr_mb = charalloc(MB_CUR_MAX);
|
||||
char symbol[MB_CUR_MAX];
|
||||
|
||||
for (; *s != '\0'; s += move_mbright(s, 0)) {
|
||||
parse_mbchar(s, chr_mb, NULL);
|
||||
parse_mbchar(s, symbol, NULL);
|
||||
|
||||
if (is_blank_mbchar(chr_mb)) {
|
||||
retval = TRUE;
|
||||
break;
|
||||
}
|
||||
if (is_blank_mbchar(symbol))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
free(chr_mb);
|
||||
|
||||
return retval;
|
||||
return FALSE;
|
||||
} else
|
||||
#endif
|
||||
return has_blank_chars(s);
|
||||
@@ -912,12 +860,11 @@ bool is_valid_unicode(wchar_t wc)
|
||||
* is, and FALSE otherwise. */
|
||||
bool is_valid_mbstring(const char *s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
return
|
||||
#ifdef ENABLE_UTF8
|
||||
use_utf8 ? (mbstowcs(NULL, s, 0) != (size_t)-1) :
|
||||
if (use_utf8)
|
||||
return (mbstowcs(NULL, s, 0) != (size_t)-1);
|
||||
else
|
||||
#endif
|
||||
TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* !DISABLE_NANORC */
|
||||
|
||||
217
src/color.c
217
src/color.c
@@ -3,7 +3,7 @@
|
||||
* *
|
||||
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, *
|
||||
* 2010, 2011, 2013, 2014, 2015 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014, 2015, 2016 Benno Schulenberg *
|
||||
* Copyright (C) 2014, 2015, 2016, 2017 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published *
|
||||
@@ -108,8 +108,6 @@ void color_init(void)
|
||||
bool using_defaults = FALSE;
|
||||
short foreground, background;
|
||||
|
||||
assert(openfile != NULL);
|
||||
|
||||
/* If the terminal is not capable of colors, forget it. */
|
||||
if (!has_colors())
|
||||
return;
|
||||
@@ -164,8 +162,6 @@ void color_update(void)
|
||||
syntaxtype *sint = NULL;
|
||||
colortype *ink;
|
||||
|
||||
assert(openfile != NULL);
|
||||
|
||||
/* If the rcfiles were not read, or contained no syntaxes, get out. */
|
||||
if (syntaxes == NULL)
|
||||
return;
|
||||
@@ -294,53 +290,12 @@ void color_update(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 *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 (; 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;
|
||||
}
|
||||
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
/* 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)
|
||||
/* Determine whether the matches of multiline regexes are still the same,
|
||||
* and if not, schedule a screen refresh, so things will be repainted. */
|
||||
void check_the_multis(filestruct *line)
|
||||
{
|
||||
const colortype *ink;
|
||||
int nobegin = 0, noend = 0;
|
||||
bool astart, anend;
|
||||
regmatch_t startmatch, endmatch;
|
||||
|
||||
/* If there is no syntax or no multiline regex, there is nothing to do. */
|
||||
@@ -348,38 +303,34 @@ void reset_multis(filestruct *fileptr, bool force)
|
||||
return;
|
||||
|
||||
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
|
||||
/* If it's not a multi-line regex, amscray. */
|
||||
/* If it's not a multiline regex, skip. */
|
||||
if (ink->end == NULL)
|
||||
continue;
|
||||
|
||||
alloc_multidata_if_needed(fileptr);
|
||||
alloc_multidata_if_needed(line);
|
||||
|
||||
if (force == FALSE) {
|
||||
/* Check whether the multidata still matches the current situation. */
|
||||
nobegin = regexec(ink->start, fileptr->data, 1, &startmatch, 0);
|
||||
noend = regexec(ink->end, fileptr->data, 1, &endmatch, 0);
|
||||
if ((fileptr->multidata[ink->id] == CWHOLELINE ||
|
||||
fileptr->multidata[ink->id] == CNONE) &&
|
||||
nobegin && noend)
|
||||
astart = (regexec(ink->start, line->data, 1, &startmatch, 0) == 0);
|
||||
anend = (regexec(ink->end, line->data, 1, &endmatch, 0) == 0);
|
||||
|
||||
/* Check whether the multidata still matches the current situation. */
|
||||
if (line->multidata[ink->id] == CNONE ||
|
||||
line->multidata[ink->id] == CWHOLELINE) {
|
||||
if (!astart && !anend)
|
||||
continue;
|
||||
else if (fileptr->multidata[ink->id] == CSTARTENDHERE &&
|
||||
!nobegin && !noend && startmatch.rm_so < endmatch.rm_so)
|
||||
} else if (line->multidata[ink->id] == CSTARTENDHERE) {
|
||||
if (astart && anend && startmatch.rm_so < endmatch.rm_so)
|
||||
continue;
|
||||
else if (fileptr->multidata[ink->id] == CBEGINBEFORE &&
|
||||
nobegin && !noend)
|
||||
} else if (line->multidata[ink->id] == CBEGINBEFORE) {
|
||||
if (!astart && anend)
|
||||
continue;
|
||||
else if (fileptr->multidata[ink->id] == CENDAFTER &&
|
||||
!nobegin && noend)
|
||||
} else if (line->multidata[ink->id] == CENDAFTER) {
|
||||
if (astart && !anend)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If we got here, things have changed. */
|
||||
reset_multis_for_id(fileptr, ink->id);
|
||||
|
||||
/* If start and end are the same, push the resets further. */
|
||||
if (force == FALSE && !nobegin && !noend &&
|
||||
startmatch.rm_so == endmatch.rm_so)
|
||||
reset_multis_for_id(fileptr, ink->id);
|
||||
/* There is a mismatch, so something changed: repaint. */
|
||||
refresh_needed = TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,103 +353,85 @@ void precalc_multicolorinfo(void)
|
||||
{
|
||||
const colortype *ink;
|
||||
regmatch_t startmatch, endmatch;
|
||||
filestruct *fileptr, *endptr;
|
||||
filestruct *line, *tailline;
|
||||
|
||||
if (openfile->colorstrings == NULL || ISSET(NO_COLOR_SYNTAX))
|
||||
return;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Entering precalculation of multiline color info\n");
|
||||
fprintf(stderr, "Precalculating the multiline color info...\n");
|
||||
#endif
|
||||
|
||||
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
|
||||
/* If this is not a multi-line regex, skip it. */
|
||||
if (ink->end == NULL)
|
||||
continue;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Starting work on color id %d\n", ink->id);
|
||||
#endif
|
||||
|
||||
for (fileptr = openfile->fileage; fileptr != NULL; fileptr = fileptr->next) {
|
||||
int startx = 0, nostart = 0;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "working on lineno %ld... ", (long)fileptr->lineno);
|
||||
#endif
|
||||
alloc_multidata_if_needed(fileptr);
|
||||
for (line = openfile->fileage; line != NULL; line = line->next) {
|
||||
int index = 0;
|
||||
|
||||
while ((nostart = regexec(ink->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(ink->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. */
|
||||
alloc_multidata_if_needed(line);
|
||||
/* Assume nothing applies until proven otherwise below. */
|
||||
line->multidata[ink->id] = CNONE;
|
||||
|
||||
/* For an unpaired start match, mark all remaining lines. */
|
||||
if (line->prev && line->prev->multidata[ink->id] == CWOULDBE) {
|
||||
line->multidata[ink->id] = CWOULDBE;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* When the line contains a start match, look for an end, and if
|
||||
* found, mark all the lines that are affected. */
|
||||
while (regexec(ink->start, line->data + index, 1,
|
||||
&startmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
/* Begin looking for an end match after the start match. */
|
||||
index += startmatch.rm_eo;
|
||||
|
||||
/* If there is an end match on this line, mark the line, but
|
||||
* continue looking for other starts after it. */
|
||||
if (regexec(ink->end, line->data + index, 1,
|
||||
&endmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
line->multidata[ink->id] = CSTARTENDHERE;
|
||||
index += endmatch.rm_eo;
|
||||
/* If both start and end are mere anchors, step ahead. */
|
||||
if (startmatch.rm_so == startmatch.rm_eo &&
|
||||
endmatch.rm_so == endmatch.rm_eo)
|
||||
startx += 1;
|
||||
fileptr->multidata[ink->id] = CSTARTENDHERE;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "end found on this line\n");
|
||||
#endif
|
||||
endmatch.rm_so == endmatch.rm_eo) {
|
||||
/* When at end-of-line, we're done. */
|
||||
if (line->data[index] == '\0')
|
||||
break;
|
||||
index = move_mbright(line->data, index);
|
||||
}
|
||||
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
|
||||
if (regexec(ink->end, endptr->data, 1, &endmatch, 0) == 0)
|
||||
/* Look for an end match on later lines. */
|
||||
tailline = line->next;
|
||||
|
||||
while (tailline != NULL) {
|
||||
if (regexec(ink->end, tailline->data, 1, &endmatch, 0) == 0)
|
||||
break;
|
||||
tailline = tailline->next;
|
||||
}
|
||||
|
||||
if (endptr == NULL) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "no end found, breaking out\n");
|
||||
#endif
|
||||
if (tailline == NULL) {
|
||||
line->multidata[ink->id] = CWOULDBE;
|
||||
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[ink->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[ink->id] = CWHOLELINE;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "marking intermediary line %ld as CWHOLELINE\n", (long)fileptr->lineno);
|
||||
#endif
|
||||
line->multidata[ink->id] = CENDAFTER;
|
||||
|
||||
for (line = line->next; line != tailline; line = line->next) {
|
||||
alloc_multidata_if_needed(line);
|
||||
line->multidata[ink->id] = CWHOLELINE;
|
||||
}
|
||||
|
||||
alloc_multidata_if_needed(endptr);
|
||||
fileptr->multidata[ink->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
|
||||
}
|
||||
alloc_multidata_if_needed(tailline);
|
||||
tailline->multidata[ink->id] = CBEGINBEFORE;
|
||||
|
||||
if (nostart && startx == 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "no match\n");
|
||||
#endif
|
||||
fileptr->multidata[ink->id] = CNONE;
|
||||
continue;
|
||||
/* Begin looking for a new start after the end match. */
|
||||
index = endmatch.rm_eo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
90
src/cut.c
90
src/cut.c
@@ -49,10 +49,10 @@ inline bool keeping_cutbuffer(void)
|
||||
void cut_line(void)
|
||||
{
|
||||
if (openfile->current != openfile->filebot)
|
||||
move_to_filestruct(&cutbuffer, &cutbottom, openfile->current, 0,
|
||||
extract_buffer(&cutbuffer, &cutbottom, openfile->current, 0,
|
||||
openfile->current->next, 0);
|
||||
else
|
||||
move_to_filestruct(&cutbuffer, &cutbottom, openfile->current, 0,
|
||||
extract_buffer(&cutbuffer, &cutbottom, openfile->current, 0,
|
||||
openfile->current, strlen(openfile->current->data));
|
||||
openfile->placewewant = 0;
|
||||
}
|
||||
@@ -60,15 +60,15 @@ void cut_line(void)
|
||||
#ifndef NANO_TINY
|
||||
/* Move all currently marked text into the cutbuffer, and set the
|
||||
* current place we want to where the text used to start. */
|
||||
void cut_marked(void)
|
||||
void cut_marked(bool *right_side_up)
|
||||
{
|
||||
filestruct *top, *bot;
|
||||
size_t top_x, bot_x;
|
||||
|
||||
mark_order((const filestruct **)&top, &top_x,
|
||||
(const filestruct **)&bot, &bot_x, NULL);
|
||||
(const filestruct **)&bot, &bot_x, right_side_up);
|
||||
|
||||
move_to_filestruct(&cutbuffer, &cutbottom, top, top_x, bot, bot_x);
|
||||
extract_buffer(&cutbuffer, &cutbottom, top, top_x, bot, bot_x);
|
||||
openfile->placewewant = xplustabs();
|
||||
}
|
||||
|
||||
@@ -82,20 +82,18 @@ void cut_to_eol(void)
|
||||
{
|
||||
size_t data_len = strlen(openfile->current->data);
|
||||
|
||||
assert(openfile->current_x <= data_len);
|
||||
|
||||
if (openfile->current_x < data_len)
|
||||
/* If we're not at the end of the line, move all the text from
|
||||
* the current position up to it, not counting the newline at
|
||||
* the end, into the cutbuffer. */
|
||||
move_to_filestruct(&cutbuffer, &cutbottom, openfile->current,
|
||||
extract_buffer(&cutbuffer, &cutbottom, openfile->current,
|
||||
openfile->current_x, openfile->current, data_len);
|
||||
else if (openfile->current != openfile->filebot) {
|
||||
/* If we're at the end of the line, and it isn't the last line
|
||||
* of the file, move all the text from the current position up
|
||||
* to the beginning of the next line, i.e. the newline at the
|
||||
* end, into the cutbuffer. */
|
||||
move_to_filestruct(&cutbuffer, &cutbottom, openfile->current,
|
||||
extract_buffer(&cutbuffer, &cutbottom, openfile->current,
|
||||
openfile->current_x, openfile->current->next, 0);
|
||||
openfile->placewewant = xplustabs();
|
||||
}
|
||||
@@ -105,7 +103,7 @@ void cut_to_eol(void)
|
||||
* file into the cutbuffer. */
|
||||
void cut_to_eof(void)
|
||||
{
|
||||
move_to_filestruct(&cutbuffer, &cutbottom,
|
||||
extract_buffer(&cutbuffer, &cutbottom,
|
||||
openfile->current, openfile->current_x,
|
||||
openfile->filebot, strlen(openfile->filebot->data));
|
||||
}
|
||||
@@ -124,45 +122,39 @@ void do_cut_text(bool copy_text, bool cut_till_eof)
|
||||
/* The length of the string at the current end of the cutbuffer,
|
||||
* before we add text to it. */
|
||||
bool old_no_newlines = ISSET(NO_NEWLINES);
|
||||
bool right_side_up = TRUE;
|
||||
/* There *is* no region, *or* it is marked forward. */
|
||||
#endif
|
||||
size_t was_totsize = openfile->totsize;
|
||||
|
||||
assert(openfile->current != NULL && openfile->current->data != NULL);
|
||||
|
||||
/* Empty the cutbuffer when a chain of cuts is broken. */
|
||||
/* If a chain of cuts was broken, empty the cutbuffer. */
|
||||
if (!keep_cutbuffer) {
|
||||
free_filestruct(cutbuffer);
|
||||
cutbuffer = NULL;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Blew away cutbuffer =)\n");
|
||||
#endif
|
||||
/* Indicate that future cuts should add to the cutbuffer. */
|
||||
keep_cutbuffer = TRUE;
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (copy_text) {
|
||||
/* If the cutbuffer isn't empty, remember where it currently ends. */
|
||||
if (cutbuffer != NULL) {
|
||||
/* If the cutbuffer isn't empty, save where it currently
|
||||
* ends. This is where we'll add the new text. */
|
||||
cb_save = cutbottom;
|
||||
cb_save_len = strlen(cutbottom->data);
|
||||
}
|
||||
|
||||
/* Set NO_NEWLINES to TRUE, so that we don't disturb the last
|
||||
* line of the file when moving text to the cutbuffer. */
|
||||
/* Don't add a magicline when moving text to the cutbuffer. */
|
||||
SET(NO_NEWLINES);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Ensure that the text we're going to move into the cutbuffer will
|
||||
* be added to the text already there, instead of replacing it. */
|
||||
keep_cutbuffer = TRUE;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (cut_till_eof) {
|
||||
/* Move all text up to the end of the file into the cutbuffer. */
|
||||
cut_to_eof();
|
||||
} else if (openfile->mark_set) {
|
||||
/* Move the marked text to the cutbuffer, and turn the mark off. */
|
||||
cut_marked();
|
||||
cut_marked(&right_side_up);
|
||||
openfile->mark_set = FALSE;
|
||||
} else if (ISSET(CUT_TO_END))
|
||||
/* Move all text up to the end of the line into the cutbuffer. */
|
||||
@@ -174,35 +166,35 @@ void do_cut_text(bool copy_text, bool cut_till_eof)
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (copy_text) {
|
||||
/* Copy the text in the cutbuffer, starting at its saved end if
|
||||
* there is one, back into the filestruct. This effectively
|
||||
* uncuts the text we just cut without marking the file as
|
||||
* modified. */
|
||||
/* Copy the text that is in the cutbuffer (starting at its saved end,
|
||||
* if there is one) back into the current buffer. This effectively
|
||||
* uncuts the text we just cut. */
|
||||
if (cutbuffer != NULL) {
|
||||
if (cb_save != NULL) {
|
||||
cb_save->data += cb_save_len;
|
||||
copy_from_filestruct(cb_save);
|
||||
copy_from_buffer(cb_save);
|
||||
cb_save->data -= cb_save_len;
|
||||
} else
|
||||
copy_from_filestruct(cutbuffer);
|
||||
copy_from_buffer(cutbuffer);
|
||||
|
||||
/* Set the current place we want to where the text from the
|
||||
* cutbuffer ends. */
|
||||
openfile->placewewant = xplustabs();
|
||||
/* If the copied region was marked forward, put the new desired
|
||||
* x position at its end; otherwise, leave it at its beginning. */
|
||||
if (right_side_up)
|
||||
openfile->placewewant = xplustabs();
|
||||
}
|
||||
|
||||
/* Set NO_NEWLINES back to what it was before, since we're done
|
||||
* disturbing the text. */
|
||||
/* Restore the magicline behavior now that we're done fiddling. */
|
||||
if (!old_no_newlines)
|
||||
UNSET(NO_NEWLINES);
|
||||
} else
|
||||
#endif /* !NANO_TINY */
|
||||
/* Only set the modification flag if actually something was cut. */
|
||||
if (openfile->totsize != was_totsize)
|
||||
set_modified();
|
||||
|
||||
refresh_needed = TRUE;
|
||||
|
||||
#ifndef DISABLE_COLOR
|
||||
reset_multis(openfile->current, FALSE);
|
||||
check_the_multis(openfile->current);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -231,7 +223,7 @@ void do_copy_text(void)
|
||||
static struct filestruct *next_contiguous_line = NULL;
|
||||
bool mark_set = openfile->mark_set;
|
||||
|
||||
/* Remember the current view port and cursor position. */
|
||||
/* Remember the current viewport and cursor position. */
|
||||
ssize_t is_edittop_lineno = openfile->edittop->lineno;
|
||||
ssize_t is_current_lineno = openfile->current->lineno;
|
||||
size_t is_current_x = openfile->current_x;
|
||||
@@ -245,7 +237,7 @@ void do_copy_text(void)
|
||||
next_contiguous_line = (mark_set ? NULL : openfile->current);
|
||||
|
||||
if (mark_set) {
|
||||
/* Restore the view port and cursor position. */
|
||||
/* Restore the viewport and cursor position. */
|
||||
openfile->edittop = fsfromline(is_edittop_lineno);
|
||||
openfile->current = fsfromline(is_current_lineno);
|
||||
openfile->current_x = is_current_x;
|
||||
@@ -264,11 +256,9 @@ void do_cut_till_eof(void)
|
||||
/* Copy text from the cutbuffer into the current filestruct. */
|
||||
void do_uncut_text(void)
|
||||
{
|
||||
int was_lineno = openfile->current->lineno;
|
||||
ssize_t was_lineno = openfile->current->lineno;
|
||||
|
||||
assert(openfile->current != NULL && openfile->current->data != NULL);
|
||||
|
||||
/* If the cutbuffer is empty, get out. */
|
||||
/* If the cutbuffer is empty, there is nothing to do. */
|
||||
if (cutbuffer == NULL)
|
||||
return;
|
||||
|
||||
@@ -278,7 +268,7 @@ void do_uncut_text(void)
|
||||
|
||||
/* Add a copy of the text in the cutbuffer to the current filestruct
|
||||
* at the current cursor position. */
|
||||
copy_from_filestruct(cutbuffer);
|
||||
copy_from_buffer(cutbuffer);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
update_undo(PASTE);
|
||||
@@ -287,17 +277,21 @@ void do_uncut_text(void)
|
||||
if (openfile->current->lineno - was_lineno < editwinrows)
|
||||
focusing = FALSE;
|
||||
|
||||
/* Set the current place we want to where the text from the
|
||||
* cutbuffer ends. */
|
||||
/* Set the desired x position to where the pasted text ends. */
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
/* Mark the file as modified. */
|
||||
set_modified();
|
||||
|
||||
/* Update the cursor position to account for the inserted lines. */
|
||||
reset_cursor();
|
||||
|
||||
ensure_line_is_visible();
|
||||
|
||||
refresh_needed = TRUE;
|
||||
|
||||
#ifndef DISABLE_COLOR
|
||||
reset_multis(openfile->current, FALSE);
|
||||
check_the_multis(openfile->current);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
338
src/files.c
338
src/files.c
@@ -148,8 +148,9 @@ void set_modified(void)
|
||||
|
||||
if (openfile->lock_filename == NULL) {
|
||||
/* TRANSLATORS: Keep the next ten messages at most 76 characters. */
|
||||
statusline(ALERT, _("Warning: Modifying a file which is not locked,"
|
||||
" check directory permission?"));
|
||||
// statusline(ALERT, _("Warning: Modifying a file which is not locked,"
|
||||
// " check directory permission?"));
|
||||
;
|
||||
} else {
|
||||
char *fullname = get_full_path(openfile->filename);
|
||||
write_lockfile(openfile->lock_filename, fullname, TRUE);
|
||||
@@ -179,8 +180,8 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
|
||||
struct stat fileinfo;
|
||||
char *lockdata = charalloc(1024);
|
||||
char myhostname[32];
|
||||
ssize_t lockdatalen = 1024;
|
||||
ssize_t wroteamt;
|
||||
size_t lockdatalen = 1024;
|
||||
size_t wroteamt;
|
||||
|
||||
mypid = getpid();
|
||||
myuid = geteuid();
|
||||
@@ -320,8 +321,8 @@ int do_lockfile(const char *filename)
|
||||
fprintf(stderr, "lock file name is %s\n", lockfilename);
|
||||
#endif
|
||||
if (stat(lockfilename, &fileinfo) != -1) {
|
||||
ssize_t readtot = 0;
|
||||
ssize_t readamt = 0;
|
||||
size_t readtot = 0;
|
||||
size_t readamt = 0;
|
||||
char *lockbuf, *question, *pidstring, *postedname, *promptstr;
|
||||
int room, response;
|
||||
|
||||
@@ -422,12 +423,8 @@ void stat_with_alloc(const char *filename, struct stat **pstat)
|
||||
* or into a new buffer when MULTIBUFFER is set or there is no buffer yet. */
|
||||
bool open_buffer(const char *filename, bool undoable)
|
||||
{
|
||||
bool new_buffer = (openfile == NULL
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
|| ISSET(MULTIBUFFER)
|
||||
#endif
|
||||
);
|
||||
/* Whether we load into this buffer or a new one. */
|
||||
bool new_buffer = (openfile == NULL || ISSET(MULTIBUFFER));
|
||||
/* Whether we load into the current buffer or a new one. */
|
||||
char *realname;
|
||||
/* The filename after tilde expansion. */
|
||||
FILE *f;
|
||||
@@ -437,6 +434,9 @@ bool open_buffer(const char *filename, bool undoable)
|
||||
|
||||
assert(filename != NULL);
|
||||
|
||||
/* Display newlines in filenames as ^J. */
|
||||
as_an_at = FALSE;
|
||||
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
if (check_operating_dir(filename, FALSE)) {
|
||||
statusline(ALERT, _("Can't insert file from outside of %s"),
|
||||
@@ -567,7 +567,8 @@ void display_buffer(void)
|
||||
precalc_multicolorinfo();
|
||||
#endif
|
||||
|
||||
refresh_needed = TRUE;
|
||||
/* Update the content of the edit window straightaway. */
|
||||
edit_refresh();
|
||||
}
|
||||
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
@@ -730,32 +731,31 @@ filestruct *read_line(char *buf, size_t buf_len, filestruct *prevnode)
|
||||
* undoable means do we want to create undo records to try and undo
|
||||
* this. Will also attempt to check file writability if fd > 0 and
|
||||
* checkwritable == TRUE. */
|
||||
void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkwritable)
|
||||
void read_file(FILE *f, int fd, const char *filename, bool undoable,
|
||||
bool checkwritable)
|
||||
{
|
||||
size_t num_lines = 0;
|
||||
/* The number of lines in the file. */
|
||||
size_t len = 0;
|
||||
/* The length of the current line of the file. */
|
||||
size_t bufx = MAX_BUF_SIZE;
|
||||
/* The size of each chunk of the file that we read. */
|
||||
char input = '\0';
|
||||
/* The current input character. */
|
||||
char *buf;
|
||||
/* The buffer where we store chunks of the file. */
|
||||
/* The buffer in which we assemble each line of the file. */
|
||||
size_t bufx = MAX_BUF_SIZE;
|
||||
/* The allocated size of the line buffer; increased as needed. */
|
||||
filestruct *fileptr = openfile->current->prev;
|
||||
/* The line after which to start inserting. */
|
||||
int input_int;
|
||||
/* The current value we read from the file, whether an input
|
||||
* character or EOF. */
|
||||
bool writable = TRUE;
|
||||
/* Is the file writable (if we care) */
|
||||
/* Whether the file is writable (in case we care). */
|
||||
#ifndef NANO_TINY
|
||||
int format = 0;
|
||||
/* 0 = *nix, 1 = DOS, 2 = Mac, 3 = both DOS and Mac. */
|
||||
#endif
|
||||
|
||||
assert(openfile->fileage != NULL && openfile->current != NULL);
|
||||
|
||||
buf = charalloc(bufx);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -838,7 +838,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
|
||||
if (len > 0) {
|
||||
#ifndef NANO_TINY
|
||||
/* If file conversion isn't disabled and the last character in
|
||||
* This file is '\r', set format to Mac if we currently think
|
||||
* this file is '\r', set format to Mac if we currently think
|
||||
* the file is a *nix file, or to both DOS and Mac if we
|
||||
* currently think the file is a DOS file. */
|
||||
if (buf[len - 1] == '\r' && !ISSET(NO_CONVERT) && format < 2)
|
||||
@@ -907,12 +907,11 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
|
||||
openfile->current_x = 0;
|
||||
}
|
||||
|
||||
/* Set the current place we want to the end of the last line of the
|
||||
* file we inserted. */
|
||||
/* Set the desired x position at the end of what was inserted. */
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
if (!writable)
|
||||
statusline(ALERT, "File '%s' is unwritable", filename);
|
||||
statusline(ALERT, _("File '%s' is unwritable"), filename);
|
||||
#ifndef NANO_TINY
|
||||
else if (format == 3) {
|
||||
/* TRANSLATORS: Keep the next four messages at most 78 characters. */
|
||||
@@ -947,13 +946,10 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Open the file (and decide if it exists). If newfie is TRUE, display
|
||||
* "New File" if the file is missing. Otherwise, say "[filename] not
|
||||
* found".
|
||||
*
|
||||
/* Open the file with the given name. If the file does not exist, display
|
||||
* "New File" if newfie is TRUE, and say "File not found" otherwise.
|
||||
* Return -2 if we say "New File", -1 if the file isn't opened, and the
|
||||
* fd opened otherwise. The file might still have an error while reading
|
||||
* with a 0 return value. *f is set to the opened file. */
|
||||
* obtained fd otherwise. *f is set to the opened file. */
|
||||
int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
|
||||
{
|
||||
struct stat fileinfo, fileinfo2;
|
||||
@@ -972,39 +968,35 @@ int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
|
||||
full_filename = mallocstrcpy(full_filename, filename);
|
||||
|
||||
if (stat(full_filename, &fileinfo) == -1) {
|
||||
/* All cases below return. */
|
||||
free(full_filename);
|
||||
|
||||
/* Well, maybe we can open the file even if the OS says it's
|
||||
* not there. */
|
||||
if ((fd = open(filename, O_RDONLY)) != -1) {
|
||||
if (!quiet)
|
||||
statusbar(_("Reading File"));
|
||||
return fd;
|
||||
}
|
||||
|
||||
if (newfie) {
|
||||
if (!quiet)
|
||||
statusbar(_("New File"));
|
||||
free(full_filename);
|
||||
return -2;
|
||||
}
|
||||
statusline(ALERT, _("File \"%s\" not found"), filename);
|
||||
return -1;
|
||||
} else if (S_ISDIR(fileinfo.st_mode) || S_ISCHR(fileinfo.st_mode) ||
|
||||
S_ISBLK(fileinfo.st_mode)) {
|
||||
free(full_filename);
|
||||
|
||||
/* Don't open directories, character files, or block files. */
|
||||
statusline(ALERT, S_ISDIR(fileinfo.st_mode) ?
|
||||
_("\"%s\" is a directory") :
|
||||
_("\"%s\" is a device file"), filename);
|
||||
return -1;
|
||||
} else if ((fd = open(full_filename, O_RDONLY)) == -1) {
|
||||
statusline(ALERT, _("File \"%s\" not found"), filename);
|
||||
free(full_filename);
|
||||
statusline(ALERT, _("Error reading %s: %s"), filename, strerror(errno));
|
||||
return -1;
|
||||
} else {
|
||||
/* The file is A-OK. Open it. */
|
||||
}
|
||||
|
||||
/* Don't open directories, character files, or block files. */
|
||||
if (S_ISDIR(fileinfo.st_mode) || S_ISCHR(fileinfo.st_mode) ||
|
||||
S_ISBLK(fileinfo.st_mode)) {
|
||||
statusline(ALERT, S_ISDIR(fileinfo.st_mode) ?
|
||||
_("\"%s\" is a directory") :
|
||||
_("\"%s\" is a device file"), filename);
|
||||
free(full_filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Try opening the file. */
|
||||
fd = open(full_filename, O_RDONLY);
|
||||
|
||||
if (fd == -1)
|
||||
statusline(ALERT, _("Error reading %s: %s"), filename, strerror(errno));
|
||||
else {
|
||||
/* The file is A-OK. Associate a stream with it. */
|
||||
*f = fdopen(fd, "rb");
|
||||
|
||||
if (*f == NULL) {
|
||||
@@ -1070,15 +1062,19 @@ void do_insertfile(void)
|
||||
bool execute = FALSE, right_side_up = FALSE, single_line = FALSE;
|
||||
#endif
|
||||
|
||||
/* Display newlines in filenames as ^J. */
|
||||
as_an_at = FALSE;
|
||||
|
||||
while (TRUE) {
|
||||
#ifndef NANO_TINY
|
||||
if (execute) {
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
if (ISSET(MULTIBUFFER))
|
||||
msg = _("Command to execute in new buffer [from %s] ");
|
||||
/* TRANSLATORS: The next four messages are prompts. */
|
||||
msg = _("Command to execute in new buffer");
|
||||
else
|
||||
#endif
|
||||
msg = _("Command to execute [from %s] ");
|
||||
msg = _("Command to execute");
|
||||
} else
|
||||
#endif /* NANO_TINY */
|
||||
{
|
||||
@@ -1092,10 +1088,7 @@ void do_insertfile(void)
|
||||
|
||||
present_path = mallocstrcpy(present_path, "./");
|
||||
|
||||
i = do_prompt(TRUE,
|
||||
#ifndef DISABLE_TABCOMP
|
||||
TRUE,
|
||||
#endif
|
||||
i = do_prompt(TRUE, TRUE,
|
||||
#ifndef NANO_TINY
|
||||
execute ? MEXTCMD :
|
||||
#endif
|
||||
@@ -1111,19 +1104,15 @@ void do_insertfile(void)
|
||||
"./");
|
||||
|
||||
/* If we're in multibuffer mode and the filename or command is
|
||||
* blank, open a new buffer instead of canceling. If the
|
||||
* filename or command begins with a newline (i.e. an encoded
|
||||
* null), treat it as though it's blank. */
|
||||
if (i == -1 || (!ISSET(MULTIBUFFER) && (i == -2 || *answer == '\n'))) {
|
||||
* blank, open a new buffer instead of canceling. */
|
||||
if (i == -1 || (i == -2 && !ISSET(MULTIBUFFER))) {
|
||||
statusbar(_("Cancelled"));
|
||||
break;
|
||||
} else {
|
||||
filestruct *edittop_save = openfile->edittop;
|
||||
ssize_t was_current_lineno = openfile->current->lineno;
|
||||
size_t was_current_x = openfile->current_x;
|
||||
ssize_t was_current_y = openfile->current_y;
|
||||
bool current_was_at_top = FALSE;
|
||||
size_t pww_save = openfile->placewewant;
|
||||
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
|
||||
functionptrtype func = func_from_key(&i);
|
||||
#endif
|
||||
@@ -1186,10 +1175,6 @@ void do_insertfile(void)
|
||||
current_was_at_top = (openfile->edittop == openfile->fileage);
|
||||
}
|
||||
|
||||
/* Convert newlines to nulls in the given filename. */
|
||||
sunder(answer);
|
||||
align(&answer);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (execute) {
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
@@ -1229,7 +1214,7 @@ void do_insertfile(void)
|
||||
#ifndef NANO_TINY
|
||||
if (!execute)
|
||||
#endif
|
||||
if (check_poshistory(answer, &priorline, &priorcol))
|
||||
if (has_old_position(answer, &priorline, &priorcol))
|
||||
do_gotolinecolumn(priorline, priorcol, FALSE, FALSE);
|
||||
}
|
||||
#endif /* !DISABLE_HISTORIES */
|
||||
@@ -1272,9 +1257,6 @@ void do_insertfile(void)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* Update the current y-coordinate to account for the
|
||||
* number of lines inserted. */
|
||||
openfile->current_y += was_current_y;
|
||||
|
||||
/* Unpartition the filestruct so that it contains all
|
||||
* the text again. Note that we've replaced the
|
||||
@@ -1289,14 +1271,19 @@ void do_insertfile(void)
|
||||
/* Restore the old edittop. */
|
||||
openfile->edittop = edittop_save;
|
||||
|
||||
/* Restore the old place we want. */
|
||||
openfile->placewewant = pww_save;
|
||||
/* Set the desired x position to the current one. */
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
/* Mark the file as modified if it changed. */
|
||||
if (openfile->current->lineno != was_current_lineno ||
|
||||
openfile->current_x != was_current_x)
|
||||
set_modified();
|
||||
|
||||
/* Update the cursor position to account for inserted lines. */
|
||||
reset_cursor();
|
||||
|
||||
ensure_line_is_visible();
|
||||
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
@@ -1307,21 +1294,16 @@ void do_insertfile(void)
|
||||
free(given);
|
||||
}
|
||||
|
||||
/* Insert a file into a new buffer or the current buffer, depending on
|
||||
* whether the MULTIBUFFER flag is set. If we're in view mode, only
|
||||
* allow inserting a file into a new buffer. */
|
||||
/* If the current mode of operation allows it, go insert a file. */
|
||||
void do_insertfile_void(void)
|
||||
{
|
||||
if (ISSET(RESTRICTED)) {
|
||||
if (ISSET(RESTRICTED))
|
||||
show_restricted_warning();
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
if (ISSET(VIEW_MODE) && !ISSET(MULTIBUFFER))
|
||||
else if (ISSET(VIEW_MODE) && !ISSET(MULTIBUFFER))
|
||||
statusbar(_("Key invalid in non-multibuffer mode"));
|
||||
else
|
||||
#endif
|
||||
else
|
||||
do_insertfile();
|
||||
}
|
||||
|
||||
@@ -1357,8 +1339,6 @@ char *get_full_path(const char *origpath)
|
||||
|
||||
/* If we succeeded, canonicalize it in d_here. */
|
||||
if (d_here != NULL) {
|
||||
align(&d_here);
|
||||
|
||||
/* If the current directory isn't "/", tack a slash onto the end
|
||||
* of it. */
|
||||
if (strcmp(d_here, "/") != 0) {
|
||||
@@ -1420,8 +1400,6 @@ char *get_full_path(const char *origpath)
|
||||
|
||||
/* If we succeeded, canonicalize it in d_there. */
|
||||
if (d_there != NULL) {
|
||||
align(&d_there);
|
||||
|
||||
/* If the current directory isn't "/", tack a slash onto
|
||||
* the end of it. */
|
||||
if (strcmp(d_there, "/") != 0) {
|
||||
@@ -1544,6 +1522,8 @@ void init_operating_dir(void)
|
||||
/* If the operating directory is inaccessible, fail. */
|
||||
if (full_operating_dir == NULL || chdir(full_operating_dir) == -1)
|
||||
die("Invalid operating directory\n");
|
||||
|
||||
snuggly_fit(&full_operating_dir);
|
||||
}
|
||||
|
||||
/* Check to see if we're inside the operating directory. Return FALSE
|
||||
@@ -1634,6 +1614,7 @@ void init_backup_dir(void)
|
||||
} else {
|
||||
free(backup_dir);
|
||||
backup_dir = full_backup_dir;
|
||||
snuggly_fit(&backup_dir);
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
@@ -1711,8 +1692,6 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
||||
char *tempname = NULL;
|
||||
/* The name of the temporary file we write to on prepend. */
|
||||
|
||||
assert(name != NULL);
|
||||
|
||||
if (*name == '\0')
|
||||
return -1;
|
||||
|
||||
@@ -2005,10 +1984,6 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
||||
}
|
||||
}
|
||||
|
||||
/* There might not be a magicline. There won't be when writing out
|
||||
* a selection. */
|
||||
assert(openfile->fileage != NULL && openfile->filebot != NULL);
|
||||
|
||||
while (fileptr != NULL) {
|
||||
size_t data_len = strlen(fileptr->data), size;
|
||||
|
||||
@@ -2156,8 +2131,6 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
|
||||
filestruct *top, *bot;
|
||||
size_t top_x, bot_x;
|
||||
|
||||
assert(openfile->mark_set);
|
||||
|
||||
/* Partition the filestruct so that it contains only the marked text. */
|
||||
mark_order((const filestruct **)&top, &top_x,
|
||||
(const filestruct **)&bot, &bot_x, NULL);
|
||||
@@ -2205,6 +2178,9 @@ int do_writeout(bool exiting)
|
||||
static bool did_credits = FALSE;
|
||||
#endif
|
||||
|
||||
/* Display newlines in filenames as ^J. */
|
||||
as_an_at = FALSE;
|
||||
|
||||
if (exiting && ISSET(TEMP_FILE) && openfile->filename[0] != '\0') {
|
||||
if (write_file(openfile->filename, NULL, FALSE, OVERWRITE, FALSE))
|
||||
return 1;
|
||||
@@ -2232,6 +2208,7 @@ int do_writeout(bool exiting)
|
||||
* it allows reading from or writing to files not specified on
|
||||
* the command line. */
|
||||
if (openfile->mark_set && !exiting && !ISSET(RESTRICTED))
|
||||
/* TRANSLATORS: The next six strings are prompts. */
|
||||
msg = (method == PREPEND) ? _("Prepend Selection to File") :
|
||||
(method == APPEND) ? _("Append Selection to File") :
|
||||
_("Write Selection to File");
|
||||
@@ -2245,12 +2222,8 @@ int do_writeout(bool exiting)
|
||||
|
||||
/* If we're using restricted mode, and the filename isn't blank,
|
||||
* disable tab completion. */
|
||||
i = do_prompt(!ISSET(RESTRICTED) ||
|
||||
openfile->filename[0] == '\0',
|
||||
#ifndef DISABLE_TABCOMP
|
||||
TRUE,
|
||||
#endif
|
||||
MWRITEFILE, given,
|
||||
i = do_prompt(!ISSET(RESTRICTED) || openfile->filename[0] == '\0',
|
||||
TRUE, MWRITEFILE, given,
|
||||
#ifndef DISABLE_HISTORIES
|
||||
NULL,
|
||||
#endif
|
||||
@@ -2262,9 +2235,7 @@ int do_writeout(bool exiting)
|
||||
#endif
|
||||
);
|
||||
|
||||
/* If the filename or command begins with a newline (i.e. an
|
||||
* encoded null), treat it as though it's blank. */
|
||||
if (i < 0 || *answer == '\n') {
|
||||
if (i < 0) {
|
||||
statusbar(_("Cancelled"));
|
||||
break;
|
||||
} else {
|
||||
@@ -2343,15 +2314,10 @@ int do_writeout(bool exiting)
|
||||
#endif
|
||||
|
||||
if (method == OVERWRITE) {
|
||||
size_t answer_len = strlen(answer);
|
||||
bool name_exists, do_warning;
|
||||
char *full_answer, *full_filename;
|
||||
struct stat st;
|
||||
|
||||
/* Convert newlines to nulls, just before we get the
|
||||
* full path. */
|
||||
sunder(answer);
|
||||
|
||||
full_answer = get_full_path(answer);
|
||||
full_filename = get_full_path(openfile->filename);
|
||||
name_exists = (stat((full_answer == NULL) ?
|
||||
@@ -2363,22 +2329,19 @@ int do_writeout(bool exiting)
|
||||
answer : full_answer, (full_filename == NULL) ?
|
||||
openfile->filename : full_filename) != 0);
|
||||
|
||||
/* Convert nulls to newlines. answer_len is the
|
||||
* string's real length. */
|
||||
unsunder(answer, answer_len);
|
||||
|
||||
free(full_filename);
|
||||
free(full_answer);
|
||||
|
||||
if (do_warning) {
|
||||
/* If we're using restricted mode, we aren't allowed
|
||||
* to overwrite an existing file with the current
|
||||
* file. We also aren't allowed to change the name
|
||||
* of the current file if it has one, because that
|
||||
* would allow reading from or writing to files not
|
||||
* specified on the command line. */
|
||||
if (ISSET(RESTRICTED))
|
||||
/* When in restricted mode, we aren't allowed to overwrite
|
||||
* an existing file with the current buffer, nor to change
|
||||
* the name of the current file if it already has one. */
|
||||
if (ISSET(RESTRICTED)) {
|
||||
/* TRANSLATORS: Restricted mode forbids overwriting. */
|
||||
warn_and_shortly_pause(_("File exists -- "
|
||||
"cannot overwrite"));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!maychange) {
|
||||
#ifndef NANO_TINY
|
||||
@@ -2421,10 +2384,6 @@ int do_writeout(bool exiting)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Convert newlines to nulls, just before we save the file. */
|
||||
sunder(answer);
|
||||
align(&answer);
|
||||
|
||||
/* Here's where we allow the selected text to be written to
|
||||
* a separate file. If we're using restricted mode, this
|
||||
* function is disabled, since it allows reading from or
|
||||
@@ -2470,8 +2429,6 @@ char *real_dir_from_tilde(const char *buf)
|
||||
{
|
||||
char *retval;
|
||||
|
||||
assert(buf != NULL);
|
||||
|
||||
if (*buf == '~') {
|
||||
size_t i = 1;
|
||||
char *tilde_dir;
|
||||
@@ -2554,8 +2511,6 @@ bool is_dir(const char *buf)
|
||||
struct stat fileinfo;
|
||||
bool retval;
|
||||
|
||||
assert(buf != NULL);
|
||||
|
||||
dirptr = real_dir_from_tilde(buf);
|
||||
|
||||
retval = (stat(dirptr, &fileinfo) != -1 && S_ISDIR(fileinfo.st_mode));
|
||||
@@ -2752,31 +2707,26 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
|
||||
char *mzero, *glued;
|
||||
const char *lastslash = revstrstr(buf, "/", buf + *place);
|
||||
size_t lastslash_len = (lastslash == NULL) ? 0 : lastslash - buf + 1;
|
||||
char *match1 = charalloc(mb_cur_max());
|
||||
char *match2 = charalloc(mb_cur_max());
|
||||
int match1_len, match2_len;
|
||||
char char1[mb_cur_max()], char2[mb_cur_max()];
|
||||
int len1, len2;
|
||||
|
||||
/* Get the number of characters that all matches have in common. */
|
||||
while (TRUE) {
|
||||
match1_len = parse_mbchar(matches[0] + common_len, match1, NULL);
|
||||
len1 = parse_mbchar(matches[0] + common_len, char1, NULL);
|
||||
|
||||
for (match = 1; match < num_matches; match++) {
|
||||
match2_len = parse_mbchar(matches[match] + common_len,
|
||||
match2, NULL);
|
||||
if (match1_len != match2_len ||
|
||||
strncmp(match1, match2, match2_len) != 0)
|
||||
len2 = parse_mbchar(matches[match] + common_len, char2, NULL);
|
||||
|
||||
if (len1 != len2 || strncmp(char1, char2, len2) != 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (match < num_matches || matches[0][common_len] == '\0')
|
||||
break;
|
||||
|
||||
common_len += match1_len;
|
||||
common_len += len1;
|
||||
}
|
||||
|
||||
free(match1);
|
||||
free(match2);
|
||||
|
||||
mzero = charalloc(lastslash_len + common_len + 1);
|
||||
|
||||
strncpy(mzero, buf, lastslash_len);
|
||||
@@ -3004,12 +2954,10 @@ void load_history(void)
|
||||
size_t buf_len = 0;
|
||||
ssize_t read;
|
||||
|
||||
while ((read = getline(&line, &buf_len, hist)) >= 0) {
|
||||
if (read > 0 && line[read - 1] == '\n') {
|
||||
read--;
|
||||
line[read] = '\0';
|
||||
}
|
||||
while ((read = getline(&line, &buf_len, hist)) > 0) {
|
||||
line[--read] = '\0';
|
||||
if (read > 0) {
|
||||
/* Encode any embedded NUL as 0x0A. */
|
||||
unsunder(line, read);
|
||||
update_history(history, line);
|
||||
} else
|
||||
@@ -3024,22 +2972,23 @@ void load_history(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Write the lines of a history list, starting with the line at h, to
|
||||
/* Write the lines of a history list, starting with the line at head, to
|
||||
* the open file at hist. Return TRUE if the write succeeded, and FALSE
|
||||
* otherwise. */
|
||||
bool writehist(FILE *hist, filestruct *h)
|
||||
bool writehist(FILE *hist, const filestruct *head)
|
||||
{
|
||||
filestruct *p;
|
||||
const filestruct *item;
|
||||
|
||||
/* Write a history list from the oldest entry to the newest. Assume
|
||||
* the last history entry is a blank line. */
|
||||
for (p = h; p != NULL; p = p->next) {
|
||||
size_t p_len = strlen(p->data);
|
||||
/* Write a history list, from the oldest item to the newest. */
|
||||
for (item = head; item != NULL; item = item->next) {
|
||||
size_t length = strlen(item->data);
|
||||
|
||||
sunder(p->data);
|
||||
/* Decode 0x0A bytes as embedded NULs. */
|
||||
sunder(item->data);
|
||||
|
||||
if (fwrite(p->data, sizeof(char), p_len, hist) < p_len ||
|
||||
putc('\n', hist) == EOF)
|
||||
if (fwrite(item->data, sizeof(char), length, hist) < length)
|
||||
return FALSE;
|
||||
if (putc('\n', hist) == EOF)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -3084,7 +3033,6 @@ void save_history(void)
|
||||
void save_poshistory(void)
|
||||
{
|
||||
char *poshist = poshistfilename();
|
||||
char *statusstr = NULL;
|
||||
poshiststruct *posptr;
|
||||
FILE *hist;
|
||||
|
||||
@@ -3100,14 +3048,25 @@ void save_poshistory(void)
|
||||
chmod(poshist, S_IRUSR | S_IWUSR);
|
||||
|
||||
for (posptr = position_history; posptr != NULL; posptr = posptr->next) {
|
||||
char *path_and_place;
|
||||
size_t length;
|
||||
|
||||
/* Assume 20 decimal positions each for line and column number,
|
||||
* plus two spaces, plus the line feed, plus the null byte. */
|
||||
statusstr = charalloc(strlen(posptr->filename) + 44);
|
||||
sprintf(statusstr, "%s %ld %ld\n", posptr->filename, (long)posptr->lineno,
|
||||
(long)posptr->xno);
|
||||
if (fwrite(statusstr, sizeof(char), strlen(statusstr), hist) < strlen(statusstr))
|
||||
fprintf(stderr, _("Error writing %s: %s\n"), poshist, strerror(errno));
|
||||
free(statusstr);
|
||||
path_and_place = charalloc(strlen(posptr->filename) + 44);
|
||||
sprintf(path_and_place, "%s %ld %ld\n", posptr->filename,
|
||||
(long)posptr->lineno, (long)posptr->xno);
|
||||
length = strlen(path_and_place);
|
||||
|
||||
/* Encode newlines in filenames as nulls. */
|
||||
sunder(path_and_place);
|
||||
/* Restore the terminating newline. */
|
||||
path_and_place[length - 1] = '\n';
|
||||
|
||||
if (fwrite(path_and_place, sizeof(char), length, hist) < length)
|
||||
fprintf(stderr, _("Error writing %s: %s\n"),
|
||||
poshist, strerror(errno));
|
||||
free(path_and_place);
|
||||
}
|
||||
fclose(hist);
|
||||
}
|
||||
@@ -3176,27 +3135,28 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
|
||||
free(fullpath);
|
||||
}
|
||||
|
||||
/* Check the recorded last file positions to see if the given file
|
||||
* matches an existing entry. If so, return 1 and set line and column
|
||||
* to the retrieved values. Otherwise, return 0. */
|
||||
int check_poshistory(const char *file, ssize_t *line, ssize_t *column)
|
||||
/* Check whether the given file matches an existing entry in the recorded
|
||||
* last file positions. If not, return FALSE. If yes, return TRUE and
|
||||
* set line and column to the retrieved values. */
|
||||
bool has_old_position(const char *file, ssize_t *line, ssize_t *column)
|
||||
{
|
||||
poshiststruct *posptr;
|
||||
poshiststruct *posptr = position_history;
|
||||
char *fullpath = get_full_path(file);
|
||||
|
||||
if (fullpath == NULL)
|
||||
return 0;
|
||||
return FALSE;
|
||||
|
||||
while (posptr != NULL && strcmp(posptr->filename, fullpath) != 0)
|
||||
posptr = posptr->next;
|
||||
|
||||
for (posptr = position_history; posptr != NULL; posptr = posptr->next) {
|
||||
if (!strcmp(posptr->filename, fullpath)) {
|
||||
*line = posptr->lineno;
|
||||
*column = posptr->xno;
|
||||
free(fullpath);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
free(fullpath);
|
||||
return 0;
|
||||
|
||||
if (posptr == NULL)
|
||||
return FALSE;
|
||||
|
||||
*line = posptr->lineno;
|
||||
*column = posptr->xno;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Load the recorded file positions from ~/.nano/filepos_history. */
|
||||
@@ -3224,13 +3184,21 @@ void load_poshistory(void)
|
||||
poshiststruct *record_ptr = NULL, *newrecord;
|
||||
|
||||
/* Read and parse each line, and store the extracted data. */
|
||||
while ((read = getline(&line, &buf_len, hist)) > 2) {
|
||||
if (line[read - 1] == '\n')
|
||||
line[--read] = '\0';
|
||||
while ((read = getline(&line, &buf_len, hist)) > 5) {
|
||||
/* Decode nulls as embedded newlines. */
|
||||
unsunder(line, read);
|
||||
|
||||
lineptr = parse_next_word(line);
|
||||
xptr = parse_next_word(lineptr);
|
||||
/* Find where the x index and line number are in the line. */
|
||||
xptr = revstrstr(line, " ", line + read - 3);
|
||||
if (xptr == NULL)
|
||||
continue;
|
||||
lineptr = revstrstr(line, " ", xptr - 2);
|
||||
if (lineptr == NULL)
|
||||
continue;
|
||||
|
||||
/* Now separate the three elements of the line. */
|
||||
*(xptr++) = '\0';
|
||||
*(lineptr++) = '\0';
|
||||
|
||||
/* Create a new position record. */
|
||||
newrecord = (poshiststruct *)nmalloc(sizeof(poshiststruct));
|
||||
|
||||
58
src/global.c
58
src/global.c
@@ -29,8 +29,8 @@
|
||||
|
||||
/* Global variables. */
|
||||
#ifndef NANO_TINY
|
||||
volatile sig_atomic_t sigwinch_counter = 0;
|
||||
/* Is incremented by the handler whenever a SIGWINCH occurs. */
|
||||
volatile sig_atomic_t the_window_resized = FALSE;
|
||||
/* Set to TRUE by the handler whenever a SIGWINCH occurs. */
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
@@ -45,20 +45,20 @@ bool shift_held;
|
||||
bool focusing = TRUE;
|
||||
/* Whether an update of the edit window should center the cursor. */
|
||||
|
||||
bool as_an_at = TRUE;
|
||||
/* Whether a 0x0A byte should be shown as a ^@ instead of a ^J. */
|
||||
|
||||
int margin = 0;
|
||||
/* The amount of space reserved at the left for line numbers. */
|
||||
int editwincols = -1;
|
||||
/* The number of usable columns in the edit window: COLS - margin. */
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
int last_drawn_line = 0;
|
||||
/* The line number of the last drawn line. */
|
||||
int last_line_y;
|
||||
/* The y coordinate of the last drawn line. */
|
||||
#endif
|
||||
|
||||
message_type lastmessage = HUSH;
|
||||
/* Messages of type HUSH should not overwrite type MILD nor ALERT. */
|
||||
|
||||
filestruct *pletion_line = NULL;
|
||||
/* The line where the last completion was found, if any. */
|
||||
|
||||
int controlleft, controlright, controlup, controldown;
|
||||
#ifndef NANO_TINY
|
||||
int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown;
|
||||
@@ -94,8 +94,8 @@ WINDOW *bottomwin;
|
||||
* messages, the statusbar prompt, and a list of shortcuts. */
|
||||
int editwinrows = 0;
|
||||
/* How many rows does the edit window take up? */
|
||||
int maxrows = 0;
|
||||
/* How many usable lines there are (due to soft wrapping). */
|
||||
int maxlines = 0;
|
||||
/* How many file lines can be shown (due to soft wrapping). */
|
||||
|
||||
filestruct *cutbuffer = NULL;
|
||||
/* The buffer where we store cut text. */
|
||||
@@ -388,18 +388,17 @@ const sc *first_sc_for(int menu, void (*func)(void))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Return the given menu's first shortcut sequence, or the default value
|
||||
* (2nd arg). Assumes currmenu for the menu to check. */
|
||||
int sc_seq_or(void (*func)(void), int defaultval)
|
||||
/* Return the first keycode that is bound to the given function in the
|
||||
* current menu, if any; otherwise, return the given default value. */
|
||||
int the_code_for(void (*func)(void), int defaultval)
|
||||
{
|
||||
const sc *s = first_sc_for(currmenu, func);
|
||||
|
||||
if (s) {
|
||||
meta_key = s->meta;
|
||||
return s->keycode;
|
||||
}
|
||||
/* else */
|
||||
return defaultval;
|
||||
if (s == NULL)
|
||||
return defaultval;
|
||||
|
||||
meta_key = s->meta;
|
||||
return s->keycode;
|
||||
}
|
||||
|
||||
/* Return a pointer to the function that is bound to the given key. */
|
||||
@@ -531,9 +530,6 @@ void shortcut_init(void)
|
||||
N_("Copy the current line and store it in the cutbuffer");
|
||||
const char *nano_indent_msg = N_("Indent the current line");
|
||||
const char *nano_unindent_msg = N_("Unindent the current line");
|
||||
#ifdef ENABLE_COMMENT
|
||||
const char *nano_comment_msg = N_("Comment/uncomment the current line or marked lines");
|
||||
#endif
|
||||
const char *nano_undo_msg = N_("Undo the last operation");
|
||||
const char *nano_redo_msg = N_("Redo the last undone operation");
|
||||
#endif
|
||||
@@ -591,6 +587,13 @@ void shortcut_init(void)
|
||||
N_("Refresh (redraw) the current screen");
|
||||
const char *nano_suspend_msg =
|
||||
N_("Suspend the editor (if suspension is enabled)");
|
||||
#ifdef ENABLE_WORDCOMPLETION
|
||||
const char *nano_completion_msg = N_("Try and complete the current word");
|
||||
#endif
|
||||
#ifdef ENABLE_COMMENT
|
||||
const char *nano_comment_msg =
|
||||
N_("Comment/uncomment the current line or marked lines");
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
const char *nano_savefile_msg = N_("Save file without prompting");
|
||||
const char *nano_findprev_msg = N_("Search next occurrence backward");
|
||||
@@ -925,6 +928,10 @@ void shortcut_init(void)
|
||||
add_to_funcs(do_suspend_void, MMAIN,
|
||||
N_("Suspend"), IFSCHELP(nano_suspend_msg), BLANKAFTER, VIEW);
|
||||
|
||||
#ifdef ENABLE_WORDCOMPLETION
|
||||
add_to_funcs(complete_a_word, MMAIN,
|
||||
N_("Complete"), IFSCHELP(nano_completion_msg), TOGETHER, NOVIEW);
|
||||
#endif
|
||||
#ifdef ENABLE_COMMENT
|
||||
add_to_funcs(do_comment, MMAIN,
|
||||
N_("Comment Lines"), IFSCHELP(nano_comment_msg), BLANKAFTER, NOVIEW);
|
||||
@@ -1096,6 +1103,9 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN, "M-U", 0, do_undo, 0);
|
||||
add_to_sclist(MMAIN, "M-E", 0, do_redo, 0);
|
||||
#endif
|
||||
#ifdef ENABLE_WORDCOMPLETION
|
||||
add_to_sclist(MMAIN, "^]", 0, complete_a_word, 0);
|
||||
#endif
|
||||
#ifdef ENABLE_COMMENT
|
||||
add_to_sclist(MMAIN, "M-3", 0, do_comment, 0);
|
||||
#endif
|
||||
@@ -1443,6 +1453,10 @@ sc *strtosc(const char *input)
|
||||
else if (!strcasecmp(input, "comment"))
|
||||
s->scfunc = do_comment;
|
||||
#endif
|
||||
#ifdef ENABLE_WORDCOMPLETION
|
||||
else if (!strcasecmp(input, "complete"))
|
||||
s->scfunc = complete_a_word;
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcasecmp(input, "indent"))
|
||||
s->scfunc = do_indent_void;
|
||||
|
||||
54
src/move.c
54
src/move.c
@@ -44,6 +44,7 @@ void do_last_line(void)
|
||||
|
||||
/* Set the last line of the screen as the target for the cursor. */
|
||||
openfile->current_y = editwinrows - 1;
|
||||
ensure_line_is_visible();
|
||||
|
||||
refresh_needed = TRUE;
|
||||
focusing = FALSE;
|
||||
@@ -56,10 +57,7 @@ void do_page_up(void)
|
||||
|
||||
/* 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) &&
|
||||
#endif
|
||||
if (openfile->current->lineno == 1 || (!ISSET(SOFTWRAP) &&
|
||||
openfile->current->lineno <= editwinrows - 2)) {
|
||||
do_first_line();
|
||||
return;
|
||||
@@ -67,10 +65,7 @@ void do_page_up(void)
|
||||
|
||||
/* If we're not in smooth scrolling mode, put the cursor at the
|
||||
* beginning of the top line of the edit window, as Pico does. */
|
||||
#ifndef NANO_TINY
|
||||
if (!ISSET(SMOOTH_SCROLL))
|
||||
#endif
|
||||
{
|
||||
if (!ISSET(SMOOTH_SCROLL)) {
|
||||
openfile->current = openfile->edittop;
|
||||
openfile->placewewant = openfile->current_y = 0;
|
||||
}
|
||||
@@ -81,9 +76,9 @@ void do_page_up(void)
|
||||
openfile->current = openfile->current->prev;
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP) && openfile->current) {
|
||||
skipped += strlenpt(openfile->current->data) / COLS;
|
||||
skipped += strlenpt(openfile->current->data) / editwincols;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_page_up: i = %d, skipped = %d based on line %ld len %lu\n",
|
||||
fprintf(stderr, "paging up: i = %d, skipped = %d based on line %ld len %lu\n",
|
||||
i, skipped, (long)openfile->current->lineno, (unsigned long)strlenpt(openfile->current->data));
|
||||
#endif
|
||||
}
|
||||
@@ -93,11 +88,6 @@ void do_page_up(void)
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
openfile->placewewant);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_page_up: openfile->current->lineno = %lu, skipped = %d\n",
|
||||
(unsigned long)openfile->current->lineno, skipped);
|
||||
#endif
|
||||
|
||||
/* Scroll the edit window up a page. */
|
||||
adjust_viewport(STATIONARY);
|
||||
refresh_needed = TRUE;
|
||||
@@ -110,27 +100,24 @@ void do_page_down(void)
|
||||
|
||||
/* 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) {
|
||||
if (openfile->current->lineno + maxlines - 2 >= openfile->filebot->lineno) {
|
||||
do_last_line();
|
||||
return;
|
||||
}
|
||||
|
||||
/* If we're not in smooth scrolling mode, put the cursor at the
|
||||
* beginning of the top line of the edit window, as Pico does. */
|
||||
#ifndef NANO_TINY
|
||||
if (!ISSET(SMOOTH_SCROLL))
|
||||
#endif
|
||||
{
|
||||
if (!ISSET(SMOOTH_SCROLL)) {
|
||||
openfile->current = openfile->edittop;
|
||||
openfile->placewewant = openfile->current_y = 0;
|
||||
}
|
||||
|
||||
mustmove = (maxrows < 3) ? 1 : maxrows - 2;
|
||||
mustmove = (maxlines < 3) ? 1 : maxlines - 2;
|
||||
|
||||
for (i = mustmove; i > 0 && openfile->current != openfile->filebot; i--) {
|
||||
openfile->current = openfile->current->next;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_page_down: moving to line %lu\n", (unsigned long)openfile->current->lineno);
|
||||
fprintf(stderr, "paging down: moving to line %lu\n", (unsigned long)openfile->current->lineno);
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -152,10 +139,9 @@ void do_para_begin(bool allow_update)
|
||||
filestruct *was_current = openfile->current;
|
||||
|
||||
if (openfile->current != openfile->fileage) {
|
||||
do {
|
||||
do
|
||||
openfile->current = openfile->current->prev;
|
||||
openfile->current_y--;
|
||||
} while (!begpar(openfile->current));
|
||||
while (!begpar(openfile->current));
|
||||
}
|
||||
|
||||
openfile->current_x = 0;
|
||||
@@ -189,7 +175,6 @@ void do_para_end(bool allow_update)
|
||||
inpar(openfile->current->next) &&
|
||||
!begpar(openfile->current->next)) {
|
||||
openfile->current = openfile->current->next;
|
||||
openfile->current_y++;
|
||||
}
|
||||
|
||||
if (openfile->current != openfile->filebot) {
|
||||
@@ -424,11 +409,8 @@ void do_up(bool scroll_only)
|
||||
|
||||
/* If we're at the top of the file, or if scroll_only is TRUE and
|
||||
* the top of the file is onscreen, get out. */
|
||||
if (openfile->current == openfile->fileage
|
||||
#ifndef NANO_TINY
|
||||
|| (scroll_only && openfile->edittop == openfile->fileage)
|
||||
#endif
|
||||
)
|
||||
if (openfile->current == openfile->fileage ||
|
||||
(scroll_only && openfile->edittop == openfile->fileage))
|
||||
return;
|
||||
|
||||
assert(ISSET(SOFTWRAP) || openfile->current_y == openfile->current->lineno - openfile->edittop->lineno);
|
||||
@@ -506,11 +488,9 @@ void do_down(bool scroll_only)
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
openfile->placewewant);
|
||||
|
||||
/* If scroll_only is FALSE and if we're on the last line of the
|
||||
* edit window, scroll the edit window down one line if we're in
|
||||
* smooth scrolling mode, or down half a page if we're not. If
|
||||
* scroll_only is TRUE, scroll the edit window down one line
|
||||
* unconditionally. */
|
||||
/* When the cursor was on the last line of the edit window (or when just
|
||||
* scrolling without moving the cursor), scroll the edit window down -- one
|
||||
* line if we're in smooth scrolling mode, and half a page otherwise. */
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->current_y == editwinrows - 1 || amount > 0 || scroll_only) {
|
||||
if (amount < 1 || scroll_only)
|
||||
@@ -593,7 +573,7 @@ void do_right(void)
|
||||
openfile->current_x = 0;
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP))
|
||||
openfile->current_y -= strlenpt(openfile->current->data) / COLS;
|
||||
openfile->current_y -= strlenpt(openfile->current->data) / editwincols;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
332
src/nano.c
332
src/nano.c
@@ -78,8 +78,6 @@ filestruct *copy_node(const filestruct *src)
|
||||
{
|
||||
filestruct *dst;
|
||||
|
||||
assert(src != NULL);
|
||||
|
||||
dst = (filestruct *)nmalloc(sizeof(filestruct));
|
||||
|
||||
dst->data = mallocstrcpy(NULL, src->data);
|
||||
@@ -96,8 +94,6 @@ filestruct *copy_node(const filestruct *src)
|
||||
/* Splice a new node into an existing linked list of filestructs. */
|
||||
void splice_node(filestruct *afterthis, filestruct *newnode)
|
||||
{
|
||||
assert(afterthis != NULL && newnode != NULL);
|
||||
|
||||
newnode->next = afterthis->next;
|
||||
newnode->prev = afterthis;
|
||||
if (afterthis->next != NULL)
|
||||
@@ -112,8 +108,6 @@ void splice_node(filestruct *afterthis, filestruct *newnode)
|
||||
/* Disconnect a node from a linked list of filestructs and delete it. */
|
||||
void unlink_node(filestruct *fileptr)
|
||||
{
|
||||
assert(fileptr != NULL);
|
||||
|
||||
if (fileptr->prev != NULL)
|
||||
fileptr->prev->next = fileptr->next;
|
||||
if (fileptr->next != NULL)
|
||||
@@ -129,8 +123,6 @@ void unlink_node(filestruct *fileptr)
|
||||
/* Free the data structures in the given node. */
|
||||
void delete_node(filestruct *fileptr)
|
||||
{
|
||||
assert(fileptr != NULL && fileptr->data != NULL);
|
||||
|
||||
free(fileptr->data);
|
||||
#ifndef DISABLE_COLOR
|
||||
free(fileptr->multidata);
|
||||
@@ -143,8 +135,6 @@ filestruct *copy_filestruct(const filestruct *src)
|
||||
{
|
||||
filestruct *head, *copy;
|
||||
|
||||
assert(src != NULL);
|
||||
|
||||
copy = copy_node(src);
|
||||
copy->prev = NULL;
|
||||
head = copy;
|
||||
@@ -237,7 +227,6 @@ partition *partition_filestruct(filestruct *top, size_t top_x,
|
||||
|
||||
/* Remove all text before top_x at the top of the partition. */
|
||||
charmove(top->data, top->data + top_x, strlen(top->data) - top_x + 1);
|
||||
align(&top->data);
|
||||
|
||||
/* Return the partition. */
|
||||
return p;
|
||||
@@ -289,7 +278,7 @@ void unpartition_filestruct(partition **p)
|
||||
* current filestruct to a filestruct beginning with file_top and ending
|
||||
* with file_bot. If no text is between (top, top_x) and (bot, bot_x),
|
||||
* don't do anything. */
|
||||
void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
|
||||
void extract_buffer(filestruct **file_top, filestruct **file_bot,
|
||||
filestruct *top, size_t top_x, filestruct *bot, size_t bot_x)
|
||||
{
|
||||
filestruct *top_save;
|
||||
@@ -364,14 +353,10 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
|
||||
}
|
||||
|
||||
/* Since the text has now been saved, remove it from the filestruct. */
|
||||
openfile->fileage = (filestruct *)nmalloc(sizeof(filestruct));
|
||||
openfile->fileage = make_new_node(NULL);
|
||||
openfile->fileage->data = mallocstrcpy(NULL, "");
|
||||
openfile->filebot = openfile->fileage;
|
||||
|
||||
#ifndef DISABLE_COLOR
|
||||
openfile->fileage->multidata = NULL;
|
||||
#endif
|
||||
|
||||
/* Restore the current line and cursor position. If the mark begins
|
||||
* inside the partition, set the beginning of the mark to where the
|
||||
* saved text used to start. */
|
||||
@@ -407,9 +392,9 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
|
||||
new_magicline();
|
||||
}
|
||||
|
||||
/* Copy all text from the given filestruct to the current filestruct
|
||||
/* Meld the given buffer into the current file buffer
|
||||
* at the current cursor position. */
|
||||
void copy_from_filestruct(filestruct *somebuffer)
|
||||
void ingraft_buffer(filestruct *somebuffer)
|
||||
{
|
||||
filestruct *top_save;
|
||||
size_t current_x_save = openfile->current_x;
|
||||
@@ -442,8 +427,8 @@ void copy_from_filestruct(filestruct *somebuffer)
|
||||
free_filestruct(openfile->fileage);
|
||||
|
||||
/* Put the top and bottom of the current filestruct at the top and
|
||||
* bottom of a copy of the passed buffer. */
|
||||
openfile->fileage = copy_filestruct(somebuffer);
|
||||
* bottom of the passed buffer. */
|
||||
openfile->fileage = somebuffer;
|
||||
openfile->filebot = openfile->fileage;
|
||||
while (openfile->filebot->next != NULL)
|
||||
openfile->filebot = openfile->filebot->next;
|
||||
@@ -480,11 +465,6 @@ void copy_from_filestruct(filestruct *somebuffer)
|
||||
/* Add the number of characters in the copied text to the file size. */
|
||||
openfile->totsize += get_totsize(openfile->fileage, openfile->filebot);
|
||||
|
||||
/* Update the current y-coordinate to account for the number of
|
||||
* lines the copied text has, less one since the first line will be
|
||||
* tacked onto the current line. */
|
||||
openfile->current_y += openfile->filebot->lineno - 1;
|
||||
|
||||
/* If we pasted onto the first line of the edit window, the corresponding
|
||||
* struct has been freed, so... point at the start of the copied text. */
|
||||
if (edittop_inside)
|
||||
@@ -504,6 +484,14 @@ void copy_from_filestruct(filestruct *somebuffer)
|
||||
new_magicline();
|
||||
}
|
||||
|
||||
/* Meld a copy of the given buffer into the current file buffer. */
|
||||
void copy_from_buffer(filestruct *somebuffer)
|
||||
{
|
||||
filestruct *the_copy = copy_filestruct(somebuffer);
|
||||
|
||||
ingraft_buffer(the_copy);
|
||||
}
|
||||
|
||||
/* Create a new openfilestruct node. */
|
||||
openfilestruct *make_new_opennode(void)
|
||||
{
|
||||
@@ -513,8 +501,7 @@ openfilestruct *make_new_opennode(void)
|
||||
/* Unlink a node from the rest of the openfilestruct, and delete it. */
|
||||
void unlink_opennode(openfilestruct *fileptr)
|
||||
{
|
||||
assert(fileptr != NULL && fileptr->prev != NULL && fileptr->next != NULL &&
|
||||
fileptr != fileptr->prev && fileptr != fileptr->next);
|
||||
assert(fileptr != fileptr->prev && fileptr != fileptr->next);
|
||||
|
||||
fileptr->prev->next = fileptr->next;
|
||||
fileptr->next->prev = fileptr->prev;
|
||||
@@ -525,8 +512,6 @@ void unlink_opennode(openfilestruct *fileptr)
|
||||
/* Free all the memory in the given open-file node. */
|
||||
void delete_opennode(openfilestruct *fileptr)
|
||||
{
|
||||
assert(fileptr != NULL && fileptr->filename != NULL && fileptr->fileage != NULL);
|
||||
|
||||
free(fileptr->filename);
|
||||
free_filestruct(fileptr->fileage);
|
||||
#ifndef NANO_TINY
|
||||
@@ -935,7 +920,7 @@ void version(void)
|
||||
printf(_(" GNU nano, version %s\n"), VERSION);
|
||||
#endif
|
||||
printf(" (C) 1999..2016 Free Software Foundation, Inc.\n");
|
||||
printf(_(" (C) 2014..%s the contributors to nano\n"), "2016");
|
||||
printf(_(" (C) 2014..%s the contributors to nano\n"), "2017");
|
||||
printf(
|
||||
_(" Email: nano@nano-editor.org Web: https://nano-editor.org/"));
|
||||
printf(_("\n Compiled options:"));
|
||||
@@ -1033,6 +1018,9 @@ void version(void)
|
||||
#ifdef DISABLE_TABCOMP
|
||||
printf(" --disable-tabcomp");
|
||||
#endif
|
||||
#ifndef ENABLE_WORDCOMPLETION
|
||||
printf(" --disable-wordcomp");
|
||||
#endif
|
||||
#ifdef DISABLE_WRAPPING
|
||||
printf(" --disable-wrapping");
|
||||
#endif
|
||||
@@ -1058,21 +1046,6 @@ void version(void)
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/* 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)
|
||||
{
|
||||
/* Warn that the current file has no name. */
|
||||
statusbar(_("No file name"));
|
||||
beep();
|
||||
|
||||
/* Ensure that we see the warning. */
|
||||
napms(1800);
|
||||
|
||||
curs_set(1);
|
||||
}
|
||||
|
||||
/* If the current file buffer has been modified, and the TEMP_FILE flag
|
||||
* isn't set, ask whether or not to save the file buffer. If the
|
||||
* TEMP_FILE flag is set and the current file has a name, save it
|
||||
@@ -1096,7 +1069,7 @@ void do_exit(void)
|
||||
/* If the TEMP_FILE flag is set, and the current file doesn't
|
||||
* have a name, warn the user before prompting for a name. */
|
||||
if (ISSET(TEMP_FILE))
|
||||
no_current_file_name_warning();
|
||||
warn_and_shortly_pause(_("No file name"));
|
||||
|
||||
i = do_yesno_prompt(FALSE, _("Save modified buffer? "
|
||||
"(Answering \"No\" will DISCARD changes.) "));
|
||||
@@ -1304,12 +1277,8 @@ RETSIGTYPE do_continue(int signal)
|
||||
* and restore the terminal to its previous state in the process. */
|
||||
regenerate_screen();
|
||||
#else
|
||||
/* Restore the terminal to its previous state. */
|
||||
/* Restore the state of the terminal and redraw the whole screen. */
|
||||
terminal_init();
|
||||
|
||||
/* Wipe statusbar; redraw titlebar and edit window (and help lines). */
|
||||
blank_statusbar();
|
||||
wnoutrefresh(bottomwin);
|
||||
total_refresh();
|
||||
#endif
|
||||
}
|
||||
@@ -1319,7 +1288,7 @@ RETSIGTYPE do_continue(int signal)
|
||||
RETSIGTYPE handle_sigwinch(int signal)
|
||||
{
|
||||
/* Let the input routine know that a SIGWINCH has occurred. */
|
||||
sigwinch_counter++;
|
||||
the_window_resized = TRUE;
|
||||
}
|
||||
|
||||
/* Reinitialize and redraw the screen completely. */
|
||||
@@ -1329,6 +1298,9 @@ void regenerate_screen(void)
|
||||
int fd, result = 0;
|
||||
struct winsize win;
|
||||
|
||||
/* Reset the trigger. */
|
||||
the_window_resized = FALSE;
|
||||
|
||||
if (tty == NULL)
|
||||
return;
|
||||
fd = open(tty, O_RDWR);
|
||||
@@ -1416,14 +1388,9 @@ void do_toggle(int flag)
|
||||
signal_init();
|
||||
break;
|
||||
case WHITESPACE_DISPLAY:
|
||||
titlebar(NULL);
|
||||
edit_refresh();
|
||||
break;
|
||||
titlebar(NULL); /* Fall through. */
|
||||
#ifndef DISABLE_COLOR
|
||||
case NO_COLOR_SYNTAX:
|
||||
#endif
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
case LINE_NUMBERS:
|
||||
#endif
|
||||
case SOFTWRAP:
|
||||
refresh_needed = TRUE;
|
||||
@@ -1432,14 +1399,7 @@ void do_toggle(int flag)
|
||||
|
||||
enabled = ISSET(flag);
|
||||
|
||||
if (flag == NO_HELP
|
||||
#ifndef DISABLE_WRAPPING
|
||||
|| flag == NO_WRAP
|
||||
#endif
|
||||
#ifndef DISABLE_COLOR
|
||||
|| flag == NO_COLOR_SYNTAX
|
||||
#endif
|
||||
)
|
||||
if (flag == NO_HELP || flag == NO_WRAP || flag == NO_COLOR_SYNTAX)
|
||||
enabled = !enabled;
|
||||
|
||||
statusline(HUSH, "%s %s", _(flagtostr(flag)),
|
||||
@@ -1553,18 +1513,18 @@ void terminal_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_KEY_DEFINED
|
||||
/* Ask ncurses for a keycode, or assign a default one. */
|
||||
int get_keycode(const char *keyname, const int standard)
|
||||
{
|
||||
#ifdef HAVE_KEY_DEFINED
|
||||
const char *keyvalue = tigetstr(keyname);
|
||||
|
||||
if (keyvalue == 0 || keyvalue == (char *)-1)
|
||||
return standard;
|
||||
else
|
||||
if (keyvalue != 0 && keyvalue != (char *)-1)
|
||||
return key_defined(keyvalue);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return standard;
|
||||
}
|
||||
|
||||
/* Say that an unbound key was struck, and if possible which one. */
|
||||
void unbound_key(int code)
|
||||
@@ -1682,7 +1642,9 @@ int do_input(bool allow_funcs)
|
||||
}
|
||||
}
|
||||
|
||||
if (have_shortcut) {
|
||||
if (!have_shortcut)
|
||||
pletion_line = NULL;
|
||||
else {
|
||||
const subnfunc *f = sctofunc(s);
|
||||
|
||||
if (ISSET(VIEW_MODE) && f && !f->viewok) {
|
||||
@@ -1699,6 +1661,10 @@ int do_input(bool allow_funcs)
|
||||
)
|
||||
preserve = TRUE;
|
||||
|
||||
#ifdef ENABLE_WORDCOMPLETION
|
||||
if (s->scfunc != complete_a_word)
|
||||
pletion_line = NULL;
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
if (s->scfunc == do_toggle_void) {
|
||||
do_toggle(s->toggle);
|
||||
@@ -1729,7 +1695,7 @@ int do_input(bool allow_funcs)
|
||||
#endif
|
||||
#ifndef DISABLE_COLOR
|
||||
if (f && !f->viewok)
|
||||
reset_multis(openfile->current, FALSE);
|
||||
check_the_multis(openfile->current);
|
||||
#endif
|
||||
if (!refresh_needed && (s->scfunc == do_delete || s->scfunc == do_backspace))
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
@@ -1759,77 +1725,70 @@ void xoff_complaint(void)
|
||||
/* Handle a mouse click on the edit window or the shortcut list. */
|
||||
int do_mouse(void)
|
||||
{
|
||||
int mouse_x, mouse_y;
|
||||
int retval = get_mouseinput(&mouse_x, &mouse_y, TRUE);
|
||||
int mouse_col, mouse_row;
|
||||
int retval = get_mouseinput(&mouse_col, &mouse_row, TRUE);
|
||||
|
||||
/* If the click is wrong or already handled, we're done. */
|
||||
if (retval != 0)
|
||||
/* The click is wrong or already handled. */
|
||||
return retval;
|
||||
|
||||
/* We can click on the edit window to move the cursor. */
|
||||
if (wmouse_trafo(edit, &mouse_y, &mouse_x, FALSE)) {
|
||||
bool sameline;
|
||||
/* Did they click on the line with the cursor? If they
|
||||
* clicked on the cursor, we set the mark. */
|
||||
/* If the click was in the edit window, put the cursor in that spot. */
|
||||
if (wmouse_trafo(edit, &mouse_row, &mouse_col, FALSE)) {
|
||||
bool sameline = (mouse_row == openfile->current_y);
|
||||
/* Whether the click was on the row where the cursor is. */
|
||||
filestruct *current_save = openfile->current;
|
||||
#ifndef NANO_TINY
|
||||
size_t current_x_save = openfile->current_x;
|
||||
#endif
|
||||
|
||||
sameline = (mouse_y == openfile->current_y);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "mouse_y = %d, current_y = %ld\n", mouse_y, (long)openfile->current_y);
|
||||
fprintf(stderr, "mouse_row = %d, current_y = %ld\n", mouse_row, (long)openfile->current_y);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
size_t i = 0;
|
||||
for (openfile->current = openfile->edittop;
|
||||
openfile->current->next && i < mouse_y;
|
||||
openfile->current = openfile->current->next, i++) {
|
||||
openfile->current_y = i;
|
||||
i += strlenpt(openfile->current->data) / COLS;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_mouse(): moving to current_y = %ld, index i = %lu\n",
|
||||
(long)openfile->current_y, (unsigned long)i);
|
||||
fprintf(stderr, " openfile->current->data = \"%s\"\n", openfile->current->data);
|
||||
#endif
|
||||
ssize_t current_row = 0;
|
||||
|
||||
if (i > mouse_y) {
|
||||
openfile->current = openfile->current->prev;
|
||||
openfile->current_x = actual_x(openfile->current->data, mouse_x + (mouse_y - openfile->current_y) * COLS);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_mouse(): i > mouse_y, mouse_x = %d, current_x to = %lu\n",
|
||||
mouse_x, (unsigned long)openfile->current_x);
|
||||
#endif
|
||||
} else {
|
||||
openfile->current_x = actual_x(openfile->current->data, mouse_x);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_mouse(): i <= mouse_y, mouse_x = %d, setting current_x to = %lu\n",
|
||||
mouse_x, (unsigned long)openfile->current_x);
|
||||
#endif
|
||||
openfile->current = openfile->edittop;
|
||||
|
||||
while (openfile->current->next != NULL && current_row < mouse_row) {
|
||||
current_row += strlenpt(openfile->current->data) / editwincols + 1;
|
||||
openfile->current = openfile->current->next;
|
||||
}
|
||||
|
||||
if (current_row > mouse_row) {
|
||||
openfile->current = openfile->current->prev;
|
||||
current_row -= strlenpt(openfile->current->data) / editwincols + 1;
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
((mouse_row - current_row) * editwincols) + mouse_col);
|
||||
} else
|
||||
openfile->current_x = actual_x(openfile->current->data, mouse_col);
|
||||
|
||||
openfile->current_y = current_row;
|
||||
ensure_line_is_visible();
|
||||
refresh_needed = TRUE;
|
||||
} else
|
||||
#endif /* NANO_TINY */
|
||||
{
|
||||
ssize_t current_row = openfile->current_y;
|
||||
|
||||
/* Move to where the click occurred. */
|
||||
for (; openfile->current_y < mouse_y && openfile->current !=
|
||||
openfile->filebot; openfile->current_y++)
|
||||
while (current_row < mouse_row && openfile->current->next != NULL) {
|
||||
openfile->current = openfile->current->next;
|
||||
for (; openfile->current_y > mouse_y && openfile->current !=
|
||||
openfile->fileage; openfile->current_y--)
|
||||
current_row++;
|
||||
}
|
||||
while (current_row > mouse_row && openfile->current->prev != NULL) {
|
||||
openfile->current = openfile->current->prev;
|
||||
current_row--;
|
||||
}
|
||||
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
get_page_start(xplustabs()) + mouse_x);
|
||||
get_page_start(xplustabs()) + mouse_col);
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Clicking where the cursor is toggles the mark, as does
|
||||
* clicking beyond the line length with the cursor at the end of
|
||||
* the line. */
|
||||
/* Clicking where the cursor is toggles the mark, as does clicking
|
||||
* beyond the line length with the cursor at the end of the line. */
|
||||
if (sameline && openfile->current_x == current_x_save)
|
||||
do_mark();
|
||||
else
|
||||
@@ -1837,7 +1796,8 @@ int do_mouse(void)
|
||||
/* The cursor moved; clean the cutbuffer on the next cut. */
|
||||
cutbuffer_reset();
|
||||
|
||||
edit_redraw(current_save);
|
||||
if (!ISSET(SOFTWRAP))
|
||||
edit_redraw(current_save);
|
||||
}
|
||||
|
||||
/* No more handling is needed. */
|
||||
@@ -1852,41 +1812,30 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
{
|
||||
size_t current_len, i = 0;
|
||||
#ifndef NANO_TINY
|
||||
size_t orig_lenpt = 0;
|
||||
size_t orig_rows = 0;
|
||||
#endif
|
||||
|
||||
char *char_buf = charalloc(mb_cur_max());
|
||||
int char_buf_len;
|
||||
|
||||
assert(openfile->current != NULL && openfile->current->data != NULL);
|
||||
int char_len;
|
||||
|
||||
current_len = strlen(openfile->current->data);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP))
|
||||
orig_lenpt = strlenpt(openfile->current->data);
|
||||
orig_rows = strlenpt(openfile->current->data) / editwincols;
|
||||
#endif
|
||||
|
||||
while (i < output_len) {
|
||||
/* If control codes are allowed, encode a verbatim null as a newline,
|
||||
* and let a verbatim ^J create a whole new line. */
|
||||
if (allow_cntrls) {
|
||||
if (output[i] == '\0')
|
||||
output[i] = '\n';
|
||||
else if (output[i] == '\n') {
|
||||
do_enter();
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/* Encode an embedded NUL byte as 0x0A. */
|
||||
if (output[i] == '\0')
|
||||
output[i] = '\n';
|
||||
|
||||
/* Get the next multibyte character. */
|
||||
char_buf_len = parse_mbchar(output + i, char_buf, NULL);
|
||||
char_len = parse_mbchar(output + i, char_buf, NULL);
|
||||
|
||||
i += char_buf_len;
|
||||
i += char_len;
|
||||
|
||||
/* If controls are not allowed, ignore an ASCII control character. */
|
||||
if (!allow_cntrls && is_ascii_cntrl_char(*(output + i - char_buf_len)))
|
||||
if (!allow_cntrls && is_ascii_cntrl_char(*(output + i - char_len)))
|
||||
continue;
|
||||
|
||||
/* If we're adding to the magicline, create a new magicline. */
|
||||
@@ -1900,13 +1849,13 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
|
||||
/* Make room for the new character and copy it into the line. */
|
||||
openfile->current->data = charealloc(openfile->current->data,
|
||||
current_len + char_buf_len + 1);
|
||||
charmove(openfile->current->data + openfile->current_x + char_buf_len,
|
||||
current_len + char_len + 1);
|
||||
charmove(openfile->current->data + openfile->current_x + char_len,
|
||||
openfile->current->data + openfile->current_x,
|
||||
current_len - openfile->current_x + 1);
|
||||
strncpy(openfile->current->data + openfile->current_x, char_buf,
|
||||
char_buf_len);
|
||||
current_len += char_buf_len;
|
||||
char_len);
|
||||
current_len += char_len;
|
||||
openfile->totsize++;
|
||||
set_modified();
|
||||
|
||||
@@ -1916,30 +1865,29 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
/* 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)
|
||||
openfile->mark_begin_x += char_buf_len;
|
||||
openfile->mark_begin_x += char_len;
|
||||
#endif
|
||||
|
||||
openfile->current_x += char_buf_len;
|
||||
openfile->current_x += char_len;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
update_undo(ADD);
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_WRAPPING
|
||||
/* If we're wrapping text, we need to call edit_refresh(). */
|
||||
if (!ISSET(NO_WRAP))
|
||||
if (do_wrap(openfile->current))
|
||||
refresh_needed = TRUE;
|
||||
/* If text gets wrapped, the edit window needs a refresh. */
|
||||
if (!ISSET(NO_WRAP) && do_wrap(openfile->current))
|
||||
refresh_needed = TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
ensure_line_is_visible();
|
||||
|
||||
/* Well, we might also need a full refresh if we've changed the
|
||||
* line length to be a new multiple of COLS. */
|
||||
/* If the number of screen rows that a softwrapped line occupies
|
||||
* has changed, we need a full refresh. */
|
||||
if (ISSET(SOFTWRAP) && refresh_needed == FALSE)
|
||||
if (strlenpt(openfile->current->data) / COLS != orig_lenpt / COLS)
|
||||
if ((strlenpt(openfile->current->data) / editwincols) != orig_rows)
|
||||
refresh_needed = TRUE;
|
||||
#endif
|
||||
|
||||
@@ -1948,7 +1896,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
#ifndef DISABLE_COLOR
|
||||
reset_multis(openfile->current, FALSE);
|
||||
check_the_multis(openfile->current);
|
||||
#endif
|
||||
|
||||
if (!refresh_needed)
|
||||
@@ -2081,6 +2029,10 @@ int main(int argc, char **argv)
|
||||
SET(NO_WRAP);
|
||||
#endif
|
||||
|
||||
/* If the executable's name starts with 'r', activate restricted mode. */
|
||||
if (*(tail(argv[0])) == 'r')
|
||||
SET(RESTRICTED);
|
||||
|
||||
while ((optchr =
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
getopt_long(argc, argv,
|
||||
@@ -2298,11 +2250,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* If the executable filename starts with 'r', enable restricted
|
||||
* mode. */
|
||||
if (*(tail(argv[0])) == 'r')
|
||||
SET(RESTRICTED);
|
||||
|
||||
/* If we're using restricted mode, disable suspending, backups,
|
||||
* rcfiles, and history files, since they all would allow reading
|
||||
* from or writing to files not specified on the command line. */
|
||||
@@ -2361,7 +2308,7 @@ int main(int argc, char **argv)
|
||||
alt_speller = NULL;
|
||||
#endif
|
||||
|
||||
do_rcfile();
|
||||
do_rcfiles();
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "After rebinding keys...\n");
|
||||
@@ -2580,14 +2527,12 @@ int main(int argc, char **argv)
|
||||
interface_color_pair[FUNCTION_TAG] = A_NORMAL;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_KEY_DEFINED
|
||||
/* Ask ncurses for the key codes for Control+Left/Right/Up/Down. */
|
||||
controlleft = get_keycode("kLFT5", CONTROL_LEFT);
|
||||
controlright = get_keycode("kRIT5", CONTROL_RIGHT);
|
||||
controlup = get_keycode("kUP5", CONTROL_UP);
|
||||
controldown = get_keycode("kDN5", CONTROL_DOWN);
|
||||
#endif
|
||||
#if !defined(NANO_TINY) && defined(HAVE_KEY_DEFINED)
|
||||
#ifndef NANO_TINY
|
||||
/* Ask for the codes for Shift+Control+Left/Right/Up/Down. */
|
||||
shiftcontrolleft = get_keycode("kLFT6", SHIFT_CONTROL_LEFT);
|
||||
shiftcontrolright = get_keycode("kRIT6", SHIFT_CONTROL_RIGHT);
|
||||
@@ -2613,7 +2558,8 @@ int main(int argc, char **argv)
|
||||
* non-option argument, and it is followed by at least one other
|
||||
* argument, the filename it applies to. */
|
||||
if (0 < optind && optind < argc - 1 && argv[optind][0] == '+') {
|
||||
parse_line_column(&argv[optind][1], &startline, &startcol);
|
||||
if (!parse_line_column(&argv[optind][1], &startline, &startcol))
|
||||
statusline(ALERT, _("Invalid line or column number"));
|
||||
optind++;
|
||||
}
|
||||
|
||||
@@ -2637,9 +2583,10 @@ int main(int argc, char **argv)
|
||||
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] == '+')
|
||||
parse_line_column(&argv[i][1], &iline, &icol);
|
||||
else {
|
||||
if (i < argc - 1 && argv[i][0] == '+') {
|
||||
if (!parse_line_column(&argv[i][1], &iline, &icol))
|
||||
statusline(ALERT, _("Invalid line or column number"));
|
||||
} else {
|
||||
/* If opening fails, don't try to position the cursor. */
|
||||
if (!open_buffer(argv[i], FALSE))
|
||||
continue;
|
||||
@@ -2654,7 +2601,7 @@ int main(int argc, char **argv)
|
||||
else if (ISSET(POS_HISTORY)) {
|
||||
ssize_t savedposline, savedposcol;
|
||||
/* If edited before, restore the last cursor position. */
|
||||
if (check_poshistory(argv[i], &savedposline, &savedposcol))
|
||||
if (has_old_position(argv[i], &savedposline, &savedposcol))
|
||||
do_gotolinecolumn(savedposline, savedposcol,
|
||||
FALSE, FALSE);
|
||||
}
|
||||
@@ -2688,7 +2635,7 @@ int main(int argc, char **argv)
|
||||
else if (ISSET(POS_HISTORY)) {
|
||||
ssize_t savedposline, savedposcol;
|
||||
/* If the file was edited before, restore the last cursor position. */
|
||||
if (check_poshistory(argv[optind], &savedposline, &savedposcol))
|
||||
if (has_old_position(argv[optind], &savedposline, &savedposcol))
|
||||
do_gotolinecolumn(savedposline, savedposcol, FALSE, FALSE);
|
||||
}
|
||||
#endif
|
||||
@@ -2704,44 +2651,43 @@ int main(int argc, char **argv)
|
||||
int needed_margin = digits(openfile->filebot->lineno) + 1;
|
||||
|
||||
/* Only enable line numbers when there is enough room for them. */
|
||||
if (ISSET(LINE_NUMBERS) && needed_margin < COLS - 3) {
|
||||
if (needed_margin != margin) {
|
||||
margin = needed_margin;
|
||||
editwincols = COLS - margin;
|
||||
/* The margin has changed -- schedule a full refresh. */
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
margin = 0;
|
||||
editwincols = COLS;
|
||||
if (!ISSET(LINE_NUMBERS) || needed_margin > COLS - 4)
|
||||
needed_margin = 0;
|
||||
|
||||
if (needed_margin != margin) {
|
||||
margin = needed_margin;
|
||||
editwincols = COLS - margin;
|
||||
/* The margin has changed -- schedule a full refresh. */
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (currmenu != MMAIN)
|
||||
display_main_list();
|
||||
|
||||
focusing = TRUE;
|
||||
lastmessage = HUSH;
|
||||
as_an_at = TRUE;
|
||||
|
||||
/* If constant cursor position display is on, and there are no
|
||||
* keys waiting in the input buffer, display the current cursor
|
||||
* position on the statusbar. */
|
||||
/* Update the displayed current cursor position only when there
|
||||
* are no keys waiting in the input buffer. */
|
||||
if (ISSET(CONST_UPDATE) && get_key_buffer_len() == 0)
|
||||
do_cursorpos(TRUE);
|
||||
|
||||
/* Refresh just the cursor position or the entire edit window. */
|
||||
if (!refresh_needed) {
|
||||
reset_cursor();
|
||||
wnoutrefresh(edit);
|
||||
} else
|
||||
edit_refresh();
|
||||
|
||||
/* Make sure the cursor is visible. */
|
||||
curs_set(1);
|
||||
|
||||
focusing = TRUE;
|
||||
|
||||
/* Forget any earlier statusbar x position. */
|
||||
reinit_statusbar_x();
|
||||
|
||||
/* Refresh either the entire edit window or just the cursor. */
|
||||
if (refresh_needed)
|
||||
edit_refresh();
|
||||
else {
|
||||
reset_cursor();
|
||||
curs_set(1);
|
||||
wnoutrefresh(edit);
|
||||
}
|
||||
|
||||
/* Read in and interpret keystrokes. */
|
||||
do_input(TRUE);
|
||||
}
|
||||
|
||||
@@ -288,6 +288,8 @@ typedef struct lintstruct {
|
||||
/* Whole line engulfed by the regex, start < me, end > me. */
|
||||
#define CSTARTENDHERE (1<<5)
|
||||
/* Regex starts and ends within this line. */
|
||||
#define CWOULDBE (1<<6)
|
||||
/* An unpaired start match on or before this line. */
|
||||
#endif /* !DISABLE_COLOR */
|
||||
|
||||
/* More structure types. */
|
||||
@@ -484,6 +486,13 @@ typedef struct subnfunc {
|
||||
/* Next item in the list. */
|
||||
} subnfunc;
|
||||
|
||||
#ifdef ENABLE_WORDCOMPLETION
|
||||
typedef struct completion_word {
|
||||
char *word;
|
||||
struct completion_word *next;
|
||||
} completion_word;
|
||||
#endif
|
||||
|
||||
/* The elements of the interface that can be colored differently. */
|
||||
enum
|
||||
{
|
||||
|
||||
132
src/prompt.c
132
src/prompt.c
@@ -34,10 +34,8 @@ static size_t statusbar_x = HIGHEST_POSITIVE;
|
||||
/* Read in a keystroke, interpret it if it is a shortcut or toggle, and
|
||||
* return it. Set ran_func to TRUE if we ran a function associated with
|
||||
* a shortcut key, and set finished to TRUE if we're done after running
|
||||
* or trying to run a function associated with a shortcut key.
|
||||
* refresh_func is the function we will call to refresh the edit window. */
|
||||
int do_statusbar_input(bool *ran_func, bool *finished,
|
||||
void (*refresh_func)(void))
|
||||
* or trying to run a function associated with a shortcut key. */
|
||||
int do_statusbar_input(bool *ran_func, bool *finished)
|
||||
{
|
||||
int input;
|
||||
/* The character we read in. */
|
||||
@@ -106,7 +104,7 @@ int do_statusbar_input(bool *ran_func, bool *finished,
|
||||
if ((have_shortcut || get_key_buffer_len() == 0) && kbinput != NULL) {
|
||||
/* Inject all characters in the input buffer at once, filtering out
|
||||
* control characters. */
|
||||
do_statusbar_output(kbinput, kbinput_len, TRUE, NULL);
|
||||
do_statusbar_output(kbinput, kbinput_len, TRUE);
|
||||
|
||||
/* Empty the input buffer. */
|
||||
kbinput_len = 0;
|
||||
@@ -117,10 +115,7 @@ int do_statusbar_input(bool *ran_func, bool *finished,
|
||||
if (have_shortcut) {
|
||||
if (s->scfunc == do_tab || s->scfunc == do_enter)
|
||||
;
|
||||
else if (s->scfunc == total_refresh) {
|
||||
total_redraw();
|
||||
refresh_func();
|
||||
} else if (s->scfunc == do_left)
|
||||
else if (s->scfunc == do_left)
|
||||
do_statusbar_left();
|
||||
else if (s->scfunc == do_right)
|
||||
do_statusbar_right();
|
||||
@@ -144,18 +139,7 @@ int do_statusbar_input(bool *ran_func, bool *finished,
|
||||
s->scfunc == do_backspace))
|
||||
;
|
||||
else if (s->scfunc == do_verbatim_input) {
|
||||
bool got_newline = FALSE;
|
||||
/* Whether we got a verbatim ^J. */
|
||||
|
||||
do_statusbar_verbatim_input(&got_newline);
|
||||
|
||||
/* If we got a verbatim ^J, remove it from the input buffer,
|
||||
* fake a press of Enter, and indicate that we're done. */
|
||||
if (got_newline) {
|
||||
get_input(NULL, 1);
|
||||
input = sc_seq_or(do_enter, 0);
|
||||
*finished = TRUE;
|
||||
}
|
||||
do_statusbar_verbatim_input();
|
||||
} else if (s->scfunc == do_cut_text_void)
|
||||
do_statusbar_cut_text();
|
||||
else if (s->scfunc == do_delete)
|
||||
@@ -207,11 +191,10 @@ int do_statusbar_mouse(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* The user typed input_len multibyte characters. Add them to the
|
||||
* statusbar prompt, setting got_newline to TRUE if we got a verbatim ^J,
|
||||
* and filtering out ASCII control characters if filtering is TRUE. */
|
||||
/* The user typed input_len multibyte characters. Add them to the answer,
|
||||
* filtering out ASCII control characters if filtering is TRUE. */
|
||||
void do_statusbar_output(int *the_input, size_t input_len,
|
||||
bool filtering, bool *got_newline)
|
||||
bool filtering)
|
||||
{
|
||||
char *output = charalloc(input_len + 1);
|
||||
char *char_buf = charalloc(mb_cur_max());
|
||||
@@ -225,18 +208,9 @@ void do_statusbar_output(int *the_input, size_t input_len,
|
||||
i = 0;
|
||||
|
||||
while (i < input_len) {
|
||||
/* When not filtering, convert nulls and stop at a newline. */
|
||||
if (!filtering) {
|
||||
if (output[i] == '\0')
|
||||
output[i] = '\n';
|
||||
else if (output[i] == '\n') {
|
||||
/* Put back the rest of the characters for reparsing,
|
||||
* indicate that we got a ^J and get out. */
|
||||
unparse_kbinput(output + i, input_len - i);
|
||||
*got_newline = TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* Encode any NUL byte as 0x0A. */
|
||||
if (output[i] == '\0')
|
||||
output[i] = '\n';
|
||||
|
||||
/* Interpret the next multibyte character. */
|
||||
char_len = parse_mbchar(output + i, char_buf, NULL);
|
||||
@@ -311,7 +285,6 @@ void do_statusbar_delete(void)
|
||||
|
||||
charmove(answer + statusbar_x, answer + statusbar_x + char_len,
|
||||
strlen(answer) - statusbar_x - char_len + 1);
|
||||
align(&answer);
|
||||
|
||||
update_the_statusbar();
|
||||
}
|
||||
@@ -375,19 +348,15 @@ void do_statusbar_prev_word(void)
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Get verbatim input, setting got_newline to TRUE if we get a ^J as
|
||||
* part of the verbatim input. */
|
||||
void do_statusbar_verbatim_input(bool *got_newline)
|
||||
/* Get verbatim input and inject it into the answer, without filtering. */
|
||||
void do_statusbar_verbatim_input(void)
|
||||
{
|
||||
int *kbinput;
|
||||
size_t kbinput_len;
|
||||
|
||||
/* Read in all the verbatim characters. */
|
||||
kbinput = get_verbatim_kbinput(bottomwin, &kbinput_len);
|
||||
|
||||
/* Display all the verbatim characters at once, not filtering out
|
||||
* control characters. */
|
||||
do_statusbar_output(kbinput, kbinput_len, FALSE, got_newline);
|
||||
do_statusbar_output(kbinput, kbinput_len, FALSE);
|
||||
}
|
||||
|
||||
/* Return the zero-based column position of the cursor in the answer. */
|
||||
@@ -464,9 +433,7 @@ void update_the_statusbar(void)
|
||||
|
||||
/* Get a string of input at the statusbar prompt. */
|
||||
functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
#ifndef DISABLE_TABCOMP
|
||||
bool allow_files, bool *listed,
|
||||
#endif
|
||||
#ifndef DISABLE_HISTORIES
|
||||
filestruct **history_list,
|
||||
#endif
|
||||
@@ -511,7 +478,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
/* Ensure the cursor is shown when waiting for input. */
|
||||
curs_set(1);
|
||||
|
||||
kbinput = do_statusbar_input(&ran_func, &finished, refresh_func);
|
||||
kbinput = do_statusbar_input(&ran_func, &finished);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If the window size changed, go reformat the prompt string. */
|
||||
@@ -537,7 +504,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
if (func == do_tab) {
|
||||
#ifndef DISABLE_HISTORIES
|
||||
if (history_list != NULL) {
|
||||
if (last_kbinput != sc_seq_or(do_tab, TAB_CODE))
|
||||
if (last_kbinput != the_code_for(do_tab, TAB_CODE))
|
||||
complete_len = strlen(answer);
|
||||
|
||||
if (complete_len > 0) {
|
||||
@@ -644,10 +611,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
* The allow_tabs parameter indicates whether we should allow tabs to be
|
||||
* interpreted. The allow_files parameter indicates whether we should
|
||||
* allow all files (as opposed to just directories) to be tab completed. */
|
||||
int do_prompt(bool allow_tabs,
|
||||
#ifndef DISABLE_TABCOMP
|
||||
bool allow_files,
|
||||
#endif
|
||||
int do_prompt(bool allow_tabs, bool allow_files,
|
||||
int menu, const char *curranswer,
|
||||
#ifndef DISABLE_HISTORIES
|
||||
filestruct **history_list,
|
||||
@@ -657,9 +621,7 @@ int do_prompt(bool allow_tabs,
|
||||
va_list ap;
|
||||
int retval;
|
||||
functionptrtype func = NULL;
|
||||
#ifndef DISABLE_TABCOMP
|
||||
bool listed = FALSE;
|
||||
#endif
|
||||
/* Save a possible current statusbar x position. */
|
||||
size_t was_statusbar_x = statusbar_x;
|
||||
|
||||
@@ -677,10 +639,7 @@ int do_prompt(bool allow_tabs,
|
||||
/* Reserve five columns for colon plus angles plus answer, ":<aa>". */
|
||||
null_at(&prompt, actual_x(prompt, (COLS < 5) ? 0 : COLS - 5));
|
||||
|
||||
func = acquire_an_answer(&retval, allow_tabs,
|
||||
#ifndef DISABLE_TABCOMP
|
||||
allow_files, &listed,
|
||||
#endif
|
||||
func = acquire_an_answer(&retval, allow_tabs, allow_files, &listed,
|
||||
#ifndef DISABLE_HISTORIES
|
||||
history_list,
|
||||
#endif
|
||||
@@ -729,30 +688,22 @@ int do_prompt(bool allow_tabs,
|
||||
int do_yesno_prompt(bool all, const char *msg)
|
||||
{
|
||||
int response = -2, width = 16;
|
||||
const char *yesstr; /* String of Yes characters accepted. */
|
||||
const char *nostr; /* Same for No. */
|
||||
const char *allstr; /* And All, surprise! */
|
||||
int oldmenu = currmenu;
|
||||
char *message = display_string(msg, 0, COLS, FALSE);
|
||||
|
||||
assert(msg != NULL);
|
||||
|
||||
/* yesstr, nostr, and allstr are strings of any length. Each string
|
||||
* consists of all single-byte characters accepted as valid
|
||||
* characters for that value. The first value will be the one
|
||||
* displayed in the shortcuts. */
|
||||
/* TRANSLATORS: For the next three strings, if possible, specify
|
||||
* the single-byte shortcuts for both your language and English.
|
||||
* For example, in French: "OoYy" for "Oui". */
|
||||
yesstr = _("Yy");
|
||||
nostr = _("Nn");
|
||||
allstr = _("Aa");
|
||||
* For example, in French: "OoYy", for both "Oui" and "Yes". */
|
||||
const char *yesstr = _("Yy");
|
||||
const char *nostr = _("Nn");
|
||||
const char *allstr = _("Aa");
|
||||
|
||||
do {
|
||||
/* The above three variables consist of all the single-byte characters
|
||||
* that are accepted for the corresponding answer. Of each variable,
|
||||
* the first character is displayed in the help lines. */
|
||||
|
||||
while (response == -2) {
|
||||
int kbinput;
|
||||
functionptrtype func;
|
||||
#ifndef DISABLE_MOUSE
|
||||
int mouse_x, mouse_y;
|
||||
#endif
|
||||
|
||||
if (!ISSET(NO_HELP)) {
|
||||
char shortstr[3];
|
||||
@@ -783,31 +734,28 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
onekey("^C", _("Cancel"), width);
|
||||
}
|
||||
|
||||
/* Color the statusbar over its full width and display the question. */
|
||||
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
|
||||
blank_statusbar();
|
||||
mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));
|
||||
|
||||
mvwaddnstr(bottomwin, 0, 0, message, actual_x(message, COLS - 1));
|
||||
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
|
||||
/* Refresh edit window and statusbar before getting input. */
|
||||
wnoutrefresh(edit);
|
||||
wnoutrefresh(bottomwin);
|
||||
|
||||
/* When not replacing, show the cursor. */
|
||||
if (!all)
|
||||
curs_set(1);
|
||||
|
||||
currmenu = MYESNO;
|
||||
kbinput = get_kbinput(bottomwin);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (kbinput == KEY_WINCH)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
func = func_from_key(&kbinput);
|
||||
|
||||
if (func == do_cancel)
|
||||
response = -1;
|
||||
#ifndef DISABLE_MOUSE
|
||||
else if (kbinput == KEY_MOUSE) {
|
||||
int mouse_x, mouse_y;
|
||||
/* We can click on the Yes/No/All shortcuts to select an answer. */
|
||||
if (get_mouseinput(&mouse_x, &mouse_y, FALSE) == 0 &&
|
||||
wmouse_trafo(bottomwin, &mouse_y, &mouse_x, FALSE) &&
|
||||
@@ -828,10 +776,7 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
}
|
||||
}
|
||||
#endif /* !DISABLE_MOUSE */
|
||||
else if (func == total_refresh) {
|
||||
total_redraw();
|
||||
continue;
|
||||
} else {
|
||||
else {
|
||||
/* Look for the kbinput in the Yes, No (and All) strings. */
|
||||
if (strchr(yesstr, kbinput) != NULL)
|
||||
response = 1;
|
||||
@@ -840,10 +785,9 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
else if (all && strchr(allstr, kbinput) != NULL)
|
||||
response = 2;
|
||||
}
|
||||
} while (response == -2);
|
||||
}
|
||||
|
||||
/* Restore the previously active menu. */
|
||||
bottombars(oldmenu);
|
||||
free(message);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
104
src/proto.h
104
src/proto.h
@@ -26,7 +26,7 @@
|
||||
|
||||
/* All external variables. See global.c for their descriptions. */
|
||||
#ifndef NANO_TINY
|
||||
extern volatile sig_atomic_t sigwinch_counter;
|
||||
extern volatile sig_atomic_t the_window_resized;
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
@@ -38,15 +38,15 @@ extern bool shift_held;
|
||||
|
||||
extern bool focusing;
|
||||
|
||||
extern bool as_an_at;
|
||||
|
||||
extern int margin;
|
||||
extern int editwincols;
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
extern int last_drawn_line;
|
||||
extern int last_line_y;
|
||||
#endif
|
||||
|
||||
extern message_type lastmessage;
|
||||
|
||||
extern filestruct *pletion_line;
|
||||
|
||||
extern int controlleft;
|
||||
extern int controlright;
|
||||
extern int controlup;
|
||||
@@ -76,7 +76,7 @@ extern WINDOW *topwin;
|
||||
extern WINDOW *edit;
|
||||
extern WINDOW *bottomwin;
|
||||
extern int editwinrows;
|
||||
extern int maxrows;
|
||||
extern int maxlines;
|
||||
|
||||
extern filestruct *cutbuffer;
|
||||
extern filestruct *cutbottom;
|
||||
@@ -209,7 +209,7 @@ bool is_cntrl_mbchar(const char *c);
|
||||
bool is_punct_mbchar(const char *c);
|
||||
bool is_word_mbchar(const char *c, bool allow_punct);
|
||||
char control_rep(const signed char c);
|
||||
char control_mbrep(const char *c);
|
||||
char control_mbrep(const char *c, bool isdata);
|
||||
int length_of_char(const char *c, int *width);
|
||||
int mbwidth(const char *c);
|
||||
int mb_cur_max(void);
|
||||
@@ -229,8 +229,8 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n);
|
||||
char *nstrcasestr(const char *haystack, const char *needle);
|
||||
#endif
|
||||
char *mbstrcasestr(const char *haystack, const char *needle);
|
||||
char *revstrstr(const char *haystack, const char *needle, const char
|
||||
*rev_start);
|
||||
char *revstrstr(const char *haystack, const char *needle,
|
||||
const char *pointer);
|
||||
char *revstrcasestr(const char *haystack, const char *needle, const char
|
||||
*rev_start);
|
||||
char *mbrevstrcasestr(const char *haystack, const char *needle, const
|
||||
@@ -266,7 +266,7 @@ 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 check_the_multis(filestruct *line);
|
||||
void alloc_multidata_if_needed(filestruct *fileptr);
|
||||
void precalc_multicolorinfo(void);
|
||||
#endif
|
||||
@@ -276,7 +276,7 @@ void cutbuffer_reset(void);
|
||||
bool keeping_cutbuffer(void);
|
||||
void cut_line(void);
|
||||
#ifndef NANO_TINY
|
||||
void cut_marked(void);
|
||||
void cut_marked(bool *right_side_up);
|
||||
void cut_to_eol(void);
|
||||
void cut_to_eof(void);
|
||||
#endif
|
||||
@@ -302,7 +302,8 @@ void switch_to_next_buffer_void(void);
|
||||
bool close_buffer(void);
|
||||
#endif
|
||||
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);
|
||||
void read_file(FILE *f, int fd, const char *filename, bool undoable,
|
||||
bool checkwritable);
|
||||
int open_file(const char *filename, bool newfie, bool quiet, FILE **f);
|
||||
char *get_next_filename(const char *name, const char *suffix);
|
||||
void do_insertfile_void(void);
|
||||
@@ -348,19 +349,19 @@ const char *tail(const char *path);
|
||||
#ifndef DISABLE_HISTORIES
|
||||
char *histfilename(void);
|
||||
void load_history(void);
|
||||
bool writehist(FILE *hist, filestruct *histhead);
|
||||
bool writehist(FILE *hist, const filestruct *head);
|
||||
void save_history(void);
|
||||
int check_dotnano(void);
|
||||
void load_poshistory(void);
|
||||
void save_poshistory(void);
|
||||
void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos);
|
||||
int check_poshistory(const char *file, ssize_t *line, ssize_t *column);
|
||||
bool has_old_position(const char *file, ssize_t *line, ssize_t *column);
|
||||
#endif
|
||||
|
||||
/* Some functions in global.c. */
|
||||
size_t length_of_list(int menu);
|
||||
const sc *first_sc_for(int menu, void (*func)(void));
|
||||
int sc_seq_or(void (*func)(void), int defaultval);
|
||||
int the_code_for(void (*func)(void), int defaultval);
|
||||
functionptrtype func_from_key(int *kbinput);
|
||||
void assign_keyinfo(sc *s, const char *keystring, const int keycode);
|
||||
void print_sclist(void);
|
||||
@@ -429,9 +430,10 @@ void renumber(filestruct *fileptr);
|
||||
partition *partition_filestruct(filestruct *top, size_t top_x,
|
||||
filestruct *bot, size_t bot_x);
|
||||
void unpartition_filestruct(partition **p);
|
||||
void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
|
||||
void extract_buffer(filestruct **file_top, filestruct **file_bot,
|
||||
filestruct *top, size_t top_x, filestruct *bot, size_t bot_x);
|
||||
void copy_from_filestruct(filestruct *somebuffer);
|
||||
void ingraft_buffer(filestruct *somebuffer);
|
||||
void copy_from_buffer(filestruct *somebuffer);
|
||||
openfilestruct *make_new_opennode(void);
|
||||
void unlink_opennode(openfilestruct *fileptr);
|
||||
void delete_opennode(openfilestruct *fileptr);
|
||||
@@ -456,7 +458,6 @@ void print_opt_full(const char *shortflag
|
||||
, const char *desc);
|
||||
void usage(void);
|
||||
void version(void);
|
||||
void no_current_file_name_warning(void);
|
||||
void do_exit(void);
|
||||
void close_and_go(void);
|
||||
void signal_init(void);
|
||||
@@ -481,14 +482,12 @@ int do_mouse(void);
|
||||
#endif
|
||||
void do_output(char *output, size_t output_len, bool allow_cntrls);
|
||||
|
||||
/* All functions in prompt.c. */
|
||||
int do_statusbar_input(bool *ran_func, bool *finished,
|
||||
void (*refresh_func)(void));
|
||||
/* Most functions in prompt.c. */
|
||||
#ifndef DISABLE_MOUSE
|
||||
int do_statusbar_mouse(void);
|
||||
#endif
|
||||
void do_statusbar_output(int *the_input, size_t input_len,
|
||||
bool filtering, bool *got_newline);
|
||||
bool filtering);
|
||||
void do_statusbar_home(void);
|
||||
void do_statusbar_end(void);
|
||||
void do_statusbar_left(void);
|
||||
@@ -500,16 +499,13 @@ void do_statusbar_cut_text(void);
|
||||
void do_statusbar_prev_word(void);
|
||||
void do_statusbar_next_word(void);
|
||||
#endif
|
||||
void do_statusbar_verbatim_input(bool *got_newline);
|
||||
void do_statusbar_verbatim_input(void);
|
||||
size_t statusbar_xplustabs(void);
|
||||
size_t get_statusbar_page_start(size_t start_col, size_t column);
|
||||
void reinit_statusbar_x(void);
|
||||
void reset_statusbar_cursor(void);
|
||||
void update_the_statusbar(void);
|
||||
int do_prompt(bool allow_tabs,
|
||||
#ifndef DISABLE_TABCOMP
|
||||
bool allow_files,
|
||||
#endif
|
||||
int do_prompt(bool allow_tabs, bool allow_files,
|
||||
int menu, const char *curranswer,
|
||||
#ifndef DISABLE_HISTORIES
|
||||
filestruct **history_list,
|
||||
@@ -522,22 +518,12 @@ int do_yesno_prompt(bool all, const char *msg);
|
||||
char *parse_next_word(char *ptr);
|
||||
#endif
|
||||
#ifndef DISABLE_NANORC
|
||||
void rcfile_error(const char *msg, ...);
|
||||
char *parse_argument(char *ptr);
|
||||
#ifndef DISABLE_COLOR
|
||||
char *parse_next_regex(char *ptr);
|
||||
void parse_syntax(char *ptr);
|
||||
void parse_includes(char *ptr);
|
||||
short color_to_short(const char *colorname, bool *bright);
|
||||
bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright);
|
||||
void grab_and_store(const char *kind, char *ptr, regexlisttype **storage);
|
||||
#endif
|
||||
void parse_rcfile(FILE *rcstream
|
||||
#ifndef DISABLE_COLOR
|
||||
, bool syntax_only
|
||||
#endif
|
||||
);
|
||||
void do_rcfile(void);
|
||||
void parse_rcfile(FILE *rcstream, bool syntax_only);
|
||||
void do_rcfiles(void);
|
||||
#endif /* !DISABLE_NANORC */
|
||||
|
||||
/* All functions in search.c. */
|
||||
@@ -548,8 +534,8 @@ void regexp_cleanup(void);
|
||||
void not_found_msg(const char *str);
|
||||
void search_replace_abort(void);
|
||||
int search_init(bool replacing, bool use_answer);
|
||||
int findnextstr(const char *needle, bool whole_word_only, size_t *match_len,
|
||||
const filestruct *begin, size_t begin_x);
|
||||
int findnextstr(const char *needle, bool whole_word_only, bool have_region,
|
||||
size_t *match_len, bool skipone, const filestruct *begin, size_t begin_x);
|
||||
void do_search(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_findprevious(void);
|
||||
@@ -603,18 +589,25 @@ void do_tab(void);
|
||||
void do_indent(ssize_t cols);
|
||||
void do_indent_void(void);
|
||||
void do_unindent(void);
|
||||
void do_undo(void);
|
||||
void do_redo(void);
|
||||
#endif
|
||||
bool white_string(const char *s);
|
||||
#ifdef ENABLE_COMMENT
|
||||
void do_comment(void);
|
||||
bool comment_line(undo_type action, filestruct *f, const char *comment_seq);
|
||||
#endif
|
||||
void do_undo(void);
|
||||
void do_redo(void);
|
||||
void do_enter(void);
|
||||
#ifndef NANO_TINY
|
||||
RETSIGTYPE cancel_command(int signal);
|
||||
bool execute_command(const char *command);
|
||||
void discard_until(const undo *thisitem, openfilestruct *thefile);
|
||||
void add_undo(undo_type action);
|
||||
#ifndef DISABLE_COMMENT
|
||||
void update_comment_undo(ssize_t lineno);
|
||||
#endif
|
||||
void update_undo(undo_type action);
|
||||
#endif /* !NANO_TINY */
|
||||
#ifndef DISABLE_WRAPPING
|
||||
void wrap_reset(void);
|
||||
bool do_wrap(filestruct *line);
|
||||
@@ -658,13 +651,16 @@ void do_formatter(void);
|
||||
void do_wordlinechar_count(void);
|
||||
#endif
|
||||
void do_verbatim_input(void);
|
||||
void complete_a_word(void);
|
||||
|
||||
/* All functions in utils.c. */
|
||||
void get_homedir(void);
|
||||
int digits(int n);
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
int digits(ssize_t n);
|
||||
#endif
|
||||
bool parse_num(const char *str, ssize_t *val);
|
||||
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column);
|
||||
void align(char **str);
|
||||
void snuggly_fit(char **str);
|
||||
void null_at(char **data, size_t index);
|
||||
void unsunder(char *str, size_t true_len);
|
||||
void sunder(char *str);
|
||||
@@ -700,16 +696,11 @@ 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(const undo *thisitem, openfilestruct *thefile);
|
||||
void add_undo(undo_type action);
|
||||
void update_undo(undo_type action);
|
||||
#ifndef DISABLE_COMMENT
|
||||
void update_comment_undo(ssize_t lineno);
|
||||
bool comment_line(undo_type action, filestruct *f, const char *comment_seq);
|
||||
#endif
|
||||
#endif
|
||||
size_t get_totsize(const filestruct *begin, const filestruct *end);
|
||||
#ifndef NANO_TINY
|
||||
filestruct *fsfromline(ssize_t lineno);
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
void dump_filestruct(const filestruct *inptr);
|
||||
void dump_filestruct_reverse(void);
|
||||
@@ -738,7 +729,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count);
|
||||
int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts);
|
||||
#endif
|
||||
const sc *get_shortcut(int *kbinput);
|
||||
void blank_line(WINDOW *win, int y, int x, int n);
|
||||
void blank_row(WINDOW *win, int y, int x, int n);
|
||||
void blank_titlebar(void);
|
||||
void blank_edit(void);
|
||||
void blank_statusbar(void);
|
||||
@@ -749,15 +740,16 @@ char *display_string(const char *buf, size_t start_col, size_t span,
|
||||
void titlebar(const char *path);
|
||||
extern void set_modified(void);
|
||||
void statusbar(const char *msg);
|
||||
void warn_and_shortly_pause(const char *msg);
|
||||
void statusline(message_type importance, const char *msg, ...);
|
||||
void bottombars(int menu);
|
||||
void onekey(const char *keystroke, const char *desc, int length);
|
||||
void reset_cursor(void);
|
||||
void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
line, size_t start);
|
||||
void edit_draw(filestruct *fileptr, const char *converted,
|
||||
int line, size_t from_col);
|
||||
int update_line(filestruct *fileptr, size_t index);
|
||||
bool need_horizontal_scroll(const size_t old_column, const size_t new_column);
|
||||
void edit_scroll(scroll_dir direction, ssize_t nlines);
|
||||
void edit_scroll(scroll_dir direction, int nrows);
|
||||
void edit_redraw(filestruct *old_current);
|
||||
void edit_refresh(void);
|
||||
void adjust_viewport(update_type location);
|
||||
|
||||
178
src/rcfile.c
178
src/rcfile.c
@@ -33,6 +33,10 @@
|
||||
|
||||
#ifndef DISABLE_NANORC
|
||||
|
||||
#ifndef RCFILE_NAME
|
||||
#define RCFILE_NAME ".nanorc"
|
||||
#endif
|
||||
|
||||
static const rcoption rcopts[] = {
|
||||
{"boldtext", BOLD_TEXT},
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
@@ -526,35 +530,40 @@ void parse_binding(char *ptr, bool dobind)
|
||||
free(keycopy);
|
||||
}
|
||||
|
||||
/* Verify that the given file is not a folder nor a device. */
|
||||
bool is_good_file(char *file)
|
||||
{
|
||||
struct stat rcinfo;
|
||||
|
||||
/* If the thing exists, it may not be a directory nor a device. */
|
||||
if (stat(file, &rcinfo) != -1 && (S_ISDIR(rcinfo.st_mode) ||
|
||||
S_ISCHR(rcinfo.st_mode) || S_ISBLK(rcinfo.st_mode))) {
|
||||
rcfile_error(S_ISDIR(rcinfo.st_mode) ? _("\"%s\" is a directory") :
|
||||
_("\"%s\" is a device file"), file);
|
||||
return FALSE;
|
||||
} else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_COLOR
|
||||
/* Read and parse one included syntax file. */
|
||||
static void parse_one_include(char *file)
|
||||
{
|
||||
struct stat rcinfo;
|
||||
FILE *rcstream;
|
||||
|
||||
/* Can't get the specified file's full path because it may screw up
|
||||
* our cwd depending on the parent directories' permissions (see
|
||||
* Savannah bug #25297). */
|
||||
|
||||
/* Don't open directories, character files, or block files. */
|
||||
if (stat(file, &rcinfo) != -1) {
|
||||
if (S_ISDIR(rcinfo.st_mode) || S_ISCHR(rcinfo.st_mode) ||
|
||||
S_ISBLK(rcinfo.st_mode)) {
|
||||
rcfile_error(S_ISDIR(rcinfo.st_mode) ?
|
||||
_("\"%s\" is a directory") :
|
||||
_("\"%s\" is a device file"), file);
|
||||
}
|
||||
}
|
||||
if (!is_good_file(file))
|
||||
return;
|
||||
|
||||
/* Open the new syntax file. */
|
||||
if ((rcstream = fopen(file, "rb")) == NULL) {
|
||||
rcfile_error(_("Error reading %s: %s"), file,
|
||||
strerror(errno));
|
||||
/* Open the included syntax file. */
|
||||
rcstream = fopen(file, "rb");
|
||||
|
||||
if (rcstream == NULL) {
|
||||
rcfile_error(_("Error reading %s: %s"), file, strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
/* Use the name and line number position of the new syntax file
|
||||
/* Use the name and line number position of the included syntax file
|
||||
* while parsing it, so we can know where any errors in it are. */
|
||||
nanorc = file;
|
||||
lineno = 0;
|
||||
@@ -585,8 +594,7 @@ void parse_includes(char *ptr)
|
||||
for (i = 0; i < files.gl_pathc; ++i)
|
||||
parse_one_include(files.gl_pathv[i]);
|
||||
} else
|
||||
rcfile_error(_("Error expanding %s: %s"), option,
|
||||
strerror(errno));
|
||||
rcfile_error(_("Error expanding %s: %s"), option, strerror(errno));
|
||||
|
||||
globfree(&files);
|
||||
free(expanded);
|
||||
@@ -640,7 +648,7 @@ void parse_colors(char *ptr, int rex_flags)
|
||||
{
|
||||
short fg, bg;
|
||||
bool bright = FALSE;
|
||||
char *fgstr;
|
||||
char *item;
|
||||
|
||||
assert(ptr != NULL);
|
||||
|
||||
@@ -656,9 +664,9 @@ void parse_colors(char *ptr, int rex_flags)
|
||||
return;
|
||||
}
|
||||
|
||||
fgstr = ptr;
|
||||
item = ptr;
|
||||
ptr = parse_next_word(ptr);
|
||||
if (!parse_color_names(fgstr, &fg, &bg, &bright))
|
||||
if (!parse_color_names(item, &fg, &bg, &bright))
|
||||
return;
|
||||
|
||||
if (*ptr == '\0') {
|
||||
@@ -688,12 +696,16 @@ void parse_colors(char *ptr, int rex_flags)
|
||||
continue;
|
||||
}
|
||||
|
||||
fgstr = ++ptr;
|
||||
item = ++ptr;
|
||||
ptr = parse_next_regex(ptr);
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
|
||||
goodstart = nregcomp(fgstr, rex_flags);
|
||||
if (*item == '\0') {
|
||||
rcfile_error(N_("Empty regex string"));
|
||||
goodstart = FALSE;
|
||||
} else
|
||||
goodstart = nregcomp(item, rex_flags);
|
||||
|
||||
/* If the starting regex is valid, initialize a new color struct,
|
||||
* and hook it in at the tail of the linked list. */
|
||||
@@ -705,7 +717,7 @@ void parse_colors(char *ptr, int rex_flags)
|
||||
newcolor->bright = bright;
|
||||
newcolor->rex_flags = rex_flags;
|
||||
|
||||
newcolor->start_regex = mallocstrcpy(NULL, fgstr);
|
||||
newcolor->start_regex = mallocstrcpy(NULL, item);
|
||||
newcolor->start = NULL;
|
||||
|
||||
newcolor->end_regex = NULL;
|
||||
@@ -738,19 +750,24 @@ void parse_colors(char *ptr, int rex_flags)
|
||||
continue;
|
||||
}
|
||||
|
||||
fgstr = ++ptr;
|
||||
item = ++ptr;
|
||||
ptr = parse_next_regex(ptr);
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
|
||||
if (*item == '\0') {
|
||||
rcfile_error(N_("Empty regex string"));
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If the start regex was invalid, skip past the end regex
|
||||
* to stay in sync. */
|
||||
if (!goodstart)
|
||||
continue;
|
||||
|
||||
/* If it's valid, save the ending regex string. */
|
||||
if (nregcomp(fgstr, rex_flags))
|
||||
newcolor->end_regex = mallocstrcpy(NULL, fgstr);
|
||||
if (nregcomp(item, rex_flags))
|
||||
newcolor->end_regex = mallocstrcpy(NULL, item);
|
||||
|
||||
/* Lame way to skip another static counter. */
|
||||
newcolor->id = live_syntax->nmultis;
|
||||
@@ -904,8 +921,8 @@ void pick_up_name(const char *kind, char *ptr, char **storage)
|
||||
}
|
||||
#endif /* !DISABLE_COLOR */
|
||||
|
||||
/* Check whether the user has unmapped every shortcut for a
|
||||
* sequence we consider 'vital', like the exit function. */
|
||||
/* Verify that the user has not unmapped every shortcut for a
|
||||
* function that we consider 'vital' (such as "Exit"). */
|
||||
static void check_vitals_mapped(void)
|
||||
{
|
||||
subnfunc *f;
|
||||
@@ -932,13 +949,9 @@ static void check_vitals_mapped(void)
|
||||
}
|
||||
|
||||
/* Parse the rcfile, once it has been opened successfully at rcstream,
|
||||
* and close it afterwards. If syntax_only is TRUE, only allow the file
|
||||
* to contain color syntax commands. */
|
||||
void parse_rcfile(FILE *rcstream
|
||||
#ifndef DISABLE_COLOR
|
||||
, bool syntax_only
|
||||
#endif
|
||||
)
|
||||
* and close it afterwards. If syntax_only is TRUE, allow the file to
|
||||
* to contain only color syntax commands. */
|
||||
void parse_rcfile(FILE *rcstream, bool syntax_only)
|
||||
{
|
||||
char *buf = NULL;
|
||||
ssize_t len;
|
||||
@@ -1115,7 +1128,7 @@ void parse_rcfile(FILE *rcstream
|
||||
#endif
|
||||
/* Make sure the option argument is a valid multibyte string. */
|
||||
if (!is_valid_mbstring(option)) {
|
||||
rcfile_error(N_("Option is not a valid multibyte string"));
|
||||
rcfile_error(N_("Argument is not a valid multibyte string"));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1144,7 +1157,8 @@ void parse_rcfile(FILE *rcstream
|
||||
option);
|
||||
wrap_at = -CHARS_FROM_EOL;
|
||||
} else
|
||||
free(option);
|
||||
UNSET(NO_WRAP);
|
||||
free(option);
|
||||
} else
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
@@ -1205,8 +1219,8 @@ void parse_rcfile(FILE *rcstream
|
||||
rcfile_error(N_("Requested tab size \"%s\" is invalid"),
|
||||
option);
|
||||
tabsize = -1;
|
||||
} else
|
||||
free(option);
|
||||
}
|
||||
free(option);
|
||||
} else
|
||||
assert(FALSE);
|
||||
}
|
||||
@@ -1223,45 +1237,43 @@ void parse_rcfile(FILE *rcstream
|
||||
fclose(rcstream);
|
||||
lineno = 0;
|
||||
|
||||
check_vitals_mapped();
|
||||
return;
|
||||
}
|
||||
|
||||
/* The main rcfile function. It tries to open the system-wide rcfile,
|
||||
* followed by the current user's rcfile. */
|
||||
void do_rcfile(void)
|
||||
/* Read and interpret one of the two nanorc files. */
|
||||
void parse_one_nanorc(void)
|
||||
{
|
||||
struct stat rcinfo;
|
||||
FILE *rcstream;
|
||||
|
||||
nanorc = mallocstrcpy(nanorc, SYSCONFDIR "/nanorc");
|
||||
|
||||
/* Don't open directories, character files, or block files. */
|
||||
if (stat(nanorc, &rcinfo) != -1) {
|
||||
if (S_ISDIR(rcinfo.st_mode) || S_ISCHR(rcinfo.st_mode) ||
|
||||
S_ISBLK(rcinfo.st_mode))
|
||||
rcfile_error(S_ISDIR(rcinfo.st_mode) ?
|
||||
_("\"%s\" is a directory") :
|
||||
_("\"%s\" is a device file"), nanorc);
|
||||
}
|
||||
/* Don't try to open directories nor devices. */
|
||||
if (!is_good_file(nanorc))
|
||||
return;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Parsing file \"%s\"\n", nanorc);
|
||||
fprintf(stderr, "Going to parse file \"%s\"\n", nanorc);
|
||||
#endif
|
||||
|
||||
/* Try to open the system-wide nanorc. */
|
||||
rcstream = fopen(nanorc, "rb");
|
||||
if (rcstream != NULL)
|
||||
parse_rcfile(rcstream
|
||||
#ifndef DISABLE_COLOR
|
||||
, FALSE
|
||||
#endif
|
||||
);
|
||||
|
||||
/* If opening the file succeeded, parse it. Otherwise, only
|
||||
* complain if the file actually exists. */
|
||||
if (rcstream != NULL)
|
||||
parse_rcfile(rcstream, FALSE);
|
||||
else if (errno != ENOENT)
|
||||
rcfile_error(N_("Error reading %s: %s"), nanorc, strerror(errno));
|
||||
}
|
||||
|
||||
/* First read the system-wide rcfile, then the user's rcfile. */
|
||||
void do_rcfiles(void)
|
||||
{
|
||||
nanorc = mallocstrcpy(nanorc, SYSCONFDIR "/nanorc");
|
||||
|
||||
/* Process the system-wide nanorc. */
|
||||
parse_one_nanorc();
|
||||
|
||||
/* When configured with --disable-wrapping-as-root, turn wrapping off
|
||||
* for root, so that only root's .nanorc or --fill can turn it on. */
|
||||
#ifdef DISABLE_ROOTWRAPPING
|
||||
/* We've already read SYSCONFDIR/nanorc, if it's there. If we're
|
||||
* root, and --disable-wrapping-as-root is used, turn wrapping off
|
||||
* now. */
|
||||
if (geteuid() == NANO_ROOT_UID)
|
||||
SET(NO_WRAP);
|
||||
#endif
|
||||
@@ -1271,38 +1283,16 @@ void do_rcfile(void)
|
||||
if (homedir == NULL)
|
||||
rcfile_error(N_("I can't find my home directory! Wah!"));
|
||||
else {
|
||||
#ifndef RCFILE_NAME
|
||||
#define RCFILE_NAME ".nanorc"
|
||||
#endif
|
||||
nanorc = charealloc(nanorc, strlen(homedir) + strlen(RCFILE_NAME) + 2);
|
||||
sprintf(nanorc, "%s/%s", homedir, RCFILE_NAME);
|
||||
|
||||
/* Don't open directories, character files, or block files. */
|
||||
if (stat(nanorc, &rcinfo) != -1) {
|
||||
if (S_ISDIR(rcinfo.st_mode) || S_ISCHR(rcinfo.st_mode) ||
|
||||
S_ISBLK(rcinfo.st_mode))
|
||||
rcfile_error(S_ISDIR(rcinfo.st_mode) ?
|
||||
_("\"%s\" is a directory") :
|
||||
_("\"%s\" is a device file"), nanorc);
|
||||
}
|
||||
|
||||
/* Try to open the current user's nanorc. */
|
||||
rcstream = fopen(nanorc, "rb");
|
||||
if (rcstream == NULL) {
|
||||
/* Don't complain about the file's not existing. */
|
||||
if (errno != ENOENT)
|
||||
rcfile_error(N_("Error reading %s: %s"), nanorc,
|
||||
strerror(errno));
|
||||
} else
|
||||
parse_rcfile(rcstream
|
||||
#ifndef DISABLE_COLOR
|
||||
, FALSE
|
||||
#endif
|
||||
);
|
||||
/* Process the current user's nanorc. */
|
||||
parse_one_nanorc();
|
||||
}
|
||||
|
||||
check_vitals_mapped();
|
||||
|
||||
free(nanorc);
|
||||
nanorc = NULL;
|
||||
|
||||
if (errors && !ISSET(QUIET)) {
|
||||
errors = FALSE;
|
||||
|
||||
236
src/search.c
236
src/search.c
@@ -3,7 +3,7 @@
|
||||
* *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
|
||||
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2015, 2016 Benno Schulenberg *
|
||||
* Copyright (C) 2015, 2016, 2017 Benno Schulenberg *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published *
|
||||
@@ -39,22 +39,19 @@ static bool history_changed = FALSE;
|
||||
static bool regexp_compiled = FALSE;
|
||||
/* Have we compiled any regular expressions? */
|
||||
|
||||
/* Compile the regular expression regexp to see if it's valid. Return
|
||||
* TRUE if it is, or FALSE otherwise. */
|
||||
/* Compile the given regular expression and store it in search_regexp.
|
||||
* Return TRUE if the expression is valid, and FALSE otherwise. */
|
||||
bool regexp_init(const char *regexp)
|
||||
{
|
||||
int rc;
|
||||
|
||||
assert(!regexp_compiled);
|
||||
|
||||
rc = regcomp(&search_regexp, fixbounds(regexp),
|
||||
int value = regcomp(&search_regexp, fixbounds(regexp),
|
||||
NANO_REG_EXTENDED | (ISSET(CASE_SENSITIVE) ? 0 : REG_ICASE));
|
||||
|
||||
if (rc != 0) {
|
||||
size_t len = regerror(rc, &search_regexp, NULL, 0);
|
||||
/* If regex compilation failed, show the error message. */
|
||||
if (value != 0) {
|
||||
size_t len = regerror(value, &search_regexp, NULL, 0);
|
||||
char *str = charalloc(len);
|
||||
|
||||
regerror(rc, &search_regexp, str, len);
|
||||
regerror(value, &search_regexp, str, len);
|
||||
statusline(ALERT, _("Bad regex \"%s\": %s"), regexp, str);
|
||||
free(str);
|
||||
|
||||
@@ -103,7 +100,7 @@ void search_replace_abort(void)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->mark_set)
|
||||
edit_refresh();
|
||||
refresh_needed = TRUE;
|
||||
#endif
|
||||
#ifdef HAVE_REGEX_H
|
||||
regexp_cleanup();
|
||||
@@ -150,10 +147,7 @@ int search_init(bool replacing, bool use_answer)
|
||||
buf = mallocstrcpy(NULL, "");
|
||||
|
||||
/* This is now one simple call. It just does a lot. */
|
||||
i = do_prompt(FALSE,
|
||||
#ifndef DISABLE_TABCOMP
|
||||
TRUE,
|
||||
#endif
|
||||
i = do_prompt(FALSE, FALSE,
|
||||
replacing ? MREPLACE : MWHEREIS, backupstring,
|
||||
#ifndef DISABLE_HISTORIES
|
||||
&search_history,
|
||||
@@ -237,32 +231,23 @@ int search_init(bool replacing, bool use_answer)
|
||||
* where we first started searching, at column begin_x. Return 1 when we
|
||||
* found something, 0 when nothing, and -2 on cancel. When match_len is
|
||||
* not NULL, set it to the length of the found string, if any. */
|
||||
int findnextstr(const char *needle, bool whole_word_only, size_t *match_len,
|
||||
const filestruct *begin, size_t begin_x)
|
||||
int findnextstr(const char *needle, bool whole_word_only, bool have_region,
|
||||
size_t *match_len, bool skipone, const filestruct *begin, size_t begin_x)
|
||||
{
|
||||
size_t found_len;
|
||||
/* The length of the match we find. */
|
||||
size_t found_len = strlen(needle);
|
||||
/* The length of a match -- will be recomputed for a regex. */
|
||||
int feedback = 0;
|
||||
/* When bigger than zero, show and wipe the "Searching..." message. */
|
||||
filestruct *fileptr = openfile->current;
|
||||
const char *rev_start = fileptr->data, *found = NULL;
|
||||
filestruct *line = openfile->current;
|
||||
/* The line that we will search through now. */
|
||||
const char *from = line->data + openfile->current_x;
|
||||
/* The point in the line from where we start searching. */
|
||||
const char *found = NULL;
|
||||
/* A pointer to the location of the match, if any. */
|
||||
size_t found_x;
|
||||
/* The x coordinate of a found occurrence. */
|
||||
time_t lastkbcheck = time(NULL);
|
||||
|
||||
/* rev_start might end up 1 character before the start or after the
|
||||
* end of the line. This won't be a problem because strstrwrapper()
|
||||
* will return immediately and say that no match was found, and
|
||||
* rev_start will be properly set when the search continues on the
|
||||
* previous or next line. */
|
||||
if (ISSET(BACKWARDS_SEARCH)) {
|
||||
if (openfile->current_x == 0)
|
||||
rev_start += -1;
|
||||
else
|
||||
rev_start += move_mbleft(fileptr->data, openfile->current_x);
|
||||
} else
|
||||
rev_start += move_mbright(fileptr->data, openfile->current_x);
|
||||
|
||||
enable_nodelay();
|
||||
|
||||
if (begin == NULL)
|
||||
@@ -293,32 +278,41 @@ int findnextstr(const char *needle, bool whole_word_only, size_t *match_len,
|
||||
}
|
||||
|
||||
/* Search for the needle in the current line. */
|
||||
found = strstrwrapper(fileptr->data, needle, rev_start);
|
||||
if (!skipone)
|
||||
found = strstrwrapper(line->data, needle, from);
|
||||
|
||||
/* Ignore the initial match at the starting position: continue
|
||||
* searching from the next character, or invalidate the match. */
|
||||
if (skipone || (!whole_word_only && !came_full_circle &&
|
||||
found == begin->data + begin_x)) {
|
||||
skipone = FALSE;
|
||||
if (ISSET(BACKWARDS_SEARCH) && from != line->data) {
|
||||
from = line->data + move_mbleft(line->data, from - line->data);
|
||||
continue;
|
||||
} else if (!ISSET(BACKWARDS_SEARCH) && *from != '\0') {
|
||||
from += move_mbright(from, 0);
|
||||
continue;
|
||||
}
|
||||
found = NULL;
|
||||
}
|
||||
|
||||
if (found != NULL) {
|
||||
/* Remember the length of the potential match. */
|
||||
found_len =
|
||||
#ifdef HAVE_REGEX_H
|
||||
ISSET(USE_REGEXP) ?
|
||||
regmatches[0].rm_eo - regmatches[0].rm_so :
|
||||
/* When doing a regex search, compute the length of the match. */
|
||||
if (ISSET(USE_REGEXP))
|
||||
found_len = regmatches[0].rm_eo - regmatches[0].rm_so;
|
||||
#endif
|
||||
strlen(needle);
|
||||
|
||||
#ifndef DISABLE_SPELLER
|
||||
/* When we're spell checking, a match is only a true match when
|
||||
* it is a separate word. */
|
||||
if (whole_word_only) {
|
||||
if (is_separate_word(found - fileptr->data, found_len,
|
||||
fileptr->data))
|
||||
break;
|
||||
else {
|
||||
/* Maybe there is a whole word in the rest of the line. */
|
||||
rev_start = found + 1;
|
||||
continue;
|
||||
}
|
||||
} else
|
||||
/* When we're spell checking, a match should be a separate word;
|
||||
* if it's not, continue looking in the rest of the line. */
|
||||
if (whole_word_only && !is_separate_word(found - line->data,
|
||||
found_len, line->data)) {
|
||||
from = found + move_mbright(found, 0);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
/* The match is valid. */
|
||||
break;
|
||||
}
|
||||
|
||||
/* If we're back at the beginning, then there is no needle. */
|
||||
@@ -330,23 +324,22 @@ int findnextstr(const char *needle, bool whole_word_only, size_t *match_len,
|
||||
|
||||
/* Move to the previous or next line in the file. */
|
||||
if (ISSET(BACKWARDS_SEARCH))
|
||||
fileptr = fileptr->prev;
|
||||
line = line->prev;
|
||||
else
|
||||
fileptr = fileptr->next;
|
||||
line = line->next;
|
||||
|
||||
/* If we've reached the start or end of the buffer, wrap around. */
|
||||
if (fileptr == NULL) {
|
||||
#ifndef DISABLE_SPELLER
|
||||
/* When we're spell-checking, end-of-buffer means we're done. */
|
||||
if (whole_word_only) {
|
||||
/* If we've reached the start or end of the buffer, wrap around;
|
||||
* but stop when spell-checking or replacing in a region. */
|
||||
if (line == NULL) {
|
||||
if (whole_word_only || have_region) {
|
||||
disable_nodelay();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ISSET(BACKWARDS_SEARCH))
|
||||
fileptr = openfile->filebot;
|
||||
line = openfile->filebot;
|
||||
else
|
||||
fileptr = openfile->fileage;
|
||||
line = openfile->fileage;
|
||||
|
||||
statusbar(_("Search Wrapped"));
|
||||
/* Delay the "Searching..." message for at least two seconds. */
|
||||
@@ -354,16 +347,16 @@ int findnextstr(const char *needle, bool whole_word_only, size_t *match_len,
|
||||
}
|
||||
|
||||
/* If we've reached the original starting line, take note. */
|
||||
if (fileptr == begin)
|
||||
if (line == begin)
|
||||
came_full_circle = TRUE;
|
||||
|
||||
/* Set the starting x to the start or end of the line. */
|
||||
rev_start = fileptr->data;
|
||||
from = line->data;
|
||||
if (ISSET(BACKWARDS_SEARCH))
|
||||
rev_start += strlen(fileptr->data);
|
||||
from += strlen(line->data);
|
||||
}
|
||||
|
||||
found_x = found - fileptr->data;
|
||||
found_x = found - line->data;
|
||||
|
||||
/* Ensure that the found occurrence is not beyond the starting x. */
|
||||
if (came_full_circle && ((!ISSET(BACKWARDS_SEARCH) && found_x > begin_x) ||
|
||||
@@ -376,9 +369,8 @@ int findnextstr(const char *needle, bool whole_word_only, size_t *match_len,
|
||||
disable_nodelay();
|
||||
|
||||
/* Set the current position to point at what we found. */
|
||||
openfile->current = fileptr;
|
||||
openfile->current = line;
|
||||
openfile->current_x = found_x;
|
||||
openfile->current_y = fileptr->lineno - openfile->edittop->lineno;
|
||||
|
||||
/* When requested, pass back the length of the match. */
|
||||
if (match_len != NULL)
|
||||
@@ -470,7 +462,7 @@ void go_looking(void)
|
||||
|
||||
came_full_circle = FALSE;
|
||||
|
||||
didfind = findnextstr(last_search, FALSE, NULL,
|
||||
didfind = findnextstr(last_search, FALSE, FALSE, NULL, FALSE,
|
||||
openfile->current, openfile->current_x);
|
||||
|
||||
/* If we found something, and we're back at the exact same spot
|
||||
@@ -519,7 +511,7 @@ int replace_regexp(char *string, bool create)
|
||||
* subexpression match to the new line. */
|
||||
if (create) {
|
||||
strncpy(string, openfile->current->data +
|
||||
openfile->current_x + regmatches[num].rm_so, i);
|
||||
regmatches[num].rm_so, i);
|
||||
string += i;
|
||||
}
|
||||
}
|
||||
@@ -586,16 +578,19 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
ssize_t numreplaced = -1;
|
||||
size_t match_len;
|
||||
bool replaceall = FALSE;
|
||||
bool skipone = FALSE;
|
||||
bool mark_was_set = FALSE;
|
||||
#ifndef NANO_TINY
|
||||
bool old_mark_set = openfile->mark_set;
|
||||
filestruct *top, *bot;
|
||||
size_t top_x, bot_x;
|
||||
bool right_side_up = FALSE;
|
||||
/* TRUE if (mark_begin, mark_begin_x) is the top of the mark,
|
||||
* FALSE if (current, current_x) is. */
|
||||
|
||||
mark_was_set = openfile->mark_set;
|
||||
|
||||
/* If the mark is on, frame the region, and turn the mark off. */
|
||||
if (old_mark_set) {
|
||||
if (mark_was_set) {
|
||||
mark_order((const filestruct **)&top, &top_x,
|
||||
(const filestruct **)&bot, &bot_x, &right_side_up);
|
||||
openfile->mark_set = FALSE;
|
||||
@@ -603,7 +598,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
/* Start either at the top or the bottom of the marked region. */
|
||||
if (!ISSET(BACKWARDS_SEARCH)) {
|
||||
openfile->current = top;
|
||||
openfile->current_x = (top_x == 0 ? 0 : top_x - 1);
|
||||
openfile->current_x = top_x;
|
||||
} else {
|
||||
openfile->current = bot;
|
||||
openfile->current_x = bot_x;
|
||||
@@ -615,8 +610,8 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
|
||||
while (TRUE) {
|
||||
int i = 0;
|
||||
int result = findnextstr(needle, whole_word_only, &match_len,
|
||||
real_current, *real_current_x);
|
||||
int result = findnextstr(needle, whole_word_only, mark_was_set,
|
||||
&match_len, skipone, real_current, *real_current_x);
|
||||
|
||||
/* If nothing more was found, or the user aborted, stop looping. */
|
||||
if (result < 1) {
|
||||
@@ -626,15 +621,14 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (old_mark_set) {
|
||||
/* When we've found an occurrence outside of the marked region,
|
||||
* stop the fanfare. */
|
||||
if (openfile->current->lineno > bot->lineno ||
|
||||
openfile->current->lineno < top->lineno ||
|
||||
(openfile->current == bot && openfile->current_x > bot_x) ||
|
||||
(openfile->current == top && openfile->current_x < top_x))
|
||||
break;
|
||||
}
|
||||
/* An occurrence outside of the marked region means we're done. */
|
||||
if (mark_was_set && (openfile->current->lineno > bot->lineno ||
|
||||
openfile->current->lineno < top->lineno ||
|
||||
(openfile->current == bot &&
|
||||
openfile->current_x + match_len > bot_x) ||
|
||||
(openfile->current == top &&
|
||||
openfile->current_x < top_x)))
|
||||
break;
|
||||
#endif
|
||||
|
||||
/* Indicate that we found the search string. */
|
||||
@@ -664,18 +658,21 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
|
||||
if (i == -1) /* The replacing was cancelled. */
|
||||
break;
|
||||
else if (i == 2)
|
||||
replaceall = TRUE;
|
||||
|
||||
/* When "No" or moving backwards, the search routine should
|
||||
* first move one character further before continuing. */
|
||||
skipone = (i == 0 || ISSET(BACKWARDS_SEARCH));
|
||||
}
|
||||
|
||||
if (i > 0 || replaceall) { /* Yes, replace it!!!! */
|
||||
if (i == 1 || replaceall) { /* Yes, replace it. */
|
||||
char *copy;
|
||||
size_t length_change;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(REPLACE);
|
||||
#endif
|
||||
if (i == 2)
|
||||
replaceall = TRUE;
|
||||
|
||||
copy = replace_line(needle);
|
||||
|
||||
length_change = strlen(copy) - strlen(openfile->current->data);
|
||||
@@ -683,7 +680,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
#ifndef NANO_TINY
|
||||
/* 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 (mark_was_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)
|
||||
@@ -696,10 +693,10 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
|
||||
/* 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) {
|
||||
if (!mark_was_set || right_side_up) {
|
||||
#endif
|
||||
if (openfile->current == real_current &&
|
||||
openfile->current_x <= *real_current_x) {
|
||||
openfile->current_x < *real_current_x) {
|
||||
if (*real_current_x < openfile->current_x + match_len)
|
||||
*real_current_x = openfile->current_x + match_len;
|
||||
*real_current_x += length_change;
|
||||
@@ -712,30 +709,22 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* Don't find the same zero-length or BOL match again. */
|
||||
if (match_len == 0 || (*needle == '^' && ISSET(USE_REGEXP)))
|
||||
match_len++;
|
||||
skipone = TRUE;
|
||||
#endif
|
||||
/* Set the cursor at the last character of the replacement
|
||||
* text, so that searching will continue /after/ it. Note
|
||||
* that current_x might be set to (size_t)-1 here. */
|
||||
/* When moving forward, put the cursor just after the replacement
|
||||
* text, so that searching will continue there. */
|
||||
if (!ISSET(BACKWARDS_SEARCH))
|
||||
openfile->current_x += match_len + length_change - 1;
|
||||
openfile->current_x += match_len + length_change;
|
||||
|
||||
/* 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;
|
||||
|
||||
#ifndef DISABLE_COLOR
|
||||
/* Reset the precalculated multiline-regex hints only when
|
||||
* the first replacement has been made. */
|
||||
if (numreplaced == 0)
|
||||
reset_multis(openfile->current, TRUE);
|
||||
#endif
|
||||
|
||||
if (!replaceall) {
|
||||
#ifndef DISABLE_COLOR
|
||||
/* If color syntaxes are available and turned on, we
|
||||
* need to call edit_refresh(). */
|
||||
/* When doing syntax coloring, the replacement might require
|
||||
* a change of colors, so refresh the whole edit window. */
|
||||
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX))
|
||||
edit_refresh();
|
||||
else
|
||||
@@ -744,15 +733,20 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
}
|
||||
|
||||
set_modified();
|
||||
as_an_at = TRUE;
|
||||
numreplaced++;
|
||||
}
|
||||
}
|
||||
|
||||
if (numreplaced == -1)
|
||||
not_found_msg(needle);
|
||||
#ifndef DISABLE_COLOR
|
||||
else if (numreplaced > 0)
|
||||
refresh_needed = TRUE;
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (old_mark_set)
|
||||
if (mark_was_set)
|
||||
openfile->mark_set = TRUE;
|
||||
#endif
|
||||
|
||||
@@ -774,7 +768,6 @@ void do_replace(void)
|
||||
|
||||
if (ISSET(VIEW_MODE)) {
|
||||
print_view_warning();
|
||||
search_replace_abort();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -790,11 +783,7 @@ void do_replace(void)
|
||||
if (i != 0)
|
||||
return;
|
||||
|
||||
i = do_prompt(FALSE,
|
||||
#ifndef DISABLE_TABCOMP
|
||||
TRUE,
|
||||
#endif
|
||||
MREPLACEWITH, NULL,
|
||||
i = do_prompt(FALSE, FALSE, MREPLACEWITH, NULL,
|
||||
#ifndef DISABLE_HISTORIES
|
||||
&replace_history,
|
||||
#endif
|
||||
@@ -826,8 +815,7 @@ void do_replace(void)
|
||||
openfile->edittop = edittop_save;
|
||||
openfile->current = begin;
|
||||
openfile->current_x = begin_x;
|
||||
|
||||
edit_refresh();
|
||||
refresh_needed = TRUE;
|
||||
|
||||
if (numreplaced >= 0)
|
||||
statusline(HUSH, P_("Replaced %lu occurrence",
|
||||
@@ -860,11 +848,8 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
functionptrtype func;
|
||||
|
||||
/* Ask for the line and column. */
|
||||
int i = do_prompt(FALSE,
|
||||
#ifndef DISABLE_TABCOMP
|
||||
TRUE,
|
||||
#endif
|
||||
MGOTOLINE, use_answer ? answer : NULL,
|
||||
int i = do_prompt(FALSE, FALSE, MGOTOLINE,
|
||||
use_answer ? answer : NULL,
|
||||
#ifndef DISABLE_HISTORIES
|
||||
NULL,
|
||||
#endif
|
||||
@@ -891,7 +876,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
|
||||
/* Try to extract one or two numbers from the user's response. */
|
||||
if (!parse_line_column(answer, &line, &column)) {
|
||||
statusbar(_("Invalid line or column number"));
|
||||
statusline(ALERT, _("Invalid line or column number"));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -1001,7 +986,6 @@ bool find_bracket_match(bool reverse, const char *bracket_set)
|
||||
/* Set the current position to the found matching bracket. */
|
||||
openfile->current = fileptr;
|
||||
openfile->current_x = found - fileptr->data;
|
||||
openfile->current_y = fileptr->lineno - openfile->edittop->lineno;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1205,10 +1189,10 @@ void update_history(filestruct **h, const char *s)
|
||||
/* If the history is full, delete the oldest item (the one at the
|
||||
* head of the list), to make room for a new item at the end. */
|
||||
if ((*hbot)->lineno == MAX_SEARCH_HISTORY + 1) {
|
||||
filestruct *foo = *hage;
|
||||
filestruct *oldest = *hage;
|
||||
|
||||
*hage = (*hage)->next;
|
||||
unlink_node(foo);
|
||||
unlink_node(oldest);
|
||||
renumber(*hage);
|
||||
}
|
||||
|
||||
|
||||
398
src/text.c
398
src/text.c
@@ -6,6 +6,7 @@
|
||||
* Copyright (C) 2014, 2015 Mark Majeres *
|
||||
* Copyright (C) 2016 Mike Scalora *
|
||||
* Copyright (C) 2015, 2016 Benno Schulenberg *
|
||||
* Copyright (C) 2016 Sumedh Pendurkar *
|
||||
* *
|
||||
* GNU nano is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published *
|
||||
@@ -48,6 +49,13 @@ static filestruct *jusbottom = NULL;
|
||||
/* A pointer to the end of the buffer with unjustified text. */
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WORDCOMPLETION
|
||||
static int pletion_x = 0;
|
||||
/* The x position in pletion_line of the last found completion. */
|
||||
static completion_word *list_of_completions;
|
||||
/* A linked list of the completions that have been attepmted. */
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Toggle the mark. */
|
||||
void do_mark(void)
|
||||
@@ -63,8 +71,8 @@ void do_mark(void)
|
||||
statusbar(_("Mark Unset"));
|
||||
openfile->mark_begin = NULL;
|
||||
openfile->mark_begin_x = 0;
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
edit_refresh();
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
@@ -84,7 +92,7 @@ char *invocation_error(const char *name)
|
||||
void do_deletion(undo_type action)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
size_t orig_lenpt = 0;
|
||||
size_t orig_rows = 0;
|
||||
#endif
|
||||
|
||||
assert(openfile->current != NULL && openfile->current->data != NULL &&
|
||||
@@ -94,7 +102,7 @@ void do_deletion(undo_type action)
|
||||
|
||||
if (openfile->current->data[openfile->current_x] != '\0') {
|
||||
/* We're in the middle of a line: delete the current character. */
|
||||
int char_buf_len = parse_mbchar(openfile->current->data +
|
||||
int char_len = parse_mbchar(openfile->current->data +
|
||||
openfile->current_x, NULL, NULL);
|
||||
size_t line_len = strlen(openfile->current->data +
|
||||
openfile->current_x);
|
||||
@@ -105,21 +113,21 @@ void do_deletion(undo_type action)
|
||||
update_undo(action);
|
||||
|
||||
if (ISSET(SOFTWRAP))
|
||||
orig_lenpt = strlenpt(openfile->current->data);
|
||||
orig_rows = strlenpt(openfile->current->data) / editwincols;
|
||||
#endif
|
||||
|
||||
/* Move the remainder of the line "in", over the current character. */
|
||||
charmove(&openfile->current->data[openfile->current_x],
|
||||
&openfile->current->data[openfile->current_x + char_buf_len],
|
||||
line_len - char_buf_len + 1);
|
||||
&openfile->current->data[openfile->current_x + char_len],
|
||||
line_len - char_len + 1);
|
||||
null_at(&openfile->current->data, openfile->current_x +
|
||||
line_len - char_buf_len);
|
||||
line_len - char_len);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Adjust the mark if it is after the cursor on the current line. */
|
||||
if (openfile->mark_set && openfile->mark_begin == openfile->current &&
|
||||
openfile->mark_begin_x > openfile->current_x)
|
||||
openfile->mark_begin_x -= char_buf_len;
|
||||
openfile->mark_begin_x -= char_len;
|
||||
#endif
|
||||
/* Adjust the file size. */
|
||||
openfile->totsize--;
|
||||
@@ -173,8 +181,10 @@ void do_deletion(undo_type action)
|
||||
#ifndef NANO_TINY
|
||||
ensure_line_is_visible();
|
||||
|
||||
/* If the number of screen rows that a softwrapped line occupies
|
||||
* has changed, we need a full refresh. */
|
||||
if (ISSET(SOFTWRAP) && refresh_needed == FALSE)
|
||||
if (strlenpt(openfile->current->data) / COLS != orig_lenpt / COLS)
|
||||
if ((strlenpt(openfile->current->data) / editwincols) != orig_rows)
|
||||
refresh_needed = TRUE;
|
||||
#endif
|
||||
|
||||
@@ -414,7 +424,6 @@ void do_indent(ssize_t cols)
|
||||
/* Throw away the undo stack, to prevent making mistakes when
|
||||
* the user tries to undo something in the reindented text. */
|
||||
discard_until(NULL, openfile);
|
||||
openfile->current_undo = NULL;
|
||||
|
||||
/* Mark the file as modified. */
|
||||
set_modified();
|
||||
@@ -638,7 +647,7 @@ void undo_cut(undo *u)
|
||||
else
|
||||
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
|
||||
|
||||
copy_from_filestruct(u->cutbuffer);
|
||||
copy_from_buffer(u->cutbuffer);
|
||||
|
||||
if (u->xflags != WAS_MARKED_FORWARD && u->type != PASTE)
|
||||
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
|
||||
@@ -789,7 +798,7 @@ void do_undo(void)
|
||||
openfile->mark_begin_x = u->mark_begin_x;
|
||||
openfile->mark_set = TRUE;
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
cut_marked();
|
||||
cut_marked(NULL);
|
||||
free_filestruct(u->cutbuffer);
|
||||
u->cutbuffer = cutbuffer;
|
||||
u->cutbottom = cutbottom;
|
||||
@@ -810,14 +819,16 @@ void do_undo(void)
|
||||
break;
|
||||
}
|
||||
|
||||
if (undidmsg)
|
||||
if (undidmsg && !pletion_line)
|
||||
statusline(HUSH, _("Undid action (%s)"), undidmsg);
|
||||
|
||||
renumber(f);
|
||||
|
||||
openfile->current_undo = openfile->current_undo->next;
|
||||
openfile->last_action = OTHER;
|
||||
openfile->mark_set = FALSE;
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
openfile->totsize = u->wassize;
|
||||
set_modified();
|
||||
}
|
||||
@@ -938,7 +949,7 @@ void do_redo(void)
|
||||
case INSERT:
|
||||
redidmsg = _("text insert");
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
copy_from_filestruct(u->cutbuffer);
|
||||
copy_from_buffer(u->cutbuffer);
|
||||
free_filestruct(u->cutbuffer);
|
||||
u->cutbuffer = NULL;
|
||||
break;
|
||||
@@ -965,13 +976,14 @@ void do_redo(void)
|
||||
openfile->last_action = OTHER;
|
||||
openfile->mark_set = FALSE;
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
openfile->totsize = u->newsize;
|
||||
set_modified();
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Someone hits Enter *gasp!* */
|
||||
void do_enter()
|
||||
/* Break the current line at the cursor position. */
|
||||
void do_enter(void)
|
||||
{
|
||||
filestruct *newnode = make_new_node(openfile->current);
|
||||
size_t extra = 0;
|
||||
@@ -981,45 +993,48 @@ void do_enter()
|
||||
#ifndef NANO_TINY
|
||||
add_undo(ENTER);
|
||||
|
||||
/* Do auto-indenting, like the neolithic Turbo Pascal editor. */
|
||||
if (ISSET(AUTOINDENT)) {
|
||||
/* If we are breaking the line in the indentation, the new
|
||||
* indentation should have only current_x characters, and
|
||||
* current_x should not change. */
|
||||
extra = indent_length(openfile->current->data);
|
||||
|
||||
/* If we are breaking the line in the indentation, limit the new
|
||||
* indentation to the current x position. */
|
||||
if (extra > openfile->current_x)
|
||||
extra = openfile->current_x;
|
||||
}
|
||||
#endif
|
||||
newnode->data = charalloc(strlen(openfile->current->data +
|
||||
openfile->current_x) + extra + 1);
|
||||
openfile->current_x) + extra + 1);
|
||||
strcpy(&newnode->data[extra], openfile->current->data +
|
||||
openfile->current_x);
|
||||
openfile->current_x);
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(AUTOINDENT)) {
|
||||
/* Copy the whitespace from the current line to the new one. */
|
||||
strncpy(newnode->data, openfile->current->data, extra);
|
||||
openfile->totsize += extra;
|
||||
}
|
||||
#endif
|
||||
|
||||
null_at(&openfile->current->data, openfile->current_x);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Adjust the mark if it was on the current line after the cursor. */
|
||||
if (openfile->mark_set && openfile->current == openfile->mark_begin &&
|
||||
openfile->current_x < openfile->mark_begin_x) {
|
||||
openfile->mark_begin = newnode;
|
||||
openfile->mark_begin_x += extra - openfile->current_x;
|
||||
}
|
||||
#endif
|
||||
openfile->current_x = extra;
|
||||
|
||||
splice_node(openfile->current, newnode);
|
||||
openfile->current = newnode;
|
||||
renumber(newnode);
|
||||
|
||||
openfile->current = newnode;
|
||||
openfile->current_x = extra;
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
openfile->totsize++;
|
||||
set_modified();
|
||||
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
update_undo(ENTER);
|
||||
#endif
|
||||
@@ -1142,6 +1157,9 @@ void discard_until(const undo *thisitem, openfilestruct *thefile)
|
||||
dropit = thefile->undotop;
|
||||
}
|
||||
|
||||
/* Adjust the pointer to the top of the undo stack. */
|
||||
thefile->current_undo = (undo *)thisitem;
|
||||
|
||||
/* Prevent a chain of editing actions from continuing. */
|
||||
thefile->last_action = OTHER;
|
||||
}
|
||||
@@ -1203,16 +1221,18 @@ void add_undo(undo_type action)
|
||||
case BACK:
|
||||
/* If the next line is the magic line, don't ever undo this
|
||||
* backspace, as it won't actually have deleted anything. */
|
||||
if (openfile->current->next == openfile->filebot && openfile->current->data[0] != '\0')
|
||||
if (openfile->current->next == openfile->filebot &&
|
||||
openfile->current->data[0] != '\0')
|
||||
u->xflags = WAS_FINAL_BACKSPACE;
|
||||
case DEL:
|
||||
if (u->begin != strlen(openfile->current->data)) {
|
||||
if (openfile->current->data[openfile->current_x] != '\0') {
|
||||
char *char_buf = charalloc(mb_cur_max() + 1);
|
||||
int char_buf_len = parse_mbchar(&openfile->current->data[u->begin], char_buf, NULL);
|
||||
null_at(&char_buf, char_buf_len);
|
||||
int char_len = parse_mbchar(&openfile->current->data[u->begin],
|
||||
char_buf, NULL);
|
||||
null_at(&char_buf, char_len);
|
||||
u->strdata = char_buf;
|
||||
if (u->type == BACK)
|
||||
u->mark_begin_x += char_buf_len;
|
||||
u->mark_begin_x += char_len;
|
||||
break;
|
||||
}
|
||||
/* Else purposely fall into the line-joining code. */
|
||||
@@ -1340,8 +1360,8 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
|
||||
openfile->current->data, (unsigned long)openfile->current_x, (unsigned long)u->begin);
|
||||
#endif
|
||||
char *char_buf = charalloc(mb_cur_max());
|
||||
size_t char_buf_len = parse_mbchar(&openfile->current->data[u->mark_begin_x], char_buf, NULL);
|
||||
u->strdata = addstrings(u->strdata, u->strdata ? strlen(u->strdata) : 0, char_buf, char_buf_len);
|
||||
int char_len = parse_mbchar(&openfile->current->data[u->mark_begin_x], char_buf, NULL);
|
||||
u->strdata = addstrings(u->strdata, u->strdata ? strlen(u->strdata) : 0, char_buf, char_len);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " >> current undo data is \"%s\"\n", u->strdata);
|
||||
#endif
|
||||
@@ -1352,17 +1372,17 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
|
||||
case BACK:
|
||||
case DEL: {
|
||||
char *char_buf = charalloc(mb_cur_max());
|
||||
size_t char_buf_len = parse_mbchar(&openfile->current->data[openfile->current_x], char_buf, NULL);
|
||||
int char_len = parse_mbchar(&openfile->current->data[openfile->current_x], char_buf, NULL);
|
||||
if (openfile->current_x == u->begin) {
|
||||
/* They're deleting. */
|
||||
u->strdata = addstrings(u->strdata, strlen(u->strdata), char_buf, char_buf_len);
|
||||
/* They deleted more: add removed character after earlier stuff. */
|
||||
u->strdata = addstrings(u->strdata, strlen(u->strdata), char_buf, char_len);
|
||||
u->mark_begin_x = openfile->current_x;
|
||||
} else if (openfile->current_x == u->begin - char_buf_len) {
|
||||
/* They're backspacing. */
|
||||
u->strdata = addstrings(char_buf, char_buf_len, u->strdata, strlen(u->strdata));
|
||||
} else if (openfile->current_x == u->begin - char_len) {
|
||||
/* They backspaced further: add removed character before earlier. */
|
||||
u->strdata = addstrings(char_buf, char_len, u->strdata, strlen(u->strdata));
|
||||
u->begin = openfile->current_x;
|
||||
} else {
|
||||
/* They deleted something else on the line. */
|
||||
/* They deleted *elsewhere* on the line: start a new undo item. */
|
||||
free(char_buf);
|
||||
add_undo(u->type);
|
||||
return;
|
||||
@@ -1982,12 +2002,9 @@ bool begpar(const filestruct *const foo)
|
||||
|
||||
/* Case 2) or 5) or 4). */
|
||||
if (foo->prev->data[quote_len + temp_id_len] == '\0' ||
|
||||
(quote_len == 0 && indent_len > 0
|
||||
#ifndef NANO_TINY
|
||||
&& !ISSET(AUTOINDENT)
|
||||
#endif
|
||||
) || !indents_match(foo->prev->data + quote_len, temp_id_len,
|
||||
foo->data + quote_len, indent_len))
|
||||
(quote_len == 0 && indent_len > 0 && !ISSET(AUTOINDENT)) ||
|
||||
!indents_match(foo->prev->data + quote_len, temp_id_len,
|
||||
foo->data + quote_len, indent_len))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
@@ -2047,12 +2064,12 @@ void backup_lines(filestruct *first_line, size_t par_len)
|
||||
|
||||
/* Move the paragraph from the current buffer's filestruct to the
|
||||
* justify buffer. */
|
||||
move_to_filestruct(&jusbuffer, &jusbottom, top, 0, bot,
|
||||
extract_buffer(&jusbuffer, &jusbottom, top, 0, bot,
|
||||
(i == 1 && bot == openfile->filebot) ? strlen(bot->data) : 0);
|
||||
|
||||
/* Copy the paragraph back to the current buffer's filestruct from
|
||||
* the justify buffer. */
|
||||
copy_from_filestruct(jusbuffer);
|
||||
copy_from_buffer(jusbuffer);
|
||||
|
||||
/* Move upward from the last line of the paragraph to the first
|
||||
* line, putting first_line, edittop, current, and mark_begin at the
|
||||
@@ -2109,9 +2126,6 @@ bool find_paragraph(size_t *const quote, size_t *const par)
|
||||
/* Number of lines in the paragraph we search for. */
|
||||
filestruct *current_save;
|
||||
/* The line at the beginning of the paragraph we search for. */
|
||||
ssize_t current_y_save;
|
||||
/* The y-coordinate at the beginning of the paragraph we search
|
||||
* for. */
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (quoterc != 0) {
|
||||
@@ -2160,7 +2174,6 @@ bool find_paragraph(size_t *const quote, size_t *const par)
|
||||
* of lines in this paragraph. */
|
||||
quote_len = quote_length(openfile->current->data);
|
||||
current_save = openfile->current;
|
||||
current_y_save = openfile->current_y;
|
||||
do_para_end(FALSE);
|
||||
par_len = openfile->current->lineno - current_save->lineno;
|
||||
|
||||
@@ -2171,7 +2184,6 @@ bool find_paragraph(size_t *const quote, size_t *const par)
|
||||
if (openfile->current_x > 0)
|
||||
par_len++;
|
||||
openfile->current = current_save;
|
||||
openfile->current_y = current_y_save;
|
||||
|
||||
/* Save the values of quote_len and par_len. */
|
||||
assert(quote != NULL && par != NULL);
|
||||
@@ -2282,8 +2294,7 @@ void do_justify(bool full_justify)
|
||||
if (first_par_line == NULL) {
|
||||
backup_lines(openfile->current, full_justify ?
|
||||
openfile->filebot->lineno - openfile->current->lineno +
|
||||
((openfile->filebot->data[0] != '\0') ? 1 : 0) :
|
||||
par_len);
|
||||
((openfile->filebot->data[0] != '\0') ? 1 : 0) : par_len);
|
||||
first_par_line = openfile->current;
|
||||
}
|
||||
|
||||
@@ -2337,8 +2348,7 @@ void do_justify(bool full_justify)
|
||||
|
||||
/* We're just about to tack the next line onto this one. If
|
||||
* this line isn't empty, make sure it ends in a space. */
|
||||
if (line_len > 0 &&
|
||||
openfile->current->data[line_len - 1] != ' ') {
|
||||
if (line_len > 0 && openfile->current->data[line_len - 1] != ' ') {
|
||||
line_len++;
|
||||
openfile->current->data =
|
||||
charealloc(openfile->current->data, line_len + 1);
|
||||
@@ -2353,8 +2363,7 @@ void do_justify(bool full_justify)
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If needed, adjust the coordinates of the mark. */
|
||||
if (openfile->mark_set &&
|
||||
openfile->mark_begin == next_line) {
|
||||
if (openfile->mark_set && openfile->mark_begin == next_line) {
|
||||
openfile->mark_begin = openfile->current;
|
||||
openfile->mark_begin_x += line_len - indent_len;
|
||||
}
|
||||
@@ -2406,11 +2415,7 @@ void do_justify(bool full_justify)
|
||||
/* If this paragraph is non-quoted, and autoindent isn't
|
||||
* turned on, set the indentation length to zero so that the
|
||||
* indentation is treated as part of the line. */
|
||||
if (quote_len == 0
|
||||
#ifndef NANO_TINY
|
||||
&& !ISSET(AUTOINDENT)
|
||||
#endif
|
||||
)
|
||||
if (quote_len == 0 && !ISSET(AUTOINDENT))
|
||||
indent_len = 0;
|
||||
|
||||
/* Insert a new line after the current one. */
|
||||
@@ -2440,17 +2445,17 @@ void do_justify(bool full_justify)
|
||||
#endif
|
||||
|
||||
/* Break the current line. */
|
||||
if (ISSET(JUSTIFY_TRIM)) {
|
||||
if (ISSET(JUSTIFY_TRIM)) {
|
||||
while (break_pos > 0 &&
|
||||
is_blank_mbchar(&openfile->current->data[break_pos - 1])) {
|
||||
break_pos--;
|
||||
openfile->totsize--;
|
||||
}
|
||||
}
|
||||
null_at(&openfile->current->data, break_pos);
|
||||
|
||||
/* Go to the next line. */
|
||||
par_len--;
|
||||
openfile->current_y++;
|
||||
openfile->current = openfile->current->next;
|
||||
}
|
||||
|
||||
@@ -2461,14 +2466,12 @@ void do_justify(bool full_justify)
|
||||
/* Go to the next line, if possible. If there is no next line,
|
||||
* move to the end of the current line. */
|
||||
if (openfile->current != openfile->filebot) {
|
||||
openfile->current_y++;
|
||||
openfile->current = openfile->current->next;
|
||||
} else
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
|
||||
/* Renumber the lines of the now-justified current paragraph,
|
||||
* since both find_paragraph() and edit_refresh() need the line
|
||||
* numbers to be right. */
|
||||
/* Renumber the now-justified paragraph, since both refreshing the
|
||||
* edit window and finding a paragraph need correct line numbers. */
|
||||
renumber(curr_first_par_line);
|
||||
|
||||
/* We've just finished justifying the paragraph. If we're not
|
||||
@@ -2480,9 +2483,8 @@ void do_justify(bool full_justify)
|
||||
}
|
||||
|
||||
/* We are now done justifying the paragraph or the file, so clean
|
||||
* up. current_y and totsize have been maintained above. If we
|
||||
* actually justified something, set last_par_line to the new end of
|
||||
* the paragraph. */
|
||||
* up. totsize has been maintained above. If we actually justified
|
||||
* something, set last_par_line to the new end of the paragraph. */
|
||||
if (first_par_line != NULL)
|
||||
last_par_line = openfile->current;
|
||||
|
||||
@@ -2566,7 +2568,6 @@ void do_justify(bool full_justify)
|
||||
/* Throw away the entire undo stack, to prevent a crash when
|
||||
* the user tries to undo something in the justified text. */
|
||||
discard_until(NULL, openfile);
|
||||
openfile->current_undo = NULL;
|
||||
#endif
|
||||
/* Blow away the unjustified text. */
|
||||
free_filestruct(jusbuffer);
|
||||
@@ -2623,16 +2624,10 @@ bool do_int_spell_fix(const char *word)
|
||||
/* Save the settings of the global flags. */
|
||||
memcpy(stash, flags, sizeof(flags));
|
||||
|
||||
/* Make sure spell-check is case sensitive. */
|
||||
/* Do the spell checking case sensitive, forward, and without regexes. */
|
||||
SET(CASE_SENSITIVE);
|
||||
|
||||
/* Make sure spell-check goes forward only. */
|
||||
UNSET(BACKWARDS_SEARCH);
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* Make sure spell-check doesn't use regular expressions. */
|
||||
UNSET(USE_REGEXP);
|
||||
#endif
|
||||
|
||||
/* Save the current search string, then set it to the misspelled word. */
|
||||
save_search = last_search;
|
||||
@@ -2647,23 +2642,21 @@ bool do_int_spell_fix(const char *word)
|
||||
* (current, current_x) (where searching starts) is at the top. */
|
||||
if (right_side_up) {
|
||||
openfile->current = top;
|
||||
openfile->current_x = (size_t)(top_x - 1);
|
||||
openfile->current_x = top_x;
|
||||
openfile->mark_begin = bot;
|
||||
openfile->mark_begin_x = bot_x;
|
||||
} else
|
||||
openfile->current_x = (size_t)(openfile->current_x - 1);
|
||||
}
|
||||
openfile->mark_set = FALSE;
|
||||
} else
|
||||
#endif
|
||||
/* Otherwise, start from the top of the file. */
|
||||
{
|
||||
openfile->edittop = openfile->fileage;
|
||||
openfile->current = openfile->fileage;
|
||||
openfile->current_x = (size_t)-1;
|
||||
openfile->current_x = 0;
|
||||
}
|
||||
|
||||
/* Find the first whole occurrence of word. */
|
||||
result = findnextstr(word, TRUE, NULL, NULL, 0);
|
||||
result = findnextstr(word, TRUE, TRUE, NULL, FALSE, NULL, 0);
|
||||
|
||||
/* If the word isn't found, alert the user; if it is, allow correction. */
|
||||
if (result == 0) {
|
||||
@@ -2679,11 +2672,7 @@ bool do_int_spell_fix(const char *word)
|
||||
spotlight(TRUE, exp_word);
|
||||
|
||||
/* Let the user supply a correctly spelled alternative. */
|
||||
proceed = (do_prompt(FALSE,
|
||||
#ifndef DISABLE_TABCOMP
|
||||
TRUE,
|
||||
#endif
|
||||
MSPELL, word,
|
||||
proceed = (do_prompt(FALSE, FALSE, MSPELL, word,
|
||||
#ifndef DISABLE_HISTORIES
|
||||
NULL,
|
||||
#endif
|
||||
@@ -2695,7 +2684,6 @@ bool do_int_spell_fix(const char *word)
|
||||
|
||||
/* If a replacement was given, go through all occurrences. */
|
||||
if (proceed && strcmp(word, answer) != 0) {
|
||||
openfile->current_x--;
|
||||
#ifndef NANO_TINY
|
||||
/* Replacements should happen only in the marked region. */
|
||||
openfile->mark_set = old_mark_set;
|
||||
@@ -2927,7 +2915,6 @@ const char *do_alt_speller(char *tempfile_name)
|
||||
int alt_spell_status;
|
||||
size_t current_x_save = openfile->current_x;
|
||||
size_t pww_save = openfile->placewewant;
|
||||
ssize_t current_y_save = openfile->current_y;
|
||||
ssize_t lineno_save = openfile->current->lineno;
|
||||
struct stat spellfileinfo;
|
||||
time_t timestamp;
|
||||
@@ -2940,7 +2927,7 @@ const char *do_alt_speller(char *tempfile_name)
|
||||
bool added_magicline = FALSE;
|
||||
/* Whether we added a magicline after filebot. */
|
||||
filestruct *top, *bot;
|
||||
size_t top_x, bot_x;
|
||||
size_t top_x, bot_x, was_x, new_x;
|
||||
bool right_side_up = FALSE;
|
||||
ssize_t mb_lineno_save = 0;
|
||||
/* We're going to close the current file, and open the output of
|
||||
@@ -3043,17 +3030,26 @@ const char *do_alt_speller(char *tempfile_name)
|
||||
#ifndef NANO_TINY
|
||||
if (old_mark_set) {
|
||||
filestruct *top_save = openfile->fileage;
|
||||
/* Adjust the end point of the marked region for any change in
|
||||
* length of the region's last line. */
|
||||
if (right_side_up)
|
||||
current_x_save = strlen(openfile->filebot->data);
|
||||
else
|
||||
openfile->mark_begin_x = strlen(openfile->filebot->data);
|
||||
|
||||
/* If a magicline was added, remove it again. */
|
||||
if (added_magicline)
|
||||
remove_magicline();
|
||||
|
||||
/* Adjust the end point of the marked region for any change in
|
||||
* length of the region's last line. */
|
||||
if (right_side_up)
|
||||
was_x = current_x_save;
|
||||
else
|
||||
was_x = openfile->mark_begin_x;
|
||||
if (top == bot)
|
||||
new_x = was_x - bot_x + top_x + strlen(openfile->filebot->data);
|
||||
else
|
||||
new_x = strlen(openfile->filebot->data);
|
||||
if (right_side_up)
|
||||
current_x_save = new_x;
|
||||
else
|
||||
openfile->mark_begin_x = new_x;
|
||||
|
||||
/* Unpartition the filestruct so that it contains all the text
|
||||
* again. Note that we've replaced the marked text originally
|
||||
* in the partition with the spell-checked marked text in the
|
||||
@@ -3074,16 +3070,22 @@ const char *do_alt_speller(char *tempfile_name)
|
||||
|
||||
/* Go back to the old position. */
|
||||
goto_line_posx(lineno_save, current_x_save);
|
||||
openfile->current_y = current_y_save;
|
||||
if (openfile->current_x > strlen(openfile->current->data))
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
openfile->placewewant = pww_save;
|
||||
adjust_viewport(STATIONARY);
|
||||
|
||||
/* Stat the temporary file again, and mark the buffer as modified only
|
||||
* if this file was changed since it was written. */
|
||||
stat(tempfile_name, &spellfileinfo);
|
||||
if (spellfileinfo.st_mtime != timestamp)
|
||||
if (spellfileinfo.st_mtime != timestamp) {
|
||||
set_modified();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Flush the undo stack, to avoid making a mess when the user
|
||||
* tries to undo things in spell-corrected lines. */
|
||||
discard_until(NULL, openfile);
|
||||
#endif
|
||||
}
|
||||
#ifndef NANO_TINY
|
||||
/* Unblock SIGWINCHes again. */
|
||||
allow_sigwinch(TRUE);
|
||||
@@ -3381,8 +3383,6 @@ void do_linter(void)
|
||||
sprintf(msg, _("This message is for unopened file %s,"
|
||||
" open it in a new buffer?"),
|
||||
curlint->filename);
|
||||
/* Show a cursor after the question. */
|
||||
curs_set(1);
|
||||
i = do_yesno_prompt(FALSE, msg);
|
||||
free(msg);
|
||||
if (i == -1) {
|
||||
@@ -3470,7 +3470,6 @@ void do_formatter(void)
|
||||
FILE *temp_file;
|
||||
int format_status;
|
||||
ssize_t lineno_save = openfile->current->lineno;
|
||||
ssize_t current_y_save = openfile->current_y;
|
||||
size_t current_x_save = openfile->current_x;
|
||||
size_t pww_save = openfile->placewewant;
|
||||
pid_t pid_format;
|
||||
@@ -3548,14 +3547,19 @@ void do_formatter(void)
|
||||
/* Replace the text of the current buffer with the formatted text. */
|
||||
replace_buffer(temp);
|
||||
|
||||
/* Restore the cursor position, and mark the file as modified. */
|
||||
/* Restore the cursor position. */
|
||||
goto_line_posx(lineno_save, current_x_save);
|
||||
openfile->current_y = current_y_save;
|
||||
if (openfile->current_x > strlen(openfile->current->data))
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
openfile->placewewant = pww_save;
|
||||
adjust_viewport(STATIONARY);
|
||||
|
||||
set_modified();
|
||||
|
||||
/* Flush the undo stack, to avoid a mess or crash when
|
||||
* the user tries to undo things in reformatted lines. */
|
||||
discard_until(NULL, openfile);
|
||||
|
||||
finalstatus = _("Finished formatting");
|
||||
}
|
||||
|
||||
@@ -3684,3 +3688,179 @@ void do_verbatim_input(void)
|
||||
|
||||
free(output);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WORDCOMPLETION
|
||||
/* Copy the found completion candidate. */
|
||||
char *copy_completion(char *check_line, int start)
|
||||
{
|
||||
char *word;
|
||||
int position = start, len_of_word = 0, index = 0;
|
||||
|
||||
/* Find the length of the word by travelling to its end. */
|
||||
while (is_word_mbchar(&check_line[position], FALSE)) {
|
||||
int next = move_mbright(check_line, position);
|
||||
len_of_word += next - position;
|
||||
position = next;
|
||||
}
|
||||
|
||||
word = (char *)nmalloc((len_of_word + 1) * sizeof(char));
|
||||
|
||||
/* Simply copy the word. */
|
||||
while (index < len_of_word)
|
||||
word[index++] = check_line[start++];
|
||||
|
||||
word[index] = '\0';
|
||||
return word;
|
||||
}
|
||||
|
||||
/* Look at the fragment the user has typed, then search the current buffer for
|
||||
* the first word that starts with this fragment, and tentatively complete the
|
||||
* fragment. If the user types 'Complete' again, search and paste the next
|
||||
* possible completion. */
|
||||
void complete_a_word(void)
|
||||
{
|
||||
char *shard, *completion = NULL;
|
||||
int start_of_shard, shard_length = 0;
|
||||
int i = 0, j = 0;
|
||||
completion_word *some_word;
|
||||
#ifndef DISABLE_WRAPPING
|
||||
bool was_set_wrapping = !ISSET(NO_WRAP);
|
||||
#endif
|
||||
|
||||
/* If this is a fresh completion attempt... */
|
||||
if (pletion_line == NULL) {
|
||||
/* Clear the list of words of a previous completion run. */
|
||||
while (list_of_completions != NULL) {
|
||||
completion_word *dropit = list_of_completions;
|
||||
list_of_completions = list_of_completions->next;
|
||||
free(dropit->word);
|
||||
free(dropit);
|
||||
}
|
||||
|
||||
/* Prevent a completion from being merged with typed text. */
|
||||
openfile->last_action = OTHER;
|
||||
|
||||
/* Initialize the starting point for searching. */
|
||||
pletion_line = openfile->fileage;
|
||||
pletion_x = 0;
|
||||
|
||||
/* Wipe the "No further matches" message. */
|
||||
blank_statusbar();
|
||||
wnoutrefresh(bottomwin);
|
||||
} else {
|
||||
/* Remove the attempted completion from the buffer. */
|
||||
do_undo();
|
||||
}
|
||||
|
||||
/* Find the start of the fragment that the user typed. */
|
||||
start_of_shard = openfile->current_x;
|
||||
while (start_of_shard > 0) {
|
||||
int step_left = move_mbleft(openfile->current->data, start_of_shard);
|
||||
|
||||
if (!is_word_mbchar(&openfile->current->data[step_left], FALSE))
|
||||
break;
|
||||
start_of_shard = step_left;
|
||||
}
|
||||
|
||||
/* If there is no word fragment before the cursor, do nothing. */
|
||||
if (start_of_shard == openfile->current_x) {
|
||||
pletion_line = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
shard = (char *)nmalloc((openfile->current_x - start_of_shard + 1) * sizeof(char));
|
||||
|
||||
/* Copy the fragment that has to be searched for. */
|
||||
while (start_of_shard < openfile->current_x)
|
||||
shard[shard_length++] = openfile->current->data[start_of_shard++];
|
||||
shard[shard_length] = '\0';
|
||||
|
||||
/* Run through all of the lines in the buffer, looking for shard. */
|
||||
while (pletion_line != NULL) {
|
||||
int threshold = strlen(pletion_line->data) - shard_length - 1;
|
||||
/* The point where we can stop searching for shard. */
|
||||
|
||||
/* Traverse the whole line, looking for shard. */
|
||||
for (i = pletion_x; i < threshold; i++) {
|
||||
/* If the first byte doesn't match, run on. */
|
||||
if (pletion_line->data[i] != shard[0])
|
||||
continue;
|
||||
|
||||
/* Compare the rest of the bytes in shard. */
|
||||
for (j = 1; j < shard_length; j++)
|
||||
if (pletion_line->data[i + j] != shard[j])
|
||||
break;
|
||||
|
||||
/* If not all of the bytes matched, continue searching. */
|
||||
if (j < shard_length)
|
||||
continue;
|
||||
|
||||
/* If the found match is not /longer/ than shard, skip it. */
|
||||
if (!is_word_mbchar(&pletion_line->data[i + j], FALSE))
|
||||
continue;
|
||||
|
||||
/* If the match is not a separate word, skip it. */
|
||||
if (i > 0 && is_word_mbchar(&pletion_line->data[
|
||||
move_mbleft(pletion_line->data, i)], FALSE))
|
||||
continue;
|
||||
|
||||
/* If this match is the shard itself, ignore it. */
|
||||
if (pletion_line == openfile->current &&
|
||||
i == openfile->current_x - shard_length)
|
||||
continue;
|
||||
|
||||
completion = copy_completion(pletion_line->data, i);
|
||||
|
||||
/* Look among earlier attempted completions for a duplicate. */
|
||||
some_word = list_of_completions;
|
||||
while (some_word && strcmp(some_word->word, completion) != 0)
|
||||
some_word = some_word->next;
|
||||
|
||||
/* If we've already tried this word, skip it. */
|
||||
if (some_word != NULL) {
|
||||
free(completion);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Add the found word to the list of completions. */
|
||||
some_word = (completion_word *)nmalloc(sizeof(completion_word));
|
||||
some_word->word = completion;
|
||||
some_word->next = list_of_completions;
|
||||
list_of_completions = some_word;
|
||||
|
||||
#ifndef DISABLE_WRAPPING
|
||||
/* Temporarily disable wrapping so only one undo item is added. */
|
||||
SET(NO_WRAP);
|
||||
#endif
|
||||
/* Inject the completion into the buffer. */
|
||||
do_output(&completion[shard_length],
|
||||
strlen(completion) - shard_length, FALSE);
|
||||
#ifndef DISABLE_WRAPPING
|
||||
/* If needed, reenable wrapping and wrap the current line. */
|
||||
if (was_set_wrapping) {
|
||||
UNSET(NO_WRAP);
|
||||
do_wrap(openfile->current);
|
||||
}
|
||||
#endif
|
||||
/* Set the position for a possible next search attempt. */
|
||||
pletion_x = ++i;
|
||||
|
||||
free(shard);
|
||||
return;
|
||||
}
|
||||
|
||||
pletion_line = pletion_line->next;
|
||||
pletion_x = 0;
|
||||
}
|
||||
|
||||
/* The search has reached the end of the file. */
|
||||
if (list_of_completions != NULL) {
|
||||
statusline(ALERT, _("No further matches"));
|
||||
refresh_needed = TRUE;
|
||||
} else
|
||||
/* TRANSLATORS: Shown when there are zero possible completions. */
|
||||
statusline(ALERT, _("No matches"));
|
||||
|
||||
free(shard);
|
||||
}
|
||||
#endif /* ENABLE_WORDCOMPLETION */
|
||||
|
||||
210
src/utils.c
210
src/utils.c
@@ -54,7 +54,7 @@ void get_homedir(void)
|
||||
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
/* Return the number of digits that the given integer n takes up. */
|
||||
int digits(int n)
|
||||
int digits(ssize_t n)
|
||||
{
|
||||
if (n < 100000) {
|
||||
if (n < 1000) {
|
||||
@@ -85,27 +85,22 @@ int digits(int n)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Read a ssize_t from str, and store it in *val (if val is not NULL).
|
||||
* On error, we return FALSE and don't change *val. Otherwise, we
|
||||
* return TRUE. */
|
||||
bool parse_num(const char *str, ssize_t *val)
|
||||
/* Read an integer from str. If it parses okay, store it in *result
|
||||
* and return TRUE; otherwise, return FALSE. */
|
||||
bool parse_num(const char *str, ssize_t *result)
|
||||
{
|
||||
char *first_error;
|
||||
ssize_t j;
|
||||
ssize_t value;
|
||||
|
||||
assert(str != NULL);
|
||||
|
||||
/* The manual page for strtol() says this is required, and
|
||||
* it looks like it is! */
|
||||
/* The manual page for strtol() says this is required. */
|
||||
errno = 0;
|
||||
|
||||
j = (ssize_t)strtol(str, &first_error, 10);
|
||||
value = (ssize_t)strtol(str, &first_error, 10);
|
||||
|
||||
if (errno == ERANGE || *str == '\0' || *first_error != '\0')
|
||||
return FALSE;
|
||||
|
||||
if (val != NULL)
|
||||
*val = j;
|
||||
*result = value;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -126,26 +121,24 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
|
||||
if (comma == NULL)
|
||||
return parse_num(str, line);
|
||||
|
||||
if (!parse_num(comma + 1, column))
|
||||
return FALSE;
|
||||
retval = parse_num(comma + 1, column);
|
||||
|
||||
if (comma == str)
|
||||
return TRUE;
|
||||
return retval;
|
||||
|
||||
firstpart = mallocstrcpy(NULL, str);
|
||||
firstpart[comma - str] = '\0';
|
||||
|
||||
retval = parse_num(firstpart, line);
|
||||
retval = parse_num(firstpart, line) && retval;
|
||||
|
||||
free(firstpart);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Fix the memory allocation for a string. */
|
||||
void align(char **str)
|
||||
/* Reduce the memory allocation of a string to what is needed. */
|
||||
void snuggly_fit(char **str)
|
||||
{
|
||||
assert(str != NULL);
|
||||
|
||||
if (*str != NULL)
|
||||
*str = charealloc(*str, strlen(*str) + 1);
|
||||
}
|
||||
@@ -153,8 +146,6 @@ void align(char **str)
|
||||
/* Null a string at a certain index and align it. */
|
||||
void null_at(char **data, size_t index)
|
||||
{
|
||||
assert(data != NULL);
|
||||
|
||||
*data = charealloc(*data, index + 1);
|
||||
(*data)[index] = '\0';
|
||||
}
|
||||
@@ -163,8 +154,6 @@ void null_at(char **data, size_t index)
|
||||
* normally have newlines in it, so encode its nulls as newlines. */
|
||||
void unsunder(char *str, size_t true_len)
|
||||
{
|
||||
assert(str != NULL);
|
||||
|
||||
for (; true_len > 0; true_len--, str++) {
|
||||
if (*str == '\0')
|
||||
*str = '\n';
|
||||
@@ -175,8 +164,6 @@ void unsunder(char *str, size_t true_len)
|
||||
* normally have newlines in it, so decode its newlines as nulls. */
|
||||
void sunder(char *str)
|
||||
{
|
||||
assert(str != NULL);
|
||||
|
||||
for (; *str != '\0'; str++) {
|
||||
if (*str == '\n')
|
||||
*str = '\0';
|
||||
@@ -313,11 +300,8 @@ const char *fixbounds(const char *r)
|
||||
* a separate word? That is: is it not part of a longer word?*/
|
||||
bool is_separate_word(size_t position, size_t length, const char *buf)
|
||||
{
|
||||
char *before = charalloc(mb_cur_max()), *after = charalloc(mb_cur_max());
|
||||
char before[mb_cur_max()], after[mb_cur_max()];
|
||||
size_t word_end = position + length;
|
||||
bool retval;
|
||||
|
||||
assert(buf != NULL && position < strlen(buf) && position + length <= strlen(buf));
|
||||
|
||||
/* Get the characters before and after the word, if any. */
|
||||
parse_mbchar(buf + move_mbleft(buf, position), before, NULL);
|
||||
@@ -326,58 +310,71 @@ bool is_separate_word(size_t position, size_t length, const char *buf)
|
||||
/* If the word starts at the beginning of the line OR the character before
|
||||
* the word isn't a letter, and if the word ends at the end of the line OR
|
||||
* the character after the word isn't a letter, we have a whole word. */
|
||||
retval = (position == 0 || !is_alpha_mbchar(before)) &&
|
||||
(word_end == strlen(buf) || !is_alpha_mbchar(after));
|
||||
|
||||
free(before);
|
||||
free(after);
|
||||
|
||||
return retval;
|
||||
return ((position == 0 || !is_alpha_mbchar(before)) &&
|
||||
(buf[word_end] == '\0' || !is_alpha_mbchar(after)));
|
||||
}
|
||||
#endif /* !DISABLE_SPELLER */
|
||||
|
||||
/* If we are searching backwards, we will find the last match that
|
||||
* starts no later than start. Otherwise we find the first match
|
||||
* starting no earlier than start. If we are doing a regexp search, we
|
||||
* fill in the global variable regmatches with at most 9 subexpression
|
||||
* matches. Also, all .rm_so elements are relative to the start of the
|
||||
* whole match, so regmatches[0].rm_so == 0. */
|
||||
/* Return the position of the needle in the haystack, or NULL if not found.
|
||||
* When searching backwards, we will find the last match that starts no later
|
||||
* than the given start; otherwise, we find the first match starting no earlier
|
||||
* than start. If we are doing a regexp search, and we find a match, we fill
|
||||
* in the global variable regmatches with at most 9 subexpression matches. */
|
||||
const char *strstrwrapper(const char *haystack, const char *needle,
|
||||
const char *start)
|
||||
{
|
||||
/* start can be 1 character before the start or after the end of the
|
||||
* line. In either case, we just say no match was found. */
|
||||
if ((start > haystack && *(start - 1) == '\0') || start < haystack)
|
||||
return NULL;
|
||||
|
||||
assert(haystack != NULL && needle != NULL && start != NULL);
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(USE_REGEXP)) {
|
||||
if (ISSET(BACKWARDS_SEARCH)) {
|
||||
if (regexec(&search_regexp, haystack, 1, regmatches, 0) == 0 &&
|
||||
haystack + regmatches[0].rm_so <= start) {
|
||||
const char *retval = haystack + regmatches[0].rm_so;
|
||||
size_t last_find, ceiling, far_end;
|
||||
size_t floor = 0, next_rung = 0;
|
||||
/* The start of the search range, and the next start. */
|
||||
|
||||
/* Search forward until there are no more matches. */
|
||||
while (regexec(&search_regexp, retval + 1, 1,
|
||||
regmatches, REG_NOTBOL) == 0 &&
|
||||
retval + regmatches[0].rm_so + 1 <= start)
|
||||
retval += regmatches[0].rm_so + 1;
|
||||
/* Finally, put the subexpression matches in global
|
||||
* variable regmatches. The REG_NOTBOL flag doesn't
|
||||
* matter now. */
|
||||
regexec(&search_regexp, retval, 10, regmatches, 0);
|
||||
return retval;
|
||||
if (regexec(&search_regexp, haystack, 1, regmatches, 0) != 0)
|
||||
return NULL;
|
||||
|
||||
far_end = strlen(haystack);
|
||||
ceiling = start - haystack;
|
||||
last_find = regmatches[0].rm_so;
|
||||
|
||||
/* A result beyond the search range also means: no match. */
|
||||
if (last_find > ceiling)
|
||||
return NULL;
|
||||
|
||||
/* Move the start-of-range forward until there is no more match;
|
||||
* then the last match found is the first match backwards. */
|
||||
while (regmatches[0].rm_so <= ceiling) {
|
||||
floor = next_rung;
|
||||
last_find = regmatches[0].rm_so;
|
||||
/* If this is the last possible match, don't try to advance. */
|
||||
if (last_find == ceiling)
|
||||
break;
|
||||
next_rung = move_mbright(haystack, last_find);
|
||||
regmatches[0].rm_so = next_rung;
|
||||
regmatches[0].rm_eo = far_end;
|
||||
if (regexec(&search_regexp, haystack, 1, regmatches,
|
||||
REG_STARTEND) != 0)
|
||||
break;
|
||||
}
|
||||
} else if (regexec(&search_regexp, start, 10, regmatches,
|
||||
(start > haystack) ? REG_NOTBOL : 0) == 0) {
|
||||
const char *retval = start + regmatches[0].rm_so;
|
||||
|
||||
regexec(&search_regexp, retval, 10, regmatches, 0);
|
||||
return retval;
|
||||
/* Find the last match again, to get possible submatches. */
|
||||
regmatches[0].rm_so = floor;
|
||||
regmatches[0].rm_eo = far_end;
|
||||
if (regexec(&search_regexp, haystack, 10, regmatches,
|
||||
REG_STARTEND) != 0)
|
||||
statusline(ALERT, "BAD: failed to refind the match!");
|
||||
|
||||
return haystack + regmatches[0].rm_so;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
/* Do a forward regex search from the starting point. */
|
||||
regmatches[0].rm_so = start - haystack;
|
||||
regmatches[0].rm_eo = strlen(haystack);
|
||||
if (regexec(&search_regexp, haystack, 10, regmatches,
|
||||
REG_STARTEND) != 0)
|
||||
return NULL;
|
||||
else
|
||||
return haystack + regmatches[0].rm_so;
|
||||
}
|
||||
#endif /* HAVE_REGEX_H */
|
||||
if (ISSET(CASE_SENSITIVE)) {
|
||||
@@ -475,8 +472,6 @@ size_t get_page_start(size_t column)
|
||||
* column position of the cursor. */
|
||||
size_t xplustabs(void)
|
||||
{
|
||||
assert(openfile->current != NULL);
|
||||
|
||||
return strnlenpt(openfile->current->data, openfile->current_x);
|
||||
}
|
||||
|
||||
@@ -489,8 +484,6 @@ size_t actual_x(const char *text, size_t column)
|
||||
size_t width = 0;
|
||||
/* The screen display width to text[index], in columns. */
|
||||
|
||||
assert(text != NULL);
|
||||
|
||||
while (*text != '\0') {
|
||||
int charlen = parse_mbchar(text, NULL, &width);
|
||||
|
||||
@@ -514,8 +507,6 @@ size_t strnlenpt(const char *text, size_t maxlen)
|
||||
if (maxlen == 0)
|
||||
return 0;
|
||||
|
||||
assert(text != NULL);
|
||||
|
||||
while (*text != '\0') {
|
||||
int charlen = parse_mbchar(text, NULL, &width);
|
||||
|
||||
@@ -539,14 +530,8 @@ size_t strlenpt(const char *text)
|
||||
/* Append a new magicline to filebot. */
|
||||
void new_magicline(void)
|
||||
{
|
||||
openfile->filebot->next = (filestruct *)nmalloc(sizeof(filestruct));
|
||||
openfile->filebot->next = make_new_node(openfile->filebot);
|
||||
openfile->filebot->next->data = mallocstrcpy(NULL, "");
|
||||
openfile->filebot->next->prev = openfile->filebot;
|
||||
openfile->filebot->next->next = NULL;
|
||||
openfile->filebot->next->lineno = openfile->filebot->lineno + 1;
|
||||
#ifndef DISABLE_COLOR
|
||||
openfile->filebot->next->multidata = NULL;
|
||||
#endif
|
||||
openfile->filebot = openfile->filebot->next;
|
||||
openfile->totsize++;
|
||||
}
|
||||
@@ -559,9 +544,6 @@ void remove_magicline(void)
|
||||
{
|
||||
if (openfile->filebot->data[0] == '\0' &&
|
||||
openfile->filebot != openfile->fileage) {
|
||||
assert(openfile->filebot != openfile->edittop &&
|
||||
openfile->filebot != openfile->current);
|
||||
|
||||
openfile->filebot = openfile->filebot->prev;
|
||||
free_filestruct(openfile->filebot->next);
|
||||
openfile->filebot->next = NULL;
|
||||
@@ -577,8 +559,6 @@ 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)
|
||||
{
|
||||
assert(top != NULL && top_x != NULL && bot != NULL && bot_x != NULL);
|
||||
|
||||
if ((openfile->current->lineno == openfile->mark_begin->lineno &&
|
||||
openfile->current_x > openfile->mark_begin_x) ||
|
||||
openfile->current->lineno > openfile->mark_begin->lineno) {
|
||||
@@ -597,37 +577,6 @@ void mark_order(const filestruct **top, size_t *top_x, const filestruct
|
||||
*right_side_up = FALSE;
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Calculate the number of characters between begin and end, and return
|
||||
* it. */
|
||||
size_t get_totsize(const filestruct *begin, const filestruct *end)
|
||||
{
|
||||
size_t totsize = 0;
|
||||
const filestruct *f;
|
||||
|
||||
/* Go through the lines from begin to end->prev, if we can. */
|
||||
for (f = begin; f != end && f != NULL; f = f->next) {
|
||||
/* Count the number of characters on this line. */
|
||||
totsize += mbstrlen(f->data);
|
||||
|
||||
/* Count the newline if we have one. */
|
||||
if (f->next != NULL)
|
||||
totsize++;
|
||||
}
|
||||
|
||||
/* Go through the line at end, if we can. */
|
||||
if (f != NULL) {
|
||||
/* Count the number of characters on this line. */
|
||||
totsize += mbstrlen(f->data);
|
||||
|
||||
/* Count the newline if we have one. */
|
||||
if (f->next != NULL)
|
||||
totsize++;
|
||||
}
|
||||
|
||||
return totsize;
|
||||
}
|
||||
|
||||
/* Given a line number, return a pointer to the corresponding struct. */
|
||||
filestruct *fsfromline(ssize_t lineno)
|
||||
@@ -642,13 +591,32 @@ filestruct *fsfromline(ssize_t lineno)
|
||||
f = f->next;
|
||||
|
||||
if (f->lineno != lineno) {
|
||||
statusline(ALERT, _("Internal error: can't match line %d. "
|
||||
"Please save your work."), lineno);
|
||||
statusline(ALERT, _("Internal error: can't match line %ld. "
|
||||
"Please save your work."), (long)lineno);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Count the number of characters from begin to end, and return it. */
|
||||
size_t get_totsize(const filestruct *begin, const filestruct *end)
|
||||
{
|
||||
const filestruct *line;
|
||||
size_t totsize = 0;
|
||||
|
||||
/* Sum the number of characters (plus a newline) in each line. */
|
||||
for (line = begin; line != end->next; line = line->next)
|
||||
totsize += mbstrlen(line->data) + 1;
|
||||
|
||||
/* The last line of a file doesn't have a newline -- otherwise it
|
||||
* wouldn't be the last line -- so subtract 1 when at EOF. */
|
||||
if (line == NULL)
|
||||
totsize--;
|
||||
|
||||
return totsize;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/* Dump the filestruct inptr to stderr. */
|
||||
|
||||
1167
src/winio.c
1167
src/winio.c
File diff suppressed because it is too large
Load Diff
@@ -20,7 +20,7 @@ color red "\"[^"]*\"" "\'[^']*\'"
|
||||
color green "`[^`]*`"
|
||||
|
||||
# Error lines:
|
||||
color black "^\*\*\*.*"
|
||||
color brightred "^\*\*\*.*"
|
||||
|
||||
# Brackets:
|
||||
color magenta "\[|\]|\(|\)"
|
||||
@@ -7,7 +7,7 @@ comment "//"
|
||||
color brightred "\<[A-Z_][0-9A-Z_]+\>"
|
||||
color green "\<(float|double|bool|char|int|short|long|sizeof|enum|void|auto|static|const|struct|union|typedef|extern|(un)?signed|inline)\>"
|
||||
color green "\<((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\>"
|
||||
color green "\<(class|namespace|template|public|protected|private|typename|this|friend|virtual|using|mutable|volatile|register|explicit)\>"
|
||||
color green "\<(class|namespace|template|public|protected|private|typename|this|friend|virtual|override|using|mutable|volatile|register|explicit)\>"
|
||||
color brightyellow "\<(for|if|while|do|else|case|default|switch)\>"
|
||||
color brightyellow "\<(try|throw|catch|operator|new|delete)\>"
|
||||
color magenta "\<(goto|continue|break|return)\>"
|
||||
@@ -1,6 +1,6 @@
|
||||
## Here is an example for Gentoo ebuilds/eclasses.
|
||||
|
||||
syntax "ebuild" "\.e(build|class)$"
|
||||
syntax "ebuild" "\.e(build|class|blit)$"
|
||||
comment "#"
|
||||
|
||||
## All the standard portage functions
|
||||
@@ -43,26 +43,30 @@ color yellow "(^|[[:space:]])#.*$"
|
||||
color brightyellow ""(\\.|[^\"])*"" "'(\\.|[^'])*'"
|
||||
## Trailing space is bad!
|
||||
color ,green "[[:space:]]+$"
|
||||
## Mixed whitespace is also bad.
|
||||
color ,green " "
|
||||
|
||||
## Here is an example for Portage control files.
|
||||
##
|
||||
syntax "/etc/portage" "\.(accept_keywords|env|keywords|mask|unmask|use)(/.+)?$"
|
||||
## Base text:
|
||||
color green "^.+$"
|
||||
## Use flags:
|
||||
color brightred "[[:space:]]+\+?[a-zA-Z0-9_-]+"
|
||||
color brightblue "[[:space:]]+-[a-zA-Z0-9_-]+"
|
||||
## Likely version and slot numbers:
|
||||
color magenta "-[[:digit:]].*([[:space:]]|$)"
|
||||
color magenta "-[[:digit:].]+(_(alpha|beta|pre|rc|p)[[:digit:]]*)*(-r[[:digit:]]+)?([:[:space:]]|$)"
|
||||
color magenta ":[^[:space:]]+([[:space:]]|$)"
|
||||
## Use flags (must come after version/slot):
|
||||
color brightred "[[:space:]]+\+?[A-Za-z0-9+_@-]+"
|
||||
color brightblue "[[:space:]]+-[A-Za-z0-9+_@-]+"
|
||||
## Accepted arches:
|
||||
color white "[~-]?\<(alpha|amd64|arm|hppa|ia64|mips|ppc|ppc64|s390|sh|sparc(-fbsd)?|x86(-fbsd)?)\>"
|
||||
color white "[~-]?\<(alpha|amd64|arm(64)?|hppa|ia64|m68k|mips|nios2|ppc(64)?|riscv|s390|sh|sparc|x86)(-(aix|(f|free|net|open)bsd|cygwin|hpux|interix|linux|macos|mint|solaris|winnt))?\>"
|
||||
color white "[[:space:]][*~-]?\*"
|
||||
## Categories:
|
||||
color cyan "^[[:space:]]*.*/"
|
||||
color cyan "^[[:space:]]*[^/]*/"
|
||||
## Masking regulators:
|
||||
color brightmagenta "^[[:space:]]*(=|~|<|<=|=<|>|>=|=>)"
|
||||
color brightmagenta "^[[:space:]]*(=|~|<|<=|>|>=)"
|
||||
## Comments:
|
||||
color yellow "#.*$"
|
||||
## Trailing space is bad!
|
||||
color ,green "[[:space:]]+$"
|
||||
## Mixed whitespace is also bad.
|
||||
color ,green " "
|
||||
28
syntax/html.nanorc
Normal file
28
syntax/html.nanorc
Normal file
@@ -0,0 +1,28 @@
|
||||
## Here is an example for HTML.
|
||||
|
||||
syntax "html" "\.html?$"
|
||||
magic "HTML document text"
|
||||
comment "<!--|-->"
|
||||
|
||||
# Tags:
|
||||
color cyan start="<[[:alpha:]/!?]" end=">"
|
||||
# Bold, italic, and underlined:
|
||||
color brightmagenta "</?[biu]>"
|
||||
|
||||
# Named character references:
|
||||
color red "&[^;[:space:]]*;"
|
||||
# Strings:
|
||||
color green ""(\\.|[^"])*""
|
||||
|
||||
# Attributes:
|
||||
color red "(abbr|accept(-charset)?|accesskey|action|alink|align|alt|archive|axis|background|bgcolor|border)="
|
||||
color red "(cell(padding|spacing)|char(off|set)?|checked|cite|class(id)?|compact|code(base|tag)?|cols(pan)?)="
|
||||
color red "(content(editable)?|contextmenu|coords|data|datetime|declare|defer|dir|disabled|enctype)="
|
||||
color red "(for|frame(border)?|headers|height|hidden|href(lang)?|hspace|http-equiv|id|ismap)="
|
||||
color red "(label|lang|link|longdesc|margin(height|width)|maxlength|media|method|multiple)="
|
||||
color red "(name|nohref|noresize|noshade|object|onclick|onfocus|onload|onmouseover|profile|readonly|rel|rev)="
|
||||
color red "(rows(pan)?|rules|scheme|scope|scrolling|selected|shape|size|span|src|standby|start|style|summary)="
|
||||
color red "(tabindex|target|text|title|type|usemap|valign|value(type)?|vlink|vspace|width|xmlns|xml:space)="
|
||||
|
||||
# Comments:
|
||||
color yellow start="<!--" end="-->"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user