Compare commits

...

54 Commits

Author SHA1 Message Date
Benno Schulenberg
f85648db68 po: update translations and regenerate POT file and PO files 2016-08-10 12:14:26 +02:00
Benno Schulenberg
b2e2c89b62 bump version numbers and add a news item for 2.6.3 2016-08-10 11:48:32 +02:00
Benno Schulenberg
290d278f68 input: make the Ctrl+Arrow keys work on a Linux console
If this breaks your build, please send report or instructions or patch.
2016-08-07 18:20:34 +02:00
Benno Schulenberg
8edb096821 input: after an Esc, don't discard starter byte of a multibyte sequence
This fixes https://savannah.gnu.org/bugs/?48711.
2016-08-07 17:40:38 +02:00
Benno Schulenberg
0a387d9d08 usage: show that the option --wordchars needs an argument 2016-08-07 17:04:23 +02:00
Benno Schulenberg
6c16744292 files: avoid a warning about not being able to write a lockfile
Instead be more specific and say that the directory is not writable.
2016-08-07 13:00:35 +02:00
Benno Schulenberg
86a64b1bb5 tweaks: reduce two comparisons to a single one 2016-08-07 13:00:21 +02:00
Rishabh Dave
1fd2354ad4 shortcuts: zero the value of 'toggle' for keys that are not toggles
This fixes http://savannah.gnu.org/bugs/?48698.

Signed-off-by: Rishabh Dave <rishabhddave@gmail.com>
2016-08-07 11:31:55 +02:00
Benno Schulenberg
c8bc05b10e chars: make searching case-insensitively some ten percent faster
It is quicker to do a handful of superfluous compares at the end of
each line than it is to compute and keep track of and compare the
remaining line length the whole time.

The typical line is some sixty characters long, the typical search
string ten characters -- with a shorter search string the speedup is
even higher: some fifteen percent.  Only when the string is longer
than half the average line length does searching become slower with
this new method.

All this for a UTF-8 locale.  For a C locale it makes no difference.
2016-08-07 11:02:41 +02:00
Benno Schulenberg
ee57cbfa66 debug: add a timing instrument to the main search routine 2016-08-07 10:14:42 +02:00
Benno Schulenberg
bd1fcc5fe2 tweaks: correct one comment, and adjust another 2016-08-06 12:17:24 +02:00
Benno Schulenberg
370406bb41 tweaks: don't optimize for a special case -- it is far too seldom 2016-08-06 11:11:56 +02:00
Benno Schulenberg
85844ee6ef chars: remove superfluous afterchecks
Now that mbstrncasecmp() does the right thing, there is no need any
more to verify that only a valid multibyte sequence was matched.

