Compare commits

...

24 Commits

Author SHA1 Message Date
Benno Schulenberg
c14b581e0a po: update translations and regenerate POT file and PO files 2016-06-27 11:07:44 +02:00
Benno Schulenberg
bfcb4cd415 bump version numbers and add a news item for 2.6.1 2016-06-27 11:01:54 +02:00
Benno Schulenberg
8fef94cd7d po: make the linguas script regenerate the POT file
So we don't have to remember its awkward target name.
2016-06-27 10:58:47 +02:00
Benno Schulenberg
61d7ca4c41 docs: adjust the description of the verbatim function 2016-06-27 09:35:05 +02:00
Rishabh Dave
559858a3dd browser: don't seem to enter a directory when it is inaccessible
This fixes https://savannah.gnu.org/bugs/?48286.

Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Rishabh Dave <rishabhddave@gmail.com>
2016-06-26 10:14:12 +02:00
Benno Schulenberg
ddd9c7a022 tweaks: try to distinguish between keystrokes and characters
Keystrokes are single integers (aided by the flags meta_key and
func_key) but in the input stream they can be encoded as escape
sequences (a series of bytes).  Characters are values in byte
range, but in UTF-8 one character can consist of multiple bytes.

Also rename two variables, because the secondary input buffer
that they refer to contains only characters (mostly just one),
never any shortcuts; and there are too many "kbinput" already.
2016-06-25 20:34:09 +02:00
Benno Schulenberg
03c689c22c tweaks: normalize a type, and rewrap a line 2016-06-25 20:33:11 +02:00
Benno Schulenberg
5270dd8b32 tweaks: add a reporter's name 2016-06-25 20:03:25 +02:00
Benno Schulenberg
f33796bee1 tweaks: elide an impossible case
Typing a Unicode code is always finished after at most six characters:
either retval == uni or retval == kbinput, but it can't be ERR.
2016-06-25 16:52:36 +02:00
Benno Schulenberg
e679c518b1 tweaks: elide an unneeded variable 2016-06-25 16:52:36 +02:00
Luke Francl
ba9214c689 syntaxes: add highlighting rules for Rust
With tweaks from Andrea Canciani, Ben Young, Tennix, and Dirkjan Ochtman.

This fulfills https://savannah.gnu.org/bugs/?48163.
2016-06-25 09:56:11 +02:00
Benno Schulenberg
68acc1dfc5 tabs: compute the number of required spaces without iterating 2016-06-24 14:56:41 +02:00
Benno Schulenberg
1a4ec6c2d3 moving: allow specifying negative numbers in "Go To Line"
The negatives are taken to mean: from the end of the file,
and: from the end of the line.

This fulfills https://savannah.gnu.org/bugs/?48248.
2016-06-24 14:47:02 +02:00
Benno Schulenberg
6bb30978fb tweaks: add a translator hint 2016-06-24 09:40:31 +02:00
Benno Schulenberg
c0c30731c4 browser: don't use a term that is not explained in the documentation
Also, other messages that are about --operatingdir don't use the term
"confined" either.

Suggested-by: Mario Blättermann <mario.blaettermann@gmail.com>
2016-06-24 09:24:00 +02:00
Jordi Mallach
49eaa7c465 docs: bump pointers to the newest version available
Fix references to an old dist dir in FAQ and RPM spec file.
2016-06-23 19:53:58 +02:00
Jordi Mallach
c2b199e926 docs: use https for nano-editor.org, and drop the www
Switch to https and drop the www. prefix for all occurrences of the
website URL.
2016-06-23 19:51:01 +02:00
Benno Schulenberg
80552aeab7 tweaks: elide an intermediate copy of some line data 2016-06-22 10:30:52 +02:00
Benno Schulenberg
dfbabc0411 tweaks: fix a date and an email address 2016-06-22 10:30:42 +02:00
Benno Schulenberg
59b9b222c8 moving: ignore any number when ^Y or ^V is given
This fixes https://savannah.gnu.org/bugs/?48282.
2016-06-21 16:47:11 +02:00
Benno Schulenberg
79e3eaf73c linter: refresh the edit window in order to actually place the cursor
This fixes https://savannah.gnu.org/bugs/?48283.
2016-06-21 16:25:07 +02:00
Benno Schulenberg
9106cc8ecc main: let the main loop restore the main menu, if needed
Don't make it the responsibility of the executed functions to restore
the list of shortcuts of the edit window.  Just detect whether another
menu was displayed, and if so, redisplay the main menu.
2016-06-21 11:03:38 +02:00
Benno Schulenberg
17fb6dfdc0 tweaks: reshuffle two lines and improve two comments 2016-06-20 13:07:25 +02:00
Benno Schulenberg
95f417fa9a tweaks: rewrap a bunch of lines and some comments 2016-06-20 13:05:45 +02:00
57 changed files with 9098 additions and 9103 deletions

View File

@@ -2966,7 +2966,7 @@ GNU nano 2.3.0 - 2011.02.26
by Eitan Adler <lists@eitanadler.com>.
2011-02-23 Kamil Dudka <kdudka@redhat.com>
* doc/man/nanorc.5: Fix small typo.
* doc/man/nanorc.5: Fix small typo. Report and original patch by John Bradshaw.
2011-02-22 Chris Allegretta <chrisa@asty.org>
* color.c (nfreeregex): Fix that we were trying to set the pointer passed by value
@@ -3009,7 +3009,7 @@ GNU nano 2.2.6 - 2010.11.22
GNU nano 2.2.5 - 2010.08.05
2010-08-04 Lauri Kasanen <curaga@operamail.comcuraga@operamail.com>
2010-08-04 Lauri Kasanen <curaga@operamail.com>
* doc/syntax/mgp.nanorc: New Magicpoint syntax highlighting definition.
2010-08-04 Peter <exodus@savannah>
@@ -3028,7 +3028,7 @@ GNU nano 2.2.5 - 2010.08.05
GNU nano 2.2.4 - 2010.04.15
2010-04-07 Chris Allegretta <chrisa@asty.org>
2010-04-14 Chris Allegretta <chrisa@asty.org>
* doc/man/nano.1,nanorc.5: Remove the backup file warnings now
that a sufficient security fix exists for the backup file code.

View File

@@ -1,6 +1,9 @@
Improvements in nano
====================
Since 2.6.0:
- The ability to use negative numbers at the Go To Line prompt.
Noteworthy changes since 2.2
----------------------------
- The ability to comment/uncomment lines with a single keystroke (M-3).

7
NEWS
View File

@@ -1,3 +1,10 @@
2016.06.27 - nano 2.6.1 "Stampede" is chiefly a translation update, but also
adds one little feature (the ability to use negative numbers
with Go To Line: -1 meaning the first line from the bottom),
includes syntax highlighting for Rust, and fixes three tiny
bugs (but in such far corners of the editor that they aren't
even worth mentioning).
2016.06.17 - nano 2.6.0 "Rubicon" fixes more than fifty little bugs -- and
some of them not so little. It improves moving about in
the file browser, corrects failings of the internal spell

2
README
View File

@@ -40,7 +40,7 @@ How to compile and install nano
Web Page
http://www.nano-editor.org/
https://nano-editor.org/
Mailing Lists and Bug Reports

