Compare commits
94 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bec0cdcb54 | ||
|
|
ba9e5ac05d | ||
|
|
46b5f83601 | ||
|
|
6d5b16562f | ||
|
|
508301a2ef | ||
|
|
2f216281e7 | ||
|
|
9459030d66 | ||
|
|
f545735638 | ||
|
|
bb8f40989f | ||
|
|
675ad6386d | ||
|
|
6ce3487b65 | ||
|
|
bc7e7d847e | ||
|
|
71a73a1a10 | ||
|
|
c2790a8af3 | ||
|
|
fde86518ae | ||
|
|
61b3aa6626 | ||
|
|
6799bc69a6 | ||
|
|
0c01227d86 | ||
|
|
c74fd81302 | ||
|
|
4b30cfb8f8 | ||
|
|
36b6416a7b | ||
|
|
e0334e861d | ||
|
|
b07fb5a811 | ||
|
|
9ab49658d7 | ||
|
|
bb3d367716 | ||
|
|
26c0a7962e | ||
|
|
a2b20a1915 | ||
|
|
2087c20a83 | ||
|
|
5512c63bdd | ||
|
|
d31cf1da68 | ||
|
|
ce656cfca8 | ||
|
|
46cdf8b745 | ||
|
|
fdc0b0ac24 | ||
|
|
42b7dea14b | ||
|
|
239c794503 | ||
|
|
189960c467 | ||
|
|
04f8aa83ef | ||
|
|
802a20b222 | ||
|
|
88f7ec38f8 | ||
|
|
baaff48547 | ||
|
|
0010cd4443 | ||
|
|
7d6ffd9e78 | ||
|
|
b8daf1fb0b | ||
|
|
fe5f05f037 | ||
|
|
5cedb53c62 | ||
|
|
650dc14e0f | ||
|
|
43ebabe05d | ||
|
|
b6366411dc | ||
|
|
914921887e | ||
|
|
64a8f1930e | ||
|
|
0ac2dfd920 | ||
|
|
aa553ee5d6 | ||
|
|
a8961c561f | ||
|
|
abce19b0e4 | ||
|
|
fc317660cb | ||
|
|
949fcde6f7 | ||
|
|
9f24b6ea65 | ||
|
|
c6ba4ae89a | ||
|
|
dab3f95c71 | ||
|
|
840ad5890f | ||
|
|
ae61bab60b | ||
|
|
d3a7f3abed | ||
|
|
694cd9ddd4 | ||
|
|
47c8e627f4 | ||
|
|
f429ebe34d | ||
|
|
083bbae0e4 | ||
|
|
eaff5ec9e5 | ||
|
|
51eb938fea | ||
|
|
296c5a32c7 | ||
|
|
ef6ccc47c8 | ||
|
|
eea2dfce48 | ||
|
|
85682abbd5 | ||
|
|
4005ee3284 | ||
|
|
9ead4c87a7 | ||
|
|
1b5d9171f2 | ||
|
|
50543300d9 | ||
|
|
d9469b894f | ||
|
|
6b9c24f7dd | ||
|
|
5954eeaff2 | ||
|
|
c84a769733 | ||
|
|
e3ef778756 | ||
|
|
806e8e439f | ||
|
|
30aaea2d04 | ||
|
|
d0cb64650b | ||
|
|
0694255893 | ||
|
|
5563c710d0 | ||
|
|
177e4e5805 | ||
|
|
8d1a666dcf | ||
|
|
fc01c5a10e | ||
|
|
896f174f94 | ||
|
|
7b4a835df4 | ||
|
|
ac85e16458 | ||
|
|
45420968ee | ||
|
|
3c35538e8b |
103
ChangeLog
103
ChangeLog
@@ -1,3 +1,106 @@
|
||||
Changes between v5.8 and v5.9:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (88):
|
||||
browser: make the keystrokes ^W^Y and ^W^V work again
|
||||
build: ensure that mkstemps() is available by importing the gnulib module
|
||||
build: help Haiku find the header files that define mkstemps()
|
||||
bump version numbers and add a news item for the 5.9 release
|
||||
copyright: update to the current year for significantly changed files
|
||||
cutting: copy anchors into the cutbuffer, so that undo can restore them
|
||||
docs: add a paragraph at the start of the README about what nano is
|
||||
docs: add a simulated "screenshot" of nano to the README
|
||||
docs: add some details to the bug-reporting paragraph in the README
|
||||
docs: correct the descriptions of how to invoke the spell checker
|
||||
docs: don't use "light" after "bold", as the latter often implies "light"
|
||||
docs: improve the description of the spotlighting of a search match
|
||||
docs: improve the description of the 'tabstospaces' option
|
||||
docs: improve the descriptions of several bindable functions
|
||||
docs: improve the recipe in the FAQ for dealing with Alt+Up on a console
|
||||
docs: indent the paragraphs in the FAQ that list commands to be typed
|
||||
docs: list the default color combo for 'spotlightcolor' in sample nanorc
|
||||
docs: mention how to properly colorize all types in nano's source code
|
||||
docs: mention in the README which licenses cover nano's code and docs
|
||||
docs: move the notice in the main man page, to try and catch other eyes
|
||||
docs: refer to the FAQ when <Alt+Up> does nothing on a Linux console
|
||||
docs: replace a non-problem in the FAQ with something possibly useful
|
||||
docs: spell "filename" as a single word, like in most other occurrences
|
||||
feedback: use a smaller diamond to represent an anchor, to not overflow
|
||||
feedback: when not in curses mode, just skip displaying any message
|
||||
feedback: when not in curses mode, write error messages to the terminal
|
||||
files: add the original file's suffix to the name of a temporary file
|
||||
files: check for a fifo only when it is an existing file
|
||||
files: check the result of fdopen(), to avoid a possible crash
|
||||
files: do not call fsync() on a fifo, to avoid a spurious error message
|
||||
files: exclude the call of fsync() from the tiny version
|
||||
files: give the user time to absorb a warning about someone else editing
|
||||
files: making a backup of a fifo makes no sense, so do not try that
|
||||
files: prepending to a fifo makes no sense, so do not try that
|
||||
files: when the buffer is nameless, include the PID in name of dump file
|
||||
files: when there is a slash after the dot, then there is no extension
|
||||
files: write a lock file also for a freshly saved buffer
|
||||
general: prevent die() from getting recursed into
|
||||
gnulib: update to its current upstream state
|
||||
help: make the keystrokes ^W^Y and ^W^V work again
|
||||
history: emit a warning when file cannot be made private [coverity]
|
||||
input: give up on the input stream only after millions of errors
|
||||
memory: free any allocated strings, also in the emergency code path
|
||||
po: delete the ancient PO files for Indonesian and Nynorsk
|
||||
po: permit the Indonesian PO file to come back -- there was a big update
|
||||
shutdown: when dying, do not install/restore a handler for Ctrl+C
|
||||
startup: if TERM is unset, try falling back to VT220 instead of failing
|
||||
syntax: nanorc: recognize also the template of the sample nanorc file
|
||||
syntax: rust: update the license to GPL3 or newer
|
||||
syntax: yaml: allow any character in tags except whitespace
|
||||
syntax: yaml: allow double colon in key & do not colorize unspaced colon
|
||||
syntax: yaml: allow slash and period in key names
|
||||
syntax: yaml: colorize backslash-escaped characters as valid or invalid
|
||||
syntax: yaml: colorize the question mark of complex mappings too
|
||||
syntax: yaml: colorize the two known directives
|
||||
syntax: yaml: new file -- coloring rules for YAML files
|
||||
tweaks: add Schiermonnikoog to the list of friendly islands
|
||||
tweaks: adjust a description of 'showcursor', to match the other ones
|
||||
tweaks: adjust three parameters -- two were mistaken, one superfluous
|
||||
tweaks: correct two typos and a spello [codespell]
|
||||
tweaks: fix a typo
|
||||
tweaks: fold two lines into two others, for conciseness
|
||||
tweaks: harmonize the indentations in the FAQ somewhat
|
||||
tweaks: in comments, say "buffer" instead of "file" where appropriate
|
||||
tweaks: instead of "one" use "you", like in the rest of the man page
|
||||
tweaks: remove a redundant feedback message
|
||||
tweaks: rename a defined type, to fit within the general pattern
|
||||
tweaks: rename a function, to be more fitting
|
||||
tweaks: rename a parameter and invert its logic
|
||||
tweaks: rename a parameter, to fit better what it is used for
|
||||
tweaks: rename a variable and flip its logic, to avoid two negations
|
||||
tweaks: rename a variable, away form an abbreviation
|
||||
tweaks: rename a variable, to be more grammatical
|
||||
tweaks: rename a variable, to be more visible and to match others
|
||||
tweaks: rename a variable, to make more sense
|
||||
tweaks: rename three variables, to follow the general scheme
|
||||
tweaks: reshuffle a few lines, for esthetics and to elide an #ifdef
|
||||
tweaks: reshuffle a few lines to avoid an #ifdef and unbalanced braces
|
||||
tweaks: reshuffle a fragment of code, to prepare for the next change
|
||||
tweaks: reshuffle some code to elide a variable, and improve a comment
|
||||
tweaks: reshuffle some lines and adjust some indentation
|
||||
tweaks: reshuffle some lines to elide a variable
|
||||
tweaks: restore a quote that was accidentally deleted four months ago
|
||||
tweaks: rewrap three lines, for esthetics
|
||||
tweaks: slightly reword or rewrap some comments in the sample nanorc
|
||||
tweaks: try chmodding a dump file only when it was actually written
|
||||
tweaks: use five symbolic names, to make eight function calls clearer
|
||||
usage: improve the description of the --positionlog option
|
||||
|
||||
David Michael (2):
|
||||
syntax: gentoo: highlight additional EAPI 7/8 variables
|
||||
syntax: gentoo: remove some obsolete keywords and add some new ones
|
||||
|
||||
Hussam al-Homsi (3):
|
||||
docs: correct the default value of the errorcolor option
|
||||
syntax: perl, ruby: remove arbitrary highlighting of here documents
|
||||
tweaks: change 'return ++var;' to 'return var + 1;'
|
||||
|
||||
|
||||
Changes between v5.7 and v5.8:
|
||||
------------------------------
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ Improvements in GNU nano
|
||||
========================
|
||||
|
||||
Since 5.0:
|
||||
- A search highlights the found text, in black on yellow by default.
|
||||
- A search briefly spotlights the found text, in black on yellow by default.
|
||||
- Option --minibar reduces the interface to a bottom bar with basic info.
|
||||
- The cursor skips over combining characters, <Del> deletes them together
|
||||
with the character they combine with, but <Bsp> deletes them separately.
|
||||
|
||||
21
NEWS
21
NEWS
@@ -1,3 +1,14 @@
|
||||
2021.10.06 - GNU nano 5.9 "El manicomio ha decidido: mañana sol!"
|
||||
• The extension of a filename is added to the name of a corresponding
|
||||
temporary file, so that spell checking a C file, for example, will
|
||||
check only the comments and strings (when using 'aspell').
|
||||
• The process number is added to the name of an emergency save file,
|
||||
so that when multiple nanos die they will not fight over a filename.
|
||||
• Undoing a cutting operation will restore an anchor that was located
|
||||
in the cut area to its original line.
|
||||
• When using --locking, saving a new buffer will create a lock file.
|
||||
• Syntax highlighting for YAML files has been added.
|
||||
|
||||
2021.06.15 - GNU nano 5.8 "Why is it necessary to be special?"
|
||||
• After a search, the spotlighting is dropped after 1.5 seconds (0.8
|
||||
seconds with --quick) to avoid the idea that the text is selected.
|
||||
@@ -1212,9 +1223,9 @@
|
||||
Have fun with it.
|
||||
|
||||
2005.06.30 - GNU nano 1.3.8 floats at its own level. This release
|
||||
contains several new features. Among other things, you
|
||||
can now move to a specified column number as well as
|
||||
line number within a file, file backups saved in a
|
||||
contains several new features. Among other things,
|
||||
you can now move to a specified column number as well
|
||||
as line number within a file, file backups saved in a
|
||||
backup directory will have unique names, the search and
|
||||
replace history routines should work more consistently,
|
||||
you can get a word count by pressing Meta-D at the edit
|
||||
@@ -1225,8 +1236,8 @@
|
||||
screen updates, UTF-8 display, and flow control; a fix
|
||||
for a segfault when displaying some lines ending with
|
||||
tabs; better handling of constant cursor position
|
||||
display; improved color parsing in the rcfile; and
|
||||
support for the "Regexp" toggle in tiny mode
|
||||
display; improved color parsing in the rcfile;
|
||||
and support for the "Regexp" toggle in tiny mode
|
||||
(-R/--regexp is gone, and --restricted's short option
|
||||
has been changed to -R), among other things. Enjoy.
|
||||
|
||||
|
||||
61
README
61
README
@@ -1,10 +1,42 @@
|
||||
|
||||
GNU nano -- a simple editor, inspired by Pico
|
||||
|
||||
Overview
|
||||
Purpose
|
||||
|
||||
The nano project was started because of a few "problems" with the
|
||||
wonderfully easy-to-use and friendly Pico text editor.
|
||||
Nano is a small and simple text editor for use on the terminal.
|
||||
It copied the interface and key bindings of the Pico editor but
|
||||
added several missing features: undo/redo, syntax highlighting,
|
||||
line numbers, softwrapping, multiple buffers, selecting text by
|
||||
holding Shift, search-and-replace with regular expressions, and
|
||||
several other conveniences.
|
||||
|
||||
Appearance
|
||||
|
||||
In rough ASCII graphics, this is what nano's screen looks like:
|
||||
|
||||
____________________________________________________________________
|
||||
| GNU nano 5.9 filename Modified |
|
||||
--------------------------------------------------------------------
|
||||
| This is the text window, displaying the contents of a 'buffer', |
|
||||
| the contents of the file you are editing. |
|
||||
| |
|
||||
| The top row of the screen is the 'title bar'; it shows nano's |
|
||||
| version, the name of the file, and whether you modified it. |
|
||||
| The two bottom rows display the most important shortcuts; in |
|
||||
| those lines ^ means Ctrl. The third row from the bottom shows |
|
||||
| some feedback message, or gets replaced with a prompt bar when |
|
||||
| you tell nano to do something that requires extra input. |
|
||||
| |
|
||||
--------------------------------------------------------------------
|
||||
| [ Some status message ] |
|
||||
|^G Help ^O Write Out ^W Where Is ^K Cut ^T Execute |
|
||||
|^X Exit ^R Read File ^\ Replace ^U Paste ^J Justify |
|
||||
--------------------------------------------------------------------
|
||||
|
||||
Origin
|
||||
|
||||
The nano project was started in 1999 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, and (before using the Apache License) it had unclear
|
||||
@@ -23,6 +55,19 @@ Overview
|
||||
The nano editor is an official GNU package. For more information on
|
||||
GNU and the Free Software Foundation, please see https://www.gnu.org/.
|
||||
|
||||
License
|
||||
|
||||
Nano's code and documentation are covered by the GPL version 3 or
|
||||
(at your option) any later version, except for two functions that
|
||||
were copied from busybox which are under a BSD license. Nano's
|
||||
documentation is additionally covered by the GNU Free Documentation
|
||||
License version 1.2 or (at your option) any later version. See the
|
||||
files COPYING and COPYING.DOC for the full text of these licenses.
|
||||
|
||||
When in any file of this package a copyright notice mentions a
|
||||
year range (such as 1999-2011), it is a shorthand for a list of
|
||||
all the years in that interval.
|
||||
|
||||
How to compile and install nano
|
||||
|
||||
Download the latest nano source tarball, and then:
|
||||
@@ -70,10 +115,8 @@ Mailing Lists
|
||||
Bug Reports
|
||||
|
||||
If you find a bug, please file a detailed description of the problem
|
||||
on nano's bug tracker: https://savannah.gnu.org/bugs/?group=nano.
|
||||
on nano's issue tracker: https://savannah.gnu.org/bugs/?group=nano
|
||||
(you will need an account to be able to do so), or send an email
|
||||
to the nano-devel list (no need to subscribe, but mention it if
|
||||
you want to be CC'ed on an answer).
|
||||
|
||||
Copyright Years
|
||||
|
||||
When in any file of this package a copyright notice mentions a
|
||||
year range (such as 1999-2011), it is a shorthand for a list of
|
||||
all the years in that interval.
|
||||
|
||||
@@ -84,7 +84,6 @@ Problems?
|
||||
Please submit any bugs you find in the code in git via the bug tracker
|
||||
on Savannah (https://savannah.gnu.org/bugs/?group=nano).
|
||||
|
||||
|
||||
Contributing something
|
||||
----------------------
|
||||
|
||||
@@ -114,3 +113,11 @@ to include 'set tabsize 4', or you could use -T4 on the command line.
|
||||
To make git display things as intended, you can do:
|
||||
|
||||
$ git config --local core.pager "less -x1,5"
|
||||
|
||||
To see all types that are used in nano's source code colorized as types,
|
||||
you can add these lines to your ~/.nanorc:
|
||||
|
||||
extendsyntax c color green "\<struct (dirent|option|passwd)\>"
|
||||
extendsyntax c color green "\<struct (sigaction|stat|termios)\>"
|
||||
extendsyntax c color green "\<struct (timespec|vt_stat|winsize)\>"
|
||||
extendsyntax c color green "\<([[:lower:]_]+(struct|type)|va_list)\>"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Generate configure & friends for GIT users.
|
||||
|
||||
gnulib_url="git://git.sv.gnu.org/gnulib.git"
|
||||
gnulib_hash="ff7c8b21e259fdc4bc721ed55519cfee06739efa"
|
||||
gnulib_hash="9aca7b67333fd0a90bf56104325ce96199644451"
|
||||
|
||||
modules="
|
||||
futimens
|
||||
@@ -13,6 +13,7 @@ modules="
|
||||
isblank
|
||||
iswblank
|
||||
lstat
|
||||
mkstemps
|
||||
nl_langinfo
|
||||
regex
|
||||
sigaction
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
|
||||
AC_INIT([GNU nano], [5.8], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [5.9], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AC_CANONICAL_HOST
|
||||
AM_INIT_AUTOMAKE([1.14])
|
||||
|
||||
77
doc/faq.html
77
doc/faq.html
@@ -5,6 +5,9 @@
|
||||
<title>The GNU nano editor FAQ</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="description" content="The genesis story of the nano editor, plus the solution to some common problems.">
|
||||
<style>
|
||||
.indented { margin-left: 2em; font-family: courier; font-size: 110%; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body text="#330000" bgcolor="#ffffff" link="#0000ef" vlink="#51188e" alink="#ff0000">
|
||||
@@ -40,7 +43,7 @@
|
||||
</p></blockquote>
|
||||
<h3><a href="#4">4. Running</a></h3>
|
||||
<blockquote><p>
|
||||
<a href="#4.1">4.1. How do I open a file with a name beginning with '+' from the command line?</a><br>
|
||||
<a href="#4.1">4.1. Alt+Up does nothing on a Linux console. How can I make it scroll?</a><br>
|
||||
<a href="#4.2">4.2. How can I make Ctrl+Shift+Left/Right select words on urxvt?</a><br>
|
||||
<a href="#4.3">4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</a><br>
|
||||
<a href="#4.4">4.4. With what keystroke can I paste text from the clipboard into nano?</a><br>
|
||||
@@ -89,7 +92,7 @@
|
||||
<h3><a name="1.3"></a>1.3. Why the name change from TIP?</h3>
|
||||
<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>
|
||||
<h3><a name="1.4"></a>1.4. What is the current version of nano?</h3>
|
||||
<blockquote><p>The current version of nano <i>should</i> be <b>5.8</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>
|
||||
<blockquote><p>The current version of nano <i>should</i> be <b>5.9</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>
|
||||
<h3><a name="1.5"></a>1.5. I want to read the man page without having to download the program!</h3>
|
||||
<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%">
|
||||
@@ -127,39 +130,39 @@
|
||||
<blockquote><p>It's simple really! As root, type <b>rpm -Uvh nano-x.y-1*.rpm</b> if you have a RedHat-ish system or <b>dpkg -i nano_x.y-1*.deb</b> if you have a Debian-ish system, where <b>x.y</b> is the version number of nano. There are other programs to install packages, and if you wish to use those, knock yourself out.</p></blockquote>
|
||||
<h3><a name="3.2"></a>3.2. Compiling from source: WHAT THE HECK DO I DO NOW?</h3>
|
||||
<blockquote><p>Okay, take a deep breath, this really isn't hard. Unpack the nano source with a command like:</p>
|
||||
<p><b>tar -xvf nano-x.y.tar.gz</b></p>
|
||||
<p class="indented"><b>tar -xvf nano-x.y.tar.gz</b></p>
|
||||
<p>Then you need to run <b>configure</b> with any options you might want (if any).</p>
|
||||
<p>The average case is this:</p>
|
||||
<p><b>cd nano-x.y/</b><br>
|
||||
<p class="indented"><b>cd nano-x.y/</b><br>
|
||||
<b>./configure</b><br>
|
||||
<b>make</b><br>
|
||||
<b>make install</b> (as root, of course)</p></blockquote>
|
||||
<b>make install</b> #(as root, of course)</p></blockquote>
|
||||
<h3><a name="3.3"></a>3.3. Why does everything go into /usr/local?</h3>
|
||||
<blockquote><p>Well, that's what the <b>configure</b> script defaults to. If you wish to change this, simply do this:</p>
|
||||
<p><b>./configure --prefix=/usr</b></p>
|
||||
<p class="indented"><b>./configure --prefix=/usr</b></p>
|
||||
<p>This will put nano into /usr/bin when you run <b>make install</b>.</p></blockquote>
|
||||
<h3><a name="3.4"></a>3.4. nano should automatically run strip on the binary when installing it!</h3>
|
||||
<blockquote><p>It does when you use <b>make install-strip</b>. The default <b>make install</b> does not, and will not, run strip automatically.</p></blockquote>
|
||||
<h3><a name="3.5"></a>3.5. How can I make the executable smaller? This is too bloated!</h3>
|
||||
<blockquote><p>Actually, there are several parts of the editor that can be disabled. You can pass arguments to the <b>configure</b> script that disable certain features. Here's a brief list:</p>
|
||||
<pre>
|
||||
<b>--disable-browser</b> Disable the built-in file browser
|
||||
<b>--disable-color</b> Disable color and syntax highlighting
|
||||
<b>--disable-comment</b> Disable the comment/uncomment function
|
||||
<b>--disable-extra</b> Disable the easter egg
|
||||
<b>--disable-help</b> Disable the built-in help texts
|
||||
<b>--disable-histories</b> Disable the saving of search strings and cursor positions
|
||||
<b>--disable-justify</b> Disable the justify/unjustify functions
|
||||
<b>--disable-libmagic</b> Disable the use of libmagic for determining a file's syntax
|
||||
<b>--disable-linenumbers</b> Disable line numbering
|
||||
<b>--disable-mouse</b> Disable mouse support
|
||||
<b>--disable-multibuffer</b> Disable the opening of multiple file buffers
|
||||
<b>--disable-nanorc</b> Disable the use of .nanorc files
|
||||
<b>--disable-operatingdir</b> Disable the setting of an operating directory
|
||||
<b>--disable-speller</b> Disable the spell-checker functions
|
||||
<b>--disable-tabcomp</b> Disable the tab-completion functions
|
||||
<b>--disable-wordcomp</b> Disable the word-completion function
|
||||
<b>--disable-wrapping</b> Disable all hard-wrapping of text</pre>
|
||||
<b>--disable-browser</b> Disable the built-in file browser
|
||||
<b>--disable-color</b> Disable color and syntax highlighting
|
||||
<b>--disable-comment</b> Disable the comment/uncomment function
|
||||
<b>--disable-extra</b> Disable the easter egg
|
||||
<b>--disable-help</b> Disable the built-in help texts
|
||||
<b>--disable-histories</b> Disable the saving of search strings and cursor positions
|
||||
<b>--disable-justify</b> Disable the justify/unjustify functions
|
||||
<b>--disable-libmagic</b> Disable the use of libmagic for determining a file's syntax
|
||||
<b>--disable-linenumbers</b> Disable line numbering
|
||||
<b>--disable-mouse</b> Disable mouse support
|
||||
<b>--disable-multibuffer</b> Disable the opening of multiple file buffers
|
||||
<b>--disable-nanorc</b> Disable the use of .nanorc files
|
||||
<b>--disable-operatingdir</b> Disable the setting of an operating directory
|
||||
<b>--disable-speller</b> Disable the spell-checker functions
|
||||
<b>--disable-tabcomp</b> Disable the 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 undo/redo code and the code for selecting text). Also, if you know you don't need other languages, you can use <b>--disable-nls</b> to disable internationalization and save a few kilobytes. And finally, there's always good old <b>strip</b> to remove all unneeded symbols.</p>
|
||||
</blockquote>
|
||||
<h3><a name="3.6"></a>3.6. Tell me more about this multibuffer stuff!</h3>
|
||||
@@ -175,13 +178,19 @@
|
||||
<hr width="100%">
|
||||
|
||||
<h1><a name="4"></a>4. Running</h1>
|
||||
<h3><a name="4.1"></a>4.1. How do I open a file with a name beginning with '+' from the command line?</h3>
|
||||
<blockquote><p>If a command-line argument that begins with '+' is followed by another argument, the former is always treated as a starting line (plus column number), and the latter always as a filename. If a command-line argument that begins with '+' isn't followed by another argument, it's treated as a filename. Examples:</p>
|
||||
<p>To open '+filename.txt': <b>nano +filename.txt</b><br>
|
||||
To open '+filename.txt' starting on line 10: <b>nano +10 +filename.txt</b><br>
|
||||
To open '+filename.txt' starting on line 1, column 20: <b>nano +,20 +filename.txt</b><br>
|
||||
To open '+filename.txt' starting on line 10, column 20: <b>nano +10,20 +filename.txt</b><br>
|
||||
To open '+filename.txt' starting on line 1 and 'filename.txt' starting on line 40: <b>nano +1 +filename.txt +40 filename.txt</b></p></blockquote>
|
||||
<h3><a name="4.1"></a>4.1. Alt+Up does nothing on a Linux console. How can I make it scroll?</h3>
|
||||
<blockquote><p>On Debian and its derivatives, the <b>Alt+Up</b> keystroke on a Linux console
|
||||
produces by default a 'KeyboardSignal', which normally does absolutely nothing and is useless
|
||||
for the average user. To get the keystroke to do what it ought to do (scroll the viewport
|
||||
one row up), run this in a Linux console:</p>
|
||||
<p class="indented"><b>dumpkeys --full | sed s/KeyboardSignal/Up/ | sudo loadkeys -</b></p>
|
||||
<p>You will need to run this command whenever you first switch to a Linux console.</p>
|
||||
<p>Or you can (as root) execute the following little script just once:</p>
|
||||
<p class="indented"><b>for file in /etc/console-setup/cached*.kmap.gz; do<br>
|
||||
gunzip $file;<br>
|
||||
sed -i 's/KeyboardSignal/Up/' ${file%.gz};<br>
|
||||
gzip ${file%.gz};<br>
|
||||
done</b></p></blockquote>
|
||||
<h3><a name="4.2"></a>4.2. How can I make Ctrl+Shift+Left/Right select words on urxvt?</h3>
|
||||
<blockquote><p>The urxvt terminal emulator produces non-standard escape sequences for the modified cursor keys. These deviant sequences are not listed in the terminfo database, which means that ncurses does not recognize them. The easiest way around this is to tell urxvt to produce xterm-compatible escape sequences for the relevant keystrokes. To achieve this, add the following lines to your ~/.Xresources file:</p>
|
||||
<pre>
|
||||
@@ -219,16 +228,16 @@
|
||||
<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>syntax/</b> subdirectory of the nano source, which are normally installed to <b>/usr/local/share/nano/</b>. To enable all of them, uncomment the line <b># include "/usr/local/share/nano/*.nanorc"</b> in your nanorc. See also section <a href="#3.9">3.9</a>.</p></blockquote>
|
||||
<h3><a name="4.9"></a>4.9. How do I make nano my default editor (in Pine, mutt, etc.)?</h3>
|
||||
<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 class="indented"><b>export EDITOR=/usr/local/bin/nano</b></p>
|
||||
<p>or, if you use tcsh, put this in your <b>.cshrc</b> file:</p>
|
||||
<p><b>setenv EDITOR /usr/local/bin/nano</b></p>
|
||||
<p class="indented"><b>setenv EDITOR /usr/local/bin/nano</b></p>
|
||||
<p>Change /usr/local/bin/nano to wherever nano is installed on your system. Type "which nano" to find out. This will not take effect until the next time you log in. So log out and back in again.</p>
|
||||
<p>Then, on top of that, if you use Pine, you must go into setup (type <b>S</b> at the main menu), and then configure (type <b>C</b>). Hit Enter on the lines that say:</p>
|
||||
<p><b>[ ] enable-alternate-editor-cmd</b><br>
|
||||
<p class="indented"><b>[ ] enable-alternate-editor-cmd</b><br>
|
||||
<b>[ ] enable-alternate-editor-implicitly</b></p>
|
||||
<p>Then exit (<b>E</b>) and select Yes (<b>Y</b>).</p>
|
||||
<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</b></p>
|
||||
<p class="indented"><b>my_hdr X-Composer: nano-x.y</b></p>
|
||||
<p>Again, replace x.y with the version of nano you use.</p></blockquote>
|
||||
<hr width="100%">
|
||||
|
||||
|
||||
45
doc/nano.1
45
doc/nano.1
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANO 1 "version 5.8" "June 2021"
|
||||
.TH NANO 1 "version 5.9" "October 2021"
|
||||
|
||||
.SH NAME
|
||||
nano \- Nano's ANOther editor, inspired by Pico
|
||||
@@ -27,20 +27,6 @@ nano \- Nano's ANOther editor, inspired by Pico
|
||||
.sp
|
||||
.BR nano " [" \fIoptions "] [[" + [ crCR ]( / | ? ) \fIstring "] " \fIfile ]...
|
||||
|
||||
.SH NOTICE
|
||||
Since version 4.0, \fBnano\fR by default:
|
||||
.sp
|
||||
.RS 4
|
||||
\(bu does not automatically hard-wrap lines that become overlong,
|
||||
.br
|
||||
\(bu includes the line below the title bar in the editing area,
|
||||
.br
|
||||
\(bu does linewise (smooth) scrolling.
|
||||
.RE
|
||||
.sp
|
||||
If you want the old, Pico behavior back, you can use \fB\-\-breaklonglines\fR,
|
||||
\fB\-\-emptyline\fR, and \fB\-\-jumpyscrolling\fR (or \fB\-bej\fR for short).
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fBnano\fP is a small and friendly editor. It copies the look and feel
|
||||
of Pico, but is free software, and implements several features that Pico
|
||||
@@ -58,7 +44,7 @@ regular expression by inserting \fBc\fR and/or \fBr\fR after the \fB+\fR sign.
|
||||
These search modes can be explicitly disabled by using the uppercase variant
|
||||
of those letters: \fBC\fR and/or \fBR\fR. When the string contains spaces,
|
||||
it needs to be enclosed in quotes. To give an example: to open a file at
|
||||
the first occurrence of the word "Foo", one would do:
|
||||
the first occurrence of the word "Foo", you would do:
|
||||
.sp
|
||||
.RS 4
|
||||
.BI "nano +c/Foo " file
|
||||
@@ -77,11 +63,11 @@ Any cursor movement or executing any other command will cause the next
|
||||
\fB^K\fR to overwrite the cutbuffer. A \fB^U\fR will paste the current
|
||||
contents of the cutbuffer at the current cursor position.
|
||||
.sp
|
||||
When a more precise piece of text needs to be cut or copied, one can mark
|
||||
When a more precise piece of text needs to be cut or copied, you can mark
|
||||
its start with \fB^6\fR, move the cursor to its end (the marked text will be
|
||||
highlighted), and then use \fB^K\fR to cut it, or \fBM\-6\fR to copy it to the
|
||||
cutbuffer. One can also save the marked text to a file with \fB^O\fR, or
|
||||
spell check it with \fB^T\fR.
|
||||
cutbuffer. You can also save the marked text to a file with \fB^O\fR, or
|
||||
spell check it with \fB^T^T\fR.
|
||||
.sp
|
||||
On some terminals, text can be selected also by holding down Shift while
|
||||
using the arrow keys. Holding down the Ctrl or Alt key too will increase
|
||||
@@ -93,6 +79,20 @@ the built-in help (\fB^G\fR) lists all the available ones.
|
||||
The default key bindings can be changed via a \fInanorc\fR file -- see
|
||||
.BR nanorc (5).
|
||||
|
||||
.SH NOTICE
|
||||
Since version 4.0, \fBnano\fR by default:
|
||||
.sp
|
||||
.RS 4
|
||||
\(bu does not automatically hard-wrap lines that become overlong,
|
||||
.br
|
||||
\(bu includes the line below the title bar in the editing area,
|
||||
.br
|
||||
\(bu does linewise (smooth) scrolling.
|
||||
.RE
|
||||
.sp
|
||||
If you want the old, Pico behavior back, you can use \fB\-\-breaklonglines\fR,
|
||||
\fB\-\-emptyline\fR, and \fB\-\-jumpyscrolling\fR (or \fB\-bej\fR for short).
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.BR \-A ", " \-\-smarthome
|
||||
@@ -118,7 +118,8 @@ by setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, \fBkeycolor\fP,
|
||||
nanorc file. See \fBnanorc\fR(5).
|
||||
.TP
|
||||
.BR \-E ", " \-\-tabstospaces
|
||||
Convert typed tabs to spaces.
|
||||
Convert each typed tab to spaces -- to the number of spaces
|
||||
that a tab at that position would take up.
|
||||
.TP
|
||||
.BR \-F ", " \-\-multibuffer
|
||||
Read a file into a new buffer by default.
|
||||
@@ -340,14 +341,14 @@ filename in the center of the title bar.
|
||||
.BR \-_ ", " \-\-minibar
|
||||
Suppress the title bar and instead show information about
|
||||
the current buffer at the bottom of the screen, in the space
|
||||
for the status bar. In this "minibar" the file name is shown
|
||||
for the status bar. In this "minibar" the filename is shown
|
||||
on the left, followed by an asterisk if the buffer has been modified.
|
||||
On the right are displayed the current line and column number, the
|
||||
code of the character under the cursor (in Unicode format: U+xxxx),
|
||||
the same flags as are shown by \fB\-\-stateflags\fR, and a percentage
|
||||
that expresses how far the cursor is into the file (linewise).
|
||||
When a file is loaded or saved, and also when switching between buffers,
|
||||
the number of lines in the buffer is displayed after the file name.
|
||||
the number of lines in the buffer is displayed after the filename.
|
||||
This number is cleared upon the next keystroke, or replaced with an
|
||||
[i/n] counter when multiple buffers are open.
|
||||
The line plus column numbers and the character code are displayed only when
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
@smallbook
|
||||
@set EDITION 0.6
|
||||
@set VERSION 5.8
|
||||
@set UPDATED June 2021
|
||||
@set VERSION 5.9
|
||||
@set UPDATED October 2021
|
||||
|
||||
@dircategory Editors
|
||||
@direntry
|
||||
@@ -23,7 +23,7 @@
|
||||
@titlepage
|
||||
@title GNU @command{nano}
|
||||
@subtitle a small and friendly text editor
|
||||
@subtitle version 5.8
|
||||
@subtitle version 5.9
|
||||
|
||||
@author Chris Allegretta
|
||||
@page
|
||||
@@ -65,7 +65,7 @@ For suggesting improvements: @email{nano-devel@@gnu.org}@*
|
||||
@node Top
|
||||
@top
|
||||
|
||||
This manual documents the GNU @command{nano} editor, version 5.8.
|
||||
This manual documents the GNU @command{nano} editor, version 5.9.
|
||||
|
||||
@menu
|
||||
* Introduction::
|
||||
@@ -195,7 +195,8 @@ nanorc file. @xref{@code{set functioncolor}} for details.
|
||||
|
||||
@item -E
|
||||
@itemx --tabstospaces
|
||||
Convert typed tabs to spaces.
|
||||
Convert each typed tab to spaces --- to the number of spaces
|
||||
that a tab at that position would take up.
|
||||
|
||||
@item -F
|
||||
@itemx --multibuffer
|
||||
@@ -483,14 +484,14 @@ filename in the center of the title bar.
|
||||
@itemx --minibar
|
||||
Suppress the title bar and instead show information about
|
||||
the current buffer at the bottom of the screen, in the space
|
||||
for the status bar. In this "minibar" the file name is shown
|
||||
for the status bar. In this "minibar" the filename is shown
|
||||
on the left, followed by an asterisk if the buffer has been modified.
|
||||
On the right are displayed the current line and column number, the
|
||||
code of the character under the cursor (in Unicode format: U+xxxx),
|
||||
the same flags as are shown by @code{--stateflags}, and a percentage
|
||||
that expresses how far the cursor is into the file (linewise).
|
||||
When a file is loaded or saved, and also when switching between buffers,
|
||||
the number of lines in the buffer is displayed after the file name.
|
||||
the number of lines in the buffer is displayed after the filename.
|
||||
This number is cleared upon the next keystroke, or replaced with an
|
||||
[i/n] counter when multiple buffers are open.
|
||||
The line plus column numbers and the character code are displayed only when
|
||||
@@ -590,7 +591,7 @@ or @kbd{M-A} and then moving the cursor to the other end of the portion
|
||||
to be selected. The selected portion of text will be highlighted.
|
||||
This selection can now be cut or copied in its entirety with a single
|
||||
@kbd{^K} or @kbd{M-6}. Or the selection can be used to limit the scope of
|
||||
a search-and-replace (@kbd{^\}) or spell-checking session (@kbd{^T}).
|
||||
a search-and-replace (@kbd{^\}) or spell-checking session (@kbd{^T^T}).
|
||||
|
||||
On some terminals, text can be selected also by holding down @kbd{Shift}
|
||||
while using the cursor keys. Holding down the @kbd{Ctrl} or @kbd{Alt}
|
||||
@@ -858,7 +859,7 @@ Do not use the line below the title bar, leaving it entirely blank.
|
||||
|
||||
@item set errorcolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
|
||||
Use this color combination for the status bar when an error message is displayed.
|
||||
The default value is @t{brightwhite,red}.
|
||||
The default value is @t{bold,white,red}.
|
||||
@xref{@code{set functioncolor}} for valid color names.
|
||||
|
||||
@item set fill @var{number}
|
||||
@@ -936,14 +937,14 @@ The default value is "@t{(<[@{)>]@}}".
|
||||
@item set minibar
|
||||
Suppress the title bar and instead show information about
|
||||
the current buffer at the bottom of the screen, in the space
|
||||
for the status bar. In this "minibar" the file name is shown
|
||||
for the status bar. In this "minibar" the filename is shown
|
||||
on the left, followed by an asterisk if the buffer has been modified.
|
||||
On the right are displayed the current line and column number, the
|
||||
code of the character under the cursor (in Unicode format: U+xxxx),
|
||||
the same flags as are shown by @code{set stateflags}, and a percentage
|
||||
that expresses how far the cursor is into the file (linewise).
|
||||
When a file is loaded or saved, and also when switching between buffers,
|
||||
the number of lines in the buffer is displayed after the file name.
|
||||
the number of lines in the buffer is displayed after the filename.
|
||||
This number is cleared upon the next keystroke, or replaced with an
|
||||
[i/n] counter when multiple buffers are open.
|
||||
The line plus column numbers and the character code are displayed only when
|
||||
@@ -1095,7 +1096,8 @@ Use a tab size of @var{number} columns. The value of @var{number} must be
|
||||
greater than 0. The default value is @t{8}.
|
||||
|
||||
@item set tabstospaces
|
||||
Convert typed tabs to spaces.
|
||||
Convert each typed tab to spaces --- to the number of spaces
|
||||
that a tab at that position would take up.
|
||||
|
||||
@item set titlecolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
|
||||
Use this color combination for the title bar.
|
||||
@@ -1412,7 +1414,8 @@ the line, column, and character positions.
|
||||
(The old name of this function, 'curpos', is deprecated.)
|
||||
|
||||
@item wordcount
|
||||
Counts the number of words, lines and characters in the current buffer.
|
||||
Counts and reports on the status bar the number of lines, words,
|
||||
and characters in the current buffer (or in the marked region).
|
||||
|
||||
@item execute
|
||||
Prompts for a program to execute. The program's output will be inserted
|
||||
@@ -1430,27 +1433,28 @@ Invokes a full-buffer-processing program (if the active syntax defines one).
|
||||
Invokes a syntax-checking program (if the active syntax defines one).
|
||||
|
||||
@item justify
|
||||
Justifies the current paragraph. A paragraph is a group of contiguous lines
|
||||
Justifies the current paragraph (or the marked region).
|
||||
A paragraph is a group of contiguous lines
|
||||
that, apart from possibly the first line, all have the same indentation. The
|
||||
beginning of a paragraph is detected by either this lone line with a differing
|
||||
indentation or by a preceding blank line.
|
||||
|
||||
@item fulljustify
|
||||
Justifies the entire current buffer.
|
||||
Justifies the entire current buffer (or the marked region).
|
||||
|
||||
@item indent
|
||||
Indents (shifts to the right) the currently marked text.
|
||||
Indents (shifts to the right) the current line or the marked lines.
|
||||
|
||||
@item unindent
|
||||
Unindents (shifts to the left) the currently marked text.
|
||||
Unindents (shifts to the left) the current line or the marked lines.
|
||||
|
||||
@item comment
|
||||
Comments or uncomments the current line or marked lines, using the comment
|
||||
style specified in the active syntax.
|
||||
Comments or uncomments the current line or the 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.
|
||||
Completes (when possible) 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).
|
||||
@@ -1467,10 +1471,14 @@ Goes one line down (in the editor or browser).
|
||||
@item scrollup
|
||||
Scrolls the viewport up one row (meaning that the text slides down)
|
||||
while keeping the cursor in the same text position, if possible.
|
||||
(This function is bound by default to <Alt+Up>.
|
||||
If <Alt+Up> does nothing on your Linux console, see the FAQ:
|
||||
@url{https://nano-editor.org/dist/latest/faq.html#4.1}.)
|
||||
|
||||
@item scrolldown
|
||||
Scrolls the viewport down one row (meaning that the text slides up)
|
||||
while keeping the cursor in the same text position, if possible.
|
||||
(This function is bound by default to <Alt+Down>.)
|
||||
|
||||
@item center
|
||||
Scrolls the line with the cursor to the middle of the screen.
|
||||
|
||||
41
doc/nanorc.5
41
doc/nanorc.5
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANORC 5 "version 5.8 "June 2021"
|
||||
.TH NANORC 5 "version 5.9" "October 2021"
|
||||
|
||||
.SH NAME
|
||||
nanorc \- GNU nano's configuration file
|
||||
@@ -127,7 +127,7 @@ Do not use the line below the title bar, leaving it entirely blank.
|
||||
.TP
|
||||
.B set errorcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
Use this color combination for the status bar when an error message is displayed.
|
||||
The default value is \fBbrightwhite,red\fR.
|
||||
The default value is \fBbold,white,red\fR.
|
||||
See \fBset titlecolor\fR for valid color names.
|
||||
.TP
|
||||
.B set fill \fInumber\fR
|
||||
@@ -185,14 +185,14 @@ The default value is "\fB(<[{)>]}\fP".
|
||||
.B set minibar
|
||||
Suppress the title bar and instead show information about
|
||||
the current buffer at the bottom of the screen, in the space
|
||||
for the status bar. In this "minibar" the file name is shown
|
||||
for the status bar. In this "minibar" the filename is shown
|
||||
on the left, followed by an asterisk if the buffer has been modified.
|
||||
On the right are displayed the current line and column number, the
|
||||
code of the character under the cursor (in Unicode format: U+xxxx),
|
||||
the same flags as are shown by \fBset stateflags\fR, and a percentage
|
||||
that expresses how far the cursor is into the file (linewise).
|
||||
When a file is loaded or saved, and also when switching between buffers,
|
||||
the number of lines in the buffer is displayed after the file name.
|
||||
the number of lines in the buffer is displayed after the filename.
|
||||
This number is cleared upon the next keystroke, or replaced with an
|
||||
[i/n] counter when multiple buffers are open.
|
||||
The line plus column numbers and the character code are displayed only when
|
||||
@@ -297,8 +297,9 @@ Use this color combination for selected text.
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
.B set showcursor
|
||||
Put the cursor on the highlighted item in the file browser, to aid
|
||||
braille users.
|
||||
Put the cursor on the highlighted item in the file browser, and show
|
||||
the cursor in the help viewer, to aid braille users and people with
|
||||
poor vision.
|
||||
.TP
|
||||
.B set smarthome
|
||||
Make the Home key smarter. When Home is pressed anywhere but at the
|
||||
@@ -345,7 +346,8 @@ Use a tab size of \fInumber\fR columns. The value of \fInumber\fP must be
|
||||
greater than 0. The default value is \fB8\fR.
|
||||
.TP
|
||||
.B set tabstospaces
|
||||
Convert typed tabs to spaces.
|
||||
Convert each typed tab to spaces -- to the number of spaces
|
||||
that a tab at that position would take up.
|
||||
.TP
|
||||
.B set titlecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
Use this color combination for the title bar.
|
||||
@@ -655,7 +657,8 @@ the line, column, and character positions.
|
||||
(The old name of this function, 'curpos', is deprecated.)
|
||||
.TP
|
||||
.B wordcount
|
||||
Counts the number of words, lines and characters in the current buffer.
|
||||
Counts and reports on the status bar the number of lines, words,
|
||||
and characters in the current buffer (or in the marked region).
|
||||
.TP
|
||||
.B execute
|
||||
Prompts for a program to execute. The program's output will be inserted
|
||||
@@ -672,27 +675,28 @@ Invokes a full-buffer-processing program (if the active syntax defines one).
|
||||
Invokes a syntax-checking program (if the active syntax defines one).
|
||||
.TP
|
||||
.B justify
|
||||
Justifies the current paragraph. A paragraph is a group of contiguous lines
|
||||
Justifies the current paragraph (or the marked region).
|
||||
A paragraph is a group of contiguous lines
|
||||
that, apart from possibly the first line, all have the same indentation. The
|
||||
beginning of a paragraph is detected by either this lone line with a differing
|
||||
indentation or by a preceding blank line.
|
||||
.TP
|
||||
.B fulljustify
|
||||
Justifies the entire current buffer.
|
||||
Justifies the entire current buffer (or the marked region).
|
||||
.TP
|
||||
.B indent
|
||||
Indents (shifts to the right) the currently marked text.
|
||||
Indents (shifts to the right) the current line or the marked lines.
|
||||
.TP
|
||||
.B unindent
|
||||
Unindents (shifts to the left) the currently marked text.
|
||||
Unindents (shifts to the left) the current line or the marked lines.
|
||||
.TP
|
||||
.B comment
|
||||
Comments or uncomments the current line or marked lines, using the comment
|
||||
style specified in the active syntax.
|
||||
Comments or uncomments the current line or the 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.
|
||||
Completes (when possible) 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).
|
||||
@@ -709,10 +713,15 @@ Goes one line down (in the editor or browser).
|
||||
.B scrollup
|
||||
Scrolls the viewport up one row (meaning that the text slides down)
|
||||
while keeping the cursor in the same text position, if possible.
|
||||
(This function is bound by default to <Alt+Up>.
|
||||
If <Alt+Up> does nothing on your Linux console, see the FAQ:
|
||||
.UR https://nano\-editor.org/dist/latest/faq.html#4.1
|
||||
.UE .)
|
||||
.TP
|
||||
.B scrolldown
|
||||
Scrolls the viewport down one row (meaning that the text slides up)
|
||||
while keeping the cursor in the same text position, if possible.
|
||||
(This function is bound by default to <Alt+Down>.)
|
||||
.TP
|
||||
.B center
|
||||
Scrolls the line with the cursor to the middle of the screen.
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH RNANO 1 "version 5.8" "June 2021"
|
||||
.TH RNANO 1 "version 5.9" "October 2021"
|
||||
|
||||
.SH NAME
|
||||
rnano \- a restricted nano
|
||||
|
||||
@@ -78,18 +78,19 @@
|
||||
## Fall back to slow libmagic to try and determine an applicable syntax.
|
||||
# set magic
|
||||
|
||||
## The opening and closing brackets that can be found by bracket
|
||||
## searches. They cannot contain blank characters. The former set must
|
||||
## come before the latter set, and both must be in the same order.
|
||||
## The opening and closing brackets that are found by a matching-bracket
|
||||
## search. This may not contain blank characters. The opening brackets
|
||||
## must come before the closing ones, and they must be in the same order.
|
||||
# set matchbrackets "(<[{)>]}"
|
||||
|
||||
## Suppress title bar and show file name and editor state at the bottom.
|
||||
## Suppress the title bar and show the filename plus a cursor-position
|
||||
## percentage in the space of the status bar.
|
||||
# set minibar
|
||||
|
||||
## Enable mouse support, if available for your system. When enabled,
|
||||
## mouse clicks can be used to place the cursor, set the mark (with a
|
||||
## double click), and execute shortcuts. The mouse will work in the X
|
||||
## Window System, and on the console when gpm is running.
|
||||
## double click), and execute shortcuts. The mouse will work in the
|
||||
## X Window System, and on the console when gpm is running.
|
||||
# set mouse
|
||||
|
||||
## Switch on multiple file buffers (inserting a file will put it into
|
||||
@@ -117,10 +118,9 @@
|
||||
## Preserve the XON and XOFF keys (^Q and ^S).
|
||||
# set preserve
|
||||
|
||||
## The characters treated as closing punctuation when justifying
|
||||
## paragraphs. They cannot contain blank characters. Only closing
|
||||
## punctuation, optionally followed by closing brackets, can end
|
||||
## sentences.
|
||||
## The characters treated as closing punctuation when justifying paragraphs.
|
||||
## This may not contain blank characters. Only these closing punctuations,
|
||||
## optionally followed by closing brackets, can end sentences.
|
||||
# set punct "!.?"
|
||||
|
||||
## Make status-bar messages disappear after 1 keystroke instead of after 20.
|
||||
@@ -144,16 +144,16 @@
|
||||
# set saveonexit
|
||||
## (The old form of this option, 'set tempfile', is deprecated.)
|
||||
|
||||
## Put the cursor on the highlighted item in the file browser, and show
|
||||
## the cursor in the help viewer; useful for people who use a braille
|
||||
## display and people with poor vision.
|
||||
## Put the cursor on the highlighted item in the file browser, and
|
||||
## show the cursor in the help viewer; useful for people who use a
|
||||
## braille display and people with poor vision.
|
||||
# set showcursor
|
||||
|
||||
## Make the Home key smarter. When Home is pressed anywhere but at the
|
||||
## Make the Home key smarter: when Home is pressed anywhere but at the
|
||||
## very beginning of non-whitespace characters on a line, the cursor
|
||||
## will jump to that beginning (either forwards or backwards). If the
|
||||
## cursor is already at that position, it will jump to the true
|
||||
## beginning of the line.
|
||||
## cursor is already at that position, it will jump to the true start
|
||||
## of the line (the left edge).
|
||||
# set smarthome
|
||||
|
||||
## Spread overlong lines over multiple screen lines.
|
||||
@@ -174,7 +174,7 @@
|
||||
## Use this tab size instead of the default; it must be greater than 0.
|
||||
# set tabsize 8
|
||||
|
||||
## Convert typed tabs to spaces.
|
||||
## Convert each typed tab to the fitting number of spaces.
|
||||
# set tabstospaces
|
||||
|
||||
## Snip whitespace at the end of lines when justifying or hard-wrapping.
|
||||
@@ -204,11 +204,11 @@
|
||||
|
||||
## Paint the interface elements of nano. These are examples; there are
|
||||
## no colors by default, except for errorcolor and spotlightcolor.
|
||||
# set titlecolor bold,lightwhite,blue
|
||||
# set promptcolor lightwhite,lightblack
|
||||
# set statuscolor bold,lightwhite,green
|
||||
# set errorcolor bold,lightwhite,red
|
||||
# set spotlightcolor black,lime
|
||||
# set titlecolor bold,white,blue
|
||||
# set promptcolor lightwhite,grey
|
||||
# set statuscolor bold,white,green
|
||||
# set errorcolor bold,white,red
|
||||
# set spotlightcolor black,lightyellow
|
||||
# set selectedcolor lightwhite,magenta
|
||||
# set stripecolor ,yellow
|
||||
# set scrollercolor cyan
|
||||
@@ -217,10 +217,10 @@
|
||||
# set functioncolor green
|
||||
|
||||
## In root's .nanorc you might want to use:
|
||||
# set titlecolor bold,lightwhite,magenta
|
||||
# set titlecolor bold,white,magenta
|
||||
# set promptcolor black,yellow
|
||||
# set statuscolor bold,lightwhite,magenta
|
||||
# set errorcolor bold,lightwhite,red
|
||||
# set statuscolor bold,white,magenta
|
||||
# set errorcolor bold,white,red
|
||||
# set spotlightcolor black,orange
|
||||
# set selectedcolor lightwhite,cyan
|
||||
# set stripecolor ,yellow
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# List of available languages.
|
||||
bg ca cs da de eo es eu fi fr ga gl hr hu id is it ja ko ms nb nl nn pl pt pt_BR ro ru sk sl sr sv tr uk vi zh_CN zh_TW
|
||||
bg ca cs da de eo es eu fi fr ga gl hr hu id is it ja ko ms nb nl pl pt pt_BR ro ru sk sl sr sv tr uk vi zh_CN zh_TW
|
||||
|
||||
1002
po/nano.pot
1002
po/nano.pot
File diff suppressed because it is too large
Load Diff
1010
po/pt_BR.po
1010
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,9 @@ rm *.po
|
||||
wget --recursive --level=1 --accept=po --no-directories --no-verbose \
|
||||
https://translationproject.org/latest/nano/ || exit 2
|
||||
|
||||
# This PO file is less than twenty percent translated:
|
||||
rm -v nn.po
|
||||
|
||||
# Are there now PO files that are not in git yet?
|
||||
NEWSTUFF=$(git status --porcelain *.po | grep "^??")
|
||||
|
||||
|
||||
1026
po/zh_CN.po
1026
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
1018
po/zh_TW.po
1018
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERSION="5.8"
|
||||
VERSION="5.9"
|
||||
|
||||
./configure -C --enable-tiny && make && ./configure -C &&
|
||||
|
||||
|
||||
@@ -359,7 +359,8 @@ void search_filename(bool forwards)
|
||||
#endif
|
||||
}
|
||||
|
||||
findfile(last_search, forwards);
|
||||
if (response == 0 || response == -2)
|
||||
findfile(last_search, forwards);
|
||||
}
|
||||
|
||||
/* Search again without prompting for the last given search string,
|
||||
@@ -380,6 +381,18 @@ void research_filename(bool forwards)
|
||||
}
|
||||
}
|
||||
|
||||
/* Select the first file in the list -- called by ^W^Y. */
|
||||
void to_first_file(void)
|
||||
{
|
||||
selected = 0;
|
||||
}
|
||||
|
||||
/* Select the last file in the list -- called by ^W^V. */
|
||||
void to_last_file(void)
|
||||
{
|
||||
selected = list_length - 1;
|
||||
}
|
||||
|
||||
/* Strip one element from the end of path, and return the stripped path.
|
||||
* The returned string is dynamically allocated, and should be freed. */
|
||||
char *strip_last_component(const char *path)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* chars.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2016-2020 Benno Schulenberg *
|
||||
* Copyright (C) 2016-2021 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 *
|
||||
@@ -644,7 +644,7 @@ bool has_blank_char(const char *string)
|
||||
|
||||
return *string;
|
||||
}
|
||||
#endif /* ENABLE_NANORC && (!NANO_TINY || ENABLE_JUSTIFY) */
|
||||
#endif
|
||||
|
||||
/* Return TRUE when the given string is empty or consists of only blanks. */
|
||||
bool white_string(const char *string)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* color.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2017, 2020 Benno Schulenberg *
|
||||
* Copyright (C) 2014-2017, 2020, 2021 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 *
|
||||
|
||||
35
src/cut.c
35
src/cut.c
@@ -249,27 +249,29 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
|
||||
bool same_line = (openfile->mark == top);
|
||||
bool post_marked = (openfile->mark && (openfile->mark->lineno > top->lineno ||
|
||||
(same_line && openfile->mark_x > top_x)));
|
||||
bool was_anchored = top->has_anchor;
|
||||
static bool inherited_anchor = FALSE;
|
||||
bool had_anchor = top->has_anchor;
|
||||
|
||||
if (top == bot && top_x == bot_x)
|
||||
return;
|
||||
|
||||
if (top != bot)
|
||||
for (linestruct *line = top->next; line != bot->next; line = line->next)
|
||||
was_anchored |= line->has_anchor;
|
||||
had_anchor |= line->has_anchor;
|
||||
#endif
|
||||
|
||||
if (top == bot) {
|
||||
taken = make_new_node(NULL);
|
||||
taken->data = measured_copy(top->data + top_x, bot_x - top_x);
|
||||
memmove(top->data + top_x, top->data + bot_x,
|
||||
strlen(top->data + bot_x) + 1);
|
||||
memmove(top->data + top_x, top->data + bot_x, strlen(top->data + bot_x) + 1);
|
||||
last = taken;
|
||||
} else if (top_x == 0 && bot_x == 0) {
|
||||
taken = top;
|
||||
last = make_new_node(NULL);
|
||||
last->data = copy_of("");
|
||||
|
||||
#ifndef NANO_TINY
|
||||
last->has_anchor = bot->has_anchor;
|
||||
#endif
|
||||
last->prev = bot->prev;
|
||||
bot->prev->next = last;
|
||||
last->next = NULL;
|
||||
@@ -309,11 +311,17 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
|
||||
if (cutbuffer == NULL) {
|
||||
cutbuffer = taken;
|
||||
cutbottom = last;
|
||||
#ifndef NANO_TINY
|
||||
inherited_anchor = taken->has_anchor;
|
||||
#endif
|
||||
} else {
|
||||
cutbottom->data = nrealloc(cutbottom->data,
|
||||
strlen(cutbottom->data) + strlen(taken->data) + 1);
|
||||
strcat(cutbottom->data, taken->data);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
cutbottom->has_anchor = taken->has_anchor && !inherited_anchor;
|
||||
inherited_anchor |= taken->has_anchor;
|
||||
#endif
|
||||
cutbottom->next = taken->next;
|
||||
delete_node(taken);
|
||||
|
||||
@@ -326,7 +334,7 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
|
||||
openfile->current_x = top_x;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
openfile->current->has_anchor = was_anchored;
|
||||
openfile->current->has_anchor = had_anchor;
|
||||
|
||||
if (post_marked || same_line)
|
||||
openfile->mark = openfile->current;
|
||||
@@ -686,10 +694,13 @@ void copy_text(void)
|
||||
/* Copy text from the cutbuffer into the current buffer. */
|
||||
void paste_text(void)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
/* Remember where the paste started. */
|
||||
linestruct *was_current = openfile->current;
|
||||
bool had_anchor = was_current->has_anchor;
|
||||
#endif
|
||||
ssize_t was_lineno = openfile->current->lineno;
|
||||
/* The line number where we started the paste. */
|
||||
size_t was_leftedge = 0;
|
||||
/* The leftedge where we started the paste. */
|
||||
|
||||
if (cutbuffer == NULL) {
|
||||
statusline(AHEM, _("Cutbuffer is empty"));
|
||||
@@ -708,6 +719,12 @@ void paste_text(void)
|
||||
copy_from_buffer(cutbuffer);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Wipe any anchors in the pasted text, so that they don't proliferate. */
|
||||
for (linestruct *line = was_current; line != openfile->current->next; line = line->next)
|
||||
line->has_anchor = FALSE;
|
||||
|
||||
was_current->has_anchor = had_anchor;
|
||||
|
||||
update_undo(PASTE);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__HAIKU__) && !defined(_DEFAULT_SOURCE)
|
||||
#define _DEFAULT_SOURCE 1
|
||||
#endif
|
||||
|
||||
#ifdef __TANDEM
|
||||
/* Tandem NonStop Kernel support. */
|
||||
#include <floss.h>
|
||||
@@ -111,6 +115,13 @@
|
||||
#define REPLACING 1
|
||||
#define INREGION 2
|
||||
|
||||
#define NORMAL TRUE
|
||||
#define SPECIAL FALSE
|
||||
#define TEMPORARY FALSE
|
||||
|
||||
#define ANNOTATE TRUE
|
||||
#define NONOTES FALSE
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
/* In UTF-8 a valid character is at most four bytes long. */
|
||||
#define MAXCHARLEN 4
|
||||
@@ -216,6 +227,7 @@
|
||||
#define INCLUDED_LAST_LINE (1<<3)
|
||||
#define MARK_WAS_SET (1<<4)
|
||||
#define CURSOR_WAS_AT_HEAD (1<<5)
|
||||
#define HAD_ANCHOR_AT_START (1<<6)
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Identifiers for the different menus. */
|
||||
@@ -624,8 +636,8 @@ typedef struct funcstruct {
|
||||
} funcstruct;
|
||||
|
||||
#ifdef ENABLE_WORDCOMPLETION
|
||||
typedef struct completion_word {
|
||||
typedef struct completionstruct {
|
||||
char *word;
|
||||
struct completion_word *next;
|
||||
} completion_word;
|
||||
struct completionstruct *next;
|
||||
} completionstruct;
|
||||
#endif
|
||||
|
||||
175
src/files.c
175
src/files.c
@@ -2,7 +2,7 @@
|
||||
* files.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2015-2020 Benno Schulenberg *
|
||||
* Copyright (C) 2015-2021 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 *
|
||||
@@ -40,19 +40,19 @@ void make_new_buffer(void)
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (openfile == NULL) {
|
||||
/* Make the first open file the only element in the list. */
|
||||
/* Make the first buffer the only element in the list. */
|
||||
newnode->prev = newnode;
|
||||
newnode->next = newnode;
|
||||
|
||||
startfile = newnode;
|
||||
} else {
|
||||
/* Add the new open file after the current one in the list. */
|
||||
/* Add the new buffer after the current one in the list. */
|
||||
newnode->prev = openfile;
|
||||
newnode->next = openfile->next;
|
||||
openfile->next->prev = newnode;
|
||||
openfile->next = newnode;
|
||||
|
||||
/* There is more than one file open: show "Close" in help lines. */
|
||||
/* There is more than one buffer: show "Close" in help lines. */
|
||||
exitfunc->desc = close_tag;
|
||||
more_than_one = !inhelp || more_than_one;
|
||||
}
|
||||
@@ -122,7 +122,7 @@ char *crop_to_fit(const char *name, int room)
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Delete the lockfile. Return TRUE on success, and FALSE otherwise. */
|
||||
/* Delete the lock file. Return TRUE on success, and FALSE otherwise. */
|
||||
bool delete_lockfile(const char *lockfilename)
|
||||
{
|
||||
if (unlink(lockfilename) < 0 && errno != ENOENT) {
|
||||
@@ -245,9 +245,11 @@ char *do_lockfile(const char *filename, bool ask_the_user)
|
||||
free(secondcopy);
|
||||
free(namecopy);
|
||||
|
||||
if (!ask_the_user && stat(lockfilename, &fileinfo) != -1)
|
||||
warn_and_briefly_pause(_("Someone else is also editing this file"));
|
||||
else if (stat(lockfilename, &fileinfo) != -1) {
|
||||
if (!ask_the_user && stat(lockfilename, &fileinfo) != -1) {
|
||||
blank_bottombars();
|
||||
statusline(ALERT, _("Someone else is also editing this file"));
|
||||
napms(1200);
|
||||
} else if (stat(lockfilename, &fileinfo) != -1) {
|
||||
char *lockbuf, *question, *pidstring, *postedname, *promptstr;
|
||||
static char lockprog[11], lockuser[17];
|
||||
int lockfd, lockpid, choice;
|
||||
@@ -476,8 +478,8 @@ bool open_buffer(const char *filename, bool new_one)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Mark the current file as modified if it isn't already, and
|
||||
* then update the title bar to display the file's new status. */
|
||||
/* Mark the current buffer as modified if it isn't already, and
|
||||
* then update the title bar to display the buffer's new status. */
|
||||
void set_modified(void)
|
||||
{
|
||||
if (openfile->modified)
|
||||
@@ -567,14 +569,14 @@ void redecorate_after_switch(void)
|
||||
mention_name_and_linecount();
|
||||
}
|
||||
|
||||
/* Switch to the previous entry in the list of open files. */
|
||||
/* Switch to the previous entry in the circular list of buffers. */
|
||||
void switch_to_prev_buffer(void)
|
||||
{
|
||||
openfile = openfile->prev;
|
||||
redecorate_after_switch();
|
||||
}
|
||||
|
||||
/* Switch to the next entry in the list of open files. */
|
||||
/* Switch to the next entry in the circular list of buffers. */
|
||||
void switch_to_next_buffer(void)
|
||||
{
|
||||
openfile = openfile->next;
|
||||
@@ -971,10 +973,10 @@ bool execute_command(const char *command)
|
||||
{
|
||||
int from_fd[2], to_fd[2];
|
||||
/* The pipes through which text will be written and read. */
|
||||
const bool should_pipe = (command[0] == '|');
|
||||
FILE *stream;
|
||||
struct sigaction oldaction, newaction = {{0}};
|
||||
/* Original and temporary handlers for SIGINT. */
|
||||
const bool should_pipe = (command[0] == '|');
|
||||
FILE *stream;
|
||||
|
||||
/* Create a pipe to read the command's output from, and, if needed,
|
||||
* a pipe to feed the command's input through. */
|
||||
@@ -1281,7 +1283,7 @@ void do_insertfile(bool execute)
|
||||
} else
|
||||
#endif /* ENABLE_MULTIBUFFER */
|
||||
{
|
||||
/* If the file actually changed, mark it as modified. */
|
||||
/* If the buffer actually changed, mark it as modified. */
|
||||
if (openfile->current->lineno != was_current_lineno ||
|
||||
openfile->current_x != was_current_x)
|
||||
set_modified();
|
||||
@@ -1357,7 +1359,7 @@ char *get_full_path(const char *origpath)
|
||||
target = real_dir_from_tilde(origpath);
|
||||
|
||||
/* Determine whether the target path refers to a directory. If statting
|
||||
* target fails, however, assume that it refers to a new, unsaved file. */
|
||||
* target fails, however, assume that it refers to a new, unsaved buffer. */
|
||||
path_only = (stat(target, &fileinfo) != -1 && S_ISDIR(fileinfo.st_mode));
|
||||
|
||||
/* If the target is a directory, make sure its path ends in a slash. */
|
||||
@@ -1451,7 +1453,8 @@ char *safe_tempfile(FILE **stream)
|
||||
{
|
||||
const char *env_dir = getenv("TMPDIR");
|
||||
char *tempdir = NULL, *tempfile_name = NULL;
|
||||
int fd;
|
||||
char *extension;
|
||||
int descriptor;
|
||||
|
||||
/* Get the absolute path for the first directory among $TMPDIR
|
||||
* and P_tmpdir that is writable, otherwise use /tmp/. */
|
||||
@@ -1464,18 +1467,26 @@ char *safe_tempfile(FILE **stream)
|
||||
if (tempdir == NULL)
|
||||
tempdir = copy_of("/tmp/");
|
||||
|
||||
tempfile_name = nrealloc(tempdir, strlen(tempdir) + 12);
|
||||
extension = strrchr(openfile->filename, '.');
|
||||
|
||||
if (!extension || strchr(extension, '/'))
|
||||
extension = openfile->filename + strlen(openfile->filename);
|
||||
|
||||
tempfile_name = nrealloc(tempdir, strlen(tempdir) + 12 + strlen(extension));
|
||||
strcat(tempfile_name, "nano.XXXXXX");
|
||||
strcat(tempfile_name, extension);
|
||||
|
||||
fd = mkstemp(tempfile_name);
|
||||
descriptor = mkstemps(tempfile_name, strlen(extension));
|
||||
|
||||
if (fd == -1) {
|
||||
*stream = (descriptor > 0) ? fdopen(descriptor, "r+b") : NULL;
|
||||
|
||||
if (*stream == NULL) {
|
||||
if (descriptor > 0)
|
||||
close(descriptor);
|
||||
free(tempfile_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*stream = fdopen(fd, "r+b");
|
||||
|
||||
return tempfile_name;
|
||||
}
|
||||
|
||||
@@ -1735,19 +1746,19 @@ bool make_backup_of(char *realname)
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Write the current buffer to disk. If thefile isn't NULL, we write to a
|
||||
* temporary file that is already open. If tmp is TRUE (when spell checking
|
||||
* or emergency dumping, for example), we don't make a backup and don't give
|
||||
* temporary file that is already open. If normal is FALSE (for a spellcheck
|
||||
* or an emergency save, for example), we don't make a backup and don't give
|
||||
* feedback. If method is APPEND or PREPEND, it means we will be appending
|
||||
* or prepending instead of overwriting the given file. If fullbuffer is TRUE
|
||||
* and when writing normally, we set the current filename and stat info.
|
||||
* or prepending instead of overwriting the given file. If annotate is TRUE
|
||||
* and when writing a normal file, we set the current filename and stat info.
|
||||
* Return TRUE on success, and FALSE otherwise. */
|
||||
bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
kind_of_writing_type method, bool fullbuffer)
|
||||
bool write_file(const char *name, FILE *thefile, bool normal,
|
||||
kind_of_writing_type method, bool annotate)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
bool is_existing_file;
|
||||
/* Becomes TRUE when the file is non-temporary and exists. */
|
||||
struct stat st;
|
||||
struct stat fileinfo;
|
||||
/* The status fields filled in by statting the file. */
|
||||
#endif
|
||||
char *realname = real_dir_from_tilde(name);
|
||||
@@ -1758,20 +1769,18 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
/* An iterator for moving through the lines of the buffer. */
|
||||
size_t lineswritten = 0;
|
||||
/* The number of lines written, for feedback on the status bar. */
|
||||
bool retval = FALSE;
|
||||
/* The return value, to become TRUE when writing has succeeded. */
|
||||
|
||||
#ifdef ENABLE_OPERATINGDIR
|
||||
/* If we're writing a temporary file, we're probably going outside
|
||||
* the operating directory, so skip the operating directory test. */
|
||||
if (!tmp && outside_of_confinement(realname, FALSE)) {
|
||||
if (normal && outside_of_confinement(realname, FALSE)) {
|
||||
statusline(ALERT, _("Can't write outside of %s"), operating_dir);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
/* Check whether the file (at the end of the symlink) exists. */
|
||||
is_existing_file = (!tmp) && (stat(realname, &st) != -1);
|
||||
is_existing_file = normal && (stat(realname, &fileinfo) != -1);
|
||||
|
||||
/* If we haven't statted this file before (say, the user just specified
|
||||
* it interactively), stat and save the value now, or else we will chase
|
||||
@@ -1782,8 +1791,9 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
/* When the user requested a backup, we do this only if the file exists and
|
||||
* isn't temporary AND the file has not been modified by someone else since
|
||||
* we opened it (or we are appending/prepending or writing a selection). */
|
||||
if (ISSET(MAKE_BACKUP) && is_existing_file && openfile->statinfo &&
|
||||
(openfile->statinfo->st_mtime == st.st_mtime ||
|
||||
if (ISSET(MAKE_BACKUP) && is_existing_file && !S_ISFIFO(fileinfo.st_mode) &&
|
||||
openfile->statinfo &&
|
||||
(openfile->statinfo->st_mtime == fileinfo.st_mtime ||
|
||||
method != OVERWRITE || openfile->mark)) {
|
||||
if (!make_backup_of(realname))
|
||||
goto cleanup_and_exit;
|
||||
@@ -1791,10 +1801,17 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
|
||||
/* When prepending, first copy the existing file to a temporary file. */
|
||||
if (method == PREPEND) {
|
||||
FILE *source = fopen(realname, "rb");
|
||||
FILE *source = NULL;
|
||||
FILE *target = NULL;
|
||||
int verdict;
|
||||
|
||||
if (is_existing_file && S_ISFIFO(fileinfo.st_mode)) {
|
||||
statusline(ALERT, _("Error writing %s: %s"), realname, "FIFO");
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
source = fopen(realname, "rb");
|
||||
|
||||
if (source == NULL) {
|
||||
statusline(ALERT, _("Error reading %s: %s"), realname, strerror(errno));
|
||||
goto cleanup_and_exit;
|
||||
@@ -1821,27 +1838,29 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
}
|
||||
}
|
||||
|
||||
if (is_existing_file && S_ISFIFO(st.st_mode))
|
||||
if (is_existing_file && S_ISFIFO(fileinfo.st_mode))
|
||||
statusbar(_("Writing to FIFO..."));
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* When it's not a temporary file, this is where we open or create it.
|
||||
* For an emergency file, access is restricted to just the owner. */
|
||||
if (thefile == NULL) {
|
||||
mode_t permissions = (tmp ? S_IRUSR|S_IWUSR : RW_FOR_ALL);
|
||||
mode_t permissions = (normal ? RW_FOR_ALL : S_IRUSR|S_IWUSR);
|
||||
int fd;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
block_sigwinch(TRUE);
|
||||
install_handler_for_Ctrl_C();
|
||||
if (normal)
|
||||
install_handler_for_Ctrl_C();
|
||||
#endif
|
||||
|
||||
/* Now open the file. Use O_EXCL for an emergency file. */
|
||||
fd = open(realname, O_WRONLY | O_CREAT | ((method == APPEND) ?
|
||||
O_APPEND : (tmp ? O_EXCL : O_TRUNC)), permissions);
|
||||
O_APPEND : (normal ? O_TRUNC : O_EXCL)), permissions);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
restore_handler_for_Ctrl_C();
|
||||
if (normal)
|
||||
restore_handler_for_Ctrl_C();
|
||||
block_sigwinch(FALSE);
|
||||
#endif
|
||||
|
||||
@@ -1867,7 +1886,7 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
}
|
||||
}
|
||||
|
||||
if (!tmp)
|
||||
if (normal)
|
||||
statusbar(_("Writing..."));
|
||||
|
||||
while (TRUE) {
|
||||
@@ -1944,22 +1963,27 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
|
||||
unlink(tempname);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Ensure the data has reached the disk before reporting it as written. */
|
||||
if (fflush(thefile) != 0 || fsync(fileno(thefile)) != 0) {
|
||||
statusline(ALERT, _("Error writing %s: %s"), realname, strerror(errno));
|
||||
fclose(thefile);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
if (!is_existing_file || !S_ISFIFO(fileinfo.st_mode))
|
||||
/* Ensure the data has reached the disk before reporting it as written. */
|
||||
if (fflush(thefile) != 0 || fsync(fileno(thefile)) != 0) {
|
||||
statusline(ALERT, _("Error writing %s: %s"), realname, strerror(errno));
|
||||
fclose(thefile);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fclose(thefile) != 0) {
|
||||
statusline(ALERT, _("Error writing %s: %s"), realname, strerror(errno));
|
||||
goto cleanup_and_exit;
|
||||
|
||||
cleanup_and_exit:
|
||||
free(tempname);
|
||||
free(realname);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* When having written an entire buffer, update some administrivia. */
|
||||
if (fullbuffer && method == OVERWRITE && !tmp) {
|
||||
if (annotate && method == OVERWRITE) {
|
||||
/* If the filename was changed, write a new lockfile when needed,
|
||||
* and check whether it means a different syntax gets used. */
|
||||
if (strcmp(openfile->filename, realname) != 0) {
|
||||
@@ -1967,8 +1991,10 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
if (openfile->lock_filename != NULL) {
|
||||
delete_lockfile(openfile->lock_filename);
|
||||
free(openfile->lock_filename);
|
||||
openfile->lock_filename = do_lockfile(realname, FALSE);
|
||||
}
|
||||
|
||||
if (ISSET(LOCKING))
|
||||
openfile->lock_filename = do_lockfile(realname, FALSE);
|
||||
#endif
|
||||
openfile->filename = mallocstrcpy(openfile->filename, realname);
|
||||
#ifdef ENABLE_COLOR
|
||||
@@ -1995,7 +2021,7 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
/* Get or update the stat info to reflect the current state. */
|
||||
stat_with_alloc(realname, &openfile->statinfo);
|
||||
|
||||
/* Record at which point in the undo stack the file was saved. */
|
||||
/* Record at which point in the undo stack the buffer was saved. */
|
||||
openfile->last_saved = openfile->current_undo;
|
||||
openfile->last_action = OTHER;
|
||||
#endif
|
||||
@@ -2004,26 +2030,24 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(MINIBAR) && LINES > 1 && fullbuffer && !tmp)
|
||||
if (ISSET(MINIBAR) && LINES > 1 && annotate)
|
||||
report_size = TRUE;
|
||||
else
|
||||
#endif
|
||||
if (!tmp)
|
||||
if (normal)
|
||||
statusline(REMARK, P_("Wrote %zu line", "Wrote %zu lines",
|
||||
lineswritten), lineswritten);
|
||||
retval = TRUE;
|
||||
|
||||
cleanup_and_exit:
|
||||
free(tempname);
|
||||
free(realname);
|
||||
|
||||
return retval;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Write the marked region of the current buffer out to disk.
|
||||
* Return TRUE on success and FALSE on error. */
|
||||
bool write_marked_file(const char *name, FILE *stream, bool tmp,
|
||||
bool write_region_to_file(const char *name, FILE *stream, bool normal,
|
||||
kind_of_writing_type method)
|
||||
{
|
||||
linestruct *birthline, *topline, *botline, *stopper, *afterline;
|
||||
@@ -2050,7 +2074,7 @@ bool write_marked_file(const char *name, FILE *stream, bool tmp,
|
||||
birthline = openfile->filetop;
|
||||
openfile->filetop = topline;
|
||||
|
||||
retval = write_file(name, stream, tmp, method, FALSE);
|
||||
retval = write_file(name, stream, normal, method, NONOTES);
|
||||
|
||||
/* Restore the proper state of the buffer. */
|
||||
openfile->filetop = birthline;
|
||||
@@ -2065,18 +2089,18 @@ bool write_marked_file(const char *name, FILE *stream, bool tmp,
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Write the current file to disk. If the mark is on, write the current
|
||||
* marked selection to disk. If exiting is TRUE, write the entire file
|
||||
/* Write the current buffer to disk. If the mark is on, write the current
|
||||
* marked selection to disk. If exiting is TRUE, write the entire buffer
|
||||
* to disk regardless of whether the mark is on. Do not ask for a name
|
||||
* when withprompt is FALSE nor when the SAVE_ON_EXIT flag is set and the
|
||||
* file already has a name. Return 0 on error, 1 on success, and 2 when
|
||||
* buffer already has a name. Return 0 on error, 1 on success, and 2 when
|
||||
* the buffer is to be discarded. */
|
||||
int do_writeout(bool exiting, bool withprompt)
|
||||
{
|
||||
char *given;
|
||||
/* The filename we offer, or what the user typed so far. */
|
||||
bool maychange = (openfile->filename[0] == '\0');
|
||||
/* Whether it's okay to save the file under a different name. */
|
||||
/* Whether it's okay to save the buffer under a different name. */
|
||||
kind_of_writing_type method = OVERWRITE;
|
||||
#ifdef ENABLE_EXTRA
|
||||
static bool did_credits = FALSE;
|
||||
@@ -2201,12 +2225,12 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
if (method == OVERWRITE) {
|
||||
bool name_exists, do_warning;
|
||||
char *full_answer, *full_filename;
|
||||
struct stat st;
|
||||
struct stat fileinfo;
|
||||
|
||||
full_answer = get_full_path(answer);
|
||||
full_filename = get_full_path(openfile->filename);
|
||||
name_exists = (stat((full_answer == NULL) ?
|
||||
answer : full_answer, &st) != -1);
|
||||
answer : full_answer, &fileinfo) != -1);
|
||||
|
||||
if (openfile->filename[0] == '\0')
|
||||
do_warning = name_exists;
|
||||
@@ -2221,11 +2245,10 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
if (do_warning) {
|
||||
/* 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. */
|
||||
* the name of the current buffer if it already has one. */
|
||||
if (ISSET(RESTRICTED)) {
|
||||
/* TRANSLATORS: Restricted mode forbids overwriting. */
|
||||
warn_and_briefly_pause(_("File exists -- "
|
||||
"cannot overwrite"));
|
||||
warn_and_briefly_pause(_("File exists -- cannot overwrite"));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2262,9 +2285,9 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
* and the stat information we had before does not match
|
||||
* what we have now. */
|
||||
else if (name_exists && openfile->statinfo &&
|
||||
(openfile->statinfo->st_mtime < st.st_mtime ||
|
||||
openfile->statinfo->st_dev != st.st_dev ||
|
||||
openfile->statinfo->st_ino != st.st_ino)) {
|
||||
(openfile->statinfo->st_mtime < fileinfo.st_mtime ||
|
||||
openfile->statinfo->st_dev != fileinfo.st_dev ||
|
||||
openfile->statinfo->st_ino != fileinfo.st_ino)) {
|
||||
|
||||
warn_and_briefly_pause(_("File on disk has changed"));
|
||||
|
||||
@@ -2279,7 +2302,7 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
free(given);
|
||||
if (choice == 1)
|
||||
return write_file(openfile->filename, NULL,
|
||||
FALSE, OVERWRITE, TRUE);
|
||||
NORMAL, OVERWRITE, NONOTES);
|
||||
else if (choice == 0)
|
||||
return 2;
|
||||
else
|
||||
@@ -2301,10 +2324,10 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
* the marked region; otherwise, write out the whole buffer. */
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->mark && withprompt && !exiting && !ISSET(RESTRICTED))
|
||||
return write_marked_file(answer, NULL, FALSE, method);
|
||||
return write_region_to_file(answer, NULL, NORMAL, method);
|
||||
else
|
||||
#endif
|
||||
return write_file(answer, NULL, FALSE, method, TRUE);
|
||||
return write_file(answer, NULL, NORMAL, method, ANNOTATE);
|
||||
}
|
||||
|
||||
/* Write the current buffer to disk, or discard it. */
|
||||
@@ -2315,7 +2338,7 @@ void do_writeout_void(void)
|
||||
close_and_go();
|
||||
}
|
||||
|
||||
/* If it has a name, write the current file to disk without prompting. */
|
||||
/* If it has a name, write the current buffer to disk without prompting. */
|
||||
void do_savefile(void)
|
||||
{
|
||||
if (do_writeout(FALSE, FALSE) == 2)
|
||||
|
||||
12
src/global.c
12
src/global.c
@@ -301,12 +301,6 @@ void flip_goto(void)
|
||||
void to_files(void)
|
||||
{
|
||||
}
|
||||
void to_first_file(void)
|
||||
{
|
||||
}
|
||||
void to_last_file(void)
|
||||
{
|
||||
}
|
||||
void goto_dir(void)
|
||||
{
|
||||
}
|
||||
@@ -1448,11 +1442,9 @@ void shortcut_init(void)
|
||||
add_to_sclist(MGOTOLINE, "^W", 0, to_para_begin, 0);
|
||||
add_to_sclist(MGOTOLINE, "^O", 0, to_para_end, 0);
|
||||
#endif
|
||||
add_to_sclist(MGOTOLINE, "^Y", 0, to_first_line, 0);
|
||||
add_to_sclist(MGOTOLINE, "^V", 0, to_last_line, 0);
|
||||
/* Some people are used to having these keystrokes in the Search menu. */
|
||||
add_to_sclist(MWHEREIS, "^Y", 0, to_first_line, 0);
|
||||
add_to_sclist(MWHEREIS, "^V", 0, to_last_line, 0);
|
||||
add_to_sclist(MGOTOLINE|MWHEREIS|MFINDINHELP, "^Y", 0, to_first_line, 0);
|
||||
add_to_sclist(MGOTOLINE|MWHEREIS|MFINDINHELP, "^V", 0, to_last_line, 0);
|
||||
#ifdef ENABLE_BROWSER
|
||||
add_to_sclist(MWHEREISFILE, "^Y", 0, to_first_file, 0);
|
||||
add_to_sclist(MWHEREISFILE, "^V", 0, to_last_file, 0);
|
||||
|
||||
@@ -310,7 +310,7 @@ void help_init(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Hard-wrap the concatenated help text, and write it into a new buffer. */
|
||||
|
||||
@@ -367,7 +367,8 @@ void save_history(void)
|
||||
}
|
||||
|
||||
/* Don't allow others to read or write the history file. */
|
||||
chmod(histname, S_IRUSR | S_IWUSR);
|
||||
if (chmod(histname, S_IRUSR | S_IWUSR) < 0)
|
||||
jot_error(N_("Cannot limit permissions on %s: %s"), histname, strerror(errno));
|
||||
|
||||
if (!write_list(searchtop, histfile) || !write_list(replacetop, histfile) ||
|
||||
!write_list(executetop, histfile))
|
||||
@@ -465,7 +466,8 @@ void save_poshistory(void)
|
||||
}
|
||||
|
||||
/* Don't allow others to read or write the history file. */
|
||||
chmod(poshistname, S_IRUSR | S_IWUSR);
|
||||
if (chmod(poshistname, S_IRUSR | S_IWUSR) < 0)
|
||||
jot_error(N_("Cannot limit permissions on %s: %s"), poshistname, strerror(errno));
|
||||
|
||||
for (posptr = position_history; posptr != NULL; posptr = posptr->next) {
|
||||
char *path_and_place;
|
||||
|
||||
70
src/nano.c
70
src/nano.c
@@ -2,7 +2,7 @@
|
||||
* nano.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2020 Benno Schulenberg *
|
||||
* Copyright (C) 2014-2021 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 *
|
||||
@@ -154,7 +154,7 @@ linestruct *copy_node(const linestruct *src)
|
||||
#endif
|
||||
dst->lineno = src->lineno;
|
||||
#ifndef NANO_TINY
|
||||
dst->has_anchor = FALSE;
|
||||
dst->has_anchor = src->has_anchor;
|
||||
#endif
|
||||
|
||||
return dst;
|
||||
@@ -309,40 +309,37 @@ void do_exit(void)
|
||||
statusbar(_("Cancelled"));
|
||||
}
|
||||
|
||||
/* Save the current buffer under the given name (or under the name "nano"
|
||||
* for a nameless buffer). If needed, the name is modified to be unique. */
|
||||
void emergency_save(const char *plainname)
|
||||
/* Save the current buffer under the given name (or "nano.<pid>" when nameless)
|
||||
* with suffix ".save". If needed, the name is further suffixed to be unique. */
|
||||
void emergency_save(const char *filename)
|
||||
{
|
||||
bool failed = TRUE;
|
||||
char *targetname;
|
||||
char *plainname, *targetname;
|
||||
|
||||
if (*plainname == '\0')
|
||||
plainname = "nano";
|
||||
if (*filename == '\0') {
|
||||
plainname = nmalloc(28);
|
||||
sprintf(plainname, "nano.%u", getpid());
|
||||
} else
|
||||
plainname = copy_of(filename);
|
||||
|
||||
targetname = get_next_filename(plainname, ".save");
|
||||
|
||||
if (*targetname != '\0')
|
||||
failed = !write_file(targetname, NULL, TRUE, OVERWRITE, FALSE);
|
||||
|
||||
if (!failed)
|
||||
if (*targetname == '\0')
|
||||
fprintf(stderr, _("\nToo many .save files\n"));
|
||||
else if (write_file(targetname, NULL, SPECIAL, OVERWRITE, NONOTES)) {
|
||||
fprintf(stderr, _("\nBuffer written to %s\n"), targetname);
|
||||
else if (*targetname != '\0')
|
||||
fprintf(stderr, _("\nBuffer not written to %s: %s\n"),
|
||||
targetname, strerror(errno));
|
||||
else
|
||||
fprintf(stderr, _("\nToo many .save files"));
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Try to chmod/chown the saved file to the values of the original file,
|
||||
* but ignore any failure as we are in a hurry to get out. */
|
||||
if (openfile->statinfo) {
|
||||
IGNORE_CALL_RESULT(chmod(targetname, openfile->statinfo->st_mode));
|
||||
IGNORE_CALL_RESULT(chown(targetname, openfile->statinfo->st_uid,
|
||||
openfile->statinfo->st_gid));
|
||||
}
|
||||
/* Try to chmod/chown the saved file to the values of the original file,
|
||||
* but ignore any failure as we are in a hurry to get out. */
|
||||
if (openfile->statinfo) {
|
||||
IGNORE_CALL_RESULT(chmod(targetname, openfile->statinfo->st_mode));
|
||||
IGNORE_CALL_RESULT(chown(targetname, openfile->statinfo->st_uid,
|
||||
openfile->statinfo->st_gid));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
free(targetname);
|
||||
free(plainname);
|
||||
}
|
||||
|
||||
/* Die gracefully -- by restoring the terminal state and saving any buffers
|
||||
@@ -351,6 +348,11 @@ void die(const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
openfilestruct *firstone = openfile;
|
||||
static int stabs = 0;
|
||||
|
||||
/* When dying for a second time, just give up. */
|
||||
if (++stabs > 1)
|
||||
exit(11);
|
||||
|
||||
restore_terminal();
|
||||
|
||||
@@ -365,7 +367,7 @@ void die(const char *msg, ...)
|
||||
|
||||
while (openfile) {
|
||||
#ifndef NANO_TINY
|
||||
/* If the current buffer has a lockfile, remove it. */
|
||||
/* If the current buffer has a lock file, remove it. */
|
||||
if (openfile->lock_filename)
|
||||
delete_lockfile(openfile->lock_filename);
|
||||
#endif
|
||||
@@ -518,7 +520,7 @@ void usage(void)
|
||||
#ifdef ENABLE_HISTORIES
|
||||
if (!ISSET(RESTRICTED))
|
||||
print_opt("-H", "--historylog",
|
||||
N_("Log & read search/replace string history"));
|
||||
N_("Save & reload old search/replace strings"));
|
||||
#endif
|
||||
#ifdef ENABLE_NANORC
|
||||
print_opt("-I", "--ignorercfiles", N_("Don't look at nanorc files"));
|
||||
@@ -546,7 +548,7 @@ void usage(void)
|
||||
#ifdef ENABLE_HISTORIES
|
||||
if (!ISSET(RESTRICTED))
|
||||
print_opt("-P", "--positionlog",
|
||||
N_("Log & read location of cursor position"));
|
||||
N_("Save & restore position of the cursor"));
|
||||
#endif
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
print_opt(_("-Q <regex>"), _("--quotestr=<regex>"),
|
||||
@@ -1094,7 +1096,7 @@ void do_toggle(int flag)
|
||||
if (flag == AUTOINDENT || flag == BREAK_LONG_LINES || flag == SOFTWRAP)
|
||||
titlebar(NULL);
|
||||
|
||||
if (ISSET(MINIBAR) && (flag == NO_HELP || flag == LINE_NUMBERS ))
|
||||
if (ISSET(MINIBAR) && (flag == NO_HELP || flag == LINE_NUMBERS))
|
||||
return;
|
||||
|
||||
if (flag == CONSTANT_SHOW)
|
||||
@@ -2053,6 +2055,10 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* Curses needs TERM; if it is unset, try falling back to a VT220. */
|
||||
if (getenv("TERM") == NULL)
|
||||
setenv("TERM", "vt220", 0);
|
||||
|
||||
/* Enter into curses mode. Abort if this fails. */
|
||||
if (initscr() == NULL)
|
||||
exit(1);
|
||||
@@ -2203,7 +2209,7 @@ int main(int argc, char **argv)
|
||||
load_history();
|
||||
if (ISSET(POSITIONLOG))
|
||||
load_poshistory();
|
||||
#endif /* ENABLE_HISTORIES */
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If a backup directory was specified and we're not in restricted mode,
|
||||
@@ -2237,7 +2243,7 @@ int main(int argc, char **argv)
|
||||
die(_("Bad quoting regex \"%s\": %s\n"), quotestr, message);
|
||||
} else
|
||||
free(quotestr);
|
||||
#endif /* ENABLE_JUSTIFY */
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SPELLER
|
||||
/* If we don't have an alternative spell checker after reading the
|
||||
|
||||
@@ -766,7 +766,7 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
choice = -2;
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_MOUSE */
|
||||
#endif
|
||||
else if (func_from_key(&kbinput) == full_refresh)
|
||||
full_refresh();
|
||||
#ifndef NANO_TINY
|
||||
|
||||
@@ -191,6 +191,8 @@ typedef void (*functionptrtype)(void);
|
||||
#ifdef ENABLE_BROWSER
|
||||
void browser_refresh(void);
|
||||
char *browse_in(const char *inpath);
|
||||
void to_first_file(void);
|
||||
void to_last_file(void);
|
||||
#endif
|
||||
|
||||
/* Most functions in chars.c. */
|
||||
@@ -294,11 +296,11 @@ bool outside_of_confinement(const char *currpath, bool allow_tabcomp);
|
||||
void init_backup_dir(void);
|
||||
#endif
|
||||
int copy_file(FILE *inn, FILE *out, bool close_out);
|
||||
bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
kind_of_writing_type method, bool fullbuffer);
|
||||
bool write_file(const char *name, FILE *thefile, bool normal,
|
||||
kind_of_writing_type method, bool annotate);
|
||||
#ifndef NANO_TINY
|
||||
bool write_marked_file(const char *name, FILE *stream, bool tmp,
|
||||
kind_of_writing_type method);
|
||||
bool write_region_to_file(const char *name, FILE *stream, bool normal,
|
||||
kind_of_writing_type method);
|
||||
#endif
|
||||
int do_writeout(bool exiting, bool withprompt);
|
||||
void do_writeout_void(void);
|
||||
@@ -636,8 +638,6 @@ void flip_replace(void);
|
||||
void flip_goto(void);
|
||||
#ifdef ENABLE_BROWSER
|
||||
void to_files(void);
|
||||
void to_first_file(void);
|
||||
void to_last_file(void);
|
||||
void goto_dir(void);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
|
||||
22
src/search.c
22
src/search.c
@@ -550,7 +550,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
openfile->current_x = bot_x;
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
#endif
|
||||
|
||||
came_full_circle = FALSE;
|
||||
|
||||
@@ -606,17 +606,16 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
}
|
||||
|
||||
if (choice == 1 || replaceall) { /* Yes, replace it. */
|
||||
char *copy;
|
||||
size_t length_change;
|
||||
char *altered;
|
||||
|
||||
altered = replace_line(needle);
|
||||
|
||||
length_change = strlen(altered) - strlen(openfile->current->data);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(REPLACE, NULL);
|
||||
#endif
|
||||
copy = replace_line(needle);
|
||||
|
||||
length_change = strlen(copy) - strlen(openfile->current->data);
|
||||
|
||||
#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 (was_mark && !right_side_up) {
|
||||
@@ -632,8 +631,9 @@ 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 (!was_mark || right_side_up) {
|
||||
if (!was_mark || right_side_up)
|
||||
#endif
|
||||
{
|
||||
if (openfile->current == real_current &&
|
||||
openfile->current_x < *real_current_x) {
|
||||
if (*real_current_x < openfile->current_x + match_len)
|
||||
@@ -641,8 +641,8 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
*real_current_x += length_change;
|
||||
#ifndef NANO_TINY
|
||||
bot_x = *real_current_x;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't find the same zero-length or BOL match again. */
|
||||
@@ -655,9 +655,9 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
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);
|
||||
openfile->totsize += mbstrlen(altered) - mbstrlen(openfile->current->data);
|
||||
free(openfile->current->data);
|
||||
openfile->current->data = copy;
|
||||
openfile->current->data = altered;
|
||||
|
||||
set_modified();
|
||||
as_an_at = TRUE;
|
||||
|
||||
59
src/text.c
59
src/text.c
@@ -6,7 +6,7 @@
|
||||
* Copyright (C) 2016 Mike Scalora *
|
||||
* Copyright (C) 2016 Sumedh Pendurkar *
|
||||
* Copyright (C) 2018 Marco Diego Aurélio Mesquita *
|
||||
* Copyright (C) 2015-2020 Benno Schulenberg *
|
||||
* Copyright (C) 2015-2021 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,7 +39,7 @@
|
||||
#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;
|
||||
static completionstruct *list_of_completions;
|
||||
/* A linked list of the completions that have been attempted. */
|
||||
#endif
|
||||
|
||||
@@ -58,7 +58,7 @@ void do_mark(void)
|
||||
refresh_needed = TRUE;
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
#endif
|
||||
|
||||
/* Insert a tab. Or, if --tabstospaces is in effect, insert the number
|
||||
* of spaces that a tab would normally take up at this position. */
|
||||
@@ -186,7 +186,7 @@ size_t length_of_white(const char *text)
|
||||
|
||||
while (TRUE) {
|
||||
if (*text == '\t')
|
||||
return ++white_count;
|
||||
return white_count + 1;
|
||||
|
||||
if (*text != ' ')
|
||||
return white_count;
|
||||
@@ -463,6 +463,10 @@ void undo_cut(undostruct *u)
|
||||
{
|
||||
goto_line_posx(u->head_lineno, (u->xflags & WAS_WHOLE_LINE) ? 0 : u->head_x);
|
||||
|
||||
/* Clear an inherited anchor but not a user-placed one. */
|
||||
if (!(u->xflags & HAD_ANCHOR_AT_START))
|
||||
openfile->current->has_anchor = FALSE;
|
||||
|
||||
if (u->cutbuffer)
|
||||
copy_from_buffer(u->cutbuffer);
|
||||
|
||||
@@ -661,7 +665,7 @@ void do_undo(void)
|
||||
|
||||
openfile->totsize = u->wassize;
|
||||
|
||||
/* When at the point where the file was last saved, unset "Modified". */
|
||||
/* When at the point where the buffer was last saved, unset "Modified". */
|
||||
if (openfile->current_undo == openfile->last_saved) {
|
||||
openfile->modified = FALSE;
|
||||
titlebar(NULL);
|
||||
@@ -821,7 +825,7 @@ void do_redo(void)
|
||||
|
||||
openfile->totsize = u->newsize;
|
||||
|
||||
/* When at the point where the file was last saved, unset "Modified". */
|
||||
/* When at the point where the buffer was last saved, unset "Modified". */
|
||||
if (openfile->current_undo == openfile->last_saved) {
|
||||
openfile->modified = FALSE;
|
||||
titlebar(NULL);
|
||||
@@ -1023,6 +1027,8 @@ void add_undo(undo_type action, const char *message)
|
||||
#endif
|
||||
case CUT_TO_EOF:
|
||||
u->xflags |= (INCLUDED_LAST_LINE | CURSOR_WAS_AT_HEAD);
|
||||
if (openfile->current->has_anchor)
|
||||
u->xflags |= HAD_ANCHOR_AT_START;
|
||||
break;
|
||||
case ZAP:
|
||||
case CUT:
|
||||
@@ -1044,6 +1050,9 @@ void add_undo(undo_type action, const char *message)
|
||||
u->tail_x = 0;
|
||||
} else
|
||||
u->xflags |= CURSOR_WAS_AT_HEAD;
|
||||
if ((openfile->mark && mark_is_before_cursor() && openfile->mark->has_anchor) ||
|
||||
((!openfile->mark || !mark_is_before_cursor()) && openfile->current->has_anchor))
|
||||
u->xflags |= HAD_ANCHOR_AT_START;
|
||||
break;
|
||||
case PASTE:
|
||||
u->cutbuffer = copy_buffer(cutbuffer);
|
||||
@@ -1933,9 +1942,11 @@ void justify_text(bool whole_buffer)
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(PASTE, NULL);
|
||||
/* Wipe an anchor on the first paragraph if it was only inherited. */
|
||||
if (whole_buffer && !openfile->mark && !cutbuffer->has_anchor)
|
||||
openfile->current->has_anchor = FALSE;
|
||||
|
||||
add_undo(PASTE, NULL);
|
||||
#endif
|
||||
/* Do the equivalent of a paste of the justified text. */
|
||||
ingraft_buffer(cutbuffer);
|
||||
@@ -1954,13 +1965,8 @@ void justify_text(bool whole_buffer)
|
||||
}
|
||||
|
||||
add_undo(COUPLE_END, N_("justification"));
|
||||
#endif
|
||||
|
||||
/* We're done justifying. Restore the old cutbuffer. */
|
||||
cutbuffer = was_cutbuffer;
|
||||
|
||||
/* Show what we justified on the status bar. */
|
||||
#ifndef NANO_TINY
|
||||
/* Report on the status bar what we justified. */
|
||||
if (openfile->mark)
|
||||
statusline(REMARK, _("Justified selection"));
|
||||
else
|
||||
@@ -1970,6 +1976,9 @@ void justify_text(bool whole_buffer)
|
||||
else
|
||||
statusbar(_("Justified paragraph"));
|
||||
|
||||
/* We're done justifying. Restore the cutbuffer. */
|
||||
cutbuffer = was_cutbuffer;
|
||||
|
||||
/* Set the desired screen column (always zero, except at EOF). */
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
@@ -2052,9 +2061,9 @@ bool replace_buffer(const char *filename, undo_type action, const char *operatio
|
||||
/* Execute the given program, with the given temp file as last argument. */
|
||||
void treat(char *tempfile_name, char *theprogram, bool spelling)
|
||||
{
|
||||
ssize_t lineno_save = openfile->current->lineno;
|
||||
size_t current_x_save = openfile->current_x;
|
||||
size_t pww_save = openfile->placewewant;
|
||||
ssize_t was_lineno = openfile->current->lineno;
|
||||
size_t was_pww = openfile->placewewant;
|
||||
size_t was_x = openfile->current_x;
|
||||
bool was_at_eol = (openfile->current->data[openfile->current_x] == '\0');
|
||||
struct stat fileinfo;
|
||||
long timestamp_sec = 0;
|
||||
@@ -2138,7 +2147,7 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
|
||||
/* Adjust the end point of the marked region for any change in
|
||||
* length of the region's last line. */
|
||||
if (upright)
|
||||
current_x_save = openfile->current_x;
|
||||
was_x = openfile->current_x;
|
||||
else
|
||||
openfile->mark_x = openfile->current_x;
|
||||
|
||||
@@ -2156,7 +2165,7 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
|
||||
}
|
||||
|
||||
/* Go back to the old position. */
|
||||
goto_line_posx(lineno_save, current_x_save);
|
||||
goto_line_posx(was_lineno, was_x);
|
||||
if (was_at_eol || openfile->current_x > strlen(openfile->current->data))
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
|
||||
@@ -2167,7 +2176,7 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
|
||||
#endif
|
||||
}
|
||||
|
||||
openfile->placewewant = pww_save;
|
||||
openfile->placewewant = was_pww;
|
||||
adjust_viewport(STATIONARY);
|
||||
|
||||
if (spelling)
|
||||
@@ -2490,10 +2499,10 @@ void do_spell(void)
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->mark)
|
||||
okay = write_marked_file(temp_name, stream, TRUE, OVERWRITE);
|
||||
okay = write_region_to_file(temp_name, stream, TEMPORARY, OVERWRITE);
|
||||
else
|
||||
#endif
|
||||
okay = write_file(temp_name, stream, TRUE, OVERWRITE, TRUE);
|
||||
okay = write_file(temp_name, stream, TEMPORARY, OVERWRITE, NONOTES);
|
||||
|
||||
if (!okay) {
|
||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||
@@ -2894,7 +2903,7 @@ void do_formatter(void)
|
||||
temp_name = safe_tempfile(&stream);
|
||||
|
||||
if (temp_name != NULL)
|
||||
okay = write_file(temp_name, stream, TRUE, OVERWRITE, TRUE);
|
||||
okay = write_file(temp_name, stream, TEMPORARY, OVERWRITE, NONOTES);
|
||||
|
||||
if (!okay) {
|
||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||
@@ -3027,7 +3036,7 @@ void complete_a_word(void)
|
||||
char *shard, *completion = NULL;
|
||||
size_t start_of_shard, shard_length = 0;
|
||||
size_t i = 0, j = 0;
|
||||
completion_word *some_word;
|
||||
completionstruct *some_word;
|
||||
#ifdef ENABLE_WRAPPING
|
||||
bool was_set_wrapping = ISSET(BREAK_LONG_LINES);
|
||||
#endif
|
||||
@@ -3036,7 +3045,7 @@ void complete_a_word(void)
|
||||
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;
|
||||
completionstruct *dropit = list_of_completions;
|
||||
list_of_completions = list_of_completions->next;
|
||||
free(dropit->word);
|
||||
free(dropit);
|
||||
@@ -3129,7 +3138,7 @@ void complete_a_word(void)
|
||||
}
|
||||
|
||||
/* Add the found word to the list of completions. */
|
||||
some_word = nmalloc(sizeof(completion_word));
|
||||
some_word = nmalloc(sizeof(completionstruct));
|
||||
some_word->word = completion;
|
||||
some_word->next = list_of_completions;
|
||||
list_of_completions = some_word;
|
||||
|
||||
@@ -61,7 +61,7 @@ const char *tail(const char *path)
|
||||
if (slash == NULL)
|
||||
return path;
|
||||
else
|
||||
return ++slash;
|
||||
return slash + 1;
|
||||
}
|
||||
|
||||
/* Return a copy of the two given strings, welded together. */
|
||||
|
||||
32
src/winio.c
32
src/winio.c
@@ -2,7 +2,7 @@
|
||||
* winio.c -- This file is part of GNU nano. *
|
||||
* *
|
||||
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2014-2020 Benno Schulenberg *
|
||||
* Copyright (C) 2014-2021 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 *
|
||||
@@ -233,11 +233,11 @@ void read_keys_from(WINDOW *win)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* When we've failed to get a keycode over a hundred times in a row,
|
||||
/* When we've failed to get a keycode millions of times in a row,
|
||||
* assume our input source is gone and die gracefully. We could
|
||||
* check if errno is set to EIO ("Input/output error") and die in
|
||||
* that case, but it's not always set properly. Argh. */
|
||||
if (input == ERR && ++errcount == 123)
|
||||
if (input == ERR && ++errcount == 12345678)
|
||||
die(_("Too many errors from stdin\n"));
|
||||
}
|
||||
|
||||
@@ -2149,7 +2149,7 @@ void minibar(void)
|
||||
}
|
||||
|
||||
/* Right after reading or writing a file, display its number of lines;
|
||||
* otherwise, when there a mutiple buffers, display an [x/n] counter. */
|
||||
* otherwise, when there are multiple buffers, display an [x/n] counter. */
|
||||
if (report_size && COLS > 35) {
|
||||
size_t count = openfile->filebot->lineno - (openfile->filebot->data[0] == '\0');
|
||||
|
||||
@@ -2176,7 +2176,7 @@ void minibar(void)
|
||||
mvwaddstr(bottomwin, 0, COLS - 27 - placewidth, location);
|
||||
|
||||
/* Display the hexadecimal code of the character under the cursor,
|
||||
* plus the codes of upto two succeeding zero-width characters. */
|
||||
* plus the codes of up to two succeeding zero-width characters. */
|
||||
if (ISSET(CONSTANT_SHOW) && namewidth + tallywidth + 28 < COLS) {
|
||||
char *this_position = openfile->current->data + openfile->current_x;
|
||||
|
||||
@@ -2254,32 +2254,36 @@ void statusline(message_type importance, const char *msg, ...)
|
||||
bool old_whitespace = ISSET(WHITESPACE_DISPLAY);
|
||||
|
||||
UNSET(WHITESPACE_DISPLAY);
|
||||
|
||||
if (isendwin())
|
||||
die("Out of curses -- please report a bug\n");
|
||||
#endif
|
||||
|
||||
/* Ignore a message with an importance that is lower than the last one. */
|
||||
if (importance < lastmessage && lastmessage > NOTICE)
|
||||
return;
|
||||
|
||||
/* On a one-row terminal, ensure that any changes in the edit window are
|
||||
* written out first, to prevent them from overwriting the message. */
|
||||
if (LINES == 1 && importance < INFO)
|
||||
wnoutrefresh(edit);
|
||||
|
||||
/* Construct the message out of all the arguments. */
|
||||
compound = nmalloc(MAXCHARLEN * COLS + 1);
|
||||
va_start(ap, msg);
|
||||
vsnprintf(compound, MAXCHARLEN * COLS + 1, msg, ap);
|
||||
va_end(ap);
|
||||
|
||||
/* When not in curses mode, write the message to standard error. */
|
||||
if (isendwin()) {
|
||||
fprintf(stderr, "\n%s\n", compound);
|
||||
free(compound);
|
||||
return;
|
||||
}
|
||||
|
||||
#if !defined(NANO_TINY) && defined(ENABLE_MULTIBUFFER)
|
||||
if (!we_are_running && importance == ALERT && openfile && !openfile->fmt &&
|
||||
!openfile->errormessage && openfile->next != openfile)
|
||||
openfile->errormessage = copy_of(compound);
|
||||
#endif
|
||||
|
||||
/* On a one-row terminal, ensure that any changes in the edit window are
|
||||
* written out first, to prevent them from overwriting the message. */
|
||||
if (LINES == 1 && importance < INFO)
|
||||
wnoutrefresh(edit);
|
||||
|
||||
/* If there are multiple alert messages, add trailing dots to the first. */
|
||||
if (lastmessage == ALERT) {
|
||||
if (start_col > 4) {
|
||||
@@ -2498,7 +2502,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||
if (line->has_anchor && (from_col == 0 || !ISSET(SOFTWRAP)))
|
||||
#ifdef ENABLE_UTF8
|
||||
if (using_utf8())
|
||||
wprintw(edit, "\xE2\x97\x86"); /* black diamond */
|
||||
wprintw(edit, "\xE2\xAC\xA5"); /* black medium diamond */
|
||||
else
|
||||
#endif
|
||||
wprintw(edit, "+");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## Syntax highlighting for Gentoo ebuilds/eclasses,
|
||||
## and (further down) for Portage control files.
|
||||
|
||||
syntax ebuild "\.e(build|class|blit)$"
|
||||
syntax ebuild "\.e(build|class)$"
|
||||
comment "#"
|
||||
|
||||
## All the standard portage functions:
|
||||
@@ -17,25 +17,25 @@ color green "-(eq|ne|gt|lt|ge|le)\>"
|
||||
## Variables... official portage ones in red, all others in bright red:
|
||||
color brightred "\$[-0-9@*#?$!]" "\$[[:alpha:]_][[:alnum:]_]*"
|
||||
color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:digit:]]|@)+\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
|
||||
color red "\<(EAPI|ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|[BHPR]?DEPEND|PROVIDE|PROPERTIES|REQUIRED_USE|RESTRICT|USERLAND)\>"
|
||||
color red "\<(S|E?D|T|PV|PF|P|PN|PR|PVR|A|CATEGORY|DISTDIR|FILESDIR|EPREFIX|E?ROOT|WORKDIR)\>"
|
||||
color red "\<(EAPI|ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|[BIPR]?DEPEND|PROVIDE|PROPERTIES|REQUIRED_USE|RESTRICT|USERLAND)\>"
|
||||
color red "\<(S|E?D|T|PV|PF|P|PN|PR|PVR|A|CATEGORY|DISTDIR|FILESDIR|EPREFIX|(B|E|E?SYS)?ROOT|WORKDIR)\>"
|
||||
color red "\<(AS|C(PP|XX)?|LD)FLAGS\>" "\<C(HOST|TARGET|BUILD)\>" "\<(MERGE_TYPE|REPLACING_VERSIONS|REPLACED_BY_VERSION)\>"
|
||||
color red "\<EBUILD_PHASE(_FUNC)?\>"
|
||||
color red "\<QA_((TEXTRELS|EXECSTACK|WX_LOAD)(_[a-zA-Z_0-9]+)?|DT_HASH|PRESTRIPPED)\>"
|
||||
color red "\<(PATCHES|(HTML_)?DOCS)\>" "\<WANT_(AUTO(CONF|MAKE)|LIBTOOL)\>" "\<AT_M4DIR\>"
|
||||
## Portage commands:
|
||||
color magenta "\<(use(_(with|enable|if_iuse)|x)?|in_iuse) [!a-zA-Z0-9_+ -]*" "inherit.*"
|
||||
color brightblue "\<e(begin|end|conf|install|make|qmake4|ant|(qa)?warn|infon?|error|log|patch(_user)?|new(group|user))\>"
|
||||
color brightblue "\<e(apply(_user)?|begin|end|conf|install|make|ninja|qmake5|ant|(qa)?warn|infon?|error|log|patch(_user)?|new(group|user))\>"
|
||||
color brightblue "\<e(pause|beep|mktemp|(cvs|svn)_clean|punt_cxx)\>" "\<e(aclocal|auto(reconf|header|conf|make)|libtoolize)\>"
|
||||
color brightblue "\<e(stack|shopts|umask)_(push|pop)\>" "\<version_is_at_least\>"
|
||||
color brightblue "\<e(stack|shopts|umask)_(push|pop)\>" "\<get_libdir\>" "\<ver_(cut|rs|test)\>" "\<version_is_at_least\>"
|
||||
color brightblue "\<make_desktop_entry\>" "\<unpack(_(makeself|pdv))?\>"
|
||||
color brightblue "\<(die|hasv?|inherit|nonfatal)\>" "\<(use(_(with|enable|if_iuse)|x)?|in_iuse)\>" "\<(has|best)_version\>"
|
||||
color brightblue "\<(do|new)(ins|(games)?s?bin|doc|lib(\.so|\.a)?|man|info|exe|initd|confd|envd|pam|menu|icon)\>"
|
||||
color brightblue "\<do(compress|header|python|sed|dir|hard|sym|html|jar|mo)\>" "\<keepdir\>"
|
||||
color brightblue "\<prepall(docs|info|man|strip)?\>" "\<prep(info|lib|lib\.(so|a)|man|strip|gamesdirs)\>"
|
||||
color brightblue "\<(doc|ins|exe)?into\>" "\<(f|games)(owners|perms)\>" "\<(exe|ins|dir)opts\>"
|
||||
color brightblue "\<(do|new)(ins|s?bin|doc|header|lib(\.so|\.a)?|man|info|exe|initd|confd|envd|pam|menu|icon)\>"
|
||||
color brightblue "\<do(compress|dir|html|mo|strip|sym)\>" "\<keepdir\>"
|
||||
color brightblue "\<prepall(docs|info|man|strip)?\>" "\<prep(info|lib|lib\.(so|a)|man|strip)\>"
|
||||
color brightblue "\<(doc|ins|exe)?into\>" "\<f(owners|perms)\>" "\<(exe|ins|dir)opts\>"
|
||||
color brightblue "\<tc-get(BUILD_)?(AR|AS|CC|CPP|CXX|LD|NM|OBJCOPY|PKG_CONFIG|RANLIB)\>"
|
||||
color brightblue "\<tc-(arch(-kernel)?|export|has-(tls|openmp))\>"
|
||||
color brightblue "\<tc-(arch(-kernel)?|export|has-(tls|openmp)|is-cross-compiler)\>"
|
||||
## Common commands used in ebuilds:
|
||||
color blue "\<(awk|cat|cd|chmod|chown|cp|echo|env|find|e?grep|ln|make|mkdir|mv|popd|printf|pushd|rm|rmdir|sed|set|tar|touch|unset|xargs)\>"
|
||||
## Comments (doesn't work that well):
|
||||
@@ -60,7 +60,7 @@ color magenta ":[^[:space:]]+([[:space:]]|$)"
|
||||
color brightred "[[:space:]]+\+?[A-Za-z0-9+_@-]+"
|
||||
color brightblue "[[:space:]]+-[A-Za-z0-9+_@-]+"
|
||||
## Accepted arches:
|
||||
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 "[~-]?\<(alpha|amd64|arm(64)?|hppa|ia64|m68k|mips|ppc(64)?|riscv|s390|sparc|x86)(-(cygwin|linux|macos|solaris|winnt))?\>"
|
||||
color white "[[:space:]][*~-]?\*"
|
||||
## Categories:
|
||||
color cyan "^[[:space:]]*[^/]*/"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## Syntax highlighting for nanorc files.
|
||||
|
||||
syntax nanorc "\.?nanorc$"
|
||||
syntax nanorc "\.?nanorc(\.in)?$"
|
||||
comment "#"
|
||||
|
||||
# Everything that does not get recolored is invalid
|
||||
|
||||
@@ -20,5 +20,3 @@ color white start="(^use| = new)" end=";"
|
||||
|
||||
# Comments.
|
||||
color green "(^|[[:blank:]])#.*"
|
||||
|
||||
color yellow start="<< 'STOP'" end="STOP"
|
||||
|
||||
@@ -31,7 +31,5 @@ color green "'([^']|(\\'))*'" "%[qw]\{[^}]*\}" "%[qw]\([^)]*\)" "%[qw]<[^>]*>" "
|
||||
# Comments.
|
||||
color cyan "#[^{].*" "#$"
|
||||
color brightcyan "##[^{].*" "##$"
|
||||
# "Here" docs.
|
||||
color green start="<<-?'?EOT'?" end="^EOT"
|
||||
# Some common markers.
|
||||
color brightcyan "XXX|TODO|FIXME|\?\?\?"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## Syntax highlighting for Rust.
|
||||
|
||||
## Copyright 2015 Luke Francl.
|
||||
## Licensed under GPL version 3.
|
||||
## Licensed under GPL version 3 or newer.
|
||||
|
||||
syntax rust "\.(rlib|rs)$"
|
||||
comment "//"
|
||||
|
||||
47
syntax/yaml.nanorc
Normal file
47
syntax/yaml.nanorc
Normal file
@@ -0,0 +1,47 @@
|
||||
## Syntax highlighting for YAML files.
|
||||
|
||||
## Original author: Benno Schulenberg
|
||||
## License: GPL version 3 or newer
|
||||
|
||||
syntax yaml "\.ya?ml$"
|
||||
header "^%YAML |^---( |$)"
|
||||
|
||||
tabgives " "
|
||||
comment "#"
|
||||
|
||||
# Keys:
|
||||
color lightgreen "(\w|::|[/.-])+:( |$)"
|
||||
color lightgreen "\[(\w|::|[/., -])+\]:( |$)"
|
||||
|
||||
# Values (booleans, numbers, octal/hex):
|
||||
color lightmagenta "[:,] +(Y(es)?|No?|y(es)?|no?|[Tt]rue|[Ff]alse|[Oo](n|ff))( *[]}]|, | +#|$)"
|
||||
color lightmagenta "[:,] +[+-]?[0-9]+(\.([0-9]+)?)?( *[]}]|, | +#|$)"
|
||||
color lightmagenta " 0(o[0-7]+|x[[:xdigit:]]+)( *[]}]|, | +#|$)"
|
||||
color normal "[:,]( |$)"
|
||||
# Values (dates, strings):
|
||||
color lightmagenta " [12][0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])"
|
||||
color lightmagenta "("([^"]|\\")+"|'[^']+')"
|
||||
|
||||
# Anchors and aliases:
|
||||
color pink " [&*](\w|-)+( |$)"
|
||||
|
||||
# Symbols:
|
||||
color bold,lagoon "^(%YAML +[1-9]\.[0-9]$|%TAG |(---|\.\.\.)( |$))"
|
||||
color bold,lagoon " [|>]([1-9]?[+-]|[+-][1-9]?)?$"
|
||||
color bold,yellow "^ *(\?|([?:] +)?-) "
|
||||
color yellow "[]{}[]"
|
||||
color normal "^ *: "
|
||||
|
||||
# Tags:
|
||||
color mint " !!(binary|bool|float|int|map|null|omap|seq|set|str)( |,|$)"
|
||||
color mint " ![^! ][^ ]*( |$)"
|
||||
|
||||
# Escaped characters:
|
||||
color orange "\\([0abefnrtv"/ \_NLP]|$)"
|
||||
color orange "\\(x[[:xdigit:]]{2}|u[[:xdigit:]]{4}|U[[:xdigit:]]{8})"
|
||||
|
||||
# Mistakes (control codes, trailing space):
|
||||
color ,red "[[:cntrl:]]| +$"
|
||||
|
||||
# Comments:
|
||||
color italic,cyan "(^| )#.*"
|
||||
Reference in New Issue
Block a user