(See https://savannah.gnu.org/bugs/?45579 for a test case.)

Also, this will make it possible to search for invalid sequences.

(Currently it isn't possible to enter a search string with invalid
characters, but... a user might edit the search history file.  And
if pasting at the prompt is implemented, it will be trivial to enter
invalid sequences if you have a file that contains them.)
2016-08-06 11:10:39 +02:00
Benno Schulenberg
e38e2c634b chars: don't persist when only one of the compared sequences is invalid
Persisting might lead to count 'n' reaching zero, which would mean that
the needle has matched, which is wrong when one of the strings contains
an invalid or incomplete multibyte sequence.
2016-08-06 10:34:38 +02:00
Benno Schulenberg
d80109dd5e chars: properly compare strings of different lengths
That is: don't run towlower() on the two differing bytes when having
reached the end of one of the strings.

This fixes https://savannah.gnu.org/bugs/?48700.

In the bargain, don't do the conversion to lowercase twice.

Furthermore, persist when encountering invalid byte sequences --
until finding bytes that differ.
2016-08-05 16:07:55 +02:00
Benno Schulenberg
b305911cba chars: straighten out the flow of a loop, so it is easier to follow 2016-08-04 13:40:55 +02:00
Benno Schulenberg
d60f95137e chars: remove a special case that never occurs
The needle is never part of the hay -- it is always a separate string.

(And even if needle and haystack were identical, the routine works fine,
the case does not need special treatment.)
2016-08-04 13:40:19 +02:00
Benno Schulenberg
14ac47517b spelling: don't abort when a misspelled word isn't found, just note it
This fixes https://savannah.gnu.org/bugs/?48660 doubly, in case there
are other ways in which 'spell' sees words differently from 'nano'.
2016-08-03 12:55:21 +02:00
Benno Schulenberg
20058a1b63 spelling: don't consider digits as word parts, because GNU spell doesn't
This fixes https://savannah.gnu.org/bugs/?48660.
2016-08-03 12:43:57 +02:00
Benno Schulenberg
f6dd0ad18a tweaks: compile a parameter unconditionally
Straightforward code is more important than the tiniest possible binary.

Also adjust some comments and rename a variable.
2016-08-02 17:30:58 +02:00
Benno Schulenberg
a7ae1766c0 locking: remove any lock files when dying
This fixes https://savannah.gnu.org/bugs/?48675.
2016-08-02 17:30:40 +02:00
Benno Schulenberg
faa46a3c71 screen: remove redundant redrawings of the entire edit window
(It may have been necessary in the past; there is no need for it now.)

This fixes https://savannah.gnu.org/bugs/?48633.
2016-08-01 19:41:13 +02:00
Benno Schulenberg
03b168d0e3 tweaks: restore earlier conditions to prevent superfluous redrawings
When doing an <Up> on the top line, or a <Down> on the bottom line of
the edit window, the affected lines have already been redrawn by the
scrolling code, so there is no need to do that again.

(However, that does not prevent the second line (or the last-but-one
line) from being redrawn unnecessarily when using the M-- (or M-+)
command elsewhere on the screen and /that/ line is horizontally
scrolled.  But we'll let that pass for now.)
2016-08-01 19:41:13 +02:00
Benno Schulenberg
2f6647687a tweaks: rename a function, and adjust some comments 2016-08-01 19:41:13 +02:00
Benno Schulenberg
c9e9964207 screen: don't look at placewewant but at where we actually were and are
For horizontal scrolling, it is not the /desired/ column position that
is relevant for determining whether a line needs to be redrawn after a
cursor movement, but the /actual/ column positions before and after.

This fixes https://savannah.gnu.org/bugs/?48627,
and fixes https://savannah.gnu.org/bugs/?48629.
2016-08-01 19:41:13 +02:00
Benno Schulenberg
0a3a6441bc tweaks: unconditionally compile a couple of parameters
Having two unneeded parameters in the tiny version is acceptable --
the code gets so much more readable.
2016-08-01 19:41:13 +02:00
Benno Schulenberg
2eafe7bf58 files: make allowances for 32-bit PIDs
This addresses https://bugs.debian.org/831636 reported by Christoph Biedl.
2016-08-01 16:24:05 +02:00
Benno Schulenberg
08c51cfd45 input: ingest as verbatim just one control code or one or two escapes
Leave the rest of any escape sequence to be processed normally, which
should be possible because those characters are all in ASCII range.

This fixes https://savannah.gnu.org/bugs/?48318.
2016-08-01 14:47:02 +02:00
Benno Schulenberg
b472f5a633 tweaks: remove some unnecessary keycodes from a switch statement
These codes are the basic codes that get assigned for the movement keys
in the list of shortcuts -- they don't need any translation.
2016-08-01 14:07:21 +02:00
Benno Schulenberg
5806bf5249 tweaks: normalize some whitespace and adjust several comments 2016-08-01 14:05:42 +02:00
Benno Schulenberg
90a90365a8 tweaks: rename three constants, for clarity, and hardcode two others 2016-08-01 12:56:05 +02:00
Benno Schulenberg
9cd30d4917 tweaks: don't bother setting meta_key to false when a key is invalid
That is a task for the key-getting routine.
2016-07-31 18:32:18 +02:00
Benno Schulenberg
f33d8cae30 tweaks: don't use a function call when reference to the variable will do 2016-07-31 18:30:53 +02:00
Benno Schulenberg
e471e2d462 tweaks: move the modified editing keys again 2016-07-31 18:29:57 +02:00
Benno Schulenberg
fe38b78486 tweaks: adjust indentation after the previous changes 2016-07-31 18:22:07 +02:00
Benno Schulenberg
1af1f5c9f4 tweaks: return quicker from the key parsing routine 2016-07-31 18:19:17 +02:00
Benno Schulenberg
b9e83fe9f8 tweaks: move some debugging stuff, and move modified editing keys too
Again, just for preapring an easier return from the parsing routine.
2016-07-31 18:17:06 +02:00
Benno Schulenberg
cb10b2b908 tweaks: elide the global variable 'func_key'
There is no need to specially flag a function key or editing key --
the keycode is indication enough in itself: outside of byte range.
2016-07-31 18:13:05 +02:00
Benno Schulenberg
19dfd20a88 tweaks: add a variable, in preparation for making returning easier 2016-07-31 18:10:31 +02:00
Benno Schulenberg
d12fdda15b tweaks: replace a three-case switch with an if and an else 2016-07-31 18:10:01 +02:00
Benno Schulenberg
3930a697e8 tweaks: consistently use a parameter instead of a struct element 2016-07-30 13:05:52 +02:00
Benno Schulenberg
9322e1e6a4 tweaks: reshuffle two ifs for a little more speed
Saving roughly twenty microseconds at startup.
2016-07-30 13:04:06 +02:00
Benno Schulenberg
b70fe38eab tweaks: normalize some indentation 2016-07-30 12:24:35 +02:00
Benno Schulenberg
1c528db8da tweaks: condense three asserts into a single one
Also, when a key string does not denote a Ctrl nor Meta nor Function key,
there is no point in assigning a keycode, because plain characters cannot
be used as a function shortcut.
2016-07-30 12:24:35 +02:00
Benno Schulenberg
1c9ab8bf16 tweaks: rename a struct element, to be more fitting
The keycode is not a sequence; it is a single integer value.
2016-07-30 12:24:35 +02:00
Benno Schulenberg
e295070193 shortcuts: group the setting of key string and keycode into one function
And instead of using two key types, just use a bool to indicate whether
a keystroke involves Meta.
2016-07-30 12:21:42 +02:00
Benno Schulenberg
91951ab22a input: don't bother putting a keycode into byte range
A keycode is either already in byte range (so there is nothing to do)
or it is not and it shouldn't be (so there is nothing to do either).
2016-07-30 12:19:47 +02:00
Benno Schulenberg
5b0ab8be62 shortcuts: remove any unnecessary classifying of keys
After initialization, the type of a key is never used nor needed
(other than for meta keys).
2016-07-30 12:13:47 +02:00
Benno Schulenberg
ecef093def tweaks: adjust indentation after previous changes 2016-07-29 09:33:28 +02:00
Benno Schulenberg
6d6f5bd4a7 tweaks: check earlier on for sufficient length of the sequence 2016-07-29 09:33:28 +02:00
Benno Schulenberg
e3dbffc9f7 input: be more strict in recognizing certain escape sequences
Accept the "Esc [ 1 n ~" and "Esc [ 2 n ~" sequences only when they
end with the "~" character, not with any character.
2016-07-29 09:33:28 +02:00
Benno Schulenberg
2225d54126 input: don't use a function call when a literal value will do 2016-07-29 09:33:28 +02:00
Benno Schulenberg
9115828e76 input: fix a pasto from eight years ago, from commit e347efb 2016-07-29 09:33:16 +02:00
Benno Schulenberg
b43a72471a docs: tweak some spacing and spelling 2016-07-29 09:05:40 +02:00
55 changed files with 16259 additions and 16032 deletions

View File

@@ -2,6 +2,7 @@ Improvements in nano
====================
Since 2.6.0:
- Ctrl+Arrow should now work also on a Linux virtual console.
- Ctrl+Up and Ctrl+Down jump to previous or next block of text.
- Feedback during Unicode Input (M-V followed by six digits).
- The option 'wordchars' for specifying extra word characters.

27
NEWS
View File

@@ -1,3 +1,12 @@
2016.08.10 - nano 2.6.3 "Marika" makes the Ctrl+Arrow keys work also on
a Linux virtual console, takes as verbatim only the very
first keystroke after M-V, removes any lock files that it
holds when dying, doesn't abort when a word contains digits
(when using the default speller), fixes a small sorting bug
in the file browser, makes searching case-insensitively in
a UTF-8 locale a little faster, and doesn't enter invalid
bytes when holding down both Alt keys. Santé!
2016.07.28 - nano 2.6.2 "Le vent nous portera" adds two new features: the
keystrokes Ctrl+Up and Ctrl+Down for jumping between blocks
of text, and the option 'wordchars' for specifying which
@@ -35,7 +44,7 @@
2016.02.25 - GNU nano 2.5.3 "Alphys" is released. This release
contains fixes for bugs like: stray cursor positioning
errors, many many memory leaks including file reading,
using the file browser, searching for multi-byte characters,
using the file browser, searching for multibyte characters,
history completion, and many other places.
New features include the ability to trim whitespace
from the ends of lines when justifying text, see nanorc(5)
@@ -161,7 +170,7 @@
2014.06.02 - GNU nano 2.3.4 won't leave you high, won't leave you dry. This
release contains only a small number of fixes, but in
particular allows nano to compile on non-UTF8 curses
particular allows nano to compile on non-UTF-8 curses
implementations (i.e. libncursesw). Other small fixes to
the undo implementation and the default syntax config are
also included. As always, Share and Enjoy!
@@ -197,7 +206,7 @@
release includes some fixes for the new libmagic code, as
well as a fix for improper character counts when using
auto-indent. Also included are new syntax highlighting
definitions for RPM spec and lua files. Thanks for
definitions for RPM spec and Lua files. Thanks for
using nano and keep circulating the tapes.
2011.02.26 - GNU nano 2.3.0 "Septic surprise" is released. This first
@@ -477,7 +486,7 @@
thanks for sticking with us!
2007.12.20- GNU nano 2.0.7 keeps its balance. This release fixes
2007.12.20 - GNU nano 2.0.7 keeps its balance. This release fixes
several bugs, among others: a segfault and several
cursor positioning problems when uncutting text or
inserting files into the current buffer; a problem where
@@ -499,12 +508,12 @@
under the GNU GPL version 3 or later and the GNU FDL
version 1.2 or later. Have fun.
2007.04.26- GNU nano 2.0.6 "that was quick" is released. This release
2007.04.26 - GNU nano 2.0.6 "that was quick" is released. This release
fixes a potential segfault after justifying text marked
from the bottom up. It also adds one more minor
documentation update. Enjoy.
2007.04.22- GNU nano 2.0.5 braces for impact. Among other things, this
2007.04.22 - GNU nano 2.0.5 braces for impact. Among other things, this
release fixes various problems (including a segfault)
when trying to open or save a file in a directory
beginning with "~" that isn't a home directory; fixes a
@@ -612,7 +621,7 @@
properly at all times; lines of text containing tabs are
now wrapped at the right place; double-column characters
are now properly displayed when past the right edge of
the screen; invalid multi-line color regexes are now
the screen; invalid multiline color regexes are now
ignored; and so on. Enjoy.
2006.03.30 - GNU nano 1.3.11 awakens from its fever dream. This release
@@ -950,7 +959,7 @@
0.11.2 of gettext, building with automake 1.6, some new
code for displaying control characters, browser
improvements, a new backup file option (-B, --backup), a
new option to ignore rc files (-I,--ignorercfiles),
new option to ignore rc files (-I, --ignorercfiles),
compatibility with -pedantic, handling null characters
before EOF, a slightly sportier nanorc.sample and more.
Fixes are included for justification,
@@ -1179,7 +1188,7 @@
nasty segfault when trying to insert one's home
directory (~), some checks for the NumLock key making
the keypad go awry, window size sanity checks, many
autoconf fixes, and support for the KDE konsole keypad
autoconf fixes, and support for the KDE Konsole keypad
layout. Have fun.
2001.01.07 - Nano 0.9.25 is the "Just one more feature I swear!"

View File

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

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.2" "July 2016"
.TH NANO 1 "version 2.6.3" "August 2016"
.\" Please adjust this date whenever revising the manpage.
.\"

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.2" "July 2016"
.TH NANORC 5 "version 2.6.3" "August 2016"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH NAME

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.2" "July 2016"
.TH RNANO 1 "version 2.6.3" "August 2016"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH NAME

View File

@@ -6,8 +6,8 @@
@smallbook
@set EDITION 0.4
@set VERSION 2.6.2
@set UPDATED July 2016
@set VERSION 2.6.3
@set UPDATED August 2016
@dircategory Editors
@direntry
@@ -21,7 +21,7 @@
@titlepage
@title @code{nano}
@subtitle a small and friendly text editor.
@subtitle version 2.6.2
@subtitle version 2.6.3
@author Chris Allegretta
@page

874
po/bg.po

File diff suppressed because it is too large Load Diff

903
po/ca.po

File diff suppressed because it is too large Load Diff

1042
po/cs.po

File diff suppressed because it is too large Load Diff

876
po/da.po

File diff suppressed because it is too large Load Diff

905
po/de.po

File diff suppressed because it is too large Load Diff

903
po/eo.po

File diff suppressed because it is too large Load Diff

876
po/es.po

File diff suppressed because it is too large Load Diff

874
po/eu.po

File diff suppressed because it is too large Load Diff

876
po/fi.po

File diff suppressed because it is too large Load Diff

916
po/fr.po

File diff suppressed because it is too large Load Diff

874
po/ga.po

File diff suppressed because it is too large Load Diff

1118
po/gl.po

File diff suppressed because it is too large Load Diff

907
po/hr.po

File diff suppressed because it is too large Load Diff

876
po/hu.po

File diff suppressed because it is too large Load Diff

872
po/id.po

File diff suppressed because it is too large Load Diff

876
po/it.po

File diff suppressed because it is too large Load Diff

874
po/ja.po

File diff suppressed because it is too large Load Diff

876
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

903
po/nb.po

File diff suppressed because it is too large Load Diff

906
po/nl.po

File diff suppressed because it is too large Load Diff

872
po/nn.po

File diff suppressed because it is too large Load Diff

1095
po/pl.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1048
po/ro.po

File diff suppressed because it is too large Load Diff

874
po/ru.po

File diff suppressed because it is too large Load Diff

874
po/sl.po

File diff suppressed because it is too large Load Diff

876
po/sr.po

File diff suppressed because it is too large Load Diff

903
po/sv.po

File diff suppressed because it is too large Load Diff

872
po/tr.po

File diff suppressed because it is too large Load Diff

903
po/uk.po

File diff suppressed because it is too large Load Diff

903
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

@@ -149,7 +149,7 @@ char *do_browser(char *path)
/* If we selected the same filename as last time, fake a
* press of the Enter key so that the file is read in. */
if (old_selected == selected)
unget_kbinput(sc_seq_or(do_enter, 0), FALSE, FALSE);
unget_kbinput(sc_seq_or(do_enter, 0), FALSE);
}
continue;

View File

@@ -93,6 +93,26 @@ void wctomb_reset(void)
IGNORE_CALL_RESULT(wctomb(NULL, 0));
}
/* This function is equivalent to isalpha() for multibyte characters. */
bool is_alpha_mbchar(const char *c)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
mbtowc_reset();
return 0;
}
return iswalpha(wc);
} else
#endif
return isalpha((unsigned char)*c);
}
/* This function is equivalent to isalnum() for multibyte characters. */
bool is_alnum_mbchar(const char *c)
{
@@ -219,7 +239,7 @@ char control_rep(const signed char c)
/* An embedded newline is an encoded null. */
if (c == '\n')
return '@';
else if (c == NANO_CONTROL_8)
else if (c == DEL_CODE)
return '?';
else if (c == -97)
return '=';
@@ -236,7 +256,7 @@ char control_mbrep(const char *c)
#ifdef ENABLE_UTF8
if (use_utf8) {
if (0 <= c[0] && c[0] <= 127)
if ((unsigned char)c[0] < 128)
return control_rep(c[0]);
else
return control_rep(c[1]);
@@ -490,32 +510,40 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
if (use_utf8) {
wchar_t wc1, wc2;
if (s1 == s2)
return 0;
assert(s1 != NULL && s2 != NULL);
for (; *s1 != '\0' && *s2 != '\0' && n > 0;
s1 += move_mbright(s1, 0), s2 += move_mbright(s2, 0), n--) {
while (*s1 != '\0' && *s2 != '\0' && n > 0) {
bool bad1 = FALSE, bad2 = FALSE;
if (mbtowc(&wc1, s1, MB_CUR_MAX) < 0) {
mbtowc_reset();
wc1 = (unsigned char)*s1;
bad1 = TRUE;
}
if (mbtowc(&wc2, s2, MB_CUR_MAX) < 0) {
mbtowc_reset();
wc2 = (unsigned char)*s2;
bad2 = TRUE;
}
if (bad1 != bad2 || towlower(wc1) != towlower(wc2))
break;
if (bad1 || bad2) {
if (*s1 != *s2)
return (unsigned char)*s1 - (unsigned char)*s2;
if (bad1 != bad2)
return (bad1 ? 1 : -1);
} else {
int difference = towlower(wc1) - towlower(wc2);
if (difference != 0)
return difference;
}
s1 += move_mbright(s1, 0);
s2 += move_mbright(s2, 0);
n--;
}
return (n > 0) ? towlower(wc1) - towlower(wc2) : 0;
return (n > 0) ? ((unsigned char)*s1 - (unsigned char)*s2) : 0;
} else
#endif
return strncasecmp(s1, s2, n);
@@ -525,20 +553,20 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
/* This function is equivalent to strcasestr(). */
char *nstrcasestr(const char *haystack, const char *needle)
{
size_t haystack_len, needle_len;
size_t needle_len;
assert(haystack != NULL && needle != NULL);
if (*needle == '\0')
return (char *)haystack;
haystack_len = strlen(haystack);
needle_len = strlen(needle);
for (; *haystack != '\0' && haystack_len >= needle_len; haystack++,
haystack_len--) {
while (*haystack != '\0') {
if (strncasecmp(haystack, needle, needle_len) == 0)
return (char *)haystack;
haystack++;
}
return NULL;
@@ -550,21 +578,20 @@ char *mbstrcasestr(const char *haystack, const char *needle)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
size_t haystack_len, needle_len;
size_t needle_len;
assert(haystack != NULL && needle != NULL);
if (*needle == '\0')
return (char *)haystack;
haystack_len = mbstrlen(haystack);
needle_len = mbstrlen(needle);
for (; *haystack != '\0' && haystack_len >= needle_len;
haystack += move_mbright(haystack, 0), haystack_len--) {
if (mbstrncasecmp(haystack, needle, needle_len) == 0 &&
mblen(haystack, MB_CUR_MAX) > 0)
while (*haystack != '\0') {
if (mbstrncasecmp(haystack, needle, needle_len) == 0)
return (char *)haystack;
haystack += move_mbright(haystack, 0);
}
return NULL;
@@ -655,8 +682,7 @@ char *mbrevstrcasestr(const char *haystack, const char *needle, const
while (TRUE) {
if (rev_start_len >= needle_len &&
mbstrncasecmp(rev_start, needle, needle_len) == 0 &&
mblen(rev_start, MB_CUR_MAX) > 0)
mbstrncasecmp(rev_start, needle, needle_len) == 0)
return (char *)rev_start;
/* If we've reached the head of the haystack, we found nothing. */

View File

@@ -51,6 +51,8 @@ bool has_valid_path(const char *filename)
statusline(ALERT, _("Path '%s' is not a directory"), parentdir);
else if (access(parentdir, X_OK) == -1)
statusline(ALERT, _("Path '%s' is not accessible"), parentdir);
else if (ISSET(LOCKING) && access(parentdir, W_OK) == -1)
statusline(MILD, _("Directory '%s' is not writable"), parentdir);
else
validity = TRUE;
@@ -232,8 +234,7 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
* byte 0 - 0x62
* byte 1 - 0x30
* bytes 2-12 - program name which created the lock
* bytes 24,25 - little endian store of creator program's PID
* (b24 = 256^0 column, b25 = 256^1 column)
* bytes 24-27 - PID (little endian) of creator process
* bytes 28-44 - username of who created the lock
* bytes 68-100 - hostname of where the lock was created
* bytes 108-876 - filename the lock is for
@@ -248,7 +249,9 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
lockdata[0] = 0x62;
lockdata[1] = 0x30;
lockdata[24] = mypid % 256;
lockdata[25] = mypid / 256;
lockdata[25] = (mypid / 256) % 256;
lockdata[26] = (mypid / (256 * 256)) % 256;
lockdata[27] = mypid / (256 * 256 * 256);
snprintf(&lockdata[2], 11, "nano %s", VERSION);
strncpy(&lockdata[28], mypwuid->pw_name, 16);
strncpy(&lockdata[68], myhostname, 31);
@@ -318,7 +321,7 @@ int do_lockfile(const char *filename)
if (stat(lockfilename, &fileinfo) != -1) {
ssize_t readtot = 0;
ssize_t readamt = 0;
char *lockbuf, *question, *postedname, *promptstr;
char *lockbuf, *question, *pidstring, *postedname, *promptstr;
int room, response;
if ((lockfd = open(lockfilename, O_RDONLY)) < 0) {
@@ -341,18 +344,23 @@ int do_lockfile(const char *filename)
}
strncpy(lockprog, &lockbuf[2], 10);
lockpid = (unsigned char)lockbuf[25] * 256 + (unsigned char)lockbuf[24];
lockpid = (((unsigned char)lockbuf[27] * 256 + (unsigned char)lockbuf[26]) * 256 +
(unsigned char)lockbuf[25]) * 256 + (unsigned char)lockbuf[24];
strncpy(lockuser, &lockbuf[28], 16);
free(lockbuf);
pidstring = charalloc(11);
sprintf (pidstring, "%u", (unsigned int)lockpid);
#ifdef DEBUG
fprintf(stderr, "lockpid = %d\n", lockpid);
fprintf(stderr, "program name which created this lock file should be %s\n", lockprog);
fprintf(stderr, "user which created this lock file should be %s\n", lockuser);
#endif
/* TRANSLATORS: The second %s is the name of the user, the third that of the editor. */
question = _("File %s is being edited (by %s with %s, PID %d); continue?");
room = COLS - strlenpt(question) - strlenpt(lockuser) - strlenpt(lockprog) + 3;
question = _("File %s is being edited (by %s with %s, PID %s); continue?");
room = COLS - strlenpt(question) + 7 - strlenpt(lockuser) -
strlenpt(lockprog) - strlenpt(pidstring);
if (room < 4)
postedname = mallocstrcpy(NULL, "_");
else if (room < strlenpt(filename)) {
@@ -365,11 +373,12 @@ int do_lockfile(const char *filename)
} else
postedname = mallocstrcpy(NULL, filename);
/* Allow extra space for username (14), program name (8), PID (3),
/* Allow extra space for username (14), program name (8), PID (8),
* and terminating \0 (1), minus the %s (2) for the file name. */
promptstr = charalloc(strlen(question) + 24 + strlen(postedname));
sprintf(promptstr, question, postedname, lockuser, lockprog, lockpid);
promptstr = charalloc(strlen(question) + 29 + strlen(postedname));
sprintf(promptstr, question, postedname, lockuser, lockprog, pidstring);
free(postedname);
free(pidstring);
response = do_yesno_prompt(FALSE, promptstr);
free(promptstr);

View File

@@ -33,10 +33,10 @@ volatile sig_atomic_t sigwinch_counter = 0;
/* Is incremented by the handler whenever a SIGWINCH occurs. */
#endif
bool console;
/* Whether we're running on a Linux VC (TRUE) or under X (FALSE). */
bool meta_key;
/* Whether the current keystroke is a Meta key. */
bool func_key;
/* Whether the current keystroke is an extended keypad value. */
bool focusing = TRUE;
/* Whether an update of the edit window should center the cursor. */
@@ -339,12 +339,10 @@ void add_to_sclist(int menus, const char *scstring, void (*func)(void), int togg
s->toggle = toggle;
if (toggle)
s->ordinal = ++counter;
s->keystr = (char *) scstring;
s->type = strtokeytype(scstring);
assign_keyinfo(s);
assign_keyinfo(s, scstring);
#ifdef DEBUG
fprintf(stderr, "Setting sequence to %d for shortcut \"%s\" in menus %x\n", s->seq, scstring, s->menus);
fprintf(stderr, "Setting keycode to %d for shortcut \"%s\" in menus %x\n", s->keycode, scstring, s->menus);
#endif
}
@@ -382,8 +380,8 @@ int sc_seq_or(void (*func)(void), int defaultval)
const sc *s = first_sc_for(currmenu, func);
if (s) {
meta_key = (s->type == META);
return s->seq;
meta_key = s->meta;
return s->keycode;
}
/* else */
return defaultval;
@@ -400,71 +398,54 @@ functionptrtype func_from_key(int *kbinput)
return NULL;
}
/* Return the type of command key based on the given string. */
key_type strtokeytype(const char *str)
/* Set the string and its corresponding keycode for the given shortcut s. */
void assign_keyinfo(sc *s, const char *keystring)
{
if (str[0] == '^')
return CONTROL;
else if (str[0] == 'M')
return META;
else if (str[0] == 'F')
return FKEY;
else
return RAWINPUT;
}
s->keystr = keystring;
s->meta = (keystring[0] == 'M');
/* Assign the info to the shortcut struct.
* Assumes keystr is already assigned, naturally. */
void assign_keyinfo(sc *s)
{
if (s->type == CONTROL) {
assert(strlen(s->keystr) > 1);
s->seq = s->keystr[1] - 64;
} else if (s->type == META) {
assert(strlen(s->keystr) > 2);
s->seq = tolower((int) s->keystr[2]);
} else if (s->type == FKEY) {
assert(strlen(s->keystr) > 1);
s->seq = KEY_F0 + atoi(&s->keystr[1]);
} else /* RAWINPUT */
s->seq = (int) s->keystr[0];
assert(strlen(keystring) > 1 && (!s->meta || strlen(keystring) > 2));
/* Override some keys which don't bind as easily as we'd like. */
if (s->type == CONTROL && (!strcasecmp(&s->keystr[1], "space")))
s->seq = 0;
else if (s->type == META && (!strcasecmp(&s->keystr[2], "space")))
s->seq = (int) ' ';
else if (s->type == RAWINPUT) {
if (!strcasecmp(s->keystr, "Up"))
s->seq = KEY_UP;
else if (!strcasecmp(s->keystr, "Down"))
s->seq = KEY_DOWN;
else if (!strcasecmp(s->keystr, "Left"))
s->seq = KEY_LEFT;
else if (!strcasecmp(s->keystr, "Right"))
s->seq = KEY_RIGHT;
else if (!strcasecmp(s->keystr, "Ins"))
s->seq = KEY_IC;
else if (!strcasecmp(s->keystr, "Del"))
s->seq = KEY_DC;
else if (!strcasecmp(s->keystr, "Bsp"))
s->seq = KEY_BACKSPACE;
/* The Tab and Enter keys don't actually produce special codes
* but the exact integer values of ^I and ^M. Rebinding the
* latter therefore also rebinds Tab and Enter. */
else if (!strcasecmp(s->keystr, "Tab"))
s->seq = NANO_CONTROL_I;
else if (!strcasecmp(s->keystr, "Enter"))
s->seq = KEY_ENTER;
else if (!strcasecmp(s->keystr, "PgUp"))
s->seq = KEY_PPAGE;
else if (!strcasecmp(s->keystr, "PgDn"))
s->seq = KEY_NPAGE;
else if (!strcasecmp(s->keystr, "Home"))
s->seq = KEY_HOME;
else if (!strcasecmp(s->keystr, "End"))
s->seq = KEY_END;
}
if (keystring[0] == '^') {
s->keycode = keystring[1] - 64;
if (strcasecmp(keystring, "^Space") == 0)
s->keycode = 0;
} else if (s->meta) {
s->keycode = tolower((int)keystring[2]);
if (strcasecmp(keystring, "M-Space") == 0)
s->keycode = (int)' ';
} else if (keystring[0] == 'F')
s->keycode = KEY_F0 + atoi(&keystring[1]);
/* Catch the strings that don't bind as easily as we'd like. */
else if (!strcasecmp(keystring, "Up"))
s->keycode = KEY_UP;
else if (!strcasecmp(keystring, "Down"))
s->keycode = KEY_DOWN;
else if (!strcasecmp(keystring, "Left"))
s->keycode = KEY_LEFT;
else if (!strcasecmp(keystring, "Right"))
s->keycode = KEY_RIGHT;
else if (!strcasecmp(keystring, "Ins"))
s->keycode = KEY_IC;
else if (!strcasecmp(keystring, "Del"))
s->keycode = KEY_DC;
else if (!strcasecmp(keystring, "Bsp"))
s->keycode = KEY_BACKSPACE;
/* The Tab and Enter keys don't actually produce special codes
* but the exact integer values of ^I and ^M. Rebinding the
* latter therefore also rebinds Tab and Enter. */
else if (!strcasecmp(keystring, "Tab"))
s->keycode = TAB_CODE;
else if (!strcasecmp(keystring, "Enter"))
s->keycode = KEY_ENTER;
else if (!strcasecmp(keystring, "PgUp"))
s->keycode = KEY_PPAGE;
else if (!strcasecmp(keystring, "PgDn"))
s->keycode = KEY_NPAGE;
else if (!strcasecmp(keystring, "Home"))
s->keycode = KEY_HOME;
else if (!strcasecmp(keystring, "End"))
s->keycode = KEY_END;
}
#ifdef DEBUG
@@ -1380,6 +1361,7 @@ sc *strtosc(const char *input)
sc *s;
s = (sc *)nmalloc(sizeof(sc));
s->toggle = 0;
#ifndef DISABLE_HELP
if (!strcasecmp(input, "help"))

View File

@@ -368,7 +368,7 @@ void do_next_word_void(void)
* if we are. */
void do_home(void)
{
size_t pww_save = openfile->placewewant;
size_t was_column = xplustabs();
#ifndef NANO_TINY
if (ISSET(SMART_HOME)) {
@@ -385,32 +385,28 @@ void do_home(void)
openfile->placewewant = xplustabs();
if (need_screen_update(pww_save))
if (need_horizontal_scroll(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x);
}
/* Move to the end of the current line. */
void do_end(void)
{
size_t pww_save = openfile->placewewant;
size_t was_column = xplustabs();
openfile->current_x = strlen(openfile->current->data);
openfile->placewewant = xplustabs();
if (need_screen_update(pww_save))
if (need_horizontal_scroll(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x);
}
/* If scroll_only is FALSE, move up one line. If scroll_only is TRUE,
* scroll up one line without scrolling the cursor. */
void do_up(
#ifndef NANO_TINY
bool scroll_only
#else
void
#endif
)
void do_up(bool scroll_only)
{
size_t was_column = xplustabs();
/* If we're at the top of the file, or if scroll_only is TRUE and
* the top of the file is onscreen, get out. */
if (openfile->current == openfile->fileage
@@ -443,47 +439,32 @@ void do_up(
#endif
editwinrows / 2 + 1);
/* If we're not on the first line of the edit window, and the target
* column is beyond the screen or the mark is on, redraw the prior
* and current lines. */
if (openfile->current_y > 0 && need_screen_update(0)) {
update_line(openfile->current->next, 0);
update_line(openfile->current, openfile->current_x);
/* If the lines weren't already redrawn, see if they need to be. */
if (openfile->current_y > 0) {
/* Redraw the prior line if it was horizontally scrolled. */
if (need_horizontal_scroll(was_column, 0))
update_line(openfile->current->next, 0);
/* Redraw the current line if it needs to be horizontally scrolled. */
if (need_horizontal_scroll(0, xplustabs()))
update_line(openfile->current, openfile->current_x);
}
}
/* Move up one line. */
void do_up_void(void)
{
do_up(
#ifndef NANO_TINY
FALSE
#endif
);
do_up(FALSE);
}
#ifndef NANO_TINY
/* Scroll up one line without scrolling the cursor. */
void do_scroll_up(void)
{
do_up(TRUE);
}
#endif
/* If scroll_only is FALSE, move down one line. If scroll_only is TRUE,
* scroll down one line without scrolling the cursor. */
void do_down(
#ifndef NANO_TINY
bool scroll_only
#else
void
#endif
)
void do_down(bool scroll_only)
{
#ifndef NANO_TINY
int amount = 0, enough;
filestruct *topline;
#endif
size_t was_column = xplustabs();
/* If we're at the bottom of the file, get out. */
if (openfile->current == openfile->filebot)
@@ -543,26 +524,30 @@ void do_down(
}
}
/* If we're not on the last line of the edit window, and the target
* column is beyond the screen or the mark is on, redraw the prior
* and current lines. */
if (openfile->current_y < editwinrows - 1 && need_screen_update(0)) {
update_line(openfile->current->prev, 0);
update_line(openfile->current, openfile->current_x);
/* If the lines weren't already redrawn, see if they need to be. */
if (openfile->current_y < editwinrows - 1) {
/* Redraw the prior line if it was horizontally scrolled. */
if (need_horizontal_scroll(was_column, 0))
update_line(openfile->current->prev, 0);
/* Redraw the current line if it needs to be horizontally scrolled. */
if (need_horizontal_scroll(0, xplustabs()))
update_line(openfile->current, openfile->current_x);
}
}
/* Move down one line. */
void do_down_void(void)
{
do_down(
#ifndef NANO_TINY
FALSE
#endif
);
do_down(FALSE);
}
#ifndef NANO_TINY
/* Scroll up one line without scrolling the cursor. */
void do_scroll_up(void)
{
do_up(TRUE);
}
/* Scroll down one line without scrolling the cursor. */
void do_scroll_down(void)
{
@@ -573,7 +558,7 @@ void do_scroll_down(void)
/* Move left one character. */
void do_left(void)
{
size_t pww_save = openfile->placewewant;
size_t was_column = xplustabs();
if (openfile->current_x > 0)
openfile->current_x = move_mbleft(openfile->current->data,
@@ -585,14 +570,14 @@ void do_left(void)
openfile->placewewant = xplustabs();
if (need_screen_update(pww_save))
if (need_horizontal_scroll(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x);
}
/* Move right one character. */
void do_right(void)
{
size_t pww_save = openfile->placewewant;
size_t was_column = xplustabs();
assert(openfile->current_x <= strlen(openfile->current->data));
@@ -600,12 +585,16 @@ void do_right(void)
openfile->current_x = move_mbright(openfile->current->data,
openfile->current_x);
else if (openfile->current != openfile->filebot) {
do_down_void();
openfile->current_x = 0;
openfile->placewewant = 0;
if (need_horizontal_scroll(was_column, 0))
update_line(openfile->current, 0);
do_down_void();
return;
}
openfile->placewewant = xplustabs();
if (need_screen_update(pww_save))
if (need_horizontal_scroll(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x);
}

View File

@@ -603,49 +603,46 @@ void die(const char *msg, ...)
vfprintf(stderr, msg, ap);
va_end(ap);
/* Save the current file buffer if it's been modified. */
#ifndef NANO_TINY
/* If the current buffer has a lockfile, remove it. */
if (ISSET(LOCKING) && openfile->lock_filename)
delete_lockfile(openfile->lock_filename);
#endif
/* If the current file buffer was modified, save it. */
if (openfile && openfile->modified) {
/* If we've partitioned the filestruct, unpartition it now. */
/* If the filestruct is partitioned, unpartition it first. */
if (filepart != NULL)
unpartition_filestruct(&filepart);
die_save_file(openfile->filename
#ifndef NANO_TINY
, openfile->current_stat
#endif
);
die_save_file(openfile->filename, openfile->current_stat);
}
#ifndef DISABLE_MULTIBUFFER
/* Save all of the other modified file buffers, if any. */
if (openfile != NULL) {
openfilestruct *tmp = openfile;
openfilestruct *firstone = openfile;
while (tmp != openfile->next) {
while (openfile->next != firstone) {
openfile = openfile->next;
/* Save the current file buffer if it's been modified. */
if (openfile->modified)
die_save_file(openfile->filename
#ifndef NANO_TINY
, openfile->current_stat
if (ISSET(LOCKING) && openfile->lock_filename)
delete_lockfile(openfile->lock_filename);
#endif
);
if (openfile->modified)
die_save_file(openfile->filename, openfile->current_stat);
}
}
#endif
/* Get out. */
/* Abandon the building. */
exit(1);
}
/* Save the current file under the name specified in die_filename, which
* is modified to be unique if necessary. */
void die_save_file(const char *die_filename
#ifndef NANO_TINY
, struct stat *die_stat
#endif
)
void die_save_file(const char *die_filename, struct stat *die_stat)
{
char *targetname;
bool failed = TRUE;
@@ -862,7 +859,7 @@ void usage(void)
#ifndef NANO_TINY
print_opt("-W", "--wordbounds",
N_("Detect word boundaries more accurately"));
print_opt("-X", "--wordchars",
print_opt(_("-X <str>"), _("--wordchars=<str>"),
N_("Which other characters are word parts"));
#endif
#ifndef DISABLE_COLOR
@@ -1539,7 +1536,7 @@ void terminal_init(void)
/* Say that an unbound key was struck, and if possible which one. */
void unbound_key(int code)
{
if (func_key)
if (!is_byte(code))
statusline(ALERT, _("Unbound key"));
else if (meta_key) {
if (code == '[')
@@ -1577,7 +1574,7 @@ int do_input(bool allow_funcs)
#endif
#ifndef DISABLE_MOUSE
if (func_key && input == KEY_MOUSE) {
if (input == KEY_MOUSE) {
/* We received a mouse click. */
if (do_mouse() == 1)
/* The click was on a shortcut -- read in the character
@@ -1599,10 +1596,8 @@ int do_input(bool allow_funcs)
/* If we got a non-high-bit control key, a meta key sequence, or a
* function key, and it's not a shortcut or toggle, throw it out. */
if (!have_shortcut) {
if (is_ascii_cntrl_char(input) || meta_key || func_key) {
if (is_ascii_cntrl_char(input) || meta_key || !is_byte(input)) {
unbound_key(input);
meta_key = FALSE;
func_key = FALSE;
input = ERR;
}
}
@@ -2487,6 +2482,9 @@ int main(int argc, char **argv)
/* Set up the terminal state. */
terminal_init();
/* Check whether we're running on a Linux console. */
console = (getenv("DISPLAY") == NULL);
#ifdef DEBUG
fprintf(stderr, "Main: set up windows\n");
#endif

View File

@@ -187,10 +187,6 @@ typedef enum {
CENTERING, FLOWING, STATIONARY
} update_type;
typedef enum {
CONTROL, META, FKEY, RAWINPUT
} key_type;
typedef enum {
ADD, DEL, BACK, CUT, CUT_EOF, REPLACE,
#ifndef DISABLE_WRAPPING
@@ -397,6 +393,8 @@ typedef struct openfilestruct {
/* The file's y-coordinate position. */
bool modified;
/* Whether the file has been modified. */
struct stat *current_stat;
/* The file's current stat information. */
#ifndef NANO_TINY
bool mark_set;
/* Whether the mark is on in this file. */
@@ -406,8 +404,6 @@ typedef struct openfilestruct {
/* The file's mark's x-coordinate position, if any. */
file_format fmt;
/* The file's format. */
struct stat *current_stat;
/* The file's current stat information. */
undo *undotop;
/* The top of the undo list. */
undo *current_undo;
@@ -439,12 +435,12 @@ typedef struct rcoption {
#endif
typedef struct sc {
char *keystr;
/* The shortcut key for a function, ASCII version. */
key_type type;
/* What kind of command key it is, for convenience later. */
int seq;
/* The actual sequence to check once the type is determined. */
const char *keystr;
/* The string that describes a keystroke, like "^C" or "M-R". */
bool meta;
/* Whether this is a Meta keystroke. */
int keycode;
/* The integer that, together with meta, identifies the keystroke. */
int menus;
/* Which menus this applies to. */
void (*scfunc)(void);
@@ -554,12 +550,10 @@ enum
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\
MEXTCMD|MBROWSER|MWHEREISFILE|MGOTODIR|MSPELL|MLINTER)
/* Control key sequences. Changing these would be very, very bad. */
#define NANO_CONTROL_SPACE 0
#define NANO_CONTROL_I 9
#define NANO_CONTROL_3 27
#define NANO_CONTROL_7 31
#define NANO_CONTROL_8 127
/* Basic control codes. */
#define TAB_CODE 0x09
#define ESC_CODE 0x1B
#define DEL_CODE 0x7F
/* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */
#define CONTROL_LEFT 0x401

View File

@@ -66,14 +66,11 @@ int do_statusbar_input(bool *ran_func, bool *finished,
#ifndef DISABLE_MOUSE
/* If we got a mouse click and it was on a shortcut, read in the
* shortcut character. */
if (func_key && input == KEY_MOUSE) {
if (input == KEY_MOUSE) {
if (do_statusbar_mouse() == 1)
input = get_kbinput(bottomwin);
else {
meta_key = FALSE;
func_key = FALSE;
else
input = ERR;
}
}
#endif
@@ -87,23 +84,19 @@ int do_statusbar_input(bool *ran_func, bool *finished,
/* If we got a non-high-bit control key, a meta key sequence, or a
* function key, and it's not a shortcut or toggle, throw it out. */
if (!have_shortcut) {
if (is_ascii_cntrl_char(input) || meta_key || func_key) {
if (is_ascii_cntrl_char(input) || meta_key || !is_byte(input)) {
beep();
meta_key = FALSE;
func_key = FALSE;
input = ERR;
}
}
/* 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 it to the input buffer, when allowed. */
if (input != ERR && !have_shortcut) {
/* If we're using restricted mode, the filename isn't blank,
* and we're at the "Write File" prompt, disable text input. */
if (!ISSET(RESTRICTED) || openfile->filename[0] == '\0' ||
currmenu != MWRITEFILE) {
/* Only accept input when not in restricted mode, or when not at
* the "Write File" prompt, or when there is no filename yet. */
if (!ISSET(RESTRICTED) || currmenu != MWRITEFILE ||
openfile->filename[0] == '\0') {
kbinput_len++;
kbinput = (int *)nrealloc(kbinput, kbinput_len * sizeof(int));
kbinput[kbinput_len - 1] = input;
@@ -591,7 +584,7 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs,
if (func == do_tab) {
#ifndef DISABLE_HISTORIES
if (history_list != NULL) {
if (last_kbinput != sc_seq_or(do_tab, NANO_CONTROL_I))
if (last_kbinput != sc_seq_or(do_tab, TAB_CODE))
complete_len = strlen(answer);
if (complete_len > 0) {

View File

@@ -30,8 +30,8 @@
extern volatile sig_atomic_t sigwinch_counter;
#endif
extern bool console;
extern bool meta_key;
extern bool func_key;
extern bool focusing;
extern message_type lastmessage;
@@ -184,6 +184,7 @@ bool nisblank(int c);
bool niswblank(wchar_t wc);
#endif
bool is_byte(int c);
bool is_alpha_mbchar(const char *c);
bool is_alnum_mbchar(const char *c);
bool is_blank_mbchar(const char *c);
bool is_ascii_cntrl_char(int c);
@@ -362,8 +363,7 @@ size_t length_of_list(int menu);
const sc *first_sc_for(int menu, void (*func)(void));
int sc_seq_or(void (*func)(void), int defaultval);
functionptrtype func_from_key(int *kbinput);
key_type strtokeytype(const char *str);
void assign_keyinfo(sc *s);
void assign_keyinfo(sc *s, const char *keystring);
void print_sclist(void);
void shortcut_init(void);
#ifndef DISABLE_COLOR
@@ -408,26 +408,12 @@ void do_next_word_void(void);
#endif
void do_home(void);
void do_end(void);
void do_up(
#ifndef NANO_TINY
bool scroll_only
#else
void
#endif
);
void do_up(bool scroll_only);
void do_up_void(void);
#ifndef NANO_TINY
void do_scroll_up(void);
#endif
void do_down(
#ifndef NANO_TINY
bool scroll_only
#else
void
#endif
);
void do_down(bool scroll_only);
void do_down_void(void);
#ifndef NANO_TINY
void do_scroll_up(void);
void do_scroll_down(void);
#endif
void do_left(void);
@@ -458,11 +444,7 @@ void say_there_is_no_help(void);
#endif
void finish(void);
void die(const char *msg, ...);
void die_save_file(const char *die_filename
#ifndef NANO_TINY
, struct stat *die_stat
#endif
);
void die_save_file(const char *die_filename, struct stat *die_stat);
void window_init(void);
#ifndef DISABLE_MOUSE
void disable_mouse_support(void);
@@ -764,7 +746,7 @@ void dump_filestruct_reverse(void);
void get_key_buffer(WINDOW *win);
size_t get_key_buffer_len(void);
void unget_input(int *input, size_t input_len);
void unget_kbinput(int kbinput, bool metakey, bool funckey);
void unget_kbinput(int kbinput, bool metakey);
int *get_input(WINDOW *win, size_t input_len);
int get_kbinput(WINDOW *win);
int parse_kbinput(WINDOW *win);
@@ -778,7 +760,7 @@ long get_unicode_kbinput(WINDOW *win, int kbinput);
int get_control_kbinput(int kbinput);
void unparse_kbinput(char *output, size_t output_len);
int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len);
int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len);
int *parse_verbatim_kbinput(WINDOW *win, size_t *count);
#ifndef DISABLE_MOUSE
int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts);
#endif
@@ -801,7 +783,7 @@ void reset_cursor(void);
void edit_draw(filestruct *fileptr, const char *converted, int
line, size_t start);
int update_line(filestruct *fileptr, size_t index);
bool need_screen_update(size_t pww_save);
bool need_horizontal_scroll(const size_t old_column, const size_t new_column);
void edit_scroll(scroll_dir direction, ssize_t nlines);
void edit_redraw(filestruct *old_current);
void edit_refresh(void);

View File

@@ -470,20 +470,18 @@ void parse_binding(char *ptr, bool dobind)
goto free_copy;
}
newsc->keystr = keycopy;
newsc->menus = menu;
newsc->type = strtokeytype(newsc->keystr);
assign_keyinfo(newsc);
assign_keyinfo(newsc, keycopy);
/* Do not allow rebinding the equivalent of the Escape key. */
if (newsc->type == META && newsc->seq == 91) {
/* Do not allow rebinding a frequent escape-sequence starter: Esc [. */
if (newsc->meta && newsc->keycode == 91) {
rcfile_error(N_("Sorry, keystroke \"%s\" may not be rebound"), newsc->keystr);
free(newsc);
goto free_copy;
}
#ifdef DEBUG
fprintf(stderr, "s->keystr = \"%s\"\n", newsc->keystr);
fprintf(stderr, "s->seq = \"%d\"\n", newsc->seq);
fprintf(stderr, "s->keycode = \"%d\"\n", newsc->keycode);
#endif
}

View File

@@ -494,6 +494,9 @@ void go_looking(void)
filestruct *was_current = openfile->current;
size_t was_current_x = openfile->current_x;
int didfind;
#ifdef DEBUG
clock_t start = clock();
#endif
came_full_circle = FALSE;
@@ -509,6 +512,10 @@ void go_looking(void)
openfile->current_x == was_current_x)
statusbar(_("This is the only occurrence"));
#ifdef DEBUG
statusline(HUSH, "Took: %.2f", (double)(clock() - start) / CLOCKS_PER_SEC);
#endif
edit_redraw(was_current);
search_replace_abort();
}

View File

@@ -2559,7 +2559,7 @@ void do_justify(bool full_justify)
}
} else {
/* Put the keystroke back into the queue. */
unget_kbinput(kbinput, meta_key, func_key);
unget_kbinput(kbinput, meta_key);
/* Set the desired screen column (always zero, except at EOF). */
openfile->placewewant = xplustabs();
@@ -2666,14 +2666,15 @@ bool do_int_spell_fix(const char *word)
/* Find the first whole occurrence of word. */
result = findnextstr(TRUE, NULL, 0, word, NULL);
/* The word must exist; if not, something is wrong. */
if (result == 0)
statusline(ALERT, "Internal error: "
"speller listed unfindable word: %s", word);
else if (result == 1) {
/* If the word isn't found, alert the user; if it is, allow correction. */
if (result == 0) {
statusline(ALERT, _("Unfindable word: %s"), word);
lastmessage = HUSH;
proceed = TRUE;
napms(2800);
} else if (result == 1) {
exp_word = display_string(openfile->current->data, xplustabs(),
strlenpt(word), FALSE);
edit_refresh();
spotlight(TRUE, exp_word);

View File

@@ -290,12 +290,11 @@ bool is_separate_word(size_t position, size_t length, const char *buf)
parse_mbchar(buf + move_mbleft(buf, position), before, NULL);
parse_mbchar(buf + word_end, after, NULL);
/* If we're at the beginning of the line or the character before the
* word isn't a non-punctuation "word" character, and if we're at
* the end of the line or the character after the word isn't a
* non-punctuation "word" character, we have a whole word. */
retval = (position == 0 || !is_alnum_mbchar(before)) &&
(word_end == strlen(buf) || !is_alnum_mbchar(after));
/* If the word starts at the beginning of the line OR the character before
* the word isn't a letter, and if the word ends at the end of the line OR
* the character after the word isn't a letter, we have a whole word. */
retval = (position == 0 || !is_alpha_mbchar(before)) &&
(word_end == strlen(buf) || !is_alpha_mbchar(after));
free(before);
free(after);

File diff suppressed because it is too large Load Diff