View File

@@ -18,7 +18,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
# USA.
AC_INIT([nano], [2.6.0], [nano-devel@gnu.org], [nano])
AC_INIT([nano], [2.6.1], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE

View File

@@ -84,22 +84,21 @@
<h2><a name="1.5"></a>1.5. Why the name change from TIP?</h2>
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program &quot;establishes a full duplex terminal connection to a remote host&quot;, and was included with many older Unix systems (and newer ones like Solaris). The conflict was not noticed at first because there is no 'tip' utility included with most GNU/Linux distributions (where nano was developed).</p></blockquote>
<h2><a name="1.6"></a>1.6. What is the current version of nano?</h2>
<blockquote><p>The current stable version of nano *should* be 2.4.2. Of course, you should always check the <a href="http://www.nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<blockquote><p>The current stable version of nano *should* be 2.4.2. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<h2><a name="1.7"></a>1.7. I want to read the man page without having to download the program!</h2>
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="http://www.nano-editor.org/dist/v2.4/nano.1.html">here</a>.</p></blockquote>
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="https://nano-editor.org/dist/v2.6/nano.1.html">here</a>.</p></blockquote>
<hr width="100%">
<h1><a name="2"></a>2. Where to get nano.</h1>
<h2><a name="2.1"></a>2.1. FTP and WWW sites that carry nano.</h2>
<blockquote><p>The nano distribution can be downloaded at the following fine web and ftp sites:</p>
<blockquote><p>The nano distribution can be downloaded at the following web sites:</p>
<ul>
<li><a href="http://www.nano-editor.org/dist/">http://www.nano-editor.org/dist/</a></li>
<li><a href="ftp://ftp.gnu.org/pub/gnu/nano/">ftp://ftp.gnu.org/pub/gnu/nano/</a></li>
<li><a href="https://nano-editor.org/dist/">https://nano-editor.org/dist/</a></li>
</ul>
</blockquote>
<h2><a name="2.2"></a>2.2. RedHat and derivatives (.rpm) packages.</h2>
<blockquote>
<ul>
<li><a href="http://www.nano-editor.org/dist/v2.2/RPMS/">http://www.nano-editor.org/dist/v2.2/RPMS/</a></li>
<li><a href="https://nano-editor.org/dist/v2.5/RPMS/">https://nano-editor.org/dist/v2.5/RPMS/</a></li>
</ul>
</blockquote>
<h2><a name="2.3"></a>2.3. Debian (.deb) packages.</h2>
@@ -232,9 +231,9 @@
<hr width="100%">
<h1><a name="6"></a>6. Advocacy and Licensing</h1>
<h2><a name="6.1"></a>6.1. Why should I use nano instead of Pico?</h2>
<blockquote><p>There are many reasons to use nano instead of Pico. A more complete list can be found at the <a href="http://www.nano-editor.org/">nano homepage</a>.</p></blockquote>
<blockquote><p>There are many reasons to use nano instead of Pico. A more complete list can be found at the <a href="https://nano-editor.org/">nano homepage</a>.</p></blockquote>
<h2><a name="6.2"></a>6.2. Why should I use Pico instead of nano?</h2>
<blockquote><p>Again, check out the <a href="http://www.nano-editor.org/">nano homepage</a> for a good summary of reasons. It really is a matter of personal preference as to which editor you should use. If you're the type of person who likes using the original version of a program, then Pico is the editor for you. If you don't mind sacrificing mailer integration with Pine, and are looking for a few more features, as well as a 'better' license in terms of adding your own changes, nano is the way to go.</p><p>Note that the last of these no longer applies to the new version of Pine, <a href="http://www.washington.edu/alpine/">Alpine</a>, which is under the Apache License, version 2.0.</p></blockquote>
<blockquote><p>Again, check out the <a href="https://nano-editor.org/">nano homepage</a> for a good summary of reasons. It really is a matter of personal preference as to which editor you should use. If you're the type of person who likes using the original version of a program, then Pico is the editor for you. If you don't mind sacrificing mailer integration with Pine, and are looking for a few more features, as well as a 'better' license in terms of adding your own changes, nano is the way to go.</p><p>Note that the last of these no longer applies to the new version of Pine, <a href="http://www.washington.edu/alpine/">Alpine</a>, which is under the Apache License, version 2.0.</p></blockquote>
<h2><a name="6.3"></a>6.3. What is so bad about the older Pine license?</h2>
<blockquote><p>The U of W license for older versions of Pine and Pico is not considered truly Free Software according to both the Free Software Foundation and the <a href="http://www.debian.org/social_contract#guidelines">Debian Free Software Guidelines</a>. The main problem regards the limitations on distributing derived works: according to UW, you can distribute their software, and you can modify it, but you can not do both, i.e. distribute modified binaries.</p></blockquote>
<h2><a name="6.4"></a>6.4. Okay, well, what mail program should I use then?</h2>
@@ -248,7 +247,7 @@ Of course, due to the license change you can now use the <A HREF="http://www.was
help-nano - <a href="http://mail.gnu.org/mailman/listinfo/help-nano/">http://mail.gnu.org/mailman/listinfo/help-nano/</a><br>
nano-devel - <a href="http://mail.gnu.org/mailman/listinfo/nano-devel/">http://mail.gnu.org/mailman/listinfo/nano-devel/</a></p></blockquote>
<h2><a name="7.2"></a>7.2. I want to send the development team a big load of cash (or just a thank you).</h2>
<blockquote><p>That's fine. Send it <a href="mailto:nano-devel@gnu.org">our way</a>! Better yet, fix a <a href="https://savannah.gnu.org/bugs/?group=nano">bug</a> in the program or implement a <a href="http://www.nano-editor.org/dist/v2.3/TODO">cool feature</a> and send us that instead (though cash is fine too).</p></blockquote>
<blockquote><p>That's fine. Send it <a href="mailto:nano-devel@gnu.org">our way</a>! Better yet, fix a <a href="https://savannah.gnu.org/bugs/?group=nano">bug</a> in the program or implement a <a href="https://nano-editor.org/dist/v2.6/TODO">cool feature</a> and send us that instead (though cash is fine too).</p></blockquote>
<h2><a name="7.3"></a>7.3. How do I submit a bug report or patch?</h2>
<blockquote>
<p>The best place to submit bugs is to the <a href="https://savannah.gnu.org/bugs/?group=nano">Savannah bug tracker</a> as you can check whether the bug you are submitting has already been submitted.

View File

@@ -17,7 +17,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 2.6.0" "June 2016"
.TH NANO 1 "version 2.6.1" "June 2016"
.\" Please adjust this date whenever revising the manpage.
.\"
@@ -278,7 +278,7 @@ Please report any other bugs that you encounter via
https://savannah.gnu.org/bugs/?group=nano.
.SH HOMEPAGE
http://www.nano-editor.org/
https://nano-editor.org/
.SH SEE ALSO
.PD 0

View File

@@ -17,7 +17,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 2.6.0" "June 2016"
.TH NANORC 5 "version 2.6.1" "June 2016"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH NAME
@@ -518,7 +518,8 @@ Goes to the first line of the file.
Goes to the last line of the file.
.TP
.B gotoline
Goes to a specific line (and column if specified).
Goes to a specific line (and column if specified). Negative numbers count
from the end of the file (and end of the line).
.TP
.B gototext
Switches from targeting a line number to searching for text.
@@ -534,7 +535,7 @@ Switches to editing/viewing the previous buffer when multiple buffers are open.
Switches to editing/viewing the next buffer when multiple buffers are open.
.TP
.B verbatim
Inserts the next character verbatim into the file.
Inserts the next keystroke verbatim into the file.
.TP
.B tab
Inserts a tab at the current cursor location.

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH RNANO 1 "version 2.6.0" "June 2016"
.TH RNANO 1 "version 2.6.1" "June 2016"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH NAME

View File

@@ -34,6 +34,7 @@ pkgdata_DATA = asm.nanorc \
pov.nanorc \
python.nanorc \
ruby.nanorc \
rust.nanorc \
sh.nanorc \
spec.nanorc \
tcl.nanorc \

39
doc/syntax/rust.nanorc Normal file
View File

@@ -0,0 +1,39 @@
## Syntax highlighting for Rust.
## Copyright 2015 Luke Francl.
## Licensed under GPL version 3.
## NOTE: Rules are applied in order: later rules re-colorize matching text.
syntax "rust" "\.rs"
comment "//"
# Function definitions
color magenta "fn [a-z_0-9]+"
# Reserved words
color yellow "\<(abstract|alignof|as|become|box|break|const|continue|crate|do|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|offsetof|override|priv|pub|pure|ref|return|sizeof|static|self|struct|super|true|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\>"
# Macros
color red "[a-z_]+!"
# Constants
color magenta "[A-Z][A-Z_0-9]+"
# Traits/Enums/Structs/Types/...
color magenta "[A-Z][a-z0-9]+"
# Strings
color green "\".*\""
color green start="\".*\\$" end=".*\""
## NOTE: This isn't accurate, but matching "#{0,} for the end of the string is too liberal.
color green start="r#+\"" end="\"#+"
# Comments
color blue "//.*"
color blue start="/\*" end="\*/"
# Attributes
color magenta start="#!\[" end="\]"
# Some common markers
color brightcyan "(XXX|TODO|FIXME|\?\?\?)"

View File

@@ -6,7 +6,7 @@
@smallbook
@set EDITION 0.4
@set VERSION 2.6.0
@set VERSION 2.6.1
@set UPDATED June 2016
@dircategory Editors
@@ -21,7 +21,7 @@
@titlepage
@title @code{nano}
@subtitle a small and friendly text editor.
@subtitle version 2.6.0
@subtitle version 2.6.1
@author Chris Allegretta
@page
@@ -1104,7 +1104,8 @@ Goes to the first line of the file.
Goes to the last line of the file.
@item gotoline
Goes to a specific line (and column if specified).
Goes to a specific line (and column if specified). Negative numbers count
from the end of the file (and end of the line).
@item gototext
Switches from targeting a line number to searching for text.
@@ -1120,7 +1121,7 @@ Switches to editing/viewing the previous buffer when multiple buffers are open.
Switches to editing/viewing the next buffer when multiple buffers are open.
@item verbatim
Inserts the next character verbatim into the file.
Inserts the next keystroke verbatim into the file.
@item tab
Inserts a tab at the current cursor location.

View File

@@ -9,8 +9,8 @@ Summary : a user-friendly editor, a Pico clone with enhancements
License : GPLv3+
Group : Applications/Editors
URL : http://www.nano-editor.org/
Source : http://www.nano-editor.org/dist/v2.4/%{name}-%{version}.tar.gz
URL : https://nano-editor.org/
Source : https://nano-editor.org/dist/v2.6/%{name}-%{version}.tar.gz
BuildRoot : %{_tmppath}/%{name}-%{version}-root
BuildRequires : autoconf, automake, gettext-devel, ncurses-devel, texinfo

474
po/bg.po

File diff suppressed because it is too large Load Diff

477
po/ca.po

File diff suppressed because it is too large Load Diff

477
po/cs.po

File diff suppressed because it is too large Load Diff

477
po/da.po

File diff suppressed because it is too large Load Diff

585
po/de.po

File diff suppressed because it is too large Load Diff

590
po/eo.po

File diff suppressed because it is too large Load Diff

588
po/es.po

File diff suppressed because it is too large Load Diff

477
po/eu.po

File diff suppressed because it is too large Load Diff

477
po/fi.po

File diff suppressed because it is too large Load Diff

584
po/fr.po

File diff suppressed because it is too large Load Diff

474
po/ga.po

File diff suppressed because it is too large Load Diff

477
po/gl.po

File diff suppressed because it is too large Load Diff

590
po/hr.po

File diff suppressed because it is too large Load Diff

591
po/hu.po

File diff suppressed because it is too large Load Diff

477
po/id.po

File diff suppressed because it is too large Load Diff

477
po/it.po

File diff suppressed because it is too large Load Diff

474
po/ja.po

File diff suppressed because it is too large Load Diff

474
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

651
po/nb.po

File diff suppressed because it is too large Load Diff

608
po/nl.po

File diff suppressed because it is too large Load Diff

475
po/nn.po

File diff suppressed because it is too large Load Diff

477
po/pl.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

594
po/ro.po

File diff suppressed because it is too large Load Diff

474
po/ru.po

File diff suppressed because it is too large Load Diff

474
po/sl.po

File diff suppressed because it is too large Load Diff

477
po/sr.po

File diff suppressed because it is too large Load Diff

477
po/sv.po

File diff suppressed because it is too large Load Diff

474
po/tr.po

File diff suppressed because it is too large Load Diff

587
po/uk.po

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
#!/bin/sh
# Execute this is the po/ subdir.
# Let this be executed in the po/ subdir.
cd "$(dirname "$0")" || exit
echo "Updating translations via TP"
@@ -15,10 +15,5 @@ if [ -n "${NEWSTUFF}" ]; then
echo $(printf '%s\n' *.po | LC_ALL=C sort | sed 's/\.po//g') >>LINGUAS
fi
echo "Remerging and recompiling the PO files..."
make
#echo "Staging the files"
#git add -v nano.pot
#git add -v *.po
#git add -v LINGUAS
echo "Regenerating POT file and remerging and recompiling PO files..."
make update-po

594
po/vi.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -115,6 +115,7 @@ char *do_browser(char *path)
old_selected = (size_t)-1;
free(newpath);
newpath = NULL;
present_path = mallocstrcpy(present_path, path);
@@ -123,14 +124,13 @@ char *do_browser(char *path)
while (TRUE) {
struct stat st;
int i;
char *new_path;
/* The path we switch to at the "Go to Directory"
* prompt. */
/* Make sure that the cursor is off. */
curs_set(0);
lastmessage = HUSH;
bottombars(MBROWSER);
#ifndef NANO_TINY
if (kbinput == KEY_WINCH) {
/* Remember the selected file, to be able to reselect it. */
@@ -245,9 +245,6 @@ char *do_browser(char *path)
#endif
/* TRANSLATORS: This is a prompt. */
browser_refresh, _("Go To Directory"));
bottombars(MBROWSER);
/* If the directory begins with a newline (i.e. an
* encoded null), treat it as though it's blank. */
if (i < 0 || *answer == '\n') {
@@ -259,37 +256,32 @@ char *do_browser(char *path)
sunder(answer);
align(&answer);
new_path = real_dir_from_tilde(answer);
newpath = real_dir_from_tilde(answer);
if (new_path[0] != '/') {
new_path = charealloc(new_path, strlen(path) +
if (newpath[0] != '/') {
newpath = charealloc(newpath, strlen(path) +
strlen(answer) + 1);
sprintf(new_path, "%s%s", path, answer);
sprintf(newpath, "%s%s", path, answer);
}
#ifndef DISABLE_OPERATINGDIR
if (check_operating_dir(new_path, FALSE)) {
/* TRANSLATORS: This refers to the option --operatingdir,
* not to --restricted. */
statusline(ALERT, _("Can't go outside of %s "
"in confined mode"), full_operating_dir);
free(new_path);
if (check_operating_dir(newpath, FALSE)) {
/* TRANSLATORS: This refers to the confining effect of the
* option --operatingdir, not of --restricted. */
statusline(ALERT, _("Can't go outside of %s"),
full_operating_dir);
free(newpath);
newpath = NULL;
continue;
}
#endif
/* In case the specified directory cannot be entered, select it
* (if it is in the current list) so it will be highlighted. */
for (i = 0; i < filelist_len; i++)
if (strcmp(filelist[i], newpath) == 0)
selected = i;
dir = opendir(new_path);
if (dir == NULL) {
/* We can't open this directory for some reason. */
statusline(ALERT, _("Error reading %s: %s"), answer,
strerror(errno));
free(new_path);
continue;
}
/* Start over again with the new path value. */
free(path);
path = new_path;
/* Try opening and reading the specified directory. */
goto read_directory_contents;
} else if (func == do_up_void) {
if (selected >= width)
@@ -323,8 +315,8 @@ char *do_browser(char *path)
* directory if it's ".." or if it's a symlink to a
* directory outside the operating directory. */
if (check_operating_dir(filelist[selected], FALSE)) {
statusline(ALERT, _("Can't go outside of %s "
"in confined mode"), full_operating_dir);
statusline(ALERT, _("Can't go outside of %s"),
full_operating_dir);
continue;
}
#endif
@@ -348,7 +340,7 @@ char *do_browser(char *path)
present_name = striponedir(filelist[selected]);
/* Try opening and reading the selected directory. */
newpath = filelist[selected];
newpath = strdup(filelist[selected]);
goto read_directory_contents;
} else if (func == do_exit) {
/* Exit from the file browser. */
@@ -782,11 +774,9 @@ void findnextfile(const char *needle)
/* Search for a filename. */
void do_filesearch(void)
{
if (filesearch_init() != 0) {
/* Cancelled, or a blank search string, or done something. */
bottombars(MBROWSER);
/* If the user cancelled or jumped to first or last file, don't search. */
if (filesearch_init() != 0)
return;
}
/* If answer is now "", copy last_search into answer. */
if (*answer == '\0')
@@ -801,8 +791,6 @@ void do_filesearch(void)
#endif
findnextfile(answer);
bottombars(MBROWSER);
}
/* Search again for the last given filename, without prompting. */

View File

@@ -590,7 +590,6 @@ void switch_to_prevnext_buffer(bool to_next)
#ifdef DEBUG
dump_filestruct(openfile->current);
#endif
display_main_list();
}
/* Switch to the previous entry in the openfile filebuffer. */
@@ -1178,8 +1177,7 @@ void do_insertfile(
size_t top_x, bot_x;
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x,
&right_side_up);
(const filestruct **)&bot, &bot_x, &right_side_up);
single_line = (top == bot);
}
@@ -1343,8 +1341,6 @@ void do_insertfile_void(void)
FALSE
#endif
);
display_main_list();
}
/* When passed "[relative path]" or "[relative path][filename]" in
@@ -2475,8 +2471,6 @@ void do_writeout_void(void)
/* If the user chose to discard the buffer, close it. */
if (do_writeout(FALSE) == 2)
close_and_go();
display_main_list();
}
#ifndef NANO_TINY

