Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb9a5bed8e | ||
|
|
b43f6912f3 | ||
|
|
5a018f0d3a | ||
|
|
752830573a | ||
|
|
daaf468c93 | ||
|
|
dcf5cbbf6a | ||
|
|
3b830ee194 | ||
|
|
d753efdb55 | ||
|
|
c9199e9e9a | ||
|
|
e2df2c899d | ||
|
|
c82f038855 | ||
|
|
8b6f6fcc1b | ||
|
|
0bff84ef9c | ||
|
|
6277f59d24 | ||
|
|
6c3d886424 | ||
|
|
879dfbaf40 | ||
|
|
e9dee887a9 | ||
|
|
123110c5dc | ||
|
|
cbba77558e | ||
|
|
e350d7a52a | ||
|
|
16e07d5878 | ||
|
|
8c1edd17e3 | ||
|
|
fc48347fb8 | ||
|
|
2cd2d4b9ae | ||
|
|
533b9fa827 | ||
|
|
f9d4fd3755 | ||
|
|
f55ada727e | ||
|
|
99c8d40db1 | ||
|
|
6f08332741 | ||
|
|
a60910cc54 | ||
|
|
7be32046b0 | ||
|
|
795be590d5 | ||
|
|
3aad8ab9aa | ||
|
|
1d461475ce | ||
|
|
a535cecd77 | ||
|
|
d233e7e240 |
2
BUGS
2
BUGS
@@ -1,5 +1,4 @@
|
||||
** Open BUGS **
|
||||
- Cutting the line at the top of the screen recenters to center (71)
|
||||
|
||||
** Fixed BUGS **
|
||||
- Marked cutting sometimes leaves a newline in the file unintelligently,
|
||||
@@ -156,6 +155,7 @@
|
||||
assigned to it (79 - may not be worth fixing) [FIXED]
|
||||
- Segfault editing at COLS presumably due to new color syntax
|
||||
highlighting (80) [FIXED]
|
||||
- Cutting the line at the top of the screen recenters to center (71) [FIXED]
|
||||
|
||||
|
||||
$Id$
|
||||
|
||||
109
ChangeLog
109
ChangeLog
@@ -1,3 +1,112 @@
|
||||
GNU nano 2.2.0 - 2009.11.30
|
||||
2009-11-29 Chris Allegretta <chrisa@asty.org>
|
||||
* prompt.c (get_prompt_string) - Universally handle help key when is disabled. Fixes Savannah
|
||||
bug 28117 by David Lawrence Ramsey <pooka109@gmail.com>.
|
||||
* chars.c, files.c: Add junk vars to silence the compiler. Sigh.
|
||||
|
||||
2009-11-29 David Lawrence Ramsey <pooka109@gmail.com>
|
||||
* Change several *chars to const char, additional cleanups and casts to make compilers happier.
|
||||
* global.c: Fix replace and insert file initializations for proper compilation options.
|
||||
* nano.c (do_suspend): Update comments to reflect actual code path, bad Chris and thanks for
|
||||
noticing Jordi.
|
||||
* configure.ac: Fix typos
|
||||
|
||||
2009-11-27 Chris Allegretta <chrisa@asty.org>
|
||||
* nano.c (do_suspend): Don't clear the screen but do move the cursor down to the last line
|
||||
first in an effort to not corrupt the screen, which contradicts Pico but is consistent
|
||||
with almost all other text editors. Fixes Savannah bug 28110/Debian bug 460510
|
||||
reported by Tim Connors <reportbug@rather.puzzling.org>.
|
||||
* doc/dyntax/makefile.nanorc - Sample Makefile highlighting based on wiki.linuxhelp.net version.
|
||||
|
||||
2009-11-26 Chris Allegretta <chrisa@asty.org>
|
||||
* winio.c (edit_scroll): Adjust for long lines when scrolling.
|
||||
* rcfile.c (parse_rcfile), initialize size argument to getline(), fixes crash on FreeBSD
|
||||
reported by Eitan Adler <eitanadlerlist@gmail.com>.
|
||||
|
||||
2009-11-26 Jordi Mallach <jordi@gnu.org>
|
||||
* doc/man/*: Update all man pages to escape unescaped hyphens.
|
||||
|
||||
2009-11-24 Chris Allegretta <chrisa@asty.org>
|
||||
* move.c (do_page_up, do_page_down): Make these functions work better with soft
|
||||
line wrapping.
|
||||
* winio.c (compute_maxrows): Make maxrows calculation more accurate when all lines are > COLS.
|
||||
|
||||
2009-11-22 Chris Allegretta <chrisa@asty.org>
|
||||
* nano.c (main): Allow edit_refresh_needed to take effect when using --enable-tiny
|
||||
(fixes Savannah bug 28076 reported by David Lawrence Ramsey).
|
||||
|
||||
2009-11-22 David Lawrence Ramsey <pooka109@gmail.com>
|
||||
* nano.c (move_to_filestruct): Fix bug 71 (cut at top of line recenters)
|
||||
* Fix compilation with --enable-tiny
|
||||
|
||||
2009-11-22 Mike Frysinger <vapier@gentoo.org>
|
||||
* doc/syntax/gentoo.nanorc: Tweak comment highlighting.
|
||||
|
||||
GNU nano 2.1.99pre2 - 2009.11.21
|
||||
2009-11-21 Chris Allegretta <chrisa@asty.org>
|
||||
* rcfile.c: Add unbinding keyword, fixes Savannah bug 22852 reported by frankd.
|
||||
* prompt.c (update_statusbar_line): Set statusbar_pww when updating the line.
|
||||
Fixes Savannah bug 24957 by Mike Frysinger.
|
||||
|
||||
2009-11-19 Chris Allegretta <chrisa@asty.org>
|
||||
* nano.c (die_save_file) Try nd match the permissions of the file we were
|
||||
editing but only make a minimal effort to do so. Fixes Savannah bug 27273
|
||||
reported by Mike Frysinger.
|
||||
|
||||
2009-11-18 Adrian Bunk <bunk via Savannah>
|
||||
* nano.c (main): Allow --fill and --nowrap to override nanorc entries and each other
|
||||
on the command line.
|
||||
|
||||
2009-11-15 Chris Allegretta <chrisa@asty.org>
|
||||
* winio.c (edit_refresh): Always computer maxsize regardless of whether smooth scrolling
|
||||
is enabled. Fixes Savannah bug 28024 by Mike Frysinger.
|
||||
|
||||
GNU nano 2.1.99pre1 - 2009.11.15
|
||||
2009-11-14 Chris Allegretta <chrisa@asty.org>
|
||||
* move.c (do_first_line, do_last_line): Just set edit_refresh_needed rather than
|
||||
get messy.
|
||||
* files.c (do_writeout) - Only mention file modification if we're writing the same
|
||||
file we originally opened.
|
||||
|
||||
2009-11-13 Chris Allegretta <chrisa@asty.org>
|
||||
* winio.c: Add new static maxsize to be able to easier calculation with
|
||||
softwrap.
|
||||
* nano.c (do_mouse): Fix mouse support not working with soft wrapping. Fixes
|
||||
Savannah bug 27549 reported by Hannes Schueller.
|
||||
|
||||
2009-11-11 Chris Allegretta <chrisa@asty.org>
|
||||
* winio.c: Large tweaking of cursor and text display based on COLS not COLS - 1,
|
||||
due to finally understanding that display_string wasn't being called properly
|
||||
when softwrap was enabled. Fixes Savnnah bug 27603, Return key doesn't scroll
|
||||
viewport reported by Hannes Schueller.
|
||||
* - Fix size_t formatting issues with -pedantic
|
||||
|
||||
2009-11-09 Chris Allegretta <chrisa@asty.org>
|
||||
* files.c (read_file): - Remove debugging messages from file load. Fixes
|
||||
Savannah bug 27838.
|
||||
|
||||
2009-11-07 Chris Allegretta <chrisa@asty.org>
|
||||
* nano.h - Add bogus value at begin of flags enumeration because it
|
||||
causes casesens rcfile option to misbehave, reported by Helmut
|
||||
Jarausch <jarausch@igpm.rwth-aachen.de>
|
||||
|
||||
2009-11-03 Chris Allegretta <chrisa@asty.org>
|
||||
* nano.h - Fix comma at end of enumerator list which angers -pedantic.
|
||||
* rcfile.c - Add in specific check for UNDOABLE and fix declaration as
|
||||
to what flag it toggles. Fixes undo mode being able to be called from
|
||||
the rc file, reported by Helmut Jarausch <jarausch@igpm.rwth-aachen.de>
|
||||
|
||||
2009-11-03 Mike Frysinger <vapier@gentoo.org>
|
||||
* files.c - Move up is_file_writable() to stop implicit definition complaints.
|
||||
|
||||
2009-10-27 Chris Allegretta <chrisa@asty.org>
|
||||
* browser.c (browser_init): Set column width to something sane when
|
||||
initializing in a directory with no file entries. Fixes Savannah
|
||||
bug 24163 found (and initial patch) by Paul Wise.
|
||||
|
||||
2009-09-15 Chris Allegretta <chrisa@asty.org>
|
||||
* winio.c: Clean up some unused variables from the soft wrapping code.
|
||||
|
||||
GNU nano 2.1.11 - 2009.09.14
|
||||
2009-09-12 Chris Allegretta <chrisa@asty.org>
|
||||
* winio.c (edit_update) - properly update edittop when using soft wrapping.
|
||||
|
||||
44
NEWS
44
NEWS
@@ -1,3 +1,47 @@
|
||||
2009.11.30 - GNU nano 2.2.0 "Doc Brown" is released! The culmination
|
||||
of almost two years of development and hot on the heels
|
||||
of nano's 10th birthday is available for all your
|
||||
editing needs! Bugs fixed since the last release
|
||||
include several fixes for tiny mode (involving both
|
||||
the help keys and replace menu text), more 'final'
|
||||
fixes for soft wrapping, and several typo and documentation
|
||||
updates including nanorc tweaks and a new syntax
|
||||
highlighting file for makefiles. Also included is a long
|
||||
standing fix for random crashing when using nanorc on
|
||||
FreeBSD, and nano will no longer clear the screen on
|
||||
suspend to maintain compatibility with other *nix editors.
|
||||
For those who haven't been playing along at home, please
|
||||
see the official web page for the summary of new
|
||||
features since 2.0. Special thanks to all who have
|
||||
submitted bug reports recently in support of our new
|
||||
stable release, and apologies for all those bugs we
|
||||
didn't yet find :-) Peace to all.
|
||||
|
||||
2009.11.21 - GNU nano 2.1.99pre2 is available for a special pre-Black
|
||||
Friday discount. Included are some (hopefully
|
||||
final) fixes for issues with last page display
|
||||
caused by the soft wrapping code, and a fix for
|
||||
a long standing issue with hittig the home key when
|
||||
going through the search history. On the features
|
||||
front, nano will now attempt to retain the proper
|
||||
ownership and permissions when trying to create a
|
||||
.save file due to receiving a signal. Nano can also
|
||||
now unbind keys from one or more menus via the 'unbind'
|
||||
keyword. Finally, passing --fill or --nowrap on
|
||||
the command line will now override any related
|
||||
.nanorc entries. Speak now or forever hold your bugs!
|
||||
|
||||
2009.11.15 - GNU nano 2.1.99pre1 "take a bow" is out there, man, it's
|
||||
out there all right. This release contains mainly
|
||||
bugfixes, underscoring that we are preparing for the
|
||||
next stable series release. Included are many fixes
|
||||
for the new soft wrapping code, compiler warning tweaks,
|
||||
and the modification time warning no longer triggers
|
||||
when saving a file as a new name. Also include are
|
||||
some fixes for various nanorc options, and there are
|
||||
surely more bugs to find before we call the code base
|
||||
stable, so please keep those reports coming!
|
||||
|
||||
2009.09.14 - GNU nano 2.1.11 is on very thin ice, very thin ice, very thin
|
||||
ice. This release includes two new features: first, nano
|
||||
will check whether the current file is writable when it
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#
|
||||
# $Id$
|
||||
|
||||
AC_INIT([GNU nano], [2.1.11], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [2.2.0], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AC_CANONICAL_TARGET([])
|
||||
AM_INIT_AUTOMAKE
|
||||
@@ -191,7 +191,7 @@ fi],
|
||||
AC_ARG_ENABLE(all,
|
||||
[ --enable-all Enable ALL extra nano functionality (ignored for compatibility as all options default to on)],
|
||||
[if test x$enableval = xyes; then
|
||||
echo "--enable-all option no longer needed, ignoring for compatiblity"
|
||||
echo "--enable-all option no longer needed, ignoring for compatibility"
|
||||
fi])
|
||||
|
||||
AC_MSG_CHECKING([whether to enable UTF-8 support])
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
<blockquote><p>For the 'bleeding edge' current version of nano, you can use subversion to download the current source code. <b>Note:</b> believe it or not, by downloading code that has not yet stabilized into an official release, there could quite possibly be bugs, in fact the code may not even compile! Anyway, see <a href="http://svn.savannah.gnu.org/viewvc/trunk/nano/README.SVN?root=nano&view=markup">the nano SVN document</a> for info on anonymous SVN access to the nano source.</p></blockquote>
|
||||
<hr width="100%">
|
||||
<h1><a name="3"></a>3. Installation and Configuration</h1>
|
||||
<h2><a name="3.1"></a>3.1. How do install the RPM or DEB package?</h2>
|
||||
<h2><a name="3.1"></a>3.1. How do I install the RPM or DEB package?</h2>
|
||||
<blockquote><p>It's simple really! As root, type <b>rpm -Uvh nano-x.y.z-1.i386.rpm</b> if you have a RedHat-ish system or <b>dpkg -i nano_x.y.z-1.deb</b> if you have a Debian-ish system, where <b>x.y.z</b> is the release of nano. There are other programs to install packages, and if you wish to use those, knock yourself out.</p></blockquote>
|
||||
<h2><a name="3.2"></a>3.2. Compiling from source: WHAT THE HECK DO I DO NOW?</h2>
|
||||
<blockquote><p>Okay, take a deep breath, this really isn't hard. Unpack the nano source with a command like:</p>
|
||||
|
||||
@@ -230,7 +230,7 @@ Passe automatiquement
|
||||
\fIcolonne\fR. Si la valeur indiquée est de 0 ou moins, le point de
|
||||
passage à la ligne aura lieu à la taille de l'écran moins \fIcolonne\fR.
|
||||
Cela permet de faire varier le point de passage à la ligne lorsque l'on
|
||||
change la taille de l'écran. La valeur par défaut est de -8.
|
||||
change la taille de l'écran. La valeur par défaut est de \-8.
|
||||
.TP
|
||||
.B \-s \fIprogramme\fP (\-\-speller=\fIprogramme\fP)
|
||||
Choix d'un correcteur orthographique de remplacement.
|
||||
|
||||
@@ -143,7 +143,7 @@ Passe automatiquement
|
||||
\fIn\fR. Si la valeur indiquée est de 0 ou moins, le point de passage à
|
||||
la ligne aura lieu à la taille de l'écran moins \fIn\fR. Cela permet de
|
||||
faire varier le point de passage à la ligne lorsque l'on change la
|
||||
taille de l'écran. La valeur par défaut est de -8.
|
||||
taille de l'écran. La valeur par défaut est de \-8.
|
||||
.TP
|
||||
.B set/unset historylog
|
||||
Active l'utilisation de
|
||||
|
||||
@@ -180,7 +180,7 @@ be acknowledged by pressing enter at startup.
|
||||
Wrap lines at column \fIcols\fP. If this value is 0 or less, wrapping
|
||||
will occur at the width of the screen less \fIcols\fP columns, allowing
|
||||
the wrap point to vary along with the width of the screen if the screen
|
||||
is resized. The default value is -8.
|
||||
is resized. The default value is \-8.
|
||||
.TP
|
||||
.B \-s \fIprog\fP (\-\-speller=\fIprog\fP)
|
||||
Enable alternative spell checker command.
|
||||
|
||||
@@ -91,7 +91,7 @@ Use cut to end of line by default.
|
||||
.B set fill \fIn\fP
|
||||
Wrap lines at column number \fIn\fP. If \fIn\fP is 0 or less, the
|
||||
maximum line length will be the screen width less \fIn\fP columns. The
|
||||
default value is -8.
|
||||
default value is \-8.
|
||||
.TP
|
||||
.B set/unset historylog
|
||||
Enable \fI~/.nano_history\fP for saving and reading search/replace
|
||||
@@ -224,7 +224,7 @@ characters as parts of words.
|
||||
.TP
|
||||
.B syntax "\fIstr\fP" ["\fIfileregex\fP" ... ]
|
||||
Defines a syntax named \fIstr\fP which can be activated via the
|
||||
-Y/--syntax command line option, or will be automatically activated if
|
||||
\-Y/\-\-syntax command line option, or will be automatically activated if
|
||||
the current filename matches the extended regular expression
|
||||
\fIfileregex\fP. All following \fBcolor\fP and \fBicolor\fP statements
|
||||
will apply to \fIsyntax\fP until a new syntax is defined.
|
||||
@@ -534,6 +534,13 @@ The 'go to directory' menu.
|
||||
.TP
|
||||
.B all
|
||||
A special name meaning: apply to all menus where this function exists.
|
||||
|
||||
.TP
|
||||
.B unbind \fIkey\fP \fImenu\fP
|
||||
Unbind the key \fIkey\fP from the menu named \fImenu\fP or from all
|
||||
menus by using \fIall\fP. Same key syntax as for binding.
|
||||
Rebinds the key \fIkey\fP to a new function named \fIfunction\fP in the
|
||||
context of menu \fImenu\fP. The format of \fIkey\fP should be one of:
|
||||
.SH FILES
|
||||
.TP
|
||||
.I SYSCONFDIR/nanorc
|
||||
|
||||
@@ -238,6 +238,9 @@
|
||||
## C/C++
|
||||
# include "@PKGDATADIR@/c.nanorc"
|
||||
|
||||
## Makefiles
|
||||
# include "@PKGDATADIR@/makefile.nanorc"
|
||||
|
||||
## Cascading Style Sheets
|
||||
# include "@PKGDATADIR@/css.nanorc"
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ pkgdata_DATA = asm.nanorc \
|
||||
xml.nanorc \
|
||||
ocaml.nanorc \
|
||||
objc.nanorc \
|
||||
fortran.nanorc
|
||||
fortran.nanorc \
|
||||
makefile.nanorc
|
||||
|
||||
EXTRA_DIST = $(pkgdata_DATA)
|
||||
|
||||
@@ -27,7 +27,7 @@ color brightblue "\<(doc|ins|exe)?into\>" "\<(f|games)(owners|perms)\>" "\<(exe|
|
||||
## Highlight common commands used in ebuilds
|
||||
color blue "\<make\>" "\<(awk|cat|cd|chmod|chown|cp|echo|env|export|find|e?grep|ln|mkdir|mv|rm|sed|set|tar|touch|unset|xargs)\>"
|
||||
## Highlight comments (doesnt work that well)
|
||||
color yellow "#.*$"
|
||||
color yellow "(^|[[:space:]])#.*$"
|
||||
## Highlight strings (doesnt work that well)
|
||||
color brightyellow ""(\\.|[^\"])*"" "'(\\.|[^'])*'"
|
||||
## Trailing space is bad!
|
||||
|
||||
8
doc/syntax/makefile.nanorc
Normal file
8
doc/syntax/makefile.nanorc
Normal file
@@ -0,0 +1,8 @@
|
||||
# unattributed syntax highlighting example from wiki.linuxhelp.net/
|
||||
|
||||
syntax "makefile" "Makefile[^/]*$"
|
||||
color red "[:=]"
|
||||
color magenta "\<(if|ifeq|else|endif)\>"
|
||||
color blue "\$+[{(][a-Z0-9_-]+[})]"
|
||||
color brightblue "^[^ ]+:"
|
||||
color green "#.*$"
|
||||
661
po/nano.pot
661
po/nano.pot
File diff suppressed because it is too large
Load Diff
659
po/pt_BR.po
659
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
659
po/zh_CN.po
659
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
659
po/zh_TW.po
659
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
@@ -534,9 +534,9 @@ void browser_init(const char *path, DIR *dir)
|
||||
}
|
||||
|
||||
/* If width isn't initialized yet, and we've taken up only one line,
|
||||
* it means that width is equal to (COLS % longest). */
|
||||
* it means that width is equal to longest. */
|
||||
if (width == 0)
|
||||
width = COLS % longest;
|
||||
width = longest;
|
||||
}
|
||||
|
||||
/* Determine the shortcut key corresponding to the values of kbinput
|
||||
|
||||
30
src/chars.c
30
src/chars.c
@@ -89,7 +89,7 @@ bool is_alnum_mbchar(const char *c)
|
||||
wchar_t wc;
|
||||
|
||||
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
int shutup = mbtowc(NULL, NULL, 0);
|
||||
wc = bad_wchar;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ bool is_blank_mbchar(const char *c)
|
||||
wchar_t wc;
|
||||
|
||||
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
int shutup = mbtowc(NULL, NULL, 0);
|
||||
wc = bad_wchar;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ bool is_cntrl_mbchar(const char *c)
|
||||
wchar_t wc;
|
||||
|
||||
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
int shutup = mbtowc(NULL, NULL, 0);
|
||||
wc = bad_wchar;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ bool is_punct_mbchar(const char *c)
|
||||
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
|
||||
|
||||
if (c_mb_len < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
int shutup = mbtowc(NULL, NULL, 0);
|
||||
wc = bad_wchar;
|
||||
}
|
||||
|
||||
@@ -243,14 +243,14 @@ char *control_mbrep(const char *c, char *crep, int *crep_len)
|
||||
wchar_t wc;
|
||||
|
||||
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
int shutup = mbtowc(NULL, NULL, 0);
|
||||
*crep_len = bad_mbchar_len;
|
||||
strncpy(crep, bad_mbchar, *crep_len);
|
||||
} else {
|
||||
*crep_len = wctomb(crep, control_wrep(wc));
|
||||
|
||||
if (*crep_len < 0) {
|
||||
wctomb(NULL, 0);
|
||||
int shutup = wctomb(NULL, 0);
|
||||
*crep_len = 0;
|
||||
}
|
||||
}
|
||||
@@ -278,14 +278,14 @@ char *mbrep(const char *c, char *crep, int *crep_len)
|
||||
|
||||
/* Reject invalid Unicode characters. */
|
||||
if (mbtowc(&wc, c, MB_CUR_MAX) < 0 || !is_valid_unicode(wc)) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
int shutup = mbtowc(NULL, NULL, 0);
|
||||
*crep_len = bad_mbchar_len;
|
||||
strncpy(crep, bad_mbchar, *crep_len);
|
||||
} else {
|
||||
*crep_len = wctomb(crep, wc);
|
||||
|
||||
if (*crep_len < 0) {
|
||||
wctomb(NULL, 0);
|
||||
int shutup = wctomb(NULL, 0);
|
||||
*crep_len = 0;
|
||||
}
|
||||
}
|
||||
@@ -311,7 +311,7 @@ int mbwidth(const char *c)
|
||||
int width;
|
||||
|
||||
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
int shutup = mbtowc(NULL, NULL, 0);
|
||||
wc = bad_wchar;
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ char *make_mbchar(long chr, int *chr_mb_len)
|
||||
|
||||
/* Reject invalid Unicode characters. */
|
||||
if (*chr_mb_len < 0 || !is_valid_unicode((wchar_t)chr)) {
|
||||
wctomb(NULL, 0);
|
||||
int shutup = wctomb(NULL, 0);
|
||||
*chr_mb_len = 0;
|
||||
}
|
||||
} else {
|
||||
@@ -388,7 +388,7 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
|
||||
/* If buf contains an invalid multibyte character, only
|
||||
* interpret buf's first byte. */
|
||||
if (buf_mb_len < 0) {
|
||||
mblen(NULL, 0);
|
||||
int shutup = mblen(NULL, 0);
|
||||
buf_mb_len = 1;
|
||||
} else if (buf_mb_len == 0)
|
||||
buf_mb_len++;
|
||||
@@ -545,7 +545,7 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
|
||||
s1_mb_len = parse_mbchar(s1, s1_mb, NULL);
|
||||
|
||||
if (mbtowc(&ws1, s1_mb, s1_mb_len) < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
int shutup = mbtowc(NULL, NULL, 0);
|
||||
ws1 = (unsigned char)*s1_mb;
|
||||
bad_s1_mb = TRUE;
|
||||
}
|
||||
@@ -553,7 +553,7 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
|
||||
s2_mb_len = parse_mbchar(s2, s2_mb, NULL);
|
||||
|
||||
if (mbtowc(&ws2, s2_mb, s2_mb_len) < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
int shutup = mbtowc(NULL, NULL, 0);
|
||||
ws2 = (unsigned char)*s2_mb;
|
||||
bad_s2_mb = TRUE;
|
||||
}
|
||||
@@ -781,7 +781,7 @@ char *mbstrchr(const char *s, const char *c)
|
||||
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
|
||||
|
||||
if (c_mb_len < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
int shutup = mbtowc(NULL, NULL, 0);
|
||||
wc = (unsigned char)*c;
|
||||
bad_c_mb = TRUE;
|
||||
}
|
||||
@@ -790,7 +790,7 @@ char *mbstrchr(const char *s, const char *c)
|
||||
int s_mb_len = parse_mbchar(s, s_mb, NULL);
|
||||
|
||||
if (mbtowc(&ws, s_mb, s_mb_len) < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
int shutup = mbtowc(NULL, NULL, 0);
|
||||
ws = (unsigned char)*s;
|
||||
bad_s_mb = TRUE;
|
||||
}
|
||||
|
||||
91
src/files.c
91
src/files.c
@@ -291,6 +291,47 @@ bool close_buffer(void)
|
||||
}
|
||||
#endif /* ENABLE_MULTIBUFFER */
|
||||
|
||||
/* A bit of a copy and paste from open_file(), is_file_writable()
|
||||
* just checks whether the file is appendable as a quick
|
||||
* permissions check, and we tend to err on the side of permissiveness
|
||||
* (reporting TRUE when it might be wrong) to not fluster users
|
||||
* editing on odd filesystems by printing incorrect warnings.
|
||||
*/
|
||||
int is_file_writable(const char *filename)
|
||||
{
|
||||
struct stat fileinfo, fileinfo2;
|
||||
int fd;
|
||||
FILE *f;
|
||||
char *full_filename;
|
||||
bool ans = TRUE;
|
||||
|
||||
|
||||
if (ISSET(VIEW_MODE))
|
||||
return TRUE;
|
||||
|
||||
assert(filename != NULL && f != NULL);
|
||||
|
||||
/* Get the specified file's full path. */
|
||||
full_filename = get_full_path(filename);
|
||||
|
||||
/* Okay, if we can't stat the path due to a component's
|
||||
permissions, just try the relative one */
|
||||
if (full_filename == NULL
|
||||
|| (stat(full_filename, &fileinfo) == -1 && stat(filename, &fileinfo2) != -1))
|
||||
full_filename = mallocstrcpy(NULL, filename);
|
||||
|
||||
if ((fd = open(full_filename, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR |
|
||||
S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) == -1
|
||||
|| (f = fdopen(fd, "a")) == NULL)
|
||||
ans = FALSE;
|
||||
else
|
||||
fclose(f);
|
||||
close(fd);
|
||||
|
||||
free(full_filename);
|
||||
return ans;
|
||||
}
|
||||
|
||||
/* We make a new line of text from buf. buf is length buf_len. If
|
||||
* first_line_ins is TRUE, then we put the new line at the top of the
|
||||
* file. Otherwise, we assume prevnode is the last line of the file,
|
||||
@@ -474,8 +515,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||
nperror(filename);
|
||||
fclose(f);
|
||||
if (fd > 0) {
|
||||
int closecode = close(fd);
|
||||
fprintf(stderr, "Closecode = %d\n", closecode);
|
||||
close(fd);
|
||||
writable = is_file_writable(filename);
|
||||
}
|
||||
|
||||
@@ -701,48 +741,6 @@ int open_file(const char *filename, bool newfie, FILE **f)
|
||||
return fd;
|
||||
}
|
||||
|
||||
/* A bit of a copy and paste from open_file(), is_file_writable()
|
||||
* just checks whether the file is appendable as a quick
|
||||
* permissions check, and we tend to err on the side of permissiveness
|
||||
* (reporting TRUE when it might be wrong) to not fluster users
|
||||
* editing on odd filesystems by printing incorrect warnings.
|
||||
*/
|
||||
int is_file_writable(const char *filename)
|
||||
{
|
||||
struct stat fileinfo, fileinfo2;
|
||||
int fd;
|
||||
FILE *f;
|
||||
char *full_filename;
|
||||
bool ans = TRUE;
|
||||
|
||||
|
||||
if (ISSET(VIEW_MODE))
|
||||
return TRUE;
|
||||
|
||||
assert(filename != NULL && f != NULL);
|
||||
|
||||
/* Get the specified file's full path. */
|
||||
full_filename = get_full_path(filename);
|
||||
|
||||
/* Okay, if we can't stat the path due to a component's
|
||||
permissions, just try the relative one */
|
||||
if (full_filename == NULL
|
||||
|| (stat(full_filename, &fileinfo) == -1 && stat(filename, &fileinfo2) != -1))
|
||||
full_filename = mallocstrcpy(NULL, filename);
|
||||
|
||||
if ((fd = open(full_filename, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR |
|
||||
S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) == -1
|
||||
|| (f = fdopen(fd, "a")) == NULL)
|
||||
ans = FALSE;
|
||||
else
|
||||
fclose(f);
|
||||
close(fd);
|
||||
|
||||
free(full_filename);
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
/* This function will return the name of the first available extension
|
||||
* of a filename (starting with [name][suffix], then [name][suffix].1,
|
||||
* etc.). Memory is allocated for the return value. If no writable
|
||||
@@ -1094,6 +1092,7 @@ char *get_full_path(const char *origpath)
|
||||
char *d_here, *d_there, *d_there_file = NULL;
|
||||
const char *last_slash;
|
||||
bool path_only;
|
||||
int shutup;
|
||||
|
||||
if (origpath == NULL)
|
||||
return NULL;
|
||||
@@ -1192,7 +1191,7 @@ char *get_full_path(const char *origpath)
|
||||
/* Finally, go back to the path specified in d_here,
|
||||
* where we were before. We don't check for a chdir()
|
||||
* error, since we can do nothing if we get one. */
|
||||
chdir(d_here);
|
||||
shutup = chdir(d_here);
|
||||
|
||||
/* Free d_here, since we're done using it. */
|
||||
free(d_here);
|
||||
@@ -2120,7 +2119,7 @@ bool do_writeout(bool exiting)
|
||||
}
|
||||
}
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->current_stat && openfile->current_stat->st_mtime < st.st_mtime) {
|
||||
if (name_exists && openfile->current_stat && openfile->current_stat->st_mtime < st.st_mtime) {
|
||||
i = do_yesno_prompt(FALSE,
|
||||
_("File was modified since you opened it, continue saving ? "));
|
||||
if (i == 0 || i == -1)
|
||||
|
||||
17
src/global.c
17
src/global.c
@@ -66,6 +66,8 @@ WINDOW *bottomwin;
|
||||
* messages, the statusbar prompt, and a list of shortcuts. */
|
||||
int editwinrows = 0;
|
||||
/* How many rows does the edit window take up? */
|
||||
int maxrows = 0;
|
||||
/* How many usable lines are there (due to soft wrapping) */
|
||||
|
||||
filestruct *cutbuffer = NULL;
|
||||
/* The buffer where we store cut text. */
|
||||
@@ -212,7 +214,7 @@ size_t length_of_list(int menu)
|
||||
}
|
||||
|
||||
/* Set type of function based on the string */
|
||||
function_type strtokeytype(char *str)
|
||||
function_type strtokeytype(const char *str)
|
||||
{
|
||||
if (str[0] == 'M' || str[0] == 'm')
|
||||
return META;
|
||||
@@ -287,7 +289,7 @@ const sc *first_sc_for(int menu, short func) {
|
||||
|
||||
/* Add a string to the new shortcut list implementation
|
||||
Allows updates to existing entries in the list */
|
||||
void add_to_sclist(int menu, char *scstring, short func, int toggle, int execute)
|
||||
void add_to_sclist(int menu, const char *scstring, short func, int toggle, int execute)
|
||||
{
|
||||
sc *s;
|
||||
|
||||
@@ -313,7 +315,7 @@ void add_to_sclist(int menu, char *scstring, short func, int toggle, int execute
|
||||
s->type = strtokeytype(scstring);
|
||||
s->menu = menu;
|
||||
s->toggle = toggle;
|
||||
s->keystr = scstring;
|
||||
s->keystr = (char *) scstring;
|
||||
s->scfunc = func;
|
||||
s->execute = execute;
|
||||
assign_keyinfo(s);
|
||||
@@ -409,7 +411,10 @@ void print_sclist(void)
|
||||
|
||||
|
||||
/* Stuff we need to make at least static here so we can access it below */
|
||||
/* TRANSLATORS: Try to keep the next five strings at most 10 characters. */
|
||||
const char *cancel_msg = N_("Cancel");
|
||||
const char *replace_msg = N_("Replace");
|
||||
const char *no_replace_msg = N_("No Replace");
|
||||
|
||||
#ifndef NANO_TINY
|
||||
const char *case_sens_msg = N_("Case Sens");
|
||||
@@ -445,8 +450,6 @@ const char *ext_cmd_msg = "";
|
||||
/* TRANSLATORS: Try to keep the next five strings at most 10 characters. */
|
||||
const char *prev_history_msg = N_("PrevHstory");
|
||||
const char *next_history_msg = N_("NextHstory");
|
||||
const char *replace_msg = N_("Replace");
|
||||
const char *no_replace_msg = N_("No Replace");
|
||||
const char *gototext_msg = N_("Go To Text");
|
||||
/* TRANSLATORS: Try to keep the next three strings at most 12 characters. */
|
||||
const char *whereis_next_msg = N_("WhereIs Next");
|
||||
@@ -488,7 +491,9 @@ void shortcut_init(bool unjustify)
|
||||
const char *fulljstify_msg = N_("FullJstify");
|
||||
#endif
|
||||
const char *refresh_msg = N_("Refresh");
|
||||
#ifndef NANO_TINY
|
||||
const char *insert_file_msg = N_("Insert File");
|
||||
#endif
|
||||
const char *go_to_line_msg = N_("Go To Line");
|
||||
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
@@ -1342,7 +1347,7 @@ const subnfunc *sctofunc(sc *s)
|
||||
#ifndef NANO_TINY
|
||||
/* Now lets come up with a single (hopefully)
|
||||
function to get a string for each flag */
|
||||
char *flagtostr(int flag)
|
||||
const char *flagtostr(int flag)
|
||||
{
|
||||
switch (flag) {
|
||||
case NO_HELP:
|
||||
|
||||
58
src/move.c
58
src/move.c
@@ -29,45 +29,40 @@
|
||||
/* Move to the first line of the file. */
|
||||
void do_first_line(void)
|
||||
{
|
||||
filestruct *current_save = openfile->current;
|
||||
size_t pww_save = openfile->placewewant;
|
||||
|
||||
openfile->current = openfile->fileage;
|
||||
openfile->current = openfile->edittop = openfile->fileage;
|
||||
openfile->current_x = 0;
|
||||
openfile->placewewant = 0;
|
||||
|
||||
edit_redraw(current_save, pww_save);
|
||||
edit_refresh_needed = 1;
|
||||
}
|
||||
|
||||
/* Move to the last line of the file. */
|
||||
void do_last_line(void)
|
||||
{
|
||||
filestruct *current_save = openfile->current;
|
||||
size_t pww_save = openfile->placewewant;
|
||||
|
||||
openfile->current = openfile->filebot;
|
||||
openfile->current_x = strlen(openfile->filebot->data);
|
||||
openfile->placewewant = xplustabs();
|
||||
openfile->current_y = editwinrows - 1;
|
||||
|
||||
edit_redraw(current_save, pww_save);
|
||||
edit_refresh_needed = 1;
|
||||
}
|
||||
|
||||
/* Move up one page. */
|
||||
void do_page_up(void)
|
||||
{
|
||||
int i;
|
||||
int i, skipped = 0;
|
||||
|
||||
/* If there's less than a page of text left on the screen, put the
|
||||
* cursor at the beginning of the first line of the file, and then
|
||||
* update the edit window. */
|
||||
if (openfile->current->lineno <= editwinrows - 2) {
|
||||
if (!ISSET(SOFTWRAP) && openfile->current->lineno <= editwinrows - 2) {
|
||||
do_first_line();
|
||||
return;
|
||||
}
|
||||
|
||||
/* If we're not in smooth scrolling mode, put the cursor at the
|
||||
* beginning of the top line of the edit window, as Pico does. */
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (!ISSET(SMOOTH_SCROLL)) {
|
||||
#endif
|
||||
@@ -77,15 +72,27 @@ void do_page_up(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = editwinrows - 2; i > 0 && openfile->current !=
|
||||
openfile->fileage; i--)
|
||||
for (i = editwinrows - 2; i - skipped > 0 && openfile->current !=
|
||||
openfile->fileage; i--) {
|
||||
openfile->current = openfile->current->prev;
|
||||
if (ISSET(SOFTWRAP) && openfile->current) {
|
||||
skipped += strlenpt(openfile->current->data) / COLS;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_page_up: i = %d, skipped = %d based on line %ld len %d\n", i, (unsigned long) skipped,
|
||||
openfile->current->lineno, strlenpt(openfile->current->data));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
openfile->placewewant);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_page_up: openfile->current->lineno = %lu, skipped = %d\n", (unsigned long) openfile->current->lineno, skipped);
|
||||
#endif
|
||||
|
||||
/* Scroll the edit window up a page. */
|
||||
edit_scroll(UP_DIR, editwinrows - 2);
|
||||
edit_scroll(UP_DIR, editwinrows - skipped - 2);
|
||||
}
|
||||
|
||||
/* Move down one page. */
|
||||
@@ -96,7 +103,7 @@ void do_page_down(void)
|
||||
/* If there's less than a page of text left on the screen, put the
|
||||
* cursor at the beginning of the last line of the file, and then
|
||||
* update the edit window. */
|
||||
if (openfile->current->lineno + editwinrows - 2 >=
|
||||
if (openfile->current->lineno + maxrows - 2 >=
|
||||
openfile->filebot->lineno) {
|
||||
do_last_line();
|
||||
return;
|
||||
@@ -113,9 +120,14 @@ void do_page_down(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = editwinrows - 2; i > 0 && openfile->current !=
|
||||
openfile->filebot; i--)
|
||||
for (i = maxrows - 2; i > 0 && openfile->current !=
|
||||
openfile->filebot; i--) {
|
||||
openfile->current = openfile->current->next;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_page_down: moving to line %lu\n", (unsigned long) openfile->current->lineno);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
openfile->placewewant);
|
||||
@@ -565,17 +577,7 @@ void do_down(
|
||||
openfile->placewewant);
|
||||
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
filestruct *foo;
|
||||
ssize_t extracuzsoft = 0;
|
||||
|
||||
for (foo = openfile->edittop; foo
|
||||
&& foo->lineno - openfile->edittop->lineno + extracuzsoft < editwinrows;
|
||||
foo = foo->next) {
|
||||
extracuzsoft += strlenpt(foo->data) / (COLS - 1);
|
||||
if (foo == openfile->current)
|
||||
break;
|
||||
}
|
||||
if (foo && foo->lineno - openfile->edittop->lineno + extracuzsoft >= editwinrows)
|
||||
if (openfile->current->lineno - openfile->edittop->lineno >= maxrows)
|
||||
onlastline = TRUE;
|
||||
}
|
||||
|
||||
|
||||
125
src/nano.c
125
src/nano.c
@@ -394,11 +394,7 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
|
||||
/* If the top of the edit window was inside the old partition, put
|
||||
* it in range of current. */
|
||||
if (edittop_inside)
|
||||
edit_update(
|
||||
#ifndef NANO_TINY
|
||||
ISSET(SMOOTH_SCROLL) ? NONE :
|
||||
#endif
|
||||
CENTER);
|
||||
edit_update(NONE);
|
||||
|
||||
/* Renumber starting with the beginning line of the old
|
||||
* partition. */
|
||||
@@ -638,7 +634,11 @@ void die(const char *msg, ...)
|
||||
if (filepart != NULL)
|
||||
unpartition_filestruct(&filepart);
|
||||
|
||||
die_save_file(openfile->filename);
|
||||
die_save_file(openfile->filename
|
||||
#ifndef NANO_TINY
|
||||
, openfile->current_stat
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
@@ -651,7 +651,11 @@ void die(const char *msg, ...)
|
||||
|
||||
/* Save the current file buffer if it's been modified. */
|
||||
if (openfile->modified)
|
||||
die_save_file(openfile->filename);
|
||||
die_save_file(openfile->filename
|
||||
#ifndef NANO_TINY
|
||||
, openfile->current_stat
|
||||
#endif
|
||||
);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -662,7 +666,11 @@ void die(const char *msg, ...)
|
||||
|
||||
/* Save the current file under the name spacified in die_filename, which
|
||||
* is modified to be unique if necessary. */
|
||||
void die_save_file(const char *die_filename)
|
||||
void die_save_file(const char *die_filename
|
||||
#ifndef NANO_TINY
|
||||
, struct stat *die_stat
|
||||
#endif
|
||||
)
|
||||
{
|
||||
char *retval;
|
||||
bool failed = TRUE;
|
||||
@@ -691,6 +699,17 @@ void die_save_file(const char *die_filename)
|
||||
fprintf(stderr, _("\nBuffer not written: %s\n"),
|
||||
_("Too many backup files?"));
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Try and chmod/chown the save file to the values of the original file, but
|
||||
dont worry if it fails because we're supposed to be bailing as fast
|
||||
as possible. */
|
||||
if (die_stat) {
|
||||
int shush;
|
||||
shush = chmod(retval, die_stat->st_mode);
|
||||
shush = chown(retval, die_stat->st_uid, die_stat->st_gid);
|
||||
}
|
||||
#endif
|
||||
|
||||
free(retval);
|
||||
}
|
||||
|
||||
@@ -1165,11 +1184,9 @@ RETSIGTYPE do_suspend(int signal)
|
||||
disable_mouse_support();
|
||||
#endif
|
||||
|
||||
/* Blank the screen, and move the cursor to the last line of the
|
||||
* screen. */
|
||||
erase();
|
||||
/* Move the cursor to the last line of the screen. */
|
||||
move(LINES - 1, 0);
|
||||
refresh();
|
||||
endwin();
|
||||
|
||||
/* Display our helpful message. */
|
||||
printf(_("Use \"fg\" to return to nano.\n"));
|
||||
@@ -1612,6 +1629,7 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
|
||||
&& openfile->syntax->nmultis > 0) {
|
||||
reset_multis(openfile->current, FALSE);
|
||||
}
|
||||
#endif
|
||||
if (edit_refresh_needed) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "running edit_refresh() as edit_refresh_needed is true\n");
|
||||
@@ -1620,7 +1638,6 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
|
||||
edit_refresh_needed = FALSE;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1667,17 +1684,53 @@ int do_mouse(void)
|
||||
|
||||
sameline = (mouse_y == openfile->current_y);
|
||||
|
||||
/* Move to where the click occurred. */
|
||||
for (; openfile->current_y < mouse_y && openfile->current !=
|
||||
openfile->filebot; openfile->current_y++)
|
||||
openfile->current = openfile->current->next;
|
||||
for (; openfile->current_y > mouse_y && openfile->current !=
|
||||
openfile->fileage; openfile->current_y--)
|
||||
openfile->current = openfile->current->prev;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "mouse_y = %d, current_y = %d\n", mouse_y, openfile->current_y);
|
||||
#endif
|
||||
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
int i = 0;
|
||||
for (openfile->current = openfile->edittop;
|
||||
openfile->current->next && i < mouse_y;
|
||||
openfile->current = openfile->current->next, i++) {
|
||||
openfile->current_y = i;
|
||||
i += strlenpt(openfile->current->data) / COLS;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_mouse(): moving to current_y = %d, i %d\n", openfile->current_y, i);
|
||||
fprintf(stderr, " openfile->current->data = \"%s\"\n", openfile->current->data);
|
||||
#endif
|
||||
|
||||
if (i > mouse_y) {
|
||||
openfile->current = openfile->current->prev;
|
||||
openfile->current_x = actual_x(openfile->current->data, mouse_x + (mouse_y - openfile->current_y) * COLS);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_mouse(): i > mouse_y, mouse_x = %d, current_x to = %d\n", mouse_x, openfile->current_x);
|
||||
#endif
|
||||
} else {
|
||||
openfile->current_x = actual_x(openfile->current->data, mouse_x);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_mouse(): i <= mouse_y, mouse_x = %d, setting current_x to = %d\n", mouse_x, openfile->current_x);
|
||||
#endif
|
||||
}
|
||||
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
} else {
|
||||
/* Move to where the click occurred. */
|
||||
for (; openfile->current_y < mouse_y && openfile->current !=
|
||||
openfile->filebot; openfile->current_y++)
|
||||
openfile->current = openfile->current->next;
|
||||
for (; openfile->current_y > mouse_y && openfile->current !=
|
||||
openfile->fileage; openfile->current_y--)
|
||||
openfile->current = openfile->current->prev;
|
||||
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
get_page_start(xplustabs()) + mouse_x);
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
openfile->placewewant = xplustabs();
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Clicking where the cursor is toggles the mark, as does
|
||||
@@ -1698,7 +1751,7 @@ int do_mouse(void)
|
||||
void alloc_multidata_if_needed(filestruct *fileptr)
|
||||
{
|
||||
if (!fileptr->multidata)
|
||||
fileptr->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
fileptr->multidata = (short *) nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
}
|
||||
|
||||
/* Precalculate the multi-line start and end regex info so we can speed up
|
||||
@@ -1737,7 +1790,7 @@ void precalc_multicolorinfo(void)
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "working on lineno %zd\n", fileptr->lineno);
|
||||
fprintf(stderr, "working on lineno %lu\n", (unsigned long) fileptr->lineno);
|
||||
#endif
|
||||
|
||||
alloc_multidata_if_needed(fileptr);
|
||||
@@ -1770,7 +1823,7 @@ void precalc_multicolorinfo(void)
|
||||
for (endptr = fileptr->next; endptr != NULL; endptr = endptr->next) {
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "advancing to line %zd to find end...\n", endptr->lineno);
|
||||
fprintf(stderr, "advancing to line %lu to find end...\n", (unsigned long) endptr->lineno);
|
||||
#endif
|
||||
/* Check for keyboard input again */
|
||||
if ((cur_check = time(NULL)) - last_check > 1) {
|
||||
@@ -1798,18 +1851,18 @@ void precalc_multicolorinfo(void)
|
||||
lines in between and the ends properly */
|
||||
fileptr->multidata[tmpcolor->id] |= CENDAFTER;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "marking line %zd as CENDAFTER\n", fileptr->lineno);
|
||||
fprintf(stderr, "marking line %lu as CENDAFTER\n", (unsigned long) fileptr->lineno);
|
||||
#endif
|
||||
for (fileptr = fileptr->next; fileptr != endptr; fileptr = fileptr->next) {
|
||||
alloc_multidata_if_needed(fileptr);
|
||||
fileptr->multidata[tmpcolor->id] = CWHOLELINE;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "marking intermediary line %zd as CWHOLELINE\n", fileptr->lineno);
|
||||
fprintf(stderr, "marking intermediary line %lu as CWHOLELINE\n", (unsigned long) fileptr->lineno);
|
||||
#endif
|
||||
}
|
||||
alloc_multidata_if_needed(endptr);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "marking line %zd as BEGINBEFORE\n", fileptr->lineno);
|
||||
fprintf(stderr, "marking line %lu as BEGINBEFORE\n", (unsigned long) fileptr->lineno);
|
||||
#endif
|
||||
endptr->multidata[tmpcolor->id] |= CBEGINBEFORE;
|
||||
/* We should be able to skip all the way to the line of the match.
|
||||
@@ -1817,12 +1870,12 @@ void precalc_multicolorinfo(void)
|
||||
fileptr = endptr;
|
||||
startx = endmatch.rm_eo;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "jumping to line %zd pos %d to continue\n", endptr->lineno, startx);
|
||||
fprintf(stderr, "jumping to line %lu pos %d to continue\n", (unsigned long) endptr->lineno, startx);
|
||||
#endif
|
||||
}
|
||||
if (nostart && startx == 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "no start found on line %zd, continuing\n", fileptr->lineno);
|
||||
fprintf(stderr, "no start found on line %lu, continuing\n", (unsigned long) fileptr->lineno);
|
||||
#endif
|
||||
fileptr->multidata[tmpcolor->id] = CNONE;
|
||||
continue;
|
||||
@@ -2227,6 +2280,11 @@ int main(int argc, char **argv)
|
||||
#ifndef DISABLE_WRAPPING
|
||||
case 'w':
|
||||
SET(NO_WRAP);
|
||||
|
||||
/* If both --fill and --nowrap are given on the command line,
|
||||
the last option wins, */
|
||||
fill_used = FALSE;
|
||||
|
||||
break;
|
||||
#endif
|
||||
case 'x':
|
||||
@@ -2354,6 +2412,13 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
#endif /* ENABLE_NANORC */
|
||||
|
||||
#ifndef DISABLE_WRAPPING
|
||||
/* Overwrite an rcfile "set nowrap" or --disable-wrapping-as-root
|
||||
if a --fill option was given on the command line. */
|
||||
if (fill_used)
|
||||
UNSET(NO_WRAP);
|
||||
#endif
|
||||
|
||||
/* If we're using bold text instead of reverse video text, set it up
|
||||
* now. */
|
||||
if (ISSET(BOLD_TEXT))
|
||||
|
||||
@@ -457,6 +457,7 @@ typedef struct subnfunc {
|
||||
* definitions. */
|
||||
enum
|
||||
{
|
||||
DONTUSE,
|
||||
CASE_SENSITIVE,
|
||||
CONST_UPDATE,
|
||||
NO_HELP,
|
||||
@@ -490,7 +491,7 @@ enum
|
||||
BOLD_TEXT,
|
||||
QUIET,
|
||||
UNDOABLE,
|
||||
SOFTWRAP,
|
||||
SOFTWRAP
|
||||
};
|
||||
|
||||
/* Flags for which menus in which a given function should be present */
|
||||
|
||||
@@ -868,7 +868,7 @@ void update_statusbar_line(const char *curranswer, size_t index)
|
||||
free(expanded);
|
||||
|
||||
wattroff(bottomwin, reverse_attr);
|
||||
|
||||
statusbar_pww = statusbar_xplustabs();
|
||||
reset_statusbar_cursor();
|
||||
wnoutrefresh(bottomwin);
|
||||
}
|
||||
@@ -956,7 +956,7 @@ const sc *get_prompt_string(int *actual, bool allow_tabs,
|
||||
currmenu = menu;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %d\n", answer, statusbar_x);
|
||||
fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answer, (unsigned long) statusbar_x);
|
||||
#endif
|
||||
|
||||
update_statusbar_line(answer, statusbar_x);
|
||||
@@ -1070,7 +1070,6 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %d\n", answer
|
||||
}
|
||||
} else
|
||||
#endif /* !NANO_TINY */
|
||||
#ifndef DISABLE_HELP
|
||||
if (s && s->scfunc == DO_HELP_VOID) {
|
||||
update_statusbar_line(answer, statusbar_x);
|
||||
|
||||
@@ -1082,7 +1081,6 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %d\n", answer
|
||||
* prompt. */
|
||||
finished = FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If we have a shortcut with an associated function, break out
|
||||
* if we're finished after running or trying to run the
|
||||
|
||||
56
src/proto.h
56
src/proto.h
@@ -46,6 +46,7 @@ extern WINDOW *topwin;
|
||||
extern WINDOW *edit;
|
||||
extern WINDOW *bottomwin;
|
||||
extern int editwinrows;
|
||||
extern int maxrows;
|
||||
|
||||
extern filestruct *cutbuffer;
|
||||
extern filestruct *cutbottom;
|
||||
@@ -427,7 +428,11 @@ void free_openfilestruct(openfilestruct *src);
|
||||
void print_view_warning(void);
|
||||
void finish(void);
|
||||
void die(const char *msg, ...);
|
||||
void die_save_file(const char *die_filename);
|
||||
void die_save_file(const char *die_filename
|
||||
#ifndef NANO_TINY
|
||||
, struct stat *die_stat
|
||||
#endif
|
||||
);
|
||||
void window_init(void);
|
||||
#ifndef DISABLE_MOUSE
|
||||
void disable_mouse_support(void);
|
||||
@@ -778,12 +783,12 @@ void display_main_list(void);
|
||||
void do_cursorpos(bool constant);
|
||||
void do_cursorpos_void(void);
|
||||
void do_replace_highlight(bool highlight, const char *word);
|
||||
char *flagtostr(int flag);
|
||||
const char *flagtostr(int flag);
|
||||
const subnfunc *sctofunc(sc *s);
|
||||
const subnfunc *getfuncfromkey(WINDOW *win);
|
||||
void print_sclist(void);
|
||||
sc *strtosc(int menu, char *input);
|
||||
function_type strtokeytype(char *str);
|
||||
function_type strtokeytype(const char *str);
|
||||
int strtomenu(char *input);
|
||||
void assign_keyinfo(sc *s);
|
||||
void xon_complaint(void);
|
||||
@@ -791,35 +796,36 @@ void xoff_complaint(void);
|
||||
int sc_seq_or (short func, int defaultval);
|
||||
void do_suspend_void(void);
|
||||
|
||||
const char *cancel_msg;
|
||||
extern const char *cancel_msg;
|
||||
#ifndef NANO_TINY
|
||||
const char *case_sens_msg;
|
||||
const char *backwards_msg;
|
||||
const char *prev_history_msg;
|
||||
const char *next_history_msg;
|
||||
extern const char *case_sens_msg;
|
||||
extern const char *backwards_msg;
|
||||
extern const char *prev_history_msg;
|
||||
extern const char *next_history_msg;
|
||||
#endif
|
||||
const char *replace_msg;
|
||||
const char *no_replace_msg;
|
||||
const char *go_to_line_msg;
|
||||
const char *whereis_next_msg;
|
||||
const char *first_file_msg;
|
||||
const char *last_file_msg;
|
||||
const char *goto_dir_msg;
|
||||
const char *ext_cmd_msg;
|
||||
const char *to_files_msg;
|
||||
const char *dos_format_msg;
|
||||
const char *mac_format_msg;
|
||||
const char *append_msg;
|
||||
const char *prepend_msg;
|
||||
const char *backup_file_msg;
|
||||
const char *gototext_msg;
|
||||
const char *new_buffer_msg;
|
||||
extern const char *replace_msg;
|
||||
extern const char *no_replace_msg;
|
||||
extern const char *go_to_line_msg;
|
||||
extern const char *whereis_next_msg;
|
||||
extern const char *first_file_msg;
|
||||
extern const char *last_file_msg;
|
||||
extern const char *goto_dir_msg;
|
||||
extern const char *ext_cmd_msg;
|
||||
extern const char *to_files_msg;
|
||||
extern const char *dos_format_msg;
|
||||
extern const char *mac_format_msg;
|
||||
extern const char *append_msg;
|
||||
extern const char *prepend_msg;
|
||||
extern const char *backup_file_msg;
|
||||
extern const char *gototext_msg;
|
||||
extern const char *new_buffer_msg;
|
||||
|
||||
void iso_me_harder_funcmap(short func);
|
||||
void enable_nodelay(void);
|
||||
void disable_nodelay(void);
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
const char *regexp_msg;
|
||||
extern const char *regexp_msg;
|
||||
#endif
|
||||
|
||||
#ifdef NANO_EXTRA
|
||||
|
||||
74
src/rcfile.c
74
src/rcfile.c
@@ -89,7 +89,7 @@ static const rcoption rcopts[] = {
|
||||
{"smarthome", SMART_HOME},
|
||||
{"smooth", SMOOTH_SCROLL},
|
||||
{"tabstospaces", TABS_TO_SPACES},
|
||||
{"undo", 0},
|
||||
{"undo", UNDOABLE},
|
||||
{"whitespace", 0},
|
||||
{"wordbounds", WORD_BOUNDS},
|
||||
{"softwrap", SOFTWRAP},
|
||||
@@ -454,7 +454,6 @@ void parse_keybinding(char *ptr)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* now let's have some fun. Try and delete the other entries
|
||||
we found for the same menu, then make this new new
|
||||
beginning */
|
||||
@@ -470,6 +469,70 @@ void parse_keybinding(char *ptr)
|
||||
sclist = newsc;
|
||||
}
|
||||
|
||||
/* Let user unbind a sequence from a given (or all) menus */
|
||||
void parse_unbinding(char *ptr)
|
||||
{
|
||||
char *keyptr = NULL, *keycopy = NULL, *menuptr = NULL;
|
||||
sc *s;
|
||||
int i, menu;
|
||||
|
||||
assert(ptr != NULL);
|
||||
|
||||
if (*ptr == '\0') {
|
||||
rcfile_error(N_("Missing key name"));
|
||||
return;
|
||||
}
|
||||
|
||||
keyptr = ptr;
|
||||
ptr = parse_next_word(ptr);
|
||||
keycopy = mallocstrcpy(NULL, keyptr);
|
||||
for (i = 0; i < strlen(keycopy); i++)
|
||||
keycopy[i] = toupper(keycopy[i]);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Starting unbinding code");
|
||||
#endif
|
||||
|
||||
if (keycopy[0] != 'M' && keycopy[0] != '^' && keycopy[0] != 'F' && keycopy[0] != 'K') {
|
||||
rcfile_error(
|
||||
N_("keybindings must begin with \"^\", \"M\", or \"F\""));
|
||||
return;
|
||||
}
|
||||
|
||||
menuptr = ptr;
|
||||
ptr = parse_next_word(ptr);
|
||||
|
||||
if (!strcmp(menuptr, "")) {
|
||||
rcfile_error(
|
||||
/* Note to translators, do not translate the word "all"
|
||||
in the sentence below, everything else is fine */
|
||||
N_("Must specify menu to bind key to (or \"all\")"));
|
||||
return;
|
||||
}
|
||||
|
||||
menu = strtomenu(menuptr);
|
||||
if (menu < 1) {
|
||||
rcfile_error(
|
||||
N_("Could not map name \"%s\" to a menu"), menuptr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "unbinding \"%s\" from menu = %d\n", keycopy, menu);
|
||||
#endif
|
||||
|
||||
/* Now find the apropriate entries in the menu to delete */
|
||||
for (s = sclist; s != NULL; s = s->next) {
|
||||
if (((s->menu & menu)) && !strcmp(s->keystr,keycopy)) {
|
||||
s->menu &= ~menu;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "deleted menu entry %d\n", s->menu);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Read and parse additional syntax files. */
|
||||
void parse_include(char *ptr)
|
||||
@@ -829,7 +892,7 @@ void parse_rcfile(FILE *rcstream
|
||||
{
|
||||
char *buf = NULL;
|
||||
ssize_t len;
|
||||
size_t n;
|
||||
size_t n = 0;
|
||||
|
||||
while ((len = getline(&buf, &n, rcstream)) > 0) {
|
||||
char *ptr, *keyword, *option;
|
||||
@@ -895,6 +958,8 @@ void parse_rcfile(FILE *rcstream
|
||||
parse_colors(ptr, TRUE);
|
||||
else if (strcasecmp(keyword, "bind") == 0)
|
||||
parse_keybinding(ptr);
|
||||
else if (strcasecmp(keyword, "unbind") == 0)
|
||||
parse_unbinding(ptr);
|
||||
#endif /* ENABLE_COLOR */
|
||||
else
|
||||
rcfile_error(N_("Command \"%s\" not understood"), keyword);
|
||||
@@ -1047,6 +1112,9 @@ void parse_rcfile(FILE *rcstream
|
||||
else
|
||||
rcfile_error(N_("Cannot unset flag \"%s\""),
|
||||
rcopts[i].name);
|
||||
/* Looks like we still need this specific hack for undo */
|
||||
if (strcasecmp(rcopts[i].name, "undo") == 0)
|
||||
shortcut_init(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
28
src/text.c
28
src/text.c
@@ -181,7 +181,7 @@ void do_tab(void)
|
||||
free(output);
|
||||
} else {
|
||||
#endif
|
||||
do_output("\t", 1, TRUE);
|
||||
do_output((char *) "\t", 1, TRUE);
|
||||
#ifndef NANO_TINY
|
||||
}
|
||||
#endif
|
||||
@@ -409,7 +409,7 @@ void redo_cut(undo *u) {
|
||||
for (c = u->cutbuffer, t = openfile->current; c->next != NULL && t->next != NULL; ) {
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Advancing, lineno = %zd, data = \"%s\"\n", t->lineno, t->data);
|
||||
fprintf(stderr, "Advancing, lineno = %lu, data = \"%s\"\n", (unsigned long) t->lineno, t->data);
|
||||
#endif
|
||||
c = c->next;
|
||||
t = t->next;
|
||||
@@ -483,7 +483,7 @@ void do_undo(void)
|
||||
break;
|
||||
case SPLIT:
|
||||
undidmsg = _("line wrap");
|
||||
f->data = nrealloc(f->data, strlen(f->data) + strlen(u->strdata) + 1);
|
||||
f->data = (char *) nrealloc(f->data, strlen(f->data) + strlen(u->strdata) + 1);
|
||||
strcpy(&f->data[strlen(f->data) - 1], u->strdata);
|
||||
if (u->strdata2 != NULL)
|
||||
f->next->data = mallocstrcpy(f->next->data, u->strdata2);
|
||||
@@ -517,7 +517,7 @@ void do_undo(void)
|
||||
undidmsg = _("line break");
|
||||
if (f->next) {
|
||||
filestruct *foo = f->next;
|
||||
f->data = nrealloc(f->data, strlen(f->data) + strlen(f->next->data) + 1);
|
||||
f->data = (char *) nrealloc(f->data, strlen(f->data) + strlen(f->next->data) + 1);
|
||||
strcat(f->data, f->next->data);
|
||||
unlink_node(foo);
|
||||
delete_node(foo);
|
||||
@@ -765,7 +765,7 @@ bool execute_command(const char *command)
|
||||
* arguments. */
|
||||
shellenv = getenv("SHELL");
|
||||
if (shellenv == NULL)
|
||||
shellenv = "/bin/sh";
|
||||
shellenv = (char *) "/bin/sh";
|
||||
|
||||
/* Fork a child. */
|
||||
if ((pid = fork()) == 0) {
|
||||
@@ -859,7 +859,7 @@ void add_undo(undo_type current_action)
|
||||
}
|
||||
|
||||
/* Allocate and initialize a new undo type */
|
||||
u = nmalloc(sizeof(undo));
|
||||
u = (undo *) nmalloc(sizeof(undo));
|
||||
u->type = current_action;
|
||||
u->lineno = fs->current->lineno;
|
||||
u->begin = fs->current_x;
|
||||
@@ -943,8 +943,8 @@ void add_undo(undo_type current_action)
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "fs->current->data = \"%s\", current_x = %zd, u->begin = %d, type = %d\n",
|
||||
fs->current->data, fs->current_x, u->begin, current_action);
|
||||
fprintf(stderr, "fs->current->data = \"%s\", current_x = %lu, u->begin = %d, type = %d\n",
|
||||
fs->current->data, (unsigned long) fs->current_x, u->begin, current_action);
|
||||
fprintf(stderr, "left add_undo...\n");
|
||||
#endif
|
||||
fs->last_action = current_action;
|
||||
@@ -966,10 +966,10 @@ void update_undo(undo_type action)
|
||||
return;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno = %zd",
|
||||
action, fs->last_action, openfile->current->lineno);
|
||||
fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno = %lu",
|
||||
action, fs->last_action, (unsigned long) openfile->current->lineno);
|
||||
if (fs->current_undo)
|
||||
fprintf(stderr, "fs->current_undo->lineno = %zd\n", fs->current_undo->lineno);
|
||||
fprintf(stderr, "fs->current_undo->lineno = %lu\n", (unsigned long) fs->current_undo->lineno);
|
||||
else
|
||||
fprintf(stderr, "\n");
|
||||
#endif
|
||||
@@ -989,11 +989,11 @@ void update_undo(undo_type action)
|
||||
switch (u->type) {
|
||||
case ADD:
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "fs->current->data = \"%s\", current_x = %zd, u->begin = %d\n",
|
||||
fs->current->data, fs->current_x, u->begin);
|
||||
fprintf(stderr, "fs->current->data = \"%s\", current_x = %lu, u->begin = %d\n",
|
||||
fs->current->data, (unsigned long) fs->current_x, u->begin);
|
||||
#endif
|
||||
len = strlen(u->strdata) + 2;
|
||||
data = nrealloc((void *) u->strdata, len * sizeof(char *));
|
||||
data = (char *) nrealloc((void *) u->strdata, len * sizeof(char *));
|
||||
data[len-2] = fs->current->data[fs->current_x];
|
||||
data[len-1] = '\0';
|
||||
u->strdata = (char *) data;
|
||||
|
||||
118
src/winio.c
118
src/winio.c
@@ -2437,14 +2437,15 @@ void reset_cursor(void)
|
||||
xpt = xplustabs();
|
||||
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
openfile->current_y = 0;
|
||||
filestruct *tmp;
|
||||
for (tmp = openfile->edittop; tmp && tmp != openfile->current; tmp = tmp->next)
|
||||
openfile->current_y += 1 + strlenpt(tmp->data) / (COLS - 1);
|
||||
openfile->current_y = 0;
|
||||
|
||||
openfile->current_y += xplustabs() / (COLS - 1);
|
||||
for (tmp = openfile->edittop; tmp && tmp != openfile->current; tmp = tmp->next)
|
||||
openfile->current_y += 1 + strlenpt(tmp->data) / COLS;
|
||||
|
||||
openfile->current_y += xplustabs() / COLS;
|
||||
if (openfile->current_y < editwinrows)
|
||||
wmove(edit, openfile->current_y, xpt % (COLS - 1));
|
||||
wmove(edit, openfile->current_y, xpt % COLS);
|
||||
} else {
|
||||
openfile->current_y = openfile->current->lineno -
|
||||
openfile->edittop->lineno;
|
||||
@@ -2494,7 +2495,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
if (fileptr->multidata == NULL && openfile->syntax
|
||||
&& openfile->syntax->nmultis > 0) {
|
||||
int i;
|
||||
fileptr->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
fileptr->multidata = (short *) nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
for (i = 0; i < openfile->syntax->nmultis; i++)
|
||||
fileptr->multidata[i] = -1; /* Assue this applies until we know otherwise */
|
||||
}
|
||||
@@ -2849,7 +2850,7 @@ int update_line(filestruct *fileptr, size_t index)
|
||||
line = fileptr->lineno - openfile->edittop->lineno;
|
||||
|
||||
if (line < 0 || line >= editwinrows)
|
||||
return;
|
||||
return 1;
|
||||
|
||||
/* First, blank out the line. */
|
||||
blank_line(edit, line, 0, COLS);
|
||||
@@ -2864,7 +2865,13 @@ int update_line(filestruct *fileptr, size_t index)
|
||||
|
||||
/* Expand the line, replacing tabs with spaces, and control
|
||||
* characters with their displayed forms. */
|
||||
converted = display_string(fileptr->data, page_start, COLS, TRUE);
|
||||
converted = display_string(fileptr->data, page_start, COLS, !ISSET(SOFTWRAP));
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ISSET(SOFTWRAP) && strlen(converted) >= COLS - 2)
|
||||
fprintf(stderr, "update_line(): converted(1) line = %s\n", converted);
|
||||
#endif
|
||||
|
||||
|
||||
/* Paint the line. */
|
||||
edit_draw(fileptr, converted, line, page_start);
|
||||
@@ -2877,16 +2884,20 @@ int update_line(filestruct *fileptr, size_t index)
|
||||
mvwaddch(edit, line, COLS - 1, '$');
|
||||
} else {
|
||||
int full_length = strlenpt(fileptr->data);
|
||||
for (index += COLS - 1; index < full_length && line < editwinrows; index += COLS - 1) {
|
||||
for (index += COLS; index <= full_length && line < editwinrows; index += COLS) {
|
||||
line++;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "update_line(): Softwrap code, moving to %d\n", line);
|
||||
fprintf(stderr, "update_line(): Softwrap code, moving to %d index %lu\n", line, (unsigned long) index);
|
||||
#endif
|
||||
blank_line(edit, line, 0, COLS);
|
||||
|
||||
/* Expand the line, replacing tabs with spaces, and control
|
||||
* characters with their displayed forms. */
|
||||
converted = display_string(fileptr->data, index, COLS, TRUE);
|
||||
converted = display_string(fileptr->data, index, COLS, !ISSET(SOFTWRAP));
|
||||
#ifdef DEBUG
|
||||
if (ISSET(SOFTWRAP) && strlen(converted) >= COLS - 2)
|
||||
fprintf(stderr, "update_line(): converted(2) line = %s\n", converted);
|
||||
#endif
|
||||
|
||||
/* Paint the line. */
|
||||
edit_draw(fileptr, converted, line, index);
|
||||
@@ -2923,6 +2934,34 @@ bool need_vertical_update(size_t pww_save)
|
||||
get_page_start(openfile->placewewant);
|
||||
}
|
||||
|
||||
/* When edittop changes, try and figure out how many lines
|
||||
* we really have to work with (i.e. set maxrows)
|
||||
*/
|
||||
void compute_maxrows(void)
|
||||
{
|
||||
int n;
|
||||
filestruct *foo = openfile->edittop;
|
||||
|
||||
if (!ISSET(SOFTWRAP)) {
|
||||
maxrows = editwinrows;
|
||||
return;
|
||||
}
|
||||
|
||||
maxrows = 0;
|
||||
for (n = 0; n < editwinrows && foo; n++) {
|
||||
maxrows ++;
|
||||
n += strlenpt(foo->data) / COLS;
|
||||
foo = foo->next;
|
||||
}
|
||||
|
||||
if (n < editwinrows)
|
||||
maxrows += editwinrows - n;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "compute_maxrows(): maxrows = %ld\n", maxrows);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Scroll the edit window in the given direction and the given number
|
||||
* of lines, and draw new lines on the blank lines left after the
|
||||
* scrolling. direction is the direction to scroll, either UP_DIR or
|
||||
@@ -2950,24 +2989,24 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
fprintf(stderr, "Softwrap: Entering check for extracuzsoft\n");
|
||||
#endif
|
||||
for (i = editwinrows, foo = openfile->edittop; foo && i > 0; i--, foo = foo->next) {
|
||||
ssize_t len = strlenpt(foo->data) / (COLS - 1);
|
||||
ssize_t len = strlenpt(foo->data) / COLS;
|
||||
if (len > 0)
|
||||
do_redraw = TRUE;
|
||||
i -= len;
|
||||
}
|
||||
if (foo) {
|
||||
extracuzsoft += strlenpt(foo->data) / (COLS - 1);
|
||||
extracuzsoft += strlenpt(foo->data) / COLS;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Setting extracuzsoft to %zd due to strlen %zd of line %zd\n", extracuzsoft,
|
||||
strlenpt(foo->data), foo->lineno);
|
||||
fprintf(stderr, "Setting extracuzsoft to %lu due to strlen %lu of line %lu\n", (unsigned long) extracuzsoft,
|
||||
(unsigned long) strlenpt(foo->data), (unsigned long) foo->lineno);
|
||||
#endif
|
||||
|
||||
|
||||
/* Now account for whether the edittop line itself is >COLS, if scrolling down */
|
||||
for (foo = openfile->edittop; foo && extracuzsoft > 0; nlines++) {
|
||||
extracuzsoft -= strlenpt(foo->data) / (COLS - 1) + 1;
|
||||
extracuzsoft -= 1 + strlenpt(foo->data) / COLS;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Edittop adjustment, setting nlines to %zd\n", nlines);
|
||||
fprintf(stderr, "Edittop adjustment, setting nlines to %lu\n", (unsigned long) nlines);
|
||||
#endif
|
||||
if (foo == openfile->filebot)
|
||||
break;
|
||||
@@ -2976,7 +3015,7 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
}
|
||||
} else if (ISSET(SOFTWRAP) && direction == UP_DIR) {
|
||||
for (foo = openfile->edittop, i = editwinrows; foo && i > 0; i--, foo = foo->prev) {
|
||||
if (strlenpt(foo->data) / (COLS - 1) > 0) {
|
||||
if (strlenpt(foo->data) / COLS > 0) {
|
||||
do_redraw = TRUE;
|
||||
break;
|
||||
}
|
||||
@@ -2999,8 +3038,12 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
break;
|
||||
openfile->edittop = openfile->edittop->next;
|
||||
}
|
||||
/* Don't over-scroll on long lines */
|
||||
if (ISSET(SOFTWRAP))
|
||||
i -= strlenpt(openfile->edittop->data) / COLS;
|
||||
}
|
||||
|
||||
compute_maxrows();
|
||||
/* Limit nlines to the number of lines we could scroll. */
|
||||
nlines -= i;
|
||||
|
||||
@@ -3076,15 +3119,14 @@ void edit_redraw(filestruct *old_current, size_t pww_save)
|
||||
bool do_redraw = need_vertical_update(0) ||
|
||||
need_vertical_update(pww_save);
|
||||
filestruct *foo = NULL;
|
||||
ssize_t i = 0, extracuzsoft = 0;
|
||||
|
||||
/* If either old_current or current is offscreen, scroll the edit
|
||||
* window until it's onscreen and get out. */
|
||||
if (old_current->lineno < openfile->edittop->lineno ||
|
||||
old_current->lineno >= openfile->edittop->lineno +
|
||||
editwinrows || openfile->current->lineno <
|
||||
maxrows || openfile->current->lineno <
|
||||
openfile->edittop->lineno || openfile->current->lineno >=
|
||||
openfile->edittop->lineno + editwinrows) {
|
||||
openfile->edittop->lineno + maxrows) {
|
||||
|
||||
filestruct *old_edittop = openfile->edittop;
|
||||
ssize_t nlines;
|
||||
@@ -3099,7 +3141,7 @@ void edit_redraw(filestruct *old_current, size_t pww_save)
|
||||
if (old_edittop->lineno < openfile->edittop->lineno)
|
||||
old_lineno = old_edittop->lineno;
|
||||
else
|
||||
old_lineno = (old_edittop->lineno + editwinrows <=
|
||||
old_lineno = (old_edittop->lineno + maxrows <=
|
||||
openfile->filebot->lineno) ?
|
||||
old_edittop->lineno + editwinrows :
|
||||
openfile->filebot->lineno;
|
||||
@@ -3118,11 +3160,7 @@ void edit_redraw(filestruct *old_current, size_t pww_save)
|
||||
/* Put edittop in range of current, get the difference in lines
|
||||
* between the original edittop and the current edittop, and
|
||||
* then restore the original edittop. */
|
||||
edit_update(
|
||||
#ifndef NANO_TINY
|
||||
ISSET(SMOOTH_SCROLL) ? NONE :
|
||||
#endif
|
||||
CENTER);
|
||||
edit_update(NONE);
|
||||
|
||||
nlines = openfile->edittop->lineno - old_edittop->lineno;
|
||||
|
||||
@@ -3188,16 +3226,21 @@ void edit_refresh(void)
|
||||
filestruct *foo;
|
||||
int nlines;
|
||||
|
||||
/* Figure out what maxrows should really be */
|
||||
compute_maxrows();
|
||||
|
||||
if (openfile->current->lineno < openfile->edittop->lineno ||
|
||||
openfile->current->lineno >= openfile->edittop->lineno +
|
||||
editwinrows)
|
||||
maxrows) {
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "edit_refresh(): line = %d, edittop %d + maxrows %d\n", openfile->current->lineno, openfile->edittop->lineno, maxrows);
|
||||
#endif
|
||||
|
||||
/* Put the top line of the edit window in range of the current
|
||||
* line. */
|
||||
edit_update(
|
||||
#ifndef NANO_TINY
|
||||
ISSET(SMOOTH_SCROLL) ? NONE :
|
||||
#endif
|
||||
CENTER);
|
||||
edit_update(NONE);
|
||||
}
|
||||
|
||||
foo = openfile->edittop;
|
||||
|
||||
@@ -3236,21 +3279,22 @@ void edit_update(update_type location)
|
||||
* screen as before, or at the top or bottom of the screen if
|
||||
* edittop is beyond either. */
|
||||
if (location == CENTER)
|
||||
goal = editwinrows / 2;
|
||||
goal = maxrows / 2;
|
||||
else {
|
||||
goal = openfile->current_y;
|
||||
|
||||
/* Limit goal to (editwinrows - 1) lines maximum. */
|
||||
if (goal > editwinrows - 1)
|
||||
goal = editwinrows - 1;
|
||||
if (goal > maxrows - 1)
|
||||
goal = maxrows - 1;
|
||||
}
|
||||
|
||||
for (; goal > 0 && foo->prev != NULL; goal--) {
|
||||
if (ISSET(SOFTWRAP))
|
||||
goal -= strlenpt(foo->data) / (COLS - 1);
|
||||
goal -= 1 + strlenpt(foo->data) / COLS;
|
||||
foo = foo->prev;
|
||||
}
|
||||
openfile->edittop = foo;
|
||||
compute_maxrows();
|
||||
}
|
||||
|
||||
/* Unconditionally redraw the entire screen. */
|
||||
|
||||
Reference in New Issue
Block a user