View File

@@ -167,8 +167,8 @@ bool refresh_needed = FALSE;
/* Did a command mangle enough of the buffer that we should
* repaint the screen? */
int currmenu;
/* The currently loaded menu. */
int currmenu = MMOST;
/* The currently active menu, initialized to a dummy value. */
sc *sclist = NULL;
/* Pointer to the start of the shortcuts list. */
subnfunc *allfuncs = NULL;

View File

@@ -218,17 +218,15 @@ partition *partition_filestruct(filestruct *top, size_t top_x,
} else
p->filebot = NULL;
/* Save the line above the top of the partition, detach the top of
* the partition from it, and save the text before top_x in
* top_data. */
/* Remember which line is above the top of the partition, detach the
* top of the partition from it, and save the text before top_x. */
p->top_prev = top->prev;
top->prev = NULL;
p->top_data = mallocstrncpy(NULL, top->data, top_x + 1);
p->top_data[top_x] = '\0';
/* Save the line below the bottom of the partition, detach the
* bottom of the partition from it, and save the text after bot_x in
* bot_data. */
/* Remember which line is below the bottom of the partition, detach the
* bottom of the partition from it, and save the text after bot_x. */
p->bot_next = bot->next;
bot->next = NULL;
p->bot_data = mallocstrcpy(NULL, bot->data + bot_x);
@@ -237,8 +235,7 @@ partition *partition_filestruct(filestruct *top, size_t top_x,
null_at(&bot->data, bot_x);
/* Remove all text before top_x at the top of the partition. */
charmove(top->data, top->data + top_x, strlen(top->data) -
top_x + 1);
charmove(top->data, top->data + top_x, strlen(top->data) - top_x + 1);
align(&top->data);
/* Return the partition. */
@@ -249,23 +246,20 @@ partition *partition_filestruct(filestruct *top, size_t top_x,
* at (filebot, strlen(filebot->data)) again. */
void unpartition_filestruct(partition **p)
{
char *tmp;
assert(p != NULL && openfile->fileage != NULL && openfile->filebot != NULL);
/* Reattach the line above the top of the partition, and restore the
* text before top_x from top_data. Free top_data when we're done
* with it. */
tmp = mallocstrcpy(NULL, openfile->fileage->data);
openfile->fileage->prev = (*p)->top_prev;
if (openfile->fileage->prev != NULL)
openfile->fileage->prev->next = openfile->fileage;
openfile->fileage->data = charealloc(openfile->fileage->data,
strlen((*p)->top_data) + strlen(openfile->fileage->data) + 1);
strcpy(openfile->fileage->data, (*p)->top_data);
strlen((*p)->top_data) + strlen(openfile->fileage->data) + 1);
charmove(openfile->fileage->data + strlen((*p)->top_data),
openfile->fileage->data, strlen(openfile->fileage->data) + 1);
strncpy(openfile->fileage->data, (*p)->top_data, strlen((*p)->top_data));
free((*p)->top_data);
strcat(openfile->fileage->data, tmp);
free(tmp);
/* Reattach the line below the bottom of the partition, and restore
* the text after bot_x from bot_data. Free bot_data when we're
@@ -274,7 +268,7 @@ void unpartition_filestruct(partition **p)
if (openfile->filebot->next != NULL)
openfile->filebot->next->prev = openfile->filebot;
openfile->filebot->data = charealloc(openfile->filebot->data,
strlen(openfile->filebot->data) + strlen((*p)->bot_data) + 1);
strlen(openfile->filebot->data) + strlen((*p)->bot_data) + 1);
strcat(openfile->filebot->data, (*p)->bot_data);
free((*p)->bot_data);
@@ -315,9 +309,8 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
* the edit window is inside the partition, and keep track of
* whether the mark begins inside the partition. */
filepart = partition_filestruct(top, top_x, bot, bot_x);
edittop_inside = (openfile->edittop->lineno >=
openfile->fileage->lineno && openfile->edittop->lineno <=
openfile->filebot->lineno);
edittop_inside = (openfile->edittop->lineno >= openfile->fileage->lineno &&
openfile->edittop->lineno <= openfile->filebot->lineno);
#ifndef NANO_TINY
if (openfile->mark_set) {
mark_inside = (openfile->mark_begin->lineno >=
@@ -332,8 +325,7 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
}
#endif
/* Get the number of characters in the text, and subtract it from
* totsize. */
/* Subtract the number of characters in the text from the file size. */
openfile->totsize -= get_totsize(top, bot);
if (*file_top == NULL) {
@@ -343,7 +335,7 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
*file_top = openfile->fileage;
*file_bot = openfile->filebot;
/* Renumber starting with file_top. */
/* Renumber, starting with file_top. */
renumber(*file_top);
} else {
filestruct *file_bot_save = *file_bot;
@@ -366,13 +358,11 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
delete_node(openfile->fileage);
/* Renumber starting with the line after the original
* file_bot. */
/* Renumber, starting with the line after the original file_bot. */
renumber(file_bot_save->next);
}
/* Since the text has now been saved, remove it from the
* filestruct. */
/* Since the text has now been saved, remove it from the filestruct. */
openfile->fileage = (filestruct *)nmalloc(sizeof(filestruct));
openfile->fileage->data = mallocstrcpy(NULL, "");
openfile->filebot = openfile->fileage;
@@ -408,12 +398,10 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
refresh_needed = TRUE;
}
/* Renumber starting with the beginning line of the old
* partition. */
/* Renumber, starting with the beginning line of the old partition. */
renumber(top_save);
/* If the NO_NEWLINES flag isn't set, and the text doesn't end with
* a magicline, add a new magicline. */
/* If the text doesn't end with a magicline, and it should, add one. */
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
new_magicline();
}
@@ -439,22 +427,21 @@ void copy_from_filestruct(filestruct *somebuffer)
size_t top_x, bot_x;
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, &right_side_up);
(const filestruct **)&bot, &bot_x, &right_side_up);
single_line = (top == bot);
}
#endif
/* Partition the filestruct so that it contains no text, and keep
* track of whether the top of the edit window is inside the
* partition. */
filepart = partition_filestruct(openfile->current,
openfile->current_x, openfile->current, openfile->current_x);
/* Partition the filestruct so that it contains no text, and remember
* whether the current line is at the top of the edit window. */
filepart = partition_filestruct(openfile->current, openfile->current_x,
openfile->current, openfile->current_x);
edittop_inside = (openfile->edittop == openfile->fileage);
free_filestruct(openfile->fileage);
/* Put the top and bottom of the current filestruct at the top and
* bottom of a copy of the passed buffer. */
free_filestruct(openfile->fileage);
openfile->fileage = copy_filestruct(somebuffer);
openfile->filebot = openfile->fileage;
while (openfile->filebot->next != NULL)
@@ -489,33 +476,29 @@ void copy_from_filestruct(filestruct *somebuffer)
}
#endif
/* Get the number of characters in the copied text, and add it to
* totsize. */
openfile->totsize += get_totsize(openfile->fileage,
openfile->filebot);
/* Add the number of characters in the copied text to the file size. */
openfile->totsize += get_totsize(openfile->fileage, openfile->filebot);
/* Update the current y-coordinate to account for the number of
* lines the copied text has, less one since the first line will be
* tacked onto the current line. */
openfile->current_y += openfile->filebot->lineno - 1;
top_save = openfile->fileage;
/* If the top of the edit window is inside the partition, set it to
* where the copied text now starts. */
/* If we pasted onto the first line of the edit window, the corresponding
* struct has been freed, so... point at the start of the copied text. */
if (edittop_inside)
openfile->edittop = openfile->fileage;
top_save = openfile->fileage;
/* Unpartition the filestruct so that it contains all the text
* again, plus the copied text. */
unpartition_filestruct(&filepart);
/* Renumber starting with the beginning line of the old
* partition. */
/* Renumber, starting with the beginning line of the old partition. */
renumber(top_save);
/* If the NO_NEWLINES flag isn't set, and the text doesn't end with
* a magicline, add a new magicline. */
/* If the text doesn't end with a magicline, and it should, add one. */
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
new_magicline();
}
@@ -942,7 +925,7 @@ void version(void)
printf(" (C) 1999..2016 Free Software Foundation, Inc.\n");
printf(_(" (C) 2014..%s the contributors to nano\n"), "2016");
printf(
_(" Email: nano@nano-editor.org Web: http://www.nano-editor.org/"));
_(" Email: nano@nano-editor.org Web: https://nano-editor.org/"));
printf(_("\n Compiled options:"));
#ifdef NANO_TINY
@@ -1126,8 +1109,6 @@ void do_exit(void)
close_and_go();
else if (i != 1)
statusbar(_("Cancelled"));
display_main_list();
}
/* Close the current buffer, and terminate nano if it was the last. */
@@ -1581,24 +1562,23 @@ void unbound_key(int code)
statusline(ALERT, _("Unbound key: %c"), code);
}
/* Read in a character, interpret it as a shortcut or toggle if
* necessary, and return it.
* If allow_funcs is FALSE, don't actually run any functions associated
* with shortcut keys. */
/* Read in a keystroke. Act on the keystroke if it is a shortcut or a toggle;
* otherwise, insert it into the edit buffer. If allow_funcs is FALSE, don't
* do anything with the keystroke -- just return it. */
int do_input(bool allow_funcs)
{
int input;
/* The character we read in. */
static int *kbinput = NULL;
/* The input buffer. */
static size_t kbinput_len = 0;
/* The keystroke we read in: a character or a shortcut. */
static int *puddle = NULL;
/* The input buffer for actual characters. */
static size_t depth = 0;
/* The length of the input buffer. */
bool preserve = FALSE;
/* Preserve the contents of the cutbuffer? */
/* Whether to preserve the contents of the cutbuffer. */
const sc *s;
bool have_shortcut;
/* Read in a character. */
/* Read in a keystroke. */
input = get_kbinput(edit);
#ifndef NANO_TINY
@@ -1638,26 +1618,23 @@ int do_input(bool allow_funcs)
}
if (allow_funcs) {
/* If we got a character, and it isn't a shortcut or toggle,
* it's a normal text character. Display the warning if we're
* in view mode, or add the character to the input buffer if
* we're not. */
/* If the keystroke isn't a shortcut nor a toggle, it's a normal text
* character: add the character to the input buffer -- or display a
* warning when we're in view mode. */
if (input != ERR && !have_shortcut) {
if (ISSET(VIEW_MODE))
print_view_warning();
else {
kbinput_len++;
kbinput = (int *)nrealloc(kbinput, kbinput_len *
sizeof(int));
kbinput[kbinput_len - 1] = input;
depth++;
puddle = (int *)nrealloc(puddle, depth * sizeof(int));
puddle[depth - 1] = input;
}
}
/* If we got a shortcut or toggle, or if there aren't any other
* characters waiting after the one we read in, we need to
* output all the characters in the input buffer if it isn't
* empty. Note that it should be empty if we're in view
* mode. */
* characters waiting after the one we read in, we need to output
* all available characters in the input puddle. Note that this
* puddle will be empty if we're in view mode. */
if (have_shortcut || get_key_buffer_len() == 0) {
#ifndef DISABLE_WRAPPING
/* If we got a shortcut or toggle, and it's not the shortcut
@@ -1666,24 +1643,24 @@ int do_input(bool allow_funcs)
wrap_reset();
#endif
if (kbinput != NULL) {
if (puddle != NULL) {
/* Display all the characters in the input buffer at
* once, filtering out control characters. */
char *output = charalloc(kbinput_len + 1);
char *output = charalloc(depth + 1);
size_t i;
for (i = 0; i < kbinput_len; i++)
output[i] = (char)kbinput[i];
for (i = 0; i < depth; i++)
output[i] = (char)puddle[i];
output[i] = '\0';
do_output(output, kbinput_len, FALSE);
do_output(output, depth, FALSE);
free(output);
/* Empty the input buffer. */
kbinput_len = 0;
free(kbinput);
kbinput = NULL;
free(puddle);
puddle = NULL;
depth = 0;
}
}
@@ -1864,12 +1841,11 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
#endif
while (i < output_len) {
/* If allow_cntrls is TRUE, convert nulls and newlines properly. */
/* If control codes are allowed, encode a null as a newline, and
* let a newline character create a whole new line. */
if (allow_cntrls) {
/* Null to newline, if needed. */
if (output[i] == '\0')
output[i] = '\n';
/* Newline to Enter, if needed. */
else if (output[i] == '\n') {
do_enter();
i++;
@@ -1877,31 +1853,29 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
}
}
/* Interpret the next multibyte character. */
/* Get the next multibyte character. */
char_buf_len = parse_mbchar(output + i, char_buf, NULL);
i += char_buf_len;
/* If allow_cntrls is FALSE, filter out an ASCII control character. */
/* If controls are not allowed, ignore an ASCII control character. */
if (!allow_cntrls && is_ascii_cntrl_char(*(output + i - char_buf_len)))
continue;
/* If the NO_NEWLINES flag isn't set, when a character is
* added to the magicline, it means we need a new magicline. */
/* If we're adding to the magicline, create a new magicline. */
if (!ISSET(NO_NEWLINES) && openfile->filebot == openfile->current)
new_magicline();
/* More dangerousness fun =) */
openfile->current->data = charealloc(openfile->current->data,
current_len + char_buf_len + 1);
assert(openfile->current_x <= current_len);
/* Make room for the new character and copy it into the line. */
openfile->current->data = charealloc(openfile->current->data,
current_len + char_buf_len + 1);
charmove(openfile->current->data + openfile->current_x + char_buf_len,
openfile->current->data + openfile->current_x,
current_len - openfile->current_x + 1);
strncpy(openfile->current->data + openfile->current_x, char_buf,
char_buf_len);
char_buf_len);
current_len += char_buf_len;
openfile->totsize++;
set_modified();
@@ -2652,12 +2626,12 @@ int main(int argc, char **argv)
fprintf(stderr, "Main: bottom win, top win and edit win\n");
#endif
display_main_list();
display_buffer();
while (TRUE) {
currmenu = MMAIN;
if (currmenu != MMAIN)
display_main_list();
focusing = TRUE;
lastmessage = HUSH;
@@ -2675,7 +2649,7 @@ int main(int argc, char **argv)
curs_set(1);
wnoutrefresh(edit);
/* Read in and interpret characters. */
/* Read in and interpret keystrokes. */
do_input(TRUE);
}

View File

@@ -917,6 +917,8 @@ int do_yesno_prompt(bool all, const char *msg)
}
} while (response == -2);
currmenu = oldmenu;
/* Restore the previously active menu. */
bottombars(oldmenu);
return response;
}

View File

@@ -104,7 +104,6 @@ void not_found_msg(const char *str)
* search, if any. */
void search_replace_abort(void)
{
display_main_list();
#ifndef NANO_TINY
if (openfile->mark_set)
edit_refresh();
@@ -302,6 +301,8 @@ int findnextstr(
}
if (++feedback > 0)
/* TRANSLATORS: This is shown when searching takes
* more than half a second. */
statusbar(_("Searching..."));
}
@@ -628,7 +629,7 @@ ssize_t do_replace_loop(
if (old_mark_set) {
/* If the mark is on, frame the region, and turn the mark off. */
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, &right_side_up);
(const filestruct **)&bot, &bot_x, &right_side_up);
openfile->mark_set = FALSE;
/* Start either at the top or the bottom of the marked region. */
@@ -913,31 +914,27 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
/* TRANSLATORS: This is a prompt. */
edit_refresh, _("Enter line number, column number"));
/* Cancel, or Enter with blank string. */
/* If the user cancelled or gave a blank answer, get out. */
if (i < 0) {
statusbar(_("Cancelled"));
display_main_list();
return;
}
func = func_from_key(&i);
if (func == gototext_void) {
/* Keep answer up on the statusbar. */
/* Retain what the user typed so far and switch to searching. */
search_init(TRUE, TRUE);
do_search();
return;
}
/* Do a bounds check. Display a warning on an out-of-bounds
* line or column number only if we hit Enter at the statusbar
* prompt. */
if (!parse_line_column(answer, &line, &column) ||
line < 1 || column < 1) {
if (i == 0)
statusbar(_("Invalid line or column number"));
display_main_list();
/* If a function was executed, we're done here. */
if (i > 0)
return;
/* Try to extract one or two numbers from the user's response. */
if (!parse_line_column(answer, &line, &column)) {
statusbar(_("Invalid line or column number"));
return;
}
} else {
@@ -948,10 +945,24 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
column = openfile->placewewant + 1;
}
/* Take a negative line number to mean: from the end of the file. */
if (line < 0)
line = openfile->filebot->lineno + line + 1;
if (line < 1)
line = 1;
/* Iterate to the requested line. */
for (openfile->current = openfile->fileage; line > 1 &&
openfile->current != openfile->filebot; line--)
openfile->current = openfile->current->next;
/* Take a negative column number to mean: from the end of the line. */
if (column < 0)
column = strlenpt(openfile->current->data) + column + 2;
if (column < 1)
column = 1;
/* Set the x position that corresponds to the requested column. */
openfile->current_x = actual_x(openfile->current->data, column - 1);
openfile->placewewant = column - 1;
@@ -959,7 +970,6 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
if (interactive) {
edit_update(CENTERING);
edit_refresh();
display_main_list();
} else {
/* If the target line is close to the tail of the file, put the last
* line of the file on the bottom line of the screen; otherwise, just

View File

@@ -247,25 +247,18 @@ void do_tab(void)
{
#ifndef NANO_TINY
if (ISSET(TABS_TO_SPACES)) {
char *output;
size_t output_len = 0, new_pww = xplustabs();
char *spaces = charalloc(tabsize + 1);
size_t length = tabsize - (xplustabs() % tabsize);
do {
new_pww++;
output_len++;
} while (new_pww % tabsize != 0);
charset(spaces, ' ', length);
spaces[length] = '\0';
output = charalloc(output_len + 1);
do_output(spaces, length, TRUE);
charset(output, ' ', output_len);
output[output_len] = '\0';
do_output(output, output_len, TRUE);
free(output);
free(spaces);
} else
#endif
do_output((char *) "\t", 1, TRUE);
do_output((char *)"\t", 1, TRUE);
}
#ifndef NANO_TINY
@@ -306,7 +299,7 @@ void do_indent(ssize_t cols)
/* If the mark is on, use all lines covered by the mark. */
if (openfile->mark_set)
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, NULL);
(const filestruct **)&bot, &bot_x, NULL);
/* Otherwise, use the current line. */
else {
top = openfile->current;
@@ -472,8 +465,8 @@ void do_comment()
/* Determine which lines to work on. */
if (openfile->mark_set)
mark_order((const filestruct **) &top, &top_x,
(const filestruct **) &bot, &bot_x, NULL);
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, NULL);
else {
top = openfile->current;
bot = top;
@@ -2037,7 +2030,7 @@ void backup_lines(filestruct *first_line, size_t par_len)
* current and filebot if filebot is the last line in the
* paragraph. */
assert(par_len > 0 && openfile->current->lineno + par_len <=
openfile->filebot->lineno + 1);
openfile->filebot->lineno + 1);
/* Move bot down par_len lines to the line after the last line of
* the paragraph, if there is one. */
@@ -2047,7 +2040,7 @@ void backup_lines(filestruct *first_line, size_t par_len)
/* Move the paragraph from the current buffer's filestruct to the
* justify buffer. */
move_to_filestruct(&jusbuffer, &jusbottom, top, 0, bot,
(i == 1 && bot == openfile->filebot) ? strlen(bot->data) : 0);
(i == 1 && bot == openfile->filebot) ? strlen(bot->data) : 0);
/* Copy the paragraph back to the current buffer's filestruct from
* the justify buffer. */
@@ -2524,8 +2517,8 @@ void do_justify(bool full_justify)
/* Partition the filestruct so that it contains only the
* text of the justified paragraph. */
filepart = partition_filestruct(first_par_line, 0,
last_par_line, filebot_inpar ?
strlen(last_par_line->data) : 0);
last_par_line, filebot_inpar ?
strlen(last_par_line->data) : 0);
/* Remove the text of the justified paragraph, and
* replace it with the text in the justify buffer. */
@@ -2650,7 +2643,7 @@ bool do_int_spell_fix(const char *word)
/* If the mark is on, start at the beginning of the marked region. */
if (old_mark_set) {
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, &right_side_up);
(const filestruct **)&bot, &bot_x, &right_side_up);
/* If the region is marked normally, swap the end points, so that
* (current, current_x) (where searching starts) is at the top. */
if (right_side_up) {
@@ -3030,7 +3023,7 @@ const char *do_alt_speller(char *tempfile_name)
if (old_mark_set) {
/* Trim the filestruct so that it contains only the marked text. */
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, &right_side_up);
(const filestruct **)&bot, &bot_x, &right_side_up);
filepart = partition_filestruct(top, top_x, bot, bot_x);
/* Foresay whether a magicline will be added when the
@@ -3139,8 +3132,6 @@ void do_spell(void)
unlink(temp);
free(temp);
currmenu = MMAIN;
/* If the spell-checker printed any error messages onscreen, make
* sure that they're cleared off. */
total_refresh();
@@ -3187,16 +3178,16 @@ void do_linter(void)
if (i == -1) {
statusbar(_("Cancelled"));
goto exit_from_lint;
return;
} else if (i == 1 && (do_writeout(FALSE) != TRUE))
goto exit_from_lint;
return;
}
lintcopy = mallocstrcpy(NULL, openfile->syntax->linter);
/* Create a pipe up front. */
if (pipe(lint_fd) == -1) {
statusbar(_("Could not create pipe"));
goto exit_from_lint;
return;
}
blank_bottombars();
@@ -3244,14 +3235,14 @@ void do_linter(void)
if (pid_lint < 0) {
close(lint_fd[0]);
statusbar(_("Could not fork"));
goto exit_from_lint;
return;
}
/* Get the system pipe buffer size. */
if ((pipe_buff_size = fpathconf(lint_fd[0], _PC_PIPE_BUF)) < 1) {
close(lint_fd[0]);
statusbar(_("Could not get size of pipe buffer"));
goto exit_from_lint;
return;
}
/* Read in the returned syntax errors. */
@@ -3349,7 +3340,7 @@ void do_linter(void)
if (!WIFEXITED(lint_status) || WEXITSTATUS(lint_status) > 2) {
statusbar(invocation_error(openfile->syntax->linter));
goto exit_from_lint;
return;
}
free(read_buff);
@@ -3357,7 +3348,7 @@ void do_linter(void)
if (parsesuccess == 0) {
statusline(HUSH, _("Got 0 parsable lines from command: %s"),
openfile->syntax->linter);
goto exit_from_lint;
return;
}
bottombars(MLINTER);
@@ -3421,8 +3412,9 @@ void do_linter(void)
bottombars(MLINTER);
}
/* Show the cursor to indicate the affected line. */
/* Place and show the cursor to indicate the affected line. */
reset_cursor();
wnoutrefresh(edit);
curs_set(1);
kbinput = get_kbinput(bottomwin);
@@ -3464,9 +3456,6 @@ void do_linter(void)
free(tmplint->filename);
free(tmplint);
}
exit_from_lint:
display_main_list();
}
#ifndef DISABLE_SPELLER
@@ -3606,7 +3595,7 @@ void do_wordlinechar_count(void)
* contains only the marked text, and turn the mark off. */
if (old_mark_set) {
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, NULL);
(const filestruct **)&bot, &bot_x, NULL);
filepart = partition_filestruct(top, top_x, bot, bot_x);
openfile->mark_set = FALSE;
}

View File

@@ -539,8 +539,9 @@ void new_magicline(void)
void remove_magicline(void)
{
if (openfile->filebot->data[0] == '\0' &&
openfile->filebot != openfile->fileage) {
assert(openfile->filebot != openfile->edittop && openfile->filebot != openfile->current);
openfile->filebot != openfile->fileage) {
assert(openfile->filebot != openfile->edittop &&
openfile->filebot != openfile->current);
openfile->filebot = openfile->filebot->prev;
free_filestruct(openfile->filebot->next);
@@ -560,8 +561,8 @@ void mark_order(const filestruct **top, size_t *top_x, const filestruct
assert(top != NULL && top_x != NULL && bot != NULL && bot_x != NULL);
if ((openfile->current->lineno == openfile->mark_begin->lineno &&
openfile->current_x > openfile->mark_begin_x) ||
openfile->current->lineno > openfile->mark_begin->lineno) {
openfile->current_x > openfile->mark_begin_x) ||
openfile->current->lineno > openfile->mark_begin->lineno) {
*top = openfile->mark_begin;
*top_x = openfile->mark_begin_x;
*bot = openfile->current;

View File

@@ -303,35 +303,29 @@ int *get_input(WINDOW *win, size_t input_len)
return input;
}
/* Read in a single character. If it's ignored, swallow it and go on.
* Otherwise, try to translate it from ASCII, meta key sequences, escape
* sequences, and/or extended keypad values. Supported extended keypad
* values consist of
* [arrow key], Ctrl-[arrow key], Shift-[arrow key], Enter, Backspace,
* the editing keypad (Insert, Delete, Home, End, PageUp, and PageDown),
* the function keypad (F1-F16), and the numeric keypad with NumLock
* off. */
/* Read in a single keystroke, ignoring any that are invalid. */
int get_kbinput(WINDOW *win)
{
int kbinput;
/* Read in a character and interpret it. Continue doing this until
* we get a recognized value or sequence. */
/* Extract one keystroke from the input stream. */
while ((kbinput = parse_kbinput(win)) == ERR)
;
/* If we read from the edit window, blank the statusbar if we need
* to. */
/* If we read from the edit window, blank the statusbar if needed. */
if (win == edit)
check_statusblank();
return kbinput;
}
/* Translate ASCII characters, extended keypad values, and escape
* sequences into their corresponding key values. Set meta_key to TRUE
* when we get a meta key sequence, and set func_key to TRUE when we get
* a function key. */
/* Extract a single keystroke from the input stream. Translate escape
* sequences and extended keypad codes into their corresponding values.
* Set meta_key to TRUE when we get a meta key sequence, and set func_key
* to TRUE when we get a function key. Supported extended keypad values
* are: [arrow key], Ctrl-[arrow key], Shift-[arrow key], Enter, Backspace,
* the editing keypad (Insert, Delete, Home, End, PageUp, and PageDown),
* the function keys (F1-F16), and the numeric keypad with NumLock off. */
int parse_kbinput(WINDOW *win)
{
static int escapes = 0, byte_digits = 0;
@@ -1209,21 +1203,18 @@ int get_byte_kbinput(int kbinput)
#ifdef ENABLE_UTF8
/* If the character in kbinput is a valid hexadecimal digit, multiply it
* by factor and add the result to uni. */
* by factor and add the result to uni, and return ERR to signify okay. */
long add_unicode_digit(int kbinput, long factor, long *uni)
{
long retval = ERR;
if ('0' <= kbinput && kbinput <= '9')
*uni += (kbinput - '0') * factor;
else if ('a' <= tolower(kbinput) && tolower(kbinput) <= 'f')
*uni += (tolower(kbinput) - 'a' + 10) * factor;
else
/* If this character isn't a valid hexadecimal value, save it as
* the result. */
retval = kbinput;
/* The character isn't hexadecimal; give it as the result. */
return (long)kbinput;
return retval;
return ERR;
}
/* Translate a Unicode sequence: turn a six-digit hexadecimal number
@@ -1287,12 +1278,6 @@ long get_unicode_kbinput(int kbinput)
if (retval == ERR)
retval = uni;
break;
default:
/* If there are more than six digits, return this character
* as the result. (Maybe we should produce an error
* instead?) */
retval = kbinput;
break;
}
/* If we have a result, reset the Unicode digit counter and the
@@ -2374,7 +2359,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
} else { /* Second case: varnish is a multiline expression. */
const filestruct *start_line = fileptr->prev;
/* The first line before fileptr that matches 'start'. */
regoff_t start_col;
size_t start_col;
/* Where the match starts in that line. */
const filestruct *end_line;
/* The line that matches 'end'. */
@@ -2446,9 +2431,8 @@ void edit_draw(filestruct *fileptr, const char *converted, int
/* No end found after this start. */
break;
start_col++;
if (regexec(varnish->start, start_line->data +
start_col, 1, &startmatch,
REG_NOTBOL) == REG_NOMATCH)
if (regexec(varnish->start, start_line->data + start_col,
1, &startmatch, REG_NOTBOL) == REG_NOMATCH)
/* No later start on this line. */
goto step_two;
}
@@ -2586,21 +2570,19 @@ void edit_draw(filestruct *fileptr, const char *converted, int
#endif /* !DISABLE_COLOR */
#ifndef NANO_TINY
/* If the mark is on, we need to display it. */
if (openfile->mark_set && (fileptr->lineno <=
openfile->mark_begin->lineno || fileptr->lineno <=
openfile->current->lineno) && (fileptr->lineno >=
openfile->mark_begin->lineno || fileptr->lineno >=
openfile->current->lineno)) {
/* fileptr is at least partially selected. */
const filestruct *top;
/* Either current or mark_begin, whichever is first. */
size_t top_x;
/* current_x or mark_begin_x, corresponding to top. */
const filestruct *bot;
size_t bot_x;
/* If the mark is on, and fileptr is at least partially selected, we
* need to paint it. */
if (openfile->mark_set &&
(fileptr->lineno <= openfile->mark_begin->lineno ||
fileptr->lineno <= openfile->current->lineno) &&
(fileptr->lineno >= openfile->mark_begin->lineno ||
fileptr->lineno >= openfile->current->lineno)) {
const filestruct *top, *bot;
/* The lines where the marked region begins and ends. */
size_t top_x, bot_x;
/* The x positions where the marked region begins and ends. */
int x_start;
/* Starting column for mvwaddnstr(). Zero-based. */
/* The starting column for mvwaddnstr(). Zero-based. */
int paintlen;
/* Number of characters to paint on this line. There are
* COLS characters on a whole line. */
@@ -2614,7 +2596,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
if (bot->lineno > fileptr->lineno || bot_x > endpos)
bot_x = endpos;
/* The selected bit of fileptr is on this page. */
/* Only paint if the marked bit of fileptr is on this page. */
if (top_x < endpos && bot_x > startpos) {
assert(startpos <= top_x);
@@ -2630,8 +2612,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
if (bot_x >= endpos)
paintlen = -1;
else
paintlen = strnlenpt(fileptr->data, bot_x) - (x_start +
start);
paintlen = strnlenpt(fileptr->data, bot_x) - (x_start + start);
/* If x_start is before the beginning of the page, shift
* paintlen x_start characters to compensate, and put
@@ -2649,8 +2630,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
paintlen = actual_x(converted + index, paintlen);
wattron(edit, hilite_attribute);
mvwaddnstr(edit, line, x_start, converted + index,
paintlen);
mvwaddnstr(edit, line, x_start, converted + index, paintlen);
wattroff(edit, hilite_attribute);
}
}
@@ -3228,7 +3208,7 @@ void do_credits(void)
"",
"",
"",
"http://www.nano-editor.org/"
"https://nano-editor.org/"
};
const char *xlcredits[XLCREDIT_LEN] = {